Skip to content

Commit 2e18895

Browse files
committed
Merge branch 'release/1.6.8'
2 parents 9b75afd + 6e8a046 commit 2e18895

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

tubeLoadNative/tubeLoadNative.Droid/Activities/SplashScreen.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected override void OnCreate(Bundle savedInstanceState)
5454
protected override void OnResume()
5555
{
5656
base.OnResume();
57-
57+
5858
Task.Run(async () =>
5959
{
6060
try
@@ -68,6 +68,12 @@ protected override void OnResume()
6868
() => Toast.MakeText(Application.Context, "Could not connect, please check your internet connection", ToastLength.Long).Show()));
6969
};
7070
});
71+
72+
if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) == Permission.Granted &&
73+
ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadExternalStorage) == Permission.Granted)
74+
{
75+
StartActivity(new Intent(Application.Context, typeof(SongsPlayer)));
76+
}
7177
}
7278

7379
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
@@ -96,17 +102,19 @@ private async void checkForUpdateVersionAsync()
96102
private void checkReadWriteToStorage()
97103
{
98104
if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) != Permission.Granted &&
99-
ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadExternalStorage) != Permission.Granted)
105+
ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadExternalStorage) != Permission.Granted &&
106+
ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadPhoneState) != Permission.Granted)
100107
{
101108
if (ActivityCompat.ShouldShowRequestPermissionRationale(this, Manifest.Permission.WriteExternalStorage) &&
102-
ActivityCompat.ShouldShowRequestPermissionRationale(this, Manifest.Permission.ReadExternalStorage))
109+
ActivityCompat.ShouldShowRequestPermissionRationale(this, Manifest.Permission.ReadExternalStorage) &&
110+
ActivityCompat.ShouldShowRequestPermissionRationale(this, Manifest.Permission.ReadPhoneState))
103111
{
104112
Toast.MakeText(Application.Context, "Permission to storage has been denied", ToastLength.Long).Show();
105113
}
106114
else
107115
{
108116
ActivityCompat.RequestPermissions(this,
109-
new string[] { Manifest.Permission.WriteExternalStorage, Manifest.Permission.ReadExternalStorage },
117+
new string[] { Manifest.Permission.WriteExternalStorage, Manifest.Permission.ReadExternalStorage, Manifest.Permission.ReadPhoneState},
110118
0);
111119
}
112120
}

tubeLoadNative/tubeLoadNative.Droid/Properties/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.okey.tubeload" android:versionName="1.6.6" android:versionCode="7">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.okey.tubeload" android:versionName="1.6.8" android:versionCode="10">
33
<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="26" />
44
<uses-permission android:name="android.permission.INTERNET" />
55
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

tubeLoadNative/tubeLoadNative.Droid/Resources/layout/view_notification_actions.axml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
android:textAppearance="?android:attr/textAppearanceSmall"
3636
android:layout_width="wrap_content"
3737
android:layout_height="match_parent"
38+
android:textColor="@android:color/white"
3839
android:id="@+id/notificationTitle"
3940
android:layout_margin="5dp" />
4041
<TextView
4142
android:text="Medium Text"
4243
android:textAppearance="?android:attr/textAppearanceMedium"
4344
android:layout_width="match_parent"
4445
android:layout_height="wrap_content"
46+
android:textColor="@android:color/white"
4547
android:id="@+id/notificationContent" />
4648
</LinearLayout>
4749
<ImageButton

tubeLoadNative/tubeLoadNative.Droid/Utils/NotificationHandler.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Android.Graphics;
99
using Android.Graphics.Drawables;
1010
using Android.Widget;
11+
using tubeLoadNative.Droid.BroadcastReceivers;
1112

1213
namespace tubeLoadNative.Droid.Utils
1314
{
@@ -17,14 +18,15 @@ public class NotificationHandler
1718
static Notification.Builder builder;
1819
static NotificationManager notificationManager;
1920
const int SONG_NOTIFICATION_ID = 0;
21+
const string CHANNEL_ID = "tubeload_song_notification";
2022

2123
static NotificationHandler()
2224
{
2325
Intent intent = new Intent(Application.Context, typeof(CurrentSong));
2426
intent.AddFlags(ActivityFlags.SingleTop);
2527
PendingIntent pendingIntent = PendingIntent.GetActivity(Application.Context, 0, intent, PendingIntentFlags.UpdateCurrent);
2628

27-
builder = new Notification.Builder(Application.Context);
29+
builder = new Notification.Builder(Application.Context, CHANNEL_ID);
2830
builder.SetContentIntent(pendingIntent);
2931

3032
builder.SetOngoing(true);
@@ -35,6 +37,15 @@ static NotificationHandler()
3537
}
3638

3739
notificationManager = Application.Context.GetSystemService(Context.NotificationService) as NotificationManager;
40+
41+
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
42+
{
43+
/* Create or update. */
44+
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
45+
"tubeload song notification",
46+
NotificationImportance.Min);
47+
notificationManager.CreateNotificationChannel(channel);
48+
}
3849
}
3950

4051
public static void BuildNotification(String songId)
@@ -70,6 +81,7 @@ public static void BuildNotification(String songId)
7081
notificationLayoutExpanded.SetImageViewBitmap(Resource.Id.songImg, bitmap);
7182
CreateNotificationMediaActions(notificationLayoutExpanded);
7283
builder.SetCustomBigContentView(notificationLayoutExpanded);
84+
builder.SetContentTitle(title);
7385
}
7486
else
7587
{
@@ -91,21 +103,25 @@ public static void DeleteNotification()
91103
private static void CreateNotificationMediaActions(RemoteViews notificationLayoutExpanded)
92104
{
93105
Intent prevIntent = new Intent("ACTION_MEDIA_BUTTON");
106+
prevIntent.SetClass(Application.Context, typeof(BluetoothRemoteControlReciever));
94107
prevIntent.PutExtra(Intent.ExtraKeyEvent, new KeyEvent(KeyEventActions.Down, Keycode.MediaPrevious));
95108
PendingIntent prevPendingIntent = PendingIntent.GetBroadcast(Application.Context, 0, prevIntent, PendingIntentFlags.UpdateCurrent);
96109
notificationLayoutExpanded.SetOnClickPendingIntent(Resource.Id.prevBtn, prevPendingIntent);
97110

98111
Intent playPauseIntent = new Intent("ACTION_MEDIA_BUTTON");
112+
playPauseIntent.SetClass(Application.Context, typeof(BluetoothRemoteControlReciever));
99113
playPauseIntent.PutExtra(Intent.ExtraKeyEvent, new KeyEvent(KeyEventActions.Down, Keycode.MediaPlayPause));
100114
PendingIntent playPausePendingIntent = PendingIntent.GetBroadcast(Application.Context, 1, playPauseIntent, PendingIntentFlags.UpdateCurrent);
101115
notificationLayoutExpanded.SetOnClickPendingIntent(Resource.Id.playBtn, playPausePendingIntent);
102116

103117
Intent nextIntent = new Intent("ACTION_MEDIA_BUTTON");
118+
nextIntent.SetClass(Application.Context, typeof(BluetoothRemoteControlReciever));
104119
nextIntent.PutExtra(Intent.ExtraKeyEvent, new KeyEvent(KeyEventActions.Down, Keycode.MediaNext));
105120
PendingIntent nextPendingIntent = PendingIntent.GetBroadcast(Application.Context, 2, nextIntent, PendingIntentFlags.UpdateCurrent);
106121
notificationLayoutExpanded.SetOnClickPendingIntent(Resource.Id.nextBtn, nextPendingIntent);
107122

108123
Intent stopIntent = new Intent("ACTION_MEDIA_BUTTON");
124+
stopIntent.SetClass(Application.Context, typeof(BluetoothRemoteControlReciever));
109125
stopIntent.PutExtra(Intent.ExtraKeyEvent, new KeyEvent(KeyEventActions.Down, Keycode.MediaStop));
110126
PendingIntent stopPendingIntent = PendingIntent.GetBroadcast(Application.Context, 3, stopIntent, PendingIntentFlags.UpdateCurrent);
111127
notificationLayoutExpanded.SetOnClickPendingIntent(Resource.Id.closeBtn, stopPendingIntent);
@@ -114,6 +130,7 @@ private static void CreateNotificationMediaActions(RemoteViews notificationLayou
114130
private static void CreateNotificationMediaActions()
115131
{
116132
Intent stopIntent = new Intent("ACTION_MEDIA_BUTTON");
133+
stopIntent.SetClass(Application.Context, typeof(BluetoothRemoteControlReciever));
117134
stopIntent.PutExtra(Intent.ExtraKeyEvent, new KeyEvent(KeyEventActions.Down, Keycode.MediaStop));
118135
PendingIntent stopPendingIntent = PendingIntent.GetBroadcast(Application.Context, 3, stopIntent, PendingIntentFlags.UpdateCurrent);
119136
Notification.Action stopAction = new Notification.Action(Resource.Drawable.ic_cancel_blue, string.Empty, stopPendingIntent);

0 commit comments

Comments
 (0)