aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java56
-rw-r--r--java/src/com/android/inputmethod/dictionarypack/DictionarySettingsActivity.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java2
-rw-r--r--java/src/com/android/inputmethod/latin/Constants.java1
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java3
-rw-r--r--java/src/com/android/inputmethod/latin/about/AboutPreferences.java28
-rw-r--r--java/src/com/android/inputmethod/latin/settings/DebugSettingsActivity.java3
-rw-r--r--java/src/com/android/inputmethod/latin/settings/SettingsActivity.java4
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java4
-rw-r--r--java/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtils.java18
-rw-r--r--java/src/com/android/inputmethod/latin/utils/FragmentUtils.java52
12 files changed, 165 insertions, 14 deletions
diff --git a/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java b/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java
new file mode 100644
index 000000000..b119d6c82
--- /dev/null
+++ b/java/src/com/android/inputmethod/compat/InputMethodSubtypeCompatUtils.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2013 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.compat;
+
+import android.os.Build;
+import android.view.inputmethod.InputMethodSubtype;
+
+import java.lang.reflect.Constructor;
+
+public final class InputMethodSubtypeCompatUtils {
+ private static final String TAG = InputMethodSubtypeCompatUtils.class.getSimpleName();
+ // Note that InputMethodSubtype(int nameId, int iconId, String locale, String mode,
+ // String extraValue, boolean isAuxiliary, boolean overridesImplicitlyEnabledSubtype, int id)
+ // has been introduced in API level 17 (Build.VERSION_CODE.JELLY_BEAN_MR1).
+ private static final Constructor<?> CONSTRUCTOR_INPUT_METHOD_SUBTYPE =
+ CompatUtils.getConstructor(InputMethodSubtype.class,
+ Integer.TYPE, Integer.TYPE, String.class, String.class, String.class,
+ Boolean.TYPE, Boolean.TYPE, Integer.TYPE);
+ static {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ if (CONSTRUCTOR_INPUT_METHOD_SUBTYPE == null) {
+ android.util.Log.w(TAG, "Warning!!! Constructor is not defined.");
+ }
+ }
+ }
+ private InputMethodSubtypeCompatUtils() {
+ // This utility class is not publicly instantiable.
+ }
+
+ public static InputMethodSubtype newInputMethodSubtype(int nameId, int iconId, String locale,
+ String mode, String extraValue, boolean isAuxiliary,
+ boolean overridesImplicitlyEnabledSubtype, int id) {
+ if (CONSTRUCTOR_INPUT_METHOD_SUBTYPE == null
+ || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ return new InputMethodSubtype(nameId, iconId, locale, mode, extraValue, isAuxiliary,
+ overridesImplicitlyEnabledSubtype);
+ }
+ return (InputMethodSubtype) CompatUtils.newInstance(CONSTRUCTOR_INPUT_METHOD_SUBTYPE,
+ nameId, iconId, locale, mode, extraValue, isAuxiliary,
+ overridesImplicitlyEnabledSubtype, id);
+ }
+}
diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionarySettingsActivity.java b/java/src/com/android/inputmethod/dictionarypack/DictionarySettingsActivity.java
index c28d72949..4366348d5 100644
--- a/java/src/com/android/inputmethod/dictionarypack/DictionarySettingsActivity.java
+++ b/java/src/com/android/inputmethod/dictionarypack/DictionarySettingsActivity.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.dictionarypack;
+import com.android.inputmethod.latin.utils.FragmentUtils;
+
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
@@ -45,6 +47,6 @@ public final class DictionarySettingsActivity extends PreferenceActivity {
// TODO: Uncomment the override annotation once we start using SDK version 19.
// @Override
public boolean isValidFragment(String fragmentName) {
- return fragmentName.equals(DEFAULT_FRAGMENT);
+ return FragmentUtils.isValidFragment(fragmentName);
}
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java b/java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java
index 09766ac6c..3133e54be 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/DynamicGridKeyboard.java
@@ -184,12 +184,12 @@ public class DynamicGridKeyboard extends Keyboard {
private int getKeyY0(final int index) {
final int row = index / mColumnsNum;
- return row * mVerticalStep;
+ return row * mVerticalStep + mVerticalGap / 2;
}
private int getKeyY1(final int index) {
final int row = index / mColumnsNum + 1;
- return row * mVerticalStep;
+ return row * mVerticalStep + mVerticalGap / 2;
}
@Override
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
index bcb80b455..e769e3cdd 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
@@ -278,7 +278,7 @@ public final class KeyboardTextsSet {
/* 50 */ "\u00A2,\u00A3,\u20AC,\u00A5,\u20B1",
/* 51 */ "$",
/* 52 */ "$,\u00A2,\u20AC,\u00A3,\u00A5,\u20B1",
- /* 53 */ "!fixedColumnOrder!3,!,\\,,?,:,;,@",
+ /* 53 */ "!fixedColumnOrder!4,#,!,\\,,?,-,:,',@",
// U+2020: "†" DAGGER
// U+2021: "‡" DOUBLE DAGGER
// U+2605: "★" BLACK STAR
diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java
index c4f96016c..9a9653094 100644
--- a/java/src/com/android/inputmethod/latin/Constants.java
+++ b/java/src/com/android/inputmethod/latin/Constants.java
@@ -174,6 +174,7 @@ public final class Constants {
public static final int CODE_SLASH = '/';
public static final int CODE_COMMERCIAL_AT = '@';
public static final int CODE_PLUS = '+';
+ public static final int CODE_PERCENT = '%';
public static final int CODE_CLOSING_PARENTHESIS = ')';
public static final int CODE_CLOSING_SQUARE_BRACKET = ']';
public static final int CODE_CLOSING_CURLY_BRACKET = '}';
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index ccdbd0d4d..46b75121a 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1503,6 +1503,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|| codePoint == Constants.CODE_CLOSING_CURLY_BRACKET
|| codePoint == Constants.CODE_CLOSING_ANGLE_BRACKET
|| codePoint == Constants.CODE_PLUS
+ || codePoint == Constants.CODE_PERCENT
|| Character.getType(codePoint) == Character.OTHER_SYMBOL;
}
@@ -2305,9 +2306,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (!mRecapitalizeStatus.isSetAt(mLastSelectionStart, mLastSelectionEnd)) {
mLastSelectionStart = mRecapitalizeStatus.getNewCursorStart();
mLastSelectionEnd = mRecapitalizeStatus.getNewCursorEnd();
- mConnection.setSelection(mLastSelectionStart, mLastSelectionEnd);
}
}
+ mConnection.finishComposingText();
mRecapitalizeStatus.rotate();
final int numCharsDeleted = mLastSelectionEnd - mLastSelectionStart;
mConnection.setSelection(mLastSelectionEnd, mLastSelectionEnd);
diff --git a/java/src/com/android/inputmethod/latin/about/AboutPreferences.java b/java/src/com/android/inputmethod/latin/about/AboutPreferences.java
new file mode 100644
index 000000000..f60b189f1
--- /dev/null
+++ b/java/src/com/android/inputmethod/latin/about/AboutPreferences.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2013 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.about;
+
+import android.app.Fragment;
+
+/**
+ * Dummy class of AboutPreferences. Never use this.
+ */
+public final class AboutPreferences extends Fragment {
+ private AboutPreferences() {
+ // Prevents this from being instantiated
+ }
+}
diff --git a/java/src/com/android/inputmethod/latin/settings/DebugSettingsActivity.java b/java/src/com/android/inputmethod/latin/settings/DebugSettingsActivity.java
index ef6ab2a38..a23e37795 100644
--- a/java/src/com/android/inputmethod/latin/settings/DebugSettingsActivity.java
+++ b/java/src/com/android/inputmethod/latin/settings/DebugSettingsActivity.java
@@ -21,6 +21,7 @@ import android.os.Bundle;
import android.preference.PreferenceActivity;
import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.utils.FragmentUtils;
public final class DebugSettingsActivity extends PreferenceActivity {
private static final String DEFAULT_FRAGMENT = DebugSettings.class.getName();
@@ -42,6 +43,6 @@ public final class DebugSettingsActivity extends PreferenceActivity {
// TODO: Uncomment the override annotation once we start using SDK version 19.
// @Override
public boolean isValidFragment(String fragmentName) {
- return fragmentName.equals(DEFAULT_FRAGMENT);
+ return FragmentUtils.isValidFragment(fragmentName);
}
}
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsActivity.java b/java/src/com/android/inputmethod/latin/settings/SettingsActivity.java
index ad68f8c37..c899507e3 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsActivity.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsActivity.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.latin.settings;
+import com.android.inputmethod.latin.utils.FragmentUtils;
+
import android.content.Intent;
import android.preference.PreferenceActivity;
@@ -36,6 +38,6 @@ public final class SettingsActivity extends PreferenceActivity {
// TODO: Uncomment the override annotation once we start using SDK version 19.
// @Override
public boolean isValidFragment(String fragmentName) {
- return fragmentName.equals(DEFAULT_FRAGMENT);
+ return FragmentUtils.isValidFragment(fragmentName);
}
}
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java
index aba563746..df9a76119 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.latin.spellcheck;
+import com.android.inputmethod.latin.utils.FragmentUtils;
+
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
@@ -42,6 +44,6 @@ public final class SpellCheckerSettingsActivity extends PreferenceActivity {
// TODO: Uncomment the override annotation once we start using SDK version 19.
// @Override
public boolean isValidFragment(String fragmentName) {
- return fragmentName.equals(DEFAULT_FRAGMENT);
+ return FragmentUtils.isValidFragment(fragmentName);
}
}
diff --git a/java/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtils.java b/java/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtils.java
index ff332cdee..d87f6f3c4 100644
--- a/java/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtils.java
@@ -25,6 +25,7 @@ import android.os.Build;
import android.text.TextUtils;
import android.view.inputmethod.InputMethodSubtype;
+import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R;
@@ -143,12 +144,17 @@ public final class AdditionalSubtypeUtils {
// from the current users. So, you should be really careful to change it.
final int subtypeId = getInputMethodSubtypeId(nameId, localeString, layoutExtraValue,
additionalSubtypeExtraValue);
- // TODO: Use InputMethodSubtypeBuilder once we use SDK version 19.
- return new InputMethodSubtype(nameId, R.drawable.ic_ime_switcher_dark,
- localeString, KEYBOARD_MODE, layoutExtraValue + "," + additionalSubtypeExtraValue
- + "," + Constants.Subtype.ExtraValue.ASCII_CAPABLE
- + "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE, false, false,
- subtypeId);
+ final String extraValue;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ extraValue = layoutExtraValue + "," + additionalSubtypeExtraValue
+ + "," + Constants.Subtype.ExtraValue.ASCII_CAPABLE
+ + "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE;
+ } else {
+ extraValue = layoutExtraValue + "," + additionalSubtypeExtraValue;
+ }
+ return InputMethodSubtypeCompatUtils.newInputMethodSubtype(nameId,
+ R.drawable.ic_ime_switcher_dark, localeString, KEYBOARD_MODE, extraValue,
+ false, false, subtypeId);
}
private static int getInputMethodSubtypeId(int nameId, String localeString,
diff --git a/java/src/com/android/inputmethod/latin/utils/FragmentUtils.java b/java/src/com/android/inputmethod/latin/utils/FragmentUtils.java
new file mode 100644
index 000000000..ee2b97b2a
--- /dev/null
+++ b/java/src/com/android/inputmethod/latin/utils/FragmentUtils.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2013 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.utils;
+
+import com.android.inputmethod.dictionarypack.DictionarySettingsFragment;
+import com.android.inputmethod.latin.about.AboutPreferences;
+import com.android.inputmethod.latin.settings.AdditionalSubtypeSettings;
+import com.android.inputmethod.latin.settings.DebugSettings;
+import com.android.inputmethod.latin.settings.SettingsFragment;
+import com.android.inputmethod.latin.spellcheck.SpellCheckerSettingsFragment;
+import com.android.inputmethod.latin.userdictionary.UserDictionaryAddWordFragment;
+import com.android.inputmethod.latin.userdictionary.UserDictionaryList;
+import com.android.inputmethod.latin.userdictionary.UserDictionaryLocalePicker;
+import com.android.inputmethod.latin.userdictionary.UserDictionarySettings;
+import com.android.inputmethod.research.FeedbackFragment;
+
+import java.util.HashSet;
+
+public class FragmentUtils {
+ private static final HashSet<String> sLatinImeFragments = new HashSet<String>();
+ static {
+ sLatinImeFragments.add(DictionarySettingsFragment.class.getName());
+ sLatinImeFragments.add(AboutPreferences.class.getName());
+ sLatinImeFragments.add(AdditionalSubtypeSettings.class.getName());
+ sLatinImeFragments.add(DebugSettings.class.getName());
+ sLatinImeFragments.add(SettingsFragment.class.getName());
+ sLatinImeFragments.add(SpellCheckerSettingsFragment.class.getName());
+ sLatinImeFragments.add(UserDictionaryAddWordFragment.class.getName());
+ sLatinImeFragments.add(UserDictionaryList.class.getName());
+ sLatinImeFragments.add(UserDictionaryLocalePicker.class.getName());
+ sLatinImeFragments.add(UserDictionarySettings.class.getName());
+ sLatinImeFragments.add(FeedbackFragment.class.getName());
+ }
+
+ public static boolean isValidFragment(String fragmentName) {
+ return sLatinImeFragments.contains(fragmentName);
+ }
+}