Fix Webview issue
This commit is contained in:
parent
6d9f7357df
commit
44756862e3
|
@ -99,6 +99,7 @@ import app.fedilab.android.interfaces.OnPlaylistActionInterface;
|
|||
import app.fedilab.android.sqlite.AccountDAO;
|
||||
import app.fedilab.android.sqlite.PeertubeFavoritesDAO;
|
||||
import app.fedilab.android.sqlite.Sqlite;
|
||||
import app.fedilab.android.webview.CustomWebview;
|
||||
import app.fedilab.android.webview.MastalabWebChromeClient;
|
||||
import app.fedilab.android.webview.MastalabWebViewClient;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
@ -180,7 +181,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
|
|||
peertube_description = findViewById(R.id.peertube_description);
|
||||
peertube_title = findViewById(R.id.peertube_title);
|
||||
peertube_information_container = findViewById(R.id.peertube_information_container);
|
||||
WebView webview_video = findViewById(R.id.webview_video);
|
||||
CustomWebview webview_video = findViewById(R.id.webview_video);
|
||||
playerView = findViewById(R.id.media_video);
|
||||
write_comment_container = findViewById(R.id.write_comment_container);
|
||||
my_pp = findViewById(R.id.my_pp);
|
||||
|
|
|
@ -55,6 +55,7 @@ import app.fedilab.android.helper.CountDrawable;
|
|||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.sqlite.DomainBlockDAO;
|
||||
import app.fedilab.android.sqlite.Sqlite;
|
||||
import app.fedilab.android.webview.CustomWebview;
|
||||
import app.fedilab.android.webview.MastalabWebChromeClient;
|
||||
import app.fedilab.android.webview.MastalabWebViewClient;
|
||||
import app.fedilab.android.webview.ProxyHelper;
|
||||
|
@ -72,7 +73,7 @@ public class WebviewActivity extends BaseActivity {
|
|||
private String url;
|
||||
private String peertubeLinkToFetch;
|
||||
private boolean peertubeLink;
|
||||
private WebView webView;
|
||||
private CustomWebview webView;
|
||||
public static List<String> trackingDomains;
|
||||
private Menu defaultMenu;
|
||||
private MastalabWebViewClient mastalabWebViewClient;
|
||||
|
|
|
@ -48,6 +48,7 @@ import java.util.HashMap;
|
|||
|
||||
import app.fedilab.android.client.HttpsConnection;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.webview.CustomWebview;
|
||||
import app.fedilab.android.webview.ProxyHelper;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
import app.fedilab.android.R;
|
||||
|
@ -60,7 +61,7 @@ import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
|
|||
public class WebviewConnectActivity extends BaseActivity {
|
||||
|
||||
|
||||
private WebView webView;
|
||||
private CustomWebview webView;
|
||||
private AlertDialog alert;
|
||||
private String clientId, clientSecret;
|
||||
private String instance;
|
||||
|
|
|
@ -152,6 +152,7 @@ import app.fedilab.android.sqlite.StatusStoredDAO;
|
|||
import app.fedilab.android.sqlite.TempMuteDAO;
|
||||
import app.fedilab.android.sqlite.TimelineCacheDAO;
|
||||
import app.fedilab.android.sqlite.TimelinesDAO;
|
||||
import app.fedilab.android.webview.CustomWebview;
|
||||
import br.com.felix.horizontalbargraph.HorizontalBar;
|
||||
import br.com.felix.horizontalbargraph.model.BarItem;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
@ -669,7 +670,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
ImageView status_cardview_image;
|
||||
TextView status_cardview_title, status_cardview_content, status_cardview_url;
|
||||
FrameLayout status_cardview_video;
|
||||
WebView status_cardview_webview;
|
||||
CustomWebview status_cardview_webview;
|
||||
ImageView hide_preview, hide_preview_h;
|
||||
TextView status_toot_app;
|
||||
RelativeLayout webview_preview;
|
||||
|
|
|
@ -66,6 +66,7 @@ import app.fedilab.android.activities.SlideMediaActivity;
|
|||
import app.fedilab.android.client.Entities.Attachment;
|
||||
import app.fedilab.android.client.TLSSocketFactory;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.webview.CustomWebview;
|
||||
import app.fedilab.android.webview.MastalabWebChromeClient;
|
||||
import app.fedilab.android.webview.MastalabWebViewClient;
|
||||
|
||||
|
@ -122,7 +123,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
|
|||
message_ready = rootView.findViewById(R.id.message_ready);
|
||||
|
||||
TextView progress = rootView.findViewById(R.id.loader_progress);
|
||||
WebView webview_video = rootView.findViewById(R.id.webview_video);
|
||||
CustomWebview webview_video = rootView.findViewById(R.id.webview_video);
|
||||
RelativeLayout content_audio = rootView.findViewById(R.id.content_audio);
|
||||
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
|
|
|
@ -215,6 +215,7 @@ import app.fedilab.android.fragments.ContentSettingsFragment;
|
|||
import app.fedilab.android.sqlite.MainMenuDAO;
|
||||
import app.fedilab.android.sqlite.StatusCacheDAO;
|
||||
import app.fedilab.android.sqlite.TimelineCacheDAO;
|
||||
import app.fedilab.android.webview.CustomWebview;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.BaseMainActivity;
|
||||
|
@ -2571,9 +2572,9 @@ public class Helper {
|
|||
}
|
||||
|
||||
|
||||
public static WebView initializeWebview(Activity activity, int webviewId) {
|
||||
public static CustomWebview initializeWebview(Activity activity, int webviewId) {
|
||||
|
||||
WebView webView = activity.findViewById(webviewId);
|
||||
CustomWebview webView = activity.findViewById(webviewId);
|
||||
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean javascript = sharedpreferences.getBoolean(Helper.SET_JAVASCRIPT, true);
|
||||
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package app.fedilab.android.webview;
|
||||
/* Copyright 2019 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Fedilab
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.webkit.WebView;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Thomas on 14/10/2019.
|
||||
* CustomWebview
|
||||
*/
|
||||
|
||||
public class CustomWebview extends WebView {
|
||||
|
||||
|
||||
public CustomWebview(Context context) {
|
||||
super(getFixedContext(context));
|
||||
}
|
||||
|
||||
public CustomWebview(Context context, AttributeSet attrs) {
|
||||
super(getFixedContext(context), attrs);
|
||||
}
|
||||
|
||||
public CustomWebview(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(getFixedContext(context), attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public CustomWebview(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(getFixedContext(context), attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public CustomWebview(Context context, AttributeSet attrs, int defStyleAttr, boolean privateBrowsing) {
|
||||
super(getFixedContext(context), attrs, defStyleAttr, privateBrowsing);
|
||||
}
|
||||
|
||||
public static Context getFixedContext(Context context) {
|
||||
return context.createConfigurationContext(new Configuration());
|
||||
}
|
||||
}
|
|
@ -48,7 +48,7 @@ public class MastalabWebChromeClient extends WebChromeClient implements MediaPla
|
|||
|
||||
private ToggledFullscreenCallback toggledFullscreenCallback;
|
||||
|
||||
private WebView webView;
|
||||
private CustomWebview webView;
|
||||
private View activityNonVideoView;
|
||||
private ViewGroup activityVideoView;
|
||||
private ProgressBar pbar;
|
||||
|
@ -60,7 +60,7 @@ public class MastalabWebChromeClient extends WebChromeClient implements MediaPla
|
|||
void toggledFullscreen(boolean fullscreen);
|
||||
}
|
||||
|
||||
public MastalabWebChromeClient(Activity activity, WebView webView, FrameLayout activityNonVideoView, ViewGroup activityVideoView) {
|
||||
public MastalabWebChromeClient(Activity activity, CustomWebview webView, FrameLayout activityNonVideoView, ViewGroup activityVideoView) {
|
||||
this.activity = activity;
|
||||
this.isVideoFullscreen = false;
|
||||
this.webView = webView;
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.lang.reflect.Method;
|
|||
public class ProxyHelper {
|
||||
|
||||
|
||||
public static void setProxy(Context context, WebView 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) {
|
||||
setProxyJB(webview, host, port);
|
||||
|
@ -44,7 +44,7 @@ public class ProxyHelper {
|
|||
|
||||
|
||||
@SuppressWarnings("all")
|
||||
private static boolean setProxyICS(WebView webview, String host, int port) {
|
||||
private static boolean setProxyICS(CustomWebview webview, String host, int port) {
|
||||
try {
|
||||
Class jwcjb = Class.forName("android.webkit.JWebCoreJavaBridge");
|
||||
Class params[] = new Class[1];
|
||||
|
@ -81,7 +81,7 @@ public class ProxyHelper {
|
|||
* Set Proxy for Android 4.1 - 4.3.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
private static boolean setProxyJB(WebView webview, String host, int port) {
|
||||
private static boolean setProxyJB(CustomWebview webview, String host, int port) {
|
||||
|
||||
try {
|
||||
Class wvcClass = Class.forName("android.webkit.WebViewClassic");
|
||||
|
@ -124,7 +124,7 @@ public class ProxyHelper {
|
|||
// from https://stackoverflow.com/questions/19979578/android-webview-set-proxy-programatically-kitkat
|
||||
@SuppressLint("NewApi")
|
||||
@SuppressWarnings("all")
|
||||
private static void setProxyKKPlus(Context appContext, WebView webView, String host, int port, String applicationClassName) {
|
||||
private static void setProxyKKPlus(Context appContext, CustomWebview webView, String host, int port, String applicationClassName) {
|
||||
|
||||
System.setProperty("http.proxyHost", host);
|
||||
System.setProperty("http.proxyPort", port + "");
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:gravity="center" />
|
||||
|
||||
<WebView
|
||||
<app.fedilab.android.webview.CustomWebview
|
||||
android:layout_width="match_parent"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/webview_video"
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<WebView
|
||||
<app.fedilab.android.webview.CustomWebview
|
||||
android:id="@+id/webview"
|
||||
android:background="@color/white"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
android:layout_height="10dp"
|
||||
android:padding="2dp"></ProgressBar>
|
||||
|
||||
<WebView
|
||||
<app.fedilab.android.webview.CustomWebview
|
||||
android:id="@+id/webviewConnect"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
|
|
@ -480,7 +480,7 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<WebView
|
||||
<app.fedilab.android.webview.CustomWebview
|
||||
android:id="@+id/status_cardview_webview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -395,7 +395,7 @@
|
|||
android:contentDescription="@string/play_video" />
|
||||
</RelativeLayout>
|
||||
|
||||
<WebView
|
||||
<app.fedilab.android.webview.CustomWebview
|
||||
android:visibility="gone"
|
||||
android:id="@+id/status_cardview_webview"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -391,7 +391,7 @@
|
|||
android:contentDescription="@string/play_video" />
|
||||
</RelativeLayout>
|
||||
|
||||
<WebView
|
||||
<app.fedilab.android.webview.CustomWebview
|
||||
android:visibility="gone"
|
||||
android:id="@+id/status_cardview_webview"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -318,7 +318,7 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<WebView
|
||||
<app.fedilab.android.webview.CustomWebview
|
||||
android:visibility="gone"
|
||||
android:id="@+id/status_cardview_webview"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<WebView
|
||||
<app.fedilab.android.webview.CustomWebview
|
||||
android:layout_width="match_parent"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/webview_video"
|
||||
|
|
Loading…
Reference in New Issue