mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-23 15:49:09 +00:00
add space and delete keys to clipboard view, move clear button to top strip
This commit is contained in:
parent
9f21f540af
commit
b921667c22
10 changed files with 176 additions and 173 deletions
|
@ -59,13 +59,4 @@ public class TabHostCompat extends TabHost implements TabHost.OnTabChangeListene
|
|||
public void setFireOnTabChangeListenerOnReselection(boolean 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
private MainKeyboardView mKeyboardView;
|
||||
private EmojiPalettesView mEmojiPalettesView;
|
||||
private View mEmojiTabStripView;
|
||||
private View mClipboardStripView;
|
||||
private View mSuggestionStripView;
|
||||
private ClipboardHistoryView mClipboardHistoryView;
|
||||
private LatinIME mLatinIME;
|
||||
|
@ -283,6 +284,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
mEmojiPalettesView.setVisibility(View.GONE);
|
||||
mEmojiPalettesView.stopEmojiPalettes();
|
||||
mEmojiTabStripView.setVisibility(View.GONE);
|
||||
mClipboardStripView.setVisibility(View.GONE);
|
||||
mSuggestionStripView.setVisibility(View.VISIBLE);
|
||||
mClipboardHistoryView.setVisibility(View.GONE);
|
||||
mClipboardHistoryView.stopClipboardHistory();
|
||||
|
@ -301,6 +303,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
// @see LatinIME#onComputeInset(android.inputmethodservice.InputMethodService.Insets)
|
||||
mKeyboardView.setVisibility(View.GONE);
|
||||
mSuggestionStripView.setVisibility(View.GONE);
|
||||
mClipboardStripView.setVisibility(View.GONE);
|
||||
mEmojiTabStripView.setVisibility(View.VISIBLE);
|
||||
mClipboardHistoryView.setVisibility(View.GONE);
|
||||
mEmojiPalettesView.startEmojiPalettes(
|
||||
|
@ -322,7 +325,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
// @see LatinIME#onComputeInset(android.inputmethodservice.InputMethodService.Insets)
|
||||
mKeyboardView.setVisibility(View.GONE);
|
||||
mEmojiTabStripView.setVisibility(View.GONE);
|
||||
mSuggestionStripView.setVisibility(View.VISIBLE);
|
||||
mSuggestionStripView.setVisibility(View.GONE);
|
||||
mClipboardStripView.setVisibility(View.VISIBLE);
|
||||
mEmojiPalettesView.setVisibility(View.GONE);
|
||||
mClipboardHistoryView.startClipboardHistory(
|
||||
mLatinIME.getClipboardHistoryManager(),
|
||||
|
@ -527,6 +531,10 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
return mEmojiTabStripView;
|
||||
}
|
||||
|
||||
public View getClipboardStrip() {
|
||||
return mClipboardStripView;
|
||||
}
|
||||
|
||||
public MainKeyboardView getMainKeyboardView() {
|
||||
return mKeyboardView;
|
||||
}
|
||||
|
@ -566,8 +574,10 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
mClipboardHistoryView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled);
|
||||
mClipboardHistoryView.setKeyboardActionListener(mLatinIME);
|
||||
mEmojiTabStripView = mCurrentInputView.findViewById(R.id.emoji_tab_strip);
|
||||
mClipboardStripView = mCurrentInputView.findViewById(R.id.clipboard_strip);
|
||||
mSuggestionStripView = mCurrentInputView.findViewById(R.id.suggestion_strip_view);
|
||||
mEmojiPalettesView.initialStart();
|
||||
mClipboardHistoryView.initialStart();
|
||||
|
||||
return mCurrentInputView;
|
||||
}
|
||||
|
|
|
@ -2,17 +2,19 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.keyboard.clipboard
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageButton
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
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.KeyVisualAttributes
|
||||
import org.dslul.openboard.inputmethod.keyboard.internal.KeyboardIconsSet
|
||||
|
@ -34,12 +36,15 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
|||
private val pinIconId: Int
|
||||
private val functionalKeyBackgroundId: Int
|
||||
private val keyBackgroundId: Int
|
||||
private val spacebarBackground: Drawable
|
||||
|
||||
private lateinit var clipboardRecyclerView: ClipboardHistoryRecyclerView
|
||||
private lateinit var placeholderView: TextView
|
||||
private lateinit var alphabetKey: TextView
|
||||
private lateinit var clearKey: ImageButton
|
||||
private lateinit var clipboardAdapter: ClipboardAdapter
|
||||
private lateinit var spacebar: View
|
||||
private lateinit var deleteKey: ImageButton
|
||||
|
||||
var keyboardActionListener: KeyboardActionListener? = null
|
||||
var clipboardHistoryManager: ClipboardHistoryManager? = null
|
||||
|
@ -51,26 +56,23 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
|||
clipboardViewAttr.recycle()
|
||||
val keyboardViewAttr = context.obtainStyledAttributes(attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView)
|
||||
keyBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_keyBackground, 0)
|
||||
functionalKeyBackgroundId = keyboardViewAttr.getResourceId(
|
||||
R.styleable.KeyboardView_functionalKeyBackground, keyBackgroundId)
|
||||
functionalKeyBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_functionalKeyBackground, keyBackgroundId)
|
||||
spacebarBackground = Settings.getInstance().current.mColors.selectAndColorDrawable(keyboardViewAttr, ColorType.SPACE_BAR_BACKGROUND);
|
||||
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) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
val res = context.resources
|
||||
// The main keyboard expands to the entire this {@link KeyboardView}.
|
||||
val width = ResourceUtils.getKeyboardWidth(res, Settings.getInstance().current) + paddingLeft + paddingRight
|
||||
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)
|
||||
}
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
fun initialStart() { // needs to be delayed for access to ClipboardStrip, which is not a child of this view
|
||||
val colors = Settings.getInstance().current.mColors
|
||||
clipboardAdapter = ClipboardAdapter(clipboardLayoutParams, this).apply {
|
||||
itemBackgroundId = keyBackgroundId
|
||||
|
@ -85,25 +87,33 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
|||
clipboardLayoutParams.setListProperties(this)
|
||||
placeholderView = this@ClipboardHistoryView.placeholderView
|
||||
}
|
||||
findViewById<FrameLayout>(R.id.clipboard_action_bar)?.apply {
|
||||
clipboardLayoutParams.setActionBarProperties(this)
|
||||
}
|
||||
alphabetKey = findViewById<TextView>(R.id.clipboard_keyboard_alphabet).apply {
|
||||
tag = Constants.CODE_ALPHA_FROM_CLIPBOARD
|
||||
setBackgroundResource(functionalKeyBackgroundId)
|
||||
setOnTouchListener(this@ClipboardHistoryView)
|
||||
setOnClickListener(this@ClipboardHistoryView)
|
||||
}
|
||||
clearKey = findViewById<ImageButton>(R.id.clipboard_clear).apply {
|
||||
setOnTouchListener(this@ClipboardHistoryView)
|
||||
setOnClickListener(this@ClipboardHistoryView)
|
||||
}
|
||||
alphabetKey = findViewById(R.id.key_alphabet)
|
||||
alphabetKey.setBackgroundResource(functionalKeyBackgroundId)
|
||||
alphabetKey.tag = Constants.CODE_ALPHA_FROM_CLIPBOARD
|
||||
alphabetKey.setOnTouchListener(this)
|
||||
alphabetKey.setOnClickListener(this)
|
||||
deleteKey = findViewById(R.id.key_delete)
|
||||
deleteKey.setBackgroundResource(functionalKeyBackgroundId)
|
||||
deleteKey.tag = Constants.CODE_DELETE
|
||||
deleteKey.setOnTouchListener(this)
|
||||
deleteKey.setOnClickListener(this)
|
||||
spacebar = findViewById(R.id.key_space)
|
||||
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.setBackground(clearKey, ColorType.CLEAR_CLIPBOARD_HISTORY_KEY)
|
||||
}
|
||||
|
||||
private fun setupAlphabetKey(key: TextView?, label: String, params: KeyDrawParams) {
|
||||
key?.apply {
|
||||
private fun setupAlphabetKey(key: TextView, label: String, params: KeyDrawParams) {
|
||||
key.apply {
|
||||
text = label
|
||||
typeface = params.mTypeface
|
||||
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) {
|
||||
clipboardAdapter.apply {
|
||||
itemBackgroundId = keyBackgroundId
|
||||
|
@ -122,6 +140,7 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
private fun setupClearKey(iconSet: KeyboardIconsSet) {
|
||||
// todo: add key to strip
|
||||
val resId = iconSet.getIconResourceId(KeyboardIconsSet.NAME_CLEAR_CLIPBOARD_KEY)
|
||||
clearKey.setImageResource(resId)
|
||||
}
|
||||
|
@ -142,10 +161,14 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
|||
historyManager.setHistoryChangeListener(this)
|
||||
clipboardHistoryManager = historyManager
|
||||
clipboardAdapter.clipboardHistoryManager = historyManager
|
||||
findViewById<LinearLayout>(R.id.action_bar).apply {
|
||||
clipboardLayoutParams.setActionBarProperties(this)
|
||||
}
|
||||
|
||||
val params = KeyDrawParams()
|
||||
params.updateParams(clipboardLayoutParams.actionBarContentHeight, keyVisualAttr)
|
||||
setupAlphabetKey(alphabetKey, switchToAlphaLabel, params)
|
||||
setupDeleteKey(deleteKey, iconSet.getIconResourceId(KeyboardIconsSet.NAME_DELETE_KEY))
|
||||
setupClipKey(params)
|
||||
setupClearKey(iconSet)
|
||||
|
||||
|
@ -168,17 +191,14 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
|||
clipboardAdapter.clipboardHistoryManager = null
|
||||
}
|
||||
|
||||
// todo: is the weird touch / click thing necessary?
|
||||
override fun onTouch(view: View, event: MotionEvent): Boolean {
|
||||
if (event.actionMasked != MotionEvent.ACTION_DOWN) {
|
||||
return false
|
||||
}
|
||||
when (view) {
|
||||
alphabetKey -> keyboardActionListener?.onPressKey(
|
||||
Constants.CODE_ALPHA_FROM_CLIPBOARD, 0 /* repeatCount */,
|
||||
true /* isSinglePointer */)
|
||||
clearKey -> keyboardActionListener?.onPressKey(
|
||||
Constants.CODE_UNSPECIFIED, 0 /* repeatCount */,
|
||||
true /* isSinglePointer */)
|
||||
alphabetKey, spacebar, deleteKey -> keyboardActionListener?.onPressKey(view.tag as Int, 0, true)
|
||||
clearKey -> keyboardActionListener?.onPressKey(Constants.CODE_UNSPECIFIED, 0, true)
|
||||
}
|
||||
// It's important to return false here. Otherwise, {@link #onClick} and touch-down visual
|
||||
// feedback stop working.
|
||||
|
@ -187,17 +207,14 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
|||
|
||||
override fun onClick(view: View) {
|
||||
when (view) {
|
||||
alphabetKey -> {
|
||||
keyboardActionListener?.onCodeInput(Constants.CODE_ALPHA_FROM_CLIPBOARD,
|
||||
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE,
|
||||
false /* isKeyRepeat */)
|
||||
keyboardActionListener?.onReleaseKey(Constants.CODE_ALPHA_FROM_CLIPBOARD,
|
||||
false /* withSliding */)
|
||||
alphabetKey, spacebar, deleteKey -> {
|
||||
keyboardActionListener?.onCodeInput(view.tag as Int,
|
||||
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false)
|
||||
keyboardActionListener?.onReleaseKey(view.tag as Int, false)
|
||||
}
|
||||
clearKey -> {
|
||||
clipboardHistoryManager?.clearHistory()
|
||||
keyboardActionListener?.onReleaseKey(Constants.CODE_UNSPECIFIED,
|
||||
false /* withSliding */)
|
||||
keyboardActionListener?.onReleaseKey(Constants.CODE_UNSPECIFIED, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,9 +56,10 @@ class ClipboardLayoutParams(res: Resources) {
|
|||
}
|
||||
}
|
||||
|
||||
fun setActionBarProperties(layout: FrameLayout) {
|
||||
fun setActionBarProperties(layout: LinearLayout) {
|
||||
(layout.layoutParams as LinearLayout.LayoutParams).apply {
|
||||
height = actionBarHeight
|
||||
width = ResourceUtils.getKeyboardWidth(layout.resources, Settings.getInstance().current)
|
||||
layout.layoutParams = this
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,8 +198,7 @@ public final class EmojiPalettesView extends LinearLayout
|
|||
final int currentCategorySize = mEmojiCategory.getCurrentCategoryPageCount();
|
||||
final int a = (int) (percentage * currentCategorySize);
|
||||
final float b = percentage * currentCategorySize - a;
|
||||
mEmojiCategoryPageIndicatorView.setCategoryPageId(
|
||||
currentCategorySize, a, b);
|
||||
mEmojiCategoryPageIndicatorView.setCategoryPageId(currentCategorySize, a, b);
|
||||
|
||||
final int firstCompleteVisibleBoard = mEmojiLayoutManager.findFirstCompletelyVisibleItemPosition();
|
||||
final int firstVisibleBoard = mEmojiLayoutManager.findFirstVisibleItemPosition();
|
||||
|
@ -211,19 +210,16 @@ public final class EmojiPalettesView extends LinearLayout
|
|||
mEmojiRecyclerView.setPersistentDrawingCache(PERSISTENT_NO_CACHE);
|
||||
mEmojiLayoutParams.setEmojiListProperties(mEmojiRecyclerView);
|
||||
|
||||
mEmojiCategoryPageIndicatorView =
|
||||
findViewById(R.id.emoji_category_page_id_view);
|
||||
mEmojiCategoryPageIndicatorView.setColors(
|
||||
mCategoryPageIndicatorColor, mColors.get(ColorType.EMOJI_CATEGORY_BACKGROUND));
|
||||
mEmojiCategoryPageIndicatorView = findViewById(R.id.emoji_category_page_id_view);
|
||||
mEmojiCategoryPageIndicatorView.setColors(mCategoryPageIndicatorColor, mColors.get(ColorType.EMOJI_CATEGORY_BACKGROUND));
|
||||
mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView);
|
||||
|
||||
setCurrentCategoryAndPageId(mEmojiCategory.getCurrentCategoryId(), mEmojiCategory.getCurrentCategoryPageId(),
|
||||
true /* force */);
|
||||
setCurrentCategoryAndPageId(mEmojiCategory.getCurrentCategoryId(), mEmojiCategory.getCurrentCategoryPageId(), true);
|
||||
// Enable reselection after the first setCurrentCategoryAndPageId() init call
|
||||
mTabHost.setFireOnTabChangeListenerOnReselection(true);
|
||||
|
||||
// deleteKey depends only on OnTouchListener.
|
||||
mDeleteKey = findViewById(R.id.emoji_keyboard_delete);
|
||||
mDeleteKey = findViewById(R.id.key_delete);
|
||||
mDeleteKey.setBackgroundResource(mFunctionalKeyBackgroundId);
|
||||
mColors.setColor(mDeleteKey, ColorType.KEY_ICON);
|
||||
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.
|
||||
// The text on alphabet keys are set at
|
||||
// {@link #startEmojiPalettes(String,int,float,Typeface)}.
|
||||
mAlphabetKeyLeft = findViewById(R.id.emoji_keyboard_alphabet_left);
|
||||
mAlphabetKeyLeft = findViewById(R.id.key_alphabet);
|
||||
mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId);
|
||||
mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
|
||||
mAlphabetKeyLeft.setOnTouchListener(this);
|
||||
mAlphabetKeyLeft.setOnClickListener(this);
|
||||
mSpacebar = findViewById(R.id.emoji_keyboard_space);
|
||||
mSpacebar = findViewById(R.id.key_space);
|
||||
mSpacebar.setBackground(mSpacebarBackground);
|
||||
mSpacebar.setTag(Constants.CODE_SPACE);
|
||||
mSpacebar.setOnTouchListener(this);
|
||||
mSpacebar.setOnClickListener(this);
|
||||
|
||||
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(mDeleteKey, ColorType.FUNCTIONAL_KEY_BACKGROUND);
|
||||
|
@ -315,9 +311,8 @@ public final class EmojiPalettesView extends LinearLayout
|
|||
return;
|
||||
}
|
||||
final int code = (Integer) tag;
|
||||
mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE,
|
||||
false /* isKeyRepeat */);
|
||||
mKeyboardActionListener.onReleaseKey(code, false /* withSliding */);
|
||||
mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE, false);
|
||||
mKeyboardActionListener.onReleaseKey(code, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -328,7 +323,7 @@ public final class EmojiPalettesView extends LinearLayout
|
|||
@Override
|
||||
public void onPressKey(final Key key) {
|
||||
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) {
|
||||
mKeyboardActionListener.onTextInput(key.getOutputText());
|
||||
} else {
|
||||
mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE,
|
||||
false /* isKeyRepeat */);
|
||||
mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE, false);
|
||||
}
|
||||
mKeyboardActionListener.onReleaseKey(code, false /* withSliding */);
|
||||
mKeyboardActionListener.onReleaseKey(code, false);
|
||||
}
|
||||
|
||||
public void setHardwareAcceleratedDrawingEnabled(final boolean enabled) {
|
||||
|
@ -371,7 +365,7 @@ public final class EmojiPalettesView extends LinearLayout
|
|||
if (deleteIconResId != 0) {
|
||||
mDeleteKey.setImageResource(deleteIconResId);
|
||||
}
|
||||
mEmojiLayoutParams.setActionBarProperties(findViewById(R.id.emoji_action_bar));
|
||||
mEmojiLayoutParams.setActionBarProperties(findViewById(R.id.action_bar));
|
||||
final KeyDrawParams params = new KeyDrawParams();
|
||||
params.updateParams(mEmojiLayoutParams.getActionBarHeight(), keyVisualAttr);
|
||||
setupAlphabetKey(mAlphabetKeyLeft, switchToAlphaLabel, params);
|
||||
|
@ -383,7 +377,7 @@ public final class EmojiPalettesView extends LinearLayout
|
|||
}
|
||||
|
||||
public void stopEmojiPalettes() {
|
||||
mEmojiPalettesAdapter.releaseCurrentKey(true /* withKeyRegistering */);
|
||||
mEmojiPalettesAdapter.releaseCurrentKey(true);
|
||||
mEmojiPalettesAdapter.flushPendingRecentKeys();
|
||||
mEmojiRecyclerView.setAdapter(null);
|
||||
}
|
||||
|
@ -399,7 +393,7 @@ public final class EmojiPalettesView extends LinearLayout
|
|||
}
|
||||
mEmojiCategoryPageIndicatorView.setCategoryPageId(
|
||||
mEmojiCategory.getCurrentCategoryPageCount(),
|
||||
mEmojiCategory.getCurrentCategoryPageId(), 0.0f /* offset */);
|
||||
mEmojiCategory.getCurrentCategoryPageId(), 0.0f);
|
||||
}
|
||||
|
||||
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) {
|
||||
mKeyboardActionListener.onPressKey(Constants.CODE_DELETE,
|
||||
0 /* repeatCount */, true /* isSinglePointer */);
|
||||
mKeyboardActionListener.onPressKey(Constants.CODE_DELETE, 0, true);
|
||||
v.setPressed(true /* pressed */);
|
||||
}
|
||||
|
||||
private void onTouchUp(final View v) {
|
||||
mKeyboardActionListener.onCodeInput(Constants.CODE_DELETE,
|
||||
NOT_A_COORDINATE, NOT_A_COORDINATE, false /* isKeyRepeat */);
|
||||
mKeyboardActionListener.onReleaseKey(Constants.CODE_DELETE, false /* withSliding */);
|
||||
mKeyboardActionListener.onCodeInput(Constants.CODE_DELETE, NOT_A_COORDINATE, NOT_A_COORDINATE, false);
|
||||
mKeyboardActionListener.onReleaseKey(Constants.CODE_DELETE, false);
|
||||
v.setPressed(false /* pressed */);
|
||||
}
|
||||
|
||||
|
|
61
app/src/main/res/layout/action_bar.xml
Normal file
61
app/src/main/res/layout/action_bar.xml
Normal 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>
|
|
@ -31,41 +31,6 @@
|
|||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
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>
|
||||
<include layout="@layout/action_bar" />
|
||||
|
||||
</org.dslul.openboard.inputmethod.keyboard.clipboard.ClipboardHistoryView>
|
|
@ -23,64 +23,6 @@
|
|||
android:id="@+id/emoji_category_page_id_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dip" />
|
||||
<LinearLayout
|
||||
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>
|
||||
<include layout="@layout/action_bar" />
|
||||
|
||||
</org.dslul.openboard.inputmethod.keyboard.emoji.EmojiPalettesView>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<LinearLayout
|
||||
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_gravity="bottom"
|
||||
android:orientation="vertical" >
|
||||
|
|
|
@ -52,4 +52,28 @@
|
|||
</FrameLayout>
|
||||
</org.dslul.openboard.inputmethod.compat.TabHostCompat>
|
||||
</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>
|
||||
|
|
Loading…
Add table
Reference in a new issue