summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-06-16 13:47:58 -0700
committerRomain Guy <romainguy@android.com>2009-06-16 13:47:58 -0700
commit708ab96f2eae9a81f8c25eaf7e51622b2b2fc889 (patch)
treed655517bdde45d78e3bfc4e5f2d4fc86c056e485 /src/com/android/launcher
parent91a9c9636f10f1e12cd1f660b2e330634fbdc7dc (diff)
downloadandroid_packages_apps_Trebuchet-708ab96f2eae9a81f8c25eaf7e51622b2b2fc889.tar.gz
android_packages_apps_Trebuchet-708ab96f2eae9a81f8c25eaf7e51622b2b2fc889.tar.bz2
android_packages_apps_Trebuchet-708ab96f2eae9a81f8c25eaf7e51622b2b2fc889.zip
Fixes #1912902. Handles orientation change when renaming gestures.
The GesturesActivity was crashing when changing the orientation while renaming a gesture. This was due to unimplemented support for orientation changes.
Diffstat (limited to 'src/com/android/launcher')
-rw-r--r--src/com/android/launcher/GesturesActivity.java43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/com/android/launcher/GesturesActivity.java b/src/com/android/launcher/GesturesActivity.java
index c93657621..3ea49e251 100644
--- a/src/com/android/launcher/GesturesActivity.java
+++ b/src/com/android/launcher/GesturesActivity.java
@@ -52,6 +52,9 @@ public class GesturesActivity extends ListActivity {
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 =
new LauncherModel.ApplicationInfoComparator();
@@ -99,6 +102,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
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo) {
@@ -185,17 +207,32 @@ public class GesturesActivity extends ListActivity {
private void changeGestureName() {
final String name = mInput.getText().toString();
if (!TextUtils.isEmpty(name)) {
- mCurrentRenameInfo.title = mInput.getText();
- LauncherModel.updateGestureInDatabase(this, mCurrentRenameInfo);
+ final ApplicationInfo renameInfo = 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() {
if (mRenameDialog != null) {
mRenameDialog.dismiss();
mRenameDialog = null;
- mInput = null;
}
+ mCurrentRenameInfo = null;
}
private void deleteGesture(ApplicationInfo info) {