|
|
@ -178,6 +178,21 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
Log.i(Helper.TAG, "Service start");
|
|
|
|
Log.i(Helper.TAG, "Service start");
|
|
|
|
super.onStartCommand(intent, flags, startId);
|
|
|
|
super.onStartCommand(intent, flags, startId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("unseen".equals(intent.getAction())) {
|
|
|
|
|
|
|
|
final long now = new Date().getTime();
|
|
|
|
|
|
|
|
executor.submit(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
DaoAccount dao = DB.getInstance(ServiceSynchronize.this).account();
|
|
|
|
|
|
|
|
for (EntityAccount account : dao.getAccounts(true)) {
|
|
|
|
|
|
|
|
account.seen_until = now;
|
|
|
|
|
|
|
|
dao.updateAccount(account);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Log.i(Helper.TAG, "Updated seen until");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return START_STICKY;
|
|
|
|
return START_STICKY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -217,6 +232,10 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
PendingIntent pi = PendingIntent.getActivity(
|
|
|
|
PendingIntent pi = PendingIntent.getActivity(
|
|
|
|
this, ActivityView.REQUEST_UNSEEN, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
this, ActivityView.REQUEST_UNSEEN, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Intent delete = new Intent(this, ServiceSynchronize.class);
|
|
|
|
|
|
|
|
delete.setAction("unseen");
|
|
|
|
|
|
|
|
PendingIntent pid = PendingIntent.getService(this, 1, delete, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
|
|
|
|
|
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
|
|
|
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
|
|
|
|
|
|
|
|
|
|
|
// Build notification
|
|
|
|
// Build notification
|
|
|
@ -231,11 +250,11 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
.setContentTitle(getString(R.string.title_notification_unseen, unseen))
|
|
|
|
.setContentTitle(getString(R.string.title_notification_unseen, unseen))
|
|
|
|
.setContentIntent(pi)
|
|
|
|
.setContentIntent(pi)
|
|
|
|
.setSound(uri)
|
|
|
|
.setSound(uri)
|
|
|
|
.setOngoing(true)
|
|
|
|
|
|
|
|
.setShowWhen(false)
|
|
|
|
.setShowWhen(false)
|
|
|
|
.setPriority(Notification.PRIORITY_DEFAULT)
|
|
|
|
.setPriority(Notification.PRIORITY_DEFAULT)
|
|
|
|
.setCategory(Notification.CATEGORY_STATUS)
|
|
|
|
.setCategory(Notification.CATEGORY_STATUS)
|
|
|
|
.setVisibility(Notification.VISIBILITY_PUBLIC);
|
|
|
|
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
|
|
|
|
|
|
|
.setDeleteIntent(pid);
|
|
|
|
|
|
|
|
|
|
|
|
return builder;
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|