Feature: Install missing login program when selected

This commit is contained in:
zt515 2017-08-23 23:30:38 +08:00
parent 7d828d63df
commit 3e208feae7
2 changed files with 20 additions and 1 deletions

View File

@ -167,7 +167,7 @@ object NeoPreference {
}
}
private fun findLoginProgram(loginProgramName: String): String? {
fun findLoginProgram(loginProgramName: String): String? {
val file = File("${NeoTermPath.USR_PATH}/bin", loginProgramName)
return if (file.canExecute()) file.absolutePath else null
}

View File

@ -3,6 +3,7 @@ package io.neoterm.ui.settings
import android.os.Bundle
import android.view.MenuItem
import io.neoterm.R
import io.neoterm.frontend.preference.NeoPreference
/**
* @author kiva
@ -14,6 +15,24 @@ class GeneralSettingsActivity : BasePreferenceActivity() {
supportActionBar?.title = getString(R.string.general_settings)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
addPreferencesFromResource(R.xml.setting_general)
findPreference(getString(R.string.key_general_shell)).setOnPreferenceChangeListener { _, value ->
val shellName = value.toString()
val newShell = NeoPreference.findLoginProgram(shellName)
if (newShell == null) {
requestInstallShell(shellName)
} else {
postChangeShell(shellName)
}
return@setOnPreferenceChangeListener true
}
}
private fun postChangeShell(shellName: String) {
NeoPreference.store(R.string.key_general_shell, shellName)
}
private fun requestInstallShell(shellName: String) {
}
override fun onBuildHeaders(target: MutableList<Header>?) {