diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/AddBookmarkPage.java | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java index 9070218..6c066fb 100644 --- a/src/com/android/browser/AddBookmarkPage.java +++ b/src/com/android/browser/AddBookmarkPage.java @@ -108,19 +108,12 @@ public class AddBookmarkPage extends Activity if (actionId == EditorInfo.IME_NULL) { // Only want to do this once. if (event.getAction() == KeyEvent.ACTION_UP) { - String name = v.getText().toString(); - long id = addFolderToCurrent(name); - mFolderNamer.setVisibility(View.GONE); - mAddNewFolder.setVisibility(View.VISIBLE); - descendInto(name,id); - InputMethodManager.getInstance(this) - .hideSoftInputFromWindow( - mFolderNamer.getWindowToken(), 0); + completeFolderNaming(); } - // Steal the key press for both up and down - return true; } } + // Steal the key press; otherwise a newline will be added + return true; } return false; } @@ -131,12 +124,7 @@ public class AddBookmarkPage extends Activity if (mFolderSelector.getVisibility() == View.VISIBLE) { // We are showing the folder selector. if (mFolderNamer.getVisibility() == View.VISIBLE) { - // Editing folder name - String name = mFolderNamer.getText().toString(); - long id = addFolderToCurrent(mFolderNamer.getText().toString()); - descendInto(name, id); - mFolderNamer.setVisibility(View.GONE); - mAddNewFolder.setVisibility(View.VISIBLE); + completeFolderNaming(); } else { // User has selected a folder. Go back to the opening page mFolderSelector.setVisibility(View.GONE); @@ -165,6 +153,18 @@ public class AddBookmarkPage extends Activity } } + private void completeFolderNaming() { + if (!TextUtils.isEmpty(mFolderNamer.getText())) { + String name = mFolderNamer.getText().toString(); + long id = addFolderToCurrent(mFolderNamer.getText().toString()); + descendInto(name, id); + mFolderNamer.setVisibility(View.GONE); + mAddNewFolder.setVisibility(View.VISIBLE); + InputMethodManager.getInstance(this).hideSoftInputFromWindow( + mFolderNamer.getWindowToken(), 0); + } + } + private long addFolderToCurrent(String name) { // Add the folder to the database ContentValues values = new ContentValues(); @@ -598,4 +598,5 @@ public class AddBookmarkPage extends Activity } return true; } + } |