From 6e3d427c320e89c6155cbcf4045e399b9b55f48f Mon Sep 17 00:00:00 2001 From: Amith Yamasani <> Date: Wed, 25 Mar 2009 17:39:38 -0700 Subject: [PATCH] Automated import from //branches/donutburger/...@142787,142787 --- res/drawable/dialog_bubble_step02.9.png | Bin 100 -> 1036 bytes res/drawable/dialog_bubble_step03.9.png | Bin 1692 -> 0 bytes res/drawable/dialog_bubble_step04.9.png | Bin 1957 -> 0 bytes res/drawable/dialog_bubble_step07.9.png | Bin 0 -> 4646 bytes res/layout/bubble_text.xml | 2 + res/values/strings.xml | 43 ++++- res/xml/prefs.xml | 48 +++--- .../android/inputmethod/latin/LatinIME.java | 160 ++++++++---------- .../inputmethod/latin/LatinIMESettings.java | 58 ++----- .../android/inputmethod/latin/Tutorial.java | 158 +++++++++-------- 10 files changed, 241 insertions(+), 228 deletions(-) delete mode 100755 res/drawable/dialog_bubble_step03.9.png delete mode 100755 res/drawable/dialog_bubble_step04.9.png create mode 100755 res/drawable/dialog_bubble_step07.9.png diff --git a/res/drawable/dialog_bubble_step02.9.png b/res/drawable/dialog_bubble_step02.9.png index 62386f2975631501e6836d8c16484a3341895d44..d77f85fe28e807d099c5bef39e8eb50c8aed60bb 100755 GIT binary patch literal 1036 zcmV+n1oQieP)w3|#000BiNkl2Z|b2sHNiA*(cRs(xqR*)_ZF~wFKz4M>4#%~)=Fn*%^sSX zQ0lp26mS7;nV9Hypy-RInpL#fgn(Y?3Ep<>LA{L15SVNO5H~+RFouGL?jx++xmyU0 zJq5Hj21lWXnR2t?OzjCoaA}_xEEJG-g5Q)?)QW*k&ZcRWEFTV98T_}Lsrp#l${1+EnqEbxE{UGlNM#1+RKmZH4uoW#91y^ zT`jEWdA&yisCBs<_#&J|o;&=#2FhNDY31(3X+d#u@$nPG!_CgAsopWI&9N3WsHFg@ zIhNGG4g6?{`>}VCO~UuUgBN=0000_9BV!3HF&rQD_gDQ!;|$B>F!$q5du|0ORpF6w$z zUt%Mn`k#Nwlm7>wEf7@jbTM-Dy6}IZuo=TK{=LremnP`~wJ~_Q`njxgN@xNA1Z5tt diff --git a/res/drawable/dialog_bubble_step03.9.png b/res/drawable/dialog_bubble_step03.9.png deleted file mode 100755 index 16b4d0226d126ed137cc5234d905afeea9e23f15..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1692 zcmV;N24ne&P)~GnP$_(`1rk_Ms2e_$4ICuoqv-))WFtO-tB7 z0$T+IB?VVe7Mw*f!AXrqhe2J_!WYmbg^~BudG0*t&c%IkFX^;r-8=K2aoPJ^|G#_A zdG0;uJnQB4-w)#DIYx9SsFYOR2E*oYLqko!(|`NGXZ*XuU4eb6M&G(sw}_Baq^>Ua zY5I8-!Ykbo8o>Oh0{Z(KTL9W(sar!otKddpi@Q~8D-kR}r&|#Xz@VX_Q+?s#;S&+u z*PU9MwelFMpsQC6S^&OgDHp(NYjv;EzXxJ3@OCF?XvMKAl`3>_u+ajrO&2o-=Ehnlib2K2+7|%y*4-+yscI(a>8lsOQ&JYi(C^3N5Ky{H*M?RMxq0(Q zDL|gRyor3XFNs{ZRwzK9KVPqU*6&KNtIn=!0es`eHPl;oR$!7%e#W5Ke z7B=BYI&ba+n4%*K$yYn$?W(YP0bvu7n3%|?u(kd1dft+Gw^HJHth-BCu??udV&%-8h-w9%OR4#eYi0?>;;`Wq#=5waE^6cSj! zrlykk?rzhT{{EAv>3=%F?)byfiF27mtB-%6YR{~8be#e42R^|s-T+@`vOH^DA50Xg zjt=80+6C`DY*5f&w1peaWf1MpaZU@s|GZJ+@Vej^d`lJ}d>pkpOERMuE_`J|Pfvr9 zUFh_M??}EOnXJ_(k}tQ%xtzck_yeEJGx!G%3An;umxdF@c6J`s39o;550TQkcgdRK zIBo=f!8iEt?5y326BV0FPHbULRa3Kd78|>Hm9LX8isHDFt}0m^>juM?=j|;yvB`X3 zdwWfRuzJz*E&2SXSZ)RWfrIks?9I@`8BcF-!$mkbcmF)Dq4O%|rjy* zbb*F@NuVPo>uloQ+ZcS2k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O*}TGp7EiQn;wlbH7MX0YK>aCbvE6`}vmi`e37DGeM7xr6DO{)itOWe;u!zvqrYX1JllF&L(a06atj~Zwtdw=89(td zqnK`CL-ai@B@K*>INP^w{mQBowiCtp>C@B0ifN%}rn}pQ=ij|@2b~n)*@4w; zHiezuCbh7N5~L=$>J(i3zSNUeL&sA2o zJCa`5T(KH2WaNn!wmg*^CdSgHuyOZLd&a6==LqVqq0UFg|4QgL6SrFeA?hg;m&Wq>}VK=~9Cm zc}6L$;-ie8K$%&!>Ni=?$aBOs!WwxZnURa}zFeh7vwZo|D#UhN-`m@*LjE&=0zUz4 zhrOgEbnye_XAT@V%8zIir|(IXn#@c~FrvW=t8Co(@lQ(E_hc|Wtcn@jM}rqu!HoBP z6!=MCJZ|JEx56rNWqg>Cr`!sw$aZkWjXZgURZc58O^^)WBN}<~3ahxN)J$Tk05|eP z3m_p?%#i8lh5ZHfvZjMG~Y`vz4JHbI$p6%(V(** ze^_@;rBWs02J4t^V7iIv=GxjhnRndri~RNLH(y|$L$*V68tBdsBO4E+?_SYAp0FBz zlGz6_PZ03%7r=s!dJKF$cSC#}+Y#t^tq(;uh`Ba_zt6`>3A)Q}4EQljYJ5{cY7zxJ zI!xfjo_n~P;0K}mXDINK0KN}07r0-1~;Gx*ZG*YTmQwE?I2F#cu cl>ZAb0GW)E?2G+NEC2ui07*qoM6N<$f|0oyV*mgE literal 0 HcmV?d00001 diff --git a/res/layout/bubble_text.xml b/res/layout/bubble_text.xml index eae3ab6fe..c3957b65e 100644 --- a/res/layout/bubble_text.xml +++ b/res/layout/bubble_text.xml @@ -25,4 +25,6 @@ android:textColor="?android:attr/textColorPrimary" android:minWidth="32dip" android:gravity="center" + android:shadowRadius="2.75" + android:shadowColor="#BB000000" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index 41809c15b..25d990e81 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -70,6 +70,21 @@ + + Quick fixes + + Corrects commonly typed mistakes + + + Show suggestions + + Display suggested words while typing + + + Auto-complete + + Spacebar and punctuation automatically insert highlighted word + None @@ -122,7 +137,33 @@ Press and hold the left-most word to add it to the dictionary - + + + Touch this hint to continue » + + + Touch here to close this hint and start typing! + + + The keyboard opens any time you touch a text field + + + Touch & hold a key to view accents\n(ø, ö, ô, ó, and so on) + + + + Switch to numbers and symbols by touching this key + + + Go back to letters by touching this key again + + + Touch & hold this key to change keyboard settings, like auto complete + + + Try it! + + Go diff --git a/res/xml/prefs.xml b/res/xml/prefs.xml index 037d5ff77..865269907 100644 --- a/res/xml/prefs.xml +++ b/res/xml/prefs.xml @@ -37,44 +37,34 @@ android:defaultValue="true" /> - - - - - + + + - \ No newline at end of file + diff --git a/src/com/android/inputmethod/latin/LatinIME.java b/src/com/android/inputmethod/latin/LatinIME.java index e5ad75bca..a36ff5747 100644 --- a/src/com/android/inputmethod/latin/LatinIME.java +++ b/src/com/android/inputmethod/latin/LatinIME.java @@ -23,7 +23,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; import android.content.res.Configuration; import android.inputmethodservice.InputMethodService; import android.inputmethodservice.Keyboard; @@ -35,6 +34,7 @@ import android.os.Message; import android.os.SystemClock; import android.os.Vibrator; import android.preference.PreferenceManager; +import android.text.AutoText; import android.text.ClipboardManager; import android.text.TextUtils; import android.util.Log; @@ -64,14 +64,13 @@ public class LatinIME extends InputMethodService private static final String PREF_VIBRATE_ON = "vibrate_on"; private static final String PREF_SOUND_ON = "sound_on"; - private static final String PREF_PROXIMITY_CORRECTION = "hit_correction"; - private static final String PREF_PREDICTION = "prediction_mode"; - private static final String PREF_PREDICTION_LANDSCAPE = "prediction_landscape"; private static final String PREF_AUTO_CAP = "auto_cap"; - static final String PREF_TUTORIAL_RUN = "tutorial_run"; + private static final String PREF_QUICK_FIXES = "quick_fixes"; + private static final String PREF_SHOW_SUGGESTIONS = "show_suggestions"; + private static final String PREF_AUTO_COMPLETE = "auto_complete"; private static final int MSG_UPDATE_SUGGESTIONS = 0; - private static final int MSG_CHECK_TUTORIAL = 1; + private static final int MSG_START_TUTORIAL = 1; // How many continuous deletes at which to start deleting at a higher speed. private static final int DELETE_ACCELERATE_AT = 20; @@ -93,7 +92,7 @@ public class LatinIME extends InputMethodService private AlertDialog mOptionsDialog; - private KeyboardSwitcher mKeyboardSwitcher; + KeyboardSwitcher mKeyboardSwitcher; private UserDictionary mUserDictionary; @@ -106,20 +105,17 @@ public class LatinIME extends InputMethodService private CharSequence mBestWord; private boolean mPredictionOn; private boolean mCompletionOn; - private boolean mPasswordMode; private boolean mAutoSpace; private boolean mAutoCorrectOn; private boolean mCapsLock; - private long mLastShiftTime; private boolean mVibrateOn; private boolean mSoundOn; - private boolean mProximityCorrection; - private int mCorrectionMode; private boolean mAutoCap; - private boolean mAutoPunctuate; - private boolean mTutorialShownBefore; + private boolean mQuickFixes; + private boolean mShowSuggestions; + private boolean mAutoComplete; + private int mCorrectionMode; // Indicates whether the suggestion strip is to be on in landscape - private boolean mShowSuggestInLand; private boolean mJustAccepted; private CharSequence mJustRevertedSeparator; private int mDeleteCount; @@ -144,10 +140,15 @@ public class LatinIME extends InputMethodService case MSG_UPDATE_SUGGESTIONS: updateSuggestions(); break; - case MSG_CHECK_TUTORIAL: - if (!mTutorialShownBefore) { - mTutorial = new Tutorial(mInputView); - mTutorial.start(); + case MSG_START_TUTORIAL: + if (mTutorial == null) { + if (mInputView.isShown()) { + mTutorial = new Tutorial(LatinIME.this, mInputView); + mTutorial.start(); + } else { + // Try again soon if the view is not yet showing + sendMessageDelayed(obtainMessage(MSG_START_TUTORIAL), 100); + } } break; } @@ -188,10 +189,6 @@ public class LatinIME extends InputMethodService if (!TextUtils.equals(conf.locale.toString(), mLocale)) { initSuggest(conf.locale.toString()); } - if (!mTutorialShownBefore && mTutorial != null) { - mTutorial.close(false); - mTutorial = null; - } super.onConfigurationChanged(conf); } @@ -253,10 +250,7 @@ public class LatinIME extends InputMethodService int variation = attribute.inputType & EditorInfo.TYPE_MASK_VARIATION; if (variation == EditorInfo.TYPE_TEXT_VARIATION_PASSWORD || variation == EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD ) { - mPasswordMode = true; mPredictionOn = false; - } else { - mPasswordMode = false; } if (variation == EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS || variation == EditorInfo.TYPE_TEXT_VARIATION_PERSON_NAME) { @@ -296,28 +290,15 @@ public class LatinIME extends InputMethodService setCandidatesViewShown(false); if (mCandidateView != null) mCandidateView.setSuggestions(null, false, false, false); loadSettings(); - mInputView.setProximityCorrectionEnabled(mProximityCorrection); + mInputView.setProximityCorrectionEnabled(true); if (mSuggest != null) { mSuggest.setCorrectionMode(mCorrectionMode); } mPredictionOn = mPredictionOn && mCorrectionMode > 0; - if (!mTutorialShownBefore && mTutorial == null) { - mHandler.sendEmptyMessageDelayed(MSG_CHECK_TUTORIAL, - mInputView.isShown() ? 100 : 3000); - } + checkTutorial(attribute.privateImeOptions); if (TRACE) Debug.startMethodTracing("latinime"); } - @Override - public void onWindowShown() { - super.onWindowShown(); - // Bring the tutorial up faster, if window just shown - if (!mTutorialShownBefore && mTutorial == null) { - mHandler.removeMessages(MSG_CHECK_TUTORIAL); - mHandler.sendEmptyMessageDelayed(MSG_CHECK_TUTORIAL, 1000); - } - } - @Override public void onFinishInput() { super.onFinishInput(); @@ -325,10 +306,6 @@ public class LatinIME extends InputMethodService if (mInputView != null) { mInputView.closing(); } -// if (!mTutorialShownBefore && mTutorial != null) { -// mTutorial.close(false); -// mTutorial = null; -// } } @Override @@ -359,8 +336,12 @@ public class LatinIME extends InputMethodService @Override public void hideWindow() { if (TRACE) Debug.stopMethodTracing(); - if (!mTutorialShownBefore && mTutorial != null) { - mTutorial.close(false); + if (mOptionsDialog != null && mOptionsDialog.isShowing()) { + mOptionsDialog.dismiss(); + mOptionsDialog = null; + } + if (mTutorial != null) { + mTutorial.close(); mTutorial = null; } super.hideWindow(); @@ -417,11 +398,21 @@ public class LatinIME extends InputMethodService if (event.getRepeatCount() == 0 && mInputView != null) { if (mInputView.handleBack()) { return true; - } else if (!mTutorialShownBefore && mTutorial != null) { - mTutorial.close(true); + } else if (mTutorial != null) { + mTutorial.close(); + mTutorial = null; } } break; + case KeyEvent.KEYCODE_DPAD_DOWN: + case KeyEvent.KEYCODE_DPAD_UP: + case KeyEvent.KEYCODE_DPAD_LEFT: + case KeyEvent.KEYCODE_DPAD_RIGHT: + // If tutorial is visible, don't allow dpad to work + if (mTutorial != null) { + return true; + } + break; } return super.onKeyDown(keyCode, event); } @@ -433,6 +424,10 @@ public class LatinIME extends InputMethodService case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_RIGHT: + // If tutorial is visible, don't allow dpad to work + if (mTutorial != null) { + return true; + } // Enable shift key and DPAD to do selections if (mInputView != null && mInputView.isShown() && mInputView.isShifted()) { event = new KeyEvent(event.getDownTime(), event.getEventTime(), @@ -596,9 +591,7 @@ public class LatinIME extends InputMethodService ic.deleteSurroundingText(1, 0); } } else { - //getCurrentInputConnection().deleteSurroundingText(1, 0); deleteChar = true; - //sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL); } updateShiftKeyState(getCurrentInputEditorInfo()); TextEntryState.backspace(); @@ -697,9 +690,6 @@ public class LatinIME extends InputMethodService private void handleClose() { commitTyped(getCurrentInputConnection()); - if (!mTutorialShownBefore && mTutorial != null) { - mTutorial.close(true); - } requestHideSelf(0); mInputView.closing(); TextEntryState.endSession(); @@ -730,11 +720,7 @@ public class LatinIME extends InputMethodService } private boolean isCandidateStripVisible() { - boolean visible = isPredictionOn() && - (!isFullscreenMode() || - mCorrectionMode == Suggest.CORRECTION_FULL || - mShowSuggestInLand); - return visible; + return isPredictionOn() && mShowSuggestions; } private void updateSuggestions() { @@ -901,14 +887,6 @@ public class LatinIME extends InputMethodService mInputView.startPlaying(text.toString()); } } -// if (mAutoCorrectOn) { -// commitTyped(getCurrentInputConnection()); -// } else if (mPredicting) { -// pickDefaultSuggestion(); -// } -// if (mAutoSpace) { -// sendSpace(); -// } } public void swipeLeft() { @@ -987,6 +965,27 @@ public class LatinIME extends InputMethodService mVibrator.vibrate(mVibrateDuration); } + private void checkTutorial(String privateImeOptions) { + if (privateImeOptions == null) return; + if (privateImeOptions.equals("com.android.setupwizard:ShowTutorial")) { + if (mTutorial == null) startTutorial(); + } else if (privateImeOptions.equals("com.android.setupwizard:HideTutorial")) { + if (mTutorial != null) { + if (mTutorial.close()) { + mTutorial = null; + } + } + } + } + + private void startTutorial() { + mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_START_TUTORIAL), 500); + } + + void tutorialDone() { + mTutorial = null; + } + private void launchSettings() { handleClose(); Intent intent = new Intent(); @@ -998,24 +997,17 @@ public class LatinIME extends InputMethodService private void loadSettings() { // Get the settings preferences SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); - mProximityCorrection = sp.getBoolean(PREF_PROXIMITY_CORRECTION, true); mVibrateOn = sp.getBoolean(PREF_VIBRATE_ON, false); mSoundOn = sp.getBoolean(PREF_SOUND_ON, false); - String predictionBasic = getString(R.string.prediction_basic); - String mode = sp.getString(PREF_PREDICTION, predictionBasic); - if (mode.equals(getString(R.string.prediction_full))) { - mCorrectionMode = 2; - } else if (mode.equals(predictionBasic)) { - mCorrectionMode = 1; - } else { - mCorrectionMode = 0; - } - mAutoCorrectOn = mSuggest != null && mCorrectionMode > 0; - mAutoCap = sp.getBoolean(PREF_AUTO_CAP, true); - //mAutoPunctuate = sp.getBoolean(PREF_AUTO_PUNCTUATE, mCorrectionMode > 0); - mShowSuggestInLand = !sp.getBoolean(PREF_PREDICTION_LANDSCAPE, false); - mTutorialShownBefore = sp.getBoolean(PREF_TUTORIAL_RUN, false); + mQuickFixes = sp.getBoolean(PREF_QUICK_FIXES, true); + // If there is no auto text data, then quickfix is forced to "on", so that the other options + // will continue to work + if (AutoText.getSize(mInputView) < 1) mQuickFixes = true; + mShowSuggestions = sp.getBoolean(PREF_SHOW_SUGGESTIONS, true) & mQuickFixes; + mAutoComplete = sp.getBoolean(PREF_AUTO_COMPLETE, true) & mShowSuggestions; + mAutoCorrectOn = mSuggest != null && (mAutoComplete || mQuickFixes); + mCorrectionMode = mAutoComplete ? 2 : (mQuickFixes ? 1 : 0); } private void showOptionsMenu() { @@ -1079,11 +1071,7 @@ public class LatinIME extends InputMethodService p.println(" mSoundOn=" + mSoundOn); p.println(" mVibrateOn=" + mVibrateOn); } - - - private static final int[] KEY_SPACE = { KEYCODE_SPACE }; - - + // Characters per second measurement private static final boolean PERF_DEBUG = false; diff --git a/src/com/android/inputmethod/latin/LatinIMESettings.java b/src/com/android/inputmethod/latin/LatinIMESettings.java index 2c23263ea..e87c4a5a1 100644 --- a/src/com/android/inputmethod/latin/LatinIMESettings.java +++ b/src/com/android/inputmethod/latin/LatinIMESettings.java @@ -16,60 +16,38 @@ package com.android.inputmethod.latin; -import android.content.SharedPreferences; -import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; -import android.preference.ListPreference; -import android.preference.Preference; +import android.preference.CheckBoxPreference; import android.preference.PreferenceActivity; import android.preference.PreferenceGroup; +import android.text.AutoText; -public class LatinIMESettings extends PreferenceActivity - implements OnSharedPreferenceChangeListener{ +public class LatinIMESettings extends PreferenceActivity { - private static final String CORRECTION_MODE_KEY = "prediction_mode"; + private static final String QUICK_FIXES_KEY = "quick_fixes"; + private static final String SHOW_SUGGESTIONS_KEY = "show_suggestions"; private static final String PREDICTION_SETTINGS_KEY = "prediction_settings"; - private static final String PREDICTION_LANDSCAPE_KEY = "prediction_landscape"; - private ListPreference mCorrectionMode; - private PreferenceGroup mPredictionSettings; - private Preference mPredictionLandscape; + private CheckBoxPreference mQuickFixes; + private CheckBoxPreference mShowSuggestions; @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.prefs); - mCorrectionMode = (ListPreference) findPreference(CORRECTION_MODE_KEY); - mPredictionSettings = (PreferenceGroup) findPreference(PREDICTION_SETTINGS_KEY); - mPredictionLandscape = findPreference(PREDICTION_LANDSCAPE_KEY); - updatePredictionSettings(); - getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); - } - - @Override - protected void onDestroy() { - getPreferenceScreen().getSharedPreferences() - .unregisterOnSharedPreferenceChangeListener(this); - super.onDestroy(); - } - - private void updatePredictionSettings() { - if (mCorrectionMode != null && mPredictionSettings != null) { - String correctionMode = mCorrectionMode.getValue(); - if (correctionMode.equals(getResources().getString(R.string.prediction_none))) { - mPredictionSettings.setEnabled(false); - } else { - mPredictionSettings.setEnabled(true); - boolean suggestionsInLandscape = - !correctionMode.equals(getResources().getString(R.string.prediction_full)); - mPredictionLandscape.setEnabled(suggestionsInLandscape); - } - } + mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY); + mShowSuggestions = (CheckBoxPreference) findPreference(SHOW_SUGGESTIONS_KEY); } - public void onSharedPreferenceChanged(SharedPreferences preferences, String key) { - if (key.equals(CORRECTION_MODE_KEY)) { - updatePredictionSettings(); + @Override + protected void onResume() { + super.onResume(); + int autoTextSize = AutoText.getSize(getListView()); + if (autoTextSize < 1) { + ((PreferenceGroup) findPreference(PREDICTION_SETTINGS_KEY)) + .removePreference(mQuickFixes); + } else { + mShowSuggestions.setDependency(QUICK_FIXES_KEY); } } } diff --git a/src/com/android/inputmethod/latin/Tutorial.java b/src/com/android/inputmethod/latin/Tutorial.java index d944d17bf..750de054b 100644 --- a/src/com/android/inputmethod/latin/Tutorial.java +++ b/src/com/android/inputmethod/latin/Tutorial.java @@ -17,38 +17,38 @@ package com.android.inputmethod.latin; import android.content.Context; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; +import android.graphics.Rect; import android.graphics.drawable.Drawable; -import android.opengl.Visibility; import android.os.Handler; import android.os.Message; -import android.os.SystemClock; -import android.preference.PreferenceManager; import android.text.Layout; +import android.text.SpannableStringBuilder; import android.text.StaticLayout; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.view.View.OnTouchListener; import android.widget.PopupWindow; import android.widget.TextView; import java.util.ArrayList; import java.util.List; -public class Tutorial { +public class Tutorial implements OnTouchListener { private List mBubbles = new ArrayList(); private long mStartTime; private static final long MINIMUM_TIME = 6000; private static final long MAXIMUM_TIME = 20000; private View mInputView; + private LatinIME mIme; private int[] mLocation = new int[2]; private int mBubblePointerOffset; private static final int MSG_SHOW_BUBBLE = 0; - private static final int MSG_HIDE_ALL = 1; + + private int mBubbleIndex; Handler mHandler = new Handler() { @Override @@ -58,8 +58,6 @@ public class Tutorial { Bubble bubba = (Bubble) msg.obj; bubba.show(mLocation[0], mLocation[1]); break; - case MSG_HIDE_ALL: - close(true); } } }; @@ -70,7 +68,7 @@ public class Tutorial { int y; int width; int gravity; - String text; + CharSequence text; boolean dismissOnTouch; boolean dismissOnClose; PopupWindow window; @@ -78,16 +76,18 @@ public class Tutorial { View inputView; Bubble(Context context, View inputView, - int backgroundResource, int bx, int by, int bw, int gravity, int textResource, - boolean dismissOnTouch, boolean dismissOnClose) { + int backgroundResource, int bx, int by, int textResource1, int textResource2) { bubbleBackground = context.getResources().getDrawable(backgroundResource); - x = bx; + x = bx; y = by; - width = bw; - this.gravity = gravity; - text = context.getResources().getString(textResource); - this.dismissOnTouch = dismissOnTouch; - this.dismissOnClose = dismissOnClose; + width = (int) (inputView.getWidth() * 0.9); + this.gravity = Gravity.TOP | Gravity.LEFT; + text = new SpannableStringBuilder() + .append(context.getResources().getText(textResource1)) + .append("\n") + .append(context.getResources().getText(textResource2)); + this.dismissOnTouch = true; + this.dismissOnClose = false; this.inputView = inputView; window = new PopupWindow(context); window.setBackgroundDrawable(null); @@ -97,19 +97,20 @@ public class Tutorial { textView = (TextView) inflate.inflate(R.layout.bubble_text, null); textView.setBackgroundDrawable(bubbleBackground); textView.setText(text); + //textView.setText(textResource1); window.setContentView(textView); window.setFocusable(false); window.setTouchable(true); window.setOutsideTouchable(false); textView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View view, MotionEvent me) { - Tutorial.this.touched(); + Tutorial.this.next(); return true; } }); } - private void chooseSize(PopupWindow pop, View parentView, CharSequence text, TextView tv) { + private int chooseSize(PopupWindow pop, View parentView, CharSequence text, TextView tv) { int wid = tv.getPaddingLeft() + tv.getPaddingRight(); int ht = tv.getPaddingTop() + tv.getPaddingBottom(); @@ -131,10 +132,12 @@ public class Tutorial { */ pop.setWidth(width); pop.setHeight(ht + l.getHeight()); + return l.getHeight(); } void show(int offx, int offy) { - chooseSize(window, inputView, text, textView); + int textHeight = chooseSize(window, inputView, text, textView); + offy -= textView.getPaddingTop() + textHeight; if (inputView.getVisibility() == View.VISIBLE && inputView.getWindowVisibility() == View.VISIBLE) { try { @@ -155,72 +158,83 @@ public class Tutorial { } } - public Tutorial(LatinKeyboardView inputView) { + public Tutorial(LatinIME ime, LatinKeyboardView inputView) { Context context = inputView.getContext(); - int inputHeight = inputView.getHeight(); + mIme = ime; int inputWidth = inputView.getWidth(); + final int x = inputWidth / 20; // Half of 1/10th mBubblePointerOffset = inputView.getContext().getResources() .getDimensionPixelOffset(R.dimen.bubble_pointer_offset); - Bubble b0 = new Bubble(context, inputView, - R.drawable.dialog_bubble_step02, 0, 0, - inputWidth, - Gravity.BOTTOM | Gravity.LEFT, - R.string.tip_dismiss, - false, true); - mBubbles.add(b0); -// Bubble b1 = new Bubble(context, inputView, -// R.drawable.dialog_bubble_step03, -// (int) (inputWidth * 0.85) + mBubblePointerOffset, inputHeight / 5, -// (int) (inputWidth * 0.45), -// Gravity.TOP | Gravity.RIGHT, -// R.string.tip_long_press, -// true, false); -// mBubbles.add(b1); -// Bubble b2 = new Bubble(inputView.getContext(), inputView, -// R.drawable.dialog_bubble_step04, -// inputWidth / 10 - mBubblePointerOffset, inputHeight - inputHeight / 5, -// (int) (inputWidth * 0.45), -// Gravity.BOTTOM | Gravity.LEFT, -// R.string.tip_access_symbols, -// true, false); -// mBubbles.add(b2); + Bubble bWelcome = new Bubble(context, inputView, + R.drawable.dialog_bubble_step02, x, 0, + R.string.tip_to_open_keyboard, R.string.touch_to_continue); + mBubbles.add(bWelcome); + Bubble bAccents = new Bubble(context, inputView, + R.drawable.dialog_bubble_step02, x, 0, + R.string.tip_to_view_accents, R.string.touch_to_continue); + mBubbles.add(bAccents); + Bubble b123 = new Bubble(context, inputView, + R.drawable.dialog_bubble_step07, x, 0, + R.string.tip_to_open_symbols, R.string.touch_to_continue); + mBubbles.add(b123); + Bubble bABC = new Bubble(context, inputView, + R.drawable.dialog_bubble_step07, x, 0, + R.string.tip_to_close_symbols, R.string.touch_to_continue); + mBubbles.add(bABC); + Bubble bSettings = new Bubble(context, inputView, + R.drawable.dialog_bubble_step07, x, 0, + R.string.tip_to_launch_settings, R.string.touch_to_continue); + mBubbles.add(bSettings); + Bubble bDone = new Bubble(context, inputView, + R.drawable.dialog_bubble_step02, x, 0, + R.string.tip_to_start_typing, R.string.touch_to_finish); + mBubbles.add(bDone); mInputView = inputView; } void start() { mInputView.getLocationInWindow(mLocation); - long delayMillis = 0; - for (int i = 0; i < mBubbles.size(); i++) { - mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SHOW_BUBBLE, mBubbles.get(i)), delayMillis); - delayMillis += 2000; + mBubbleIndex = -1; + mInputView.setOnTouchListener(this); + next(); + } + + boolean next() { + if (mBubbleIndex >= 0) { + mBubbles.get(mBubbleIndex).hide(); } - //mHandler.sendEmptyMessageDelayed(MSG_HIDE_ALL, MAXIMUM_TIME); - mStartTime = SystemClock.uptimeMillis(); + mBubbleIndex++; + if (mBubbleIndex >= mBubbles.size()) { + mInputView.setOnTouchListener(null); + mIme.sendDownUpKeyEvents(-1); // Inform the setupwizard that tutorial is in last bubble + mIme.tutorialDone(); + return false; + } + if (mBubbleIndex == 3 || mBubbleIndex == 4) { + mIme.mKeyboardSwitcher.toggleSymbols(); + } + mHandler.sendMessageDelayed( + mHandler.obtainMessage(MSG_SHOW_BUBBLE, mBubbles.get(mBubbleIndex)), 200); + return true; } - void touched() { - if (SystemClock.uptimeMillis() - mStartTime < MINIMUM_TIME) { - return; - } - for (int i = 0; i < mBubbles.size(); i++) { - Bubble bubba = mBubbles.get(i); - if (bubba.dismissOnTouch) { - bubba.hide(); - } - } - } - - void close(boolean completed) { - mHandler.removeMessages(MSG_SHOW_BUBBLE); + void hide() { for (int i = 0; i < mBubbles.size(); i++) { mBubbles.get(i).hide(); } - if (completed) { - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences( - mInputView.getContext()); - Editor editor = sp.edit(); - editor.putBoolean(LatinIME.PREF_TUTORIAL_RUN, true); - editor.commit(); + mInputView.setOnTouchListener(null); + } + + boolean close() { + mHandler.removeMessages(MSG_SHOW_BUBBLE); + hide(); + return true; + } + + public boolean onTouch(View v, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_UP) { + next(); } + return true; } }