@@ -85,8 +85,6 @@ protected void onCreate(final Bundle savedInstanceState) {
8585 activityErrorBinding = ActivityErrorBinding .inflate (getLayoutInflater ());
8686 setContentView (activityErrorBinding .getRoot ());
8787
88- final Intent intent = getIntent ();
89-
9088 setSupportActionBar (activityErrorBinding .toolbarLayout .toolbar );
9189
9290 final ActionBar actionBar = getSupportActionBar ();
@@ -96,13 +94,12 @@ protected void onCreate(final Bundle savedInstanceState) {
9694 actionBar .setDisplayShowTitleEnabled (true );
9795 }
9896
99- errorInfo = IntentCompat .getParcelableExtra (intent , ERROR_INFO , ErrorInfo .class );
97+ errorInfo = IntentCompat .getParcelableExtra (getIntent () , ERROR_INFO , ErrorInfo .class );
10098
10199 // important add guru meditation
102100 addGuruMeditation ();
103101 // print current time, as zoned ISO8601 timestamp
104- final ZonedDateTime now = ZonedDateTime .now ();
105- currentTimeStamp = now .format (DateTimeFormatter .ISO_OFFSET_DATE_TIME );
102+ currentTimeStamp = ZonedDateTime .now ().format (DateTimeFormatter .ISO_OFFSET_DATE_TIME );
106103
107104 activityErrorBinding .errorReportEmailButton .setOnClickListener (v ->
108105 openPrivacyPolicyDialog (this , "EMAIL" ));
@@ -160,9 +157,7 @@ private void openPrivacyPolicyDialog(final Context context, final String action)
160157 final Intent i = new Intent (Intent .ACTION_SENDTO )
161158 .setData (Uri .parse ("mailto:" )) // only email apps should handle this
162159 .putExtra (Intent .EXTRA_EMAIL , new String []{ERROR_EMAIL_ADDRESS })
163- .putExtra (Intent .EXTRA_SUBJECT , ERROR_EMAIL_SUBJECT
164- + getString (R .string .app_name ) + " "
165- + BuildConfig .VERSION_NAME )
160+ .putExtra (Intent .EXTRA_SUBJECT , getErrorEmailSubject ())
166161 .putExtra (Intent .EXTRA_TEXT , buildJson ());
167162 ShareUtils .openIntentInApp (context , i );
168163 } else if (action .equals ("GITHUB" )) { // open the NewPipe issue page on GitHub
@@ -180,12 +175,10 @@ private String formErrorText(final String[] el) {
180175 }
181176
182177 private void buildInfo (final ErrorInfo info ) {
183- String text = "" ;
184-
185178 activityErrorBinding .errorInfoLabelsView .setText (getString (R .string .info_labels )
186179 .replace ("\\ n" , "\n " ));
187180
188- text += getUserActionString ( info .getUserAction ()) + "\n "
181+ final String text = info .getUserAction (). getMessage ( ) + "\n "
189182 + info .getRequest () + "\n "
190183 + getContentLanguageString () + "\n "
191184 + getContentCountryString () + "\n "
@@ -203,7 +196,7 @@ private String buildJson() {
203196 try {
204197 return JsonWriter .string ()
205198 .object ()
206- .value ("user_action" , getUserActionString ( errorInfo .getUserAction ()))
199+ .value ("user_action" , errorInfo .getUserAction (). getMessage ( ))
207200 .value ("request" , errorInfo .getRequest ())
208201 .value ("content_language" , getContentLanguageString ())
209202 .value ("content_country" , getContentCountryString ())
@@ -239,7 +232,7 @@ private String buildMarkdown() {
239232 htmlErrorReport
240233 .append ("## Exception" )
241234 .append ("\n * __User Action:__ " )
242- .append (getUserActionString ( errorInfo .getUserAction ()))
235+ .append (errorInfo .getUserAction (). getMessage ( ))
243236 .append ("\n * __Request:__ " ).append (errorInfo .getRequest ())
244237 .append ("\n * __Content Country:__ " ).append (getContentCountryString ())
245238 .append ("\n * __Content Language:__ " ).append (getContentLanguageString ())
@@ -286,14 +279,6 @@ private String buildMarkdown() {
286279 }
287280 }
288281
289- private String getUserActionString (final UserAction userAction ) {
290- if (userAction == null ) {
291- return "Your description is in another castle." ;
292- } else {
293- return userAction .getMessage ();
294- }
295- }
296-
297282 private String getContentCountryString () {
298283 return Localization .getPreferredContentCountry (this ).getCountryCode ();
299284 }
@@ -306,6 +291,10 @@ private String getAppLanguage() {
306291 return Localization .getAppLocale ().toString ();
307292 }
308293
294+ private String getErrorEmailSubject () {
295+ return ERROR_EMAIL_SUBJECT + getString (R .string .app_name ) + " " + BuildConfig .VERSION_NAME ;
296+ }
297+
309298 private String getOsString () {
310299 final String osBase = Build .VERSION .SDK_INT >= Build .VERSION_CODES .M
311300 ? Build .VERSION .BASE_OS : "Android" ;
0 commit comments