From: Soren Stoutner Date: Thu, 17 Sep 2015 02:44:27 +0000 (-0700) Subject: Implement a progress bar and switch the style to a light action bar. X-Git-Tag: v1.0~56 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=fda0da47d78471ff653a84832723a52551d32a21;p=PrivacyBrowserAndroid.git Implement a progress bar and switch the style to a light action bar. --- diff --git a/app/app.iml b/app/app.iml index b50a32da..5faf5798 100644 --- a/app/app.iml +++ b/app/app.iml @@ -71,8 +71,8 @@ - - + + @@ -88,10 +88,10 @@ - + - - - + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index c749baaf..5fb35bdb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 17718ffb..7774f930 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -5,7 +5,8 @@ diff --git a/app/src/main/java/com/stoutner/privacybrowser/Webview.java b/app/src/main/java/com/stoutner/privacybrowser/Webview.java index 6e8f237e..cdb09a51 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/Webview.java +++ b/app/src/main/java/com/stoutner/privacybrowser/Webview.java @@ -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); diff --git a/app/src/main/res/layout/activity_webview.xml b/app/src/main/res/layout/activity_webview.xml index 2e4bc603..deb2b745 100644 --- a/app/src/main/res/layout/activity_webview.xml +++ b/app/src/main/res/layout/activity_webview.xml @@ -13,7 +13,7 @@ - + tools:context=".MainActivity" + android:id="@+id/relativeLayout"> + + + + + + diff --git a/app/src/main/res/menu/menu_webview.xml b/app/src/main/res/menu/menu_webview.xml index 20c482e2..d4493a59 100644 --- a/app/src/main/res/menu/menu_webview.xml +++ b/app/src/main/res/menu/menu_webview.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" tools:context=".Webview"> + -