DO NOT MERGE - Merge pi-platform-release (PPRL.190205.001) into stage-aosp-master

Bug: 124234733
Change-Id: I2a9c871f67bdb715e266d8b4de8d225d28168414
This commit is contained in:
Xin Li
2019-02-12 09:53:42 -08:00
16 changed files with 127 additions and 21 deletions
@@ -165,6 +165,14 @@ public class UiFactory {
}
}
public static void onEnterAnimationComplete(Context context) {
// After the transition to home, enable the high-res thumbnail loader if it wasn't enabled
// as a part of quickstep/scrub, so that high-res thumbnails can load the next time we
// enter overview
RecentsModel.getInstance(context).getRecentsTaskLoader()
.getHighResThumbnailLoader().setVisible(true);
}
public static void onLauncherStateOrResumeChanged(Launcher launcher) {
LauncherState state = launcher.getStateManager().getState();
DeviceProfile profile = launcher.getDeviceProfile();
@@ -294,6 +294,9 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
private void playScaleDownAnim(AnimatorSet anim, Launcher launcher) {
RecentsView recentsView = launcher.getOverviewPanel();
TaskView v = recentsView.getTaskViewAt(recentsView.getCurrentPage());
if (v == null) {
return;
}
ClipAnimationHelper clipHelper = new ClipAnimationHelper();
clipHelper.fromTaskThumbnailView(v.getThumbnail(), (RecentsView) v.getParent(), null);
if (!clipHelper.getSourceRect().isEmpty() && !clipHelper.getTargetRect().isEmpty()) {
@@ -240,6 +240,12 @@ public class RecentsActivity extends BaseDraggingActivity {
onTrimMemory(TRIM_MEMORY_UI_HIDDEN);
}
@Override
public void onEnterAnimationComplete() {
super.onEnterAnimationComplete();
UiFactory.onEnterAnimationComplete(this);
}
@Override
public void onTrimMemory(int level) {
super.onTrimMemory(level);
@@ -232,7 +232,6 @@ public class RecentsModel extends TaskStackChangeListener {
public void onStart() {
mRecentsTaskLoader.startLoader(mContext);
mRecentsTaskLoader.getHighResThumbnailLoader().setVisible(true);
}
public void onTrimMemory(int level) {
@@ -30,7 +30,6 @@ import android.os.UserHandle;
import android.util.Log;
import android.view.View;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.ItemInfo;
@@ -270,9 +269,4 @@ public class TaskSystemShortcut<T extends SystemShortcut> extends SystemShortcut
return null;
}
}
private static void dismissTaskMenuView(BaseDraggingActivity activity) {
AbstractFloatingView.closeOpenViews(activity, true,
AbstractFloatingView.TYPE_ALL & ~AbstractFloatingView.TYPE_REBIND_SAFE);
}
}
@@ -483,6 +483,12 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
if (LatencyTrackerCompat.isEnabled(mContext)) {
LatencyTrackerCompat.logToggleRecents((int) (mLauncherFrameDrawnTime - mTouchTimeMs));
}
// This method is only called when STATE_GESTURE_STARTED_QUICKSTEP/
// STATE_GESTURE_STARTED_QUICKSCRUB is set, so we can enable the high-res thumbnail loader
// here once we are sure that we will end up in an overview state
RecentsModel.getInstance(mContext).getRecentsTaskLoader()
.getHighResThumbnailLoader().setVisible(true);
}
public void updateInteractionType(@InteractionType int interactionType) {
+4 -4
View File
@@ -133,13 +133,13 @@
launcher:name="Nexus 7"
launcher:minWidthDps="575"
launcher:minHeightDps="904"
launcher:numRows="5"
launcher:numRows="6"
launcher:numColumns="6"
launcher:numFolderRows="4"
launcher:numFolderColumns="5"
launcher:iconSize="64"
launcher:iconTextSize="14.4"
launcher:numHotseatIcons="7"
launcher:numHotseatIcons="6"
launcher:defaultLayoutId="@xml/default_workspace_5x6"
/>
@@ -147,8 +147,8 @@
launcher:name="Nexus 10"
launcher:minWidthDps="727"
launcher:minHeightDps="1207"
launcher:numRows="5"
launcher:numColumns="6"
launcher:numRows="6"
launcher:numColumns="7"
launcher:numFolderRows="4"
launcher:numFolderColumns="5"
launcher:iconSize="76"
+6 -1
View File
@@ -59,6 +59,9 @@ public class DeviceProfile {
private static final float TALL_DEVICE_ASPECT_RATIO_THRESHOLD = 2.0f;
// To evenly space the icons, increase the left/right margins for tablets in portrait mode.
private static final int PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER = 4;
// Workspace
public final int desiredWorkspaceLeftRightMarginPx;
public final int cellLayoutPaddingLeftRightPx;
@@ -172,7 +175,9 @@ public class DeviceProfile {
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
desiredWorkspaceLeftRightMarginPx = isVerticalBarLayout() ? 0 : edgeMarginPx;
cellLayoutPaddingLeftRightPx =
int cellLayoutPaddingLeftRightMultiplier = !isVerticalBarLayout() && isTablet
? PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER : 1;
cellLayoutPaddingLeftRightPx = cellLayoutPaddingLeftRightMultiplier *
res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_layout_padding);
cellLayoutBottomPaddingPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_layout_bottom_padding);
+6
View File
@@ -347,6 +347,12 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
TraceHelper.endSection("Launcher-onCreate");
}
@Override
public void onEnterAnimationComplete() {
super.onEnterAnimationComplete();
UiFactory.onEnterAnimationComplete(this);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
int diff = newConfig.diff(mOldConfig);
+3 -1
View File
@@ -286,7 +286,9 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mInsets.set(insets);
DeviceProfile grid = mLauncher.getDeviceProfile();
mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx);
mMaxDistanceForFolderCreation = grid.isTablet
? 0.75f * grid.iconSizePx
: 0.55f * grid.iconSizePx;
mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
Rect padding = grid.workspacePadding;
@@ -126,13 +126,13 @@ public class ShadowGenerator {
}
public Bitmap createPill(int width, int height) {
radius = height / 2;
radius = height / 2f;
int centerX = Math.round(width / 2 + shadowBlur);
int centerX = Math.round(width / 2f + shadowBlur);
int centerY = Math.round(radius + shadowBlur + keyShadowDistance);
int center = Math.max(centerX, centerY);
bounds.set(0, 0, width, height);
bounds.offsetTo(center - width / 2, center - height / 2);
bounds.offsetTo(center - width / 2f, center - height / 2f);
int size = center * 2;
Bitmap result = Bitmap.createBitmap(size, size, Config.ARGB_8888);
@@ -75,6 +75,7 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite
public View.OnClickListener getOnClickListener(
BaseDraggingActivity activity, ItemInfo itemInfo) {
return (view) -> {
dismissTaskMenuView(activity);
Rect sourceBounds = activity.getViewBounds(view);
Bundle opts = activity.getActivityLaunchOptionsAsBundle(view);
new PackageManagerHelper(activity).startDetailsActivityForInfo(
@@ -117,4 +118,9 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite
};
}
}
protected static void dismissTaskMenuView(BaseDraggingActivity activity) {
AbstractFloatingView.closeOpenViews(activity, true,
AbstractFloatingView.TYPE_ALL & ~AbstractFloatingView.TYPE_REBIND_SAFE);
}
}
@@ -162,7 +162,6 @@ public class QsbContainerView extends FrameLayout {
.getAppWidgetOptions(widgetId), opts)) {
mQsb.updateAppWidgetOptions(opts);
}
mQsb.setPadding(0, 0, 0, 0);
mQsbWidgetHost.startListening();
return mQsb;
}
@@ -52,6 +52,11 @@ public class QsbWidgetHostView extends AppWidgetHostView {
return mPreviousOrientation != orientation;
}
@Override
public void setPadding(int left, int top, int right, int bottom) {
// Prevent the base class from applying the default widget padding.
super.setPadding(0, 0, 0, 0);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
@@ -21,37 +21,102 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.Point;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.os.Handler;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
/**
* {@link BroadcastReceiver} which watches configuration changes and
* restarts the process in case changes which affect the device profile occur.
*/
public class ConfigMonitor extends BroadcastReceiver {
public class ConfigMonitor extends BroadcastReceiver implements DisplayListener {
private static final String TAG = "ConfigMonitor";
private final Point mTmpPoint1 = new Point();
private final Point mTmpPoint2 = new Point();
private final Context mContext;
private final float mFontScale;
private final int mDensity;
private final int mDisplayId;
private final Point mRealSize;
private final Point mSmallestSize, mLargestSize;
public ConfigMonitor(Context context) {
mContext = context;
Configuration config = context.getResources().getConfiguration();
mFontScale = config.fontScale;
mDensity = config.densityDpi;
Display display = getDefaultDisplay(context);
mDisplayId = display.getDisplayId();
mRealSize = new Point();
display.getRealSize(mRealSize);
mSmallestSize = new Point();
mLargestSize = new Point();
display.getCurrentSizeRange(mSmallestSize, mLargestSize);
}
@Override
public void onReceive(Context context, Intent intent) {
Configuration config = context.getResources().getConfiguration();
if (mFontScale != config.fontScale || mDensity != config.densityDpi) {
Log.d("ConfigMonitor", "Configuration changed, restarting launcher");
mContext.unregisterReceiver(this);
android.os.Process.killProcess(android.os.Process.myPid());
Log.d(TAG, "Configuration changed");
killProcess();
}
}
public void register() {
mContext.registerReceiver(this, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
mContext.getSystemService(DisplayManager.class)
.registerDisplayListener(this, new Handler(UiThreadHelper.getBackgroundLooper()));
}
@Override
public void onDisplayAdded(int displayId) { }
@Override
public void onDisplayRemoved(int displayId) { }
@Override
public void onDisplayChanged(int displayId) {
if (displayId != mDisplayId) {
return;
}
Display display = getDefaultDisplay(mContext);
display.getRealSize(mTmpPoint1);
if (!mRealSize.equals(mTmpPoint1) && !mRealSize.equals(mTmpPoint1.y, mTmpPoint1.x)) {
Log.d(TAG, String.format("Display size changed from %s to %s", mRealSize, mTmpPoint1));
killProcess();
return;
}
display.getCurrentSizeRange(mTmpPoint1, mTmpPoint2);
if (!mSmallestSize.equals(mTmpPoint1) || !mLargestSize.equals(mTmpPoint2)) {
Log.d(TAG, String.format("Available size changed from [%s, %s] to [%s, %s]",
mSmallestSize, mLargestSize, mTmpPoint1, mTmpPoint2));
killProcess();
}
}
private void killProcess() {
Log.d(TAG, "restarting launcher");
mContext.unregisterReceiver(this);
mContext.getSystemService(DisplayManager.class).unregisterDisplayListener(this);
android.os.Process.killProcess(android.os.Process.myPid());
}
private Display getDefaultDisplay(Context context) {
return context.getSystemService(WindowManager.class).getDefaultDisplay();
}
}
@@ -48,6 +48,8 @@ public class UiFactory {
public static void onStart(Launcher launcher) { }
public static void onEnterAnimationComplete(Context context) {}
public static void onLauncherStateOrResumeChanged(Launcher launcher) { }
public static void onTrimMemory(Launcher launcher, int level) { }