summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey <joey@lineageos.org>2018-04-12 19:31:25 (GMT)
committerJoey <joey@lineageos.org>2018-05-21 12:42:22 (GMT)
commit57b4c04e745eb8ab0d8259ed5a24ea176976191f (patch)
tree991ad4997b97d4a30be16e30dfc56edf655e1ae1
parent8fc47fa6856ccd6ddbef8c096c5df8885baeca8b (diff)
downloadandroid_packages_apps_Trebuchet-57b4c04e745eb8ab0d8259ed5a24ea176976191f.zip
android_packages_apps_Trebuchet-57b4c04e745eb8ab0d8259ed5a24ea176976191f.tar.gz
android_packages_apps_Trebuchet-57b4c04e745eb8ab0d8259ed5a24ea176976191f.tar.bz2
Trebuchet: make forced adaptive icons optional
Change-Id: Ie84af7114118f54b2d267a35ce24dd5e58c0be22 Signed-off-by: Joey <joey@lineageos.org>
-rw-r--r--res/drawable/ic_settings_force_adaptive.xml24
-rw-r--r--res/values/lineage_strings.xml3
-rw-r--r--res/xml/launcher_preferences.xml9
-rw-r--r--src/com/android/launcher3/SettingsActivity.java13
-rw-r--r--src/com/android/launcher3/Utilities.java5
-rw-r--r--src/com/android/launcher3/graphics/LauncherIcons.java8
6 files changed, 58 insertions, 4 deletions
diff --git a/res/drawable/ic_settings_force_adaptive.xml b/res/drawable/ic_settings_force_adaptive.xml
new file mode 100644
index 0000000..21a9c90
--- /dev/null
+++ b/res/drawable/ic_settings_force_adaptive.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ Copyright (C) 2017 The LineageOS Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="@dimen/settings_icon_size"
+ android:height="@dimen/settings_icon_size"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ <path
+ android:fillColor="@color/settings_icons"
+ android:pathData="M12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM5,15L3,15v4c0,1.1 0.9,2 2,2h4v-2L5,19v-4zM5,5h4L9,3L5,3c-1.1,0 -2,0.9 -2,2v4h2L5,5zM19,3h-4v2h4v4h2L21,5c0,-1.1 -0.9,-2 -2,-2zM19,19h-4v2h4c1.1,0 2,-0.9 2,-2v-4h-2v4z" />
+</vector>
diff --git a/res/values/lineage_strings.xml b/res/values/lineage_strings.xml
index 49114cb..980de5d 100644
--- a/res/values/lineage_strings.xml
+++ b/res/values/lineage_strings.xml
@@ -67,6 +67,9 @@
<string name="settings_icon_shape">Icons shape</string>
<string name="settings_icon_badging_desc_on">A bubble will be displayed above the icon when there\'s a notification</string>
<string name="settings_icon_badging_desc_off">No bubble will be displayed above the icon when there\'s a notification</string>
+ <string name="settings_icon_force_adaptive_title">Force adaptive icons</string>
+ <string name="settings_icon_force_adaptive_desc_on">Icons with a custom shape will be boxed</string>
+ <string name="settings_icon_force_adaptive_desc_off">Icons with a custom shape will not be boxed</string>
<string name="settings_feed">Enable feed integration</string>
<string name="settings_edit_allow_title">Allow edit</string>
<string name="settings_edit_allow_summary_on">Icons and widgets can be added, removed and moved on the homescreen</string>
diff --git a/res/xml/launcher_preferences.xml b/res/xml/launcher_preferences.xml
index 45f3b6e..195b6bf 100644
--- a/res/xml/launcher_preferences.xml
+++ b/res/xml/launcher_preferences.xml
@@ -97,6 +97,15 @@
android:summary="%s"
android:title="@string/settings_icon_shape" />
+ <SwitchPreference
+ android:defaultValue="false"
+ android:icon="@drawable/ic_settings_force_adaptive"
+ android:key="pref_icon_force_adaptive"
+ android:persistent="true"
+ android:summaryOn="@string/settings_icon_force_adaptive_desc_on"
+ android:summaryOff="@string/settings_icon_force_adaptive_desc_off"
+ android:title="@string/settings_icon_force_adaptive_title" />
+
<com.android.launcher3.views.ButtonPreference
android:key="pref_icon_badging"
android:title="@string/icon_badging_title"
diff --git a/src/com/android/launcher3/SettingsActivity.java b/src/com/android/launcher3/SettingsActivity.java
index 8cab471..647ad7d 100644
--- a/src/com/android/launcher3/SettingsActivity.java
+++ b/src/com/android/launcher3/SettingsActivity.java
@@ -32,6 +32,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
@@ -62,6 +63,7 @@ public class SettingsActivity extends Activity {
static final String KEY_FEED_INTEGRATION = "pref_feed_integration";
public static final String KEY_WORKSPACE_EDIT = "pref_workspace_edit";
+ public static final String KEY_FORCE_ADAPTIVE_ICONS = "pref_icon_force_adaptive";
static final String EXTRA_SCHEDULE_RESTART = "extraScheduleRestart";
@@ -142,6 +144,16 @@ public class SettingsActivity extends Activity {
homeGroup.removePreference(feedIntegration);
}
+ SwitchPreference iconAdaptiveOverride = (SwitchPreference)
+ findPreference(KEY_FORCE_ADAPTIVE_ICONS);
+ if (iconAdaptiveOverride != null) {
+ iconAdaptiveOverride.setOnPreferenceChangeListener((preference, newValue) -> {
+ // Clear the icon cache.
+ LauncherAppState.getInstance(getContext()).getIconCache().clear();
+ return true;
+ });
+ }
+
Preference iconShapeOverride = findPreference(IconShapeOverride.KEY_PREFERENCE);
if (iconShapeOverride != null) {
if (IconShapeOverride.isSupported(getActivity())) {
@@ -175,6 +187,7 @@ public class SettingsActivity extends Activity {
switch (key) {
case KEY_SHOW_DESKTOP_LABELS:
case KEY_SHOW_DRAWER_LABELS:
+ case KEY_FORCE_ADAPTIVE_ICONS:
mShouldRestart = true;
break;
}
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 453b466..b6c623a 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -742,4 +742,9 @@ public final class Utilities {
int hours = calendar.get(Calendar.HOUR_OF_DAY);
return hours > SUGGESTIONS_DAY_START && hours < SUGGESTIONS_DAY_END;
}
+
+ public static boolean isAdaptiveIconForced(Context context) {
+ SharedPreferences prefs = getPrefs(context.getApplicationContext());
+ return prefs.getBoolean(SettingsActivity.KEY_FORCE_ADAPTIVE_ICONS, false);
+ }
}
diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java
index a1884a7..fb0d36c 100644
--- a/src/com/android/launcher3/graphics/LauncherIcons.java
+++ b/src/com/android/launcher3/graphics/LauncherIcons.java
@@ -112,7 +112,7 @@ public class LauncherIcons {
context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate();
dr.setBounds(0, 0, 1, 1);
scale = normalizer.getScale(icon, null, dr.getIconMask(), outShape);
- if (FeatureFlags.LEGACY_ICON_TREATMENT && !outShape[0]) {
+ if (Utilities.isAdaptiveIconForced(context) && !outShape[0]) {
Drawable wrappedIcon = wrapToAdaptiveIconDrawable(context, icon, scale);
if (wrappedIcon != icon) {
icon = wrappedIcon;
@@ -165,7 +165,7 @@ public class LauncherIcons {
context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate();
dr.setBounds(0, 0, 1, 1);
scale = normalizer.getScale(icon, iconBounds, dr.getIconMask(), outShape);
- if (FeatureFlags.LEGACY_ICON_TREATMENT && !outShape[0]) {
+ if (Utilities.isAdaptiveIconForced(context) && !outShape[0]) {
Drawable wrappedIcon = wrapToAdaptiveIconDrawable(context, icon, scale);
if (wrappedIcon != icon) {
icon = wrappedIcon;
@@ -214,7 +214,7 @@ public class LauncherIcons {
public static Bitmap createIconBitmap(Drawable icon, Context context) {
float scale = 1f;
- if (FeatureFlags.LEGACY_ICON_TREATMENT && Utilities.ATLEAST_OREO &&
+ if (Utilities.isAdaptiveIconForced(context) && Utilities.ATLEAST_OREO &&
!(icon instanceof AdaptiveIconDrawable)) {
Drawable wrappedIcon = wrapToAdaptiveIconDrawable(context, icon, scale);
if (wrappedIcon != icon) {
@@ -305,7 +305,7 @@ public class LauncherIcons {
* create AdaptiveIconDrawable.
*/
public static Drawable wrapToAdaptiveIconDrawable(Context context, Drawable drawable, float scale) {
- if (!(FeatureFlags.LEGACY_ICON_TREATMENT && Utilities.ATLEAST_OREO)) {
+ if (!(Utilities.isAdaptiveIconForced(context) && Utilities.ATLEAST_OREO)) {
return drawable;
}