show a number above the letters in the first row
This commit is contained in:
parent
e999e4900b
commit
3c4d2f0ee3
|
@ -212,6 +212,9 @@ class MyKeyboard {
|
|||
/** Label to display */
|
||||
var label: CharSequence = ""
|
||||
|
||||
/** First row of letters can also be used for inserting numbers by long pressing them, show those numbers */
|
||||
var topSmallNumber: String = ""
|
||||
|
||||
/** Icon to display instead of a label. Icon takes precedence over a label */
|
||||
var icon: Drawable? = null
|
||||
|
||||
|
@ -307,6 +310,7 @@ class MyKeyboard {
|
|||
|
||||
label = a.getText(R.styleable.MyKeyboard_Key_keyLabel) ?: ""
|
||||
text = a.getText(R.styleable.MyKeyboard_Key_keyOutputText)
|
||||
topSmallNumber = a.getString(R.styleable.MyKeyboard_Key_topSmallNumber) ?: ""
|
||||
|
||||
if (label.isNotEmpty()) {
|
||||
codes = arrayListOf(label[0].toInt())
|
||||
|
|
|
@ -17,6 +17,7 @@ import android.view.accessibility.AccessibilityEvent
|
|||
import android.view.accessibility.AccessibilityManager
|
||||
import android.widget.PopupWindow
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.commons.extensions.adjustAlpha
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.helpers.MyKeyboard
|
||||
import com.simplemobiletools.keyboard.helpers.SHIFT_OFF
|
||||
|
@ -190,6 +191,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
private val mSwipeThreshold: Int
|
||||
private val mDisambiguateSwipe: Boolean
|
||||
private var mPopupMaxMoveDistance = 0f
|
||||
private var topSmallNumberSize = 0f
|
||||
private var topSmallNumberMarginWidth = 0f
|
||||
private var topSmallNumberMarginHeight = 0f
|
||||
|
||||
// Variables for dealing with multiple pointers
|
||||
private var mOldPointerCount = 1
|
||||
|
@ -299,12 +303,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
mPaint.alpha = 255
|
||||
mPadding = Rect(0, 0, 0, 0)
|
||||
mMiniKeyboardCache = HashMap()
|
||||
mKeyBackground!!.getPadding(mPadding)
|
||||
mSwipeThreshold = (500 * resources.displayMetrics.density).toInt()
|
||||
mDisambiguateSwipe = false//resources.getBoolean(R.bool.config_swipeDisambiguation)
|
||||
mAccessibilityManager = (context.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager)
|
||||
mAudioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
mPopupMaxMoveDistance = context.resources.getDimension(R.dimen.popup_max_move_distance)
|
||||
mPopupMaxMoveDistance = resources.getDimension(R.dimen.popup_max_move_distance)
|
||||
topSmallNumberSize = resources.getDimension(R.dimen.small_text_size)
|
||||
topSmallNumberMarginWidth = resources.getDimension(R.dimen.top_small_number_margin_width)
|
||||
topSmallNumberMarginHeight = resources.getDimension(R.dimen.top_small_number_margin_height)
|
||||
resetMultiTap()
|
||||
}
|
||||
|
||||
|
@ -543,6 +549,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
val keys = mKeys
|
||||
val invalidKey = mInvalidatedKey
|
||||
paint.color = mKeyTextColor
|
||||
val smallLetterPaint = Paint()
|
||||
smallLetterPaint.set(paint)
|
||||
smallLetterPaint.apply {
|
||||
color = paint.color.adjustAlpha(0.8f)
|
||||
textSize = topSmallNumberSize
|
||||
typeface = Typeface.DEFAULT
|
||||
}
|
||||
|
||||
var drawSingleKey = false
|
||||
if (invalidKey != null && canvas.getClipBounds(clipRegion)) {
|
||||
// Is clipRegion completely contained within the invalidated key?
|
||||
|
@ -595,6 +609,11 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
label, ((key.width - padding.left - padding.right) / 2 + padding.left).toFloat(),
|
||||
(key.height - padding.top - padding.bottom) / 2 + (paint.textSize - paint.descent()) / 2 + padding.top, paint
|
||||
)
|
||||
|
||||
if (key.topSmallNumber.isNotEmpty()) {
|
||||
canvas.drawText(key.topSmallNumber, key.width - topSmallNumberMarginWidth, topSmallNumberMarginHeight, smallLetterPaint)
|
||||
}
|
||||
|
||||
// Turn off drop shadow
|
||||
paint.setShadowLayer(0f, 0f, 0f, 0)
|
||||
} else if (key.icon != null && mKeyboard != null) {
|
||||
|
|
|
@ -87,5 +87,7 @@
|
|||
<attr name="keyIcon" format="reference" />
|
||||
<!-- Mode of the keyboard. If the mode doesn't match the requested keyboard mode, the key will be skipped. -->
|
||||
<attr name="keyboardMode" />
|
||||
<!-- Top small number shown above letters of the first row. -->
|
||||
<attr name="topSmallNumber" format="string" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<resources>
|
||||
<dimen name="popup_max_move_distance">60dp</dimen>
|
||||
<dimen name="top_small_number_margin_width">12dp</dimen>
|
||||
<dimen name="top_small_number_margin_height">18dp</dimen>
|
||||
</resources>
|
||||
|
|
|
@ -11,53 +11,63 @@
|
|||
app:keyEdgeFlags="left"
|
||||
app:keyLabel="q"
|
||||
app:popupCharacters="1"
|
||||
app:popupKeyboard="@xml/keyboard_popup_template" />
|
||||
app:popupKeyboard="@xml/keyboard_popup_template"
|
||||
app:topSmallNumber="1" />
|
||||
<Key
|
||||
app:codes="119"
|
||||
app:keyLabel="w"
|
||||
app:popupCharacters="2"
|
||||
app:popupKeyboard="@xml/keyboard_popup_template" />
|
||||
app:popupKeyboard="@xml/keyboard_popup_template"
|
||||
app:topSmallNumber="2" />
|
||||
<Key
|
||||
app:codes="101"
|
||||
app:keyLabel="e"
|
||||
app:popupCharacters="3"
|
||||
app:popupKeyboard="@xml/keyboard_popup_template" />
|
||||
app:popupKeyboard="@xml/keyboard_popup_template"
|
||||
app:topSmallNumber="3" />
|
||||
<Key
|
||||
app:codes="114"
|
||||
app:keyLabel="r"
|
||||
app:popupCharacters="4"
|
||||
app:popupKeyboard="@xml/keyboard_popup_template" />
|
||||
app:popupKeyboard="@xml/keyboard_popup_template"
|
||||
app:topSmallNumber="4" />
|
||||
<Key
|
||||
app:codes="116"
|
||||
app:keyLabel="t"
|
||||
app:popupCharacters="5"
|
||||
app:popupKeyboard="@xml/keyboard_popup_template" />
|
||||
app:popupKeyboard="@xml/keyboard_popup_template"
|
||||
app:topSmallNumber="5" />
|
||||
<Key
|
||||
app:codes="121"
|
||||
app:keyLabel="y"
|
||||
app:popupCharacters="6"
|
||||
app:popupKeyboard="@xml/keyboard_popup_template" />
|
||||
app:popupKeyboard="@xml/keyboard_popup_template"
|
||||
app:topSmallNumber="6" />
|
||||
<Key
|
||||
app:codes="117"
|
||||
app:keyLabel="u"
|
||||
app:popupCharacters="7"
|
||||
app:popupKeyboard="@xml/keyboard_popup_template" />
|
||||
app:popupKeyboard="@xml/keyboard_popup_template"
|
||||
app:topSmallNumber="7" />
|
||||
<Key
|
||||
app:codes="105"
|
||||
app:keyLabel="i"
|
||||
app:popupCharacters="8"
|
||||
app:popupKeyboard="@xml/keyboard_popup_template" />
|
||||
app:popupKeyboard="@xml/keyboard_popup_template"
|
||||
app:topSmallNumber="8" />
|
||||
<Key
|
||||
app:codes="111"
|
||||
app:keyLabel="o"
|
||||
app:popupCharacters="9"
|
||||
app:popupKeyboard="@xml/keyboard_popup_template" />
|
||||
app:popupKeyboard="@xml/keyboard_popup_template"
|
||||
app:topSmallNumber="9" />
|
||||
<Key
|
||||
app:codes="112"
|
||||
app:keyEdgeFlags="right"
|
||||
app:keyLabel="p"
|
||||
app:popupCharacters="0"
|
||||
app:popupKeyboard="@xml/keyboard_popup_template" />
|
||||
app:popupKeyboard="@xml/keyboard_popup_template"
|
||||
app:topSmallNumber="0" />
|
||||
</Row>
|
||||
<Row>
|
||||
<Key
|
||||
|
|
Loading…
Reference in New Issue