Add a dummy activity which we can catch on-click in launcher to open allapps/widgets
Change-Id: Idc718a9e03e7358f972c59fcfc3bf2eaf75e56ee
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 81d7c8b..e205fea 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -83,6 +83,17 @@
</activity>
<activity
+ android:name="com.android.launcher3.WidgetAdder"
+ android:label="@string/widget_adder"
+ android:icon="@mipmap/ic_launcher_home">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity
android:name="com.android.launcher3.WallpaperChooser"
android:theme="@style/Theme.WallpaperPicker"
android:label="@string/pick_wallpaper"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 102e43e..f6abf68 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -39,6 +39,8 @@
<!-- Labels for the tabs in the customize drawer -->
<string name="widgets_tab_label">Widgets</string>
+ <string name="widget_adder">Widgets</string>
+
<!-- AppsCustomize pane -->
<!-- Message to tell the user to press and hold on a widget to add it [CHAR_LIMIT=50] -->
<string name="long_press_widget_to_add">Touch & hold to pick up a widget.</string>
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 347a1d4..1214806 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -236,14 +236,7 @@
public void onClick(View v) {
Object tag = v.getTag();
if (tag instanceof ShortcutInfo) {
- // refactor this code from Folder
- ShortcutInfo item = (ShortcutInfo) tag;
- int[] pos = new int[2];
- v.getLocationOnScreen(pos);
- item.intent.setSourceBounds(new Rect(pos[0], pos[1],
- pos[0] + v.getWidth(), pos[1] + v.getHeight()));
-
- mLauncher.startActivitySafely(v, item.intent, item);
+ mLauncher.onClick(v);
}
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index a5a90d2..664b763 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2000,6 +2000,12 @@
if (tag instanceof ShortcutInfo) {
// Open shortcut
final Intent intent = ((ShortcutInfo) tag).intent;
+
+ ComponentName widgetComp = new ComponentName(this, WidgetAdder.class);
+ if (intent.getComponent().getClassName().equals(widgetComp.getClassName())) {
+ showAllApps(true);
+ return;
+ }
int[] pos = new int[2];
v.getLocationOnScreen(pos);
intent.setSourceBounds(new Rect(pos[0], pos[1],
diff --git a/src/com/android/launcher3/WidgetAdder.java b/src/com/android/launcher3/WidgetAdder.java
new file mode 100644
index 0000000..79ac504
--- /dev/null
+++ b/src/com/android/launcher3/WidgetAdder.java
@@ -0,0 +1,7 @@
+package com.android.launcher3;
+
+import android.app.Activity;
+
+public class WidgetAdder extends Activity {
+
+}