forked from extern/Unexpected-Keyboard
Reference the "special key font" in the Theme object
Remove the last cast of the context.
This commit is contained in:
parent
15ce200ce3
commit
93704cca0a
@ -17,7 +17,7 @@ public class EmojiKeyButton extends Button
|
|||||||
_key = KeyValue.getKeyByName(attrs.getAttributeValue(null, "key"));
|
_key = KeyValue.getKeyByName(attrs.getAttributeValue(null, "key"));
|
||||||
setText(_key.symbol);
|
setText(_key.symbol);
|
||||||
if ((_key.flags & KeyValue.FLAG_KEY_FONT) != 0)
|
if ((_key.flags & KeyValue.FLAG_KEY_FONT) != 0)
|
||||||
setTypeface(((Keyboard2)context).getSpecialKeyFont());
|
setTypeface(Theme.getSpecialKeyFont(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
|
@ -31,7 +31,6 @@ public class Keyboard2 extends InputMethodService
|
|||||||
private Keyboard2View _keyboardView;
|
private Keyboard2View _keyboardView;
|
||||||
private int _currentTextLayout;
|
private int _currentTextLayout;
|
||||||
private ViewGroup _emojiPane = null;
|
private ViewGroup _emojiPane = null;
|
||||||
private Typeface _specialKeyFont = null;
|
|
||||||
|
|
||||||
private Config _config;
|
private Config _config;
|
||||||
|
|
||||||
@ -52,7 +51,6 @@ public class Keyboard2 extends InputMethodService
|
|||||||
public void onCreate()
|
public void onCreate()
|
||||||
{
|
{
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
_specialKeyFont = Typeface.createFromAsset(getAssets(), "fonts/keys.ttf");
|
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.settings, false);
|
PreferenceManager.setDefaultValues(this, R.xml.settings, false);
|
||||||
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
|
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
|
||||||
Config.initGlobalConfig(this, new KeyEventHandler(this.new Receiver()));
|
Config.initGlobalConfig(this, new KeyEventHandler(this.new Receiver()));
|
||||||
@ -61,11 +59,6 @@ public class Keyboard2 extends InputMethodService
|
|||||||
_keyboardView.reset();
|
_keyboardView.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Typeface getSpecialKeyFont()
|
|
||||||
{
|
|
||||||
return (_specialKeyFont);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<InputMethodSubtype> getEnabledSubtypes(InputMethodManager imm)
|
private List<InputMethodSubtype> getEnabledSubtypes(InputMethodManager imm)
|
||||||
{
|
{
|
||||||
String pkg = getPackageName();
|
String pkg = getPackageName();
|
||||||
|
@ -35,9 +35,9 @@ public class Theme
|
|||||||
keyDownBgPaint.setColor(res.getColor(R.color.key_down_bg));
|
keyDownBgPaint.setColor(res.getColor(R.color.key_down_bg));
|
||||||
_keyLabelPaint = initLabelPaint(Paint.Align.CENTER, null);
|
_keyLabelPaint = initLabelPaint(Paint.Align.CENTER, null);
|
||||||
_keySubLabelPaint = initLabelPaint(Paint.Align.LEFT, null);
|
_keySubLabelPaint = initLabelPaint(Paint.Align.LEFT, null);
|
||||||
Typeface specialKeysFont = ((Keyboard2)context).getSpecialKeyFont();
|
Typeface specialKeyFont = getSpecialKeyFont(context);
|
||||||
_specialKeyLabelPaint = initLabelPaint(Paint.Align.CENTER, specialKeysFont);
|
_specialKeyLabelPaint = initLabelPaint(Paint.Align.CENTER, specialKeyFont);
|
||||||
_specialKeySubLabelPaint = initLabelPaint(Paint.Align.LEFT, specialKeysFont);
|
_specialKeySubLabelPaint = initLabelPaint(Paint.Align.LEFT, specialKeyFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Paint labelPaint(boolean special_font)
|
public Paint labelPaint(boolean special_font)
|
||||||
@ -61,4 +61,15 @@ public class Theme
|
|||||||
paint.setTypeface(font);
|
paint.setTypeface(font);
|
||||||
return (paint);
|
return (paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Typeface _specialKeyFont = null;
|
||||||
|
|
||||||
|
static public Typeface getSpecialKeyFont(Context context)
|
||||||
|
{
|
||||||
|
if (_specialKeyFont == null)
|
||||||
|
{
|
||||||
|
_specialKeyFont = Typeface.createFromAsset(context.getAssets(), "fonts/keys.ttf");
|
||||||
|
}
|
||||||
|
return _specialKeyFont;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user