Update seen until on notification delete

pull/30/head
M66B 7 years ago
parent b0f20f79a0
commit d263720b56

@ -269,9 +269,9 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
intent.setAction(null); intent.setAction(null);
setIntent(intent); setIntent(intent);
if ("unseen".equals(action)) {
final long now = new Date().getTime(); final long now = new Date().getTime();
if ("unseen".equals(action))
executor.submit(new Runnable() { executor.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -284,6 +284,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
} }
}); });
} }
}
private void init() { private void init() {
invalidateOptionsMenu(); invalidateOptionsMenu();

@ -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;
} }

Loading…
Cancel
Save