mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-03-02 10:37:47 +01:00
removing the keyboard.row style attributes
This commit is contained in:
parent
4d20e0c047
commit
7457808c49
app/src/main
kotlin/com/simplemobiletools/keyboard
res
@ -115,10 +115,7 @@ class MyKeyboard {
|
|||||||
* Some of the key size defaults can be overridden per row from what the [MyKeyboard]
|
* Some of the key size defaults can be overridden per row from what the [MyKeyboard]
|
||||||
* defines.
|
* defines.
|
||||||
* @attr ref android.R.styleable#Keyboard_keyWidth
|
* @attr ref android.R.styleable#Keyboard_keyWidth
|
||||||
* @attr ref android.R.styleable#Keyboard_keyHeight
|
|
||||||
* @attr ref android.R.styleable#Keyboard_horizontalGap
|
* @attr ref android.R.styleable#Keyboard_horizontalGap
|
||||||
* @attr ref android.R.styleable#Keyboard_Row_rowEdgeFlags
|
|
||||||
* @attr ref android.R.styleable#Keyboard_Row_keyboardMode
|
|
||||||
*/
|
*/
|
||||||
class Row {
|
class Row {
|
||||||
/** Default width of a key in this row. */
|
/** Default width of a key in this row. */
|
||||||
@ -132,12 +129,6 @@ class MyKeyboard {
|
|||||||
|
|
||||||
var mKeys = ArrayList<Key>()
|
var mKeys = ArrayList<Key>()
|
||||||
|
|
||||||
/**
|
|
||||||
* Edge flags for this row of keys. Possible values that can be assigned are
|
|
||||||
* [EDGE_TOP][MyKeyboard.EDGE_TOP] and [EDGE_BOTTOM][MyKeyboard.EDGE_BOTTOM]
|
|
||||||
*/
|
|
||||||
var rowEdgeFlags = 0
|
|
||||||
|
|
||||||
/** The keyboard mode for this row */
|
/** The keyboard mode for this row */
|
||||||
var mode = 0
|
var mode = 0
|
||||||
var parent: MyKeyboard
|
var parent: MyKeyboard
|
||||||
@ -148,15 +139,11 @@ class MyKeyboard {
|
|||||||
|
|
||||||
constructor(res: Resources, parent: MyKeyboard, parser: XmlResourceParser?) {
|
constructor(res: Resources, parent: MyKeyboard, parser: XmlResourceParser?) {
|
||||||
this.parent = parent
|
this.parent = parent
|
||||||
var a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard)
|
val a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard)
|
||||||
defaultWidth = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyWidth, parent.mDisplayWidth, parent.mDefaultWidth)
|
defaultWidth = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyWidth, parent.mDisplayWidth, parent.mDefaultWidth)
|
||||||
defaultHeight = res.getDimension(R.dimen.key_height).toInt()
|
defaultHeight = res.getDimension(R.dimen.key_height).toInt()
|
||||||
defaultHorizontalGap = getDimensionOrFraction(a, R.styleable.MyKeyboard_horizontalGap, parent.mDisplayWidth, parent.mDefaultHorizontalGap)
|
defaultHorizontalGap = getDimensionOrFraction(a, R.styleable.MyKeyboard_horizontalGap, parent.mDisplayWidth, parent.mDefaultHorizontalGap)
|
||||||
|
|
||||||
a.recycle()
|
a.recycle()
|
||||||
a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard_Row)
|
|
||||||
rowEdgeFlags = a.getInt(R.styleable.MyKeyboard_Row_rowEdgeFlags, 0)
|
|
||||||
mode = a.getResourceId(R.styleable.MyKeyboard_Row_keyboardMode, 0)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +216,7 @@ class MyKeyboard {
|
|||||||
* that are just out of the boundary of the key. This is a bit mask of
|
* that are just out of the boundary of the key. This is a bit mask of
|
||||||
* [MyKeyboard.EDGE_LEFT], [MyKeyboard.EDGE_RIGHT], [MyKeyboard.EDGE_TOP] and [MyKeyboard.EDGE_BOTTOM].
|
* [MyKeyboard.EDGE_LEFT], [MyKeyboard.EDGE_RIGHT], [MyKeyboard.EDGE_TOP] and [MyKeyboard.EDGE_BOTTOM].
|
||||||
*/
|
*/
|
||||||
var edgeFlags: Int
|
var edgeFlags = 0
|
||||||
|
|
||||||
/** Whether this is a modifier key, such as Shift or Alt */
|
/** Whether this is a modifier key, such as Shift or Alt */
|
||||||
var modifier = false
|
var modifier = false
|
||||||
@ -280,7 +267,6 @@ class MyKeyboard {
|
|||||||
modifier = a.getBoolean(R.styleable.MyKeyboard_Key_isModifier, false)
|
modifier = a.getBoolean(R.styleable.MyKeyboard_Key_isModifier, false)
|
||||||
sticky = a.getBoolean(R.styleable.MyKeyboard_Key_isSticky, false)
|
sticky = a.getBoolean(R.styleable.MyKeyboard_Key_isSticky, false)
|
||||||
edgeFlags = a.getInt(R.styleable.MyKeyboard_Key_keyEdgeFlags, 0)
|
edgeFlags = a.getInt(R.styleable.MyKeyboard_Key_keyEdgeFlags, 0)
|
||||||
edgeFlags = edgeFlags or parent.rowEdgeFlags
|
|
||||||
icon = a.getDrawable(R.styleable.MyKeyboard_Key_keyIcon)
|
icon = a.getDrawable(R.styleable.MyKeyboard_Key_keyIcon)
|
||||||
icon?.setBounds(0, 0, icon!!.intrinsicWidth, icon!!.intrinsicHeight)
|
icon?.setBounds(0, 0, icon!!.intrinsicWidth, icon!!.intrinsicHeight)
|
||||||
|
|
||||||
@ -299,7 +285,6 @@ class MyKeyboard {
|
|||||||
height = parent.defaultHeight
|
height = parent.defaultHeight
|
||||||
width = parent.defaultWidth
|
width = parent.defaultWidth
|
||||||
gap = parent.defaultHorizontalGap
|
gap = parent.defaultHorizontalGap
|
||||||
edgeFlags = parent.rowEdgeFlags
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onPressed() {
|
fun onPressed() {
|
||||||
@ -413,7 +398,6 @@ class MyKeyboard {
|
|||||||
row.defaultHeight = mDefaultHeight
|
row.defaultHeight = mDefaultHeight
|
||||||
row.defaultWidth = mDefaultWidth
|
row.defaultWidth = mDefaultWidth
|
||||||
row.defaultHorizontalGap = mDefaultHorizontalGap
|
row.defaultHorizontalGap = mDefaultHorizontalGap
|
||||||
row.rowEdgeFlags = EDGE_TOP or EDGE_BOTTOM
|
|
||||||
|
|
||||||
characters.forEachIndexed { index, character ->
|
characters.forEachIndexed { index, character ->
|
||||||
val key = Key(row)
|
val key = Key(row)
|
||||||
@ -534,6 +518,7 @@ class MyKeyboard {
|
|||||||
return mGridNeighbors!![index]!!
|
return mGridNeighbors!![index]!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return IntArray(0)
|
return IntArray(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,11 +549,6 @@ class MyKeyboard {
|
|||||||
x = 0
|
x = 0
|
||||||
currentRow = createRowFromXml(res, parser)
|
currentRow = createRowFromXml(res, parser)
|
||||||
rows.add(currentRow)
|
rows.add(currentRow)
|
||||||
val skipRow = currentRow.mode != 0 && currentRow.mode != mKeyboardMode
|
|
||||||
if (skipRow) {
|
|
||||||
skipToEndOfRow(parser)
|
|
||||||
inRow = false
|
|
||||||
}
|
|
||||||
} else if (TAG_KEY == tag) {
|
} else if (TAG_KEY == tag) {
|
||||||
inKey = true
|
inKey = true
|
||||||
key = createKeyFromXml(res, currentRow!!, x, y, parser)
|
key = createKeyFromXml(res, currentRow!!, x, y, parser)
|
||||||
@ -613,15 +593,6 @@ class MyKeyboard {
|
|||||||
height = y
|
height = y
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun skipToEndOfRow(parser: XmlResourceParser) {
|
|
||||||
var event: Int
|
|
||||||
while (parser.next().also { event = it } != XmlResourceParser.END_DOCUMENT) {
|
|
||||||
if (event == XmlResourceParser.END_TAG && parser.name == TAG_ROW) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun parseKeyboardAttributes(res: Resources, parser: XmlResourceParser) {
|
private fun parseKeyboardAttributes(res: Resources, parser: XmlResourceParser) {
|
||||||
val a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard)
|
val a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard)
|
||||||
mDefaultWidth = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyWidth, mDisplayWidth, mDisplayWidth / 10)
|
mDefaultWidth = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyWidth, mDisplayWidth, mDisplayWidth / 10)
|
||||||
|
@ -195,10 +195,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
val attributes = context.obtainStyledAttributes(attrs, R.styleable.MyKeyboardView, 0, defStyleRes)
|
val attributes = context.obtainStyledAttributes(attrs, R.styleable.MyKeyboardView, 0, defStyleRes)
|
||||||
val inflate = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
val inflate = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||||
val keyTextSize = 0
|
val keyTextSize = 0
|
||||||
val n = attributes.indexCount
|
val indexCnt = attributes.indexCount
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (i in 0 until n) {
|
for (i in 0 until indexCnt) {
|
||||||
val attr = attributes.getIndex(i)
|
val attr = attributes.getIndex(i)
|
||||||
when (attr) {
|
when (attr) {
|
||||||
R.styleable.MyKeyboardView_keyTextSize -> mKeyTextSize = attributes.getDimensionPixelSize(attr, 18)
|
R.styleable.MyKeyboardView_keyTextSize -> mKeyTextSize = attributes.getDimensionPixelSize(attr, 18)
|
||||||
|
@ -5,29 +5,14 @@
|
|||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="MyKeyboardView">
|
<declare-styleable name="MyKeyboardView">
|
||||||
<!-- Size of the text for character keys. -->
|
|
||||||
<attr name="keyTextSize" format="dimension" />
|
<attr name="keyTextSize" format="dimension" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="MyKeyboard">
|
<declare-styleable name="MyKeyboard">
|
||||||
<!-- Default width of a key in percentage of display width. -->
|
|
||||||
<attr name="keyWidth" format="fraction" />
|
<attr name="keyWidth" format="fraction" />
|
||||||
<!-- Default horizontal gap between keys. -->
|
|
||||||
<attr name="horizontalGap" format="fraction" />
|
<attr name="horizontalGap" format="fraction" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="MyKeyboard_Row">
|
|
||||||
<!-- Row edge flags. -->
|
|
||||||
<attr name="rowEdgeFlags">
|
|
||||||
<!-- Row is anchored to the top of the keyboard. -->
|
|
||||||
<flag name="top" value="4" />
|
|
||||||
<!-- Row is anchored to the bottom of the keyboard. -->
|
|
||||||
<flag name="bottom" value="8" />
|
|
||||||
</attr>
|
|
||||||
<!-- Mode of the keyboard. If the mode doesn't match the requested keyboard mode, the row will be skipped. -->
|
|
||||||
<attr name="keyboardMode" format="reference" />
|
|
||||||
</declare-styleable>
|
|
||||||
|
|
||||||
<declare-styleable name="MyKeyboard_Key">
|
<declare-styleable name="MyKeyboard_Key">
|
||||||
<!-- The unicode value or comma-separated values that this key outputs. -->
|
<!-- The unicode value or comma-separated values that this key outputs. -->
|
||||||
<attr name="codes" format="integer|string" />
|
<attr name="codes" format="integer|string" />
|
||||||
|
@ -144,7 +144,7 @@
|
|||||||
app:keyIcon="@drawable/ic_clear_vector"
|
app:keyIcon="@drawable/ic_clear_vector"
|
||||||
app:keyWidth="15%p" />
|
app:keyWidth="15%p" />
|
||||||
</Row>
|
</Row>
|
||||||
<Row app:rowEdgeFlags="bottom">
|
<Row>
|
||||||
<Key
|
<Key
|
||||||
app:codes="-2"
|
app:codes="-2"
|
||||||
app:keyEdgeFlags="left"
|
app:keyEdgeFlags="left"
|
||||||
|
@ -102,7 +102,7 @@
|
|||||||
app:keyIcon="@drawable/ic_clear_vector"
|
app:keyIcon="@drawable/ic_clear_vector"
|
||||||
app:keyWidth="15%p" />
|
app:keyWidth="15%p" />
|
||||||
</Row>
|
</Row>
|
||||||
<Row app:rowEdgeFlags="bottom">
|
<Row>
|
||||||
<Key
|
<Key
|
||||||
app:codes="-2"
|
app:codes="-2"
|
||||||
app:keyEdgeFlags="left"
|
app:keyEdgeFlags="left"
|
||||||
|
@ -102,7 +102,7 @@
|
|||||||
app:keyIcon="@drawable/ic_clear_vector"
|
app:keyIcon="@drawable/ic_clear_vector"
|
||||||
app:keyWidth="15%p" />
|
app:keyWidth="15%p" />
|
||||||
</Row>
|
</Row>
|
||||||
<Row app:rowEdgeFlags="bottom">
|
<Row>
|
||||||
<Key
|
<Key
|
||||||
app:codes="-2"
|
app:codes="-2"
|
||||||
app:keyEdgeFlags="left"
|
app:keyEdgeFlags="left"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user