Compare commits

...

7 Commits

Author SHA1 Message Date
Yuriy Liskov
70cfd73ac8 mouse pointer animation fix: update 2 2018-09-17 02:41:00 +03:00
Yuriy Liskov
0a42892d2d mouse pointer animation fix 2018-09-17 01:59:05 +03:00
Yuriy Liskov
c5c88e622d bit refactor 2018-09-17 01:25:26 +03:00
Yuriy Liskov
6e7db94a30 fix issue #7 2018-09-15 03:27:45 +03:00
Yuriy Liskov
80b76e9d1e donation 2018-09-08 00:08:58 +03:00
Yuriy Liskov
8c1c36cf0e update readme 2018-09-04 16:32:26 +03:00
Yuriy Liskov
a4d615bbf2 persian fix 2018-08-29 15:59:25 +03:00
10 changed files with 102 additions and 58 deletions

View File

@@ -47,9 +47,8 @@ __Standard installation via ADB__
### Donation:
If you want to support my developments you are welcome to buy me a cup of coffee :)
* BTC: 1JAT5VVWarVBkpVbNDn8UA8HXNdrukuBSx
* WMZ: Z375157140784
* WMU: U449339012933
* [__PrivatBank (Ukraine)__](https://privatbank.ua/ru/sendmoney?payment=5fcdddf53e3d491d63fcb050e6e2e05f2f2678c2)
* __BTC__: 1JAT5VVWarVBkpVbNDn8UA8HXNdrukuBSx
### Screens:
![Screenshot of LeanKeyKeyboard](img/leankeykeyboard_screenshot_01.png "Screenshot of LeanKeyKeyboard")

View File

@@ -8,8 +8,8 @@ android {
applicationId "org.liskovsoft.leankeykeyboard.pro"
minSdkVersion project.properties.minSdkVersion
targetSdkVersion project.properties.targetSdkVersion
versionCode 75
versionName "4.3.25"
versionCode 78
versionName "4.3.28"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

View File

@@ -446,23 +446,23 @@ public class LeanbackKeyboardContainer {
boolean overestimateHeight = false;
switch (focus.type) {
case KeyFocus.TYPE_MAIN:
boolean showScale = false;
overestimateHeight = true;
if (focus.code != LeanbackKeyboardView.ASCII_SPACE) {
overestimateWidth = true;
} else {
overestimateWidth = false;
showScale = true;
}
LeanbackKeyboardView mainView = mMainKeyboardView;
int index = focus.index;
boolean isClicked = false;
if (mTouchState == TOUCH_STATE_CLICK) {
overestimateHeight = true;
} else {
overestimateHeight = false;
isClicked = true;
}
mainView.setFocus(index, overestimateHeight, overestimateWidth);
mainView.setFocus(index, isClicked, showScale);
mPrevView = mMainKeyboardView;
overestimateHeight = true;
break;
case KeyFocus.TYPE_VOICE:
mVoiceButtonView.setMicFocused(true);
@@ -594,7 +594,12 @@ public class LeanbackKeyboardContainer {
mSelector.setX(translatedX);
mSelector.setY(translatedY);
} else {
mSelector.animate().x(translatedX).y(translatedY).setInterpolator(sMovementInterpolator).setDuration(MOVEMENT_ANIMATION_DURATION).start();
mSelector.animate()
.x(translatedX)
.y(translatedY)
.setInterpolator(sMovementInterpolator)
.setDuration(MOVEMENT_ANIMATION_DURATION)
.start();
}
}
@@ -853,7 +858,7 @@ public class LeanbackKeyboardContainer {
}
public boolean isVoiceVisible() {
return mVoiceButtonView.getVisibility() == 0;
return mVoiceButtonView.getVisibility() == View.VISIBLE;
}
public void onInitInputView() {
@@ -1031,6 +1036,10 @@ public class LeanbackKeyboardContainer {
setKbFocus(focus, false, true);
}
public void setFocus(LeanbackKeyboardContainer.KeyFocus focus, final boolean animate) {
setKbFocus(focus, false, animate);
}
public void setSelectorToFocus(Rect rect, boolean overestimateWidth, boolean overestimateHeight, boolean animate) {
if (this.mSelector.getWidth() != 0 && this.mSelector.getHeight() != 0 && rect.width() != 0 && rect.height() != 0) {
final float width = (float) rect.width();
@@ -1132,7 +1141,7 @@ public class LeanbackKeyboardContainer {
}
public void updateAddonKeyboard() {
mKeyboardManager = new KeyboardManager(mContext, mAbcKeyboard);
mKeyboardManager = new KeyboardManager(mContext);
switchToNextKeyboard();
}

View File

@@ -1,7 +1,6 @@
package com.google.android.leanback.ime;
import android.graphics.PointF;
import android.graphics.Rect;
import android.inputmethodservice.InputMethodService;
import android.inputmethodservice.Keyboard.Key;
import android.os.Handler;
@@ -51,7 +50,7 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
private LeanbackKeyboardContainer.KeyFocus mTempFocus;
private PointF mTempPoint;
private LeanbackKeyboardController.TouchEventListener mTouchEventListener;
private long prevTime;
private long mPrevTime;
private boolean mShowInput;
private int mLastEditorIdPhysicalKeyboardWasUsed;
private boolean mHideKeyboardWhenPhysicalKeyboardUsed = true;
@@ -500,15 +499,39 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
updatePositionToCurrentFocus();
}
private boolean isCallAllowed(int periodMillis) {
/**
* Simple throttle routine.
* @param callInterval interval
* @return is allowed
*/
private boolean isCallAllowedOrigin(int callInterval) {
long currTimeMS = System.currentTimeMillis();
if (this.prevTime != 0L && currTimeMS - this.prevTime <= (long) (periodMillis * 3)) {
if (currTimeMS - this.prevTime > (long) periodMillis) {
this.prevTime = 0L;
long timeDelta = currTimeMS - mPrevTime;
if (mPrevTime != 0 && timeDelta <= (callInterval * 3)) {
if (timeDelta > callInterval) {
mPrevTime = 0;
return true;
}
} else {
this.prevTime = currTimeMS;
mPrevTime = currTimeMS;
}
return false;
}
/**
* Simple throttle routine. Simplified comparing to previous. Not tested yet!!!!
* @param interval interval
* @return is allowed
*/
private boolean isCallAllowed2(int interval) {
long currTimeMS = System.currentTimeMillis();
long timeDelta = currTimeMS - mPrevTime;
if (mPrevTime == 0) {
mPrevTime = currTimeMS;
return true;
} else if (timeDelta > interval) {
mPrevTime = 0;
}
return false;
@@ -540,13 +563,10 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
}
private void moveSelectorToPoint(float x, float y) {
LeanbackKeyboardContainer container = this.mContainer;
LeanbackKeyboardContainer.KeyFocus focus = this.mTempFocus;
container.getBestFocus(new Float(x), new Float(y), focus);
this.mContainer.setFocus(this.mTempFocus);
container = this.mContainer;
Rect rect = this.mTempFocus.rect;
container.alignSelector((float) rect.centerX(), (float) rect.centerY(), false);
LeanbackKeyboardContainer container = mContainer;
LeanbackKeyboardContainer.KeyFocus focus = mTempFocus;
container.getBestFocus(x, y, focus);
mContainer.setFocus(mTempFocus, false);
}
private boolean onDirectionalMove(int dir) {
@@ -634,21 +654,21 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
}
/**
* Try to handle on hover event
* Control keyboard from the mouse. Movement catching
* @param view active view
* @param event event object
* @return is hover handled
*/
@Override
public boolean onHover(View view, MotionEvent event) {
boolean allowed = isCallAllowed(300);
if (allowed) {
if (event.getAction() == MotionEvent.ACTION_HOVER_MOVE) {
PointF pos = getRelativePosition(mContainer.getView(), event);
moveSelectorToPoint(pos.x, pos.y);
}
boolean handled = false;
if (event.getAction() == MotionEvent.ACTION_HOVER_MOVE) {
PointF pos = getRelativePosition(mContainer.getView(), event);
moveSelectorToPoint(pos.x, pos.y);
handled = true;
}
return allowed;
return handled;
}
/**

View File

@@ -523,8 +523,12 @@ public class LeanbackKeyboardView extends FrameLayout {
}
mCurrentFocusView = mKeyImageViews[indexFull];
mCurrentFocusView.animate().scaleX(scale).scaleY(scale).setInterpolator(LeanbackKeyboardContainer.sMovementInterpolator)
.setDuration((long) mClickAnimDur).start();
mCurrentFocusView.animate()
.scaleX(scale)
.scaleY(scale)
.setInterpolator(LeanbackKeyboardContainer.sMovementInterpolator)
.setDuration((long) mClickAnimDur)
.start();
}
mFocusIndex = indexFull;

View File

@@ -8,7 +8,6 @@ import java.util.ArrayList;
import java.util.List;
public class KeyboardManager {
private final Keyboard mEnglishKeyboard;
private final Context mContext;
private final KeyboardStateManager mStateManager;
private List<? extends KeyboardBuilder> mKeyboardBuilders;
@@ -17,13 +16,8 @@ public class KeyboardManager {
private int mKeyboardIndex = 0;
public KeyboardManager(Context ctx, int keyboardResId) {
this(ctx, new Keyboard(ctx, keyboardResId));
}
public KeyboardManager(Context ctx, Keyboard englishKeyboard) {
public KeyboardManager(Context ctx) {
mContext = ctx;
mEnglishKeyboard = englishKeyboard;
mStateManager = new KeyboardStateManager(mContext, this);
mStateManager.restore();
init();
@@ -37,7 +31,6 @@ public class KeyboardManager {
private List<Keyboard> buildAllKeyboards() {
List<Keyboard> keyboards = new ArrayList<>();
keyboards.add(mEnglishKeyboard);
if (!mKeyboardBuilders.isEmpty()) {
for (KeyboardBuilder builder : mKeyboardBuilders) {
keyboards.add(builder.createKeyboard());

View File

@@ -21,26 +21,37 @@ public class ResKeyboardFactory implements KeyboardFactory {
@Override
public List<? extends KeyboardBuilder> getAllAvailableKeyboards(Context context) {
List<KeyboardBuilder> result = new ArrayList<>();
List<KeyboardInfo> infos = ResKeyboardInfo.getAllKeyboardInfos(context);
final Resources resources = mContext.getResources();
for (final KeyboardInfo info : infos) {
if (!info.isEnabled()) {
continue;
}
result.add(new KeyboardBuilder() {
@Nullable
@Override
public Keyboard createKeyboard() {
return new Keyboard(mContext, resources.getIdentifier("qwerty_" + info.getLangCode(), "xml", mContext.getPackageName()));
}
});
result.add(createKeyboard(info.getLangCode()));
}
// at least one kbd should be enabled
if (result.isEmpty()) {
KeyboardInfo firstKbd = infos.get(0);
result.add(createKeyboard(firstKbd.getLangCode()));
firstKbd.setEnabled(true);
ResKeyboardInfo.updateAllKeyboardInfos(mContext, infos);
}
return result;
}
private KeyboardBuilder createKeyboard(final String langCode) {
return new KeyboardBuilder() {
@Nullable
@Override
public Keyboard createKeyboard() {
return new Keyboard(mContext, mContext.getResources().getIdentifier("qwerty_" + langCode, "xml", mContext.getPackageName()));
}
};
}
@Override
public boolean needUpdate() {
return ResKeyboardInfo.needUpdate();

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="additional_languages">
<item>Swedish|sv</item>
<item>English|us</item>
<item>Arabic|ar</item>
<item>Bulgarian|bg</item>
<item>Dutch|nl</item>
@@ -13,6 +13,7 @@
<item>Italian|it</item>
<item>Persian|fa</item>
<item>Russian|ru</item>
<item>Swedish|sv</item>
<item>Thai|th</item>
<item>Turkish|tr</item>
<item>Ukrainian|uk</item>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Keyboard android:keyWidth="@dimen/key_width" android:keyHeight="@dimen/key_height" android:horizontalGap="@dimen/keyboard_horizontal_gap" android:verticalGap="@dimen/keyboard_vertical_gap"
xmlns:android="http://schemas.android.com/apk/res/android">
<Row>
<Key android:keyLabel="آ" />
</Row>
</Keyboard>

View File

@@ -38,7 +38,7 @@
<Key android:keyLabel="ب" />
<Key android:keyLabel="ل" />
<!-- fix from Shobair Mohammadi <shobairmohammadi@gmail.com> -->
<Key android:keyLabel="ا|آ" />
<Key android:keyLabel="ا|آ" android:popupKeyboard="@xml/accent_fa_a" />
<Key android:keyLabel="ت" />
<Key android:keyLabel="ن" />
<Key android:keyLabel="م" />