Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a9cef937 authored by Takamasa Kuramitsu's avatar Takamasa Kuramitsu Committed by android-build-merger
Browse files

Fix crash when opening inspector screen of broken folder

am: 59710528

Change-Id: Iacb95f2405e1557cfaad157ef086c4cb90d6269a
parents 0f49d4dd 59710528
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -383,6 +383,13 @@ public abstract class BaseActivity
                && !root.isRecents();
    }

    /**
     * Returns true if a directory can be inspected.
     */
    protected boolean canInspectDirectory() {
        return false;
    }

    // TODO: make navigator listen to state
    @Override
    public final void updateNavigator() {
+4 −0
Original line number Diff line number Diff line
@@ -381,5 +381,9 @@ public abstract class MenuManager {
        public boolean canCreateDirectory() {
            return mActivity.canCreateDirectory();
        }

        public boolean canInspectDirectory() {
            return mActivity.canInspectDirectory();
        }
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -1117,6 +1117,10 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
            if (!mModel.isLoading()) {
                mActivity.notifyDirectoryLoaded(
                        mModel.doc != null ? mModel.doc.derivedUri : null);
                if (mModel.doc == null) {
                    // Invalid model, then update options menu to disable some items.
                    mActivity.invalidateOptionsMenu();
                }
            }
        }
    }
+5 −0
Original line number Diff line number Diff line
@@ -398,6 +398,11 @@ public class FilesActivity extends BaseActivity implements ActionHandler.Addons
        mInjector.focusManager.focusDocument(doc.documentId);
    }

    @Override
    protected boolean canInspectDirectory() {
        return getCurrentDirectory() != null && mInjector.getModel().doc != null;
    }

    @CallSuper
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
+1 −3
Original line number Diff line number Diff line
@@ -270,9 +270,7 @@ public final class MenuManager extends com.android.documentsui.MenuManager {
    protected void updateInspect(MenuItem inspect) {
        boolean visible = mFeatures.isInspectorEnabled();
        inspect.setVisible(visible);
        // use a null check w/ peek instead of isEmpty since
        // DocumentStack accepts null values (not sure why).
        inspect.setEnabled(visible && mState.stack.peek() != null);
        inspect.setEnabled(visible && mDirDetails.canInspectDirectory());
    }

    @Override
Loading