gecko/mobile/android/base/InputMethods.java

86 lines
4.2 KiB
Java
Raw Normal View History

/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko;
import android.content.Context;
import android.os.Build;
import android.provider.Settings.Secure;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import java.util.Collection;
import java.util.Locale;
final class InputMethods {
public static final String METHOD_ANDROID_LATINIME = "com.android.inputmethod.latin/.LatinIME";
public static final String METHOD_ATOK = "com.justsystems.atokmobile.service/.AtokInputMethodService";
public static final String METHOD_GOOGLE_JAPANESE_INPUT = "com.google.android.inputmethod.japanese/.MozcService";
public static final String METHOD_GOOGLE_LATINIME = "com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME";
public static final String METHOD_HTC_TOUCH_INPUT = "com.htc.android.htcime/.HTCIMEService";
public static final String METHOD_IWNN = "jp.co.omronsoft.iwnnime.ml/.standardcommon.IWnnLanguageSwitcher";
public static final String METHOD_OPENWNN_PLUS = "com.owplus.ime.openwnnplus/.OpenWnnJAJP";
public static final String METHOD_SAMSUNG = "com.sec.android.inputmethod/.SamsungKeypad";
public static final String METHOD_SIMEJI = "com.adamrocker.android.input.simeji/.OpenWnnSimeji";
public static final String METHOD_SWIFTKEY = "com.touchtype.swiftkey/com.touchtype.KeyboardService";
public static final String METHOD_SWYPE = "com.swype.android.inputmethod/.SwypeInputMethod";
public static final String METHOD_SWYPE_BETA = "com.nuance.swype.input/.IME";
public static final String METHOD_TOUCHPAL_KEYBOARD = "com.cootek.smartinputv5/com.cootek.smartinput5.TouchPalIME";
private InputMethods() {}
public static String getCurrentInputMethod(Context context) {
String inputMethod = Secure.getString(context.getContentResolver(), Secure.DEFAULT_INPUT_METHOD);
return (inputMethod != null ? inputMethod : "");
}
public static InputMethodInfo getInputMethodInfo(Context context, String inputMethod) {
InputMethodManager imm = getInputMethodManager(context);
Collection<InputMethodInfo> infos = imm.getEnabledInputMethodList();
for (InputMethodInfo info : infos) {
if (info.getId().equals(inputMethod)) {
return info;
}
}
return null;
}
public static InputMethodManager getInputMethodManager(Context context) {
return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
}
public static boolean needsSoftResetWorkaround(String inputMethod) {
// Stock latin IME on Android 4.2 and above
return Build.VERSION.SDK_INT >= 17 && (METHOD_ANDROID_LATINIME.equals(inputMethod) ||
METHOD_GOOGLE_LATINIME.equals(inputMethod));
}
public static boolean shouldCommitCharAsKey(String inputMethod) {
return METHOD_HTC_TOUCH_INPUT.equals(inputMethod);
}
public static boolean shouldDisableUrlBarUpdate(Context context) {
String inputMethod = getCurrentInputMethod(context);
return METHOD_HTC_TOUCH_INPUT.equals(inputMethod);
}
Bug 871645 - Consolidate naming of URL bar variables and resources. r=lucasr * * * Bug 871645 - (Part 1) Rename "awesome" things "url" things in BrowserToolbar * * * Bug 871645 - (Part 2) Rename ic_awesomebar_* icon resources * * * Bug 871645 - (Part 3) Rename shouldDelayAwesomebarUpdate * * * Bug 871645 - (Part 4) Rename favicon dimensions that affect generic favicons * * * Bug 871645 - (Part 5) Rename awesome_* string entities * * * Bug 871645 - (Part 6) Rename color resources * * * Bug 871645 - (Part 7) Rename address_bar things * * * Bug 871645 - (Part 8) Rename addressBar things in BrowserToolbar * * * Bug 871645 - (Part 9) Rename AddressBar styles --HG-- rename : mobile/android/base/resources/color/awesome_bar_title.xml => mobile/android/base/resources/color/url_bar_title.xml rename : mobile/android/base/resources/color/awesome_bar_title_hint.xml => mobile/android/base/resources/color/url_bar_title_hint.xml rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_go.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_go.png rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_reader.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_reader.png rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_search.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_search.png rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_star.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_star.png rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_tab.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_tab.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_bg_shadow.png => mobile/android/base/resources/drawable-hdpi/url_bar_bg_shadow.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_url_default.9.png => mobile/android/base/resources/drawable-hdpi/url_bar_entry_default.9.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_url_default_pb.9.png => mobile/android/base/resources/drawable-hdpi/url_bar_entry_default_pb.9.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_url_pressed.9.png => mobile/android/base/resources/drawable-hdpi/url_bar_entry_pressed.9.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_url_pressed_pb.9.png => mobile/android/base/resources/drawable-hdpi/url_bar_entry_pressed_pb.9.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_go.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_go.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_reader.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_reader.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_search.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_search.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_star.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_star.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_tab.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_tab.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_bg_shadow.png => mobile/android/base/resources/drawable-mdpi/url_bar_bg_shadow.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_url_default.9.png => mobile/android/base/resources/drawable-mdpi/url_bar_entry_default.9.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_url_default_pb.9.png => mobile/android/base/resources/drawable-mdpi/url_bar_entry_default_pb.9.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_url_pressed.9.png => mobile/android/base/resources/drawable-mdpi/url_bar_entry_pressed.9.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_url_pressed_pb.9.png => mobile/android/base/resources/drawable-mdpi/url_bar_entry_pressed_pb.9.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_go.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_go.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_reader.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_reader.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_search.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_search.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_star.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_star.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_tab.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_tab.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_bg_shadow.png => mobile/android/base/resources/drawable-xhdpi/url_bar_bg_shadow.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_url_default.9.png => mobile/android/base/resources/drawable-xhdpi/url_bar_entry_default.9.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_url_default_pb.9.png => mobile/android/base/resources/drawable-xhdpi/url_bar_entry_default_pb.9.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_url_pressed.9.png => mobile/android/base/resources/drawable-xhdpi/url_bar_entry_pressed.9.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_url_pressed_pb.9.png => mobile/android/base/resources/drawable-xhdpi/url_bar_entry_pressed_pb.9.png rename : mobile/android/base/resources/drawable/address_bar_bg.xml => mobile/android/base/resources/drawable/url_bar_bg.xml rename : mobile/android/base/resources/drawable/address_bar_bg_shadow_repeat.xml => mobile/android/base/resources/drawable/url_bar_bg_shadow_repeat.xml rename : mobile/android/base/resources/drawable/address_bar_url.xml => mobile/android/base/resources/drawable/url_bar_entry.xml rename : mobile/android/base/resources/drawable/address_bar_nav_button.xml => mobile/android/base/resources/drawable/url_bar_nav_button.xml rename : mobile/android/base/resources/drawable/address_bar_right_edge.xml => mobile/android/base/resources/drawable/url_bar_right_edge.xml
2013-05-28 08:48:27 -07:00
public static boolean shouldDelayUrlBarUpdate(Context context) {
String inputMethod = getCurrentInputMethod(context);
return METHOD_SAMSUNG.equals(inputMethod) ||
METHOD_SWIFTKEY.equals(inputMethod);
}
public static boolean isGestureKeyboard(Context context) {
// SwiftKey is a gesture keyboard, but it doesn't seem to need any special-casing
// to do AwesomeBar auto-spacing.
String inputMethod = getCurrentInputMethod(context);
return (Build.VERSION.SDK_INT >= 17 && (METHOD_ANDROID_LATINIME.equals(inputMethod) ||
METHOD_GOOGLE_LATINIME.equals(inputMethod))) ||
METHOD_SWYPE.equals(inputMethod) ||
METHOD_SWYPE_BETA.equals(inputMethod) ||
METHOD_TOUCHPAL_KEYBOARD.equals(inputMethod);
}
}