cyclic scroll: upd1

This commit is contained in:
Yuriy Liskov
2020-06-30 20:05:08 +03:00
parent 3d9cd08dc3
commit 1f4e245d7f
3 changed files with 42 additions and 21 deletions

View File

@@ -52,6 +52,7 @@ import com.liskovsoft.leankeyboard.activity.settings.KbSettingsActivity;
import com.liskovsoft.leankeyboard.addons.keyboards.KeyboardManager;
import com.liskovsoft.leankeyboard.helpers.Helpers;
import com.liskovsoft.leankeyboard.helpers.MessageHelpers;
import com.liskovsoft.leankeyboard.utils.LeanKeyPreferences;
import com.liskovsoft.leankeykeyboard.R;
import java.util.ArrayList;
@@ -677,6 +678,45 @@ public class LeanbackKeyboardContainer {
return type == KeyFocus.TYPE_MAIN ? this.mMainKeyboardView.getKey(index) : null;
}
public void updateCyclicFocus(int dir, KeyFocus oldFocus, KeyFocus newFocus) {
if (oldFocus.equals(newFocus)) {
if (LeanKeyPreferences.instance(mContext).getCyclicNavigationEnabled()) {
if (dir == DIRECTION_LEFT) {
offsetRect(mRect, mMainKeyboardView);
// rightmost key (usually ok button)
int keyIdx = mMainKeyboardView.getNearestIndex(mRect.right, mY - mRect.top);
Key key = mMainKeyboardView.getKey(keyIdx);
configureFocus(newFocus, mRect, keyIdx, key, 0);
} else if (dir == DIRECTION_RIGHT) {
offsetRect(mRect, mMainKeyboardView);
// leftmost key (usually a button)
int keyIdx = mMainKeyboardView.getNearestIndex(0, mY - mRect.top);
Key key = mMainKeyboardView.getKey(keyIdx);
configureFocus(newFocus, mRect, keyIdx, key, 0);
}
}
String direction = "UNKNOWN";
switch (dir) {
case LeanbackKeyboardContainer.DIRECTION_DOWN:
direction = "DOWN";
break;
case LeanbackKeyboardContainer.DIRECTION_LEFT:
direction = "LEFT";
break;
case LeanbackKeyboardContainer.DIRECTION_RIGHT:
direction = "RIGHT";
break;
case LeanbackKeyboardContainer.DIRECTION_UP:
direction = "UP";
break;
}
Log.d(TAG, "Same key focus found! Direction: " + direction + " Key Label: " + oldFocus.label);
}
}
public boolean getNextFocusInDirection(int direction, KeyFocus startFocus, KeyFocus nextFocus) {
switch (startFocus.type) {
case KeyFocus.TYPE_MAIN:

View File

@@ -576,26 +576,7 @@ public class LeanbackKeyboardController implements LeanbackKeyboardContainer.Voi
private boolean onDirectionalMove(int dir) {
if (mContainer.getNextFocusInDirection(dir, mCurrentFocus, mTempFocus)) {
if (mCurrentFocus.equals(mTempFocus)) {
String direction = "UNKNOWN";
switch (dir) {
case LeanbackKeyboardContainer.DIRECTION_DOWN:
direction = "DOWN";
break;
case LeanbackKeyboardContainer.DIRECTION_LEFT:
direction = "LEFT";
break;
case LeanbackKeyboardContainer.DIRECTION_RIGHT:
direction = "RIGHT";
break;
case LeanbackKeyboardContainer.DIRECTION_UP:
direction = "UP";
break;
}
Log.d(TAG, "Same key focus found! Direction: " + direction + " Key Label: " + mCurrentFocus.label);
}
mContainer.updateCyclicFocus(dir, mCurrentFocus, mTempFocus);
mContainer.setFocus(mTempFocus);
mCurrentFocus.set(mTempFocus);
clearKeyIfNecessary();

View File

@@ -24,7 +24,7 @@
<string name="keyboardview_keycode_lang">Langue</string>
<string name="keyboardview_keycode_voice">Entrée vocale</string>
<string name="language_dialog_title">Sélectionnez des dispositions supplémentaires</string>
<string name="language_dialog_subtitle">Pour ouvrir la boîte de dialogue la prochaine fois, appuyez longuement sur le bouton \\'monde \\'</string>
<string name="language_dialog_subtitle">Pour ouvrir la boîte de dialogue la prochaine fois, appuyez longuement sur le bouton \'monde \'</string>
<string name="user_name">Nom d\'utilisateur</string>
<string name="email_id">Email</string>
<string name="kb_layout_desc">Clavier</string>