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

Commit 3b7ed7ae authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Dashboard search bar polish" into oc-dr1-dev

parents fbfca43e 40be7df5
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 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.
-->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="@dimen/search_bar_margin">
    <View
        android:layout_width="match_parent"
        android:layout_height="?android:attr/actionBarSize"/>
</LinearLayout>
+26 −22
Original line number Diff line number Diff line
@@ -17,14 +17,15 @@
*/
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
    android:orientation="vertical">
    <FrameLayout
        android:id="@+id/main_content"
        android:layout_height="match_parent"
        android:layout_width="match_parent"/>
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/material_grey_300">
        <android.support.v7.widget.CardView
            android:id="@+id/search_bar"
            android:layout_width="match_parent"
@@ -37,12 +38,15 @@
                android:id="@+id/search_action_bar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/search_bar_negative_margin"
                android:background="?android:attr/selectableItemBackground"
                android:contentInsetStartWithNavigation="64dp"
                android:navigationIcon="@drawable/ic_search_24dp"
            android:title="@string/search_menu"
            android:titleTextAppearance="?android:attr/subtitleTextAppearance"
            android:titleTextColor="?android:attr/textColorHint"
                android:titleTextColor="@*android:color/text_color_primary"
                android:theme="?android:attr/actionBarTheme"/>
        </android.support.v7.widget.CardView>
    </FrameLayout>
    <FrameLayout
        android:id="@+id/main_content"
        android:layout_height="match_parent"
        android:layout_width="match_parent"/>
</LinearLayout>
+8 −0
Original line number Diff line number Diff line
@@ -337,6 +337,14 @@ public class SettingsActivity extends SettingsDrawerActivity
            Toolbar toolbar = findViewById(R.id.search_action_bar);
            toolbar.setOnClickListener(this);
            setActionBar(toolbar);

            // Please forgive me for what I am about to do.
            //
            // Need to make the navigation icon non-clickable so that the entire card is clickable
            // and goes to the search UI. Also set the background to null so there's no ripple.
            View navView = toolbar.getNavigationView();
            navView.setClickable(false);
            navView.setBackground(null);
        }

        ActionBar actionBar = getActionBar();
+0 −31
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
    private static final String STATE_CATEGORY_LIST = "category_list";
    private static final String STATE_SUGGESTION_MODE = "suggestion_mode";
    private static final String STATE_SUGGESTIONS_SHOWN_LOGGED = "suggestions_shown_logged";
    private static final int DONT_SET_BACKGROUND_ATTR = -1;
    private static final String STATE_SUGGESTION_CONDITION_MODE = "suggestion_condition_mode";

    private final IconCache mCache;
@@ -305,9 +304,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
    public void onBindViewHolder(DashboardItemHolder holder, int position) {
        final int type = mDashboardData.getItemTypeByPosition(position);
        switch (type) {
            case R.layout.dashboard_header_spacer:
                onBindHeaderSpacer(holder, position);
                break;
            case R.layout.dashboard_category:
                onBindCategory(holder,
                        (DashboardCategory) mDashboardData.getItemEntityByPosition(position));
@@ -484,33 +480,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
        notifyDashboardDataChanged(prevData);
    }

    private void onBindHeaderSpacer(DashboardItemHolder holder, int position) {
        if (mDashboardData.size() > (position + 1)) {
            // The spacer that goes underneath the search bar needs to match the
            // background of the first real view. That view is either a condition,
            // a suggestion, or the dashboard item.
            //
            // If it's a dashboard item, set null background so it uses the parent's
            // background like the other views. Otherwise, match the colors.
            int nextType = mDashboardData.getItemTypeByPosition(position + 1);
            int colorAttr = nextType == R.layout.suggestion_header
                    ? android.R.attr.colorSecondary
                    : nextType == R.layout.condition_card
                            ? android.R.attr.colorAccent
                            : DONT_SET_BACKGROUND_ATTR;

            if (colorAttr != DONT_SET_BACKGROUND_ATTR) {
                TypedArray array = holder.itemView.getContext()
                        .obtainStyledAttributes(new int[]{colorAttr});
                @ColorInt int color = array.getColor(0, 0);
                array.recycle();
                holder.itemView.setBackgroundColor(color);
            } else {
                holder.itemView.setBackground(null);
            }
        }
    }

    @VisibleForTesting
    void onBindSuggestionHeader(final DashboardItemHolder holder, DashboardData
            .SuggestionHeaderData data) {
+1 −5
Original line number Diff line number Diff line
@@ -60,8 +60,7 @@ public class DashboardData {
    public static final int DEFAULT_SUGGESTION_COUNT = 2;

    // id namespace for different type of items.
    private static final int NS_HEADER_SPACER = 0;
    private static final int NS_SPACER = 1000;
    private static final int NS_SPACER = 0;
    private static final int NS_ITEMS = 2000;
    private static final int NS_CONDITION = 3000;
    private static final int NS_SUGGESTION_CONDITION = 4000;
@@ -283,9 +282,6 @@ public class DashboardData {
     * and mIsShowingAll, mSuggestionMode flag.
     */
    private void buildItemsData() {
        // add the view that goes under the search bar
        countItem(null, R.layout.dashboard_header_spacer, true, NS_HEADER_SPACER);
        resetCount();
        final boolean hasSuggestions = sizeOf(mSuggestions) > 0;
        if (!mCombineSuggestionAndCondition) {
            boolean hasConditions = false;
Loading