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

Commit 7276a00c authored by Tony Huang's avatar Tony Huang Committed by Android (Google) Code Review
Browse files

Merge "Update inspector view design" into qt-dev

parents 1ab79483 9f298eab
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 −48
Original line number Diff line number Diff line
@@ -18,16 +18,11 @@ package com.android.documentsui.inspector;
import static androidx.core.util.Preconditions.checkArgument;

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;
@@ -36,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) {
@@ -59,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));

@@ -72,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();