am 63584323
: Add themeId to Keyboard
* commit '63584323cab56c76debf6bb000621f2c605329a9': Add themeId to Keyboard
This commit is contained in:
commit
cc4d71a062
11 changed files with 31 additions and 2 deletions
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<declare-styleable name="KeyboardTheme">
|
<declare-styleable name="KeyboardTheme">
|
||||||
|
<attr name="themeId" format="integer" />
|
||||||
<!-- Keyboard style -->
|
<!-- Keyboard style -->
|
||||||
<attr name="keyboardStyle" format="reference" />
|
<attr name="keyboardStyle" format="reference" />
|
||||||
<!-- LatinKeyboard style -->
|
<!-- LatinKeyboard style -->
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<style name="KeyboardTheme.HighContrast" parent="KeyboardIcons">
|
<style name="KeyboardTheme.HighContrast" parent="KeyboardIcons">
|
||||||
|
<item name="themeId">1</item>
|
||||||
<item name="keyboardStyle">@style/Keyboard</item>
|
<item name="keyboardStyle">@style/Keyboard</item>
|
||||||
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
|
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.HighContrast</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.HighContrast</item>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<style name="KeyboardTheme" parent="KeyboardIcons">
|
<style name="KeyboardTheme" parent="KeyboardIcons">
|
||||||
|
<item name="themeId">0</item>
|
||||||
<item name="keyboardStyle">@style/Keyboard</item>
|
<item name="keyboardStyle">@style/Keyboard</item>
|
||||||
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
|
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView</item>
|
<item name="keyboardViewStyle">@style/KeyboardView</item>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<style name="KeyboardTheme.Gingerbread" parent="KeyboardIcons">
|
<style name="KeyboardTheme.Gingerbread" parent="KeyboardIcons">
|
||||||
|
<item name="themeId">8</item>
|
||||||
<item name="keyboardStyle">@style/Keyboard.Gingerbread</item>
|
<item name="keyboardStyle">@style/Keyboard.Gingerbread</item>
|
||||||
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
|
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.Gingerbread</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.Gingerbread</item>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<style name="KeyboardTheme.IceCreamSandwich" parent="KeyboardIcons.IceCreamSandwich">
|
<style name="KeyboardTheme.IceCreamSandwich" parent="KeyboardIcons.IceCreamSandwich">
|
||||||
|
<item name="themeId">5</item>
|
||||||
<item name="keyboardStyle">@style/Keyboard.IceCreamSandwich</item>
|
<item name="keyboardStyle">@style/Keyboard.IceCreamSandwich</item>
|
||||||
<item name="latinKeyboardStyle">@style/LatinKeyboard.IceCreamSandwich</item>
|
<item name="latinKeyboardStyle">@style/LatinKeyboard.IceCreamSandwich</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.IceCreamSandwich</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.IceCreamSandwich</item>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<style name="KeyboardTheme.Stone.Bold" parent="KeyboardIcons.Black">
|
<style name="KeyboardTheme.Stone.Bold" parent="KeyboardIcons.Black">
|
||||||
|
<item name="themeId">7</item>
|
||||||
<item name="keyboardStyle">@style/Keyboard.Stone</item>
|
<item name="keyboardStyle">@style/Keyboard.Stone</item>
|
||||||
<item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</item>
|
<item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.Stone.Bold</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.Stone.Bold</item>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<style name="KeyboardTheme.Stone" parent="KeyboardIcons.Black">
|
<style name="KeyboardTheme.Stone" parent="KeyboardIcons.Black">
|
||||||
|
<item name="themeId">6</item>
|
||||||
<item name="keyboardStyle">@style/Keyboard.Stone</item>
|
<item name="keyboardStyle">@style/Keyboard.Stone</item>
|
||||||
<item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</item>
|
<item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.Stone</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.Stone</item>
|
||||||
|
|
|
@ -84,6 +84,7 @@ public class Keyboard {
|
||||||
public static final int CODE_UNSPECIFIED = -99;
|
public static final int CODE_UNSPECIFIED = -99;
|
||||||
|
|
||||||
public final KeyboardId mId;
|
public final KeyboardId mId;
|
||||||
|
public final int mThemeId;
|
||||||
|
|
||||||
/** Total height of the keyboard, including the padding and keys */
|
/** Total height of the keyboard, including the padding and keys */
|
||||||
public final int mOccupiedHeight;
|
public final int mOccupiedHeight;
|
||||||
|
@ -121,6 +122,7 @@ public class Keyboard {
|
||||||
|
|
||||||
public Keyboard(KeyboardParams params) {
|
public Keyboard(KeyboardParams params) {
|
||||||
mId = params.mId;
|
mId = params.mId;
|
||||||
|
mThemeId = params.mThemeId;
|
||||||
mOccupiedHeight = params.mOccupiedHeight;
|
mOccupiedHeight = params.mOccupiedHeight;
|
||||||
mOccupiedWidth = params.mOccupiedWidth;
|
mOccupiedWidth = params.mOccupiedWidth;
|
||||||
mMostCommonKeyHeight = params.mMostCommonKeyHeight;
|
mMostCommonKeyHeight = params.mMostCommonKeyHeight;
|
||||||
|
@ -238,4 +240,17 @@ public class Keyboard {
|
||||||
public int[] getNearestKeys(int x, int y) {
|
public int[] getNearestKeys(int x, int y) {
|
||||||
return mProximityInfo.getNearestKeys(x, y);
|
return mProximityInfo.getNearestKeys(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String themeName(int themeId) {
|
||||||
|
// This should be aligned with theme-*.xml resource files' themeId attribute.
|
||||||
|
switch (themeId) {
|
||||||
|
case 0: return "Basic";
|
||||||
|
case 1: return "BasicHighContrast";
|
||||||
|
case 5: return "IceCreamSandwich";
|
||||||
|
case 6: return "Stone";
|
||||||
|
case 7: return "StoneBold";
|
||||||
|
case 8: return "GingerBread";
|
||||||
|
default: return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,10 +275,12 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
|
|
||||||
if (DEBUG_CACHE) {
|
if (DEBUG_CACHE) {
|
||||||
Log.d(TAG, "keyboard cache size=" + mKeyboardCache.size() + ": "
|
Log.d(TAG, "keyboard cache size=" + mKeyboardCache.size() + ": "
|
||||||
+ ((ref == null) ? "LOAD" : "GCed") + " id=" + id);
|
+ ((ref == null) ? "LOAD" : "GCed") + " id=" + id
|
||||||
|
+ " theme=" + Keyboard.themeName(keyboard.mThemeId));
|
||||||
}
|
}
|
||||||
} else if (DEBUG_CACHE) {
|
} else if (DEBUG_CACHE) {
|
||||||
Log.d(TAG, "keyboard cache size=" + mKeyboardCache.size() + ": HIT id=" + id);
|
Log.d(TAG, "keyboard cache size=" + mKeyboardCache.size() + ": HIT id=" + id
|
||||||
|
+ " theme=" + Keyboard.themeName(keyboard.mThemeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
keyboard.onAutoCorrectionStateChanged(mIsAutoCorrectionActive);
|
keyboard.onAutoCorrectionStateChanged(mIsAutoCorrectionActive);
|
||||||
|
|
|
@ -244,6 +244,10 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
||||||
|
|
||||||
mParams = params;
|
mParams = params;
|
||||||
|
|
||||||
|
final TypedArray a = context.obtainStyledAttributes(R.styleable.KeyboardTheme);
|
||||||
|
mParams.mThemeId = a.getInt(R.styleable.KeyboardTheme_themeId, 0);
|
||||||
|
a.recycle();
|
||||||
|
|
||||||
mParams.GRID_WIDTH = res.getInteger(R.integer.config_keyboard_grid_width);
|
mParams.GRID_WIDTH = res.getInteger(R.integer.config_keyboard_grid_width);
|
||||||
mParams.GRID_HEIGHT = res.getInteger(R.integer.config_keyboard_grid_height);
|
mParams.GRID_HEIGHT = res.getInteger(R.integer.config_keyboard_grid_height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import java.util.Set;
|
||||||
|
|
||||||
public class KeyboardParams {
|
public class KeyboardParams {
|
||||||
public KeyboardId mId;
|
public KeyboardId mId;
|
||||||
|
public int mThemeId;
|
||||||
|
|
||||||
/** Total height and width of the keyboard, including the paddings and keys */
|
/** Total height and width of the keyboard, including the paddings and keys */
|
||||||
public int mOccupiedHeight;
|
public int mOccupiedHeight;
|
||||||
|
|
Loading…
Reference in a new issue