Skip to content

Commit

Permalink
GestureNavbarManager: fix toggle notifications panel
Browse files Browse the repository at this point in the history
Signed-off-by: DHD2280 <[email protected]>
  • Loading branch information
DHD2280 committed Dec 13, 2024
1 parent 436ad34 commit b881103
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,6 @@ public Buttons(Context context) {
super(context);
}

public static void toggleNotifications() {
if (PWM != null) {
Object statusBarService = callMethod(PWM, "getStatusBarService");
try {
if (statusBarService != null)
callMethod(PWM, "statusBarService");
} catch (Throwable t) {
XposedBridge.log("[ Oxygen Customizer - Buttons ] ERROR: " + t);
}
}
}

@Override
public void updatePrefs(String... Key) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import static de.robv.android.xposed.XposedHelpers.setAdditionalInstanceField;
import static de.robv.android.xposed.XposedHelpers.setObjectField;
import static it.dhd.oxygencustomizer.xposed.XPrefs.Xprefs;
import static it.dhd.oxygencustomizer.xposed.hooks.framework.Buttons.toggleNotifications;

import android.app.ActivityManager;
import android.content.Context;
Expand All @@ -33,6 +32,7 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.Toast;

import androidx.core.content.res.ResourcesCompat;
Expand All @@ -44,6 +44,7 @@
import java.util.UUID;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import it.dhd.oxygencustomizer.R;
import it.dhd.oxygencustomizer.utils.Constants;
Expand Down Expand Up @@ -78,6 +79,7 @@ public class GestureNavbarManager extends XposedMods {
private String QSExpandMethodName = "";
private Object NotificationPanelViewController;
private Object mNavigationBarInflaterView = null;
private Object mCentralSurfacesImpl = null;
//region pill color
private boolean colorReplaced = false;
//endregion
Expand Down Expand Up @@ -141,6 +143,14 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th
SideGestureNavView = findClass("com.oplusos.systemui.navigationbar.gesture.sidegesture.SideGestureNavView", lpparam.classLoader); // OOS 13
}

Class<?> CentralSurfacesImpl = findClass("com.android.systemui.statusbar.phone.CentralSurfacesImpl", lpparam.classLoader);
hookAllConstructors(CentralSurfacesImpl, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
mCentralSurfacesImpl = param.thisObject;
}
});

if (Build.VERSION.SDK_INT >= 34) {
hookAllConstructors(SideGestureDetector, new XC_MethodHook() {
@Override
Expand Down Expand Up @@ -313,6 +323,13 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
mNavigationBarInflaterView = param.thisObject;
// android.app.contextualsearch.ContextualSearchManager
// ContextualSearchManager contextualSearchManager = (ContextualSearchManager) this.context.getSystemService(ContextualSearchManager.class);
FrameLayout frame = (FrameLayout) mNavigationBarInflaterView;
frame.setOnLongClickListener(v -> {
XposedBridge.log("Long click");
return true;
});
refreshNavbar();
}
});
Expand Down Expand Up @@ -522,6 +539,16 @@ private void showPowerMenu() {

}

private void toggleNotifications() {
if (mCentralSurfacesImpl == null) return;

try {
new Handler(Looper.getMainLooper()).post(() -> callMethod(mCentralSurfacesImpl, "togglePanel"));
} catch (Throwable t) {
log(t);
}
}

private String getDefaultLauncherPackageName() {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
Expand Down

0 comments on commit b881103

Please sign in to comment.