Merge "Hide task bar when folding before the new config renders the correct task bar" into main
diff --git a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java
index 037f7a8..694475a 100644
--- a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java
+++ b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java
@@ -77,19 +77,15 @@
public AppsDividerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- boolean isMainColorDark = Themes.getAttrBoolean(context, R.attr.isMainColorDark);
mDividerSize = new int[]{
getResources().getDimensionPixelSize(R.dimen.all_apps_divider_width),
getResources().getDimensionPixelSize(R.dimen.all_apps_divider_height)
};
- mStrokeColor = ContextCompat.getColor(context, isMainColorDark
- ? R.color.all_apps_prediction_row_separator_dark
- : R.color.all_apps_prediction_row_separator);
+ mStrokeColor = ContextCompat.getColor(context, R.color.material_color_outline_variant);
- mAllAppsLabelTextColor = ContextCompat.getColor(context, isMainColorDark
- ? R.color.all_apps_label_text_dark
- : R.color.all_apps_label_text);
+ mAllAppsLabelTextColor = ContextCompat.getColor(context,
+ R.color.material_color_on_surface_variant);
mShowAllAppsLabel = !ALL_APPS_VISITED_COUNT.hasReachedMax(context);
}
diff --git a/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java b/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java
index 278ca56..1e05a69 100644
--- a/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java
+++ b/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java
@@ -67,15 +67,15 @@
/**
* Adds a log to be printed at log-dump-time.
*/
- public void addLog(String event) {
+ public void addLog(@NonNull String event) {
addLog(event, null);
}
- public void addLog(String event, int extras) {
+ public void addLog(@NonNull String event, int extras) {
addLog(event, extras, null);
}
- public void addLog(String event, boolean extras) {
+ public void addLog(@NonNull String event, boolean extras) {
addLog(event, extras, null);
}
@@ -85,30 +85,30 @@
* @param gestureEvent GestureEvent representing the event being logged.
*/
public void addLog(
- String event, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
+ @NonNull String event, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
addLog(new CompoundString(event), gestureEvent);
}
public void addLog(
- String event,
+ @NonNull String event,
int extras,
@Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
addLog(new CompoundString(event).append(": ").append(extras), gestureEvent);
}
public void addLog(
- String event,
+ @NonNull String event,
boolean extras,
@Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
addLog(new CompoundString(event).append(": ").append(extras), gestureEvent);
}
- public void addLog(CompoundString compoundString) {
+ public void addLog(@NonNull CompoundString compoundString) {
addLog(compoundString, null);
}
public void addLog(
- CompoundString compoundString,
+ @NonNull CompoundString compoundString,
@Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
EventLog lastEventLog = logs[(nextIndex + logs.length - 1) % logs.length];
if (lastEventLog == null || mCurrentLogId != lastEventLog.logId) {
@@ -259,21 +259,20 @@
public CompoundString(String substring) {
mIsNoOp = substring == null;
- if (mIsNoOp) {
- mSubstrings = null;
- mArgs = null;
- return;
+ mSubstrings = mIsNoOp ? null : new ArrayList<>();
+ mArgs = mIsNoOp ? null : new ArrayList<>();
+
+ if (!mIsNoOp) {
+ mSubstrings.add(substring);
}
- mSubstrings = new ArrayList<>();
- mSubstrings.add(substring);
- mArgs = new ArrayList<>();
}
public CompoundString append(CompoundString substring) {
- if (mIsNoOp) {
+ if (mIsNoOp || substring.mIsNoOp) {
return this;
}
mSubstrings.addAll(substring.mSubstrings);
+ mArgs.addAll(substring.mArgs);
return this;
}
@@ -288,30 +287,53 @@
}
public CompoundString append(int num) {
+ if (mIsNoOp) {
+ return this;
+ }
+ mArgs.add(num);
+
+ return append("%d");
+ }
+
+ public CompoundString append(long num) {
+ if (mIsNoOp) {
+ return this;
+ }
mArgs.add(num);
return append("%d");
}
public CompoundString append(float num) {
+ if (mIsNoOp) {
+ return this;
+ }
mArgs.add(num);
return append("%.2f");
}
public CompoundString append(double num) {
+ if (mIsNoOp) {
+ return this;
+ }
mArgs.add(num);
return append("%.2f");
}
public CompoundString append(boolean bool) {
+ if (mIsNoOp) {
+ return this;
+ }
mArgs.add(bool);
return append("%b");
}
- public Object[] getArgs() {
+ private Object[] getArgs() {
+ Preconditions.assertTrue(!mIsNoOp);
+
return mArgs.toArray();
}
@@ -320,7 +342,7 @@
return String.format(toUnformattedString(), getArgs());
}
- public String toUnformattedString() {
+ private String toUnformattedString() {
Preconditions.assertTrue(!mIsNoOp);
StringBuilder sb = new StringBuilder();
@@ -333,7 +355,7 @@
@Override
public int hashCode() {
- return Objects.hash(mIsNoOp, mSubstrings);
+ return Objects.hash(mIsNoOp, mSubstrings, mArgs);
}
@Override
@@ -342,7 +364,9 @@
return false;
}
CompoundString other = (CompoundString) obj;
- return (mIsNoOp == other.mIsNoOp) && Objects.equals(mSubstrings, other.mSubstrings);
+ return (mIsNoOp == other.mIsNoOp)
+ && Objects.equals(mSubstrings, other.mSubstrings)
+ && Objects.equals(mArgs, other.mArgs);
}
}
}
diff --git a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
index a8a96ce..b8bc828 100644
--- a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
+++ b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
@@ -96,8 +96,14 @@
mSpeedSomewhatFast = res.getDimension(R.dimen.motion_pause_detector_speed_somewhat_fast);
mSpeedFast = res.getDimension(R.dimen.motion_pause_detector_speed_fast);
mForcePauseTimeout = new Alarm();
- mForcePauseTimeout.setOnAlarmListener(alarm -> updatePaused(true /* isPaused */,
- "Force pause timeout after " + alarm.getLastSetTimeout() + "ms" /* reason */));
+ mForcePauseTimeout.setOnAlarmListener(alarm -> {
+ ActiveGestureLog.CompoundString log =
+ new ActiveGestureLog.CompoundString("Force pause timeout after ")
+ .append(alarm.getLastSetTimeout())
+ .append("ms");
+ addLogs(log);
+ updatePaused(true /* isPaused */, log);
+ });
mMakePauseHarderToTrigger = makePauseHarderToTrigger;
mVelocityProvider = new SystemVelocityProvider(axis);
}
@@ -113,8 +119,14 @@
* @param disallowPause If true, we will not detect any pauses until this is set to false again.
*/
public void setDisallowPause(boolean disallowPause) {
+ ActiveGestureLog.CompoundString log =
+ new ActiveGestureLog.CompoundString("Set disallowPause=")
+ .append(disallowPause);
+ if (mDisallowPause != disallowPause) {
+ addLogs(log);
+ }
mDisallowPause = disallowPause;
- updatePaused(mIsPaused, "Set disallowPause=" + disallowPause);
+ updatePaused(mIsPaused, log);
}
/**
@@ -148,27 +160,30 @@
float speed = Math.abs(velocity);
float previousSpeed = Math.abs(prevVelocity);
boolean isPaused;
- String isPausedReason = "";
+ ActiveGestureLog.CompoundString isPausedReason;
if (mIsPaused) {
// Continue to be paused until moving at a fast speed.
isPaused = speed < mSpeedFast || previousSpeed < mSpeedFast;
- isPausedReason = "Was paused, but started moving at a fast speed";
+ isPausedReason = new ActiveGestureLog.CompoundString(
+ "Was paused, but started moving at a fast speed");
} else {
if (velocity < 0 != prevVelocity < 0) {
// We're just changing directions, not necessarily stopping.
isPaused = false;
- isPausedReason = "Velocity changed directions";
+ isPausedReason = new ActiveGestureLog.CompoundString("Velocity changed directions");
} else {
isPaused = speed < mSpeedVerySlow && previousSpeed < mSpeedVerySlow;
- isPausedReason = "Pause requires back to back slow speeds";
+ isPausedReason = new ActiveGestureLog.CompoundString(
+ "Pause requires back to back slow speeds");
if (!isPaused && !mHasEverBeenPaused) {
// We want to be more aggressive about detecting the first pause to ensure it
// feels as responsive as possible; getting two very slow speeds back to back
// takes too long, so also check for a rapid deceleration.
boolean isRapidDeceleration = speed < previousSpeed * RAPID_DECELERATION_FACTOR;
isPaused = isRapidDeceleration && speed < mSpeedSomewhatFast;
- isPausedReason = "Didn't have back to back slow speeds, checking for rapid"
- + " deceleration on first pause only";
+ isPausedReason = new ActiveGestureLog.CompoundString(
+ "Didn't have back to back slow speeds, checking for rapid ")
+ .append(" deceleration on first pause only");
}
if (mMakePauseHarderToTrigger) {
if (speed < mSpeedSlow) {
@@ -176,12 +191,14 @@
mSlowStartTime = time;
}
isPaused = time - mSlowStartTime >= HARDER_TRIGGER_TIMEOUT;
- isPausedReason = "Maintained slow speed for sufficient duration when making"
- + " pause harder to trigger";
+ isPausedReason = new ActiveGestureLog.CompoundString(
+ "Maintained slow speed for sufficient duration when making")
+ .append(" pause harder to trigger");
} else {
mSlowStartTime = 0;
isPaused = false;
- isPausedReason = "Intentionally making pause harder to trigger";
+ isPausedReason = new ActiveGestureLog.CompoundString(
+ "Intentionally making pause harder to trigger");
}
}
}
@@ -189,18 +206,21 @@
updatePaused(isPaused, isPausedReason);
}
- private void updatePaused(boolean isPaused, String reason) {
+ private void updatePaused(boolean isPaused, ActiveGestureLog.CompoundString reason) {
if (mDisallowPause) {
- reason = "Disallow pause; otherwise, would have been " + isPaused + " due to " + reason;
+ reason = new ActiveGestureLog.CompoundString(
+ "Disallow pause; otherwise, would have been ")
+ .append(isPaused)
+ .append(" due to reason:")
+ .append(reason);
isPaused = false;
}
if (mIsPaused != isPaused) {
mIsPaused = isPaused;
- String logString = "onMotionPauseChanged, paused=" + mIsPaused + " reason=" + reason;
- if (Utilities.isRunningInTestHarness()) {
- Log.d(TAG, logString);
- }
- ActiveGestureLog.INSTANCE.addLog(logString);
+ addLogs(new ActiveGestureLog.CompoundString("onMotionPauseChanged triggered; paused=")
+ .append(mIsPaused)
+ .append(", reason=")
+ .append(reason));
boolean isFirstDetectedPause = !mHasEverBeenPaused && mIsPaused;
if (mIsPaused) {
AccessibilityManagerCompat.sendTestProtocolEventToTest(mContext,
@@ -219,6 +239,16 @@
}
}
+ private void addLogs(ActiveGestureLog.CompoundString compoundString) {
+ ActiveGestureLog.CompoundString logString =
+ new ActiveGestureLog.CompoundString("MotionPauseDetector: ")
+ .append(compoundString);
+ if (Utilities.isRunningInTestHarness()) {
+ Log.d(TAG, logString.toString());
+ }
+ ActiveGestureLog.INSTANCE.addLog(logString);
+ }
+
public void clear() {
mVelocityProvider.clear();
mPreviousVelocity = null;
diff --git a/res/layout/widgets_two_pane_sheet.xml b/res/layout/widgets_two_pane_sheet.xml
index cd7f2e1..f692e24 100644
--- a/res/layout/widgets_two_pane_sheet.xml
+++ b/res/layout/widgets_two_pane_sheet.xml
@@ -116,6 +116,7 @@
android:clipToOutline="true"
android:paddingBottom="36dp"
android:background="@drawable/widgets_surface_background"
+ android:importantForAccessibility="yes"
android:id="@+id/right_pane">
<com.android.launcher3.widget.picker.WidgetsRecommendationTableLayout
android:id="@+id/recommended_widget_table"
diff --git a/res/values-ldrtl/strings.xml b/res/values-ldrtl/strings.xml
new file mode 100644
index 0000000..118b499
--- /dev/null
+++ b/res/values-ldrtl/strings.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+/*
+* 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.
+* 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.
+*/
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- General -->
+ <skip />
+
+ <!-- accessibilityPaneTitle for the right pane when showing suggested widgets. -->
+ <string name="widget_picker_right_pane_accessibility_title"><xliff:g id="selected_header" example="Calendar">%1$s</xliff:g> widgets on left, search and options on right</string>
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5cc4616..a4e7ec4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -77,6 +77,8 @@
<string name="fitness_widget_recommendation_category_label">Reach Your Fitness Goals</string>
<string name="weather_widget_recommendation_category_label">Stay Ahead of the Weather</string>
<string name="others_widget_recommendation_category_label">You Might Also Like</string>
+ <!-- accessibilityPaneTitle for the right pane when showing suggested widgets. -->
+ <string name="widget_picker_right_pane_accessibility_title"><xliff:g id="selected_header" example="Calendar">%1$s</xliff:g> widgets on right, search and options on left</string>
<!-- Label for showing the number of widgets an app has in the full widgets picker.
[CHAR_LIMIT=25][ICU SYNTAX] -->
<string name="widgets_count">
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index 28bae59..4e704fd 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -20,15 +20,16 @@
import static com.android.launcher3.Flags.enableUnfoldedTwoPanePicker;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.LauncherPrefs.WIDGETS_EDUCATION_DIALOG_SEEN;
+import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.SEARCH;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGETSTRAY_SEARCHED;
import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL;
import android.animation.Animator;
import android.content.Context;
-import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Build;
+import android.os.Parcelable;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
@@ -99,7 +100,6 @@
// resolution or landscape on phone. This ratio defines the max percentage of content area that
// the table can display.
private static final float RECOMMENDATION_TABLE_HEIGHT_RATIO = 0.75f;
-
private final UserCache mUserCache;
private final UserManagerState mUserManagerState = new UserManagerState();
private final UserHandle mCurrentUser = Process.myUserHandle();
@@ -522,11 +522,13 @@
}
@Override
- public void enterSearchMode() {
+ public void enterSearchMode(boolean shouldLog) {
if (mIsInSearchMode) return;
setViewVisibilityBasedOnSearch(/*isInSearchMode= */ true);
attachScrollbarToRecyclerView(mAdapters.get(AdapterHolder.SEARCH).mWidgetsRecyclerView);
- mActivityContext.getStatsLogManager().logger().log(LAUNCHER_WIDGETSTRAY_SEARCHED);
+ if (shouldLog) {
+ mActivityContext.getStatsLogManager().logger().log(LAUNCHER_WIDGETSTRAY_SEARCHED);
+ }
}
@Override
@@ -789,16 +791,28 @@
+ marginLayoutParams.topMargin;
}
- @Override
- protected void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
+ private int getCurrentAdapterHolderType() {
if (mIsInSearchMode) {
- mSearchBar.reset();
+ return SEARCH;
+ } else if (mViewPager != null) {
+ return mViewPager.getCurrentPage();
+ } else {
+ return AdapterHolder.PRIMARY;
+ }
+ }
+
+ private void restorePreviousAdapterHolderType(int previousAdapterHolderType) {
+ if (previousAdapterHolderType == AdapterHolder.WORK && mViewPager != null) {
+ mViewPager.setCurrentPage(previousAdapterHolderType);
+ } else if (previousAdapterHolderType == AdapterHolder.SEARCH) {
+ enterSearchMode(false);
}
}
@Override
public void onDeviceProfileChanged(DeviceProfile dp) {
+ super.onDeviceProfileChanged(dp);
+
if (mDeviceProfile.isLandscape != dp.isLandscape && dp.isTablet && !dp.isTwoPanels) {
handleClose(false);
show(BaseActivity.fromContext(getContext()), false);
@@ -810,8 +824,12 @@
// When folding/unfolding the foldables, we need to switch between the regular widget picker
// and the two pane picker, so we rebuild the picker with the correct layout.
if (mDeviceProfile.isTwoPanels != dp.isTwoPanels && enableUnfoldedTwoPanePicker()) {
+ SparseArray<Parcelable> widgetsState = new SparseArray<>();
+ saveHierarchyState(widgetsState);
handleClose(false);
- show(BaseActivity.fromContext(getContext()), false);
+ WidgetsFullSheet sheet = show(BaseActivity.fromContext(getContext()), false);
+ sheet.restoreHierarchyState(widgetsState);
+ sheet.restorePreviousAdapterHolderType(getCurrentAdapterHolderType());
}
mDeviceProfile = dp;
diff --git a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java
index 5a1ec87..744c45b 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java
@@ -18,7 +18,6 @@
import static com.android.launcher3.Flags.enableUnfoldedTwoPanePicker;
import android.content.Context;
-import android.content.res.Configuration;
import android.graphics.Outline;
import android.graphics.Rect;
import android.os.Process;
@@ -127,10 +126,6 @@
mFastScroller.setVisibility(GONE);
}
- /** Overrides onConfigurationChanged method from WidgetsFullSheet. Needed for b/319150904 */
- @Override
- protected void onConfigurationChanged(Configuration newConfig) {}
-
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
@@ -200,10 +195,14 @@
return false;
}
};
- packageItemInfo.title = getContext().getString(R.string.suggested_widgets_header_title);
+ String suggestionsHeaderTitle = getContext().getString(
+ R.string.suggested_widgets_header_title);
+ String suggestionsRightPaneTitle = getContext().getString(
+ R.string.widget_picker_right_pane_accessibility_title, suggestionsHeaderTitle);
+ packageItemInfo.title = suggestionsHeaderTitle;
WidgetsListHeaderEntry widgetsListHeaderEntry = WidgetsListHeaderEntry.create(
packageItemInfo,
- getContext().getString(R.string.suggested_widgets_header_title),
+ suggestionsHeaderTitle,
mActivityContext.getPopupDataProvider().getRecommendedWidgets())
.withWidgetListShown();
@@ -216,10 +215,12 @@
mRightPane.removeAllViews();
mRightPane.addView(mRecommendedWidgetsTable);
mRightPaneScrollView.setScrollY(0);
+ mRightPane.setAccessibilityPaneTitle(suggestionsRightPaneTitle);
mSuggestedWidgetsPackageUserKey = PackageUserKey.fromPackageItemInfo(packageItemInfo);
mSelectedHeader = mSuggestedWidgetsPackageUserKey;
});
mSuggestedWidgetsContainer.addView(mSuggestedWidgetsHeader);
+ mRightPane.setAccessibilityPaneTitle(suggestionsRightPaneTitle);
}
@Override
@@ -322,6 +323,10 @@
mRightPane.removeAllViews();
mRightPane.addView(widgetsRowViewHolder.itemView);
mRightPaneScrollView.setScrollY(0);
+ mRightPane.setAccessibilityPaneTitle(
+ getContext().getString(
+ R.string.widget_picker_right_pane_accessibility_title,
+ contentEntry.mPkgItem.title));
}
};
}
diff --git a/src/com/android/launcher3/widget/picker/search/SearchModeListener.java b/src/com/android/launcher3/widget/picker/search/SearchModeListener.java
index cee7d67..b2620d0 100644
--- a/src/com/android/launcher3/widget/picker/search/SearchModeListener.java
+++ b/src/com/android/launcher3/widget/picker/search/SearchModeListener.java
@@ -26,7 +26,7 @@
/**
* Notifies the subscriber when user enters widget picker search mode.
*/
- void enterSearchMode();
+ void enterSearchMode(boolean shouldLog);
/**
* Notifies the subscriber when user exits widget picker search mode.
diff --git a/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java b/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java
index a15508a..2d96cbd 100644
--- a/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java
+++ b/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarController.java
@@ -70,7 +70,7 @@
mCancelButton.setVisibility(GONE);
} else {
mSearchAlgorithm.cancel(/* interruptActiveRequests= */ false);
- mSearchModeListener.enterSearchMode();
+ mSearchModeListener.enterSearchMode(true);
mSearchAlgorithm.doSearch(mQuery, this);
mCancelButton.setVisibility(VISIBLE);
}
diff --git a/tests/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarControllerTest.java b/tests/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarControllerTest.java
index 583d37f..8457ac6 100644
--- a/tests/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarControllerTest.java
+++ b/tests/src/com/android/launcher3/widget/picker/search/WidgetsSearchBarControllerTest.java
@@ -78,7 +78,7 @@
public void afterTextChanged_shouldInformSearchModeListenerToEnterSearch() {
mEditText.setText("abc");
- verify(mSearchModeListener).enterSearchMode();
+ verify(mSearchModeListener).enterSearchMode(true);
verifyNoMoreInteractions(mSearchModeListener);
}