Preference: rename ambiguous method names

This commit is contained in:
zt515 2017-12-06 23:53:08 +08:00
parent 7bb71a5aba
commit 787cd79768
6 changed files with 18 additions and 16 deletions

View File

@ -1,7 +0,0 @@
package io.neoterm.component.profile
/**
* @author kiva
*/
abstract class Profile {
}

View File

@ -1,12 +1,13 @@
package io.neoterm.component.profile
import io.neoterm.frontend.component.NeoComponent
import io.neoterm.frontend.session.shell.ShellProfile
/**
* @author kiva
*/
class ProfileComponent : NeoComponent {
private val profileList = mutableListOf<Profile>()
private val profileList = mutableListOf<ShellProfile>()
override fun onServiceInit() {
}
@ -16,4 +17,6 @@ class ProfileComponent : NeoComponent {
override fun onServiceObtained() {
}
}

View File

@ -125,7 +125,7 @@ object NeoPreference {
return null
}
fun setLoginShell(loginProgramName: String?): Boolean {
fun setLoginShellName(loginProgramName: String?): Boolean {
if (loginProgramName == null) {
return false
}
@ -137,14 +137,18 @@ object NeoPreference {
return true
}
fun getLoginShell(): String {
val loginProgramName = loadString(R.string.key_general_shell, DefaultPreference.loginShell)
fun getLoginShellName(): String {
return loadString(R.string.key_general_shell, DefaultPreference.loginShell)
}
fun getLoginShellPath(): String {
val loginProgramName = getLoginShellName()
// Some programs like ssh needs it
val shell = File(NeoTermPath.NEOTERM_SHELL_PATH)
val loginProgramPath = findLoginProgram(loginProgramName) ?: {
setLoginShell("sh")
"${NeoTermPath.USR_PATH}/bin/sh"
setLoginShellName(DefaultPreference.loginShell)
"${NeoTermPath.USR_PATH}/bin/${DefaultPreference.loginShell}"
}()
if (!shell.exists()) {

View File

@ -4,6 +4,7 @@ import io.neoterm.component.color.ColorSchemeComponent
import io.neoterm.component.font.FontComponent
import io.neoterm.frontend.component.ComponentManager
import io.neoterm.frontend.preference.DefaultPreference
import io.neoterm.frontend.preference.NeoPreference
/**
* @author kiva
@ -27,5 +28,7 @@ class ShellProfile {
profileFont = fontComp.getCurrentFontName()
profileColorScheme = colorComp.getCurrentColorSchemeName()
loginShell = NeoPreference.getLoginShellPath()
}
}

View File

@ -154,7 +154,7 @@ open class ShellTermSession private constructor(shellPath: String, cwd: String,
if (systemShell)
"/system/bin/sh"
else
NeoPreference.getLoginShell()
NeoPreference.getLoginShellPath()
val args = this.args ?: mutableListOf(shell)
val env = transformEnvironment(this.env) ?: buildEnvironment(cwd, systemShell)

View File

@ -4,7 +4,6 @@ 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.DefaultPreference
import io.neoterm.frontend.preference.NeoPreference
import io.neoterm.utils.PackageUtils
@ -34,7 +33,7 @@ class GeneralSettingsActivity : BasePreferenceActivity() {
}
private fun postChangeShell(shellName: String) {
NeoPreference.setLoginShell(shellName)
NeoPreference.setLoginShellName(shellName)
}
private fun requestInstallShell(shellName: String, currentShell: String) {