summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherRootView.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-11-23 11:47:50 -0800
committerSunny Goyal <sunnygoyal@google.com>2015-12-01 14:43:32 -0800
commit9326461652c36c2ddd888d1452cf7f075a391868 (patch)
tree1ad864d2009abbed3c2749232352008f8cdf0e24 /src/com/android/launcher3/LauncherRootView.java
parent0c2f0700a55080318a4c21457408abb8af26740d (diff)
downloadandroid_packages_apps_Trebuchet-9326461652c36c2ddd888d1452cf7f075a391868.tar.gz
android_packages_apps_Trebuchet-9326461652c36c2ddd888d1452cf7f075a391868.tar.bz2
android_packages_apps_Trebuchet-9326461652c36c2ddd888d1452cf7f075a391868.zip
Adding margin to Drag layer instead of checking for right insets at every place
Bug: 25692432 Change-Id: I853f41a17c54b30b7772b9fd8556d9465de84752
Diffstat (limited to 'src/com/android/launcher3/LauncherRootView.java')
-rw-r--r--src/com/android/launcher3/LauncherRootView.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java
index 1c6ca8713..71ccd85fc 100644
--- a/src/com/android/launcher3/LauncherRootView.java
+++ b/src/com/android/launcher3/LauncherRootView.java
@@ -1,17 +1,22 @@
package com.android.launcher3;
+import android.annotation.TargetApi;
+import android.app.ActivityManager;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
+import android.view.View;
public class LauncherRootView extends InsettableFrameLayout {
private final Paint mOpaquePaint;
private boolean mDrawRightInsetBar;
+ private View mAlignedView;
+
public LauncherRootView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -21,10 +26,32 @@ public class LauncherRootView extends InsettableFrameLayout {
}
@Override
+ protected void onFinishInflate() {
+ if (getChildCount() > 0) {
+ // LauncherRootView contains only one child, which should be aligned
+ // based on the horizontal insets.
+ mAlignedView = getChildAt(0);
+ }
+ super.onFinishInflate();
+ }
+
+ @TargetApi(23)
+ @Override
protected boolean fitSystemWindows(Rect insets) {
- setInsets(insets);
- mDrawRightInsetBar = mInsets.right > 0 && LauncherAppState
- .getInstance().getInvariantDeviceProfile().isRightInsetOpaque;
+ mDrawRightInsetBar = insets.right > 0 &&
+ (!Utilities.ATLEAST_MARSHMALLOW ||
+ getContext().getSystemService(ActivityManager.class).isLowRamDevice());
+ setInsets(mDrawRightInsetBar ? new Rect(0, insets.top, 0, insets.bottom) : insets);
+
+ if (mAlignedView != null) {
+ // Apply margins on aligned view to handle left/right insets.
+ MarginLayoutParams lp = (MarginLayoutParams) mAlignedView.getLayoutParams();
+ if (lp.leftMargin != insets.left || lp.rightMargin != insets.right) {
+ lp.leftMargin = insets.left;
+ lp.rightMargin = insets.right;
+ mAlignedView.setLayoutParams(lp);
+ }
+ }
return true; // I'll take it from here
}