From bde3c8b6bdc1e56b67e9e002c196cff72fa1de07 Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Tue, 15 Mar 2022 13:35:06 -0700 Subject: [PATCH 1/7] Move activity starting logic into new ActivityContext extension. This code branch is needed for taskbar, so needs to be moved from the activity classes to an interface that both can share. Test: Manual Bug: 216683257 Change-Id: I042c0dcf08207d94847b9d7a1783acc14613ef5f --- src/com/android/launcher3/BaseActivity.java | 26 +-- .../launcher3/BaseDraggingActivity.java | 130 +---------- src/com/android/launcher3/Launcher.java | 2 +- .../android/launcher3/views/AppLauncher.java | 213 ++++++++++++++++++ 4 files changed, 225 insertions(+), 146 deletions(-) create mode 100644 src/com/android/launcher3/views/AppLauncher.java diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java index 42f70536d4..73d3e3301c 100644 --- a/src/com/android/launcher3/BaseActivity.java +++ b/src/com/android/launcher3/BaseActivity.java @@ -16,7 +16,6 @@ package com.android.launcher3; -import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_WIDGETS; import static com.android.launcher3.util.SystemUiController.UI_STATE_FULLSCREEN_TASK; import static java.lang.annotation.RetentionPolicy.SOURCE; @@ -25,12 +24,7 @@ import android.app.Activity; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; -import android.content.pm.LauncherApps; import android.content.res.Configuration; -import android.graphics.Rect; -import android.os.Bundle; -import android.os.UserHandle; -import android.util.Log; import androidx.annotation.IntDef; @@ -39,7 +33,7 @@ import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.util.SystemUiController; import com.android.launcher3.util.ViewCache; -import com.android.launcher3.views.ActivityContext; +import com.android.launcher3.views.AppLauncher; import com.android.launcher3.views.ScrimView; import java.io.PrintWriter; @@ -50,7 +44,7 @@ import java.util.List; /** * Launcher BaseActivity */ -public abstract class BaseActivity extends Activity implements ActivityContext, +public abstract class BaseActivity extends Activity implements AppLauncher, DeviceProfileListenable { private static final String TAG = "BaseActivity"; @@ -314,22 +308,6 @@ public abstract class BaseActivity extends Activity implements ActivityContext, writer.println(prefix + "mForceInvisible: " + mForceInvisible); } - /** - * A wrapper around the platform method with Launcher specific checks - */ - public void startShortcut(String packageName, String id, Rect sourceBounds, - Bundle startActivityOptions, UserHandle user) { - if (GO_DISABLE_WIDGETS) { - return; - } - try { - getSystemService(LauncherApps.class).startShortcut(packageName, id, sourceBounds, - startActivityOptions, user); - } catch (SecurityException | IllegalStateException e) { - Log.e(TAG, "Failed to start shortcut", e); - } - } - public static T fromContext(Context context) { if (context instanceof BaseActivity) { return (T) context; diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index f53d01e183..3af43c021b 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -16,50 +16,33 @@ package com.android.launcher3; -import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP; import static com.android.launcher3.util.DisplayController.CHANGE_ROTATION; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; -import android.app.ActivityOptions; import android.app.WallpaperColors; import android.app.WallpaperManager; import android.app.WallpaperManager.OnColorsChangedListener; -import android.content.ActivityNotFoundException; import android.content.Context; -import android.content.Intent; -import android.content.pm.LauncherApps; import android.content.res.Configuration; import android.graphics.Point; import android.graphics.Rect; -import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.os.Process; -import android.os.StrictMode; -import android.os.UserHandle; -import android.util.Log; import android.view.ActionMode; import android.view.Display; import android.view.View; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.allapps.ActivityAllAppsContainerView; import com.android.launcher3.allapps.search.DefaultSearchAdapterProvider; import com.android.launcher3.allapps.search.SearchAdapterProvider; -import com.android.launcher3.logging.InstanceId; -import com.android.launcher3.logging.InstanceIdSequence; -import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.model.data.ItemInfo; -import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.touch.ItemClickHandler; import com.android.launcher3.util.ActivityOptionsWrapper; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.DisplayController.DisplayInfoChangeListener; import com.android.launcher3.util.DisplayController.Info; -import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.util.RunnableList; import com.android.launcher3.util.Themes; import com.android.launcher3.util.TraceHelper; @@ -162,112 +145,12 @@ public abstract class BaseDraggingActivity extends BaseActivity // no-op } + @Override @NonNull public ActivityOptionsWrapper getActivityLaunchOptions(View v, @Nullable ItemInfo item) { - int left = 0, top = 0; - int width = v.getMeasuredWidth(), height = v.getMeasuredHeight(); - if (v instanceof BubbleTextView) { - // Launch from center of icon, not entire view - Drawable icon = ((BubbleTextView) v).getIcon(); - if (icon != null) { - Rect bounds = icon.getBounds(); - left = (width - bounds.width()) / 2; - top = v.getPaddingTop(); - width = bounds.width(); - height = bounds.height(); - } - } - ActivityOptions options = - ActivityOptions.makeClipRevealAnimation(v, left, top, width, height); - - options.setLaunchDisplayId( - (v != null && v.getDisplay() != null) ? v.getDisplay().getDisplayId() - : Display.DEFAULT_DISPLAY); - RunnableList callback = new RunnableList(); - addOnResumeCallback(callback::executeAllAndDestroy); - return new ActivityOptionsWrapper(options, callback); - } - - public boolean startActivitySafely(View v, Intent intent, @Nullable ItemInfo item) { - if (mIsSafeModeEnabled && !PackageManagerHelper.isSystemApp(this, intent)) { - Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show(); - return false; - } - - Bundle optsBundle = (v != null) ? getActivityLaunchOptions(v, item).toBundle() : null; - UserHandle user = item == null ? null : item.user; - - // Prepare intent - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - if (v != null) { - intent.setSourceBounds(Utilities.getViewBounds(v)); - } - try { - boolean isShortcut = (item instanceof WorkspaceItemInfo) - && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT - || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) - && !((WorkspaceItemInfo) item).isPromise(); - if (isShortcut) { - // Shortcuts need some special checks due to legacy reasons. - startShortcutIntentSafely(intent, optsBundle, item); - } else if (user == null || user.equals(Process.myUserHandle())) { - // Could be launching some bookkeeping activity - startActivity(intent, optsBundle); - } else { - getSystemService(LauncherApps.class).startMainActivity( - intent.getComponent(), user, intent.getSourceBounds(), optsBundle); - } - if (item != null) { - InstanceId instanceId = new InstanceIdSequence().newInstanceId(); - logAppLaunch(getStatsLogManager(), item, instanceId); - } - return true; - } catch (NullPointerException | ActivityNotFoundException | SecurityException e) { - Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); - Log.e(TAG, "Unable to launch. tag=" + item + " intent=" + intent, e); - } - return false; - } - - /** - * Creates and logs a new app launch event. - */ - public void logAppLaunch(StatsLogManager statsLogManager, ItemInfo info, - InstanceId instanceId) { - statsLogManager.logger().withItemInfo(info).withInstanceId(instanceId) - .log(LAUNCHER_APP_LAUNCH_TAP); - } - - private void startShortcutIntentSafely(Intent intent, Bundle optsBundle, ItemInfo info) { - try { - StrictMode.VmPolicy oldPolicy = StrictMode.getVmPolicy(); - try { - // Temporarily disable deathPenalty on all default checks. For eg, shortcuts - // containing file Uri's would cause a crash as penaltyDeathOnFileUriExposure - // is enabled by default on NYC. - StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll() - .penaltyLog().build()); - - if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) { - String id = ((WorkspaceItemInfo) info).getDeepShortcutId(); - String packageName = intent.getPackage(); - startShortcut(packageName, id, intent.getSourceBounds(), optsBundle, info.user); - } else { - // Could be launching some bookkeeping activity - startActivity(intent, optsBundle); - } - } finally { - StrictMode.setVmPolicy(oldPolicy); - } - } catch (SecurityException e) { - if (!onErrorStartingShortcut(intent, info)) { - throw e; - } - } - } - - protected boolean onErrorStartingShortcut(Intent intent, ItemInfo info) { - return false; + ActivityOptionsWrapper wrapper = super.getActivityLaunchOptions(v, item); + addOnResumeCallback(wrapper.onEndCallback::executeAllAndDestroy); + return wrapper; } @Override @@ -337,4 +220,9 @@ public abstract class BaseDraggingActivity extends BaseActivity ActivityAllAppsContainerView allApps) { return new DefaultSearchAdapterProvider(this); } + + @Override + public boolean isAppBlockedForSafeMode() { + return mIsSafeModeEnabled; + } } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 5c406bd284..2f9b563073 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2065,7 +2065,7 @@ public class Launcher extends StatefulActivity implements Launche @TargetApi(Build.VERSION_CODES.M) @Override - protected boolean onErrorStartingShortcut(Intent intent, ItemInfo info) { + public boolean onErrorStartingShortcut(Intent intent, ItemInfo info) { // Due to legacy reasons, direct call shortcuts require Launchers to have the // corresponding permission. Show the appropriate permission prompt if that // is the case. diff --git a/src/com/android/launcher3/views/AppLauncher.java b/src/com/android/launcher3/views/AppLauncher.java new file mode 100644 index 0000000000..19e66abd78 --- /dev/null +++ b/src/com/android/launcher3/views/AppLauncher.java @@ -0,0 +1,213 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.launcher3.views; + +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP; +import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_WIDGETS; + +import android.app.ActivityOptions; +import android.content.ActivityNotFoundException; +import android.content.Context; +import android.content.Intent; +import android.content.pm.LauncherApps; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.os.Process; +import android.os.StrictMode; +import android.os.UserHandle; +import android.util.Log; +import android.view.Display; +import android.view.View; +import android.widget.Toast; + +import androidx.annotation.Nullable; + +import com.android.launcher3.BubbleTextView; +import com.android.launcher3.LauncherSettings; +import com.android.launcher3.R; +import com.android.launcher3.Utilities; +import com.android.launcher3.logging.InstanceId; +import com.android.launcher3.logging.InstanceIdSequence; +import com.android.launcher3.logging.StatsLogManager; +import com.android.launcher3.model.data.ItemInfo; +import com.android.launcher3.model.data.WorkspaceItemInfo; +import com.android.launcher3.util.ActivityOptionsWrapper; +import com.android.launcher3.util.PackageManagerHelper; +import com.android.launcher3.util.RunnableList; + +/** An {@link ActivityContext} that can also launch app activities and shortcuts safely. */ +public interface AppLauncher extends ActivityContext { + + String TAG = "AppLauncher"; + + /** + * Safely starts an activity. + * + * @param v View starting the activity. + * @param intent Base intent being launched. + * @param item Item associated with the view. + * @return {@code true} if the activity starts successfully. + */ + default boolean startActivitySafely( + View v, Intent intent, @Nullable ItemInfo item) { + + Context context = (Context) this; + if (isAppBlockedForSafeMode() && !PackageManagerHelper.isSystemApp(context, intent)) { + Toast.makeText(context, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show(); + return false; + } + + Bundle optsBundle = (v != null) ? getActivityLaunchOptions(v, item).toBundle() : null; + UserHandle user = item == null ? null : item.user; + + // Prepare intent + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + if (v != null) { + intent.setSourceBounds(Utilities.getViewBounds(v)); + } + try { + boolean isShortcut = (item instanceof WorkspaceItemInfo) + && (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT + || item.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) + && !((WorkspaceItemInfo) item).isPromise(); + if (isShortcut) { + // Shortcuts need some special checks due to legacy reasons. + startShortcutIntentSafely(intent, optsBundle, item); + } else if (user == null || user.equals(Process.myUserHandle())) { + // Could be launching some bookkeeping activity + context.startActivity(intent, optsBundle); + } else { + context.getSystemService(LauncherApps.class).startMainActivity( + intent.getComponent(), user, intent.getSourceBounds(), optsBundle); + } + if (item != null) { + InstanceId instanceId = new InstanceIdSequence().newInstanceId(); + logAppLaunch(getStatsLogManager(), item, instanceId); + } + return true; + } catch (NullPointerException | ActivityNotFoundException | SecurityException e) { + Toast.makeText(context, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); + Log.e(TAG, "Unable to launch. tag=" + item + " intent=" + intent, e); + } + return false; + } + + /** Returns {@code true} if an app launch is blocked due to safe mode. */ + default boolean isAppBlockedForSafeMode() { + return false; + } + + /** + * Creates and logs a new app launch event. + */ + default void logAppLaunch(StatsLogManager statsLogManager, ItemInfo info, + InstanceId instanceId) { + statsLogManager.logger().withItemInfo(info).withInstanceId(instanceId) + .log(LAUNCHER_APP_LAUNCH_TAP); + } + + /** + * Returns launch options for an Activity. + * + * @param v View initiating a launch. + * @param item Item associated with the view. + */ + default ActivityOptionsWrapper getActivityLaunchOptions(View v, @Nullable ItemInfo item) { + int left = 0, top = 0; + int width = v.getMeasuredWidth(), height = v.getMeasuredHeight(); + if (v instanceof BubbleTextView) { + // Launch from center of icon, not entire view + Drawable icon = ((BubbleTextView) v).getIcon(); + if (icon != null) { + Rect bounds = icon.getBounds(); + left = (width - bounds.width()) / 2; + top = v.getPaddingTop(); + width = bounds.width(); + height = bounds.height(); + } + } + ActivityOptions options = + ActivityOptions.makeClipRevealAnimation(v, left, top, width, height); + + options.setLaunchDisplayId( + (v != null && v.getDisplay() != null) ? v.getDisplay().getDisplayId() + : Display.DEFAULT_DISPLAY); + RunnableList callback = new RunnableList(); + return new ActivityOptionsWrapper(options, callback); + } + + /** + * Safely launches an intent for a shortcut. + * + * @param intent Intent to start. + * @param optsBundle Optional launch arguments. + * @param info Shortcut information. + */ + default void startShortcutIntentSafely(Intent intent, Bundle optsBundle, ItemInfo info) { + try { + StrictMode.VmPolicy oldPolicy = StrictMode.getVmPolicy(); + try { + // Temporarily disable deathPenalty on all default checks. For eg, shortcuts + // containing file Uri's would cause a crash as penaltyDeathOnFileUriExposure + // is enabled by default on NYC. + StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll() + .penaltyLog().build()); + + if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) { + String id = ((WorkspaceItemInfo) info).getDeepShortcutId(); + String packageName = intent.getPackage(); + startShortcut(packageName, id, intent.getSourceBounds(), optsBundle, info.user); + } else { + // Could be launching some bookkeeping activity + ((Context) this).startActivity(intent, optsBundle); + } + } finally { + StrictMode.setVmPolicy(oldPolicy); + } + } catch (SecurityException e) { + if (!onErrorStartingShortcut(intent, info)) { + throw e; + } + } + } + + /** + * A wrapper around the platform method with Launcher specific checks. + */ + default void startShortcut(String packageName, String id, Rect sourceBounds, + Bundle startActivityOptions, UserHandle user) { + if (GO_DISABLE_WIDGETS) { + return; + } + try { + ((Context) this).getSystemService(LauncherApps.class).startShortcut(packageName, id, + sourceBounds, startActivityOptions, user); + } catch (SecurityException | IllegalStateException e) { + Log.e(TAG, "Failed to start shortcut", e); + } + } + + /** + * Invoked when a shortcut fails to launch. + * @param intent Shortcut intent that failed to start. + * @param info Shortcut information. + * @return {@code true} if the error is handled by this callback. + */ + default boolean onErrorStartingShortcut(Intent intent, ItemInfo info) { + return false; + } +} From 487a62c361eaf1aba096e7e9780f303537ecb9ae Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Thu, 17 Mar 2022 02:59:04 +0000 Subject: [PATCH 2/7] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I25ea0d6596cffa1269137572a2fe565da433926b --- go/quickstep/res/values-bn/strings.xml | 2 +- go/quickstep/res/values-gu/strings.xml | 2 +- go/quickstep/res/values-kk/strings.xml | 2 +- go/quickstep/res/values-ml/strings.xml | 2 +- go/quickstep/res/values-mn/strings.xml | 2 +- go/quickstep/res/values-ms/strings.xml | 2 +- go/quickstep/res/values-ta/strings.xml | 2 +- go/quickstep/res/values-zu/strings.xml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go/quickstep/res/values-bn/strings.xml b/go/quickstep/res/values-bn/strings.xml index 4fb714da7a..5485d6bbf5 100644 --- a/go/quickstep/res/values-bn/strings.xml +++ b/go/quickstep/res/values-bn/strings.xml @@ -4,7 +4,7 @@ "অ্যাপ শেয়ার করুন" "শুনুন" "অনুবাদ করুন" - "লেন্স" + "Lens" "বুঝেছি" "বাতিল করুন" "সেটিংস" diff --git a/go/quickstep/res/values-gu/strings.xml b/go/quickstep/res/values-gu/strings.xml index 7c627e18f8..9cd1101e7c 100644 --- a/go/quickstep/res/values-gu/strings.xml +++ b/go/quickstep/res/values-gu/strings.xml @@ -4,7 +4,7 @@ "ઍપ શેર કરો" "સાંભળો" "અનુવાદ કરો" - "લેન્સ" + "Lens" "સમજાઈ ગયું" "રદ કરો" "સેટિંગ" diff --git a/go/quickstep/res/values-kk/strings.xml b/go/quickstep/res/values-kk/strings.xml index b68ab3e86b..9720e2ab0a 100644 --- a/go/quickstep/res/values-kk/strings.xml +++ b/go/quickstep/res/values-kk/strings.xml @@ -4,7 +4,7 @@ "Қолданбаны бөлісу" "Тыңдау" "Аудару" - "Объектив" + "Lens" "ТҮСІНІКТІ" "БАС ТАРТУ" "ПАРАМЕТРЛЕР" diff --git a/go/quickstep/res/values-ml/strings.xml b/go/quickstep/res/values-ml/strings.xml index 04e8b0aa41..d34a5f1b3f 100644 --- a/go/quickstep/res/values-ml/strings.xml +++ b/go/quickstep/res/values-ml/strings.xml @@ -4,7 +4,7 @@ "ആപ്പ് പങ്കിടുക" "കേൾക്കുക" "വിവർത്തനം ചെയ്യുക" - "ലെൻസ്" + "Lens" "മനസ്സിലായി" "റദ്ദാക്കുക" "ക്രമീകരണം" diff --git a/go/quickstep/res/values-mn/strings.xml b/go/quickstep/res/values-mn/strings.xml index cf20677db6..d1144ee648 100644 --- a/go/quickstep/res/values-mn/strings.xml +++ b/go/quickstep/res/values-mn/strings.xml @@ -4,7 +4,7 @@ "Аппыг хуваалцах" "Сонсох" "Орчуулах" - "Дуран" + "Lens" "ОЙЛГОЛОО" "ЦУЦЛАХ" "ТОХИРГОО" diff --git a/go/quickstep/res/values-ms/strings.xml b/go/quickstep/res/values-ms/strings.xml index 8169256bfb..9ecbe99133 100644 --- a/go/quickstep/res/values-ms/strings.xml +++ b/go/quickstep/res/values-ms/strings.xml @@ -4,7 +4,7 @@ "Kongsi Apl" "Dengar" "Terjemah" - "Kanta" + "Lens" "OK" "BATAL" "TETAPAN" diff --git a/go/quickstep/res/values-ta/strings.xml b/go/quickstep/res/values-ta/strings.xml index 896c7c6e8c..89848d5213 100644 --- a/go/quickstep/res/values-ta/strings.xml +++ b/go/quickstep/res/values-ta/strings.xml @@ -4,7 +4,7 @@ "ஆப்ஸைப் பகிருங்கள்" "கேளுங்கள்" "மொழிபெயர்" - "லென்ஸ்" + "Lens" "சரி" "ரத்துசெய்" "அமைப்புகள்" diff --git a/go/quickstep/res/values-zu/strings.xml b/go/quickstep/res/values-zu/strings.xml index 64b163549f..20b7894a1f 100644 --- a/go/quickstep/res/values-zu/strings.xml +++ b/go/quickstep/res/values-zu/strings.xml @@ -4,7 +4,7 @@ "Yabelana nge-App" "Lalela" "Humusha" - "Ilensi" + "Lens" "NGIYITHOLILE" "KHANSELA" "AMASETHINGI" From 7933df7269a1152630f2d7cca591e5ce204f736b Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Thu, 17 Mar 2022 02:59:43 +0000 Subject: [PATCH 3/7] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I480f37dd715c29100722f29e601013255513fb28 --- res/values-ar/strings.xml | 6 +++--- res/values-it/strings.xml | 6 +++--- res/values-pt-rPT/strings.xml | 6 +++--- res/values-ru/strings.xml | 4 ++-- res/values-te/strings.xml | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index 8571d46711..e420d87532 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -40,19 +40,19 @@ "يمكنك النقر على الأداة مع الاستمرار لتحريكها على الشاشة الرئيسية." "إضافة إلى الشاشة الرئيسية" "تمت إضافة الأداة %1$s إلى الشاشة الرئيسية." - "{count,plural, =1{أداة واحدة}zero{# أداة}two{أداتان}few{# أدوات}many{# أداة}other{# أداة}}" + "{count,plural, =1{تطبيق مصغّر واحد}zero{# تطبيق مصغّر}two{تطبيقان مصغّران}few{# تطبيقات مصغّرة}many{# تطبيقًا مصغّرًا}other{# تطبيق مصغّر}}" "{count,plural, =1{اختصار واحد}zero{# اختصار}two{اختصاران}few{# اختصارات}many{# اختصارًا}other{# اختصار}}" "%1$s، %2$s" "الأدوات" "بحث" "محو النص من مربّع البحث" "الأدوات والاختصارات غير متاحة." - "لم يتم العثور على أدوات أو اختصارات." + "لم يتم العثور على تطبيقات مصغّرة أو اختصارات." "الأدوات الشخصية" "أدوات العمل" "المحادثات" "معلومات مفيدة في متناول يديك" - "للحصول على معلومات بدون فتح التطبيقات، يمكنك إضافة الأدوات إلى الشاشة الرئيسية." + "للحصول على معلومات بدون فتح التطبيقات، يمكنك إضافة التطبيقات المصغّرة إلى الشاشة الرئيسية." "انقر لتغيير إعدادات الأداة" "حسنًا" "تغيير إعدادات الأداة" diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index ff0b6c03ee..2bf2fc717e 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -40,8 +40,8 @@ "Tocca e tieni premuto il widget per spostarlo nella schermata Home" "Aggiungi a schermata Home" "Widget %1$s aggiunto alla schermata Home" - "{count,plural, =1{# widget}one{# widget}other{# widget}}" - "{count,plural, =1{# scorciatoia}one{# scorciatoia}other{# scorciatoie}}" + "{count,plural, =1{# widget}other{# widget}}" + "{count,plural, =1{# scorciatoia}other{# scorciatoie}}" "%1$s, %2$s" "Widget" "Cerca" @@ -90,7 +90,7 @@ "Questa è un\'app di sistema e non può essere disinstallata." "Modifica nome" "App %1$s disattivata" - "{count,plural,offset:1 =1{{app_name} ha # notifica}one{{app_name} ha # notifica}other{{app_name} ha # notifiche}}" + "{count,plural,offset:1 =1{{app_name} ha # notifica}other{{app_name} ha # notifiche}}" "Pagina %1$d di %2$d" "Schermata Home %1$d di %2$d" "Nuova pagina Schermata Home" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index 0ddef70e34..85878ad1a1 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -40,8 +40,8 @@ "Toque sem soltar no widget para o mover à volta do ecrã principal" "Adicionar ao ecrã principal" "Widget %1$s adicionado ao ecrã principal" - "{count,plural, =1{# widget}one{# widget(s)}other{# widgets}}" - "{count,plural, =1{# atalho}one{# atalho(s)}other{# atalhos}}" + "{count,plural, =1{# widget}other{# widgets}}" + "{count,plural, =1{# atalho}other{# atalhos}}" "%1$s, %2$s" "Widgets" "Pesquisar" @@ -90,7 +90,7 @@ "É uma app de sistema e não pode ser desinstalada." "Edite o nome" "%1$s desativado" - "{count,plural,offset:1 =1{A app {app_name} tem # notificação}one{A app {app_name} tem # notificação(ões)}other{A app {app_name} tem # notificações}}" + "{count,plural,offset:1 =1{A app {app_name} tem # notificação}other{A app {app_name} tem # notificações}}" "Página %1$d de %2$d" "Ecrã principal %1$d de %2$d" "Nova página do ecrã principal" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 4e72d40f63..07e14f57da 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -41,7 +41,7 @@ "Добавить на главный экран" "Виджет \"%1$s\" добавлен на главный экран" "{count,plural, =1{# виджет}one{# виджет}few{# виджета}many{# виджетов}other{# виджета}}" - "{count,plural, =1{# быстрая команда}one{# быстрая команда}few{# быстрые команды}many{# быстрых команд}other{# быстрой команды}}" + "{count,plural, =1{# ярлык}one{# ярлык}few{# ярлыка}many{# ярлыков}other{# ярлыка}}" "%1$s, %2$s" "Виджеты" "Поиск" @@ -129,7 +129,7 @@ "Добавить на главный экран" "Переместить элемент сюда" "Элемент добавлен на главный экран" - "Объект удален." + "Объект убран." "Отменить" "Переместить элемент" "Переместить в ячейку %1$s %2$s" diff --git a/res/values-te/strings.xml b/res/values-te/strings.xml index ce364bdef7..73c2e1a390 100644 --- a/res/values-te/strings.xml +++ b/res/values-te/strings.xml @@ -140,7 +140,7 @@ "%1$s గల ఫోల్డర్‌కు జోడించు" "అంశం ఫోల్డర్‌కు జోడించబడింది" "ఈ పేరుతో ఫోల్డర్‌ను క్రియేట్ చేయండి: %1$s" - "ఫోల్డర్ సృష్టించబడింది" + "ఫోల్డర్ క్రియేట్ చేయబడింది" "హోమ్‌స్క్రీన్‌కు తరలించు" "పరిమాణం మార్చు" "వెడల్పును పెంచు" From 294ebbca1933fccf7fac63af731a3b8feaccea95 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Thu, 17 Mar 2022 03:01:21 +0000 Subject: [PATCH 4/7] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I759b7d4db0e74540ff60265ec53766a0db9b6a22 --- go/quickstep/res/values-bn/strings.xml | 2 +- go/quickstep/res/values-gu/strings.xml | 2 +- go/quickstep/res/values-kk/strings.xml | 2 +- go/quickstep/res/values-ml/strings.xml | 2 +- go/quickstep/res/values-mn/strings.xml | 2 +- go/quickstep/res/values-ms/strings.xml | 2 +- go/quickstep/res/values-ta/strings.xml | 2 +- go/quickstep/res/values-zu/strings.xml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go/quickstep/res/values-bn/strings.xml b/go/quickstep/res/values-bn/strings.xml index 60671912c8..8c27e63376 100644 --- a/go/quickstep/res/values-bn/strings.xml +++ b/go/quickstep/res/values-bn/strings.xml @@ -4,7 +4,7 @@ "অ্যাপ শেয়ার করুন" "শুনুন" "অনুবাদ করুন" - "লেন্স" + "Lens" "বুঝেছি" "বাতিল করুন" "সেটিংস" diff --git a/go/quickstep/res/values-gu/strings.xml b/go/quickstep/res/values-gu/strings.xml index faa66fcc40..80d9e2ec30 100644 --- a/go/quickstep/res/values-gu/strings.xml +++ b/go/quickstep/res/values-gu/strings.xml @@ -4,7 +4,7 @@ "ઍપ શેર કરો" "સાંભળો" "અનુવાદ કરો" - "લેન્સ" + "Lens" "સમજાઈ ગયું" "રદ કરો" "સેટિંગ" diff --git a/go/quickstep/res/values-kk/strings.xml b/go/quickstep/res/values-kk/strings.xml index 2361cbb619..2a2f96db54 100644 --- a/go/quickstep/res/values-kk/strings.xml +++ b/go/quickstep/res/values-kk/strings.xml @@ -4,7 +4,7 @@ "Қолданбаны бөлісу" "Тыңдау" "Аудару" - "Объектив" + "Lens" "ТҮСІНІКТІ" "БАС ТАРТУ" "ПАРАМЕТРЛЕР" diff --git a/go/quickstep/res/values-ml/strings.xml b/go/quickstep/res/values-ml/strings.xml index 19d0b75a5e..ed5739568c 100644 --- a/go/quickstep/res/values-ml/strings.xml +++ b/go/quickstep/res/values-ml/strings.xml @@ -4,7 +4,7 @@ "ആപ്പ് പങ്കിടുക" "കേൾക്കുക" "വിവർത്തനം ചെയ്യുക" - "ലെൻസ്" + "Lens" "മനസ്സിലായി" "റദ്ദാക്കുക" "ക്രമീകരണം" diff --git a/go/quickstep/res/values-mn/strings.xml b/go/quickstep/res/values-mn/strings.xml index 2eb3c98979..d03b2d2ad7 100644 --- a/go/quickstep/res/values-mn/strings.xml +++ b/go/quickstep/res/values-mn/strings.xml @@ -4,7 +4,7 @@ "Аппыг хуваалцах" "Сонсох" "Орчуулах" - "Дуран" + "Lens" "ОЙЛГОЛОО" "ЦУЦЛАХ" "ТОХИРГОО" diff --git a/go/quickstep/res/values-ms/strings.xml b/go/quickstep/res/values-ms/strings.xml index 36e167878a..3b0a7fbe71 100644 --- a/go/quickstep/res/values-ms/strings.xml +++ b/go/quickstep/res/values-ms/strings.xml @@ -4,7 +4,7 @@ "Kongsi Apl" "Dengar" "Terjemah" - "Kanta" + "Lens" "OK" "BATAL" "TETAPAN" diff --git a/go/quickstep/res/values-ta/strings.xml b/go/quickstep/res/values-ta/strings.xml index 9d04e9a72c..cd97aa3c7a 100644 --- a/go/quickstep/res/values-ta/strings.xml +++ b/go/quickstep/res/values-ta/strings.xml @@ -4,7 +4,7 @@ "ஆப்ஸைப் பகிருங்கள்" "கேளுங்கள்" "மொழிபெயர்" - "லென்ஸ்" + "Lens" "சரி" "ரத்துசெய்" "அமைப்புகள்" diff --git a/go/quickstep/res/values-zu/strings.xml b/go/quickstep/res/values-zu/strings.xml index d496b6442d..1be7898a4b 100644 --- a/go/quickstep/res/values-zu/strings.xml +++ b/go/quickstep/res/values-zu/strings.xml @@ -4,7 +4,7 @@ "Yabelana nge-App" "Lalela" "Humusha" - "Ilensi" + "Lens" "NGIYITHOLILE" "KHANSELA" "AMASETHINGI" From b4479127a7fadf1580d37441ff038288a9f8fd09 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Thu, 17 Mar 2022 03:01:56 +0000 Subject: [PATCH 5/7] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I453c0760c0bd69f5f758b6223b9cbae3c2ec2771 --- go/quickstep/res/values-bn/strings.xml | 2 +- go/quickstep/res/values-gu/strings.xml | 2 +- go/quickstep/res/values-kk/strings.xml | 2 +- go/quickstep/res/values-ml/strings.xml | 2 +- go/quickstep/res/values-mn/strings.xml | 2 +- go/quickstep/res/values-ms/strings.xml | 2 +- go/quickstep/res/values-ta/strings.xml | 2 +- go/quickstep/res/values-zu/strings.xml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go/quickstep/res/values-bn/strings.xml b/go/quickstep/res/values-bn/strings.xml index 60671912c8..8c27e63376 100644 --- a/go/quickstep/res/values-bn/strings.xml +++ b/go/quickstep/res/values-bn/strings.xml @@ -4,7 +4,7 @@ "অ্যাপ শেয়ার করুন" "শুনুন" "অনুবাদ করুন" - "লেন্স" + "Lens" "বুঝেছি" "বাতিল করুন" "সেটিংস" diff --git a/go/quickstep/res/values-gu/strings.xml b/go/quickstep/res/values-gu/strings.xml index faa66fcc40..80d9e2ec30 100644 --- a/go/quickstep/res/values-gu/strings.xml +++ b/go/quickstep/res/values-gu/strings.xml @@ -4,7 +4,7 @@ "ઍપ શેર કરો" "સાંભળો" "અનુવાદ કરો" - "લેન્સ" + "Lens" "સમજાઈ ગયું" "રદ કરો" "સેટિંગ" diff --git a/go/quickstep/res/values-kk/strings.xml b/go/quickstep/res/values-kk/strings.xml index 2361cbb619..2a2f96db54 100644 --- a/go/quickstep/res/values-kk/strings.xml +++ b/go/quickstep/res/values-kk/strings.xml @@ -4,7 +4,7 @@ "Қолданбаны бөлісу" "Тыңдау" "Аудару" - "Объектив" + "Lens" "ТҮСІНІКТІ" "БАС ТАРТУ" "ПАРАМЕТРЛЕР" diff --git a/go/quickstep/res/values-ml/strings.xml b/go/quickstep/res/values-ml/strings.xml index 19d0b75a5e..ed5739568c 100644 --- a/go/quickstep/res/values-ml/strings.xml +++ b/go/quickstep/res/values-ml/strings.xml @@ -4,7 +4,7 @@ "ആപ്പ് പങ്കിടുക" "കേൾക്കുക" "വിവർത്തനം ചെയ്യുക" - "ലെൻസ്" + "Lens" "മനസ്സിലായി" "റദ്ദാക്കുക" "ക്രമീകരണം" diff --git a/go/quickstep/res/values-mn/strings.xml b/go/quickstep/res/values-mn/strings.xml index 2eb3c98979..d03b2d2ad7 100644 --- a/go/quickstep/res/values-mn/strings.xml +++ b/go/quickstep/res/values-mn/strings.xml @@ -4,7 +4,7 @@ "Аппыг хуваалцах" "Сонсох" "Орчуулах" - "Дуран" + "Lens" "ОЙЛГОЛОО" "ЦУЦЛАХ" "ТОХИРГОО" diff --git a/go/quickstep/res/values-ms/strings.xml b/go/quickstep/res/values-ms/strings.xml index 36e167878a..3b0a7fbe71 100644 --- a/go/quickstep/res/values-ms/strings.xml +++ b/go/quickstep/res/values-ms/strings.xml @@ -4,7 +4,7 @@ "Kongsi Apl" "Dengar" "Terjemah" - "Kanta" + "Lens" "OK" "BATAL" "TETAPAN" diff --git a/go/quickstep/res/values-ta/strings.xml b/go/quickstep/res/values-ta/strings.xml index 9d04e9a72c..cd97aa3c7a 100644 --- a/go/quickstep/res/values-ta/strings.xml +++ b/go/quickstep/res/values-ta/strings.xml @@ -4,7 +4,7 @@ "ஆப்ஸைப் பகிருங்கள்" "கேளுங்கள்" "மொழிபெயர்" - "லென்ஸ்" + "Lens" "சரி" "ரத்துசெய்" "அமைப்புகள்" diff --git a/go/quickstep/res/values-zu/strings.xml b/go/quickstep/res/values-zu/strings.xml index d496b6442d..1be7898a4b 100644 --- a/go/quickstep/res/values-zu/strings.xml +++ b/go/quickstep/res/values-zu/strings.xml @@ -4,7 +4,7 @@ "Yabelana nge-App" "Lalela" "Humusha" - "Ilensi" + "Lens" "NGIYITHOLILE" "KHANSELA" "AMASETHINGI" From 8cee1ebed0692028adc413ea1a9877888a0ffeb0 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Thu, 17 Mar 2022 14:55:14 +0000 Subject: [PATCH 6/7] Fix splitPrimaryScrollOffset in RTL Fix: 225165124 Test: split select in RTL and non-RTL, check min/max scroll Change-Id: I5fb13e39560d9dceb4a53c9c79a355f72faf3dba --- quickstep/src/com/android/quickstep/views/RecentsView.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 6bb20fca32..a6b88976ca 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -3872,9 +3872,10 @@ public abstract class RecentsView Date: Fri, 18 Mar 2022 15:24:07 +0000 Subject: [PATCH 7/7] Use correct config.smallestScreenWidthDp when creating Resource in DeviceProfile - This is a regression from ag/17070486 when tested, likely because DeviceProfiles are no longer re-created when changing display sizes, so correct values need to be calculated on the starting state Bug: 221961069 Test: verify smallestWidth specific resource on changing display sizes Change-Id: I1539bad4b35b36f0056d59307ab5fbec23a71f49 --- src/com/android/launcher3/DeviceProfile.java | 6 ++++-- .../android/launcher3/util/DisplayController.java | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 622d750c83..0e9b5da569 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -257,7 +257,8 @@ public class DeviceProfile { // Some more constants. context = getContext(context, info, isVerticalBarLayout() || (isTablet && isLandscape) ? Configuration.ORIENTATION_LANDSCAPE - : Configuration.ORIENTATION_PORTRAIT); + : Configuration.ORIENTATION_PORTRAIT, + windowBounds); final Resources res = context.getResources(); mMetrics = res.getDisplayMetrics(); @@ -1231,10 +1232,11 @@ public class DeviceProfile { writer.println(prefix + pxToDpStr("overviewGridSideMargin", overviewGridSideMargin)); } - private static Context getContext(Context c, Info info, int orientation) { + private static Context getContext(Context c, Info info, int orientation, WindowBounds bounds) { Configuration config = new Configuration(c.getResources().getConfiguration()); config.orientation = orientation; config.densityDpi = info.densityDpi; + config.smallestScreenWidthDp = (int) info.smallestSizeDp(bounds); return c.createConfigurationContext(config); } diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java index 22e3de8f76..8b4ff85f90 100644 --- a/src/com/android/launcher3/util/DisplayController.java +++ b/src/com/android/launcher3/util/DisplayController.java @@ -345,16 +345,21 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { * Returns {@code true} if the bounds represent a tablet. */ public boolean isTablet(WindowBounds bounds) { - return dpiFromPx(Math.min(bounds.bounds.width(), bounds.bounds.height()), - densityDpi) >= MIN_TABLET_WIDTH; + return smallestSizeDp(bounds) >= MIN_TABLET_WIDTH; } /** * Returns {@code true} if the bounds represent a large tablet. */ public boolean isLargeTablet(WindowBounds bounds) { - return dpiFromPx(Math.min(bounds.bounds.width(), bounds.bounds.height()), - densityDpi) >= MIN_LARGE_TABLET_WIDTH; + return smallestSizeDp(bounds) >= MIN_LARGE_TABLET_WIDTH; + } + + /** + * Returns smallest size in dp for given bounds. + */ + public float smallestSizeDp(WindowBounds bounds) { + return dpiFromPx(Math.min(bounds.bounds.width(), bounds.bounds.height()), densityDpi); } }