summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-03-28 19:30:34 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-03-28 19:30:35 +0000
commite4eaa0e98320978f12126d5b492141df2f692a90 (patch)
tree5bf0e0eea7a0e0cc76dfa3ae751c9f66c96b4d37
parent676e29ce5d4bb2a38aca704db2855f2d73e09cc5 (diff)
parentf37a21412afb16f61ca23b5aca2e90691b57e171 (diff)
downloadandroid_packages_apps_Trebuchet-e4eaa0e98320978f12126d5b492141df2f692a90.tar.gz
android_packages_apps_Trebuchet-e4eaa0e98320978f12126d5b492141df2f692a90.tar.bz2
android_packages_apps_Trebuchet-e4eaa0e98320978f12126d5b492141df2f692a90.zip
Merge "Defining separate layouts for horizontal and vertical drop target bars instead of chaning the layouts in DeviceProfile" into ub-launcher3-calgary
-rw-r--r--res/layout-land/launcher.xml4
-rw-r--r--res/layout-port/launcher.xml4
-rw-r--r--res/layout-sw720dp/launcher.xml4
-rw-r--r--res/layout/drop_target_bar_horz_info.xml (renamed from res/layout/app_info_drop_target_bar.xml)37
-rw-r--r--res/layout/drop_target_bar_horz_search.xml (renamed from res/layout/search_drop_target_bar.xml)22
-rw-r--r--res/layout/drop_target_bar_vert_info.xml39
-rw-r--r--res/layout/drop_target_bar_vert_search.xml56
-rw-r--r--res/values-land/dimens.xml4
-rw-r--r--res/values-land/styles.xml39
-rw-r--r--res/values-sw720dp/styles.xml5
-rw-r--r--res/values/attrs.xml4
-rw-r--r--res/values/styles.xml9
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java21
-rw-r--r--src/com/android/launcher3/DeleteDropTarget.java3
-rw-r--r--src/com/android/launcher3/DeviceProfile.java27
15 files changed, 155 insertions, 123 deletions
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 63e460e5d..3a361e28d 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -52,11 +52,11 @@
<include
android:id="@+id/app_info_drop_target_bar"
- layout="@layout/app_info_drop_target_bar" />
+ layout="@layout/drop_target_bar_vert_info" />
<include
android:id="@+id/search_drop_target_bar"
- layout="@layout/search_drop_target_bar" />
+ layout="@layout/drop_target_bar_vert_search" />
<include layout="@layout/overview_panel"
android:id="@+id/overview_panel"
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index 39f5ac1c9..f711274fc 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -66,11 +66,11 @@
<include
android:id="@+id/app_info_drop_target_bar"
- layout="@layout/app_info_drop_target_bar" />
+ layout="@layout/drop_target_bar_horz_info" />
<include
android:id="@+id/search_drop_target_bar"
- layout="@layout/search_drop_target_bar" />
+ layout="@layout/drop_target_bar_horz_search" />
<include layout="@layout/widgets_view"
android:id="@+id/widgets_view"
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index b57244414..780d6454b 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -52,11 +52,11 @@
<include
android:id="@+id/app_info_drop_target_bar"
- layout="@layout/app_info_drop_target_bar" />
+ layout="@layout/drop_target_bar_horz_info" />
<include
android:id="@+id/search_drop_target_bar"
- layout="@layout/search_drop_target_bar" />
+ layout="@layout/drop_target_bar_horz_search" />
<include layout="@layout/overview_panel"
android:id="@+id/overview_panel"
diff --git a/res/layout/app_info_drop_target_bar.xml b/res/layout/drop_target_bar_horz_info.xml
index 5f19d4331..92a9b2286 100644
--- a/res/layout/app_info_drop_target_bar.xml
+++ b/res/layout/drop_target_bar_horz_info.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2011 The Android Open Source Project
+ Copyright (C) 2016 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.
@@ -16,27 +16,24 @@
-->
<com.android.launcher3.AppInfoDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="48dp"
+ android:layout_gravity="center_horizontal|bottom"
android:focusable="false" >
- <!-- Drag specific targets container -->
- <LinearLayout
+ <FrameLayout
android:id="@+id/drag_target_bar"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center|bottom" >
-
- <FrameLayout
- style="@style/DropTargetButtonContainer"
- android:layout_weight="1" >
-
- <!-- Info target -->
-
- <com.android.launcher3.InfoDropTarget
- android:id="@+id/info_target_text"
- style="@style/DropTargetButton"
- android:text="@string/app_info_drop_target_label" />
- </FrameLayout>
- </LinearLayout>
-
+ android:layout_height="match_parent">
+
+ <!-- Info target -->
+
+ <com.android.launcher3.InfoDropTarget
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:id="@+id/info_target_text"
+ style="@style/DropTargetButton"
+ android:text="@string/app_info_drop_target_label" />
+ </FrameLayout>
</com.android.launcher3.AppInfoDropTargetBar> \ No newline at end of file
diff --git a/res/layout/search_drop_target_bar.xml b/res/layout/drop_target_bar_horz_search.xml
index 50f96791a..7997801b4 100644
--- a/res/layout/search_drop_target_bar.xml
+++ b/res/layout/drop_target_bar_horz_search.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2011 The Android Open Source Project
+ Copyright (C) 2015 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.
@@ -15,9 +15,11 @@
limitations under the License.
-->
<com.android.launcher3.SearchDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:focusable="false" >
+ android:layout_gravity="center_horizontal|top"
+ android:focusable="false">
<!-- Drag specific targets container -->
@@ -28,24 +30,36 @@
android:layout_gravity="center" >
<FrameLayout
- style="@style/DropTargetButtonContainer"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
android:layout_weight="1" >
<!-- Delete target -->
<com.android.launcher3.DeleteDropTarget
+ launcher:hideParentOnDisable="true"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:gravity="center"
android:id="@+id/delete_target_text"
style="@style/DropTargetButton"
android:text="@string/remove_drop_target_label" />
</FrameLayout>
<FrameLayout
- style="@style/DropTargetButtonContainer"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
android:layout_weight="1" >
<!-- Uninstall target -->
<com.android.launcher3.UninstallDropTarget
+ launcher:hideParentOnDisable="true"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:gravity="center"
android:id="@+id/uninstall_target_text"
style="@style/DropTargetButton"
android:text="@string/uninstall_drop_target_label" />
diff --git a/res/layout/drop_target_bar_vert_info.xml b/res/layout/drop_target_bar_vert_info.xml
new file mode 100644
index 000000000..da33d1a9c
--- /dev/null
+++ b/res/layout/drop_target_bar_vert_info.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2016 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.
+-->
+<com.android.launcher3.AppInfoDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="48dp"
+ android:layout_height="match_parent"
+ android:focusable="false" >
+
+ <FrameLayout
+ android:id="@+id/drag_target_bar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <!-- Info target -->
+ <com.android.launcher3.InfoDropTarget
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:layout_gravity="center_horizontal|bottom"
+ android:gravity="center"
+ android:paddingLeft="14dp"
+ android:paddingRight="14dp"
+ android:textColor="@android:color/white"
+ android:id="@+id/info_target_text" />
+ </FrameLayout>
+
+</com.android.launcher3.AppInfoDropTargetBar> \ No newline at end of file
diff --git a/res/layout/drop_target_bar_vert_search.xml b/res/layout/drop_target_bar_vert_search.xml
new file mode 100644
index 000000000..d5e41df39
--- /dev/null
+++ b/res/layout/drop_target_bar_vert_search.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+<com.android.launcher3.SearchDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="48dp"
+ android:layout_height="match_parent"
+ android:focusable="false">
+
+ <!-- Drag specific targets container -->
+
+ <LinearLayout
+ android:id="@+id/drag_target_bar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_gravity="center"
+ android:paddingTop="20dp">
+
+ <!-- Delete target -->
+ <com.android.launcher3.DeleteDropTarget
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:gravity="center"
+ android:paddingLeft="14dp"
+ android:paddingRight="14dp"
+ android:id="@+id/delete_target_text"
+ android:textColor="@android:color/white"
+ android:layout_marginBottom="10dp" />
+
+ <!-- Uninstall target -->
+ <com.android.launcher3.UninstallDropTarget
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:paddingLeft="14dp"
+ android:paddingRight="14dp"
+ android:id="@+id/uninstall_target_text"
+ android:textColor="@android:color/white"
+ android:layout_marginTop="10dp"/>
+ </LinearLayout>
+
+</com.android.launcher3.SearchDropTargetBar> \ No newline at end of file
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index 2be939154..391575995 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -15,10 +15,6 @@
-->
<resources>
-<!-- QSB -->
- <dimen name="toolbar_button_vertical_padding">8dip</dimen>
- <dimen name="toolbar_button_horizontal_padding">0dip</dimen>
-
<!-- Container -->
<item name="container_margin" format="fraction" type="fraction">12%</item>
</resources>
diff --git a/res/values-land/styles.xml b/res/values-land/styles.xml
deleted file mode 100644
index 40926799f..000000000
--- a/res/values-land/styles.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2008 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>
-
- <style name="DropTargetButtonContainer">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">wrap_content</item>
- </style>
-
- <!-- This style applies to the drop target when it is shown in the sidebar -->
- <style name="DropTargetButton" parent="DropTargetButtonBase">
- <item name="android:layout_height">wrap_content</item>
- <item name="android:gravity">center</item>
- <item name="android:drawablePadding">0dp</item>
- <item name="android:paddingTop">@dimen/toolbar_button_vertical_padding</item>
- <item name="android:paddingBottom">@dimen/toolbar_button_vertical_padding</item>
- <item name="android:paddingLeft">@dimen/toolbar_button_horizontal_padding</item>
- <item name="android:paddingRight">@dimen/toolbar_button_horizontal_padding</item>
- <item name="android:shadowColor">#DD000000</item>
- </style>
-
-</resources> \ No newline at end of file
diff --git a/res/values-sw720dp/styles.xml b/res/values-sw720dp/styles.xml
index 1fdb267c7..674edaabc 100644
--- a/res/values-sw720dp/styles.xml
+++ b/res/values-sw720dp/styles.xml
@@ -28,11 +28,6 @@
</style>
<!-- Workspace -->
- <style name="DropTargetButtonContainer">
- <item name="android:layout_width">0dp</item>
- <item name="android:layout_height">match_parent</item>
- </style>
-
<style name="DropTargetButton" parent="DropTargetButtonBase">
<item name="android:paddingLeft">60dp</item>
<item name="android:paddingRight">60dp</item>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 2224ac820..6d8efaa34 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -83,4 +83,8 @@
<declare-styleable name="InsettableFrameLayout_Layout">
<attr name="layout_ignoreInsets" format="boolean" />
</declare-styleable>
+
+ <declare-styleable name="ButtonDropTarget">
+ <attr name="hideParentOnDisable" format="boolean" />
+ </declare-styleable>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 92cbe044c..1b7072d1d 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -71,16 +71,7 @@
</style>
<!-- Drop targets -->
- <style name="DropTargetButtonContainer">
- <item name="android:layout_width">0dp</item>
- <item name="android:layout_height">match_parent</item>
- </style>
-
<style name="DropTargetButtonBase">
- <item name="android:layout_width">wrap_content</item>
- <item name="android:layout_height">match_parent</item>
- <item name="android:layout_gravity">center</item>
- <item name="android:gravity">center_vertical</item>
<item name="android:drawablePadding">7.5dp</item>
<item name="android:paddingLeft">25dp</item>
<item name="android:paddingRight">25dp</item>
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index d8826831a..af1ebde8f 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -24,11 +24,13 @@ import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
+import android.content.res.TypedArray;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.InsetDrawable;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
@@ -52,6 +54,8 @@ public abstract class ButtonDropTarget extends TextView
private static final int DRAG_VIEW_DROP_DURATION = 285;
+ private final boolean mHideParentOnDisable;
+
protected Launcher mLauncher;
private int mBottomDragPadding;
protected BaseDropTargetBar mDropTargetBar;
@@ -65,12 +69,9 @@ public abstract class ButtonDropTarget extends TextView
protected ColorStateList mOriginalTextColor;
protected Drawable mDrawable;
- protected DeviceProfile mDeviceProfile;
-
private AnimatorSet mCurrentColorAnim;
@Thunk ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter;
-
public ButtonDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -78,18 +79,17 @@ public abstract class ButtonDropTarget extends TextView
public ButtonDropTarget(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mBottomDragPadding = getResources().getDimensionPixelSize(R.dimen.drop_target_drag_padding);
+
+ TypedArray a = context.obtainStyledAttributes(attrs,
+ R.styleable.ButtonDropTarget, defStyle, 0);
+ mHideParentOnDisable = a.getBoolean(R.styleable.ButtonDropTarget_hideParentOnDisable, false);
+ a.recycle();
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mOriginalTextColor = getTextColors();
-
- // Remove the text in the Phone UI in landscape
- mDeviceProfile = ((Launcher) getContext()).getDeviceProfile();
- if (mDeviceProfile.isVerticalBarLayout()) {
- setText("");
- }
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@@ -203,7 +203,8 @@ public abstract class ButtonDropTarget extends TextView
mCurrentColorAnim = null;
}
setTextColor(mOriginalTextColor);
- ((ViewGroup) getParent()).setVisibility(mActive ? View.VISIBLE : View.GONE);
+ (mHideParentOnDisable ? ((ViewGroup) getParent()) : this)
+ .setVisibility(mActive ? View.VISIBLE : View.GONE);
}
@Override
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index 997ded2d3..f24e00b5c 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -19,6 +19,7 @@ package com.android.launcher3;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.graphics.PointF;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.AnimationUtils;
@@ -69,7 +70,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
* Set the drop target's text to either "Remove" or "Cancel" depending on the drag source.
*/
public void setTextBasedOnDragSource(DragSource dragSource) {
- if (!mDeviceProfile.isVerticalBarLayout()) {
+ if (!TextUtils.isEmpty(getText())) {
setText(dragSource.supportsDeleteDropTarget() ? R.string.remove_drop_target_label
: android.R.string.cancel);
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 5bfa716ee..7c6f39e9c 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -31,7 +31,6 @@ import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.FrameLayout;
-import android.widget.LinearLayout;
import com.android.launcher3.config.FeatureFlags;
@@ -469,7 +468,7 @@ public class DeviceProfile {
// Layout the search bar space
Rect searchBarBounds = getSearchBarBounds(isLayoutRtl);
View searchBar = launcher.getSearchDropTargetBar();
- lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, searchBar, Gravity.TOP);
+ lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams();
lp.width = searchBarBounds.width();
lp.height = searchBarBounds.height();
lp.topMargin = searchBarTopExtraPaddingPx;
@@ -477,7 +476,7 @@ public class DeviceProfile {
// Layout the app info bar space
View appInfoBar = launcher.getAppInfoDropTargetBar();
- lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, appInfoBar, Gravity.BOTTOM);
+ lp = (FrameLayout.LayoutParams) appInfoBar.getLayoutParams();
lp.bottomMargin = hotseatBarHeightPx;
appInfoBar.setLayoutParams(lp);
@@ -584,28 +583,6 @@ public class DeviceProfile {
}
}
- private FrameLayout.LayoutParams getDropTargetBarLayoutParams(boolean hasVerticalBarLayout,
- View dropTargetBar, int verticalGravity) {
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) dropTargetBar.getLayoutParams();
- if (hasVerticalBarLayout) {
- // Vertical drop target bar space -- The drop target bar is fixed in the layout to be on
- // the left of the screen regardless of RTL
- lp.gravity = Gravity.LEFT;
- lp.width = normalSearchBarSpaceHeightPx;
-
- LinearLayout targets = (LinearLayout) dropTargetBar.findViewById(R.id.drag_target_bar);
- targets.setOrientation(LinearLayout.VERTICAL);
- FrameLayout.LayoutParams targetsLp = (FrameLayout.LayoutParams) targets.getLayoutParams();
- targetsLp.gravity = verticalGravity;
- targetsLp.height = LayoutParams.WRAP_CONTENT;
- } else {
- // Horizontal drop target bar space
- lp.gravity = verticalGravity | Gravity.CENTER_HORIZONTAL;
- lp.height = searchBarSpaceHeightPx;
- }
- return lp;
- }
-
private int getCurrentWidth() {
return isLandscape
? Math.max(widthPx, heightPx)