From 96ee07225393e5ba44a1b3ac15674882e3fa204e Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Wed, 9 Sep 2020 17:16:29 +0900 Subject: [PATCH] shortcuts: improved icons --- android/app/build.gradle | 1 + .../deckers/thibault/aves/MainActivity.java | 19 +++++++++---------- .../main/res/drawable/ic_outline_movie.xml | 5 ----- .../main/res/drawable/ic_outline_search.xml | 5 ----- .../drawable/ic_shortcut_movie_foreground.xml | 15 +++++++++++++++ .../ic_shortcut_search_foreground.xml | 15 +++++++++++++++ .../mipmap-anydpi-v26/ic_shortcut_movie.xml | 5 +++++ .../mipmap-anydpi-v26/ic_shortcut_search.xml | 5 +++++ ...{ic_launcher_background.xml => colors.xml} | 1 + 9 files changed, 51 insertions(+), 20 deletions(-) delete mode 100644 android/app/src/main/res/drawable/ic_outline_movie.xml delete mode 100644 android/app/src/main/res/drawable/ic_outline_search.xml create mode 100644 android/app/src/main/res/drawable/ic_shortcut_movie_foreground.xml create mode 100644 android/app/src/main/res/drawable/ic_shortcut_search_foreground.xml create mode 100644 android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut_movie.xml create mode 100644 android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut_search.xml rename android/app/src/main/res/values/{ic_launcher_background.xml => colors.xml} (67%) diff --git a/android/app/build.gradle b/android/app/build.gradle index 4b05d4c59..4ddc01781 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -103,6 +103,7 @@ dependencies { // enable support for Java 8 language APIs (stream, optional, etc.) // coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9' + implementation 'androidx.core:core:1.5.0-alpha02' // v1.5.0-alpha02 for ShortcutManagerCompat.setDynamicShortcuts implementation "androidx.exifinterface:exifinterface:1.2.0" implementation 'com.commonsware.cwac:document:0.4.1' implementation 'com.drewnoakes:metadata-extractor:2.14.0' diff --git a/android/app/src/main/java/deckers/thibault/aves/MainActivity.java b/android/app/src/main/java/deckers/thibault/aves/MainActivity.java index e4161da04..4b30fce3a 100644 --- a/android/app/src/main/java/deckers/thibault/aves/MainActivity.java +++ b/android/app/src/main/java/deckers/thibault/aves/MainActivity.java @@ -1,15 +1,15 @@ package deckers.thibault.aves; import android.content.Intent; -import android.content.pm.ShortcutInfo; -import android.content.pm.ShortcutManager; -import android.graphics.drawable.Icon; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.util.Log; import androidx.annotation.RequiresApi; +import androidx.core.content.pm.ShortcutInfoCompat; +import androidx.core.content.pm.ShortcutManagerCompat; +import androidx.core.graphics.drawable.IconCompat; import java.util.ArrayList; import java.util.Arrays; @@ -85,25 +85,24 @@ public class MainActivity extends FlutterActivity { @RequiresApi(Build.VERSION_CODES.N_MR1) private void setupShortcuts() { - ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); - // do not use 'route' as extra key, as the Flutter framework acts on it - ShortcutInfo search = new ShortcutInfo.Builder(this, "search") + ShortcutInfoCompat search = new ShortcutInfoCompat.Builder(this, "search") .setShortLabel(getString(R.string.search_shortcut_short_label)) - .setIcon(Icon.createWithResource(this, R.drawable.ic_outline_search)) + .setIcon(IconCompat.createWithResource(this, R.mipmap.ic_shortcut_search)) .setIntent(new Intent(Intent.ACTION_MAIN, null, this, MainActivity.class) .putExtra("page", "/search")) .build(); - ShortcutInfo videos = new ShortcutInfo.Builder(this, "videos") + ShortcutInfoCompat videos = new ShortcutInfoCompat.Builder(this, "videos") .setShortLabel(getString(R.string.videos_shortcut_short_label)) - .setIcon(Icon.createWithResource(this, R.drawable.ic_outline_movie)) + .setIcon(IconCompat.createWithResource(this, R.mipmap.ic_shortcut_movie)) .setIntent(new Intent(Intent.ACTION_MAIN, null, this, MainActivity.class) .putExtra("page", "/collection") .putExtra("filters", new String[]{"{\"type\":\"mime\",\"mime\":\"video/*\"}"})) .build(); - shortcutManager.setDynamicShortcuts(Arrays.asList(videos, search)); + + ShortcutManagerCompat.setDynamicShortcuts(this, Arrays.asList(videos, search)); } private void handleIntent(Intent intent) { diff --git a/android/app/src/main/res/drawable/ic_outline_movie.xml b/android/app/src/main/res/drawable/ic_outline_movie.xml deleted file mode 100644 index ca2e076e1..000000000 --- a/android/app/src/main/res/drawable/ic_outline_movie.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/android/app/src/main/res/drawable/ic_outline_search.xml b/android/app/src/main/res/drawable/ic_outline_search.xml deleted file mode 100644 index 029cb754c..000000000 --- a/android/app/src/main/res/drawable/ic_outline_search.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/android/app/src/main/res/drawable/ic_shortcut_movie_foreground.xml b/android/app/src/main/res/drawable/ic_shortcut_movie_foreground.xml new file mode 100644 index 000000000..0955cd1d5 --- /dev/null +++ b/android/app/src/main/res/drawable/ic_shortcut_movie_foreground.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/android/app/src/main/res/drawable/ic_shortcut_search_foreground.xml b/android/app/src/main/res/drawable/ic_shortcut_search_foreground.xml new file mode 100644 index 000000000..fb2972b41 --- /dev/null +++ b/android/app/src/main/res/drawable/ic_shortcut_search_foreground.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut_movie.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut_movie.xml new file mode 100644 index 000000000..a31978c2d --- /dev/null +++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut_movie.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut_search.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut_search.xml new file mode 100644 index 000000000..1ab11ea64 --- /dev/null +++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut_search.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/values/ic_launcher_background.xml b/android/app/src/main/res/values/colors.xml similarity index 67% rename from android/app/src/main/res/values/ic_launcher_background.xml rename to android/app/src/main/res/values/colors.xml index c5d5899fd..45ea13c03 100644 --- a/android/app/src/main/res/values/ic_launcher_background.xml +++ b/android/app/src/main/res/values/colors.xml @@ -1,4 +1,5 @@ #FFFFFF + #FFFFFF \ No newline at end of file