Fix: #7
This commit is contained in:
parent
7fc5373e22
commit
304b00ceda
@ -67,7 +67,7 @@ object NeoPreference {
|
||||
preference!!.edit().putStringSet(key, value).apply()
|
||||
}
|
||||
|
||||
fun loadStrings(key: String) : Set<String> {
|
||||
fun loadStrings(key: String): Set<String> {
|
||||
return preference!!.getStringSet(key, setOf())
|
||||
}
|
||||
|
||||
@ -142,22 +142,28 @@ object NeoPreference {
|
||||
|
||||
// Some programs like ssh needs it
|
||||
val shell = File(NeoTermPath.NEOTERM_SHELL_PATH)
|
||||
val loginProgramPath = findLoginProgram(loginProgramName) ?: {
|
||||
setLoginShell("sh")
|
||||
"${NeoTermPath.USR_PATH}/bin/sh"
|
||||
}()
|
||||
|
||||
if (!shell.exists()) {
|
||||
symlinkLoginShell(loginProgramName)
|
||||
symlinkLoginShell(loginProgramPath)
|
||||
}
|
||||
|
||||
return "${NeoTermPath.USR_PATH}/bin/$loginProgramName"
|
||||
return loginProgramPath
|
||||
}
|
||||
|
||||
fun validateFontSize(fontSize: Int) : Int {
|
||||
fun validateFontSize(fontSize: Int): Int {
|
||||
return Math.max(MIN_FONT_SIZE, Math.min(fontSize, MAX_FONT_SIZE))
|
||||
}
|
||||
|
||||
private fun symlinkLoginShell(loginProgramPath: String) {
|
||||
File(NeoTermPath.CUSTOM_PATH).mkdirs()
|
||||
try {
|
||||
if (File(NeoTermPath.NEOTERM_SHELL_PATH).exists()) {
|
||||
Os.remove(NeoTermPath.NEOTERM_SHELL_PATH)
|
||||
val shellSymlink = File(NeoTermPath.NEOTERM_SHELL_PATH)
|
||||
if (shellSymlink.exists()) {
|
||||
shellSymlink.delete()
|
||||
}
|
||||
Os.symlink(loginProgramPath, NeoTermPath.NEOTERM_SHELL_PATH)
|
||||
Os.chmod(NeoTermPath.NEOTERM_SHELL_PATH, 448 /*Decimal of 0700 */)
|
||||
|
@ -4,6 +4,7 @@ import android.app.AlertDialog
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import io.neoterm.R
|
||||
import io.neoterm.frontend.logging.NLog
|
||||
import io.neoterm.frontend.preference.NeoPreference
|
||||
import io.neoterm.utils.PackageUtils
|
||||
|
||||
@ -36,7 +37,6 @@ class GeneralSettingsActivity : BasePreferenceActivity() {
|
||||
}
|
||||
|
||||
private fun requestInstallShell(shellName: String, currentShell: String) {
|
||||
var selectedShell = currentShell
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(getString(R.string.shell_not_found, shellName))
|
||||
.setMessage(R.string.shell_not_found_message)
|
||||
@ -44,7 +44,7 @@ class GeneralSettingsActivity : BasePreferenceActivity() {
|
||||
PackageUtils.executeApt(this, "install", arrayOf("-y", shellName), { exitStatus, dialog ->
|
||||
if (exitStatus == 0) {
|
||||
dialog.dismiss()
|
||||
selectedShell = shellName
|
||||
postChangeShell(shellName)
|
||||
} else {
|
||||
dialog.setTitle(getString(R.string.error))
|
||||
}
|
||||
@ -52,7 +52,7 @@ class GeneralSettingsActivity : BasePreferenceActivity() {
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.setOnDismissListener {
|
||||
postChangeShell(selectedShell)
|
||||
postChangeShell(currentShell)
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user