@Override public boolean onKeyDown(int keycode, KeyEvent event) { String current = mFileMag.getCurrentDir(); if (keycode == KeyEvent.KEYCODE_BACK && mUseBackKey && !current.equals("/")) { mHandler.updateDirectory(mFileMag.getPreviousDir()); mPathLabel.setText(mFileMag.getCurrentDir()); return true; } else if (keycode == KeyEvent.KEYCODE_BACK && mUseBackKey && current.equals("/")) { Toast.makeText(FileImportActivity.this, R.string.root_directory_tip, Toast.LENGTH_SHORT) .show(); mUseBackKey = false; mPathLabel.setText(mFileMag.getCurrentDir()); return false; } else if (keycode == KeyEvent.KEYCODE_BACK && !mUseBackKey && current.equals("/")) { finish(); return false; } return false; }
/* * (non-Javadoc) * This will check if the user is at root dir. If so, if they press back * again, it will close the app. * @see android.app.Activity#onKeyDown(int, android.view.KeyEvent) */ @Override public boolean onKeyDown(int keycode, KeyEvent event) { String current = flmg.getCurrentDir(); if (keycode == KeyEvent.KEYCODE_SEARCH) { showDialog(SEARCH_B); return true; } else if (keycode == KeyEvent.KEYCODE_BACK && use_back_key && !current.equals("/")) { if (handler.isMultiSelected()) { table.killMultiSelect(); Toast.makeText(Main.this, "Multi-select is now off", Toast.LENGTH_SHORT).show(); } handler.updateDirectory(flmg.getPreviousDir()); path_label.setText(flmg.getCurrentDir()); return true; } else if (keycode == KeyEvent.KEYCODE_BACK && use_back_key && current.equals("/")) { Toast.makeText(Main.this, "Press back again to quit.", Toast.LENGTH_SHORT).show(); use_back_key = false; path_label.setText(flmg.getCurrentDir()); return false; } else if (keycode == KeyEvent.KEYCODE_BACK && !use_back_key && current.equals("/")) { finish(); return false; } return false; }