Skip to content

Commit

Permalink
fix custom app alias
Browse files Browse the repository at this point in the history
Signed-off-by: Saul Henriquez <[email protected]>
  • Loading branch information
saulhdev committed Sep 20, 2020
1 parent 0011547 commit 2bd7065
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 47 deletions.
1 change: 1 addition & 0 deletions Omega/res/layout/preference_preview_icon.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
3 changes: 2 additions & 1 deletion Omega/res/xml/omega_preferences_theme.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

<Preference
android:key="pref_reset_custom_icon"
android:title="@string/reset_custom_icons" />
android:title="@string/reset_custom_icons"
app:iconSpaceReserved="false" />

<com.saggitt.omega.preferences.ColorPreferenceCompat
android:defaultValue="@color/colorAccent"
Expand Down
6 changes: 3 additions & 3 deletions Omega/src/com/saggitt/omega/OmegaLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import com.saggitt.omega.util.ContextUtils;
import com.saggitt.omega.util.CustomLauncherClient;

import org.jetbrains.annotations.NotNull;
import java.util.Objects;

import static com.saggitt.omega.iconpack.IconPackManager.Companion;
import static com.saggitt.omega.iconpack.IconPackManager.CustomIconEntry;
Expand Down Expand Up @@ -150,14 +150,14 @@ public void startEditIcon(ItemInfo itemInfo, CustomInfoProvider<ItemInfo> 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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Omega/src/com/saggitt/omega/iconpack/IconPackManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
8 changes: 0 additions & 8 deletions Omega/src/com/saggitt/omega/override/CustomInfoProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ abstract class CustomInfoProvider<in T : ItemInfo>(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")
Expand Down
8 changes: 0 additions & 8 deletions Omega/src/com/saggitt/omega/override/ShortcutInfoProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ android {
buildToolsVersion "30.0.2"

def name = "0.4.0"
def code = 31
def code = 32

defaultConfig {
minSdkVersion 25
Expand Down
13 changes: 6 additions & 7 deletions res/raw/downgrade_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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);",
Expand Down
12 changes: 11 additions & 1 deletion src/com/android/launcher3/BubbleTextView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -326,14 +327,23 @@ 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)
: info.contentDescription);
}
}

private CharSequence getTitle(ItemInfo info) {
CustomInfoProvider<ItemInfo> customInfoProvider = CustomInfoProvider.Companion.forItem(getContext(), info);
if (customInfoProvider != null) {
return customInfoProvider.getTitle(info);
} else {
return info.title;
}
}

/**
* Overrides the default long press timeout.
*/
Expand Down
1 change: 1 addition & 0 deletions src/com/android/launcher3/LauncherFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class LauncherFiles {

public static final List<String> ALL_FILES = Collections.unmodifiableList(Arrays.asList(
LAUNCHER_DB,
LAUNCHER_DB2,
SHARED_PREFERENCES_KEY + XML,
WIDGET_PREVIEWS_DB,
MANAGED_USER_PREFERENCES_KEY + XML,
Expand Down
7 changes: 3 additions & 4 deletions src/com/android/launcher3/WorkspaceItemInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions src/com/android/launcher3/model/ModelWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 2bd7065

Please sign in to comment.