1
0
mirror of https://github.com/tateisu/SubwayTooter synced 2025-01-27 17:19:24 +01:00

「アプリについて」から公式アカウントや更新履歴に飛べるボタンを追加

This commit is contained in:
tateisu 2019-01-26 20:07:04 +09:00
parent 19172518bd
commit d0d2863d2f
4 changed files with 156 additions and 75 deletions

View File

@ -5,6 +5,8 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.Gravity
import android.view.View
import android.widget.Button
import android.widget.LinearLayout
import android.widget.TextView
@ -17,18 +19,22 @@ class ActAbout : AppCompatActivity() {
const val EXTRA_SEARCH = "search"
const val url_store = "https://play.google.com/store/apps/details?id=jp.juggler.subwaytooter"
const val url_store =
"https://play.google.com/store/apps/details?id=jp.juggler.subwaytooter"
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_futaba = "https://www.instagram.com/hinomoto_hutaba/"
const val url_weblate = "https://hosted.weblate.org/projects/subway-tooter/"
val contributors = arrayOf(
"@Balor@freeradical.zone", "update english language",
"@Luattic@oc.todon.fr", "update french language",
"@BoF@mstdn.fr", "update arabic language"
Pair("@Balor@freeradical.zone", "update english language"),
Pair("@Luattic@oc.todon.fr", "update french language"),
Pair("@BoF@mstdn.fr", "update arabic language")
)
}
@ -43,65 +49,76 @@ class ActAbout : AppCompatActivity() {
try {
val pInfo = packageManager.getPackageInfo(packageName, 0)
val tv = findViewById<TextView>(R.id.tvVersion)
tv.text = getString(R.string.version_is, pInfo.versionName)
tv.text = getString(R.string.version_is, pInfo.versionName)
} catch(ex : PackageManager.NameNotFoundException) {
log.trace(ex,"getPackageInfo failed.")
log.trace(ex, "getPackageInfo failed.")
}
var b : Button
fun setButton(btnId : Int, caption : String, onClick : () -> Unit) {
val b : Button = findViewById(btnId)
b.text = caption
b.setOnClickListener { onClick() }
}
b = findViewById(R.id.btnDeveloper)
b.text = getString(R.string.search_for, developer_acct)
b.setOnClickListener {
val data = Intent()
data.putExtra(EXTRA_SEARCH, developer_acct)
setResult(Activity.RESULT_OK, data)
fun searchAcct(acct : String) {
setResult(Activity.RESULT_OK, Intent().apply { putExtra(EXTRA_SEARCH, acct) })
finish()
}
b = findViewById(R.id.btnRate)
b.text = url_store
b.setOnClickListener {App1.openBrowser(this@ActAbout,url_store) }
fun openUrl(url : String) {
App1.openBrowser(this@ActAbout, url)
}
b = findViewById(R.id.btnIconDesign)
b.text = url_futaba
b.setOnClickListener { App1.openBrowser(this@ActAbout,url_futaba) }
setButton(
R.id.btnDeveloper,
getString(R.string.search_for, developer_acct)
) { searchAcct(developer_acct) }
b = findViewById(R.id.btnWeblate)
b.text = "Please help translation!"
b.setOnClickListener { App1.openBrowser(this@ActAbout,url_weblate) }
setButton(
R.id.btnOfficialAccount,
getString(R.string.search_for, official_acct)
) { searchAcct(official_acct) }
setButton(R.id.btnRate, url_store) { openUrl(url_store) }
setButton(R.id.btnReleaseNote, url_release) { openUrl(url_release) }
setButton(R.id.btnIconDesign, url_futaba) { openUrl(url_futaba) }
setButton(R.id.btnWeblate, "Please help translation!") { openUrl(url_weblate) }
val ll = findViewById<LinearLayout>(R.id.llContributors)
val density = resources.displayMetrics.density
val margin_top = (0.5f + density * 8).toInt()
val padding = (0.5f + density * 8).toInt()
var i = 0
val ie = contributors.size
while(i < ie) {
val acct = contributors[i]
val works = contributors[i + 1]
b = Button(this)
//
val lp = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)
if(i < 0) lp.topMargin = margin_top
b.layoutParams = lp
//
b.setBackgroundResource(R.drawable.btn_bg_transparent)
b.setPadding(padding, padding, padding, padding)
b.isAllCaps = false
//
b.text = getString(R.string.search_for, acct) + "\n" + getString(R.string.thanks_for, works)
b.setOnClickListener {
val data = Intent()
data.putExtra(EXTRA_SEARCH, acct)
setResult(Activity.RESULT_OK, data)
finish()
}
//
ll.addView(b)
i += 2
for( pair in contributors){
ll.addView(Button(this).apply{
val acct = pair.first
val works = pair.second
//
layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
).apply{
if( ll.childCount != 0 ) topMargin = margin_top
}
//
setBackgroundResource(R.drawable.btn_bg_transparent)
setPadding(padding, padding, padding, padding)
isAllCaps = false
//
text = getString(R.string.search_for, acct) + "\n" +
getString(R.string.thanks_for, works)
gravity = Gravity.START or Gravity.CENTER_VERTICAL
setOnClickListener {
val data = Intent()
data.putExtra(EXTRA_SEARCH, acct)
setResult(Activity.RESULT_OK, data)
finish()
}
})
}
}
}

View File

@ -6,6 +6,7 @@
android:layout_height="match_parent"
android:fillViewport="true"
android:padding="12dp"
android:scrollbarStyle="outsideOverlay"
android:id="@+id/svContent"
android:clipToPadding="false"
@ -15,7 +16,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:gravity="start"
android:orientation="vertical"
android:paddingTop="12dp"
android:paddingBottom="12dp"
@ -32,6 +33,7 @@
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="32sp"
android:layout_gravity="center"
/>
<TextView
@ -39,28 +41,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="version 0.0.0"
/>
<View
android:layout_width="0dp"
android:layout_height="8dp"
android:layout_weight="0.2"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/developer"
/>
<Button
android:id="@+id/btnDeveloper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_bg_transparent"
android:padding="8dp"
android:textAllCaps="false"
tools:text="tateisu@mastodon.juggler.jp"
android:layout_gravity="center"
/>
<View
@ -83,8 +64,83 @@
android:padding="8dp"
android:textAllCaps="false"
tools:text="rate_on_store"
android:layout_marginStart="32dp"
android:gravity="start|center_vertical"
/>
<View
android:layout_width="0dp"
android:layout_height="8dp"
android:layout_weight="0.2"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/releases"
/>
<Button
android:id="@+id/btnReleaseNote"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_bg_transparent"
android:padding="8dp"
android:textAllCaps="false"
tools:text="https://github.com/tateisu/SubwayTooter/releases"
android:layout_marginStart="32dp"
android:gravity="start|center_vertical"
/>
<View
android:layout_width="0dp"
android:layout_height="8dp"
android:layout_weight="0.2"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/official_account"
/>
<Button
android:id="@+id/btnOfficialAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_bg_transparent"
android:padding="8dp"
android:textAllCaps="false"
tools:text="SubwayTooter@mastodon.juggler.jp"
android:layout_marginStart="32dp"
android:gravity="start|center_vertical"
/>
<View
android:layout_width="0dp"
android:layout_height="8dp"
android:layout_weight="0.2"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/developer"
/>
<Button
android:id="@+id/btnDeveloper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_bg_transparent"
android:padding="8dp"
android:textAllCaps="false"
tools:text="tateisu@mastodon.juggler.jp"
android:layout_marginStart="32dp"
android:gravity="start|center_vertical"
/>
<View
android:layout_width="0dp"
android:layout_height="8dp"
@ -104,6 +160,8 @@
android:background="@drawable/btn_bg_transparent"
android:padding="8dp"
android:textAllCaps="false"
android:layout_marginStart="32dp"
android:gravity="start|center_vertical"
/>
<!--<View-->
@ -144,8 +202,8 @@
android:id="@+id/llContributors"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:layout_marginStart="32dp"
/>
<View
@ -161,6 +219,8 @@
android:background="@drawable/btn_bg_transparent"
android:padding="8dp"
android:textAllCaps="false"
android:layout_marginStart="32dp"
android:gravity="start|center_vertical"
/>
</LinearLayout>
</ScrollView>

View File

@ -370,7 +370,7 @@
<string name="language_code">ja</string>
<string name="languages">言語</string>
<string name="last_selection">最後に選択した</string>
<string name="launcher_icon_by">ランチャーアイコンはフタバさんがデザインしました</string>
<string name="launcher_icon_by">ランチャーアイコンのデザイン:フタバさん</string>
<string name="led">LED</string>
<string name="length_warning">\"%1$s\"が長すぎます(%2$d/%3$d文字).\n標準的なサーバーではエラーとなりますが、一部のサーバーでは通るかも。\nよろしいですか?</string>
<string name="list">リスト</string>
@ -853,5 +853,7 @@
<string name="open_in_admin_ui">管理者WebUIで開く</string>
<string name="show_acct_in_system_notification">システム通知に(ユーザ名ではなく)acctを使用する</string>
<string name="show_link_underline">リンクの下線を表示する</string>
<string name="official_account">公式アカウント</string>
<string name="releases">更新履歴</string>
</resources>

View File

@ -875,5 +875,7 @@
<string name="open_in_admin_ui">Open in admin web UI</string>
<string name="show_acct_in_system_notification">Show acct (instead of user name) in system notification</string>
<string name="show_link_underline">Show link underline</string>
<string name="official_account">Official account</string>
<string name="releases">Releases</string>
</resources>