summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThecrazyskull <anaskarbila@gmail.com>2017-12-02 16:37:04 +0100
committerLuca Stefani <luca.stefani.ge1@gmail.com>2019-01-05 11:07:24 +0100
commit038d82514590597c8902a942aa84149572cb4cdb (patch)
tree104d98d18a456e00db3a0e7a3c4d191831f603b3
parent2b56ff08e4a04d72e1901203110fd3d150388863 (diff)
downloadandroid_packages_apps_Trebuchet-038d82514590597c8902a942aa84149572cb4cdb.tar.gz
android_packages_apps_Trebuchet-038d82514590597c8902a942aa84149572cb4cdb.tar.bz2
android_packages_apps_Trebuchet-038d82514590597c8902a942aa84149572cb4cdb.zip
Trebuchet: expand statusbar on swipe down
Change-Id: I5e75b7e1c6806dae9ac2a000e377873319a5f787 Signed-off-by: Joey Rizzoli <joey@lineageos.org> Signed-off-by: Luca Stefani <luca.stefani.ge1@gmail.com>
-rw-r--r--AndroidManifest.xml1
-rw-r--r--quickstep/src/com/android/launcher3/uioverrides/SwipeDownListener.java81
-rw-r--r--quickstep/src/com/android/launcher3/uioverrides/UiFactory.java9
-rw-r--r--res/values/lineage_strings.xml3
-rw-r--r--res/xml/launcher_preferences.xml6
5 files changed, 97 insertions, 3 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 578e01745..6141d56c9 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -49,6 +49,7 @@
<uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" />
<uses-permission android:name="com.android.launcher3.permission.READ_SETTINGS" />
<uses-permission android:name="com.android.launcher3.permission.WRITE_SETTINGS" />
+ <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<application
android:backupAgent="com.android.launcher3.LauncherBackupAgent"
diff --git a/quickstep/src/com/android/launcher3/uioverrides/SwipeDownListener.java b/quickstep/src/com/android/launcher3/uioverrides/SwipeDownListener.java
new file mode 100644
index 000000000..f4dd99caa
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/uioverrides/SwipeDownListener.java
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+package com.android.launcher3.uioverrides;
+
+import static com.android.launcher3.LauncherState.NORMAL;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.util.Log;
+import android.view.GestureDetector;
+import android.view.MotionEvent;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.Utilities;
+import com.android.launcher3.util.TouchController;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+public class SwipeDownListener implements TouchController {
+ private static final String PREF_STATUSBAR_EXPAND = "pref_expand_statusbar";
+
+ private GestureDetector mGestureDetector;
+ private Launcher mLauncher;
+
+ public SwipeDownListener(Launcher launcher) {
+ SharedPreferences prefs = Utilities.getPrefs(launcher.getApplicationContext());
+
+ mLauncher = launcher;
+ mGestureDetector = new GestureDetector(launcher,
+ new GestureDetector.SimpleOnGestureListener() {
+ @Override
+ public boolean onFling(MotionEvent e1, MotionEvent e2, float vX, float vy) {
+ if (prefs.getBoolean(PREF_STATUSBAR_EXPAND, true) && e1.getY() < e2.getY()) {
+ expandStatusBar(launcher);
+ }
+ return true;
+ }
+ });
+ }
+
+ @Override
+ public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
+ if (mLauncher.isInState(NORMAL)) {
+ mGestureDetector.onTouchEvent(ev);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onControllerTouchEvent(MotionEvent ev) {
+ return false;
+ }
+
+ private void expandStatusBar(Context context) {
+ try {
+ Object service = context.getSystemService("statusbar");
+ Class<?> manager = Class.forName("android.app.StatusBarManager");
+ Method expand = manager.getMethod("expandNotificationsPanel");
+ expand.invoke(service);
+ } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException |
+ InvocationTargetException e) {
+ Log.w("Reflection",
+ "Can't to invoke android.app.StatusBarManager$expandNotificationsPanel");
+ }
+ }
+} \ No newline at end of file
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index ac9f8634e..a893dafd0 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -63,19 +63,22 @@ public class UiFactory {
return new TouchController[] {
launcher.getDragController(),
new OverviewToAllAppsTouchController(launcher),
- new LauncherTaskViewController(launcher)};
+ new LauncherTaskViewController(launcher),
+ new SwipeDownListener(launcher)};
}
if (launcher.getDeviceProfile().isVerticalBarLayout()) {
return new TouchController[] {
launcher.getDragController(),
new OverviewToAllAppsTouchController(launcher),
new LandscapeEdgeSwipeController(launcher),
- new LauncherTaskViewController(launcher)};
+ new LauncherTaskViewController(launcher),
+ new SwipeDownListener(launcher)};
} else {
return new TouchController[] {
launcher.getDragController(),
new PortraitStatesTouchController(launcher),
- new LauncherTaskViewController(launcher)};
+ new LauncherTaskViewController(launcher),
+ new SwipeDownListener(launcher)};
}
}
diff --git a/res/values/lineage_strings.xml b/res/values/lineage_strings.xml
index d580a7a76..8a8b7ec87 100644
--- a/res/values/lineage_strings.xml
+++ b/res/values/lineage_strings.xml
@@ -61,4 +61,7 @@
<!-- Folder titles -->
<string name="google_title" translatable="false">Google</string>
<string name="play_folder_title">Play</string>
+
+ <!-- Expand statusbar -->
+ <string name="statusbar_expand">Swipe down to show notifications</string>
</resources>
diff --git a/res/xml/launcher_preferences.xml b/res/xml/launcher_preferences.xml
index 85efcd03b..17a7925eb 100644
--- a/res/xml/launcher_preferences.xml
+++ b/res/xml/launcher_preferences.xml
@@ -57,6 +57,12 @@
android:title="@string/desktop_show_labels"
android:defaultValue="true"
android:persistent="true" />
+
+ <SwitchPreference
+ android:key="pref_expand_statusbar"
+ android:title="@string/statusbar_expand"
+ android:defaultValue="true"
+ android:persistent="true" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/settings_category_drawer">