Fix crash when playing youtube videos

This commit is contained in:
tom79 2020-04-11 14:43:33 +02:00
parent 4284bccab9
commit 62fd00c871
8 changed files with 39 additions and 8 deletions

View File

@ -47,6 +47,7 @@ android {
packagingOptions { packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro' exclude 'META-INF/proguard/androidx-annotations.pro'
} }
viewBinding.enabled = true
} }
allprojects { allprojects {
repositories { repositories {

View File

@ -0,0 +1,5 @@
Changed:
Fixed:
- Crash when Youtube videos in timelines

View File

@ -2141,7 +2141,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
if (status.getReblog() == null) { if (status.getReblog() == null) {
if (status.getWebviewURL() != null) { if (status.getWebviewURL() != null) {
String url = status.getWebviewURL().replaceAll("&", "&"); String url = status.getWebviewURL().replaceAll("&", "&");
holder.status_cardview_webview.loadUrl(url); try {
holder.status_cardview_webview.loadUrl(url);
}catch (Exception e){
e.printStackTrace();
}
holder.status_cardview_webview.setVisibility(View.VISIBLE); holder.status_cardview_webview.setVisibility(View.VISIBLE);
holder.status_cardview_video.setVisibility(View.VISIBLE); holder.status_cardview_video.setVisibility(View.VISIBLE);
holder.webview_preview.setVisibility(View.GONE); holder.webview_preview.setVisibility(View.GONE);
@ -2153,7 +2157,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
} else { } else {
if (status.getReblog().getWebviewURL() != null) { if (status.getReblog().getWebviewURL() != null) {
String url = status.getReblog().getWebviewURL().replaceAll("&", "&"); String url = status.getReblog().getWebviewURL().replaceAll("&", "&");
holder.status_cardview_webview.loadUrl(url); try {
holder.status_cardview_webview.loadUrl(url);
}catch (Exception e){
e.printStackTrace();
}
holder.status_cardview_webview.setVisibility(View.VISIBLE); holder.status_cardview_webview.setVisibility(View.VISIBLE);
holder.status_cardview_video.setVisibility(View.VISIBLE); holder.status_cardview_video.setVisibility(View.VISIBLE);
holder.webview_preview.setVisibility(View.GONE); holder.webview_preview.setVisibility(View.GONE);

View File

@ -79,6 +79,7 @@ import android.view.WindowManager;
import android.webkit.CookieManager; import android.webkit.CookieManager;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import android.webkit.URLUtil; import android.webkit.URLUtil;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.widget.Button; import android.widget.Button;
@ -2222,7 +2223,12 @@ public class Helper {
webView.getSettings().setAppCacheEnabled(true); webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setDatabaseEnabled(true); webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
webView.setWebChromeClient(new WebChromeClient() {
@Override
public Bitmap getDefaultVideoPoster() {
return Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
}
});
boolean proxyEnabled = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false); boolean proxyEnabled = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false);
if (proxyEnabled) { if (proxyEnabled) {
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1"); String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");

View File

@ -76,6 +76,11 @@ public class MastalabWebChromeClient extends WebChromeClient implements MediaPla
} }
} }
@Override
public Bitmap getDefaultVideoPoster() {
return Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
}
@Override @Override
public void onReceivedIcon(WebView view, Bitmap icon) { public void onReceivedIcon(WebView view, Bitmap icon) {
super.onReceivedIcon(view, icon); super.onReceivedIcon(view, icon);

View File

@ -1843,7 +1843,9 @@
android:id="@+id/translation_key" android:id="@+id/translation_key"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/your_api_key" /> android:hint="@string/your_api_key"
android:inputType="text"
android:importantForAutofill="no" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -2363,7 +2365,9 @@
android:id="@+id/custom_sharing_url" android:id="@+id/custom_sharing_url"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/settings_custom_sharing_url" /> android:hint="@string/settings_custom_sharing_url"
android:inputType="textUri"
android:importantForAutofill="no" />
<!-- ADD TAGS --> <!-- ADD TAGS -->
<LinearLayout <LinearLayout
@ -2500,7 +2504,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:hint="@string/set_invidious_host" android:hint="@string/set_invidious_host"
android:inputType="textWebEditText" /> android:inputType="textWebEditText"
android:importantForAutofill="no" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -2675,7 +2680,7 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/set_enable_crash_report_indication" android:text="@string/set_custom_tabs_indication"
android:textColor="@color/mastodonC2" android:textColor="@color/mastodonC2"
android:textSize="12sp" /> android:textSize="12sp" />
</LinearLayout> </LinearLayout>

View File

@ -1226,4 +1226,5 @@
<string name="action_announcements">Announcements</string> <string name="action_announcements">Announcements</string>
<string name="no_announcements">No announcements!</string> <string name="no_announcements">No announcements!</string>
<string name="add_reaction">Add a reaction</string> <string name="add_reaction">Add a reaction</string>
<string name="set_custom_tabs_indication">Use your favourite browser inside the app. Uncheck this feature to open links externally.</string>
</resources> </resources>

View File

@ -6,7 +6,7 @@ buildscript {
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.6.1' classpath 'com.android.tools.build:gradle:3.6.2'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files