Skip to content

Commit

Permalink
Fix Appbar visibility setting
Browse files Browse the repository at this point in the history
also rename Navbar texts to Appbar (cause that's what it's called, thanks to @ort163)

Closes #18
  • Loading branch information
92lleo committed Jun 17, 2020
1 parent 299fdf9 commit 3db55ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions app/src/main/java/io/kuenzler/whatsappwebtogo/WebviewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ protected void onResume() {
mWebView.onResume();

mKeyboardEnabled = mSharedPrefs.getBoolean("keyboardEnabled", true);
setNavbarEnabled(mSharedPrefs.getBoolean("navbarEnabled", true));
setAppbarEnabled(mSharedPrefs.getBoolean("appbarEnabled", true));

setKeyboardEnabled(mKeyboardEnabled);

Expand Down Expand Up @@ -439,15 +439,15 @@ private void setKeyboardEnabled(final boolean enable) {
mSharedPrefs.edit().putBoolean("keyboardEnabled", enable).apply();
}

private void setNavbarEnabled(boolean enable) {
ActionBar navbar = getSupportActionBar();
if (navbar != null) {
private void setAppbarEnabled(boolean enable) {
ActionBar actionBar= getSupportActionBar();
if (actionBar != null) {
if (enable) {
navbar.show();
actionBar.show();
} else {
navbar.hide();
actionBar.hide();
}
mSharedPrefs.edit().putBoolean("navbarEnabled", enable).apply();
mSharedPrefs.edit().putBoolean("appbarEnabled", enable).apply();
}
}

Expand Down Expand Up @@ -539,13 +539,13 @@ public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();

if (id == R.id.nav_hide) {
MenuItem view = findViewById(R.id.nav_hide);
if (id == R.id.appbar_hide) {
MenuItem view = findViewById(R.id.appbar_hide);
if (getSupportActionBar().isShowing()) {
showSnackbar("hiding... swipe right to show navigation bar");
getSupportActionBar().hide();
setAppbarEnabled(false);
} else {
getSupportActionBar().show();
setAppbarEnabled(true);
}
} else if (id == R.id.nav_logout) {
showSnackbar("logging out...");
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/menu/activity_main_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
android:title="Switch Session"
android:visible="false" />
<item
android:id="@+id/nav_hide"
android:id="@+id/appbar_hide"
android:icon="@android:drawable/ic_menu_more"
android:title="(un)hide Navbar" />
android:title="Toggle Appbar Visibility" />
<item
android:id="@+id/nav_dark_mode"
android:icon="@drawable/baseline_brightness_2_white_24"
Expand Down

0 comments on commit 3db55ee

Please sign in to comment.