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

Commit 9f298eab authored by Tony Huang's avatar Tony Huang
Browse files

Update inspector view design

Due to a11y visual issue, update inspector page toolbar design
and also update elevation to fit design mock.

Bug: 123209419
Test: manual
Test: atest DocumentsUIGoogleTests
Change-Id: I784af24dc17862a3d1621d17b612443627248c4c
parent 75671357
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -35,21 +35,30 @@
            android:minHeight="?android:attr/actionBarSize"
            android:fitsSystemWindows="true"
            app:titleEnabled="false"
            app:contentScrim="?android:colorBackground"
            app:statusBarScrim="@android:color/transparent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.widget.Space
                    android:layout_width="match_parent"
                    android:layout_height="?android:attr/actionBarSize"/>

                <com.android.documentsui.inspector.HeaderView
                    android:id="@+id/inspector_header_view"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/inspector_header_height"
                    app:layout_collapseMode="parallax"/>
            </LinearLayout>

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?android:attr/actionBarSize"
                android:background="@drawable/gradient_actionbar_background"
                android:background="?android:attr/colorBackground"
                android:theme="?actionBarTheme"
                app:title="@string/inspector_title"
                app:layout_collapseMode="pin">
@@ -61,7 +70,7 @@
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:behavior_overlapTop="40dp"
        app:behavior_overlapTop="10dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
@@ -69,8 +78,6 @@
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/bottom_sheet_dialog_background"
            android:layout_marginTop="4dp"
            android:elevation="8dp"
            android:paddingBottom="5dp">

            <com.android.documentsui.inspector.DetailsView
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@
    <dimen name="bottom_bar_button_horizontal_padding">24dp</dimen>
    <dimen name="bottom_bar_button_corner_radius">4dp</dimen>

    <dimen name="inspector_header_height">350dp</dimen>
    <dimen name="inspector_header_height">280dp</dimen>

    <dimen name="root_info_header_height">60dp</dimen>
    <dimen name="root_info_header_horizontal_padding">24dp</dimen>
+0 −49
Original line number Diff line number Diff line
@@ -17,18 +17,12 @@ package com.android.documentsui.inspector;

import static androidx.core.util.Preconditions.checkArgument;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.MenuItem;
import android.view.View;

import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.loader.app.LoaderManager;
@@ -37,14 +31,11 @@ import com.android.documentsui.R;
import com.android.documentsui.base.Shared;
import com.android.documentsui.inspector.InspectorController.DataSupplier;

import com.google.android.material.appbar.AppBarLayout;

public class InspectorActivity extends AppCompatActivity {

    private InspectorController mController;
    private View mView;
    private Toolbar mToolbar;
    private @ColorInt int mTitleColor;

    @Override
    public void onCreate(Bundle savedInstanceState) {
@@ -60,10 +51,6 @@ public class InspectorActivity extends AppCompatActivity {
        mToolbar = findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        initRes();

        AppBarLayout appBarLayout = findViewById(R.id.app_bar);
        appBarLayout.addOnOffsetChangedListener(this::onOffsetChanged);

        final DataSupplier loader = new RuntimeDataSupplier(this, LoaderManager.getInstance(this));

@@ -73,42 +60,6 @@ public class InspectorActivity extends AppCompatActivity {
                getIntent().getBooleanExtra(Shared.EXTRA_SHOW_DEBUG, false));
    }

    private void onOffsetChanged(AppBarLayout layout, int offset) {
        int diff = layout.getTotalScrollRange() - Math.abs(offset);
        if (diff <= 0) {
            //Collapsing tool bar is collapsed, recover to original bar present.
            mToolbar.getBackground().setAlpha(0);
            setActionBarItemColor(mTitleColor);
        } else {
            float ratio = (float) diff / (float) layout.getTotalScrollRange();
            int alpha = (int) (ratio * 255);
            mToolbar.getBackground().setAlpha(alpha);
            setActionBarItemColor(Color.WHITE);
        }
    }

    private void setActionBarItemColor(int color) {
        mToolbar.setTitleTextColor(color);
        mToolbar.getNavigationIcon().setTint(color);
        mToolbar.getOverflowIcon().setTint(color);
    }

    private void initRes() {
        final Resources.Theme theme = this.getTheme();
        final TypedValue outValue = new TypedValue();
        // Resolve actionBarTheme from AppCompat theme, keep obtain textColorPrimary if found
        final boolean found = theme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
        if (found) {
            TypedArray ta =
                    this.obtainStyledAttributes(outValue.data, R.styleable.ActionBarView);
            mTitleColor = ta.getColor(R.styleable.ActionBarView_android_textColorPrimary,
                    Color.BLACK);
            ta.recycle();
        } else {
            mTitleColor = Color.BLACK;
        }
    }

    @Override
    protected void onStart() {
        super.onStart();