From f86fcc50f67fdf2bce1a181ddedbf33f420f875e Mon Sep 17 00:00:00 2001 From: Giuseppe Maggio Date: Tue, 9 Apr 2019 12:28:46 +0200 Subject: [PATCH 01/29] SystemShortcut: Add uninstall option This allows to easily uninstall application on the popup activity triggered by long pressing on the applications. @neobuddy89: Add back support functions in Utilities. Signed-off-by: Pranav Vashi --- src/com/android/launcher3/Utilities.java | 70 +++++++++++++++++++ .../launcher3/popup/SystemShortcut.java | 35 ++++++++++ .../popup/SystemShortcutFactory.java | 1 + 3 files changed, 106 insertions(+) diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 108898e992a..2fa6089818a 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -24,9 +24,15 @@ import android.app.Person; import android.app.WallpaperManager; import android.content.BroadcastReceiver; +import android.content.ComponentName; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.ApplicationInfo; import android.content.pm.LauncherActivityInfo; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.pm.ShortcutInfo; import android.content.res.Resources; @@ -52,6 +58,7 @@ import android.text.style.TtsSpan; import android.util.DisplayMetrics; import android.util.Log; +import android.util.Pair; import android.util.TypedValue; import android.view.MotionEvent; import android.view.View; @@ -337,6 +344,69 @@ public static float mapRange(float value, float min, float max) { return min + (value * (max - min)); } + public static boolean isSystemApp(Context context, String pkgName) { + return isSystemApp(context, null, pkgName); + } + + public static boolean isSystemApp(Context context, Intent intent) { + return isSystemApp(context, intent, null); + } + + public static boolean isSystemApp(Context context, Intent intent, String pkgName) { + PackageManager pm = context.getPackageManager(); + String packageName = null; + // If the intent is not null, let's get the package name from the intent. + if (intent != null) { + ComponentName cn = intent.getComponent(); + if (cn == null) { + ResolveInfo info = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); + if ((info != null) && (info.activityInfo != null)) { + packageName = info.activityInfo.packageName; + } + } else { + packageName = cn.getPackageName(); + } + } + // Otherwise we have the package name passed from the method. + else { + packageName = pkgName; + } + // Check if the provided package is a system app. + if (packageName != null) { + try { + PackageInfo info = pm.getPackageInfo(packageName, 0); + return (info != null) && (info.applicationInfo != null) && + ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0); + } catch (NameNotFoundException e) { + return false; + } + } else { + return false; + } + } + + /* + * Finds a system apk which had a broadcast receiver listening to a particular action. + * @param action intent action used to find the apk + * @return a pair of apk package name and the resources. + */ + static Pair findSystemApk(String action, PackageManager pm) { + final Intent intent = new Intent(action); + for (ResolveInfo info : pm.queryBroadcastReceivers(intent, 0)) { + if (info.activityInfo != null && + (info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { + final String packageName = info.activityInfo.packageName; + try { + final Resources res = pm.getResourcesForApplication(packageName); + return Pair.create(packageName, res); + } catch (NameNotFoundException e) { + Log.w(TAG, "Failed to find resources for " + packageName); + } + } + } + return null; + } + /** * Trims the string, removing all whitespace at the beginning and end of the string. * Non-breaking whitespaces are also removed. diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index cad73eb0309..c8f9eb734b9 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -6,6 +6,7 @@ import android.content.Intent; import android.graphics.Rect; import android.graphics.drawable.Icon; +import android.net.Uri; import android.os.Handler; import android.os.Looper; import android.view.View; @@ -229,6 +230,40 @@ public View.OnClickListener getOnClickListener(Launcher activity, ItemInfo itemI } } + public static class Uninstall extends SystemShortcut { + public Uninstall() { + super(R.drawable.ic_uninstall_no_shadow, R.string.uninstall_drop_target_label); + } + + @Override + public View.OnClickListener getOnClickListener( + BaseDraggingActivity activity, ItemInfo itemInfo) { + // Get application information. + String packageName = itemInfo.getTargetComponent().getPackageName(); + boolean isSystemApp = Utilities.isSystemApp(activity.getApplicationContext(), + packageName); + // Do not show the uninstall action if it's a system app. + if (isSystemApp) { + return null; + } + // Create uninstall action. + return createOnClickListener(activity, packageName); + } + + private View.OnClickListener createOnClickListener( + BaseDraggingActivity activity, String packageName) { + return view -> { + // Dismiss drop down. + dismissTaskMenuView(activity); + // Send intent to uninstall package. + Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); + intent.setData(Uri.parse("package:" + packageName)); + intent.putExtra(Intent.EXTRA_RETURN_RESULT, true); + activity.startActivity(intent); + }; + } + } + protected static void dismissTaskMenuView(BaseDraggingActivity activity) { AbstractFloatingView.closeOpenViews(activity, true, AbstractFloatingView.TYPE_ALL & ~AbstractFloatingView.TYPE_REBIND_SAFE); diff --git a/src/com/android/launcher3/popup/SystemShortcutFactory.java b/src/com/android/launcher3/popup/SystemShortcutFactory.java index dfcc2f8224c..ce42ab6e9ba 100644 --- a/src/com/android/launcher3/popup/SystemShortcutFactory.java +++ b/src/com/android/launcher3/popup/SystemShortcutFactory.java @@ -41,6 +41,7 @@ public SystemShortcutFactory() { this(new SystemShortcut.AppInfo(), new SystemShortcut.Widgets(), new SystemShortcut.Install(), + new SystemShortcut.Uninstall(), new SystemShortcut.DismissPrediction()); } From 0917f878c4635967f4d2fc560d0d84ff8176bb5a Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Sun, 8 Mar 2020 22:05:18 +0530 Subject: [PATCH 02/29] Launcher3: Ensure no divider shown in preferences Signed-off-by: Pranav Vashi --- res/values/styles.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/res/values/styles.xml b/res/values/styles.xml index 80c791c5891..a3e3de8c772 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -132,6 +132,8 @@ + @*android:color/primary_dark_material_settings ?attr/workspaceTextColor @@ -86,12 +86,12 @@ #EA212121 102 #80000000 - #3C4043 - #5F6368 - #757575 + @*android:color/primary_dark_material_settings + @*android:color/secondary_material_settings + @*android:color/tertiary_material_settings @style/WidgetContainerTheme.Dark #FF464646 - #DD3C4043 + @*android:color/primary_dark_material_settings #FF80868B @android:color/white true @@ -106,7 +106,7 @@ - \ No newline at end of file + diff --git a/quickstep/src/com/android/quickstep/util/LayoutUtils.java b/quickstep/src/com/android/quickstep/util/LayoutUtils.java index 2e118b44dfd..a3bc2beac91 100644 --- a/quickstep/src/com/android/quickstep/util/LayoutUtils.java +++ b/quickstep/src/com/android/quickstep/util/LayoutUtils.java @@ -105,6 +105,8 @@ public static void calculateTaskSize(Context context, DeviceProfile dp, } float topIconMargin = res.getDimension(R.dimen.task_thumbnail_top_margin); + // Add extra spacing for the icon + title + topIconMargin += res.getDimension(R.dimen.task_thumbnail_icon_size); float paddingVert = res.getDimension(R.dimen.task_card_vert_space); // Note this should be same as dp.availableWidthPx and dp.availableHeightPx unless From ed0808feb4b23ea984ecb5f77bbf4e33c336d383 Mon Sep 17 00:00:00 2001 From: Gabriel de Oliveira Date: Thu, 11 Nov 2021 10:34:34 -0300 Subject: [PATCH 16/29] Fix misleading "Search apps" pt translation Fix the string "Apps de pesquisa" that roughly means "apps you can use to search", not the act searching an app as intended by the hint. Change-Id: I65d91a9c0c5de49a76a55e10ec5f6364091da77a --- res/values-pt/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index bb4834f69d0..243bab68928 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -34,7 +34,7 @@ "%1$d de largura por %2$d de altura" "Toque e mantenha pressionado para mover manualmente" "Adicionar automaticamente" - "Apps de pesquisa" + "Pesquisar apps" "Carregando apps…" "Nenhum app encontrado que corresponda a \"%1$s\"" "Pesquisar mais apps" From f1bed188f2a75c793cd7a3ad3c14bbc3440ff10b Mon Sep 17 00:00:00 2001 From: Amir Zaidi Date: Thu, 9 Jan 2020 19:40:28 +0100 Subject: [PATCH 17/29] Launcher3: Add AppInfo Bottom Sheet from Shade Launcher Shade: Rename ShortcutFactory to ShadeShortcutFactory Shade: Override AppInfoShortcut with BottomSheetShortcut Shade: Import bottom sheet class from Pie Shade: Fix ShadeShortcutFactory constructor Shade: Add testing entries to App Info Shade: Add real entries to App Info Shade: Implement parsing for app info Shade: Move all preference title strings to global strings file Shade: Set source to "Unknown" if it is empty Shade: Set icon pack to "None" by default Shade: Update app info bottom sheet to Q widgets bottom sheet Shade: Disable overscroll effect on bottom sheet preferences Shade: Update Version app info preference icon Shade: Reorder app info preference entries Change-Id: I34fe46944561723d3a47db92b3814e1deee80b5b Signed-off-by: Pranav Vashi --- 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 | 41 +++++ res/values/config.xml | 2 +- res/values/lineage_strings.xml | 12 ++ res/xml/app_info_preferences.xml | 54 +++++++ .../customization/InfoBottomSheet.java | 142 ++++++++++++++++++ .../customization/MetadataExtractor.java | 73 +++++++++ .../customization/ShadeShortcutFactory.java | 45 ++++++ 11 files changed, 413 insertions(+), 1 deletion(-) create mode 100644 res/drawable/ic_app_info_icon_pack.xml create mode 100644 res/drawable/ic_app_info_last_update.xml create mode 100644 res/drawable/ic_app_info_source.xml create mode 100644 res/drawable/ic_app_info_version.xml create mode 100644 res/layout/app_info_bottom_sheet.xml create mode 100644 res/xml/app_info_preferences.xml create mode 100644 src/com/android/launcher3/customization/InfoBottomSheet.java create mode 100644 src/com/android/launcher3/customization/MetadataExtractor.java create mode 100644 src/com/android/launcher3/customization/ShadeShortcutFactory.java diff --git a/res/drawable/ic_app_info_icon_pack.xml b/res/drawable/ic_app_info_icon_pack.xml new file mode 100644 index 00000000000..4a809b14ed0 --- /dev/null +++ b/res/drawable/ic_app_info_icon_pack.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/res/drawable/ic_app_info_last_update.xml b/res/drawable/ic_app_info_last_update.xml new file mode 100644 index 00000000000..bc51923d794 --- /dev/null +++ b/res/drawable/ic_app_info_last_update.xml @@ -0,0 +1,10 @@ + + + diff --git a/res/drawable/ic_app_info_source.xml b/res/drawable/ic_app_info_source.xml new file mode 100644 index 00000000000..2aafd6068d7 --- /dev/null +++ b/res/drawable/ic_app_info_source.xml @@ -0,0 +1,10 @@ + + + diff --git a/res/drawable/ic_app_info_version.xml b/res/drawable/ic_app_info_version.xml new file mode 100644 index 00000000000..e3fd7bdf7ac --- /dev/null +++ b/res/drawable/ic_app_info_version.xml @@ -0,0 +1,10 @@ + + + diff --git a/res/layout/app_info_bottom_sheet.xml b/res/layout/app_info_bottom_sheet.xml new file mode 100644 index 00000000000..fcfc7813f5f --- /dev/null +++ b/res/layout/app_info_bottom_sheet.xml @@ -0,0 +1,41 @@ + + + + + + + + + + \ No newline at end of file diff --git a/res/values/config.xml b/res/values/config.xml index b3e07e28f9c..56fd75ee6e1 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -69,7 +69,7 @@ - + com.android.launcher3.customization.ShadeShortcutFactory diff --git a/res/values/lineage_strings.xml b/res/values/lineage_strings.xml index f1e8fa7cca1..58d1448d820 100644 --- a/res/values/lineage_strings.xml +++ b/res/values/lineage_strings.xml @@ -64,4 +64,16 @@ Double tap to sleep Double tap on empty space for power-off + + + Swipe down to close app info. + %1$s (%2$d) + Loading... + Icon pack + None + Source + Unknown + Last update + Version + More diff --git a/res/xml/app_info_preferences.xml b/res/xml/app_info_preferences.xml new file mode 100644 index 00000000000..8af0e1ab989 --- /dev/null +++ b/res/xml/app_info_preferences.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + diff --git a/src/com/android/launcher3/customization/InfoBottomSheet.java b/src/com/android/launcher3/customization/InfoBottomSheet.java new file mode 100644 index 00000000000..050fe226cda --- /dev/null +++ b/src/com/android/launcher3/customization/InfoBottomSheet.java @@ -0,0 +1,142 @@ +package com.android.launcher3.customization; + +import android.app.Fragment; +import android.app.FragmentManager; +import android.content.ComponentName; +import android.content.Context; +import android.os.Bundle; +import androidx.preference.Preference; +import androidx.preference.PreferenceFragment; +import androidx.recyclerview.widget.RecyclerView; + +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.android.launcher3.ItemInfo; +import com.android.launcher3.Launcher; +import com.android.launcher3.R; +import com.android.launcher3.util.ComponentKey; +import com.android.launcher3.widget.WidgetsBottomSheet; + +public class InfoBottomSheet extends WidgetsBottomSheet { + private final FragmentManager mFragmentManager; + private View.OnClickListener mOnAppInfoClick; + + 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 setOnAppInfoClick(View.OnClickListener onclick) { + mOnAppInfoClick = onclick; + } + + @Override + public void populateAndShow(ItemInfo itemInfo) { + super.populateAndShow(itemInfo); + TextView title = findViewById(R.id.title); + title.setText(itemInfo.title); + + // Use a proxy so we can update the reference at runtime. + View.OnClickListener l = v -> mOnAppInfoClick.onClick(v); + + PrefsFragment fragment = + (PrefsFragment) mFragmentManager.findFragmentById(R.id.sheet_prefs); + fragment.loadForApp(itemInfo, l); + } + + @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 ComponentName mComponent; + private ComponentKey mKey; + private View.OnClickListener mOnMoreClick; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mContext = getActivity(); + } + + @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, final View.OnClickListener onMoreClick) { + mComponent = itemInfo.getTargetComponent(); + mKey = new ComponentKey(mComponent, itemInfo.user); + mOnMoreClick = onMoreClick; + + MetadataExtractor extractor = new MetadataExtractor(mContext, mComponent); + + Preference iconPack = findPreference(KEY_ICON_PACK); + iconPack.setOnPreferenceChangeListener(this); + iconPack.setSummary(R.string.app_info_icon_pack_none); + findPreference(KEY_SOURCE).setSummary(extractor.getSource()); + findPreference(KEY_LAST_UPDATE).setSummary(extractor.getLastUpdate()); + findPreference(KEY_VERSION).setSummary(mContext.getString( + R.string.app_info_version_value, + extractor.getVersionName(), + extractor.getVersionCode())); + findPreference(KEY_MORE).setOnPreferenceClickListener(this); + } + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + if (KEY_ICON_PACK.equals(preference.getKey())) { + // Reload in launcher. + } + return false; + } + + @Override + public boolean onPreferenceClick(Preference preference) { + if (KEY_MORE.equals(preference.getKey())) { + mOnMoreClick.onClick(getView()); + } + return false; + } + } +} diff --git a/src/com/android/launcher3/customization/MetadataExtractor.java b/src/com/android/launcher3/customization/MetadataExtractor.java new file mode 100644 index 00000000000..51c3260f455 --- /dev/null +++ b/src/com/android/launcher3/customization/MetadataExtractor.java @@ -0,0 +1,73 @@ +package com.android.launcher3.customization; + +import android.content.ComponentName; +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +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 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); + } 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_unknown); + } + 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; + } +} diff --git a/src/com/android/launcher3/customization/ShadeShortcutFactory.java b/src/com/android/launcher3/customization/ShadeShortcutFactory.java new file mode 100644 index 00000000000..aef8266ff23 --- /dev/null +++ b/src/com/android/launcher3/customization/ShadeShortcutFactory.java @@ -0,0 +1,45 @@ +package com.android.launcher3.customization; + +import android.content.Context; +import android.view.View; + +import com.android.launcher3.BaseDraggingActivity; +import com.android.launcher3.ItemInfo; +import com.android.launcher3.Launcher; +import com.android.launcher3.R; +import com.android.launcher3.popup.SystemShortcut; +import com.android.launcher3.popup.SystemShortcutFactory; + +@SuppressWarnings("unused") +public class ShadeShortcutFactory extends SystemShortcutFactory { + public ShadeShortcutFactory(Context context) { + super(new BottomSheetShortcut(), + new SystemShortcut.Widgets(), + new SystemShortcut.Install()); + } + + public static class BottomSheetShortcut extends SystemShortcut.AppInfo { + @Override + public View.OnClickListener getOnClickListener( + BaseDraggingActivity activity, ItemInfo itemInfo) { + Launcher launcher = (Launcher) activity; + final View.OnClickListener aiListener = super.getOnClickListener(launcher, itemInfo); + return new View.OnClickListener() { + private InfoBottomSheet cbs; + + @Override + public void onClick(View v) { + if (cbs == null) { + dismissTaskMenuView(launcher); + cbs = (InfoBottomSheet) launcher.getLayoutInflater().inflate( + R.layout.app_info_bottom_sheet, + launcher.getDragLayer(), + false); + cbs.setOnAppInfoClick(aiListener); + cbs.populateAndShow(itemInfo); + } + } + }; + } + } +} From c58fc350d3331ee88d0b2ae3a3a0c74146ad0367 Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Wed, 27 May 2020 20:08:52 +0530 Subject: [PATCH 18/29] Launcher3: Fix font family for App Info sheet Signed-off-by: Pranav Vashi --- res/layout/app_info_bottom_sheet.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/res/layout/app_info_bottom_sheet.xml b/res/layout/app_info_bottom_sheet.xml index fcfc7813f5f..f3dd4f79370 100644 --- a/res/layout/app_info_bottom_sheet.xml +++ b/res/layout/app_info_bottom_sheet.xml @@ -16,6 +16,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" + android:fontFamily="@*android:string/config_headlineFontFamily" android:textColor="?android:attr/textColorPrimary" android:textSize="24sp"/> @@ -25,7 +26,7 @@ android:gravity="center_horizontal" android:paddingTop="4dp" android:paddingBottom="16dp" - android:fontFamily="sans-serif" + android:fontFamily="@*android:string/config_bodyFontFamily" android:textColor="?android:attr/textColorTertiary" android:textSize="14sp" android:text="@string/app_info_subtext"/> From a01c617678a2b05232d0d4b75596e9e2201b1470 Mon Sep 17 00:00:00 2001 From: maxwen Date: Wed, 23 Oct 2019 01:33:17 +0200 Subject: [PATCH 19/29] Launcher3: remove extra space for hotseat Change-Id: I380f38c370e60453218db3d384014d04a1908348 Signed-off-by: Pranav Vashi --- res/values/dimens.xml | 2 +- src/com/android/launcher3/DeviceProfile.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/res/values/dimens.xml b/res/values/dimens.xml index d9b0f9a0b86..f64949fb35e 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -38,7 +38,7 @@ 4dp - 24dp + 20dp 0dp diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 4a240ffb99f..3bae41336d3 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -235,11 +235,11 @@ public DeviceProfile(Context context, InvariantDeviceProfile inv, // Note: This calculation was created after noticing a pattern in the design spec. int extraSpace = getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2 - verticalDragHandleSizePx; - hotseatBarSizePx += extraSpace; - hotseatBarBottomPaddingPx += extraSpace; + //hotseatBarSizePx += extraSpace; + //hotseatBarBottomPaddingPx += extraSpace; // Recalculate the available dimensions using the new hotseat size. - updateAvailableDimensions(dm, res); + //updateAvailableDimensions(dm, res); } if (originalIDP != null) { From d631b5caf763f1c53d096e5ae28d80dae26fa2db Mon Sep 17 00:00:00 2001 From: Chris Crump Date: Tue, 26 Nov 2019 04:17:17 -0500 Subject: [PATCH 20/29] Launcher3: Consider extra header content as visible elements Invoking extra header content such as floating header (predictions view) causes the overview panel to show under recent task. The search bar doesn't show in this case since it expects to scrim based on all apps content. Since predictions appear in this area, set the search bar to show as well, otherwise we get empty space above the predictions view. Change-Id: I7eb68f4bc2efdc383f0ced5ff4a0ad13e9bed528 Signed-off-by: Pranav Vashi --- .../launcher3/allapps/search/AppsSearchContainerLayout.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java index bcfdf916bbc..627b2225fd5 100644 --- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java +++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java @@ -20,6 +20,7 @@ import static android.view.View.MeasureSpec.makeMeasureSpec; import static com.android.launcher3.LauncherState.ALL_APPS_HEADER; +import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA; import static com.android.launcher3.Utilities.prefixTextWithIcon; import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTOR; @@ -233,6 +234,9 @@ public float getScrollRangeDelta(Rect insets) { @Override public void setContentVisibility(int visibleElements, PropertySetter setter, Interpolator interpolator) { - setter.setViewAlpha(this, (visibleElements & ALL_APPS_HEADER) != 0 ? 1 : 0, interpolator); + boolean hasAllAppsHeaderExtra = mAppsView != null + && mAppsView.getFloatingHeaderView().hasVisibleContent(); + int headerElement = hasAllAppsHeaderExtra ? ALL_APPS_HEADER_EXTRA : ALL_APPS_HEADER; + setter.setViewAlpha(this, (visibleElements & headerElement) != 0 ? 1 : 0, interpolator); } } From 6777083366dbe12fea64cd0477351c87de74018b Mon Sep 17 00:00:00 2001 From: DennySPB Date: Fri, 6 Dec 2019 15:37:40 +0300 Subject: [PATCH 21/29] Increase all apps top padding to avoid visual glitch in recents Signed-off-by: DennySPB Change-Id: Ie7c995318b4fdf09c1de3220e12aeae2225cefbc Signed-off-by: Pranav Vashi --- res/values/dimens.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/dimens.xml b/res/values/dimens.xml index f64949fb35e..1a53832d334 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -79,7 +79,7 @@ 475dp 50dp 2dp - 36dp + 60dp 16dp 20dp 12dp From 4f319d9aebf04a267ae04352d1c4ffc7f79e3956 Mon Sep 17 00:00:00 2001 From: SirRGB Date: Wed, 24 May 2023 18:44:48 +0200 Subject: [PATCH 22/29] [DNM] disable top shadow on statusbar * looks horrible on oled, but could not find any commit making it optional for A10 trebuchet. --- .../android/launcher3/graphics/WorkspaceAndHotseatScrim.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java b/src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java index 15ff207bd1c..cdd31f86dbc 100644 --- a/src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java +++ b/src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java @@ -255,7 +255,7 @@ private void reapplySysUiAlpha() { } private void reapplySysUiAlphaNoInvalidate() { - float factor = mSysUiProgress * mSysUiAnimMultiplier; + float factor = 0.0f; mBottomMaskPaint.setAlpha(Math.round(MAX_HOTSEAT_SCRIM_ALPHA * factor)); if (mTopScrim != null) { mTopScrim.setAlpha(Math.round(255 * factor)); From ce83c37419d2d5bca3e7a865cc267e24ed621ebd Mon Sep 17 00:00:00 2001 From: Amir Zaidi Date: Wed, 5 Jun 2019 16:06:39 +0200 Subject: [PATCH 23/29] Launcher3: Load backported notification icon from correct package Conflicts: src/com/android/launcher3/notification/NotificationInfo.java --- .../launcher3/notification/NotificationInfo.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/notification/NotificationInfo.java b/src/com/android/launcher3/notification/NotificationInfo.java index e5525b2faa7..c70f7cae5ea 100644 --- a/src/com/android/launcher3/notification/NotificationInfo.java +++ b/src/com/android/launcher3/notification/NotificationInfo.java @@ -20,6 +20,8 @@ import android.app.Notification; import android.app.PendingIntent; import android.content.Context; +import android.content.pm.PackageManager; +import android.content.res.Resources; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; @@ -76,9 +78,13 @@ public NotificationInfo(Context context, StatusBarNotification statusBarNotifica mIconColor = statusBarNotification.getNotification().color; mIsIconLarge = false; } else { - // Use the large icon. - mIconDrawable = icon.loadDrawable(context); - mIsIconLarge = true; + try { + String pkg = statusBarNotification.getPackageName(); + Resources res = context.getPackageManager().getResourcesForApplication(pkg); + mIconDrawable = res.getDrawable(notification.icon); + } catch (PackageManager.NameNotFoundException | Resources.NotFoundException e) { + e.printStackTrace(); + } } if (mIconDrawable == null) { mIconDrawable = new BitmapDrawable(context.getResources(), LauncherAppState From dd6bb24bb9199f765023ef401e3dd7d418f49f66 Mon Sep 17 00:00:00 2001 From: Amir Zaidi Date: Tue, 13 Aug 2019 17:56:04 +0200 Subject: [PATCH 24/29] Launcher3: Keep spring adaptive icon hidden until drag starts --- src/com/android/launcher3/dragndrop/DragView.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java index f66d07e3d8e..074238d4cdd 100644 --- a/src/com/android/launcher3/dragndrop/DragView.java +++ b/src/com/android/launcher3/dragndrop/DragView.java @@ -109,6 +109,7 @@ public class DragView extends View implements LauncherStateManager.StateListener private Path mScaledMaskPath; private Drawable mBadge; private ColorMatrixColorFilter mBaseFilter; + private boolean mShowSpringIcon; /** * Construct the drag view. @@ -397,7 +398,7 @@ protected void onDraw(Canvas canvas) { } } - if (mScaledMaskPath != null) { + if (mScaledMaskPath != null && mShowSpringIcon) { int cnt = canvas.save(); canvas.clipPath(mScaledMaskPath); mBgSpringDrawable.draw(canvas); @@ -516,6 +517,9 @@ public void cancelAnimation() { public void move(int touchX, int touchY) { if (touchX > 0 && touchY > 0 && mLastTouchX > 0 && mLastTouchY > 0 && mScaledMaskPath != null) { + if (mLastTouchX != touchX || mLastTouchY != touchY) { + mShowSpringIcon = true; + } mTranslateX.animateToPos(mLastTouchX - touchX); mTranslateY.animateToPos(mLastTouchY - touchY); } From 65de34f872ee325ef469ef46986d30d528802c8c Mon Sep 17 00:00:00 2001 From: SirRGB Date: Sun, 4 Jun 2023 02:21:25 +0200 Subject: [PATCH 25/29] use system fonts --- .../com/android/launcher3/appprediction/AppsDividerView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/AppsDividerView.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/AppsDividerView.java index 425fb139906..be1b8c112cc 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/AppsDividerView.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/AppsDividerView.java @@ -206,7 +206,7 @@ protected void onDraw(Canvas canvas) { private Layout getAllAppsLabelLayout() { if (mAllAppsLabelLayout == null) { mPaint.setAntiAlias(true); - mPaint.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL)); + mPaint.setTypeface(Typeface.create("@*android:string/config_headlineFontFamilyMedium", Typeface.NORMAL)); mPaint.setTextSize( getResources().getDimensionPixelSize(R.dimen.all_apps_label_text_size)); From 2894ae4986ff375c7ce5e86282dbdd2178a99041 Mon Sep 17 00:00:00 2001 From: maxwen Date: Thu, 9 Jan 2020 23:46:55 +0100 Subject: [PATCH 26/29] Launcher3: add dark primary support Change-Id: I2368b690571517dfb7f331832c9f52dcc8ac8531 Signed-off-by: RJ Trujillo --- res/drawable/bg_all_apps_searchbox.xml | 4 ++-- res/values-night-v26/colors.xml | 24 +++++++++++++++++++++ res/values-night-v26/styles.xml | 30 +++++++++++++++++++++++++- res/values-v26/styles.xml | 4 ---- res/values/colors.xml | 2 ++ 5 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 res/values-night-v26/colors.xml diff --git a/res/drawable/bg_all_apps_searchbox.xml b/res/drawable/bg_all_apps_searchbox.xml index ac1e991e2f6..ecfa9dc888e 100644 --- a/res/drawable/bg_all_apps_searchbox.xml +++ b/res/drawable/bg_all_apps_searchbox.xml @@ -14,6 +14,6 @@ limitations under the License. --> - + - \ No newline at end of file + diff --git a/res/values-night-v26/colors.xml b/res/values-night-v26/colors.xml new file mode 100644 index 00000000000..3ed1b1878b1 --- /dev/null +++ b/res/values-night-v26/colors.xml @@ -0,0 +1,24 @@ + + + + @*android:color/primary_dark_device_default_settings + @*android:color/primary_device_default_settings + @color/omni_color1 + diff --git a/res/values-night-v26/styles.xml b/res/values-night-v26/styles.xml index 510e1f4cd01..de89fbfafcc 100644 --- a/res/values-night-v26/styles.xml +++ b/res/values-night-v26/styles.xml @@ -23,4 +23,32 @@ @style/WidgetContainerTheme.Dark - \ No newline at end of file + + + + diff --git a/res/values-v26/styles.xml b/res/values-v26/styles.xml index 8fb408b5842..2fa4fbbe435 100644 --- a/res/values-v26/styles.xml +++ b/res/values-v26/styles.xml @@ -22,9 +22,5 @@ #E8EAED ?android:attr/textColorSecondary - diff --git a/res/values/colors.xml b/res/values/colors.xml index 3c8fe1e2536..0ee15f01539 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -35,6 +35,8 @@ #E0E0E0 + @android:color/white + #E5E5E5 #9AA0A6 From 14d48fc480fa13478ccca6c8d4fa5c2599ec662e Mon Sep 17 00:00:00 2001 From: maxwen Date: Mon, 13 Jan 2020 01:34:11 +0100 Subject: [PATCH 27/29] Launcher3: fix dark primary folder bg color Change-Id: I0355a5bdb21773783f965d9a5eae1ffee32d4206 Signed-off-by: RJ Trujillo --- res/values-night-v26/styles.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/res/values-night-v26/styles.xml b/res/values-night-v26/styles.xml index de89fbfafcc..d033ca5af85 100644 --- a/res/values-night-v26/styles.xml +++ b/res/values-night-v26/styles.xml @@ -42,7 +42,7 @@ #80000000 @color/omni_color2 @color/omni_color1 - #757575 + @color/omni_color1 @style/WidgetContainerTheme.Dark #FF464646 @color/omni_color2 @@ -51,4 +51,9 @@ true #99FFFFFF + + From 7a7f1db63bd4294f397215fae534cb4fbfb549fb Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Thu, 1 Jun 2023 18:12:44 -0700 Subject: [PATCH 28/29] Fix permission issue in legacy shortcut When building legacy shortcut, Launcher calls PackageManager#resolveActivity to retrieve necessary permission to launch the intent. However, when the source app wraps an arbitrary intent within Intent#createChooser, the existing logic will fail because launching Chooser doesn't require additional permission. This CL fixes the security vulnerability by performing the permission check against the intent that is wrapped within. Bug: 270152142 Test: manual (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:c53818a16b4322a823497726ac7e7a44501b4442) Merged-In: If35344c08975e35085c7c2b9b814a3c457a144b0 Change-Id: If35344c08975e35085c7c2b9b814a3c457a144b0 --- .../android/launcher3/util/PackageManagerHelper.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/com/android/launcher3/util/PackageManagerHelper.java b/src/com/android/launcher3/util/PackageManagerHelper.java index 78d1d3ca8fe..f263331f8f2 100644 --- a/src/com/android/launcher3/util/PackageManagerHelper.java +++ b/src/com/android/launcher3/util/PackageManagerHelper.java @@ -112,6 +112,18 @@ public static boolean isAppSuspended(ApplicationInfo info) { * any permissions */ public boolean hasPermissionForActivity(Intent intent, String srcPackage) { + // b/270152142 + if (Intent.ACTION_CHOOSER.equals(intent.getAction())) { + final Bundle extras = intent.getExtras(); + if (extras == null) { + return true; + } + // If given intent is ACTION_CHOOSER, verify srcPackage has permission over EXTRA_INTENT + intent = (Intent) extras.getParcelable(Intent.EXTRA_INTENT); + if (intent == null) { + return true; + } + } ResolveInfo target = mPm.resolveActivity(intent, 0); if (target == null) { // Not a valid target From af2fcd606fcd6eb3d9818c2ac69faabc8d3ffb2a Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Tue, 12 Sep 2023 22:37:16 +0000 Subject: [PATCH 29/29] Fix permission bypass in legacy shortcut Intent created for Chooser should not be allowed in legacy shortcuts since it doesn't make sense for user to tap on a shortcut in homescreen to share, the expected share flow started from ShareSheet. Bug: 295334906, 295045199 Test: manual (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b7b192bd7f24a2aa7d6881ee949657c9760c0305) Merged-In: I8d0cbccdc31bd4cb927830e5ecf841147400fdfa Change-Id: I8d0cbccdc31bd4cb927830e5ecf841147400fdfa --- .../android/launcher3/util/PackageManagerHelper.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/com/android/launcher3/util/PackageManagerHelper.java b/src/com/android/launcher3/util/PackageManagerHelper.java index f263331f8f2..1ca28f82dc7 100644 --- a/src/com/android/launcher3/util/PackageManagerHelper.java +++ b/src/com/android/launcher3/util/PackageManagerHelper.java @@ -114,15 +114,8 @@ public static boolean isAppSuspended(ApplicationInfo info) { public boolean hasPermissionForActivity(Intent intent, String srcPackage) { // b/270152142 if (Intent.ACTION_CHOOSER.equals(intent.getAction())) { - final Bundle extras = intent.getExtras(); - if (extras == null) { - return true; - } - // If given intent is ACTION_CHOOSER, verify srcPackage has permission over EXTRA_INTENT - intent = (Intent) extras.getParcelable(Intent.EXTRA_INTENT); - if (intent == null) { - return true; - } + // Chooser shortcuts is not a valid target + return false; } ResolveInfo target = mPm.resolveActivity(intent, 0); if (target == null) {