am ded9ec91: Merge change 4383 into donut

Merge commit 'ded9ec91f6623d2566e1b2439ab302b6451e1657'

* commit 'ded9ec91f6623d2566e1b2439ab302b6451e1657':
  Fixes #1912902. Handles orientation change when renaming gestures.
This commit is contained in:
Android (Google) Code Review 2009-06-16 16:43:07 -07:00 committed by The Android Open Source Project
commit 7287d2d444
1 changed files with 40 additions and 3 deletions

View File

@ -52,6 +52,9 @@ public class GesturesActivity extends ListActivity {
private static final int DIALOG_RENAME_GESTURE = 1; private static final int DIALOG_RENAME_GESTURE = 1;
// Type: long (id)
private static final String GESTURES_INFO_ID = "gestures.info_id";
private final Comparator<ApplicationInfo> mSorter = private final Comparator<ApplicationInfo> mSorter =
new LauncherModel.ApplicationInfoComparator(); new LauncherModel.ApplicationInfoComparator();
@ -98,6 +101,25 @@ public class GesturesActivity extends ListActivity {
} }
} }
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (mCurrentRenameInfo != null) {
outState.putLong(GESTURES_INFO_ID, mCurrentRenameInfo.id);
}
}
@Override
protected void onRestoreInstanceState(Bundle state) {
super.onRestoreInstanceState(state);
long id = state.getLong(GESTURES_INFO_ID, -1);
if (id != -1) {
mCurrentRenameInfo = Launcher.getModel().queryGesture(this, String.valueOf(id));
}
}
@Override @Override
public void onCreateContextMenu(ContextMenu menu, View v, public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo) { ContextMenu.ContextMenuInfo menuInfo) {
@ -185,17 +207,32 @@ public class GesturesActivity extends ListActivity {
private void changeGestureName() { private void changeGestureName() {
final String name = mInput.getText().toString(); final String name = mInput.getText().toString();
if (!TextUtils.isEmpty(name)) { if (!TextUtils.isEmpty(name)) {
mCurrentRenameInfo.title = mInput.getText(); final ApplicationInfo renameInfo = mCurrentRenameInfo;
LauncherModel.updateGestureInDatabase(this, mCurrentRenameInfo); final GesturesActivity.GesturesAdapter adapter = mAdapter;
final int count = adapter.getCount();
// Simple linear search, there should not be enough items to warrant
// a more sophisticated search
for (int i = 0; i < count; i++) {
final ApplicationInfo info = adapter.getItem(i);
if (info.id == renameInfo.id) {
info.title = mInput.getText();
LauncherModel.updateGestureInDatabase(this, info);
break;
}
}
adapter.notifyDataSetChanged();
} }
mCurrentRenameInfo = null;
} }
private void cleanupRenameDialog() { private void cleanupRenameDialog() {
if (mRenameDialog != null) { if (mRenameDialog != null) {
mRenameDialog.dismiss(); mRenameDialog.dismiss();
mRenameDialog = null; mRenameDialog = null;
mInput = null;
} }
mCurrentRenameInfo = null;
} }
private void deleteGesture(ApplicationInfo info) { private void deleteGesture(ApplicationInfo info) {