@Override public void setEnabled(boolean enabled) { if (enabled) switchToStandardInput(); else switchToManualInput(); mPathEditText.setEnabled(enabled); mGoButton.setVisibility(enabled ? View.VISIBLE : View.GONE); super.setEnabled(enabled); }
/** * Use instead of {@link #cd(String)} when in {@link Mode#MANUAL_INPUT}. * * @param path The path to cd() to. * @return true if the cd succeeded. */ private boolean manualInputCd(String path) { if (cd(path)) { // if cd() successful, hide the keyboard InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getWindowToken(), 0); switchToStandardInput(); return true; } else { Log.w(TAG, "Input path does not exist or is not a folder!"); return false; } }
/** * Activities containing this bar, will have to call this method when the back button is pressed * to provide correct backstack redirection and mode switching. * * @return Whether this view consumed the event. */ public boolean pressBack() { // Switch mode. if (mCurrentMode == Mode.MANUAL_INPUT) { switchToStandardInput(); } // Go back. else if (mCurrentMode == Mode.STANDARD_INPUT) { if (!backWillExit(mCurrentDirectory.getAbsolutePath())) { cd(mCurrentDirectory.getParent()); return true; } else return false; } return true; }