-
Notifications
You must be signed in to change notification settings - Fork 215
/
BaseKeyboard.java
49 lines (41 loc) · 1.83 KB
/
BaseKeyboard.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.mozilla.vrbrowser.ui.keyboards;
import android.content.Context;
import android.view.inputmethod.EditorInfo;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement;
import org.mozilla.vrbrowser.utils.StringUtils;
import java.util.Locale;
import java.util.regex.Pattern;
public abstract class BaseKeyboard implements KeyboardInterface {
protected Context mContext;
BaseKeyboard(Context aContext) {
mContext = aContext;
}
@Override
public String getEnterKeyText(int aIMEOptions, String aComposingText) {
Locale locale = getLocale();
switch (aIMEOptions & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
case EditorInfo.IME_ACTION_GO:
return StringUtils.getStringByLocale(mContext, R.string.keyboard_go_label, locale);
case EditorInfo.IME_ACTION_NEXT:
return StringUtils.getStringByLocale(mContext, R.string.keyboard_next_label, locale);
case EditorInfo.IME_ACTION_SEARCH:
return StringUtils.getStringByLocale(mContext, R.string.keyboard_search_label, locale);
case EditorInfo.IME_ACTION_SEND:
return StringUtils.getStringByLocale(mContext, R.string.keyboard_send_label, locale);
default:
return StringUtils.getStringByLocale(mContext, R.string.keyboard_enter_label, locale);
}
}
@Override
public String getComposingText(String aComposing, String aCode) {
return aComposing.replaceFirst(Pattern.quote(aCode), "");
}
@Override
public String getModeChangeKeyText() {
return mContext.getString(R.string.keyboard_mode_change);
}
public float getAlphabeticKeyboardWidth() {
return WidgetPlacement.dpDimension(mContext, R.dimen.keyboard_alphabetic_width);
}
}