diff options
-rw-r--r-- | res/layout-sw600dp/edit_event_1.xml | 2 | ||||
-rw-r--r-- | res/layout/edit_event_1.xml | 3 | ||||
-rw-r--r-- | src/com/android/calendar/event/EditEventView.java | 135 |
3 files changed, 4 insertions, 136 deletions
diff --git a/res/layout-sw600dp/edit_event_1.xml b/res/layout-sw600dp/edit_event_1.xml index f5689f3f..f5935cc5 100644 --- a/res/layout-sw600dp/edit_event_1.xml +++ b/res/layout-sw600dp/edit_event_1.xml @@ -72,7 +72,7 @@ android:id="@+id/what_label" android:text="@string/what_label" style="@style/TextAppearance.EditEvent_Label" /> - <AutoCompleteTextView + <EditText android:id="@+id/title" style="@style/TextAppearance.EditEvent_Value" android:layout_width="wrap_content" diff --git a/res/layout/edit_event_1.xml b/res/layout/edit_event_1.xml index be04cff5..7242a384 100644 --- a/res/layout/edit_event_1.xml +++ b/res/layout/edit_event_1.xml @@ -68,7 +68,7 @@ </LinearLayout> <!-- WHAT --> - <AutoCompleteTextView + <EditText android:id="@+id/title" style="@style/TextAppearance.EditEvent_Value" android:singleLine="true" @@ -78,7 +78,6 @@ android:minHeight="48dip" android:hint="@string/hint_what" android:capitalize="sentences" - android:imeOptions="actionDone" android:inputType="textAutoCorrect|textCapSentences" android:focusable="true" /> diff --git a/src/com/android/calendar/event/EditEventView.java b/src/com/android/calendar/event/EditEventView.java index a41b099b..1c7b910e 100644 --- a/src/com/android/calendar/event/EditEventView.java +++ b/src/com/android/calendar/event/EditEventView.java @@ -24,14 +24,12 @@ import android.app.ProgressDialog; import android.app.Service; import android.app.TimePickerDialog; import android.app.TimePickerDialog.OnTimeSetListener; -import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources; import android.database.Cursor; -import android.database.MatrixCursor; import android.graphics.drawable.Drawable; import android.provider.CalendarContract.Attendees; import android.provider.CalendarContract.Calendars; @@ -100,7 +98,6 @@ import java.util.Formatter; import java.util.HashMap; import java.util.Locale; import java.util.TimeZone; -import java.util.TreeMap; public class EditEventView implements View.OnClickListener, DialogInterface.OnCancelListener, DialogInterface.OnClickListener, OnItemSelectedListener { @@ -108,19 +105,6 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa private static final String GOOGLE_SECONDARY_CALENDAR = "calendar.google.com"; private static final String PERIOD_SPACE = ". "; - // Constants used for title autocompletion. - private static final String[] EVENT_PROJECTION = new String[] { - Events._ID, - Events.TITLE, - Events.VISIBLE, - }; - private static final int EVENT_INDEX_ID = 0; - private static final int EVENT_INDEX_TITLE = 1; - private static final int EVENT_INDEX_VISIBLE = 2; - private static final String TITLE_WHERE = Events.VISIBLE + "=? AND " - + Events.TITLE + " LIKE ?"; - private static final int MAX_TITLE_SUGGESTIONS = 4; - ArrayList<View> mEditOnlyList = new ArrayList<View>(); ArrayList<View> mEditViewList = new ArrayList<View>(); ArrayList<View> mViewOnlyList = new ArrayList<View>(); @@ -142,7 +126,7 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa Spinner mAvailabilitySpinner; Spinner mAccessLevelSpinner; RadioGroup mResponseRadioGroup; - AutoCompleteTextView mTitleTextView; + TextView mTitleTextView; AutoCompleteTextView mLocationTextView; EventLocationAdapter mLocationAdapter; TextView mDescriptionTextView; @@ -649,108 +633,6 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa } /** - * Adapter for title auto completion. - */ - private static class TitleAdapter extends ResourceCursorAdapter { - private final ContentResolver mContentResolver; - - public TitleAdapter(Context context) { - super(context, android.R.layout.simple_dropdown_item_1line, null, 0); - mContentResolver = context.getContentResolver(); - } - - @Override - public int getCount() { - return Math.min(MAX_TITLE_SUGGESTIONS, super.getCount()); - } - - private static String getTitleAtCursor(Cursor cursor) { - return cursor.getString(EVENT_INDEX_TITLE); - } - - @Override - public final String convertToString(Cursor cursor) { - return getTitleAtCursor(cursor); - } - - @Override - public void bindView(View view, Context context, Cursor cursor) { - TextView textView = (TextView) view; - textView.setText(getTitleAtCursor(cursor)); - } - - @Override - public Cursor runQueryOnBackgroundThread(CharSequence constraint) { - String filter = constraint == null ? "" : constraint.toString() + "%"; - if (filter.isEmpty()) { - return null; - } - long startTime = System.currentTimeMillis(); - - // Query all titles prefixed with the constraint. There is no way to insert - // 'DISTINCT' or 'GROUP BY' to get rid of dupes, so use post-processing to - // remove dupes. We will order query results by descending event ID to show - // results that were most recently inputted. - Cursor tempCursor = mContentResolver.query(Events.CONTENT_URI, EVENT_PROJECTION, - TITLE_WHERE, new String[] { "1", filter }, Events._ID + " DESC"); - if (tempCursor != null) { - try { - // Post process query results. - Cursor c = uniqueTitlesCursor(tempCursor); - - // Log the processing duration. - if (Log.isLoggable(TAG, Log.DEBUG)) { - long duration = System.currentTimeMillis() - startTime; - StringBuilder msg = new StringBuilder(); - msg.append("Autocomplete of "); - msg.append(constraint); - msg.append(": title query match took "); - msg.append(duration); - msg.append("ms."); - Log.d(TAG, msg.toString()); - } - return c; - } finally { - tempCursor.close(); - } - } else { - return null; - } - } - - /** - * Post-process the query results to return the first MAX_TITLE_SUGGESTIONS - * unique titles in alphabetical order. - */ - private Cursor uniqueTitlesCursor(Cursor cursor) { - TreeMap<String, String[]> titleToQueryResults = - new TreeMap<String, String[]>(String.CASE_INSENSITIVE_ORDER); - int numColumns = cursor.getColumnCount(); - cursor.moveToPosition(-1); - - // Remove dupes. - while ((titleToQueryResults.size() < MAX_TITLE_SUGGESTIONS) && cursor.moveToNext()) { - String title = getTitleAtCursor(cursor).trim(); - String data[] = new String[numColumns]; - if (!titleToQueryResults.containsKey(title)) { - for (int i = 0; i < numColumns; i++) { - data[i] = cursor.getString(i); - } - titleToQueryResults.put(title, data); - } - } - - // Copy the sorted results to a new cursor. - MatrixCursor newCursor = new MatrixCursor(EVENT_PROJECTION); - for (String[] result : titleToQueryResults.values()) { - newCursor.addRow(result); - } - newCursor.moveToFirst(); - return newCursor; - } - } - - /** * Does prep steps for saving a calendar event. * * This triggers a parse of the attendees list and checks if the event is @@ -953,7 +835,7 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa // cache all the widgets mCalendarsSpinner = (Spinner) view.findViewById(R.id.calendars_spinner); - mTitleTextView = (AutoCompleteTextView) view.findViewById(R.id.title); + mTitleTextView = (TextView) view.findViewById(R.id.title); mLocationTextView = (AutoCompleteTextView) view.findViewById(R.id.location); mDescriptionTextView = (TextView) view.findViewById(R.id.description); mTimezoneLabel = (TextView) view.findViewById(R.id.timezone_label); @@ -987,19 +869,6 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa mAttendeesList = (MultiAutoCompleteTextView) view.findViewById(R.id.attendees); mTitleTextView.setTag(mTitleTextView.getBackground()); - mTitleTextView.setAdapter(new TitleAdapter(activity)); - mTitleTextView.setOnEditorActionListener(new OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (actionId == EditorInfo.IME_ACTION_DONE) { - // Dismiss the suggestions dropdown. Return false so the other - // side effects still occur (soft keyboard going away, etc.). - mTitleTextView.dismissDropDown(); - } - return false; - } - }); - mLocationTextView.setTag(mLocationTextView.getBackground()); mLocationAdapter = new EventLocationAdapter(activity); mLocationTextView.setAdapter(mLocationAdapter); |