Fix some crashes

This commit is contained in:
tom79 2020-03-28 17:18:23 +01:00
parent 4c7dbc3237
commit 596f72f6da
19 changed files with 64 additions and 88 deletions

View File

@ -1,9 +1,11 @@
Added:
- Announcements for Mastodon with reactions
- Pleroma: reactions in posts
Changed:
- Filters changed to speed-up the scroll
- Move the favourite item in menu
Fixed:
- Custom emojis not displayed in compose activity
- Filters not working
- Crash when sharing http URLs
- Missing ogg image when sharing
- Extra space with quick replies
- Crash when doing search
- Fix crash when clicking on conversations
- Fix crash when editing profile

View File

@ -358,12 +358,12 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
set_profile_save.setOnClickListener(v -> {
if (set_profile_name.getText() != null && !set_profile_name.getText().toString().contentEquals(set_profile_name.getHint()))
if (set_profile_name != null && set_profile_name.getText() != null && !set_profile_name.getText().toString().contentEquals(set_profile_name.getHint()))
profile_username = set_profile_name.getText().toString().trim();
else
profile_username = null;
if (set_profile_description.getText() != null && !set_profile_description.getText().toString().contentEquals(set_profile_description.getHint()))
if (set_profile_description != null && set_profile_description.getText() != null && !set_profile_description.getText().toString().contentEquals(set_profile_description.getHint()))
profile_note = set_profile_description.getText().toString().trim();
else
profile_note = null;

View File

@ -41,6 +41,7 @@ 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;
@ -107,7 +108,6 @@ 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;
@ -185,7 +185,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);
CustomWebview webview_video = findViewById(R.id.webview_video);
WebView 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

@ -394,12 +394,12 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
if (i == targetedPosition) {
if (targetedPosition < statuses.size() - 1)
statuses.get(targetedPosition).setShowBottomLine(true);
if (targetedPosition > 0 && statuses.get(targetedPosition).getIn_reply_to_id().compareTo(statuses.get(targetedPosition - 1).getId()) == 0) {
if (targetedPosition > 0 && statuses.get(targetedPosition).getIn_reply_to_id() != null && statuses.get(targetedPosition).getIn_reply_to_id().compareTo(statuses.get(targetedPosition - 1).getId()) == 0) {
statuses.get(targetedPosition - 1).setShowBottomLine(true);
statuses.get(targetedPosition).setShowTopLine(true);
}
} else if (0 < i && i <= statuses.size() - 1) {
if (statuses.get(i - 1).getId().compareTo(statuses.get(i).getIn_reply_to_id()) == 0) {
if (statuses.get(i).getIn_reply_to_id() != null && statuses.get(i - 1).getId().compareTo(statuses.get(i).getIn_reply_to_id()) == 0) {
statuses.get(i - 1).setShowBottomLine(true);
statuses.get(i).setShowTopLine(true);
}

View File

@ -34,6 +34,7 @@ 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;
@ -55,7 +56,6 @@ 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 CustomWebview webView;
private WebView webView;
private Menu defaultMenu;
private MastalabWebViewClient mastalabWebViewClient;

View File

@ -51,7 +51,6 @@ 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;
/**
@ -61,7 +60,7 @@ import es.dmoral.toasty.Toasty;
public class WebviewConnectActivity extends BaseActivity {
private CustomWebview webView;
private WebView webView;
private AlertDialog alert;
private String clientId, clientSecret;
private String instance;

View File

@ -176,7 +176,6 @@ 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;
@ -4057,7 +4056,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;
CustomWebview status_cardview_webview;
WebView status_cardview_webview;
ImageView hide_preview, hide_preview_h;
TextView status_toot_app;
RelativeLayout webview_preview;

View File

@ -30,6 +30,7 @@ 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;
@ -71,7 +72,6 @@ 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;
@ -90,7 +90,6 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
private static final Handler HANDLER = new Handler();
private Context context;
private int mediaPosition;
private SimpleExoPlayer player;
private MediaPlayer playeraudio;
private Timer timer;
@ -117,14 +116,11 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
Bundle bundle = this.getArguments();
if (bundle != null) {
mediaPosition = bundle.getInt("position", 1);
attachment = bundle.getParcelable("attachment");
}
message_ready = rootView.findViewById(R.id.message_ready);
TextView progress = rootView.findViewById(R.id.loader_progress);
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);
@ -146,18 +142,6 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
changeDrawableColor(context, prev, R.color.white);
changeDrawableColor(context, next, R.color.white);
}
prev.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mediaPosition--;
}
});
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mediaPosition++;
}
});
url = attachment.getUrl();
imageView.setOnMatrixChangeListener(new OnMatrixChangedListener() {
@ -242,9 +226,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
pbar_inf.setScaleY(3f);
try {
HttpsURLConnection.setDefaultSSLSocketFactory(new TLSSocketFactory(Helper.getLiveInstance(context)));
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
} catch (KeyManagementException | NoSuchAlgorithmException e) {
e.printStackTrace();
}
videoView.setVisibility(View.VISIBLE);
@ -263,31 +245,28 @@ 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, null);
WebView 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);
MastalabWebChromeClient mastalabWebChromeClient = new MastalabWebChromeClient((Activity) context, webview_video, webview_container, videoLayout);
mastalabWebChromeClient.setOnToggledFullscreen(new MastalabWebChromeClient.ToggledFullscreenCallback() {
@Override
public void toggledFullscreen(boolean fullscreen) {
mastalabWebChromeClient.setOnToggledFullscreen(fullscreen -> {
if (fullscreen) {
videoLayout.setVisibility(View.VISIBLE);
WindowManager.LayoutParams attrs = ((Activity) context).getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
attrs.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
((Activity) context).getWindow().setAttributes(attrs);
((Activity) context).getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
} else {
WindowManager.LayoutParams attrs = ((Activity) context).getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
attrs.flags &= ~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
((Activity) context).getWindow().setAttributes(attrs);
((Activity) context).getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
videoLayout.setVisibility(View.GONE);
}
if (fullscreen) {
videoLayout.setVisibility(View.VISIBLE);
WindowManager.LayoutParams attrs = ((Activity) context).getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
attrs.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
((Activity) context).getWindow().setAttributes(attrs);
((Activity) context).getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
} else {
WindowManager.LayoutParams attrs = ((Activity) context).getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
attrs.flags &= ~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
((Activity) context).getWindow().setAttributes(attrs);
((Activity) context).getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
videoLayout.setVisibility(View.GONE);
}
});
webview_video.getSettings().setAllowFileAccess(true);
@ -425,14 +404,11 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
public void togglePlaying(View v) {
HANDLER.postDelayed(new Runnable() {
@Override
public void run() {
if (isPlaying()) {
stopPlaying();
} else {
startPlaying();
}
HANDLER.postDelayed(() -> {
if (isPlaying()) {
stopPlaying();
} else {
startPlaying();
}
}, 100);
}
@ -494,8 +470,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
}
try {
visualizerView.onResume();
} catch (Exception e) {
}
} catch (Exception ignored) {}
}
public boolean canSwipe() {

View File

@ -85,6 +85,7 @@ import android.webkit.CookieManager;
import android.webkit.MimeTypeMap;
import android.webkit.URLUtil;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
@ -225,7 +226,6 @@ 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;
@ -2472,9 +2472,9 @@ public class Helper {
return spannableString;
}
public static CustomWebview initializeWebview(Activity activity, int webviewId, View rootView) {
public static WebView initializeWebview(Activity activity, int webviewId, View rootView) {
CustomWebview webView;
WebView webView;
if (rootView == null) {
webView = activity.findViewById(webviewId);
} else {

View File

@ -46,7 +46,7 @@ public class MastalabWebChromeClient extends WebChromeClient implements MediaPla
private ToggledFullscreenCallback toggledFullscreenCallback;
private CustomWebview webView;
private WebView 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, CustomWebview webView, FrameLayout activityNonVideoView, ViewGroup activityVideoView) {
public MastalabWebChromeClient(Activity activity, WebView webView, FrameLayout activityNonVideoView, ViewGroup activityVideoView) {
this.activity = activity;
this.isVideoFullscreen = false;
this.webView = webView;

View File

@ -19,6 +19,7 @@ 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;
@ -28,14 +29,14 @@ import java.lang.reflect.Method;
public class ProxyHelper {
public static void setProxy(Context context, CustomWebview webview, String host, int port, String applicationClassName) {
public static void setProxy(Context context, WebView webview, String host, int port, String applicationClassName) {
setProxyKKPlus(context, webview, host, port, applicationClassName);
}
@SuppressWarnings("all")
private static boolean setProxyICS(CustomWebview webview, String host, int port) {
private static boolean setProxyICS(WebView webview, String host, int port) {
try {
Class jwcjb = Class.forName("android.webkit.JWebCoreJavaBridge");
Class params[] = new Class[1];
@ -72,7 +73,7 @@ public class ProxyHelper {
* Set Proxy for Android 4.1 - 4.3.
*/
@SuppressWarnings("all")
private static boolean setProxyJB(CustomWebview webview, String host, int port) {
private static boolean setProxyJB(WebView webview, String host, int port) {
try {
Class wvcClass = Class.forName("android.webkit.WebViewClassic");
@ -115,7 +116,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, CustomWebview webView, String host, int port, String applicationClassName) {
private static void setProxyKKPlus(Context appContext, WebView 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" />
<app.fedilab.android.webview.CustomWebview
<WebView
android:id="@+id/webview_video"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -19,7 +19,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@ -29,7 +29,7 @@
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="10dp"
android:padding="1dp"></ProgressBar>
android:padding="1dp"/>
<FrameLayout
android:id="@+id/webview_container"
@ -37,7 +37,7 @@
android:layout_height="0dp"
android:layout_weight="1">
<app.fedilab.android.webview.CustomWebview
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -19,7 +19,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@ -29,9 +29,9 @@
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="10dp"
android:padding="2dp"></ProgressBar>
android:padding="2dp"/>
<app.fedilab.android.webview.CustomWebview
<WebView
android:id="@+id/webviewConnect"
android:layout_width="match_parent"
android:layout_height="0dp"

View File

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

View File

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

View File

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

View File

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