From 463dd8ea74003317abc6a38779b299b2a4c181b1 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 9 Jan 2021 16:33:59 +0100 Subject: [PATCH] Completely remove return activity, now outdated --- app/src/main/java/org/schabi/newpipe/App.java | 2 +- .../schabi/newpipe/CheckForNewAppVersion.java | 6 +- .../java/org/schabi/newpipe/MainActivity.java | 10 +- .../org/schabi/newpipe/RouterActivity.java | 2 +- .../newpipe/download/DownloadDialog.java | 2 +- .../newpipe/error/AcraReportSender.java | 2 +- .../schabi/newpipe/error/ErrorActivity.java | 120 ++++++++---------- .../schabi/newpipe/error/ErrorPanelHelper.kt | 7 +- .../newpipe/fragments/BaseStateFragment.java | 16 +-- .../newpipe/fragments/MainFragment.java | 4 +- .../fragments/detail/VideoDetailFragment.java | 5 +- .../fragments/list/BaseListFragment.java | 5 +- .../list/channel/ChannelFragment.java | 3 +- .../list/playlist/PlaylistFragment.java | 3 +- .../fragments/list/search/SearchFragment.java | 3 +- .../holder/CommentsMiniInfoItemHolder.java | 2 +- .../SubscriptionsImportFragment.java | 2 +- .../services/BaseImportExportService.java | 2 +- .../settings/ContentSettingsFragment.java | 4 +- .../settings/HistorySettingsFragment.java | 16 +-- .../settings/SelectChannelFragment.java | 2 +- .../newpipe/settings/SelectKioskFragment.java | 2 +- .../settings/SelectPlaylistFragment.java | 2 +- .../newpipe/settings/SettingMigrations.java | 2 +- .../settings/tabs/ChooseTabsFragment.java | 2 +- .../org/schabi/newpipe/settings/tabs/Tab.java | 2 +- .../giga/ui/adapter/MissionAdapter.java | 2 +- 27 files changed, 98 insertions(+), 132 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index d8519d0cb..e3e9c3e4e 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -227,7 +227,7 @@ public class App extends MultiDexApplication { ACRA.init(this, acraConfig); } catch (final ACRAConfigurationException exception) { exception.printStackTrace(); - ErrorActivity.reportError(this, null, null, new ErrorInfo(exception, + ErrorActivity.reportError(this, new ErrorInfo(exception, UserAction.SOMETHING_ELSE, "Could not initialize ACRA crash report")); } } diff --git a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java index ad8aae93d..f84d986aa 100644 --- a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java +++ b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java @@ -63,7 +63,7 @@ public final class CheckForNewAppVersion { packageInfo = application.getPackageManager().getPackageInfo( application.getPackageName(), PackageManager.GET_SIGNATURES); } catch (final PackageManager.NameNotFoundException e) { - ErrorActivity.reportError(application, null, null, new ErrorInfo(e, + ErrorActivity.reportError(application, new ErrorInfo(e, UserAction.CHECK_FOR_NEW_APP_VERSION, "Could not find package info")); return ""; } @@ -76,7 +76,7 @@ public final class CheckForNewAppVersion { final CertificateFactory cf = CertificateFactory.getInstance("X509"); c = (X509Certificate) cf.generateCertificate(input); } catch (final CertificateException e) { - ErrorActivity.reportError(application, null, null, new ErrorInfo(e, + ErrorActivity.reportError(application, new ErrorInfo(e, UserAction.CHECK_FOR_NEW_APP_VERSION, "Certificate error")); return ""; } @@ -86,7 +86,7 @@ public final class CheckForNewAppVersion { final byte[] publicKey = md.digest(c.getEncoded()); return byte2HexFormatted(publicKey); } catch (NoSuchAlgorithmException | CertificateEncodingException e) { - ErrorActivity.reportError(application, null, null, new ErrorInfo(e, + ErrorActivity.reportError(application, new ErrorInfo(e, UserAction.CHECK_FOR_NEW_APP_VERSION, "Could not retrieve SHA1 key")); return ""; } diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index f382874ac..1b8f3190e 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -153,7 +153,7 @@ public class MainActivity extends AppCompatActivity { try { setupDrawer(); } catch (final Exception e) { - ErrorActivity.reportUiError(this, null, "Setting up drawer", e); + ErrorActivity.reportUiErrorInSnackbar(this, "Setting up drawer", e); } if (DeviceUtils.isTv(this)) { @@ -238,7 +238,7 @@ public class MainActivity extends AppCompatActivity { try { tabSelected(item); } catch (final Exception e) { - ErrorActivity.reportUiError(this, null, "Selecting main page tab", e); + ErrorActivity.reportUiErrorInSnackbar(this, "Selecting main page tab", e); } break; case R.id.menu_options_about_group: @@ -340,7 +340,7 @@ public class MainActivity extends AppCompatActivity { try { showTabs(); } catch (final Exception e) { - ErrorActivity.reportUiError(this, null, "Showing main page tabs", e); + ErrorActivity.reportUiErrorInSnackbar(this, "Showing main page tabs", e); } } } @@ -487,7 +487,7 @@ public class MainActivity extends AppCompatActivity { drawerHeaderBinding.drawerHeaderActionButton.setContentDescription( getString(R.string.drawer_header_description) + selectedServiceName); } catch (final Exception e) { - ErrorActivity.reportUiError(this, null, "Setting up service toggle", e); + ErrorActivity.reportUiErrorInSnackbar(this, "Setting up service toggle", e); } final SharedPreferences sharedPreferences @@ -796,7 +796,7 @@ public class MainActivity extends AppCompatActivity { NavigationHelper.gotoMainFragment(getSupportFragmentManager()); } } catch (final Exception e) { - ErrorActivity.reportUiError(this, null, "Handling intent", e); + ErrorActivity.reportUiErrorInSnackbar(this, "Handling intent", e); } } diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 59b876386..7fe64633c 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -219,7 +219,7 @@ public class RouterActivity extends AppCompatActivity { // unfortunately we cannot tell if the error is really caused by an unsupported url ((RouterActivity) context).showUnsupportedUrlDialog(errorInfo.getRequest()); } else { - ErrorActivity.reportError(context, MainActivity.class, null, errorInfo); + ErrorActivity.reportError(context, errorInfo); } if (context instanceof RouterActivity) { diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index 20c9558fc..e573879c0 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -693,7 +693,7 @@ public class DownloadDialog extends DialogFragment mainStorage.getTag()); } } catch (final Exception e) { - ErrorActivity.reportError(context, null, null, + ErrorActivity.reportErrorInSnackbar(this, new ErrorInfo(e, UserAction.DOWNLOAD_FAILED, "Getting storage")); return; } diff --git a/app/src/main/java/org/schabi/newpipe/error/AcraReportSender.java b/app/src/main/java/org/schabi/newpipe/error/AcraReportSender.java index cc7911417..60d4908eb 100644 --- a/app/src/main/java/org/schabi/newpipe/error/AcraReportSender.java +++ b/app/src/main/java/org/schabi/newpipe/error/AcraReportSender.java @@ -33,7 +33,7 @@ public class AcraReportSender implements ReportSender { @Override public void send(@NonNull final Context context, @NonNull final CrashReportData report) { - ErrorActivity.reportError(context, null, null, new ErrorInfo( + ErrorActivity.reportError(context, new ErrorInfo( new String[]{report.getString(ReportField.STACK_TRACE)}, UserAction.UI_ERROR, ErrorInfo.SERVICE_NONE, diff --git a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java index cd1108b0c..dd7593473 100644 --- a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java @@ -8,7 +8,6 @@ import android.graphics.Color; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.os.Handler; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; @@ -18,7 +17,7 @@ import android.view.View; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; -import androidx.core.app.NavUtils; +import androidx.fragment.app.Fragment; import com.google.android.material.snackbar.Snackbar; import com.grack.nanojson.JsonWriter; @@ -74,64 +73,67 @@ public class ErrorActivity extends AppCompatActivity { = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); - /** - * Singleton: - * Used to send data between certain Activity/Services within the same process. - * This can be considered as an ugly hack inside the Android universe. - **/ - @Nullable private static Class savedReturnActivity = null; - private ErrorInfo errorInfo; private String currentTimeStamp; private ActivityErrorBinding activityErrorBinding; - public static void reportUiError(final Context context, - @Nullable final View rootView, - final String request, - final Throwable throwable) { - reportError(context, (context instanceof Activity ? context.getClass() : null), rootView, - new ErrorInfo(throwable, UserAction.UI_ERROR, request)); - } - - public static void reportError(final Context context, - final Class returnActivity, - @Nullable final View rootView, - final ErrorInfo errorInfo) { - if (rootView != null) { - Snackbar.make(rootView, R.string.error_snackbar_message, Snackbar.LENGTH_LONG) - .setActionTextColor(Color.YELLOW) - .setAction(context.getString(R.string.error_snackbar_action).toUpperCase(), v -> - startErrorActivity(returnActivity, context, errorInfo)).show(); - } else { - startErrorActivity(returnActivity, context, errorInfo); - } - } - - // async call - public static void reportError(final Handler handler, - final Context context, - final Class returnActivity, - final View rootView, - final ErrorInfo errorInfo) { - handler.post(() -> reportError(context, returnActivity, rootView, errorInfo)); - } - - - //////////////////////////////////////////////////////////////////////// - // UTILS - //////////////////////////////////////////////////////////////////////// - - private static void startErrorActivity(@Nullable final Class returnActivity, - final Context context, - final ErrorInfo errorInfo) { - savedReturnActivity = returnActivity; + public static void reportError(final Context context, final ErrorInfo errorInfo) { final Intent intent = new Intent(context, ErrorActivity.class); intent.putExtra(ERROR_INFO, errorInfo); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } + public static void reportErrorInSnackbar(final Context context, final ErrorInfo errorInfo) { + final View rootView = context instanceof Activity + ? ((Activity) context).findViewById(android.R.id.content) : null; + reportErrorInSnackbar(context, rootView, errorInfo); + } + + public static void reportErrorInSnackbar(final Fragment fragment, final ErrorInfo errorInfo) { + View rootView = fragment.getView(); + if (rootView == null && fragment.getActivity() != null) { + rootView = fragment.getActivity().findViewById(android.R.id.content); + } + reportErrorInSnackbar(fragment.requireContext(), rootView, errorInfo); + } + + public static void reportUiErrorInSnackbar(final Context context, + final String request, + final Throwable throwable) { + reportErrorInSnackbar(context, new ErrorInfo(throwable, UserAction.UI_ERROR, request)); + } + + public static void reportUiErrorInSnackbar(final Fragment fragment, + final String request, + final Throwable throwable) { + reportErrorInSnackbar(fragment, new ErrorInfo(throwable, UserAction.UI_ERROR, request)); + } + + + //////////////////////////////////////////////////////////////////////// + // Utils + //////////////////////////////////////////////////////////////////////// + + private static void reportErrorInSnackbar(final Context context, + @Nullable final View rootView, + final ErrorInfo errorInfo) { + if (rootView != null) { + Snackbar.make(rootView, R.string.error_snackbar_message, Snackbar.LENGTH_LONG) + .setActionTextColor(Color.YELLOW) + .setAction(context.getString(R.string.error_snackbar_action).toUpperCase(), v -> + reportError(context, errorInfo)).show(); + } else { + reportError(context, errorInfo); + } + } + + + //////////////////////////////////////////////////////////////////////// + // Activity lifecycle + //////////////////////////////////////////////////////////////////////// + @Override protected void onCreate(final Bundle savedInstanceState) { assureCorrectAppLanguage(this); @@ -189,7 +191,7 @@ public class ErrorActivity extends AppCompatActivity { public boolean onOptionsItemSelected(final MenuItem item) { final int id = item.getItemId(); if (id == android.R.id.home) { - goToReturnActivity(); + onBackPressed(); } else if (id == R.id.menu_item_share_error) { ShareUtils.shareText(this, getString(R.string.error_report_title), buildJson()); } else { @@ -258,18 +260,6 @@ public class ErrorActivity extends AppCompatActivity { return checkedReturnActivity; } - private void goToReturnActivity() { - final Class checkedReturnActivity = - getReturnActivity(savedReturnActivity); - if (checkedReturnActivity == null) { - super.onBackPressed(); - } else { - final Intent intent = new Intent(this, checkedReturnActivity); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - NavUtils.navigateUpTo(this, intent); - } - } - private void buildInfo(final ErrorInfo info) { String text = ""; @@ -409,10 +399,4 @@ public class ErrorActivity extends AppCompatActivity { text += "\n" + getString(R.string.guru_meditation); activityErrorBinding.errorSorryView.setText(text); } - - @Override - public void onBackPressed() { - //super.onBackPressed(); - goToReturnActivity(); - } } diff --git a/app/src/main/java/org/schabi/newpipe/error/ErrorPanelHelper.kt b/app/src/main/java/org/schabi/newpipe/error/ErrorPanelHelper.kt index ca65d2836..49bcfa926 100644 --- a/app/src/main/java/org/schabi/newpipe/error/ErrorPanelHelper.kt +++ b/app/src/main/java/org/schabi/newpipe/error/ErrorPanelHelper.kt @@ -74,12 +74,7 @@ class ErrorPanelHelper( } else { errorButtonAction.setText(R.string.error_snackbar_action) errorButtonAction.setOnClickListener { - ErrorActivity.reportError( - context, - MainActivity::class.java, - null, - errorInfo - ) + ErrorActivity.reportError(context, errorInfo) } // hide retry button by default, then show only if not unavailable/unsupported content diff --git a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java index 0d244231d..0a43c0525 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java @@ -1,6 +1,5 @@ package org.schabi.newpipe.fragments; -import android.content.Context; import android.os.Bundle; import android.util.Log; import android.view.View; @@ -10,7 +9,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import org.schabi.newpipe.BaseFragment; -import org.schabi.newpipe.MainActivity; import org.schabi.newpipe.R; import org.schabi.newpipe.error.ErrorActivity; import org.schabi.newpipe.error.ErrorInfo; @@ -157,7 +155,7 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC errorPanelHelper.showError(errorInfo); } - public final void showTextError(final @NonNull String errorString) { + public final void showTextError(@NonNull final String errorString) { handleError(); if (isDetached() || isRemoving()) { @@ -180,7 +178,7 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC /** * Show a SnackBar and only call - * {@link ErrorActivity#reportError(Context, Class, View, ErrorInfo)} + * {@link ErrorActivity.reportErrorInSnackbar(androidx.fragment.app.Fragment, ErrorInfo)} * IF we a find a valid view (otherwise the error screen appears). * * @param errorInfo The error information @@ -189,14 +187,6 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC if (DEBUG) { Log.d(TAG, "showSnackBarError() called with: errorInfo = [" + errorInfo + "]"); } - View rootView = activity != null ? activity.findViewById(android.R.id.content) : null; - if (rootView == null) { - rootView = getView(); - } - if (rootView == null) { - return; - } - - ErrorActivity.reportError(requireContext(), MainActivity.class, rootView, errorInfo); + ErrorActivity.reportErrorInSnackbar(this, errorInfo); } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java index 9443bac05..5fb68ba30 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -147,7 +147,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte NavigationHelper.openSearchFragment(getFM(), ServiceHelper.getSelectedServiceId(activity), ""); } catch (final Exception e) { - ErrorActivity.reportUiError(getActivity(), null, "Opening search fragment", e); + ErrorActivity.reportUiErrorInSnackbar(this, "Opening search fragment", e); } return true; } @@ -238,7 +238,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte } if (throwable != null) { - ErrorActivity.reportUiError(context, null, "Getting fragment item", throwable); + ErrorActivity.reportUiErrorInSnackbar(context, "Getting fragment item", throwable); return new BlankFragment(); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index c6789804c..dc35a86f0 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -523,7 +523,7 @@ public final class VideoDetailFragment NavigationHelper.openChannelFragment(getFM(), currentInfo.getServiceId(), subChannelUrl, subChannelName); } catch (final Exception e) { - ErrorActivity.reportUiError(getActivity(), null, "Opening channel fragment", e); + ErrorActivity.reportUiErrorInSnackbar(this, "Opening channel fragment", e); } } @@ -1596,8 +1596,7 @@ public final class VideoDetailFragment downloadDialog.show(activity.getSupportFragmentManager(), "downloadDialog"); } catch (final Exception e) { - ErrorActivity.reportError(activity, activity.getClass(), - activity.findViewById(android.R.id.content), + ErrorActivity.reportErrorInSnackbar(activity, new ErrorInfo(e, UserAction.DOWNLOAD_OPEN_DIALOG, "Showing download dialog", currentInfo)); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java index 01f5fa5d4..257ccde43 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java @@ -291,7 +291,8 @@ public abstract class BaseListFragment extends BaseStateFragment selectedItem.getUrl(), selectedItem.getName()); } catch (final Exception e) { - ErrorActivity.reportUiError(getActivity(), null, "Opening channel fragment", e); + ErrorActivity.reportUiErrorInSnackbar( + BaseListFragment.this, "Opening channel fragment", e); } } }); @@ -306,7 +307,7 @@ public abstract class BaseListFragment extends BaseStateFragment selectedItem.getUrl(), selectedItem.getName()); } catch (final Exception e) { - ErrorActivity.reportUiError(getActivity(), null, + ErrorActivity.reportUiErrorInSnackbar(BaseListFragment.this, "Opening playlist fragment", e); } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index 8a2defb35..a94581cfd 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -403,8 +403,7 @@ public class ChannelFragment extends BaseListInfoFragment currentInfo.getParentChannelUrl(), currentInfo.getParentChannelName()); } catch (final Exception e) { - ErrorActivity.reportUiError(getActivity(), null, - "Opening channel fragment", e); + ErrorActivity.reportUiErrorInSnackbar(this, "Opening channel fragment", e); } } else if (DEBUG) { Log.i(TAG, "Can't open parent channel because we got no channel URL"); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java index 071bed685..326013885 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java @@ -286,8 +286,7 @@ public class PlaylistFragment extends BaseListInfoFragment { NavigationHelper.openChannelFragment(getFM(), result.getServiceId(), result.getUploaderUrl(), result.getUploaderName()); } catch (final Exception e) { - ErrorActivity.reportUiError(getActivity(), null, - "Opening channel fragment", e); + ErrorActivity.reportUiErrorInSnackbar(this, "Opening channel fragment", e); } }); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index ca90622b9..9acdacd16 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -257,8 +257,7 @@ public class SearchFragment extends BaseListFragment Toast.makeText(context, R.string.watch_history_states_deleted, Toast.LENGTH_SHORT).show(), - throwable -> ErrorActivity.reportError(context, SettingsActivity.class, - null, new ErrorInfo(throwable, UserAction.DELETE_FROM_HISTORY, + throwable -> ErrorActivity.reportError(context, + new ErrorInfo(throwable, UserAction.DELETE_FROM_HISTORY, "Delete playback states"))); } @@ -81,8 +81,8 @@ public class HistorySettingsFragment extends BasePreferenceFragment { .subscribe( howManyDeleted -> Toast.makeText(context, R.string.watch_history_deleted, Toast.LENGTH_SHORT).show(), - throwable -> ErrorActivity.reportError(context, SettingsActivity.class, - null, new ErrorInfo(throwable, UserAction.DELETE_FROM_HISTORY, + throwable -> ErrorActivity.reportError(context, + new ErrorInfo(throwable, UserAction.DELETE_FROM_HISTORY, "Delete from history"))); } @@ -92,8 +92,8 @@ public class HistorySettingsFragment extends BasePreferenceFragment { .observeOn(AndroidSchedulers.mainThread()) .subscribe( howManyDeleted -> { }, - throwable -> ErrorActivity.reportError(context, SettingsActivity.class, - null, new ErrorInfo(throwable, UserAction.DELETE_FROM_HISTORY, + throwable -> ErrorActivity.reportError(context, + new ErrorInfo(throwable, UserAction.DELETE_FROM_HISTORY, "Clear orphaned records"))); } @@ -104,8 +104,8 @@ public class HistorySettingsFragment extends BasePreferenceFragment { .subscribe( howManyDeleted -> Toast.makeText(context, R.string.search_history_deleted, Toast.LENGTH_SHORT).show(), - throwable -> ErrorActivity.reportError(context, SettingsActivity.class, - null, new ErrorInfo(throwable, UserAction.DELETE_FROM_HISTORY, + throwable -> ErrorActivity.reportError(context, + new ErrorInfo(throwable, UserAction.DELETE_FROM_HISTORY, "Delete search history"))); } diff --git a/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java index 3f718146b..7f706be77 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectChannelFragment.java @@ -162,7 +162,7 @@ public class SelectChannelFragment extends DialogFragment { @Override public void onError(@NonNull final Throwable exception) { - ErrorActivity.reportUiError(requireContext(), null, + ErrorActivity.reportUiErrorInSnackbar(SelectChannelFragment.this, "Loading subscription", exception); } diff --git a/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java index 6b11e0654..5c20b752c 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java @@ -80,7 +80,7 @@ public class SelectKioskFragment extends DialogFragment { try { selectKioskAdapter = new SelectKioskAdapter(); } catch (final Exception e) { - ErrorActivity.reportUiError(getActivity(), null, "Selecting kiosk", e); + ErrorActivity.reportUiErrorInSnackbar(this, "Selecting kiosk", e); } recyclerView.setAdapter(selectKioskAdapter); diff --git a/app/src/main/java/org/schabi/newpipe/settings/SelectPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SelectPlaylistFragment.java index 8ff4b4112..63da3274f 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectPlaylistFragment.java @@ -115,7 +115,7 @@ public class SelectPlaylistFragment extends DialogFragment { protected void onError(final Throwable e) { final Activity activity = requireActivity(); - ErrorActivity.reportError(activity, activity.getClass(), null, new ErrorInfo(e, + ErrorActivity.reportErrorInSnackbar(activity, new ErrorInfo(e, UserAction.UI_ERROR, "Loading playlists")); } diff --git a/app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java b/app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java index d96bd7353..c59746428 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java @@ -95,7 +95,7 @@ public final class SettingMigrations { } catch (final Exception e) { // save the version with the last successful migration and report the error sp.edit().putInt(lastPrefVersionKey, currentVersion).apply(); - ErrorActivity.reportError(context, SettingMigrations.class, null, new ErrorInfo( + ErrorActivity.reportError(context, new ErrorInfo( e, UserAction.PREFERENCES_MIGRATION, "Migrating preferences from version " + lastPrefVersion + " to " diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/ChooseTabsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/ChooseTabsFragment.java index ed035d021..572741d03 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/tabs/ChooseTabsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/ChooseTabsFragment.java @@ -183,7 +183,7 @@ public class ChooseTabsFragment extends Fragment { final Tab.Type type = typeFrom(tabId); if (type == null) { - ErrorActivity.reportError(requireContext(), null, null, + ErrorActivity.reportErrorInSnackbar(this, new ErrorInfo(new IllegalStateException("Tab id not found: " + tabId), UserAction.SOMETHING_ELSE, "Choosing tabs on settings")); return; diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java index 15ab3460a..0ffda2261 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java +++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java @@ -483,7 +483,7 @@ public abstract class Tab { final StreamingService service = NewPipe.getService(kioskServiceId); kioskId = service.getKioskList().getDefaultKioskId(); } catch (final ExtractionException e) { - ErrorActivity.reportError(context, null, null, new ErrorInfo(e, + ErrorActivity.reportErrorInSnackbar(context, new ErrorInfo(e, UserAction.REQUESTED_KIOSK, "Loading default kiosk for selected service")); } return kioskId; diff --git a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java index 455dd0614..41a254b49 100644 --- a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java +++ b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java @@ -586,7 +586,7 @@ public class MissionAdapter extends Adapter implements Handler.Callb service = ErrorInfo.SERVICE_NONE; } - ErrorActivity.reportError(mContext, null, null, + ErrorActivity.reportError(mContext, new ErrorInfo(ErrorInfo.Companion.throwableToStringList(mission.errObject), action, service, request.toString(), reason, null)); }