From: Soren Stoutner Date: Thu, 29 Oct 2015 23:09:50 +0000 (-0700) Subject: Move favoriteIcon, urlTextBox, and progressBar to a custom view in the app bar. X-Git-Tag: v1.0~33 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=20d57b6738e2676b9bf4c902d0d825b2c5ad6e8d;p=PrivacyBrowserAndroid.git Move favoriteIcon, urlTextBox, and progressBar to a custom view in the app bar. --- diff --git a/app/src/main/java/com/stoutner/privacybrowser/Webview.java b/app/src/main/java/com/stoutner/privacybrowser/Webview.java index fb72f87c..7e87fdfd 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/Webview.java +++ b/app/src/main/java/com/stoutner/privacybrowser/Webview.java @@ -15,6 +15,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewTreeObserver; +import android.view.Window; import android.view.inputmethod.InputMethodManager; import android.webkit.WebChromeClient; import android.webkit.WebView; @@ -45,17 +46,24 @@ public class Webview extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_webview); - urlTextBox = (EditText) findViewById(R.id.urlTextBox); swipeToRefresh = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayoutContainer); mainWebView = (WebView) findViewById(R.id.mainWebView); - progressBar = (ProgressBar) findViewById(R.id.progressBar); - favoriteIcon = (ImageView) findViewById(R.id.favoriteIcon); - // Remove the title from the action bar. final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { + // Remove the title from the action bar. actionBar.setDisplayShowTitleEnabled(false); - // actionBar.setHideOnContentScrollEnabled(true); + + // Add the custom app_bar layout, which shows the favoriteIcon, urlTextBar, and progressBar. + actionBar.setCustomView(R.layout.app_bar); + actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); + + // Initialize the variables for favoriteIcon, urlTextBox, and progressBar + favoriteIcon = (ImageView) actionBar.getCustomView().findViewById(R.id.favoriteIcon); + urlTextBox = (EditText) actionBar.getCustomView().findViewById(R.id.urlTextBox); + progressBar = (ProgressBar) actionBar.getCustomView().findViewById(R.id.progressBar); + + //actionBar.setHideOnContentScrollEnabled(true); } // Implement swipe down to refresh. diff --git a/app/src/main/res/layout/activity_webview.xml b/app/src/main/res/layout/activity_webview.xml index 5613cef0..28c0552b 100644 --- a/app/src/main/res/layout/activity_webview.xml +++ b/app/src/main/res/layout/activity_webview.xml @@ -1,69 +1,15 @@ + - - - - - - - - - - - - - - - - - - - - - - + android:focusable="true" + android:focusableInTouchMode="true" /> diff --git a/app/src/main/res/layout/app_bar.xml b/app/src/main/res/layout/app_bar.xml new file mode 100644 index 00000000..ece3f5d9 --- /dev/null +++ b/app/src/main/res/layout/app_bar.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_webview.xml b/app/src/main/res/menu/menu_webview.xml index 2a8923dc..fddbcc68 100644 --- a/app/src/main/res/menu/menu_webview.xml +++ b/app/src/main/res/menu/menu_webview.xml @@ -9,19 +9,19 @@ android:title="@string/home" android:orderInCategory="100" android:icon="@drawable/ic_home_black_24dp" - app:showAsAction="ifRoom" /> + app:showAsAction="never" /> + app:showAsAction="never" /> + app:showAsAction="never" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c51a4a26..a87e46d4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,13 +1,13 @@ - // Activities. + Privacy Browser - // Menu. + + Favorite Icon + + Home Back Forward - // Layout. - Go -