]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Create code to toggle Save Form Data, but disable it until database storage is implem...
authorSoren Stoutner <soren@stoutner.com>
Wed, 27 Jan 2016 22:23:29 +0000 (15:23 -0700)
committerSoren Stoutner <soren@stoutner.com>
Wed, 27 Jan 2016 22:23:29 +0000 (15:23 -0700)
app/src/main/java/com/stoutner/privacybrowser/Webview.java
app/src/main/res/menu/menu_webview.xml
app/src/main/res/values/strings.xml

index a1eb26be2f675c78012256a6dde4dca3a796f18f..154353f7ff7b120c5c46538481894e4ddcae8004 100644 (file)
@@ -65,10 +65,16 @@ public class Webview extends AppCompatActivity implements CreateHomeScreenShortc
     private String formattedUrlString;
     // homepage is used in onCreate and onOptionsItemSelected.
     private String homepage = "https://www.duckduckgo.com/";
-    // enableJavaScript is used in onCreate and onOptionsItemSelected.
+    // enableJavaScript is used in onCreate, onCreateOptionsMenu, and onOptionsItemSelected.
     private boolean enableJavaScript;
-    // enableDomStorage is used in onCreate and onOptionsItemSelected.
+    // enableDomStorage is used in onCreate, onCreateOptionsMenu, and onOptionsItemSelected.
     private boolean enableDomStorage;
+
+    /*  enableSaveFormData does nothing until database storage is implemented.
+    // enableSaveFormData is used in onCreate, onCreateOptionsMenu, and onOptionsItemSelected.
+    private boolean enableSaveFormData;
+    */
+
     // actionBar is used in onCreate and onOptionsItemSelected.
     private ActionBar actionBar;
 
@@ -263,6 +269,12 @@ public class Webview extends AppCompatActivity implements CreateHomeScreenShortc
         enableDomStorage = true;
         mainWebView.getSettings().setDomStorageEnabled(enableDomStorage);
 
+        /* Save Form Data does nothing until database storage is implemented.
+        // Set Save Form Data initial status.
+        enableSaveFormData = true;
+        mainWebView.getSettings().setSaveFormData(enableSaveFormData);
+        */
+
         // Get the intent information that started the app.
         final Intent intent = getIntent();
 
@@ -287,12 +299,16 @@ public class Webview extends AppCompatActivity implements CreateHomeScreenShortc
         getMenuInflater().inflate(R.menu.menu_webview, menu);
         MenuItem toggleJavaScriptMenuItem = menu.findItem(R.id.toggleJavaScript);
         MenuItem toggleDomStorageMenuItem = menu.findItem(R.id.toggleDomStorage);
+        /* toggleSaveFormData does nothing until database storage is implemented.
+        MenuItem toggleSaveFormDataMenuItem = menu.findItem(R.id.toggleSaveFormData);
+        */
 
-        // Set the JavaScript menu item checkbox initial status.
+        // Set the initial status of the menu item checkboxes.
         toggleJavaScriptMenuItem.setChecked(enableJavaScript);
-
-        // Set the DOM Storage menu item checkbox initial status.
         toggleDomStorageMenuItem.setChecked(enableDomStorage);
+        /* toggleSaveFormData does nothing until database storage is implemented.
+        toggleSaveFormDataMenuItem.setChecked(enableSaveFormData);
+        */
 
         return true;
     }
@@ -313,12 +329,12 @@ public class Webview extends AppCompatActivity implements CreateHomeScreenShortc
                     enableJavaScript = false;
                     menuItem.setChecked(false);
                     mainWebView.getSettings().setJavaScriptEnabled(false);
-                    mainWebView.loadUrl(formattedUrlString);
+                    mainWebView.reload();
                 } else {
                     enableJavaScript = true;
                     menuItem.setChecked(true);
                     mainWebView.getSettings().setJavaScriptEnabled(true);
-                    mainWebView.loadUrl(formattedUrlString);
+                    mainWebView.reload();
                 }
                 return true;
 
@@ -327,21 +343,37 @@ public class Webview extends AppCompatActivity implements CreateHomeScreenShortc
                     enableDomStorage = false;
                     menuItem.setChecked(false);
                     mainWebView.getSettings().setDomStorageEnabled(false);
-                    mainWebView.loadUrl(formattedUrlString);
+                    mainWebView.reload();
                 } else {
                     enableDomStorage = true;
                     menuItem.setChecked(true);
                     mainWebView.getSettings().setDomStorageEnabled(true);
-                    mainWebView.loadUrl(formattedUrlString);
+                    mainWebView.reload();
                 }
                 return true;
 
+            /* toggleSaveFormData does nothing until database storage is implemented.
+            case R.id.toggleSaveFormData:
+                if (enableSaveFormData) {
+                    enableSaveFormData = false;
+                    menuItem.setChecked(false);
+                    mainWebView.getSettings().setSaveFormData(false);
+                    mainWebView.reload();
+                } else {
+                    enableSaveFormData = true;
+                    menuItem.setChecked(true);
+                    mainWebView.getSettings().setSaveFormData(true);
+                    mainWebView.reload();
+                }
+                return true;
+            */
+
             case R.id.home:
                 mainWebView.loadUrl(homepage);
                 return true;
 
             case R.id.refresh:
-                mainWebView.loadUrl(formattedUrlString);
+                mainWebView.reload();
                 return true;
 
             case R.id.back:
index 84e1c75d01a4562d3237e4fd72c3cb6eb32cdecf..d6010645c4676c34359e394a50cf1aba468b8d25 100644 (file)
         android:checkable="true"
         app:showAsAction="never" />
 
+    <!-- toggleSaveFormData does nothing until database storage is implemented
+    <item
+        android:id="@+id/toggleSaveFormData"
+        android:title="@string/saveFormData"
+        android:orderInCategory="3"
+        android:checkable="true"
+        app:showAsAction="never" />
+        -->
+
     <item
         android:id="@+id/home"
         android:title="@string/home"
-        android:orderInCategory="2"
+        android:orderInCategory="10"
         android:icon="@drawable/ic_home_black_24dp"
         app:showAsAction="never" />
 
     <item
         android:id="@+id/refresh"
         android:title="@string/refresh"
-        android:orderInCategory="3"
+        android:orderInCategory="20"
         app:showAsAction="never" />
 
     <item
         android:id="@+id/back"
         android:title="@string/back"
-        android:orderInCategory="4"
+        android:orderInCategory="30"
         android:icon="@drawable/ic_back"
         app:showAsAction="never" />
 
     <item
         android:id="@+id/forward"
         android:title="@string/forward"
-        android:orderInCategory="5"
+        android:orderInCategory="40"
         android:icon="@drawable/ic_forward"
         app:showAsAction="never" />
 
@@ -68,7 +77,7 @@
     <item
         android:id="@+id/copyURL"
         android:title="@string/copy_URL"
-        android:orderInCategory="6"
+        android:orderInCategory="50"
         tools:targetApi="11"
         app:showAsAction="never" />
 
     <item
         android:id="@+id/pasteURL"
         android:title="@string/paste_URL"
-        android:orderInCategory="7"
+        android:orderInCategory="60"
         tools:targetApi="11"
         app:showAsAction="never" />
 
     <item
         android:id="@+id/shareURL"
         android:title="@string/share_URL"
-        android:orderInCategory="8"
+        android:orderInCategory="70"
         app:showAsAction="never" />
 
     <item
         android:id="@+id/addToHomescreen"
         android:title="@string/add_to_home_screen"
-        android:orderInCategory="9"
+        android:orderInCategory="80"
         app:showAsAction="never" />
 
     <item
         android:id="@+id/downloads"
         android:title="@string/downloads"
-        android:orderInCategory="10"
+        android:orderInCategory="90"
         app:showAsAction="never" />
 
     <item
         android:id="@+id/about"
         android:title="@string/about"
-        android:orderInCategory="11"
+        android:orderInCategory="100"
         app:showAsAction="never" />
 </menu>
index 879cef1b59ac6210e3fb3d3cbc2bfabe9520dbdf..aa9d518732da210b0ca04f80383844fe4b29c67c 100644 (file)
@@ -26,6 +26,7 @@
     <!-- Menu. -->
     <string name="javaScript">JavaScript</string>
     <string name="domStorage">DOM Storage</string>
+    <string name="saveFormData">Save Form Data</string>
     <string name="home">Home</string>
     <string name="refresh">Refresh</string>
     <string name="back">Back</string>