From: Soren Stoutner Date: Thu, 28 Jan 2016 02:54:31 +0000 (-0700) Subject: Deactavite Back and Forward when they can't be used. X-Git-Tag: v1.0~14 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=5f3848c8f5fc3701bb7e85eb918b6b325c62cd23;p=PrivacyBrowserAndroid.git Deactavite Back and Forward when they can't be used. --- diff --git a/app/src/main/java/com/stoutner/privacybrowser/Webview.java b/app/src/main/java/com/stoutner/privacybrowser/Webview.java index 6295ce52..d2631c48 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/Webview.java +++ b/app/src/main/java/com/stoutner/privacybrowser/Webview.java @@ -326,9 +326,6 @@ public class Webview extends AppCompatActivity implements CreateHomeScreenShortc */ toggleCookies.setChecked(enableCookies); - // Disable Clear Cookies if there are none. - clearCookies.setEnabled(cookieManager.hasCookies()); - return true; } @@ -338,10 +335,18 @@ public class Webview extends AppCompatActivity implements CreateHomeScreenShortc MenuItem clearCookies = menu.findItem(R.id.clearCookies); clearCookies.setEnabled(cookieManager.hasCookies()); + // Enable Back if canGoBack(). + MenuItem back = menu.findItem(R.id.back); + back.setEnabled(mainWebView.canGoBack()); + + // Enable forward if canGoForward(). + MenuItem forward = menu.findItem(R.id.forward); + forward.setEnabled(mainWebView.canGoForward()); + // Run all the other default commands. super.onPrepareOptionsMenu(menu); - // Return true displays the menu. + // return true displays the menu. return true; } @@ -350,6 +355,8 @@ public class Webview extends AppCompatActivity implements CreateHomeScreenShortc @TargetApi(11) // Remove Android Studio's warning about the dangers of using SetJavaScriptEnabled. @SuppressLint("SetJavaScriptEnabled") + // removeAllCookies is deprecated, but it is required for API < 21. + @SuppressWarnings("deprecation") public boolean onOptionsItemSelected(MenuItem menuItem) { int menuItemId = menuItem.getItemId(); ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);