]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Move the progress bar to the bottom of the app bar. Implements https://redmine.stout...
authorSoren Stoutner <soren@stoutner.com>
Wed, 22 Mar 2017 23:39:15 +0000 (16:39 -0700)
committerSoren Stoutner <soren@stoutner.com>
Wed, 22 Mar 2017 23:39:15 +0000 (16:39 -0700)
.idea/dictionaries/soren.xml
app/src/free/java/com/stoutner/privacybrowser/BannerAd.java
app/src/free/res/layout/main_webview.xml
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
app/src/main/res/layout/drawerlayout.xml [deleted file]
app/src/main/res/layout/main_drawerlayout.xml [new file with mode: 0644]
app/src/main/res/layout/main_webview.xml
app/src/main/res/layout/url_app_bar.xml

index a5cc4b46f9c2351af3951c1bbcbac30ee3e6fb48..780edc6d4654af0d9a7d3dcb0cd438cadf23309f 100644 (file)
@@ -4,6 +4,7 @@
       <w>aaaa</w>
       <w>adsense</w>
       <w>adservers</w>
+      <w>adview</w>
       <w>amiunique</w>
       <w>androidversion</w>
       <w>anonymized</w>
@@ -75,6 +76,7 @@
       <w>radiogroup</w>
       <w>redmine</w>
       <w>referer</w>
+      <w>refreshlayout</w>
       <w>relativelayout</w>
       <w>requery</w>
       <w>robinlinus</w>
index 3f9d9a7358355686163385f42a6db61915fb9774..88e3985ba8c771e2a54008e47dbe4e55ac80bd0c 100644 (file)
@@ -1,5 +1,5 @@
-/**
- * Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+/*
+ * Copyright 2016-2017 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -39,24 +39,24 @@ public class BannerAd extends AppCompatActivity{
     }
 
     public static void reloadAfterRotate (View view, Context applicationContext, String ad_id) {
-        // Cast view to an AdView.
+        // Cast `view` to an `AdView`.
         AdView adView = (AdView) view;
 
         // Save the layout parameters.
         RelativeLayout.LayoutParams adViewLayoutParameters = (RelativeLayout.LayoutParams) adView.getLayoutParams();
 
-        // Remove the AdView.
+        // Remove the `AdView`.
         RelativeLayout adViewParentLayout = (RelativeLayout) adView.getParent();
         adViewParentLayout.removeView(adView);
 
-        // Setup the new AdView.
+        // Setup the new `AdView`.
         adView = new AdView(applicationContext);
         adView.setAdSize(AdSize.SMART_BANNER);
         adView.setAdUnitId(ad_id);
-        adView.setId(R.id.adView);
+        adView.setId(R.id.adview);
         adView.setLayoutParams(adViewLayoutParameters);
 
-        // Display the new AdView.
+        // Display the new `AdView`.
         adViewParentLayout.addView(adView);
 
         // Request a new ad.
@@ -65,7 +65,7 @@ public class BannerAd extends AppCompatActivity{
     }
 
     public static void hideAd(View view) {
-        // Cast view to an AdView.
+        // Cast `view` to an `AdView`.
         AdView adView = (AdView) view;
 
         // Hide the ad.
@@ -73,26 +73,26 @@ public class BannerAd extends AppCompatActivity{
     }
 
     public static void showAd(View view) {
-        // Cast view to an AdView.
+        // Cast `view` to an `AdView`.
         AdView adView = (AdView) view;
 
-        // Hide the ad.
+        // Show the ad.
         adView.setVisibility(View.VISIBLE);
     }
 
     public static void pauseAd(View view) {
-        // Cast view to an AdView.
+        // Cast `view` to an `AdView`.
         AdView adView = (AdView) view;
 
-        // Pause the AdView.
+        // Pause the `AdView`.
         adView.pause();
     }
 
     public static void resumeAd(View view) {
-        // Cast view to an AdView.
+        // Cast `view` to an `AdView`.
         AdView adView = (AdView) view;
 
-        // Resume the AdView.
+        // Resume the `AdView`.
         adView.resume();
     }
 }
\ No newline at end of file
index 6013ae2901489ef5eaaac16e9d567e8a21bca95b..a6fd37b429fe5f293dc725259137fbfa0690db39 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <!--
-  Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+  Copyright 2016-2017 Soren Stoutner <soren@stoutner.com>.
 
   This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
 
@@ -18,8 +18,7 @@
   You should have received a copy of the GNU General Public License
   along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
 
-<!-- android:layout_martinTop="?attr/actionBarSize" moves adRelativeLayout below the appBarLayout, which otherwise would cover the top of mainWebView.
-  android:layout_weight="1" sets the RelativeLayout to fill the rest of the screen because it is encapsulated in a LinearLayout with android:orientation="vertical"-->
+<!-- `android:layout_weight="1"` sets the `RelativeLayout` to fill the rest of the screen because it is encapsulated in a `LinearLayout` with `android:orientation="vertical"`.-->
 <RelativeLayout
     android:id="@+id/main_webview_relativelayout"
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_height="0dp"
     android:layout_weight="1"
     tools:context="com.stoutner.privacybrowser.activities.MainWebViewActivity"
-    tools:showIn="@layout/drawerlayout">
+    tools:showIn="@layout/main_drawerlayout">
 
     <com.google.android.gms.ads.AdView
-        android:id="@+id/adView"
+        android:id="@+id/adview"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerHorizontal="true"
     </com.google.android.gms.ads.AdView>
 
     <android.support.v4.widget.SwipeRefreshLayout
-        android:id="@+id/swipeRefreshLayout"
+        android:id="@+id/swipe_refreshlayout"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:layout_above="@id/adView">
+        android:layout_above="@id/adview">
 
         <!-- Google does not currently want to support hiding the AppBar on scroll for a WebView child with the Support Toolbar.  https://code.google.com/p/android/issues/detail?id=200394 -->
         <WebView
-            android:id="@+id/mainWebView"
+            android:id="@+id/main_webview"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:focusable="true"
index 2ca1f0fb52d7d700a62c150a79e79cf873fab57a..e3c85f5705996074959e4fd3362d2066be6188b2 100644 (file)
@@ -253,7 +253,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
     @SuppressLint("SetJavaScriptEnabled")
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.drawerlayout);
+        setContentView(R.layout.main_drawerlayout);
 
         // Get a handle for `inputMethodManager`.
         inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -266,12 +266,12 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
         // This is needed to get rid of the Android Studio warning that `appBar` might be null.
         assert appBar != null;
 
-        // Add the custom url_app_bar layout, which shows the favoriteIcon, urlTextBar, and progressBar.
+        // Add the custom `url_app_bar` layout, which shows the favorite icon and the URL text bar.
         appBar.setCustomView(R.layout.url_app_bar);
         appBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
 
         // Set the "go" button on the keyboard to load the URL in urlTextBox.
-        urlTextBox = (EditText) appBar.getCustomView().findViewById(R.id.urlTextBox);
+        urlTextBox = (EditText) appBar.getCustomView().findViewById(R.id.url_edittext);
         urlTextBox.setOnKeyListener(new View.OnKeyListener() {
             @Override
             public boolean onKey(View v, int keyCode, KeyEvent event) {
@@ -334,7 +334,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
         drawerLayout = (DrawerLayout) findViewById(R.id.drawerlayout);
         rootCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.root_coordinatorlayout);
         mainWebViewRelativeLayout = (RelativeLayout) findViewById(R.id.main_webview_relativelayout);
-        mainWebView = (WebView) findViewById(R.id.mainWebView);
+        mainWebView = (WebView) findViewById(R.id.main_webview);
         findOnPageLinearLayout = (LinearLayout) findViewById(R.id.find_on_page_linearlayout);
         findOnPageEditText = (EditText) findViewById(R.id.find_on_page_edittext);
         fullScreenVideoFrameLayout = (FrameLayout) findViewById(R.id.full_screen_video_framelayout);
@@ -392,7 +392,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                             BannerAd.reloadAfterRotate(adView, getApplicationContext(), getString(R.string.ad_id));
 
                             // Reinitialize the `adView` variable, as the `View` will have been removed and re-added by `BannerAd.reloadAfterRotate()`.
-                            adView = findViewById(R.id.adView);
+                            adView = findViewById(R.id.adview);
                         }
 
                         // Remove the translucent navigation bar flag if it is set.
@@ -482,7 +482,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
         });
 
         // Implement swipe to refresh
-        swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
+        swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refreshlayout);
         swipeRefreshLayout.setColorSchemeResources(R.color.blue_700);
         swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
             @Override
@@ -665,11 +665,13 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
             }
         });
 
+        // Get a handle for the progress bar.
+        final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
+
         mainWebView.setWebChromeClient(new WebChromeClient() {
             // Update the progress bar when a page is loading.
             @Override
             public void onProgressChanged(WebView view, int progress) {
-                ProgressBar progressBar = (ProgressBar) appBar.getCustomView().findViewById(R.id.progressBar);
                 progressBar.setProgress(progress);
                 if (progress < 100) {
                     progressBar.setVisibility(View.VISIBLE);
@@ -688,7 +690,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                 favoriteIcon = icon;
 
                 // Place the favorite icon in the appBar.
-                ImageView imageViewFavoriteIcon = (ImageView) appBar.getCustomView().findViewById(R.id.favoriteIcon);
+                ImageView imageViewFavoriteIcon = (ImageView) appBar.getCustomView().findViewById(R.id.favorite_icon);
                 imageViewFavoriteIcon.setImageBitmap(Bitmap.createScaledBitmap(icon, 64, 64, true));
             }
 
@@ -745,7 +747,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                     BannerAd.reloadAfterRotate(adView, getApplicationContext(), getString(R.string.ad_id));
 
                     // Reinitialize the `adView` variable, as the `View` will have been removed and re-added by `BannerAd.reloadAfterRotate()`.
-                    adView = findViewById(R.id.adView);
+                    adView = findViewById(R.id.adview);
                 }
             }
         });
@@ -793,7 +795,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
         inFullScreenBrowsingMode = false;
 
         // Initialize AdView for the free flavor.
-        adView = findViewById(R.id.adView);
+        adView = findViewById(R.id.adview);
 
         // Initialize the privacy settings variables.
         javaScriptEnabled = false;
@@ -995,11 +997,11 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
 
                 // Display a `Snackbar`.
                 if (javaScriptEnabled) {  // JavaScrip is enabled.
-                    Snackbar.make(findViewById(R.id.mainWebView), R.string.javascript_enabled, Snackbar.LENGTH_SHORT).show();
+                    Snackbar.make(findViewById(R.id.main_webview), R.string.javascript_enabled, Snackbar.LENGTH_SHORT).show();
                 } else if (firstPartyCookiesEnabled) {  // JavaScript is disabled, but first-party cookies are enabled.
-                    Snackbar.make(findViewById(R.id.mainWebView), R.string.javascript_disabled, Snackbar.LENGTH_SHORT).show();
+                    Snackbar.make(findViewById(R.id.main_webview), R.string.javascript_disabled, Snackbar.LENGTH_SHORT).show();
                 } else {  // Privacy mode.
-                    Snackbar.make(findViewById(R.id.mainWebView), R.string.privacy_mode, Snackbar.LENGTH_SHORT).show();
+                    Snackbar.make(findViewById(R.id.main_webview), R.string.privacy_mode, Snackbar.LENGTH_SHORT).show();
                 }
 
                 // Reload the WebView.
@@ -1021,11 +1023,11 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
 
                 // Display a `Snackbar`.
                 if (firstPartyCookiesEnabled) {  // First-party cookies are enabled.
-                    Snackbar.make(findViewById(R.id.mainWebView), R.string.first_party_cookies_enabled, Snackbar.LENGTH_SHORT).show();
+                    Snackbar.make(findViewById(R.id.main_webview), R.string.first_party_cookies_enabled, Snackbar.LENGTH_SHORT).show();
                 } else if (javaScriptEnabled){  // JavaScript is still enabled.
-                    Snackbar.make(findViewById(R.id.mainWebView), R.string.first_party_cookies_disabled, Snackbar.LENGTH_SHORT).show();
+                    Snackbar.make(findViewById(R.id.main_webview), R.string.first_party_cookies_disabled, Snackbar.LENGTH_SHORT).show();
                 } else {  // Privacy mode.
-                    Snackbar.make(findViewById(R.id.mainWebView), R.string.privacy_mode, Snackbar.LENGTH_SHORT).show();
+                    Snackbar.make(findViewById(R.id.main_webview), R.string.privacy_mode, Snackbar.LENGTH_SHORT).show();
                 }
 
                 // Reload the WebView.
@@ -1045,9 +1047,9 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
 
                     // Display a `Snackbar`.
                     if (thirdPartyCookiesEnabled) {
-                        Snackbar.make(findViewById(R.id.mainWebView), R.string.third_party_cookies_enabled, Snackbar.LENGTH_SHORT).show();
+                        Snackbar.make(findViewById(R.id.main_webview), R.string.third_party_cookies_enabled, Snackbar.LENGTH_SHORT).show();
                     } else {
-                        Snackbar.make(findViewById(R.id.mainWebView), R.string.third_party_cookies_disabled, Snackbar.LENGTH_SHORT).show();
+                        Snackbar.make(findViewById(R.id.main_webview), R.string.third_party_cookies_disabled, Snackbar.LENGTH_SHORT).show();
                     }
 
                     // Reload the WebView.
@@ -1070,9 +1072,9 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
 
                 // Display a `Snackbar`.
                 if (domStorageEnabled) {
-                    Snackbar.make(findViewById(R.id.mainWebView), R.string.dom_storage_enabled, Snackbar.LENGTH_SHORT).show();
+                    Snackbar.make(findViewById(R.id.main_webview), R.string.dom_storage_enabled, Snackbar.LENGTH_SHORT).show();
                 } else {
-                    Snackbar.make(findViewById(R.id.mainWebView), R.string.dom_storage_disabled, Snackbar.LENGTH_SHORT).show();
+                    Snackbar.make(findViewById(R.id.main_webview), R.string.dom_storage_disabled, Snackbar.LENGTH_SHORT).show();
                 }
 
                 // Reload the WebView.
@@ -1091,9 +1093,9 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
 
                 // Display a `Snackbar`.
                 if (saveFormDataEnabled) {
-                    Snackbar.make(findViewById(R.id.mainWebView), R.string.form_data_enabled, Snackbar.LENGTH_SHORT).show();
+                    Snackbar.make(findViewById(R.id.main_webview), R.string.form_data_enabled, Snackbar.LENGTH_SHORT).show();
                 } else {
-                    Snackbar.make(findViewById(R.id.mainWebView), R.string.form_data_disabled, Snackbar.LENGTH_SHORT).show();
+                    Snackbar.make(findViewById(R.id.main_webview), R.string.form_data_disabled, Snackbar.LENGTH_SHORT).show();
                 }
 
                 // Update the privacy icon.  `true` runs `invalidateOptionsMenu` as the last step.
@@ -1109,19 +1111,19 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                 } else {
                     cookieManager.removeAllCookies(null);
                 }
-                Snackbar.make(findViewById(R.id.mainWebView), R.string.cookies_deleted, Snackbar.LENGTH_SHORT).show();
+                Snackbar.make(findViewById(R.id.main_webview), R.string.cookies_deleted, Snackbar.LENGTH_SHORT).show();
                 return true;
 
             case R.id.clearDomStorage:
                 WebStorage webStorage = WebStorage.getInstance();
                 webStorage.deleteAllData();
-                Snackbar.make(findViewById(R.id.mainWebView), R.string.dom_storage_deleted, Snackbar.LENGTH_SHORT).show();
+                Snackbar.make(findViewById(R.id.main_webview), R.string.dom_storage_deleted, Snackbar.LENGTH_SHORT).show();
                 return true;
 
             case R.id.clearFormData:
                 WebViewDatabase mainWebViewDatabase = WebViewDatabase.getInstance(this);
                 mainWebViewDatabase.clearFormData();
-                Snackbar.make(findViewById(R.id.mainWebView), R.string.form_data_deleted, Snackbar.LENGTH_SHORT).show();
+                Snackbar.make(findViewById(R.id.main_webview), R.string.form_data_deleted, Snackbar.LENGTH_SHORT).show();
                 return true;
 
             case R.id.fontSizeFiftyPercent:
@@ -1376,7 +1378,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
             BannerAd.reloadAfterRotate(adView, getApplicationContext(), getString(R.string.ad_id));
 
             // Reinitialize the `adView` variable, as the `View` will have been removed and re-added by `BannerAd.reloadAfterRotate()`.
-            adView = findViewById(R.id.adView);
+            adView = findViewById(R.id.adview);
         }
 
         // `invalidateOptionsMenu` should recalculate the number of action buttons from the menu to display on the app bar, but it doesn't because of the this bug:  https://code.google.com/p/android/issues/detail?id=20493#c8
@@ -1891,7 +1893,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                 hostname = hostname.substring(hostname.indexOf(".") + 1);
             }
 
-            FrameLayout urlAppBarFrameLayout = (FrameLayout) findViewById(R.id.url_app_bar_framelayout);
+            RelativeLayout urlAppBarRelativeLayout = (RelativeLayout) findViewById(R.id.url_app_bar_relativelayout);
 
             if (hostHasDomainSettings) {  // The url we are loading has custom domain settings.
                 // Get a cursor for the current host and move it to the first position.
@@ -1932,7 +1934,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                 }
 
                 // Set a green background on `urlTextBox` to indicate that custom domain settings are being used.  We have to use the deprecated `.getDrawable()` until the minimum API >= 21.
-                urlAppBarFrameLayout.setBackground(getResources().getDrawable(R.drawable.url_bar_background_green));
+                urlAppBarRelativeLayout.setBackground(getResources().getDrawable(R.drawable.url_bar_background_green));
             } else {  // The URL we are loading does not have custom domain settings.  Load the defaults.
                 // Get the shared preference values.  `this` references the current context.
                 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
@@ -1978,7 +1980,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                 }
 
                 // Set a transparent background on `urlTextBox`.  We have to use the deprecated `.getDrawable()` until the minimum API >= 21.
-                urlAppBarFrameLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.url_bar_background_transparent));
+                urlAppBarRelativeLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.url_bar_background_transparent));
             }
 
             // Close `domainsDatabaseHelper`.
@@ -2161,7 +2163,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                 BannerAd.reloadAfterRotate(adView, getApplicationContext(), getString(R.string.ad_id));
 
                 // Reinitialize the `adView` variable, as the `View` will have been removed and re-added by `BannerAd.reloadAfterRotate()`.
-                adView = findViewById(R.id.adView);
+                adView = findViewById(R.id.adview);
             }
 
             // Remove the translucent navigation bar flag if it is set.
diff --git a/app/src/main/res/layout/drawerlayout.xml b/app/src/main/res/layout/drawerlayout.xml
deleted file mode 100644 (file)
index ca8cffe..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-  Copyright 2015-2016 Soren Stoutner <soren@stoutner.com>.
-
-  This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>>.
-
-  Privacy Browser is free software: you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation, either version 3 of the License, or
-  (at your option) any later version.
-
-  Privacy Browser is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
-
-<android.support.v4.widget.DrawerLayout
-    android:id="@+id/drawerlayout"
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_height="match_parent"
-    android:layout_width="match_parent" >
-
-    <!-- android:fitsSystemWindows="true" moves rootCoordinatorLayout below the system status bar.
-        When it is specified the theme should include <item name="android:windowTranslucentStatus">true</item>.
-        Setting the layout root to be focusableInTouchMode prevents urlTextBox from stealing focus on launch and opening the keyboard. -->
-    <android.support.design.widget.CoordinatorLayout
-        android:id="@+id/root_coordinatorlayout"
-        xmlns:tools="http://schemas.android.com/tools"
-        tools:context="com.stoutner.privacybrowser.activities.MainWebViewActivity"
-        android:layout_height="match_parent"
-        android:layout_width="match_parent"
-        android:fitsSystemWindows="true"
-        android:focusable="true"
-        android:focusableInTouchMode="true" >
-
-        <!-- The purpose of the LinearLayout is to place the included main_webview below appBarLayout. -->
-        <LinearLayout
-            android:layout_height="match_parent"
-            android:layout_width="match_parent"
-            android:orientation="vertical" >
-
-            <android.support.design.widget.AppBarLayout
-                android:id="@+id/app_bar_layout"
-                android:layout_height="wrap_content"
-                android:layout_width="match_parent"
-                android:theme="@style/AppBarOverlay" >
-
-                <!-- The `FrameLayout` allows `appBar` and `find_on_page_app_bar` to occupy the same space. -->
-                <FrameLayout
-                    android:layout_height="wrap_content"
-                    android:layout_width="match_parent" >
-
-                    <android.support.v7.widget.Toolbar
-                        android:id="@+id/app_bar"
-                        android:layout_height="wrap_content"
-                        android:layout_width="match_parent"
-                        android:background="@color/gray_100"
-                        app:popupTheme="@style/LightPopupOverlay" />
-
-                    <include layout="@layout/find_on_page_app_bar" />
-                </FrameLayout>
-            </android.support.design.widget.AppBarLayout>
-
-            <include layout="@layout/main_webview" />
-        </LinearLayout>
-
-        <!-- `full_screen_video_framelayout` is used to display full screen videos.  It is initially `android:visibility="gone"` to hide it from view. -->
-        <FrameLayout
-            android:id="@+id/full_screen_video_framelayout"
-            android:layout_height="match_parent"
-            android:layout_width="match_parent"
-            android:visibility="gone"
-            android:background="@color/black" />
-    </android.support.design.widget.CoordinatorLayout>
-
-    <!-- The navigation drawer. -->
-    <android.support.design.widget.NavigationView
-        android:id="@+id/navigationview"
-        android:layout_height="match_parent"
-        android:layout_width="wrap_content"
-        android:layout_gravity="start"
-        app:headerLayout="@layout/navigation_header"
-        app:menu="@menu/webview_navigation_menu"
-        app:itemIconTint="@color/blue_800" />
-</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/main_drawerlayout.xml b/app/src/main/res/layout/main_drawerlayout.xml
new file mode 100644 (file)
index 0000000..c616f68
--- /dev/null
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+  Copyright 2015-2017 Soren Stoutner <soren@stoutner.com>.
+
+  This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>>.
+
+  Privacy Browser is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  Privacy Browser is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
+
+<android.support.v4.widget.DrawerLayout
+    android:id="@+id/drawerlayout"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_height="match_parent"
+    android:layout_width="match_parent" >
+
+    <!-- android:fitsSystemWindows="true" moves rootCoordinatorLayout below the system status bar.
+        When it is specified the theme should include <item name="android:windowTranslucentStatus">true</item>.
+        Setting the layout root to be focusableInTouchMode prevents urlTextBox from stealing focus on launch and opening the keyboard. -->
+    <android.support.design.widget.CoordinatorLayout
+        android:id="@+id/root_coordinatorlayout"
+        xmlns:tools="http://schemas.android.com/tools"
+        tools:context="com.stoutner.privacybrowser.activities.MainWebViewActivity"
+        android:layout_height="match_parent"
+        android:layout_width="match_parent"
+        android:fitsSystemWindows="true"
+        android:focusable="true"
+        android:focusableInTouchMode="true" >
+
+        <!-- The purpose of the LinearLayout is to place the included main_webview below appBarLayout. -->
+        <LinearLayout
+            android:layout_height="match_parent"
+            android:layout_width="match_parent"
+            android:orientation="vertical" >
+
+            <android.support.design.widget.AppBarLayout
+                android:id="@+id/app_bar_layout"
+                android:layout_height="wrap_content"
+                android:layout_width="match_parent"
+                android:theme="@style/AppBarOverlay" >
+
+                <!-- The `FrameLayout` allows `appBar` and `find_on_page_app_bar` to occupy the same space. -->
+                <FrameLayout
+                    android:layout_height="wrap_content"
+                    android:layout_width="match_parent" >
+
+                    <android.support.v7.widget.Toolbar
+                        android:id="@+id/app_bar"
+                        android:layout_height="wrap_content"
+                        android:layout_width="match_parent"
+                        android:background="@color/gray_100"
+                        app:popupTheme="@style/LightPopupOverlay" />
+
+                    <!-- `android:max` changes the maximum `ProgressBar` value from 10000 to 100 to match progress percentage.
+                        `android:layout_height="2dp"` works best for API >= 23, but `3dp` is required for visibility on API <= 22.
+                        `tools:ignore="UnusedAttribute"` removes the lint waring about `progressTint` and `progressBackgroundTint` not applying to API < 21. -->
+                    <ProgressBar
+                        android:id="@+id/progress_bar"
+                        style="?android:attr/progressBarStyleHorizontal"
+                        android:layout_width="fill_parent"
+                        android:layout_height="3dp"
+                        android:layout_gravity="bottom"
+                        android:max="100"
+                        android:progressTint="@color/blue_700"
+                        android:progressBackgroundTint="@color/transparent"
+                        android:visibility="gone"
+                        tools:ignore="UnusedAttribute" />
+
+                    <include layout="@layout/find_on_page_app_bar" />
+                </FrameLayout>
+            </android.support.design.widget.AppBarLayout>
+
+            <include layout="@layout/main_webview" />
+        </LinearLayout>
+
+        <!-- `full_screen_video_framelayout` is used to display full screen videos.  It is initially `android:visibility="gone"` to hide it from view. -->
+        <FrameLayout
+            android:id="@+id/full_screen_video_framelayout"
+            android:layout_height="match_parent"
+            android:layout_width="match_parent"
+            android:visibility="gone"
+            android:background="@color/black" />
+    </android.support.design.widget.CoordinatorLayout>
+
+    <!-- The navigation drawer. -->
+    <android.support.design.widget.NavigationView
+        android:id="@+id/navigationview"
+        android:layout_height="match_parent"
+        android:layout_width="wrap_content"
+        android:layout_gravity="start"
+        app:headerLayout="@layout/navigation_header"
+        app:menu="@menu/webview_navigation_menu"
+        app:itemIconTint="@color/blue_800" />
+</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
index bda4ce531247632f70a13cedbff34e023b18d8f8..d395ac594eb97088106b21018264f3b12a41d622 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <!--
-  Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+  Copyright 2016-2017 Soren Stoutner <soren@stoutner.com>.
 
   This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
 
@@ -18,7 +18,7 @@
   You should have received a copy of the GNU General Public License
   along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
 
-<!-- android:layout_weight="1" sets the RelativeLayout to fill the rest of the screen because it is encapsulated in a LinearLayout with android:orientation="vertical". -->
+<!-- `android:layout_weight="1"` sets the `RelativeLayout` to fill the rest of the screen because it is encapsulated in a `LinearLayout` with `android:orientation="vertical"`. -->
 <RelativeLayout
     android:id="@+id/main_webview_relativelayout"
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_height="0dp"
     android:layout_weight="1"
     tools:context="com.stoutner.privacybrowser.activities.MainWebViewActivity"
-    tools:showIn="@layout/drawerlayout" >
+    tools:showIn="@layout/main_drawerlayout" >
 
     <!-- This `TextView` has an id of `adView` so that the ad commands (which do nothing in the standard flavor) don't produce errors. -->
     <TextView
-        android:id="@+id/adView"
+        android:id="@+id/adview"
         android:layout_height="wrap_content"
         android:layout_width="wrap_content"
         android:visibility="gone" />
 
     <android.support.v4.widget.SwipeRefreshLayout
-        android:id="@+id/swipeRefreshLayout"
+        android:id="@+id/swipe_refreshlayout"
         android:layout_width="match_parent"
         android:layout_height="match_parent" >
 
         <!-- Google does not currently want to support hiding the AppBar on scroll for a WebView child with the Support Toolbar.  https://code.google.com/p/android/issues/detail?id=200394 -->
         <WebView
-            android:id="@+id/mainWebView"
+            android:id="@+id/main_webview"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:focusable="true"
             android:focusableInTouchMode="true"/>
     </android.support.v4.widget.SwipeRefreshLayout>
-</RelativeLayout>
+</RelativeLayout>
\ No newline at end of file
index 34d6339f1529e844c3c36be80417f31a967d3ca6..377deff4340b5f025704cf8c204d5900db0d4564 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <!--
-  Copyright 2015-2016 Soren Stoutner <soren@stoutner.com>.
+  Copyright 2015-2017 Soren Stoutner <soren@stoutner.com>.
 
   This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
 
   You should have received a copy of the GNU General Public License
   along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
 
-<!-- `FrameLayout` lets the `ProgressBar` float on top of `urlTextBox`. -->
-<FrameLayout
-    android:id="@+id/url_app_bar_framelayout"
-    xmlns:tools="http://schemas.android.com/tools"
+<!-- `RelativeLayout` is used instead of a `LinearLayout` because `supportAppBar` does not let `android:layout_weight="1"` cause `urlTextBox` to fill all the available space. -->
+<RelativeLayout
+    android:id="@+id/url_app_bar_relativelayout"
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_height="wrap_content"
     android:layout_width="match_parent"
     tools:context=".activities.MainWebViewActivity" >
 
-    <!-- `RelativeLayout` is used instead of a `LinearLayout` because `supportAppBar` does not let `android:layout_weight="1"` cause `urlTextBox` to fill all the available space. -->
-    <RelativeLayout
+    <!-- Set `@drawable/world` as the initial `favoriteIcon`.
+        `layout_height` and `layout_width` of 26dp matches the `AppBar` icons. -->
+    <ImageView
+        android:id="@+id/favorite_icon"
+        android:src="@drawable/world"
+        android:layout_height="26dp"
+        android:layout_width="26dp"
+        android:layout_centerVertical="true"
+        android:onClick="viewSslCertificate"
+        android:contentDescription="@string/favorite_icon" />
+
+    <!-- `android:imeOptions="actionGo"` sets the keyboard to have a `go` key instead of a `new line` key.
+        `android:inputType="textUri"` disables spell check in the `EditText`. -->
+    <EditText
+        android:id="@+id/url_edittext"
         android:layout_height="wrap_content"
-        android:layout_width="match_parent" >
-
-        <!-- Set the program icon as the initial `favoriteIcon`.
-            `layout_height` and `layout_width` of 26dp matches the `AppBar` icons. -->
-        <ImageView
-            android:id="@+id/favoriteIcon"
-            android:src="@drawable/world"
-            android:layout_height="26dp"
-            android:layout_width="26dp"
-            android:layout_centerVertical="true"
-            android:onClick="viewSslCertificate"
-            android:contentDescription="@string/favorite_icon" />
-
-        <!-- `android:imeOptions="actionGo"` sets the keyboard to have a `go` key instead of a `new line` key.
-            `android:inputType="textUri"` disables spell check in the `EditText`. -->
-        <EditText
-            android:id="@+id/urlTextBox"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            android:layout_toEndOf="@id/favoriteIcon"
-            android:hint="@string/url_or_search_terms"
-            android:imeOptions="actionGo"
-            android:inputType="textUri" />
-    </RelativeLayout>
-
-    <!-- `android:max` changes the maximum `ProgressBar` value from 10000 to 100 to match progress percentage.
-        `android:layout_height="2dp"` works best for API 23 Marshmallow, but `3dp` is required for visibility on API <= 22.
-        `tools:ignore="UnusedAttribute"` removes the lint waring about `progressTint` and `progressBackgroundTint` not applying to API < 21. -->
-    <ProgressBar
-        android:id="@+id/progressBar"
-        style="?android:attr/progressBarStyleHorizontal"
-        android:layout_width="fill_parent"
-        android:layout_height="3dp"
-        android:layout_gravity="bottom"
-        android:max="100"
-        android:progressTint="@color/blue_700"
-        android:progressBackgroundTint="@color/white"
-        android:visibility="gone"
-        tools:ignore="UnusedAttribute" />
-</FrameLayout>
\ No newline at end of file
+        android:layout_width="match_parent"
+        android:layout_toEndOf="@id/favorite_icon"
+        android:hint="@string/url_or_search_terms"
+        android:imeOptions="actionGo"
+        android:inputType="textUri" />
+</RelativeLayout>
\ No newline at end of file