Merge commit 'goog/master'

main
satok 2010-05-12 10:05:17 +09:00
commit f6ecc28767
8 changed files with 35 additions and 126 deletions

View File

@ -21,4 +21,8 @@
<color name="candidate_normal">#FF000000</color> <color name="candidate_normal">#FF000000</color>
<color name="candidate_recommended">#FFE35900</color> <color name="candidate_recommended">#FFE35900</color>
<color name="candidate_other">#ff808080</color> <color name="candidate_other">#ff808080</color>
<color name="latinkeyboard_transparent">#00000000</color>
<color name="latinkeyboard_bar_language_shadow">#80000000</color>
<color name="latinkeyboard_bar_language_text">#FF808080</color>
<color name="latinkeyboard_text_color">#FF000000</color>
</resources> </resources>

View File

@ -40,7 +40,6 @@ import android.os.Message;
import android.os.SystemClock; import android.os.SystemClock;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.speech.SpeechRecognizer; import android.speech.SpeechRecognizer;
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;
@ -78,6 +77,7 @@ public class LatinIME extends InputMethodService
VoiceInput.UiListener, VoiceInput.UiListener,
SharedPreferences.OnSharedPreferenceChangeListener { SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "LatinIME"; private static final String TAG = "LatinIME";
private static final boolean PERF_DEBUG = false;
static final boolean DEBUG = false; static final boolean DEBUG = false;
static final boolean TRACE = false; static final boolean TRACE = false;
static final boolean VOICE_INSTALLED = true; static final boolean VOICE_INSTALLED = true;
@ -189,7 +189,6 @@ public class LatinIME extends InputMethodService
private boolean mAutoCorrectOn; private boolean mAutoCorrectOn;
private boolean mCapsLock; private boolean mCapsLock;
private boolean mPasswordText; private boolean mPasswordText;
private boolean mEmailText;
private boolean mVibrateOn; private boolean mVibrateOn;
private boolean mSoundOn; private boolean mSoundOn;
private boolean mAutoCap; private boolean mAutoCap;
@ -458,7 +457,6 @@ public class LatinIME extends InputMethodService
mCompletionOn = false; mCompletionOn = false;
mCompletions = null; mCompletions = null;
mCapsLock = false; mCapsLock = false;
mEmailText = false;
mEnteredText = null; mEnteredText = null;
switch (attribute.inputType & EditorInfo.TYPE_MASK_CLASS) { switch (attribute.inputType & EditorInfo.TYPE_MASK_CLASS) {
@ -481,9 +479,6 @@ public class LatinIME extends InputMethodService
variation == EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD ) { variation == EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD ) {
mPredictionOn = false; mPredictionOn = false;
} }
if (variation == EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS) {
mEmailText = true;
}
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) {
mAutoSpace = false; mAutoSpace = false;
@ -683,7 +678,7 @@ public class LatinIME extends InputMethodService
@Override @Override
public void onDisplayCompletions(CompletionInfo[] completions) { public void onDisplayCompletions(CompletionInfo[] completions) {
if (false) { if (DEBUG) {
Log.i("foo", "Received completions:"); Log.i("foo", "Received completions:");
for (int i=0; i<(completions != null ? completions.length : 0); i++) { for (int i=0; i<(completions != null ? completions.length : 0); i++) {
Log.i("foo", " #" + i + ": " + completions[i]); Log.i("foo", " #" + i + ": " + completions[i]);
@ -1126,7 +1121,7 @@ public class LatinIME extends InputMethodService
sendKeyChar((char)primaryCode); sendKeyChar((char)primaryCode);
} }
updateShiftKeyState(getCurrentInputEditorInfo()); updateShiftKeyState(getCurrentInputEditorInfo());
measureCps(); if (LatinIME.PERF_DEBUG) measureCps();
TextEntryState.typedCharacter((char) primaryCode, isWordSeparator(primaryCode)); TextEntryState.typedCharacter((char) primaryCode, isWordSeparator(primaryCode));
} }
@ -1868,7 +1863,7 @@ public class LatinIME extends InputMethodService
launchSettings(LatinIMESettings.class); launchSettings(LatinIMESettings.class);
} }
protected void launchSettings(Class settingsClass) { protected void launchSettings(Class<LatinIMESettings> settingsClass) {
handleClose(); handleClose();
Intent intent = new Intent(); Intent intent = new Intent();
intent.setClass(LatinIME.this, settingsClass); intent.setClass(LatinIME.this, settingsClass);
@ -2005,7 +2000,6 @@ public class LatinIME extends InputMethodService
// Characters per second measurement // Characters per second measurement
private static final boolean PERF_DEBUG = false;
private long mLastCpsTime; private long mLastCpsTime;
private static final int CPS_BUFFER_SIZE = 16; private static final int CPS_BUFFER_SIZE = 16;
private long[] mCpsIntervals = new long[CPS_BUFFER_SIZE]; private long[] mCpsIntervals = new long[CPS_BUFFER_SIZE];
@ -2013,7 +2007,6 @@ public class LatinIME extends InputMethodService
private boolean mInputTypeNoAutoCorrect; private boolean mInputTypeNoAutoCorrect;
private void measureCps() { private void measureCps() {
if (!LatinIME.PERF_DEBUG) return;
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (mLastCpsTime == 0) mLastCpsTime = now - 100; // Initial if (mLastCpsTime == 0) mLastCpsTime = now - 100; // Initial
mCpsIntervals[mCpsIndex] = now - mLastCpsTime; mCpsIntervals[mCpsIndex] = now - mLastCpsTime;

View File

@ -47,7 +47,6 @@ public class LatinKeyboard extends Keyboard {
private Drawable mShiftLockIcon; private Drawable mShiftLockIcon;
private Drawable mShiftLockPreviewIcon; private Drawable mShiftLockPreviewIcon;
private Drawable mOldShiftIcon; private Drawable mOldShiftIcon;
private Drawable mOldShiftPreviewIcon;
private Drawable mSpaceIcon; private Drawable mSpaceIcon;
private Drawable mSpacePreviewIcon; private Drawable mSpacePreviewIcon;
private Drawable mMicIcon; private Drawable mMicIcon;
@ -68,7 +67,6 @@ public class LatinKeyboard extends Keyboard {
private LanguageSwitcher mLanguageSwitcher; private LanguageSwitcher mLanguageSwitcher;
private Resources mRes; private Resources mRes;
private Context mContext; private Context mContext;
private int mMode;
// Whether this keyboard has voice icon on it // Whether this keyboard has voice icon on it
private boolean mHasVoiceButton; private boolean mHasVoiceButton;
// Whether voice icon is enabled at all // Whether voice icon is enabled at all
@ -77,9 +75,7 @@ public class LatinKeyboard extends Keyboard {
private CharSequence m123Label; private CharSequence m123Label;
private boolean mCurrentlyInSpace; private boolean mCurrentlyInSpace;
private SlidingLocaleDrawable mSlidingLocaleIcon; private SlidingLocaleDrawable mSlidingLocaleIcon;
private Rect mBounds = new Rect();
private int[] mPrefLetterFrequencies; private int[] mPrefLetterFrequencies;
private boolean mPreemptiveCorrection;
private int mPrefLetter; private int mPrefLetter;
private int mPrefLetterX; private int mPrefLetterX;
private int mPrefLetterY; private int mPrefLetterY;
@ -107,7 +103,6 @@ public class LatinKeyboard extends Keyboard {
super(context, xmlLayoutResId, mode); super(context, xmlLayoutResId, mode);
final Resources res = context.getResources(); final Resources res = context.getResources();
mContext = context; mContext = context;
mMode = mode;
mRes = res; mRes = res;
mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked); mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked);
mShiftLockPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked); mShiftLockPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked);
@ -224,7 +219,6 @@ public class LatinKeyboard extends Keyboard {
((LatinKey)mShiftKey).enableShiftLock(); ((LatinKey)mShiftKey).enableShiftLock();
} }
mOldShiftIcon = mShiftKey.icon; mOldShiftIcon = mShiftKey.icon;
mOldShiftPreviewIcon = mShiftKey.iconPreview;
} }
} }
@ -338,21 +332,19 @@ public class LatinKeyboard extends Keyboard {
} }
private void drawSpaceBar(Canvas canvas, int width, int height, int opacity) { private void drawSpaceBar(Canvas canvas, int width, int height, int opacity) {
canvas.drawColor(0x00000000, PorterDuff.Mode.CLEAR); canvas.drawColor(mRes.getColor(R.color.latinkeyboard_transparent), PorterDuff.Mode.CLEAR);
Paint paint = new Paint(); Paint paint = new Paint();
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setAlpha(opacity); paint.setAlpha(opacity);
// Get the text size from the theme // Get the text size from the theme
paint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Small, 14)); paint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Small, 14));
paint.setTextAlign(Align.CENTER); paint.setTextAlign(Align.CENTER);
//// Draw a drop shadow for the text
//paint.setShadowLayer(2f, 0, 0, 0xFF000000);
final String language = getInputLanguage(mSpaceKey.width, paint); final String language = getInputLanguage(mSpaceKey.width, paint);
final int ascent = (int) -paint.ascent(); final int ascent = (int) -paint.ascent();
paint.setColor(0x80000000); paint.setColor(mRes.getColor(R.color.latinkeyboard_bar_language_shadow));
canvas.drawText(language, canvas.drawText(language,
width / 2, ascent - 1, paint); width / 2, ascent - 1, paint);
paint.setColor(0xFF808080); paint.setColor(mRes.getColor(R.color.latinkeyboard_bar_language_text));
canvas.drawText(language, canvas.drawText(language,
width / 2, ascent, paint); width / 2, ascent, paint);
// Put arrows on either side of the text // Put arrows on either side of the text
@ -503,9 +495,10 @@ public class LatinKeyboard extends Keyboard {
// Handle preferred next letter // Handle preferred next letter
final int[] pref = mPrefLetterFrequencies; final int[] pref = mPrefLetterFrequencies;
if (mPrefLetter > 0) { if (mPrefLetter > 0) {
if (DEBUG_PREFERRED_LETTER && mPrefLetter == code if (DEBUG_PREFERRED_LETTER) {
&& !key.isInsideSuper(x, y)) { if (mPrefLetter == code && !key.isInsideSuper(x, y)) {
Log.d(TAG, "CORRECTED !!!!!!"); Log.d(TAG, "CORRECTED !!!!!!");
}
} }
return mPrefLetter == code; return mPrefLetter == code;
} else { } else {
@ -718,7 +711,7 @@ public class LatinKeyboard extends Keyboard {
public void draw(Canvas canvas) { public void draw(Canvas canvas) {
canvas.save(); canvas.save();
if (mHitThreshold) { if (mHitThreshold) {
mTextPaint.setColor(0xFF000000); mTextPaint.setColor(mRes.getColor(R.color.latinkeyboard_text_color));
canvas.clipRect(0, 0, mWidth, mHeight); canvas.clipRect(0, 0, mWidth, mHeight);
if (mCurrentLanguage == null) { if (mCurrentLanguage == null) {
mCurrentLanguage = getInputLanguage(mWidth, mTextPaint); mCurrentLanguage = getInputLanguage(mWidth, mTextPaint);

View File

@ -23,7 +23,6 @@ import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.inputmethodservice.Keyboard; import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView; import android.inputmethodservice.KeyboardView;
import android.inputmethodservice.KeyboardView.OnKeyboardActionListener;
import android.inputmethodservice.Keyboard.Key; import android.inputmethodservice.Keyboard.Key;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
@ -453,26 +452,29 @@ public class LatinKeyboardView extends KeyboardView {
} }
} }
void startPlaying(String s) { public void startPlaying(String s) {
if (!DEBUG_AUTO_PLAY) return; if (DEBUG_AUTO_PLAY) {
if (s == null) return; if (s == null) return;
mStringToPlay = s.toLowerCase(); mStringToPlay = s.toLowerCase();
mPlaying = true; mPlaying = true;
mDownDelivered = false; mDownDelivered = false;
mStringIndex = 0; mStringIndex = 0;
mHandler2.sendEmptyMessageDelayed(MSG_TOUCH_DOWN, 10); mHandler2.sendEmptyMessageDelayed(MSG_TOUCH_DOWN, 10);
}
} }
@Override @Override
public void draw(Canvas c) { public void draw(Canvas c) {
super.draw(c); super.draw(c);
if (DEBUG_AUTO_PLAY && mPlaying) { if (DEBUG_AUTO_PLAY) {
mHandler2.removeMessages(MSG_TOUCH_DOWN); if (mPlaying) {
mHandler2.removeMessages(MSG_TOUCH_UP); mHandler2.removeMessages(MSG_TOUCH_DOWN);
if (mDownDelivered) { mHandler2.removeMessages(MSG_TOUCH_UP);
mHandler2.sendEmptyMessageDelayed(MSG_TOUCH_UP, 20); if (mDownDelivered) {
} else { mHandler2.sendEmptyMessageDelayed(MSG_TOUCH_UP, 20);
mHandler2.sendEmptyMessageDelayed(MSG_TOUCH_DOWN, 20); } else {
mHandler2.sendEmptyMessageDelayed(MSG_TOUCH_DOWN, 20);
}
} }
} }
if (DEBUG_LINE) { if (DEBUG_LINE) {

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) 2009 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.android.inputmethod.voice;
import android.content.Intent;
import com.android.inputmethod.latin.LatinIME;
public class LatinIMEWithVoice extends LatinIME {
@Override
protected void launchSettings() {
launchSettings(LatinIMEWithVoiceSettings.class);
}
}

View File

@ -1,21 +0,0 @@
/*
* Copyright (C) 2009 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.android.inputmethod.voice;
import com.android.inputmethod.latin.LatinIMESettings;
public class LatinIMEWithVoiceSettings extends LatinIMESettings {}

View File

@ -1,29 +0,0 @@
/*
*
* Copyright (C) 2009 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.android.voicesearch;
import android.content.Intent;
import com.android.inputmethod.latin.LatinIME;
public class LatinIMEWithVoice extends LatinIME {
@Override
protected void launchSettings() {
launchSettings(LatinIMEWithVoiceSettings.class);
}
}

View File

@ -1,5 +0,0 @@
package com.google.android.voicesearch;
import com.android.inputmethod.latin.LatinIMESettings;
public class LatinIMEWithVoiceSettings extends LatinIMESettings {}