diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardContainer.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardContainer.java index ce86dcc..fc211be 100644 --- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardContainer.java +++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardContainer.java @@ -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: diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardController.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardController.java index 35db496..2606039 100644 --- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardController.java +++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardController.java @@ -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(); diff --git a/leankeykeyboard/src/main/res/values-fr/strings.xml b/leankeykeyboard/src/main/res/values-fr/strings.xml index 4946133..b68e545 100644 --- a/leankeykeyboard/src/main/res/values-fr/strings.xml +++ b/leankeykeyboard/src/main/res/values-fr/strings.xml @@ -24,7 +24,7 @@ Langue Entrée vocale Sélectionnez des dispositions supplémentaires - Pour ouvrir la boîte de dialogue la prochaine fois, appuyez longuement sur le bouton \\'monde \\' + Pour ouvrir la boîte de dialogue la prochaine fois, appuyez longuement sur le bouton \'monde \' Nom d\'utilisateur Email Clavier