Automated import from //branches/donutburger/...@142787,142787

main
Amith Yamasani 2009-03-25 17:39:38 -07:00 committed by The Android Open Source Project
parent eb9ab35a42
commit 6e3d427c32
10 changed files with 241 additions and 228 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 B

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -25,4 +25,6 @@
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:minWidth="32dip" android:minWidth="32dip"
android:gravity="center" android:gravity="center"
android:shadowRadius="2.75"
android:shadowColor="#BB000000"
/> />

View File

@ -70,6 +70,21 @@
<!-- Description for auto punctuate --> <!-- Description for auto punctuate -->
<string name="auto_punctuate_summary"></string> <string name="auto_punctuate_summary"></string>
<!-- Option to enable quick fixes -->
<string name="quick_fixes">Quick fixes</string>
<!-- Description for quick fixes -->
<string name="quick_fixes_summary">Corrects commonly typed mistakes</string>
<!-- Option to enable showing suggestions -->
<string name="show_suggestions">Show suggestions</string>
<!-- Description for show suggestions -->
<string name="show_suggestions_summary">Display suggested words while typing</string>
<!-- Option to enable auto completion -->
<string name="auto_complete">Auto-complete</string>
<!-- Description for auto completion -->
<string name="auto_complete_summary">Spacebar and punctuation automatically insert highlighted word</string>
<!-- Array of prediction modes --> <!-- Array of prediction modes -->
<string-array name="prediction_modes"> <string-array name="prediction_modes">
<item>None</item> <item>None</item>
@ -123,6 +138,32 @@
<string name="tip_add_to_dictionary">Press and hold the left-most word to add it to the dictionary <string name="tip_add_to_dictionary">Press and hold the left-most word to add it to the dictionary
</string> </string>
<!-- Instruction to touch the bubble to continue -->
<string name="touch_to_continue">Touch this hint to continue »</string>
<!-- Instruction to touch the bubble to start typing -->
<string name="touch_to_finish">Touch here to close this hint and start typing!</string>
<!-- Tutorial tip 1 - The keyboard opens any time you touch a text field -->
<string name="tip_to_open_keyboard"><b>The keyboard opens any time you touch a text field</b></string>
<!-- Tutorial tip 2 - Touch and hold a key to view accents (examples) -->
<string name="tip_to_view_accents"><b>Touch &amp; hold a key to view accents\n(ø, ö, ô, ó, and so on)</b>
</string>
<!-- Tutorial tip 3 - How to switch to number/symbol keyboard -->
<string name="tip_to_open_symbols"><b>Switch to numbers and symbols by touching this key</b></string>
<!-- Tutorial tip 4 - How to switch back to alphabet keyboard -->
<string name="tip_to_close_symbols"><b>Go back to letters by touching this key again</b></string>
<!-- Tutorial tip 5 - How to launch keyboard settings -->
<string name="tip_to_launch_settings"><b>Touch &amp; hold this key to change keyboard settings, like auto complete</b></string>
<!-- Tutorial tip 6 - Done with the tutorial -->
<string name="tip_to_start_typing"><b>Try it!</b></string>
<!-- Label for soft enter key when it performs GO action. Must be short to fit on key! --> <!-- Label for soft enter key when it performs GO action. Must be short to fit on key! -->
<string name="label_go_key">Go</string> <string name="label_go_key">Go</string>
<!-- Label for soft enter key when it performs NEXT action. Must be short to fit on key! --> <!-- Label for soft enter key when it performs NEXT action. Must be short to fit on key! -->

View File

@ -37,43 +37,33 @@
android:defaultValue="true" android:defaultValue="true"
/> />
<!--CheckBoxPreference
android:key="auto_punctuate"
android:title="@string/auto_punctuate"
android:persistent="true"
android:defaultValue="true"
android:visible="false"
/-->
<ListPreference
android:key="prediction_mode"
android:title="@string/prediction"
android:dialogTitle="@string/auto_complete_dialog_title"
android:summary="@string/prediction_summary"
android:persistent="true"
android:entries="@array/prediction_modes"
android:entryValues="@array/prediction_modes_values"
android:defaultValue="@string/prediction_basic"
/>
<PreferenceCategory <PreferenceCategory
android:title="@string/prediction_category" android:title="@string/prediction_category"
android:key="prediction_settings"> android:key="prediction_settings">
<CheckBoxPreference <CheckBoxPreference
android:key="hit_correction" android:key="quick_fixes"
android:title="@string/hit_correction" android:title="@string/quick_fixes"
android:summary="@string/hit_correction_summary" android:summary="@string/quick_fixes_summary"
android:persistent="true" android:persistent="true"
android:defaultValue="true" android:defaultValue="true"
/> />
<CheckBoxPreference <CheckBoxPreference
android:key="prediction_landscape" android:key="show_suggestions"
android:title="@string/prediction_landscape" android:title="@string/show_suggestions"
android:summary="@string/prediction_landscape_summary" android:summary="@string/show_suggestions_summary"
android:persistent="true" android:persistent="true"
android:defaultValue="false" android:defaultValue="true"
/>
<CheckBoxPreference
android:key="auto_complete"
android:title="@string/auto_complete"
android:summary="@string/auto_complete_summary"
android:persistent="true"
android:defaultValue="true"
android:dependency="show_suggestions"
/> />
</PreferenceCategory> </PreferenceCategory>

View File

@ -23,7 +23,6 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.inputmethodservice.InputMethodService; import android.inputmethodservice.InputMethodService;
import android.inputmethodservice.Keyboard; import android.inputmethodservice.Keyboard;
@ -35,6 +34,7 @@ import android.os.Message;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.Vibrator; import android.os.Vibrator;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.AutoText;
import android.text.ClipboardManager; import android.text.ClipboardManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; 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_VIBRATE_ON = "vibrate_on";
private static final String PREF_SOUND_ON = "sound_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"; 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_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. // How many continuous deletes at which to start deleting at a higher speed.
private static final int DELETE_ACCELERATE_AT = 20; private static final int DELETE_ACCELERATE_AT = 20;
@ -93,7 +92,7 @@ public class LatinIME extends InputMethodService
private AlertDialog mOptionsDialog; private AlertDialog mOptionsDialog;
private KeyboardSwitcher mKeyboardSwitcher; KeyboardSwitcher mKeyboardSwitcher;
private UserDictionary mUserDictionary; private UserDictionary mUserDictionary;
@ -106,20 +105,17 @@ public class LatinIME extends InputMethodService
private CharSequence mBestWord; private CharSequence mBestWord;
private boolean mPredictionOn; private boolean mPredictionOn;
private boolean mCompletionOn; private boolean mCompletionOn;
private boolean mPasswordMode;
private boolean mAutoSpace; private boolean mAutoSpace;
private boolean mAutoCorrectOn; private boolean mAutoCorrectOn;
private boolean mCapsLock; private boolean mCapsLock;
private long mLastShiftTime;
private boolean mVibrateOn; private boolean mVibrateOn;
private boolean mSoundOn; private boolean mSoundOn;
private boolean mProximityCorrection;
private int mCorrectionMode;
private boolean mAutoCap; private boolean mAutoCap;
private boolean mAutoPunctuate; private boolean mQuickFixes;
private boolean mTutorialShownBefore; private boolean mShowSuggestions;
private boolean mAutoComplete;
private int mCorrectionMode;
// Indicates whether the suggestion strip is to be on in landscape // Indicates whether the suggestion strip is to be on in landscape
private boolean mShowSuggestInLand;
private boolean mJustAccepted; private boolean mJustAccepted;
private CharSequence mJustRevertedSeparator; private CharSequence mJustRevertedSeparator;
private int mDeleteCount; private int mDeleteCount;
@ -144,10 +140,15 @@ public class LatinIME extends InputMethodService
case MSG_UPDATE_SUGGESTIONS: case MSG_UPDATE_SUGGESTIONS:
updateSuggestions(); updateSuggestions();
break; break;
case MSG_CHECK_TUTORIAL: case MSG_START_TUTORIAL:
if (!mTutorialShownBefore) { if (mTutorial == null) {
mTutorial = new Tutorial(mInputView); if (mInputView.isShown()) {
mTutorial = new Tutorial(LatinIME.this, mInputView);
mTutorial.start(); mTutorial.start();
} else {
// Try again soon if the view is not yet showing
sendMessageDelayed(obtainMessage(MSG_START_TUTORIAL), 100);
}
} }
break; break;
} }
@ -188,10 +189,6 @@ public class LatinIME extends InputMethodService
if (!TextUtils.equals(conf.locale.toString(), mLocale)) { if (!TextUtils.equals(conf.locale.toString(), mLocale)) {
initSuggest(conf.locale.toString()); initSuggest(conf.locale.toString());
} }
if (!mTutorialShownBefore && mTutorial != null) {
mTutorial.close(false);
mTutorial = null;
}
super.onConfigurationChanged(conf); super.onConfigurationChanged(conf);
} }
@ -253,10 +250,7 @@ public class LatinIME extends InputMethodService
int variation = attribute.inputType & EditorInfo.TYPE_MASK_VARIATION; int variation = attribute.inputType & EditorInfo.TYPE_MASK_VARIATION;
if (variation == EditorInfo.TYPE_TEXT_VARIATION_PASSWORD || if (variation == EditorInfo.TYPE_TEXT_VARIATION_PASSWORD ||
variation == EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD ) { variation == EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD ) {
mPasswordMode = true;
mPredictionOn = false; mPredictionOn = false;
} else {
mPasswordMode = false;
} }
if (variation == EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS if (variation == EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|| variation == EditorInfo.TYPE_TEXT_VARIATION_PERSON_NAME) { || variation == EditorInfo.TYPE_TEXT_VARIATION_PERSON_NAME) {
@ -296,28 +290,15 @@ public class LatinIME extends InputMethodService
setCandidatesViewShown(false); setCandidatesViewShown(false);
if (mCandidateView != null) mCandidateView.setSuggestions(null, false, false, false); if (mCandidateView != null) mCandidateView.setSuggestions(null, false, false, false);
loadSettings(); loadSettings();
mInputView.setProximityCorrectionEnabled(mProximityCorrection); mInputView.setProximityCorrectionEnabled(true);
if (mSuggest != null) { if (mSuggest != null) {
mSuggest.setCorrectionMode(mCorrectionMode); mSuggest.setCorrectionMode(mCorrectionMode);
} }
mPredictionOn = mPredictionOn && mCorrectionMode > 0; mPredictionOn = mPredictionOn && mCorrectionMode > 0;
if (!mTutorialShownBefore && mTutorial == null) { checkTutorial(attribute.privateImeOptions);
mHandler.sendEmptyMessageDelayed(MSG_CHECK_TUTORIAL,
mInputView.isShown() ? 100 : 3000);
}
if (TRACE) Debug.startMethodTracing("latinime"); 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 @Override
public void onFinishInput() { public void onFinishInput() {
super.onFinishInput(); super.onFinishInput();
@ -325,10 +306,6 @@ public class LatinIME extends InputMethodService
if (mInputView != null) { if (mInputView != null) {
mInputView.closing(); mInputView.closing();
} }
// if (!mTutorialShownBefore && mTutorial != null) {
// mTutorial.close(false);
// mTutorial = null;
// }
} }
@Override @Override
@ -359,8 +336,12 @@ public class LatinIME extends InputMethodService
@Override @Override
public void hideWindow() { public void hideWindow() {
if (TRACE) Debug.stopMethodTracing(); if (TRACE) Debug.stopMethodTracing();
if (!mTutorialShownBefore && mTutorial != null) { if (mOptionsDialog != null && mOptionsDialog.isShowing()) {
mTutorial.close(false); mOptionsDialog.dismiss();
mOptionsDialog = null;
}
if (mTutorial != null) {
mTutorial.close();
mTutorial = null; mTutorial = null;
} }
super.hideWindow(); super.hideWindow();
@ -417,11 +398,21 @@ public class LatinIME extends InputMethodService
if (event.getRepeatCount() == 0 && mInputView != null) { if (event.getRepeatCount() == 0 && mInputView != null) {
if (mInputView.handleBack()) { if (mInputView.handleBack()) {
return true; return true;
} else if (!mTutorialShownBefore && mTutorial != null) { } else if (mTutorial != null) {
mTutorial.close(true); mTutorial.close();
mTutorial = null;
} }
} }
break; 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); return super.onKeyDown(keyCode, event);
} }
@ -433,6 +424,10 @@ public class LatinIME extends InputMethodService
case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_UP:
case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_DPAD_RIGHT: 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 // Enable shift key and DPAD to do selections
if (mInputView != null && mInputView.isShown() && mInputView.isShifted()) { if (mInputView != null && mInputView.isShown() && mInputView.isShifted()) {
event = new KeyEvent(event.getDownTime(), event.getEventTime(), event = new KeyEvent(event.getDownTime(), event.getEventTime(),
@ -596,9 +591,7 @@ public class LatinIME extends InputMethodService
ic.deleteSurroundingText(1, 0); ic.deleteSurroundingText(1, 0);
} }
} else { } else {
//getCurrentInputConnection().deleteSurroundingText(1, 0);
deleteChar = true; deleteChar = true;
//sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
} }
updateShiftKeyState(getCurrentInputEditorInfo()); updateShiftKeyState(getCurrentInputEditorInfo());
TextEntryState.backspace(); TextEntryState.backspace();
@ -697,9 +690,6 @@ public class LatinIME extends InputMethodService
private void handleClose() { private void handleClose() {
commitTyped(getCurrentInputConnection()); commitTyped(getCurrentInputConnection());
if (!mTutorialShownBefore && mTutorial != null) {
mTutorial.close(true);
}
requestHideSelf(0); requestHideSelf(0);
mInputView.closing(); mInputView.closing();
TextEntryState.endSession(); TextEntryState.endSession();
@ -730,11 +720,7 @@ public class LatinIME extends InputMethodService
} }
private boolean isCandidateStripVisible() { private boolean isCandidateStripVisible() {
boolean visible = isPredictionOn() && return isPredictionOn() && mShowSuggestions;
(!isFullscreenMode() ||
mCorrectionMode == Suggest.CORRECTION_FULL ||
mShowSuggestInLand);
return visible;
} }
private void updateSuggestions() { private void updateSuggestions() {
@ -901,14 +887,6 @@ public class LatinIME extends InputMethodService
mInputView.startPlaying(text.toString()); mInputView.startPlaying(text.toString());
} }
} }
// if (mAutoCorrectOn) {
// commitTyped(getCurrentInputConnection());
// } else if (mPredicting) {
// pickDefaultSuggestion();
// }
// if (mAutoSpace) {
// sendSpace();
// }
} }
public void swipeLeft() { public void swipeLeft() {
@ -987,6 +965,27 @@ public class LatinIME extends InputMethodService
mVibrator.vibrate(mVibrateDuration); 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() { private void launchSettings() {
handleClose(); handleClose();
Intent intent = new Intent(); Intent intent = new Intent();
@ -998,24 +997,17 @@ public class LatinIME extends InputMethodService
private void loadSettings() { private void loadSettings() {
// Get the settings preferences // Get the settings preferences
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
mProximityCorrection = sp.getBoolean(PREF_PROXIMITY_CORRECTION, true);
mVibrateOn = sp.getBoolean(PREF_VIBRATE_ON, false); mVibrateOn = sp.getBoolean(PREF_VIBRATE_ON, false);
mSoundOn = sp.getBoolean(PREF_SOUND_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); mAutoCap = sp.getBoolean(PREF_AUTO_CAP, true);
//mAutoPunctuate = sp.getBoolean(PREF_AUTO_PUNCTUATE, mCorrectionMode > 0); mQuickFixes = sp.getBoolean(PREF_QUICK_FIXES, true);
mShowSuggestInLand = !sp.getBoolean(PREF_PREDICTION_LANDSCAPE, false); // If there is no auto text data, then quickfix is forced to "on", so that the other options
mTutorialShownBefore = sp.getBoolean(PREF_TUTORIAL_RUN, false); // 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() { private void showOptionsMenu() {
@ -1080,10 +1072,6 @@ public class LatinIME extends InputMethodService
p.println(" mVibrateOn=" + mVibrateOn); p.println(" mVibrateOn=" + mVibrateOn);
} }
private static final int[] KEY_SPACE = { KEYCODE_SPACE };
// Characters per second measurement // Characters per second measurement
private static final boolean PERF_DEBUG = false; private static final boolean PERF_DEBUG = false;

View File

@ -16,60 +16,38 @@
package com.android.inputmethod.latin; package com.android.inputmethod.latin;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle; import android.os.Bundle;
import android.preference.ListPreference; import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup; import android.preference.PreferenceGroup;
import android.text.AutoText;
public class LatinIMESettings extends PreferenceActivity public class LatinIMESettings extends PreferenceActivity {
implements OnSharedPreferenceChangeListener{
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_SETTINGS_KEY = "prediction_settings";
private static final String PREDICTION_LANDSCAPE_KEY = "prediction_landscape";
private ListPreference mCorrectionMode; private CheckBoxPreference mQuickFixes;
private PreferenceGroup mPredictionSettings; private CheckBoxPreference mShowSuggestions;
private Preference mPredictionLandscape;
@Override @Override
protected void onCreate(Bundle icicle) { protected void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
addPreferencesFromResource(R.xml.prefs); addPreferencesFromResource(R.xml.prefs);
mCorrectionMode = (ListPreference) findPreference(CORRECTION_MODE_KEY); mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY);
mPredictionSettings = (PreferenceGroup) findPreference(PREDICTION_SETTINGS_KEY); mShowSuggestions = (CheckBoxPreference) findPreference(SHOW_SUGGESTIONS_KEY);
mPredictionLandscape = findPreference(PREDICTION_LANDSCAPE_KEY);
updatePredictionSettings();
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
} }
@Override @Override
protected void onDestroy() { protected void onResume() {
getPreferenceScreen().getSharedPreferences() super.onResume();
.unregisterOnSharedPreferenceChangeListener(this); int autoTextSize = AutoText.getSize(getListView());
super.onDestroy(); if (autoTextSize < 1) {
} ((PreferenceGroup) findPreference(PREDICTION_SETTINGS_KEY))
.removePreference(mQuickFixes);
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 { } else {
mPredictionSettings.setEnabled(true); mShowSuggestions.setDependency(QUICK_FIXES_KEY);
boolean suggestionsInLandscape =
!correctionMode.equals(getResources().getString(R.string.prediction_full));
mPredictionLandscape.setEnabled(suggestionsInLandscape);
}
}
}
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
if (key.equals(CORRECTION_MODE_KEY)) {
updatePredictionSettings();
} }
} }
} }

View File

@ -17,38 +17,38 @@
package com.android.inputmethod.latin; package com.android.inputmethod.latin;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.graphics.Rect;
import android.content.SharedPreferences.Editor;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.opengl.Visibility;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.text.Layout; import android.text.Layout;
import android.text.SpannableStringBuilder;
import android.text.StaticLayout; import android.text.StaticLayout;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Tutorial { public class Tutorial implements OnTouchListener {
private List<Bubble> mBubbles = new ArrayList<Bubble>(); private List<Bubble> mBubbles = new ArrayList<Bubble>();
private long mStartTime; private long mStartTime;
private static final long MINIMUM_TIME = 6000; private static final long MINIMUM_TIME = 6000;
private static final long MAXIMUM_TIME = 20000; private static final long MAXIMUM_TIME = 20000;
private View mInputView; private View mInputView;
private LatinIME mIme;
private int[] mLocation = new int[2]; private int[] mLocation = new int[2];
private int mBubblePointerOffset; private int mBubblePointerOffset;
private static final int MSG_SHOW_BUBBLE = 0; private static final int MSG_SHOW_BUBBLE = 0;
private static final int MSG_HIDE_ALL = 1;
private int mBubbleIndex;
Handler mHandler = new Handler() { Handler mHandler = new Handler() {
@Override @Override
@ -58,8 +58,6 @@ public class Tutorial {
Bubble bubba = (Bubble) msg.obj; Bubble bubba = (Bubble) msg.obj;
bubba.show(mLocation[0], mLocation[1]); bubba.show(mLocation[0], mLocation[1]);
break; break;
case MSG_HIDE_ALL:
close(true);
} }
} }
}; };
@ -70,7 +68,7 @@ public class Tutorial {
int y; int y;
int width; int width;
int gravity; int gravity;
String text; CharSequence text;
boolean dismissOnTouch; boolean dismissOnTouch;
boolean dismissOnClose; boolean dismissOnClose;
PopupWindow window; PopupWindow window;
@ -78,16 +76,18 @@ public class Tutorial {
View inputView; View inputView;
Bubble(Context context, View inputView, Bubble(Context context, View inputView,
int backgroundResource, int bx, int by, int bw, int gravity, int textResource, int backgroundResource, int bx, int by, int textResource1, int textResource2) {
boolean dismissOnTouch, boolean dismissOnClose) {
bubbleBackground = context.getResources().getDrawable(backgroundResource); bubbleBackground = context.getResources().getDrawable(backgroundResource);
x = bx; x = bx;
y = by; y = by;
width = bw; width = (int) (inputView.getWidth() * 0.9);
this.gravity = gravity; this.gravity = Gravity.TOP | Gravity.LEFT;
text = context.getResources().getString(textResource); text = new SpannableStringBuilder()
this.dismissOnTouch = dismissOnTouch; .append(context.getResources().getText(textResource1))
this.dismissOnClose = dismissOnClose; .append("\n")
.append(context.getResources().getText(textResource2));
this.dismissOnTouch = true;
this.dismissOnClose = false;
this.inputView = inputView; this.inputView = inputView;
window = new PopupWindow(context); window = new PopupWindow(context);
window.setBackgroundDrawable(null); window.setBackgroundDrawable(null);
@ -97,19 +97,20 @@ public class Tutorial {
textView = (TextView) inflate.inflate(R.layout.bubble_text, null); textView = (TextView) inflate.inflate(R.layout.bubble_text, null);
textView.setBackgroundDrawable(bubbleBackground); textView.setBackgroundDrawable(bubbleBackground);
textView.setText(text); textView.setText(text);
//textView.setText(textResource1);
window.setContentView(textView); window.setContentView(textView);
window.setFocusable(false); window.setFocusable(false);
window.setTouchable(true); window.setTouchable(true);
window.setOutsideTouchable(false); window.setOutsideTouchable(false);
textView.setOnTouchListener(new View.OnTouchListener() { textView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent me) { public boolean onTouch(View view, MotionEvent me) {
Tutorial.this.touched(); Tutorial.this.next();
return true; 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 wid = tv.getPaddingLeft() + tv.getPaddingRight();
int ht = tv.getPaddingTop() + tv.getPaddingBottom(); int ht = tv.getPaddingTop() + tv.getPaddingBottom();
@ -131,10 +132,12 @@ public class Tutorial {
*/ */
pop.setWidth(width); pop.setWidth(width);
pop.setHeight(ht + l.getHeight()); pop.setHeight(ht + l.getHeight());
return l.getHeight();
} }
void show(int offx, int offy) { 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 if (inputView.getVisibility() == View.VISIBLE
&& inputView.getWindowVisibility() == View.VISIBLE) { && inputView.getWindowVisibility() == View.VISIBLE) {
try { try {
@ -155,72 +158,83 @@ public class Tutorial {
} }
} }
public Tutorial(LatinKeyboardView inputView) { public Tutorial(LatinIME ime, LatinKeyboardView inputView) {
Context context = inputView.getContext(); Context context = inputView.getContext();
int inputHeight = inputView.getHeight(); mIme = ime;
int inputWidth = inputView.getWidth(); int inputWidth = inputView.getWidth();
final int x = inputWidth / 20; // Half of 1/10th
mBubblePointerOffset = inputView.getContext().getResources() mBubblePointerOffset = inputView.getContext().getResources()
.getDimensionPixelOffset(R.dimen.bubble_pointer_offset); .getDimensionPixelOffset(R.dimen.bubble_pointer_offset);
Bubble b0 = new Bubble(context, inputView, Bubble bWelcome = new Bubble(context, inputView,
R.drawable.dialog_bubble_step02, 0, 0, R.drawable.dialog_bubble_step02, x, 0,
inputWidth, R.string.tip_to_open_keyboard, R.string.touch_to_continue);
Gravity.BOTTOM | Gravity.LEFT, mBubbles.add(bWelcome);
R.string.tip_dismiss, Bubble bAccents = new Bubble(context, inputView,
false, true); R.drawable.dialog_bubble_step02, x, 0,
mBubbles.add(b0); R.string.tip_to_view_accents, R.string.touch_to_continue);
// Bubble b1 = new Bubble(context, inputView, mBubbles.add(bAccents);
// R.drawable.dialog_bubble_step03, Bubble b123 = new Bubble(context, inputView,
// (int) (inputWidth * 0.85) + mBubblePointerOffset, inputHeight / 5, R.drawable.dialog_bubble_step07, x, 0,
// (int) (inputWidth * 0.45), R.string.tip_to_open_symbols, R.string.touch_to_continue);
// Gravity.TOP | Gravity.RIGHT, mBubbles.add(b123);
// R.string.tip_long_press, Bubble bABC = new Bubble(context, inputView,
// true, false); R.drawable.dialog_bubble_step07, x, 0,
// mBubbles.add(b1); R.string.tip_to_close_symbols, R.string.touch_to_continue);
// Bubble b2 = new Bubble(inputView.getContext(), inputView, mBubbles.add(bABC);
// R.drawable.dialog_bubble_step04, Bubble bSettings = new Bubble(context, inputView,
// inputWidth / 10 - mBubblePointerOffset, inputHeight - inputHeight / 5, R.drawable.dialog_bubble_step07, x, 0,
// (int) (inputWidth * 0.45), R.string.tip_to_launch_settings, R.string.touch_to_continue);
// Gravity.BOTTOM | Gravity.LEFT, mBubbles.add(bSettings);
// R.string.tip_access_symbols, Bubble bDone = new Bubble(context, inputView,
// true, false); R.drawable.dialog_bubble_step02, x, 0,
// mBubbles.add(b2); R.string.tip_to_start_typing, R.string.touch_to_finish);
mBubbles.add(bDone);
mInputView = inputView; mInputView = inputView;
} }
void start() { void start() {
mInputView.getLocationInWindow(mLocation); mInputView.getLocationInWindow(mLocation);
long delayMillis = 0; mBubbleIndex = -1;
for (int i = 0; i < mBubbles.size(); i++) { mInputView.setOnTouchListener(this);
mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SHOW_BUBBLE, mBubbles.get(i)), delayMillis); next();
delayMillis += 2000;
}
//mHandler.sendEmptyMessageDelayed(MSG_HIDE_ALL, MAXIMUM_TIME);
mStartTime = SystemClock.uptimeMillis();
} }
void touched() { boolean next() {
if (SystemClock.uptimeMillis() - mStartTime < MINIMUM_TIME) { if (mBubbleIndex >= 0) {
return; mBubbles.get(mBubbleIndex).hide();
} }
for (int i = 0; i < mBubbles.size(); i++) { mBubbleIndex++;
Bubble bubba = mBubbles.get(i); if (mBubbleIndex >= mBubbles.size()) {
if (bubba.dismissOnTouch) { mInputView.setOnTouchListener(null);
bubba.hide(); 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 close(boolean completed) { void hide() {
mHandler.removeMessages(MSG_SHOW_BUBBLE);
for (int i = 0; i < mBubbles.size(); i++) { for (int i = 0; i < mBubbles.size(); i++) {
mBubbles.get(i).hide(); mBubbles.get(i).hide();
} }
if (completed) { mInputView.setOnTouchListener(null);
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences( }
mInputView.getContext());
Editor editor = sp.edit(); boolean close() {
editor.putBoolean(LatinIME.PREF_TUTORIAL_RUN, true); mHandler.removeMessages(MSG_SHOW_BUBBLE);
editor.commit(); hide();
} return true;
}
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
next();
}
return true;
} }
} }