Skip to content

Commit

Permalink
PixelHome: Allow users to toggle legacy icon masking
Browse files Browse the repository at this point in the history
Pixelhome: we aren't rearranged stuff wo still relay on SettingsActivity, I edited the code to work in our case.

After r16 rebase, commit AospExtended/platform_packages_apps_Launcher3@0d84d7d enforces icon mask to all non adaptive icons,
causing ugly UX specially with custom icon packs, so simply make it toggleable by user and disable it by default.

Thanks to @eldainosor for pointing me to the commit causing it

Change-Id: Ia4a3e394874391dca1d72aad4d3d162f64ccbe21
Signed-off-by: Shubham Singh <[email protected]>
  • Loading branch information
ishubhamsingh authored and iamsj7 committed Feb 16, 2019
1 parent 39cad64 commit eaa1062
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
3 changes: 3 additions & 0 deletions res/values/pixel_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="icon_pack">Icon pack</string>
<string name="icon_pack_summary">Select a custom icon pack</string>
<string name="icons_category_title">Icons</string>
<!-- Icon mask -->
<string name="legacy_icon_mask_title">Force shape mask on legacy icons</string>
<string name="legacy_icon_mask_summary">Could cause issue with custom icon packs, if enabled</string>

</resources>
21 changes: 14 additions & 7 deletions res/xml/launcher_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@
</intent>
</com.android.launcher3.views.ButtonPreference>

<com.android.launcher3.preferences.IconPackPreference
android:key="pref_iconPackPackage"
android:title="@string/icon_pack"
android:summary="@string/icon_pack_summary"
android:persistent="true"
/>

<SwitchPreference
android:defaultValue="true"
android:icon="@drawable/google_app"
Expand Down Expand Up @@ -73,6 +66,20 @@

<PreferenceCategory android:title="@string/homescreen_category_title">

<com.android.launcher3.preferences.IconPackPreference
android:key="pref_iconPackPackage"
android:title="@string/icon_pack"
android:summary="@string/icon_pack_summary"
android:persistent="true"
/>

<SwitchPreference
android:key="pref_legacy_icon_mask"
android:title="@string/legacy_icon_mask_title"
android:summary="@string/legacy_icon_mask_summary"
android:defaultValue="false"
android:persistent="true"/>

<SwitchPreference
android:defaultValue="true"
android:icon="@drawable/add_icons"
Expand Down
2 changes: 1 addition & 1 deletion src/com/android/launcher3/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -2541,7 +2541,7 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
}
}

if ("pref_iconPackPackage".equals(key)) {
if ("pref_iconPackPackage".equals(key) || SettingsActivity.KEY_PREF_LEGACY_ICON_MASK.equals(key)) {
mModel.clearIconCache();
mModel.forceReload();
}
Expand Down
1 change: 1 addition & 0 deletions src/com/android/launcher3/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class SettingsActivity extends Activity {

private static final String ICON_BADGING_PREFERENCE_KEY = "pref_icon_badging";
static final String KEY_FEED_INTEGRATION = "pref_feed_integration";
static final String KEY_PREF_LEGACY_ICON_MASK = "pref_legacy_icon_mask";

/** Hidden field Settings.Secure.NOTIFICATION_BADGING */
public static final String NOTIFICATION_BADGING = "notification_badging";
Expand Down
5 changes: 5 additions & 0 deletions src/com/android/launcher3/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ public static int getHotseatIcons(Context context, int fallback) {
return getIconCount(context, HOTSEAT_ICONS, fallback);
}

public static boolean forceLegacyIconMask(Context context) {
SharedPreferences prefs = getPrefs(context.getApplicationContext());
return prefs.getBoolean(SettingsActivity.KEY_PREF_LEGACY_ICON_MASK, false);
}

public static float getIconSizeModifier(Context context) {
String saved = getPrefs(context).getString(ICON_SIZE, "average");
float offset;
Expand Down
4 changes: 2 additions & 2 deletions src/com/android/launcher3/graphics/LauncherIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ public void setWrapperBackgroundColor(int color) {
private Drawable normalizeAndWrapToAdaptiveIcon(Drawable icon, int iconAppTargetSdk,
RectF outIconBounds, float[] outScale) {
float scale = 1f;
if ((Utilities.ATLEAST_OREO && iconAppTargetSdk >= Build.VERSION_CODES.O) ||
Utilities.ATLEAST_P) {
if (((Utilities.ATLEAST_OREO && iconAppTargetSdk >= Build.VERSION_CODES.O) ||
Utilities.ATLEAST_P) && Utilities.forceLegacyIconMask(mContext)) {
boolean[] outShape = new boolean[1];
if (mWrapperIcon == null) {
mWrapperIcon = mContext.getDrawable(R.drawable.adaptive_icon_drawable_wrapper)
Expand Down

0 comments on commit eaa1062

Please sign in to comment.