mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
Revert "Revert "Adding support for hiding widgets from the widget tray and reconfiguring widgets""
This reverts commit f502e5faec.
Reason for revert: Reverting post-build
Change-Id: I09eb292dbbbe37ffaf3abc477aa2ddb5700093b8
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
package com.android.launcher3.util;
|
||||
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@@ -24,13 +26,23 @@ import android.content.pm.LauncherActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.launcher3.AppInfo;
|
||||
import com.android.launcher3.ItemInfo;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.PendingAddItemInfo;
|
||||
import com.android.launcher3.PromiseAppInfo;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.ShortcutInfo;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||
|
||||
@@ -42,6 +54,8 @@ import java.util.List;
|
||||
*/
|
||||
public class PackageManagerHelper {
|
||||
|
||||
private static final String TAG = "PackageManagerHelper";
|
||||
|
||||
private final Context mContext;
|
||||
private final PackageManager mPm;
|
||||
private final LauncherAppsCompat mLauncherApps;
|
||||
@@ -169,4 +183,35 @@ public class PackageManagerHelper {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Starts the details activity for {@code info}
|
||||
*/
|
||||
public void startDetailsActivityForInfo(ItemInfo info, Rect sourceBounds, Bundle opts) {
|
||||
if (info instanceof PromiseAppInfo) {
|
||||
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info;
|
||||
mContext.startActivity(promiseAppInfo.getMarketIntent(mContext));
|
||||
return;
|
||||
}
|
||||
ComponentName componentName = null;
|
||||
if (info instanceof AppInfo) {
|
||||
componentName = ((AppInfo) info).componentName;
|
||||
} else if (info instanceof ShortcutInfo) {
|
||||
componentName = info.getTargetComponent();
|
||||
} else if (info instanceof PendingAddItemInfo) {
|
||||
componentName = ((PendingAddItemInfo) info).componentName;
|
||||
} else if (info instanceof LauncherAppWidgetInfo) {
|
||||
componentName = ((LauncherAppWidgetInfo) info).providerName;
|
||||
}
|
||||
if (componentName != null) {
|
||||
try {
|
||||
mLauncherApps.showAppDetailsForProfile(
|
||||
componentName, info.user, sourceBounds, opts);
|
||||
} catch (SecurityException | ActivityNotFoundException e) {
|
||||
Toast.makeText(mContext, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
|
||||
Log.e(TAG, "Unable to launch settings", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user