Fix: Crash when no file picker found
This commit is contained in:
parent
188af8ad9e
commit
3479289792
@ -135,6 +135,7 @@
|
||||
android:theme="@style/AppTheme.NoActionBar.Dark" />
|
||||
<activity
|
||||
android:name=".ui.setup.SetupActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:exported="true"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.neoterm.ui.setup
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
@ -48,6 +49,7 @@ class SetupActivity : AppCompatActivity(), View.OnClickListener, ResultListener
|
||||
setContentView(R.layout.ui_setup)
|
||||
|
||||
val parameterEditor = findViewById<EditText>(R.id.setup_source_parameter)
|
||||
|
||||
val tipText = findViewById<TextView>(R.id.setup_url_tip_text)
|
||||
|
||||
val onCheckedChangeListener = CompoundButton.OnCheckedChangeListener { button, checked ->
|
||||
@ -129,13 +131,18 @@ class SetupActivity : AppCompatActivity(), View.OnClickListener, ResultListener
|
||||
}
|
||||
|
||||
private fun doSelectParameter() {
|
||||
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
|
||||
|
||||
// Filter to only show results that can be "opened", such as a
|
||||
// file (as opposed to a list of contacts or timezones)
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
|
||||
startActivityForResult(intent, REQUEST_SELECT_PARAMETER)
|
||||
val id = findViewById<RadioGroup>(R.id.setup_method_group).checkedRadioButtonId
|
||||
when (id) {
|
||||
R.id.setup_method_backup,
|
||||
R.id.setup_method_local -> {
|
||||
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT)
|
||||
try {
|
||||
startActivityForResult(intent, REQUEST_SELECT_PARAMETER)
|
||||
} catch (ignore: ActivityNotFoundException) {
|
||||
Toast.makeText(this, R.string.no_file_picker, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createSourceConnection(id: Int, parameter: String, parameterUri: Uri?): SourceConnection {
|
||||
|
@ -87,8 +87,8 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:clickable="false"
|
||||
android:hint="@string/setup_hint_online"
|
||||
android:text="@string/default_source_url" />
|
||||
|
||||
|
@ -79,7 +79,7 @@
|
||||
<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_local">启动文件(*.zip)路径</string>
|
||||
<string name="setup_hint_assets">不可用</string>
|
||||
<string name="setup_hint_backup">备份文件(*.neobackup) 路径</string>
|
||||
<string name="setup_error_file_not_found">文件不存在</string>
|
||||
@ -155,6 +155,7 @@
|
||||
<string name="new_x_session">新建图形会话</string>
|
||||
<string name="new_session_with_profile">新建个性化会话</string>
|
||||
<string name="no_profile_available">没有可用的个性化配置</string>
|
||||
<string name="no_file_picker">没有文件选择器</string>
|
||||
|
||||
<string-array name="color_item_names">
|
||||
<item>背景色</item>
|
||||
|
@ -159,6 +159,7 @@
|
||||
<string name="new_x_session">New X Session</string>
|
||||
<string name="new_session_with_profile">New Session With Profile</string>
|
||||
<string name="no_profile_available">No profile available</string>
|
||||
<string name="no_file_picker">No file picker found</string>
|
||||
|
||||
<string name="default_source_url">http://janyo.pw:82/kiva/neoterm</string>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user