add space and delete keys to clipboard view, move clear button to top strip

This commit is contained in:
Helium314 2023-12-20 22:08:07 +01:00
parent 9f21f540af
commit b921667c22
10 changed files with 176 additions and 173 deletions

View file

@ -59,13 +59,4 @@ public class TabHostCompat extends TabHost implements TabHost.OnTabChangeListene
public void setFireOnTabChangeListenerOnReselection(boolean whether) { public void setFireOnTabChangeListenerOnReselection(boolean whether) {
mFireOnTabChangeListenerOnReselection = whether; mFireOnTabChangeListenerOnReselection = whether;
} }
@Override public void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
final Resources res = getContext().getResources();
// fill full width, otherwise the layout is messed up
final int width = ResourceUtils.getDefaultKeyboardWidth(res);
final int height = res.getDimensionPixelSize(R.dimen.config_suggestions_strip_height);
setMeasuredDimension(width, height);
}
} }

View file

@ -47,6 +47,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
private MainKeyboardView mKeyboardView; private MainKeyboardView mKeyboardView;
private EmojiPalettesView mEmojiPalettesView; private EmojiPalettesView mEmojiPalettesView;
private View mEmojiTabStripView; private View mEmojiTabStripView;
private View mClipboardStripView;
private View mSuggestionStripView; private View mSuggestionStripView;
private ClipboardHistoryView mClipboardHistoryView; private ClipboardHistoryView mClipboardHistoryView;
private LatinIME mLatinIME; private LatinIME mLatinIME;
@ -283,6 +284,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mEmojiPalettesView.setVisibility(View.GONE); mEmojiPalettesView.setVisibility(View.GONE);
mEmojiPalettesView.stopEmojiPalettes(); mEmojiPalettesView.stopEmojiPalettes();
mEmojiTabStripView.setVisibility(View.GONE); mEmojiTabStripView.setVisibility(View.GONE);
mClipboardStripView.setVisibility(View.GONE);
mSuggestionStripView.setVisibility(View.VISIBLE); mSuggestionStripView.setVisibility(View.VISIBLE);
mClipboardHistoryView.setVisibility(View.GONE); mClipboardHistoryView.setVisibility(View.GONE);
mClipboardHistoryView.stopClipboardHistory(); mClipboardHistoryView.stopClipboardHistory();
@ -301,6 +303,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
// @see LatinIME#onComputeInset(android.inputmethodservice.InputMethodService.Insets) // @see LatinIME#onComputeInset(android.inputmethodservice.InputMethodService.Insets)
mKeyboardView.setVisibility(View.GONE); mKeyboardView.setVisibility(View.GONE);
mSuggestionStripView.setVisibility(View.GONE); mSuggestionStripView.setVisibility(View.GONE);
mClipboardStripView.setVisibility(View.GONE);
mEmojiTabStripView.setVisibility(View.VISIBLE); mEmojiTabStripView.setVisibility(View.VISIBLE);
mClipboardHistoryView.setVisibility(View.GONE); mClipboardHistoryView.setVisibility(View.GONE);
mEmojiPalettesView.startEmojiPalettes( mEmojiPalettesView.startEmojiPalettes(
@ -322,7 +325,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
// @see LatinIME#onComputeInset(android.inputmethodservice.InputMethodService.Insets) // @see LatinIME#onComputeInset(android.inputmethodservice.InputMethodService.Insets)
mKeyboardView.setVisibility(View.GONE); mKeyboardView.setVisibility(View.GONE);
mEmojiTabStripView.setVisibility(View.GONE); mEmojiTabStripView.setVisibility(View.GONE);
mSuggestionStripView.setVisibility(View.VISIBLE); mSuggestionStripView.setVisibility(View.GONE);
mClipboardStripView.setVisibility(View.VISIBLE);
mEmojiPalettesView.setVisibility(View.GONE); mEmojiPalettesView.setVisibility(View.GONE);
mClipboardHistoryView.startClipboardHistory( mClipboardHistoryView.startClipboardHistory(
mLatinIME.getClipboardHistoryManager(), mLatinIME.getClipboardHistoryManager(),
@ -527,6 +531,10 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
return mEmojiTabStripView; return mEmojiTabStripView;
} }
public View getClipboardStrip() {
return mClipboardStripView;
}
public MainKeyboardView getMainKeyboardView() { public MainKeyboardView getMainKeyboardView() {
return mKeyboardView; return mKeyboardView;
} }
@ -566,8 +574,10 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mClipboardHistoryView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled); mClipboardHistoryView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled);
mClipboardHistoryView.setKeyboardActionListener(mLatinIME); mClipboardHistoryView.setKeyboardActionListener(mLatinIME);
mEmojiTabStripView = mCurrentInputView.findViewById(R.id.emoji_tab_strip); mEmojiTabStripView = mCurrentInputView.findViewById(R.id.emoji_tab_strip);
mClipboardStripView = mCurrentInputView.findViewById(R.id.clipboard_strip);
mSuggestionStripView = mCurrentInputView.findViewById(R.id.suggestion_strip_view); mSuggestionStripView = mCurrentInputView.findViewById(R.id.suggestion_strip_view);
mEmojiPalettesView.initialStart(); mEmojiPalettesView.initialStart();
mClipboardHistoryView.initialStart();
return mCurrentInputView; return mCurrentInputView;
} }

View file

@ -2,17 +2,19 @@
package org.dslul.openboard.inputmethod.keyboard.clipboard package org.dslul.openboard.inputmethod.keyboard.clipboard
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.graphics.drawable.Drawable
import android.util.AttributeSet import android.util.AttributeSet
import android.util.TypedValue import android.util.TypedValue
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
import android.widget.FrameLayout
import android.widget.ImageButton import android.widget.ImageButton
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.recyclerview.widget.StaggeredGridLayoutManager import androidx.recyclerview.widget.StaggeredGridLayoutManager
import org.dslul.openboard.inputmethod.keyboard.KeyboardActionListener import org.dslul.openboard.inputmethod.keyboard.KeyboardActionListener
import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher
import org.dslul.openboard.inputmethod.keyboard.internal.KeyDrawParams import org.dslul.openboard.inputmethod.keyboard.internal.KeyDrawParams
import org.dslul.openboard.inputmethod.keyboard.internal.KeyVisualAttributes import org.dslul.openboard.inputmethod.keyboard.internal.KeyVisualAttributes
import org.dslul.openboard.inputmethod.keyboard.internal.KeyboardIconsSet import org.dslul.openboard.inputmethod.keyboard.internal.KeyboardIconsSet
@ -34,12 +36,15 @@ class ClipboardHistoryView @JvmOverloads constructor(
private val pinIconId: Int private val pinIconId: Int
private val functionalKeyBackgroundId: Int private val functionalKeyBackgroundId: Int
private val keyBackgroundId: Int private val keyBackgroundId: Int
private val spacebarBackground: Drawable
private lateinit var clipboardRecyclerView: ClipboardHistoryRecyclerView private lateinit var clipboardRecyclerView: ClipboardHistoryRecyclerView
private lateinit var placeholderView: TextView private lateinit var placeholderView: TextView
private lateinit var alphabetKey: TextView private lateinit var alphabetKey: TextView
private lateinit var clearKey: ImageButton private lateinit var clearKey: ImageButton
private lateinit var clipboardAdapter: ClipboardAdapter private lateinit var clipboardAdapter: ClipboardAdapter
private lateinit var spacebar: View
private lateinit var deleteKey: ImageButton
var keyboardActionListener: KeyboardActionListener? = null var keyboardActionListener: KeyboardActionListener? = null
var clipboardHistoryManager: ClipboardHistoryManager? = null var clipboardHistoryManager: ClipboardHistoryManager? = null
@ -51,26 +56,23 @@ class ClipboardHistoryView @JvmOverloads constructor(
clipboardViewAttr.recycle() clipboardViewAttr.recycle()
val keyboardViewAttr = context.obtainStyledAttributes(attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView) val keyboardViewAttr = context.obtainStyledAttributes(attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView)
keyBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_keyBackground, 0) keyBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_keyBackground, 0)
functionalKeyBackgroundId = keyboardViewAttr.getResourceId( functionalKeyBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_functionalKeyBackground, keyBackgroundId)
R.styleable.KeyboardView_functionalKeyBackground, keyBackgroundId) spacebarBackground = Settings.getInstance().current.mColors.selectAndColorDrawable(keyboardViewAttr, ColorType.SPACE_BAR_BACKGROUND);
keyboardViewAttr.recycle() keyboardViewAttr.recycle()
} }
// todo: add another strip to clipboard, with select all, arrow keys, select, copy, clear buttons
// at the bottom, remove the clear button and add the keys like in the emoji view (abc, space, delete)
// also allow swipe to remove a word from clipboard history (except current clip and pinned clips)
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec) super.onMeasure(widthMeasureSpec, heightMeasureSpec)
val res = context.resources val res = context.resources
// The main keyboard expands to the entire this {@link KeyboardView}. // The main keyboard expands to the entire this {@link KeyboardView}.
val width = ResourceUtils.getKeyboardWidth(res, Settings.getInstance().current) + paddingLeft + paddingRight val width = ResourceUtils.getKeyboardWidth(res, Settings.getInstance().current) + paddingLeft + paddingRight
val height = ResourceUtils.getKeyboardHeight(res, Settings.getInstance().current) + paddingTop + paddingBottom val height = ResourceUtils.getKeyboardHeight(res, Settings.getInstance().current) + paddingTop + paddingBottom
findViewById<FrameLayout>(R.id.clipboard_action_bar)?.layoutParams?.width = width findViewById<LinearLayout>(R.id.action_bar)?.layoutParams?.width = width
setMeasuredDimension(width, height) setMeasuredDimension(width, height)
} }
override fun onFinishInflate() { @SuppressLint("ClickableViewAccessibility")
super.onFinishInflate() fun initialStart() { // needs to be delayed for access to ClipboardStrip, which is not a child of this view
val colors = Settings.getInstance().current.mColors val colors = Settings.getInstance().current.mColors
clipboardAdapter = ClipboardAdapter(clipboardLayoutParams, this).apply { clipboardAdapter = ClipboardAdapter(clipboardLayoutParams, this).apply {
itemBackgroundId = keyBackgroundId itemBackgroundId = keyBackgroundId
@ -85,25 +87,33 @@ class ClipboardHistoryView @JvmOverloads constructor(
clipboardLayoutParams.setListProperties(this) clipboardLayoutParams.setListProperties(this)
placeholderView = this@ClipboardHistoryView.placeholderView placeholderView = this@ClipboardHistoryView.placeholderView
} }
findViewById<FrameLayout>(R.id.clipboard_action_bar)?.apply { alphabetKey = findViewById(R.id.key_alphabet)
clipboardLayoutParams.setActionBarProperties(this) alphabetKey.setBackgroundResource(functionalKeyBackgroundId)
} alphabetKey.tag = Constants.CODE_ALPHA_FROM_CLIPBOARD
alphabetKey = findViewById<TextView>(R.id.clipboard_keyboard_alphabet).apply { alphabetKey.setOnTouchListener(this)
tag = Constants.CODE_ALPHA_FROM_CLIPBOARD alphabetKey.setOnClickListener(this)
setBackgroundResource(functionalKeyBackgroundId) deleteKey = findViewById(R.id.key_delete)
setOnTouchListener(this@ClipboardHistoryView) deleteKey.setBackgroundResource(functionalKeyBackgroundId)
setOnClickListener(this@ClipboardHistoryView) deleteKey.tag = Constants.CODE_DELETE
} deleteKey.setOnTouchListener(this)
clearKey = findViewById<ImageButton>(R.id.clipboard_clear).apply { deleteKey.setOnClickListener(this)
setOnTouchListener(this@ClipboardHistoryView) spacebar = findViewById(R.id.key_space)
setOnClickListener(this@ClipboardHistoryView) spacebar.background = spacebarBackground
} spacebar.tag = Constants.CODE_SPACE
spacebar.setOnTouchListener(this)
spacebar.setOnClickListener(this)
// todo: more buttons, like select all, arrow keys, copy, clear (and maybe start/end select?)
val clipboardStrip = KeyboardSwitcher.getInstance().clipboardStrip
colors.setBackground(clipboardStrip, ColorType.EMOJI_CATEGORY_BACKGROUND) // todo: choose a color
clearKey = clipboardStrip.findViewById(R.id.clipboard_clear)
clearKey.setOnTouchListener(this@ClipboardHistoryView)
clearKey.setOnClickListener(this@ClipboardHistoryView)
colors.setColor(clearKey, ColorType.CLEAR_CLIPBOARD_HISTORY_KEY) colors.setColor(clearKey, ColorType.CLEAR_CLIPBOARD_HISTORY_KEY)
colors.setBackground(clearKey, ColorType.CLEAR_CLIPBOARD_HISTORY_KEY) colors.setBackground(clearKey, ColorType.CLEAR_CLIPBOARD_HISTORY_KEY)
} }
private fun setupAlphabetKey(key: TextView?, label: String, params: KeyDrawParams) { private fun setupAlphabetKey(key: TextView, label: String, params: KeyDrawParams) {
key?.apply { key.apply {
text = label text = label
typeface = params.mTypeface typeface = params.mTypeface
Settings.getInstance().current.mColors.setBackground(this, ColorType.FUNCTIONAL_KEY_BACKGROUND) Settings.getInstance().current.mColors.setBackground(this, ColorType.FUNCTIONAL_KEY_BACKGROUND)
@ -112,6 +122,14 @@ class ClipboardHistoryView @JvmOverloads constructor(
} }
} }
private fun setupDeleteKey(key: ImageButton, iconId: Int) {
key.apply {
setImageResource(iconId)
Settings.getInstance().current.mColors.setBackground(this, ColorType.FUNCTIONAL_KEY_BACKGROUND)
Settings.getInstance().current.mColors.setColor(this, ColorType.KEY_ICON)
}
}
private fun setupClipKey(params: KeyDrawParams) { private fun setupClipKey(params: KeyDrawParams) {
clipboardAdapter.apply { clipboardAdapter.apply {
itemBackgroundId = keyBackgroundId itemBackgroundId = keyBackgroundId
@ -122,6 +140,7 @@ class ClipboardHistoryView @JvmOverloads constructor(
} }
private fun setupClearKey(iconSet: KeyboardIconsSet) { private fun setupClearKey(iconSet: KeyboardIconsSet) {
// todo: add key to strip
val resId = iconSet.getIconResourceId(KeyboardIconsSet.NAME_CLEAR_CLIPBOARD_KEY) val resId = iconSet.getIconResourceId(KeyboardIconsSet.NAME_CLEAR_CLIPBOARD_KEY)
clearKey.setImageResource(resId) clearKey.setImageResource(resId)
} }
@ -142,10 +161,14 @@ class ClipboardHistoryView @JvmOverloads constructor(
historyManager.setHistoryChangeListener(this) historyManager.setHistoryChangeListener(this)
clipboardHistoryManager = historyManager clipboardHistoryManager = historyManager
clipboardAdapter.clipboardHistoryManager = historyManager clipboardAdapter.clipboardHistoryManager = historyManager
findViewById<LinearLayout>(R.id.action_bar).apply {
clipboardLayoutParams.setActionBarProperties(this)
}
val params = KeyDrawParams() val params = KeyDrawParams()
params.updateParams(clipboardLayoutParams.actionBarContentHeight, keyVisualAttr) params.updateParams(clipboardLayoutParams.actionBarContentHeight, keyVisualAttr)
setupAlphabetKey(alphabetKey, switchToAlphaLabel, params) setupAlphabetKey(alphabetKey, switchToAlphaLabel, params)
setupDeleteKey(deleteKey, iconSet.getIconResourceId(KeyboardIconsSet.NAME_DELETE_KEY))
setupClipKey(params) setupClipKey(params)
setupClearKey(iconSet) setupClearKey(iconSet)
@ -168,17 +191,14 @@ class ClipboardHistoryView @JvmOverloads constructor(
clipboardAdapter.clipboardHistoryManager = null clipboardAdapter.clipboardHistoryManager = null
} }
// todo: is the weird touch / click thing necessary?
override fun onTouch(view: View, event: MotionEvent): Boolean { override fun onTouch(view: View, event: MotionEvent): Boolean {
if (event.actionMasked != MotionEvent.ACTION_DOWN) { if (event.actionMasked != MotionEvent.ACTION_DOWN) {
return false return false
} }
when (view) { when (view) {
alphabetKey -> keyboardActionListener?.onPressKey( alphabetKey, spacebar, deleteKey -> keyboardActionListener?.onPressKey(view.tag as Int, 0, true)
Constants.CODE_ALPHA_FROM_CLIPBOARD, 0 /* repeatCount */, clearKey -> keyboardActionListener?.onPressKey(Constants.CODE_UNSPECIFIED, 0, true)
true /* isSinglePointer */)
clearKey -> keyboardActionListener?.onPressKey(
Constants.CODE_UNSPECIFIED, 0 /* repeatCount */,
true /* isSinglePointer */)
} }
// It's important to return false here. Otherwise, {@link #onClick} and touch-down visual // It's important to return false here. Otherwise, {@link #onClick} and touch-down visual
// feedback stop working. // feedback stop working.
@ -187,17 +207,14 @@ class ClipboardHistoryView @JvmOverloads constructor(
override fun onClick(view: View) { override fun onClick(view: View) {
when (view) { when (view) {
alphabetKey -> { alphabetKey, spacebar, deleteKey -> {
keyboardActionListener?.onCodeInput(Constants.CODE_ALPHA_FROM_CLIPBOARD, keyboardActionListener?.onCodeInput(view.tag as Int,
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false)
false /* isKeyRepeat */) keyboardActionListener?.onReleaseKey(view.tag as Int, false)
keyboardActionListener?.onReleaseKey(Constants.CODE_ALPHA_FROM_CLIPBOARD,
false /* withSliding */)
} }
clearKey -> { clearKey -> {
clipboardHistoryManager?.clearHistory() clipboardHistoryManager?.clearHistory()
keyboardActionListener?.onReleaseKey(Constants.CODE_UNSPECIFIED, keyboardActionListener?.onReleaseKey(Constants.CODE_UNSPECIFIED, false)
false /* withSliding */)
} }
} }
} }

View file

@ -56,9 +56,10 @@ class ClipboardLayoutParams(res: Resources) {
} }
} }
fun setActionBarProperties(layout: FrameLayout) { fun setActionBarProperties(layout: LinearLayout) {
(layout.layoutParams as LinearLayout.LayoutParams).apply { (layout.layoutParams as LinearLayout.LayoutParams).apply {
height = actionBarHeight height = actionBarHeight
width = ResourceUtils.getKeyboardWidth(layout.resources, Settings.getInstance().current)
layout.layoutParams = this layout.layoutParams = this
} }
} }

View file

@ -198,8 +198,7 @@ public final class EmojiPalettesView extends LinearLayout
final int currentCategorySize = mEmojiCategory.getCurrentCategoryPageCount(); final int currentCategorySize = mEmojiCategory.getCurrentCategoryPageCount();
final int a = (int) (percentage * currentCategorySize); final int a = (int) (percentage * currentCategorySize);
final float b = percentage * currentCategorySize - a; final float b = percentage * currentCategorySize - a;
mEmojiCategoryPageIndicatorView.setCategoryPageId( mEmojiCategoryPageIndicatorView.setCategoryPageId(currentCategorySize, a, b);
currentCategorySize, a, b);
final int firstCompleteVisibleBoard = mEmojiLayoutManager.findFirstCompletelyVisibleItemPosition(); final int firstCompleteVisibleBoard = mEmojiLayoutManager.findFirstCompletelyVisibleItemPosition();
final int firstVisibleBoard = mEmojiLayoutManager.findFirstVisibleItemPosition(); final int firstVisibleBoard = mEmojiLayoutManager.findFirstVisibleItemPosition();
@ -211,19 +210,16 @@ public final class EmojiPalettesView extends LinearLayout
mEmojiRecyclerView.setPersistentDrawingCache(PERSISTENT_NO_CACHE); mEmojiRecyclerView.setPersistentDrawingCache(PERSISTENT_NO_CACHE);
mEmojiLayoutParams.setEmojiListProperties(mEmojiRecyclerView); mEmojiLayoutParams.setEmojiListProperties(mEmojiRecyclerView);
mEmojiCategoryPageIndicatorView = mEmojiCategoryPageIndicatorView = findViewById(R.id.emoji_category_page_id_view);
findViewById(R.id.emoji_category_page_id_view); mEmojiCategoryPageIndicatorView.setColors(mCategoryPageIndicatorColor, mColors.get(ColorType.EMOJI_CATEGORY_BACKGROUND));
mEmojiCategoryPageIndicatorView.setColors(
mCategoryPageIndicatorColor, mColors.get(ColorType.EMOJI_CATEGORY_BACKGROUND));
mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView); mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView);
setCurrentCategoryAndPageId(mEmojiCategory.getCurrentCategoryId(), mEmojiCategory.getCurrentCategoryPageId(), setCurrentCategoryAndPageId(mEmojiCategory.getCurrentCategoryId(), mEmojiCategory.getCurrentCategoryPageId(), true);
true /* force */);
// Enable reselection after the first setCurrentCategoryAndPageId() init call // Enable reselection after the first setCurrentCategoryAndPageId() init call
mTabHost.setFireOnTabChangeListenerOnReselection(true); mTabHost.setFireOnTabChangeListenerOnReselection(true);
// deleteKey depends only on OnTouchListener. // deleteKey depends only on OnTouchListener.
mDeleteKey = findViewById(R.id.emoji_keyboard_delete); mDeleteKey = findViewById(R.id.key_delete);
mDeleteKey.setBackgroundResource(mFunctionalKeyBackgroundId); mDeleteKey.setBackgroundResource(mFunctionalKeyBackgroundId);
mColors.setColor(mDeleteKey, ColorType.KEY_ICON); mColors.setColor(mDeleteKey, ColorType.KEY_ICON);
mDeleteKey.setTag(Constants.CODE_DELETE); mDeleteKey.setTag(Constants.CODE_DELETE);
@ -236,19 +232,19 @@ public final class EmojiPalettesView extends LinearLayout
// if the event is canceled by moving off the finger from the view. // if the event is canceled by moving off the finger from the view.
// The text on alphabet keys are set at // The text on alphabet keys are set at
// {@link #startEmojiPalettes(String,int,float,Typeface)}. // {@link #startEmojiPalettes(String,int,float,Typeface)}.
mAlphabetKeyLeft = findViewById(R.id.emoji_keyboard_alphabet_left); mAlphabetKeyLeft = findViewById(R.id.key_alphabet);
mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId); mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId);
mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI); mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
mAlphabetKeyLeft.setOnTouchListener(this); mAlphabetKeyLeft.setOnTouchListener(this);
mAlphabetKeyLeft.setOnClickListener(this); mAlphabetKeyLeft.setOnClickListener(this);
mSpacebar = findViewById(R.id.emoji_keyboard_space); mSpacebar = findViewById(R.id.key_space);
mSpacebar.setBackground(mSpacebarBackground); mSpacebar.setBackground(mSpacebarBackground);
mSpacebar.setTag(Constants.CODE_SPACE); mSpacebar.setTag(Constants.CODE_SPACE);
mSpacebar.setOnTouchListener(this); mSpacebar.setOnTouchListener(this);
mSpacebar.setOnClickListener(this); mSpacebar.setOnClickListener(this);
mEmojiLayoutParams.setKeyProperties(mSpacebar); mEmojiLayoutParams.setKeyProperties(mSpacebar);
mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon); mSpacebarIcon = findViewById(R.id.key_space_icon);
mColors.setBackground(mAlphabetKeyLeft, ColorType.FUNCTIONAL_KEY_BACKGROUND); mColors.setBackground(mAlphabetKeyLeft, ColorType.FUNCTIONAL_KEY_BACKGROUND);
mColors.setBackground(mDeleteKey, ColorType.FUNCTIONAL_KEY_BACKGROUND); mColors.setBackground(mDeleteKey, ColorType.FUNCTIONAL_KEY_BACKGROUND);
@ -315,9 +311,8 @@ public final class EmojiPalettesView extends LinearLayout
return; return;
} }
final int code = (Integer) tag; final int code = (Integer) tag;
mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE, mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE, false);
false /* isKeyRepeat */); mKeyboardActionListener.onReleaseKey(code, false);
mKeyboardActionListener.onReleaseKey(code, false /* withSliding */);
} }
/** /**
@ -328,7 +323,7 @@ public final class EmojiPalettesView extends LinearLayout
@Override @Override
public void onPressKey(final Key key) { public void onPressKey(final Key key) {
final int code = key.getCode(); final int code = key.getCode();
mKeyboardActionListener.onPressKey(code, 0 /* repeatCount */, true /* isSinglePointer */); mKeyboardActionListener.onPressKey(code, 0, true);
} }
/** /**
@ -344,10 +339,9 @@ public final class EmojiPalettesView extends LinearLayout
if (code == Constants.CODE_OUTPUT_TEXT) { if (code == Constants.CODE_OUTPUT_TEXT) {
mKeyboardActionListener.onTextInput(key.getOutputText()); mKeyboardActionListener.onTextInput(key.getOutputText());
} else { } else {
mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE, mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE, false);
false /* isKeyRepeat */);
} }
mKeyboardActionListener.onReleaseKey(code, false /* withSliding */); mKeyboardActionListener.onReleaseKey(code, false);
} }
public void setHardwareAcceleratedDrawingEnabled(final boolean enabled) { public void setHardwareAcceleratedDrawingEnabled(final boolean enabled) {
@ -371,7 +365,7 @@ public final class EmojiPalettesView extends LinearLayout
if (deleteIconResId != 0) { if (deleteIconResId != 0) {
mDeleteKey.setImageResource(deleteIconResId); mDeleteKey.setImageResource(deleteIconResId);
} }
mEmojiLayoutParams.setActionBarProperties(findViewById(R.id.emoji_action_bar)); mEmojiLayoutParams.setActionBarProperties(findViewById(R.id.action_bar));
final KeyDrawParams params = new KeyDrawParams(); final KeyDrawParams params = new KeyDrawParams();
params.updateParams(mEmojiLayoutParams.getActionBarHeight(), keyVisualAttr); params.updateParams(mEmojiLayoutParams.getActionBarHeight(), keyVisualAttr);
setupAlphabetKey(mAlphabetKeyLeft, switchToAlphaLabel, params); setupAlphabetKey(mAlphabetKeyLeft, switchToAlphaLabel, params);
@ -383,7 +377,7 @@ public final class EmojiPalettesView extends LinearLayout
} }
public void stopEmojiPalettes() { public void stopEmojiPalettes() {
mEmojiPalettesAdapter.releaseCurrentKey(true /* withKeyRegistering */); mEmojiPalettesAdapter.releaseCurrentKey(true);
mEmojiPalettesAdapter.flushPendingRecentKeys(); mEmojiPalettesAdapter.flushPendingRecentKeys();
mEmojiRecyclerView.setAdapter(null); mEmojiRecyclerView.setAdapter(null);
} }
@ -399,7 +393,7 @@ public final class EmojiPalettesView extends LinearLayout
} }
mEmojiCategoryPageIndicatorView.setCategoryPageId( mEmojiCategoryPageIndicatorView.setCategoryPageId(
mEmojiCategory.getCurrentCategoryPageCount(), mEmojiCategory.getCurrentCategoryPageCount(),
mEmojiCategory.getCurrentCategoryPageId(), 0.0f /* offset */); mEmojiCategory.getCurrentCategoryPageId(), 0.0f);
} }
private void setCurrentCategoryAndPageId(final int categoryId, final int categoryPageId, private void setCurrentCategoryAndPageId(final int categoryId, final int categoryPageId,
@ -458,15 +452,13 @@ public final class EmojiPalettesView extends LinearLayout
} }
private void onTouchDown(final View v) { private void onTouchDown(final View v) {
mKeyboardActionListener.onPressKey(Constants.CODE_DELETE, mKeyboardActionListener.onPressKey(Constants.CODE_DELETE, 0, true);
0 /* repeatCount */, true /* isSinglePointer */);
v.setPressed(true /* pressed */); v.setPressed(true /* pressed */);
} }
private void onTouchUp(final View v) { private void onTouchUp(final View v) {
mKeyboardActionListener.onCodeInput(Constants.CODE_DELETE, mKeyboardActionListener.onCodeInput(Constants.CODE_DELETE, NOT_A_COORDINATE, NOT_A_COORDINATE, false);
NOT_A_COORDINATE, NOT_A_COORDINATE, false /* isKeyRepeat */); mKeyboardActionListener.onReleaseKey(Constants.CODE_DELETE, false);
mKeyboardActionListener.onReleaseKey(Constants.CODE_DELETE, false /* withSliding */);
v.setPressed(false /* pressed */); v.setPressed(false /* pressed */);
} }

View file

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/action_bar"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
>
<!-- TODO: Implement a KeyView and replace this. -->
<!-- Provide audio and haptic feedback by ourselves based on the keyboard settings.
We just need to ignore the system's audio and haptic feedback settings. -->
<TextView
android:id="@+id/key_alphabet"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.15"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="2dp"
android:gravity="center"
android:hapticFeedbackEnabled="false"
android:soundEffectsEnabled="false" />
<!-- TODO: Implement KeyView and replace this. -->
<!-- Provide audio and haptic feedback by ourselves based on the keyboard settings.
We just need to ignore the system's audio and haptic feedback settings. -->
<RelativeLayout
android:id="@+id/key_space"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.70"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="2dp"
android:hapticFeedbackEnabled="false"
android:soundEffectsEnabled="false"
android:contentDescription="@string/spoken_description_space">
<!-- WORKAROUND: Show the spacebar icon as a background of this View. -->
<View
android:id="@+id/key_space_icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_centerInParent="true" />
</RelativeLayout>
<!-- TODO: Implement KeyView and replace this. -->
<!-- Provide audio and haptic feedback by ourselves based on the keyboard settings.
We just need to ignore the system's audio and haptic feedback settings. -->
<ImageButton
android:id="@+id/key_delete"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.15"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="2dp"
android:gravity="center"
android:hapticFeedbackEnabled="false"
android:soundEffectsEnabled="false"
android:contentDescription="@string/spoken_description_delete" />
</LinearLayout>

View file

@ -31,41 +31,6 @@
</FrameLayout> </FrameLayout>
<FrameLayout <include layout="@layout/action_bar" />
android:id="@+id/clipboard_action_bar"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<!-- TODO: Implement a KeyView and replace this. -->
<!-- Provide audio and haptic feedback by ourselves based on the keyboard settings.
We just need to ignore the system's audio and haptic feedback settings. -->
<TextView
android:id="@+id/clipboard_keyboard_alphabet"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="2dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="1dp"
android:layout_gravity="start|center_vertical"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:drawablePadding="12dp"
android:gravity="center"
android:hapticFeedbackEnabled="false"
android:soundEffectsEnabled="false" />
<ImageButton
android:id="@+id/clipboard_clear"
android:layout_width="@dimen/config_suggestions_strip_edge_key_width"
android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical"
android:layout_marginEnd="2dp"
android:padding="8dp"
android:hapticFeedbackEnabled="false"
android:soundEffectsEnabled="false"
android:scaleType="fitCenter"
style="?attr/suggestionWordStyle" />
</FrameLayout>
</org.dslul.openboard.inputmethod.keyboard.clipboard.ClipboardHistoryView> </org.dslul.openboard.inputmethod.keyboard.clipboard.ClipboardHistoryView>

View file

@ -23,64 +23,6 @@
android:id="@+id/emoji_category_page_id_view" android:id="@+id/emoji_category_page_id_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="2dip" /> android:layout_height="2dip" />
<LinearLayout <include layout="@layout/action_bar" />
android:id="@+id/emoji_action_bar"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
>
<!-- TODO: Implement a KeyView and replace this. -->
<!-- Provide audio and haptic feedback by ourselves based on the keyboard settings.
We just need to ignore the system's audio and haptic feedback settings. -->
<TextView
android:id="@+id/emoji_keyboard_alphabet_left"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.15"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="2dp"
android:gravity="center"
android:hapticFeedbackEnabled="false"
android:soundEffectsEnabled="false" />
<!-- TODO: Implement KeyView and replace this. -->
<!-- Provide audio and haptic feedback by ourselves based on the keyboard settings.
We just need to ignore the system's audio and haptic feedback settings. -->
<RelativeLayout
android:id="@+id/emoji_keyboard_space"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.70"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="2dp"
android:hapticFeedbackEnabled="false"
android:soundEffectsEnabled="false"
android:contentDescription="@string/spoken_description_space">
<!-- WORKAROUND: Show the spacebar icon as a bacground of this View. -->
<View
android:id="@+id/emoji_keyboard_space_icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_centerInParent="true" />
</RelativeLayout>
<!-- TODO: Implement KeyView and replace this. -->
<!-- Provide audio and haptic feedback by ourselves based on the keyboard settings.
We just need to ignore the system's audio and haptic feedback settings. -->
<ImageButton
android:id="@+id/emoji_keyboard_delete"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.15"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="2dp"
android:gravity="center"
android:hapticFeedbackEnabled="false"
android:soundEffectsEnabled="false"
android:contentDescription="@string/spoken_description_delete" />
</LinearLayout>
</org.dslul.openboard.inputmethod.keyboard.emoji.EmojiPalettesView> </org.dslul.openboard.inputmethod.keyboard.emoji.EmojiPalettesView>

View file

@ -7,7 +7,7 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:orientation="vertical" > android:orientation="vertical" >

View file

@ -52,4 +52,28 @@
</FrameLayout> </FrameLayout>
</org.dslul.openboard.inputmethod.compat.TabHostCompat> </org.dslul.openboard.inputmethod.compat.TabHostCompat>
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/clipboard_strip"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="?attr/suggestionStripViewStyle"
>
<!-- empty view to move clear button to the right -->
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<ImageButton
android:id="@+id/clipboard_clear"
android:layout_width="@dimen/config_suggestions_strip_edge_key_width"
android:layout_height="match_parent"
android:layout_gravity="end|center_vertical"
android:layout_marginEnd="2dp"
android:padding="8dp"
android:hapticFeedbackEnabled="false"
android:soundEffectsEnabled="false"
android:scaleType="fitCenter"
style="?attr/suggestionWordStyle" />
</LinearLayout>
</FrameLayout> </FrameLayout>