UI: Setup Activity

This commit is contained in:
zt515 2017-12-17 01:25:37 +08:00
parent e28b12c9fd
commit 804b2044ab
4 changed files with 54 additions and 9 deletions

View File

@ -2,6 +2,9 @@ package io.neoterm.ui.setup
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.CompoundButton
import android.widget.EditText
import android.widget.RadioButton
import io.neoterm.R
import io.neoterm.utils.PackageUtils
@ -12,10 +15,35 @@ import io.neoterm.utils.PackageUtils
class SetupActivity : AppCompatActivity() {
private var aptUpdated = false
private val MAPPING = arrayOf(
R.id.setup_method_online, R.string.setup_hint_online,
R.id.setup_method_local, R.string.setup_hint_local,
R.id.setup_method_assets, R.string.setup_hint_assets,
R.id.setup_method_backup, R.string.setup_hint_backup
)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.ui_setup)
setup()
val parameterEditor = findViewById<EditText>(R.id.setup_source_parameter)
val onCheckedChangeListener = CompoundButton.OnCheckedChangeListener { button, checked ->
if (checked) {
val id = button.id
val index = MAPPING.indexOf(id)
if (index < 0 || index % 2 != 0) {
parameterEditor.setHint(R.string.setup_input_source_parameter)
return@OnCheckedChangeListener
}
parameterEditor.setHint(MAPPING[index + 1])
}
}
findViewById<RadioButton>(R.id.setup_method_online).setOnCheckedChangeListener(onCheckedChangeListener)
findViewById<RadioButton>(R.id.setup_method_local).setOnCheckedChangeListener(onCheckedChangeListener)
findViewById<RadioButton>(R.id.setup_method_assets).setOnCheckedChangeListener(onCheckedChangeListener)
findViewById<RadioButton>(R.id.setup_method_backup).setOnCheckedChangeListener(onCheckedChangeListener)
}
private fun setup() {

View File

@ -39,6 +39,7 @@
android:orientation="vertical">
<RadioGroup
android:id="@+id/setup_method_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkedButton="@id/setup_method_online">
@ -61,6 +62,12 @@
android:layout_height="wrap_content"
android:text="@string/setup_assets" />
<RadioButton
android:id="@+id/setup_method_backup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/setup_backup" />
</RadioGroup>
<TextView
@ -68,7 +75,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/setup_source_url" />
android:text="@string/setup_source_parameter" />
<LinearLayout
android:layout_width="match_parent"
@ -76,16 +83,16 @@
android:orientation="horizontal">
<EditText
android:id="@+id/setup_source_url"
android:id="@+id/setup_source_parameter"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:clickable="false"
android:focusable="false"
android:hint="@string/setup_input_source_url" />
android:hint="@string/setup_hint_online" />
<Button
android:id="@+id/setup_source_url_select"
android:id="@+id/setup_source_parameter_select"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"

View File

@ -72,8 +72,13 @@
<string name="setup_online">在线设置</string>
<string name="setup_local">本地 Zip 文件</string>
<string name="setup_assets">软件自带 Zip 文件</string>
<string name="setup_source_url">配置地址</string>
<string name="setup_input_source_url">输入配置地址</string>
<string name="setup_backup">NeoTerm 备份</string>
<string name="setup_source_parameter">配置参数</string>
<string name="setup_input_source_parameter">输入配置地址</string>
<string name="setup_hint_online">含有启动文件的软件源地址</string>
<string name="setup_hint_local">启动文件路径</string>
<string name="setup_hint_assets">不可用</string>
<string name="setup_hint_backup">备份文件(*.neobackup) 路径</string>
<string name="crash_model">设备: %s</string>
<string name="crash_app">应用: %s</string>
<string name="crash_stack_trace">堆栈信息</string>

View File

@ -18,9 +18,14 @@
<string name="setup_online">Online Setup</string>
<string name="setup_local">Local Zip File Setup</string>
<string name="setup_assets">Assets Zip File Setup</string>
<string name="setup_source_url">Source URL</string>
<string name="setup_input_source_url">Input source URL…</string>
<string name="setup_backup">NeoTerm Backup</string>
<string name="setup_source_parameter">Source Parameter</string>
<string name="setup_input_source_parameter">Input source parameter…</string>
<string name="setup_dots" translatable="false"></string>
<string name="setup_hint_online">URL of mirror that contains setup zip files</string>
<string name="setup_hint_local">File path to setup zip files</string>
<string name="setup_hint_assets">Not available</string>
<string name="setup_hint_backup">File path to backup file(*.neobackup)</string>
<string name="about">About</string>
<string name="settings">Settings</string>