diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-06-24 13:08:37 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-06-24 13:08:37 +0200 |
commit | 74cef32d258fc362559b13eb450581fe37496acb (patch) | |
tree | 04ea0a0edaacffc0af97c8971ad2dc5b849e8828 /OpenKeychain/src/main/java/org/sufficientlysecure | |
parent | 8cd7e295404fdfad5167b96fdf3a5cbeca8e4cd1 (diff) | |
download | open-keychain-74cef32d258fc362559b13eb450581fe37496acb.tar.gz open-keychain-74cef32d258fc362559b13eb450581fe37496acb.tar.bz2 open-keychain-74cef32d258fc362559b13eb450581fe37496acb.zip |
Notification: follow design guidelines, fix #1313
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java | 79 |
1 files changed, 31 insertions, 48 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java index 8edd657b5..c1aa1bb3b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java @@ -493,59 +493,42 @@ public class PassphraseCacheService extends Service { private Notification getNotification() { NotificationCompat.Builder builder = new NotificationCompat.Builder(this); + builder.setSmallIcon(R.drawable.ic_stat_notify_24dp) + .setLargeIcon(getBitmap(R.drawable.ic_launcher, getBaseContext())) + .setContentTitle(getResources().getQuantityString(R.plurals.passp_cache_notif_n_keys, + mPassphraseCache.size(), mPassphraseCache.size())) + .setContentText(getString(R.string.passp_cache_notif_click_to_clear)); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - builder.setSmallIcon(R.drawable.ic_stat_notify_24dp) - .setLargeIcon(getBitmap(R.drawable.ic_launcher, getBaseContext())) - .setContentTitle(getString(R.string.app_name)) - .setContentText(String.format(getString(R.string.passp_cache_notif_n_keys), - mPassphraseCache.size())); + NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); - NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); + inboxStyle.setBigContentTitle(getString(R.string.passp_cache_notif_keys)); - inboxStyle.setBigContentTitle(getString(R.string.passp_cache_notif_keys)); + // Moves events into the big view + for (int i = 0; i < mPassphraseCache.size(); i++) { + inboxStyle.addLine(mPassphraseCache.valueAt(i).getPrimaryUserID()); + } - // Moves events into the big view - for (int i = 0; i < mPassphraseCache.size(); i++) { - inboxStyle.addLine(mPassphraseCache.valueAt(i).getPrimaryUserID()); - } + // Moves the big view style object into the notification object. + builder.setStyle(inboxStyle); - // Moves the big view style object into the notification object. - builder.setStyle(inboxStyle); - - // Add purging action - Intent intent = new Intent(getApplicationContext(), PassphraseCacheService.class); - intent.setAction(ACTION_PASSPHRASE_CACHE_CLEAR); - builder.addAction( - R.drawable.abc_ic_clear_mtrl_alpha, - getString(R.string.passp_cache_notif_clear), - PendingIntent.getService( - getApplicationContext(), - 0, - intent, - PendingIntent.FLAG_UPDATE_CURRENT - ) - ); - } else { - // Fallback, since expandable notifications weren't available back then - builder.setSmallIcon(R.drawable.ic_stat_notify) - .setLargeIcon(getBitmap(R.drawable.ic_launcher, getBaseContext())) - .setContentTitle(String.format(getString(R.string.passp_cache_notif_n_keys), - mPassphraseCache.size())) - .setContentText(getString(R.string.passp_cache_notif_click_to_clear)); - - Intent intent = new Intent(getApplicationContext(), PassphraseCacheService.class); - intent.setAction(ACTION_PASSPHRASE_CACHE_CLEAR); - - builder.setContentIntent( - PendingIntent.getService( - getApplicationContext(), - 0, - intent, - PendingIntent.FLAG_UPDATE_CURRENT - ) - ); - } + Intent intent = new Intent(getApplicationContext(), PassphraseCacheService.class); + intent.setAction(ACTION_PASSPHRASE_CACHE_CLEAR); + PendingIntent clearCachePi = PendingIntent.getService( + getApplicationContext(), + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT + ); + + // Add cache clear PI to normal touch + builder.setContentIntent(clearCachePi); + + // Add clear PI action below text + builder.addAction( + R.drawable.abc_ic_clear_mtrl_alpha, + getString(R.string.passp_cache_notif_clear), + clearCachePi + ); return builder.build(); } |