removing unused previewlayout

This commit is contained in:
tibbi 2022-01-21 18:21:00 +01:00
parent 51df440857
commit 8004b2fd03
3 changed files with 6 additions and 20 deletions

View File

@ -93,17 +93,12 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
var onKeyboardActionListener: OnKeyboardActionListener? = null var onKeyboardActionListener: OnKeyboardActionListener? = null
private var mVerticalCorrection = 0 private var mVerticalCorrection = 0
private var mProximityThreshold = 0 private var mProximityThreshold = 0
/** /**
* Returns the enabled state of the key feedback popup. * Returns the enabled state of the key feedback popup.
* @return whether or not the key feedback popup is enabled * @return whether or not the key feedback popup is enabled
* @see .setPreviewEnabled * @see .setPreviewEnabled
*/ */
/**
* Enables or disables the key feedback popup. This is a popup that shows a magnified version of the depressed key. By default the preview is enabled.
* @param previewEnabled whether or not to enable the key feedback popup
* @see .isPreviewEnabled
*/
private var isPreviewEnabled = true
private var mPopupPreviewX = 0 private var mPopupPreviewX = 0
private var mPopupPreviewY = 0 private var mPopupPreviewY = 0
private var mLastX = 0 private var mLastX = 0
@ -199,7 +194,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
init { init {
val attributes = context.theme.obtainStyledAttributes(attrs, R.styleable.MyKeyboardView, defStyleAttr, defStyleRes) val attributes = context.theme.obtainStyledAttributes(attrs, R.styleable.MyKeyboardView, defStyleAttr, defStyleRes)
val inflate = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater val inflate = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
var previewLayout = 0
val keyTextSize = 0 val keyTextSize = 0
val n = attributes.indexCount val n = attributes.indexCount
@ -209,7 +203,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
when (attr) { when (attr) {
R.styleable.MyKeyboardView_keyBackground -> mKeyBackground = attributes.getDrawable(attr) R.styleable.MyKeyboardView_keyBackground -> mKeyBackground = attributes.getDrawable(attr)
R.styleable.MyKeyboardView_verticalCorrection -> mVerticalCorrection = attributes.getDimensionPixelOffset(attr, 0) R.styleable.MyKeyboardView_verticalCorrection -> mVerticalCorrection = attributes.getDimensionPixelOffset(attr, 0)
R.styleable.MyKeyboardView_keyPreviewLayout -> previewLayout = attributes.getResourceId(attr, 0)
R.styleable.MyKeyboardView_keyPreviewHeight -> mPreviewHeight = attributes.getDimensionPixelSize(attr, 80) R.styleable.MyKeyboardView_keyPreviewHeight -> mPreviewHeight = attributes.getDimensionPixelSize(attr, 80)
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_labelTextSize -> mLabelTextSize = attributes.getDimensionPixelSize(attr, 14)
@ -227,14 +220,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
mBackgroundDimAmount = 0.5f mBackgroundDimAmount = 0.5f
mPreviewPopup = PopupWindow(context) mPreviewPopup = PopupWindow(context)
if (previewLayout != 0) { mPreviewText = inflate.inflate(resources.getLayout(R.layout.keyboard_key_preview), null) as TextView
mPreviewText = inflate.inflate(previewLayout, null) as TextView mPreviewTextSizeLarge = context.resources.getDimension(R.dimen.preview_text_size).toInt()
mPreviewTextSizeLarge = context.resources.getDimension(R.dimen.preview_text_size).toInt() mPreviewPopup.contentView = mPreviewText
mPreviewPopup.contentView = mPreviewText mPreviewPopup.setBackgroundDrawable(null)
mPreviewPopup.setBackgroundDrawable(null)
} else {
isPreviewEnabled = false
}
mPreviewPopup.isTouchable = false mPreviewPopup.isTouchable = false
mPopupKeyboard = PopupWindow(context) mPopupKeyboard = PopupWindow(context)
@ -700,7 +689,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
} }
// If key changed and preview is on ... // If key changed and preview is on ...
if (oldKeyIndex != mCurrentKeyIndex && isPreviewEnabled) { if (oldKeyIndex != mCurrentKeyIndex) {
mHandler!!.removeMessages(MSG_SHOW_PREVIEW) mHandler!!.removeMessages(MSG_SHOW_PREVIEW)
if (previewPopup.isShowing) { if (previewPopup.isShowing) {
if (keyIndex == NOT_A_KEY) { if (keyIndex == NOT_A_KEY) {

View File

@ -13,8 +13,6 @@
<attr name="keyTextSize" format="dimension" /> <attr name="keyTextSize" format="dimension" />
<!-- Size of the text for custom keys with some text and no icon. --> <!-- Size of the text for custom keys with some text and no icon. -->
<attr name="labelTextSize" format="dimension" /> <attr name="labelTextSize" format="dimension" />
<!-- Layout resource for key press feedback. -->
<attr name="keyPreviewLayout" format="reference" />
<!-- Height of the key press feedback popup. --> <!-- Height of the key press feedback popup. -->
<attr name="keyPreviewHeight" format="dimension" /> <attr name="keyPreviewHeight" format="dimension" />
<!-- Amount to offset the touch Y coordinate by, for bias correction. --> <!-- Amount to offset the touch Y coordinate by, for bias correction. -->

View File

@ -9,7 +9,6 @@
<style name="Widget.KeyboardView" parent="Widget"> <style name="Widget.KeyboardView" parent="Widget">
<item name="keyBackground">@drawable/keyboard_key_selector</item> <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="keyPreviewLayout">@layout/keyboard_key_preview</item>
<item name="keyPreviewHeight">60dp</item> <item name="keyPreviewHeight">60dp</item>
<item name="labelTextSize">16sp</item> <item name="labelTextSize">16sp</item>
<item name="popupLayout">@layout/keyboard_popup_keyboard</item> <item name="popupLayout">@layout/keyboard_popup_keyboard</item>