Merge remote-tracking branch 'goog/master' into merge
Conflicts: java/res/xml/method.xml java/res/xml/prefs.xml Change-Id: I466a43c56ec01ddac2f8ae4f15dd3a7f8c21175dmain
commit
e75e4463cd
|
@ -0,0 +1,101 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
** Copyright 2011, The Android Open Source Project
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:background="@drawable/background_voice">
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/popup_layout"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_height="371dip"
|
||||||
|
android:layout_width="500dip"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:background="@drawable/vs_dialog_red">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text"
|
||||||
|
android:text="@string/voice_error"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:layout_marginTop="10dip"
|
||||||
|
android:textSize="28sp"
|
||||||
|
android:textColor="#ffffff"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:visibility="invisible"/>
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_height="0dip"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_weight="1.0">
|
||||||
|
<com.android.inputmethod.deprecated.voice.SoundIndicator
|
||||||
|
android:id="@+id/sound_indicator"
|
||||||
|
android:src="@drawable/mic_full"
|
||||||
|
android:background="@drawable/mic_base"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/image"
|
||||||
|
android:src="@drawable/mic_slash"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:visibility="visible"/>
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:indeterminateOnly="false"
|
||||||
|
android:layout_height="60dip"
|
||||||
|
android:layout_width="60dip"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
<!--
|
||||||
|
The text is set by the code. We specify a random text (voice_error), so the
|
||||||
|
text view does not have a zero height. This is necessary to keep the slash
|
||||||
|
mic and the recording mic is the same position
|
||||||
|
-->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/language"
|
||||||
|
android:text="@string/voice_error"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:layout_marginBottom="3dip"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:textColor="#ffffff"
|
||||||
|
android:visibility="invisible"/>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="54dip"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:text="@string/cancel"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:background="@drawable/btn_center"
|
||||||
|
android:textColor="#ffffff"
|
||||||
|
android:textSize="19sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</RelativeLayout>
|
|
@ -1,19 +1,19 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
/*
|
/*
|
||||||
**
|
**
|
||||||
** Copyright 2009, The Android Open Source Project
|
** Copyright 2009, The Android Open Source Project
|
||||||
**
|
**
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
** you may not use this file except in compliance with the License.
|
** you may not use this file except in compliance with the License.
|
||||||
** You may obtain a copy of the License at
|
** You may obtain a copy of the License at
|
||||||
**
|
**
|
||||||
** http://www.apache.org/licenses/LICENSE-2.0
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
**
|
**
|
||||||
** Unless required by applicable law or agreed to in writing, software
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
** See the License for the specific language governing permissions and
|
** See the License for the specific language governing permissions and
|
||||||
** limitations under the License.
|
** limitations under the License.
|
||||||
*/
|
*/
|
||||||
-->
|
-->
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:layout_marginTop="10dip"
|
android:layout_marginTop="10dip"
|
||||||
android:textSize="28sp"
|
android:textSize="20sp"
|
||||||
android:textColor="#ffffff"
|
android:textColor="#ffffff"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:visibility="invisible"/>
|
android:visibility="invisible"/>
|
||||||
|
@ -81,7 +81,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textSize="14sp"
|
android:textSize="15sp"
|
||||||
|
android:layout_marginTop="3dip"
|
||||||
android:layout_marginBottom="3dip"
|
android:layout_marginBottom="3dip"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:textColor="#ffffff"
|
android:textColor="#ffffff"
|
||||||
|
@ -89,13 +90,13 @@
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button"
|
android:id="@+id/button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="54dip"
|
android:layout_height="30dip"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:text="@string/cancel"
|
android:text="@string/cancel"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:background="@drawable/btn_center"
|
android:background="@drawable/btn_center"
|
||||||
android:textColor="#ffffff"
|
android:textColor="#ffffff"
|
||||||
android:textSize="19sp" />
|
android:textSize="15sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
** Copyright 2011, The Android Open Source Project
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<bool name="config_require_umlaut_processing">true</bool>
|
||||||
|
</resources>
|
|
@ -78,4 +78,5 @@
|
||||||
</string-array>
|
</string-array>
|
||||||
<!-- Screen metrics for logging. 0 = "mdpi", 1 = "hdpi", 2 = "xlarge" -->
|
<!-- Screen metrics for logging. 0 = "mdpi", 1 = "hdpi", 2 = "xlarge" -->
|
||||||
<integer name="log_screen_metrics">0</integer>
|
<integer name="log_screen_metrics">0</integer>
|
||||||
|
<bool name="config_require_umlaut_processing">false</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -48,7 +48,8 @@
|
||||||
<string name="alternates_for_currency_euro">¢,£,$,¥,₱</string>
|
<string name="alternates_for_currency_euro">¢,£,$,¥,₱</string>
|
||||||
<string name="alternates_for_currency_pound">¢,$,€,¥,₱</string>
|
<string name="alternates_for_currency_pound">¢,$,€,¥,₱</string>
|
||||||
<string name="alternates_for_smiley">":-)|:-) ,:-(|:-( ,;-)|;-) ,:-P|:-P ,=-O|=-O ,:-*|:-* ,:O|:O ,B-)|B-) ,:-$|:-$ ,:-!|:-! ,:-[|:-[ ,O:-)|O:-) ,:-\\\\\\\\|:-\\\\\\\\ ,:\'(|:\'( ,:-D|:-D "</string>
|
<string name="alternates_for_smiley">":-)|:-) ,:-(|:-( ,;-)|;-) ,:-P|:-P ,=-O|=-O ,:-*|:-* ,:O|:O ,B-)|B-) ,:-$|:-$ ,:-!|:-! ,:-[|:-[ ,O:-)|O:-) ,:-\\\\\\\\|:-\\\\\\\\ ,:\'(|:\'( ,:-D|:-D "</string>
|
||||||
<string name="alternates_for_punctuation">":,/,&,(,),-,+,;,\@,\',\",\?,!,\\,"</string>
|
<string name="alternates_for_punctuation">"\?,!,\\,,:,-,\',\",(,),/,;,+,&,\@"</string>
|
||||||
|
<string name="alternates_for_web_tab_punctuation">".,\?,!,\\,,:,-,\',\",(,),/,;,+,&,\@"</string>
|
||||||
<string name="keylabel_for_popular_domain">".com"</string>
|
<string name="keylabel_for_popular_domain">".com"</string>
|
||||||
<!-- popular web domains for the locale - most popular, displayed on the keyboard -->
|
<!-- popular web domains for the locale - most popular, displayed on the keyboard -->
|
||||||
<string name="alternates_for_popular_domain">".net,.org,.gov,.edu"</string>
|
<string name="alternates_for_popular_domain">".net,.org,.gov,.edu"</string>
|
||||||
|
|
|
@ -45,6 +45,13 @@
|
||||||
latin:keyStyle="micKeyStyle" />
|
latin:keyStyle="micKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<!-- latin:hasVoiceKey="false" -->
|
<!-- latin:hasVoiceKey="false" -->
|
||||||
|
<case
|
||||||
|
latin:mode="web"
|
||||||
|
>
|
||||||
|
<Key
|
||||||
|
latin:keyLabel="."
|
||||||
|
latin:keyStyle="settingsPopupStyle" />
|
||||||
|
</case>
|
||||||
<default>
|
<default>
|
||||||
<Key
|
<Key
|
||||||
latin:keyLabel=","
|
latin:keyLabel=","
|
||||||
|
|
|
@ -43,8 +43,10 @@
|
||||||
latin:mode="web"
|
latin:mode="web"
|
||||||
>
|
>
|
||||||
<Key
|
<Key
|
||||||
latin:keyStyle="tabKeyStyle"
|
latin:keyHintIcon="@drawable/hint_popup"
|
||||||
latin:keyWidth="10%p" />
|
latin:popupCharacters="@string/alternates_for_web_tab_punctuation"
|
||||||
|
latin:maxPopupKeyboardColumn="8"
|
||||||
|
latin:keyStyle="tabKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<default>
|
<default>
|
||||||
<Key
|
<Key
|
||||||
|
@ -83,28 +85,28 @@
|
||||||
latin:keyStyle="settingsKeyStyle" />
|
latin:keyStyle="settingsKeyStyle" />
|
||||||
<include
|
<include
|
||||||
latin:keyboardLayout="@xml/kbd_qwerty_f1" />
|
latin:keyboardLayout="@xml/kbd_qwerty_f1" />
|
||||||
|
<Key
|
||||||
|
latin:keyStyle="spaceKeyStyle"
|
||||||
|
latin:keyWidth="30%p" />
|
||||||
<switch>
|
<switch>
|
||||||
<case
|
<case
|
||||||
latin:mode="web"
|
latin:mode="web"
|
||||||
>
|
>
|
||||||
<Key
|
<Key
|
||||||
latin:keyStyle="spaceKeyStyle"
|
latin:keyHintIcon="@drawable/hint_popup"
|
||||||
latin:keyWidth="30%p" />
|
latin:popupCharacters="@string/alternates_for_web_tab_punctuation"
|
||||||
<Key
|
latin:maxPopupKeyboardColumn="8"
|
||||||
latin:keyStyle="tabKeyStyle" />
|
latin:keyStyle="tabKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<default>
|
<default>
|
||||||
<Key
|
<Key
|
||||||
latin:keyStyle="spaceKeyStyle"
|
latin:keyLabel="."
|
||||||
latin:keyWidth="30%p" />
|
latin:keyHintIcon="@drawable/hint_popup"
|
||||||
|
latin:popupCharacters="@string/alternates_for_punctuation"
|
||||||
|
latin:maxPopupKeyboardColumn="7"
|
||||||
|
latin:keyStyle="functionalKeyStyle" />
|
||||||
</default>
|
</default>
|
||||||
</switch>
|
</switch>
|
||||||
<Key
|
|
||||||
latin:keyLabel="."
|
|
||||||
latin:keyHintIcon="@drawable/hint_popup"
|
|
||||||
latin:popupCharacters="@string/alternates_for_punctuation"
|
|
||||||
latin:maxPopupKeyboardColumn="7"
|
|
||||||
latin:keyStyle="functionalKeyStyle" />
|
|
||||||
<switch>
|
<switch>
|
||||||
<case
|
<case
|
||||||
latin:mode="im"
|
latin:mode="im"
|
||||||
|
@ -114,14 +116,6 @@
|
||||||
latin:keyWidth="25%p"
|
latin:keyWidth="25%p"
|
||||||
latin:keyEdgeFlags="right" />
|
latin:keyEdgeFlags="right" />
|
||||||
</case>
|
</case>
|
||||||
<case
|
|
||||||
latin:mode="web"
|
|
||||||
>
|
|
||||||
<Key
|
|
||||||
latin:keyStyle="returnKeyStyle"
|
|
||||||
latin:keyWidth="15%p"
|
|
||||||
latin:keyEdgeFlags="right" />
|
|
||||||
</case>
|
|
||||||
<default>
|
<default>
|
||||||
<Key
|
<Key
|
||||||
latin:keyStyle="returnKeyStyle"
|
latin:keyStyle="returnKeyStyle"
|
||||||
|
|
|
@ -107,7 +107,7 @@
|
||||||
android:title="@string/prefs_enable_log"
|
android:title="@string/prefs_enable_log"
|
||||||
android:summary="@string/prefs_description_log"
|
android:summary="@string/prefs_description_log"
|
||||||
android:persistent="true"
|
android:persistent="true"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="true" />
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="pref_keyboard_layout_20100902"
|
android:key="pref_keyboard_layout_20100902"
|
||||||
android:title="@string/keyboard_layout"
|
android:title="@string/keyboard_layout"
|
||||||
|
@ -115,12 +115,12 @@
|
||||||
android:entryValues="@array/keyboard_layout_modes_values"
|
android:entryValues="@array/keyboard_layout_modes_values"
|
||||||
android:entries="@array/keyboard_layout_modes"
|
android:entries="@array/keyboard_layout_modes"
|
||||||
android:defaultValue="@string/config_default_keyboard_theme_id" />
|
android:defaultValue="@string/config_default_keyboard_theme_id" />
|
||||||
<Preference
|
<!-- <Preference
|
||||||
android:title="Debug Settings"
|
android:title="Debug Settings"
|
||||||
android:key="debug_settings">
|
android:key="debug_settings">
|
||||||
<intent
|
<intent
|
||||||
android:action="android.intent.action.MAIN"
|
android:action="android.intent.action.MAIN"
|
||||||
android:targetPackage="com.android.inputmethod.latin"
|
android:targetPackage="com.android.inputmethod.latin"
|
||||||
android:targetClass="com.android.inputmethod.latin.DebugSettings" />
|
android:targetClass="com.android.inputmethod.latin.DebugSettings" />
|
||||||
</Preference>
|
</Preference>-->
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
|
@ -67,7 +67,8 @@ public class InputMethodManagerCompatWrapper {
|
||||||
|
|
||||||
// For the compatibility, IMM will create dummy subtypes if subtypes are not found.
|
// For the compatibility, IMM will create dummy subtypes if subtypes are not found.
|
||||||
// This is required to be false if the current behavior is broken. For now, it's ok to be true.
|
// This is required to be false if the current behavior is broken. For now, it's ok to be true.
|
||||||
private static final boolean HAS_VOICE_FUNCTION = true;
|
public static final boolean FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES =
|
||||||
|
!InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED;
|
||||||
private static final String VOICE_MODE = "voice";
|
private static final String VOICE_MODE = "voice";
|
||||||
private static final String KEYBOARD_MODE = "keyboard";
|
private static final String KEYBOARD_MODE = "keyboard";
|
||||||
|
|
||||||
|
@ -118,8 +119,7 @@ public class InputMethodManagerCompatWrapper {
|
||||||
Object retval = CompatUtils.invoke(mImm, null, METHOD_getEnabledInputMethodSubtypeList,
|
Object retval = CompatUtils.invoke(mImm, null, METHOD_getEnabledInputMethodSubtypeList,
|
||||||
(imi != null ? imi.getInputMethodInfo() : null), allowsImplicitlySelectedSubtypes);
|
(imi != null ? imi.getInputMethodInfo() : null), allowsImplicitlySelectedSubtypes);
|
||||||
if (retval == null || !(retval instanceof List) || ((List<?>)retval).isEmpty()) {
|
if (retval == null || !(retval instanceof List) || ((List<?>)retval).isEmpty()) {
|
||||||
if (InputMethodServiceCompatWrapper.
|
if (!FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES) {
|
||||||
CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) {
|
|
||||||
// Returns an empty list
|
// Returns an empty list
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ public class InputMethodManagerCompatWrapper {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private InputMethodSubtypeCompatWrapper getLastResortSubtype(String mode) {
|
private InputMethodSubtypeCompatWrapper getLastResortSubtype(String mode) {
|
||||||
if (VOICE_MODE.equals(mode) && !HAS_VOICE_FUNCTION)
|
if (VOICE_MODE.equals(mode) && !FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES)
|
||||||
return null;
|
return null;
|
||||||
Locale inputLocale = SubtypeSwitcher.getInstance().getInputLocale();
|
Locale inputLocale = SubtypeSwitcher.getInstance().getInputLocale();
|
||||||
if (inputLocale == null)
|
if (inputLocale == null)
|
||||||
|
@ -160,8 +160,7 @@ public class InputMethodManagerCompatWrapper {
|
||||||
getShortcutInputMethodsAndSubtypes() {
|
getShortcutInputMethodsAndSubtypes() {
|
||||||
Object retval = CompatUtils.invoke(mImm, null, METHOD_getShortcutInputMethodsAndSubtypes);
|
Object retval = CompatUtils.invoke(mImm, null, METHOD_getShortcutInputMethodsAndSubtypes);
|
||||||
if (retval == null || !(retval instanceof Map) || ((Map<?, ?>)retval).isEmpty()) {
|
if (retval == null || !(retval instanceof Map) || ((Map<?, ?>)retval).isEmpty()) {
|
||||||
if (InputMethodServiceCompatWrapper.
|
if (!FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES) {
|
||||||
CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) {
|
|
||||||
// Returns an empty map
|
// Returns an empty map
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,11 +47,17 @@ public class InputMethodServiceCompatWrapper extends InputMethodService {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void notifyOnCurrentInputMethodSubtypeChanged(InputMethodSubtypeCompatWrapper subtype) {
|
public void notifyOnCurrentInputMethodSubtypeChanged(InputMethodSubtypeCompatWrapper subtype) {
|
||||||
// Do nothing when the API level is 11 or later
|
// Do nothing when the API level is 11 or later
|
||||||
if (CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) return;
|
// and FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES is not true
|
||||||
|
if (CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED && !InputMethodManagerCompatWrapper.
|
||||||
|
FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (subtype == null) {
|
if (subtype == null) {
|
||||||
subtype = mImm.getCurrentInputMethodSubtype();
|
subtype = mImm.getCurrentInputMethodSubtype();
|
||||||
}
|
}
|
||||||
if (subtype != null) {
|
if (subtype != null) {
|
||||||
|
if (!InputMethodManagerCompatWrapper.FORCE_ENABLE_VOICE_EVEN_WITH_NO_VOICE_SUBTYPES
|
||||||
|
&& !subtype.isDummy()) return;
|
||||||
if (!InputMethodManagerCompatWrapper.SUBTYPE_SUPPORTED) {
|
if (!InputMethodManagerCompatWrapper.SUBTYPE_SUPPORTED) {
|
||||||
LanguageSwitcherProxy.getInstance().setLocale(subtype.getLocale());
|
LanguageSwitcherProxy.getInstance().setLocale(subtype.getLocale());
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,10 @@ public final class InputMethodSubtypeCompatWrapper extends AbstractCompatWrapper
|
||||||
return (String)CompatUtils.invoke(mObj, null, METHOD_getExtraValueOf, key);
|
return (String)CompatUtils.invoke(mObj, null, METHOD_getExtraValueOf, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDummy() {
|
||||||
|
return !hasOriginalObject();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o instanceof InputMethodSubtypeCompatWrapper) {
|
if (o instanceof InputMethodSubtypeCompatWrapper) {
|
||||||
|
|
|
@ -63,18 +63,12 @@ public class BinaryDictionary extends Dictionary {
|
||||||
|
|
||||||
private final KeyboardSwitcher mKeyboardSwitcher = KeyboardSwitcher.getInstance();
|
private final KeyboardSwitcher mKeyboardSwitcher = KeyboardSwitcher.getInstance();
|
||||||
|
|
||||||
public static class Flag {
|
|
||||||
public final String mName;
|
|
||||||
public final int mValue;
|
|
||||||
|
|
||||||
public Flag(String name, int value) {
|
|
||||||
mName = name;
|
|
||||||
mValue = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Flag FLAG_REQUIRES_GERMAN_UMLAUT_PROCESSING =
|
public static final Flag FLAG_REQUIRES_GERMAN_UMLAUT_PROCESSING =
|
||||||
new Flag("requiresGermanUmlautProcessing", 0x1);
|
new Flag(R.bool.config_require_umlaut_processing, 0x1);
|
||||||
|
|
||||||
|
// Can create a new flag from extravalue :
|
||||||
|
// public static final Flag FLAG_MYFLAG =
|
||||||
|
// new Flag("my_flag", 0x02);
|
||||||
|
|
||||||
private static final Flag[] ALL_FLAGS = {
|
private static final Flag[] ALL_FLAGS = {
|
||||||
// Here should reside all flags that trigger some special processing
|
// Here should reside all flags that trigger some special processing
|
||||||
|
@ -118,12 +112,12 @@ public class BinaryDictionary extends Dictionary {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sInstance.mFlags = initFlags(ALL_FLAGS, SubtypeSwitcher.getInstance());
|
sInstance.mFlags = Flag.initFlags(ALL_FLAGS, context, SubtypeSwitcher.getInstance());
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package for test */ static BinaryDictionary initDictionary(File dictionary, long startOffset,
|
/* package for test */ static BinaryDictionary initDictionary(Context context, File dictionary,
|
||||||
long length, int dicTypeId, Flag[] flagArray) {
|
long startOffset, long length, int dicTypeId, Flag[] flagArray) {
|
||||||
synchronized (sInstance) {
|
synchronized (sInstance) {
|
||||||
sInstance.closeInternal();
|
sInstance.closeInternal();
|
||||||
if (dictionary.isFile()) {
|
if (dictionary.isFile()) {
|
||||||
|
@ -134,19 +128,10 @@ public class BinaryDictionary extends Dictionary {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sInstance.mFlags = initFlags(flagArray, null);
|
sInstance.mFlags = Flag.initFlags(flagArray, context, null);
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int initFlags(Flag[] flagArray, SubtypeSwitcher switcher) {
|
|
||||||
int flags = 0;
|
|
||||||
for (Flag entry : flagArray) {
|
|
||||||
if (switcher == null || switcher.currentSubtypeContainsExtraValueKey(entry.mName))
|
|
||||||
flags |= entry.mValue;
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Utils.loadNativeLibrary();
|
Utils.loadNativeLibrary();
|
||||||
}
|
}
|
||||||
|
@ -179,6 +164,7 @@ public class BinaryDictionary extends Dictionary {
|
||||||
sInstance.mDicTypeId = dicTypeId;
|
sInstance.mDicTypeId = dicTypeId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sInstance.mFlags = Flag.initFlags(ALL_FLAGS, context, SubtypeSwitcher.getInstance());
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* 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.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
|
||||||
|
public class Flag {
|
||||||
|
public final String mName;
|
||||||
|
public final int mResource;
|
||||||
|
public final int mMask;
|
||||||
|
public final int mSource;
|
||||||
|
|
||||||
|
static private final int SOURCE_CONFIG = 1;
|
||||||
|
static private final int SOURCE_EXTRAVALUE = 2;
|
||||||
|
|
||||||
|
public Flag(int resourceId, int mask) {
|
||||||
|
mName = null;
|
||||||
|
mResource = resourceId;
|
||||||
|
mSource = SOURCE_CONFIG;
|
||||||
|
mMask = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Flag(String name, int mask) {
|
||||||
|
mName = name;
|
||||||
|
mResource = 0;
|
||||||
|
mSource = SOURCE_EXTRAVALUE;
|
||||||
|
mMask = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If context/switcher are null, set all related flags in flagArray to on.
|
||||||
|
public static int initFlags(Flag[] flagArray, Context context, SubtypeSwitcher switcher) {
|
||||||
|
int flags = 0;
|
||||||
|
final Resources res = null == context ? null : context.getResources();
|
||||||
|
for (Flag entry : flagArray) {
|
||||||
|
switch (entry.mSource) {
|
||||||
|
case Flag.SOURCE_CONFIG:
|
||||||
|
if (res == null || res.getBoolean(entry.mResource))
|
||||||
|
flags |= entry.mMask;
|
||||||
|
break;
|
||||||
|
case Flag.SOURCE_EXTRAVALUE:
|
||||||
|
if (switcher == null ||
|
||||||
|
switcher.currentSubtypeContainsExtraValueKey(entry.mName))
|
||||||
|
flags |= entry.mMask;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
}
|
|
@ -112,10 +112,10 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
dictionaryResId));
|
dictionaryResId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package for test */ Suggest(File dictionary, long startOffset, long length,
|
/* package for test */ Suggest(Context context, File dictionary, long startOffset, long length,
|
||||||
BinaryDictionary.Flag[] flagArray) {
|
Flag[] flagArray) {
|
||||||
init(null, BinaryDictionary.initDictionary(dictionary, startOffset, length, DIC_MAIN,
|
init(null, BinaryDictionary.initDictionary(context, dictionary, startOffset, length,
|
||||||
flagArray));
|
DIC_MAIN, flagArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(Context context, BinaryDictionary mainDict) {
|
private void init(Context context, BinaryDictionary mainDict) {
|
||||||
|
|
|
@ -32,14 +32,14 @@ public class SuggestedWords {
|
||||||
public final List<SuggestedWordInfo> mSuggestedWordInfoList;
|
public final List<SuggestedWordInfo> mSuggestedWordInfoList;
|
||||||
|
|
||||||
private SuggestedWords(List<CharSequence> words, boolean typedWordValid,
|
private SuggestedWords(List<CharSequence> words, boolean typedWordValid,
|
||||||
boolean hasMinamlSuggestion, List<SuggestedWordInfo> suggestedWordInfoList) {
|
boolean hasMinimalSuggestion, List<SuggestedWordInfo> suggestedWordInfoList) {
|
||||||
if (words != null) {
|
if (words != null) {
|
||||||
mWords = words;
|
mWords = words;
|
||||||
} else {
|
} else {
|
||||||
mWords = Collections.emptyList();
|
mWords = Collections.emptyList();
|
||||||
}
|
}
|
||||||
mTypedWordValid = typedWordValid;
|
mTypedWordValid = typedWordValid;
|
||||||
mHasMinimalSuggestion = hasMinamlSuggestion;
|
mHasMinimalSuggestion = hasMinimalSuggestion;
|
||||||
mSuggestedWordInfoList = suggestedWordInfoList;
|
mSuggestedWordInfoList = suggestedWordInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,8 +113,8 @@ public class SuggestedWords {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setHasMinimalSuggestion(boolean hasMinamlSuggestion) {
|
public Builder setHasMinimalSuggestion(boolean hasMinimalSuggestion) {
|
||||||
mHasMinimalSuggestion = hasMinamlSuggestion;
|
mHasMinimalSuggestion = hasMinimalSuggestion;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ package com.android.inputmethod.latin;
|
||||||
import com.android.inputmethod.compat.InputMethodInfoCompatWrapper;
|
import com.android.inputmethod.compat.InputMethodInfoCompatWrapper;
|
||||||
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
|
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
|
||||||
import com.android.inputmethod.compat.InputTypeCompatUtils;
|
import com.android.inputmethod.compat.InputTypeCompatUtils;
|
||||||
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
import com.android.inputmethod.keyboard.KeyboardId;
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -258,6 +259,8 @@ public class Utils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Damerau-Levenshtein distance */
|
||||||
public static int editDistance(CharSequence s, CharSequence t) {
|
public static int editDistance(CharSequence s, CharSequence t) {
|
||||||
if (s == null || t == null) {
|
if (s == null || t == null) {
|
||||||
throw new IllegalArgumentException("editDistance: Arguments should not be null.");
|
throw new IllegalArgumentException("editDistance: Arguments should not be null.");
|
||||||
|
@ -273,14 +276,29 @@ public class Utils {
|
||||||
}
|
}
|
||||||
for (int i = 0; i < sl; ++i) {
|
for (int i = 0; i < sl; ++i) {
|
||||||
for (int j = 0; j < tl; ++j) {
|
for (int j = 0; j < tl; ++j) {
|
||||||
if (Character.toLowerCase(s.charAt(i)) == Character.toLowerCase(t.charAt(j))) {
|
final char sc = Character.toLowerCase(s.charAt(i));
|
||||||
dp[i + 1][j + 1] = dp[i][j];
|
final char tc = Character.toLowerCase(t.charAt(j));
|
||||||
} else {
|
final int cost = sc == tc ? 0 : 1;
|
||||||
dp[i + 1][j + 1] = 1 + Math.min(dp[i][j],
|
dp[i + 1][j + 1] = Math.min(
|
||||||
Math.min(dp[i + 1][j], dp[i][j + 1]));
|
dp[i][j + 1] + 1, Math.min(dp[i + 1][j] + 1, dp[i][j] + cost));
|
||||||
|
// Overwrite for transposition cases
|
||||||
|
if (i > 0 && j > 0
|
||||||
|
&& sc == Character.toLowerCase(t.charAt(j - 1))
|
||||||
|
&& tc == Character.toLowerCase(s.charAt(i - 1))) {
|
||||||
|
dp[i + 1][j + 1] = Math.min(dp[i + 1][j + 1], dp[i - 1][j - 1] + cost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (LatinImeLogger.sDBG) {
|
||||||
|
Log.d(TAG, "editDistance:" + s + "," + t);
|
||||||
|
for (int i = 0; i < dp.length; ++i) {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for (int j = 0; j < dp[i].length; ++j) {
|
||||||
|
sb.append(dp[i][j]).append(',');
|
||||||
|
}
|
||||||
|
Log.d(TAG, i + ":" + sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
return dp[sl][tl];
|
return dp[sl][tl];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,8 +345,16 @@ public class Utils {
|
||||||
final int distance = editDistance(before, after);
|
final int distance = editDistance(before, after);
|
||||||
// If afterLength < beforeLength, the algorithm is suggesting a word by excessive character
|
// If afterLength < beforeLength, the algorithm is suggesting a word by excessive character
|
||||||
// correction.
|
// correction.
|
||||||
|
int spaceCount = 0;
|
||||||
|
for (int i = 0; i < afterLength; ++i) {
|
||||||
|
if (after.charAt(i) == Keyboard.CODE_SPACE) {
|
||||||
|
++spaceCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (spaceCount == afterLength) return 0;
|
||||||
final double maximumScore = MAX_INITIAL_SCORE
|
final double maximumScore = MAX_INITIAL_SCORE
|
||||||
* Math.pow(TYPED_LETTER_MULTIPLIER, Math.min(beforeLength, afterLength))
|
* Math.pow(
|
||||||
|
TYPED_LETTER_MULTIPLIER, Math.min(beforeLength, afterLength - spaceCount))
|
||||||
* FULL_WORD_MULTIPLIER;
|
* FULL_WORD_MULTIPLIER;
|
||||||
// add a weight based on edit distance.
|
// add a weight based on edit distance.
|
||||||
// distance <= max(afterLength, beforeLength) == afterLength,
|
// distance <= max(afterLength, beforeLength) == afterLength,
|
||||||
|
|
|
@ -574,7 +574,7 @@ inline int UnigramDictionary::calculateFinalFreq(const int inputIndex, const int
|
||||||
* (10 * mInputLength - WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X)
|
* (10 * mInputLength - WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X)
|
||||||
/ (10 * mInputLength
|
/ (10 * mInputLength
|
||||||
- WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X + 10);
|
- WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X + 10);
|
||||||
if (DEBUG_DICT) {
|
if (DEBUG_DICT_FULL) {
|
||||||
LOGI("Demotion rate for missing character is %d.", demotionRate);
|
LOGI("Demotion rate for missing character is %d.", demotionRate);
|
||||||
}
|
}
|
||||||
multiplyRate(demotionRate, &finalFreq);
|
multiplyRate(demotionRate, &finalFreq);
|
||||||
|
@ -603,7 +603,7 @@ inline int UnigramDictionary::calculateFinalFreq(const int inputIndex, const int
|
||||||
if (sameLength && transposedPos < 0 && skipPos < 0 && excessivePos < 0) {
|
if (sameLength && transposedPos < 0 && skipPos < 0 && excessivePos < 0) {
|
||||||
finalFreq = capped255MultForFullMatchAccentsOrCapitalizationDifference(finalFreq);
|
finalFreq = capped255MultForFullMatchAccentsOrCapitalizationDifference(finalFreq);
|
||||||
}
|
}
|
||||||
} else if (sameLength && transposedPos < 0 && skipPos < 0 && excessivePos < 0 && depth > 1) {
|
} else if (sameLength && transposedPos < 0 && skipPos < 0 && excessivePos < 0 && depth > 0) {
|
||||||
// A word with proximity corrections
|
// A word with proximity corrections
|
||||||
if (DEBUG_DICT) {
|
if (DEBUG_DICT) {
|
||||||
LOGI("Found one proximity correction.");
|
LOGI("Found one proximity correction.");
|
||||||
|
@ -611,6 +611,9 @@ inline int UnigramDictionary::calculateFinalFreq(const int inputIndex, const int
|
||||||
finalFreq *= 2;
|
finalFreq *= 2;
|
||||||
multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq);
|
multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq);
|
||||||
}
|
}
|
||||||
|
if (DEBUG_DICT) {
|
||||||
|
LOGI("calc: %d, %d", depth, sameLength);
|
||||||
|
}
|
||||||
if (sameLength) finalFreq *= FULL_WORD_MULTIPLIER;
|
if (sameLength) finalFreq *= FULL_WORD_MULTIPLIER;
|
||||||
return finalFreq;
|
return finalFreq;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class SuggestHelper {
|
||||||
|
|
||||||
protected SuggestHelper(Context context, File dictionaryPath, long startOffset, long length,
|
protected SuggestHelper(Context context, File dictionaryPath, long startOffset, long length,
|
||||||
KeyboardId keyboardId) {
|
KeyboardId keyboardId) {
|
||||||
mSuggest = new Suggest(dictionaryPath, startOffset, length, null);
|
mSuggest = new Suggest(context, dictionaryPath, startOffset, length, null);
|
||||||
mKeyboard = new LatinKeyboard(context, keyboardId);
|
mKeyboard = new LatinKeyboard(context, keyboardId);
|
||||||
mKeyDetector = new KeyDetector();
|
mKeyDetector = new KeyDetector();
|
||||||
init();
|
init();
|
||||||
|
|
Loading…
Reference in New Issue