Fix issue #394
This commit is contained in:
parent
ffb1bcf510
commit
0341c6aaf4
|
@ -265,7 +265,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
||||||
webview_video.setVisibility(View.VISIBLE);
|
webview_video.setVisibility(View.VISIBLE);
|
||||||
playerView.setVisibility(View.GONE);
|
playerView.setVisibility(View.GONE);
|
||||||
|
|
||||||
webview_video = Helper.initializeWebview(PeertubeActivity.this, R.id.webview_video);
|
webview_video = Helper.initializeWebview(PeertubeActivity.this, R.id.webview_video, null);
|
||||||
FrameLayout webview_container = findViewById(R.id.main_media_frame);
|
FrameLayout webview_container = findViewById(R.id.main_media_frame);
|
||||||
final ViewGroup videoLayout = findViewById(R.id.videoLayout);
|
final ViewGroup videoLayout = findViewById(R.id.videoLayout);
|
||||||
|
|
||||||
|
|
|
@ -108,19 +108,13 @@ public class WebviewActivity extends BaseActivity {
|
||||||
if (getSupportActionBar() != null)
|
if (getSupportActionBar() != null)
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
webView = Helper.initializeWebview(WebviewActivity.this, R.id.webview);
|
webView = Helper.initializeWebview(WebviewActivity.this, R.id.webview, null);
|
||||||
setTitle("");
|
setTitle("");
|
||||||
FrameLayout webview_container = findViewById(R.id.webview_container);
|
FrameLayout webview_container = findViewById(R.id.webview_container);
|
||||||
final ViewGroup videoLayout = findViewById(R.id.videoLayout); // Your own view, read class comments
|
final ViewGroup videoLayout = findViewById(R.id.videoLayout); // Your own view, read class comments
|
||||||
webView.getSettings().setJavaScriptEnabled(true);
|
webView.getSettings().setJavaScriptEnabled(true);
|
||||||
|
|
||||||
|
|
||||||
boolean proxyEnabled = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false);
|
|
||||||
if (proxyEnabled) {
|
|
||||||
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
|
|
||||||
int port = sharedpreferences.getInt(Helper.SET_PROXY_PORT, 8118);
|
|
||||||
ProxyHelper.setProxy(getApplicationContext(), webView, host, port, WebviewActivity.class.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
MastalabWebChromeClient mastalabWebChromeClient = new MastalabWebChromeClient(WebviewActivity.this, webView, webview_container, videoLayout);
|
MastalabWebChromeClient mastalabWebChromeClient = new MastalabWebChromeClient(WebviewActivity.this, webView, webview_container, videoLayout);
|
||||||
mastalabWebChromeClient.setOnToggledFullscreen(new MastalabWebChromeClient.ToggledFullscreenCallback() {
|
mastalabWebChromeClient.setOnToggledFullscreen(new MastalabWebChromeClient.ToggledFullscreenCallback() {
|
||||||
|
|
|
@ -158,12 +158,6 @@ public class WebviewConnectActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
boolean proxyEnabled = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false);
|
|
||||||
if (proxyEnabled) {
|
|
||||||
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
|
|
||||||
int port = sharedpreferences.getInt(Helper.SET_PROXY_PORT, 8118);
|
|
||||||
ProxyHelper.setProxy(getApplicationContext(), webView, host, port, WebviewConnectActivity.class.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
webView.setWebViewClient(new WebViewClient() {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
|
|
@ -186,6 +186,7 @@ public class HttpsConnection {
|
||||||
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
|
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
|
||||||
httpsURLConnection.setRequestProperty("Accept", "application/json");
|
httpsURLConnection.setRequestProperty("Accept", "application/json");
|
||||||
|
httpsURLConnection.setUseCaches(true);
|
||||||
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
||||||
if (token != null && !token.startsWith("Basic "))
|
if (token != null && !token.startsWith("Basic "))
|
||||||
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
|
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
|
||||||
|
@ -282,9 +283,10 @@ public class HttpsConnection {
|
||||||
httpsURLConnection.setRequestProperty("http.keepAlive", "false");
|
httpsURLConnection.setRequestProperty("http.keepAlive", "false");
|
||||||
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
|
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
|
||||||
httpsURLConnection.setRequestProperty("Accept", "application/json");
|
httpsURLConnection.setRequestProperty("Accept", "application/json");
|
||||||
httpsURLConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36");
|
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
||||||
httpsURLConnection.setRequestMethod("GET");
|
httpsURLConnection.setRequestMethod("GET");
|
||||||
|
httpsURLConnection.setUseCaches(true);
|
||||||
String response;
|
String response;
|
||||||
if (httpsURLConnection.getResponseCode() >= 200 && httpsURLConnection.getResponseCode() < 400) {
|
if (httpsURLConnection.getResponseCode() >= 200 && httpsURLConnection.getResponseCode() < 400) {
|
||||||
getSinceMaxId();
|
getSinceMaxId();
|
||||||
|
|
|
@ -4376,6 +4376,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
fetch_more = itemView.findViewById(R.id.fetch_more);
|
fetch_more = itemView.findViewById(R.id.fetch_more);
|
||||||
webview_preview_card = itemView.findViewById(R.id.webview_preview_card);
|
webview_preview_card = itemView.findViewById(R.id.webview_preview_card);
|
||||||
webview_preview = itemView.findViewById(R.id.webview_preview);
|
webview_preview = itemView.findViewById(R.id.webview_preview);
|
||||||
|
|
||||||
status_horizontal_document_container = itemView.findViewById(R.id.status_horizontal_document_container);
|
status_horizontal_document_container = itemView.findViewById(R.id.status_horizontal_document_container);
|
||||||
status_document_container = itemView.findViewById(R.id.status_document_container);
|
status_document_container = itemView.findViewById(R.id.status_document_container);
|
||||||
status_horizontal_document_container = itemView.findViewById(R.id.status_horizontal_document_container);
|
status_horizontal_document_container = itemView.findViewById(R.id.status_horizontal_document_container);
|
||||||
|
@ -4437,7 +4438,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
status_cardview_content = itemView.findViewById(R.id.status_cardview_content);
|
status_cardview_content = itemView.findViewById(R.id.status_cardview_content);
|
||||||
status_cardview_url = itemView.findViewById(R.id.status_cardview_url);
|
status_cardview_url = itemView.findViewById(R.id.status_cardview_url);
|
||||||
status_cardview_video = itemView.findViewById(R.id.status_cardview_video);
|
status_cardview_video = itemView.findViewById(R.id.status_cardview_video);
|
||||||
status_cardview_webview = itemView.findViewById(R.id.status_cardview_webview);
|
//status_cardview_webview = itemView.findViewById(R.id.status_cardview_webview);
|
||||||
|
status_cardview_webview = Helper.initializeWebview((Activity) context, R.id.status_cardview_webview, itemView);
|
||||||
|
status_cardview_webview.getSettings().setJavaScriptEnabled(true);
|
||||||
hide_preview = itemView.findViewById(R.id.hide_preview);
|
hide_preview = itemView.findViewById(R.id.hide_preview);
|
||||||
hide_preview_h = itemView.findViewById(R.id.hide_preview_h);
|
hide_preview_h = itemView.findViewById(R.id.hide_preview_h);
|
||||||
status_toot_app = itemView.findViewById(R.id.status_toot_app);
|
status_toot_app = itemView.findViewById(R.id.status_toot_app);
|
||||||
|
|
|
@ -263,7 +263,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
||||||
break;
|
break;
|
||||||
case "web":
|
case "web":
|
||||||
loader.setVisibility(View.GONE);
|
loader.setVisibility(View.GONE);
|
||||||
webview_video = Helper.initializeWebview((Activity) context, R.id.webview_video);
|
webview_video = Helper.initializeWebview((Activity) context, R.id.webview_video, null);
|
||||||
webview_video.setVisibility(View.VISIBLE);
|
webview_video.setVisibility(View.VISIBLE);
|
||||||
FrameLayout webview_container = rootView.findViewById(R.id.main_media_frame);
|
FrameLayout webview_container = rootView.findViewById(R.id.main_media_frame);
|
||||||
final ViewGroup videoLayout = rootView.findViewById(R.id.videoLayout);
|
final ViewGroup videoLayout = rootView.findViewById(R.id.videoLayout);
|
||||||
|
|
|
@ -228,9 +228,11 @@ import app.fedilab.android.sqlite.Sqlite;
|
||||||
import app.fedilab.android.sqlite.StatusCacheDAO;
|
import app.fedilab.android.sqlite.StatusCacheDAO;
|
||||||
import app.fedilab.android.sqlite.TimelineCacheDAO;
|
import app.fedilab.android.sqlite.TimelineCacheDAO;
|
||||||
import app.fedilab.android.webview.CustomWebview;
|
import app.fedilab.android.webview.CustomWebview;
|
||||||
|
import app.fedilab.android.webview.ProxyHelper;
|
||||||
import es.dmoral.toasty.Toasty;
|
import es.dmoral.toasty.Toasty;
|
||||||
import info.guardianproject.netcipher.client.StrongBuilder;
|
import info.guardianproject.netcipher.client.StrongBuilder;
|
||||||
import info.guardianproject.netcipher.client.StrongOkHttpClientBuilder;
|
import info.guardianproject.netcipher.client.StrongOkHttpClientBuilder;
|
||||||
|
import okhttp3.Cache;
|
||||||
import okhttp3.ConnectionSpec;
|
import okhttp3.ConnectionSpec;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.TlsVersion;
|
import okhttp3.TlsVersion;
|
||||||
|
@ -2462,9 +2464,14 @@ public class Helper {
|
||||||
return spannableString;
|
return spannableString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CustomWebview initializeWebview(Activity activity, int webviewId) {
|
public static CustomWebview initializeWebview(Activity activity, int webviewId, View rootView) {
|
||||||
|
|
||||||
CustomWebview webView = activity.findViewById(webviewId);
|
CustomWebview webView;
|
||||||
|
if( rootView == null) {
|
||||||
|
webView = activity.findViewById(webviewId);
|
||||||
|
}else{
|
||||||
|
webView = rootView.findViewById(webviewId);
|
||||||
|
}
|
||||||
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
boolean javascript = sharedpreferences.getBoolean(Helper.SET_JAVASCRIPT, true);
|
boolean javascript = sharedpreferences.getBoolean(Helper.SET_JAVASCRIPT, true);
|
||||||
|
|
||||||
|
@ -2492,6 +2499,13 @@ public class Helper {
|
||||||
webView.getSettings().setDatabaseEnabled(true);
|
webView.getSettings().setDatabaseEnabled(true);
|
||||||
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
|
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||||
|
|
||||||
|
boolean proxyEnabled = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false);
|
||||||
|
if (proxyEnabled) {
|
||||||
|
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
|
||||||
|
int port = sharedpreferences.getInt(Helper.SET_PROXY_PORT, 8118);
|
||||||
|
ProxyHelper.setProxy(activity, webView, host, port, WebviewActivity.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
return webView;
|
return webView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4372,14 +4386,16 @@ public class Helper {
|
||||||
public static OkHttpClient getHttpClient(Context context) {
|
public static OkHttpClient getHttpClient(Context context) {
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
boolean proxyEnabled = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false);
|
boolean proxyEnabled = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false);
|
||||||
|
int cacheSize = 30*1024*1024;
|
||||||
|
Cache cache = new Cache(context.getCacheDir(), cacheSize);
|
||||||
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder()
|
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder()
|
||||||
.followRedirects(true)
|
.followRedirects(true)
|
||||||
.followSslRedirects(true)
|
.followSslRedirects(true)
|
||||||
.retryOnConnectionFailure(true)
|
.retryOnConnectionFailure(true)
|
||||||
.connectTimeout(15, TimeUnit.SECONDS)
|
.connectTimeout(15, TimeUnit.SECONDS)
|
||||||
.writeTimeout(30, TimeUnit.SECONDS)
|
.writeTimeout(120, TimeUnit.SECONDS)
|
||||||
.readTimeout(30, TimeUnit.SECONDS)
|
.readTimeout(30, TimeUnit.SECONDS)
|
||||||
.cache(null);
|
.cache(cache);
|
||||||
if (proxyEnabled) {
|
if (proxyEnabled) {
|
||||||
Proxy proxy;
|
Proxy proxy;
|
||||||
int type = sharedpreferences.getInt(Helper.SET_PROXY_TYPE, 0);
|
int type = sharedpreferences.getInt(Helper.SET_PROXY_TYPE, 0);
|
||||||
|
|
|
@ -31,13 +31,7 @@ public class ProxyHelper {
|
||||||
|
|
||||||
public static void setProxy(Context context, CustomWebview webview, String host, int port, String applicationClassName) {
|
public static void setProxy(Context context, CustomWebview webview, String host, int port, String applicationClassName) {
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT <= 18) {
|
setProxyKKPlus(context, webview, host, port, applicationClassName);
|
||||||
setProxyJB(webview, host, port);
|
|
||||||
}
|
|
||||||
// 4.4 (KK) & 5.0 (Lollipop)
|
|
||||||
else {
|
|
||||||
setProxyKKPlus(context, webview, host, port, applicationClassName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue