diff options
author | Jean Chalard <jchalard@google.com> | 2012-05-09 18:39:36 +0900 |
---|---|---|
committer | Jean Chalard <jchalard@google.com> | 2012-05-09 19:57:08 +0900 |
commit | 1571c0a377f4aa94ef424da326a52fad638b3e54 (patch) | |
tree | 5549f7467cf455970e963016dffa41944e611115 /src/com/android/settings/UserDictionarySettings.java | |
parent | 99e509cc4c2057dcfba1745ae7584fc1f4047aca (diff) | |
download | packages_apps_settings-1571c0a377f4aa94ef424da326a52fad638b3e54.zip packages_apps_settings-1571c0a377f4aa94ef424da326a52fad638b3e54.tar.gz packages_apps_settings-1571c0a377f4aa94ef424da326a52fad638b3e54.tar.bz2 |
Pass the shortcut to the user dictionary provider.
Bug: 6026080
Change-Id: I87b7c8b1ae89856f393871e6d3440b43efc22a29
Diffstat (limited to 'src/com/android/settings/UserDictionarySettings.java')
-rw-r--r-- | src/com/android/settings/UserDictionarySettings.java | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/com/android/settings/UserDictionarySettings.java b/src/com/android/settings/UserDictionarySettings.java index 931fc94..ec21111 100644 --- a/src/com/android/settings/UserDictionarySettings.java +++ b/src/com/android/settings/UserDictionarySettings.java @@ -155,9 +155,10 @@ public class UserDictionarySettings extends ListFragment { @Override public void onListItemClick(ListView l, View v, int position, long id) { - String word = getWord(position); + final String word = getWord(position); + final String shortcut = getShortcut(position); if (word != null) { - showAddOrEditDialog(word); + showAddOrEditDialog(word, shortcut); } } @@ -173,7 +174,7 @@ public class UserDictionarySettings extends ListFragment { @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == OPTIONS_MENU_ADD) { - showAddOrEditDialog(null); + showAddOrEditDialog(null, null); return true; } return false; @@ -182,13 +183,15 @@ public class UserDictionarySettings extends ListFragment { /** * Add or edit a word. If editingWord is null, it's an add; otherwise, it's an edit. * @param editingWord the word to edit, or null if it's an add. + * @param editingShortcut the shortcut for this entry, or null if none. */ - private void showAddOrEditDialog(final String editingWord) { + private void showAddOrEditDialog(final String editingWord, final String editingShortcut) { final Bundle args = new Bundle(); args.putInt(UserDictionaryAddWordContents.EXTRA_MODE, null == editingWord ? UserDictionaryAddWordContents.MODE_INSERT : UserDictionaryAddWordContents.MODE_EDIT); args.putString(UserDictionaryAddWordContents.EXTRA_WORD, editingWord); + args.putString(UserDictionaryAddWordContents.EXTRA_SHORTCUT, editingShortcut); args.putString(UserDictionaryAddWordContents.EXTRA_LOCALE, mLocale); android.preference.PreferenceActivity pa = (android.preference.PreferenceActivity)getActivity(); @@ -197,7 +200,7 @@ public class UserDictionarySettings extends ListFragment { args, R.string.details_title, null, null, 0); } - private String getWord(int position) { + private String getWord(final int position) { if (null == mCursor) return null; mCursor.moveToPosition(position); // Handle a possible race-condition @@ -207,6 +210,16 @@ public class UserDictionarySettings extends ListFragment { mCursor.getColumnIndexOrThrow(UserDictionary.Words.WORD)); } + private String getShortcut(final int position) { + if (null == mCursor) return null; + mCursor.moveToPosition(position); + // Handle a possible race-condition + if (mCursor.isAfterLast()) return null; + + return mCursor.getString( + mCursor.getColumnIndexOrThrow(UserDictionary.Words.SHORTCUT)); + } + public static void deleteWord(final String word, final ContentResolver resolver) { resolver.delete( UserDictionary.Words.CONTENT_URI, DELETE_SELECTION, new String[] { word }); |