Snap for 7253016 from ed85ee6ca6 to sc-v2-release
Change-Id: I5fe0323c752962388817b791dbd5ac8c618e40ad
This commit is contained in:
-17
@@ -38,7 +38,6 @@ import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.graphics.PointF;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
@@ -155,11 +154,6 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
|
||||
super.onDragEnd(velocity);
|
||||
}
|
||||
|
||||
View searchView = mLauncher.getHotseat().getQsb();
|
||||
if (searchView instanceof FeedbackHandler) {
|
||||
((FeedbackHandler) searchView).resetFeedback();
|
||||
}
|
||||
|
||||
mMotionPauseDetector.clear();
|
||||
mNormalToHintOverviewScrimAnimator = null;
|
||||
if (mLauncher.isInState(OVERVIEW)) {
|
||||
@@ -314,15 +308,4 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
|
||||
}
|
||||
return super.getConfigForStates(fromState, toState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for views with feedback animation requiring reset
|
||||
*/
|
||||
public interface FeedbackHandler {
|
||||
|
||||
/**
|
||||
* reset searchWidget feedback
|
||||
*/
|
||||
void resetFeedback();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1071,9 +1071,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
||||
HomeAnimationFactory homeAnimFactory = createHomeAnimationFactory(duration);
|
||||
mIsSwipingPipToHome = homeAnimFactory.supportSwipePipToHome()
|
||||
&& runningTaskTarget != null
|
||||
&& runningTaskTarget.pictureInPictureParams != null
|
||||
&& runningTaskTarget.taskInfo.pictureInPictureParams != null
|
||||
&& TaskInfoCompat.isAutoEnterPipEnabled(
|
||||
runningTaskTarget.pictureInPictureParams);
|
||||
runningTaskTarget.taskInfo.pictureInPictureParams);
|
||||
if (mIsSwipingPipToHome) {
|
||||
mSwipePipToHomeAnimator = getSwipePipToHomeAnimator(
|
||||
homeAnimFactory, runningTaskTarget, start);
|
||||
@@ -1161,7 +1161,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
||||
final Rect destinationBounds = SystemUiProxy.INSTANCE.get(mContext)
|
||||
.startSwipePipToHome(taskInfo.topActivity,
|
||||
TaskInfoCompat.getTopActivityInfo(taskInfo),
|
||||
runningTaskTarget.pictureInPictureParams,
|
||||
runningTaskTarget.taskInfo.pictureInPictureParams,
|
||||
homeRotation,
|
||||
mDp.hotseatBarSizePx);
|
||||
final Rect startBounds = new Rect();
|
||||
@@ -1170,7 +1170,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
||||
runningTaskTarget.taskId,
|
||||
taskInfo.topActivity,
|
||||
runningTaskTarget.leash.getSurfaceControl(),
|
||||
TaskInfoCompat.getPipSourceRectHint(runningTaskTarget.pictureInPictureParams),
|
||||
TaskInfoCompat.getPipSourceRectHint(
|
||||
runningTaskTarget.taskInfo.pictureInPictureParams),
|
||||
TaskInfoCompat.getWindowConfigurationBounds(taskInfo),
|
||||
startBounds,
|
||||
destinationBounds,
|
||||
|
||||
@@ -187,7 +187,7 @@ public class RecentsAnimationDeviceState implements
|
||||
SettingsCache.OnChangeListener onChangeListener =
|
||||
enabled -> mIsOneHandedModeEnabled = enabled;
|
||||
settingsCache.register(oneHandedUri, onChangeListener);
|
||||
settingsCache.dispatchOnChange(oneHandedUri);
|
||||
mIsOneHandedModeEnabled = settingsCache.getValue(oneHandedUri);
|
||||
runOnDestroy(() -> settingsCache.unregister(oneHandedUri, onChangeListener));
|
||||
} else {
|
||||
mIsOneHandedModeEnabled = false;
|
||||
@@ -199,7 +199,7 @@ public class RecentsAnimationDeviceState implements
|
||||
SettingsCache.OnChangeListener onChangeListener =
|
||||
enabled -> mIsSwipeToNotificationEnabled = enabled;
|
||||
settingsCache.register(swipeBottomNotificationUri, onChangeListener);
|
||||
settingsCache.dispatchOnChange(swipeBottomNotificationUri);
|
||||
mIsSwipeToNotificationEnabled = settingsCache.getValue(swipeBottomNotificationUri);
|
||||
runOnDestroy(() -> settingsCache.unregister(swipeBottomNotificationUri, onChangeListener));
|
||||
|
||||
Uri setupCompleteUri = Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE);
|
||||
|
||||
@@ -80,7 +80,7 @@ public class SettingsChangeLogger implements
|
||||
SettingsCache mSettingsCache = SettingsCache.INSTANCE.get(context);
|
||||
mSettingsCache.register(NOTIFICATION_BADGING_URI,
|
||||
this::onNotificationDotsChanged);
|
||||
mSettingsCache.dispatchOnChange(NOTIFICATION_BADGING_URI);
|
||||
onNotificationDotsChanged(mSettingsCache.getValue(NOTIFICATION_BADGING_URI));
|
||||
}
|
||||
|
||||
private static ArrayMap<String, LoggablePref> loadPrefKeys(Context context) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.graphics.Insets;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.os.StrictMode;
|
||||
|
||||
@@ -400,12 +400,7 @@ public class DeviceProfile {
|
||||
.setMultiWindowMode(true)
|
||||
.build();
|
||||
|
||||
// If there isn't enough vertical cell padding with the labels displayed, hide the labels.
|
||||
float workspaceCellPaddingY = profile.getCellSize().y - profile.iconSizePx
|
||||
- iconDrawablePaddingPx - profile.iconTextSizePx;
|
||||
if (workspaceCellPaddingY < profile.iconDrawablePaddingPx * 2) {
|
||||
profile.adjustToHideWorkspaceLabels();
|
||||
}
|
||||
profile.hideWorkspaceLabelsIfNotEnoughSpace();
|
||||
|
||||
// We use these scales to measure and layout the widgets using their full invariant profile
|
||||
// sizes and then draw them scaled and centered to fit in their multi-window mode cellspans.
|
||||
@@ -426,24 +421,32 @@ public class DeviceProfile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the profile so that the labels on the Workspace are hidden.
|
||||
* Checks if there is enough space for labels on the workspace.
|
||||
* If there is not, labels on the Workspace are hidden.
|
||||
* It is important to call this method after the All Apps variables have been set.
|
||||
*/
|
||||
private void adjustToHideWorkspaceLabels() {
|
||||
iconTextSizePx = 0;
|
||||
iconDrawablePaddingPx = 0;
|
||||
cellHeightPx = iconSizePx;
|
||||
autoResizeAllAppsCells();
|
||||
private void hideWorkspaceLabelsIfNotEnoughSpace() {
|
||||
float iconTextHeight = Utilities.calculateTextHeight(iconTextSizePx);
|
||||
float workspaceCellPaddingY = getCellSize().y - iconSizePx - iconDrawablePaddingPx
|
||||
- iconTextHeight;
|
||||
|
||||
// We want enough space so that the text is closer to its corresponding icon.
|
||||
if (workspaceCellPaddingY < iconTextHeight) {
|
||||
iconTextSizePx = 0;
|
||||
iconDrawablePaddingPx = 0;
|
||||
cellHeightPx = iconSizePx;
|
||||
autoResizeAllAppsCells();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-computes the all-apps cell size to be independent of workspace
|
||||
*/
|
||||
public void autoResizeAllAppsCells() {
|
||||
int topBottomPadding = allAppsIconDrawablePaddingPx * (isVerticalBarLayout() ? 2 : 1);
|
||||
int textHeight = Utilities.calculateTextHeight(allAppsIconTextSizePx);
|
||||
int topBottomPadding = textHeight;
|
||||
allAppsCellHeightPx = allAppsIconSizePx + allAppsIconDrawablePaddingPx
|
||||
+ Utilities.calculateTextHeight(allAppsIconTextSizePx)
|
||||
+ topBottomPadding * 2;
|
||||
+ textHeight + (topBottomPadding * 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -532,9 +535,7 @@ public class DeviceProfile {
|
||||
allAppsIconSizePx = pxFromDp(inv.allAppsIconSize, mInfo.metrics);
|
||||
allAppsIconTextSizePx = Utilities.pxFromSp(inv.allAppsIconTextSize, mInfo.metrics);
|
||||
allAppsIconDrawablePaddingPx = iconDrawablePaddingOriginalPx;
|
||||
// We use 4 below to ensure labels are closer to their corresponding icon.
|
||||
allAppsCellHeightPx = Math.round(allAppsIconSizePx + allAppsIconTextSizePx
|
||||
+ (4 * allAppsIconDrawablePaddingPx));
|
||||
autoResizeAllAppsCells();
|
||||
} else {
|
||||
allAppsIconSizePx = iconSizePx;
|
||||
allAppsIconTextSizePx = iconTextSizePx;
|
||||
@@ -543,9 +544,8 @@ public class DeviceProfile {
|
||||
}
|
||||
allAppsCellWidthPx = allAppsIconSizePx + allAppsIconDrawablePaddingPx;
|
||||
|
||||
if (isVerticalBarLayout()) {
|
||||
// Always hide the Workspace text with vertical bar layout.
|
||||
adjustToHideWorkspaceLabels();
|
||||
if (isVerticalLayout) {
|
||||
hideWorkspaceLabelsIfNotEnoughSpace();
|
||||
}
|
||||
|
||||
// Hotseat
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -97,7 +96,6 @@ public class Hotseat extends CellLayout implements Insettable {
|
||||
} else {
|
||||
setGridSize(idp.numHotseatIcons, 1);
|
||||
}
|
||||
showInlineQsb();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,10 +180,6 @@ public class Hotseat extends CellLayout implements Insettable {
|
||||
mOnVisibilityAggregatedCallback = callback;
|
||||
}
|
||||
|
||||
protected void showInlineQsb() {
|
||||
//Does nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
@@ -223,13 +217,6 @@ public class Hotseat extends CellLayout implements Insettable {
|
||||
mTaskbarView.layout(left, top, right, bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first View for which the given itemOperator returns true, or null.
|
||||
*/
|
||||
public View getFirstItemMatch(Workspace.ItemOperator itemOperator) {
|
||||
return mWorkspace.getFirstMatch(Arrays.asList(this), itemOperator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the alpha value of just our ShortcutAndWidgetContainer.
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,6 @@ import static com.android.launcher3.LauncherState.FLAG_NON_INTERACTIVE;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.NO_OFFSET;
|
||||
import static com.android.launcher3.LauncherState.NO_SCALE;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.LauncherState.SPRING_LOADED;
|
||||
import static com.android.launcher3.Utilities.postAsyncCallback;
|
||||
import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.getSupportedActions;
|
||||
@@ -149,7 +148,6 @@ import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.qsb.QsbContainerView;
|
||||
import com.android.launcher3.statemanager.StateManager;
|
||||
import com.android.launcher3.statemanager.StateManager.StateHandler;
|
||||
import com.android.launcher3.statemanager.StateManager.StateListener;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.states.RotationHelper;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
@@ -269,9 +267,6 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
private static final int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5;
|
||||
@Thunk @VisibleForTesting public static final int NEW_APPS_ANIMATION_DELAY = 500;
|
||||
|
||||
private static final int APPS_VIEW_ALPHA_CHANNEL_INDEX = 1;
|
||||
private static final int SCRIM_VIEW_ALPHA_CHANNEL_INDEX = 0;
|
||||
|
||||
private static final int THEME_CROSS_FADE_ANIMATION_DURATION = 375;
|
||||
|
||||
private Configuration mOldConfig;
|
||||
@@ -342,8 +337,6 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
|
||||
private RotationHelper mRotationHelper;
|
||||
|
||||
private float mCurrentAssistantVisibility = 0f;
|
||||
|
||||
protected LauncherOverlayManager mOverlayManager;
|
||||
// If true, overlay callbacks are deferred
|
||||
private boolean mDeferOverlayCallbacks;
|
||||
@@ -457,24 +450,6 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
OverlayPlugin.class, false /* allowedMultiple */);
|
||||
|
||||
mRotationHelper.initialize();
|
||||
|
||||
mStateManager.addStateListener(new StateListener<LauncherState>() {
|
||||
|
||||
@Override
|
||||
public void onStateTransitionComplete(LauncherState finalState) {
|
||||
float alpha = 1f - mCurrentAssistantVisibility;
|
||||
if (finalState == NORMAL) {
|
||||
mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
|
||||
} else if (finalState == OVERVIEW) {
|
||||
mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
|
||||
mScrimView.setAlpha(alpha);
|
||||
} else {
|
||||
mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(1f);
|
||||
mScrimView.setAlpha(1f);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
TraceHelper.INSTANCE.endSection(traceToken);
|
||||
|
||||
mUserChangedCallbackCloseable = UserCache.INSTANCE.get(this).addUserChangeListener(
|
||||
@@ -563,15 +538,7 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
}
|
||||
|
||||
public void onAssistantVisibilityChanged(float visibility) {
|
||||
mCurrentAssistantVisibility = visibility;
|
||||
float alpha = 1f - visibility;
|
||||
LauncherState state = mStateManager.getState();
|
||||
if (state == NORMAL) {
|
||||
mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
|
||||
} else if (state == OVERVIEW) {
|
||||
mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
|
||||
mScrimView.setAlpha(alpha);
|
||||
}
|
||||
mHotseat.getQsb().setAlpha(1f - visibility);
|
||||
}
|
||||
|
||||
private void initDeviceProfile(InvariantDeviceProfile idp) {
|
||||
|
||||
@@ -116,7 +116,7 @@ public class LauncherAppState {
|
||||
mNotificationSettingsChangedListener = this::onNotificationSettingsChanged;
|
||||
mSettingsCache.register(NOTIFICATION_BADGING_URI,
|
||||
mNotificationSettingsChangedListener);
|
||||
mSettingsCache.dispatchOnChange(NOTIFICATION_BADGING_URI);
|
||||
onNotificationSettingsChanged(mSettingsCache.getValue(NOTIFICATION_BADGING_URI));
|
||||
}
|
||||
|
||||
public LauncherAppState(Context context, @Nullable String iconCacheFileName) {
|
||||
|
||||
@@ -64,8 +64,6 @@ import com.android.launcher3.keyboard.FocusedItemDecorator;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.MultiValueAlpha;
|
||||
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.RecyclerViewFastScroller;
|
||||
import com.android.launcher3.views.SpringRelativeLayout;
|
||||
@@ -80,7 +78,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
private static final float FLING_VELOCITY_MULTIPLIER = 1000 * .8f;
|
||||
// Starts the springs after at least 55% of the animation has passed.
|
||||
private static final float FLING_ANIMATION_THRESHOLD = 0.55f;
|
||||
private static final int ALPHA_CHANNEL_COUNT = 2;
|
||||
|
||||
protected final BaseDraggingActivity mLauncher;
|
||||
protected final AdapterHolder[] mAH;
|
||||
@@ -107,8 +104,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
protected RecyclerViewFastScroller mTouchHandler;
|
||||
protected final Point mFastScrollerOffset = new Point();
|
||||
|
||||
private final MultiValueAlpha mMultiValueAlpha;
|
||||
|
||||
private Rect mInsets = new Rect();
|
||||
|
||||
SearchAdapterProvider mSearchAdapterProvider;
|
||||
@@ -139,8 +134,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
mNavBarScrimPaint.setColor(Themes.getAttrColor(context, R.attr.allAppsNavBarScrimColor));
|
||||
|
||||
mAllAppsStore.addUpdateListener(this::onAppsUpdated);
|
||||
|
||||
mMultiValueAlpha = new MultiValueAlpha(this, ALPHA_CHANNEL_COUNT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,10 +149,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
return mAllAppsStore;
|
||||
}
|
||||
|
||||
public AlphaProperty getAlphaProperty(int index) {
|
||||
return mMultiValueAlpha.getProperty(index);
|
||||
}
|
||||
|
||||
public WorkModeSwitch getWorkModeSwitch() {
|
||||
return mWorkModeSwitch;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,6 @@ public class AllAppsTransitionController
|
||||
setScrollRangeDelta(mScrollRangeDelta);
|
||||
|
||||
if (mIsVerticalLayout) {
|
||||
mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(1);
|
||||
mLauncher.getHotseat().setTranslationY(0);
|
||||
mLauncher.getWorkspace().getPageIndicator().setTranslationY(0);
|
||||
}
|
||||
|
||||
@@ -27,15 +27,21 @@ import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.android.launcher3.widget.LauncherAppWidgetHostView;
|
||||
|
||||
/** A drawable which renders {@link LauncherAppWidgetHostView} to a canvas. */
|
||||
/**
|
||||
* A drawable which renders {@link LauncherAppWidgetHostView} to a canvas.
|
||||
*
|
||||
* TODO(b/183609936) Stop using that class and remove it.
|
||||
*/
|
||||
public final class AppWidgetHostViewDrawable extends Drawable {
|
||||
|
||||
private final LauncherAppWidgetHostView mAppWidgetHostView;
|
||||
private Paint mPaint = new Paint();
|
||||
private final Path mClipPath;
|
||||
private final boolean mWasAttached;
|
||||
|
||||
public AppWidgetHostViewDrawable(LauncherAppWidgetHostView appWidgetHostView) {
|
||||
mAppWidgetHostView = appWidgetHostView;
|
||||
mWasAttached = appWidgetHostView.isAttachedToWindow();
|
||||
Path clipPath = null;
|
||||
if (appWidgetHostView.getClipToOutline()) {
|
||||
Outline outline = new Outline();
|
||||
@@ -56,7 +62,12 @@ public final class AppWidgetHostViewDrawable extends Drawable {
|
||||
if (mClipPath != null) {
|
||||
canvas.clipPath(mClipPath);
|
||||
}
|
||||
mAppWidgetHostView.draw(canvas);
|
||||
// If the view was never attached, or is current attached, then draw. Otherwise do not try
|
||||
// to draw, or we might trigger bugs with items that get drawn while requiring the view to
|
||||
// be attached.
|
||||
if (!mWasAttached || mAppWidgetHostView.isAttachedToWindow()) {
|
||||
mAppWidgetHostView.draw(canvas);
|
||||
}
|
||||
canvas.restoreToCount(saveCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* 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.graphics;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
|
||||
/**
|
||||
* Utility class which draws a bitmap by dissecting it into 3 segments and stretching
|
||||
* the middle segment.
|
||||
*/
|
||||
public class NinePatchDrawHelper {
|
||||
|
||||
// The extra width used for the bitmap. This portion of the bitmap is stretched to match the
|
||||
// width of the draw region. Randomly chosen, any value > 4 will be sufficient.
|
||||
public static final int EXTENSION_PX = 20;
|
||||
|
||||
private final Rect mSrc = new Rect();
|
||||
private final RectF mDst = new RectF();
|
||||
// Enable filtering to always get a nice edge. This avoids jagged line, when bitmap is
|
||||
// translated by half pixel.
|
||||
public final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
|
||||
|
||||
/**
|
||||
* Draws the bitmap split into three parts horizontally, with the middle part having width
|
||||
* as {@link #EXTENSION_PX} in the center of the bitmap.
|
||||
*/
|
||||
public void draw(Bitmap bitmap, Canvas canvas, float left, float top, float right) {
|
||||
int height = bitmap.getHeight();
|
||||
|
||||
mSrc.top = 0;
|
||||
mSrc.bottom = height;
|
||||
mDst.top = top;
|
||||
mDst.bottom = top + height;
|
||||
draw3Patch(bitmap, canvas, left, right);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws the bitmap split horizontally into 3 parts (same as {@link #draw}) and split
|
||||
* vertically into two parts, bottom part of size {@link #EXTENSION_PX} / 2 which is
|
||||
* stretched vertically.
|
||||
*/
|
||||
public void drawVerticallyStretched(Bitmap bitmap, Canvas canvas, float left, float top,
|
||||
float right, float bottom) {
|
||||
draw(bitmap, canvas, left, top, right);
|
||||
|
||||
// Draw bottom stretched region.
|
||||
int height = bitmap.getHeight();
|
||||
mSrc.top = height - EXTENSION_PX / 4;
|
||||
mSrc.bottom = height;
|
||||
mDst.top = top + height;
|
||||
mDst.bottom = bottom;
|
||||
draw3Patch(bitmap, canvas, left, right);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void draw3Patch(Bitmap bitmap, Canvas canvas, float left, float right) {
|
||||
int width = bitmap.getWidth();
|
||||
int halfWidth = width / 2;
|
||||
|
||||
// Draw left edge
|
||||
drawRegion(bitmap, canvas, 0, halfWidth, left, left + halfWidth);
|
||||
|
||||
// Draw right edge
|
||||
drawRegion(bitmap, canvas, halfWidth, width, right - halfWidth, right);
|
||||
|
||||
// Draw middle stretched region
|
||||
int halfExt = EXTENSION_PX / 4;
|
||||
drawRegion(bitmap, canvas, halfWidth - halfExt, halfWidth + halfExt,
|
||||
left + halfWidth, right - halfWidth);
|
||||
}
|
||||
|
||||
private void drawRegion(Bitmap bitmap, Canvas c,
|
||||
int srcLeft, int srcRight, float dstLeft, float dstRight) {
|
||||
mSrc.left = srcLeft;
|
||||
mSrc.right = srcRight;
|
||||
|
||||
mDst.left = dstLeft;
|
||||
mDst.right = dstRight;
|
||||
c.drawBitmap(bitmap, mSrc, mDst, paint);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import static android.app.PendingIntent.FLAG_IMMUTABLE;
|
||||
import static android.app.PendingIntent.FLAG_ONE_SHOT;
|
||||
import static android.os.Process.myUserHandle;
|
||||
|
||||
import static com.android.launcher3.pm.InstallSessionHelper.getUserHandle;
|
||||
@@ -140,7 +142,7 @@ public class FirstScreenBroadcast {
|
||||
.putStringArrayListExtra(HOTSEAT_ITEM_EXTRA, new ArrayList<>(hotseatItems))
|
||||
.putStringArrayListExtra(WIDGET_ITEM_EXTRA, new ArrayList<>(widgetItems))
|
||||
.putExtra(VERIFICATION_TOKEN_EXTRA, PendingIntent.getActivity(context, 0,
|
||||
new Intent(), PendingIntent.FLAG_ONE_SHOT)));
|
||||
new Intent(), FLAG_ONE_SHOT | FLAG_IMMUTABLE)));
|
||||
}
|
||||
|
||||
private static String getPackageName(ItemInfo info) {
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package com.android.launcher3.notification;
|
||||
|
||||
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
|
||||
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
@@ -37,8 +37,8 @@ import androidx.annotation.AnyThread;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.launcher3.util.PackageUserKey;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -213,7 +213,7 @@ public class NotificationListener extends NotificationListenerService {
|
||||
mNotificationSettingsChangedListener = this::onNotificationSettingsChanged;
|
||||
mSettingsCache.register(NOTIFICATION_BADGING_URI,
|
||||
mNotificationSettingsChangedListener);
|
||||
mSettingsCache.dispatchOnChange(NOTIFICATION_BADGING_URI);
|
||||
onNotificationSettingsChanged(mSettingsCache.getValue(NOTIFICATION_BADGING_URI));
|
||||
|
||||
onNotificationFullRefresh();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ package com.android.launcher3.settings;
|
||||
|
||||
import static com.android.launcher3.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
|
||||
import static com.android.launcher3.settings.SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGS;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
@@ -24,6 +26,7 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.database.ContentObserver;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.AttributeSet;
|
||||
@@ -49,6 +52,14 @@ public class NotificationDotsPreference extends Preference
|
||||
/** Hidden field Settings.Secure.ENABLED_NOTIFICATION_LISTENERS */
|
||||
private static final String NOTIFICATION_ENABLED_LISTENERS = "enabled_notification_listeners";
|
||||
|
||||
private final ContentObserver mListenerListObserver =
|
||||
new ContentObserver(MAIN_EXECUTOR.getHandler()) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
updateUI();
|
||||
}
|
||||
};
|
||||
|
||||
public NotificationDotsPreference(
|
||||
Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
@@ -66,6 +77,29 @@ public class NotificationDotsPreference extends Preference
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttached() {
|
||||
super.onAttached();
|
||||
SettingsCache.INSTANCE.get(getContext()).register(NOTIFICATION_BADGING_URI, this);
|
||||
getContext().getContentResolver().registerContentObserver(
|
||||
Settings.Secure.getUriFor(NOTIFICATION_ENABLED_LISTENERS),
|
||||
false, mListenerListObserver);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
onSettingsChanged(SettingsCache.INSTANCE.get(getContext())
|
||||
.getValue(NOTIFICATION_BADGING_URI));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetached() {
|
||||
super.onDetached();
|
||||
SettingsCache.INSTANCE.get(getContext()).unregister(NOTIFICATION_BADGING_URI, this);
|
||||
getContext().getContentResolver().unregisterContentObserver(mListenerListObserver);
|
||||
|
||||
}
|
||||
|
||||
private void setWidgetFrameVisible(boolean isVisible) {
|
||||
if (mWidgetFrameVisible != isVisible) {
|
||||
mWidgetFrameVisible = isVisible;
|
||||
|
||||
@@ -18,8 +18,6 @@ package com.android.launcher3.settings;
|
||||
|
||||
import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS;
|
||||
|
||||
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
|
||||
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_ENABLED_LISTENERS;
|
||||
import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY;
|
||||
import static com.android.launcher3.states.RotationHelper.getAllowRotationDefaultValue;
|
||||
|
||||
@@ -45,7 +43,6 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.WidgetsModel;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
|
||||
|
||||
/**
|
||||
@@ -124,11 +121,8 @@ public class SettingsActivity extends FragmentActivity
|
||||
*/
|
||||
public static class LauncherSettingsFragment extends PreferenceFragmentCompat {
|
||||
|
||||
private SettingsCache mSettingsCache;
|
||||
|
||||
private String mHighLightKey;
|
||||
private boolean mPreferenceHighlighted = false;
|
||||
private NotificationDotsPreference mNotificationSettingsChangedListener;
|
||||
private Preference mDeveloperOptionPref;
|
||||
|
||||
@Override
|
||||
@@ -172,22 +166,7 @@ public class SettingsActivity extends FragmentActivity
|
||||
protected boolean initPreference(Preference preference) {
|
||||
switch (preference.getKey()) {
|
||||
case NOTIFICATION_DOTS_PREFERENCE_KEY:
|
||||
if (WidgetsModel.GO_DISABLE_NOTIFICATION_DOTS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Listen to system notification dot settings while this UI is active.
|
||||
mSettingsCache = SettingsCache.INSTANCE.get(getActivity());
|
||||
mNotificationSettingsChangedListener =
|
||||
((NotificationDotsPreference) preference);
|
||||
mSettingsCache.register(NOTIFICATION_BADGING_URI,
|
||||
(NotificationDotsPreference) mNotificationSettingsChangedListener);
|
||||
// Also listen if notification permission changes
|
||||
mSettingsCache.register(NOTIFICATION_ENABLED_LISTENERS,
|
||||
mNotificationSettingsChangedListener);
|
||||
mSettingsCache.dispatchOnChange(NOTIFICATION_BADGING_URI);
|
||||
mSettingsCache.dispatchOnChange(NOTIFICATION_ENABLED_LISTENERS);
|
||||
return true;
|
||||
return !WidgetsModel.GO_DISABLE_NOTIFICATION_DOTS;
|
||||
|
||||
case ALLOW_ROTATION_PREFERENCE_KEY:
|
||||
if (getResources().getBoolean(R.bool.allow_rotation)) {
|
||||
@@ -269,16 +248,5 @@ public class SettingsActivity extends FragmentActivity
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (mSettingsCache != null) {
|
||||
mSettingsCache.unregister(NOTIFICATION_BADGING_URI,
|
||||
mNotificationSettingsChangedListener);
|
||||
mSettingsCache.unregister(NOTIFICATION_ENABLED_LISTENERS,
|
||||
mNotificationSettingsChangedListener);
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,12 +39,11 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
* {@link #unregister(Uri, OnChangeListener)} methods.
|
||||
*
|
||||
* This can be used as a normal cache without any listeners as well via the
|
||||
* {@link #getValue(Uri, int)} and {@link #dispatchOnChange(Uri)} to update (and subsequently call
|
||||
* {@link #getValue(Uri, int)} and {@link #onChange)} to update (and subsequently call
|
||||
* get)
|
||||
*
|
||||
* The cache will be invalidated/updated through the normal
|
||||
* {@link ContentObserver#onChange(boolean)} calls
|
||||
* or can be force updated by calling {@link #dispatchOnChange(Uri)}.
|
||||
*
|
||||
* Cache will also be updated if a key queried is missing (even if it has no listeners registered).
|
||||
*/
|
||||
@@ -58,9 +57,6 @@ public class SettingsCache extends ContentObserver {
|
||||
/** Hidden field Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED */
|
||||
public static final String ONE_HANDED_SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED =
|
||||
"swipe_bottom_to_notification_enabled";
|
||||
/** Hidden field Settings.Secure.ENABLED_NOTIFICATION_LISTENERS */
|
||||
public static final Uri NOTIFICATION_ENABLED_LISTENERS =
|
||||
Settings.Secure.getUriFor("enabled_notification_listeners");
|
||||
public static final Uri ROTATION_SETTING_URI =
|
||||
Settings.System.getUriFor(ACCELEROMETER_ROTATION);
|
||||
|
||||
@@ -99,6 +95,14 @@ public class SettingsCache extends ContentObserver {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value for this classes key from the cache. If not in cache, will call
|
||||
* {@link #updateValue(Uri, int)} to fetch.
|
||||
*/
|
||||
public boolean getValue(Uri keySetting) {
|
||||
return getValue(keySetting, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value for this classes key from the cache. If not in cache, will call
|
||||
* {@link #updateValue(Uri, int)} to fetch.
|
||||
@@ -139,14 +143,6 @@ public class SettingsCache extends ContentObserver {
|
||||
return newVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force update a change for a given URI and have all listeners for that URI receive callbacks
|
||||
* even if the value is unchanged.
|
||||
*/
|
||||
public void dispatchOnChange(Uri uri) {
|
||||
onChange(true, uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call to stop receiving updates on the given {@param listener}.
|
||||
* This Uri/Listener pair must correspond to the same pair called with for
|
||||
|
||||
@@ -122,7 +122,9 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
|
||||
endY = startY - swipeLength;
|
||||
} else {
|
||||
startX = getSwipeStartX();
|
||||
endX = startX - swipeLength;
|
||||
// TODO(b/184059820) make horizontal swipe use swipe width not height, for the
|
||||
// moment just double the swipe length.
|
||||
endX = startX - swipeLength * 2;
|
||||
startY = endY = mLauncher.getDevice().getDisplayHeight() / 2;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user