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);
|
||||
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);
|
||||
final ViewGroup videoLayout = findViewById(R.id.videoLayout);
|
||||
|
||||
|
|
|
@ -108,19 +108,13 @@ public class WebviewActivity extends BaseActivity {
|
|||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
webView = Helper.initializeWebview(WebviewActivity.this, R.id.webview);
|
||||
webView = Helper.initializeWebview(WebviewActivity.this, R.id.webview, null);
|
||||
setTitle("");
|
||||
FrameLayout webview_container = findViewById(R.id.webview_container);
|
||||
final ViewGroup videoLayout = findViewById(R.id.videoLayout); // Your own view, read class comments
|
||||
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.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() {
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
|
@ -186,6 +186,7 @@ public class HttpsConnection {
|
|||
httpsURLConnection.setRequestProperty("User-Agent", USER_AGENT);
|
||||
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
|
||||
httpsURLConnection.setRequestProperty("Accept", "application/json");
|
||||
httpsURLConnection.setUseCaches(true);
|
||||
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
|
||||
if (token != null && !token.startsWith("Basic "))
|
||||
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
|
||||
|
@ -282,9 +283,10 @@ public class HttpsConnection {
|
|||
httpsURLConnection.setRequestProperty("http.keepAlive", "false");
|
||||
httpsURLConnection.setRequestProperty("Content-Type", "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.setRequestMethod("GET");
|
||||
httpsURLConnection.setUseCaches(true);
|
||||
String response;
|
||||
if (httpsURLConnection.getResponseCode() >= 200 && httpsURLConnection.getResponseCode() < 400) {
|
||||
getSinceMaxId();
|
||||
|
|
|
@ -4376,6 +4376,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
fetch_more = itemView.findViewById(R.id.fetch_more);
|
||||
webview_preview_card = itemView.findViewById(R.id.webview_preview_card);
|
||||
webview_preview = itemView.findViewById(R.id.webview_preview);
|
||||
|
||||
status_horizontal_document_container = itemView.findViewById(R.id.status_horizontal_document_container);
|
||||
status_document_container = itemView.findViewById(R.id.status_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_url = itemView.findViewById(R.id.status_cardview_url);
|
||||
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_h = itemView.findViewById(R.id.hide_preview_h);
|
||||
status_toot_app = itemView.findViewById(R.id.status_toot_app);
|
||||
|
|
|
@ -263,7 +263,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
break;
|
||||
case "web":
|
||||
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);
|
||||
FrameLayout webview_container = rootView.findViewById(R.id.main_media_frame);
|
||||
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.TimelineCacheDAO;
|
||||
import app.fedilab.android.webview.CustomWebview;
|
||||
import app.fedilab.android.webview.ProxyHelper;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
import info.guardianproject.netcipher.client.StrongBuilder;
|
||||
import info.guardianproject.netcipher.client.StrongOkHttpClientBuilder;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.ConnectionSpec;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.TlsVersion;
|
||||
|
@ -2462,9 +2464,14 @@ public class Helper {
|
|||
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);
|
||||
boolean javascript = sharedpreferences.getBoolean(Helper.SET_JAVASCRIPT, true);
|
||||
|
||||
|
@ -2492,6 +2499,13 @@ public class Helper {
|
|||
webView.getSettings().setDatabaseEnabled(true);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -4372,14 +4386,16 @@ public class Helper {
|
|||
public static OkHttpClient getHttpClient(Context context) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
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()
|
||||
.followRedirects(true)
|
||||
.followSslRedirects(true)
|
||||
.retryOnConnectionFailure(true)
|
||||
.connectTimeout(15, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS)
|
||||
.writeTimeout(120, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.cache(null);
|
||||
.cache(cache);
|
||||
if (proxyEnabled) {
|
||||
Proxy proxy;
|
||||
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) {
|
||||
|
||||
if (Build.VERSION.SDK_INT <= 18) {
|
||||
setProxyJB(webview, host, port);
|
||||
}
|
||||
// 4.4 (KK) & 5.0 (Lollipop)
|
||||
else {
|
||||
setProxyKKPlus(context, webview, host, port, applicationClassName);
|
||||
}
|
||||
setProxyKKPlus(context, webview, host, port, applicationClassName);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue