Fix issue for stopping delayed/live notifications

This commit is contained in:
tom79 2019-12-07 16:01:01 +01:00
parent 59bc06c77c
commit c7a7b8cc82
6 changed files with 22 additions and 26 deletions

View File

@ -6,5 +6,7 @@ Added
Fixed
- Issue with polls not displayed
- Notifications not stopped
- Pleroma wysiwyg
- Login issue
- Some crashes

View File

@ -1408,43 +1408,34 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (liveNotificationCount > 0) {
SharedPreferences.Editor editor = sharedpreferences.edit();
context.sendBroadcast(new Intent(context, StopLiveNotificationReceiver.class));
context.sendBroadcast(new Intent(context, StopDelayedNotificationReceiver.class));
ApplicationJob.cancelAllJob(NotificationsSyncJob.NOTIFICATION_REFRESH);
switch (position) {
case Helper.NOTIF_LIVE:
editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, false);
live_notif_per_account.setVisibility(View.VISIBLE);
editor.apply();
context.sendBroadcast(new Intent(context, StopDelayedNotificationReceiver.class));
ApplicationJob.cancelAllJob(NotificationsSyncJob.NOTIFICATION_REFRESH);
editor.commit();
set_live_type_indication.setText(R.string.live_notif_indication);
Helper.startStreaming(context);
break;
case Helper.NOTIF_DELAYED:
editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false);
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, true);
live_notif_per_account.setVisibility(View.VISIBLE);
context.sendBroadcast(new Intent(context, StopLiveNotificationReceiver.class));
editor.apply();
ApplicationJob.cancelAllJob(NotificationsSyncJob.NOTIFICATION_REFRESH);
set_live_type_indication.setText(R.string.set_live_type_indication);
editor.commit();
Helper.startStreaming(context);
break;
case Helper.NOTIF_NONE:
editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false);
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, false);
live_notif_per_account.setVisibility(View.GONE);
context.sendBroadcast(new Intent(context, StopLiveNotificationReceiver.class));
context.sendBroadcast(new Intent(context, StopDelayedNotificationReceiver.class));
NotificationsSyncJob.schedule(false);
editor.apply();
break;
}
Helper.startStreaming(context);
switch (Helper.liveNotifType(context)) {
case Helper.NOTIF_LIVE:
set_live_type_indication.setText(R.string.live_notif_indication);
break;
case Helper.NOTIF_DELAYED:
set_live_type_indication.setText(R.string.set_live_type_indication);
break;
case Helper.NOTIF_NONE:
editor.commit();
set_live_type_indication.setText(R.string.no_live_indication);
live_notif_per_account.setVisibility(View.GONE);
NotificationsSyncJob.schedule(false);
break;
}
} else {

View File

@ -4696,9 +4696,7 @@ public class Helper {
} else {
context.startService(streamingIntent);
}
} catch (Exception ignored) {
ignored.printStackTrace();
}
} catch (Exception ignored) {}
}
}

View File

@ -150,6 +150,9 @@ public class LiveNotificationDelayedService extends Service {
assert notificationManager != null;
notificationManager.deleteNotificationChannel(CHANNEL_ID);
}
if (intent != null) {
intent.replaceExtras(new Bundle());
}
stopSelf();
}
if (totalAccount > 0) {

View File

@ -185,6 +185,9 @@ public class LiveNotificationService extends Service implements NetworkStateRece
assert notificationManager != null;
notificationManager.deleteNotificationChannel(CHANNEL_ID);
}
if (intent != null) {
intent.replaceExtras(new Bundle());
}
stopSelf();
}
if (totalAccount > 0) {

View File

@ -20,7 +20,6 @@ import android.content.Context;
import android.content.Intent;
/**
* Created by Thomas on 18/10/2019.
* BroadcastReceiver for restarting delayed notification service