From 787cd79768dee536fb48bda2233e1dd1ad28d72f Mon Sep 17 00:00:00 2001 From: zt515 Date: Wed, 6 Dec 2017 23:53:08 +0800 Subject: [PATCH] Preference: rename ambiguous method names --- .../java/io/neoterm/component/profile/Profile.kt | 7 ------- .../neoterm/component/profile/ProfileComponent.kt | 5 ++++- .../neoterm/frontend/preference/NeoPreference.kt | 14 +++++++++----- .../neoterm/frontend/session/shell/ShellProfile.kt | 3 +++ .../frontend/session/shell/ShellTermSession.kt | 2 +- .../neoterm/ui/settings/GeneralSettingsActivity.kt | 3 +-- 6 files changed, 18 insertions(+), 16 deletions(-) delete mode 100644 app/src/main/java/io/neoterm/component/profile/Profile.kt diff --git a/app/src/main/java/io/neoterm/component/profile/Profile.kt b/app/src/main/java/io/neoterm/component/profile/Profile.kt deleted file mode 100644 index 6a1c0e2..0000000 --- a/app/src/main/java/io/neoterm/component/profile/Profile.kt +++ /dev/null @@ -1,7 +0,0 @@ -package io.neoterm.component.profile - -/** - * @author kiva - */ -abstract class Profile { -} \ No newline at end of file diff --git a/app/src/main/java/io/neoterm/component/profile/ProfileComponent.kt b/app/src/main/java/io/neoterm/component/profile/ProfileComponent.kt index 9db2f3e..5c4582c 100644 --- a/app/src/main/java/io/neoterm/component/profile/ProfileComponent.kt +++ b/app/src/main/java/io/neoterm/component/profile/ProfileComponent.kt @@ -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() + private val profileList = mutableListOf() override fun onServiceInit() { } @@ -16,4 +17,6 @@ class ProfileComponent : NeoComponent { override fun onServiceObtained() { } + + } \ No newline at end of file diff --git a/app/src/main/java/io/neoterm/frontend/preference/NeoPreference.kt b/app/src/main/java/io/neoterm/frontend/preference/NeoPreference.kt index fe1a7f8..bce1caf 100644 --- a/app/src/main/java/io/neoterm/frontend/preference/NeoPreference.kt +++ b/app/src/main/java/io/neoterm/frontend/preference/NeoPreference.kt @@ -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()) { diff --git a/app/src/main/java/io/neoterm/frontend/session/shell/ShellProfile.kt b/app/src/main/java/io/neoterm/frontend/session/shell/ShellProfile.kt index 708e0ce..54c2ba6 100644 --- a/app/src/main/java/io/neoterm/frontend/session/shell/ShellProfile.kt +++ b/app/src/main/java/io/neoterm/frontend/session/shell/ShellProfile.kt @@ -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() } } \ No newline at end of file diff --git a/app/src/main/java/io/neoterm/frontend/session/shell/ShellTermSession.kt b/app/src/main/java/io/neoterm/frontend/session/shell/ShellTermSession.kt index a932ebd..bc593f4 100644 --- a/app/src/main/java/io/neoterm/frontend/session/shell/ShellTermSession.kt +++ b/app/src/main/java/io/neoterm/frontend/session/shell/ShellTermSession.kt @@ -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) diff --git a/app/src/main/java/io/neoterm/ui/settings/GeneralSettingsActivity.kt b/app/src/main/java/io/neoterm/ui/settings/GeneralSettingsActivity.kt index e5b6319..7dec48a 100644 --- a/app/src/main/java/io/neoterm/ui/settings/GeneralSettingsActivity.kt +++ b/app/src/main/java/io/neoterm/ui/settings/GeneralSettingsActivity.kt @@ -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) {