This commit is contained in:
Thomas 2020-04-25 11:18:42 +02:00
parent 9ebae35817
commit e848b7e517
18 changed files with 87 additions and 28 deletions

View File

@ -40,7 +40,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.FrameLayout;
@ -106,6 +105,7 @@ import app.fedilab.android.interfaces.OnRetrievePeertubeInterface;
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;
@ -183,7 +183,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);
ImageView my_pp = findViewById(R.id.my_pp);

View File

@ -56,6 +56,7 @@ import app.fedilab.android.imageeditor.filters.FilterListener;
import app.fedilab.android.imageeditor.filters.FilterViewAdapter;
import app.fedilab.android.imageeditor.tools.EditingToolsAdapter;
import app.fedilab.android.imageeditor.tools.ToolType;
import es.dmoral.toasty.Toasty;
import ja.burhanrashid52.photoeditor.OnPhotoEditorListener;
import ja.burhanrashid52.photoeditor.PhotoEditor;
import ja.burhanrashid52.photoeditor.PhotoEditorView;
@ -163,8 +164,11 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorLi
mPhotoEditor.setOnPhotoEditorListener(this);
//Set Image Dynamically
mPhotoEditorView.getSource().setImageURI(uri);
try {
mPhotoEditorView.getSource().setImageURI(uri);
}catch (Exception e){
Toasty.error(PhotoEditorActivity.this, getString(R.string.error)).show();
}
if (uri != null) {
try (InputStream inputStream = getContentResolver().openInputStream(uri)) {

View File

@ -34,7 +34,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.Toast;
@ -56,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 es.dmoral.toasty.Toasty;
@ -72,7 +72,7 @@ public class WebviewActivity extends BaseActivity {
private String url;
private String peertubeLinkToFetch;
private boolean peertubeLink;
private WebView webView;
private CustomWebview webView;
private Menu defaultMenu;
private MastalabWebViewClient mastalabWebViewClient;

View File

@ -51,6 +51,7 @@ import app.fedilab.android.R;
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
import app.fedilab.android.client.HttpsConnection;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.webview.CustomWebview;
import es.dmoral.toasty.Toasty;
/**
@ -60,7 +61,7 @@ import es.dmoral.toasty.Toasty;
public class WebviewConnectActivity extends BaseActivity {
private WebView webView;
private CustomWebview webView;
private AlertDialog alert;
private String clientId, clientSecret;
private String instance;

View File

@ -182,6 +182,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 es.dmoral.toasty.Toasty;
import jp.wasabeef.glide.transformations.BlurTransformation;
@ -4071,7 +4072,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;

View File

@ -31,7 +31,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
@ -74,6 +73,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;
@ -258,7 +258,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
break;
case "web":
loader.setVisibility(View.GONE);
WebView webview_video = Helper.initializeWebview((Activity) context, R.id.webview_video, null);
CustomWebview 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);

View File

@ -221,6 +221,7 @@ import app.fedilab.android.sqlite.MainMenuDAO;
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;
@ -2203,9 +2204,9 @@ public class Helper {
return spannableString;
}
public static WebView initializeWebview(Activity activity, int webviewId, View rootView) {
public static CustomWebview initializeWebview(Activity activity, int webviewId, View rootView) {
WebView webView;
CustomWebview webView;
if (rootView == null) {
webView = activity.findViewById(webviewId);
} else {

View File

@ -1,4 +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>. */
public class CustomWebview {
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());
}
}

View File

@ -46,7 +46,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;
@ -54,7 +54,7 @@ public class MastalabWebChromeClient extends WebChromeClient implements MediaPla
private Activity activity;
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;

View File

@ -19,7 +19,6 @@ import android.content.Context;
import android.content.Intent;
import android.net.Proxy;
import android.util.ArrayMap;
import android.webkit.WebView;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@ -29,14 +28,14 @@ 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) {
setProxyKKPlus(context, webview, host, port, applicationClassName);
}
@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];
@ -73,7 +72,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");
@ -116,7 +115,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 + "");

View File

@ -51,7 +51,7 @@
android:layout_height="match_parent"
android:gravity="center" />
<WebView
<app.fedilab.android.webview.CustomWebview
android:id="@+id/webview_video"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -37,7 +37,7 @@
android:layout_height="0dp"
android:layout_weight="1">
<WebView
<app.fedilab.android.webview.CustomWebview
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -31,7 +31,7 @@
android:layout_height="10dp"
android:padding="2dp"/>
<WebView
<app.fedilab.android.webview.CustomWebview
android:id="@+id/webviewConnect"
android:layout_width="match_parent"
android:layout_height="0dp"

View File

@ -557,7 +557,7 @@
</RelativeLayout>
<WebView
<app.fedilab.android.webview.CustomWebview
android:id="@+id/status_cardview_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -481,7 +481,7 @@
/>
</RelativeLayout>
<WebView
<app.fedilab.android.webview.CustomWebview
android:id="@+id/status_cardview_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -432,7 +432,7 @@
/>
</RelativeLayout>
<WebView
<app.fedilab.android.webview.CustomWebview
android:id="@+id/status_cardview_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -414,7 +414,7 @@
</RelativeLayout>
<WebView
<app.fedilab.android.webview.CustomWebview
android:id="@+id/status_cardview_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -37,7 +37,7 @@
android:layout_height="match_parent"
android:layout_centerInParent="true">
<WebView
<app.fedilab.android.webview.CustomWebview
android:id="@+id/webview_video"
android:layout_width="match_parent"
android:layout_height="match_parent"