fixed compilation issue with deprecated setLatestEventInfo in EntryActivity by creating a new Notification instead

used support-v4 NotificationCompat builder for that, did have to upgrade minSdk from 3 to 4 because of that
This commit is contained in:
Hans Cappelle
2017-10-08 14:56:32 +02:00
parent 8e353b8172
commit 72542af042
3 changed files with 22 additions and 7 deletions

View File

@@ -6,7 +6,7 @@ android {
defaultConfig {
applicationId = "com.android.keepass"
minSdkVersion = 3
minSdkVersion 4
targetSdkVersion 23
versionCode = 154
versionName = "2.0.6.4"
@@ -54,4 +54,6 @@ dependencies {
compile 'com.madgag.spongycastle:core:1.54.0.0'
compile 'com.madgag.spongycastle:prov:1.54.0.0'
compile 'joda-time:joda-time:2.9.4'
compile 'com.android.support:support-v4:23.0.0'
}

View File

@@ -41,6 +41,7 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.method.PasswordTransformationMethod;
@@ -228,12 +229,16 @@ public class EntryActivity extends LockCloseHideActivity {
private Notification getNotification(String intentText, int descResId) {
String desc = getString(descResId);
Notification notify = new Notification(R.drawable.notify, desc, System.currentTimeMillis());
Intent intent = new Intent(intentText);
PendingIntent pending = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
notify.setLatestEventInfo(this, getString(R.string.app_name), desc, pending);
// no longer supported for api level >22
// notify.setLatestEventInfo(this, getString(R.string.app_name), desc, pending);
// so instead using compat builder and create new notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
Notification notify = builder.setContentIntent(pending).setContentText(desc).setContentTitle(getString(R.string.app_name))
.setSmallIcon(R.drawable.notify).setTicker(desc).setWhen(System.currentTimeMillis()).build();
return notify;
}

View File

@@ -2,6 +2,10 @@
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
@@ -11,5 +15,9 @@ buildscript {
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}