From 261706383554cfd54131300e1c9ce94b0e972e29 Mon Sep 17 00:00:00 2001 From: Ricki Hirner Date: Mon, 1 Aug 2016 21:15:55 +0200 Subject: [PATCH] Clean up launcher icon * clean up launcher icon * update dependencies --- app/build.gradle | 16 +++++++-------- .../at/bitfire/davdroid/AccountSettings.java | 2 +- .../main/java/at/bitfire/davdroid/App.java | 20 ++++++++++++++++++- .../java/at/bitfire/davdroid/DavService.java | 2 +- .../syncadapter/SyncAdapterService.java | 2 +- .../davdroid/syncadapter/SyncManager.java | 2 +- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8bee7e8a..d105609a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,13 +9,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 23 - buildToolsVersion "23.0.3" + compileSdkVersion 24 + buildToolsVersion "24.0.1" defaultConfig { applicationId "at.bitfire.davdroid" minSdkVersion 14 - targetSdkVersion 23 + targetSdkVersion 24 versionCode 110 @@ -65,10 +65,10 @@ dependencies { compile project(':ical4android') compile project(':vcard4android') - compile 'com.android.support:appcompat-v7:23.+' - compile 'com.android.support:cardview-v7:23.+' - compile 'com.android.support:design:23.+' - compile 'com.android.support:preference-v14:23.+' + compile 'com.android.support:appcompat-v7:24.+' + compile 'com.android.support:cardview-v7:24.+' + compile 'com.android.support:design:24.+' + compile 'com.android.support:preference-v14:24.+' compile 'com.github.yukuku:ambilwarna:2.0.1' compile project(':MemorizingTrustManager') @@ -76,7 +76,7 @@ dependencies { compile 'dnsjava:dnsjava:2.1.7' compile 'org.apache.commons:commons-lang3:3.4' compile 'org.apache.commons:commons-collections4:4.1' - provided 'org.projectlombok:lombok:1.16.8' + provided 'org.projectlombok:lombok:1.16.10' // for tests testCompile 'junit:junit:4.12' diff --git a/app/src/main/java/at/bitfire/davdroid/AccountSettings.java b/app/src/main/java/at/bitfire/davdroid/AccountSettings.java index e415f999..6cd99e59 100644 --- a/app/src/main/java/at/bitfire/davdroid/AccountSettings.java +++ b/app/src/main/java/at/bitfire/davdroid/AccountSettings.java @@ -126,7 +126,7 @@ public class AccountSettings { Notification notify = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_new_releases_light) - .setLargeIcon(bitmapLogo) + .setLargeIcon(App.getLauncherBitmap(context)) .setContentTitle(context.getString(R.string.settings_version_update)) .setContentText(context.getString(R.string.settings_version_update_settings_updated)) .setSubText(context.getString(R.string.settings_version_update_install_hint)) diff --git a/app/src/main/java/at/bitfire/davdroid/App.java b/app/src/main/java/at/bitfire/davdroid/App.java index 363b96e5..0b6b8155 100644 --- a/app/src/main/java/at/bitfire/davdroid/App.java +++ b/app/src/main/java/at/bitfire/davdroid/App.java @@ -8,12 +8,18 @@ package at.bitfire.davdroid; +import android.annotation.TargetApi; import android.app.Application; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.os.Build; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v7.app.NotificationCompat; import android.util.Log; @@ -94,7 +100,7 @@ public class App extends Application { if (logToFile) { NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder .setSmallIcon(R.drawable.ic_sd_storage_light) - .setLargeIcon(((BitmapDrawable)getResources().getDrawable(R.drawable.ic_launcher)).getBitmap()) + .setLargeIcon(getLauncherBitmap(this)) .setContentTitle(getString(R.string.logging_davdroid_file_logging)) .setLocalOnly(true); @@ -130,6 +136,18 @@ public class App extends Application { nm.cancel(Constants.NOTIFICATION_EXTERNAL_FILE_LOGGING); } + @Nullable + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + public static Bitmap getLauncherBitmap(@NonNull Context context) { + Bitmap bitmapLogo = null; + Drawable drawableLogo = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP ? + context.getDrawable(R.drawable.ic_launcher) : + context.getResources().getDrawable(R.drawable.ic_launcher); + if (drawableLogo instanceof BitmapDrawable) + bitmapLogo = ((BitmapDrawable)drawableLogo).getBitmap(); + return bitmapLogo; + } + public static class ReinitLoggingReceiver extends BroadcastReceiver { diff --git a/app/src/main/java/at/bitfire/davdroid/DavService.java b/app/src/main/java/at/bitfire/davdroid/DavService.java index ff4ea019..9d684bff 100644 --- a/app/src/main/java/at/bitfire/davdroid/DavService.java +++ b/app/src/main/java/at/bitfire/davdroid/DavService.java @@ -312,7 +312,7 @@ public class DavService extends Service { NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); Notification notify = new NotificationCompat.Builder(DavService.this) .setSmallIcon(R.drawable.ic_error_light) - .setLargeIcon(((BitmapDrawable)getResources().getDrawable(R.drawable.ic_launcher)).getBitmap()) + .setLargeIcon(App.getLauncherBitmap(DavService.this)) .setContentTitle(getString(R.string.dav_service_refresh_failed)) .setContentText(getString(R.string.dav_service_refresh_couldnt_refresh)) .setContentIntent(PendingIntent.getActivity(DavService.this, 0, debugIntent, PendingIntent.FLAG_UPDATE_CURRENT)) diff --git a/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncAdapterService.java b/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncAdapterService.java index f56109df..6cb417af 100644 --- a/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncAdapterService.java +++ b/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncAdapterService.java @@ -72,7 +72,7 @@ public abstract class SyncAdapterService extends Service { Notification notify = new NotificationCompat.Builder(getContext()) .setSmallIcon(R.drawable.ic_error_light) - .setLargeIcon(((BitmapDrawable)getContext().getResources().getDrawable(R.drawable.ic_launcher)).getBitmap()) + .setLargeIcon(App.getLauncherBitmap(getContext())) .setContentTitle(getContext().getString(R.string.sync_error_permissions)) .setContentText(getContext().getString(R.string.sync_error_permissions_text)) .setContentIntent(PendingIntent.getActivity(getContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT)) diff --git a/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncManager.java b/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncManager.java index cecf066a..23f14ec8 100644 --- a/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncManager.java +++ b/app/src/main/java/at/bitfire/davdroid/syncadapter/SyncManager.java @@ -230,7 +230,7 @@ abstract public class SyncManager { NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder .setSmallIcon(R.drawable.ic_error_light) - .setLargeIcon(((BitmapDrawable)context.getResources().getDrawable(R.drawable.ic_launcher)).getBitmap()) + .setLargeIcon(App.getLauncherBitmap(context)) .setContentTitle(getSyncErrorTitle()) .setContentIntent(PendingIntent.getActivity(context, 0, detailsIntent, PendingIntent.FLAG_CANCEL_CURRENT)) .setCategory(NotificationCompat.CATEGORY_ERROR)