Compare commits

...

2 Commits

Author SHA1 Message Date
Yuriy Liskov
c16cc2525a fix: remember selected kbd 2018-07-18 14:29:08 +03:00
Yuriy Liskov
a1f7c7959a add Swedish kbd 2018-07-08 23:13:43 +03:00
27 changed files with 100 additions and 42 deletions

View File

@@ -14,14 +14,14 @@ buildscript {
// https://stackoverflow.com/questions/20404476/how-to-define-common-android-properties-for-all-modules-using-gradle
// Gradle constants example: https://github.com/google/ExoPlayer
ext {
compileSdkVersion = 27
buildToolsVersion = "27.0.3"
compileSdkVersion = 26
buildToolsVersion = "26.0.2"
minSdkVersion = 14
targetSdkVersion = 27
appCompatVersion = 'com.android.support:appcompat-v7:27.+'
targetSdkVersion = 26
appCompatVersion = 'com.android.support:appcompat-v7:26.+'
espressoCoreVersion = 'com.android.support.test.espresso:espresso-core:2.2.2'
junitVersion = 'junit:junit:4.12'
supportVersion = 'com.android.support:support-v4:27.+'
supportVersion = 'com.android.support:support-v4:26.+'
robolectricVersion = 'org.robolectric:robolectric:3.5.1'
crashlyticsVersion = 'com.crashlytics.sdk.android:crashlytics:2.8.0@aar'
}

View File

@@ -8,8 +8,8 @@ android {
applicationId "org.liskovsoft.leankeykeyboard.pro"
minSdkVersion project.properties.minSdkVersion
targetSdkVersion project.properties.targetSdkVersion
versionCode 62
versionName "4.3.12"
versionCode 65
versionName "4.3.15"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

View File

@@ -166,7 +166,6 @@ public class LeanbackKeyboardContainer {
mAlphaIn = res.getFraction(R.fraction.alpha_in, 1, 1);
mAlphaOut = res.getFraction(R.fraction.alpha_out, 1, 1);
mVoiceAnimator = new LeanbackKeyboardContainer.VoiceIntroAnimator(mVoiceEnterListener, mVoiceExitListener);
initKeyboards();
mRootView = (RelativeLayout) mContext.getLayoutInflater().inflate(R.layout.root_leanback, null);
mKeyboardsContainer = mRootView.findViewById(R.id.keyboard);
mSuggestionsBg = mRootView.findViewById(R.id.candidate_background);
@@ -208,6 +207,7 @@ public class LeanbackKeyboardContainer {
LeanbackKeyboardContainer.this.cancelVoiceRecording();
}
});
initKeyboards();
}
private void configureFocus(LeanbackKeyboardContainer.KeyFocus focus, Rect rect, int index, int type) {
@@ -1128,9 +1128,8 @@ public class LeanbackKeyboardContainer {
}
public void updateAddonKeyboard() {
KeyboardManager manager = new KeyboardManager(mContext, mAbcKeyboard);
mKeyboardManager = manager;
mInitialMainKeyboard = manager.getNextKeyboard();
mKeyboardManager = new KeyboardManager(mContext, mAbcKeyboard);
switchToNextKeyboard();
}
public void updateSuggestions(ArrayList<String> suggestions) {

View File

@@ -2,7 +2,7 @@ package com.liskovsoft.keyboardaddons;
import android.content.Context;
import android.inputmethodservice.Keyboard;
import com.liskovsoft.keyboardaddons.reslangfactory.ResKeyboardFactory;
import com.liskovsoft.keyboardaddons.reskbdfactory.ResKeyboardFactory;
import java.util.ArrayList;
import java.util.List;
@@ -10,9 +10,11 @@ import java.util.List;
public class KeyboardManager {
private final Keyboard mEnglishKeyboard;
private final Context mContext;
private final KeyboardStateManager mStateManager;
private List<? extends KeyboardBuilder> mKeyboardBuilders;
private List<Keyboard> mAllKeyboards;
private KeyboardFactory mKeyboardFactory;
private int mKeyboardIndex = 0;
public KeyboardManager(Context ctx, int keyboardResId) {
@@ -22,6 +24,8 @@ public class KeyboardManager {
public KeyboardManager(Context ctx, Keyboard englishKeyboard) {
mContext = ctx;
mEnglishKeyboard = englishKeyboard;
mStateManager = new KeyboardStateManager(mContext, this);
mStateManager.restore();
init();
}
@@ -42,6 +46,13 @@ public class KeyboardManager {
return keyboards;
}
/**
* Performs callback to event handlers
*/
private void onNextKeyboard() {
mStateManager.onNextKeyboard();
}
/**
* Get next keyboard from internal source (looped)
* @return keyboard
@@ -58,8 +69,18 @@ public class KeyboardManager {
throw new IllegalStateException(String.format("Keyboard %s not initialized", mKeyboardIndex));
}
onNextKeyboard();
++mKeyboardIndex;
return kbd;
}
public int getKeyboardIndex() {
return mKeyboardIndex;
}
public void setKeyboardIndex(int idx) {
mKeyboardIndex = idx;
}
}

View File

@@ -0,0 +1,25 @@
package com.liskovsoft.keyboardaddons;
import android.content.Context;
import com.liskovsoft.utils.LeanKeyPreferences;
public class KeyboardStateManager {
private final Context mContext;
private final KeyboardManager mManager;
private final LeanKeyPreferences mPrefs;
public KeyboardStateManager(Context context, KeyboardManager manager) {
mContext = context;
mManager = manager;
mPrefs = LeanKeyPreferences.instance(mContext);
}
public void restore() {
int idx = mPrefs.getKeyboardIndex();
mManager.setKeyboardIndex(idx);
}
public void onNextKeyboard() {
mPrefs.setKeyboardIndex(mManager.getKeyboardIndex());
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.keyboardaddons.apklangfactory.addons;
package com.liskovsoft.keyboardaddons.apkkbdfactory.addons;
import android.content.Context;
import android.support.annotation.NonNull;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.keyboardaddons.apklangfactory.addons;
package com.liskovsoft.keyboardaddons.apkkbdfactory.addons;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -23,7 +23,7 @@ import android.support.annotation.Nullable;
import android.support.v4.util.SparseArrayCompat;
import android.util.SparseIntArray;
import com.liskovsoft.keyboardaddons.apklangfactory.utils.Logger;
import com.liskovsoft.keyboardaddons.apkkbdfactory.utils.Logger;
import java.lang.ref.WeakReference;
import java.util.Arrays;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.keyboardaddons.apklangfactory.addons;
package com.liskovsoft.keyboardaddons.apkkbdfactory.addons;
import android.content.Context;
import android.content.Intent;
@@ -27,7 +27,7 @@ import android.util.AttributeSet;
import android.util.Xml;
//import com.liskovsoft.keyboardaddons.apklangfactory.AnySoftKeyboard;
import com.liskovsoft.keyboardaddons.apklangfactory.utils.Logger;
import com.liskovsoft.keyboardaddons.apkkbdfactory.utils.Logger;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

View File

@@ -1,11 +1,11 @@
package com.liskovsoft.keyboardaddons.apklangfactory.addons;
package com.liskovsoft.keyboardaddons.apkkbdfactory.addons;
import android.content.Context;
import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.util.SparseIntArray;
import com.liskovsoft.keyboardaddons.apklangfactory.utils.Logger;
import com.liskovsoft.keyboardaddons.apkkbdfactory.utils.Logger;
import java.util.ArrayList;
import java.util.List;

View File

@@ -14,14 +14,14 @@
* limitations under the License.
*/
package com.liskovsoft.keyboardaddons.apklangfactory.keyboards;
package com.liskovsoft.keyboardaddons.apkkbdfactory.keyboards;
import android.content.Context;
import android.support.annotation.Nullable;
import com.liskovsoft.keyboardaddons.KeyboardBuilder;
import com.liskovsoft.keyboardaddons.apklangfactory.addons.AddOn;
import com.liskovsoft.keyboardaddons.apklangfactory.addons.AddOnImpl;
import com.liskovsoft.keyboardaddons.apkkbdfactory.addons.AddOn;
import com.liskovsoft.keyboardaddons.apkkbdfactory.addons.AddOnImpl;
public class ApkKeyboardAddOnAndBuilder extends AddOnImpl implements KeyboardBuilder {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.keyboardaddons.apklangfactory.keyboards;
package com.liskovsoft.keyboardaddons.apkkbdfactory.keyboards;
import android.content.Context;
import android.content.SharedPreferences;
@@ -25,9 +25,9 @@ import android.util.AttributeSet;
import com.liskovsoft.keyboardaddons.KeyboardBuilder;
import com.liskovsoft.keyboardaddons.KeyboardFactory;
import com.liskovsoft.keyboardaddons.apklangfactory.addons.AddOn;
import com.liskovsoft.keyboardaddons.apklangfactory.addons.AddOnsFactory;
import com.liskovsoft.keyboardaddons.apklangfactory.utils.Logger;
import com.liskovsoft.keyboardaddons.apkkbdfactory.addons.AddOn;
import com.liskovsoft.keyboardaddons.apkkbdfactory.addons.AddOnsFactory;
import com.liskovsoft.keyboardaddons.apkkbdfactory.utils.Logger;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.liskovsoft.keyboardaddons.apklangfactory.utils;
package com.liskovsoft.keyboardaddons.apkkbdfactory.utils;
public class BuildConfig {
public final static boolean TESTING_BUILD = true;

View File

@@ -1,4 +1,4 @@
package com.liskovsoft.keyboardaddons.apklangfactory.utils;
package com.liskovsoft.keyboardaddons.apkkbdfactory.utils;
import android.os.Build;
import android.util.Log;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.keyboardaddons.apklangfactory.utils;
package com.liskovsoft.keyboardaddons.apkkbdfactory.utils;
public interface LogProvider {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.keyboardaddons.apklangfactory.utils;
package com.liskovsoft.keyboardaddons.apkkbdfactory.utils;
import android.support.annotation.NonNull;

View File

@@ -1,4 +1,4 @@
package com.liskovsoft.keyboardaddons.apklangfactory.utils;
package com.liskovsoft.keyboardaddons.apkkbdfactory.utils;
/**
* Doesn't do anything. For release.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.liskovsoft.keyboardaddons.apklangfactory.utils;
package com.liskovsoft.keyboardaddons.apkkbdfactory.utils;
import android.util.Xml;

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
package com.liskovsoft.keyboardaddons.apklangfactory.utils;
package com.liskovsoft.keyboardaddons.apkkbdfactory.utils;
import java.io.File;
import java.io.FileWriter;

View File

@@ -1,10 +1,10 @@
package com.liskovsoft.keyboardaddons.reslangfactory;
package com.liskovsoft.keyboardaddons.reskbdfactory;
import android.inputmethodservice.Keyboard;
import android.support.annotation.Nullable;
import com.liskovsoft.keyboardaddons.KeyboardBuilder;
public class ResKeyboardBuilder implements KeyboardBuilder {
class ResKeyboardBuilder implements KeyboardBuilder {
@Nullable
@Override
public Keyboard createKeyboard() {

View File

@@ -1,4 +1,4 @@
package com.liskovsoft.keyboardaddons.reslangfactory;
package com.liskovsoft.keyboardaddons.reskbdfactory;
import android.content.Context;
import android.content.res.Resources;
@@ -7,7 +7,6 @@ import android.support.annotation.Nullable;
import com.liskovsoft.keyboardaddons.KeyboardBuilder;
import com.liskovsoft.keyboardaddons.KeyboardFactory;
import com.liskovsoft.keyboardaddons.KeyboardInfo;
import com.liskovsoft.leankeykeyboard.R;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.liskovsoft.keyboardaddons.reslangfactory;
package com.liskovsoft.keyboardaddons.reskbdfactory;
import android.content.Context;
import android.content.SharedPreferences;

View File

@@ -1,10 +1,10 @@
package com.liskovsoft.keyboardaddons.reslangfactory;
package com.liskovsoft.keyboardaddons.reskbdfactory;
import com.liskovsoft.keyboardaddons.KeyboardInfo;
import java.util.List;
public class ResKeyboardManager {
class ResKeyboardManager {
public List<KeyboardInfo> getAllKeyboardInfos() {
return null;
}

View File

@@ -16,7 +16,7 @@ import android.view.Window;
import android.view.WindowManager;
import android.widget.CheckedTextView;
import com.liskovsoft.keyboardaddons.KeyboardInfo;
import com.liskovsoft.keyboardaddons.reslangfactory.ResKeyboardInfo;
import com.liskovsoft.keyboardaddons.reskbdfactory.ResKeyboardInfo;
import com.liskovsoft.leankeykeyboard.R;
import java.util.ArrayList;

View File

@@ -7,6 +7,7 @@ import android.preference.PreferenceManager;
public final class LeanKeyPreferences {
private static final String APP_RUN_ONCE = "appRunOnce";
private static final String BOOTSTRAP_SELECTED_LANGUAGE = "bootstrapSelectedLanguage";
private static final String APP_KEYBOARD_INDEX = "appKeyboardIndex";
private static LeanKeyPreferences sInstance;
private final Context mContext;
private SharedPreferences mPrefs;
@@ -42,4 +43,15 @@ public final class LeanKeyPreferences {
String name = mPrefs.getString(BOOTSTRAP_SELECTED_LANGUAGE, "");
return name;
}
public int getKeyboardIndex() {
int idx = mPrefs.getInt(APP_KEYBOARD_INDEX, 0);
return idx;
}
public void setKeyboardIndex(int idx) {
mPrefs.edit()
.putInt(APP_KEYBOARD_INDEX, idx)
.apply();
}
}

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="additional_languages">
<item>Swedish|sv</item>
<item>Arabic|ar</item>
<item>Bulgarian|bg</item>
<item>Dutch|nl</item>

View File

@@ -56,7 +56,8 @@
<Row android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyEdgeFlags="left" android:keyLabel="@string/keyboardview_keycode_mode_change" android:keyIcon="@drawable/ic_ime_symbols" />
<Key android:codes="-1" android:keyLabel="@string/keyboardview_keycode_shift" android:keyIcon="@drawable/ic_ime_shift_off" />
<Key android:keyWidth="@dimen/space_key_width" android:codes="32" android:keyLabel="@string/keyboardview_keycode_space" android:keyIcon="@drawable/ic_ime_space" />
<Key android:codes="-9" android:keyLabel="@string/keyboardview_keycode_lang" android:keyIcon="@drawable/ic_ime_world" />
<Key android:keyWidth="@dimen/space_key_width" android:codes="32" android:keyLabel="@string/keyboardview_keycode_space" android:keyIcon="@drawable/ic_ime_space_sv" />
<Key android:codes="-3" android:keyLabel="@string/keyboardview_keycode_left" android:keyIcon="@drawable/ic_ime_left_arrow" />
<Key android:codes="-4" android:keyEdgeFlags="right" android:keyLabel="@string/keyboardview_keycode_right" android:keyIcon="@drawable/ic_ime_right_arrow" />
</Row>