removing some more attributes
This commit is contained in:
parent
99ac5e42b2
commit
4d20e0c047
|
@ -22,8 +22,9 @@ import com.simplemobiletools.keyboard.helpers.*
|
||||||
import kotlinx.android.synthetic.main.keyboard_popup_keyboard.view.*
|
import kotlinx.android.synthetic.main.keyboard_popup_keyboard.view.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int = R.attr.keyboardViewStyle, defStyleRes: Int = 0) :
|
@SuppressLint("UseCompatLoadingForDrawables")
|
||||||
View(context, attrs, defStyleAttr, defStyleRes) {
|
class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int = 0) :
|
||||||
|
View(context, attrs, defStyleRes) {
|
||||||
|
|
||||||
interface OnKeyboardActionListener {
|
interface OnKeyboardActionListener {
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +63,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
|
|
||||||
private var mLabelTextSize = 0
|
private var mLabelTextSize = 0
|
||||||
private var mKeyTextSize = 0
|
private var mKeyTextSize = 0
|
||||||
private val mBackgroundDimAmount: Float
|
|
||||||
|
|
||||||
private var mTextColor = 0
|
private var mTextColor = 0
|
||||||
private var mBackgroundColor = 0
|
private var mBackgroundColor = 0
|
||||||
|
@ -192,7 +192,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val attributes = context.theme.obtainStyledAttributes(attrs, R.styleable.MyKeyboardView, defStyleAttr, 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 n = attributes.indexCount
|
||||||
|
@ -201,24 +201,23 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
for (i in 0 until n) {
|
for (i in 0 until n) {
|
||||||
val attr = attributes.getIndex(i)
|
val attr = attributes.getIndex(i)
|
||||||
when (attr) {
|
when (attr) {
|
||||||
R.styleable.MyKeyboardView_keyBackground -> mKeyBackground = attributes.getDrawable(attr)
|
|
||||||
R.styleable.MyKeyboardView_verticalCorrection -> mVerticalCorrection = attributes.getDimensionPixelOffset(attr, 0)
|
|
||||||
R.styleable.MyKeyboardView_keyTextSize -> mKeyTextSize = attributes.getDimensionPixelSize(attr, 18)
|
R.styleable.MyKeyboardView_keyTextSize -> mKeyTextSize = attributes.getDimensionPixelSize(attr, 18)
|
||||||
R.styleable.MyKeyboardView_labelTextSize -> mLabelTextSize = attributes.getDimensionPixelSize(attr, 14)
|
|
||||||
R.styleable.MyKeyboardView_popupLayout -> mPopupLayout = attributes.getResourceId(attr, 0)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
attributes.recycle()
|
attributes.recycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mPopupLayout = R.layout.keyboard_popup_keyboard
|
||||||
|
mKeyBackground = resources.getDrawable(R.drawable.keyboard_key_selector, context.theme)
|
||||||
|
mVerticalCorrection = resources.getDimension(R.dimen.vertical_correction).toInt()
|
||||||
|
mLabelTextSize = resources.getDimension(R.dimen.label_text_size).toInt()
|
||||||
mPreviewHeight = resources.getDimension(R.dimen.key_height).toInt()
|
mPreviewHeight = resources.getDimension(R.dimen.key_height).toInt()
|
||||||
mSpaceMoveThreshold = resources.getDimension(R.dimen.medium_margin).toInt()
|
mSpaceMoveThreshold = resources.getDimension(R.dimen.medium_margin).toInt()
|
||||||
mTextColor = context.config.textColor
|
mTextColor = context.config.textColor
|
||||||
mBackgroundColor = context.config.backgroundColor
|
mBackgroundColor = context.config.backgroundColor
|
||||||
mPrimaryColor = context.getAdjustedPrimaryColor()
|
mPrimaryColor = context.getAdjustedPrimaryColor()
|
||||||
|
|
||||||
mBackgroundDimAmount = 0.5f
|
|
||||||
mPreviewPopup = PopupWindow(context)
|
mPreviewPopup = PopupWindow(context)
|
||||||
mPreviewText = inflate.inflate(resources.getLayout(R.layout.keyboard_key_preview), null) as TextView
|
mPreviewText = inflate.inflate(resources.getLayout(R.layout.keyboard_key_preview), null) as TextView
|
||||||
mPreviewTextSizeLarge = context.resources.getDimension(R.dimen.preview_text_size).toInt()
|
mPreviewTextSizeLarge = context.resources.getDimension(R.dimen.preview_text_size).toInt()
|
||||||
|
@ -544,7 +543,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
mInvalidatedKey = null
|
mInvalidatedKey = null
|
||||||
// Overlay a dark rectangle to dim the keyboard
|
// Overlay a dark rectangle to dim the keyboard
|
||||||
if (mMiniKeyboardOnScreen) {
|
if (mMiniKeyboardOnScreen) {
|
||||||
paint.color = (mBackgroundDimAmount * 0xFF).toInt() shl 24
|
paint.color = Color.BLACK.adjustAlpha(0.3f)
|
||||||
canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), paint)
|
canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), paint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<item android:id="@+id/button_background_shape">
|
<item android:id="@+id/button_background_shape">
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<solid android:color="@color/theme_dark_background_color" />
|
<solid android:color="@color/theme_dark_background_color" />
|
||||||
<corners android:radius="4dp" />
|
<corners android:radius="@dimen/small_margin" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
</layer-list>
|
</layer-list>
|
||||||
|
|
|
@ -5,18 +5,8 @@
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="MyKeyboardView">
|
<declare-styleable name="MyKeyboardView">
|
||||||
<attr name="keyboardViewStyle" format="reference" />
|
|
||||||
<!-- Image for the key. This image needs to be a StateListDrawable, with the following possible states:
|
|
||||||
normal, pressed, checkable, checkable+pressed, checkable+checked, checkable+checked+pressed. -->
|
|
||||||
<attr name="keyBackground" format="reference" />
|
|
||||||
<!-- Size of the text for character keys. -->
|
<!-- Size of the text for character keys. -->
|
||||||
<attr name="keyTextSize" format="dimension" />
|
<attr name="keyTextSize" format="dimension" />
|
||||||
<!-- Size of the text for custom keys with some text and no icon. -->
|
|
||||||
<attr name="labelTextSize" format="dimension" />
|
|
||||||
<!-- Amount to offset the touch Y coordinate by, for bias correction. -->
|
|
||||||
<attr name="verticalCorrection" format="dimension" />
|
|
||||||
<!-- Layout resource for popup keyboards. -->
|
|
||||||
<attr name="popupLayout" format="reference" />
|
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="MyKeyboard">
|
<declare-styleable name="MyKeyboard">
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
<dimen name="top_small_number_margin_width">12dp</dimen>
|
<dimen name="top_small_number_margin_width">12dp</dimen>
|
||||||
<dimen name="top_small_number_margin_height">18dp</dimen>
|
<dimen name="top_small_number_margin_height">18dp</dimen>
|
||||||
<dimen name="key_height">60dp</dimen>
|
<dimen name="key_height">60dp</dimen>
|
||||||
|
<dimen name="vertical_correction">-10dp</dimen>
|
||||||
|
|
||||||
<dimen name="keyboard_text_size">22sp</dimen>
|
<dimen name="keyboard_text_size">22sp</dimen>
|
||||||
<dimen name="preview_text_size">26sp</dimen>
|
<dimen name="preview_text_size">26sp</dimen>
|
||||||
|
<dimen name="label_text_size">16sp</dimen> <!-- text size used at keys with longer labels, like "123" -->
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -7,11 +7,7 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.KeyboardView" parent="Widget">
|
<style name="Widget.KeyboardView" parent="Widget">
|
||||||
<item name="keyBackground">@drawable/keyboard_key_selector</item>
|
|
||||||
<item name="keyTextSize">@dimen/keyboard_text_size</item>
|
<item name="keyTextSize">@dimen/keyboard_text_size</item>
|
||||||
<item name="labelTextSize">16sp</item>
|
|
||||||
<item name="popupLayout">@layout/keyboard_popup_keyboard</item>
|
|
||||||
<item name="verticalCorrection">-10dp</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.KeyboardViewPopup" parent="Widget.KeyboardView">
|
<style name="Widget.KeyboardViewPopup" parent="Widget.KeyboardView">
|
||||||
|
|
Loading…
Reference in New Issue