Implement a progress bar and switch the style to a light action bar.
authorSoren Stoutner <soren@stoutner.com>
Thu, 17 Sep 2015 02:44:27 +0000 (19:44 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 17 Sep 2015 02:44:27 +0000 (19:44 -0700)
app/app.iml
app/build.gradle
app/src/main/AndroidManifest.xml
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/styles.xml

index b50a32d..5faf579 100644 (file)
@@ -71,8 +71,8 @@
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
       <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
       <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
     </content>
-    <orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
+    <orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
-    <orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
-    <orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
+    <orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
+    <orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
+    <orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
   </component>
 </module>
\ No newline at end of file
index c749baa..5fb35bd 100644 (file)
@@ -1,13 +1,13 @@
 apply plugin: 'com.android.application'
 
 android {
-    compileSdkVersion 22
-    buildToolsVersion "22.0.1"
+    compileSdkVersion 23
+    buildToolsVersion "23.0.1"
 
     defaultConfig {
         applicationId "com.stoutner.privacybrowser"
         minSdkVersion 8
-        targetSdkVersion 22
+        targetSdkVersion 23
         versionCode 1
         versionName "1.0"
     }
@@ -21,5 +21,5 @@ android {
 
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
-    compile 'com.android.support:appcompat-v7:22.2.0'
+    compile 'com.android.support:appcompat-v7:23.0.1'
 }
index 17718ff..7774f93 100644 (file)
@@ -5,7 +5,8 @@
     <uses-permission android:name="android.permission.INTERNET" />
 
     <application
-        android:allowBackup="true"
+        android:allowBackup="false"
+        android:fullBackupContent="false"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/privacy_browser"
         android:theme="@style/AppTheme" >
index 6e8f237..cdb09a5 100644 (file)
@@ -3,24 +3,27 @@ package com.stoutner.privacybrowser;
 import android.app.Activity;
 import android.content.Intent;
 import android.net.Uri;
-import android.support.v7.app.ActionBarActivity;
 import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
 import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.inputmethod.InputMethodManager;
+import android.webkit.WebChromeClient;
 import android.webkit.WebView;
 import android.webkit.WebViewClient;
 import android.widget.EditText;
+import android.widget.ProgressBar;
 
 import java.net.URL;
 
 
-public class Webview extends ActionBarActivity {
+public class Webview extends AppCompatActivity {
 
     static String formattedUrlString;
     static WebView mainWebView;
+    static ProgressBar progressBar;
     static final String homepage = "https://www.duckduckgo.com";
 
     @Override
@@ -30,10 +33,23 @@ public class Webview extends ActionBarActivity {
 
         final EditText urlTextBox = (EditText) findViewById(R.id.urlTextBox);
         mainWebView = (WebView) findViewById(R.id.mainWebView);
+        progressBar = (ProgressBar) findViewById(R.id.progressBar);
 
         // setWebViewClient makes this WebView the default handler for URLs inside the app, so that links are not kicked out to other apps.
         mainWebView.setWebViewClient(new WebViewClient());
 
+        // Update the progress bar when a page is loading.
+        mainWebView.setWebChromeClient(new WebChromeClient() {
+            public void onProgressChanged(WebView view, int progress) {
+                if (progress < 100) {
+                    progressBar.setVisibility(View.VISIBLE);
+                } else {
+                    progressBar.setVisibility(View.GONE);
+                }
+                progressBar.setProgress(progress);
+            }
+        });
+
         // Allow pinch to zoom.
         mainWebView.getSettings().setBuiltInZoomControls(true);
 
index 2e4bc60..deb2b74 100644 (file)
@@ -13,7 +13,7 @@
 
         <EditText
             android:id="@+id/urlTextBox"
-            android:layout_width="wrap_content"
+            android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:inputType="textUri"
             android:imeOptions="actionGo"
             android:layout_height="wrap_content" />
     </LinearLayout>
 
-    <WebView
-        android:id="@+id/mainWebView"
+    <FrameLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_below="@+id/topBarLayout"
-        android:focusable="true"
-        android:focusableInTouchMode="true" />
+        tools:context=".MainActivity"
+        android:id="@+id/relativeLayout">
+
+        <WebView
+            android:id="@+id/mainWebView"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:focusable="true"
+            android:focusableInTouchMode="true" />
+
+        <ProgressBar
+            android:id="@+id/progressBar"
+            style="?android:attr/progressBarStyleHorizontal"
+            android:layout_width="fill_parent"
+            android:layout_height="7dp"
+            android:max="100"
+            android:progressTint="#FF29A8FF"
+            android:progressBackgroundTint="#FFFFFFFF"
+            android:visibility="gone" />
+    </FrameLayout>
+
 </RelativeLayout>
index 20c482e..d4493a5 100644 (file)
@@ -4,6 +4,7 @@
     xmlns:tools="http://schemas.android.com/tools"
     tools:context=".Webview">
 
+
     <item
         android:id="@+id/back"
         android:title="@string/back"
index 766ab99..92795d1 100644 (file)
@@ -1,7 +1,7 @@
 <resources>
 
     <!-- Base application theme. -->
-    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+    <style name="AppTheme" parent="Theme.AppCompat.Light">
         <!-- Customize your theme here. -->
     </style>