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

Commit d2fc4cde authored by Garfield Tan's avatar Garfield Tan
Browse files

Fix a DocsUI crash...

when user toggles multiwindow mode with an empty search widget. Also a
bit cleaning around Toolbar.

Bug: 34881838
Change-Id: Ib093ed5bf5e9f9a95d815119620ecddd84d428f7
parent 390cd78b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@
            android:layout_height="match_parent"
            android:orientation="vertical">

            <com.android.documentsui.DocumentsToolbar
            <Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?android:attr/actionBarSize"
@@ -50,7 +50,7 @@
                    android:background="@android:color/transparent"
                    android:overlapAnchor="true" />

            </com.android.documentsui.DocumentsToolbar>
            </Toolbar>

            <FrameLayout
                android:layout_width="match_parent"
+2 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
        android:layout_height="match_parent"
        android:orientation="vertical">

        <com.android.documentsui.DocumentsToolbar
        <Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?android:attr/actionBarSize"
@@ -45,7 +45,7 @@
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

        </com.android.documentsui.DocumentsToolbar>
        </Toolbar>

        <LinearLayout
            android:layout_width="match_parent"
+3 −2
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toolbar;

import com.android.documentsui.AbstractActionHandler.CommonAddons;
import com.android.documentsui.Injector.Injected;
@@ -140,7 +141,7 @@ public abstract class BaseActivity
        mRoots = DocumentsApplication.getRootsCache(this);
        mDocs = DocumentsAccess.create(this);

        DocumentsToolbar toolbar = (DocumentsToolbar) findViewById(R.id.toolbar);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setActionBar(toolbar);

        Breadcrumb breadcrumb =
@@ -227,7 +228,7 @@ public abstract class BaseActivity
        getMenuInflater().inflate(R.menu.activity, menu);
        mNavigator.update();
        boolean fullBarSearch = getResources().getBoolean(R.bool.full_bar_search_view);
        mSearchManager.install((DocumentsToolbar) findViewById(R.id.toolbar), fullBarSearch);
        mSearchManager.install(menu, fullBarSearch);

        return showMenu;
    }
+0 −72
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.documentsui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MenuItem;
import android.widget.Toolbar;

/**
 * ToolBar of Documents UI.
 */
public class DocumentsToolbar extends Toolbar {
    interface OnActionViewCollapsedListener {
        void onActionViewCollapsed();
    }

    private OnActionViewCollapsedListener mOnActionViewCollapsedListener;

    public DocumentsToolbar(Context context, AttributeSet attrs,
            int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public DocumentsToolbar(Context context, AttributeSet attrs,
            int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public DocumentsToolbar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DocumentsToolbar(Context context) {
        super(context);
    }

    @Override
    public void collapseActionView() {
        super.collapseActionView();
        if (mOnActionViewCollapsedListener != null) {
            mOnActionViewCollapsedListener.onActionViewCollapsed();
        }
    }

    /**
     * Adds a listener that is invoked after collapsing the action view.
     * @param listener
     */
    public void setOnActionViewCollapsedListener(
            OnActionViewCollapsedListener listener) {
        mOnActionViewCollapsedListener = listener;
    }

    public MenuItem getSearchMenu() {
        return getMenu().findItem(R.id.menu_search);
    }
}
+7 −6
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.Nullable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import android.widget.Toolbar;

import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.State;
@@ -36,15 +37,15 @@ public class NavigationViewManager {

    private static final String TAG = "NavigationViewManager";

    final DrawerController mDrawer;
    final DocumentsToolbar mToolbar;
    final State mState;
    final NavigationViewManager.Environment mEnv;
    final Breadcrumb mBreadcrumb;
    private final DrawerController mDrawer;
    private final Toolbar mToolbar;
    private final State mState;
    private final NavigationViewManager.Environment mEnv;
    private final Breadcrumb mBreadcrumb;

    public NavigationViewManager(
            DrawerController drawer,
            DocumentsToolbar toolbar,
            Toolbar toolbar,
            State state,
            NavigationViewManager.Environment env,
            Breadcrumb breadcrumb) {
Loading