mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Fix key feedback
This commit is contained in:
parent
5a4f42cafe
commit
0b3af718b8
@ -16,13 +16,12 @@
|
||||
<layer-list
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
<item android:top="50dp" android:bottom="0dp">
|
||||
<shape
|
||||
android:shape="rectangle"
|
||||
>
|
||||
<item android:top="0dp" android:bottom="0dp">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="8dp" />
|
||||
<size android:width="48dp" android:height="24dp" />
|
||||
<solid android:color="@color/key_feedback_color_lxx_dark" />
|
||||
<padding android:bottom="50dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
@ -41,8 +41,8 @@
|
||||
<dimen name="config_more_keys_keyboard_vertical_correction_holo">-22.4dp</dimen>
|
||||
<dimen name="config_key_preview_offset_holo">1.6dp</dimen>
|
||||
<dimen name="config_key_preview_height_holo">80dp</dimen>
|
||||
<dimen name="config_key_preview_offset_lxx">36.0dp</dimen>
|
||||
<dimen name="config_key_preview_height_lxx">160dp</dimen>
|
||||
<dimen name="config_key_preview_offset_lxx">43.6dp</dimen>
|
||||
<dimen name="config_key_preview_height_lxx">122dp</dimen>
|
||||
<fraction name="config_key_preview_text_ratio">90%</fraction>
|
||||
<fraction name="config_key_letter_ratio_holo">65%</fraction>
|
||||
<fraction name="config_key_letter_ratio_lxx">65%</fraction>
|
||||
|
@ -45,7 +45,7 @@
|
||||
<dimen name="config_key_preview_offset_holo">8.0dp</dimen>
|
||||
<dimen name="config_key_preview_height_holo">80dp</dimen>
|
||||
<dimen name="config_key_preview_offset_lxx">50.0dp</dimen>
|
||||
<dimen name="config_key_preview_height_lxx">160dp</dimen>
|
||||
<dimen name="config_key_preview_height_lxx">122dp</dimen>
|
||||
<fraction name="config_key_preview_text_ratio">82%</fraction>
|
||||
<fraction name="config_key_letter_ratio_holo">55%</fraction>
|
||||
<fraction name="config_key_letter_ratio_lxx">55%</fraction>
|
||||
|
@ -96,7 +96,7 @@ public class KeyboardView extends View {
|
||||
private final Drawable mKeyBackground;
|
||||
private final Drawable mFunctionalKeyBackground;
|
||||
private final Drawable mSpacebarBackground;
|
||||
private final KeyboardDrawableProvider mDrawableProvider;
|
||||
protected final KeyboardDrawableProvider mDrawableProvider;
|
||||
private final float mSpacebarIconWidthRatio;
|
||||
private final Rect mKeyBackgroundPadding = new Rect();
|
||||
private static final float KET_TEXT_SHADOW_RADIUS_DISABLED = -1.0f;
|
||||
|
@ -231,7 +231,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
|
||||
final int altCodeKeyWhileTypingFadeinAnimatorResId = mainKeyboardViewAttr.getResourceId(
|
||||
R.styleable.MainKeyboardView_altCodeKeyWhileTypingFadeinAnimator, 0);
|
||||
|
||||
mKeyPreviewDrawParams = new KeyPreviewDrawParams(mainKeyboardViewAttr);
|
||||
mKeyPreviewDrawParams = new KeyPreviewDrawParams(mainKeyboardViewAttr, mDrawableProvider);
|
||||
mKeyPreviewChoreographer = new KeyPreviewChoreographer(mKeyPreviewDrawParams);
|
||||
|
||||
final int moreKeysKeyboardLayoutId = mainKeyboardViewAttr.getResourceId(
|
||||
|
@ -59,7 +59,7 @@ public final class KeyPreviewChoreographer {
|
||||
}
|
||||
final Context context = placerView.getContext();
|
||||
keyPreviewView = new KeyPreviewView(context, null /* attrs */);
|
||||
keyPreviewView.setBackgroundResource(mParams.mPreviewBackgroundResId);
|
||||
keyPreviewView.setBackground(mParams.mPreviewBackground);
|
||||
placerView.addView(keyPreviewView, ViewLayoutUtils.newLayoutParam(placerView, 0, 0));
|
||||
return keyPreviewView;
|
||||
}
|
||||
|
@ -21,17 +21,19 @@ import android.animation.AnimatorInflater;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
|
||||
import org.futo.inputmethod.latin.KeyboardDrawableProvider;
|
||||
import org.futo.inputmethod.latin.R;
|
||||
|
||||
public final class KeyPreviewDrawParams {
|
||||
// XML attributes of {@link MainKeyboardView}.
|
||||
public final int mPreviewOffset;
|
||||
public final int mPreviewHeight;
|
||||
public final int mPreviewBackgroundResId;
|
||||
public final Drawable mPreviewBackground;
|
||||
private final int mShowUpAnimatorResId;
|
||||
private final int mDismissAnimatorResId;
|
||||
private boolean mHasCustomAnimationParams;
|
||||
@ -69,13 +71,12 @@ public final class KeyPreviewDrawParams {
|
||||
// preview background.
|
||||
private int mVisibleOffset;
|
||||
|
||||
public KeyPreviewDrawParams(final TypedArray mainKeyboardViewAttr) {
|
||||
public KeyPreviewDrawParams(final TypedArray mainKeyboardViewAttr, final KeyboardDrawableProvider provider) {
|
||||
mPreviewOffset = mainKeyboardViewAttr.getDimensionPixelOffset(
|
||||
R.styleable.MainKeyboardView_keyPreviewOffset, 0);
|
||||
mPreviewHeight = mainKeyboardViewAttr.getDimensionPixelSize(
|
||||
R.styleable.MainKeyboardView_keyPreviewHeight, 0);
|
||||
mPreviewBackgroundResId = mainKeyboardViewAttr.getResourceId(
|
||||
R.styleable.MainKeyboardView_keyPreviewBackground, 0);
|
||||
mPreviewBackground = provider.getKeyFeedback();
|
||||
mLingerTimeout = mainKeyboardViewAttr.getInt(
|
||||
R.styleable.MainKeyboardView_keyPreviewLingerTimeout, 0);
|
||||
mShowUpAnimatorResId = mainKeyboardViewAttr.getResourceId(
|
||||
|
@ -10,6 +10,7 @@ import android.graphics.drawable.LayerDrawable
|
||||
import android.graphics.drawable.ShapeDrawable
|
||||
import android.graphics.drawable.StateListDrawable
|
||||
import android.graphics.drawable.shapes.OvalShape
|
||||
import android.graphics.drawable.shapes.RoundRectShape
|
||||
import android.graphics.drawable.shapes.Shape
|
||||
import android.inputmethodservice.InputMethodService
|
||||
import android.util.TypedValue
|
||||
@ -50,6 +51,7 @@ import androidx.savedstate.findViewTreeSavedStateRegistryOwner
|
||||
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
|
||||
import org.futo.inputmethod.latin.uix.ActionBar
|
||||
import org.futo.inputmethod.latin.uix.theme.DarkColorScheme
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
interface KeyboardDrawableProvider {
|
||||
@ -59,6 +61,8 @@ interface KeyboardDrawableProvider {
|
||||
val keyBackground: Drawable
|
||||
val spaceBarBackground: Drawable
|
||||
|
||||
val keyFeedback: Drawable
|
||||
|
||||
val moreKeysKeyboardBackground: Drawable
|
||||
val popupKey: Drawable
|
||||
}
|
||||
@ -72,6 +76,8 @@ class BasicThemeProvider(val context: Context) : KeyboardDrawableProvider {
|
||||
override val keyBackground: Drawable
|
||||
override val spaceBarBackground: Drawable
|
||||
|
||||
override val keyFeedback: Drawable
|
||||
|
||||
override val moreKeysKeyboardBackground: Drawable
|
||||
override val popupKey: Drawable
|
||||
|
||||
@ -168,9 +174,20 @@ class BasicThemeProvider(val context: Context) : KeyboardDrawableProvider {
|
||||
)
|
||||
}
|
||||
|
||||
moreKeysKeyboardBackground = coloredRoundedRectangle(surface, dp(8.dp)).apply {
|
||||
keyFeedback = ShapeDrawable().apply {
|
||||
paint.color = secondary
|
||||
shape = RoundRectShape(floatArrayOf(
|
||||
dp(8.dp),dp(8.dp),dp(8.dp),dp(8.dp),
|
||||
dp(8.dp),dp(8.dp),dp(8.dp),dp(8.dp),
|
||||
), null, null)
|
||||
|
||||
intrinsicWidth = dp(48.dp).roundToInt()
|
||||
intrinsicHeight = dp(24.dp).roundToInt()
|
||||
|
||||
setPadding(0, 0, 0, dp(50.dp).roundToInt())
|
||||
}
|
||||
|
||||
moreKeysKeyboardBackground = coloredRoundedRectangle(surface, dp(8.dp))
|
||||
popupKey = StateListDrawable().apply {
|
||||
addStateWithHighlightLayerOnPressed(highlight, intArrayOf(),
|
||||
coloredRoundedRectangle(surface, dp(8.dp))
|
||||
|
Loading…
x
Reference in New Issue
Block a user