show an overlay for clipboard manager on button press

This commit is contained in:
tibbi 2022-01-26 23:02:06 +01:00
parent 4eafb16871
commit 9dabc77fe7
3 changed files with 21 additions and 4 deletions

View file

@ -42,7 +42,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
val keyboardHolder = layoutInflater.inflate(R.layout.keyboard_view_keyboard, null)
keyboardView = keyboardHolder.keyboard_view as MyKeyboardView
keyboardView!!.setKeyboard(keyboard!!)
keyboardView!!.setToolbarHolder(keyboardHolder.toolbar_holder)
keyboardView!!.setKeyboardHolder(keyboardHolder.keyboard_holder)
keyboardView!!.mOnKeyboardActionListener = this
return keyboardHolder!!
}

View file

@ -142,6 +142,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
private val mDistances = IntArray(MAX_NEARBY_KEYS)
private var mToolbarHolder: View? = null
private var mClipboardManagerHolder: View? = null
// For multi-tap
private var mLastTapTime = 0L
@ -281,6 +282,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
pinned_clipboard_items.applyColorFilter(mTextColor)
clipboard_clear.applyColorFilter(mTextColor)
}
mClipboardManagerHolder?.apply {
clipboard_manager_holder.background = ColorDrawable(mBackgroundColor.darkenColor())
}
}
}
@ -309,8 +314,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
}
/** Sets the top row above the keyboard containing a couple buttons and the clipboard **/
fun setToolbarHolder(toolbarHolder: View) {
mToolbarHolder = toolbarHolder
fun setKeyboardHolder(keyboardHolder: View) {
mToolbarHolder = keyboardHolder.toolbar_holder
mClipboardManagerHolder = keyboardHolder.clipboard_manager_holder
mToolbarHolder!!.apply {
settings_cog.setOnLongClickListener { context.toast(R.string.settings); true; }
@ -323,7 +329,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
pinned_clipboard_items.setOnLongClickListener { context.toast(R.string.clipboard); true; }
pinned_clipboard_items.setOnClickListener {
mClipboardManagerHolder!!.clipboard_manager_holder.beVisible()
}
clipboard_clear.setOnLongClickListener { context.toast(R.string.clear_clipboard_data); true; }

View file

@ -95,4 +95,15 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<RelativeLayout
android:id="@+id/clipboard_manager_holder"
android:layout_width="match_parent"
android:layout_height="0dp"
android:clickable="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/toolbar_holder" />
</androidx.constraintlayout.widget.ConstraintLayout>