summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable-hdpi/cling.pngbin0 -> 57394 bytes
-rw-r--r--res/drawable-mdpi/cling.pngbin0 -> 32299 bytes
-rw-r--r--res/drawable-xhdpi/cling.pngbin0 -> 94777 bytes
-rw-r--r--res/drawable/cling_button_bg.xml20
-rw-r--r--res/layout-land/all_apps_cling.xml44
-rw-r--r--res/layout-land/launcher.xml6
-rw-r--r--res/layout-land/workspace_cling.xml51
-rw-r--r--res/layout-large-land/all_apps_cling.xml43
-rw-r--r--res/layout-large-land/workspace_cling.xml54
-rw-r--r--res/layout-large-port/all_apps_cling.xml44
-rw-r--r--res/layout-large-port/workspace_cling.xml54
-rw-r--r--res/layout-large/launcher.xml6
-rw-r--r--res/layout-port/all_apps_cling.xml45
-rw-r--r--res/layout-port/launcher.xml6
-rw-r--r--res/layout-port/workspace_cling.xml51
-rw-r--r--res/layout/apps_customize_pane.xml10
-rw-r--r--res/values/attrs.xml7
-rw-r--r--res/values/colors.xml3
-rw-r--r--res/values/dimens.xml3
-rw-r--r--res/values/strings.xml16
-rw-r--r--res/values/styles.xml29
-rw-r--r--src/com/android/launcher2/Cling.java303
-rw-r--r--src/com/android/launcher2/Launcher.java53
23 files changed, 845 insertions, 3 deletions
diff --git a/res/drawable-hdpi/cling.png b/res/drawable-hdpi/cling.png
new file mode 100644
index 000000000..d60579940
--- /dev/null
+++ b/res/drawable-hdpi/cling.png
Binary files differ
diff --git a/res/drawable-mdpi/cling.png b/res/drawable-mdpi/cling.png
new file mode 100644
index 000000000..fba3a0787
--- /dev/null
+++ b/res/drawable-mdpi/cling.png
Binary files differ
diff --git a/res/drawable-xhdpi/cling.png b/res/drawable-xhdpi/cling.png
new file mode 100644
index 000000000..1cee1de51
--- /dev/null
+++ b/res/drawable-xhdpi/cling.png
Binary files differ
diff --git a/res/drawable/cling_button_bg.xml b/res/drawable/cling_button_bg.xml
new file mode 100644
index 000000000..791250b7d
--- /dev/null
+++ b/res/drawable/cling_button_bg.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_pressed="true" android:drawable="@color/cling_button_pressed" />
+ <item android:drawable="@color/cling_button" />
+</selector>
diff --git a/res/layout-land/all_apps_cling.xml b/res/layout-land/all_apps_cling.xml
new file mode 100644
index 000000000..95d88b00c
--- /dev/null
+++ b/res/layout-land/all_apps_cling.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<com.android.launcher2.Cling
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
+ launcher:drawIdentifier="all_apps_landscape"
+ android:background="#CA000000">
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="20dp"
+ android:layout_marginTop="50dp">
+ <TextView
+ style="@style/ClingTitleText"
+ android:id="@+id/all_apps_cling_title"
+ android:layout_marginTop="0dp"
+ android:text="@string/all_apps_cling_title" />
+ <TextView
+ style="@style/ClingText"
+ android:id="@+id/all_apps_cling_add_item"
+ android:layout_width="280dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="45dp"
+ android:text="@string/all_apps_cling_add_item" />
+ <Button
+ style="@style/ClingButton"
+ android:id="@+id/cling_dismiss"
+ android:layout_marginTop="100dp"
+ android:onClick="dismissAllAppsCling" />
+ </FrameLayout>
+</com.android.launcher2.Cling>
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 9d394d09c..5af49a2d7 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -83,4 +83,10 @@
android:layout_width="@dimen/button_bar_height"
android:layout_height="match_parent"
android:layout_gravity="right" />
+
+ <include layout="@layout/workspace_cling"
+ android:id="@+id/workspace_cling"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone" />
</com.android.launcher2.DragLayer>
diff --git a/res/layout-land/workspace_cling.xml b/res/layout-land/workspace_cling.xml
new file mode 100644
index 000000000..fa8550760
--- /dev/null
+++ b/res/layout-land/workspace_cling.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<com.android.launcher2.Cling
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
+ launcher:drawIdentifier="workspace_landscape"
+ android:background="#AA000000">
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="20dp"
+ android:layout_marginTop="20dp">
+ <TextView
+ style="@style/ClingTitleText"
+ android:id="@+id/workspace_cling_title"
+ android:layout_marginTop="0dp"
+ android:text="@string/workspace_cling_title" />
+ <TextView
+ style="@style/ClingText"
+ android:id="@+id/workspace_cling_move_item"
+ android:layout_width="285dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="50dp"
+ android:text="@string/workspace_cling_move_item" />
+ <TextView
+ style="@style/ClingText"
+ android:id="@+id/workspace_cling_open_all_apps"
+ android:layout_width="200dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="100dp"
+ android:text="@string/workspace_cling_open_all_apps" />
+ <Button
+ style="@style/ClingButton"
+ android:id="@+id/cling_dismiss"
+ android:layout_marginTop="160dp"
+ android:onClick="dismissWorkspaceCling" />
+ </FrameLayout>
+</com.android.launcher2.Cling> \ No newline at end of file
diff --git a/res/layout-large-land/all_apps_cling.xml b/res/layout-large-land/all_apps_cling.xml
new file mode 100644
index 000000000..bca7baf33
--- /dev/null
+++ b/res/layout-large-land/all_apps_cling.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<com.android.launcher2.Cling
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
+ launcher:drawIdentifier="large_all_apps_landscape">
+ <FrameLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="160dp"
+ android:layout_marginLeft="200dp">
+ <TextView
+ style="@style/ClingTitleText"
+ android:id="@+id/all_apps_cling_title"
+ android:layout_marginTop="0dp"
+ android:text="@string/all_apps_cling_title" />
+ <TextView
+ style="@style/ClingText"
+ android:id="@+id/all_apps_cling_add_item"
+ android:layout_width="340dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="45dp"
+ android:text="@string/all_apps_cling_add_item" />
+ <Button
+ style="@style/ClingButton"
+ android:id="@+id/cling_dismiss"
+ android:layout_marginTop="120dp"
+ android:onClick="dismissAllAppsCling" />
+ </FrameLayout>
+</com.android.launcher2.Cling> \ No newline at end of file
diff --git a/res/layout-large-land/workspace_cling.xml b/res/layout-large-land/workspace_cling.xml
new file mode 100644
index 000000000..7175297d7
--- /dev/null
+++ b/res/layout-large-land/workspace_cling.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<com.android.launcher2.Cling
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
+ launcher:drawIdentifier="large_workspace_landscape">
+ <FrameLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="260dp"
+ android:layout_marginTop="30dp"
+ android:layout_gravity="left|center_vertical">
+ <TextView
+ style="@style/ClingTitleText"
+ android:id="@+id/workspace_cling_title"
+ android:layout_marginTop="20dp"
+ android:text="@string/workspace_cling_title" />
+ <TextView
+ style="@style/ClingText"
+ android:id="@+id/workspace_cling_move_item"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="65dp"
+ android:text="@string/workspace_cling_move_item" />
+ <Button
+ style="@style/ClingButton"
+ android:id="@+id/cling_dismiss"
+ android:layout_marginTop="95dp"
+ android:onClick="dismissWorkspaceCling" />
+ </FrameLayout>
+ <TextView
+ style="@style/ClingText"
+ android:id="@+id/workspace_cling_open_all_apps"
+ android:layout_width="200dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right|top"
+ android:layout_marginRight="160dp"
+ android:layout_marginTop="30dp"
+ android:gravity="left"
+ android:text="@string/workspace_cling_open_all_apps" />
+</com.android.launcher2.Cling> \ No newline at end of file
diff --git a/res/layout-large-port/all_apps_cling.xml b/res/layout-large-port/all_apps_cling.xml
new file mode 100644
index 000000000..507af512f
--- /dev/null
+++ b/res/layout-large-port/all_apps_cling.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<com.android.launcher2.Cling
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
+ launcher:drawIdentifier="large_all_apps_portrait">
+ <FrameLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="100dp"
+ android:layout_marginLeft="0dp">
+ <TextView
+ style="@style/ClingTitleText"
+ android:id="@+id/all_apps_cling_title"
+ android:layout_marginTop="0dp"
+ android:text="@string/all_apps_cling_title" />
+ <TextView
+ style="@style/ClingText"
+ android:id="@+id/all_apps_cling_add_item"
+ android:layout_width="340dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="45dp"
+ android:text="@string/all_apps_cling_add_item" />
+ <Button
+ style="@style/ClingButton"
+ android:id="@+id/cling_dismiss"
+ android:layout_marginTop="95dp"
+ android:onClick="dismissAllAppsCling" />
+ </FrameLayout>
+</com.android.launcher2.Cling> \ No newline at end of file
diff --git a/res/layout-large-port/workspace_cling.xml b/res/layout-large-port/workspace_cling.xml
new file mode 100644
index 000000000..0b9477c46
--- /dev/null
+++ b/res/layout-large-port/workspace_cling.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<com.android.launcher2.Cling
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
+ launcher:drawIdentifier="large_workspace_portrait">
+ <FrameLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="60dp"
+ android:layout_marginTop="30dp"
+ android:layout_gravity="left|center_vertical">
+ <TextView
+ style="@style/ClingTitleText"
+ android:id="@+id/workspace_cling_title"
+ android:layout_marginTop="20dp"
+ android:text="@string/workspace_cling_title" />
+ <TextView
+ style="@style/ClingText"
+ android:id="@+id/workspace_cling_move_item"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="65dp"
+ android:text="@string/workspace_cling_move_item" />
+ <Button
+ style="@style/ClingButton"
+ android:id="@+id/cling_dismiss"
+ android:layout_marginTop="95dp"
+ android:onClick="dismissWorkspaceCling" />
+ </FrameLayout>
+ <TextView
+ style="@style/ClingText"
+ android:id="@+id/workspace_cling_open_all_apps"
+ android:layout_width="200dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right|top"
+ android:layout_marginRight="160dp"
+ android:layout_marginTop="30dp"
+ android:gravity="left"
+ android:text="@string/workspace_cling_open_all_apps" />
+</com.android.launcher2.Cling> \ No newline at end of file
diff --git a/res/layout-large/launcher.xml b/res/layout-large/launcher.xml
index cb84b5a2a..bfa6f3e08 100644
--- a/res/layout-large/launcher.xml
+++ b/res/layout-large/launcher.xml
@@ -39,4 +39,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible" />
+
+ <include layout="@layout/workspace_cling"
+ android:id="@+id/workspace_cling"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone" />
</com.android.launcher2.DragLayer>
diff --git a/res/layout-port/all_apps_cling.xml b/res/layout-port/all_apps_cling.xml
new file mode 100644
index 000000000..cd702ed1a
--- /dev/null
+++ b/res/layout-port/all_apps_cling.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<com.android.launcher2.Cling
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
+ launcher:drawIdentifier="all_apps_portrait"
+ android:background="#CA000000">
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="20dp"
+ android:layout_marginTop="50dp">
+ <TextView
+ style="@style/ClingTitleText"
+ android:id="@+id/all_apps_cling_title"
+ android:layout_marginTop="0dp"
+ android:text="@string/all_apps_cling_title" />
+ <TextView
+ style="@style/ClingText"
+ android:id="@+id/all_apps_cling_add_item"
+ android:layout_width="280dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="45dp"
+ android:text="@string/all_apps_cling_add_item" />
+ </FrameLayout>
+ <Button
+ style="@style/ClingButton"
+ android:id="@+id/cling_dismiss"
+ android:layout_marginBottom="40dp"
+ android:layout_gravity="center_horizontal|bottom"
+ android:onClick="dismissAllAppsCling" />
+</com.android.launcher2.Cling>
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index 8a5d4aeb6..1bd8d7c21 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -84,4 +84,10 @@
android:layout_width="match_parent"
android:layout_height="@dimen/button_bar_height_plus_padding"
android:layout_gravity="bottom" />
+
+ <include layout="@layout/workspace_cling"
+ android:id="@+id/workspace_cling"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone" />
</com.android.launcher2.DragLayer>
diff --git a/res/layout-port/workspace_cling.xml b/res/layout-port/workspace_cling.xml
new file mode 100644
index 000000000..8c4a0b3b0
--- /dev/null
+++ b/res/layout-port/workspace_cling.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<com.android.launcher2.Cling
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
+ launcher:drawIdentifier="workspace_portrait"
+ android:background="#AA000000">
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="20dp"
+ android:layout_marginTop="90dp">
+ <TextView
+ style="@style/ClingTitleText"
+ android:id="@+id/workspace_cling_title"
+ android:layout_marginTop="0dp"
+ android:text="@string/workspace_cling_title" />
+ <TextView
+ style="@style/ClingText"
+ android:id="@+id/workspace_cling_move_item"
+ android:layout_width="285dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="50dp"
+ android:text="@string/workspace_cling_move_item" />
+ <TextView
+ style="@style/ClingText"
+ android:id="@+id/workspace_cling_open_all_apps"
+ android:layout_width="200dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="100dp"
+ android:text="@string/workspace_cling_open_all_apps" />
+ <Button
+ style="@style/ClingButton"
+ android:id="@+id/cling_dismiss"
+ android:layout_marginTop="160dp"
+ android:onClick="dismissWorkspaceCling" />
+ </FrameLayout>
+</com.android.launcher2.Cling> \ No newline at end of file
diff --git a/res/layout/apps_customize_pane.xml b/res/layout/apps_customize_pane.xml
index 95b7dc2ef..75b0e7ba8 100644
--- a/res/layout/apps_customize_pane.xml
+++ b/res/layout/apps_customize_pane.xml
@@ -75,6 +75,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
- </FrameLayout>
- </LinearLayout>
+ </FrameLayout>
+ </LinearLayout>
+
+ <include layout="@layout/all_apps_cling"
+ android:id="@+id/all_apps_cling"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone" />
</com.android.launcher2.AppsCustomizeTabHost>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 43591035f..6c0bc1467 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -27,6 +27,13 @@
<skip />
+ <!-- Cling specific attributes. These attributes are used to customize
+ the cling in XML files. -->
+ <declare-styleable name="Cling">
+ <!-- Used to identify how to draw the cling bg -->
+ <attr name="drawIdentifier" format="string" />
+ </declare-styleable>
+
<!-- Workspace specific attributes. These attributes are used to customize
the workspace in XML files. -->
<declare-styleable name="Workspace">
diff --git a/res/values/colors.xml b/res/values/colors.xml
index ece0fd895..2389f8e4f 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -32,4 +32,7 @@
<color name="workspace_all_apps_and_delete_zone_text_color">#CCFFFFFF</color>
<color name="workspace_all_apps_and_delete_zone_text_shadow_color">#A0000000</color>
+
+ <color name="cling_button">#BA49C0EC</color>
+ <color name="cling_button_pressed">#FF49C0EC</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a51642435..509b7f146 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -15,6 +15,9 @@
-->
<resources>
+<!-- Cling -->
+ <dimen name="clingPunchThroughGraphicCenterRadius">94dp</dimen>
+
<!-- Workspace -->
<dimen name="qsb_bar_height">40dp</dimen>
<dimen name="workspace_cell_width">80dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e71f7da96..0b3adcff5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -231,4 +231,20 @@ s -->
<string name="apps_customize_apps_scroll_format" translatable="false">Apps page %1$d of %2$d</string>
<!-- The format string for AppsCustomize Apps page scroll text [CHAR_LIMIT=none] -->
<string name="apps_customize_widgets_scroll_format" translatable="false">Widgets page %1$d of %2$d</string>
+
+ <!-- Clings -->
+ <!-- The title text for the workspace cling [CHAR_LIMIT=none] -->
+ <string name="workspace_cling_title">Welcome Home!</string>
+ <!-- The description of how to pick up and move an item on the workspace [CHAR_LIMIT=none] -->
+ <string name="workspace_cling_move_item">To move an app or widget, touch &amp; hold, then reposition it.</string>
+ <!-- The description of how to open all apps from the workspace [CHAR_LIMIT=none] -->
+ <string name="workspace_cling_open_all_apps">To see all your apps, touch the All Apps button.</string>
+ <!-- The title text for the All Apps cling [CHAR_LIMIT=none] -->
+ <string name="all_apps_cling_title">Here are all your apps</string>
+ <!-- The description of how to pick up and add an item to the workspace [CHAR_LIMIT=none] -->
+ <string name="all_apps_cling_add_item">To add an app or widget to your home screen, touch &amp; hold, then position it.</string>
+
+ <!-- The text on the button to dismiss a cling [CHAR_LIMIT=none] -->
+ <string name="cling_dismiss">OK</string>
+
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index be9b0fd2c..376d5c40c 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -25,6 +25,35 @@
<style name="Theme" parent="@android:style/Theme.Holo.Wallpaper.NoTitleBar">
</style>
+ <style name="ClingButton">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:paddingTop">14dp</item>
+ <item name="android:paddingBottom">14dp</item>
+ <item name="android:paddingLeft">58dp</item>
+ <item name="android:paddingRight">58dp</item>
+ <item name="android:text">@string/cling_dismiss</item>
+ <item name="android:textStyle">bold</item>
+ <item name="android:background">@drawable/cling_button_bg</item>
+ </style>
+ <style name="ClingTitleText">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textSize">28sp</item>
+ <item name="android:textColor">#49C0EC</item>
+ <item name="android:shadowColor">#000000</item>
+ <item name="android:shadowDy">2</item>
+ <item name="android:shadowRadius">2.0</item>
+ </style>
+ <style name="ClingText">
+ <item name="android:textSize">15sp</item>
+ <item name="android:textColor">#FFFFFF</item>
+ <item name="android:shadowColor">#000000</item>
+ <item name="android:shadowDy">2</item>
+ <item name="android:shadowRadius">2.0</item>
+ <item name="android:lineSpacingMultiplier">1.1</item>
+ </style>
+
<style name="WorkspaceIcon">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
diff --git a/src/com/android/launcher2/Cling.java b/src/com/android/launcher2/Cling.java
new file mode 100644
index 000000000..ae8dd4319
--- /dev/null
+++ b/src/com/android/launcher2/Cling.java
@@ -0,0 +1,303 @@
+/*
+ * 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.launcher2;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Point;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.view.View;
+import android.widget.FrameLayout;
+
+import com.android.launcher.R;
+
+public class Cling extends FrameLayout {
+
+ private static String WORKSPACE_PORTRAIT = "workspace_portrait";
+ private static String WORKSPACE_LANDSCAPE = "workspace_landscape";
+ private static String ALLAPPS_PORTRAIT = "all_apps_portrait";
+ private static String ALLAPPS_LANDSCAPE = "all_apps_landscape";
+
+ private Launcher mLauncher;
+ private boolean mIsInitialized;
+ private String mDrawIdentifier;
+ private Drawable mPunchThroughGraphic;
+ private int mPunchThroughGraphicCenterRadius;
+ private int mAppIconSize;
+ private int mTabBarHeight;
+ private int mTabBarHorizontalPadding;
+
+ View mWorkspaceDesc1;
+ View mWorkspaceDesc2;
+ View mAllAppsDesc;
+
+ public Cling(Context context) {
+ this(context, null, 0);
+ }
+
+ public Cling(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public Cling(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Cling, defStyle, 0);
+ mDrawIdentifier = a.getString(R.styleable.Cling_drawIdentifier);
+ a.recycle();
+ }
+
+ void init(Launcher l) {
+ if (!mIsInitialized) {
+ mLauncher = l;
+
+ Resources r = getContext().getResources();
+ mPunchThroughGraphic = r.getDrawable(R.drawable.cling);
+ mPunchThroughGraphicCenterRadius =
+ r.getDimensionPixelSize(R.dimen.clingPunchThroughGraphicCenterRadius);
+ mAppIconSize = r.getDimensionPixelSize(R.dimen.app_icon_size);
+ mTabBarHeight = r.getDimensionPixelSize(R.dimen.apps_customize_tab_bar_height);
+ mTabBarHorizontalPadding =
+ r.getDimensionPixelSize(R.dimen.toolbar_button_horizontal_padding);
+
+ mWorkspaceDesc1 = findViewById(R.id.workspace_cling_move_item);
+ mWorkspaceDesc2 = findViewById(R.id.workspace_cling_open_all_apps);
+ mAllAppsDesc = findViewById(R.id.all_apps_cling_add_item);
+ mIsInitialized = true;
+ }
+ }
+
+ void cleanup() {
+ mPunchThroughGraphic = null;
+ }
+
+ @Override
+ public boolean onTouchEvent(android.view.MotionEvent event) {
+ // Do nothing
+ return true;
+ };
+
+ @Override
+ protected void dispatchDraw(Canvas canvas) {
+ // Draw the rest of the cling
+ super.dispatchDraw(canvas);
+
+ if (mIsInitialized) {
+ DisplayMetrics metrics = new DisplayMetrics();
+ mLauncher.getWindowManager().getDefaultDisplay().getMetrics(metrics);
+ int dotRadius = (int) (6f * metrics.density);
+
+ Paint p = new Paint();
+ p.setAntiAlias(true);
+ p.setColor(0xFF49C0EC);
+
+ if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT)) {
+ /* Draw the all apps line */ {
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams)
+ mWorkspaceDesc2.getLayoutParams();
+ int[] loc = new int[2];
+ mWorkspaceDesc2.getLocationInWindow(loc);
+ int x = loc[0];
+ int xOffset = (int) (10f * metrics.density);
+ int y = loc[1];
+ int yOffset = (int) (30f * metrics.density);
+ int w = mWorkspaceDesc2.getWidth();
+ int h = mWorkspaceDesc2.getHeight();
+
+ Point p1 = new Point(x + w + xOffset, y - (2 * dotRadius));
+ Point p2 = new Point(getMeasuredWidth() / 2, getMeasuredHeight() -
+ mAppIconSize / 2 - yOffset);
+ canvas.drawCircle(p1.x, p1.y, dotRadius, p);
+ canvas.drawCircle(p2.x, p2.y, dotRadius, p);
+
+ Point p3 = new Point(p1.x, (int) (p1.y + (p2.y - p1.y) * 0.30f));
+ Point p4 = new Point(p2.x, (int) (p1.y + (p2.y - p1.y) * 0.55f));
+ canvas.drawLine(p1.x, p1.y, p3.x, p3.y, p);
+ canvas.drawLine(p3.x, p3.y, p4.x, p4.y, p);
+ canvas.drawLine(p4.x, p4.y, p2.x, p2.y, p);
+ }
+
+ /* Draw the move line */ {
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams)
+ mWorkspaceDesc1.getLayoutParams();
+ int[] loc = new int[2];
+ mWorkspaceDesc1.getLocationInWindow(loc);
+ int x = loc[0];
+ int y = loc[1];
+ int w = mWorkspaceDesc1.getWidth();
+ int h = mWorkspaceDesc1.getHeight();
+
+ Point p1 = new Point(x + w, y - (2 * dotRadius));
+ Point p2 = new Point(x + w, getMeasuredHeight() - (4 * mAppIconSize));
+ canvas.drawCircle(p1.x, p1.y, dotRadius, p);
+ canvas.drawCircle(p2.x, p2.y, dotRadius, p);
+ canvas.drawLine(p1.x, p1.y, p2.x, p2.y, p);
+ }
+ } else if (mDrawIdentifier.equals(WORKSPACE_LANDSCAPE)) {
+ int xOffset = (int) (1.5f * mAppIconSize);
+ /* Draw the all apps line */ {
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams)
+ mWorkspaceDesc2.getLayoutParams();
+ int[] loc = new int[2];
+ mWorkspaceDesc2.getLocationInWindow(loc);
+ int x = loc[0];
+ int y = loc[1];
+ int w = mWorkspaceDesc2.getWidth();
+ int h = mWorkspaceDesc2.getHeight();
+
+ Point p1 = new Point(x + w, y - (2 * dotRadius));
+ Point p2 = new Point(getMeasuredWidth() - xOffset,
+ getMeasuredHeight() / 2);
+ canvas.drawCircle(p1.x, p1.y, dotRadius, p);
+ canvas.drawCircle(p2.x, p2.y, dotRadius, p);
+
+ Point p3 = new Point((int) (p1.x + (p2.x - p1.x) * 0.6f), p1.y);
+ Point p4 = new Point((int) (p1.x + (p2.x - p1.x) * 0.75f), p2.y);
+ canvas.drawLine(p1.x, p1.y, p3.x, p3.y, p);
+ canvas.drawLine(p3.x, p3.y, p4.x, p4.y, p);
+ canvas.drawLine(p4.x, p4.y, p2.x, p2.y, p);
+ }
+
+ /* Draw the move line */ {
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams)
+ mWorkspaceDesc1.getLayoutParams();
+ int[] loc = new int[2];
+ mWorkspaceDesc1.getLocationInWindow(loc);
+ int x = loc[0];
+ int y = loc[1];
+ int w = mWorkspaceDesc1.getWidth();
+ int h = mWorkspaceDesc1.getHeight();
+
+ Point p1 = new Point(x + w, y - (2 * dotRadius));
+ Point p2 = new Point(getMeasuredWidth() - xOffset, y - (2 * dotRadius));
+ canvas.drawCircle(p1.x, p1.y, dotRadius, p);
+ canvas.drawCircle(p2.x, p2.y, dotRadius, p);
+ canvas.drawLine(p1.x, p1.y, p2.x, p2.y, p);
+ }
+ } else if (mDrawIdentifier.equals(ALLAPPS_PORTRAIT)) {
+ float r = mAppIconSize * 1.1f;
+ float scale = r / mPunchThroughGraphicCenterRadius;
+ int dw = (int) (scale * mPunchThroughGraphic.getIntrinsicWidth());
+ int dh = (int) (scale * mPunchThroughGraphic.getIntrinsicHeight());
+ int cx = getMeasuredWidth() / 2;
+ int cy = mTabBarHeight + ((getMeasuredHeight() - mTabBarHeight) / 2);
+ mPunchThroughGraphic.setBounds(cx - dw/2, cy - dh/2, cx + dw/2, cy + dh/2);
+ mPunchThroughGraphic.draw(canvas);
+
+ /* Draw the line */ {
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams)
+ mAllAppsDesc.getLayoutParams();
+ int[] loc = new int[2];
+ mAllAppsDesc.getLocationInWindow(loc);
+ int x = loc[0];
+ int y = loc[1];
+ int yOffset = (int) (2.5f * metrics.density);
+ int w = mAllAppsDesc.getWidth();
+ int h = mAllAppsDesc.getHeight();
+
+ Point p1 = new Point(getMeasuredWidth() / 2, y + h + yOffset);
+ Point p2 = new Point(cx, cy);
+ canvas.drawCircle(p1.x, p1.y, dotRadius, p);
+ canvas.drawCircle(p2.x, p2.y, dotRadius, p);
+ canvas.drawLine(p1.x, p1.y, p2.x, p2.y, p);
+ }
+ } else if (mDrawIdentifier.equals(ALLAPPS_LANDSCAPE)) {
+ float r = mAppIconSize * 1.1f;
+ float scale = r / mPunchThroughGraphicCenterRadius;
+ int dw = (int) (scale * mPunchThroughGraphic.getIntrinsicWidth());
+ int dh = (int) (scale * mPunchThroughGraphic.getIntrinsicHeight());
+ int cx = getMeasuredWidth() / 2 + getMeasuredWidth() / 4;
+ int cy = mTabBarHeight + ((getMeasuredHeight() - mTabBarHeight) / 2);
+ mPunchThroughGraphic.setBounds(cx - dw/2, cy - dh/2, cx + dw/2, cy + dh/2);
+ mPunchThroughGraphic.draw(canvas);
+
+ /* Draw the line */ {
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams)
+ mAllAppsDesc.getLayoutParams();
+ int[] loc = new int[2];
+ mAllAppsDesc.getLocationInWindow(loc);
+ int x = loc[0];
+ int y = loc[1];
+ int w = mAllAppsDesc.getWidth();
+ int h = mAllAppsDesc.getHeight();
+
+ Point p1 = new Point(x + w, y);
+ Point p2 = new Point(cx, cy);
+ canvas.drawCircle(p1.x, p1.y, dotRadius, p);
+ canvas.drawCircle(p2.x, p2.y, dotRadius, p);
+ canvas.drawLine(p1.x, p1.y, p2.x, p2.y, p);
+ }
+ }
+
+ /*
+ // Draw the background
+ Bitmap b = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(),
+ Bitmap.Config.ARGB_8888);
+ Canvas c = new Canvas(b);
+ c.drawColor(0xD4000000);
+ Paint p = new Paint();
+ p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
+ p.setColor(0xFFFFFF);
+ p.setAlpha(0);
+
+ int cx = -1;
+ int cy = -1;
+ float r = mAppIconSize * 1.4f;
+ float scale = r / mPunchThroughGraphicCenterRadius;
+ int dw = (int) (scale * mPunchThroughGraphic.getIntrinsicWidth());
+ int dh = (int) (scale * mPunchThroughGraphic.getIntrinsicHeight());
+
+ if (mDrawIdentifier.equals("workspace_portrait")) {
+ cx = getMeasuredWidth() / 2;
+ cy = getMeasuredHeight() - mAppIconSize / 2;
+ } else if (mDrawIdentifier.equals("workspace_landscape")) {
+ cx = getMeasuredWidth() - mAppIconSize / 2;
+ cy = getMeasuredHeight() / 2;
+ } else if (mDrawIdentifier.equals("large_workspace_landscape") ||
+ mDrawIdentifier.equals("large_workspace_portrait")) {
+ cx = getMeasuredWidth() - mTabBarHorizontalPadding;
+ cy = 0;
+ } else if (mDrawIdentifier.equals("all_apps_portrait")) {
+ cx = getMeasuredWidth() / 2;
+ cy = mTabBarHeight + ((getMeasuredHeight() - mTabBarHeight) / 2);
+ } else if (mDrawIdentifier.equals("all_apps_landscape")) {
+ cx = getMeasuredWidth() / 2 + getMeasuredWidth() / 4;
+ cy = mTabBarHeight + ((getMeasuredHeight() - mTabBarHeight) / 2);
+ } else if (mDrawIdentifier.equals("large_all_apps_portrait")) {
+ cx = getMeasuredWidth() / 2;
+ cy = mTabBarHeight + (int) ((getMeasuredHeight() - mTabBarHeight) * 2f / 5f);
+ } else if (mDrawIdentifier.equals("large_all_apps_landscape")) {
+ cx = getMeasuredWidth() / 2 + getMeasuredWidth() / 6;
+ cy = mTabBarHeight + (int) ((getMeasuredHeight() - mTabBarHeight) * 2f / 5f);
+ }
+ if (cx > -1 && cy > -1) {
+ c.drawCircle(cx, cy, r, p);
+ mPunchThroughGraphic.setBounds(cx - dw/2, cy - dh/2, cx + dw/2, cy + dh/2);
+ mPunchThroughGraphic.draw(c);
+ }
+ canvas.drawBitmap(b, 0, 0, null);
+ c.setBitmap(null);
+ b = null;
+ */
+ }
+ };
+}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index a0601e004..41fb185d5 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -40,6 +40,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -72,8 +73,8 @@ import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
-import android.view.ViewGroup;
import android.view.View.OnLongClickListener;
+import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.DecelerateInterpolator;
import android.view.inputmethod.InputMethodManager;
@@ -155,6 +156,7 @@ public final class Launcher extends Activity
static final int APPWIDGET_HOST_ID = 1024;
private static final int EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT = 300;
private static final int EXIT_SPRINGLOADED_MODE_LONG_TIMEOUT = 600;
+ private static final int DISMISS_CLING_DURATION = 300;
private static final Object sLock = new Object();
private static int sScreen = DEFAULT_SCREEN;
@@ -264,6 +266,7 @@ public final class Launcher extends Activity
checkForLocaleChange();
setContentView(R.layout.launcher);
setupViews();
+ enableClingsIfNecessary();
registerContentObservers();
@@ -2960,6 +2963,54 @@ public final class Launcher extends Activity
}, mRestoreScreenOrientationDelay);
}
+ /* Cling related */
+ private static final String WORKSPACE_CLING_DISMISSED_KEY = "cling.workspace.dismissed";
+ private static final String ALLAPPS_CLING_DISMISSED_KEY = "cling.allapps.dismissed";
+ private void enableClingsIfNecessary() {
+ // TEMPORARY: DISABLE CLINGS ON LARGE UI
+ if (LauncherApplication.isScreenLarge()) return;
+
+ // Enable the clings only if they have not been dismissed before
+ SharedPreferences prefs =
+ getSharedPreferences("com.android.launcher2.prefs", Context.MODE_PRIVATE);
+ if (!prefs.getBoolean(WORKSPACE_CLING_DISMISSED_KEY, false)) {
+ Cling cling = (Cling) findViewById(R.id.workspace_cling);
+ cling.init(this);
+ cling.setVisibility(View.VISIBLE);
+ }
+ if (!prefs.getBoolean(ALLAPPS_CLING_DISMISSED_KEY, false)) {
+ Cling cling = (Cling) findViewById(R.id.all_apps_cling);
+ cling.init(this);
+ cling.setVisibility(View.VISIBLE);
+ }
+ }
+ private void dismissCling(final Cling cling, final String flag) {
+ if (cling != null) {
+ ObjectAnimator anim = ObjectAnimator.ofFloat(cling, "alpha", 0f);
+ anim.setDuration(DISMISS_CLING_DURATION);
+ anim.addListener(new AnimatorListenerAdapter() {
+ public void onAnimationEnd(Animator animation) {
+ cling.setVisibility(View.GONE);
+ cling.cleanup();
+ SharedPreferences prefs =
+ getSharedPreferences("com.android.launcher2.prefs", Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean(flag, true);
+ editor.commit();
+ };
+ });
+ anim.start();
+ }
+ }
+ public void dismissWorkspaceCling(View v) {
+ Cling cling = (Cling) findViewById(R.id.workspace_cling);
+ dismissCling(cling, WORKSPACE_CLING_DISMISSED_KEY);
+ }
+ public void dismissAllAppsCling(View v) {
+ Cling cling = (Cling) findViewById(R.id.all_apps_cling);
+ dismissCling(cling, ALLAPPS_CLING_DISMISSED_KEY);
+ }
+
/**
* Prints out out state for debugging.
*/