From 2bd7065b3b51077e08f74b1cfb46f041eaaf47fc Mon Sep 17 00:00:00 2001 From: Saul Henriquez Date: Sun, 20 Sep 2020 13:51:03 -0600 Subject: [PATCH] fix custom app alias Signed-off-by: Saul Henriquez --- Omega/res/layout/preference_preview_icon.xml | 1 + Omega/res/xml/omega_preferences_theme.xml | 3 ++- Omega/src/com/saggitt/omega/OmegaLauncher.java | 6 +++--- .../saggitt/omega/iconpack/IconPackManager.kt | 2 +- .../omega/override/CustomInfoProvider.kt | 8 -------- .../omega/override/ShortcutInfoProvider.kt | 8 -------- build.gradle | 2 +- res/raw/downgrade_schema.json | 13 ++++++------- src/com/android/launcher3/BubbleTextView.java | 12 +++++++++++- src/com/android/launcher3/LauncherFiles.java | 1 + .../android/launcher3/WorkspaceItemInfo.java | 7 +++---- .../android/launcher3/model/ModelWriter.java | 18 +++++++++--------- .../shortcuts/DeepShortcutManager.java | 8 ++++---- 13 files changed, 42 insertions(+), 47 deletions(-) diff --git a/Omega/res/layout/preference_preview_icon.xml b/Omega/res/layout/preference_preview_icon.xml index fdf2171669..10903021fe 100644 --- a/Omega/res/layout/preference_preview_icon.xml +++ b/Omega/res/layout/preference_preview_icon.xml @@ -1,3 +1,4 @@ + + android:title="@string/reset_custom_icons" + app:iconSpaceReserved="false" /> infoPr } - private void handleEditIconResult(int resultCode, @NotNull Bundle data) { + private void handleEditIconResult(int resultCode, Bundle data) { if (resultCode == Activity.RESULT_OK) { if (currentEditInfo == null) { return; } ItemInfo itemInfo = currentEditInfo; String entryString = data.getString(EditIconActivity.EXTRA_ENTRY); - CustomIconEntry customIconEntry = CustomIconEntry.Companion.fromString(entryString); + CustomIconEntry customIconEntry = CustomIconEntry.Companion.fromString(Objects.requireNonNull(entryString)); (CustomInfoProvider.Companion.forItem(this, itemInfo)).setIcon(itemInfo, customIconEntry); } } diff --git a/Omega/src/com/saggitt/omega/iconpack/IconPackManager.kt b/Omega/src/com/saggitt/omega/iconpack/IconPackManager.kt index 68e91cf1e9..70a60a2eac 100644 --- a/Omega/src/com/saggitt/omega/iconpack/IconPackManager.kt +++ b/Omega/src/com/saggitt/omega/iconpack/IconPackManager.kt @@ -307,7 +307,7 @@ class IconPackManager(private val context: Context) { "com.gau.go.launcherex.theme", "org.adw.launcher.THEMES", "net.oneplus.launcher.icons.ACTION_PICK_ICON", - "ch.deletescape.lawnchair.ICONPACK") + "com.saggitt.omega.ICONPACK") internal fun isPackProvider(context: Context, packageName: String?): Boolean { if (packageName != null && !packageName.isEmpty()) { diff --git a/Omega/src/com/saggitt/omega/override/CustomInfoProvider.kt b/Omega/src/com/saggitt/omega/override/CustomInfoProvider.kt index 6f05d52702..0c6516f5d7 100644 --- a/Omega/src/com/saggitt/omega/override/CustomInfoProvider.kt +++ b/Omega/src/com/saggitt/omega/override/CustomInfoProvider.kt @@ -52,14 +52,6 @@ abstract class CustomInfoProvider(val context: Context) { open fun supportsBadgeVisible(info: T) = false - open fun setBadgeVisible(info: T, visible: Boolean) { - TODO("not implemented") - } - - open fun getBadgeVisible(info: T): Boolean { - TODO("not implemented") - } - companion object { @Suppress("UNCHECKED_CAST") diff --git a/Omega/src/com/saggitt/omega/override/ShortcutInfoProvider.kt b/Omega/src/com/saggitt/omega/override/ShortcutInfoProvider.kt index 2767b3a7b4..47f23a10c4 100644 --- a/Omega/src/com/saggitt/omega/override/ShortcutInfoProvider.kt +++ b/Omega/src/com/saggitt/omega/override/ShortcutInfoProvider.kt @@ -86,14 +86,6 @@ class ShortcutInfoProvider private constructor(context: Context) : CustomInfoPro else -> false } - override fun setBadgeVisible(info: WorkspaceItemInfo, visible: Boolean) { - info.setBadgeVisible(context, visible) - } - - override fun getBadgeVisible(info: WorkspaceItemInfo): Boolean { - return info.isBadgeVisible - } - private fun getLauncherActivityInfo(info: WorkspaceItemInfo): LauncherActivityInfo? { return launcherApps.resolveActivity(info.getIntent(), info.user) } diff --git a/build.gradle b/build.gradle index 062019fdd7..b8233903ea 100644 --- a/build.gradle +++ b/build.gradle @@ -80,7 +80,7 @@ android { buildToolsVersion "30.0.2" def name = "0.4.0" - def code = 31 + def code = 32 defaultConfig { minSdkVersion 25 diff --git a/res/raw/downgrade_schema.json b/res/raw/downgrade_schema.json index 8f1780e5f7..957cf440bf 100644 --- a/res/raw/downgrade_schema.json +++ b/res/raw/downgrade_schema.json @@ -2,17 +2,16 @@ // Note: Comments are not supported in JSON schema, but android parser is lenient. // Maximum DB version supported by this schema - "version" : 28, - - "downgrade_to_27" : [ + "version": 32, + "downgrade_to_27": [ "CREATE TABLE workspaceScreens (_id INTEGER PRIMARY KEY,screenRank INTEGER,modified INTEGER NOT NULL DEFAULT 0)", "insert into workspaceScreens (_id, screenRank) select screen as _id, screen as screenRank from favorites where container = -100 group by screen order by screen" ], // Downgrade from 27 to 26. Empty array indicates, the DB is compatible - "downgrade_to_26" : [], - "downgrade_to_25" : [], - "downgrade_to_24" : [], - "downgrade_to_23" : [], + "downgrade_to_26": [], + "downgrade_to_25": [], + "downgrade_to_24": [], + "downgrade_to_23": [], "downgrade_to_22" : [ "ALTER TABLE favorites RENAME TO temp_favorites;", "CREATE TABLE favorites(_id INTEGER PRIMARY KEY, title TEXT, intent TEXT, container INTEGER, screen INTEGER, cellX INTEGER, cellY INTEGER, spanX INTEGER, spanY INTEGER, itemType INTEGER, appWidgetId INTEGER NOT NULL DEFAULT - 1, iconPackage TEXT, iconResource TEXT, icon BLOB, appWidgetProvider TEXT, modified INTEGER NOT NULL DEFAULT 0, restored INTEGER NOT NULL DEFAULT 0, profileId INTEGER DEFAULT 0, rank INTEGER NOT NULL DEFAULT 0);", diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 6941616968..912e705db8 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -56,6 +56,7 @@ import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.IconLabelDotView; import com.saggitt.omega.OmegaPreferences; +import com.saggitt.omega.override.CustomInfoProvider; import java.text.NumberFormat; @@ -326,7 +327,7 @@ private void applyIconAndLabel(ItemInfoWithIcon info) { } setIcon(iconDrawable); if (!isTextHidden()) - setText(info.title); + setText(getTitle(info)); if (info.contentDescription != null) { setContentDescription(info.isDisabled() ? getContext().getString(R.string.disabled_app_label, info.contentDescription) @@ -334,6 +335,15 @@ private void applyIconAndLabel(ItemInfoWithIcon info) { } } + private CharSequence getTitle(ItemInfo info) { + CustomInfoProvider customInfoProvider = CustomInfoProvider.Companion.forItem(getContext(), info); + if (customInfoProvider != null) { + return customInfoProvider.getTitle(info); + } else { + return info.title; + } + } + /** * Overrides the default long press timeout. */ diff --git a/src/com/android/launcher3/LauncherFiles.java b/src/com/android/launcher3/LauncherFiles.java index ddc0fbdeec..496ba292c3 100644 --- a/src/com/android/launcher3/LauncherFiles.java +++ b/src/com/android/launcher3/LauncherFiles.java @@ -30,6 +30,7 @@ public class LauncherFiles { public static final List ALL_FILES = Collections.unmodifiableList(Arrays.asList( LAUNCHER_DB, + LAUNCHER_DB2, SHARED_PREFERENCES_KEY + XML, WIDGET_PREVIEWS_DB, MANAGED_USER_PREFERENCES_KEY + XML, diff --git a/src/com/android/launcher3/WorkspaceItemInfo.java b/src/com/android/launcher3/WorkspaceItemInfo.java index 75b706fdbf..9d5f5893c5 100644 --- a/src/com/android/launcher3/WorkspaceItemInfo.java +++ b/src/com/android/launcher3/WorkspaceItemInfo.java @@ -29,6 +29,7 @@ import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.icons.IconCache; import com.android.launcher3.model.ModelWriter; +import com.android.launcher3.shortcuts.ShortcutInfoCompat; import com.android.launcher3.shortcuts.ShortcutKey; import com.android.launcher3.util.ContentWriter; import com.saggitt.omega.iconpack.IconPackManager; @@ -103,6 +104,8 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon { public CharSequence customTitle; public Bitmap customIcon; public IconPackManager.CustomIconEntry customIconEntry; + + public ShortcutInfoCompat shortcutInfo; /** * The installation progress [0-100] of the package that this shortcut represents. */ @@ -266,10 +269,6 @@ public void setSwipeUpAction(@NonNull Context context, @Nullable String action) updateDatabase(context, false, true); } - public void setBadgeVisible(@NonNull Context context, @NonNull Boolean visible) { - updateDatabase(context, false, true); - } - @Override public ItemInfoWithIcon clone() { return new WorkspaceItemInfo(this); diff --git a/src/com/android/launcher3/model/ModelWriter.java b/src/com/android/launcher3/model/ModelWriter.java index 4fea2c06a2..63d4974c23 100644 --- a/src/com/android/launcher3/model/ModelWriter.java +++ b/src/com/android/launcher3/model/ModelWriter.java @@ -439,17 +439,17 @@ public void run() { } } - private abstract class UpdateItemBaseRunnable implements Runnable { - private final StackTraceElement[] mStackTrace; - private final ModelVerifier mVerifier = new ModelVerifier(); + private abstract class UpdateItemBaseRunnable implements Runnable { + private final StackTraceElement[] mStackTrace; + private final ModelVerifier mVerifier = new ModelVerifier(); - UpdateItemBaseRunnable() { - mStackTrace = new Throwable().getStackTrace(); - } + UpdateItemBaseRunnable() { + mStackTrace = new Throwable().getStackTrace(); + } - protected void updateItemArrays(ItemInfo item, int itemId) { - // Lock on mBgLock *after* the db operation - synchronized (mBgDataModel) { + protected void updateItemArrays(ItemInfo item, int itemId) { + // Lock on mBgLock *after* the db operation + synchronized (mBgDataModel) { checkItemInfoLocked(itemId, item, mStackTrace); if (item.container != Favorites.CONTAINER_DESKTOP && diff --git a/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java b/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java index fd13db2567..89010dd91f 100644 --- a/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java +++ b/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java @@ -71,10 +71,6 @@ public static boolean supportsShortcuts(ItemInfo info) { && !info.isDisabled() && !isItemPromise; } - public static boolean supportsEdit(ItemInfo info) { - return CustomInfoProvider.Companion.isEditable(info) || supportsShortcuts(info); - } - /** * Queries for the shortcuts with the package name and provided ids. *

@@ -170,6 +166,10 @@ public Drawable getShortcutIconDrawable(ShortcutInfoCompat shortcutInfo, int den return null; } + public static boolean supportsEdit(ItemInfo info) { + return CustomInfoProvider.Companion.isEditable(info) || supportsShortcuts(info); + } + public boolean wasLastCallSuccess() { return mWasLastCallSuccess; }