Loading packages/DocumentsUI/res/layout/fixed_layout.xml +4 −1 Original line number Diff line number Diff line Loading @@ -16,11 +16,14 @@ <!-- CoordinatorLayout is necessary for various components (e.g. Snackbars, and floating action buttons) to operate correctly. --> <!-- focusableInTouchMode is set in order to force key events to go to the activity's global key callback, which is necessary for proper event routing. See BaseActivity.onKeyDown. --> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/coordinator_layout"> android:id="@+id/coordinator_layout" android:focusableInTouchMode="true"> <LinearLayout android:layout_width="match_parent" Loading packages/DocumentsUI/res/layout/fragment_directory.xml +1 −1 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/list" android:id="@+id/dir_list" android:scrollbars="vertical" android:layout_width="match_parent" android:layout_height="match_parent" Loading packages/DocumentsUI/res/layout/fragment_roots.xml +2 −2 Original line number Diff line number Diff line Loading @@ -14,8 +14,8 @@ limitations under the License. --> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list" <com.android.documentsui.RootsList xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/roots_list" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="8dp" Loading packages/DocumentsUI/res/layout/single_pane_layout.xml +4 −1 Original line number Diff line number Diff line Loading @@ -16,11 +16,14 @@ <!-- CoordinatorLayout is necessary for various components (e.g. Snackbars, and floating action buttons) to operate correctly. --> <!-- focusableInTouchMode is set in order to force key events to go to the activity's global key callback, which is necessary for proper event routing. See BaseActivity.onKeyDown. --> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/coordinator_layout"> android:id="@+id/coordinator_layout" android:focusableInTouchMode="true"> <LinearLayout android:layout_width="match_parent" Loading packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java +51 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import android.support.annotation.CallSuper; import android.support.annotation.LayoutRes; import android.support.annotation.Nullable; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.widget.Spinner; Loading Loading @@ -83,6 +84,8 @@ public abstract class BaseActivity extends Activity // We use the time gap to figure out whether to close app or reopen the drawer. private long mDrawerLastFiddled; private boolean mNavDrawerHasFocus; public abstract void onDocumentPicked(DocumentInfo doc, @Nullable SiblingProvider siblings); public abstract void onDocumentsPicked(List<DocumentInfo> docs); Loading Loading @@ -580,6 +583,54 @@ public abstract class BaseActivity extends Activity } } /** * Declare a global key handler to route key events when there isn't a specific focus view. This * covers the scenario where a user opens DocumentsUI and just starts typing. * * @param keyCode * @param event * @return */ @CallSuper @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (Events.isNavigationKeyCode(keyCode)) { // Forward all unclaimed navigation keystrokes to the DirectoryFragment. This causes any // stray navigation keystrokes focus the content pane, which is probably what the user // is trying to do. DirectoryFragment df = DirectoryFragment.get(getFragmentManager()); if (df != null) { df.requestFocus(); return true; } } else if (keyCode == KeyEvent.KEYCODE_TAB) { toggleNavDrawerFocus(); return true; } return super.onKeyDown(keyCode, event); } /** * Toggles focus between the navigation drawer and the directory listing. If the drawer isn't * locked, open/close it as appropriate. */ void toggleNavDrawerFocus() { if (mNavDrawerHasFocus) { mDrawer.setOpen(false); DirectoryFragment df = DirectoryFragment.get(getFragmentManager()); if (df != null) { df.requestFocus(); } } else { mDrawer.setOpen(true); RootsFragment rf = RootsFragment.get(getFragmentManager()); if (rf != null) { rf.requestFocus(); } } mNavDrawerHasFocus = !mNavDrawerHasFocus; } DocumentInfo getRootDocumentBlocking(RootInfo root) { try { final Uri uri = DocumentsContract.buildDocumentUri( Loading Loading
packages/DocumentsUI/res/layout/fixed_layout.xml +4 −1 Original line number Diff line number Diff line Loading @@ -16,11 +16,14 @@ <!-- CoordinatorLayout is necessary for various components (e.g. Snackbars, and floating action buttons) to operate correctly. --> <!-- focusableInTouchMode is set in order to force key events to go to the activity's global key callback, which is necessary for proper event routing. See BaseActivity.onKeyDown. --> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/coordinator_layout"> android:id="@+id/coordinator_layout" android:focusableInTouchMode="true"> <LinearLayout android:layout_width="match_parent" Loading
packages/DocumentsUI/res/layout/fragment_directory.xml +1 −1 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/list" android:id="@+id/dir_list" android:scrollbars="vertical" android:layout_width="match_parent" android:layout_height="match_parent" Loading
packages/DocumentsUI/res/layout/fragment_roots.xml +2 −2 Original line number Diff line number Diff line Loading @@ -14,8 +14,8 @@ limitations under the License. --> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list" <com.android.documentsui.RootsList xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/roots_list" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="8dp" Loading
packages/DocumentsUI/res/layout/single_pane_layout.xml +4 −1 Original line number Diff line number Diff line Loading @@ -16,11 +16,14 @@ <!-- CoordinatorLayout is necessary for various components (e.g. Snackbars, and floating action buttons) to operate correctly. --> <!-- focusableInTouchMode is set in order to force key events to go to the activity's global key callback, which is necessary for proper event routing. See BaseActivity.onKeyDown. --> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/coordinator_layout"> android:id="@+id/coordinator_layout" android:focusableInTouchMode="true"> <LinearLayout android:layout_width="match_parent" Loading
packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java +51 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import android.support.annotation.CallSuper; import android.support.annotation.LayoutRes; import android.support.annotation.Nullable; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.widget.Spinner; Loading Loading @@ -83,6 +84,8 @@ public abstract class BaseActivity extends Activity // We use the time gap to figure out whether to close app or reopen the drawer. private long mDrawerLastFiddled; private boolean mNavDrawerHasFocus; public abstract void onDocumentPicked(DocumentInfo doc, @Nullable SiblingProvider siblings); public abstract void onDocumentsPicked(List<DocumentInfo> docs); Loading Loading @@ -580,6 +583,54 @@ public abstract class BaseActivity extends Activity } } /** * Declare a global key handler to route key events when there isn't a specific focus view. This * covers the scenario where a user opens DocumentsUI and just starts typing. * * @param keyCode * @param event * @return */ @CallSuper @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (Events.isNavigationKeyCode(keyCode)) { // Forward all unclaimed navigation keystrokes to the DirectoryFragment. This causes any // stray navigation keystrokes focus the content pane, which is probably what the user // is trying to do. DirectoryFragment df = DirectoryFragment.get(getFragmentManager()); if (df != null) { df.requestFocus(); return true; } } else if (keyCode == KeyEvent.KEYCODE_TAB) { toggleNavDrawerFocus(); return true; } return super.onKeyDown(keyCode, event); } /** * Toggles focus between the navigation drawer and the directory listing. If the drawer isn't * locked, open/close it as appropriate. */ void toggleNavDrawerFocus() { if (mNavDrawerHasFocus) { mDrawer.setOpen(false); DirectoryFragment df = DirectoryFragment.get(getFragmentManager()); if (df != null) { df.requestFocus(); } } else { mDrawer.setOpen(true); RootsFragment rf = RootsFragment.get(getFragmentManager()); if (rf != null) { rf.requestFocus(); } } mNavDrawerHasFocus = !mNavDrawerHasFocus; } DocumentInfo getRootDocumentBlocking(RootInfo root) { try { final Uri uri = DocumentsContract.buildDocumentUri( Loading