Compare commits

...

4 Commits

Author SHA1 Message Date
Yuriy Liskov
43ef8324bf fix: home activity not found 2018-09-17 03:33:41 +03:00
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
6 changed files with 87 additions and 40 deletions

View File

@@ -8,8 +8,8 @@ android {
applicationId "org.liskovsoft.leankeykeyboard.pro"
minSdkVersion project.properties.minSdkVersion
targetSdkVersion project.properties.targetSdkVersion
versionCode 77
versionName "4.3.27"
versionCode 79
versionName "4.3.29"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

View File

@@ -5,9 +5,12 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
<application android:banner="@drawable/banner_app" android:label="@string/ime_name" android:icon="@drawable/ic_launcher" tools:targetApi="21">
<activity android:launchMode="singleTop" android:name="com.liskovsoft.other.SettingsActivity">
<activity android:launchMode="singleTop" android:name="com.liskovsoft.other.GenericLaunchActivity">
<meta-data android:name="package" android:value="com.android.settings"/>
<meta-data android:name="class" android:value="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity"/>
<meta-data android:name="class" android:value="com.android.settings.Settings$LanguageAndInputSettingsActivity"/>
<!-- "Languages & input" on old api -->
<meta-data android:name="package_alt" android:value="com.android.settings"/>
<meta-data android:name="class_alt" android:value="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

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();

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

@@ -15,8 +15,10 @@ import android.content.pm.ActivityInfo;
import android.content.Intent;
import android.app.Activity;
public class SettingsActivity extends Activity
public class GenericLaunchActivity extends Activity
{
private boolean isSecondLaunch = false;
@SuppressLint("WrongConstant")
private void addIntentFlags(final Intent intent) {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@@ -43,13 +45,16 @@ public class SettingsActivity extends Activity
}
private Intent makeIntent(final ActivityInfo activityInfo) {
String metaPackage = isSecondLaunch ? "package_alt" : "package";
String metaClass = isSecondLaunch ? "class_alt" : "class";
final Bundle metaData = activityInfo.metaData;
final Intent intent = new Intent();
if (metaData.getString("intent") != null) {
intent.setAction(metaData.getString("intent"));
return intent;
} else {
intent.setComponent(new ComponentName(metaData.getString(metaPackage), metaData.getString(metaClass)));
}
intent.setComponent(new ComponentName(metaData.getString("package"), metaData.getString("class")));
return intent;
}
@@ -65,6 +70,12 @@ public class SettingsActivity extends Activity
startActivity(intent);
}
catch (ActivityNotFoundException ex) {
if (!isSecondLaunch) {
isSecondLaunch = true;
launchApp();
return;
}
ex.printStackTrace();
makeLongToast(ex.getLocalizedMessage(), 10);
}