diff options
Diffstat (limited to 'src')
13 files changed, 247 insertions, 41 deletions
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java index 300f22bd96..3625e2da06 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; @@ -238,23 +237,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); @@ -307,12 +289,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 ff7a90cb2c..5d3b5fd166 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -402,7 +402,7 @@ public class InvariantDeviceProfile { // Re-init grid String gridName = getCurrentGridName(context); - initGrid(context, gridName); + initGrid(context, Utilities.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/OverlayCallbackImpl.java b/src/com/android/launcher3/OverlayCallbackImpl.java new file mode 100644 index 0000000000..8d8609bce4 --- /dev/null +++ b/src/com/android/launcher3/OverlayCallbackImpl.java @@ -0,0 +1,185 @@ +/* + * Copyright (C) 2016 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; + +import android.app.Activity; +import android.content.SharedPreferences; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; +import android.os.Bundle; + +import com.android.launcher3.Launcher; +import com.android.launcher3.Utilities; +import com.android.systemui.plugins.shared.LauncherOverlayManager; +import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay; + +import com.google.android.libraries.gsa.launcherclient.LauncherClient; +import com.google.android.libraries.gsa.launcherclient.LauncherClientCallbacks; + +import java.io.PrintWriter; + +/** + * Implements {@link LauncherOverlay} and passes all the corresponding events to {@link + * LauncherClient}. {@see setClient} + * + * <p>Implements {@link LauncherClientCallbacks} and sends all the corresponding callbacks to {@link + * Launcher}. + */ +public class OverlayCallbackImpl + implements LauncherOverlay, LauncherClientCallbacks, LauncherOverlayManager, + OnSharedPreferenceChangeListener { + + public static final String KEY_ENABLE_MINUS_ONE = "pref_enable_minus_one"; + + private final Launcher mLauncher; + private final LauncherClient mClient; + + private LauncherOverlayCallbacks mLauncherOverlayCallbacks; + private boolean mWasOverlayAttached = false; + + public OverlayCallbackImpl(Launcher launcher) { + SharedPreferences prefs = Utilities.getPrefs(launcher); + + mLauncher = launcher; + mClient = new LauncherClient(mLauncher, this, getClientOptions(prefs)); + prefs.registerOnSharedPreferenceChangeListener(this); + } + + @Override + public void onDeviceProvideChanged() { + mClient.reattachOverlay(); + } + + @Override + public void onAttachedToWindow() { + mClient.onAttachedToWindow(); + } + + @Override + public void onDetachedFromWindow() { + mClient.onDetachedFromWindow(); + } + + @Override + public void dump(String prefix, PrintWriter w) { + mClient.dump(prefix, w); + } + + @Override + public void openOverlay() { + mClient.showOverlay(true); + } + + @Override + public void hideOverlay(boolean animate) { + mClient.hideOverlay(animate); + } + + @Override + public void hideOverlay(int duration) { + mClient.hideOverlay(duration); + } + + @Override + public boolean startSearch(byte[] config, Bundle extras) { + return false; + } + + @Override + public void onActivityCreated(Activity activity, Bundle bundle) { + // Not called + } + + @Override + public void onActivityStarted(Activity activity) { + mClient.onStart(); + } + + @Override + public void onActivityResumed(Activity activity) { + mClient.onResume(); + } + + @Override + public void onActivityPaused(Activity activity) { + mClient.onPause(); + } + + @Override + public void onActivityStopped(Activity activity) { + mClient.onStop(); + } + + @Override + public void onActivitySaveInstanceState(Activity activity, Bundle bundle) { } + + @Override + public void onActivityDestroyed(Activity activity) { + mClient.onDestroy(); + mLauncher.getSharedPrefs().unregisterOnSharedPreferenceChangeListener(this); + } + + @Override + public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { + if (KEY_ENABLE_MINUS_ONE.equals(key)) { + mClient.setClientOptions(getClientOptions(prefs)); + } + } + + @Override + public void onServiceStateChanged(boolean overlayAttached, boolean hotwordActive) { + if (overlayAttached != mWasOverlayAttached) { + mWasOverlayAttached = overlayAttached; + mLauncher.setLauncherOverlay(overlayAttached ? this : null); + } + } + + @Override + public void onOverlayScrollChanged(float progress) { + if (mLauncherOverlayCallbacks != null) { + mLauncherOverlayCallbacks.onScrollChanged(progress); + } + } + + @Override + public void onScrollInteractionBegin() { + mClient.startMove(); + } + + @Override + public void onScrollInteractionEnd() { + mClient.endMove(); + } + + @Override + public void onScrollChange(float progress, boolean rtl) { + mClient.updateMove(progress); + } + + @Override + public void setOverlayCallbacks(LauncherOverlayCallbacks callbacks) { + mLauncherOverlayCallbacks = callbacks; + } + + + private LauncherClient.ClientOptions getClientOptions(SharedPreferences prefs) { + return new LauncherClient.ClientOptions( + prefs.getBoolean(KEY_ENABLE_MINUS_ONE, true), + true, /* enableHotword */ + true /* enablePrewarming */ + ); + } +} diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index d2fe483c96..84663c64ac 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -139,7 +139,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 281dfea492..f4f14e802d 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2078,8 +2078,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> final LauncherAppWidgetHostView hostView = (LauncherAppWidgetHostView) cell; AppWidgetProviderInfo pInfo = hostView.getAppWidgetInfo(); - if (pInfo != null && pInfo.resizeMode != AppWidgetProviderInfo.RESIZE_NONE - && !options.isAccessibleDrag) { + if (pInfo != null && !options.isAccessibleDrag) { onCompleteRunnable = () -> { if (!isPageInTransition()) { AppWidgetResizeFrame.showForWidget(hostView, cellLayout); diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 3ba6ea4de9..a796d13931 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -760,6 +760,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo if (headerColor != mHeaderColor || mTabsProtectionAlpha != tabsAlpha) { mHeaderColor = headerColor; mTabsProtectionAlpha = tabsAlpha; + getSearchView().setBackgroundResource(R.drawable.bg_all_apps_searchbox); invalidateHeader(); } if (mSearchUiManager.getEditText() != null) { diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java index 85ee636a12..44ec71c2ec 100644 --- a/src/com/android/launcher3/allapps/FloatingHeaderView.java +++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java @@ -314,7 +314,7 @@ public class FloatingHeaderView extends LinearLayout implements mTabLayout.setTranslationY(mTranslationY); - int clipHeight = mHeaderTopPadding - getPaddingBottom(); + int clipHeight = mHeaderTopPadding - getPaddingBottom() * 2; mRVClip.top = mTabsHidden ? clipHeight : 0; mHeaderClip.top = clipHeight; // clipping on a draw might cause additional redraw @@ -441,7 +441,7 @@ public class FloatingHeaderView extends LinearLayout implements if (mTabsHidden || !mHeaderCollapsed) { return 0; } - return Math.max(getHeight() - getPaddingTop() + mTranslationY, 0); + return Math.max(getHeight() - getPaddingTop() + mTranslationY + getPaddingBottom(), 0); } } diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java index 0137e2a2c0..c24b2d4680 100644 --- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java @@ -134,7 +134,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 4c5a9e64c9..77ed7962ac 100644 --- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java +++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java @@ -79,7 +79,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_field_height) / 2; diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 2d31aa4687..26045f0066 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -52,7 +52,7 @@ public final class FeatureFlags { * Enable moving the QSB on the 0th screen of the workspace. This is not a configuration feature * and should be modified at a project level. */ - public static final boolean QSB_ON_FIRST_SCREEN = true; + public static final boolean QSB_ON_FIRST_SCREEN = false; /** * Feature flag to handle define config changes dynamically instead of killing the process. @@ -209,7 +209,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_SPLIT_SELECT = getDebugFlag( diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java index 0c39632708..0885df9be2 100644 --- a/src/com/android/launcher3/settings/SettingsActivity.java +++ b/src/com/android/launcher3/settings/SettingsActivity.java @@ -20,8 +20,12 @@ import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.ACTIO import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY; +import static com.android.launcher3.OverlayCallbackImpl.KEY_ENABLE_MINUS_ONE; + +import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.os.Bundle; import android.text.TextUtils; import android.view.MenuItem; @@ -189,6 +193,10 @@ public class SettingsActivity extends FragmentActivity private boolean mPreferenceHighlighted = false; private Preference mDeveloperOptionPref; + protected static final String GSA_PACKAGE = "com.google.android.googlequicksearchbox"; + + private Preference mShowGoogleAppPref; + @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { final Bundle args = getArguments(); @@ -270,6 +278,11 @@ public class SettingsActivity extends FragmentActivity case DEVELOPER_OPTIONS_KEY: mDeveloperOptionPref = preference; return updateDeveloperOption(); + + case KEY_ENABLE_MINUS_ONE: + mShowGoogleAppPref = preference; + updateIsGoogleAppEnabled(); + return true; } return true; @@ -293,6 +306,20 @@ public class SettingsActivity extends FragmentActivity return showPreference; } + public static boolean isGSAEnabled(Context context) { + try { + return context.getPackageManager().getApplicationInfo(GSA_PACKAGE, 0).enabled; + } catch (PackageManager.NameNotFoundException e) { + return false; + } + } + + private void updateIsGoogleAppEnabled() { + if (mShowGoogleAppPref != null) { + mShowGoogleAppPref.setEnabled(isGSAEnabled(getContext())); + } + } + @Override public void onResume() { super.onResume(); @@ -308,6 +335,7 @@ public class SettingsActivity extends FragmentActivity requestAccessibilityFocus(getListView()); } } + updateIsGoogleAppEnabled(); } private PreferenceHighlighter createHighlighter() { diff --git a/src/com/android/launcher3/touch/WorkspaceTouchListener.java b/src/com/android/launcher3/touch/WorkspaceTouchListener.java index 20d2ad36a5..de484de283 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.Secure.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; @@ -24,8 +26,12 @@ import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.LauncherState.NORMAL; 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; @@ -67,15 +73,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 @@ -180,4 +192,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; + } } |