diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
3 files changed, 46 insertions, 36 deletions
diff --git a/java/src/com/android/inputmethod/latin/SettingsFragment.java b/java/src/com/android/inputmethod/latin/SettingsFragment.java index a96c997c8..79036c276 100644 --- a/java/src/com/android/inputmethod/latin/SettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/SettingsFragment.java @@ -77,10 +77,13 @@ public final class SettingsFragment extends InputMethodSettingsFragment final Resources res = getResources(); final Context context = getActivity(); - // When we are called from the Settings application but we are not already running, the - // {@link SubtypeLocale} class may not have been initialized. It is safe to call - // {@link SubtypeLocale#init(Context)} multiple times. + // When we are called from the Settings application but we are not already running, some + // singleton and utility classes may not have been initialized. We have to call + // initialization method of these classes here. See {@link LatinIME#onCreate()}. + SubtypeSwitcher.init(context); SubtypeLocale.init(context); + AudioAndHapticFeedbackManager.init(context); + mVoicePreference = (ListPreference) findPreference(Settings.PREF_VOICE_MODE); mShowCorrectionSuggestionsPreference = (ListPreference) findPreference(Settings.PREF_SHOW_SUGGESTIONS_SETTING); diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index 2f9e34ff1..bef8a3cf1 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -80,6 +80,7 @@ public final class SubtypeSwitcher { public static void init(final Context context) { SubtypeLocale.init(context); + RichInputMethodManager.init(context); sInstance.initialize(context); } @@ -87,10 +88,13 @@ public final class SubtypeSwitcher { // Intentional empty constructor for singleton. } - private void initialize(final Context service) { - mResources = service.getResources(); + private void initialize(final Context context) { + if (mResources != null) { + return; + } + mResources = context.getResources(); mRichImm = RichInputMethodManager.getInstance(); - mConnectivityManager = (ConnectivityManager) service.getSystemService( + mConnectivityManager = (ConnectivityManager) context.getSystemService( Context.CONNECTIVITY_SERVICE); mNoLanguageSubtype = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( SubtypeLocale.NO_LANGUAGE, SubtypeLocale.QWERTY); diff --git a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java index 15d0bac37..cb1de1834 100644 --- a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java +++ b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java @@ -20,7 +20,6 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.res.Resources; -import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Message; @@ -109,17 +108,16 @@ public final class SetupActivity extends Activity { return; } - // 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); - final int appName = getApplicationInfo().labelRes; - titleView.setText(getString(R.string.setup_title, getString(appName))); + final String applicationName = getResources().getString(getApplicationInfo().labelRes); + titleView.setText(getString(R.string.setup_steps_title, applicationName)); mStepIndicatorView = (SetupStepIndicatorView)findViewById(R.id.setup_step_indicator); - final SetupStep step1 = new SetupStep(findViewById(R.id.setup_step1), - appName, R.string.setup_step1_title, R.string.setup_step1_instruction, - R.drawable.ic_settings_language, R.string.language_settings); + final SetupStep step1 = new SetupStep(applicationName, + (TextView)findViewById(R.id.setup_step1_bullet), findViewById(R.id.setup_step1), + R.string.setup_step1_title, R.string.setup_step1_instruction, + R.drawable.ic_setup_step1, R.string.setup_step1_action); step1.setAction(new Runnable() { @Override public void run() { @@ -129,9 +127,10 @@ public final class SetupActivity extends Activity { }); mSetupSteps.addStep(STEP_1, step1); - final SetupStep step2 = new SetupStep(findViewById(R.id.setup_step2), - appName, R.string.setup_step2_title, R.string.setup_step2_instruction, - 0 /* actionIcon */, R.string.select_input_method); + final SetupStep step2 = new SetupStep(applicationName, + (TextView)findViewById(R.id.setup_step2_bullet), findViewById(R.id.setup_step2), + R.string.setup_step2_title, R.string.setup_step2_instruction, + R.drawable.ic_setup_step2, R.string.setup_step2_action); step2.setAction(new Runnable() { @Override public void run() { @@ -142,9 +141,10 @@ public final class SetupActivity extends Activity { }); mSetupSteps.addStep(STEP_2, step2); - final SetupStep step3 = new SetupStep(findViewById(R.id.setup_step3), - appName, R.string.setup_step3_title, 0 /* instruction */, - R.drawable.sym_keyboard_language_switch, R.string.setup_step3_instruction); + final SetupStep step3 = new SetupStep(applicationName, + (TextView)findViewById(R.id.setup_step3_bullet), findViewById(R.id.setup_step3), + R.string.setup_step3_title, R.string.setup_step3_instruction, + R.drawable.ic_setup_step3, R.string.setup_step3_action); step3.setAction(new Runnable() { @Override public void run() { @@ -287,20 +287,26 @@ public final class SetupActivity extends Activity { } static final class SetupStep implements View.OnClickListener { - private final View mRootView; + private final View mStepView; + private final TextView mBulletView; + private final int mActivatedColor; + private final int mDeactivatedColor; private final TextView mActionLabel; private Runnable mAction; - 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(appName); + public SetupStep(final String applicationName, final TextView bulletView, + final View stepView, final int title, final int instruction, final int actionIcon, + final int actionLabel) { + mStepView = stepView; + mBulletView = bulletView; + final Resources res = stepView.getResources(); + mActivatedColor = res.getColor(R.color.setup_text_action); + mDeactivatedColor = res.getColor(R.color.setup_text_dark); - final TextView titleView = (TextView)rootView.findViewById(R.id.setup_step_title); + final TextView titleView = (TextView)mStepView.findViewById(R.id.setup_step_title); titleView.setText(res.getString(title, applicationName)); - final TextView instructionView = (TextView)rootView.findViewById( + final TextView instructionView = (TextView)mStepView.findViewById( R.id.setup_step_instruction); if (instruction == 0) { instructionView.setVisibility(View.GONE); @@ -308,23 +314,20 @@ public final class SetupActivity extends Activity { instructionView.setText(res.getString(instruction, applicationName)); } - mActionLabel = (TextView)rootView.findViewById(R.id.setup_step_action_label); + mActionLabel = (TextView)mStepView.findViewById(R.id.setup_step_action_label); mActionLabel.setText(res.getString(actionLabel)); if (actionIcon == 0) { final int paddingEnd = ViewCompatUtils.getPaddingEnd(mActionLabel); ViewCompatUtils.setPaddingRelative(mActionLabel, paddingEnd, 0, paddingEnd, 0); } else { - final int overrideColor = res.getColor(R.color.setup_text_action); - final Drawable icon = res.getDrawable(actionIcon); - icon.setColorFilter(overrideColor, PorterDuff.Mode.MULTIPLY); - icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); - TextViewCompatUtils.setCompoundDrawablesRelative( - mActionLabel, icon, null, null, null); + TextViewCompatUtils.setCompoundDrawablesRelativeWithIntrinsicBounds( + mActionLabel, res.getDrawable(actionIcon), null, null, null); } } public void setEnabled(final boolean enabled) { - mRootView.setVisibility(enabled ? View.VISIBLE : View.GONE); + mStepView.setVisibility(enabled ? View.VISIBLE : View.GONE); + mBulletView.setTextColor(enabled ? mActivatedColor : mDeactivatedColor); } public void setAction(final Runnable action) { |