summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout-land/launcher.xml8
-rw-r--r--res/layout-port/launcher.xml10
-rw-r--r--res/layout-sw720dp/launcher.xml10
-rw-r--r--res/layout/drop_target_bar_horz.xml79
-rw-r--r--res/layout/drop_target_bar_horz_info.xml39
-rw-r--r--res/layout/drop_target_bar_horz_search.xml69
-rw-r--r--res/layout/drop_target_bar_vert.xml63
-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/dimens.xml23
-rw-r--r--src/com/android/launcher3/AppInfoDropTargetBar.java80
-rw-r--r--src/com/android/launcher3/BaseDropTargetBar.java146
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java12
-rw-r--r--src/com/android/launcher3/DeviceProfile.java174
-rw-r--r--src/com/android/launcher3/DropTargetBar.java153
-rw-r--r--src/com/android/launcher3/FocusHelper.java2
-rw-r--r--src/com/android/launcher3/Launcher.java31
-rw-r--r--src/com/android/launcher3/LauncherAppWidgetProviderInfo.java5
-rw-r--r--src/com/android/launcher3/LauncherStateTransitionAnimation.java6
-rw-r--r--src/com/android/launcher3/SearchDropTargetBar.java140
-rw-r--r--src/com/android/launcher3/Workspace.java57
-rw-r--r--src/com/android/launcher3/WorkspaceStateTransitionAnimation.java3
-rw-r--r--src/com/android/launcher3/dragndrop/DragLayer.java30
-rw-r--r--src/com/android/launcher3/folder/Folder.java6
-rw-r--r--tests/src/com/android/launcher3/InvariantDeviceProfileTest.java71
25 files changed, 418 insertions, 894 deletions
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 3a361e28d..1147326f7 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -51,12 +51,8 @@
android:layout_gravity="right" />
<include
- android:id="@+id/app_info_drop_target_bar"
- layout="@layout/drop_target_bar_vert_info" />
-
- <include
- android:id="@+id/search_drop_target_bar"
- layout="@layout/drop_target_bar_vert_search" />
+ android:id="@+id/drop_target_bar"
+ layout="@layout/drop_target_bar_vert" />
<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 4576e4d06..fed99f331 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -60,15 +60,11 @@
<com.android.launcher3.pageindicators.PageIndicatorLine
android:id="@+id/page_indicator"
android:layout_width="match_parent"
- android:layout_height="1dp" />
+ android:layout_height="@dimen/dynamic_grid_page_indicator_height" />
<include
- android:id="@+id/app_info_drop_target_bar"
- layout="@layout/drop_target_bar_horz_info" />
-
- <include
- android:id="@+id/search_drop_target_bar"
- layout="@layout/drop_target_bar_horz_search" />
+ android:id="@+id/drop_target_bar"
+ layout="@layout/drop_target_bar_horz" />
<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 0f755d8e1..23e673cbf 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -51,12 +51,8 @@
android:layout_height="match_parent" />
<include
- android:id="@+id/app_info_drop_target_bar"
- layout="@layout/drop_target_bar_horz_info" />
-
- <include
- android:id="@+id/search_drop_target_bar"
- layout="@layout/drop_target_bar_horz_search" />
+ android:id="@+id/drop_target_bar"
+ layout="@layout/drop_target_bar_horz" />
<include layout="@layout/overview_panel"
android:id="@+id/overview_panel"
@@ -67,7 +63,7 @@
<com.android.launcher3.pageindicators.PageIndicatorLine
android:id="@+id/page_indicator"
android:layout_width="match_parent"
- android:layout_height="1dp" />
+ android:layout_height="@dimen/dynamic_grid_page_indicator_height" />
<include layout="@layout/widgets_view"
android:id="@+id/widgets_view"
diff --git a/res/layout/drop_target_bar_horz.xml b/res/layout/drop_target_bar_horz.xml
new file mode 100644
index 000000000..ee22d1e74
--- /dev/null
+++ b/res/layout/drop_target_bar_horz.xml
@@ -0,0 +1,79 @@
+<?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.DropTargetBar
+ 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="@dimen/dynamic_grid_drop_target_size"
+ android:layout_gravity="center_horizontal|top"
+ android:focusable="false">
+
+ <FrameLayout
+ 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
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1" >
+
+ <!-- App Info -->
+
+ <com.android.launcher3.InfoDropTarget
+ launcher:hideParentOnDisable="true"
+ 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>
+
+ <FrameLayout
+ 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" />
+ </FrameLayout>
+
+</com.android.launcher3.DropTargetBar> \ No newline at end of file
diff --git a/res/layout/drop_target_bar_horz_info.xml b/res/layout/drop_target_bar_horz_info.xml
deleted file mode 100644
index 92a9b2286..000000000
--- a/res/layout/drop_target_bar_horz_info.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?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="match_parent"
- android:layout_height="48dp"
- android:layout_gravity="center_horizontal|bottom"
- 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="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/drop_target_bar_horz_search.xml b/res/layout/drop_target_bar_horz_search.xml
deleted file mode 100644
index 7997801b4..000000000
--- a/res/layout/drop_target_bar_horz_search.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?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"
- xmlns:launcher="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center_horizontal|top"
- 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:layout_gravity="center" >
-
- <FrameLayout
- 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
- 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" />
- </FrameLayout>
- </LinearLayout>
-
-</com.android.launcher3.SearchDropTargetBar> \ No newline at end of file
diff --git a/res/layout/drop_target_bar_vert.xml b/res/layout/drop_target_bar_vert.xml
new file mode 100644
index 000000000..10b1d7cc8
--- /dev/null
+++ b/res/layout/drop_target_bar_vert.xml
@@ -0,0 +1,63 @@
+<?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.DropTargetBar
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="@dimen/dynamic_grid_drop_target_size"
+ android:orientation="vertical"
+ android:layout_height="match_parent"
+ android:layout_gravity="left"
+ android:focusable="false"
+ android:paddingTop="@dimen/vert_drop_target_vertical_gap" >
+
+ <!-- Delete target -->
+ <com.android.launcher3.DeleteDropTarget
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/dynamic_grid_drop_target_size"
+ android:gravity="center"
+ android:paddingLeft="@dimen/vert_drop_target_horizontal_gap"
+ android:paddingRight="@dimen/vert_drop_target_horizontal_gap"
+ android:id="@+id/delete_target_text"
+ android:textColor="@android:color/white" />
+
+ <!-- Uninstall target -->
+ <com.android.launcher3.UninstallDropTarget
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/dynamic_grid_drop_target_size"
+ android:gravity="center"
+ android:paddingLeft="@dimen/vert_drop_target_horizontal_gap"
+ android:paddingRight="@dimen/vert_drop_target_horizontal_gap"
+ android:id="@+id/uninstall_target_text"
+ android:textColor="@android:color/white"
+ android:layout_marginTop="@dimen/vert_drop_target_vertical_gap"/>
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1" />
+
+ <!-- App Info -->
+ <com.android.launcher3.InfoDropTarget
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/dynamic_grid_drop_target_size"
+ android:gravity="center"
+ android:paddingLeft="@dimen/vert_drop_target_horizontal_gap"
+ android:paddingRight="@dimen/vert_drop_target_horizontal_gap"
+ android:id="@+id/info_target_text"
+ android:textColor="@android:color/white"
+ android:layout_marginBottom="64dp"/>
+
+</com.android.launcher3.DropTargetBar> \ No newline at end of file
diff --git a/res/layout/drop_target_bar_vert_info.xml b/res/layout/drop_target_bar_vert_info.xml
deleted file mode 100644
index da33d1a9c..000000000
--- a/res/layout/drop_target_bar_vert_info.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?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
deleted file mode 100644
index d5e41df39..000000000
--- a/res/layout/drop_target_bar_vert_search.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?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/dimens.xml b/res/values/dimens.xml
index 7510fafd5..35ee58e69 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -17,19 +17,7 @@
<resources>
<!-- Dynamic Grid -->
<dimen name="dynamic_grid_edge_margin">6dp</dimen>
- <dimen name="dynamic_grid_search_bar_height">48dp</dimen>
- <!-- We want 46dp extra for the tall search bar. -->
- <dimen name="dynamic_grid_search_bar_height_tall">94dp</dimen>
- <dimen name="qsb_internal_padding_top">8dp</dimen>
- <dimen name="qsb_internal_padding_bottom">8dp</dimen>
- <dimen name="dynamic_grid_search_bar_extra_top_padding">0dp</dimen>
- <!-- Reduce the space between the status bar and the search bar when the search bar is tall -->
- <dimen name="dynamic_grid_search_bar_negative_top_padding_short">-4dp</dimen>
- <dimen name="dynamic_grid_search_bar_bottom_padding">4dp</dimen>
- <!-- Reduce the padding between the search bar and workspace when the search bar is tall -->
- <dimen name="dynamic_grid_search_bar_bottom_negative_padding_short">-6dp</dimen>
- <dimen name="dynamic_grid_search_bar_bottom_padding_tablet">16dp</dimen>
- <dimen name="dynamic_grid_page_indicator_height">20dp</dimen>
+ <dimen name="dynamic_grid_page_indicator_height">1dp</dimen>
<dimen name="dynamic_grid_icon_drawable_padding">4dp</dimen>
<dimen name="dynamic_grid_workspace_page_spacing">8dp</dimen>
<dimen name="dynamic_grid_overview_min_icon_zone_height">80dp</dimen>
@@ -37,6 +25,15 @@
<dimen name="dynamic_grid_overview_bar_item_width">80dp</dimen>
<dimen name="dynamic_grid_overview_bar_spacer_width">20dp</dimen>
+ <dimen name="dynamic_grid_workspace_top_padding">12dp</dimen>
+ <!-- Minimum space between workspace and hotseat in spring loaded mode -->
+ <dimen name="dynamic_grid_min_spring_loaded_space">8dp</dimen>
+
+<!-- Drop target bar -->
+ <dimen name="dynamic_grid_drop_target_size">48dp</dimen>
+ <dimen name="vert_drop_target_vertical_gap">20dp</dimen>
+ <dimen name="vert_drop_target_horizontal_gap">14dp</dimen>
+
<!-- App Widget resize frame -->
<dimen name="default_widget_padding">8dp</dimen>
<dimen name="widget_handle_margin">13dp</dimen>
diff --git a/src/com/android/launcher3/AppInfoDropTargetBar.java b/src/com/android/launcher3/AppInfoDropTargetBar.java
deleted file mode 100644
index e06f94100..000000000
--- a/src/com/android/launcher3/AppInfoDropTargetBar.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.android.launcher3;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.android.launcher3.dragndrop.DragController;
-
-public class AppInfoDropTargetBar extends BaseDropTargetBar {
- private ButtonDropTarget mAppInfoDropTarget;
-
- public AppInfoDropTargetBar(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public AppInfoDropTargetBar(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
-
- // Get the individual components
- mAppInfoDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target_text);
-
- mAppInfoDropTarget.setDropTargetBar(this);
- }
-
- @Override
- public void setup(Launcher launcher, DragController dragController) {
- dragController.addDragListener(this);
-
- dragController.addDragListener(mAppInfoDropTarget);
- dragController.addDropTarget(mAppInfoDropTarget);
-
- mAppInfoDropTarget.setLauncher(launcher);
- }
-
- @Override
- public void showDropTargets() {
- animateDropTargetBarToAlpha(1f, DEFAULT_DRAG_FADE_DURATION);
- }
-
- @Override
- public void hideDropTargets() {
- animateDropTargetBarToAlpha(0f, DEFAULT_DRAG_FADE_DURATION);
- }
-
- private void animateDropTargetBarToAlpha(float alpha, int duration) {
- resetAnimation(duration);
- if (duration > 0) {
- animateAlpha(mDropTargetBar, alpha, DEFAULT_INTERPOLATOR);
- mCurrentAnimation.start();
- } else {
- mDropTargetBar.setAlpha(alpha);
- AlphaUpdateListener.updateVisibility(mDropTargetBar, mAccessibilityEnabled);
- }
- }
-
- @Override
- public void enableAccessibleDrag(boolean enable) {
- mAppInfoDropTarget.enableAccessibleDrag(enable);
- }
-}
diff --git a/src/com/android/launcher3/BaseDropTargetBar.java b/src/com/android/launcher3/BaseDropTargetBar.java
deleted file mode 100644
index 9b38623c2..000000000
--- a/src/com/android/launcher3/BaseDropTargetBar.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.android.launcher3;
-
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.AnimatorSet;
-import android.animation.ObjectAnimator;
-import android.animation.TimeInterpolator;
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.accessibility.AccessibilityManager;
-import android.view.animation.AccelerateInterpolator;
-import android.widget.FrameLayout;
-
-import com.android.launcher3.dragndrop.DragController;
-
-/**
- * Base class for drop target bars (where you can drop apps to do actions such as uninstall).
- */
-public abstract class BaseDropTargetBar extends FrameLayout implements DragController.DragListener {
- protected static final int DEFAULT_DRAG_FADE_DURATION = 175;
- protected static final TimeInterpolator DEFAULT_INTERPOLATOR = new AccelerateInterpolator();
-
- protected View mDropTargetBar;
- protected boolean mAccessibilityEnabled = false;
-
- protected AnimatorSet mCurrentAnimation;
- protected boolean mDeferOnDragEnd;
-
- public BaseDropTargetBar(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public BaseDropTargetBar(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
-
- mDropTargetBar = findViewById(R.id.drag_target_bar);
-
- // Create the various fade animations
- mDropTargetBar.setAlpha(0f);
- }
-
- /**
- * Convenience method to animate the alpha of a view.
- */
- protected void animateAlpha(View v, float alpha, TimeInterpolator interpolator) {
- if (Float.compare(v.getAlpha(), alpha) != 0) {
- ObjectAnimator anim = ObjectAnimator.ofFloat(v, View.ALPHA, alpha);
- anim.setInterpolator(interpolator);
- anim.addListener(new ViewVisiblilyUpdateHandler(v));
- mCurrentAnimation.play(anim);
- }
- }
-
- protected void resetAnimation(int newAnimationDuration) {
- // Update the accessibility state
- AccessibilityManager am = (AccessibilityManager)
- getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
- mAccessibilityEnabled = am.isEnabled();
-
- // Cancel any existing animation
- if (mCurrentAnimation != null) {
- mCurrentAnimation.cancel();
- mCurrentAnimation = null;
- }
-
- if (newAnimationDuration > 0) {
- mCurrentAnimation = new AnimatorSet();
- mCurrentAnimation.setDuration(newAnimationDuration);
- }
- }
-
- /*
- * DragController.DragListener implementation
- */
- @Override
- public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
- showDropTargets();
- }
-
- /**
- * This is called to defer hiding the delete drop target until the drop animation has completed,
- * instead of hiding immediately when the drag has ended.
- */
- protected void deferOnDragEnd() {
- mDeferOnDragEnd = true;
- }
-
- @Override
- public void onDragEnd() {
- if (!mDeferOnDragEnd) {
- hideDropTargets();
- } else {
- mDeferOnDragEnd = false;
- }
- }
-
- public abstract void showDropTargets();
-
- public abstract void hideDropTargets();
-
- public abstract void enableAccessibleDrag(boolean enable);
-
- public abstract void setup(Launcher launcher, DragController dragController);
-
- private class ViewVisiblilyUpdateHandler extends AnimatorListenerAdapter {
- private final View mView;
-
- ViewVisiblilyUpdateHandler(View v) {
- mView = v;
- }
-
- @Override
- public void onAnimationStart(Animator animation) {
- // Ensure that the view is visible for the animation
- mView.setVisibility(View.VISIBLE);
- }
-
- @Override
- public void onAnimationEnd(Animator animation){
- AlphaUpdateListener.updateVisibility(mView, mAccessibilityEnabled);
- }
-
- }
-}
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index 43afbe59e..61ac713a5 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -55,10 +55,10 @@ public abstract class ButtonDropTarget extends TextView
private static final int DRAG_VIEW_DROP_DURATION = 285;
private final boolean mHideParentOnDisable;
+ protected final Launcher mLauncher;
- protected Launcher mLauncher;
private int mBottomDragPadding;
- protected BaseDropTargetBar mDropTargetBar;
+ protected DropTargetBar mDropTargetBar;
/** Whether this drop target is active for the current drag */
protected boolean mActive;
@@ -80,6 +80,8 @@ public abstract class ButtonDropTarget extends TextView
public ButtonDropTarget(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ mLauncher = (Launcher) context;
+
Resources resources = getResources();
mBottomDragPadding = resources.getDimensionPixelSize(R.dimen.drop_target_drag_padding);
@@ -109,11 +111,7 @@ public abstract class ButtonDropTarget extends TextView
}
}
- public void setLauncher(Launcher launcher) {
- mLauncher = launcher;
- }
-
- public void setDropTargetBar(BaseDropTargetBar dropTargetBar) {
+ public void setDropTargetBar(DropTargetBar dropTargetBar) {
mDropTargetBar = dropTargetBar;
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 8d11aaa96..4a550ed9a 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -70,7 +70,10 @@ public class DeviceProfile {
public final Rect defaultWidgetPadding;
private final int pageIndicatorHeightPx;
private final int defaultPageSpacingPx;
+ private final int topWorkspacePadding;
private float dragViewScale;
+ public float workspaceSpringLoadShrinkFactor;
+ public final int workspaceSpringLoadedBottomSpace;
// Workspace icons
public int iconSizePx;
@@ -92,8 +95,7 @@ public class DeviceProfile {
public int hotseatCellWidthPx;
public int hotseatCellHeightPx;
public int hotseatIconSizePx;
- private int normalHotseatBarHeightPx, shortHotseatBarHeightPx;
- private int hotseatBarHeightPx; // One of the above.
+ private int hotseatBarHeightPx;
// All apps
public int allAppsNumCols;
@@ -102,15 +104,8 @@ public class DeviceProfile {
public final int allAppsIconSizePx;
public final float allAppsIconTextSizeSp;
- // QSB
- private int searchBarWidgetInternalPaddingTop, searchBarWidgetInternalPaddingBottom;
- private int searchBarTopPaddingPx;
- private int tallSearchBarNegativeTopPaddingPx, normalSearchBarTopExtraPaddingPx;
- private int searchBarTopExtraPaddingPx; // One of the above.
- private int normalSearchBarBottomPaddingPx, tallSearchBarBottomPaddingPx;
- private int searchBarBottomPaddingPx; // One of the above.
- private int normalSearchBarSpaceHeightPx, tallSearchBarSpaceHeightPx;
- private int searchBarSpaceHeightPx; // One of the above.
+ // Drop Target
+ public int dropTargetBarSizePx;
public DeviceProfile(Context context, InvariantDeviceProfile inv,
Point minSize, Point maxSize,
@@ -140,6 +135,8 @@ public class DeviceProfile {
res.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_height);
defaultPageSpacingPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_workspace_page_spacing);
+ topWorkspacePadding =
+ res.getDimensionPixelSize(R.dimen.dynamic_grid_workspace_top_padding);
overviewModeMinIconZoneHeightPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_min_icon_zone_height);
overviewModeMaxIconZoneHeightPx =
@@ -152,6 +149,9 @@ public class DeviceProfile {
res.getInteger(R.integer.config_dynamic_grid_overview_icon_zone_percentage) / 100f;
iconDrawablePaddingOriginalPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_icon_drawable_padding);
+ dropTargetBarSizePx = res.getDimensionPixelSize(R.dimen.dynamic_grid_drop_target_size);
+ workspaceSpringLoadedBottomSpace =
+ res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space);
// AllApps uses the original non-scaled icon text size
allAppsIconTextSizeSp = inv.iconTextSize;
@@ -195,7 +195,7 @@ public class DeviceProfile {
float usedHeight = (cellHeightPx * inv.numRows);
// We only care about the top and bottom workspace padding, which is not affected by RTL.
- Rect workspacePadding = getWorkspacePadding(false /* isLayoutRtl */);
+ Rect workspacePadding = getWorkspacePadding();
int maxHeight = (availableHeightPx - workspacePadding.top - workspacePadding.bottom);
if (usedHeight > maxHeight) {
scale = maxHeight / usedHeight;
@@ -211,33 +211,6 @@ public class DeviceProfile {
iconDrawablePaddingPx = drawablePadding;
hotseatIconSizePx = (int) (Utilities.pxFromDp(inv.hotseatIconSize, dm) * scale);
- // Search Bar
- normalSearchBarSpaceHeightPx = res.getDimensionPixelSize(
- R.dimen.dynamic_grid_search_bar_height);
- tallSearchBarSpaceHeightPx = res.getDimensionPixelSize(
- R.dimen.dynamic_grid_search_bar_height_tall);
- searchBarWidgetInternalPaddingTop = res.getDimensionPixelSize(
- R.dimen.qsb_internal_padding_top);
- searchBarWidgetInternalPaddingBottom = res.getDimensionPixelSize(
- R.dimen.qsb_internal_padding_bottom);
- normalSearchBarTopExtraPaddingPx = res.getDimensionPixelSize(
- R.dimen.dynamic_grid_search_bar_extra_top_padding);
- tallSearchBarNegativeTopPaddingPx = res.getDimensionPixelSize(
- R.dimen.dynamic_grid_search_bar_negative_top_padding_short);
- if (isTablet && !isVerticalBarLayout()) {
- searchBarTopPaddingPx = searchBarWidgetInternalPaddingTop;
- normalSearchBarBottomPaddingPx = searchBarWidgetInternalPaddingBottom +
- res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_bottom_padding_tablet);
- tallSearchBarBottomPaddingPx = normalSearchBarBottomPaddingPx;
- } else {
- searchBarTopPaddingPx = searchBarWidgetInternalPaddingTop;
- normalSearchBarBottomPaddingPx = searchBarWidgetInternalPaddingBottom +
- res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_bottom_padding);
- tallSearchBarBottomPaddingPx = searchBarWidgetInternalPaddingBottom
- + res.getDimensionPixelSize(
- R.dimen.dynamic_grid_search_bar_bottom_negative_padding_short);
- }
-
// Calculate the actual text height
Paint textPaint = new Paint();
textPaint.setTextSize(iconTextSizePx);
@@ -249,11 +222,22 @@ public class DeviceProfile {
dragViewScale = (iconSizePx + scaleDps) / iconSizePx;
// Hotseat
- normalHotseatBarHeightPx = iconSizePx + 4 * edgeMarginPx;
- shortHotseatBarHeightPx = iconSizePx + 2 * edgeMarginPx;
+ hotseatBarHeightPx = iconSizePx + 4 * edgeMarginPx;
hotseatCellWidthPx = iconSizePx;
hotseatCellHeightPx = iconSizePx;
+ if (!isVerticalBarLayout()) {
+ int expectedWorkspaceHeight = availableHeightPx - hotseatBarHeightPx
+ - pageIndicatorHeightPx - topWorkspacePadding;
+ float minRequiredHeight = dropTargetBarSizePx + workspaceSpringLoadedBottomSpace;
+ workspaceSpringLoadShrinkFactor = Math.min(
+ res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f,
+ 1 - (minRequiredHeight / expectedWorkspaceHeight));
+ } else {
+ workspaceSpringLoadShrinkFactor =
+ res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
+ }
+
// Folder
int folderCellPadding = isTablet || isLandscape ? 6 * edgeMarginPx : 3 * edgeMarginPx;
// Don't let the folder get too close to the edges of the screen.
@@ -281,60 +265,33 @@ public class DeviceProfile {
allAppsNumPredictiveCols = numPredictiveAppCols;
}
- /** Returns the amount of extra space to allocate to the search bar for vertical padding. */
- private int getSearchBarTotalVerticalPadding() {
- return searchBarTopPaddingPx + searchBarTopExtraPaddingPx + searchBarBottomPaddingPx;
- }
-
/** Returns the width and height of the search bar, ignoring any padding. */
- public Point getSearchBarDimensForWidgetOpts(Resources res) {
- Rect searchBarBounds = getSearchBarBounds(Utilities.isRtl(res));
+ public Point getSearchBarDimensForWidgetOpts() {
if (isVerticalBarLayout()) {
- return new Point(searchBarBounds.width(), searchBarBounds.height());
- }
- int widgetInternalPadding = searchBarWidgetInternalPaddingTop +
- searchBarWidgetInternalPaddingBottom;
- return new Point(searchBarBounds.width(), searchBarSpaceHeightPx + widgetInternalPadding);
- }
-
- /** Returns the search bar bounds in the current orientation */
- public Rect getSearchBarBounds(boolean isLayoutRtl) {
- Rect bounds = new Rect();
- if (isVerticalBarLayout()) {
- if (isLayoutRtl) {
- bounds.set(availableWidthPx - normalSearchBarSpaceHeightPx, edgeMarginPx,
- availableWidthPx, availableHeightPx - edgeMarginPx);
- } else {
- bounds.set(0, edgeMarginPx, normalSearchBarSpaceHeightPx,
- availableHeightPx - edgeMarginPx);
- }
+ return new Point(dropTargetBarSizePx, availableHeightPx - 2 * edgeMarginPx);
} else {
- int boundsBottom = searchBarSpaceHeightPx + getSearchBarTotalVerticalPadding();
+ int gap;
if (isTablet) {
// Pad the left and right of the workspace to ensure consistent spacing
// between all icons
int width = getCurrentWidth();
// XXX: If the icon size changes across orientations, we will have to take
// that into account here too.
- int gap = (int) ((width - 2 * edgeMarginPx -
- (inv.numColumns * cellWidthPx)) / (2 * (inv.numColumns + 1)));
- bounds.set(edgeMarginPx + gap, 0,
- availableWidthPx - (edgeMarginPx + gap), boundsBottom);
+ gap = ((width - 2 * edgeMarginPx
+ - (inv.numColumns * cellWidthPx)) / (2 * (inv.numColumns + 1)))
+ + edgeMarginPx;
} else {
- bounds.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left,
- 0,
- availableWidthPx - (desiredWorkspaceLeftRightMarginPx -
- defaultWidgetPadding.right), boundsBottom);
+ gap = desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.right;
}
+ return new Point(availableWidthPx - 2 * gap, dropTargetBarSizePx);
}
- return bounds;
}
public Point getCellSize() {
Point result = new Point();
// Since we are only concerned with the overall padding, layout direction does
// not matter.
- Rect padding = getWorkspacePadding(false /* isLayoutRtl */ );
+ Rect padding = getWorkspacePadding();
result.x = calculateCellWidth(availableWidthPx - padding.left - padding.right,
inv.numColumns);
result.y = calculateCellHeight(availableHeightPx - padding.top - padding.bottom,
@@ -343,20 +300,13 @@ public class DeviceProfile {
}
/** Returns the workspace padding in the specified orientation */
- public Rect getWorkspacePadding(boolean isLayoutRtl) {
- Rect searchBarBounds = getSearchBarBounds(isLayoutRtl);
+ public Rect getWorkspacePadding() {
Rect padding = new Rect();
if (isVerticalBarLayout()) {
- // Pad the left and right of the workspace with search/hotseat bar sizes
- if (isLayoutRtl) {
- padding.set(normalHotseatBarHeightPx, edgeMarginPx,
- searchBarBounds.width(), edgeMarginPx);
- } else {
- padding.set(searchBarBounds.width(), edgeMarginPx,
- normalHotseatBarHeightPx, edgeMarginPx);
- }
+ // in case of isVerticalBarLayout, the hotseat is always on the right and the drop
+ // target bar is on the left, independent of the layout direction.
+ padding.set(dropTargetBarSizePx, edgeMarginPx, hotseatBarHeightPx, edgeMarginPx);
} else {
- int paddingTop = searchBarBounds.bottom;
int paddingBottom = hotseatBarHeightPx + pageIndicatorHeightPx;
if (isTablet) {
// Pad the left and right of the workspace to ensure consistent spacing
@@ -369,14 +319,14 @@ public class DeviceProfile {
((inv.numColumns - 1) * gapScale * cellWidthPx)));
availablePaddingX = (int) Math.min(availablePaddingX,
width * MAX_HORIZONTAL_PADDING_PERCENT);
- int availablePaddingY = Math.max(0, height - paddingTop - paddingBottom
+ int availablePaddingY = Math.max(0, height - topWorkspacePadding - paddingBottom
- (int) (2 * inv.numRows * cellHeightPx));
- padding.set(availablePaddingX / 2, paddingTop + availablePaddingY / 2,
+ padding.set(availablePaddingX / 2, topWorkspacePadding + availablePaddingY / 2,
availablePaddingX / 2, paddingBottom + availablePaddingY / 2);
} else {
// Pad the top and bottom of the workspace with search/hotseat bar sizes
padding.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left,
- paddingTop,
+ topWorkspacePadding,
desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.right,
paddingBottom);
}
@@ -384,7 +334,7 @@ public class DeviceProfile {
return padding;
}
- private int getWorkspacePageSpacing(boolean isLayoutRtl) {
+ private int getWorkspacePageSpacing() {
if (isVerticalBarLayout() || isLargeTablet) {
// In landscape mode the page spacing is set to the default.
return defaultPageSpacingPx;
@@ -392,7 +342,7 @@ public class DeviceProfile {
// In portrait, we want the pages spaced such that there is no
// overhang of the previous / next page into the current page viewport.
// We assume symmetrical padding in portrait mode.
- return Math.max(defaultPageSpacingPx, 2 * getWorkspacePadding(isLayoutRtl).left);
+ return Math.max(defaultPageSpacingPx, 2 * getWorkspacePadding().left);
}
}
@@ -444,50 +394,28 @@ public class DeviceProfile {
return visibleChildren;
}
- // TODO(twickham): b/25154513
- public void setSearchBarHeight(int searchBarHeight) {
- if (searchBarHeight == LauncherCallbacks.SEARCH_BAR_HEIGHT_TALL) {
- hotseatBarHeightPx = shortHotseatBarHeightPx;
- searchBarSpaceHeightPx = tallSearchBarSpaceHeightPx;
- searchBarBottomPaddingPx = tallSearchBarBottomPaddingPx;
- searchBarTopExtraPaddingPx = isPhone ? tallSearchBarNegativeTopPaddingPx
- : normalSearchBarTopExtraPaddingPx;
- } else {
- hotseatBarHeightPx = normalHotseatBarHeightPx;
- searchBarSpaceHeightPx = normalSearchBarSpaceHeightPx;
- searchBarBottomPaddingPx = normalSearchBarBottomPaddingPx;
- searchBarTopExtraPaddingPx = normalSearchBarTopExtraPaddingPx;
- }
- }
-
public void layout(Launcher launcher) {
FrameLayout.LayoutParams lp;
boolean hasVerticalBarLayout = isVerticalBarLayout();
final boolean isLayoutRtl = Utilities.isRtl(launcher.getResources());
// Layout the search bar space
- Rect searchBarBounds = getSearchBarBounds(isLayoutRtl);
- View searchBar = launcher.getSearchDropTargetBar();
+ Point searchBarBounds = getSearchBarDimensForWidgetOpts();
+ View searchBar = launcher.getDropTargetBar();
lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams();
- lp.width = searchBarBounds.width();
- lp.height = searchBarBounds.height();
- lp.topMargin = searchBarTopExtraPaddingPx;
+ lp.width = searchBarBounds.x;
+ lp.height = searchBarBounds.y;
+ lp.topMargin = edgeMarginPx;
searchBar.setLayoutParams(lp);
- // Layout the app info bar space
- View appInfoBar = launcher.getAppInfoDropTargetBar();
- lp = (FrameLayout.LayoutParams) appInfoBar.getLayoutParams();
- lp.bottomMargin = hotseatBarHeightPx;
- appInfoBar.setLayoutParams(lp);
-
// Layout the workspace
PagedView workspace = (PagedView) launcher.findViewById(R.id.workspace);
lp = (FrameLayout.LayoutParams) workspace.getLayoutParams();
lp.gravity = Gravity.CENTER;
- Rect padding = getWorkspacePadding(isLayoutRtl);
+ Rect padding = getWorkspacePadding();
workspace.setLayoutParams(lp);
workspace.setPadding(padding.left, padding.top, padding.right, padding.bottom);
- workspace.setPageSpacing(getWorkspacePageSpacing(isLayoutRtl));
+ workspace.setPageSpacing(getWorkspacePageSpacing());
// Layout the hotseat
View hotseat = launcher.findViewById(R.id.hotseat);
@@ -503,7 +431,7 @@ public class DeviceProfile {
// Vertical hotseat -- The hotseat is fixed in the layout to be on the right of the
// screen regardless of RTL
lp.gravity = Gravity.RIGHT;
- lp.width = normalHotseatBarHeightPx;
+ lp.width = hotseatBarHeightPx;
lp.height = LayoutParams.MATCH_PARENT;
hotseat.findViewById(R.id.layout).setPadding(0, 2 * edgeMarginPx, 0, 2 * edgeMarginPx);
} else if (isTablet) {
diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java
new file mode 100644
index 000000000..5966af51c
--- /dev/null
+++ b/src/com/android/launcher3/DropTargetBar.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package com.android.launcher3;
+
+import android.animation.TimeInterpolator;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewDebug;
+import android.view.ViewPropertyAnimator;
+import android.view.accessibility.AccessibilityManager;
+import android.view.animation.AccelerateInterpolator;
+import android.widget.LinearLayout;
+
+import com.android.launcher3.dragndrop.DragController;
+
+/*
+ * The top bar containing various drop targets: Delete/App Info/Uninstall.
+ */
+public class DropTargetBar extends LinearLayout implements DragController.DragListener {
+
+ protected static final int DEFAULT_DRAG_FADE_DURATION = 175;
+ protected static final TimeInterpolator DEFAULT_INTERPOLATOR = new AccelerateInterpolator();
+
+ private final Runnable mFadeAnimationEndRunnable = new Runnable() {
+
+ @Override
+ public void run() {
+ AccessibilityManager am = (AccessibilityManager)
+ getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
+ boolean accessibilityEnabled = am.isEnabled();
+ AlphaUpdateListener.updateVisibility(DropTargetBar.this, accessibilityEnabled);
+ }
+ };
+
+ @ViewDebug.ExportedProperty(category = "launcher")
+ protected boolean mDeferOnDragEnd;
+
+ @ViewDebug.ExportedProperty(category = "launcher")
+ protected boolean mVisible = false;
+
+ private ViewPropertyAnimator mCurrentAnimation;
+
+ // Drop targets
+ private ButtonDropTarget mDeleteDropTarget;
+ private ButtonDropTarget mAppInfoDropTarget;
+ private ButtonDropTarget mUninstallDropTarget;
+
+ public DropTargetBar(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public DropTargetBar(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+
+ // Get the individual components
+ mDeleteDropTarget = (ButtonDropTarget) findViewById(R.id.delete_target_text);
+ mAppInfoDropTarget = (ButtonDropTarget) findViewById(R.id.info_target_text);
+ mUninstallDropTarget = (ButtonDropTarget) findViewById(R.id.uninstall_target_text);
+
+ mDeleteDropTarget.setDropTargetBar(this);
+ mAppInfoDropTarget.setDropTargetBar(this);
+ mUninstallDropTarget.setDropTargetBar(this);
+
+ // Initialize with hidden state
+ setAlpha(0f);
+ }
+
+ public void setup(DragController dragController) {
+ dragController.addDragListener(this);
+ dragController.setFlingToDeleteDropTarget(mDeleteDropTarget);
+
+ dragController.addDragListener(mDeleteDropTarget);
+ dragController.addDragListener(mAppInfoDropTarget);
+ dragController.addDragListener(mUninstallDropTarget);
+
+ dragController.addDropTarget(mDeleteDropTarget);
+ dragController.addDropTarget(mAppInfoDropTarget);
+ dragController.addDropTarget(mUninstallDropTarget);
+ }
+
+ private void animateToVisibility(boolean isVisible) {
+ if (mVisible != isVisible) {
+ mVisible = isVisible;
+
+ // Cancel any existing animation
+ if (mCurrentAnimation != null) {
+ mCurrentAnimation.cancel();
+ mCurrentAnimation = null;
+ }
+
+ float finalAlpha = mVisible ? 1 : 0;
+ if (Float.compare(getAlpha(), finalAlpha) != 0) {
+ setVisibility(View.VISIBLE);
+ mCurrentAnimation = animate().alpha(finalAlpha)
+ .setInterpolator(DEFAULT_INTERPOLATOR)
+ .setDuration(DEFAULT_DRAG_FADE_DURATION)
+ .withEndAction(mFadeAnimationEndRunnable);
+ }
+
+ }
+ }
+
+ public void enableAccessibleDrag(boolean enable) {
+ mDeleteDropTarget.enableAccessibleDrag(enable);
+ mAppInfoDropTarget.enableAccessibleDrag(enable);
+ mUninstallDropTarget.enableAccessibleDrag(enable);
+ }
+
+ /*
+ * DragController.DragListener implementation
+ */
+ @Override
+ public void onDragStart(DragSource source, ItemInfo info, int dragAction) {
+ animateToVisibility(true);
+ }
+
+ /**
+ * This is called to defer hiding the delete drop target until the drop animation has completed,
+ * instead of hiding immediately when the drag has ended.
+ */
+ protected void deferOnDragEnd() {
+ mDeferOnDragEnd = true;
+ }
+
+ @Override
+ public void onDragEnd() {
+ if (!mDeferOnDragEnd) {
+ animateToVisibility(false);
+ } else {
+ mDeferOnDragEnd = false;
+ }
+ }
+}
diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java
index f99c08a59..0b9e4ac07 100644
--- a/src/com/android/launcher3/FocusHelper.java
+++ b/src/com/android/launcher3/FocusHelper.java
@@ -356,7 +356,7 @@ public class FocusHelper {
CellLayout iconLayout = (CellLayout) parent.getParent();
final Workspace workspace = (Workspace) iconLayout.getParent();
final ViewGroup dragLayer = (ViewGroup) workspace.getParent();
- final ViewGroup tabs = (ViewGroup) dragLayer.findViewById(R.id.search_drop_target_bar);
+ final ViewGroup tabs = (ViewGroup) dragLayer.findViewById(R.id.drop_target_bar);
final Hotseat hotseat = (Hotseat) dragLayer.findViewById(R.id.hotseat);
final ItemInfo itemInfo = (ItemInfo) v.getTag();
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 13690b43a..e1d292cbb 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -252,8 +252,7 @@ public class Launcher extends Activity
private View mAllAppsButton;
private View mWidgetsButton;
- private SearchDropTargetBar mSearchDropTargetBar;
- private AppInfoDropTargetBar mAppInfoDropTargetBar;
+ private DropTargetBar mDropTargetBar;
// Main container view for the all apps screen.
@Thunk AllAppsContainerView mAppsView;
@@ -435,8 +434,6 @@ public class Launcher extends Activity
setContentView(R.layout.launcher);
- app.getInvariantDeviceProfile().landscapeProfile.setSearchBarHeight(getSearchBarHeight());
- app.getInvariantDeviceProfile().portraitProfile.setSearchBarHeight(getSearchBarHeight());
setupViews();
mDeviceProfile.layout(this);
mExtractedColors = new ExtractedColors();
@@ -1374,11 +1371,7 @@ public class Launcher extends Activity
mDragController.addDragListener(mWorkspace);
// Get the search/delete/uninstall bar
- mSearchDropTargetBar = (SearchDropTargetBar)
- mDragLayer.findViewById(R.id.search_drop_target_bar);
- // Get the app info bar
- mAppInfoDropTargetBar = (AppInfoDropTargetBar)
- mDragLayer.findViewById(R.id.app_info_drop_target_bar);
+ mDropTargetBar = (DropTargetBar) mDragLayer.findViewById(R.id.drop_target_bar);
// Setup Apps and Widgets
mAppsView = (AllAppsContainerView) findViewById(R.id.apps_view);
@@ -1394,12 +1387,7 @@ public class Launcher extends Activity
mDragController.setScrollView(mDragLayer);
mDragController.setMoveTarget(mWorkspace);
mDragController.addDropTarget(mWorkspace);
- if (mSearchDropTargetBar != null) {
- mSearchDropTargetBar.setup(this, mDragController);
- }
- if (mAppInfoDropTargetBar != null) {
- mAppInfoDropTargetBar.setup(this, mDragController);
- }
+ mDropTargetBar.setup(mDragController);
if (TestingUtils.MEMORY_DUMP_ENABLED) {
TestingUtils.addWeightWatcher(this);
@@ -1808,12 +1796,8 @@ public class Launcher extends Activity
return mOverviewPanel;
}
- public SearchDropTargetBar getSearchDropTargetBar() {
- return mSearchDropTargetBar;
- }
-
- public AppInfoDropTargetBar getAppInfoDropTargetBar() {
- return mAppInfoDropTargetBar;
+ public DropTargetBar getDropTargetBar() {
+ return mDropTargetBar;
}
public LauncherAppWidgetHost getAppWidgetHost() {
@@ -4039,11 +4023,6 @@ public class Launcher extends Activity
return mDeviceProfile.isVerticalBarLayout();
}
- /** Returns the search bar bounds in pixels. */
- protected Rect getSearchBarBounds() {
- return mDeviceProfile.getSearchBarBounds(Utilities.isRtl(getResources()));
- }
-
public int getSearchBarHeight() {
if (mLauncherCallbacks != null) {
return mLauncherCallbacks.getSearchBarHeight();
diff --git a/src/com/android/launcher3/LauncherAppWidgetProviderInfo.java b/src/com/android/launcher3/LauncherAppWidgetProviderInfo.java
index 28d805269..f245cd3e7 100644
--- a/src/com/android/launcher3/LauncherAppWidgetProviderInfo.java
+++ b/src/com/android/launcher3/LauncherAppWidgetProviderInfo.java
@@ -63,9 +63,8 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo {
LauncherAppState app = LauncherAppState.getInstance();
InvariantDeviceProfile idp = app.getInvariantDeviceProfile();
- // We only care out the cell size, which is independent of the the layout direction.
- Rect paddingLand = idp.landscapeProfile.getWorkspacePadding(false /* isLayoutRtl */);
- Rect paddingPort = idp.portraitProfile.getWorkspacePadding(false /* isLayoutRtl */);
+ Rect paddingLand = idp.landscapeProfile.getWorkspacePadding();
+ Rect paddingPort = idp.portraitProfile.getWorkspacePadding();
// Always assume we're working with the smallest span to make sure we
// reserve enough space in both orientations.
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index 41e30b129..b40917408 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -460,12 +460,6 @@ public class LauncherStateTransitionAnimation {
Animator workspaceAnim = mLauncher.startWorkspaceStateChangeAnimation(toWorkspaceState,
animated, layerViews);
- // Animate the search bar
- final SearchDropTargetBar.State toSearchBarState =
- toWorkspaceState.searchDropTargetBarState;
- mLauncher.getSearchDropTargetBar().animateToState(toSearchBarState,
- animated ? revealDuration : 0, animation);
-
if (animated && initialized) {
// Play the workspace animation
if (workspaceAnim != null) {
diff --git a/src/com/android/launcher3/SearchDropTargetBar.java b/src/com/android/launcher3/SearchDropTargetBar.java
deleted file mode 100644
index e43e96c76..000000000
--- a/src/com/android/launcher3/SearchDropTargetBar.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-package com.android.launcher3;
-
-import android.animation.AnimatorSet;
-import android.animation.ObjectAnimator;
-import android.animation.TimeInterpolator;
-import android.content.Context;
-import android.graphics.Rect;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewDebug;
-import android.view.animation.DecelerateInterpolator;
-
-import com.android.launcher3.dragndrop.DragController;
-import com.android.launcher3.util.Thunk;
-
-/*
- * This bar will manage the transition between the QSB search bar and the delete/uninstall drop
- * targets so that each of the individual ButtonDropTargets don't have to.
- */
-public class SearchDropTargetBar extends BaseDropTargetBar {
-
- /** The different states that the search bar space can be in. */
- public enum State {
- INVISIBLE (0f),
- DROP_TARGET (1f);
-
- private final float mDropTargetBarAlpha;
-
- State(float dtbAlpha) {
- mDropTargetBarAlpha = dtbAlpha;
- }
- }
-
-
- @ViewDebug.ExportedProperty(category = "launcher")
- private State mState = State.INVISIBLE;
-
- // Drop targets
- private ButtonDropTarget mDeleteDropTarget;
- private ButtonDropTarget mUninstallDropTarget;
-
- public SearchDropTargetBar(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SearchDropTargetBar(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
-
- // Get the individual components
- mDeleteDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.delete_target_text);
- mUninstallDropTarget = (ButtonDropTarget) mDropTargetBar
- .findViewById(R.id.uninstall_target_text);
-
- mDeleteDropTarget.setDropTargetBar(this);
- mUninstallDropTarget.setDropTargetBar(this);
- }
-
- @Override
- public void setup(Launcher launcher, DragController dragController) {
- dragController.addDragListener(this);
- dragController.setFlingToDeleteDropTarget(mDeleteDropTarget);
-
- dragController.addDragListener(mDeleteDropTarget);
- dragController.addDragListener(mUninstallDropTarget);
-
- dragController.addDropTarget(mDeleteDropTarget);
- dragController.addDropTarget(mUninstallDropTarget);
-
- mDeleteDropTarget.setLauncher(launcher);
- mUninstallDropTarget.setLauncher(launcher);
- }
-
- @Override
- public void showDropTargets() {
- animateToState(State.DROP_TARGET, DEFAULT_DRAG_FADE_DURATION);
- }
-
- @Override
- public void hideDropTargets() {
- animateToState(State.INVISIBLE, DEFAULT_DRAG_FADE_DURATION);
- }
-
- /**
- * Animates the current search bar state to a new state. If the {@param duration} is 0, then
- * the state is applied immediately.
- */
- public void animateToState(State newState, int duration) {
- animateToState(newState, duration, null);
- }
-
- public void animateToState(State newState, int duration, AnimatorSet animation) {
- if (mState != newState) {
- mState = newState;
-
- resetAnimation(duration);
- if (duration > 0) {
- animateAlpha(mDropTargetBar, mState.mDropTargetBarAlpha, DEFAULT_INTERPOLATOR);
- } else {
- mDropTargetBar.setAlpha(mState.mDropTargetBarAlpha);
- AlphaUpdateListener.updateVisibility(mDropTargetBar, mAccessibilityEnabled);
- }
-
- // Start the final animation
- if (duration > 0) {
- if (animation != null) {
- animation.play(mCurrentAnimation);
- } else {
- mCurrentAnimation.start();
- }
- }
- }
- }
-
- @Override
- public void enableAccessibleDrag(boolean enable) {
- mDeleteDropTarget.enableAccessibleDrag(enable);
- mUninstallDropTarget.enableAccessibleDrag(enable);
- }
-}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index da262cac6..dd487fd93 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -176,26 +176,22 @@ public class Workspace extends PagedView
private Matrix mTempMatrix = new Matrix();
private SpringLoadedDragController mSpringLoadedDragController;
- private float mSpringLoadedShrinkFactor;
private float mOverviewModeShrinkFactor;
// State variable that indicates whether the pages are small (ie when you're
// in all apps or customize mode)
enum State {
- NORMAL (SearchDropTargetBar.State.INVISIBLE, false, false),
- NORMAL_HIDDEN (SearchDropTargetBar.State.INVISIBLE, false, false),
- SPRING_LOADED (SearchDropTargetBar.State.DROP_TARGET, false, true),
- OVERVIEW (SearchDropTargetBar.State.INVISIBLE, true, true),
- OVERVIEW_HIDDEN (SearchDropTargetBar.State.INVISIBLE, true, false);
+ NORMAL (false, false),
+ NORMAL_HIDDEN (false, false),
+ SPRING_LOADED (false, true),
+ OVERVIEW (true, true),
+ OVERVIEW_HIDDEN (true, false);
- public final SearchDropTargetBar.State searchDropTargetBarState;
public final boolean shouldUpdateWidget;
public final boolean hasMultipleVisiblePages;
- State(SearchDropTargetBar.State searchBarState, boolean shouldUpdateWidget,
- boolean hasMultipleVisiblePages) {
- searchDropTargetBarState = searchBarState;
+ State(boolean shouldUpdateWidget, boolean hasMultipleVisiblePages) {
this.shouldUpdateWidget = shouldUpdateWidget;
this.hasMultipleVisiblePages = hasMultipleVisiblePages;
}
@@ -316,9 +312,6 @@ public class Workspace extends PagedView
mWallpaperManager = WallpaperManager.getInstance(context);
mWallpaperOffset = new WallpaperOffsetInterpolator(this);
-
- mSpringLoadedShrinkFactor =
- res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
mOverviewModeShrinkFactor =
res.getInteger(R.integer.config_workspaceOverviewShrinkPercentage) / 100f;
@@ -347,6 +340,7 @@ public class Workspace extends PagedView
// estimate the size of a widget with spans hSpan, vSpan. return MAX_VALUE for each
// dimension if unsuccessful
public int[] estimateItemSize(ItemInfo itemInfo, boolean springLoaded) {
+ float shrinkFactor = mLauncher.getDeviceProfile().workspaceSpringLoadShrinkFactor;
int[] size = new int[2];
if (getChildCount() > 0) {
// Use the first non-custom page to estimate the child position
@@ -355,8 +349,8 @@ public class Workspace extends PagedView
size[0] = r.width();
size[1] = r.height();
if (springLoaded) {
- size[0] *= mSpringLoadedShrinkFactor;
- size[1] *= mSpringLoadedShrinkFactor;
+ size[0] *= shrinkFactor;
+ size[1] *= shrinkFactor;
}
return size;
} else {
@@ -1380,7 +1374,6 @@ public class Workspace extends PagedView
// TODO(adamcohen): figure out a final effect here. We may need to recommend
// different effects based on device performance. On at least one relatively high-end
// device I've tried, translating the launcher causes things to get quite laggy.
- setTranslationAndAlpha(mLauncher.getSearchDropTargetBar(), transX, alpha);
setTranslationAndAlpha(getPageIndicator(), transX, alpha);
setTranslationAndAlpha(getChildAt(getCurrentPage()), transX, alpha);
setTranslationAndAlpha(mLauncher.getHotseat(), transX, alpha);
@@ -1536,8 +1529,7 @@ public class Workspace extends PagedView
// Reset our click listener
setOnClickListener(mLauncher);
}
- mLauncher.getSearchDropTargetBar().enableAccessibleDrag(enable);
- mLauncher.getAppInfoDropTargetBar().enableAccessibleDrag(enable);
+ mLauncher.getDropTargetBar().enableAccessibleDrag(enable);
mLauncher.getHotseat().getLayout()
.enableAccessibleDrag(enable, CellLayout.WORKSPACE_ACCESSIBILITY_DRAG);
}
@@ -1938,7 +1930,7 @@ public class Workspace extends PagedView
int getOverviewModeTranslationY() {
DeviceProfile grid = mLauncher.getDeviceProfile();
- Rect workspacePadding = grid.getWorkspacePadding(Utilities.isRtl(getResources()));
+ Rect workspacePadding = grid.getWorkspacePadding();
int overviewButtonBarHeight = grid.getOverviewModeButtonBarHeight();
int scaledHeight = (int) (mOverviewModeShrinkFactor * getNormalChildHeight());
@@ -1951,15 +1943,26 @@ public class Workspace extends PagedView
return -workspaceOffsetTopEdge + overviewOffsetTopEdge;
}
- int getSpringLoadedTranslationY() {
+ float getSpringLoadedTranslationY() {
DeviceProfile grid = mLauncher.getDeviceProfile();
- Rect workspacePadding = grid.getWorkspacePadding(Utilities.isRtl(getResources()));
- int scaledHeight = (int) (mSpringLoadedShrinkFactor * getNormalChildHeight());
- int workspaceTop = mInsets.top + workspacePadding.top;
- int workspaceBottom = getViewportHeight() - mInsets.bottom - workspacePadding.bottom;
- int workspaceHeight = workspaceBottom - workspaceTop;
- // Center the spring-loaded pages by translating it up by half of the reduced height.
- return -(workspaceHeight - scaledHeight) / 2;
+ if (grid.isVerticalBarLayout() || getChildCount() == 0) {
+ return 0;
+ }
+ Rect workspacePadding = grid.getWorkspacePadding();
+
+ float scaledHeight = grid.workspaceSpringLoadShrinkFactor * getNormalChildHeight();
+ float shrunkTop = mInsets.top + grid.dropTargetBarSizePx;
+ float shrunkBottom = getViewportHeight() - mInsets.bottom
+ - workspacePadding.bottom - grid.workspaceSpringLoadedBottomSpace;
+ float totalShrunkSpace = shrunkBottom - shrunkTop;
+
+ float desiredCellTop = shrunkTop + (totalShrunkSpace - scaledHeight) / 2;
+
+ float halfHeight = getHeight() / 2;
+ float myCenter = getTop() + halfHeight;
+ float cellTopFromCenter = halfHeight - getChildAt(0).getTop();
+ float actualCellTop = myCenter - cellTopFromCenter * grid.workspaceSpringLoadShrinkFactor;
+ return (desiredCellTop - actualCellTop) / grid.workspaceSpringLoadShrinkFactor;
}
float getOverviewModeShrinkFactor() {
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index e26864087..0f437c1f9 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -211,8 +211,7 @@ public class WorkspaceStateTransitionAnimation {
mOverviewTransitionTime = res.getInteger(R.integer.config_overviewTransitionTime);
mOverlayTransitionTime = res.getInteger(R.integer.config_overlayTransitionTime);
mSpringLoadedTransitionTime = mOverlayTransitionTime / 2;
- mSpringLoadedShrinkFactor =
- res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100f;
+ mSpringLoadedShrinkFactor = mLauncher.getDeviceProfile().workspaceSpringLoadShrinkFactor;
mOverviewModeShrinkFactor =
res.getInteger(R.integer.config_workspaceOverviewShrinkPercentage) / 100f;
mWorkspaceScrimAlpha = res.getInteger(R.integer.config_workspaceScrimAlpha) / 100f;
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index e4c84360c..94cce4449 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -29,7 +29,6 @@ import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.DragEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -52,7 +51,7 @@ import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppWidgetHostView;
import com.android.launcher3.PinchToOverviewListener;
import com.android.launcher3.R;
-import com.android.launcher3.SearchDropTargetBar;
+import com.android.launcher3.DropTargetBar;
import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
@@ -184,31 +183,17 @@ public class DragLayer extends InsettableFrameLayout {
private boolean isEventOverFolderTextRegion(Folder folder, MotionEvent ev) {
getDescendantRectRelativeToSelf(folder.getEditTextRegion(), mHitRect);
- if (mHitRect.contains((int) ev.getX(), (int) ev.getY())) {
- return true;
- }
- return false;
+ return mHitRect.contains((int) ev.getX(), (int) ev.getY());
}
private boolean isEventOverFolder(Folder folder, MotionEvent ev) {
getDescendantRectRelativeToSelf(folder, mHitRect);
- if (mHitRect.contains((int) ev.getX(), (int) ev.getY())) {
- return true;
- }
- return false;
+ return mHitRect.contains((int) ev.getX(), (int) ev.getY());
}
private boolean isEventOverDropTargetBar(MotionEvent ev) {
- getDescendantRectRelativeToSelf(mLauncher.getSearchDropTargetBar(), mHitRect);
- if (mHitRect.contains((int) ev.getX(), (int) ev.getY())) {
- return true;
- }
-
- getDescendantRectRelativeToSelf(mLauncher.getAppInfoDropTargetBar(), mHitRect);
- if (mHitRect.contains((int) ev.getX(), (int) ev.getY())) {
- return true;
- }
- return false;
+ getDescendantRectRelativeToSelf(mLauncher.getDropTargetBar(), mHitRect);
+ return mHitRect.contains((int) ev.getX(), (int) ev.getY());
}
private boolean handleTouchDown(MotionEvent ev, boolean intercept) {
@@ -356,7 +341,7 @@ public class DragLayer extends InsettableFrameLayout {
return super.onRequestSendAccessibilityEvent(child, event);
}
- if (isInAccessibleDrag() && child instanceof SearchDropTargetBar) {
+ if (isInAccessibleDrag() && child instanceof DropTargetBar) {
return super.onRequestSendAccessibilityEvent(child, event);
}
// Skip propagating onRequestSendAccessibilityEvent all for other children
@@ -374,8 +359,7 @@ public class DragLayer extends InsettableFrameLayout {
childrenForAccessibility.add(currentFolder);
if (isInAccessibleDrag()) {
- childrenForAccessibility.add(mLauncher.getSearchDropTargetBar());
- childrenForAccessibility.add(mLauncher.getAppInfoDropTargetBar());
+ childrenForAccessibility.add(mLauncher.getDropTargetBar());
}
} else {
super.addChildrenForAccessibility(childrenForAccessibility);
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 6df296e7d..af9370773 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -318,7 +318,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
@Override
public void enableAccessibleDrag(boolean enable) {
- mLauncher.getSearchDropTargetBar().enableAccessibleDrag(enable);
+ mLauncher.getDropTargetBar().enableAccessibleDrag(enable);
for (int i = 0; i < mContent.getChildCount(); i++) {
mContent.getPageAt(i).enableAccessibleDrag(enable, CellLayout.FOLDER_ACCESSIBILITY_DRAG);
}
@@ -1054,7 +1054,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
int top = Math.min(Math.max(sTempRect.top, centeredTop),
sTempRect.top + sTempRect.height() - height);
- int distFromEdgeOfScreen = grid.getWorkspacePadding(isLayoutRtl()).left + getPaddingLeft();
+ int distFromEdgeOfScreen = grid.getWorkspacePadding().left + getPaddingLeft();
if (grid.isPhone && (grid.availableWidthPx - width) < 4 * distFromEdgeOfScreen) {
// Center the folder if it is very close to being centered anyway, by virtue of
@@ -1093,7 +1093,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
private int getContentAreaHeight() {
DeviceProfile grid = mLauncher.getDeviceProfile();
- Rect workspacePadding = grid.getWorkspacePadding(mContent.mIsRtl);
+ Rect workspacePadding = grid.getWorkspacePadding();
int maxContentAreaHeight = grid.availableHeightPx -
workspacePadding.top - workspacePadding.bottom -
mFooterHeight;
diff --git a/tests/src/com/android/launcher3/InvariantDeviceProfileTest.java b/tests/src/com/android/launcher3/InvariantDeviceProfileTest.java
index 476eb0afb..35f686f55 100644
--- a/tests/src/com/android/launcher3/InvariantDeviceProfileTest.java
+++ b/tests/src/com/android/launcher3/InvariantDeviceProfileTest.java
@@ -116,75 +116,4 @@ public class InvariantDeviceProfileTest extends AndroidTestCase {
// Add more tests for other devices, however, running them once on a single device is enough
// for verifying that for a platform version, the WindowManager and DisplayMetrics is
// working as intended.
-
- /**
- * Make sure that the height for the QSB is what we expect in normal mode.
- */
- public void testQsbNormalHeight() {
- Resources resources = getContext().getResources();
- DeviceProfile landscapeProfile = mInvariantProfile.landscapeProfile;
- DeviceProfile portraitProfile = mInvariantProfile.portraitProfile;
- landscapeProfile.setSearchBarHeight(LauncherCallbacks.SEARCH_BAR_HEIGHT_NORMAL);
- portraitProfile.setSearchBarHeight(LauncherCallbacks.SEARCH_BAR_HEIGHT_NORMAL);
- Rect portraitBounds = portraitProfile.getSearchBarBounds(true); // RTL shouldn't matter.
- int portraitHeight = (int) Utilities.dpiFromPx(portraitBounds.height(),
- resources.getDisplayMetrics());
- Rect landscapeBounds = landscapeProfile.getSearchBarBounds(true); // RTL shouldn't matter.
- int landscapeHeight = (int) Utilities.dpiFromPx(landscapeBounds.height(),
- resources.getDisplayMetrics());
- if (portraitProfile.isTablet) {
- assertEquals(8 + 48 + 24, portraitHeight);
- } else {
- assertEquals(8 + 48 + 12, portraitHeight);
- }
- // Make sure the height that we pass in the widget options bundle is the height of the
- // search bar + 8dps padding top and bottom.
- Point portraitDimens = portraitProfile.getSearchBarDimensForWidgetOpts(resources);
- int portraitWidgetOptsHeight = portraitDimens.y;
- Point landscapeDimens = landscapeProfile.getSearchBarDimensForWidgetOpts(resources);
- int landscapeWidgetOptsHeight = landscapeDimens.y;
- assertEquals(8 + 48 + 8, (int) Utilities.dpiFromPx(portraitWidgetOptsHeight,
- resources.getDisplayMetrics()));
- if (!landscapeProfile.isVerticalBarLayout()) {
- assertEquals(portraitHeight, landscapeHeight);
- assertEquals(portraitWidgetOptsHeight, landscapeWidgetOptsHeight);
- }
- }
-
- /**
- * Make sure that the height for the QSB is what we expect in tall mode.
- */
- public void testQsbTallHeight() {
- Resources resources = getContext().getResources();
- DeviceProfile landscapeProfile = mInvariantProfile.landscapeProfile;
- DeviceProfile portraitProfile = mInvariantProfile.portraitProfile;
- landscapeProfile.setSearchBarHeight(LauncherCallbacks.SEARCH_BAR_HEIGHT_TALL);
- portraitProfile.setSearchBarHeight(LauncherCallbacks.SEARCH_BAR_HEIGHT_TALL);
- Rect portraitBounds = portraitProfile.getSearchBarBounds(true); // RTL shouldn't matter.
- int portraitHeight = (int) Utilities.dpiFromPx(portraitBounds.height(),
- resources.getDisplayMetrics());
- Rect landscapeBounds = landscapeProfile.getSearchBarBounds(true); // RTL shouldn't matter.
- int landscapeHeight = (int) Utilities.dpiFromPx(landscapeBounds.height(),
- resources.getDisplayMetrics());
- if (portraitProfile.isPhone) {
- // This fails on some devices due to http://b/26884580 (portraitHeight is 101, not 100).
- // TODO: Remove the comparision against 101 once b/26884580 is fixed
- // assertEquals(4 + 94 + 2, portraitHeight);
- assertTrue(portraitHeight == (4 + 94 + 2) || portraitHeight == (4 + 95 + 2));
- } else {
- assertEquals(8 + 94 + 24, portraitHeight);
- }
- // Make sure the height that we pass in the widget options bundle is the height of the
- // search bar + 8dps padding top and bottom.
- Point portraitDimens = portraitProfile.getSearchBarDimensForWidgetOpts(resources);
- int portraitWidgetOptsHeight = portraitDimens.y;
- Point landscapeDimens = landscapeProfile.getSearchBarDimensForWidgetOpts(resources);
- int landscapeWidgetOptsHeight = landscapeDimens.y;
- assertEquals(8 + 94 + 8, (int) Utilities.dpiFromPx(portraitWidgetOptsHeight,
- resources.getDisplayMetrics()));
- if (!landscapeProfile.isVerticalBarLayout()) {
- assertEquals(portraitHeight, landscapeHeight);
- assertEquals(portraitWidgetOptsHeight, landscapeWidgetOptsHeight);
- }
- }
}