From 37a8f4308ef7ea22cb788883a0c1744f0d01a79e Mon Sep 17 00:00:00 2001 From: zt515 Date: Thu, 27 Jul 2017 23:54:35 +0800 Subject: [PATCH] Improve: Repeatable ExtraKeysView --- README.md | 4 ++ app/build.gradle | 4 +- app/src/main/AndroidManifest.xml | 2 +- .../io/neoterm/customize/eks/EksConfig.kt | 4 +- .../neoterm/customize/eks/EksConfigParser.kt | 2 +- .../CustomizeActivity.kt} | 10 ++- .../io/neoterm/ui/term/NeoTermActivity.kt | 2 +- .../java/io/neoterm/view/eks/ControlButton.kt | 17 ----- .../java/io/neoterm/view/eks/ExtraKeysView.kt | 65 ++++++++----------- .../neoterm/view/eks/ScrollExtraKeysView.kt | 43 ++++++------ .../java/io/neoterm/view/eks/TextButton.kt | 23 ------- .../neoterm/view/eks/button/ControlButton.kt | 11 ++++ .../IExtraButton.kt} | 10 ++- .../view/eks/button/RepeatableButton.kt | 58 +++++++++++++++++ .../eks/{ => button}/StatedControlButton.kt | 24 +++++-- .../io/neoterm/view/eks/button/TextButton.kt | 30 +++++++++ .../io/neoterm/view/eks/impl/ArrowButton.kt | 9 +++ app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/settings_main.xml | 2 +- 21 files changed, 205 insertions(+), 118 deletions(-) create mode 100644 README.md rename app/src/main/java/io/neoterm/ui/{customization/CustomizationActivity.kt => customize/CustomizeActivity.kt} (96%) delete mode 100644 app/src/main/java/io/neoterm/view/eks/ControlButton.kt delete mode 100644 app/src/main/java/io/neoterm/view/eks/TextButton.kt create mode 100644 app/src/main/java/io/neoterm/view/eks/button/ControlButton.kt rename app/src/main/java/io/neoterm/view/eks/{ExtraButton.kt => button/IExtraButton.kt} (88%) create mode 100644 app/src/main/java/io/neoterm/view/eks/button/RepeatableButton.kt rename app/src/main/java/io/neoterm/view/eks/{ => button}/StatedControlButton.kt (53%) create mode 100644 app/src/main/java/io/neoterm/view/eks/button/TextButton.kt create mode 100644 app/src/main/java/io/neoterm/view/eks/impl/ArrowButton.kt diff --git a/README.md b/README.md new file mode 100644 index 0000000..d21a8c5 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +NeoTerm +======= +A modern-designed android terminal emulator for the 21st century. + diff --git a/app/build.gradle b/app/build.gradle index bff4831..68d14a4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,8 +17,8 @@ android { applicationId "io.neoterm" minSdkVersion 21 targetSdkVersion 25 - versionCode 16 - versionName "1.2.0-rc5" + versionCode 17 + versionName "1.2.0-rc6" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" resConfigs "zh-rCN", "zh-rTW" externalNativeBuild { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c3dd3f4..0828088 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,7 +86,7 @@ android:label="@string/package_settings" android:theme="@style/AppTheme.NoActionBar.Dark" /> = mutableListOf() - val shortcutKeys: MutableList = mutableListOf() + val shortcutKeys: MutableList = mutableListOf() var withDefaultKeys: Boolean = true } \ No newline at end of file diff --git a/app/src/main/java/io/neoterm/customize/eks/EksConfigParser.kt b/app/src/main/java/io/neoterm/customize/eks/EksConfigParser.kt index 0d02a58..42e4e2b 100644 --- a/app/src/main/java/io/neoterm/customize/eks/EksConfigParser.kt +++ b/app/src/main/java/io/neoterm/customize/eks/EksConfigParser.kt @@ -1,6 +1,6 @@ package io.neoterm.customize.eks -import io.neoterm.view.eks.TextButton +import io.neoterm.view.eks.button.TextButton import java.io.* /** diff --git a/app/src/main/java/io/neoterm/ui/customization/CustomizationActivity.kt b/app/src/main/java/io/neoterm/ui/customize/CustomizeActivity.kt similarity index 96% rename from app/src/main/java/io/neoterm/ui/customization/CustomizationActivity.kt rename to app/src/main/java/io/neoterm/ui/customize/CustomizeActivity.kt index c49f2b6..ac9b9cc 100644 --- a/app/src/main/java/io/neoterm/ui/customization/CustomizationActivity.kt +++ b/app/src/main/java/io/neoterm/ui/customize/CustomizeActivity.kt @@ -1,16 +1,14 @@ -package io.neoterm.ui.customization +package io.neoterm.ui.customize import android.app.Activity +import android.app.AlertDialog import android.content.Intent import android.os.Bundle import android.support.v7.app.AppCompatActivity import android.support.v7.widget.Toolbar import android.view.MenuItem import android.view.View -import android.widget.AdapterView -import android.widget.ArrayAdapter -import android.widget.Spinner -import android.widget.Toast +import android.widget.* import io.neoterm.R import io.neoterm.backend.TerminalSession import io.neoterm.customize.color.ColorSchemeManager @@ -30,7 +28,7 @@ import java.io.FileInputStream /** * @author kiva */ -class CustomizationActivity : AppCompatActivity() { +class CustomizeActivity : AppCompatActivity() { lateinit var terminalView: TerminalView lateinit var viewClient: BasicViewClient lateinit var sessionCallback: BasicSessionCallback diff --git a/app/src/main/java/io/neoterm/ui/term/NeoTermActivity.kt b/app/src/main/java/io/neoterm/ui/term/NeoTermActivity.kt index 1ea234d..9fb25fc 100644 --- a/app/src/main/java/io/neoterm/ui/term/NeoTermActivity.kt +++ b/app/src/main/java/io/neoterm/ui/term/NeoTermActivity.kt @@ -43,7 +43,7 @@ import io.neoterm.ui.term.event.TitleChangedEvent import io.neoterm.ui.term.event.ToggleFullScreenEvent import io.neoterm.ui.term.event.ToggleImeEvent import io.neoterm.utils.FullScreenHelper -import io.neoterm.view.eks.StatedControlButton +import io.neoterm.view.eks.button.StatedControlButton import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.Subscribe import org.greenrobot.eventbus.ThreadMode diff --git a/app/src/main/java/io/neoterm/view/eks/ControlButton.kt b/app/src/main/java/io/neoterm/view/eks/ControlButton.kt deleted file mode 100644 index 5da221f..0000000 --- a/app/src/main/java/io/neoterm/view/eks/ControlButton.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.neoterm.view.eks - -import android.view.View - -/** - * @author kiva - */ - -open class ControlButton(text: String) : ExtraButton() { - init { - buttonText = text - } - - override fun onClick(view: View) { - ExtraButton.Companion.sendKey(view, buttonText!!) - } -} diff --git a/app/src/main/java/io/neoterm/view/eks/ExtraKeysView.kt b/app/src/main/java/io/neoterm/view/eks/ExtraKeysView.kt index 9412cfd..2d74d67 100755 --- a/app/src/main/java/io/neoterm/view/eks/ExtraKeysView.kt +++ b/app/src/main/java/io/neoterm/view/eks/ExtraKeysView.kt @@ -11,22 +11,27 @@ import android.widget.ToggleButton import io.neoterm.R import io.neoterm.customize.eks.EksConfigParser import io.neoterm.ui.term.event.ToggleImeEvent +import io.neoterm.view.eks.button.ControlButton +import io.neoterm.view.eks.button.IExtraButton +import io.neoterm.view.eks.button.RepeatableButton +import io.neoterm.view.eks.button.StatedControlButton +import io.neoterm.view.eks.impl.ArrowButton import org.greenrobot.eventbus.EventBus class ExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) { companion object { - private val ESC = ControlButton(ExtraButton.KEY_ESC) - private val TAB = ControlButton(ExtraButton.KEY_TAB) - private val PAGE_UP = ControlButton(ExtraButton.KEY_PAGE_UP) - private val PAGE_DOWN = ControlButton(ExtraButton.KEY_PAGE_DOWN) - private val HOME = ControlButton(ExtraButton.KEY_HOME) - private val END = ControlButton(ExtraButton.KEY_END) - private val ARROW_UP = ControlButton(ExtraButton.KEY_ARROW_UP) - private val ARROW_DOWN = ControlButton(ExtraButton.KEY_ARROW_DOWN) - private val ARROW_LEFT = ControlButton(ExtraButton.KEY_ARROW_LEFT) - private val ARROW_RIGHT = ControlButton(ExtraButton.KEY_ARROW_RIGHT) - private val TOGGLE_IME = object : ControlButton(ExtraButton.KEY_TOGGLE_IME) { + private val ESC = ControlButton(IExtraButton.KEY_ESC) + private val TAB = ControlButton(IExtraButton.KEY_TAB) + private val PAGE_UP = ControlButton(IExtraButton.KEY_PAGE_UP) + private val PAGE_DOWN = ControlButton(IExtraButton.KEY_PAGE_DOWN) + private val HOME = ControlButton(IExtraButton.KEY_HOME) + private val END = ControlButton(IExtraButton.KEY_END) + private val ARROW_UP = ArrowButton(IExtraButton.KEY_ARROW_UP) + private val ARROW_DOWN = ArrowButton(IExtraButton.KEY_ARROW_DOWN) + private val ARROW_LEFT = ArrowButton(IExtraButton.KEY_ARROW_LEFT) + private val ARROW_RIGHT = ArrowButton(IExtraButton.KEY_ARROW_RIGHT) + private val TOGGLE_IME = object : ControlButton(IExtraButton.KEY_TOGGLE_IME) { override fun onClick(view: View) { EventBus.getDefault().post(ToggleImeEvent()) } @@ -37,19 +42,19 @@ class ExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout(contex private val EXPANDED_ALPHA = 0.5f } - private val builtinKeys = mutableListOf() - private val userKeys = mutableListOf() + private val builtinKeys = mutableListOf() + private val userKeys = mutableListOf() private val buttonBars: MutableList = mutableListOf() private var typeface: Typeface? = null // Initialize StatedControlButton here // For avoid memory and context leak. - private val CTRL = StatedControlButton(ExtraButton.KEY_CTRL) - private val ALT = StatedControlButton(ExtraButton.KEY_ALT) + private val CTRL = StatedControlButton(IExtraButton.KEY_CTRL) + private val ALT = StatedControlButton(IExtraButton.KEY_ALT) private var buttonPanelExpanded = false - private val EXPAND_BUTTONS = object : ControlButton(ExtraButton.KEY_SHOW_ALL_BUTTONS) { + private val EXPAND_BUTTONS = object : ControlButton(IExtraButton.KEY_SHOW_ALL_BUTTONS) { override fun onClick(view: View) { expandButtonPanel() } @@ -78,7 +83,7 @@ class ExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout(contex } fun setTextColor(textColor: Int) { - ExtraButton.NORMAL_TEXT_COLOR = textColor + IExtraButton.NORMAL_TEXT_COLOR = textColor updateButtons() } @@ -95,11 +100,11 @@ class ExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout(contex return ALT.readState() } - fun addUserKey(button: ExtraButton) { + fun addUserKey(button: IExtraButton) { addKeyButton(userKeys, button) } - fun addBuiltinKey(button: ExtraButton) { + fun addBuiltinKey(button: IExtraButton) { addKeyButton(builtinKeys, button) } @@ -173,28 +178,14 @@ class ExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout(contex return buttonBars[position] } - private fun addKeyButton(buttons: MutableList?, button: ExtraButton) { + private fun addKeyButton(buttons: MutableList?, button: IExtraButton) { if (buttons != null && !buttons.contains(button)) { buttons.add(button) } } - private fun addKeyButton(contentView: LinearLayout, extraButton: ExtraButton) { - val outerButton: Button - if (extraButton is StatedControlButton) { - val btn = extraButton - val toggleButton = ToggleButton(context, null, android.R.attr.buttonBarButtonStyle) - btn.toggleButton = toggleButton - outerButton = toggleButton - - outerButton.isClickable = true - if (btn.initState) { - btn.toggleButton!!.isChecked = true - btn.toggleButton!!.setTextColor(ExtraButton.SELECTED_TEXT_COLOR) - } - } else { - outerButton = Button(context, null, android.R.attr.buttonBarButtonStyle) - } + private fun addKeyButton(contentView: LinearLayout, extraButton: IExtraButton) { + val outerButton = extraButton.makeButton(context, null, android.R.attr.buttonBarButtonStyle) val param = GridLayout.LayoutParams() param.setGravity(Gravity.CENTER) @@ -208,7 +199,7 @@ class ExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout(contex outerButton.layoutParams = param outerButton.typeface = typeface outerButton.text = extraButton.buttonText - outerButton.setTextColor(ExtraButton.NORMAL_TEXT_COLOR) + outerButton.setTextColor(IExtraButton.NORMAL_TEXT_COLOR) outerButton.setAllCaps(false) outerButton.setOnClickListener { diff --git a/app/src/main/java/io/neoterm/view/eks/ScrollExtraKeysView.kt b/app/src/main/java/io/neoterm/view/eks/ScrollExtraKeysView.kt index e773b97..fcebac0 100755 --- a/app/src/main/java/io/neoterm/view/eks/ScrollExtraKeysView.kt +++ b/app/src/main/java/io/neoterm/view/eks/ScrollExtraKeysView.kt @@ -18,6 +18,9 @@ import java.util.ArrayList import io.neoterm.customize.eks.EksConfigParser import io.neoterm.preference.NeoTermPath import io.neoterm.utils.FileUtils +import io.neoterm.view.eks.button.ControlButton +import io.neoterm.view.eks.button.IExtraButton +import io.neoterm.view.eks.button.StatedControlButton /** * A view showing extra keys (such as Escape, Ctrl, Alt) not normally available on an Android soft @@ -25,8 +28,8 @@ import io.neoterm.utils.FileUtils */ class ScrollExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) { - private var builtinExtraKeys: MutableList? = null - private var userDefinedExtraKeys: MutableList? = null + private var builtinExtraKeys: MutableList? = null + private var userDefinedExtraKeys: MutableList? = null private val lineOne: LinearLayout private val lineTwo: LinearLayout @@ -68,11 +71,11 @@ class ScrollExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout( return ALT.readState() } - fun addUserKey(button: ExtraButton) { + fun addUserKey(button: IExtraButton) { addKeyButton(userDefinedExtraKeys, button) } - fun addBuiltinKey(button: ExtraButton) { + fun addBuiltinKey(button: IExtraButton) { addKeyButton(builtinExtraKeys, button) } @@ -81,7 +84,7 @@ class ScrollExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout( } fun loadUserKeys() { - userDefinedExtraKeys = ArrayList(8) + userDefinedExtraKeys = ArrayList(8) val defaultFile = File(NeoTermPath.EKS_DEFAULT_FILE) if (!defaultFile.exists()) { generateDefaultFile(defaultFile) @@ -99,7 +102,7 @@ class ScrollExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout( } fun loadBuiltinKeys() { - builtinExtraKeys = ArrayList(7) + builtinExtraKeys = ArrayList(7) builtinExtraKeys!!.clear() builtinExtraKeys!!.add(ESC) builtinExtraKeys!!.add(CTRL) @@ -136,13 +139,13 @@ class ScrollExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout( updateButtons() } - private fun addKeyButton(buttons: MutableList?, button: ExtraButton) { + private fun addKeyButton(buttons: MutableList?, button: IExtraButton) { if (buttons != null && !buttons.contains(button)) { buttons.add(button) } } - private fun addKeyButton(contentView: LinearLayout, extraButton: ExtraButton) { + private fun addKeyButton(contentView: LinearLayout, extraButton: IExtraButton) { val button: Button if (extraButton is StatedControlButton) { val btn = extraButton @@ -174,19 +177,19 @@ class ScrollExtraKeysView(context: Context, attrs: AttributeSet) : LinearLayout( companion object { @SuppressLint("StaticFieldLeak") - val CTRL = StatedControlButton(ExtraButton.KEY_CTRL) + val CTRL = StatedControlButton(IExtraButton.KEY_CTRL) @SuppressLint("StaticFieldLeak") - val ALT = StatedControlButton(ExtraButton.KEY_ALT) - val ESC = ControlButton(ExtraButton.KEY_ESC) - val TAB = ControlButton(ExtraButton.KEY_TAB) - val PAGE_UP = ControlButton(ExtraButton.KEY_PAGE_UP) - val PAGE_DOWN = ControlButton(ExtraButton.KEY_PAGE_DOWN) - val HOME = ControlButton(ExtraButton.KEY_HOME) - val END = ControlButton(ExtraButton.KEY_END) - val ARROW_UP = ControlButton(ExtraButton.KEY_ARROW_UP) - val ARROW_DOWN = ControlButton(ExtraButton.KEY_ARROW_DOWN) - val ARROW_LEFT = ControlButton(ExtraButton.KEY_ARROW_LEFT) - val ARROW_RIGHT = ControlButton(ExtraButton.KEY_ARROW_RIGHT) + val ALT = StatedControlButton(IExtraButton.KEY_ALT) + val ESC = ControlButton(IExtraButton.KEY_ESC) + val TAB = ControlButton(IExtraButton.KEY_TAB) + val PAGE_UP = ControlButton(IExtraButton.KEY_PAGE_UP) + val PAGE_DOWN = ControlButton(IExtraButton.KEY_PAGE_DOWN) + val HOME = ControlButton(IExtraButton.KEY_HOME) + val END = ControlButton(IExtraButton.KEY_END) + val ARROW_UP = ControlButton(IExtraButton.KEY_ARROW_UP) + val ARROW_DOWN = ControlButton(IExtraButton.KEY_ARROW_DOWN) + val ARROW_LEFT = ControlButton(IExtraButton.KEY_ARROW_LEFT) + val ARROW_RIGHT = ControlButton(IExtraButton.KEY_ARROW_RIGHT) val DEFAULT_FILE_CONTENT = "version " + EksConfigParser.PARSER_VERSION + "\n" + "program default\n" + diff --git a/app/src/main/java/io/neoterm/view/eks/TextButton.kt b/app/src/main/java/io/neoterm/view/eks/TextButton.kt deleted file mode 100644 index d4a024e..0000000 --- a/app/src/main/java/io/neoterm/view/eks/TextButton.kt +++ /dev/null @@ -1,23 +0,0 @@ -package io.neoterm.view.eks - -import android.view.View - -/** - * @author kiva - */ - -open class TextButton @JvmOverloads constructor(text: String, withEnter: Boolean = false) : ExtraButton() { - private var withEnter = false - - init { - this.buttonText = text - this.withEnter = withEnter - } - - override fun onClick(view: View) { - ExtraButton.sendKey(view, buttonText!!) - if (withEnter) { - ExtraButton.sendKey(view, "\n") - } - } -} diff --git a/app/src/main/java/io/neoterm/view/eks/button/ControlButton.kt b/app/src/main/java/io/neoterm/view/eks/button/ControlButton.kt new file mode 100644 index 0000000..7282e4f --- /dev/null +++ b/app/src/main/java/io/neoterm/view/eks/button/ControlButton.kt @@ -0,0 +1,11 @@ +package io.neoterm.view.eks.button + +/** + * @author kiva + */ + +open class ControlButton(text: String) : TextButton(text, false) { + init { + buttonText = text + } +} diff --git a/app/src/main/java/io/neoterm/view/eks/ExtraButton.kt b/app/src/main/java/io/neoterm/view/eks/button/IExtraButton.kt similarity index 88% rename from app/src/main/java/io/neoterm/view/eks/ExtraButton.kt rename to app/src/main/java/io/neoterm/view/eks/button/IExtraButton.kt index 7923ea6..2d47400 100644 --- a/app/src/main/java/io/neoterm/view/eks/ExtraButton.kt +++ b/app/src/main/java/io/neoterm/view/eks/button/IExtraButton.kt @@ -1,22 +1,26 @@ -package io.neoterm.view.eks +package io.neoterm.view.eks.button +import android.content.Context +import android.util.AttributeSet import android.view.KeyEvent import android.view.View +import android.widget.Button import io.neoterm.R -import io.neoterm.backend.TerminalSession import io.neoterm.view.TerminalView /** * @author kiva */ -abstract class ExtraButton : View.OnClickListener { +abstract class IExtraButton : View.OnClickListener { var buttonText: String? = null abstract override fun onClick(view: View) + abstract fun makeButton(context: Context?, attrs: AttributeSet?, defStyleAttr: Int): Button + companion object { val KEY_ESC = "Esc" val KEY_TAB = "Tab" diff --git a/app/src/main/java/io/neoterm/view/eks/button/RepeatableButton.kt b/app/src/main/java/io/neoterm/view/eks/button/RepeatableButton.kt new file mode 100644 index 0000000..229177a --- /dev/null +++ b/app/src/main/java/io/neoterm/view/eks/button/RepeatableButton.kt @@ -0,0 +1,58 @@ +package io.neoterm.view.eks.button + +import android.content.Context +import android.os.Handler +import android.os.Looper +import android.util.AttributeSet +import android.view.MotionEvent +import android.widget.Button + + +/** + * @author kiva + */ +open class RepeatableButton(buttonText: String) : ControlButton(buttonText) { + + override fun makeButton(context: Context?, attrs: AttributeSet?, defStyleAttr: Int): Button { + return RepeatableButtonWidget(context, attrs, defStyleAttr) + } + + private class RepeatableButtonWidget(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) + : Button(context, attrs, defStyleAttr) { + + /** + * Milliseconds how long we trigger an action + * when long pressing + */ + private val LONG_CLICK_ACTION_INTERVAL = 100L + + private var isMotionEventUp = true + + var mHandler: Handler = object : Handler(Looper.getMainLooper()) { + override fun handleMessage(msg: android.os.Message) { + if (!isMotionEventUp && isEnabled) { + performClick() + this.sendEmptyMessageDelayed(0, LONG_CLICK_ACTION_INTERVAL) + } + } + } + + init { + this.setOnLongClickListener { + isMotionEventUp = false + mHandler.sendEmptyMessage(0) + false + } + this.setOnTouchListener { v, event -> + if (event.action == MotionEvent.ACTION_UP) { + isMotionEventUp = true + } + false + } + } + + override fun performClick(): Boolean { + return super.performClick() + } + } +} diff --git a/app/src/main/java/io/neoterm/view/eks/StatedControlButton.kt b/app/src/main/java/io/neoterm/view/eks/button/StatedControlButton.kt similarity index 53% rename from app/src/main/java/io/neoterm/view/eks/StatedControlButton.kt rename to app/src/main/java/io/neoterm/view/eks/button/StatedControlButton.kt index dba83a7..3bc8c40 100644 --- a/app/src/main/java/io/neoterm/view/eks/StatedControlButton.kt +++ b/app/src/main/java/io/neoterm/view/eks/button/StatedControlButton.kt @@ -1,6 +1,9 @@ -package io.neoterm.view.eks +package io.neoterm.view.eks.button +import android.content.Context +import android.util.AttributeSet import android.view.View +import android.widget.Button import android.widget.ToggleButton /** @@ -14,13 +17,26 @@ open class StatedControlButton @JvmOverloads constructor(text: String, var initS setStatus(toggleButton?.isChecked) } + override fun makeButton(context: Context?, attrs: AttributeSet?, defStyleAttr: Int): Button { + val outerButton = ToggleButton(context, null, android.R.attr.buttonBarButtonStyle) + + outerButton.isClickable = true + if (initState) { + outerButton.isChecked = true + outerButton.setTextColor(IExtraButton.SELECTED_TEXT_COLOR) + } + + this.toggleButton = outerButton + return outerButton + } + fun setStatus(status: Boolean?) { val button = toggleButton if (button != null && status != null) { button.isChecked = status button.setTextColor( - if (status) ExtraButton.SELECTED_TEXT_COLOR - else ExtraButton.NORMAL_TEXT_COLOR + if (status) SELECTED_TEXT_COLOR + else NORMAL_TEXT_COLOR ) } } @@ -32,7 +48,7 @@ open class StatedControlButton @JvmOverloads constructor(text: String, var initS val result = button.isChecked if (result) { button.isChecked = false - button.setTextColor(ExtraButton.NORMAL_TEXT_COLOR) + button.setTextColor(NORMAL_TEXT_COLOR) } return result } diff --git a/app/src/main/java/io/neoterm/view/eks/button/TextButton.kt b/app/src/main/java/io/neoterm/view/eks/button/TextButton.kt new file mode 100644 index 0000000..5a81dff --- /dev/null +++ b/app/src/main/java/io/neoterm/view/eks/button/TextButton.kt @@ -0,0 +1,30 @@ +package io.neoterm.view.eks.button + +import android.content.Context +import android.util.AttributeSet +import android.view.View +import android.widget.Button + +/** + * @author kiva + */ + +open class TextButton @JvmOverloads constructor(text: String, withEnter: Boolean = false) : IExtraButton() { + private var withEnter = false + + init { + this.buttonText = text + this.withEnter = withEnter + } + + override fun onClick(view: View) { + sendKey(view, buttonText!!) + if (withEnter) { + sendKey(view, "\n") + } + } + + override fun makeButton(context: Context?, attrs: AttributeSet?, defStyleAttr: Int): Button { + return Button(context, attrs, defStyleAttr) + } +} diff --git a/app/src/main/java/io/neoterm/view/eks/impl/ArrowButton.kt b/app/src/main/java/io/neoterm/view/eks/impl/ArrowButton.kt new file mode 100644 index 0000000..89d25a3 --- /dev/null +++ b/app/src/main/java/io/neoterm/view/eks/impl/ArrowButton.kt @@ -0,0 +1,9 @@ +package io.neoterm.view.eks.impl + +import io.neoterm.view.eks.button.RepeatableButton + +/** + * @author kiva + */ +class ArrowButton(arrowText: String) : RepeatableButton(arrowText) { +} diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index ff2f75f..70fcb56 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -93,4 +93,5 @@ 处理的文件 可用的用户脚本 从操作列表中移除文件? + 移除? \ No newline at end of file diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 75605d5..733522d 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -93,4 +93,5 @@ 處理的檔案 可用的使用者腳本 從操作列表中中移除檔案? + 移除? \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4a30173..b311cc7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -88,6 +88,7 @@ Files to Handle Available User Scripts Remove file from list? + Remove this? sh diff --git a/app/src/main/res/xml/settings_main.xml b/app/src/main/res/xml/settings_main.xml index f55cd85..b0cdabb 100644 --- a/app/src/main/res/xml/settings_main.xml +++ b/app/src/main/res/xml/settings_main.xml @@ -24,7 +24,7 @@ android:summary="@string/customization_settings_desc" android:title="@string/customization_settings">