summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThecrazyskull <anaskarbila@gmail.com>2017-12-02 15:37:04 (GMT)
committerArne Coucheron <arco68@gmail.com>2017-12-16 05:58:07 (GMT)
commit68a4b998a40e8f4717e6b509ca98ddbe7bd0754e (patch)
treec59113268405fd1f38aef01539315baa12dfa6d9
parentcf6e472d8fee34c6fa371786ade4b91f9829f44a (diff)
downloadandroid_packages_apps_Trebuchet-68a4b998a40e8f4717e6b509ca98ddbe7bd0754e.zip
android_packages_apps_Trebuchet-68a4b998a40e8f4717e6b509ca98ddbe7bd0754e.tar.gz
android_packages_apps_Trebuchet-68a4b998a40e8f4717e6b509ca98ddbe7bd0754e.tar.bz2
Trebuchet expand statusbar on swipe down
Change-Id: I5e75b7e1c6806dae9ac2a000e377873319a5f787 Signed-off-by: Joey Rizzoli <joey@lineageos.org>
-rw-r--r--AndroidManifest.xml1
-rw-r--r--res/values/lineageos_strings.xml2
-rw-r--r--res/xml/launcher_preferences.xml6
-rw-r--r--src/com/android/launcher3/PinchToOverviewListener.java38
4 files changed, 46 insertions, 1 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b41a39d..e9000ae 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -51,6 +51,7 @@
<uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" />
<uses-permission android:name="org.lineageos.trebuchet.permission.READ_SETTINGS" />
<uses-permission android:name="org.lineageos.trebuchet.permission.WRITE_SETTINGS" />
+ <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<application
android:backupAgent="com.android.launcher3.LauncherBackupAgent"
diff --git a/res/values/lineageos_strings.xml b/res/values/lineageos_strings.xml
index f664705..5a453ef 100644
--- a/res/values/lineageos_strings.xml
+++ b/res/values/lineageos_strings.xml
@@ -22,4 +22,6 @@
<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 28a35b8..3be5d47 100644
--- a/res/xml/launcher_preferences.xml
+++ b/res/xml/launcher_preferences.xml
@@ -53,4 +53,10 @@
android:defaultValue=""
android:persistent="false" />
+ <SwitchPreference
+ android:key="pref_expand_statusbar"
+ android:title="@string/statusbar_expand"
+ android:defaultValue="true"
+ android:persistent="true" />
+
</PreferenceScreen>
diff --git a/src/com/android/launcher3/PinchToOverviewListener.java b/src/com/android/launcher3/PinchToOverviewListener.java
index 42515d1..e8ea7d7 100644
--- a/src/com/android/launcher3/PinchToOverviewListener.java
+++ b/src/com/android/launcher3/PinchToOverviewListener.java
@@ -18,11 +18,17 @@ package com.android.launcher3;
import android.animation.TimeInterpolator;
import android.content.Context;
+import android.content.SharedPreferences;
+import android.util.Log;
+import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import com.android.launcher3.util.TouchController;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
/**
* Detects pinches and animates the Workspace to/from overview mode.
*
@@ -42,6 +48,8 @@ public class PinchToOverviewListener extends ScaleGestureDetector.SimpleOnScaleG
*/
private static final float FLING_VELOCITY = 0.003f;
+ private static final String PREF_STATUSBAR_EXPAND = "pref_expand_statusbar";
+
private ScaleGestureDetector mPinchDetector;
private Launcher mLauncher;
private Workspace mWorkspace = null;
@@ -56,13 +64,28 @@ public class PinchToOverviewListener extends ScaleGestureDetector.SimpleOnScaleG
private PinchThresholdManager mThresholdManager;
private PinchAnimationManager mAnimationManager;
+ private GestureDetector mGestureDetector;
+
public PinchToOverviewListener(Launcher launcher) {
+ SharedPreferences prefs = Utilities.getPrefs(launcher.getApplicationContext());
+
mLauncher = launcher;
- mPinchDetector = new ScaleGestureDetector((Context) mLauncher, this);
+ mPinchDetector = new ScaleGestureDetector(launcher, this);
+ 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;
+ }
+ });
}
public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
mPinchDetector.onTouchEvent(ev);
+ mGestureDetector.onTouchEvent(ev);
return mPinchStarted;
}
@@ -212,4 +235,17 @@ public class PinchToOverviewListener extends ScaleGestureDetector.SimpleOnScaleG
mPreviousTimeMillis = System.currentTimeMillis();
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