@@ -34,7 +34,7 @@ class ErrorActivity : AppCompatActivity() {
3434 private lateinit var errorInfo: ErrorInfo
3535 private lateinit var currentTimeStamp: String
3636
37- private lateinit var activityErrorBinding : ActivityErrorBinding
37+ private lateinit var binding : ActivityErrorBinding
3838
3939 private val contentCountryString: String
4040 get() = Localization .getPreferredContentCountry(this ).countryCode
@@ -69,10 +69,10 @@ class ErrorActivity : AppCompatActivity() {
6969 ThemeHelper .setDayNightMode(this )
7070 ThemeHelper .setTheme(this )
7171
72- activityErrorBinding = ActivityErrorBinding .inflate(layoutInflater)
73- setContentView(activityErrorBinding .getRoot())
72+ binding = ActivityErrorBinding .inflate(layoutInflater)
73+ setContentView(binding .getRoot())
7474
75- setSupportActionBar(activityErrorBinding .toolbarLayout.toolbar)
75+ setSupportActionBar(binding .toolbarLayout.toolbar)
7676 supportActionBar?.apply {
7777 setDisplayHomeAsUpEnabled(true )
7878 setTitle(R .string.error_report_title)
@@ -86,22 +86,22 @@ class ErrorActivity : AppCompatActivity() {
8686 // print current time, as zoned ISO8601 timestamp
8787 currentTimeStamp = ZonedDateTime .now().format(DateTimeFormatter .ISO_OFFSET_DATE_TIME )
8888
89- activityErrorBinding .errorReportEmailButton.setOnClickListener { _ ->
89+ binding .errorReportEmailButton.setOnClickListener { _ ->
9090 openPrivacyPolicyDialog(this , " EMAIL" )
9191 }
9292
93- activityErrorBinding .errorReportCopyButton.setOnClickListener { _ ->
93+ binding .errorReportCopyButton.setOnClickListener { _ ->
9494 ShareUtils .copyToClipboard(this , buildMarkdown())
9595 }
9696
97- activityErrorBinding .errorReportGitHubButton.setOnClickListener { _ ->
97+ binding .errorReportGitHubButton.setOnClickListener { _ ->
9898 openPrivacyPolicyDialog(this , " GITHUB" )
9999 }
100100
101101 // normal bugreport
102102 buildInfo(errorInfo)
103- activityErrorBinding .errorMessageView.text = errorInfo.getMessage(this )
104- activityErrorBinding .errorView.text = formErrorText(errorInfo.stackTraces)
103+ binding .errorMessageView.text = errorInfo.getMessage(this )
104+ binding .errorView.text = formErrorText(errorInfo.stackTraces)
105105
106106 // print stack trace once again for debugging:
107107 errorInfo.stackTraces.forEach { Log .e(TAG , it) }
@@ -143,12 +143,12 @@ class ErrorActivity : AppCompatActivity() {
143143 }
144144 .setPositiveButton(R .string.accept) { _, _ ->
145145 if (action == " EMAIL" ) { // send on email
146- val i = Intent (Intent .ACTION_SENDTO )
146+ val intent = Intent (Intent .ACTION_SENDTO )
147147 .setData(" mailto:" .toUri()) // only email apps should handle this
148148 .putExtra(Intent .EXTRA_EMAIL , arrayOf(ERROR_EMAIL_ADDRESS ))
149149 .putExtra(Intent .EXTRA_SUBJECT , errorEmailSubject)
150150 .putExtra(Intent .EXTRA_TEXT , buildJson())
151- ShareUtils .openIntentInApp(context, i )
151+ ShareUtils .openIntentInApp(context, intent )
152152 } else if (action == " GITHUB" ) { // open the NewPipe issue page on GitHub
153153 ShareUtils .openUrlInApp(this , ERROR_GITHUB_ISSUE_URL )
154154 }
@@ -157,13 +157,13 @@ class ErrorActivity : AppCompatActivity() {
157157 .show()
158158 }
159159
160- private fun formErrorText (el : Array <String >): String {
160+ private fun formErrorText (stacktrace : Array <String >): String {
161161 val separator = " -------------------------------------"
162- return el .joinToString(separator + " \n " , separator + " \n " , separator)
162+ return stacktrace .joinToString(separator + " \n " , separator + " \n " , separator)
163163 }
164164
165165 private fun buildInfo (info : ErrorInfo ) {
166- activityErrorBinding .errorInfoLabelsView.text = getString(R .string.info_labels)
166+ binding .errorInfoLabelsView.text = getString(R .string.info_labels)
167167 .replace(" \\ n" , " \n " )
168168
169169 val text = info.userAction.message + " \n " +
@@ -177,7 +177,7 @@ class ErrorActivity : AppCompatActivity() {
177177 BuildConfig .VERSION_NAME + " \n " +
178178 osString
179179
180- activityErrorBinding .errorInfosView.text = text
180+ binding .errorInfosView.text = text
181181 }
182182
183183 private fun buildJson (): String {
@@ -195,7 +195,7 @@ class ErrorActivity : AppCompatActivity() {
195195 .value(" os" , osString)
196196 .value(" time" , currentTimeStamp)
197197 .array(" exceptions" , errorInfo.stackTraces.toList())
198- .value(" user_comment" , activityErrorBinding .errorCommentBox.getText().toString())
198+ .value(" user_comment" , binding .errorCommentBox.getText().toString())
199199 .end()
200200 .done()
201201 } catch (error: Throwable ) {
@@ -208,7 +208,7 @@ class ErrorActivity : AppCompatActivity() {
208208 private fun buildMarkdown (): String {
209209 try {
210210 return buildString(1024 ) {
211- val userComment = activityErrorBinding .errorCommentBox.getText().toString()
211+ val userComment = binding .errorCommentBox.getText().toString()
212212 if (! userComment.isEmpty()) {
213213 appendLine(userComment)
214214 }
@@ -261,21 +261,21 @@ class ErrorActivity : AppCompatActivity() {
261261
262262 private fun addGuruMeditation () {
263263 // just an easter egg
264- var text = activityErrorBinding .errorSorryView.getText() .toString()
264+ var text = binding .errorSorryView.text .toString()
265265 text + = " \n " + getString(R .string.guru_meditation)
266- activityErrorBinding .errorSorryView.text = text
266+ binding .errorSorryView.text = text
267267 }
268268
269269 companion object {
270270 // LOG TAGS
271- val TAG : String = ErrorActivity ::class .java.toString()
271+ private val TAG = ErrorActivity ::class .java.toString()
272272
273273 // BUNDLE TAGS
274- const val ERROR_INFO : String = " error_info"
274+ const val ERROR_INFO = " error_info"
275275
276- const val ERROR_EMAIL_ADDRESS : String = " crashreport@newpipe.schabi.org"
277- const val ERROR_EMAIL_SUBJECT : String = " Exception in "
276+ private const val ERROR_EMAIL_ADDRESS = " crashreport@newpipe.schabi.org"
277+ private const val ERROR_EMAIL_SUBJECT = " Exception in "
278278
279- const val ERROR_GITHUB_ISSUE_URL : String = " https://github.com/TeamNewPipe/NewPipe/issues"
279+ private const val ERROR_GITHUB_ISSUE_URL = " https://github.com/TeamNewPipe/NewPipe/issues"
280280 }
281281}
0 commit comments