Some improvements

This commit is contained in:
tom79 2019-10-13 18:57:45 +02:00
parent 93247ebfb0
commit 1ee84799f5
4 changed files with 34 additions and 8 deletions

View File

@ -90,7 +90,6 @@ public class AccountLiveAdapter extends RecyclerView.Adapter {
case Helper.NOTIF_DELAYED:
streamingIntent = new Intent(context, LiveNotificationDelayedService.class);
context.startService(streamingIntent);
editor.apply();
break;
case Helper.NOTIF_NONE:
if (Build.VERSION.SDK_INT >= 26) {

View File

@ -1715,14 +1715,25 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
} else {
LiveNotificationDelayedService.totalAccount--;
}
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
if (liveNotifications) {
Intent streamingServiceIntent = new Intent(context.getApplicationContext(), LiveNotificationDelayedService.class);
try {
context.startService(streamingServiceIntent);
} catch (Exception ignored) {
}
if (set_allow_live_notifications.isChecked()) {
LiveNotificationDelayedService.totalAccount++;
} else {
LiveNotificationDelayedService.totalAccount--;
}
context.sendBroadcast(new Intent(context, StopLiveNotificationReceiver.class));
try {
switch (Helper.liveNotifType(context)) {
case Helper.NOTIF_LIVE:
Intent streamingIntent = new Intent(context, LiveNotificationService.class);
context.startService(streamingIntent);
break;
case Helper.NOTIF_DELAYED:
streamingIntent = new Intent(context, LiveNotificationDelayedService.class);
context.startService(streamingIntent);
break;
}
} catch (Exception ignored) {}
}
});

View File

@ -147,8 +147,17 @@ public class LiveNotificationDelayedService extends Service {
}
}
if( totalAccount > 0) {
Intent myIntent = new Intent(getApplicationContext(), MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
getApplicationContext(),
0,
myIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setShowWhen(false)
.setContentIntent(pendingIntent)
.setContentTitle(getString(R.string.top_notification))
.setSmallIcon(R.drawable.fedilab_notification_icon)
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();

View File

@ -161,8 +161,15 @@ public class LiveNotificationService extends Service implements NetworkStateRece
}
}
if( totalAccount > 0) {
Intent myIntent = new Intent(getApplicationContext(), MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
getApplicationContext(),
0,
myIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle(getString(R.string.top_notification))
.setContentIntent(pendingIntent)
.setSmallIcon(getNotificationIcon(getApplicationContext()))
.setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build();