Skip to content

Commit 35b948b

Browse files
Convert ErrorInfo to Kotlin and use the Parcelize annotation.
1 parent 21c4aac commit 35b948b

24 files changed

+87
-102
lines changed

app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.junit.Test;
99
import org.junit.runner.RunWith;
1010
import org.schabi.newpipe.R;
11-
import org.schabi.newpipe.report.ErrorActivity.ErrorInfo;
1211

1312
import static org.junit.Assert.assertEquals;
1413

@@ -29,10 +28,10 @@ public void errorInfoTestParcelable() {
2928
parcel.setDataPosition(0);
3029
final ErrorInfo infoFromParcel = ErrorInfo.CREATOR.createFromParcel(parcel);
3130

32-
assertEquals(UserAction.USER_REPORT, infoFromParcel.userAction);
33-
assertEquals("youtube", infoFromParcel.serviceName);
34-
assertEquals("request", infoFromParcel.request);
35-
assertEquals(R.string.general_error, infoFromParcel.message);
31+
assertEquals(UserAction.USER_REPORT, infoFromParcel.getUserAction());
32+
assertEquals("youtube", infoFromParcel.getServiceName());
33+
assertEquals("request", infoFromParcel.getRequest());
34+
assertEquals(R.string.general_error, infoFromParcel.getMessage());
3635

3736
parcel.recycle();
3837
}

app/src/main/java/org/schabi/newpipe/App.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.schabi.newpipe.extractor.NewPipe;
2323
import org.schabi.newpipe.extractor.downloader.Downloader;
2424
import org.schabi.newpipe.report.ErrorActivity;
25+
import org.schabi.newpipe.report.ErrorInfo;
2526
import org.schabi.newpipe.report.UserAction;
2627
import org.schabi.newpipe.settings.SettingsActivity;
2728
import org.schabi.newpipe.util.ExceptionUtils;
@@ -226,7 +227,7 @@ protected void initACRA() {
226227
ace,
227228
null,
228229
null,
229-
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
230+
ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
230231
"Could not initialize ACRA crash report", R.string.app_ui_crash));
231232
}
232233
}

app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
2525
import org.schabi.newpipe.report.ErrorActivity;
26+
import org.schabi.newpipe.report.ErrorInfo;
2627
import org.schabi.newpipe.report.UserAction;
2728

2829
import java.io.ByteArrayInputStream;
@@ -67,7 +68,7 @@ private static String getCertificateSHA1Fingerprint(@NonNull final Application a
6768
packageInfo = pm.getPackageInfo(packageName, flags);
6869
} catch (final PackageManager.NameNotFoundException e) {
6970
ErrorActivity.reportError(application, e, null, null,
70-
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
71+
ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
7172
"Could not find package info", R.string.app_ui_crash));
7273
}
7374

@@ -82,7 +83,7 @@ private static String getCertificateSHA1Fingerprint(@NonNull final Application a
8283
c = (X509Certificate) cf.generateCertificate(input);
8384
} catch (final CertificateException e) {
8485
ErrorActivity.reportError(application, e, null, null,
85-
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
86+
ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
8687
"Certificate error", R.string.app_ui_crash));
8788
}
8889

@@ -94,7 +95,7 @@ private static String getCertificateSHA1Fingerprint(@NonNull final Application a
9495
hexString = byte2HexFormatted(publicKey);
9596
} catch (NoSuchAlgorithmException | CertificateEncodingException e) {
9697
ErrorActivity.reportError(application, e, null, null,
97-
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
98+
ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
9899
"Could not retrieve SHA1 key", R.string.app_ui_crash));
99100
}
100101

app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.schabi.newpipe.extractor.stream.SubtitlesStream;
5050
import org.schabi.newpipe.extractor.stream.VideoStream;
5151
import org.schabi.newpipe.report.ErrorActivity;
52+
import org.schabi.newpipe.report.ErrorInfo;
5253
import org.schabi.newpipe.report.UserAction;
5354
import org.schabi.newpipe.settings.NewPipeSettings;
5455
import org.schabi.newpipe.util.FilePickerActivityHelper;
@@ -602,7 +603,7 @@ private void showErrorActivity(final Exception e) {
602603
Collections.singletonList(e),
603604
null,
604605
null,
605-
ErrorActivity.ErrorInfo
606+
ErrorInfo
606607
.make(UserAction.SOMETHING_ELSE, "-", "-", R.string.general_error)
607608
);
608609
}

app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
2424
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
2525
import org.schabi.newpipe.report.ErrorActivity;
26+
import org.schabi.newpipe.report.ErrorInfo;
2627
import org.schabi.newpipe.report.UserAction;
2728
import org.schabi.newpipe.util.ExceptionUtils;
2829
import org.schabi.newpipe.util.InfoCache;
@@ -252,7 +253,7 @@ public void onUnrecoverableError(final List<Throwable> exception, final UserActi
252253
}
253254

254255
ErrorActivity.reportError(getContext(), exception, MainActivity.class, null,
255-
ErrorActivity.ErrorInfo.make(userAction, serviceName == null ? "none" : serviceName,
256+
ErrorInfo.make(userAction, serviceName == null ? "none" : serviceName,
256257
request == null ? "none" : request, errorId));
257258
}
258259

@@ -265,7 +266,7 @@ public void showSnackBarError(final Throwable exception, final UserAction userAc
265266

266267
/**
267268
* Show a SnackBar and only call
268-
* {@link ErrorActivity#reportError(Context, List, Class, View, ErrorActivity.ErrorInfo)}
269+
* {@link ErrorActivity#reportError(Context, List, Class, View, ErrorInfo)}
269270
* IF we a find a valid view (otherwise the error screen appears).
270271
*
271272
* @param exception List of the exceptions to show
@@ -291,6 +292,6 @@ public void showSnackBarError(final List<Throwable> exception, final UserAction
291292
}
292293

293294
ErrorActivity.reportError(getContext(), exception, MainActivity.class, rootView,
294-
ErrorActivity.ErrorInfo.make(userAction, serviceName, request, errorId));
295+
ErrorInfo.make(userAction, serviceName, request, errorId));
295296
}
296297
}

app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.schabi.newpipe.R;
2828
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
2929
import org.schabi.newpipe.report.ErrorActivity;
30+
import org.schabi.newpipe.report.ErrorInfo;
3031
import org.schabi.newpipe.report.UserAction;
3132
import org.schabi.newpipe.settings.tabs.Tab;
3233
import org.schabi.newpipe.settings.tabs.TabsManager;
@@ -242,7 +243,7 @@ public Fragment getItem(final int position) {
242243
}
243244

244245
if (throwable != null) {
245-
ErrorActivity.reportError(context, throwable, null, null, ErrorActivity.ErrorInfo
246+
ErrorActivity.reportError(context, throwable, null, null, ErrorInfo
246247
.make(UserAction.UI_ERROR, "none", "", R.string.app_ui_crash));
247248
return new BlankFragment();
248249
}

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
9494
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
9595
import org.schabi.newpipe.report.ErrorActivity;
96+
import org.schabi.newpipe.report.ErrorInfo;
9697
import org.schabi.newpipe.report.UserAction;
9798
import org.schabi.newpipe.util.Constants;
9899
import org.schabi.newpipe.util.DeviceUtils;
@@ -1626,7 +1627,7 @@ public void openDownloadDialog() {
16261627

16271628
downloadDialog.show(activity.getSupportFragmentManager(), "downloadDialog");
16281629
} catch (final Exception e) {
1629-
final ErrorActivity.ErrorInfo info = ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR,
1630+
final ErrorInfo info = ErrorInfo.make(UserAction.UI_ERROR,
16301631
ServiceList.all()
16311632
.get(currentInfo
16321633
.getServiceId())

app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.schabi.newpipe.fragments.list.BaseListFragment;
5050
import org.schabi.newpipe.local.history.HistoryRecordManager;
5151
import org.schabi.newpipe.report.ErrorActivity;
52+
import org.schabi.newpipe.report.ErrorInfo;
5253
import org.schabi.newpipe.report.UserAction;
5354
import org.schabi.newpipe.util.AnimationUtils;
5455
import org.schabi.newpipe.util.Constants;
@@ -248,7 +249,7 @@ public void onResume() {
248249
} catch (final Exception e) {
249250
ErrorActivity.reportError(getActivity(), e, requireActivity().getClass(),
250251
requireActivity().findViewById(android.R.id.content),
251-
ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR,
252+
ErrorInfo.make(UserAction.UI_ERROR,
252253
"",
253254
"", R.string.general_error));
254255
}

app/src/main/java/org/schabi/newpipe/local/history/StatisticsPlaylistFragment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.schabi.newpipe.player.playqueue.PlayQueue;
3535
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
3636
import org.schabi.newpipe.report.ErrorActivity;
37+
import org.schabi.newpipe.report.ErrorInfo;
3738
import org.schabi.newpipe.report.UserAction;
3839
import org.schabi.newpipe.settings.SettingsActivity;
3940
import org.schabi.newpipe.util.NavigationHelper;
@@ -183,7 +184,7 @@ public boolean onOptionsItemSelected(final MenuItem item) {
183184
throwable -> ErrorActivity.reportError(getContext(),
184185
throwable,
185186
SettingsActivity.class, null,
186-
ErrorActivity.ErrorInfo.make(
187+
ErrorInfo.make(
187188
UserAction.DELETE_FROM_HISTORY,
188189
"none",
189190
"Delete view history",
@@ -197,7 +198,7 @@ public boolean onOptionsItemSelected(final MenuItem item) {
197198
throwable -> ErrorActivity.reportError(getContext(),
198199
throwable,
199200
SettingsActivity.class, null,
200-
ErrorActivity.ErrorInfo.make(
201+
ErrorInfo.make(
201202
UserAction.DELETE_FROM_HISTORY,
202203
"none",
203204
"Delete search history",

app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionsImportFragment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
2828
import org.schabi.newpipe.local.subscription.services.SubscriptionsImportService;
2929
import org.schabi.newpipe.report.ErrorActivity;
30+
import org.schabi.newpipe.report.ErrorInfo;
3031
import org.schabi.newpipe.report.UserAction;
3132
import org.schabi.newpipe.util.Constants;
3233
import org.schabi.newpipe.util.FilePickerActivityHelper;
@@ -84,7 +85,7 @@ public void onCreate(final Bundle savedInstanceState) {
8485
setupServiceVariables();
8586
if (supportedSources.isEmpty() && currentServiceId != Constants.NO_SERVICE_ID) {
8687
ErrorActivity.reportError(activity, Collections.emptyList(), null, null,
87-
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE,
88+
ErrorInfo.make(UserAction.SOMETHING_ELSE,
8889
NewPipe.getNameOfService(currentServiceId),
8990
"Service don't support importing", R.string.general_error));
9091
activity.finish();

0 commit comments

Comments
 (0)