2018-01-04 19:52:25 +01:00
|
|
|
package jp.juggler.subwaytooter
|
|
|
|
|
|
|
|
import android.app.Activity
|
|
|
|
import android.content.Intent
|
|
|
|
import android.os.Bundle
|
2019-01-26 12:07:04 +01:00
|
|
|
import android.view.Gravity
|
2018-01-04 19:52:25 +01:00
|
|
|
import android.widget.Button
|
|
|
|
import android.widget.LinearLayout
|
2019-11-21 10:48:15 +01:00
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
2021-11-08 11:04:30 +01:00
|
|
|
import androidx.appcompat.widget.AppCompatButton
|
2023-01-14 21:37:23 +01:00
|
|
|
import jp.juggler.subwaytooter.databinding.ActAboutBinding
|
2020-09-29 19:44:56 +02:00
|
|
|
import jp.juggler.subwaytooter.util.openBrowser
|
2022-09-10 23:09:26 +02:00
|
|
|
import jp.juggler.util.getPackageInfoCompat
|
2023-01-13 13:22:25 +01:00
|
|
|
import jp.juggler.util.log.LogCategory
|
2023-01-14 21:37:23 +01:00
|
|
|
import jp.juggler.util.ui.setNavigationBack
|
2018-01-04 19:52:25 +01:00
|
|
|
|
|
|
|
class ActAbout : AppCompatActivity() {
|
2021-05-08 07:56:34 +02:00
|
|
|
|
|
|
|
class Translators(
|
|
|
|
val name: String,
|
|
|
|
val acct: String?,
|
2021-06-20 15:12:25 +02:00
|
|
|
val lang: String,
|
2021-05-08 07:56:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
|
|
|
|
val log = LogCategory("ActAbout")
|
|
|
|
|
|
|
|
const val EXTRA_SEARCH = "search"
|
|
|
|
|
|
|
|
const val developer_acct = "tateisu@mastodon.juggler.jp"
|
|
|
|
const val official_acct = "SubwayTooter@mastodon.juggler.jp"
|
|
|
|
|
|
|
|
const val url_release = "https://github.com/tateisu/SubwayTooter/releases"
|
|
|
|
|
|
|
|
const val url_weblate = "https://hosted.weblate.org/projects/subway-tooter/"
|
|
|
|
|
|
|
|
// git log --pretty=format:"%an %s" |grep "Translated using Weblate"|sort|uniq
|
|
|
|
val translators = arrayOf(
|
|
|
|
Translators("Allan Nordhøy", null, "English, Norwegian Bokmål"),
|
|
|
|
Translators("ayiniho", null, "French"),
|
|
|
|
Translators("ButterflyOfFire", "@ButterflyOfFire@mstdn.fr", "Arabic, French, Kabyle"),
|
|
|
|
Translators("Ch", null, "Korean"),
|
|
|
|
Translators("chinnux", "@chinnux@neko.ci", "Chinese (Simplified)"),
|
|
|
|
Translators("Dyxang", null, "Chinese (Simplified)"),
|
|
|
|
Translators("Elizabeth Sherrock", null, "Chinese (Simplified)"),
|
|
|
|
Translators("Gennady Archangorodsky", null, "Hebrew"),
|
|
|
|
Translators("inqbs Siina", null, "Korean"),
|
|
|
|
Translators("J. Lavoie", null, "French, German"),
|
|
|
|
Translators("Jeong Arm", "@jarm@qdon.space", "Korean"),
|
|
|
|
Translators("Joan Pujolar", "@jpujolar@mastodont.cat", "Catalan"),
|
|
|
|
Translators("Kai Zhang", "@bearzk@mastodon.social", "Chinese (Simplified)"),
|
|
|
|
Translators("koyu", null, "German"),
|
|
|
|
Translators("Liaizon Wakest", null, "English"),
|
|
|
|
Translators("lingcas", null, "Chinese (Traditional)"),
|
|
|
|
Translators("Love Xu", null, "Chinese (Simplified)"),
|
|
|
|
Translators("lptprjh", null, "Korean"),
|
|
|
|
Translators("mv87", null, "German"),
|
|
|
|
Translators("mynameismonkey", null, "Welsh"),
|
|
|
|
Translators("Nathan", null, "French"),
|
|
|
|
Translators("Niek Visser", null, "Dutch"),
|
|
|
|
Translators("Owain Rhys Lewis", null, "Welsh"),
|
|
|
|
Translators("Remi Rampin", null, "French"),
|
|
|
|
Translators("Sachin", null, "Kannada"),
|
|
|
|
Translators("Swann Martinet", null, "French"),
|
|
|
|
Translators("takubunn", null, "Chinese (Simplified)"),
|
|
|
|
Translators("Whod", null, "Bulgarian"),
|
|
|
|
Translators("yucj", null, "Chinese (Traditional)"),
|
|
|
|
Translators("邓志诚", null, "Chinese (Simplified)"),
|
|
|
|
Translators("배태길", null, "Korea"),
|
2021-06-20 15:12:25 +02:00
|
|
|
)
|
2021-05-08 07:56:34 +02:00
|
|
|
}
|
|
|
|
|
2023-01-14 21:37:23 +01:00
|
|
|
private val views by lazy {
|
|
|
|
ActAboutBinding.inflate(layoutInflater)
|
|
|
|
}
|
|
|
|
|
2021-05-08 07:56:34 +02:00
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
App1.setActivityTheme(this)
|
2023-01-14 21:37:23 +01:00
|
|
|
setContentView(views.root)
|
|
|
|
setSupportActionBar(views.toolbar)
|
|
|
|
setNavigationBack(views.toolbar)
|
|
|
|
fixHorizontalMargin(views.svContent)
|
2021-05-08 07:56:34 +02:00
|
|
|
|
|
|
|
try {
|
2022-09-10 23:09:26 +02:00
|
|
|
packageManager.getPackageInfoCompat(packageName)?.let { pInfo ->
|
2023-01-14 21:37:23 +01:00
|
|
|
views.tvVersion.text = getString(R.string.version_is, pInfo.versionName)
|
2022-09-10 23:09:26 +02:00
|
|
|
}
|
|
|
|
} catch (ex: Throwable) {
|
2022-12-27 03:54:52 +01:00
|
|
|
log.e(ex, "can't get app version.")
|
2021-05-08 07:56:34 +02:00
|
|
|
}
|
|
|
|
|
2023-01-14 21:37:23 +01:00
|
|
|
fun setButton(b: Button, caption: String, onClick: () -> Unit) {
|
2021-05-08 07:56:34 +02:00
|
|
|
b.text = caption
|
|
|
|
b.setOnClickListener { onClick() }
|
|
|
|
}
|
|
|
|
|
|
|
|
fun searchAcct(acct: String) {
|
|
|
|
setResult(Activity.RESULT_OK, Intent().apply { putExtra(EXTRA_SEARCH, acct) })
|
|
|
|
finish()
|
|
|
|
}
|
|
|
|
|
|
|
|
setButton(
|
2023-01-14 21:37:23 +01:00
|
|
|
views.btnDeveloper,
|
2021-05-08 07:56:34 +02:00
|
|
|
getString(R.string.search_for, developer_acct)
|
|
|
|
) { searchAcct(developer_acct) }
|
|
|
|
|
|
|
|
setButton(
|
2023-01-14 21:37:23 +01:00
|
|
|
views.btnOfficialAccount,
|
2021-05-08 07:56:34 +02:00
|
|
|
getString(R.string.search_for, official_acct)
|
2023-01-14 21:37:23 +01:00
|
|
|
) { searchAcct(official_acct) }
|
2021-05-08 07:56:34 +02:00
|
|
|
|
2023-01-14 21:37:23 +01:00
|
|
|
setButton(
|
|
|
|
views.btnReleaseNote,
|
|
|
|
url_release
|
|
|
|
) { openBrowser(url_release) }
|
2021-05-08 07:56:34 +02:00
|
|
|
|
|
|
|
// setButton(R.id.btnIconDesign, url_futaba)
|
|
|
|
// { openUrl(url_futaba) }
|
|
|
|
|
2023-01-14 21:37:23 +01:00
|
|
|
setButton(views.btnWeblate, getString(R.string.please_help_translation)) {
|
2021-06-20 15:12:25 +02:00
|
|
|
openBrowser(url_weblate)
|
|
|
|
}
|
2021-05-08 07:56:34 +02:00
|
|
|
|
2023-01-14 21:37:23 +01:00
|
|
|
val ll = views.llContributors
|
2021-05-08 07:56:34 +02:00
|
|
|
val density = resources.displayMetrics.density
|
2021-06-20 15:12:25 +02:00
|
|
|
val marginTop = (0.5f + density * 8).toInt()
|
2021-05-08 07:56:34 +02:00
|
|
|
val padding = (0.5f + density * 8).toInt()
|
|
|
|
|
|
|
|
for (who in translators) {
|
2022-06-04 20:35:07 +02:00
|
|
|
AppCompatButton(this).apply {
|
2021-05-08 07:56:34 +02:00
|
|
|
//
|
|
|
|
layoutParams = LinearLayout.LayoutParams(
|
|
|
|
LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
|
|
LinearLayout.LayoutParams.WRAP_CONTENT
|
|
|
|
).apply {
|
2021-06-20 15:12:25 +02:00
|
|
|
if (ll.childCount != 0) topMargin = marginTop
|
2021-05-08 07:56:34 +02:00
|
|
|
}
|
|
|
|
//
|
|
|
|
setBackgroundResource(R.drawable.btn_bg_transparent_round6dp)
|
|
|
|
setPadding(padding, padding, padding, padding)
|
|
|
|
isAllCaps = false
|
|
|
|
|
|
|
|
//
|
|
|
|
val acct = who.acct ?: "@?@?"
|
|
|
|
text = "${who.name}\n$acct\n${getString(R.string.thanks_for, who.lang)}"
|
|
|
|
gravity = Gravity.START or Gravity.CENTER_VERTICAL
|
|
|
|
|
|
|
|
setOnClickListener {
|
|
|
|
val data = Intent()
|
|
|
|
data.putExtra(EXTRA_SEARCH, who.acct ?: who.name)
|
|
|
|
setResult(Activity.RESULT_OK, data)
|
|
|
|
finish()
|
|
|
|
}
|
2022-06-04 20:35:07 +02:00
|
|
|
}.let { ll.addView(it) }
|
2021-05-08 07:56:34 +02:00
|
|
|
}
|
|
|
|
}
|
2018-01-04 19:52:25 +01:00
|
|
|
}
|