Merge "Encoding the locale list in systemState so that icons and labels are updated properly" into ub-launcher3-master
diff --git a/quickstep/res/values/config.xml b/quickstep/res/values/config.xml
new file mode 100644
index 0000000..94211c6
--- /dev/null
+++ b/quickstep/res/values/config.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <string name="task_overlay_factory_class" translatable="false"></string>
+
+</resources>
diff --git a/quickstep/src/com/android/launcher3/uioverrides/IgnoreTouchesInQuickScrub.java b/quickstep/src/com/android/launcher3/uioverrides/IgnoreTouchesInQuickScrub.java
index 92aa1fd..2d5eb5a 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/IgnoreTouchesInQuickScrub.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/IgnoreTouchesInQuickScrub.java
@@ -18,20 +18,15 @@
import android.view.MotionEvent;
-import com.android.launcher3.Launcher;
import com.android.launcher3.util.TouchController;
-import com.android.quickstep.QuickScrubController;
-import com.android.quickstep.RecentsView;
+import com.android.quickstep.TouchInteractionService;
/**
* Consumes touches when quick scrub is enabled.
*/
public class IgnoreTouchesInQuickScrub implements TouchController {
- private QuickScrubController mQuickScrubController;
-
- public IgnoreTouchesInQuickScrub(Launcher l) {
- mQuickScrubController = ((RecentsView) l.getOverviewPanel()).getQuickScrubController();
+ public IgnoreTouchesInQuickScrub() {
}
@Override
@@ -41,6 +36,6 @@
@Override
public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
- return mQuickScrubController.isQuickScrubEnabled();
+ return TouchInteractionService.isQuickScrubEnabled();
}
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index 1c92f2c..a004dac 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -43,13 +43,13 @@
public static TouchController[] createTouchControllers(Launcher launcher) {
if (FeatureFlags.ENABLE_TWO_SWIPE_TARGETS) {
return new TouchController[] {
- new IgnoreTouchesInQuickScrub(launcher),
+ new IgnoreTouchesInQuickScrub(),
new EdgeSwipeController(launcher),
new TwoStepSwipeController(launcher),
new OverviewSwipeController(launcher)};
} else {
return new TouchController[] {
- new IgnoreTouchesInQuickScrub(launcher),
+ new IgnoreTouchesInQuickScrub(),
new TwoStepSwipeController(launcher),
new OverviewSwipeController(launcher)};
}
diff --git a/quickstep/src/com/android/quickstep/QuickScrubController.java b/quickstep/src/com/android/quickstep/QuickScrubController.java
index d656f8a..3e65ffe 100644
--- a/quickstep/src/com/android/quickstep/QuickScrubController.java
+++ b/quickstep/src/com/android/quickstep/QuickScrubController.java
@@ -40,7 +40,6 @@
private int mQuickScrubSection;
private int mStartPage;
- private boolean mQuickScrubEnabled;
public QuickScrubController(Launcher launcher) {
mLauncher = launcher;
@@ -52,13 +51,11 @@
mRecentsView = mLauncher.getOverviewPanel();
mStartPage = startingFromHome ? 0 : mRecentsView.getFirstTaskIndex();
mQuickScrubSection = 0;
- mQuickScrubEnabled = true;
}
public void onQuickScrubEnd() {
mAutoAdvanceAlarm.cancelAlarm();
if (mRecentsView == null) {
- mQuickScrubEnabled = false;
} else {
int page = mRecentsView.getNextPage();
// Settle on the page then launch it.
@@ -71,15 +68,10 @@
} else {
((TaskView) mRecentsView.getPageAt(page)).launchTask(true);
}
- mQuickScrubEnabled = false;
}, snapDuration);
}
}
- public boolean isQuickScrubEnabled() {
- return mQuickScrubEnabled;
- }
-
public void onQuickScrubProgress(float progress) {
int quickScrubSection = Math.round(progress * NUM_QUICK_SCRUB_SECTIONS);
if (quickScrubSection != mQuickScrubSection) {
diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
new file mode 100644
index 0000000..c2fb7be
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2018 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.quickstep;
+
+import android.content.Context;
+import android.graphics.Matrix;
+import android.view.View;
+
+import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
+import com.android.launcher3.util.Preconditions;
+import com.android.systemui.shared.recents.model.ThumbnailData;
+
+/**
+ * Factory class to create and add an overlays on the TaskView
+ */
+public class TaskOverlayFactory {
+
+ private static TaskOverlayFactory sInstance;
+
+ public static TaskOverlayFactory get(Context context) {
+ Preconditions.assertUIThread();
+ if (sInstance == null) {
+ sInstance = Utilities.getOverrideObject(TaskOverlayFactory.class,
+ context.getApplicationContext(), R.string.task_overlay_factory_class);
+ }
+ return sInstance;
+ }
+
+ public TaskOverlay createOverlay(View thumbnailView) {
+ return new TaskOverlay();
+ }
+
+ public static class TaskOverlay {
+
+ public void setTaskInfo(ThumbnailData thumbnail, Matrix matrix) { }
+
+ public void reset() { }
+
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/TaskThumbnailView.java
index 87dec67..36a0601 100644
--- a/quickstep/src/com/android/quickstep/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/TaskThumbnailView.java
@@ -28,7 +28,6 @@
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
-import android.graphics.Rect;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;
@@ -36,6 +35,7 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
+import com.android.quickstep.TaskOverlayFactory.TaskOverlay;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -49,15 +49,14 @@
private final float mCornerRadius;
private final float mFadeLength;
+ private final TaskOverlay mOverlay;
private final Paint mPaint = new Paint();
private final Matrix mMatrix = new Matrix();
- private final Rect mThumbnailRect = new Rect();
private ThumbnailData mThumbnailData;
protected BitmapShader mBitmapShader;
- private float mThumbnailScale;
private float mDimAlpha = 1f;
public TaskThumbnailView(Context context) {
@@ -72,6 +71,11 @@
super(context, attrs, defStyleAttr);
mCornerRadius = getResources().getDimension(R.dimen.task_corner_radius);
mFadeLength = getResources().getDimension(R.dimen.task_fade_length);
+ mOverlay = TaskOverlayFactory.get(context).createOverlay(this);
+ }
+
+ public void bind() {
+ mOverlay.reset();
}
/**
@@ -83,19 +87,15 @@
if (thumbnailData != null && thumbnailData.thumbnail != null) {
Bitmap bm = thumbnailData.thumbnail;
bm.prepareToDraw();
- mThumbnailScale = thumbnailData.scale;
mBitmapShader = new BitmapShader(bm, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mPaint.setShader(mBitmapShader);
- mThumbnailRect.set(0, 0,
- bm.getWidth() - thumbnailData.insets.left - thumbnailData.insets.right,
- bm.getHeight() - thumbnailData.insets.top - thumbnailData.insets.bottom);
mThumbnailData = thumbnailData;
updateThumbnailMatrix();
} else {
mBitmapShader = null;
mThumbnailData = null;
mPaint.setShader(null);
- mThumbnailRect.setEmpty();
+ mOverlay.reset();
}
updateThumbnailPaintFilter();
}
@@ -126,36 +126,41 @@
}
private void updateThumbnailMatrix() {
- mThumbnailScale = 1f;
if (mBitmapShader != null && mThumbnailData != null) {
+ float scale = mThumbnailData.scale;
+ float thumbnailWidth = mThumbnailData.thumbnail.getWidth() -
+ (mThumbnailData.insets.left + mThumbnailData.insets.right) * scale;
+ float thumbnailHeight = mThumbnailData.thumbnail.getHeight() -
+ (mThumbnailData.insets.top + mThumbnailData.insets.bottom) * scale;
+ final float thumbnailScale;
+
if (getMeasuredWidth() == 0) {
// If we haven't measured , skip the thumbnail drawing and only draw the background
// color
- mThumbnailScale = 0f;
+ thumbnailScale = 0f;
} else {
- float invThumbnailScale = 1f / mThumbnailScale;
final Configuration configuration =
getContext().getApplicationContext().getResources().getConfiguration();
final DeviceProfile profile = Launcher.getLauncher(getContext()).getDeviceProfile();
if (configuration.orientation == mThumbnailData.orientation) {
// If we are in the same orientation as the screenshot, just scale it to the
// width of the task view
- mThumbnailScale = (float) getMeasuredWidth() / mThumbnailRect.width();
+ thumbnailScale = getMeasuredWidth() / thumbnailWidth;
} else if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
// Scale the landscape thumbnail up to app size, then scale that to the task
// view size to match other portrait screenshots
- mThumbnailScale = invThumbnailScale *
- ((float) getMeasuredWidth() / profile.widthPx);
+ thumbnailScale = ((float) getMeasuredWidth() / profile.widthPx);
} else {
// Otherwise, scale the screenshot to fit 1:1 in the current orientation
- mThumbnailScale = invThumbnailScale;
+ thumbnailScale = 1;
}
}
- mMatrix.setTranslate(-mThumbnailData.insets.left, -mThumbnailData.insets.top);
- mMatrix.postScale(mThumbnailScale, mThumbnailScale);
+ mMatrix.setTranslate(-mThumbnailData.insets.left * scale,
+ -mThumbnailData.insets.top * scale);
+ mMatrix.postScale(thumbnailScale, thumbnailScale);
mBitmapShader.setLocalMatrix(mMatrix);
- float bitmapHeight = Math.max(mThumbnailRect.height() * mThumbnailScale, 0);
+ float bitmapHeight = Math.max(thumbnailHeight * thumbnailScale, 0);
Shader shader = mBitmapShader;
if (bitmapHeight < getMeasuredHeight()) {
int color = mPaint.getColor();
@@ -165,7 +170,7 @@
shader = new ComposeShader(fade, shader, Mode.DST_OVER);
}
- float bitmapWidth = Math.max(mThumbnailRect.width() * mThumbnailScale, 0);
+ float bitmapWidth = Math.max(thumbnailWidth * thumbnailScale, 0);
if (bitmapWidth < getMeasuredWidth()) {
int color = mPaint.getColor();
LinearGradient fade = new LinearGradient(
@@ -175,6 +180,8 @@
}
mPaint.setShader(shader);
}
+
+ mOverlay.setTaskInfo(mThumbnailData, mMatrix);
invalidate();
}
diff --git a/quickstep/src/com/android/quickstep/TaskView.java b/quickstep/src/com/android/quickstep/TaskView.java
index 0e999f8..46fcc72 100644
--- a/quickstep/src/com/android/quickstep/TaskView.java
+++ b/quickstep/src/com/android/quickstep/TaskView.java
@@ -36,6 +36,7 @@
import com.android.launcher3.R;
import com.android.quickstep.RecentsView.PageCallbacks;
import com.android.quickstep.RecentsView.ScrollState;
+import com.android.quickstep.TaskOverlayFactory.TaskOverlay;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.Task.TaskCallbacks;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -113,6 +114,7 @@
mTask.removeCallback(this);
}
mTask = task;
+ mSnapshotView.bind();
task.addCallback(this);
}
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 9b31c14..509ffa9 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -106,6 +106,7 @@
@Override
public void onQuickScrubStart() {
startTouchTracking(INTERACTION_QUICK_SCRUB);
+ sQuickScrubEnabled = true;
}
@Override
@@ -114,6 +115,7 @@
mInteractionHandler.onQuickScrubEnd();
mInteractionHandler = null;
}
+ sQuickScrubEnabled = false;
}
@Override
@@ -129,11 +131,16 @@
private final Consumer<MotionEvent> mNoOpTouchConsumer = (ev) -> {};
private static boolean sConnected = false;
+ private static boolean sQuickScrubEnabled = false;
public static boolean isConnected() {
return sConnected;
}
+ public static boolean isQuickScrubEnabled() {
+ return sQuickScrubEnabled;
+ }
+
private ActivityManagerWrapper mAM;
private RunningTaskInfo mRunningTask;
private RecentsModel mRecentsModel;
@@ -178,6 +185,7 @@
@Override
public void onDestroy() {
sConnected = false;
+ sQuickScrubEnabled = false;
super.onDestroy();
}