OSDN Git Service

Refactoring layout of launcher
authorMichael Jurka <mikejurka@google.com>
Sat, 19 Feb 2011 03:22:12 +0000 (19:22 -0800)
committerMichael Jurka <mikejurka@google.com>
Thu, 24 Feb 2011 03:48:35 +0000 (19:48 -0800)
- Only one layout of launcher for landspace/portrait now
- Programmatically vertically centering the shrunken workspace screens rather than using a custom value

Change-Id: Ib689b4031f122b9a1b2bc1ca711b91320619bebd

res/layout-xlarge-port/launcher.xml [deleted file]
res/layout-xlarge/launcher.xml [moved from res/layout-xlarge-land/launcher.xml with 97% similarity]
res/values-xlarge-land/dimens.xml
res/values-xlarge-port/dimens.xml
res/values-xlarge/dimens.xml
src/com/android/launcher2/Launcher.java
src/com/android/launcher2/Workspace.java

diff --git a/res/layout-xlarge-port/launcher.xml b/res/layout-xlarge-port/launcher.xml
deleted file mode 100644 (file)
index 4c83fda..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.launcher2.DragLayer
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
-
-    android:id="@+id/drag_layer"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
-
-    <!-- The workspace contains 5 screens of cells -->
-    <com.android.launcher2.Workspace
-        android:id="@+id/workspace"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:paddingTop="?android:attr/actionBarSize"
-        android:paddingBottom="10dp"
-        launcher:defaultScreen="2"
-        launcher:cellCountX="8"
-        launcher:cellCountY="7"
-        launcher:pageSpacing="64dp">
-
-        <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
-        <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
-        <include android:id="@+id/cell3" layout="@layout/workspace_screen" />
-        <include android:id="@+id/cell4" layout="@layout/workspace_screen" />
-        <include android:id="@+id/cell5" layout="@layout/workspace_screen" />
-    </com.android.launcher2.Workspace>
-
-    <include
-        layout="@layout/all_apps_tabbed"
-        android:id="@+id/all_apps_view"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_gravity="top" />
-
-    <RelativeLayout
-        android:id="@+id/all_apps_button_cluster"
-        android:layout_width="fill_parent"
-        android:layout_height="?android:attr/actionBarSize"
-        android:layout_gravity="top">
-
-       <!-- Global search icon -->
-       <ImageView
-           android:id="@+id/search_button"
-           android:layout_width="wrap_content"
-           android:layout_height="wrap_content"
-           android:layout_alignParentTop="true"
-           android:layout_alignParentLeft="true"
-           android:paddingLeft="@dimen/toolbar_button_horizontal_padding"
-           android:paddingRight="@dimen/toolbar_button_horizontal_padding"
-           android:paddingTop="@dimen/toolbar_button_vertical_padding"
-           android:paddingBottom="@dimen/toolbar_button_vertical_padding"
-           android:src="@drawable/ic_generic_search"
-           android:background="@drawable/button_bg"
-           android:onClick="onClickSearchButton"
-           android:focusable="true"
-           android:clickable="true" />
-           
-        <ImageView
-            android:id="@+id/search_divider"
-            android:src="@drawable/divider_launcher_holo"
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:layout_toRightOf="@id/search_button"
-            android:paddingTop="@dimen/toolbar_button_vertical_padding"
-            android:paddingBottom="@dimen/toolbar_button_vertical_padding"
-
-            android:onClick="onClickSearchButton"
-            android:focusable="false"
-            android:clickable="true" />
-
-        <!-- Voice search icon -->
-        <ImageView
-            android:id="@+id/voice_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_toRightOf="@id/search_divider"
-            android:paddingLeft="@dimen/toolbar_button_horizontal_padding"
-            android:paddingRight="@dimen/toolbar_button_horizontal_padding"
-            android:paddingTop="@dimen/toolbar_button_vertical_padding"
-            android:paddingBottom="@dimen/toolbar_button_vertical_padding"
-            android:src="@drawable/ic_voice_search"
-            android:background="@drawable/button_bg"
-            android:onClick="onClickVoiceButton"
-            android:focusable="true"
-            android:clickable="true"/>
-
-        <ImageView
-            android:id="@+id/configure_button"
-            android:src="@drawable/ic_home_add_holo_dark"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentTop="true"
-            android:layout_alignParentRight="true"
-            android:paddingLeft="@dimen/toolbar_button_horizontal_padding"
-            android:paddingRight="@dimen/toolbar_button_horizontal_padding"
-            android:paddingTop="@dimen/toolbar_button_vertical_padding"
-            android:paddingBottom="@dimen/toolbar_button_vertical_padding"
-            android:background="@drawable/button_bg"
-
-            android:focusable="true"
-            android:clickable="true" />
-        <ImageView
-            android:id="@+id/divider"
-            android:src="@drawable/divider_launcher_holo"
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:layout_toLeftOf="@id/configure_button"
-            android:paddingTop="@dimen/toolbar_button_vertical_padding"
-            android:paddingBottom="@dimen/toolbar_button_vertical_padding"
-
-            android:focusable="false"
-            android:clickable="true" />
-        <TextView
-            android:id="@+id/all_apps_button"
-            android:text="@string/all_apps_button_label"
-            android:drawablePadding="@dimen/all_apps_button_drawable_padding"
-            android:drawableLeft="@drawable/ic_home_all_apps_holo_dark"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_toLeftOf="@id/divider"
-            android:paddingLeft="@dimen/toolbar_button_horizontal_padding"
-            android:paddingRight="@dimen/toolbar_button_horizontal_padding"
-            android:paddingTop="@dimen/all_apps_button_vertical_padding"
-            android:paddingBottom="@dimen/all_apps_button_vertical_padding"
-            android:background="@drawable/button_bg"
-            
-            android:gravity="center_horizontal|center_vertical"
-            android:textColor="#CCFFFFFF"
-            android:textSize="18sp"
-
-            android:shadowColor="#DA000000"
-            android:shadowDx="0.0"
-            android:shadowDy="0.0"
-            android:shadowRadius="2.5"
-
-            android:focusable="true"
-            android:clickable="true" />
-        <ImageView
-            android:id="@+id/divider_during_drag"
-            android:src="@drawable/divider_launcher_holo"
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:layout_toLeftOf="@id/configure_button"
-            android:paddingTop="@dimen/toolbar_button_vertical_padding"
-            android:paddingBottom="@dimen/toolbar_button_vertical_padding"
-            android:visibility="gone"/>
-        <com.android.launcher2.DeleteZone
-            android:id="@+id/delete_zone"
-            android:text="@string/delete_zone_label_workspace"
-            android:drawablePadding="@dimen/delete_zone_drawable_padding"
-            android:drawableLeft="@drawable/delete_zone_selector"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignRight="@id/configure_button"
-            android:paddingLeft="@dimen/toolbar_button_horizontal_padding"
-            android:paddingRight="@dimen/toolbar_button_horizontal_padding"
-            android:paddingTop="@dimen/toolbar_button_vertical_padding"
-            android:paddingBottom="@dimen/toolbar_button_vertical_padding"
-            android:background="@drawable/button_bg"
-
-            android:gravity="center_horizontal|center_vertical"
-            android:textColor="@color/workspace_all_apps_and_delete_zone_text_color"
-            android:textSize="18sp"
-            android:shadowColor="@color/workspace_all_apps_and_delete_zone_text_shadow_color"
-            android:shadowDx="0.0"
-            android:shadowDy="0.0"
-            android:shadowRadius="2.0"
-
-            android:visibility="gone"
-            launcher:direction="horizontal" />
-    </RelativeLayout>
-
-    <TabHost
-        android:id="@+id/customization_drawer"
-        android:layout_width="match_parent"
-        android:layout_height="800dp"
-        android:layout_gravity="bottom">
-        <LinearLayout
-            android:orientation="vertical"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent">
-            <TabWidget
-                android:id="@android:id/tabs"
-                android:layout_width="700dp"
-                android:layout_height="wrap_content"
-                android:layout_gravity="center_horizontal"
-                android:background="@drawable/tab_unselected_holo"
-                android:tabStripEnabled="false" />
-            <FrameLayout
-                android:id="@android:id/tabcontent"
-                android:layout_width="match_parent"
-                android:layout_height="650dp">
-             </FrameLayout>
-          </LinearLayout>
-    </TabHost>
-</com.android.launcher2.DragLayer>
similarity index 97%
rename from res/layout-xlarge-land/launcher.xml
rename to res/layout-xlarge/launcher.xml
index 590787f..7f2b8e1 100644 (file)
@@ -32,7 +32,7 @@
         launcher:defaultScreen="2"
         launcher:cellCountX="8"
         launcher:cellCountY="7"
-        launcher:pageSpacing="50dp">
+        launcher:pageSpacing="@dimen/workspace_page_spacing">
 
         <include android:id="@+id/cell1" layout="@layout/workspace_screen" />
         <include android:id="@+id/cell2" layout="@layout/workspace_screen" />
@@ -70,7 +70,7 @@
            android:onClick="onClickSearchButton"
            android:focusable="true"
            android:clickable="true" />
-           
+
         <ImageView
             android:id="@+id/search_divider"
             android:src="@drawable/divider_launcher_holo"
             android:paddingTop="@dimen/all_apps_button_vertical_padding"
             android:paddingBottom="@dimen/all_apps_button_vertical_padding"
             android:background="@drawable/button_bg"
-            
+
             android:gravity="center_horizontal|center_vertical"
             android:textColor="#CCFFFFFF"
             android:textSize="18sp"
             android:layout_toLeftOf="@id/configure_button"
             android:paddingTop="@dimen/toolbar_button_vertical_padding"
             android:paddingBottom="@dimen/toolbar_button_vertical_padding"
-            android:visibility="gone"/>
+            android:visibility="gone" />
         <com.android.launcher2.DeleteZone
             android:id="@+id/delete_zone"
             android:text="@string/delete_zone_label_workspace"
     <TabHost
         android:id="@+id/customization_drawer"
         android:layout_width="match_parent"
-        android:layout_height="480dp"
+        android:layout_height="@dimen/customization_drawer_height"
         android:layout_gravity="bottom">
         <LinearLayout
             android:orientation="vertical"
             android:layout_height="match_parent">
             <TabWidget
                 android:id="@android:id/tabs"
-                android:layout_width="952dp"
+                android:layout_width="@dimen/customization_drawer_tab_widget_width"
                 android:layout_height="wrap_content"
                 android:layout_gravity="center_horizontal"
                 android:background="@drawable/tab_unselected_holo"
index 51037f5..ccea6eb 100644 (file)
@@ -22,4 +22,9 @@
     <!-- Width/height gap overrides for the workspace -->
     <dimen name="workspace_width_gap">32dp</dimen>
     <dimen name="workspace_height_gap">2dp</dimen>
+
+    <dimen name="workspace_page_spacing">50dp</dimen>
+
+    <dimen name="customization_drawer_height">480dp</dimen>
+    <dimen name="customization_drawer_tab_widget_width">952dp</dimen>
 </resources>
\ No newline at end of file
index baa31aa..eca8f44 100644 (file)
@@ -22,4 +22,9 @@
     <!-- Width/height gap overrides for the workspace -->
     <dimen name="workspace_width_gap">0dp</dimen>
     <dimen name="workspace_height_gap">32dp</dimen>
+
+    <dimen name="workspace_page_spacing">64dp</dimen>
+
+    <dimen name="customization_drawer_height">800dp</dimen>
+    <dimen name="customization_drawer_tab_widget_width">700dp</dimen>
 </resources>
\ No newline at end of file
index c4988e4..421c9e3 100644 (file)
     <dimen name="allAppsSmallScreenVerticalMarginLandscape">30dip</dimen>
     <dimen name="allAppsSmallScreenVerticalMarginPortrait">60dip</dimen>
 
-    <!-- Vertical spacing between edge of screen and mini cell layouts when they
-         are minimized to the top when the customization drawer is showing -->
-    <dimen name="customizeSmallScreenVerticalMarginLandscape">90dip</dimen>
-    <dimen name="customizeSmallScreenVerticalMarginPortrait">180dip</dimen>
-
     <dimen name="delete_zone_drawable_padding">8dip</dimen>
     <dimen name="all_apps_button_drawable_padding">0dip</dimen>
     <dimen name="all_apps_button_vertical_padding">4dip</dimen>
index 55680f4..7920472 100644 (file)
@@ -2427,6 +2427,10 @@ public final class Launcher extends Activity
         return mWorkspace;
     }
 
+    TabHost getCustomizationDrawer() {
+        return mHomeCustomizationDrawer;
+    }
+
     @Override
     protected Dialog onCreateDialog(int id) {
         switch (id) {
index 38471df..fe54ae7 100644 (file)
@@ -23,7 +23,6 @@ import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
 import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
-import android.animation.PropertyValuesHolder;
 import android.animation.TimeInterpolator;
 import android.animation.ValueAnimator;
 import android.animation.Animator.AnimatorListener;
@@ -62,6 +61,8 @@ import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.DecelerateInterpolator;
+import android.widget.TabHost;
+import android.widget.TabWidget;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -1327,6 +1328,19 @@ public class Workspace extends SmoothPagedView
         shrink(shrinkState, true);
     }
 
+    private int getCustomizeDrawerHeight() {
+        TabHost customizationDrawer = mLauncher.getCustomizationDrawer();
+        int height = customizationDrawer.getHeight();
+        TabWidget tabWidget = (TabWidget)
+            customizationDrawer.findViewById(com.android.internal.R.id.tabs);
+        if (tabWidget.getTabCount() > 0) {
+            TextView tabText = (TextView) tabWidget.getChildTabViewAt(0);
+            // subtract the empty space above the tab text
+            height -= ((tabWidget.getHeight() - tabText.getLineHeight())) / 2;
+        }
+        return height;
+    }
+
     // we use this to shrink the workspace for the all apps view and the customize view
     public void shrink(ShrinkState shrinkState, boolean animated) {
         // In the launcher interaction model, we're never in the state where we're shrunken and
@@ -1403,9 +1417,7 @@ public class Workspace extends SmoothPagedView
             y = screenHeight / 2 - scaledPageHeight / 2;
             finalAlpha = 1.0f;
         } else if (shrinkState == ShrinkState.TOP) {
-            y = (isPortrait ?
-                getResources().getDimension(R.dimen.customizeSmallScreenVerticalMarginPortrait) :
-                getResources().getDimension(R.dimen.customizeSmallScreenVerticalMarginLandscape));
+            y = (screenHeight - getCustomizeDrawerHeight() - scaledPageHeight) / 2;
         }
 
         int duration;