Add menu entry for home.
authorSoren Stoutner <soren@stoutner.com>
Thu, 8 Oct 2015 22:12:39 +0000 (15:12 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 8 Oct 2015 22:12:39 +0000 (15:12 -0700)
app/src/main/java/com/stoutner/privacybrowser/Webview.java
app/src/main/res/layout/activity_webview.xml
app/src/main/res/menu/menu_webview.xml
app/src/main/res/values/strings.xml

index a0455bc9394b9c03399968b243f99bee61f787d1..a627a780f4af35d5661ee2f7dd2bdd182e4bba4a 100644 (file)
@@ -16,9 +16,6 @@ import android.webkit.WebViewClient;
 import android.widget.EditText;
 import android.widget.ProgressBar;
 
-import java.net.URL;
-
-
 public class Webview extends AppCompatActivity {
 
     static String formattedUrlString;
@@ -117,8 +114,11 @@ public class Webview extends AppCompatActivity {
         int menuItemId = menuItem.getItemId();
         final WebView mainWebView = (WebView) findViewById(R.id.mainWebView);
 
-        // Use the menu items to go forward or back.
+        // Sets the commands that relate to the menu entries.
         switch (menuItemId) {
+            case R.id.home:
+                mainWebView.loadUrl(homepage);
+                break;
             case R.id.back:
                 mainWebView.goBack();
                 break;
index 3244bb203e98fd04a0d2bae12191772add855eca..d214b1b456b7bcdd07744058f4331ab4e66a3e4e 100644 (file)
@@ -11,6 +11,7 @@
         android:orientation="horizontal"
         android:id="@+id/topBarLayout">
 
+        // android:inputType="textUri" sets the keyboard to have a go arrow.
         <EditText
             android:id="@+id/urlTextBox"
             android:layout_width="0dp"
index d4493a59d7eefa72116ab88a5ec0d4d9e8c4ebe9..8dcf42d42ab1db4f532c145473870dec3638177b 100644 (file)
@@ -4,16 +4,21 @@
     xmlns:tools="http://schemas.android.com/tools"
     tools:context=".Webview">
 
+    <item
+        android:id="@+id/home"
+        android:title="@string/home"
+        android:orderInCategory="100"
+        app:showAsAction="ifRoom" />
 
     <item
         android:id="@+id/back"
         android:title="@string/back"
-        android:orderInCategory="100"
+        android:orderInCategory="200"
         app:showAsAction="ifRoom" />
 
     <item
         android:id="@+id/forward"
         android:title="@string/forward"
-        android:orderInCategory="200"
+        android:orderInCategory="300"
         app:showAsAction="ifRoom" />
 </menu>
index 1052d8f3f678da035ba1c619b8c9297a1964266b..c51a4a269dc19c6d9360b52e8d0c6854aab220b4 100644 (file)
@@ -3,6 +3,7 @@
     <string name="privacy_browser">Privacy Browser</string>
 
     // Menu.
+    <string name="home">Home</string>
     <string name="back">Back</string>
     <string name="forward">Forward</string>