<dictionary name="soren">
<words>
<w>duckduckgo</w>
+ <w>webview</w>
</words>
</dictionary>
</component>
\ No newline at end of file
<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" />
</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
android {
compileSdkVersion 23
- buildToolsVersion "23.0.1"
+ buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.stoutner.privacybrowser"
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'
}
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;
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")
@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();
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.
progressBar.setVisibility(View.VISIBLE);
} else {
progressBar.setVisibility(View.GONE);
-
- // Stop the refreshing indicator if it is running.
- swipeToRefresh.setRefreshing(false);
}
}
mainWebView.loadUrl(homepage);
break;
+ case R.id.refresh:
+ mainWebView.loadUrl(formattedUrlString);
+ break;
+
case R.id.back:
mainWebView.goBack();
break;
-<!-- 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>
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"
<!-- Menu. -->
<string name="home">Home</string>
+ <string name="refresh">Refresh</string>
<string name="back">Back</string>
<string name="forward">Forward</string>
<!-- 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>