Added Purging for Android < 4.1

This commit is contained in:
Daniel Albert 2014-07-12 12:42:48 +02:00
parent cf40517eac
commit 2568ea4b2e

View File

@ -26,6 +26,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
@ -353,6 +354,7 @@ public class PassphraseCacheService extends Service {
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if(mPassphraseCache.size() > 0) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setSmallIcon(R.drawable.ic_launcher)
@ -386,6 +388,27 @@ public class PassphraseCacheService extends Service {
);
notificationManager.notify(NOTIFICATION_ID, builder.build());
} else { // Fallback, since expandable notifications weren't available back then
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Open Keychain has cached " + mPassphraseCache.size() + " keys.")
.setContentText("Click to purge the cache");
Intent intent = new Intent(getApplicationContext(), PassphraseCacheService.class);
intent.setAction(ACTION_PASSPHRASE_CACHE_PURGE);
builder.setContentIntent(
PendingIntent.getService(
getApplicationContext(),
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
)
);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}
} else {
notificationManager.cancel(NOTIFICATION_ID);