aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java37
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java3
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java10
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java2
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsFragment.java5
-rw-r--r--java/src/com/android/inputmethod/latin/Utils.java20
-rw-r--r--java/src/com/android/inputmethod/latin/setup/SetupActivity.java15
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java7
8 files changed, 64 insertions, 35 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
index c0028e4cf..73896dfd3 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
@@ -64,6 +64,9 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
*/
private int mEdgeSlop;
+ /** The most recently set keyboard mode. */
+ private int mLastKeyboardMode;
+
public static void init(final InputMethodService inputMethod) {
sInstance.initInternal(inputMethod);
}
@@ -113,16 +116,19 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
if (mView == null) {
return;
}
-
if (mAccessibilityNodeProvider != null) {
mAccessibilityNodeProvider.setKeyboard();
}
+ final int keyboardMode = mView.getKeyboard().mId.mMode;
// Since this method is called even when accessibility is off, make sure
- // to check the state before announcing anything.
- if (AccessibilityUtils.getInstance().isAccessibilityEnabled()) {
- announceKeyboardMode();
+ // to check the state before announcing anything. Also, don't announce
+ // changes within the same mode.
+ if (AccessibilityUtils.getInstance().isAccessibilityEnabled()
+ && (mLastKeyboardMode != keyboardMode)) {
+ announceKeyboardMode(keyboardMode);
}
+ mLastKeyboardMode = keyboardMode;
}
/**
@@ -132,25 +138,24 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
if (mView == null) {
return;
}
-
announceKeyboardHidden();
+ mLastKeyboardMode = -1;
}
/**
* Announces which type of keyboard is being displayed. If the keyboard type
* is unknown, no announcement is made.
+ *
+ * @param mode The new keyboard mode.
*/
- private void announceKeyboardMode() {
- final Keyboard keyboard = mView.getKeyboard();
- final int resId = KEYBOARD_MODE_RES_IDS.get(keyboard.mId.mMode);
+ private void announceKeyboardMode(int mode) {
+ final int resId = KEYBOARD_MODE_RES_IDS.get(mode);
if (resId == 0) {
return;
}
-
final Context context = mView.getContext();
final String keyboardMode = context.getString(resId);
final String text = context.getString(R.string.announce_keyboard_mode, keyboardMode);
-
sendWindowStateChanged(text);
}
@@ -167,7 +172,7 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
/**
* Sends a window state change event with the specified text.
*
- * @param text
+ * @param text The text to send with the event.
*/
private void sendWindowStateChanged(final String text) {
final AccessibilityEvent stateChange = AccessibilityEvent.obtain(
@@ -195,7 +200,6 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
if (mView == null) {
return null;
}
-
return getAccessibilityNodeProvider();
}
@@ -248,11 +252,9 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
case MotionEvent.ACTION_HOVER_MOVE:
if (key != previousKey) {
return onTransitionKey(key, previousKey, event);
- } else {
- return onHoverKey(key, event);
}
+ return onHoverKey(key, event);
}
-
return false;
}
@@ -294,18 +296,13 @@ public final class AccessibleKeyboardViewProxy extends AccessibilityDelegateComp
private boolean onTransitionKey(final Key currentKey, final Key previousKey,
final MotionEvent event) {
final int savedAction = event.getAction();
-
event.setAction(MotionEvent.ACTION_HOVER_EXIT);
onHoverKey(previousKey, event);
-
event.setAction(MotionEvent.ACTION_HOVER_ENTER);
onHoverKey(currentKey, event);
-
event.setAction(MotionEvent.ACTION_HOVER_MOVE);
final boolean handled = onHoverKey(currentKey, event);
-
event.setAction(savedAction);
-
return handled;
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
index ab851bd64..8ae1b8881 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
@@ -24,7 +24,6 @@ import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.util.Xml;
-import android.view.InflateException;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.keyboard.Key;
@@ -750,7 +749,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
private void endRow(final KeyboardRow row) {
if (mCurrentRow == null) {
- throw new InflateException("orphan end row tag");
+ throw new RuntimeException("orphan end row tag");
}
if (mRightEdgeKey != null) {
mRightEdgeKey.markAsRightEdge(mParams);
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
index d0b382e35..7ec1c9406 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
@@ -21,7 +21,6 @@ import android.content.res.Resources;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.CollectionUtils;
-import com.android.inputmethod.latin.R;
import java.util.HashMap;
@@ -61,13 +60,14 @@ public final class KeyboardTextsSet {
}
}
- public void loadStringResources(Context context) {
- loadStringResourcesInternal(context, RESOURCE_NAMES, R.string.english_ime_name);
+ public void loadStringResources(final Context context) {
+ final int referenceId = context.getApplicationInfo().labelRes;
+ loadStringResourcesInternal(context, RESOURCE_NAMES, referenceId);
}
@UsedForTesting
- void loadStringResourcesInternal(Context context, final String[] resourceNames,
- int referenceId) {
+ void loadStringResourcesInternal(final Context context, final String[] resourceNames,
+ final int referenceId) {
final Resources res = context.getResources();
final String packageName = res.getResourcePackageName(referenceId);
for (final String resName : resourceNames) {
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index e3650d9cc..ea7ee6d5b 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2526,7 +2526,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
final CharSequence[] items = new CharSequence[] {
// TODO: Should use new string "Select active input modes".
getString(R.string.language_selection_title),
- getString(R.string.english_ime_settings),
+ getString(Utils.getAcitivityTitleResId(this, SettingsActivity.class)),
};
final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
@Override
diff --git a/java/src/com/android/inputmethod/latin/SettingsFragment.java b/java/src/com/android/inputmethod/latin/SettingsFragment.java
index 4fdd83911..928141c32 100644
--- a/java/src/com/android/inputmethod/latin/SettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/SettingsFragment.java
@@ -69,6 +69,11 @@ public final class SettingsFragment extends InputMethodSettingsFragment
setInputMethodSettingsCategoryTitle(R.string.language_selection_title);
setSubtypeEnablerTitle(R.string.select_language);
addPreferencesFromResource(R.xml.prefs);
+ final PreferenceScreen preferenceScreen = getPreferenceScreen();
+ if (preferenceScreen != null) {
+ preferenceScreen.setTitle(
+ Utils.getAcitivityTitleResId(getActivity(), SettingsActivity.class));
+ }
final Resources res = getResources();
final Context context = getActivity();
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java
index 7a604dc6a..aff5d17d7 100644
--- a/java/src/com/android/inputmethod/latin/Utils.java
+++ b/java/src/com/android/inputmethod/latin/Utils.java
@@ -16,8 +16,13 @@
package com.android.inputmethod.latin;
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.inputmethodservice.InputMethodService;
import android.net.Uri;
import android.os.AsyncTask;
@@ -45,6 +50,8 @@ import java.util.Date;
import java.util.Locale;
public final class Utils {
+ private static final String TAG = Utils.class.getSimpleName();
+
private Utils() {
// This utility class is not publicly instantiable.
}
@@ -453,4 +460,17 @@ public final class Utils {
if (TextUtils.isEmpty(info)) return null;
return info;
}
+
+ public static int getAcitivityTitleResId(Context context, Class<? extends Activity> cls) {
+ final ComponentName cn = new ComponentName(context, cls);
+ try {
+ final ActivityInfo ai = context.getPackageManager().getActivityInfo(cn, 0);
+ if (ai != null) {
+ return ai.labelRes;
+ }
+ } catch (NameNotFoundException e) {
+ Log.e(TAG, "Failed to get settings activity title res id.", e);
+ }
+ return 0;
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
index 7f66c6d3e..15d0bac37 100644
--- a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
+++ b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
@@ -112,12 +112,13 @@ public final class SetupActivity extends Activity {
// TODO: Use sans-serif-thin font family depending on the system locale white list and
// the SDK version.
final TextView titleView = (TextView)findViewById(R.id.setup_title);
- titleView.setText(getString(R.string.setup_title, getString(R.string.english_ime_name)));
+ final int appName = getApplicationInfo().labelRes;
+ titleView.setText(getString(R.string.setup_title, getString(appName)));
mStepIndicatorView = (SetupStepIndicatorView)findViewById(R.id.setup_step_indicator);
final SetupStep step1 = new SetupStep(findViewById(R.id.setup_step1),
- R.string.setup_step1_title, R.string.setup_step1_instruction,
+ appName, R.string.setup_step1_title, R.string.setup_step1_instruction,
R.drawable.ic_settings_language, R.string.language_settings);
step1.setAction(new Runnable() {
@Override
@@ -129,7 +130,7 @@ public final class SetupActivity extends Activity {
mSetupSteps.addStep(STEP_1, step1);
final SetupStep step2 = new SetupStep(findViewById(R.id.setup_step2),
- R.string.setup_step2_title, R.string.setup_step2_instruction,
+ appName, R.string.setup_step2_title, R.string.setup_step2_instruction,
0 /* actionIcon */, R.string.select_input_method);
step2.setAction(new Runnable() {
@Override
@@ -142,7 +143,7 @@ public final class SetupActivity extends Activity {
mSetupSteps.addStep(STEP_2, step2);
final SetupStep step3 = new SetupStep(findViewById(R.id.setup_step3),
- R.string.setup_step3_title, 0 /* instruction */,
+ appName, R.string.setup_step3_title, 0 /* instruction */,
R.drawable.sym_keyboard_language_switch, R.string.setup_step3_instruction);
step3.setAction(new Runnable() {
@Override
@@ -290,11 +291,11 @@ public final class SetupActivity extends Activity {
private final TextView mActionLabel;
private Runnable mAction;
- public SetupStep(final View rootView, final int title, final int instruction,
- final int actionIcon, final int actionLabel) {
+ public SetupStep(final View rootView, final int appName, final int title,
+ final int instruction, final int actionIcon, final int actionLabel) {
mRootView = rootView;
final Resources res = rootView.getResources();
- final String applicationName = res.getString(R.string.english_ime_name);
+ final String applicationName = res.getString(appName);
final TextView titleView = (TextView)rootView.findViewById(R.id.setup_step_title);
titleView.setText(res.getString(title, applicationName));
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java
index 9606b0352..5ce9d8e47 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java
@@ -18,8 +18,10 @@ package com.android.inputmethod.latin.spellcheck;
import android.os.Bundle;
import android.preference.PreferenceFragment;
+import android.preference.PreferenceScreen;
import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.Utils;
/**
* Preference screen.
@@ -35,5 +37,10 @@ public final class SpellCheckerSettingsFragment extends PreferenceFragment {
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
addPreferencesFromResource(R.xml.spell_checker_settings);
+ final PreferenceScreen preferenceScreen = getPreferenceScreen();
+ if (preferenceScreen != null) {
+ preferenceScreen.setTitle(Utils.getAcitivityTitleResId(
+ getActivity(), SpellCheckerSettingsActivity.class));
+ }
}
}