Merge pull request #702 from dosiecki/master

Android: Ensure links in stories open in browser on all platforms. (#700)
This commit is contained in:
Samuel Clay 2015-06-08 21:10:42 -07:00
commit 9b98f9f62e

View file

@ -1,6 +1,8 @@
package com.newsblur.view;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
@ -8,12 +10,13 @@ import android.util.AttributeSet;
import android.util.Log;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.newsblur.util.AppConstants;
public class NewsblurWebview extends WebView {
public NewsblurWebview(Context context, AttributeSet attrs) {
public NewsblurWebview(final Context context, AttributeSet attrs) {
super(context, attrs);
setVerticalScrollBarEnabled(false);
@ -27,18 +30,23 @@ public class NewsblurWebview extends WebView {
getSettings().setAppCachePath("/data/data/com.newsblur/cache");
getSettings().setAllowFileAccess(true);
getSettings().setAppCacheEnabled(true);
this.setScrollBarStyle(SCROLLBARS_INSIDE_OVERLAY);
}
public void onPause() {
// TODO: is there anything more we can do to get media content to stop playing on pause?
super.onPause();
}
public void onResume() {
// TODO: restore media content if it was disabled above
super.onResume();
}
this.setScrollBarStyle(SCROLLBARS_INSIDE_OVERLAY);
// as of v43.0.2357.121 of the system WebView, links no longer open in the user's chosen
// browser, but open in-app. Override the default behaviour so it works as expected on
// all devices.
setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Uri uri = Uri.parse(url);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(uri);
context.startActivity(i);
return true;
}
});
}
public void setTextSize(float textSize) {
Log.d("Reading", "Setting textsize to " + textSize);