0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 12:02:16 +02:00

NF: info use scoped function

This commit is contained in:
Arthur Milchior 2022-05-29 12:08:09 +02:00 committed by Mike Hardy
parent e4432d044b
commit 1deca6b22d

View File

@ -74,12 +74,18 @@ class Info : AnkiActivity() {
} }
} }
} }
val marketButton = findViewById<Button>(R.id.left_button) findViewById<Button>(R.id.left_button).run {
if (canOpenMarketUri()) { if (canOpenMarketUri()) {
marketButton.setText(R.string.info_rate) setText(R.string.info_rate)
marketButton.setOnClickListener { tryOpenIntent(this, AnkiDroidApp.getMarketIntent(this)) } setOnClickListener {
} else { tryOpenIntent(
marketButton.visibility = View.GONE this@Info,
AnkiDroidApp.getMarketIntent(this@Info)
)
}
} else {
visibility = View.GONE
}
} }
// Apply Theme colors // Apply Theme colors
@ -92,14 +98,16 @@ class Info : AnkiActivity() {
TYPE_ABOUT -> { TYPE_ABOUT -> {
val htmlContent = getAboutAnkiDroidHtml(res, textColor) val htmlContent = getAboutAnkiDroidHtml(res, textColor)
mWebView!!.loadDataWithBaseURL("", htmlContent, "text/html", "utf-8", null) mWebView!!.loadDataWithBaseURL("", htmlContent, "text/html", "utf-8", null)
val debugCopy = findViewById<Button>(R.id.right_button) findViewById<Button>(R.id.right_button).run {
debugCopy.text = res.getString(R.string.feedback_copy_debug) text = res.getString(R.string.feedback_copy_debug)
debugCopy.setOnClickListener { copyDebugInfo() } setOnClickListener { copyDebugInfo() }
}
} }
TYPE_NEW_VERSION -> { TYPE_NEW_VERSION -> {
val continueButton = findViewById<Button>(R.id.right_button) findViewById<Button>(R.id.right_button).run {
continueButton.text = res.getString(R.string.dialog_continue) text = res.getString(R.string.dialog_continue)
continueButton.setOnClickListener { close() } setOnClickListener { close() }
}
val background = String.format("#%06X", 0xFFFFFF and backgroundColor) val background = String.format("#%06X", 0xFFFFFF and backgroundColor)
mWebView!!.loadUrl("file:///android_asset/changelog.html") mWebView!!.loadUrl("file:///android_asset/changelog.html")
mWebView!!.settings.javaScriptEnabled = true mWebView!!.settings.javaScriptEnabled = true