diff options
Diffstat (limited to 'src')
13 files changed, 68 insertions, 55 deletions
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java index 76a91c0029..0149dcb0f7 100644 --- a/src/com/android/launcher3/AppWidgetResizeFrame.java +++ b/src/com/android/launcher3/AppWidgetResizeFrame.java @@ -15,7 +15,6 @@ import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; -import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import android.graphics.Rect; import android.graphics.drawable.Drawable; @@ -220,23 +219,6 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O mWidgetPadding = getDefaultPaddingForWidget(getContext(), widgetView.getAppWidgetInfo().provider, null); - // Only show resize handles for the directions in which resizing is possible. - InvariantDeviceProfile idp = LauncherAppState.getIDP(cellLayout.getContext()); - mVerticalResizeActive = (info.resizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0 - && mMinVSpan < idp.numRows && mMaxVSpan > 1 - && mMinVSpan < mMaxVSpan; - if (!mVerticalResizeActive) { - mDragHandles[INDEX_TOP].setVisibility(GONE); - mDragHandles[INDEX_BOTTOM].setVisibility(GONE); - } - mHorizontalResizeActive = (info.resizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0 - && mMinHSpan < idp.numColumns && mMaxHSpan > 1 - && mMinHSpan < mMaxHSpan; - if (!mHorizontalResizeActive) { - mDragHandles[INDEX_LEFT].setVisibility(GONE); - mDragHandles[INDEX_RIGHT].setVisibility(GONE); - } - mReconfigureButton = (ImageButton) findViewById(R.id.widget_reconfigure_button); if (info.isReconfigurable()) { mReconfigureButton.setVisibility(VISIBLE); @@ -289,12 +271,10 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O } public boolean beginResizeIfPointInRegion(int x, int y) { - mLeftBorderActive = (x < mTouchTargetWidth) && mHorizontalResizeActive; - mRightBorderActive = (x > getWidth() - mTouchTargetWidth) && mHorizontalResizeActive; - mTopBorderActive = (y < mTouchTargetWidth + mTopTouchRegionAdjustment) - && mVerticalResizeActive; - mBottomBorderActive = (y > getHeight() - mTouchTargetWidth + mBottomTouchRegionAdjustment) - && mVerticalResizeActive; + mLeftBorderActive = x < mTouchTargetWidth; + mRightBorderActive = x > getWidth() - mTouchTargetWidth; + mTopBorderActive = y < mTouchTargetWidth + mTopTouchRegionAdjustment; + mBottomBorderActive = y > getHeight() - mTouchTargetWidth + mBottomTouchRegionAdjustment; boolean anyBordersActive = mLeftBorderActive || mRightBorderActive || mTopBorderActive || mBottomBorderActive; diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index a4020f9cab..60c2b35dc8 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -470,7 +470,7 @@ public class InvariantDeviceProfile { // Re-init grid String gridName = getCurrentGridName(context); - initGrid(context, gridName); + initGrid(context, LauncherPrefs.getPrefs(context).getString(KEY_IDP_GRID_NAME, gridName)); boolean modelPropsChanged = !Arrays.equals(oldState, toModelState()); for (OnIDPChangeListener listener : mChangeListeners) { diff --git a/src/com/android/launcher3/LauncherFiles.java b/src/com/android/launcher3/LauncherFiles.java index e59eac8dd2..583640eddc 100644 --- a/src/com/android/launcher3/LauncherFiles.java +++ b/src/com/android/launcher3/LauncherFiles.java @@ -17,10 +17,8 @@ public class LauncherFiles { public static final String LAUNCHER_DB = "launcher.db"; public static final String LAUNCHER_6_BY_5_DB = "launcher_6_by_5.db"; + public static final String LAUNCHER_5_BY_6_DB = "launcher_5_by_6.db"; public static final String LAUNCHER_4_BY_5_DB = "launcher_4_by_5.db"; - public static final String LAUNCHER_4_BY_4_DB = "launcher_4_by_4.db"; - public static final String LAUNCHER_3_BY_3_DB = "launcher_3_by_3.db"; - public static final String LAUNCHER_2_BY_2_DB = "launcher_2_by_2.db"; public static final String BACKUP_DB = "backup.db"; public static final String SHARED_PREFERENCES_KEY = "com.android.launcher3.prefs"; public static final String MANAGED_USER_PREFERENCES_KEY = @@ -34,10 +32,8 @@ public class LauncherFiles { public static final List<String> GRID_DB_FILES = Collections.unmodifiableList(Arrays.asList( LAUNCHER_DB, LAUNCHER_6_BY_5_DB, - LAUNCHER_4_BY_5_DB, - LAUNCHER_4_BY_4_DB, - LAUNCHER_3_BY_3_DB, - LAUNCHER_2_BY_2_DB)); + LAUNCHER_5_BY_6_DB, + LAUNCHER_4_BY_5_DB)); public static final List<String> OTHER_FILES = Collections.unmodifiableList(Arrays.asList( BACKUP_DB, diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index d7e84f0306..d76e5383cf 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -132,7 +132,6 @@ public final class Utilities { * add extra logging and not for changing the app behavior. */ public static final boolean IS_DEBUG_DEVICE = - Build.TYPE.toLowerCase(Locale.ROOT).contains("debug") || Build.TYPE.toLowerCase(Locale.ROOT).equals("eng"); /** diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 483309d1cf..4640b19a24 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2105,8 +2105,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T> private Runnable getWidgetResizeFrameRunnable(DragOptions options, LauncherAppWidgetHostView hostView, CellLayout cellLayout) { AppWidgetProviderInfo pInfo = hostView.getAppWidgetInfo(); - if (pInfo != null && pInfo.resizeMode != AppWidgetProviderInfo.RESIZE_NONE - && !options.isAccessibleDrag) { + if (pInfo != null && !options.isAccessibleDrag) { return () -> { if (!isPageInTransition()) { AppWidgetResizeFrame.showForWidget(hostView, cellLayout); diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index 2511cada78..787d543c6f 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -43,7 +43,8 @@ import java.util.ArrayList; public class ActivityAllAppsContainerView<T extends Context & ActivityContext> extends BaseAllAppsContainerView<T> { - private static final long DEFAULT_SEARCH_TRANSITION_DURATION_MS = 300; + // As of this writing, search transition does not seem to work properly, so set duration to 0. + private static final long DEFAULT_SEARCH_TRANSITION_DURATION_MS = 0; // Used to animate Search results out and A-Z apps in, or vice-versa. private final SearchTransitionController mSearchTransitionController; @@ -122,6 +123,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> // Fade out the button to pause work apps. mWorkManager.onActivePageChanged(SEARCH); } + setScrollbarVisibility(!goingToSearch); mSearchTransitionController.animateToSearchState(goingToSearch, durationMs, /* onEndRunnable = */ () -> { mIsSearching = goingToSearch; @@ -243,6 +245,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> @Override protected void updateHeaderScroll(int scrolledOffset) { super.updateHeaderScroll(scrolledOffset); + getSearchView().setBackgroundResource(R.drawable.bg_all_apps_searchbox); if (mSearchUiManager.getEditText() == null) { return; } @@ -270,13 +273,15 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> } RelativeLayout.LayoutParams layoutParams = (LayoutParams) v.getLayoutParams(); - layoutParams.addRule(RelativeLayout.ALIGN_TOP, R.id.search_container_all_apps); + layoutParams.addRule(RelativeLayout.BELOW, R.id.search_container_all_apps); int topMargin = getContext().getResources().getDimensionPixelSize( - R.dimen.all_apps_header_top_margin); + R.dimen.all_apps_search_bar_bottom_adjustment); if (includeTabsMargin) { topMargin += getContext().getResources().getDimensionPixelSize( - R.dimen.all_apps_header_pill_height); + R.dimen.all_apps_header_pill_height) + + getContext().getResources().getDimensionPixelSize( + R.dimen.all_apps_tabs_margin_top); } layoutParams.topMargin = topMargin; } @@ -313,6 +318,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> layoutParams.removeRule(RelativeLayout.ABOVE); layoutParams.removeRule(RelativeLayout.ALIGN_TOP); layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_TOP); + layoutParams.removeRule(RelativeLayout.BELOW); } @Override diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java index 29767bf465..2567fab1d6 100644 --- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java +++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java @@ -20,6 +20,7 @@ import android.content.Context; import androidx.annotation.Nullable; import androidx.recyclerview.widget.DiffUtil; +import com.android.launcher3.R; import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; @@ -28,7 +29,6 @@ import com.android.launcher3.views.ActivityContext; import java.util.ArrayList; import java.util.List; -import java.util.Locale; import java.util.Objects; import java.util.TreeMap; import java.util.function.Predicate; @@ -85,6 +85,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement private final int mNumAppsPerRowAllApps; private int mNumAppRowsInAdapter; private Predicate<ItemInfo> mItemFilter; + private final boolean mSortSections; public AlphabeticalAppsList(Context context, @Nullable AllAppsStore appsStore, WorkProfileManager workProfileManager) { @@ -96,6 +97,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement if (mAllAppsStore != null) { mAllAppsStore.addUpdateListener(this); } + mSortSections = context.getResources().getBoolean(R.bool.config_appsListSortSections); } public void updateItemFilter(Predicate<ItemInfo> itemFilter) { @@ -201,9 +203,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement // As a special case for some languages (currently only Simplified Chinese), we may need to // coalesce sections - Locale curLocale = mActivityContext.getResources().getConfiguration().locale; - boolean localeRequiresSectionSorting = curLocale.equals(Locale.SIMPLIFIED_CHINESE); - if (localeRequiresSectionSorting) { + if (mSortSections) { // Compute the section headers. We use a TreeMap with the section name comparator to // ensure that the sections are ordered when we iterate over it later appSteam = appSteam.collect(Collectors.groupingBy( diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java index 00e89bacc5..068e3101f2 100644 --- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java @@ -96,6 +96,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte public static final float FLING_VELOCITY_MULTIPLIER = 1200f; // Render the header protection at all times to debug clipping issues. + // This is useful enough to warrant the comment you are reading now to point it out! private static final boolean DEBUG_HEADER_PROTECTION = false; private final Paint mHeaderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); @@ -610,6 +611,13 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.SEARCH).mRecyclerView); } + protected void setScrollbarVisibility(boolean visible) { + final RecyclerViewFastScroller scrollbar = getScrollBar(); + if (scrollbar != null) { + scrollbar.setVisibility(visible ? VISIBLE : GONE); + } + } + protected void updateSearchResultsVisibility() { if (isSearching()) { getSearchRecyclerView().setVisibility(VISIBLE); @@ -751,13 +759,22 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte tabsHidden); int padding = mHeader.getMaxTranslation(); - mAH.forEach(adapterHolder -> { - adapterHolder.mPadding.top = padding; + for (int i = 0; i < mAH.size(); i++) { + final AdapterHolder adapterHolder = mAH.get(i); + // Search and other adapters need to be handled a bit differently; otherwise, when + // when leaving search, the All Apps view may be noticeably shifted downward because + // its padding was unnecessarily impacted, and never restored, upon entering search. + if (i != AdapterHolder.SEARCH && !tabsHidden && mHeader.getFloatingRowsHeight() == 0) { + // Only the Search adapter needs padding when there are tabs but no floating rows. + adapterHolder.mPadding.top = 0; + } else { + adapterHolder.mPadding.top = padding; + } adapterHolder.applyPadding(); if (adapterHolder.mRecyclerView != null) { adapterHolder.mRecyclerView.scrollToTop(); } - }); + } } public boolean isHeaderVisible() { diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java index c18f9e1884..051955b56a 100644 --- a/src/com/android/launcher3/allapps/FloatingHeaderView.java +++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java @@ -225,7 +225,6 @@ public class FloatingHeaderView extends LinearLayout implements for (FloatingHeaderRow row : mAllRows) { row.setup(this, mAllRows, tabsHidden); } - updateExpectedHeight(); mTabsHidden = tabsHidden; mTabLayout.setVisibility(tabsHidden ? View.GONE : View.VISIBLE); @@ -250,6 +249,8 @@ public class FloatingHeaderView extends LinearLayout implements rvType == AdapterHolder.MAIN ? mMainRV : rvType == AdapterHolder.WORK ? mWorkRV : mSearchRV; mCurrentRV.addOnScrollListener(mOnScrollListener); + + updateExpectedHeight(); } private void updateExpectedHeight() { @@ -259,10 +260,7 @@ public class FloatingHeaderView extends LinearLayout implements return; } mMaxTranslation += mFloatingRowsHeight; - if (!mTabsHidden) { - mMaxTranslation += mTabsAdditionalPaddingBottom - + getResources().getDimensionPixelSize(R.dimen.all_apps_tabs_margin_top); - } + // No need for mMaxTranslation to be any taller now that we align below the header. } int getMaxTranslation() { diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java index 4427a49dab..f94658c404 100644 --- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java @@ -132,7 +132,7 @@ public class AllAppsSearchBarController public boolean onBackKey() { // Only hide the search field if there is no query String query = Utilities.trim(mInput.getEditableText().toString()); - if (query.isEmpty()) { + if (!query.isEmpty()) { reset(); return true; } diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java index 78c305b2eb..d83efd6c16 100644 --- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java +++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java @@ -77,7 +77,6 @@ public class AppsSearchContainerLayout extends ExtendedEditText mSearchQueryBuilder = new SpannableStringBuilder(); Selection.setSelection(mSearchQueryBuilder, 0); - setHint(prefixTextWithIcon(getContext(), R.drawable.ic_allapps_search, getHint())); mContentOverlap = getResources().getDimensionPixelSize(R.dimen.all_apps_search_bar_content_overlap); diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index e2d81997f8..8dd26a9ce4 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -201,7 +201,7 @@ public final class FeatureFlags { "Uses two panel on home screen. Only applicable on large screen devices."); public static final BooleanFlag ENABLE_SCRIM_FOR_APP_LAUNCH = getDebugFlag( - "ENABLE_SCRIM_FOR_APP_LAUNCH", false, + "ENABLE_SCRIM_FOR_APP_LAUNCH", true, "Enables scrim during app launch animation."); public static final BooleanFlag ENABLE_ENFORCED_ROUNDED_CORNERS = new DeviceFlag( @@ -343,7 +343,7 @@ public final class FeatureFlags { "Use a single page for the workspace"); public static final BooleanFlag ENABLE_TRANSIENT_TASKBAR = getDebugFlag( - "ENABLE_TRANSIENT_TASKBAR", false, "Enables transient taskbar."); + "ENABLE_TRANSIENT_TASKBAR", true, "Enables transient taskbar."); public static final BooleanFlag SECONDARY_DRAG_N_DROP_TO_PIN = getDebugFlag( "SECONDARY_DRAG_N_DROP_TO_PIN", false, diff --git a/src/com/android/launcher3/touch/WorkspaceTouchListener.java b/src/com/android/launcher3/touch/WorkspaceTouchListener.java index 96ae4a32fd..7dd9b7ba16 100644 --- a/src/com/android/launcher3/touch/WorkspaceTouchListener.java +++ b/src/com/android/launcher3/touch/WorkspaceTouchListener.java @@ -15,6 +15,8 @@ */ package com.android.launcher3.touch; +import static android.provider.Settings.System.DOUBLE_TAP_SLEEP_GESTURE; + import static android.view.MotionEvent.ACTION_CANCEL; import static android.view.MotionEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_MOVE; @@ -26,8 +28,12 @@ import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_CLOSE_TAP_OUTSIDE; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORKSPACE_LONGPRESS; +import android.content.ContentResolver; +import android.content.Context; import android.graphics.PointF; import android.graphics.Rect; +import android.os.PowerManager; +import android.provider.Settings; import android.view.GestureDetector; import android.view.HapticFeedbackConstants; import android.view.MotionEvent; @@ -71,15 +77,21 @@ public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListe private int mLongPressState = STATE_CANCELLED; + private final PowerManager mPm; + private final GestureDetector mGestureDetector; + private final ContentResolver mContentResolver; + public WorkspaceTouchListener(Launcher launcher, Workspace<?> workspace) { mLauncher = launcher; mWorkspace = workspace; // Use twice the touch slop as we are looking for long press which is more // likely to cause movement. mTouchSlop = 2 * ViewConfiguration.get(launcher).getScaledTouchSlop(); + mPm = (PowerManager) workspace.getContext().getSystemService(Context.POWER_SERVICE); mGestureDetector = new GestureDetector(workspace.getContext(), this); + mContentResolver = workspace.getContext().getContentResolver(); } @Override @@ -210,4 +222,11 @@ public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListe } } } + + @Override + public boolean onDoubleTap(MotionEvent event) { + if (Settings.Secure.getInt(mContentResolver, DOUBLE_TAP_SLEEP_GESTURE, 0) == 1) + mPm.goToSleep(event.getEventTime()); + return true; + } } |