/*
* Copyright (C) 2008-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.latin;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.inputmethodservice.InputMethodService;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
import android.media.AudioManager;
import android.os.Debug;
import android.os.Handler;
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;
import android.util.PrintWriterPrinter;
import android.util.Printer;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
/**
* Input method implementation for Qwerty'ish keyboard.
*/
public class LatinIME extends InputMethodService
implements KeyboardView.OnKeyboardActionListener {
static final boolean DEBUG = false;
static final boolean TRACE = false;
private static final String PREF_VIBRATE_ON = "vibrate_on";
private static final String PREF_SOUND_ON = "sound_on";
private static final String PREF_AUTO_CAP = "auto_cap";
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_START_TUTORIAL = 1;
// How many continuous deletes at which to start deleting at a higher speed.
private static final int DELETE_ACCELERATE_AT = 20;
// Key events coming any faster than this are long-presses.
private static final int QUICK_PRESS = 200;
private static final int KEYCODE_ENTER = 10;
private static final int KEYCODE_SPACE = ' ';
// Contextual menu positions
private static final int POS_SETTINGS = 0;
private static final int POS_METHOD = 1;
private LatinKeyboardView mInputView;
private CandidateViewContainer mCandidateViewContainer;
private CandidateView mCandidateView;
private Suggest mSuggest;
private CompletionInfo[] mCompletions;
private AlertDialog mOptionsDialog;
KeyboardSwitcher mKeyboardSwitcher;
private UserDictionary mUserDictionary;
private String mLocale;
private StringBuilder mComposing = new StringBuilder();
private WordComposer mWord = new WordComposer();
private int mCommittedLength;
private boolean mPredicting;
private CharSequence mBestWord;
private boolean mPredictionOn;
private boolean mCompletionOn;
private boolean mAutoSpace;
private boolean mAutoCorrectOn;
private boolean mCapsLock;
private boolean mVibrateOn;
private boolean mSoundOn;
private boolean mAutoCap;
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 mJustAccepted;
private CharSequence mJustRevertedSeparator;
private int mDeleteCount;
private long mLastKeyTime;
private Tutorial mTutorial;
private Vibrator mVibrator;
private long mVibrateDuration;
private AudioManager mAudioManager;
private final float FX_VOLUME = 1.0f;
private boolean mSilentMode;
private String mWordSeparators;
private String mSentenceSeparators;
Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_UPDATE_SUGGESTIONS:
updateSuggestions();
break;
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;
}
}
};
@Override public void onCreate() {
super.onCreate();
//setStatusIcon(R.drawable.ime_qwerty);
mKeyboardSwitcher = new KeyboardSwitcher(this);
initSuggest(getResources().getConfiguration().locale.toString());
mVibrateDuration = getResources().getInteger(R.integer.vibrate_duration_ms);
// register to receive ringer mode changes for silent mode
IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION);
registerReceiver(mReceiver, filter);
}
private void initSuggest(String locale) {
mLocale = locale;
mSuggest = new Suggest(this, R.raw.main);
mSuggest.setCorrectionMode(mCorrectionMode);
mUserDictionary = new UserDictionary(this);
mSuggest.setUserDictionary(mUserDictionary);
mWordSeparators = getResources().getString(R.string.word_separators);
mSentenceSeparators = getResources().getString(R.string.sentence_separators);
}
@Override public void onDestroy() {
mUserDictionary.close();
unregisterReceiver(mReceiver);
super.onDestroy();
}
@Override
public void onConfigurationChanged(Configuration conf) {
if (!TextUtils.equals(conf.locale.toString(), mLocale)) {
initSuggest(conf.locale.toString());
}
super.onConfigurationChanged(conf);
}
@Override
public View onCreateInputView() {
mInputView = (LatinKeyboardView) getLayoutInflater().inflate(
R.layout.input, null);
mKeyboardSwitcher.setInputView(mInputView);
mKeyboardSwitcher.makeKeyboards();
mInputView.setOnKeyboardActionListener(this);
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_TEXT, 0);
return mInputView;
}
@Override
public View onCreateCandidatesView() {
mKeyboardSwitcher.makeKeyboards();
mCandidateViewContainer = (CandidateViewContainer) getLayoutInflater().inflate(
R.layout.candidates, null);
mCandidateViewContainer.initViews();
mCandidateView = (CandidateView) mCandidateViewContainer.findViewById(R.id.candidates);
mCandidateView.setService(this);
setCandidatesViewShown(true);
return mCandidateViewContainer;
}
@Override
public void onStartInputView(EditorInfo attribute, boolean restarting) {
// In landscape mode, this method gets ca
没有合适的资源?快使用搜索试试~ 我知道了~
深入浅出Google Android源码
共858个文件
class:274个
xml:164个
java:101个
4星 · 超过85%的资源 需积分: 10 141 下载量 40 浏览量
2010-08-01
11:24:45
上传
评论
收藏 1.4MB RAR 举报
温馨提示
作者: E2ECloud工作室 [作译者介绍] 丛书名: 图灵程序设计丛书 出版社:人民邮电出版社 随着越来越多的手机厂商和移动运营商加入了开放手机联盟,Android平台日益受到广大开发者的关注和推崇。. 本书是国内最早的Android开发团队的集体智慧结晶,真正完全基于Android最新的SDK 1.5,内容详实,示例生动丰富,包含大量示例代码,可操作性强。它不仅涵盖了Android平台从基础概念到高级应用的所有主题,而且深入浅出地介绍了几种常见的Android项目,具有很强的参考价值。特别是在本书的第10、11章重点介绍了Android SDK 1.5引入的最为重要的三个特性,即桌面部件、实时文件夹、虚拟键盘与输入法应用的开发方法。.. 通过本书,读者可以迅速掌握Android平台来构建应用程序,成为Android开发高手,跻身新技术的弄潮儿。
资源推荐
资源详情
资源评论
收起资源包目录
深入浅出Google Android源码 (858个子文件)
resources.ap_ 56KB
resources.ap_ 18KB
resources.ap_ 8KB
resources.ap_ 7KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 6KB
resources.ap_ 5KB
resources.ap_ 5KB
resources.ap_ 5KB
resources.ap_ 5KB
resources.ap_ 5KB
resources.ap_ 5KB
resources.ap_ 5KB
resources.ap_ 5KB
ex5.apk 59KB
TinyPlayer.apk 26KB
LiveFolderSample.apk 13KB
EarthquakeListWithMap.apk 13KB
SQLite2.apk 12KB
CurrentWeather.apk 12KB
ESTTime.apk 11KB
CurrentLocationWithMap.apk 11KB
EarthquakeList.apk 11KB
SQLite3.apk 10KB
HttpPostConnection.apk 10KB
ParsingXML.apk 10KB
ex1.apk 10KB
TinySMS.apk 10KB
CurrentLocation.apk 10KB
TinyDialer.apk 10KB
UrgentCall.apk 10KB
ex1.apk 9KB
ex13.apk 9KB
ex3.apk 9KB
FileIO.apk 9KB
Preferences.apk 9KB
HttpGet.apk 9KB
ex12.apk 9KB
ex10.apk 9KB
SQLite1.apk 9KB
ex11.apk 9KB
ex8.apk 9KB
ex4.apk 9KB
SQLite4.apk 8KB
ex7.apk 8KB
ex9.apk 8KB
ex2.apk 8KB
ex14.apk 8KB
ex6.apk 8KB
MyAllContacts.apk 8KB
TinyPlayer.class 6KB
EarthquakeList.class 6KB
MyProvider.class 6KB
MyProvider.class 6KB
EarthquakeList.class 5KB
HttpPostConnection.class 5KB
CurrentLocationWithMap.class 5KB
CurrentWeather$1.class 4KB
SQLite2.class 4KB
SQLite2.class 4KB
GoogleWeatherHandler.class 3KB
MusicPlayService.class 3KB
CurrentLocation.class 3KB
EarthquakeList$1.class 3KB
ExampleHandler.class 3KB
UrgentCall.class 3KB
ParsingXML.class 2KB
TinySMS.class 2KB
SQLite3.class 2KB
MyAllContacts.class 2KB
FileIO.class 2KB
TinyPlayer$2.class 2KB
TinyPlayer$UpdateReceiver.class 2KB
MusicPlayService$CommandReceiver.class 2KB
HttpGet.class 2KB
SQLite3$1.class 2KB
TinyDialer$1.class 2KB
Preferences.class 2KB
共 858 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
- xuwei_20082012-02-28我怎么解压不出来,解压过程中报错了!
- wolfdancing2013-03-05可用,很是不错
- mfdqb2012-08-09楼上的没下载好吧,可以解压的
- gxy7818958022012-04-24可以解压的呀,很好用
echoes2017
- 粉丝: 7
- 资源: 17
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功