Backward compatibility

pull/207/head
M66B 3 years ago
parent 905e79fc8b
commit 5477c3c654

@ -90,7 +90,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
EntityLog.log(this, "Service send create"); EntityLog.log(this, "Service send create");
super.onCreate(); super.onCreate();
startForeground(NotificationHelper.NOTIFICATION_SEND, startForeground(NotificationHelper.NOTIFICATION_SEND,
getNotificationService().build()); getNotificationService(false).build());
owner = new TwoStateOwner(this, "send"); owner = new TwoStateOwner(this, "send");
@ -110,7 +110,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
NotificationManager nm = NotificationManager nm =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(NotificationHelper.NOTIFICATION_SEND, nm.notify(NotificationHelper.NOTIFICATION_SEND,
getNotificationService().build()); getNotificationService(false).build());
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);
} }
@ -205,7 +205,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId); super.onStartCommand(intent, flags, startId);
startForeground(NotificationHelper.NOTIFICATION_SEND, startForeground(NotificationHelper.NOTIFICATION_SEND,
getNotificationService().build()); getNotificationService(false).build());
Log.i("Send intent=" + intent); Log.i("Send intent=" + intent);
Log.logExtras(intent); Log.logExtras(intent);
@ -213,7 +213,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
return START_STICKY; return START_STICKY;
} }
NotificationCompat.Builder getNotificationService() { NotificationCompat.Builder getNotificationService(boolean alert) {
NotificationCompat.Builder builder = NotificationCompat.Builder builder =
new NotificationCompat.Builder(this, "send") new NotificationCompat.Builder(this, "send")
.setSmallIcon(R.drawable.baseline_send_white_24) .setSmallIcon(R.drawable.baseline_send_white_24)
@ -221,7 +221,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
.setContentIntent(getPendingIntent(this)) .setContentIntent(getPendingIntent(this))
.setAutoCancel(false) .setAutoCancel(false)
.setShowWhen(true) .setShowWhen(true)
.setOnlyAlertOnce(true) .setOnlyAlertOnce(!alert)
.setDefaults(0) // disable sound on pre Android 8 .setDefaults(0) // disable sound on pre Android 8
.setLocalOnly(true) .setLocalOnly(true)
.setPriority(NotificationCompat.PRIORITY_MIN) .setPriority(NotificationCompat.PRIORITY_MIN)
@ -334,7 +334,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
NotificationManager nm = NotificationManager nm =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(NotificationHelper.NOTIFICATION_SEND, nm.notify(NotificationHelper.NOTIFICATION_SEND,
getNotificationService().build()); getNotificationService(false).build());
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);
} }
@ -521,7 +521,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
NotificationManager nm = NotificationManager nm =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(NotificationHelper.NOTIFICATION_SEND, getNotificationService().build()); nm.notify(NotificationHelper.NOTIFICATION_SEND, getNotificationService(true).build());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean reply_move = prefs.getBoolean("reply_move", false); boolean reply_move = prefs.getBoolean("reply_move", false);
@ -735,7 +735,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
if (now > last + PROGRESS_UPDATE_INTERVAL) { if (now > last + PROGRESS_UPDATE_INTERVAL) {
last = now; last = now;
lastProgress = progress; lastProgress = progress;
nm.notify(NotificationHelper.NOTIFICATION_SEND, getNotificationService().build()); nm.notify(NotificationHelper.NOTIFICATION_SEND, getNotificationService(false).build());
} }
} }
} }
@ -776,7 +776,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
iservice.close(); iservice.close();
if (lastProgress >= 0) { if (lastProgress >= 0) {
lastProgress = -1; lastProgress = -1;
nm.notify(NotificationHelper.NOTIFICATION_SEND, getNotificationService().build()); nm.notify(NotificationHelper.NOTIFICATION_SEND, getNotificationService(false).build());
} }
db.identity().setIdentityState(ident.id, null); db.identity().setIdentityState(ident.id, null);
} }

Loading…
Cancel
Save