summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/UserDictionarySettings.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-05-09 17:47:17 +0900
committerJean Chalard <jchalard@google.com>2012-05-09 18:35:12 +0900
commit99e509cc4c2057dcfba1745ae7584fc1f4047aca (patch)
tree09b913c28bad65aec1dc8f311838495f5ba5c597 /src/com/android/settings/UserDictionarySettings.java
parentc4c4b916eb007dc08f971af45e989a9f0e6c6585 (diff)
downloadpackages_apps_Settings-99e509cc4c2057dcfba1745ae7584fc1f4047aca.zip
packages_apps_Settings-99e509cc4c2057dcfba1745ae7584fc1f4047aca.tar.gz
packages_apps_Settings-99e509cc4c2057dcfba1745ae7584fc1f4047aca.tar.bz2
Rework the list interface
Display the shortcut in the list, and remove the cross button. Bug: 6026080 Change-Id: I7f594f07a84e4df3ad5b8160129d92d1a4b0fc28
Diffstat (limited to 'src/com/android/settings/UserDictionarySettings.java')
-rw-r--r--src/com/android/settings/UserDictionarySettings.java33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/com/android/settings/UserDictionarySettings.java b/src/com/android/settings/UserDictionarySettings.java
index 8d4e8b4..931fc94 100644
--- a/src/com/android/settings/UserDictionarySettings.java
+++ b/src/com/android/settings/UserDictionarySettings.java
@@ -28,6 +28,7 @@ import android.database.Cursor;
import android.os.Bundle;
import android.provider.UserDictionary;
import android.text.InputType;
+import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -53,11 +54,11 @@ public class UserDictionarySettings extends ListFragment {
private static final String TAG = "UserDictionarySettings";
private static final String[] QUERY_PROJECTION = {
- UserDictionary.Words._ID, UserDictionary.Words.WORD
+ UserDictionary.Words._ID, UserDictionary.Words.WORD, UserDictionary.Words.SHORTCUT
};
- private static final int INDEX_ID = 0;
- private static final int INDEX_WORD = 1;
+ // The index of the shortcut in the above array.
+ private static final int INDEX_SHORTCUT = 2;
// Either the locale is empty (means the word is applicable to all locales)
// or the word equals our current locale
@@ -148,8 +149,8 @@ public class UserDictionarySettings extends ListFragment {
private ListAdapter createAdapter() {
return new MyAdapter(getActivity(),
R.layout.user_dictionary_item, mCursor,
- new String[] { UserDictionary.Words.WORD, UserDictionary.Words._ID },
- new int[] { android.R.id.text1, R.id.delete_button }, this);
+ new String[] { UserDictionary.Words.WORD, UserDictionary.Words.SHORTCUT },
+ new int[] { android.R.id.text1, android.R.id.text2 }, this);
}
@Override
@@ -211,18 +212,22 @@ public class UserDictionarySettings extends ListFragment {
UserDictionary.Words.CONTENT_URI, DELETE_SELECTION, new String[] { word });
}
- private static class MyAdapter extends SimpleCursorAdapter implements SectionIndexer,
- View.OnClickListener {
+ private static class MyAdapter extends SimpleCursorAdapter implements SectionIndexer {
private AlphabetIndexer mIndexer;
- private UserDictionarySettings mSettings;
private ViewBinder mViewBinder = new ViewBinder() {
public boolean setViewValue(View v, Cursor c, int columnIndex) {
- if (v instanceof ImageView && columnIndex == INDEX_ID) {
- v.setOnClickListener(MyAdapter.this);
- v.setTag(c.getString(INDEX_WORD));
+ if (columnIndex == INDEX_SHORTCUT) {
+ final String shortcut = c.getString(INDEX_SHORTCUT);
+ if (TextUtils.isEmpty(shortcut)) {
+ v.setVisibility(View.GONE);
+ } else {
+ ((TextView)v).setText(shortcut);
+ v.setVisibility(View.VISIBLE);
+ }
+ v.invalidate();
return true;
}
@@ -234,7 +239,6 @@ public class UserDictionarySettings extends ListFragment {
UserDictionarySettings settings) {
super(context, layout, c, from, to);
- mSettings = settings;
if (null != c) {
final String alphabet = context.getString(
com.android.internal.R.string.fast_scroll_alphabet);
@@ -255,10 +259,5 @@ public class UserDictionarySettings extends ListFragment {
public Object[] getSections() {
return null == mIndexer ? null : mIndexer.getSections();
}
-
- public void onClick(View v) {
- UserDictionarySettings.deleteWord((String) v.getTag(),
- mSettings.getActivity().getContentResolver());
- }
}
}