Skip to content

Commit 5f47fc7

Browse files
Convert ErrorInfo to Kotlin and use the Parcelize annotation.
1 parent 1b11dc5 commit 5f47fc7

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;
@@ -214,7 +215,7 @@ protected void initACRA() {
214215
ace,
215216
null,
216217
null,
217-
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
218+
ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
218219
"Could not initialize ACRA crash report", R.string.app_ui_crash));
219220
}
220221
}

app/src/main/java/org/schabi/newpipe/CheckForNewAppVersionTask.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;
@@ -64,7 +65,7 @@ private static String getCertificateSHA1Fingerprint() {
6465
packageInfo = pm.getPackageInfo(packageName, flags);
6566
} catch (final PackageManager.NameNotFoundException e) {
6667
ErrorActivity.reportError(APP, e, null, null,
67-
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
68+
ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
6869
"Could not find package info", R.string.app_ui_crash));
6970
}
7071

@@ -79,7 +80,7 @@ private static String getCertificateSHA1Fingerprint() {
7980
c = (X509Certificate) cf.generateCertificate(input);
8081
} catch (final CertificateException e) {
8182
ErrorActivity.reportError(APP, e, null, null,
82-
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
83+
ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
8384
"Certificate error", R.string.app_ui_crash));
8485
}
8586

@@ -91,7 +92,7 @@ private static String getCertificateSHA1Fingerprint() {
9192
hexString = byte2HexFormatted(publicKey);
9293
} catch (NoSuchAlgorithmException | CertificateEncodingException e) {
9394
ErrorActivity.reportError(APP, e, null, null,
94-
ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
95+
ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
9596
"Could not retrieve SHA1 key", R.string.app_ui_crash));
9697
}
9798

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
@@ -92,6 +92,7 @@
9292
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
9393
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
9494
import org.schabi.newpipe.report.ErrorActivity;
95+
import org.schabi.newpipe.report.ErrorInfo;
9596
import org.schabi.newpipe.report.UserAction;
9697
import org.schabi.newpipe.util.Constants;
9798
import org.schabi.newpipe.util.DeviceUtils;
@@ -1609,7 +1610,7 @@ public void openDownloadDialog() {
16091610

16101611
downloadDialog.show(activity.getSupportFragmentManager(), "downloadDialog");
16111612
} catch (final Exception e) {
1612-
final ErrorActivity.ErrorInfo info = ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR,
1613+
final ErrorInfo info = ErrorInfo.make(UserAction.UI_ERROR,
16131614
ServiceList.all()
16141615
.get(currentInfo
16151616
.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;
@@ -249,7 +250,7 @@ public void onResume() {
249250
} catch (final Exception e) {
250251
ErrorActivity.reportError(getActivity(), e, requireActivity().getClass(),
251252
requireActivity().findViewById(android.R.id.content),
252-
ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR,
253+
ErrorInfo.make(UserAction.UI_ERROR,
253254
"",
254255
"", R.string.general_error));
255256
}

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
@@ -33,6 +33,7 @@
3333
import org.schabi.newpipe.player.playqueue.PlayQueue;
3434
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
3535
import org.schabi.newpipe.report.ErrorActivity;
36+
import org.schabi.newpipe.report.ErrorInfo;
3637
import org.schabi.newpipe.report.UserAction;
3738
import org.schabi.newpipe.settings.SettingsActivity;
3839
import org.schabi.newpipe.util.NavigationHelper;
@@ -181,7 +182,7 @@ public boolean onOptionsItemSelected(final MenuItem item) {
181182
throwable -> ErrorActivity.reportError(getContext(),
182183
throwable,
183184
SettingsActivity.class, null,
184-
ErrorActivity.ErrorInfo.make(
185+
ErrorInfo.make(
185186
UserAction.DELETE_FROM_HISTORY,
186187
"none",
187188
"Delete view history",
@@ -195,7 +196,7 @@ public boolean onOptionsItemSelected(final MenuItem item) {
195196
throwable -> ErrorActivity.reportError(getContext(),
196197
throwable,
197198
SettingsActivity.class, null,
198-
ErrorActivity.ErrorInfo.make(
199+
ErrorInfo.make(
199200
UserAction.DELETE_FROM_HISTORY,
200201
"none",
201202
"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)