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
|
<layer-list
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
>
|
>
|
||||||
<item android:top="50dp" android:bottom="0dp">
|
<item android:top="0dp" android:bottom="0dp">
|
||||||
<shape
|
<shape android:shape="rectangle">
|
||||||
android:shape="rectangle"
|
|
||||||
>
|
|
||||||
<corners android:radius="8dp" />
|
<corners android:radius="8dp" />
|
||||||
<size android:width="48dp" android:height="24dp" />
|
<size android:width="48dp" android:height="24dp" />
|
||||||
<solid android:color="@color/key_feedback_color_lxx_dark" />
|
<solid android:color="@color/key_feedback_color_lxx_dark" />
|
||||||
|
<padding android:bottom="50dp"/>
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
</layer-list>
|
</layer-list>
|
||||||
|
@ -41,8 +41,8 @@
|
|||||||
<dimen name="config_more_keys_keyboard_vertical_correction_holo">-22.4dp</dimen>
|
<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_offset_holo">1.6dp</dimen>
|
||||||
<dimen name="config_key_preview_height_holo">80dp</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_offset_lxx">43.6dp</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">90%</fraction>
|
<fraction name="config_key_preview_text_ratio">90%</fraction>
|
||||||
<fraction name="config_key_letter_ratio_holo">65%</fraction>
|
<fraction name="config_key_letter_ratio_holo">65%</fraction>
|
||||||
<fraction name="config_key_letter_ratio_lxx">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_offset_holo">8.0dp</dimen>
|
||||||
<dimen name="config_key_preview_height_holo">80dp</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_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_preview_text_ratio">82%</fraction>
|
||||||
<fraction name="config_key_letter_ratio_holo">55%</fraction>
|
<fraction name="config_key_letter_ratio_holo">55%</fraction>
|
||||||
<fraction name="config_key_letter_ratio_lxx">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 mKeyBackground;
|
||||||
private final Drawable mFunctionalKeyBackground;
|
private final Drawable mFunctionalKeyBackground;
|
||||||
private final Drawable mSpacebarBackground;
|
private final Drawable mSpacebarBackground;
|
||||||
private final KeyboardDrawableProvider mDrawableProvider;
|
protected final KeyboardDrawableProvider mDrawableProvider;
|
||||||
private final float mSpacebarIconWidthRatio;
|
private final float mSpacebarIconWidthRatio;
|
||||||
private final Rect mKeyBackgroundPadding = new Rect();
|
private final Rect mKeyBackgroundPadding = new Rect();
|
||||||
private static final float KET_TEXT_SHADOW_RADIUS_DISABLED = -1.0f;
|
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(
|
final int altCodeKeyWhileTypingFadeinAnimatorResId = mainKeyboardViewAttr.getResourceId(
|
||||||
R.styleable.MainKeyboardView_altCodeKeyWhileTypingFadeinAnimator, 0);
|
R.styleable.MainKeyboardView_altCodeKeyWhileTypingFadeinAnimator, 0);
|
||||||
|
|
||||||
mKeyPreviewDrawParams = new KeyPreviewDrawParams(mainKeyboardViewAttr);
|
mKeyPreviewDrawParams = new KeyPreviewDrawParams(mainKeyboardViewAttr, mDrawableProvider);
|
||||||
mKeyPreviewChoreographer = new KeyPreviewChoreographer(mKeyPreviewDrawParams);
|
mKeyPreviewChoreographer = new KeyPreviewChoreographer(mKeyPreviewDrawParams);
|
||||||
|
|
||||||
final int moreKeysKeyboardLayoutId = mainKeyboardViewAttr.getResourceId(
|
final int moreKeysKeyboardLayoutId = mainKeyboardViewAttr.getResourceId(
|
||||||
|
@ -59,7 +59,7 @@ public final class KeyPreviewChoreographer {
|
|||||||
}
|
}
|
||||||
final Context context = placerView.getContext();
|
final Context context = placerView.getContext();
|
||||||
keyPreviewView = new KeyPreviewView(context, null /* attrs */);
|
keyPreviewView = new KeyPreviewView(context, null /* attrs */);
|
||||||
keyPreviewView.setBackgroundResource(mParams.mPreviewBackgroundResId);
|
keyPreviewView.setBackground(mParams.mPreviewBackground);
|
||||||
placerView.addView(keyPreviewView, ViewLayoutUtils.newLayoutParam(placerView, 0, 0));
|
placerView.addView(keyPreviewView, ViewLayoutUtils.newLayoutParam(placerView, 0, 0));
|
||||||
return keyPreviewView;
|
return keyPreviewView;
|
||||||
}
|
}
|
||||||
|
@ -21,17 +21,19 @@ import android.animation.AnimatorInflater;
|
|||||||
import android.animation.AnimatorSet;
|
import android.animation.AnimatorSet;
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.AccelerateInterpolator;
|
import android.view.animation.AccelerateInterpolator;
|
||||||
import android.view.animation.DecelerateInterpolator;
|
import android.view.animation.DecelerateInterpolator;
|
||||||
|
|
||||||
|
import org.futo.inputmethod.latin.KeyboardDrawableProvider;
|
||||||
import org.futo.inputmethod.latin.R;
|
import org.futo.inputmethod.latin.R;
|
||||||
|
|
||||||
public final class KeyPreviewDrawParams {
|
public final class KeyPreviewDrawParams {
|
||||||
// XML attributes of {@link MainKeyboardView}.
|
// XML attributes of {@link MainKeyboardView}.
|
||||||
public final int mPreviewOffset;
|
public final int mPreviewOffset;
|
||||||
public final int mPreviewHeight;
|
public final int mPreviewHeight;
|
||||||
public final int mPreviewBackgroundResId;
|
public final Drawable mPreviewBackground;
|
||||||
private final int mShowUpAnimatorResId;
|
private final int mShowUpAnimatorResId;
|
||||||
private final int mDismissAnimatorResId;
|
private final int mDismissAnimatorResId;
|
||||||
private boolean mHasCustomAnimationParams;
|
private boolean mHasCustomAnimationParams;
|
||||||
@ -69,13 +71,12 @@ public final class KeyPreviewDrawParams {
|
|||||||
// preview background.
|
// preview background.
|
||||||
private int mVisibleOffset;
|
private int mVisibleOffset;
|
||||||
|
|
||||||
public KeyPreviewDrawParams(final TypedArray mainKeyboardViewAttr) {
|
public KeyPreviewDrawParams(final TypedArray mainKeyboardViewAttr, final KeyboardDrawableProvider provider) {
|
||||||
mPreviewOffset = mainKeyboardViewAttr.getDimensionPixelOffset(
|
mPreviewOffset = mainKeyboardViewAttr.getDimensionPixelOffset(
|
||||||
R.styleable.MainKeyboardView_keyPreviewOffset, 0);
|
R.styleable.MainKeyboardView_keyPreviewOffset, 0);
|
||||||
mPreviewHeight = mainKeyboardViewAttr.getDimensionPixelSize(
|
mPreviewHeight = mainKeyboardViewAttr.getDimensionPixelSize(
|
||||||
R.styleable.MainKeyboardView_keyPreviewHeight, 0);
|
R.styleable.MainKeyboardView_keyPreviewHeight, 0);
|
||||||
mPreviewBackgroundResId = mainKeyboardViewAttr.getResourceId(
|
mPreviewBackground = provider.getKeyFeedback();
|
||||||
R.styleable.MainKeyboardView_keyPreviewBackground, 0);
|
|
||||||
mLingerTimeout = mainKeyboardViewAttr.getInt(
|
mLingerTimeout = mainKeyboardViewAttr.getInt(
|
||||||
R.styleable.MainKeyboardView_keyPreviewLingerTimeout, 0);
|
R.styleable.MainKeyboardView_keyPreviewLingerTimeout, 0);
|
||||||
mShowUpAnimatorResId = mainKeyboardViewAttr.getResourceId(
|
mShowUpAnimatorResId = mainKeyboardViewAttr.getResourceId(
|
||||||
|
@ -10,6 +10,7 @@ import android.graphics.drawable.LayerDrawable
|
|||||||
import android.graphics.drawable.ShapeDrawable
|
import android.graphics.drawable.ShapeDrawable
|
||||||
import android.graphics.drawable.StateListDrawable
|
import android.graphics.drawable.StateListDrawable
|
||||||
import android.graphics.drawable.shapes.OvalShape
|
import android.graphics.drawable.shapes.OvalShape
|
||||||
|
import android.graphics.drawable.shapes.RoundRectShape
|
||||||
import android.graphics.drawable.shapes.Shape
|
import android.graphics.drawable.shapes.Shape
|
||||||
import android.inputmethodservice.InputMethodService
|
import android.inputmethodservice.InputMethodService
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
@ -50,6 +51,7 @@ import androidx.savedstate.findViewTreeSavedStateRegistryOwner
|
|||||||
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
|
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
|
||||||
import org.futo.inputmethod.latin.uix.ActionBar
|
import org.futo.inputmethod.latin.uix.ActionBar
|
||||||
import org.futo.inputmethod.latin.uix.theme.DarkColorScheme
|
import org.futo.inputmethod.latin.uix.theme.DarkColorScheme
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
|
||||||
interface KeyboardDrawableProvider {
|
interface KeyboardDrawableProvider {
|
||||||
@ -59,6 +61,8 @@ interface KeyboardDrawableProvider {
|
|||||||
val keyBackground: Drawable
|
val keyBackground: Drawable
|
||||||
val spaceBarBackground: Drawable
|
val spaceBarBackground: Drawable
|
||||||
|
|
||||||
|
val keyFeedback: Drawable
|
||||||
|
|
||||||
val moreKeysKeyboardBackground: Drawable
|
val moreKeysKeyboardBackground: Drawable
|
||||||
val popupKey: Drawable
|
val popupKey: Drawable
|
||||||
}
|
}
|
||||||
@ -72,6 +76,8 @@ class BasicThemeProvider(val context: Context) : KeyboardDrawableProvider {
|
|||||||
override val keyBackground: Drawable
|
override val keyBackground: Drawable
|
||||||
override val spaceBarBackground: Drawable
|
override val spaceBarBackground: Drawable
|
||||||
|
|
||||||
|
override val keyFeedback: Drawable
|
||||||
|
|
||||||
override val moreKeysKeyboardBackground: Drawable
|
override val moreKeysKeyboardBackground: Drawable
|
||||||
override val popupKey: 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 {
|
popupKey = StateListDrawable().apply {
|
||||||
addStateWithHighlightLayerOnPressed(highlight, intArrayOf(),
|
addStateWithHighlightLayerOnPressed(highlight, intArrayOf(),
|
||||||
coloredRoundedRectangle(surface, dp(8.dp))
|
coloredRoundedRectangle(surface, dp(8.dp))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user