Flip recents if setting is true

Bug: 72860694
Change-Id: I5cb71f553b2833a18a1b419b3744175bff963da8
This commit is contained in:
Tony Wickham
2018-02-26 16:41:57 -08:00
parent 7eadfc4f15
commit dfb5cc9a09
4 changed files with 32 additions and 10 deletions
@@ -259,6 +259,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
int launchedTaskIndex = recentsView.indexOfChild(v);
int centerTaskIndex = recentsView.getCurrentPage();
boolean launchingCenterTask = launchedTaskIndex == centerTaskIndex;
boolean isRtl = recentsView.isRtl();
if (launchingCenterTask) {
if (launchedTaskIndex - 1 >= recentsView.getFirstTaskIndex()) {
TaskView adjacentPage1 = (TaskView) recentsView.getPageAt(launchedTaskIndex - 1);
@@ -267,7 +268,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
new PropertyListBuilder()
.scale(adjacentPage1.getScaleX() * mRecentsScale)
.translationY(mRecentsTransY)
.translationX(mIsRtl ? mRecentsTransX : -mRecentsTransX)
.translationX(isRtl ? mRecentsTransX : -mRecentsTransX)
.build());
launcherAnimator.play(adjacentTask1ScaleAndTranslate);
}
@@ -278,7 +279,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
new PropertyListBuilder()
.scale(adjacentTask2.getScaleX() * mRecentsScale)
.translationY(mRecentsTransY)
.translationX(mIsRtl ? -mRecentsTransX : mRecentsTransX)
.translationX(isRtl ? -mRecentsTransX : mRecentsTransX)
.build());
launcherAnimator.play(adjacentTask2ScaleAndTranslate);
}
@@ -290,7 +291,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
LauncherAnimUtils.ofPropertyValuesHolder(centerTask,
new PropertyListBuilder()
.scale(v.getScaleX())
.translationX(mIsRtl ? -translationX : translationX)
.translationX(isRtl ? -translationX : translationX)
.build());
launcherAnimator.play(centerTaskParallaxToRight);
int otherAdjacentTaskIndex = centerTaskIndex + (centerTaskIndex - launchedTaskIndex);
@@ -302,7 +303,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
LauncherAnimUtils.ofPropertyValuesHolder(otherAdjacentTask,
new PropertyListBuilder()
.translationX(otherAdjacentTask.getTranslationX()
+ (mIsRtl ? -translationX : translationX))
+ (isRtl ? -translationX : translationX))
.build());
launcherAnimator.play(otherAdjacentTaskParallaxToRight);
}
@@ -745,7 +746,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
Matrix matrix = new Matrix();
float height = mLauncher.getDeviceProfile().heightPx;
float width = mLauncher.getDeviceProfile().widthPx;
float endX = (Utilities.isRtl(mLauncher.getResources()) ? -width : width) * 1.16f;
float endX = (mLauncher.<RecentsView>getOverviewPanel().isRtl() ? -width : width) * 1.16f;
ValueAnimator closingAnimator = ValueAnimator.ofFloat(0, 1);
closingAnimator.setDuration(CLOSING_TRANSITION_DURATION_MS);
@@ -26,7 +26,6 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.quickstep.RecentsView;
@@ -111,7 +110,7 @@ public class OverviewState extends LauncherState {
scale * (halfWidth - ws.getPaddingLeft() - insets.left - childWidth / 2);
float translationX = pageRect.centerX() - childCenter;
if (Utilities.isRtl(launcher.getResources())) {
if (launcher.<RecentsView>getOverviewPanel().isRtl()) {
translationX -= offsetX / scale;
} else {
translationX += offsetX / scale;
@@ -23,6 +23,8 @@ import static com.android.quickstep.TaskView.CURVE_INTERPOLATOR;
import android.animation.LayoutTransition;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
@@ -62,7 +64,7 @@ import java.util.ArrayList;
/**
* A list of recent tasks.
*/
public class RecentsView extends PagedView implements Insettable {
public class RecentsView extends PagedView implements Insettable, OnSharedPreferenceChangeListener {
private static final Rect sTempStableInsets = new Rect();
@@ -70,6 +72,8 @@ public class RecentsView extends PagedView implements Insettable {
public static final int SCROLL_TYPE_TASK = 1;
public static final int SCROLL_TYPE_WORKSPACE = 2;
private static final String PREF_FLIP_RECENTS = "pref_flip_recents";
private final Launcher mLauncher;
private QuickScrubController mQuickScrubController;
private final ScrollState mScrollState = new ScrollState();
@@ -130,7 +134,23 @@ public class RecentsView extends PagedView implements Insettable {
mQuickScrubController = new QuickScrubController(mLauncher, this);
mModel = RecentsModel.getInstance(context);
mScrollState.isRtl = mIsRtl;
onSharedPreferenceChanged(Utilities.getPrefs(context), PREF_FLIP_RECENTS);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
if (s.equals(PREF_FLIP_RECENTS)) {
mIsRtl = Utilities.isRtl(getResources());
if (sharedPreferences.getBoolean(PREF_FLIP_RECENTS, false)) {
mIsRtl = !mIsRtl;
}
setLayoutDirection(mIsRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
mScrollState.isRtl = mIsRtl;
}
}
public boolean isRtl() {
return mIsRtl;
}
public TaskView updateThumbnail(int taskId, ThumbnailData thumbnailData) {
@@ -172,12 +192,14 @@ public class RecentsView extends PagedView implements Insettable {
protected void onAttachedToWindow() {
super.onAttachedToWindow();
updateTaskStackListenerState();
Utilities.getPrefs(getContext()).registerOnSharedPreferenceChangeListener(this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
updateTaskStackListenerState();
Utilities.getPrefs(getContext()).unregisterOnSharedPreferenceChangeListener(this);
}
@Override
+1 -1
View File
@@ -182,7 +182,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
private static final Rect sTmpRect = new Rect();
protected final Rect mInsets = new Rect();
protected final boolean mIsRtl;
protected boolean mIsRtl;
// Similar to the platform implementation of isLayoutValid();
protected boolean mIsLayoutValid;