Merge "Fix NPE in overview action buttons" into main
diff --git a/aconfig/launcher_search.aconfig b/aconfig/launcher_search.aconfig
new file mode 100644
index 0000000..87ccec5
--- /dev/null
+++ b/aconfig/launcher_search.aconfig
@@ -0,0 +1,8 @@
+package: "com.android.launcher3"
+
+flag {
+ name: "enable_private_space"
+ namespace: "launcher_search"
+ description: "Enables all Launcher features associated with private space."
+ bug: "306187906"
+}
diff --git a/quickstep/res/values-land/dimens.xml b/quickstep/res/values-land/dimens.xml
index ee594c8..2b17b93 100644
--- a/quickstep/res/values-land/dimens.xml
+++ b/quickstep/res/values-land/dimens.xml
@@ -84,4 +84,5 @@
<dimen name="keyboard_quick_switch_taskview_width">205dp</dimen>
<dimen name="keyboard_quick_switch_taskview_height">119dp</dimen>
+
</resources>
diff --git a/quickstep/res/values-sw600dp-land/dimens.xml b/quickstep/res/values-sw600dp-land/dimens.xml
index 9cb3fec..5e9a177 100644
--- a/quickstep/res/values-sw600dp-land/dimens.xml
+++ b/quickstep/res/values-sw600dp-land/dimens.xml
@@ -27,4 +27,10 @@
<dimen name="gesture_tutorial_menu_done_button_top_spacing">40dp</dimen>
<dimen name="gesture_tutorial_menu_back_shape_bottom_margin">49dp</dimen>
+ <!-- Grid Only Overview -->
+ <!-- The top margin above the top row of tasks in grid only overview -->
+ <dimen name="overview_top_margin_grid_only">24dp</dimen>
+ <!-- The bottom margin above the bottom row of tasks in grid only overview -->
+ <dimen name="overview_bottom_margin_grid_only">40dp</dimen>
+
</resources>
diff --git a/quickstep/res/values-sw600dp/dimens.xml b/quickstep/res/values-sw600dp/dimens.xml
index daf1f63..f9528b3 100644
--- a/quickstep/res/values-sw600dp/dimens.xml
+++ b/quickstep/res/values-sw600dp/dimens.xml
@@ -33,6 +33,10 @@
<dimen name="overview_page_spacing">36dp</dimen>
<!-- The space to the left and to the right of the "Clear all" button -->
<dimen name="overview_grid_side_margin">64dp</dimen>
+ <!-- The top margin above the top row of tasks in grid only overview -->
+ <dimen name="overview_top_margin_grid_only">80dp</dimen>
+ <!-- The bottom margin above the bottom row of tasks in grid only overview -->
+ <dimen name="overview_bottom_margin_grid_only">80dp</dimen>
<!-- Overview actions -->
<dimen name="overview_actions_top_margin">24dp</dimen>
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index e77d2c6..c5d0b95 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -1057,9 +1057,9 @@
boolean allowBlurringLauncher = mLauncher.getStateManager().getState() != OVERVIEW
&& BlurUtils.supportsBlursOnWindows();
- LaunchDepthController depthController = new LaunchDepthController(mLauncher);
- ObjectAnimator backgroundRadiusAnim = ObjectAnimator.ofFloat(depthController.stateDepth,
- MULTI_PROPERTY_VALUE, BACKGROUND_APP.getDepth(mLauncher))
+ ObjectAnimator backgroundRadiusAnim =
+ ObjectAnimator.ofFloat(mLauncher.getDepthController().stateDepth,
+ MULTI_PROPERTY_VALUE, BACKGROUND_APP.getDepth(mLauncher))
.setDuration(APP_LAUNCH_DURATION);
if (allowBlurringLauncher) {
@@ -1085,9 +1085,6 @@
new SurfaceControl.Transaction().remove(dimLayer).apply()));
}
- backgroundRadiusAnim.addListener(
- AnimatorListeners.forEndCallback(depthController::dispose));
-
return backgroundRadiusAnim;
}
diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
index 882682d..957db64 100644
--- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
+++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
@@ -94,18 +94,6 @@
}
}
- /**
- * Cleans up after this controller so it can be garbage collected without leaving traces.
- */
- public void dispose() {
- removeSecondaryListeners();
-
- if (mLauncher.getRootView() != null && mOnAttachListener != null) {
- mLauncher.getRootView().removeOnAttachStateChangeListener(mOnAttachListener);
- mOnAttachListener = null;
- }
- }
-
private void removeSecondaryListeners() {
if (mCrossWindowBlurListener != null) {
CrossWindowBlurListeners.getInstance().removeListener(mCrossWindowBlurListener);
diff --git a/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java b/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java
similarity index 79%
rename from quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java
rename to quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java
index a922ed1..396f94f 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java
@@ -15,9 +15,6 @@
*/
package com.android.launcher3.uioverrides.flags;
-import static android.content.Intent.ACTION_PACKAGE_ADDED;
-import static android.content.Intent.ACTION_PACKAGE_CHANGED;
-import static android.content.Intent.ACTION_PACKAGE_REMOVED;
import static android.content.pm.PackageManager.GET_RESOLVED_FILTER;
import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
import static android.view.View.GONE;
@@ -30,7 +27,7 @@
import static com.android.launcher3.LauncherPrefs.LONG_PRESS_NAV_HANDLE_HAPTIC_HINT_START_SCALE_PERCENT;
import static com.android.launcher3.LauncherPrefs.LONG_PRESS_NAV_HANDLE_SLOP_PERCENTAGE;
import static com.android.launcher3.LauncherPrefs.LONG_PRESS_NAV_HANDLE_TIMEOUT_MS;
-import static com.android.launcher3.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
+import static com.android.launcher3.settings.SettingsActivity.EXTRA_FRAGMENT_HIGHLIGHT_KEY;
import static com.android.launcher3.uioverrides.plugins.PluginManagerWrapper.PLUGIN_CHANGED;
import static com.android.launcher3.uioverrides.plugins.PluginManagerWrapper.pluginEnabledKey;
import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;
@@ -40,7 +37,6 @@
import static com.android.launcher3.util.OnboardingPrefs.HOTSEAT_LONGPRESS_TIP_SEEN;
import static com.android.launcher3.util.OnboardingPrefs.TASKBAR_EDU_TOOLTIP_STEP;
-import android.annotation.TargetApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -48,23 +44,17 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
import android.provider.Settings;
import android.text.Editable;
-import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.ArrayMap;
import android.util.Pair;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
+import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Toast;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceDataStore;
@@ -81,7 +71,6 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.secondarydisplay.SecondaryDisplayLauncher;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
-import com.android.launcher3.util.SimpleBroadcastReceiver;
import java.util.ArrayList;
import java.util.List;
@@ -92,30 +81,32 @@
* Dev-build only UI allowing developers to toggle flag settings and plugins.
* See {@link FeatureFlags}.
*/
-@TargetApi(Build.VERSION_CODES.O)
-public class DeveloperOptionsFragment extends PreferenceFragmentCompat {
+public class DeveloperOptionsUI {
- private static final String ACTION_PLUGIN_SETTINGS = "com.android.systemui.action.PLUGIN_SETTINGS";
+ private static final String ACTION_PLUGIN_SETTINGS =
+ "com.android.systemui.action.PLUGIN_SETTINGS";
private static final String PLUGIN_PERMISSION = "com.android.systemui.permission.PLUGIN";
- private final SimpleBroadcastReceiver mPluginReceiver =
- new SimpleBroadcastReceiver(i -> loadPluginPrefs());
-
- private PreferenceScreen mPreferenceScreen;
+ private final PreferenceFragmentCompat mFragment;
+ private final PreferenceScreen mPreferenceScreen;
private PreferenceCategory mPluginsCategory;
- private FlagTogglerPrefUi mFlagTogglerPrefUi;
- @Override
- public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
- mPluginReceiver.registerPkgActions(getContext(), null,
- ACTION_PACKAGE_ADDED, ACTION_PACKAGE_CHANGED, ACTION_PACKAGE_REMOVED);
- mPluginReceiver.register(getContext(), Intent.ACTION_USER_UNLOCKED);
+ public DeveloperOptionsUI(PreferenceFragmentCompat fragment, PreferenceCategory flags) {
+ mFragment = fragment;
+ mPreferenceScreen = fragment.getPreferenceScreen();
- mPreferenceScreen = getPreferenceManager().createPreferenceScreen(getContext());
- setPreferenceScreen(mPreferenceScreen);
+ // Add search bar
+ View listView = mFragment.getListView();
+ ViewGroup parent = (ViewGroup) listView.getParent();
+ View topBar = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.developer_options_top_bar, parent, false);
+ parent.addView(topBar, parent.indexOfChild(listView));
+ initSearch(topBar.findViewById(R.id.filter_box));
- initFlags();
+ new FlagTogglerPrefUi(mFragment.requireActivity(), topBar.findViewById(R.id.flag_apply_btn))
+ .applyTo(flags);
+
loadPluginPrefs();
maybeAddSandboxCategory();
addOnboardingPrefsCatergory();
@@ -123,10 +114,6 @@
addAllAppsFromOverviewCatergory();
}
addCustomLpnhCategory();
-
- if (getActivity() != null) {
- getActivity().setTitle("Developer Options");
- }
}
private void filterPreferences(String query, PreferenceGroup pg) {
@@ -149,21 +136,13 @@
pg.setVisible(hidden != count);
}
- @Override
- public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- EditText filterBox = view.findViewById(R.id.filter_box);
- filterBox.setVisibility(VISIBLE);
+ private void initSearch(EditText filterBox) {
filterBox.addTextChangedListener(new TextWatcher() {
@Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
-
- }
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { }
@Override
- public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
-
- }
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { }
@Override
public void afterTextChanged(Editable editable) {
@@ -172,85 +151,33 @@
}
});
- if (getArguments() != null) {
- String filter = getArguments().getString(EXTRA_FRAGMENT_ARG_KEY);
+ if (mFragment.getArguments() != null) {
+ String filter = mFragment.getArguments().getString(EXTRA_FRAGMENT_HIGHLIGHT_KEY);
// Normally EXTRA_FRAGMENT_ARG_KEY is used to highlight the preference with the given
// key. This is a slight variation where we instead filter by the human-readable titles.
if (filter != null) {
filterBox.setText(filter);
}
}
-
- View listView = getListView();
- final int bottomPadding = listView.getPaddingBottom();
- listView.setOnApplyWindowInsetsListener((v, insets) -> {
- v.setPadding(
- v.getPaddingLeft(),
- v.getPaddingTop(),
- v.getPaddingRight(),
- bottomPadding + insets.getSystemWindowInsetBottom());
- return insets.consumeSystemWindowInsets();
- });
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- mPluginReceiver.unregisterReceiverSafely(getContext());
}
private PreferenceCategory newCategory(String title) {
- return newCategory(title, null);
- }
-
- private PreferenceCategory newCategory(String title, @Nullable String summary) {
PreferenceCategory category = new PreferenceCategory(getContext());
category.setOrder(Preference.DEFAULT_ORDER);
category.setTitle(title);
- if (!TextUtils.isEmpty(summary)) {
- category.setSummary(summary);
- }
mPreferenceScreen.addPreference(category);
return category;
}
- private void initFlags() {
- if (!FeatureFlags.showFlagTogglerUi(getContext())) {
- return;
- }
-
- mFlagTogglerPrefUi = new FlagTogglerPrefUi(this);
- mFlagTogglerPrefUi.applyTo(newCategory("Feature flags", "Long press to reset"));
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- if (mFlagTogglerPrefUi != null) {
- mFlagTogglerPrefUi.onCreateOptionsMenu(menu);
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (mFlagTogglerPrefUi != null) {
- mFlagTogglerPrefUi.onOptionsItemSelected(item);
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public void onStop() {
- if (mFlagTogglerPrefUi != null) {
- mFlagTogglerPrefUi.onStop();
- }
- super.onStop();
+ private Context getContext() {
+ return mFragment.requireContext();
}
private void loadPluginPrefs() {
if (mPluginsCategory != null) {
mPreferenceScreen.removePreference(mPluginsCategory);
}
- if (!PluginManagerWrapper.hasPlugins(getActivity())) {
+ if (!PluginManagerWrapper.hasPlugins(getContext())) {
mPluginsCategory = null;
return;
}
@@ -323,68 +250,57 @@
launchTutorialStepMenuPreference.setKey("launchTutorialStepMenu");
launchTutorialStepMenuPreference.setTitle("Launch Gesture Tutorial Steps menu");
launchTutorialStepMenuPreference.setSummary("Select a gesture tutorial step.");
- launchTutorialStepMenuPreference.setOnPreferenceClickListener(preference -> {
- startActivity(launchSandboxIntent.putExtra("use_tutorial_menu", true));
- return true;
- });
+ launchTutorialStepMenuPreference.setIntent(
+ new Intent(launchSandboxIntent).putExtra("use_tutorial_menu", true));
+
sandboxCategory.addPreference(launchTutorialStepMenuPreference);
Preference launchOnboardingTutorialPreference = new Preference(context);
launchOnboardingTutorialPreference.setKey("launchOnboardingTutorial");
launchOnboardingTutorialPreference.setTitle("Launch Onboarding Tutorial");
launchOnboardingTutorialPreference.setSummary("Learn the basic navigation gestures.");
- launchOnboardingTutorialPreference.setOnPreferenceClickListener(preference -> {
- startActivity(launchSandboxIntent
- .putExtra("use_tutorial_menu", false)
- .putExtra("tutorial_steps",
- new String[] {
- "HOME_NAVIGATION",
- "BACK_NAVIGATION",
- "OVERVIEW_NAVIGATION"}));
- return true;
- });
+ launchTutorialStepMenuPreference.setIntent(new Intent(launchSandboxIntent)
+ .putExtra("use_tutorial_menu", false)
+ .putExtra("tutorial_steps",
+ new String[] {
+ "HOME_NAVIGATION",
+ "BACK_NAVIGATION",
+ "OVERVIEW_NAVIGATION"}));
+
sandboxCategory.addPreference(launchOnboardingTutorialPreference);
Preference launchBackTutorialPreference = new Preference(context);
launchBackTutorialPreference.setKey("launchBackTutorial");
launchBackTutorialPreference.setTitle("Launch Back Tutorial");
launchBackTutorialPreference.setSummary("Learn how to use the Back gesture");
- launchBackTutorialPreference.setOnPreferenceClickListener(preference -> {
- startActivity(launchSandboxIntent
+ launchBackTutorialPreference.setIntent(new Intent(launchSandboxIntent)
.putExtra("use_tutorial_menu", false)
.putExtra("tutorial_steps", new String[] {"BACK_NAVIGATION"}));
- return true;
- });
+
sandboxCategory.addPreference(launchBackTutorialPreference);
Preference launchHomeTutorialPreference = new Preference(context);
launchHomeTutorialPreference.setKey("launchHomeTutorial");
launchHomeTutorialPreference.setTitle("Launch Home Tutorial");
launchHomeTutorialPreference.setSummary("Learn how to use the Home gesture");
- launchHomeTutorialPreference.setOnPreferenceClickListener(preference -> {
- startActivity(launchSandboxIntent
+ launchHomeTutorialPreference.setIntent(new Intent(launchSandboxIntent)
.putExtra("use_tutorial_menu", false)
.putExtra("tutorial_steps", new String[] {"HOME_NAVIGATION"}));
- return true;
- });
+
sandboxCategory.addPreference(launchHomeTutorialPreference);
Preference launchOverviewTutorialPreference = new Preference(context);
launchOverviewTutorialPreference.setKey("launchOverviewTutorial");
launchOverviewTutorialPreference.setTitle("Launch Overview Tutorial");
launchOverviewTutorialPreference.setSummary("Learn how to use the Overview gesture");
- launchOverviewTutorialPreference.setOnPreferenceClickListener(preference -> {
- startActivity(launchSandboxIntent
+ launchOverviewTutorialPreference.setIntent(new Intent(launchSandboxIntent)
.putExtra("use_tutorial_menu", false)
.putExtra("tutorial_steps", new String[] {"OVERVIEW_NAVIGATION"}));
- return true;
- });
+
sandboxCategory.addPreference(launchOverviewTutorialPreference);
Preference launchSecondaryDisplayPreference = new Preference(context);
launchSecondaryDisplayPreference.setKey("launchSecondaryDisplay");
launchSecondaryDisplayPreference.setTitle("Launch Secondary Display");
launchSecondaryDisplayPreference.setSummary("Launch secondary display activity");
- launchSecondaryDisplayPreference.setOnPreferenceClickListener(preference -> {
- startActivity(new Intent(context, SecondaryDisplayLauncher.class));
- return true;
- });
- sandboxCategory.addPreference(launchSecondaryDisplayPreference);
+ launchSecondaryDisplayPreference.setIntent(
+ new Intent(context, SecondaryDisplayLauncher.class));
+
}
private void addOnboardingPrefsCatergory() {
diff --git a/quickstep/src/com/android/launcher3/uioverrides/flags/FlagTogglerPrefUi.java b/quickstep/src/com/android/launcher3/uioverrides/flags/FlagTogglerPrefUi.java
index 87c836b..ec0566a 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/flags/FlagTogglerPrefUi.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/flags/FlagTogglerPrefUi.java
@@ -19,24 +19,23 @@
import static com.android.launcher3.config.FeatureFlags.FlagState.TEAMFOOD;
import static com.android.launcher3.uioverrides.flags.FlagsFactory.TEAMFOOD_FLAG;
+import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.os.Process;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
+import android.view.View;
import android.widget.Toast;
import androidx.preference.PreferenceDataStore;
-import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceViewHolder;
import androidx.preference.SwitchPreference;
-import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.util.ActivityLifecycleCallbacksAdapter;
import java.util.List;
import java.util.Set;
@@ -44,12 +43,13 @@
/**
* Dev-build only UI allowing developers to toggle flag settings. See {@link FeatureFlags}.
*/
-public final class FlagTogglerPrefUi {
+public final class FlagTogglerPrefUi implements ActivityLifecycleCallbacksAdapter {
private static final String TAG = "FlagTogglerPrefFrag";
- private final PreferenceFragmentCompat mFragment;
+ private final View mFlagsApplyButton;
private final Context mContext;
+
private final PreferenceDataStore mDataStore = new PreferenceDataStore() {
@Override
@@ -64,9 +64,17 @@
}
};
- public FlagTogglerPrefUi(PreferenceFragmentCompat fragment) {
- mFragment = fragment;
- mContext = fragment.getActivity();
+ public FlagTogglerPrefUi(Activity activity, View flagsApplyButton) {
+ mFlagsApplyButton = flagsApplyButton;
+ mContext = mFlagsApplyButton.getContext();
+ activity.registerActivityLifecycleCallbacks(this);
+
+ mFlagsApplyButton.setOnClickListener(v -> {
+ FlagsFactory.getSharedPreferences().edit().commit();
+ Log.e(TAG,
+ "Killing launcher process " + Process.myPid() + " to apply new flag values");
+ System.exit(0);
+ });
}
public void applyTo(PreferenceGroup parent) {
@@ -137,27 +145,11 @@
}
private void updateMenu() {
- mFragment.setHasOptionsMenu(anyChanged());
- mFragment.getActivity().invalidateOptionsMenu();
+ mFlagsApplyButton.setVisibility(anyChanged() ? View.VISIBLE : View.INVISIBLE);
}
- public void onCreateOptionsMenu(Menu menu) {
- if (anyChanged()) {
- menu.add(0, R.id.menu_apply_flags, 0, "Apply")
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
- }
- }
-
- public void onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == R.id.menu_apply_flags) {
- FlagsFactory.getSharedPreferences().edit().commit();
- Log.e(TAG,
- "Killing launcher process " + Process.myPid() + " to apply new flag values");
- System.exit(0);
- }
- }
-
- public void onStop() {
+ @Override
+ public void onActivityStopped(Activity activity) {
if (anyChanged()) {
Toast.makeText(mContext, "Flag won't be applied until you restart launcher",
Toast.LENGTH_LONG).show();
diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
index 25389c5..88933f4 100644
--- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
@@ -267,7 +267,7 @@
Resources res = context.getResources();
float maxScale = res.getFloat(R.dimen.overview_max_scale);
Rect gridRect = new Rect();
- calculateGridSize(dp, gridRect);
+ calculateGridSize(dp, context, gridRect);
calculateTaskSizeInternal(context, dp, gridRect, maxScale, Gravity.CENTER, outRect);
}
@@ -321,10 +321,16 @@
/**
* Calculates the overview grid size for the provided device configuration.
*/
- public final void calculateGridSize(DeviceProfile dp, Rect outRect) {
+ public final void calculateGridSize(DeviceProfile dp, Context context, Rect outRect) {
Rect insets = dp.getInsets();
int topMargin = dp.overviewTaskThumbnailTopMarginPx;
int bottomMargin = dp.getOverviewActionsClaimedSpace();
+ if (dp.isTaskbarPresent && Flags.enableGridOnlyOverview()) {
+ topMargin += context.getResources().getDimensionPixelSize(
+ R.dimen.overview_top_margin_grid_only);
+ bottomMargin += context.getResources().getDimensionPixelSize(
+ R.dimen.overview_bottom_margin_grid_only);
+ }
int sideMargin = dp.overviewGridSideMargin;
outRect.set(0, 0, dp.widthPx, dp.heightPx);
@@ -340,7 +346,7 @@
Resources res = context.getResources();
Rect potentialTaskRect = new Rect();
if (Flags.enableGridOnlyOverview()) {
- calculateGridSize(dp, potentialTaskRect);
+ calculateGridSize(dp, context, potentialTaskRect);
} else {
calculateFocusTaskSize(context, dp, potentialTaskRect);
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 0a195c3..e6f015e 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -2064,7 +2064,7 @@
dp.widthPx - mInsets.right - mTempRect.right,
dp.heightPx - mInsets.bottom - mTempRect.bottom);
- mSizeStrategy.calculateGridSize(mActivity.getDeviceProfile(),
+ mSizeStrategy.calculateGridSize(mActivity.getDeviceProfile(), mActivity,
mLastComputedGridSize);
mSizeStrategy.calculateGridTaskSize(mActivity, mActivity.getDeviceProfile(),
mLastComputedGridTaskSize, mOrientationHandler);
diff --git a/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java b/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java
index eba3252..f6368b0 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java
@@ -82,7 +82,7 @@
taskMenu.touchOutsideTaskMenuToDismiss();
OverviewTaskMenu splitMenu =
- mLauncher.getOverview().getCurrentTask().tapSplitTaskMenu();
+ mLauncher.goHome().switchToOverview().getCurrentTask().tapSplitTaskMenu();
assertTrue("App info item not appearing in expanded split task's menu.",
splitMenu.hasMenuItem("App info"));
splitMenu.touchOutsideTaskMenuToDismiss();
diff --git a/res/layout/developer_options_top_bar.xml b/res/layout/developer_options_top_bar.xml
new file mode 100644
index 0000000..1b138ea
--- /dev/null
+++ b/res/layout/developer_options_top_bar.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:showDividers="middle">
+
+ <EditText
+ android:id="@+id/filter_box"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:layout_marginHorizontal="@dimen/developer_options_filter_margins"
+ android:hint="@string/developer_options_filter_hint"
+ android:inputType="text"
+ android:maxLines="1"
+ android:imeOptions="actionDone"
+ />
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:text="Apply"
+ android:visibility="invisible"
+ android:id="@+id/flag_apply_btn" />
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/home_settings.xml b/res/layout/home_settings.xml
index c0f16e2..62900a8 100644
--- a/res/layout/home_settings.xml
+++ b/res/layout/home_settings.xml
@@ -3,22 +3,5 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <EditText
- android:id="@+id/filter_box"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginHorizontal="@dimen/developer_options_filter_margins"
- android:hint="@string/developer_options_filter_hint"
- android:visibility="gone"
- android:inputType="text"
- android:maxLines="1"
- android:imeOptions="actionDone"
- />
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:id="@android:id/list_container"/>
-</LinearLayout>
\ No newline at end of file
+ android:layout_height="match_parent"
+ android:id="@android:id/list_container"/>
diff --git a/res/values/config.xml b/res/values/config.xml
index cd9c9de..4b15a6b 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -242,6 +242,8 @@
<item>@dimen/iconSize72dp</item>
</integer-array>
+ <dimen name="minimum_icon_label_size">8sp</dimen>
+
<!-- Used for custom widgets -->
<array name="custom_widget_providers"/>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index e532dad..81c2337 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -412,6 +412,9 @@
<dimen name="overview_grid_side_margin">0dp</dimen>
<dimen name="overview_grid_row_spacing">0dp</dimen>
<dimen name="overview_page_spacing">0dp</dimen>
+ <dimen name="overview_top_margin_grid_only">0dp</dimen>
+ <dimen name="overview_bottom_margin_grid_only">0dp</dimen>
+
<dimen name="split_placeholder_size">72dp</dimen>
<dimen name="split_placeholder_inset">16dp</dimen>
<dimen name="split_placeholder_icon_size">44dp</dimen>
@@ -423,7 +426,7 @@
<dimen name="split_instructions_drawable_padding">10dp</dimen>
<dimen name="split_instructions_bottom_margin_phone_landscape">24dp</dimen>
<dimen name="split_instructions_bottom_margin_phone_portrait">60dp</dimen>
-
+
<!-- Workspace grid visualization parameters -->
<dimen name="grid_visualization_rounding_radius">28dp</dimen>
<dimen name="grid_visualization_horizontal_cell_spacing">6dp</dimen>
diff --git a/src/com/android/launcher3/AppWidgetsRestoredReceiver.java b/src/com/android/launcher3/AppWidgetsRestoredReceiver.java
index 55b8fcc..641fd83 100644
--- a/src/com/android/launcher3/AppWidgetsRestoredReceiver.java
+++ b/src/com/android/launcher3/AppWidgetsRestoredReceiver.java
@@ -1,17 +1,20 @@
package com.android.launcher3;
+import static com.android.launcher3.LauncherPrefs.APP_WIDGET_IDS;
+import static com.android.launcher3.LauncherPrefs.OLD_APP_WIDGET_IDS;
+
import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
-import com.android.launcher3.provider.RestoreDbTask;
+import com.android.launcher3.util.IntArray;
import com.android.launcher3.widget.LauncherWidgetHolder;
public class AppWidgetsRestoredReceiver extends BroadcastReceiver {
- private static final String TAG = "AWRestoredReceiver";
+ private static final String TAG = "AppWidgetsRestoredReceiver";
@Override
public void onReceive(final Context context, Intent intent) {
@@ -25,7 +28,9 @@
final int[] oldIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_OLD_IDS);
final int[] newIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
if (oldIds != null && newIds != null && oldIds.length == newIds.length) {
- RestoreDbTask.setRestoredAppWidgetIds(context, oldIds, newIds);
+ LauncherPrefs.get(context).putSync(
+ OLD_APP_WIDGET_IDS.to(IntArray.wrap(oldIds).toConcatString()),
+ APP_WIDGET_IDS.to(IntArray.wrap(newIds).toConcatString()));
} else {
Log.e(TAG, "Invalid host restored received");
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 2ac6098..bdffe46 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -63,6 +63,7 @@
import com.android.launcher3.responsive.HotseatSpecs;
import com.android.launcher3.responsive.WorkspaceSpecs;
import com.android.launcher3.uioverrides.ApiWrapper;
+import com.android.launcher3.util.CellContentDimensions;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.DisplayController.Info;
import com.android.launcher3.util.IconSizeSteps;
@@ -299,6 +300,7 @@
public final int stashedTaskbarHeight;
public final int taskbarBottomMargin;
public final int taskbarIconSize;
+ private final int mTransientTaskbarClaimedSpace;
// If true, used to layout taskbar in 3 button navigation mode.
public final boolean startAlignTaskbar;
public final boolean isTransientTaskbar;
@@ -370,18 +372,23 @@
}
this.isTransientTaskbar = isTransientTaskbar;
+ int transientTaskbarIconSize = pxFromDp(inv.transientTaskbarIconSize[mTypeIndex], mMetrics);
+ int transientTaskbarBottomMargin =
+ res.getDimensionPixelSize(R.dimen.transient_taskbar_bottom_margin);
+ int transientTaskbarHeight =
+ Math.round((transientTaskbarIconSize * ICON_VISIBLE_AREA_FACTOR)
+ + (2 * res.getDimensionPixelSize(R.dimen.transient_taskbar_padding)));
+ mTransientTaskbarClaimedSpace = transientTaskbarHeight + 2 * transientTaskbarBottomMargin;
+
if (!isTaskbarPresent) {
taskbarIconSize = taskbarHeight = stashedTaskbarHeight = taskbarBottomMargin = 0;
startAlignTaskbar = false;
} else if (isTransientTaskbar) {
- float invTransientIconSizeDp = inv.transientTaskbarIconSize[mTypeIndex];
- taskbarIconSize = pxFromDp(invTransientIconSizeDp, mMetrics);
- taskbarHeight = Math.round((taskbarIconSize * ICON_VISIBLE_AREA_FACTOR)
- + (2 * res.getDimensionPixelSize(R.dimen.transient_taskbar_padding)));
+ taskbarIconSize = transientTaskbarIconSize;
+ taskbarHeight = transientTaskbarHeight;
stashedTaskbarHeight =
res.getDimensionPixelSize(R.dimen.transient_taskbar_stashed_height);
- taskbarBottomMargin =
- res.getDimensionPixelSize(R.dimen.transient_taskbar_bottom_margin);
+ taskbarBottomMargin = transientTaskbarBottomMargin;
startAlignTaskbar = false;
} else {
taskbarIconSize = pxFromDp(ResourcesCompat.getFloat(res, R.dimen.taskbar_icon_size),
@@ -924,14 +931,11 @@
- iconTextHeight;
if (mIsResponsiveGrid) {
- // Hide text only if doesn't fit inside the cell for responsive grid
- if (workspaceCellPaddingY < 0) {
- iconTextSizePx = 0;
- iconDrawablePaddingPx = 0;
- int iconSizeWithOverlap = getIconSizeWithOverlap(iconSizePx);
- cellYPaddingPx = Math.max(0, getCellSize().y - iconSizeWithOverlap) / 2;
- autoResizeAllAppsCells();
- }
+ iconTextSizePx = 0;
+ iconDrawablePaddingPx = 0;
+ int iconSizeWithOverlap = getIconSizeWithOverlap(iconSizePx);
+ cellYPaddingPx = Math.max(0, getCellSize().y - iconSizeWithOverlap) / 2;
+ autoResizeAllAppsCells();
return;
}
@@ -1047,22 +1051,23 @@
iconSizePx = mIconSizeSteps.getIconSmallerThan(cellWidthPx);
}
- // TODO(b/296400197): isVerticalBar shouldn't show labels anymore
iconDrawablePaddingPx = getNormalizedIconDrawablePadding();
- int iconTextHeight = Utilities.calculateTextHeight(iconTextSizePx);
- int cellContentHeight = iconSizePx + iconDrawablePaddingPx + iconTextHeight;
- while (iconSizePx > mIconSizeSteps.minimumIconSize()
- && cellContentHeight > cellHeightPx) {
- iconDrawablePaddingPx -= cellContentHeight - cellHeightPx;
- if (iconDrawablePaddingPx < 0) {
- // get a smaller icon size
- iconSizePx = mIconSizeSteps.getNextLowerIconSize(iconSizePx);
- iconDrawablePaddingPx = getNormalizedIconDrawablePadding();
+ CellContentDimensions cellContentDimensions = new CellContentDimensions(iconSizePx,
+ iconDrawablePaddingPx,
+ iconTextSizePx);
+ if (isVerticalLayout) {
+ if (cellHeightPx < iconSizePx) {
+ cellContentDimensions.setIconSizePx(
+ mIconSizeSteps.getIconSmallerThan(cellHeightPx));
}
- // calculate new cellContentHeight
- cellContentHeight = iconSizePx + iconDrawablePaddingPx + iconTextHeight;
+ } else {
+ cellContentDimensions.resizeToFitCellHeight(cellHeightPx, mIconSizeSteps);
}
+ iconSizePx = cellContentDimensions.getIconSizePx();
+ iconDrawablePaddingPx = cellContentDimensions.getIconDrawablePaddingPx();
+ iconTextSizePx = cellContentDimensions.getIconTextSizePx();
+ int cellContentHeight = cellContentDimensions.getCellContentHeight();
cellYPaddingPx = Math.max(0, cellHeightPx - cellContentHeight) / 2;
} else if (mIsScalableGrid) {
@@ -1760,14 +1765,9 @@
return getHotseatBarBottomPadding() + launcherIconBottomSpace - taskbarIconBottomSpace;
}
- /**
- * Returns the number of pixels required below OverviewActions excluding insets.
- */
+ /** Returns the number of pixels required below OverviewActions. */
public int getOverviewActionsClaimedSpaceBelow() {
- if (isTaskbarPresent) {
- return taskbarHeight + taskbarBottomMargin * 2;
- }
- return mInsets.bottom;
+ return isTaskbarPresent ? mTransientTaskbarClaimedSpace : mInsets.bottom;
}
/** Gets the space that the overview actions will take, including bottom margin. */
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index b629ec2..c0520c1 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -143,7 +143,6 @@
import com.android.launcher3.allapps.AllAppsRecyclerView;
import com.android.launcher3.allapps.AllAppsStore;
import com.android.launcher3.allapps.AllAppsTransitionController;
-import com.android.launcher3.allapps.BaseSearchConfig;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.PropertyListBuilder;
@@ -418,7 +417,6 @@
private LauncherState mPrevLauncherState;
private StringCache mStringCache;
- private BaseSearchConfig mBaseSearchConfig;
private StartupLatencyLogger mStartupLatencyLogger;
private CellPosMapper mCellPosMapper = CellPosMapper.DEFAULT;
private boolean mIsFirstPagePinnedItemEnabled = QSB_ON_FIRST_SCREEN
@@ -532,9 +530,6 @@
mAllAppsController = new AllAppsTransitionController(this);
mStateManager = new StateManager<>(this, NORMAL);
- // TODO: move the SearchConfig to SearchState when new LauncherState is created.
- mBaseSearchConfig = new BaseSearchConfig();
-
setupViews();
mAppWidgetManager = new WidgetManagerHelper(this);
@@ -3316,10 +3311,6 @@
return mOldConfig.orientation;
}
- public BaseSearchConfig getSearchConfig() {
- return mBaseSearchConfig;
- }
-
/**
* Returns the CellLayout of the specified container at the specified screen.
*
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 7b27a71..e797147 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -58,7 +58,6 @@
import android.os.Message;
import android.os.Process;
import android.os.TransactionTooLargeException;
-import android.provider.Settings;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
@@ -168,11 +167,6 @@
return nightMode == Configuration.UI_MODE_NIGHT_YES;
}
- public static boolean isDevelopersOptionsEnabled(Context context) {
- return Settings.Global.getInt(context.getApplicationContext().getContentResolver(),
- Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
- }
-
private static boolean sIsRunningInTestHarness = ActivityManager.isRunningInTestHarness();
public static boolean isRunningInTestHarness() {
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 278e4e5..03ac9df 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -33,7 +33,6 @@
import static com.android.launcher3.util.SystemUiController.UI_STATE_ALL_APPS;
import android.animation.Animator;
-import android.animation.Animator.AnimatorListener;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.util.FloatProperty;
@@ -54,7 +53,6 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatedFloat;
-import com.android.launcher3.anim.AnimatorListeners;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.config.FeatureFlags;
@@ -171,9 +169,6 @@
private boolean mIsVerticalLayout;
- // Whether this class should take care of closing the keyboard.
- private boolean mShouldControlKeyboard;
-
// Animation in this class is controlled by a single variable {@link mProgress}.
// Visually, it represents top y coordinate of the all apps container if multiplied with
// {@link mShiftRange}.
@@ -276,7 +271,6 @@
public void setState(LauncherState state) {
setProgress(state.getVerticalProgress(mLauncher));
setAlphas(state, new StateAnimationConfig(), NO_ANIM_PROPERTY_SETTER);
- onProgressAnimationEnd();
}
@Override
@@ -339,25 +333,11 @@
public void setStateWithAnimation(LauncherState toState,
StateAnimationConfig config, PendingAnimation builder) {
if (mLauncher.isInState(ALL_APPS) && !ALL_APPS.equals(toState)) {
- // For atomic animations, we close the keyboard immediately.
- if (!config.userControlled && mShouldControlKeyboard) {
- mLauncher.getAppsView().getSearchUiManager().getEditText().hideKeyboard();
- }
-
builder.addEndListener(success -> {
// Reset pull back progress and alpha after switching states.
ALL_APPS_PULL_BACK_TRANSLATION.set(this, ALL_APPS_PULL_BACK_TRANSLATION_DEFAULT);
ALL_APPS_PULL_BACK_ALPHA.set(this, ALL_APPS_PULL_BACK_ALPHA_DEFAULT);
- // We only want to close the keyboard if the animation has completed successfully.
- // The reason is that with keyboard sync, if the user swipes down from All Apps with
- // the keyboard open and then changes their mind and swipes back up, we want the
- // keyboard to remain open. However an onCancel signal is sent to the listeners
- // (success = false), so we need to check for that.
- if (config.userControlled && success && mShouldControlKeyboard) {
- mLauncher.getAppsView().getSearchUiManager().getEditText().hideKeyboard();
- }
-
mAllAppScale.updateValue(1f);
});
}
@@ -390,7 +370,6 @@
config.userControlled ? LINEAR : DECELERATE_1_7);
Animator anim = createSpringAnimation(mProgress, targetProgress);
anim.setInterpolator(verticalProgressInterpolator);
- anim.addListener(getProgressAnimatorListener());
builder.add(anim);
setAlphas(toState, config, builder);
@@ -428,10 +407,6 @@
mScrimView.setDrawingController(shouldProtectHeader ? mAppsView : null);
}
- public AnimatorListener getProgressAnimatorListener() {
- return AnimatorListeners.forSuccessCallback(this::onProgressAnimationEnd);
- }
-
/**
* see Launcher#setupViews
*/
@@ -445,8 +420,6 @@
mAppsViewAlpha.setUpdateVisibility(true);
mAppsViewTranslationY = new MultiPropertyFactory<>(
mAppsView, VIEW_TRANSLATE_Y, APPS_VIEW_INDEX_COUNT, Float::sum);
-
- mShouldControlKeyboard = !mLauncher.getSearchConfig().isKeyboardSyncEnabled();
}
/**
@@ -530,18 +503,6 @@
}
/**
- * Set the final view states based on the progress.
- * TODO: This logic should go in {@link LauncherState}
- */
- private void onProgressAnimationEnd() {
- if (Float.compare(mProgress, 1f) == 0) {
- if (mShouldControlKeyboard) {
- mLauncher.getAppsView().getSearchUiManager().getEditText().hideKeyboard();
- }
- }
- }
-
- /**
* This VibrationAnimatorUpdateListener class takes in four parameters, a controller, start
* threshold, end threshold, and a Vibrator wrapper. We use the progress given by the controller
* as it gives an accurate progress that dictates where the vibrator should vibrate.
diff --git a/src/com/android/launcher3/allapps/BaseSearchConfig.java b/src/com/android/launcher3/allapps/BaseSearchConfig.java
deleted file mode 100644
index 9f47e8d..0000000
--- a/src/com/android/launcher3/allapps/BaseSearchConfig.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.allapps;
-
-/** Base config values for search. */
-public class BaseSearchConfig {
- public BaseSearchConfig() {}
-
- /**
- * Returns whether to enable the synchronized keyboard transition between Home and All Apps.
- */
- public boolean isKeyboardSyncEnabled() {
- return false;
- }
-}
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index b8787fd..9c0a508 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -23,13 +23,10 @@
import static com.android.launcher3.uioverrides.flags.FlagsFactory.getDebugFlag;
import static com.android.launcher3.uioverrides.flags.FlagsFactory.getReleaseFlag;
-import android.content.Context;
-
import androidx.annotation.VisibleForTesting;
import com.android.launcher3.BuildConfig;
import com.android.launcher3.Flags;
-import com.android.launcher3.Utilities;
import java.util.function.Predicate;
import java.util.function.ToIntFunction;
@@ -48,10 +45,6 @@
private FeatureFlags() { }
- public static boolean showFlagTogglerUi(Context context) {
- return BuildConfig.IS_DEBUG_DEVICE && Utilities.isDevelopersOptionsEnabled(context);
- }
-
/**
* True when the build has come from Android Studio and is being used for local debugging.
* @deprecated Use {@link BuildConfig#IS_STUDIO_BUILD} directly
diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java
index 6ab8fc5..1ab0355 100644
--- a/src/com/android/launcher3/model/LoaderTask.java
+++ b/src/com/android/launcher3/model/LoaderTask.java
@@ -18,6 +18,7 @@
import static com.android.launcher3.BuildConfig.WIDGET_ON_FIRST_SCREEN;
import static com.android.launcher3.LauncherPrefs.SHOULD_SHOW_SMARTSPACE;
+import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APP_PAIR;
import static com.android.launcher3.LauncherSettings.Favorites.TABLE_NAME;
import static com.android.launcher3.config.FeatureFlags.ENABLE_SMARTSPACE_REMOVAL;
import static com.android.launcher3.config.FeatureFlags.SMARTSPACE_AS_A_WIDGET;
@@ -480,7 +481,10 @@
// for now. Database will be updated once user manually modifies folder.
for (int rank = 0; rank < size; ++rank) {
WorkspaceItemInfo info = folder.contents.get(rank);
- info.rank = rank;
+ // rank is used differently in app pairs, so don't reset
+ if (folder.itemType != ITEM_TYPE_APP_PAIR) {
+ info.rank = rank;
+ }
if (info.usingLowResIcon()
&& info.itemType == Favorites.ITEM_TYPE_APPLICATION
diff --git a/src/com/android/launcher3/provider/RestoreDbTask.java b/src/com/android/launcher3/provider/RestoreDbTask.java
index 10005e5..dbd13b3 100644
--- a/src/com/android/launcher3/provider/RestoreDbTask.java
+++ b/src/com/android/launcher3/provider/RestoreDbTask.java
@@ -529,13 +529,6 @@
}
}
- public static void setRestoredAppWidgetIds(Context context, @NonNull int[] oldIds,
- @NonNull int[] newIds) {
- LauncherPrefs.get(context).putSync(
- OLD_APP_WIDGET_IDS.to(IntArray.wrap(oldIds).toConcatString()),
- APP_WIDGET_IDS.to(IntArray.wrap(newIds).toConcatString()));
- }
-
protected static void maybeOverrideShortcuts(Context context, ModelDbController controller,
SQLiteDatabase db, long currentUser) {
Map<String, LauncherActivityInfo> activityOverrides = ApiWrapper.getActivityOverrides(
diff --git a/src/com/android/launcher3/settings/NotificationDotsPreference.java b/src/com/android/launcher3/settings/NotificationDotsPreference.java
index 1816e7b..ac5571f 100644
--- a/src/com/android/launcher3/settings/NotificationDotsPreference.java
+++ b/src/com/android/launcher3/settings/NotificationDotsPreference.java
@@ -15,8 +15,7 @@
*/
package com.android.launcher3.settings;
-import static com.android.launcher3.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
-import static com.android.launcher3.settings.SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGS;
+import static com.android.launcher3.settings.SettingsActivity.EXTRA_FRAGMENT_HIGHLIGHT_KEY;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
@@ -51,6 +50,7 @@
/** Hidden field Settings.Secure.ENABLED_NOTIFICATION_LISTENERS */
private static final String NOTIFICATION_ENABLED_LISTENERS = "enabled_notification_listeners";
+ private static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args";
private final ContentObserver mListenerListObserver =
new ContentObserver(MAIN_EXECUTOR.getHandler()) {
@@ -88,7 +88,7 @@
// Update intent
Bundle extras = new Bundle();
- extras.putString(EXTRA_FRAGMENT_ARG_KEY, "notification_badging");
+ extras.putString(EXTRA_FRAGMENT_HIGHLIGHT_KEY, "notification_badging");
setIntent(new Intent("android.settings.NOTIFICATION_SETTINGS")
.putExtra(EXTRA_SHOW_FRAGMENT_ARGS, extras));
@@ -169,11 +169,11 @@
public void onClick(DialogInterface dialogInterface, int i) {
ComponentName cn = new ComponentName(getActivity(), NotificationListener.class);
Bundle showFragmentArgs = new Bundle();
- showFragmentArgs.putString(EXTRA_FRAGMENT_ARG_KEY, cn.flattenToString());
+ showFragmentArgs.putString(EXTRA_FRAGMENT_HIGHLIGHT_KEY, cn.flattenToString());
Intent intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- .putExtra(EXTRA_FRAGMENT_ARG_KEY, cn.flattenToString())
+ .putExtra(EXTRA_FRAGMENT_HIGHLIGHT_KEY, cn.flattenToString())
.putExtra(EXTRA_SHOW_FRAGMENT_ARGS, showFragmentArgs);
getActivity().startActivity(intent);
}
diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java
index 623b557..228af4c 100644
--- a/src/com/android/launcher3/settings/SettingsActivity.java
+++ b/src/com/android/launcher3/settings/SettingsActivity.java
@@ -16,19 +16,26 @@
package com.android.launcher3.settings;
-import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS;
+import static android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED;
-import static com.android.launcher3.config.FeatureFlags.IS_STUDIO_BUILD;
+import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS;
+import static androidx.preference.PreferenceFragmentCompat.ARG_PREFERENCE_ROOT;
+
+import static com.android.launcher3.BuildConfig.IS_DEBUG_DEVICE;
+import static com.android.launcher3.BuildConfig.IS_STUDIO_BUILD;
import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY;
+import android.app.Activity;
import android.content.Intent;
-import android.content.SharedPreferences;
+import android.net.Uri;
import android.os.Bundle;
+import android.provider.Settings;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.view.WindowCompat;
import androidx.fragment.app.DialogFragment;
@@ -36,6 +43,7 @@
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartFragmentCallback;
import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartScreenCallback;
@@ -43,59 +51,51 @@
import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;
+import com.android.launcher3.BuildConfig;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherFiles;
-import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.states.RotationHelper;
-import com.android.launcher3.uioverrides.flags.DeveloperOptionsFragment;
-import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
+import com.android.launcher3.uioverrides.flags.DeveloperOptionsUI;
import com.android.launcher3.util.DisplayController;
-
-import java.util.Collections;
-import java.util.List;
+import com.android.launcher3.util.Executors;
+import com.android.launcher3.util.SettingsCache;
/**
* Settings activity for Launcher. Currently implements the following setting: Allow rotation
*/
public class SettingsActivity extends FragmentActivity
- implements OnPreferenceStartFragmentCallback, OnPreferenceStartScreenCallback,
- SharedPreferences.OnSharedPreferenceChangeListener{
+ implements OnPreferenceStartFragmentCallback, OnPreferenceStartScreenCallback {
- /** List of fragments that can be hosted by this activity. */
- private static final List<String> VALID_PREFERENCE_FRAGMENTS =
- !Utilities.IS_DEBUG_DEVICE ? Collections.emptyList()
- : Collections.singletonList(DeveloperOptionsFragment.class.getName());
-
- private static final String DEVELOPER_OPTIONS_KEY = "pref_developer_options";
- private static final String FLAGS_PREFERENCE_KEY = "flag_toggler";
+ @VisibleForTesting
+ static final String DEVELOPER_OPTIONS_KEY = "pref_developer_options";
private static final String NOTIFICATION_DOTS_PREFERENCE_KEY = "pref_icon_badging";
- public static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key";
- public static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args";
+ public static final String EXTRA_FRAGMENT_ARGS = ":settings:fragment_args";
+
+ // Intent extra to indicate the pref-key to highlighted when opening the settings activity
+ public static final String EXTRA_FRAGMENT_HIGHLIGHT_KEY = ":settings:fragment_args_key";
+ // Intent extra to indicate the pref-key of the root screen when opening the settings activity
+ public static final String EXTRA_FRAGMENT_ROOT_KEY = ARG_PREFERENCE_ROOT;
+
private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 600;
public static final String SAVE_HIGHLIGHTED_KEY = "android:preference_highlighted";
- @VisibleForTesting
- static final String EXTRA_FRAGMENT = ":settings:fragment";
- @VisibleForTesting
- static final String EXTRA_FRAGMENT_ARGS = ":settings:fragment_args";
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
+
setActionBar(findViewById(R.id.action_bar));
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
Intent intent = getIntent();
- if (intent.hasExtra(EXTRA_FRAGMENT) || intent.hasExtra(EXTRA_FRAGMENT_ARGS)
- || intent.hasExtra(EXTRA_FRAGMENT_ARG_KEY)) {
+ if (intent.hasExtra(EXTRA_FRAGMENT_ROOT_KEY) || intent.hasExtra(EXTRA_FRAGMENT_ARGS)
+ || intent.hasExtra(EXTRA_FRAGMENT_HIGHLIGHT_KEY)) {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
@@ -105,46 +105,24 @@
args = new Bundle();
}
- String prefKey = intent.getStringExtra(EXTRA_FRAGMENT_ARG_KEY);
- if (!TextUtils.isEmpty(prefKey)) {
- args.putString(EXTRA_FRAGMENT_ARG_KEY, prefKey);
+ String highlight = intent.getStringExtra(EXTRA_FRAGMENT_HIGHLIGHT_KEY);
+ if (!TextUtils.isEmpty(highlight)) {
+ args.putString(EXTRA_FRAGMENT_HIGHLIGHT_KEY, highlight);
+ }
+ String root = intent.getStringExtra(EXTRA_FRAGMENT_ROOT_KEY);
+ if (!TextUtils.isEmpty(root)) {
+ args.putString(EXTRA_FRAGMENT_ROOT_KEY, root);
}
final FragmentManager fm = getSupportFragmentManager();
final Fragment f = fm.getFragmentFactory().instantiate(getClassLoader(),
- getPreferenceFragment());
+ getString(R.string.settings_fragment_name));
f.setArguments(args);
// Display the fragment as the main content.
fm.beginTransaction().replace(R.id.content_frame, f).commit();
}
- LauncherPrefs.getPrefs(getApplicationContext())
- .registerOnSharedPreferenceChangeListener(this);
}
- /**
- * Obtains the preference fragment to instantiate in this activity.
- *
- * @return the preference fragment class
- * @throws IllegalArgumentException if the fragment is unknown to this activity
- */
- private String getPreferenceFragment() {
- String preferenceFragment = getIntent().getStringExtra(EXTRA_FRAGMENT);
- String defaultFragment = getString(R.string.settings_fragment_name);
-
- if (TextUtils.isEmpty(preferenceFragment)) {
- return defaultFragment;
- } else if (!preferenceFragment.equals(defaultFragment)
- && !VALID_PREFERENCE_FRAGMENTS.contains(preferenceFragment)) {
- throw new IllegalArgumentException(
- "Invalid fragment for this activity: " + preferenceFragment);
- } else {
- return preferenceFragment;
- }
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { }
-
private boolean startPreference(String fragment, Bundle args, String key) {
if (Utilities.ATLEAST_P && getSupportFragmentManager().isStateSaved()) {
// Sometimes onClick can come after onPause because of being posted on the handler.
@@ -158,7 +136,6 @@
((DialogFragment) f).show(fm, key);
} else {
startActivity(new Intent(this, SettingsActivity.class)
- .putExtra(EXTRA_FRAGMENT, fragment)
.putExtra(EXTRA_FRAGMENT_ARGS, args));
}
return true;
@@ -173,7 +150,7 @@
@Override
public boolean onPreferenceStartScreen(PreferenceFragmentCompat caller, PreferenceScreen pref) {
Bundle args = new Bundle();
- args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, pref.getKey());
+ args.putString(ARG_PREFERENCE_ROOT, pref.getKey());
return startPreference(getString(R.string.settings_fragment_name), args, pref.getKey());
}
@@ -189,19 +166,31 @@
/**
* This fragment shows the launcher preferences.
*/
- public static class LauncherSettingsFragment extends PreferenceFragmentCompat {
+ public static class LauncherSettingsFragment extends PreferenceFragmentCompat implements
+ SettingsCache.OnChangeListener {
+
+ protected boolean mDeveloperOptionsEnabled = false;
+
+ private boolean mRestartOnResume = false;
private String mHighLightKey;
private boolean mPreferenceHighlighted = false;
- private Preference mDeveloperOptionPref;
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ if (BuildConfig.IS_DEBUG_DEVICE) {
+ Uri devUri = Settings.Global.getUriFor(DEVELOPMENT_SETTINGS_ENABLED);
+ SettingsCache settingsCache = SettingsCache.INSTANCE.get(getContext());
+ mDeveloperOptionsEnabled = settingsCache.getValue(devUri);
+ settingsCache.register(devUri, this);
+ }
+ super.onCreate(savedInstanceState);
+ }
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
final Bundle args = getArguments();
- mHighLightKey = args == null ? null : args.getString(EXTRA_FRAGMENT_ARG_KEY);
- if (rootKey == null && !TextUtils.isEmpty(mHighLightKey)) {
- rootKey = getParentKeyForPref(mHighLightKey);
- }
+ mHighLightKey = args == null ? null : args.getString(EXTRA_FRAGMENT_HIGHLIGHT_KEY);
if (savedInstanceState != null) {
mPreferenceHighlighted = savedInstanceState.getBoolean(SAVE_HIGHLIGHTED_KEY);
@@ -213,11 +202,7 @@
PreferenceScreen screen = getPreferenceScreen();
for (int i = screen.getPreferenceCount() - 1; i >= 0; i--) {
Preference preference = screen.getPreference(i);
- if (initPreference(preference)) {
- if (IS_STUDIO_BUILD && preference == mDeveloperOptionPref) {
- preference.setOrder(0);
- }
- } else {
+ if (!initPreference(preference)) {
screen.removePreference(preference);
}
}
@@ -249,6 +234,7 @@
bottomPadding + insets.getSystemWindowInsetBottom());
return insets.consumeSystemWindowInsets();
});
+
// Overriding Text Direction in the Androidx preference library to support RTL
view.setTextDirection(View.TEXT_DIRECTION_LOCALE);
}
@@ -259,10 +245,6 @@
outState.putBoolean(SAVE_HIGHLIGHTED_KEY, mPreferenceHighlighted);
}
- protected String getParentKeyForPref(String key) {
- return null;
- }
-
/**
* Initializes a preference. This is called for every preference. Returning false here
* will remove that preference from the list.
@@ -283,42 +265,26 @@
preference.setDefaultValue(RotationHelper.getAllowRotationDefaultValue(info));
return true;
- case FLAGS_PREFERENCE_KEY:
- // Only show flag toggler UI if this build variant implements that.
- return FeatureFlags.showFlagTogglerUi(getContext());
-
case DEVELOPER_OPTIONS_KEY:
- mDeveloperOptionPref = preference;
- return updateDeveloperOption();
+ if (IS_STUDIO_BUILD) {
+ preference.setOrder(0);
+ }
+ return mDeveloperOptionsEnabled;
+ case "pref_developer_flags":
+ if (mDeveloperOptionsEnabled && preference instanceof PreferenceCategory pc) {
+ Executors.MAIN_EXECUTOR.post(() -> new DeveloperOptionsUI(this, pc));
+ return true;
+ }
+ return false;
}
return true;
}
- /**
- * Show if plugins are enabled or flag UI is enabled.
- * @return True if we should show the preference option.
- */
- private boolean updateDeveloperOption() {
- boolean showPreference = FeatureFlags.showFlagTogglerUi(getContext())
- || PluginManagerWrapper.hasPlugins(getContext());
- if (mDeveloperOptionPref != null) {
- mDeveloperOptionPref.setEnabled(showPreference);
- if (showPreference) {
- getPreferenceScreen().addPreference(mDeveloperOptionPref);
- } else {
- getPreferenceScreen().removePreference(mDeveloperOptionPref);
- }
- }
- return showPreference;
- }
-
@Override
public void onResume() {
super.onResume();
- updateDeveloperOption();
-
if (isAdded() && !mPreferenceHighlighted) {
PreferenceHighlighter highlighter = createHighlighter();
if (highlighter != null) {
@@ -328,6 +294,43 @@
requestAccessibilityFocus(getListView());
}
}
+
+ if (mRestartOnResume) {
+ recreateActivityNow();
+ }
+ }
+
+ @Override
+ public void onSettingsChanged(boolean isEnabled) {
+ // Developer options changed, try recreate
+ tryRecreateActivity();
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ if (IS_DEBUG_DEVICE) {
+ SettingsCache.INSTANCE.get(getContext())
+ .unregister(Settings.Global.getUriFor(DEVELOPMENT_SETTINGS_ENABLED), this);
+ }
+ }
+
+ /**
+ * Tries to recreate the preference
+ */
+ protected void tryRecreateActivity() {
+ if (isResumed()) {
+ recreateActivityNow();
+ } else {
+ mRestartOnResume = true;
+ }
+ }
+
+ private void recreateActivityNow() {
+ Activity activity = getActivity();
+ if (activity != null) {
+ activity.recreate();
+ }
}
private PreferenceHighlighter createHighlighter() {
diff --git a/src/com/android/launcher3/util/CellContentDimensions.kt b/src/com/android/launcher3/util/CellContentDimensions.kt
new file mode 100644
index 0000000..3c8e0c4
--- /dev/null
+++ b/src/com/android/launcher3/util/CellContentDimensions.kt
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2023 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.util
+
+import com.android.launcher3.Utilities
+import kotlin.math.max
+
+class CellContentDimensions(
+ var iconSizePx: Int,
+ var iconDrawablePaddingPx: Int,
+ var iconTextSizePx: Int
+) {
+ /**
+ * This method goes through some steps to reduce the padding between icon and label, icon size
+ * and then label size, until it can fit in the [cellHeightPx].
+ *
+ * @return the height of the content after being sized down.
+ */
+ fun resizeToFitCellHeight(cellHeightPx: Int, iconSizeSteps: IconSizeSteps): Int {
+ var cellContentHeight = getCellContentHeight()
+
+ // Step 1. Decrease drawable padding
+ if (cellContentHeight > cellHeightPx) {
+ val diff = cellContentHeight - cellHeightPx
+ iconDrawablePaddingPx = max(0, iconDrawablePaddingPx - diff)
+ cellContentHeight = getCellContentHeight()
+ }
+
+ while (
+ (iconTextSizePx > iconSizeSteps.minimumIconLabelSize ||
+ iconSizePx > iconSizeSteps.minimumIconSize()) && cellContentHeight > cellHeightPx
+ ) {
+ // Step 2. Decrease icon size
+ iconSizePx = iconSizeSteps.getNextLowerIconSize(iconSizePx)
+ cellContentHeight = getCellContentHeight()
+
+ // Step 3. Decrease label size
+ if (cellContentHeight > cellHeightPx) {
+ iconTextSizePx =
+ max(
+ iconSizeSteps.minimumIconLabelSize,
+ iconTextSizePx - IconSizeSteps.TEXT_STEP
+ )
+ cellContentHeight = getCellContentHeight()
+ }
+ }
+
+ return cellContentHeight
+ }
+
+ /** Calculate new cellContentHeight */
+ fun getCellContentHeight(): Int {
+ val iconTextHeight = Utilities.calculateTextHeight(iconTextSizePx.toFloat())
+ return iconSizePx + iconDrawablePaddingPx + iconTextHeight
+ }
+}
diff --git a/src/com/android/launcher3/util/IconSizeSteps.kt b/src/com/android/launcher3/util/IconSizeSteps.kt
index 2a5afe0..aa644b0 100644
--- a/src/com/android/launcher3/util/IconSizeSteps.kt
+++ b/src/com/android/launcher3/util/IconSizeSteps.kt
@@ -23,12 +23,14 @@
class IconSizeSteps(res: Resources) {
private val steps: List<Int>
+ val minimumIconLabelSize: Int
init {
steps =
res.obtainTypedArray(R.array.icon_size_steps).use {
(0 until it.length()).map { step -> it.getDimensionOrThrow(step).toInt() }.sorted()
}
+ minimumIconLabelSize = res.getDimensionPixelSize(R.dimen.minimum_icon_label_size)
}
fun minimumIconSize(): Int = steps[0]
@@ -44,4 +46,8 @@
private fun getIndexForIconSize(iconSizePx: Int): Int {
return max(0, steps.indexOfFirst { iconSizePx <= it })
}
+
+ companion object {
+ internal const val TEXT_STEP = 1
+ }
}
diff --git a/src/com/android/launcher3/util/SettingsCache.java b/src/com/android/launcher3/util/SettingsCache.java
index 06cb00e..29ec5ab 100644
--- a/src/com/android/launcher3/util/SettingsCache.java
+++ b/src/com/android/launcher3/util/SettingsCache.java
@@ -25,8 +25,6 @@
import android.os.Handler;
import android.provider.Settings;
-import androidx.annotation.VisibleForTesting;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -61,6 +59,7 @@
Settings.System.getUriFor(ACCELEROMETER_ROTATION);
private static final String SYSTEM_URI_PREFIX = Settings.System.CONTENT_URI.toString();
+ private static final String GLOBAL_URI_PREFIX = Settings.Global.CONTENT_URI.toString();
/**
* Caches the last seen value for registered keys.
@@ -139,6 +138,8 @@
boolean newVal;
if (keyUri.toString().startsWith(SYSTEM_URI_PREFIX)) {
newVal = Settings.System.getInt(mResolver, key, defaultValue) == 1;
+ } else if (keyUri.toString().startsWith(GLOBAL_URI_PREFIX)) {
+ newVal = Settings.Global.getInt(mResolver, key, defaultValue) == 1;
} else { // SETTING_SECURE
newVal = Settings.Secure.getInt(mResolver, key, defaultValue) == 1;
}
@@ -154,23 +155,9 @@
*/
public void unregister(Uri uri, OnChangeListener listener) {
List<OnChangeListener> listenersToRemoveFrom = mListenerMap.get(uri);
- if (listenersToRemoveFrom == null) {
- return;
+ if (listenersToRemoveFrom != null) {
+ listenersToRemoveFrom.remove(listener);
}
-
- listenersToRemoveFrom.remove(listener);
- if (listenersToRemoveFrom.isEmpty()) {
- mListenerMap.remove(uri);
- }
- }
-
- /**
- * Don't use this. Ever.
- * @param keyCache Cache to replace {@link #mKeyCache}
- */
- @VisibleForTesting
- void setKeyCache(Map<Uri, Boolean> keyCache) {
- mKeyCache = keyCache;
}
public interface OnChangeListener {
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java b/src_ui_overrides/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java
similarity index 75%
rename from src_ui_overrides/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java
rename to src_ui_overrides/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java
index 68843f2..6afa446 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java
@@ -15,8 +15,13 @@
*/
package com.android.launcher3.uioverrides.flags;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceFragmentCompat;
+
/**
* Place holder class for developer options.
*/
-public class DeveloperOptionsFragment {
+public class DeveloperOptionsUI {
+
+ public DeveloperOptionsUI(PreferenceFragmentCompat fragment, PreferenceCategory flags) { }
}
diff --git a/tests/Android.bp b/tests/Android.bp
index a3d05bb..8725b46 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -40,19 +40,14 @@
"src/com/android/launcher3/ui/PortraitLandscapeRunner.java",
"src/com/android/launcher3/ui/TestViewHelpers.java",
"src/com/android/launcher3/util/LauncherLayoutBuilder.java",
+ "src/com/android/launcher3/util/ModelTestExtensions.kt",
"src/com/android/launcher3/util/TestConstants.java",
"src/com/android/launcher3/util/TestUtil.java",
"src/com/android/launcher3/util/Wait.java",
"src/com/android/launcher3/util/WidgetUtils.java",
- "src/com/android/launcher3/util/rule/FailureWatcher.java",
- "src/com/android/launcher3/util/rule/ViewCaptureRule.kt",
+ "src/com/android/launcher3/util/rule/*.java",
+ "src/com/android/launcher3/util/rule/*.kt",
"src/com/android/launcher3/util/viewcapture_analysis/*.java",
- "src/com/android/launcher3/util/rule/SamplerRule.java",
- "src/com/android/launcher3/util/rule/ScreenRecordRule.java",
- "src/com/android/launcher3/util/rule/ShellCommandRule.java",
- "src/com/android/launcher3/util/rule/TestIsolationRule.java",
- "src/com/android/launcher3/util/rule/TestStabilityRule.java",
- "src/com/android/launcher3/util/ModelTestExtensions.kt",
"src/com/android/launcher3/testcomponent/*.java",
"src/com/android/launcher3/testcomponent/*.kt",
],
diff --git a/tests/src/com/android/launcher3/AppWidgetsRestoredReceiverTest.kt b/tests/src/com/android/launcher3/AppWidgetsRestoredReceiverTest.kt
new file mode 100644
index 0000000..21abab4
--- /dev/null
+++ b/tests/src/com/android/launcher3/AppWidgetsRestoredReceiverTest.kt
@@ -0,0 +1,171 @@
+package com.android.launcher3
+
+import android.appwidget.AppWidgetManager.ACTION_APPWIDGET_DELETED
+import android.appwidget.AppWidgetManager.ACTION_APPWIDGET_HOST_RESTORED
+import android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_IDS
+import android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_OLD_IDS
+import android.appwidget.AppWidgetManager.EXTRA_HOST_ID
+import android.content.Intent
+import android.platform.uiautomator_helpers.DeviceHelpers
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.launcher3.LauncherPrefs.Companion.APP_WIDGET_IDS
+import com.android.launcher3.LauncherPrefs.Companion.OLD_APP_WIDGET_IDS
+import com.android.launcher3.util.IntArray
+import com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE
+import com.android.launcher3.widget.LauncherWidgetHolder.APPWIDGET_HOST_ID
+import com.google.common.truth.Truth.assertThat
+import org.junit.After
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/** Tests for [AppWidgetsRestoredReceiver] */
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class AppWidgetsRestoredReceiverTest {
+ private lateinit var launcherPrefs: LauncherPrefs
+ private lateinit var receiverUnderTest: AppWidgetsRestoredReceiver
+
+ @Before
+ fun setup() {
+ launcherPrefs = LauncherPrefs(DeviceHelpers.context)
+ receiverUnderTest = AppWidgetsRestoredReceiver()
+ }
+
+ @After
+ fun tearDown() {
+ launcherPrefs.remove(OLD_APP_WIDGET_IDS, APP_WIDGET_IDS)
+ }
+
+ @Test
+ fun `When AppWidgetsRestoredReceiver gets valid broadcast it sets old and new app widget ids`() {
+ // Given
+ val oldIds = intArrayOf(1, 2, 10)
+ val newIds = intArrayOf(10, 11, 12)
+ val expectedOldIds = IntArray.wrap(*oldIds).toConcatString()
+ val expectedNewIds = IntArray.wrap(*newIds).toConcatString()
+ val intent =
+ Intent().apply {
+ component = null
+ `package` = TEST_PACKAGE
+ action = ACTION_APPWIDGET_HOST_RESTORED
+ putExtra(EXTRA_APPWIDGET_OLD_IDS, oldIds)
+ putExtra(EXTRA_APPWIDGET_IDS, newIds)
+ putExtra(EXTRA_HOST_ID, APPWIDGET_HOST_ID)
+ }
+
+ // When
+ receiverUnderTest.onReceive(DeviceHelpers.context, intent)
+
+ // Then
+ assertThat(launcherPrefs.get(OLD_APP_WIDGET_IDS)).isEqualTo(expectedOldIds)
+ assertThat(launcherPrefs.get(APP_WIDGET_IDS)).isEqualTo(expectedNewIds)
+ }
+
+ @Test
+ fun `AppWidgetsRestoredReceiver does not set widget ids when Intent action is invalid`() {
+ // Given
+ val oldIds = intArrayOf(1, 2, 10)
+ val newIds = intArrayOf(10, 11, 12)
+ val intent =
+ Intent().apply {
+ component = null
+ `package` = TEST_PACKAGE
+ action = ACTION_APPWIDGET_DELETED
+ putExtra(EXTRA_APPWIDGET_OLD_IDS, oldIds)
+ putExtra(EXTRA_APPWIDGET_IDS, newIds)
+ putExtra(EXTRA_HOST_ID, APPWIDGET_HOST_ID)
+ }
+
+ // When
+ receiverUnderTest.onReceive(DeviceHelpers.context, intent)
+
+ // Then
+ assertThat(launcherPrefs.has(OLD_APP_WIDGET_IDS, APP_WIDGET_IDS)).isFalse()
+ }
+
+ @Test
+ fun `AppWidgetsRestoredReceiver does not set widget ids when Intent host id is not Launcher`() {
+ // Given
+ val oldIds = intArrayOf(1, 2, 10)
+ val newIds = intArrayOf(10, 11, 12)
+ val intent =
+ Intent().apply {
+ component = null
+ `package` = TEST_PACKAGE
+ action = ACTION_APPWIDGET_HOST_RESTORED
+ putExtra(EXTRA_APPWIDGET_OLD_IDS, oldIds)
+ putExtra(EXTRA_APPWIDGET_IDS, newIds)
+ putExtra(EXTRA_HOST_ID, 999999999)
+ }
+
+ // When
+ receiverUnderTest.onReceive(DeviceHelpers.context, intent)
+
+ // Then
+ assertThat(launcherPrefs.has(OLD_APP_WIDGET_IDS, APP_WIDGET_IDS)).isFalse()
+ }
+
+ @Test
+ fun `AppWidgetsRestoredReceiver does not set ids when new and old ids differ in length`() {
+ // Given
+ val oldIds = intArrayOf(10)
+ val newIds = intArrayOf(10, 11, 12)
+ val intent =
+ Intent().apply {
+ component = null
+ `package` = TEST_PACKAGE
+ action = ACTION_APPWIDGET_HOST_RESTORED
+ putExtra(EXTRA_APPWIDGET_OLD_IDS, oldIds)
+ putExtra(EXTRA_APPWIDGET_IDS, newIds)
+ putExtra(EXTRA_HOST_ID, APPWIDGET_HOST_ID)
+ }
+
+ // When
+ receiverUnderTest.onReceive(DeviceHelpers.context, intent)
+
+ // Then
+ assertThat(launcherPrefs.has(OLD_APP_WIDGET_IDS, APP_WIDGET_IDS)).isFalse()
+ }
+
+ @Test
+ fun `AppWidgetsRestoredReceiver does not set widget ids when old ids not set`() {
+ // Given
+ val newIds = intArrayOf(10, 11, 12)
+ val intent =
+ Intent().apply {
+ component = null
+ `package` = TEST_PACKAGE
+ action = ACTION_APPWIDGET_HOST_RESTORED
+ putExtra(EXTRA_APPWIDGET_IDS, newIds)
+ putExtra(EXTRA_HOST_ID, APPWIDGET_HOST_ID)
+ }
+
+ // When
+ receiverUnderTest.onReceive(DeviceHelpers.context, intent)
+
+ // Then
+ assertThat(launcherPrefs.has(OLD_APP_WIDGET_IDS, APP_WIDGET_IDS)).isFalse()
+ }
+
+ @Test
+ fun `AppWidgetsRestoredReceiver does not set widget ids when new ids not set`() {
+ // Given
+ val oldIds = intArrayOf(10, 11, 12)
+ val intent =
+ Intent().apply {
+ component = null
+ `package` = TEST_PACKAGE
+ action = ACTION_APPWIDGET_HOST_RESTORED
+ putExtra(EXTRA_APPWIDGET_OLD_IDS, oldIds)
+ putExtra(EXTRA_HOST_ID, APPWIDGET_HOST_ID)
+ }
+
+ // When
+ receiverUnderTest.onReceive(DeviceHelpers.context, intent)
+
+ // Then
+ assertThat(launcherPrefs.has(OLD_APP_WIDGET_IDS, APP_WIDGET_IDS)).isFalse()
+ }
+}
diff --git a/tests/src/com/android/launcher3/provider/RestoreDbTaskTest.java b/tests/src/com/android/launcher3/provider/RestoreDbTaskTest.java
index a21c9b9..10d9133 100644
--- a/tests/src/com/android/launcher3/provider/RestoreDbTaskTest.java
+++ b/tests/src/com/android/launcher3/provider/RestoreDbTaskTest.java
@@ -60,6 +60,7 @@
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.model.ModelDbController;
+import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.LauncherModelHelper;
import org.junit.After;
@@ -233,7 +234,7 @@
mPrefs.remove(RESTORE_DEVICE);
// When
- RestoreDbTask.setRestoredAppWidgetIds(mContext, expectedOldIds, expectedNewIds);
+ setRestoredAppWidgetIds(mContext, expectedOldIds, expectedNewIds);
mTask.restoreAppWidgetIdsIfExists(mContext, mMockController);
// Then
@@ -255,7 +256,7 @@
RestoreDbTask.setPending(mContext);
// When
- RestoreDbTask.setRestoredAppWidgetIds(mContext, expectedOldIds, expectedNewIds);
+ setRestoredAppWidgetIds(mContext, expectedOldIds, expectedNewIds);
mTask.restoreAppWidgetIdsIfExists(mContext, mMockController);
// Then
@@ -283,7 +284,7 @@
RestoreDbTask.setPending(mContext);
// When
- RestoreDbTask.setRestoredAppWidgetIds(mContext, expectedOldIds, expectedNewIds);
+ setRestoredAppWidgetIds(mContext, expectedOldIds, expectedNewIds);
mTask.restoreAppWidgetIdsIfExists(mContext, mMockController);
// Then
@@ -402,4 +403,10 @@
return index >= 0 ? users.keyAt(index) : -1;
}
}
+
+ private void setRestoredAppWidgetIds(Context context, int[] oldIds, int[] newIds) {
+ LauncherPrefs.get(context).putSync(
+ OLD_APP_WIDGET_IDS.to(IntArray.wrap(oldIds).toConcatString()),
+ APP_WIDGET_IDS.to(IntArray.wrap(newIds).toConcatString()));
+ }
}
diff --git a/tests/src/com/android/launcher3/settings/SettingsActivityTest.java b/tests/src/com/android/launcher3/settings/SettingsActivityTest.java
index 837973f..10e0be8 100644
--- a/tests/src/com/android/launcher3/settings/SettingsActivityTest.java
+++ b/tests/src/com/android/launcher3/settings/SettingsActivityTest.java
@@ -31,8 +31,9 @@
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
-import static com.android.launcher3.settings.SettingsActivity.EXTRA_FRAGMENT;
+import static com.android.launcher3.settings.SettingsActivity.DEVELOPER_OPTIONS_KEY;
import static com.android.launcher3.settings.SettingsActivity.EXTRA_FRAGMENT_ARGS;
+import static com.android.launcher3.settings.SettingsActivity.EXTRA_FRAGMENT_ROOT_KEY;
import static com.google.common.truth.Truth.assertThat;
@@ -43,18 +44,15 @@
import android.content.Intent;
import android.os.Bundle;
-import androidx.preference.PreferenceFragmentCompat;
import androidx.test.core.app.ActivityScenario;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.espresso.intent.Intents;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.launcher3.R;
-import com.android.launcher3.uioverrides.flags.DeveloperOptionsFragment;
import com.android.systemui.shared.plugins.PluginPrefs;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -100,7 +98,7 @@
intended(allOf(
hasComponent(SettingsActivity.class.getName()),
- hasExtra(EXTRA_FRAGMENT, DeveloperOptionsFragment.class.getName())));
+ hasExtra(EXTRA_FRAGMENT_ROOT_KEY, DEVELOPER_OPTIONS_KEY)));
}
@Test
@@ -122,7 +120,7 @@
@Ignore // b/199309785
public void testSettings_developerOptionsFragmentIntent() {
Intent intent = new Intent(mApplicationContext, SettingsActivity.class)
- .putExtra(EXTRA_FRAGMENT, DeveloperOptionsFragment.class.getName());
+ .putExtra(EXTRA_FRAGMENT_ROOT_KEY, DEVELOPER_OPTIONS_KEY);
ActivityScenario.launch(intent);
onView(withText("Developer Options")).check(matches(isDisplayed()));
@@ -132,21 +130,6 @@
@Test
@Ignore // b/199309785
- public void testSettings_intentWithUnknownFragment() {
- String fragmentClass = PreferenceFragmentCompat.class.getName();
- Intent intent = new Intent(mApplicationContext, SettingsActivity.class)
- .putExtra(EXTRA_FRAGMENT, fragmentClass);
-
- try {
- ActivityScenario.launch(intent);
- Assert.fail("Should have thrown an IllegalArgumentException.");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(fragmentClass);
- }
- }
-
- @Test
- @Ignore // b/199309785
public void testSettings_backButtonFinishesActivity() {
Bundle fragmentArgs = new Bundle();
fragmentArgs.putString(ARG_PREFERENCE_ROOT, "about_screen");
diff --git a/tests/src/com/android/launcher3/util/CellContentDimensionsTest.kt b/tests/src/com/android/launcher3/util/CellContentDimensionsTest.kt
new file mode 100644
index 0000000..4770546
--- /dev/null
+++ b/tests/src/com/android/launcher3/util/CellContentDimensionsTest.kt
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2023 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.util
+
+import android.content.Context
+import android.content.res.Configuration
+import android.util.DisplayMetrics
+import androidx.test.core.app.ApplicationProvider
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.google.common.truth.Truth.assertThat
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class CellContentDimensionsTest {
+ private var context: Context? = null
+ private val runningContext: Context = ApplicationProvider.getApplicationContext()
+ private lateinit var iconSizeSteps: IconSizeSteps
+
+ @Before
+ fun setup() {
+ // 160dp makes 1px = 1dp
+ val config =
+ Configuration(runningContext.resources.configuration).apply {
+ this.densityDpi = DisplayMetrics.DENSITY_DEFAULT
+ }
+ context = runningContext.createConfigurationContext(config)
+ iconSizeSteps = IconSizeSteps(context!!.resources)
+ }
+
+ @Test
+ fun dimensionsFitTheCell() {
+ val cellSize = Pair(80, 104)
+ val cellContentDimensions =
+ CellContentDimensions(iconSizePx = 66, iconDrawablePaddingPx = 8, iconTextSizePx = 14)
+
+ val contentHeight =
+ cellContentDimensions.resizeToFitCellHeight(cellSize.second, iconSizeSteps)
+
+ assertThat(contentHeight).isEqualTo(93)
+ cellContentDimensions.run {
+ assertThat(iconSizePx).isEqualTo(66)
+ assertThat(iconDrawablePaddingPx).isEqualTo(8)
+ assertThat(iconTextSizePx).isEqualTo(14)
+ }
+ }
+
+ @Test
+ fun decreasePadding() {
+ val cellSize = Pair(67, 87)
+ val cellContentDimensions =
+ CellContentDimensions(iconSizePx = 66, iconDrawablePaddingPx = 8, iconTextSizePx = 14)
+
+ val contentHeight =
+ cellContentDimensions.resizeToFitCellHeight(cellSize.second, iconSizeSteps)
+
+ assertThat(contentHeight).isEqualTo(87)
+ cellContentDimensions.run {
+ assertThat(iconSizePx).isEqualTo(66)
+ assertThat(iconDrawablePaddingPx).isEqualTo(2)
+ assertThat(iconTextSizePx).isEqualTo(14)
+ }
+ }
+
+ @Test
+ fun decreaseIcon() {
+ val cellSize = Pair(65, 84)
+ val cellContentDimensions =
+ CellContentDimensions(iconSizePx = 66, iconDrawablePaddingPx = 8, iconTextSizePx = 14)
+
+ val contentHeight =
+ cellContentDimensions.resizeToFitCellHeight(cellSize.second, iconSizeSteps)
+
+ assertThat(contentHeight).isEqualTo(82)
+ cellContentDimensions.run {
+ assertThat(iconSizePx).isEqualTo(63)
+ assertThat(iconDrawablePaddingPx).isEqualTo(0)
+ assertThat(iconTextSizePx).isEqualTo(14)
+ }
+ }
+
+ @Test
+ fun decreaseText() {
+ val cellSize = Pair(63, 81)
+ val cellContentDimensions =
+ CellContentDimensions(iconSizePx = 66, iconDrawablePaddingPx = 8, iconTextSizePx = 14)
+
+ val contentHeight =
+ cellContentDimensions.resizeToFitCellHeight(cellSize.second, iconSizeSteps)
+
+ assertThat(contentHeight).isEqualTo(81)
+ cellContentDimensions.run {
+ assertThat(iconSizePx).isEqualTo(63)
+ assertThat(iconDrawablePaddingPx).isEqualTo(0)
+ assertThat(iconTextSizePx).isEqualTo(13)
+ }
+ }
+
+ @Test
+ fun decreaseIconAndTextTwoSteps() {
+ val cellSize = Pair(60, 78)
+ val cellContentDimensions =
+ CellContentDimensions(iconSizePx = 66, iconDrawablePaddingPx = 8, iconTextSizePx = 14)
+
+ val contentHeight =
+ cellContentDimensions.resizeToFitCellHeight(cellSize.second, iconSizeSteps)
+
+ assertThat(contentHeight).isEqualTo(77)
+ cellContentDimensions.run {
+ assertThat(iconSizePx).isEqualTo(61)
+ assertThat(iconDrawablePaddingPx).isEqualTo(0)
+ assertThat(iconTextSizePx).isEqualTo(12)
+ }
+ }
+
+ @Test
+ fun decreaseIconAndTextToMinimum() {
+ val cellSize = Pair(52, 63)
+ val cellContentDimensions =
+ CellContentDimensions(iconSizePx = 66, iconDrawablePaddingPx = 8, iconTextSizePx = 14)
+
+ val contentHeight =
+ cellContentDimensions.resizeToFitCellHeight(cellSize.second, iconSizeSteps)
+
+ assertThat(contentHeight).isEqualTo(63)
+ cellContentDimensions.run {
+ assertThat(iconSizePx).isEqualTo(52)
+ assertThat(iconDrawablePaddingPx).isEqualTo(0)
+ assertThat(iconTextSizePx).isEqualTo(8)
+ }
+ }
+}
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java b/tests/src/com/android/launcher3/util/rule/SetFlagsRuleExt.kt
similarity index 65%
copy from src_ui_overrides/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java
copy to tests/src/com/android/launcher3/util/rule/SetFlagsRuleExt.kt
index 68843f2..d682456 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java
+++ b/tests/src/com/android/launcher3/util/rule/SetFlagsRuleExt.kt
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2008 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.
@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher3.uioverrides.flags;
-/**
- * Place holder class for developer options.
- */
-public class DeveloperOptionsFragment {
+package com.android.launcher3.util.rule
+
+import android.platform.test.flag.junit.SetFlagsRule
+
+fun SetFlagsRule.setFlags(enabled: Boolean, vararg flagName: String) {
+ if (enabled) enableFlags(*flagName) else disableFlags(*flagName)
}
diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java b/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java
index 25c73de..38cc321 100644
--- a/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java
+++ b/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java
@@ -16,8 +16,6 @@
package com.android.launcher3.tapl;
-import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
-
import androidx.annotation.NonNull;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.UiObject2;
@@ -61,14 +59,8 @@
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"before tapping the app info menu item")) {
-
- mLauncher.executeAndWaitForLauncherEvent(
- () -> mLauncher.clickLauncherObject(
- mLauncher.findObjectInContainer(mMenu, By.text("App info"))),
- accessibilityEvent ->
- accessibilityEvent.getEventType() == TYPE_WINDOW_STATE_CHANGED,
- () -> "Unable to start Settings by clicking App Info",
- "Tap the app info menu item");
+ mLauncher.clickLauncherObject(
+ mLauncher.findObjectInContainer(mMenu, By.text("App info")));
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"tapped app info menu item")) {