Feature: Toggle visibility of extra keys
This commit is contained in:
parent
043733a353
commit
31d955eeac
@ -17,7 +17,6 @@ class TermDataHolder {
|
||||
var termUI: TermUiPresenter? = null
|
||||
var termView: TerminalView? = null
|
||||
var extraKeysView: ExtraKeysView? = null
|
||||
var showExtraKeysView: Boolean = true
|
||||
|
||||
fun cleanup() {
|
||||
onAutoCompleteListener?.onCleanUp()
|
||||
@ -30,8 +29,6 @@ class TermDataHolder {
|
||||
termView = null
|
||||
extraKeysView = null
|
||||
termSession = null
|
||||
|
||||
showExtraKeysView = true
|
||||
}
|
||||
|
||||
fun initializeSessionWith(session: TerminalSession, sessionCallback: TermSessionCallback?, viewClient: TermViewClient?) {
|
||||
@ -40,13 +37,11 @@ class TermDataHolder {
|
||||
this.viewClient = viewClient
|
||||
this.sessionCallback?.termData = this
|
||||
this.viewClient?.termData = this
|
||||
this.showExtraKeysView = true
|
||||
}
|
||||
|
||||
fun initializeViewWith(termUI: TermUiPresenter?, termView: TerminalView?, eks: ExtraKeysView?) {
|
||||
this.termUI = termUI
|
||||
this.termView = termView
|
||||
this.extraKeysView = eks
|
||||
this.showExtraKeysView = true
|
||||
}
|
||||
}
|
@ -212,12 +212,12 @@ class TermViewClient(val context: Context) : TerminalViewClient {
|
||||
fun updateExtraKeys(title: String?, force: Boolean = false) {
|
||||
val extraKeysView = termData?.extraKeysView
|
||||
|
||||
if (extraKeysView == null || title == null || title.isEmpty()
|
||||
|| !updateExtraKeysVisibility()) {
|
||||
if (extraKeysView == null || title == null || title.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
if (lastTitle != title || force) {
|
||||
if ((lastTitle != title || force)
|
||||
&& updateExtraKeysVisibility()) {
|
||||
removeExtraKeys()
|
||||
ComponentManager.getComponent<ExtraKeysComponent>().showShortcutKeys(title, extraKeysView)
|
||||
extraKeysView.updateButtons()
|
||||
@ -225,15 +225,15 @@ class TermViewClient(val context: Context) : TerminalViewClient {
|
||||
}
|
||||
}
|
||||
|
||||
fun updateExtraKeysVisibility() : Boolean {
|
||||
private fun updateExtraKeysVisibility() : Boolean {
|
||||
val extraKeysView = termData?.extraKeysView ?: return false
|
||||
|
||||
if (termData?.showExtraKeysView != true) {
|
||||
extraKeysView.visibility = View.GONE
|
||||
return false
|
||||
} else {
|
||||
return if (NeoPreference.loadBoolean(R.string.key_ui_eks_enabled, true)) {
|
||||
extraKeysView.visibility = View.VISIBLE
|
||||
return true
|
||||
true
|
||||
} else {
|
||||
extraKeysView.visibility = View.GONE
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,10 +145,6 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
|
||||
startActivity(Intent(this, PackageManagerActivity::class.java))
|
||||
true
|
||||
}
|
||||
R.id.menu_item_toggle_eks -> {
|
||||
forEachTab<TermTab> { it.setExtraKeyEnabled(!it.getExtraKeyEnabled()) }
|
||||
true
|
||||
}
|
||||
R.id.menu_item_new_session -> {
|
||||
addNewSession()
|
||||
true
|
||||
@ -488,7 +484,11 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
|
||||
private fun createTab(tabTitle: String?): Tab {
|
||||
val tab = TermTab(tabTitle ?: "NeoTerm")
|
||||
tab.isCloseable = true
|
||||
|
||||
// We must create a Bundle for each tab
|
||||
// tabs can use them to store status.
|
||||
tab.parameters = Bundle()
|
||||
|
||||
tab.setBackgroundColor(ContextCompat.getColor(this, R.color.tab_background_color))
|
||||
tab.setTitleTextColor(ContextCompat.getColor(this, R.color.tab_title_text_color))
|
||||
return tab
|
||||
|
@ -16,6 +16,10 @@ import org.greenrobot.eventbus.EventBus
|
||||
*/
|
||||
|
||||
class TermTab(title: CharSequence) : Tab(title), TermUiPresenter {
|
||||
companion object {
|
||||
val PARAMETER_SHOW_EKS = "show_eks"
|
||||
}
|
||||
|
||||
var termData = TermDataHolder()
|
||||
var toolbar: Toolbar? = null
|
||||
|
||||
@ -101,13 +105,4 @@ class TermTab(title: CharSequence) : Tab(title), TermUiPresenter {
|
||||
termData.termView?.updateSize()
|
||||
termData.termView?.onScreenUpdated()
|
||||
}
|
||||
|
||||
fun setExtraKeyEnabled(enabled: Boolean) {
|
||||
termData.showExtraKeysView = enabled
|
||||
termData.viewClient?.updateExtraKeysVisibility()
|
||||
}
|
||||
|
||||
fun getExtraKeyEnabled(): Boolean {
|
||||
return termData.showExtraKeysView
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,6 @@
|
||||
android:id="@+id/menu_item_new_system_session"
|
||||
android:title="@string/new_system_session"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_item_toggle_eks"
|
||||
android:title="@string/toggle_eks"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_item_package_settings"
|
||||
android:title="@string/package_settings"
|
||||
|
@ -32,6 +32,8 @@
|
||||
<string name="pref_ui_hide_toolbar_desc">键盘显示时隐藏标题栏</string>
|
||||
<string name="pref_ui_eks_weight_explicit">为快捷键盘强制设置权重</string>
|
||||
<string name="pref_ui_eks_weight_explicit_desc">如果快捷键盘显示不正确,请勾选本项</string>
|
||||
<string name="pref_ui_eks_enabled">显示拓展键</string>
|
||||
<string name="pref_ui_eks_enabled_desc">屏幕下方出现一行有方向键,esc 键之类的按键</string>
|
||||
<string name="pref_customization_color_scheme">配色方案</string>
|
||||
<string name="pref_customization_font">字体</string>
|
||||
<string name="settings">设置</string>
|
||||
|
@ -13,6 +13,7 @@
|
||||
<string name="key_ui_hide_toolbar" translatable="false">neoterm_ui_hide_toolbar</string>
|
||||
<string name="key_ui_next_tab_anim" translatable="false">neoterm_ui_next_tab_anim</string>
|
||||
<string name="key_ui_eks_weight_explicit" translatable="false">neoterm_ui_eks_weight_explicit</string>
|
||||
<string name="key_ui_eks_enabled" translatable="false">neoterm_ui_eks_enabled</string>
|
||||
|
||||
<string name="key_package_source" translatable="false">neoterm_package_source</string>
|
||||
|
||||
|
@ -79,6 +79,8 @@
|
||||
<string name="pref_ui_close_tab_anim_next_tab_desc">Switch to the next tab instead of the previous tab when closing tab</string>
|
||||
<string name="pref_ui_eks_weight_explicit">Use explicit weight for ExtraKeysView</string>
|
||||
<string name="pref_ui_eks_weight_explicit_desc">If ExtraKeysView shows incorrectly, please enable this</string>
|
||||
<string name="pref_ui_eks_enabled">Show extra keys</string>
|
||||
<string name="pref_ui_eks_enabled_desc">Some useful keys like arrow, esc, tab, etc.</string>
|
||||
<string name="pref_customization_font">Font</string>
|
||||
<string name="pref_customization_color_scheme">Color Scheme</string>
|
||||
<string name="pref_customization_eks">Extra Keys</string>
|
||||
|
@ -17,8 +17,15 @@
|
||||
android:summary="@string/pref_ui_close_tab_anim_next_tab_desc"
|
||||
android:title="@string/pref_ui_close_tab_anim_next_tab" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_ui_eks_enabled"
|
||||
android:title="@string/pref_ui_eks_enabled"
|
||||
android:summary="@string/pref_ui_eks_enabled_desc" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="@string/key_ui_eks_enabled"
|
||||
android:key="@string/key_ui_eks_weight_explicit"
|
||||
android:summary="@string/pref_ui_eks_weight_explicit_desc"
|
||||
android:title="@string/pref_ui_eks_weight_explicit" />
|
||||
|
Loading…
Reference in New Issue
Block a user