From 6006d9205c3e4a023640607f2b8782ae499f5b83 Mon Sep 17 00:00:00 2001 From: fazilsheik96 Date: Tue, 12 Mar 2024 00:38:13 +0530 Subject: [PATCH] [SQUASH]Revert "Launcher3: Add AppInfo Bottom Sheet from Shade Launcher" This reverts commit 78e1005614321b24d9e51afe51a20755fe2d464b. Revert "SystemShortcuts: fix fc with InfoBottomSheet" This reverts commit 2d2c5768a63a6f3948116f8a951b856a55c41873. Revert "Launcher3: Do not attempt to show promise icon when info is null" This reverts commit a15d13d8007614e1e729077b8d709e52bf6e9f99. Revert "Launcher3: Fix NPE with AppInfoBottomSheet" This reverts commit 41e92c2a48dcea01a217df987b245e3fb6aefb51. Revert "InfoBottomSheet: Fix NPE with AppTransitionManager" This reverts commit f9a5fb840228869af1d45bf3911c3fec4899abc8. --- res/drawable/ic_app_info_icon_pack.xml | 15 -- res/drawable/ic_app_info_last_update.xml | 10 - res/drawable/ic_app_info_source.xml | 10 - res/drawable/ic_app_info_version.xml | 10 - res/layout/app_info_bottom_sheet.xml | 12 - res/layout/app_info_bottom_sheet_content.xml | 61 ----- res/xml/app_info_preferences.xml | 50 ---- .../customization/InfoBottomSheet.java | 218 ------------------ .../customization/MetadataExtractor.java | 87 ------- .../launcher3/model/ItemInstallQueue.java | 1 - .../launcher3/popup/SystemShortcut.java | 18 +- 11 files changed, 2 insertions(+), 490 deletions(-) delete mode 100644 res/drawable/ic_app_info_icon_pack.xml delete mode 100644 res/drawable/ic_app_info_last_update.xml delete mode 100644 res/drawable/ic_app_info_source.xml delete mode 100644 res/drawable/ic_app_info_version.xml delete mode 100644 res/layout/app_info_bottom_sheet.xml delete mode 100644 res/layout/app_info_bottom_sheet_content.xml delete mode 100644 res/xml/app_info_preferences.xml delete mode 100644 src/com/android/launcher3/customization/InfoBottomSheet.java delete mode 100644 src/com/android/launcher3/customization/MetadataExtractor.java diff --git a/res/drawable/ic_app_info_icon_pack.xml b/res/drawable/ic_app_info_icon_pack.xml deleted file mode 100644 index 4a809b14ed..0000000000 --- a/res/drawable/ic_app_info_icon_pack.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/res/drawable/ic_app_info_last_update.xml b/res/drawable/ic_app_info_last_update.xml deleted file mode 100644 index bc51923d79..0000000000 --- a/res/drawable/ic_app_info_last_update.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/res/drawable/ic_app_info_source.xml b/res/drawable/ic_app_info_source.xml deleted file mode 100644 index 2aafd6068d..0000000000 --- a/res/drawable/ic_app_info_source.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/res/drawable/ic_app_info_version.xml b/res/drawable/ic_app_info_version.xml deleted file mode 100644 index e3fd7bdf7a..0000000000 --- a/res/drawable/ic_app_info_version.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/res/layout/app_info_bottom_sheet.xml b/res/layout/app_info_bottom_sheet.xml deleted file mode 100644 index c7dba41add..0000000000 --- a/res/layout/app_info_bottom_sheet.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/res/layout/app_info_bottom_sheet_content.xml b/res/layout/app_info_bottom_sheet_content.xml deleted file mode 100644 index 7fb3767710..0000000000 --- a/res/layout/app_info_bottom_sheet_content.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/xml/app_info_preferences.xml b/res/xml/app_info_preferences.xml deleted file mode 100644 index 2340652560..0000000000 --- a/res/xml/app_info_preferences.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/src/com/android/launcher3/customization/InfoBottomSheet.java b/src/com/android/launcher3/customization/InfoBottomSheet.java deleted file mode 100644 index 5f94e99195..0000000000 --- a/src/com/android/launcher3/customization/InfoBottomSheet.java +++ /dev/null @@ -1,218 +0,0 @@ -package com.android.launcher3.customization; - -import android.app.ActivityOptions; -import android.app.Fragment; -import android.app.FragmentManager; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import androidx.preference.Preference; -import androidx.preference.PreferenceFragment; -import androidx.recyclerview.widget.RecyclerView; -import android.graphics.Rect; - -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import com.android.launcher3.BaseDraggingActivity; -import com.android.launcher3.model.data.ItemInfo; -import com.android.launcher3.Launcher; -import com.android.launcher3.QuickstepTransitionManager; -import com.android.launcher3.R; -import com.android.launcher3.util.ActivityOptionsWrapper; -import com.android.launcher3.util.ComponentKey; -import com.android.launcher3.widget.WidgetsBottomSheet; -import com.android.launcher3.util.PackageManagerHelper; - -import com.android.launcher3.settings.preference.IconPackPrefSetter; -import com.android.launcher3.settings.preference.ReloadingListPreference; -import com.android.launcher3.util.AppReloader; - -import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; -import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR; - -public class InfoBottomSheet extends WidgetsBottomSheet { - private final FragmentManager mFragmentManager; - protected static Rect mSourceBounds; - protected static Context mTarget; - - public InfoBottomSheet(Context context) { - this(context, null); - } - - public InfoBottomSheet(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public InfoBottomSheet(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - mFragmentManager = Launcher.getLauncher(context).getFragmentManager(); - } - - public void configureBottomSheet(Rect sourceBounds, Context target) { - mSourceBounds = sourceBounds; - mTarget = target; - } - - @Override - public void populateAndShow(ItemInfo itemInfo) { - super.populateAndShow(itemInfo); - TextView title = findViewById(R.id.title); - title.setText(itemInfo.title); - - PrefsFragment fragment = - (PrefsFragment) mFragmentManager.findFragmentById(R.id.sheet_prefs); - fragment.loadForApp(itemInfo); - } - - @Override - public void onDetachedFromWindow() { - Fragment pf = mFragmentManager.findFragmentById(R.id.sheet_prefs); - if (pf != null) { - mFragmentManager.beginTransaction() - .remove(pf) - .commitAllowingStateLoss(); - } - super.onDetachedFromWindow(); - } - - @Override - public void onWidgetsBound() { - } - - public static class PrefsFragment extends PreferenceFragment - implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener { - private static final String KEY_ICON_PACK = "pref_app_info_icon_pack"; - private static final String KEY_SOURCE = "pref_app_info_source"; - private static final String KEY_LAST_UPDATE = "pref_app_info_last_update"; - private static final String KEY_VERSION = "pref_app_info_version"; - private static final String KEY_MORE = "pref_app_info_more"; - - private Context mContext; - - private ItemInfo mItemInfo; - - private ComponentName mComponent; - private ComponentKey mKey; - private QuickstepTransitionManager mAppTransitionManager; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - mContext = getActivity(); - mAppTransitionManager = new QuickstepTransitionManager(mContext); - mAppTransitionManager.registerRemoteAnimations(); - mAppTransitionManager.registerRemoteTransitions(); - } - - private QuickstepTransitionManager getAppTransitionManager() { - return mAppTransitionManager; - } - - public ActivityOptionsWrapper getActivityLaunchOptions(View v) { - return mAppTransitionManager.getActivityLaunchOptions(v); - } - - @Override - public void onDestroy() { - mAppTransitionManager.onActivityDestroyed(); - super.onDestroy(); - } - - @Override - public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { - addPreferencesFromResource(R.xml.app_info_preferences); - } - - @Override - public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent, - Bundle savedInstanceState) { - RecyclerView view = super.onCreateRecyclerView(inflater, parent, savedInstanceState); - view.setOverScrollMode(View.OVER_SCROLL_NEVER); - return view; - } - - public void loadForApp(ItemInfo itemInfo) { - mComponent = itemInfo.getTargetComponent(); - mItemInfo = itemInfo; - mKey = new ComponentKey(mComponent, itemInfo.user); - - ReloadingListPreference icons = (ReloadingListPreference) findPreference(KEY_ICON_PACK); - icons.setValue(IconDatabase.getByComponent(mContext, mKey)); - icons.setOnReloadListener(ctx -> new IconPackPrefSetter(ctx, mComponent)); - icons.setOnPreferenceChangeListener(this); - - THREAD_POOL_EXECUTOR.execute(() -> { - MetadataExtractor extractor = new MetadataExtractor(mContext, mComponent); - - CharSequence source = extractor.getSource(); - CharSequence lastUpdate = extractor.getLastUpdate(); - CharSequence version = mContext.getString( - R.string.app_info_version_value, - extractor.getVersionName(), - extractor.getVersionCode()); - Intent marketIntent = extractor.getMarketIntent(); - - MAIN_EXECUTOR.execute(() -> { - Preference sourcePref = findPreference(KEY_SOURCE); - Preference lastUpdatePref = findPreference(KEY_LAST_UPDATE); - Preference versionPref = findPreference(KEY_VERSION); - Preference morePref = findPreference(KEY_MORE); - - sourcePref.setSummary(source); - lastUpdatePref.setSummary(lastUpdate); - versionPref.setSummary(version); - morePref.setOnPreferenceClickListener(this); - - if (marketIntent != null) { - sourcePref.setOnPreferenceClickListener( - pref -> tryStartActivity(marketIntent)); - } - }); - }); - } - - private boolean tryStartActivity(Intent intent) { - Launcher launcher = Launcher.getLauncher(mContext); - Bundle opts = getAppTransitionManager() - .getActivityLaunchOptions(getView()) - .toBundle(); - try { - launcher.startActivity(intent, opts); - } catch (Exception ignored) { - } - return false; - } - - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - if (newValue.equals(IconDatabase.getGlobal(mContext))) { - IconDatabase.resetForComponent(mContext, mKey); - } else { - IconDatabase.setForComponent(mContext, mKey, (String) newValue); - } - AppReloader.get(mContext).reload(mKey); - return true; - } - - private void onMoreClick() { - new PackageManagerHelper(InfoBottomSheet.mTarget).startDetailsActivityForInfo( - mItemInfo, InfoBottomSheet.mSourceBounds, ActivityOptions.makeBasic().toBundle()); - } - - @Override - public boolean onPreferenceClick(Preference preference) { - onMoreClick(); - return true; - } - } - - @Override - protected boolean hasSeenEducationTip() { - return true; - } -} diff --git a/src/com/android/launcher3/customization/MetadataExtractor.java b/src/com/android/launcher3/customization/MetadataExtractor.java deleted file mode 100644 index eeb5861f51..0000000000 --- a/src/com/android/launcher3/customization/MetadataExtractor.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.android.launcher3.customization; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.text.TextUtils; -import android.text.format.DateUtils; - -import com.android.launcher3.R; -import com.android.launcher3.Utilities; - -import java.io.File; - -import static android.content.pm.PackageManager.GET_META_DATA; - -class MetadataExtractor { - private final Context mContext; - private final PackageManager mPm; - - private String mSourcePkg = ""; - private Intent mMarketIntent; - - private long mLastUpdate = 0; - private String mVersionName = "Unknown"; - private long mVersionCode = 0; - - MetadataExtractor(Context context, ComponentName cn) { - mContext = context; - mPm = context.getPackageManager(); - String pkg = cn.getPackageName(); - - try { - mSourcePkg = mPm.getInstallerPackageName(pkg); - if (!TextUtils.isEmpty(mSourcePkg)) { - mMarketIntent = new Intent(Intent.ACTION_VIEW) - .setData(Uri.parse("market://details?id=" + pkg)) - .setPackage(mSourcePkg); - } - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } - - try { - PackageInfo pi = mPm.getPackageInfo(pkg, GET_META_DATA); - mLastUpdate = new File(pi.applicationInfo.sourceDir).lastModified(); - mVersionName = pi.versionName; - mVersionCode = Utilities.ATLEAST_P ? pi.getLongVersionCode() : pi.versionCode; - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - } - } - - CharSequence getSource() { - if (TextUtils.isEmpty(mSourcePkg)) { - return mContext.getString(R.string.app_info_source_system); - } - try { - ApplicationInfo pi = mPm.getApplicationInfo(mSourcePkg, 0); - return pi.loadLabel(mPm); - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - } - return mSourcePkg; - } - - String getLastUpdate() { - return DateUtils.formatDateTime(mContext, mLastUpdate, - DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_DATE); - } - - String getVersionName() { - return mVersionName; - } - - long getVersionCode() { - return mVersionCode; - } - - Intent getMarketIntent() { - return mMarketIntent; - } - -} diff --git a/src/com/android/launcher3/model/ItemInstallQueue.java b/src/com/android/launcher3/model/ItemInstallQueue.java index ae49e716af..69f9b53090 100644 --- a/src/com/android/launcher3/model/ItemInstallQueue.java +++ b/src/com/android/launcher3/model/ItemInstallQueue.java @@ -107,7 +107,6 @@ public class ItemInstallQueue { @WorkerThread private void addToQueue(PendingInstallShortcutInfo info) { - if (info == null) return; ensureQueueLoaded(); if (!mItems.contains(info)) { mItems.add(info); diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index 8e375a66bd..e7712b1fc5 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -15,7 +15,6 @@ import android.graphics.Rect; import android.net.Uri; import android.util.Log; import android.view.View; -import android.view.InflateException; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.ImageView; import android.widget.TextView; @@ -37,7 +36,6 @@ import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.widget.WidgetsBottomSheet; -import com.android.launcher3.customization.InfoBottomSheet; import java.net.URISyntaxException; import java.util.List; @@ -199,24 +197,12 @@ public abstract class SystemShortcut extend } } - @Override public void onClick(View view) { - InfoBottomSheet cbs; dismissTaskMenuView(mTarget); Rect sourceBounds = Utilities.getViewBounds(view); - try { - cbs = (InfoBottomSheet) mTarget.getLayoutInflater().inflate( - R.layout.app_info_bottom_sheet, - mTarget.getDragLayer(), - false); - cbs.configureBottomSheet(sourceBounds, mTarget); - cbs.populateAndShow(mItemInfo); - } catch (InflateException e) { - new PackageManagerHelper(mTarget).startDetailsActivityForInfo( - mItemInfo, sourceBounds, ActivityOptions.makeBasic().toBundle()); - } - + new PackageManagerHelper(mTarget).startDetailsActivityForInfo( + mItemInfo, sourceBounds, ActivityOptions.makeBasic().toBundle()); mTarget.getStatsLogManager().logger().withItemInfo(mItemInfo) .log(LAUNCHER_SYSTEM_SHORTCUT_APP_INFO_TAP); }