diff options
Diffstat (limited to 'java/src')
7 files changed, 56 insertions, 35 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java index c34464314..4c53b528f 100644 --- a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java +++ b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java @@ -25,6 +25,7 @@ import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.Rect; +import android.graphics.Typeface; import android.os.Build; import android.os.CountDownTimer; import android.preference.PreferenceManager; @@ -34,6 +35,7 @@ import android.util.AttributeSet; import android.util.Log; import android.util.Pair; import android.util.SparseArray; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -84,6 +86,8 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange private EmojiPalettesAdapter mEmojiPalettesAdapter; private final EmojiLayoutParams mEmojiLayoutParams; + private TextView mAlphabetKeyLeft; + private TextView mAlphabetKeyRight; private TabHost mTabHost; private ViewPager mEmojiPager; private int mCurrentPagerPosition = 0; @@ -487,20 +491,23 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange deleteKey.setTag(Constants.CODE_DELETE); deleteKey.setOnTouchListener(mDeleteKeyOnTouchListener); - // alphabetKey, alphabetKey2, and spaceKey depend on {@link View.OnClickListener} as well as - // {@link View.OnTouchListener}. {@link View.OnTouchListener} is used as the trigger of - // key-press, while {@link View.OnClickListener} is used as the trigger of key-release which - // does not occur if the event is canceled by moving off the finger from the view. - final ImageView alphabetKey = (ImageView)findViewById(R.id.emoji_keyboard_alphabet); - alphabetKey.setBackgroundResource(mEmojiFunctionalKeyBackgroundId); - alphabetKey.setTag(Constants.CODE_ALPHA_FROM_EMOJI); - alphabetKey.setOnTouchListener(this); - alphabetKey.setOnClickListener(this); - final ImageView alphabetKey2 = (ImageView)findViewById(R.id.emoji_keyboard_alphabet2); - alphabetKey2.setBackgroundResource(mEmojiFunctionalKeyBackgroundId); - alphabetKey2.setTag(Constants.CODE_ALPHA_FROM_EMOJI); - alphabetKey2.setOnTouchListener(this); - alphabetKey2.setOnClickListener(this); + // {@link #mAlphabetKeyLeft}, {@link #mAlphabetKeyRight, and spaceKey depend on + // {@link View.OnClickListener} as well as {@link View.OnTouchListener}. + // {@link View.OnTouchListener} is used as the trigger of key-press, while + // {@link View.OnClickListener} is used as the trigger of key-release which does not occur + // if the event is canceled by moving off the finger from the view. + // The text on alphabet keys are set at + // {@link #startEmojiPalettes(String,int,float,Typeface)}. + mAlphabetKeyLeft = (TextView)findViewById(R.id.emoji_keyboard_alphabet_left); + mAlphabetKeyLeft.setBackgroundResource(mEmojiFunctionalKeyBackgroundId); + mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI); + mAlphabetKeyLeft.setOnTouchListener(this); + mAlphabetKeyLeft.setOnClickListener(this); + mAlphabetKeyRight = (TextView)findViewById(R.id.emoji_keyboard_alphabet_right); + mAlphabetKeyRight.setBackgroundResource(mEmojiFunctionalKeyBackgroundId); + mAlphabetKeyRight.setTag(Constants.CODE_ALPHA_FROM_EMOJI); + mAlphabetKeyRight.setOnTouchListener(this); + mAlphabetKeyRight.setOnClickListener(this); final ImageView spaceKey = (ImageView)findViewById(R.id.emoji_keyboard_space); spaceKey.setBackgroundResource(mKeyBackgroundId); spaceKey.setTag(Constants.CODE_SPACE); @@ -627,10 +634,20 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange // TODO: } - public void startEmojiPalettes() { + // Hack: These parameters are hacky. + public void startEmojiPalettes(final String switchToAlphaLabel, final int switchToAlphaColor, + final float switchToAlphaSize, final Typeface switchToAlphaTypeface) { if (DEBUG_PAGER) { Log.d(TAG, "allocate emoji palettes memory " + mCurrentPagerPosition); } + mAlphabetKeyLeft.setText(switchToAlphaLabel); + mAlphabetKeyLeft.setTextColor(switchToAlphaColor); + mAlphabetKeyLeft.setTextSize(TypedValue.COMPLEX_UNIT_PX, switchToAlphaSize); + mAlphabetKeyLeft.setTypeface(switchToAlphaTypeface); + mAlphabetKeyRight.setText(switchToAlphaLabel); + mAlphabetKeyRight.setTextColor(switchToAlphaColor); + mAlphabetKeyRight.setTextSize(TypedValue.COMPLEX_UNIT_PX, switchToAlphaSize); + mAlphabetKeyRight.setTypeface(switchToAlphaTypeface); mEmojiPager.setAdapter(mEmojiPalettesAdapter); mEmojiPager.setCurrentItem(mCurrentPagerPosition); } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index aebba60fb..6215e2710 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; +import android.graphics.Paint; import android.preference.PreferenceManager; import android.util.Log; import android.view.ContextThemeWrapper; @@ -30,6 +31,7 @@ import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy; import com.android.inputmethod.compat.InputMethodServiceCompatUtils; import com.android.inputmethod.keyboard.KeyboardLayoutSet.KeyboardLayoutSetException; import com.android.inputmethod.keyboard.internal.KeyboardState; +import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.InputView; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinImeLogger; @@ -74,13 +76,13 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { private MainKeyboardView mKeyboardView; private EmojiPalettesView mEmojiPalettesView; private LatinIME mLatinIME; - private Resources mResources; private boolean mIsHardwareAcceleratedDrawingEnabled; private KeyboardState mState; private KeyboardLayoutSet mKeyboardLayoutSet; private SettingsValues mCurrentSettingsValues; + private Key mSwitchToAlphaKey; /** mIsAutoCorrectionActive indicates that auto corrected word will be input instead of * what user actually typed. */ @@ -106,7 +108,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { private void initInternal(final LatinIME latinIme, final SharedPreferences prefs) { mLatinIME = latinIme; - mResources = latinIme.getResources(); mPrefs = prefs; mSubtypeSwitcher = SubtypeSwitcher.getInstance(); mState = new KeyboardState(this); @@ -162,6 +163,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { mCurrentSettingsValues = settingsValues; try { mState.onLoadKeyboard(); + final Keyboard symbols = mKeyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_SYMBOLS); + mSwitchToAlphaKey = symbols.getKey(Constants.CODE_SWITCH_ALPHA_SYMBOL); } catch (KeyboardLayoutSetException e) { Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause()); LatinImeLogger.logOnException(e.mKeyboardId.toString(), e.getCause()); @@ -287,7 +290,10 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { @Override public void setEmojiKeyboard() { mMainKeyboardFrame.setVisibility(View.GONE); - mEmojiPalettesView.startEmojiPalettes(); + final Paint paint = mKeyboardView.newLabelPaint(mSwitchToAlphaKey); + mEmojiPalettesView.startEmojiPalettes( + mSwitchToAlphaKey.getLabel(), paint.getColor(), paint.getTextSize(), + paint.getTypeface()); mEmojiPalettesView.setVisibility(View.VISIBLE); } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 422bd12a3..dd3ab9cce 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -582,6 +582,7 @@ public class KeyboardView extends View { paint.setTypeface(mKeyDrawParams.mTypeface); paint.setTextSize(mKeyDrawParams.mLabelSize); } else { + paint.setColor(key.selectTextColor(mKeyDrawParams)); paint.setTypeface(key.selectTypeface(mKeyDrawParams)); paint.setTextSize(key.selectTextSize(mKeyDrawParams)); } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index d1125afcc..d69fbb182 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1176,14 +1176,22 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen @Override public void onClick(final DialogInterface di, final int position) { di.dismiss(); - ImportantNoticeUtils.updateLastImportantNoticeVersion(context); - setNeutralSuggestionStrip(); + if (position == DialogInterface.BUTTON_POSITIVE) { + ImportantNoticeUtils.updateLastImportantNoticeVersion(context); + setNeutralSuggestionStrip(); + return; + } + if (position == DialogInterface.BUTTON_NEGATIVE) { + launchSettings(); + return; + } } }; final AlertDialog.Builder builder = new AlertDialog.Builder(context, AlertDialog.THEME_HOLO_DARK); builder.setMessage(R.string.important_notice_contents) - .setPositiveButton(android.R.string.ok, listener); + .setPositiveButton(android.R.string.ok, listener) + .setNegativeButton(R.string.go_to_settings, listener); showOptionDialog(builder.create(), true /* cancelable */); } @@ -1612,13 +1620,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen launchSubActivity(SettingsActivity.class); } - public void launchKeyboardedDialogActivity(final Class<? extends Activity> activityClass) { - // Put the text in the attached EditText into a safe, saved state before switching to a - // new activity that will also use the soft keyboard. - mInputLogic.commitTyped(mSettings.getCurrent(), LastComposedWord.NOT_A_SEPARATOR); - launchSubActivity(activityClass); - } - private void launchSubActivity(final Class<? extends Activity> activityClass) { Intent intent = new Intent(); intent.setClass(LatinIME.this, activityClass); diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java index 45c5b733f..b51c765f0 100644 --- a/java/src/com/android/inputmethod/latin/settings/Settings.java +++ b/java/src/com/android/inputmethod/latin/settings/Settings.java @@ -66,6 +66,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang "pref_include_other_imes_in_language_switch_list"; public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20110916"; public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles"; + // TODO: consolidate key preview dismiss delay with the key preview animation parameters. public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY = "pref_key_preview_popup_dismiss_delay"; public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction"; diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java index 67017a43b..bb5547fc9 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java @@ -169,6 +169,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS, advancedSettings); } + // TODO: consolidate key preview dismiss delay with the key preview animation parameters. if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) { removePreference(Settings.PREF_POPUP_ON, generalSettings); removePreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY, advancedSettings); diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java index 7c11f5432..e77c55069 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java @@ -44,7 +44,6 @@ import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; -import com.android.inputmethod.compat.TextViewCompatUtils; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.PunctuationSuggestions; import com.android.inputmethod.latin.R; @@ -506,15 +505,10 @@ final class SuggestionStripLayoutHelper { } public void layoutImportantNotice(final View importantNoticeStrip, final int stripWidth) { - final Resources res = importantNoticeStrip.getResources(); - final Drawable infoIcon = res.getDrawable(R.drawable.sym_keyboard_info_holo_dark); - final Drawable moreIcon = res.getDrawable(R.drawable.sym_keyboard_more_holo_dark); - final int width = stripWidth - infoIcon.getIntrinsicWidth() - moreIcon.getIntrinsicWidth(); final TextView titleView = (TextView)importantNoticeStrip.findViewById( R.id.important_notice_title); + final int width = stripWidth - titleView.getPaddingLeft() - titleView.getPaddingRight(); titleView.setTextColor(mColorAutoCorrect); - TextViewCompatUtils.setCompoundDrawablesRelativeWithIntrinsicBounds( - titleView, infoIcon, null, moreIcon, null); final CharSequence importantNoticeTitle = titleView.getText(); titleView.setTextScaleX(1.0f); // Reset textScaleX. final float titleScaleX = getTextScaleX( |