summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2015-09-28 23:27:25 (GMT)
committerDanesh M <daneshm90@gmail.com>2015-09-28 23:53:49 (GMT)
commite4a62ee23304930700f6935904295350d0883016 (patch)
tree58d6ab0807918f1a7462e779baee31063bbf3c11
parent76a7d9c0c0105462415235dc5dab917da9f12b6e (diff)
downloadandroid_packages_apps_Trebuchet-staging/catchup.zip
android_packages_apps_Trebuchet-staging/catchup.tar.gz
android_packages_apps_Trebuchet-staging/catchup.tar.bz2
Trebuchet : Fix insets for panelsstaging/catchup
Change-Id: I001a3c87ef2226f6a241b9538c0157b310961978
-rw-r--r--res/layout-land/launcher.xml2
-rw-r--r--res/layout-port/launcher.xml2
-rw-r--r--res/layout-sw720dp/launcher.xml2
-rw-r--r--res/layout/dynamic_grid_size_screen.xml11
-rw-r--r--res/layout/hidden_folder.xml2
-rw-r--r--res/layout/settings_transitions_screen.xml10
-rw-r--r--res/values/attrs.xml14
-rw-r--r--src/com/android/launcher3/InsettableFrameLayout.java14
-rw-r--r--src/com/android/launcher3/InsettableLinearLayout.java106
-rw-r--r--src/com/android/launcher3/OverviewPanel.java2
-rw-r--r--src/com/android/launcher3/TransitionEffectsFragment.java5
11 files changed, 152 insertions, 18 deletions
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 0d6bd50..877725f 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -18,6 +18,7 @@
<com.android.launcher3.LauncherRootView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
+ xmlns:insettable="http://schemas.android.com/apk/res-auto"
android:id="@+id/launcher"
android:layout_width="match_parent"
@@ -31,6 +32,7 @@
android:layout_height="match_parent"
android:visibility="invisible"
android:alpha="1.0"
+ insettable:layout_ignoreInsets="true"
android:clipToPadding="false">
<ImageView
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index e8bac4b..83c6860 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -18,6 +18,7 @@
<com.android.launcher3.LauncherRootView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
+ xmlns:insettable="http://schemas.android.com/apk/res-auto"
android:id="@+id/launcher"
android:layout_width="match_parent"
@@ -31,6 +32,7 @@
android:layout_height="match_parent"
android:visibility="invisible"
android:alpha="1.0"
+ insettable:layout_ignoreInsets="true"
android:clipToPadding="false">
<ImageView
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index 6364f09..874b504 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -18,6 +18,7 @@
<com.android.launcher3.LauncherRootView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
+ xmlns:insettable="http://schemas.android.com/apk/res-auto"
android:id="@+id/launcher"
android:layout_width="match_parent"
@@ -31,6 +32,7 @@
android:layout_height="match_parent"
android:visibility="invisible"
android:alpha="1.0"
+ insettable:layout_ignoreInsets="true"
android:clipToPadding="false">
<ImageView
diff --git a/res/layout/dynamic_grid_size_screen.xml b/res/layout/dynamic_grid_size_screen.xml
index 8b6ed95..aa2b209 100644
--- a/res/layout/dynamic_grid_size_screen.xml
+++ b/res/layout/dynamic_grid_size_screen.xml
@@ -1,15 +1,15 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.launcher3.InsettableLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:insettable="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|bottom"
android:background="@color/settings_bg_color"
android:orientation="vertical"
- android:paddingBottom="@dimen/overview_panel_bottom_padding"
- android:paddingTop="@dimen/overview_panel_bottom_padding"
android:clickable="true" >
<LinearLayout
android:id="@+id/dynamic_grid_title"
+ insettable:layout_ignoreBottomInsets="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
@@ -36,6 +36,7 @@
</LinearLayout>
<view
+ insettable:layout_ignoreInsets="true"
class="com.android.launcher3.DynamicGridSizeFragment$GridSizeView"
android:id="@+id/dynamic_grid_size_image"
android:layout_width="150dp"
@@ -44,10 +45,10 @@
android:layout_marginBottom="@dimen/grid_padding"/>
<ListView
- xmlns:android="http://schemas.android.com/apk/res/android"
+ insettable:layout_ignoreTopInsets="true"
android:id="@+id/dynamic_grid_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:listSelector="@android:color/transparent"
android:splitMotionEvents="false"/>
-</LinearLayout>
+</com.android.launcher3.InsettableLinearLayout>
diff --git a/res/layout/hidden_folder.xml b/res/layout/hidden_folder.xml
index f4e7852..48e6c43 100644
--- a/res/layout/hidden_folder.xml
+++ b/res/layout/hidden_folder.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:insettable="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/settings_bg_color"
@@ -9,6 +10,7 @@
android:paddingTop="@dimen/overview_panel_bottom_padding"
android:focusable="true"
android:focusableInTouchMode="true"
+ insettable:layout_ignoreInsets="true"
android:clickable="true" >
<RelativeLayout
diff --git a/res/layout/settings_transitions_screen.xml b/res/layout/settings_transitions_screen.xml
index fca36a8..4ec8ebc 100644
--- a/res/layout/settings_transitions_screen.xml
+++ b/res/layout/settings_transitions_screen.xml
@@ -1,13 +1,14 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.launcher3.InsettableLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:insettable="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|bottom"
android:background="@color/settings_bg_color"
android:orientation="vertical"
- android:paddingTop="@dimen/overview_panel_bottom_padding"
android:clickable="true" >
<RelativeLayout
+ insettable:layout_ignoreBottomInsets="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
@@ -52,6 +53,7 @@
</RelativeLayout>
<ImageView
+ insettable:layout_ignoreInsets="true"
android:id="@+id/settings_transition_image"
android:layout_width="150dp"
android:layout_height="150dp"
@@ -59,10 +61,10 @@
android:adjustViewBounds="true" />
<ListView
- xmlns:android="http://schemas.android.com/apk/res/android"
+ insettable:layout_ignoreTopInsets="true"
android:id="@+id/settings_transitions_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:listSelector="@android:color/transparent"
android:splitMotionEvents="false"/>
-</LinearLayout>
+</com.android.launcher3.InsettableLinearLayout>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 0dc3464..4d1a3c6 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -148,7 +148,19 @@
<attr name="sizeToFit" format="boolean" />
</declare-styleable>
+ <attr name="layout_ignoreInsets" format="boolean" />
+ <attr name="layout_ignoreBottomInsets" format="boolean" />
+ <attr name="layout_ignoreTopInsets" format="boolean" />
+
<declare-styleable name="InsettableFrameLayout_Layout">
- <attr name="layout_ignoreInsets" format="boolean" />
+ <attr name="layout_ignoreInsets" />
+ <attr name="layout_ignoreTopInsets" />
+ <attr name="layout_ignoreBottomInsets" />
+ </declare-styleable>
+
+ <declare-styleable name="InsettableLinearLayout_Layout">
+ <attr name="layout_ignoreInsets" />
+ <attr name="layout_ignoreTopInsets" />
+ <attr name="layout_ignoreBottomInsets" />
</declare-styleable>
</resources>
diff --git a/src/com/android/launcher3/InsettableFrameLayout.java b/src/com/android/launcher3/InsettableFrameLayout.java
index 7343bf6..6400a0f 100644
--- a/src/com/android/launcher3/InsettableFrameLayout.java
+++ b/src/com/android/launcher3/InsettableFrameLayout.java
@@ -24,10 +24,14 @@ public class InsettableFrameLayout extends FrameLayout implements
if (child instanceof Insettable) {
((Insettable) child).setInsets(newInsets);
} else if (!lp.ignoreInsets) {
- lp.topMargin += (newInsets.top - oldInsets.top);
+ if (!lp.ignoreTopInsets) {
+ lp.topMargin += (newInsets.top - oldInsets.top);
+ }
lp.leftMargin += (newInsets.left - oldInsets.left);
lp.rightMargin += (newInsets.right - oldInsets.right);
- lp.bottomMargin += (newInsets.bottom - oldInsets.bottom);
+ if (!lp.ignoreBottomInsets) {
+ lp.bottomMargin += (newInsets.bottom - oldInsets.bottom);
+ }
}
child.setLayoutParams(lp);
}
@@ -65,6 +69,8 @@ public class InsettableFrameLayout extends FrameLayout implements
public static class LayoutParams extends FrameLayout.LayoutParams {
boolean ignoreInsets = false;
+ boolean ignoreTopInsets = false;
+ boolean ignoreBottomInsets = false;
public LayoutParams(Context c, AttributeSet attrs) {
super(c, attrs);
@@ -72,6 +78,10 @@ public class InsettableFrameLayout extends FrameLayout implements
R.styleable.InsettableFrameLayout_Layout);
ignoreInsets = a.getBoolean(
R.styleable.InsettableFrameLayout_Layout_layout_ignoreInsets, false);
+ ignoreTopInsets = a.getBoolean(
+ R.styleable.InsettableFrameLayout_Layout_layout_ignoreTopInsets, false);
+ ignoreBottomInsets = a.getBoolean(
+ R.styleable.InsettableFrameLayout_Layout_layout_ignoreBottomInsets, false);
a.recycle();
}
diff --git a/src/com/android/launcher3/InsettableLinearLayout.java b/src/com/android/launcher3/InsettableLinearLayout.java
new file mode 100644
index 0000000..c48c088
--- /dev/null
+++ b/src/com/android/launcher3/InsettableLinearLayout.java
@@ -0,0 +1,106 @@
+package com.android.launcher3;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+
+public class InsettableLinearLayout extends LinearLayout implements
+ ViewGroup.OnHierarchyChangeListener, Insettable {
+
+ protected Rect mInsets = new Rect();
+
+ public InsettableLinearLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setOnHierarchyChangeListener(this);
+ }
+
+ public void setLinearLayoutChildInsets(View child, Rect newInsets, Rect oldInsets) {
+ final LayoutParams lp = (LayoutParams) child.getLayoutParams();
+
+ if (child instanceof Insettable) {
+ ((Insettable) child).setInsets(newInsets);
+ } else if (!lp.ignoreInsets) {
+ if (!lp.ignoreTopInsets) {
+ lp.topMargin += (newInsets.top - oldInsets.top);
+ }
+ lp.leftMargin += (newInsets.left - oldInsets.left);
+ lp.rightMargin += (newInsets.right - oldInsets.right);
+ if (!lp.ignoreBottomInsets) {
+ lp.bottomMargin += (newInsets.bottom - oldInsets.bottom);
+ }
+ }
+ child.setLayoutParams(lp);
+ }
+
+ @Override
+ public void setInsets(Rect insets) {
+ final int n = getChildCount();
+ for (int i = 0; i < n; i++) {
+ final View child = getChildAt(i);
+ setLinearLayoutChildInsets(child, insets, mInsets);
+ }
+ mInsets.set(insets);
+ }
+
+ @Override
+ public LayoutParams generateLayoutParams(AttributeSet attrs) {
+ return new InsettableLinearLayout.LayoutParams(getContext(), attrs);
+ }
+
+ @Override
+ protected LayoutParams generateDefaultLayoutParams() {
+ return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ }
+
+ // Override to allow type-checking of LayoutParams.
+ @Override
+ protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
+ return p instanceof InsettableLinearLayout.LayoutParams;
+ }
+
+ @Override
+ protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
+ return new LayoutParams(p);
+ }
+
+ public static class LayoutParams extends LinearLayout.LayoutParams {
+ boolean ignoreInsets = false;
+ boolean ignoreTopInsets = false;
+ boolean ignoreBottomInsets = false;
+
+ public LayoutParams(Context c, AttributeSet attrs) {
+ super(c, attrs);
+ TypedArray a = c.obtainStyledAttributes(attrs,
+ R.styleable.InsettableLinearLayout_Layout);
+ ignoreInsets = a.getBoolean(
+ R.styleable.InsettableLinearLayout_Layout_layout_ignoreInsets, false);
+ ignoreTopInsets = a.getBoolean(
+ R.styleable.InsettableLinearLayout_Layout_layout_ignoreTopInsets, false);
+ ignoreBottomInsets = a.getBoolean(
+ R.styleable.InsettableLinearLayout_Layout_layout_ignoreBottomInsets, false);
+ a.recycle();
+ }
+
+ public LayoutParams(int width, int height) {
+ super(width, height);
+ }
+
+ public LayoutParams(ViewGroup.LayoutParams lp) {
+ super(lp);
+ }
+ }
+
+ @Override
+ public void onChildViewAdded(View parent, View child) {
+ setLinearLayoutChildInsets(child, mInsets, new Rect());
+ }
+
+ @Override
+ public void onChildViewRemoved(View parent, View child) {
+ }
+
+}
diff --git a/src/com/android/launcher3/OverviewPanel.java b/src/com/android/launcher3/OverviewPanel.java
index 83603d8..d7f20d3 100644
--- a/src/com/android/launcher3/OverviewPanel.java
+++ b/src/com/android/launcher3/OverviewPanel.java
@@ -27,7 +27,7 @@ public class OverviewPanel extends SlidingUpPanelLayout implements Insettable {
findViewById(R.id.settings_container);
FrameLayout.LayoutParams lp =
(FrameLayout.LayoutParams) layout.getLayoutParams();
- lp.bottomMargin += insets.bottom - insets.bottom;
+ lp.bottomMargin = insets.bottom;
layout.setLayoutParams(lp);
}
}
diff --git a/src/com/android/launcher3/TransitionEffectsFragment.java b/src/com/android/launcher3/TransitionEffectsFragment.java
index 22b6df7..6c5542b 100644
--- a/src/com/android/launcher3/TransitionEffectsFragment.java
+++ b/src/com/android/launcher3/TransitionEffectsFragment.java
@@ -74,11 +74,6 @@ public class TransitionEffectsFragment extends Fragment {
mListView = (ListView) v.findViewById(R.id.settings_transitions_list);
final Launcher launcher = (Launcher) getActivity();
- LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)
- mListView.getLayoutParams();
- lp.bottomMargin = ((FrameLayout.LayoutParams) launcher.getOverviewPanel()
- .findViewById(R.id.settings_container).getLayoutParams()).bottomMargin;
- mListView.setLayoutParams(lp);
mIsDrawer = getArguments().getBoolean(PAGE_OR_DRAWER_SCROLL_SELECT);