Bug 727451 - Pressing the back button in the bookmarks list should go up a folder level if possible. r=lucasr

This commit is contained in:
Margaret Leibovic 2012-02-23 10:48:48 -08:00
Родитель e586a75214
Коммит b6dcf74f32
2 изменённых файлов: 31 добавлений и 5 удалений

Просмотреть файл

@ -163,17 +163,27 @@ public class AwesomeBar extends Activity implements GeckoEventListener {
mText.setOnKeyPreImeListener(new AwesomeBarEditText.OnKeyPreImeListener() {
public boolean onKeyPreIme(View v, int keyCode, KeyEvent event) {
InputMethodManager imm =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// We only want to process one event per tap
if (event.getAction() != KeyEvent.ACTION_DOWN)
return false;
if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
openUserEnteredAndFinish(mText.getText().toString());
return true;
}
// If input method is in fullscreen mode, we want to dismiss
// it instead of closing awesomebar straight away.
if (!imm.isFullscreenMode() && keyCode == KeyEvent.KEYCODE_BACK) {
InputMethodManager imm =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (keyCode == KeyEvent.KEYCODE_BACK && !imm.isFullscreenMode()) {
// Let mAwesomeTabs try to handle the back press, since we may be in a
// bookmarks sub-folder.
if (mAwesomeTabs.onBackPressed())
return true;
// If mAwesomeTabs.onBackPressed() returned false, we didn't move up
// a folder level, so just exit the activity.
cancelAndFinish();
return true;
}

Просмотреть файл

@ -227,9 +227,15 @@ public class AwesomeBarTabs extends TabHost {
mRefreshTask.execute();
}
public void moveToParentFolder() {
// Returns false if there is no parent folder to move to
public boolean moveToParentFolder() {
// If we're already at the root, we can't move to a parent folder
if (mParentStack.size() == 1)
return false;
mParentStack.pop();
refreshCurrentFolder();
return true;
}
public void moveToChildFolder(int folderId, String folderTitle) {
@ -310,6 +316,16 @@ public class AwesomeBarTabs extends TabHost {
}
}
// This method checks to see if we're in a bookmark sub-folder. If we are,
// it will go up a level and return true. Otherwise it will return false.
public boolean onBackPressed() {
// If we're not in the bookmarks tab, we have nothing to do
if (!getCurrentTabTag().equals(BOOKMARKS_TAB))
return false;
return mBookmarksAdapter.moveToParentFolder();
}
private class BookmarksQueryTask extends AsyncTask<Void, Void, Cursor> {
protected Cursor doInBackground(Void... arg0) {
return BrowserDB.getBookmarksInFolder(mContentResolver, Bookmarks.FIXED_ROOT_ID);