]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Remove swipe to refresh and add app bar scrolling (which appear to not be compatible...
authorSoren Stoutner <soren@stoutner.com>
Thu, 12 Nov 2015 03:16:58 +0000 (20:16 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 12 Nov 2015 03:16:58 +0000 (20:16 -0700)
.idea/dictionaries/soren.xml
app/app.iml
app/build.gradle
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
app/src/main/res/values/styles.xml

index 750cd2214f2b869b33aa84a209cb26d64beb16dd..5c98ab4c778da94babf4c2a9cac095ca40d42203 100644 (file)
@@ -2,6 +2,7 @@
   <dictionary name="soren">
     <words>
       <w>duckduckgo</w>
+      <w>webview</w>
     </words>
   </dictionary>
 </component>
\ No newline at end of file
index 84d6657d454e86ad667166a87f299d5b7ad39f38..c4326d48800c269d70c8df3c21383041b81865ad 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/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/exploded-aar/com.android.support/appcompat-v7/23.1.0/jars" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.0/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" />
@@ -90,8 +90,8 @@
     </content>
     <orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
-    <orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
-    <orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
+    <orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
+    <orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
+    <orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
   </component>
 </module>
\ No newline at end of file
index 5fb35bdb8fec8d61939c2665bb6758ce46706e76..1f926caa8fa62601b50ecf752f2e213b0c8f3031 100644 (file)
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
 
 android {
     compileSdkVersion 23
-    buildToolsVersion "23.0.1"
+    buildToolsVersion "23.0.2"
 
     defaultConfig {
         applicationId "com.stoutner.privacybrowser"
@@ -21,5 +21,5 @@ android {
 
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
-    compile 'com.android.support:appcompat-v7:23.0.1'
+    compile 'com.android.support:appcompat-v7:23.1.0'
 }
index 7b0cf3065d99973369c3c258e5d614216415cf34..ff718ff961bd5a43f83b752bc35f00cec61b1c72 100644 (file)
@@ -6,16 +6,14 @@ import android.content.Intent;
 import android.graphics.Bitmap;
 import android.net.Uri;
 import android.os.Bundle;
-import android.support.v4.widget.SwipeRefreshLayout;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.AppCompatActivity;
+import android.support.v7.app.AppCompatDelegate;
 import android.util.Patterns;
 import android.view.KeyEvent;
 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;
@@ -33,10 +31,9 @@ public class Webview extends AppCompatActivity {
     static String formattedUrlString;
     static WebView mainWebView;
     static ProgressBar progressBar;
-    static SwipeRefreshLayout swipeToRefresh;
     static EditText urlTextBox;
     static ImageView favoriteIcon;
-    static final String homepage = "https://www.duckduckgo.com";
+    static final String homepage = "https://www.google.com/";
 
     // Remove Android Studio's warning about the dangers of using SetJavaScriptEnabled.
     @SuppressLint("SetJavaScriptEnabled")
@@ -44,9 +41,12 @@ public class Webview extends AppCompatActivity {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+
+        // FEATURE_ACTION_BAR_OVERLAY is required to scroll the actionBar.
+        supportRequestWindowFeature(AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR_OVERLAY);
+
         setContentView(R.layout.activity_webview);
 
-        swipeToRefresh = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayoutContainer);
         mainWebView = (WebView) findViewById(R.id.mainWebView);
 
         final ActionBar actionBar = getSupportActionBar();
@@ -63,30 +63,10 @@ public class Webview extends AppCompatActivity {
             urlTextBox = (EditText) actionBar.getCustomView().findViewById(R.id.urlTextBox);
             progressBar = (ProgressBar) actionBar.getCustomView().findViewById(R.id.progressBar);
 
-            // TODO actionBar.setHideOnContentScrollEnabled(true);
+            // Scroll the actionBar.
+            actionBar.setHideOnContentScrollEnabled(true);
         }
 
-        // Implement swipe down to refresh.
-        swipeToRefresh.setColorSchemeColors(0xFF0097FF);
-        swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
-            @Override
-            public void onRefresh() {
-                mainWebView.loadUrl(formattedUrlString);
-            }
-        });
-
-        // Only enable swipeToRefresh if is mainWebView is scrolled to the top.
-        mainWebView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
-            @Override
-            public void onScrollChanged() {
-                if (mainWebView.getScrollY() == 0) {
-                    swipeToRefresh.setEnabled(true);
-                } else {
-                    swipeToRefresh.setEnabled(false);
-                }
-            }
-        });
-
         mainWebView.setWebViewClient(new WebViewClient() {
 
             // setWebViewClient makes this WebView the default handler for URLs inside the app, so that links are not kicked out to other apps.
@@ -121,9 +101,6 @@ public class Webview extends AppCompatActivity {
                     progressBar.setVisibility(View.VISIBLE);
                 } else {
                     progressBar.setVisibility(View.GONE);
-
-                    // Stop the refreshing indicator if it is running.
-                    swipeToRefresh.setRefreshing(false);
                 }
             }
 
@@ -202,6 +179,10 @@ public class Webview extends AppCompatActivity {
                 mainWebView.loadUrl(homepage);
                 break;
 
+            case R.id.refresh:
+                mainWebView.loadUrl(formattedUrlString);
+                break;
+
             case R.id.back:
                 mainWebView.goBack();
                 break;
index 2e968f3db7a28aa7c5ff563b54f6a1e567a33ab2..d085905f54cc039cae26715eaf794b2e5845955d 100644 (file)
@@ -1,15 +1,18 @@
-<!-- SwipeRefreshLayout allows the user to swipe down to refresh. -->
-<android.support.v4.widget.SwipeRefreshLayout
-    android:id="@+id/swipeRefreshLayoutContainer"
+<!-- nextedScrollingEnabled is required to enable scrolling of the actionBar. -->
+<ScrollView
+    android:id="@+id/scrollView"
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:nestedScrollingEnabled="true" >
 
-    <WebView
-        android:id="@+id/mainWebView"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:focusable="true"
-        android:focusableInTouchMode="true"/>
+        <!-- layout_marginTop is required to force the top of the website below the overlayed actionBar. -->
+        <WebView
+            android:id="@+id/mainWebView"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:focusable="true"
+            android:focusableInTouchMode="true"
+            android:layout_marginTop="?attr/actionBarSize"/>
 
-</android.support.v4.widget.SwipeRefreshLayout>
+</ScrollView>
index fddbcc68ecb41883c45eecd4e1aabcd6352d7b6c..a2feb8733d6ec5cdca358875046b8279d7e44e05 100644 (file)
         android:icon="@drawable/ic_home_black_24dp"
         app:showAsAction="never" />
 
+    <item
+        android:id="@+id/refresh"
+        android:title="@string/refresh"
+        android:orderInCategory="200"
+        app:showAsAction="never" />
+
     <item
         android:id="@+id/back"
         android:title="@string/back"
index a87e46d45f60305efc16b590af8537fb18da3e04..71142ba84e239b21caa0bb884a01ef714902d9d8 100644 (file)
@@ -7,6 +7,7 @@
 
     <!-- Menu. -->
     <string name="home">Home</string>
+    <string name="refresh">Refresh</string>
     <string name="back">Back</string>
     <string name="forward">Forward</string>
 
index 8ccbef5c7562d2abaaca15197b9c2ab9d3d31da4..dc7da63b96d3149126acc4ab9b0496d1d1c54a68 100644 (file)
@@ -2,9 +2,7 @@
 
     <!-- Base application theme. -->
     <style name="AppTheme" parent="Theme.AppCompat.Light">
-        <!-- TODO windowActionBarOverlay is necessary for scrolling the app bar.
-        <item name="android:windowActionBarOverlay">true</item>
-        <item name="windowActionBarOverlay">true</item> -->
+        <!-- Customize style here. -->
     </style>
 
 </resources>