Snap for 7175096 from d3b82a2471 to sc-release
Change-Id: I2286c5027e35d162bee0b921a4a504b4d4ece4a6
This commit is contained in:
commit
fccd3bce8c
34 files changed
+779
-189
No files matched your search
@@ -60,6 +60,14 @@ public class DeviceFlag extends DebugFlag {
|
||||
mListeners.add(r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeChangeListener(Runnable r) {
|
||||
if (mListeners == null) {
|
||||
return;
|
||||
}
|
||||
mListeners.remove(r);
|
||||
}
|
||||
|
||||
private void registerDeviceConfigChangedListener(Context context) {
|
||||
DeviceConfig.addOnPropertiesChangedListener(
|
||||
NAMESPACE_LAUNCHER,
|
||||
|
||||
@@ -1746,7 +1746,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<?>, Q extends
|
||||
if (mWindowTransitionController != null) {
|
||||
mWindowTransitionController.setProgress(mCurrentShift.value, mDragLengthFactor);
|
||||
}
|
||||
if (mRecentsAnimationTargets != null) {
|
||||
// No need to apply any transform if there is ongoing swipe-pip-to-home animator since
|
||||
// that animator handles the leash solely.
|
||||
if (mRecentsAnimationTargets != null && !mIsSwipingPipToHome) {
|
||||
if (mRecentsViewScrollLinked) {
|
||||
mTaskViewSimulator.setScroll(mRecentsView.getScrollOffset());
|
||||
}
|
||||
|
||||
@@ -200,8 +200,8 @@ public class NavigationModeSwitchRule implements TestRule {
|
||||
() -> launcher.getNavigationModel() == expectedMode, WAIT_TIME_MS, launcher);
|
||||
|
||||
Wait.atMost(() -> "Switching nav mode: "
|
||||
+ launcher.getNavigationModeMismatchError(),
|
||||
() -> launcher.getNavigationModeMismatchError() == null,
|
||||
+ launcher.getNavigationModeMismatchError(false),
|
||||
() -> launcher.getNavigationModeMismatchError(false) == null,
|
||||
WAIT_TIME_MS, launcher);
|
||||
AbstractLauncherUiTest.checkDetectedLeaks(launcher);
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2021 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.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<solid android:color="#FFFFF7" />
|
||||
<corners android:radius="24dp" />
|
||||
</shape>
|
||||
@@ -23,6 +23,7 @@
|
||||
android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
|
||||
android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
|
||||
android:orientation="horizontal"
|
||||
android:elevation="2dp"
|
||||
style="@style/TextHeadline">
|
||||
|
||||
<Button
|
||||
|
||||
@@ -16,13 +16,15 @@
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:launcher="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<include layout="@layout/personal_work_tabs" />
|
||||
<include layout="@layout/personal_work_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp" />
|
||||
|
||||
<com.android.launcher3.workprofile.PersonalWorkPagedView
|
||||
android:id="@+id/widgets_view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/tabs"
|
||||
android:clipToPadding="false"
|
||||
android:descendantFocusability="afterDescendants"
|
||||
launcher:pageIndicator="@+id/tabs">
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2021 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.
|
||||
-->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/search_and_recommendations_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:orientation="vertical">
|
||||
<View
|
||||
android:id="@+id/collapse_handle"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="2dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="@color/popup_color_primary_dark"/>
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="24sp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/widget_button_text"/>
|
||||
<!-- Disable the search bar because it has not been implemented. -->
|
||||
<EditText
|
||||
android:id="@+id/widgets_search_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/bg_widgets_searchbox"
|
||||
android:drawablePadding="8dp"
|
||||
android:drawableStart="@drawable/ic_allapps_search"
|
||||
android:hint="@string/widgets_full_sheet_search_bar_hint"
|
||||
android:padding="12dp" />
|
||||
</LinearLayout>
|
||||
@@ -183,13 +183,11 @@
|
||||
<dimen name="popup_padding_start">10dp</dimen>
|
||||
<dimen name="popup_padding_end">16dp</dimen>
|
||||
<dimen name="popup_vertical_padding">4dp</dimen>
|
||||
<dimen name="popup_arrow_width">10dp</dimen>
|
||||
<dimen name="popup_arrow_height">8dp</dimen>
|
||||
<dimen name="popup_arrow_vertical_offset">-2dp</dimen>
|
||||
<dimen name="popup_arrow_width">12dp</dimen>
|
||||
<dimen name="popup_arrow_height">10dp</dimen>
|
||||
<dimen name="popup_arrow_vertical_offset">-1dp</dimen>
|
||||
<!-- popup_padding_start + deep_shortcut_icon_size / 2 -->
|
||||
<dimen name="popup_arrow_horizontal_center_start">28dp</dimen>
|
||||
<!-- popup_padding_end + deep_shortcut_drag_handle_size / 2 -->
|
||||
<dimen name="popup_arrow_horizontal_center_end">24dp</dimen>
|
||||
<dimen name="popup_arrow_horizontal_center_offset">28dp</dimen>
|
||||
<dimen name="popup_arrow_corner_radius">2dp</dimen>
|
||||
<!-- popup_padding_start + icon_size + 10dp -->
|
||||
<dimen name="deep_shortcuts_text_padding_start">56dp</dimen>
|
||||
|
||||
@@ -57,6 +57,12 @@
|
||||
<item quantity="one"><xliff:g id="widget_count" example="1">%1$d</xliff:g> widget</item>
|
||||
<item quantity="other"><xliff:g id="widget_count" example="2">%1$d</xliff:g> widgets</item>
|
||||
</plurals>
|
||||
<!-- Text for both the tile of a popup view, which shows all available widgets installed on
|
||||
the device, and the text of a button, which opens this popup view. [CHAR LIMIT=30]-->
|
||||
<string name="widget_button_text">Widgets</string>
|
||||
<!-- Search bar text shown in the popup view showing all available widgets installed on the
|
||||
device. [CHAR_LIMIT=50] -->
|
||||
<string name="widgets_full_sheet_search_bar_hint">Search</string>
|
||||
|
||||
<!-- All Apps -->
|
||||
<!-- Search bar text in the apps view. [CHAR_LIMIT=50] -->
|
||||
@@ -185,8 +191,6 @@
|
||||
<string name="folder_name_format_overflow">Folder: <xliff:g id="name" example="Games">%1$s</xliff:g>, <xliff:g id="size" example="2">%2$d</xliff:g> or more items</string>
|
||||
|
||||
<!-- Strings for the customization mode -->
|
||||
<!-- Text for widget add button [CHAR LIMIT=30]-->
|
||||
<string name="widget_button_text">Widgets</string>
|
||||
<!-- Text for wallpaper change button [CHAR LIMIT=30]-->
|
||||
<string name="wallpaper_button_text">Wallpapers</string>
|
||||
<!-- Text for wallpaper change button [CHAR LIMIT=30]-->
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.launcher3.compat.AccessibilityManagerCompat;
|
||||
@@ -188,4 +189,21 @@ public abstract class BaseRecyclerView extends RecyclerView {
|
||||
super.onInitializeAccessibilityNodeInfo(info);
|
||||
if (isLayoutSuppressed()) info.setScrollable(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls this recycler view to the top.
|
||||
*/
|
||||
public void scrollToTop() {
|
||||
if (mScrollbar != null) {
|
||||
mScrollbar.reattachThumbToScroll();
|
||||
}
|
||||
if (getLayoutManager() instanceof LinearLayoutManager) {
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager();
|
||||
if (layoutManager.findFirstCompletelyVisibleItemPosition() == 0) {
|
||||
// We are at the top, so don't scrollToPosition (would cause unnecessary relayout).
|
||||
return;
|
||||
}
|
||||
}
|
||||
scrollToPosition(0);
|
||||
}
|
||||
}
|
||||
@@ -615,7 +615,9 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
|
||||
+ "\" bitmapIcon=" + info.bitmap.icon
|
||||
+ " componentName=" + info.componentName.getPackageName());
|
||||
}
|
||||
writer.println();
|
||||
}
|
||||
mModelDelegate.dump(prefix, fd, writer, args);
|
||||
mBgDataModel.dump(prefix, fd, writer, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
package com.android.launcher3.allapps;
|
||||
|
||||
import static com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB;
|
||||
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_HAS_SHORTCUT_PERMISSION;
|
||||
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_CHANGE_PERMISSION;
|
||||
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_ENABLED;
|
||||
@@ -432,9 +434,19 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
mAH[AdapterHolder.WORK].setup(mViewPager.getChildAt(1), mWorkMatcher);
|
||||
mViewPager.getPageIndicator().setActiveMarker(AdapterHolder.MAIN);
|
||||
findViewById(R.id.tab_personal)
|
||||
.setOnClickListener((View view) -> mViewPager.snapToPage(AdapterHolder.MAIN));
|
||||
.setOnClickListener((View view) -> {
|
||||
if (mViewPager.snapToPage(AdapterHolder.MAIN)) {
|
||||
mLauncher.getStatsLogManager().logger()
|
||||
.log(LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB);
|
||||
}
|
||||
});
|
||||
findViewById(R.id.tab_work)
|
||||
.setOnClickListener((View view) -> mViewPager.snapToPage(AdapterHolder.WORK));
|
||||
.setOnClickListener((View view) -> {
|
||||
if (mViewPager.snapToPage(AdapterHolder.WORK)) {
|
||||
mLauncher.getStatsLogManager().logger()
|
||||
.log(LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB);
|
||||
}
|
||||
});
|
||||
onActivePageChanged(mViewPager.getNextPage());
|
||||
} else {
|
||||
mAH[AdapterHolder.MAIN].setup(findViewById(R.id.apps_list_view), null);
|
||||
|
||||
@@ -15,9 +15,13 @@
|
||||
*/
|
||||
package com.android.launcher3.allapps;
|
||||
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SWIPE_TO_PERSONAL_TAB;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SWIPE_TO_WORK_TAB;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.PagedView;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
@@ -44,4 +48,16 @@ public class AllAppsPagedView extends PersonalWorkPagedView {
|
||||
R.dimen.all_apps_header_top_padding);
|
||||
setPadding(0, topPadding, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean snapToPageWithVelocity(int whichPage, int velocity) {
|
||||
boolean resp = super.snapToPageWithVelocity(whichPage, velocity);
|
||||
if (resp && whichPage != mCurrentPage) {
|
||||
Launcher.getLauncher(getContext()).getStatsLogManager().logger()
|
||||
.log(mCurrentPage < whichPage
|
||||
? LAUNCHER_ALLAPPS_SWIPE_TO_WORK_TAB
|
||||
: LAUNCHER_ALLAPPS_SWIPE_TO_PERSONAL_TAB);
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,6 @@ import com.android.launcher3.BaseRecyclerView;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.allapps.AllAppsGridAdapter.AppsGridLayoutManager;
|
||||
import com.android.launcher3.views.RecyclerViewFastScroller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -109,23 +108,6 @@ public class AllAppsRecyclerView extends BaseRecyclerView {
|
||||
mViewHeights.put(AllAppsGridAdapter.VIEW_TYPE_ICON, grid.allAppsCellHeightPx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls this recycler view to the top.
|
||||
*/
|
||||
public void scrollToTop() {
|
||||
// Ensure we reattach the scrollbar if it was previously detached while fast-scrolling
|
||||
if (mScrollbar != null) {
|
||||
mScrollbar.reattachThumbToScroll();
|
||||
}
|
||||
if (getLayoutManager() instanceof AppsGridLayoutManager) {
|
||||
AppsGridLayoutManager layoutManager = (AppsGridLayoutManager) getLayoutManager();
|
||||
if (layoutManager.findFirstCompletelyVisibleItemPosition() == 0) {
|
||||
// We are at the top, so don't scrollToPosition (would cause unnecessary relayout).
|
||||
return;
|
||||
}
|
||||
}
|
||||
scrollToPosition(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas c) {
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
package com.android.launcher3.allapps;
|
||||
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_KEYBOARD_CLOSED;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SWITCHED_TO_MAIN_TAB;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SWITCHED_TO_WORK_TAB;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
@@ -90,14 +88,6 @@ public class LauncherAllAppsContainerView extends AllAppsContainerView {
|
||||
public void onActivePageChanged(int currentActivePage) {
|
||||
super.onActivePageChanged(currentActivePage);
|
||||
if (mUsingTabs) {
|
||||
// Log tab switches only when the launcher is in AllApps state
|
||||
if (mLauncher.getStateManager().getCurrentStableState() == LauncherState.ALL_APPS) {
|
||||
mLauncher.getStatsLogManager().logger()
|
||||
.log(currentActivePage == AdapterHolder.WORK
|
||||
? LAUNCHER_ALLAPPS_SWITCHED_TO_WORK_TAB
|
||||
: LAUNCHER_ALLAPPS_SWITCHED_TO_MAIN_TAB);
|
||||
}
|
||||
|
||||
if (currentActivePage == AdapterHolder.WORK) {
|
||||
WorkEduView.showWorkEduIfNeeded(mLauncher);
|
||||
} else {
|
||||
|
||||
@@ -33,10 +33,10 @@ import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.search.SearchAlgorithm;
|
||||
import com.android.launcher3.search.SearchCallback;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* An interface to a search box that AllApps can command.
|
||||
*/
|
||||
@@ -45,11 +45,11 @@ public class AllAppsSearchBarController
|
||||
OnFocusChangeListener {
|
||||
|
||||
protected BaseDraggingActivity mLauncher;
|
||||
protected Callbacks mCb;
|
||||
protected SearchCallback<AdapterItem> mCallback;
|
||||
protected ExtendedEditText mInput;
|
||||
protected String mQuery;
|
||||
|
||||
protected SearchAlgorithm mSearchAlgorithm;
|
||||
protected SearchAlgorithm<AdapterItem> mSearchAlgorithm;
|
||||
|
||||
public void setVisibility(int visibility) {
|
||||
mInput.setVisibility(visibility);
|
||||
@@ -59,9 +59,9 @@ public class AllAppsSearchBarController
|
||||
* Sets the references to the apps model and the search result callback.
|
||||
*/
|
||||
public final void initialize(
|
||||
SearchAlgorithm searchAlgorithm, ExtendedEditText input,
|
||||
BaseDraggingActivity launcher, Callbacks cb) {
|
||||
mCb = cb;
|
||||
SearchAlgorithm<AdapterItem> searchAlgorithm, ExtendedEditText input,
|
||||
BaseDraggingActivity launcher, SearchCallback<AdapterItem> callback) {
|
||||
mCallback = callback;
|
||||
mLauncher = launcher;
|
||||
|
||||
mInput = input;
|
||||
@@ -87,10 +87,10 @@ public class AllAppsSearchBarController
|
||||
mQuery = s.toString();
|
||||
if (mQuery.isEmpty()) {
|
||||
mSearchAlgorithm.cancel(true);
|
||||
mCb.clearSearchResult();
|
||||
mCallback.clearSearchResult();
|
||||
} else {
|
||||
mSearchAlgorithm.cancel(false);
|
||||
mSearchAlgorithm.doSearch(mQuery, mCb);
|
||||
mSearchAlgorithm.doSearch(mQuery, mCallback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class AllAppsSearchBarController
|
||||
}
|
||||
// If play store continues auto updating an app, we want to show partial result.
|
||||
mSearchAlgorithm.cancel(false);
|
||||
mSearchAlgorithm.doSearch(mQuery, mCb);
|
||||
mSearchAlgorithm.doSearch(mQuery, mCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,7 +153,7 @@ public class AllAppsSearchBarController
|
||||
* Resets the search bar state.
|
||||
*/
|
||||
public void reset() {
|
||||
mCb.clearSearchResult();
|
||||
mCallback.clearSearchResult();
|
||||
mInput.reset();
|
||||
mQuery = null;
|
||||
}
|
||||
@@ -171,31 +171,4 @@ public class AllAppsSearchBarController
|
||||
public boolean isSearchFieldFocused() {
|
||||
return mInput.isFocused();
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for getting search results.
|
||||
*/
|
||||
public interface Callbacks {
|
||||
|
||||
/**
|
||||
* Called when the search from primary source is complete.
|
||||
*
|
||||
* @param items sorted list of search result adapter items
|
||||
*/
|
||||
void onSearchResult(String query, ArrayList<AdapterItem> items);
|
||||
|
||||
/**
|
||||
* Called when the search from secondary source is complete.
|
||||
*
|
||||
* @param items sorted list of search result adapter items
|
||||
*/
|
||||
void onAppendSearchResult(String query, ArrayList<AdapterItem> items);
|
||||
|
||||
/**
|
||||
* Called when the search results should be cleared.
|
||||
*/
|
||||
void clearSearchResult();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -47,6 +47,7 @@ import com.android.launcher3.allapps.AlphabeticalAppsList;
|
||||
import com.android.launcher3.allapps.SearchUiManager;
|
||||
import com.android.launcher3.anim.PropertySetter;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.search.SearchCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -54,7 +55,7 @@ import java.util.ArrayList;
|
||||
* Layout to contain the All-apps search UI.
|
||||
*/
|
||||
public class AppsSearchContainerLayout extends ExtendedEditText
|
||||
implements SearchUiManager, AllAppsSearchBarController.Callbacks,
|
||||
implements SearchUiManager, SearchCallback<AdapterItem>,
|
||||
AllAppsStore.OnUpdateListener, Insettable {
|
||||
|
||||
private final BaseDraggingActivity mLauncher;
|
||||
|
||||
@@ -19,14 +19,17 @@ import android.content.Context;
|
||||
import android.os.Handler;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.search.SearchAlgorithm;
|
||||
import com.android.launcher3.search.SearchCallback;
|
||||
|
||||
import java.text.Collator;
|
||||
|
||||
/**
|
||||
* The default search implementation.
|
||||
*/
|
||||
public class DefaultAppSearchAlgorithm implements SearchAlgorithm {
|
||||
public class DefaultAppSearchAlgorithm implements SearchAlgorithm<AdapterItem> {
|
||||
|
||||
protected final Handler mResultHandler;
|
||||
private final AppsSearchPipeline mAppsSearchPipeline;
|
||||
@@ -45,7 +48,7 @@ public class DefaultAppSearchAlgorithm implements SearchAlgorithm {
|
||||
|
||||
@Override
|
||||
public void doSearch(final String query,
|
||||
final AllAppsSearchBarController.Callbacks callback) {
|
||||
final SearchCallback<AdapterItem> callback) {
|
||||
mAppsSearchPipeline.query(query,
|
||||
results -> mResultHandler.post(
|
||||
() -> callback.onSearchResult(query, results)),
|
||||
|
||||
@@ -158,7 +158,7 @@ public final class FeatureFlags {
|
||||
"ENABLE_SMARTSPACE_UNIVERSAL", false,
|
||||
"Replace Smartspace with a version rendered by System UI.");
|
||||
|
||||
public static final BooleanFlag ENABLE_SMARTSPACE_ENHANCED = getDebugFlag(
|
||||
public static final BooleanFlag ENABLE_SMARTSPACE_ENHANCED = new DeviceFlag(
|
||||
"ENABLE_SMARTSPACE_ENHANCED", false,
|
||||
"Replace Smartspace with the enhanced version. "
|
||||
+ "Ignored if ENABLE_SMARTSPACE_UNIVERSAL is enabled.");
|
||||
@@ -263,6 +263,8 @@ public final class FeatureFlags {
|
||||
}
|
||||
|
||||
public void addChangeListener(Context context, Runnable r) { }
|
||||
|
||||
public void removeChangeListener(Runnable r) {}
|
||||
}
|
||||
|
||||
public static class DebugFlag extends BooleanFlag {
|
||||
|
||||
@@ -362,11 +362,11 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
@UiEvent(doc = "User closed the AllApps keyboard.")
|
||||
LAUNCHER_ALLAPPS_KEYBOARD_CLOSED(694),
|
||||
|
||||
@UiEvent(doc = "User switched to Main tab in AllApps screen.")
|
||||
LAUNCHER_ALLAPPS_SWITCHED_TO_MAIN_TAB(695),
|
||||
@UiEvent(doc = "User switched to AllApps Main/Personal tab by swiping left.")
|
||||
LAUNCHER_ALLAPPS_SWIPE_TO_PERSONAL_TAB(695),
|
||||
|
||||
@UiEvent(doc = "User switched to Work tab in AllApps screen.")
|
||||
LAUNCHER_ALLAPPS_SWITCHED_TO_WORK_TAB(696),
|
||||
@UiEvent(doc = "User switched to AllApps Work tab by swiping right.")
|
||||
LAUNCHER_ALLAPPS_SWIPE_TO_WORK_TAB(696),
|
||||
|
||||
@UiEvent(doc = "Default event when dedicated UI event is not available for the user action"
|
||||
+ " on slice .")
|
||||
@@ -396,8 +396,17 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
@UiEvent(doc = "IME is used for selecting the focused item on the AllApps screen.")
|
||||
LAUNCHER_ALLAPPS_FOCUSED_ITEM_SELECTED_WITH_IME(718),
|
||||
|
||||
@UiEvent(doc = "User long-pressed on an AllApps item.")
|
||||
LAUNCHER_ALLAPPS_ITEM_LONG_PRESSED(719),
|
||||
|
||||
@UiEvent(doc = "Launcher entered into AllApps state with device search enabled.")
|
||||
LAUNCHER_ALLAPPS_ENTRY_WITH_DEVICE_SEARCH(720),
|
||||
|
||||
@UiEvent(doc = "User switched to AllApps Main/Personal tab by tapping on it.")
|
||||
LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB(721),
|
||||
|
||||
@UiEvent(doc = "User switched to AllApps Work tab by tapping on it.")
|
||||
LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB(722),
|
||||
;
|
||||
|
||||
// ADD MORE
|
||||
|
||||
@@ -27,6 +27,8 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.shortcuts.ShortcutKey;
|
||||
import com.android.launcher3.util.ResourceBasedOverride;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -89,4 +91,11 @@ public class ModelDelegate implements ResourceBasedOverride {
|
||||
@WorkerThread
|
||||
public void destroy() { }
|
||||
|
||||
/**
|
||||
* Add data to a dumpsys request for Launcher (e.g. for bug reports).
|
||||
*
|
||||
* @see com.android.launcher3.Launcher#dump(java.lang.String, java.io.FileDescriptor,
|
||||
* java.io.PrintWriter, java.lang.String[])
|
||||
**/
|
||||
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) { }
|
||||
}
|
||||
@@ -26,11 +26,8 @@ import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.CornerPathEffect;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Pair;
|
||||
import android.view.Gravity;
|
||||
@@ -51,7 +48,6 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.RevealOutlineAnimation;
|
||||
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.graphics.TriangleShape;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
|
||||
@@ -72,7 +68,11 @@ public abstract class ArrowPopup<T extends BaseDraggingActivity> extends Abstrac
|
||||
protected final T mLauncher;
|
||||
protected final boolean mIsRtl;
|
||||
|
||||
private final int mArrowOffset;
|
||||
private final int mArrowOffsetVertical;
|
||||
private final int mArrowOffsetHorizontal;
|
||||
private final int mArrowWidth;
|
||||
private final int mArrowHeight;
|
||||
private final int mArrowPointRadius;
|
||||
private final View mArrow;
|
||||
|
||||
protected boolean mIsLeftAligned;
|
||||
@@ -103,11 +103,14 @@ public abstract class ArrowPopup<T extends BaseDraggingActivity> extends Abstrac
|
||||
|
||||
// Initialize arrow view
|
||||
final Resources resources = getResources();
|
||||
final int arrowWidth = resources.getDimensionPixelSize(R.dimen.popup_arrow_width);
|
||||
final int arrowHeight = resources.getDimensionPixelSize(R.dimen.popup_arrow_height);
|
||||
mArrowWidth = resources.getDimensionPixelSize(R.dimen.popup_arrow_width);
|
||||
mArrowHeight = resources.getDimensionPixelSize(R.dimen.popup_arrow_height);
|
||||
mArrow = new View(context);
|
||||
mArrow.setLayoutParams(new DragLayer.LayoutParams(arrowWidth, arrowHeight));
|
||||
mArrowOffset = resources.getDimensionPixelSize(R.dimen.popup_arrow_vertical_offset);
|
||||
mArrow.setLayoutParams(new DragLayer.LayoutParams(mArrowWidth, mArrowHeight));
|
||||
mArrowOffsetVertical = resources.getDimensionPixelSize(R.dimen.popup_arrow_vertical_offset);
|
||||
mArrowOffsetHorizontal = resources.getDimensionPixelSize(
|
||||
R.dimen.popup_arrow_horizontal_center_offset) - (mArrowWidth / 2);
|
||||
mArrowPointRadius = resources.getDimensionPixelSize(R.dimen.popup_arrow_corner_radius);
|
||||
}
|
||||
|
||||
public ArrowPopup(Context context, AttributeSet attrs) {
|
||||
@@ -200,48 +203,33 @@ public abstract class ArrowPopup<T extends BaseDraggingActivity> extends Abstrac
|
||||
orientAboutObject();
|
||||
}
|
||||
|
||||
private void addArrow() {
|
||||
final Resources res = getResources();
|
||||
final int arrowCenterOffset = res.getDimensionPixelSize(isAlignedWithStart()
|
||||
? R.dimen.popup_arrow_horizontal_center_start
|
||||
: R.dimen.popup_arrow_horizontal_center_end);
|
||||
final int halfArrowWidth = res.getDimensionPixelSize(R.dimen.popup_arrow_width) / 2;
|
||||
getPopupContainer().addView(mArrow);
|
||||
DragLayer.LayoutParams arrowLp = (DragLayer.LayoutParams) mArrow.getLayoutParams();
|
||||
private int getArrowLeft() {
|
||||
if (mIsLeftAligned) {
|
||||
mArrow.setX(getX() + arrowCenterOffset - halfArrowWidth);
|
||||
} else {
|
||||
mArrow.setX(getX() + getMeasuredWidth() - arrowCenterOffset - halfArrowWidth);
|
||||
return mArrowOffsetHorizontal;
|
||||
}
|
||||
return getMeasuredWidth() - mArrowOffsetHorizontal - mArrowWidth;
|
||||
}
|
||||
|
||||
private void addArrow() {
|
||||
getPopupContainer().addView(mArrow);
|
||||
mArrow.setX(getX() + getArrowLeft());
|
||||
|
||||
if (Gravity.isVertical(mGravity)) {
|
||||
// This is only true if there wasn't room for the container next to the icon,
|
||||
// so we centered it instead. In that case we don't want to showDefaultOptions the arrow.
|
||||
mArrow.setVisibility(INVISIBLE);
|
||||
} else {
|
||||
ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create(
|
||||
arrowLp.width, arrowLp.height, !mIsAboveIcon));
|
||||
Paint arrowPaint = arrowDrawable.getPaint();
|
||||
arrowPaint.setColor(Themes.getAttrColor(getContext(), R.attr.popupColorPrimary));
|
||||
// The corner path effect won't be reflected in the shadow, but shouldn't be noticeable.
|
||||
int radius = getResources().getDimensionPixelSize(R.dimen.popup_arrow_corner_radius);
|
||||
arrowPaint.setPathEffect(new CornerPathEffect(radius));
|
||||
mArrow.setBackground(arrowDrawable);
|
||||
// Clip off the part of the arrow that is underneath the popup.
|
||||
if (mIsAboveIcon) {
|
||||
mArrow.setClipBounds(new Rect(0, -mArrowOffset, arrowLp.width, arrowLp.height));
|
||||
} else {
|
||||
mArrow.setClipBounds(new Rect(0, 0, arrowLp.width, arrowLp.height + mArrowOffset));
|
||||
}
|
||||
mArrow.setBackground(new RoundedArrowDrawable(
|
||||
mArrowWidth, mArrowHeight, mArrowPointRadius,
|
||||
mOutlineRadius, getMeasuredWidth(), getMeasuredHeight(),
|
||||
mArrowOffsetHorizontal, -mArrowOffsetVertical,
|
||||
!mIsAboveIcon, mIsLeftAligned,
|
||||
Themes.getAttrColor(getContext(), R.attr.popupColorPrimary)));
|
||||
mArrow.setElevation(getElevation());
|
||||
}
|
||||
|
||||
mArrow.setPivotX(arrowLp.width / 2);
|
||||
mArrow.setPivotY(mIsAboveIcon ? arrowLp.height : 0);
|
||||
}
|
||||
|
||||
protected boolean isAlignedWithStart() {
|
||||
return mIsLeftAligned && !mIsRtl || !mIsLeftAligned && mIsRtl;
|
||||
mArrow.setPivotX(mArrowWidth / 2.0f);
|
||||
mArrow.setPivotY(mIsAboveIcon ? mArrowHeight : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,8 +262,9 @@ public abstract class ArrowPopup<T extends BaseDraggingActivity> extends Abstrac
|
||||
*/
|
||||
private void orientAboutObject(boolean allowAlignLeft, boolean allowAlignRight) {
|
||||
measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
|
||||
|
||||
int width = getMeasuredWidth();
|
||||
int extraVerticalSpace = mArrow.getLayoutParams().height + mArrowOffset
|
||||
int extraVerticalSpace = mArrowHeight + mArrowOffsetVertical
|
||||
+ getResources().getDimensionPixelSize(R.dimen.popup_vertical_padding);
|
||||
int height = getMeasuredHeight() + extraVerticalSpace;
|
||||
|
||||
@@ -291,22 +280,7 @@ public abstract class ArrowPopup<T extends BaseDraggingActivity> extends Abstrac
|
||||
|
||||
// Offset x so that the arrow and shortcut icons are center-aligned with the original icon.
|
||||
int iconWidth = mTempRect.width();
|
||||
Resources resources = getResources();
|
||||
int xOffset;
|
||||
if (isAlignedWithStart()) {
|
||||
// Aligning with the shortcut icon.
|
||||
int shortcutIconWidth = resources.getDimensionPixelSize(R.dimen.deep_shortcut_icon_size);
|
||||
int shortcutPaddingStart = resources.getDimensionPixelSize(
|
||||
R.dimen.popup_padding_start);
|
||||
xOffset = iconWidth / 2 - shortcutIconWidth / 2 - shortcutPaddingStart;
|
||||
} else {
|
||||
// Aligning with the drag handle.
|
||||
int shortcutDragHandleWidth = resources.getDimensionPixelSize(
|
||||
R.dimen.deep_shortcut_drag_handle_size);
|
||||
int shortcutPaddingEnd = resources.getDimensionPixelSize(
|
||||
R.dimen.popup_padding_end);
|
||||
xOffset = iconWidth / 2 - shortcutDragHandleWidth / 2 - shortcutPaddingEnd;
|
||||
}
|
||||
int xOffset = iconWidth / 2 - mArrowOffsetHorizontal - mArrowWidth / 2;
|
||||
x += mIsLeftAligned ? xOffset : -xOffset;
|
||||
|
||||
// Check whether we can still align as we originally wanted, now that we've calculated x.
|
||||
@@ -375,12 +349,14 @@ public abstract class ArrowPopup<T extends BaseDraggingActivity> extends Abstrac
|
||||
FrameLayout.LayoutParams arrowLp = (FrameLayout.LayoutParams) mArrow.getLayoutParams();
|
||||
if (mIsAboveIcon) {
|
||||
arrowLp.gravity = lp.gravity = Gravity.BOTTOM;
|
||||
lp.bottomMargin = getPopupContainer().getHeight() - y - getMeasuredHeight() - insets.top;
|
||||
arrowLp.bottomMargin = lp.bottomMargin - arrowLp.height - mArrowOffset - insets.bottom;
|
||||
lp.bottomMargin =
|
||||
getPopupContainer().getHeight() - y - getMeasuredHeight() - insets.top;
|
||||
arrowLp.bottomMargin =
|
||||
lp.bottomMargin - arrowLp.height - mArrowOffsetVertical - insets.bottom;
|
||||
} else {
|
||||
arrowLp.gravity = lp.gravity = Gravity.TOP;
|
||||
lp.topMargin = y + insets.top;
|
||||
arrowLp.topMargin = lp.topMargin - insets.top - arrowLp.height - mArrowOffset;
|
||||
arrowLp.topMargin = lp.topMargin - insets.top - arrowLp.height - mArrowOffsetVertical;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,22 +505,13 @@ public abstract class ArrowPopup<T extends BaseDraggingActivity> extends Abstrac
|
||||
protected void onCreateCloseAnimation(AnimatorSet anim) { }
|
||||
|
||||
private RoundedRectRevealOutlineProvider createOpenCloseOutlineProvider() {
|
||||
Resources res = getResources();
|
||||
int arrowCenterX = res.getDimensionPixelSize(mIsLeftAligned ^ mIsRtl ?
|
||||
R.dimen.popup_arrow_horizontal_center_start:
|
||||
R.dimen.popup_arrow_horizontal_center_end);
|
||||
int halfArrowWidth = res.getDimensionPixelSize(R.dimen.popup_arrow_width) / 2;
|
||||
float arrowCornerRadius = res.getDimension(R.dimen.popup_arrow_corner_radius);
|
||||
if (!mIsLeftAligned) {
|
||||
arrowCenterX = getMeasuredWidth() - arrowCenterX;
|
||||
}
|
||||
int arrowLeft = getArrowLeft();
|
||||
int arrowCenterY = mIsAboveIcon ? getMeasuredHeight() : 0;
|
||||
|
||||
mStartRect.set(arrowCenterX - halfArrowWidth, arrowCenterY, arrowCenterX + halfArrowWidth,
|
||||
arrowCenterY);
|
||||
mStartRect.set(arrowLeft, arrowCenterY, arrowLeft + mArrowWidth, arrowCenterY);
|
||||
|
||||
return new RoundedRectRevealOutlineProvider
|
||||
(arrowCornerRadius, mOutlineRadius, mStartRect, mEndRect);
|
||||
return new RoundedRectRevealOutlineProvider(
|
||||
mArrowPointRadius, mOutlineRadius, mStartRect, mEndRect);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.popup;
|
||||
|
||||
import static java.lang.Math.atan;
|
||||
import static java.lang.Math.cos;
|
||||
import static java.lang.Math.sin;
|
||||
import static java.lang.Math.toDegrees;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
/**
|
||||
* A drawable for a very specific purpose. Used for the caret arrow on a rounded rectangle popup
|
||||
* bubble.
|
||||
* Draws a triangle with one rounded tip, the opposite edge is clipped by the body of the popup
|
||||
* so there is no overlap when drawing them together.
|
||||
*/
|
||||
public class RoundedArrowDrawable extends Drawable {
|
||||
|
||||
private final Path mPath;
|
||||
private final Paint mPaint;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* @param width of the arrow.
|
||||
* @param height of the arrow.
|
||||
* @param radius of the tip of the arrow.
|
||||
* @param popupRadius of the rect to clip this by.
|
||||
* @param popupWidth of the rect to clip this by.
|
||||
* @param popupHeight of the rect to clip this by.
|
||||
* @param arrowOffsetX from the edge of the popup to the arrow.
|
||||
* @param arrowOffsetY how much the arrow will overlap the popup.
|
||||
* @param isPointingUp or not.
|
||||
* @param leftAligned or false for right aligned.
|
||||
* @param color to draw the triangle.
|
||||
*/
|
||||
public RoundedArrowDrawable(float width, float height, float radius, float popupRadius,
|
||||
float popupWidth, float popupHeight,
|
||||
float arrowOffsetX, float arrowOffsetY, boolean isPointingUp, boolean leftAligned,
|
||||
int color) {
|
||||
mPath = new Path();
|
||||
mPaint = new Paint();
|
||||
mPaint.setColor(color);
|
||||
mPaint.setStyle(Paint.Style.FILL);
|
||||
mPaint.setAntiAlias(true);
|
||||
|
||||
// Make the drawable with the triangle pointing down and positioned on the left..
|
||||
addDownPointingRoundedTriangleToPath(width, height, radius, mPath);
|
||||
clipPopupBodyFromPath(popupRadius, popupWidth, popupHeight, arrowOffsetX, arrowOffsetY,
|
||||
mPath);
|
||||
|
||||
// ... then flip it horizontal or vertical based on where it will be used.
|
||||
Matrix pathTransform = new Matrix();
|
||||
pathTransform.setScale(
|
||||
leftAligned ? 1 : -1, isPointingUp ? -1 : 1, width * 0.5f, height * 0.5f);
|
||||
mPath.transform(pathTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
canvas.drawPath(mPath, mPaint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOutline(Outline outline) {
|
||||
outline.setPath(mPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int i) {
|
||||
mPaint.setAlpha(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter colorFilter) {
|
||||
mPaint.setColorFilter(colorFilter);
|
||||
}
|
||||
|
||||
private static void addDownPointingRoundedTriangleToPath(float width, float height,
|
||||
float radius, Path path) {
|
||||
// Calculated for the arrow pointing down, will be flipped later if needed.
|
||||
|
||||
// Theta is half of the angle inside the triangle tip
|
||||
float tanTheta = width / (2.0f * height);
|
||||
float theta = (float) atan(tanTheta);
|
||||
|
||||
// Some trigonometry to find the center of the circle for the rounded tip
|
||||
float roundedPointCenterY = (float) (height - (radius / sin(theta)));
|
||||
|
||||
// p is the distance along the triangle side to the intersection with the point circle
|
||||
float p = radius / tanTheta;
|
||||
float lineRoundPointIntersectFromCenter = (float) (p * sin(theta));
|
||||
float lineRoundPointIntersectFromTop = (float) (height - (p * cos(theta)));
|
||||
|
||||
float centerX = width / 2.0f;
|
||||
float thetaDeg = (float) toDegrees(theta);
|
||||
|
||||
path.reset();
|
||||
path.moveTo(0, 0);
|
||||
// Draw the top
|
||||
path.lineTo(width, 0);
|
||||
// Draw the right side up to the circle intersection
|
||||
path.lineTo(
|
||||
centerX + lineRoundPointIntersectFromCenter,
|
||||
lineRoundPointIntersectFromTop);
|
||||
// Draw the rounded point
|
||||
path.arcTo(
|
||||
centerX - radius,
|
||||
roundedPointCenterY - radius,
|
||||
centerX + radius,
|
||||
roundedPointCenterY + radius,
|
||||
thetaDeg,
|
||||
180 - (2 * thetaDeg),
|
||||
false);
|
||||
// Draw the left edge to close
|
||||
path.lineTo(0, 0);
|
||||
path.close();
|
||||
}
|
||||
|
||||
private static void clipPopupBodyFromPath(float popupRadius, float popupWidth,
|
||||
float popupHeight, float arrowOffsetX, float arrowOffsetY, Path path) {
|
||||
// Make a path that is used to clip the triangle, this represents the body of the popup
|
||||
Path clipPiece = new Path();
|
||||
clipPiece.addRoundRect(
|
||||
0, 0, popupWidth, popupHeight,
|
||||
popupRadius, popupRadius, Path.Direction.CW);
|
||||
// clipping is performed as if the arrow is pointing down and positioned on the left, the
|
||||
// resulting path will be flipped as needed later.
|
||||
// The extra 0.5 in the vertical offset is to close the gap between this anti-aliased object
|
||||
// and the anti-aliased body of the popup.
|
||||
clipPiece.offset(-arrowOffsetX, -popupHeight + arrowOffsetY - 0.5f);
|
||||
path.op(clipPiece, Path.Op.DIFFERENCE);
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -13,17 +13,19 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.launcher3.allapps.search;
|
||||
package com.android.launcher3.search;
|
||||
|
||||
/**
|
||||
* An interface for handling search.
|
||||
*
|
||||
* @param <T> Search Result type
|
||||
*/
|
||||
public interface SearchAlgorithm {
|
||||
public interface SearchAlgorithm<T> {
|
||||
|
||||
/**
|
||||
* Performs search and sends the result to the callback.
|
||||
* Performs search and sends the result to {@link SearchCallback}.
|
||||
*/
|
||||
void doSearch(String query, AllAppsSearchBarController.Callbacks callback);
|
||||
void doSearch(String query, SearchCallback<T> callback);
|
||||
|
||||
/**
|
||||
* Cancels any active request.
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* An interface for receiving search results.
|
||||
*
|
||||
* @param <T> Search Result type
|
||||
*/
|
||||
public interface SearchCallback<T> {
|
||||
|
||||
/**
|
||||
* Called when the search from primary source is complete.
|
||||
*
|
||||
* @param items list of search results
|
||||
*/
|
||||
void onSearchResult(String query, ArrayList<T> items);
|
||||
|
||||
/**
|
||||
* Called when the search from secondary source is complete.
|
||||
*
|
||||
* @param items list of search results
|
||||
*/
|
||||
void onAppendSearchResult(String query, ArrayList<T> items);
|
||||
|
||||
/**
|
||||
* Called when the search results should be cleared.
|
||||
*/
|
||||
void clearSearchResult();
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ public class SettingsActivity extends FragmentActivity
|
||||
private String mHighLightKey;
|
||||
private boolean mPreferenceHighlighted = false;
|
||||
private NotificationDotsPreference mNotificationSettingsChangedListener;
|
||||
private Preference mDeveloperOptionPref;
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
@@ -202,18 +203,37 @@ public class SettingsActivity extends FragmentActivity
|
||||
return FeatureFlags.showFlagTogglerUi(getContext());
|
||||
|
||||
case DEVELOPER_OPTIONS_KEY:
|
||||
// Show if plugins are enabled or flag UI is enabled.
|
||||
return FeatureFlags.showFlagTogglerUi(getContext()) ||
|
||||
PluginManagerWrapper.hasPlugins(getContext());
|
||||
mDeveloperOptionPref = preference;
|
||||
return updateDeveloperOption();
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import static android.view.View.VISIBLE;
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_ITEM_LONG_PRESSED;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.View.OnLongClickListener;
|
||||
@@ -32,6 +33,7 @@ import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.dragndrop.DragController;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.folder.Folder;
|
||||
import com.android.launcher3.logging.StatsLogManager.StatsLogger;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
@@ -86,6 +88,12 @@ public class ItemLongClickListener {
|
||||
if (!launcher.isInState(ALL_APPS) && !launcher.isInState(OVERVIEW)) return false;
|
||||
if (launcher.getWorkspace().isSwitchingState()) return false;
|
||||
|
||||
StatsLogger logger = launcher.getStatsLogManager().logger();
|
||||
if (v.getTag() instanceof ItemInfo) {
|
||||
logger.withItemInfo((ItemInfo) v.getTag());
|
||||
}
|
||||
logger.log(LAUNCHER_ALLAPPS_ITEM_LONG_PRESSED);
|
||||
|
||||
// Start the drag
|
||||
final DragController dragController = launcher.getDragController();
|
||||
dragController.addDragListener(new DragController.DragListener() {
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.launcher3.BaseRecyclerView;
|
||||
@@ -99,6 +100,7 @@ public class RecyclerViewFastScroller extends View {
|
||||
private boolean mIsThumbDetached;
|
||||
private final boolean mCanThumbDetach;
|
||||
private boolean mIgnoreDragGesture;
|
||||
private boolean mIsRecyclerViewFirstChildInParent = true;
|
||||
|
||||
// This is the offset from the top of the scrollbar when the user first starts touching. To
|
||||
// prevent jumping, this offset is applied as the user scrolls.
|
||||
@@ -112,6 +114,7 @@ public class RecyclerViewFastScroller extends View {
|
||||
|
||||
protected BaseRecyclerView mRv;
|
||||
private RecyclerView.OnScrollListener mOnScrollListener;
|
||||
@Nullable private OnFastScrollChangeListener mOnFastScrollChangeListener;
|
||||
|
||||
private int mDownX;
|
||||
private int mDownY;
|
||||
@@ -188,6 +191,9 @@ public class RecyclerViewFastScroller extends View {
|
||||
updatePopupY(y);
|
||||
mThumbOffsetY = y;
|
||||
invalidate();
|
||||
if (mOnFastScrollChangeListener != null) {
|
||||
mOnFastScrollChangeListener.onThumbOffsetYChanged(mThumbOffsetY);
|
||||
}
|
||||
}
|
||||
|
||||
public int getThumbOffsetY() {
|
||||
@@ -391,7 +397,9 @@ public class RecyclerViewFastScroller extends View {
|
||||
return false;
|
||||
}
|
||||
getHitRect(sTempRect);
|
||||
sTempRect.top += mRv.getScrollBarTop();
|
||||
if (mIsRecyclerViewFirstChildInParent) {
|
||||
sTempRect.top += mRv.getScrollBarTop();
|
||||
}
|
||||
if (outOffset != null) {
|
||||
outOffset.set(sTempRect.left, sTempRect.top);
|
||||
}
|
||||
@@ -404,4 +412,23 @@ public class RecyclerViewFastScroller extends View {
|
||||
// alpha is so low, it does not matter.
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setIsRecyclerViewFirstChildInParent(boolean isRecyclerViewFirstChildInParent) {
|
||||
mIsRecyclerViewFirstChildInParent = isRecyclerViewFirstChildInParent;
|
||||
}
|
||||
|
||||
public void setOnFastScrollChangeListener(
|
||||
@Nullable OnFastScrollChangeListener onFastScrollChangeListener) {
|
||||
mOnFastScrollChangeListener = onFastScrollChangeListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback that is invoked when there is a scroll change in {@link RecyclerViewFastScroller}.
|
||||
*/
|
||||
public interface OnFastScrollChangeListener {
|
||||
/**
|
||||
* Called when the thumb offset vertical position, in pixels, has changed to {@code y}.
|
||||
*/
|
||||
void onThumbOffsetYChanged(int y);
|
||||
}
|
||||
}
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.widget.picker;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.launcher3.views.RecyclerViewFastScroller;
|
||||
import com.android.launcher3.widget.picker.WidgetsFullSheet.SearchAndRecommendationViewHolder;
|
||||
import com.android.launcher3.workprofile.PersonalWorkPagedView;
|
||||
|
||||
/**
|
||||
* A controller which measures & updates {@link WidgetsFullSheet}'s views padding, margin and
|
||||
* vertical displacement upon scrolling.
|
||||
*/
|
||||
final class SearchAndRecommendationsScrollController implements
|
||||
RecyclerViewFastScroller.OnFastScrollChangeListener {
|
||||
private final boolean mHasWorkProfile;
|
||||
private final SearchAndRecommendationViewHolder mViewHolder;
|
||||
private final RecyclerView mPrimaryRecyclerView;
|
||||
|
||||
// The following are only non null if mHasWorkProfile is true.
|
||||
@Nullable private final RecyclerView mWorkRecyclerView;
|
||||
@Nullable private final View mPrimaryWorkTabsView;
|
||||
@Nullable private final PersonalWorkPagedView mPrimaryWorkViewPager;
|
||||
|
||||
private int mMaxCollapsibleHeight = 0;
|
||||
|
||||
SearchAndRecommendationsScrollController(
|
||||
boolean hasWorkProfile,
|
||||
SearchAndRecommendationViewHolder viewHolder,
|
||||
RecyclerView primaryRecyclerView,
|
||||
@Nullable RecyclerView workRecyclerView,
|
||||
@Nullable View personalWorkTabsView,
|
||||
@Nullable PersonalWorkPagedView primaryWorkViewPager) {
|
||||
mHasWorkProfile = hasWorkProfile;
|
||||
mViewHolder = viewHolder;
|
||||
mPrimaryRecyclerView = primaryRecyclerView;
|
||||
mWorkRecyclerView = workRecyclerView;
|
||||
mPrimaryWorkTabsView = personalWorkTabsView;
|
||||
mPrimaryWorkViewPager = primaryWorkViewPager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the margin and padding of {@link WidgetsFullSheet} to accumulate collapsible views.
|
||||
*/
|
||||
public void updateMarginAndPadding() {
|
||||
// The maximum vertical distance, in pixels, until the last collapsible element is not
|
||||
// visible from the screen when the user scrolls down the recycler view.
|
||||
mMaxCollapsibleHeight = mViewHolder.mContainer.getPaddingTop()
|
||||
+ mViewHolder.mCollapseHandle.getMeasuredHeight()
|
||||
+ mViewHolder.mHeaderTitle.getMeasuredHeight();
|
||||
|
||||
int topContainerHeight = mViewHolder.mContainer.getMeasuredHeight();
|
||||
if (mHasWorkProfile) {
|
||||
// In a work profile setup, the full widget sheet contains the following views:
|
||||
// ------- -|
|
||||
// Widgets -|---> LinearLayout for search & recommendations
|
||||
// Search bar -|
|
||||
// Personal | Work
|
||||
// View Pager
|
||||
//
|
||||
// Views after the search & recommendations are not bound by RelativelyLayout param.
|
||||
// To position them on the expected location, padding & margin are added to these views
|
||||
|
||||
// Tabs should have a padding of the height of the search & recommendations container.
|
||||
mPrimaryWorkTabsView.setPadding(
|
||||
mPrimaryWorkTabsView.getPaddingLeft(),
|
||||
topContainerHeight,
|
||||
mPrimaryWorkTabsView.getPaddingRight(),
|
||||
mPrimaryWorkTabsView.getPaddingBottom());
|
||||
|
||||
// Instead of setting the top offset directly, we split the top offset into two values:
|
||||
// 1. topOffsetAfterAllViewsCollapsed: this is the top offset after all collapsible
|
||||
// views are no longer visible on the screen.
|
||||
// This value is set as the margin for the view pager.
|
||||
// 2. mMaxCollapsibleDistance
|
||||
// This value is set as the padding for the recycler views in order to work with
|
||||
// clipToPadding="false", which is an attribute for not showing top / bottom padding
|
||||
// when a recycler view has not reached the top or bottom of the list.
|
||||
// e.g. a list of 10 entries, only 3 entries are visible at a time.
|
||||
// case 1: recycler view is scrolled to the top. Top padding is visible/
|
||||
// (top padding)
|
||||
// item 1
|
||||
// item 2
|
||||
// item 3
|
||||
//
|
||||
// case 2: recycler view is scrolled to the middle. No padding is visible.
|
||||
// item 4
|
||||
// item 5
|
||||
// item 6
|
||||
//
|
||||
// case 3: recycler view is scrolled to the end. bottom padding is visible.
|
||||
// item 8
|
||||
// item 9
|
||||
// item 10
|
||||
// (bottom padding): not set in this case.
|
||||
//
|
||||
// When the views are first inflated, the sum of topOffsetAfterAllViewsCollapsed and
|
||||
// mMaxCollapsibleDistance should equal to the top container height.
|
||||
int tabsViewActualHeight =
|
||||
mPrimaryWorkTabsView.getMeasuredHeight() - mPrimaryWorkTabsView.getPaddingTop();
|
||||
int topOffsetAfterAllViewsCollapsed =
|
||||
topContainerHeight + tabsViewActualHeight - mMaxCollapsibleHeight;
|
||||
|
||||
RelativeLayout.LayoutParams layoutParams =
|
||||
(RelativeLayout.LayoutParams) mPrimaryWorkViewPager.getLayoutParams();
|
||||
layoutParams.setMargins(0, topOffsetAfterAllViewsCollapsed, 0, 0);
|
||||
mPrimaryWorkViewPager.setLayoutParams(layoutParams);
|
||||
mPrimaryWorkViewPager.requestLayout();
|
||||
|
||||
mPrimaryRecyclerView.setPadding(
|
||||
mPrimaryRecyclerView.getPaddingLeft(),
|
||||
mMaxCollapsibleHeight,
|
||||
mPrimaryRecyclerView.getPaddingRight(),
|
||||
mPrimaryRecyclerView.getPaddingBottom());
|
||||
mWorkRecyclerView.setPadding(
|
||||
mWorkRecyclerView.getPaddingLeft(),
|
||||
mMaxCollapsibleHeight,
|
||||
mWorkRecyclerView.getPaddingRight(),
|
||||
mWorkRecyclerView.getPaddingBottom());
|
||||
} else {
|
||||
mPrimaryRecyclerView.setPadding(
|
||||
mPrimaryRecyclerView.getPaddingLeft(),
|
||||
topContainerHeight,
|
||||
mPrimaryRecyclerView.getPaddingRight(),
|
||||
mPrimaryRecyclerView.getPaddingBottom());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the displacement of collapsible views (e.g. title & widget recommendations) and fixed
|
||||
* views (e.g. recycler views, tabs) upon scrolling.
|
||||
*/
|
||||
@Override
|
||||
public void onThumbOffsetYChanged(int y) {
|
||||
if (mMaxCollapsibleHeight > 0) {
|
||||
int yDisplacement = Math.max(-y, -mMaxCollapsibleHeight);
|
||||
mViewHolder.mHeaderTitle.setTranslationY(yDisplacement);
|
||||
mViewHolder.mSearchBar.setTranslationY(yDisplacement);
|
||||
if (mHasWorkProfile) {
|
||||
mPrimaryWorkTabsView.setTranslationY(yDisplacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,8 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -61,7 +63,8 @@ import java.util.function.Predicate;
|
||||
* Popup for showing the full list of available widgets
|
||||
*/
|
||||
public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
implements Insettable, ProviderChangedListener, OnActivePageChangedListener {
|
||||
implements Insettable, ProviderChangedListener, OnActivePageChangedListener,
|
||||
WidgetsRecyclerView.HeaderViewDimensionsProvider {
|
||||
|
||||
private static final long DEFAULT_OPEN_DURATION = 267;
|
||||
private static final long FADE_IN_DURATION = 150;
|
||||
@@ -77,6 +80,10 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
mPrimaryWidgetsFilter.negate();
|
||||
|
||||
@Nullable private PersonalWorkPagedView mViewPager;
|
||||
private int mInitialTabsHeight = 0;
|
||||
private View mTabsView;
|
||||
private SearchAndRecommendationViewHolder mSearchAndRecommendationViewHolder;
|
||||
private SearchAndRecommendationsScrollController mSearchAndRecommendationsScrollController;
|
||||
|
||||
public WidgetsFullSheet(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
@@ -98,8 +105,9 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
|
||||
int contentLayoutRes = mHasWorkProfile ? R.layout.widgets_full_sheet_paged_view
|
||||
: R.layout.widgets_full_sheet_recyclerview;
|
||||
layoutInflater.inflate(contentLayoutRes, springLayout, true);
|
||||
layoutInflater.inflate(contentLayoutRes, springLayout, true);
|
||||
|
||||
RecyclerViewFastScroller fastScroller = findViewById(R.id.fast_scroller);
|
||||
if (mHasWorkProfile) {
|
||||
mViewPager = findViewById(R.id.widgets_view_pager);
|
||||
// Temporarily disable swipe gesture until widgets list horizontal scrollviews per
|
||||
@@ -108,10 +116,12 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
mViewPager.initParentViews(this);
|
||||
mViewPager.getPageIndicator().setOnActivePageChangedListener(this);
|
||||
mViewPager.getPageIndicator().setActiveMarker(AdapterHolder.PRIMARY);
|
||||
mTabsView = findViewById(R.id.tabs);
|
||||
findViewById(R.id.tab_personal)
|
||||
.setOnClickListener((View view) -> mViewPager.snapToPage(0));
|
||||
findViewById(R.id.tab_work)
|
||||
.setOnClickListener((View view) -> mViewPager.snapToPage(1));
|
||||
fastScroller.setIsRecyclerViewFirstChildInParent(false);
|
||||
springLayout.addSpringView(R.id.primary_widgets_list_view);
|
||||
springLayout.addSpringView(R.id.work_widgets_list_view);
|
||||
} else {
|
||||
@@ -119,12 +129,36 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
springLayout.addSpringView(R.id.primary_widgets_list_view);
|
||||
}
|
||||
|
||||
layoutInflater.inflate(R.layout.widgets_full_sheet_search_and_recommendations, springLayout,
|
||||
true);
|
||||
springLayout.addSpringView(R.id.search_and_recommendations_container);
|
||||
|
||||
mSearchAndRecommendationViewHolder = new SearchAndRecommendationViewHolder(
|
||||
findViewById(R.id.search_and_recommendations_container));
|
||||
mSearchAndRecommendationsScrollController = new SearchAndRecommendationsScrollController(
|
||||
mHasWorkProfile,
|
||||
mSearchAndRecommendationViewHolder,
|
||||
findViewById(R.id.primary_widgets_list_view),
|
||||
mHasWorkProfile ? findViewById(R.id.work_widgets_list_view) : null,
|
||||
mTabsView,
|
||||
mViewPager);
|
||||
fastScroller.setOnFastScrollChangeListener(mSearchAndRecommendationsScrollController);
|
||||
|
||||
onWidgetsBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivePageChanged(int currentActivePage) {
|
||||
mAdapters.get(currentActivePage).mWidgetsRecyclerView.bindFastScrollbar();
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
mAdapters.get(AdapterHolder.PRIMARY).mWidgetsRecyclerView.scrollToTop();
|
||||
if (mHasWorkProfile) {
|
||||
mAdapters.get(AdapterHolder.WORK).mWidgetsRecyclerView.scrollToTop();
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -220,6 +254,12 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
contentLeft + contentWidth, height);
|
||||
|
||||
setTranslationShift(mTranslationShift);
|
||||
|
||||
if (mInitialTabsHeight == 0 && mTabsView != null) {
|
||||
mInitialTabsHeight = mTabsView.getMeasuredHeight();
|
||||
}
|
||||
|
||||
mSearchAndRecommendationsScrollController.updateMarginAndPadding();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -325,6 +365,14 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
AccessibilityManagerCompat.sendStateEventToTest(getContext(), NORMAL_STATE_ORDINAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeaderViewHeight() {
|
||||
// No need to check work profile here because mInitialTabHeight is always 0 if there is no
|
||||
// work profile.
|
||||
return mInitialTabsHeight
|
||||
+ mSearchAndRecommendationViewHolder.mContainer.getMeasuredHeight();
|
||||
}
|
||||
|
||||
/** A holder class for holding adapters & their corresponding recycler view. */
|
||||
private final class AdapterHolder {
|
||||
static final int PRIMARY = 0;
|
||||
@@ -354,9 +402,24 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
||||
void setup(WidgetsRecyclerView recyclerView) {
|
||||
mWidgetsRecyclerView = recyclerView;
|
||||
mWidgetsRecyclerView.setAdapter(mWidgetsListAdapter);
|
||||
mWidgetsRecyclerView.setHeaderViewDimensionsProvider(WidgetsFullSheet.this);
|
||||
mWidgetsRecyclerView.setEdgeEffectFactory(
|
||||
((TopRoundedCornerView) mContent).createEdgeEffectFactory());
|
||||
mWidgetsListAdapter.setApplyBitmapDeferred(false, mWidgetsRecyclerView);
|
||||
}
|
||||
}
|
||||
|
||||
final class SearchAndRecommendationViewHolder {
|
||||
final View mContainer;
|
||||
final View mCollapseHandle;
|
||||
final EditText mSearchBar;
|
||||
final TextView mHeaderTitle;
|
||||
|
||||
SearchAndRecommendationViewHolder(View searchAndRecommendationContainer) {
|
||||
mContainer = searchAndRecommendationContainer;
|
||||
mCollapseHandle = mContainer.findViewById(R.id.collapse_handle);
|
||||
mSearchBar = mContainer.findViewById(R.id.widgets_search_bar);
|
||||
mHeaderTitle = mContainer.findViewById(R.id.title);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public class WidgetsRecyclerView extends BaseRecyclerView implements OnItemTouch
|
||||
|
||||
private final Point mFastScrollerOffset = new Point();
|
||||
private boolean mTouchDownOnScroller;
|
||||
private HeaderViewDimensionsProvider mHeaderViewDimensionsProvider;
|
||||
|
||||
public WidgetsRecyclerView(Context context) {
|
||||
this(context, null);
|
||||
@@ -135,8 +136,8 @@ public class WidgetsRecyclerView extends BaseRecyclerView implements OnItemTouch
|
||||
@Override
|
||||
protected int getAvailableScrollHeight() {
|
||||
View child = getChildAt(0);
|
||||
return child.getMeasuredHeight() * mAdapter.getItemCount() - getScrollbarTrackHeight()
|
||||
- mScrollbarTop;
|
||||
return child.getMeasuredHeight() * mAdapter.getItemCount() + getScrollBarTop()
|
||||
+ getPaddingBottom() - mScrollbar.getHeight();
|
||||
}
|
||||
|
||||
private boolean isModelNotReady() {
|
||||
@@ -145,7 +146,9 @@ public class WidgetsRecyclerView extends BaseRecyclerView implements OnItemTouch
|
||||
|
||||
@Override
|
||||
public int getScrollBarTop() {
|
||||
return mScrollbarTop;
|
||||
return mHeaderViewDimensionsProvider == null
|
||||
? mScrollbarTop
|
||||
: mHeaderViewDimensionsProvider.getHeaderViewHeight() + mScrollbarTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -171,4 +174,21 @@ public class WidgetsRecyclerView extends BaseRecyclerView implements OnItemTouch
|
||||
@Override
|
||||
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
||||
}
|
||||
|
||||
public void setHeaderViewDimensionsProvider(
|
||||
HeaderViewDimensionsProvider headerViewDimensionsProvider) {
|
||||
mHeaderViewDimensionsProvider = headerViewDimensionsProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides dimensions of the header view that is shown at the top of a
|
||||
* {@link WidgetsRecyclerView}.
|
||||
*/
|
||||
public interface HeaderViewDimensionsProvider {
|
||||
/**
|
||||
* Returns the height, in pixels, of the header view that is shown at the top of a
|
||||
* {@link WidgetsRecyclerView}.
|
||||
*/
|
||||
int getHeaderViewHeight();
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ abstract class Launchable {
|
||||
() -> "Launching an app didn't open a new window: " + label);
|
||||
|
||||
mLauncher.assertTrue(
|
||||
"App didn't start: " + label,
|
||||
"App didn't start: " + label + " (" + selector + ")",
|
||||
TestHelpers.wait(Until.hasObject(selector), LauncherInstrumentation.WAIT_TIME_MS));
|
||||
return new Background(mLauncher);
|
||||
}
|
||||
|
||||
@@ -365,9 +365,11 @@ public final class LauncherInstrumentation {
|
||||
|
||||
if (hasSystemUiObject("keyguard_status_view")) return "Phone is locked";
|
||||
|
||||
if (!mDevice.hasObject(By.textStartsWith(""))) return "Screen is empty";
|
||||
if (!mDevice.wait(Until.hasObject(By.textStartsWith("")), WAIT_TIME_MS)) {
|
||||
return "Screen is empty";
|
||||
}
|
||||
|
||||
final String navigationModeError = getNavigationModeMismatchError();
|
||||
final String navigationModeError = getNavigationModeMismatchError(true);
|
||||
if (navigationModeError != null) return navigationModeError;
|
||||
} catch (Throwable e) {
|
||||
Log.w(TAG, "getSystemAnomalyMessage failed", e);
|
||||
@@ -535,17 +537,28 @@ public final class LauncherInstrumentation {
|
||||
mExpectedRotation = expectedRotation;
|
||||
}
|
||||
|
||||
public String getNavigationModeMismatchError() {
|
||||
public String getNavigationModeMismatchError(boolean waitForCorrectState) {
|
||||
final int waitTime = waitForCorrectState ? WAIT_TIME_MS : 0;
|
||||
final NavigationModel navigationModel = getNavigationModel();
|
||||
final boolean hasRecentsButton = hasSystemUiObject("recent_apps");
|
||||
final boolean hasHomeButton = hasSystemUiObject("home");
|
||||
if ((navigationModel == NavigationModel.THREE_BUTTON) != hasRecentsButton) {
|
||||
return "Presence of recents button doesn't match the interaction mode, mode="
|
||||
+ navigationModel.name() + ", hasRecents=" + hasRecentsButton;
|
||||
|
||||
if (navigationModel == NavigationModel.THREE_BUTTON) {
|
||||
if (!mDevice.wait(Until.hasObject(By.res(SYSTEMUI_PACKAGE, "recent_apps")), waitTime)) {
|
||||
return "Recents button not present in 3-button mode";
|
||||
}
|
||||
} else {
|
||||
if (!mDevice.wait(Until.gone(By.res(SYSTEMUI_PACKAGE, "recent_apps")), waitTime)) {
|
||||
return "Recents button is present in non-3-button mode";
|
||||
}
|
||||
}
|
||||
if ((navigationModel != NavigationModel.ZERO_BUTTON) != hasHomeButton) {
|
||||
return "Presence of home button doesn't match the interaction mode, mode="
|
||||
+ navigationModel.name() + ", hasHome=" + hasHomeButton;
|
||||
|
||||
if (navigationModel == NavigationModel.ZERO_BUTTON) {
|
||||
if (!mDevice.wait(Until.gone(By.res(SYSTEMUI_PACKAGE, "home")), waitTime)) {
|
||||
return "Home button is present in gestural mode";
|
||||
}
|
||||
} else {
|
||||
if (!mDevice.wait(Until.hasObject(By.res(SYSTEMUI_PACKAGE, "home")), waitTime)) {
|
||||
return "Home button not present in non-gestural mode";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -556,7 +569,7 @@ public final class LauncherInstrumentation {
|
||||
assertEquals("Unexpected display rotation",
|
||||
mExpectedRotation, mDevice.getDisplayRotation());
|
||||
|
||||
final String error = getNavigationModeMismatchError();
|
||||
final String error = getNavigationModeMismatchError(true);
|
||||
assertTrue(error, error == null);
|
||||
|
||||
log("verifyContainerType: " + containerType);
|
||||
|
||||
@@ -110,7 +110,8 @@ public final class Workspace extends Home {
|
||||
TestProtocol.REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT).
|
||||
getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
|
||||
LauncherInstrumentation.log(
|
||||
"switchToAllApps: swipeHeight = " + swipeHeight + ", slop = "
|
||||
"switchToAllApps: deviceHeight = " + deviceHeight + ", startY = " + startY
|
||||
+ ", swipeHeight = " + swipeHeight + ", slop = "
|
||||
+ mLauncher.getTouchSlop());
|
||||
|
||||
mLauncher.swipeToState(
|
||||
|
||||
Reference in new issue
Block a user