Skip to content

Commit 7b4c0db

Browse files
committed
App key: change visibility only in case new state is different from
previous state
1 parent dbd4156 commit 7b4c0db

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/com/ceco/gm2/gravitybox/ModNavigationBar.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static class NavbarViewInfo {
7171
View originalView;
7272
KeyButtonView appLauncherView;
7373
int position;
74+
boolean visible;
7475
}
7576

7677
private static BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@@ -261,7 +262,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
261262
XposedHelpers.findAndHookMethod(navbarViewClass, "setDisabledFlags",
262263
int.class, boolean.class, new XC_MethodHook() {
263264
@Override
264-
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
265+
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
265266
boolean visible = mAppLauncherEnabled;
266267
View v = (View) XposedHelpers.callMethod(param.thisObject, "getRecentsButton");
267268
if (v != null) {
@@ -346,6 +347,8 @@ private static void prepareNavbarViewInfo(ViewGroup navButtons, int index, KeyBu
346347
private static void setAppKeyVisibility(boolean visible) {
347348
try {
348349
for (int i = 0; i <= 1; i++) {
350+
if (mNavbarViewInfo[i].visible == visible) continue;
351+
349352
if (mNavbarViewInfo[i].originalView != null) {
350353
mNavbarViewInfo[i].navButtons.removeViewAt(mNavbarViewInfo[i].position);
351354
mNavbarViewInfo[i].navButtons.addView(visible ?
@@ -359,6 +362,9 @@ private static void setAppKeyVisibility(boolean visible) {
359362
mNavbarViewInfo[i].navButtons.removeView(mNavbarViewInfo[i].appLauncherView);
360363
}
361364
}
365+
mNavbarViewInfo[i].visible = visible;
366+
mNavbarViewInfo[i].navButtons.requestLayout();
367+
if (DEBUG) log("setAppKeyVisibility: visible=" + visible);
362368
}
363369
} catch (Throwable t) {
364370
log("Error setting app key visibility: " + t.getMessage());

0 commit comments

Comments
 (0)