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

Commit f8a51f6f authored by Ben Kwa's avatar Ben Kwa
Browse files

Update grid items to look more like the mocks.

- Create a new layout for directory items, which have a different
  layout (no thumbnail, size or mod_date).

- Add drop shadows.

Also refactor a few things in the DocumentHolder and child classes to
make things more efficient and cleaner.

BUG=24326989,26229570

Change-Id: I05df52b071667190d4c4c671f50d25498383cdaa
parent d8391498
Loading
Loading
Loading
Loading
+62 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 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.
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="@dimen/grid_item_margin"
    android:background="@color/item_doc_background"
    android:elevation="5dp"
    android:focusable="true">

    <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal"
      android:paddingTop="16dp"
      android:paddingBottom="16dp"
      android:paddingLeft="12dp"
      android:paddingRight="12dp">

        <ImageView
            android:src="@drawable/ic_doc_folder"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginEnd="8dp"
            android:scaleType="centerInside"
            android:contentDescription="@null"/>

        <TextView
            android:id="@android:id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:ellipsize="middle"
            android:textAlignment="viewStart"
            android:textAppearance="@android:style/TextAppearance.Material.Subhead"
            android:textColor="@*android:color/primary_text_default_material_light" />

    </LinearLayout>

    <!-- An overlay that draws the item border when it is focused. -->
    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@null"
        android:background="@drawable/item_doc_grid_border"
        android:duplicateParentState="true" />

</FrameLayout>
+1 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@
    android:layout_height="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/grid_item_margin"
    android:layout_margin="@dimen/grid_item_margin"
    android:background="@color/item_doc_background"
    android:background="@color/item_doc_background"
    android:elevation="5dp"
    android:focusable="true">
    android:focusable="true">


    <!-- Main item thumbnail.  Comprised of two overlapping images, the
    <!-- Main item thumbnail.  Comprised of two overlapping images, the
+14 −2
Original line number Original line Diff line number Diff line
@@ -964,7 +964,16 @@ public class DirectoryFragment extends Fragment {
            final State state = getDisplayState();
            final State state = getDisplayState();
            switch (state.derivedMode) {
            switch (state.derivedMode) {
                case MODE_GRID:
                case MODE_GRID:
                    holder = new GridDocumentHolder(getContext(), parent, mIconHelper, viewType);
                    switch (viewType) {
                        case ITEM_TYPE_DIRECTORY:
                            holder = new GridDirectoryHolder(getContext(), parent);
                            break;
                        case ITEM_TYPE_DOCUMENT:
                            holder = new GridDocumentHolder(getContext(), parent, mIconHelper);
                            break;
                        default:
                            throw new IllegalStateException("Unsupported layout type.");
                    }
                    break;
                    break;
                case MODE_LIST:
                case MODE_LIST:
                    holder = new ListDocumentHolder(getContext(), parent, mIconHelper);
                    holder = new ListDocumentHolder(getContext(), parent, mIconHelper);
@@ -1031,7 +1040,10 @@ public class DirectoryFragment extends Fragment {
        @Override
        @Override
        public void onModelUpdate(Model model) {
        public void onModelUpdate(Model model) {
            mModelIds = Lists.newArrayList(model.getModelIds());
            mModelIds = Lists.newArrayList(model.getModelIds());
            mDividerPosition = 0;
            // Start the divider at the end. That way if the code below encounters no documents
            // (i.e. in a directory containing only directories), the divider is placed at the end
            // of the list, as expected.
            mDividerPosition = mModelIds.size();


            // Walk down the list of IDs till we encounter something that's not a directory, and
            // Walk down the list of IDs till we encounter something that's not a directory, and
            // insert a whitespace element - this introduces a visual break in the grid between
            // insert a whitespace element - this introduces a visual break in the grid between
+3 −6
Original line number Original line Diff line number Diff line
@@ -40,16 +40,15 @@ public abstract class DocumentHolder
    final int mDefaultItemColor;
    final int mDefaultItemColor;
    final boolean mAlwaysShowSummary;
    final boolean mAlwaysShowSummary;
    final Context mContext;
    final Context mContext;
    final IconHelper mIconHelper;


    private ListDocumentHolder.ClickListener mClickListener;
    private ListDocumentHolder.ClickListener mClickListener;
    private View.OnKeyListener mKeyListener;
    private View.OnKeyListener mKeyListener;


    public DocumentHolder(Context context, ViewGroup parent, int layout, IconHelper iconHelper) {
    public DocumentHolder(Context context, ViewGroup parent, int layout) {
        this(context, inflateLayout(context, parent, layout), iconHelper);
        this(context, inflateLayout(context, parent, layout));
    }
    }


    public DocumentHolder(Context context, View item, IconHelper iconHelper) {
    public DocumentHolder(Context context, View item) {
        super(item);
        super(item);


        itemView.setOnKeyListener(this);
        itemView.setOnKeyListener(this);
@@ -59,8 +58,6 @@ public abstract class DocumentHolder
        mDefaultItemColor = context.getColor(R.color.item_doc_background);
        mDefaultItemColor = context.getColor(R.color.item_doc_background);
        mSelectedItemColor = context.getColor(R.color.item_doc_background_selected);
        mSelectedItemColor = context.getColor(R.color.item_doc_background_selected);
        mAlwaysShowSummary = context.getResources().getBoolean(R.bool.always_show_summary);
        mAlwaysShowSummary = context.getResources().getBoolean(R.bool.always_show_summary);

        mIconHelper = iconHelper;
    }
    }


    /**
    /**
+1 −1
Original line number Original line Diff line number Diff line
@@ -24,7 +24,7 @@ import com.android.documentsui.State;


final class EmptyDocumentHolder extends DocumentHolder {
final class EmptyDocumentHolder extends DocumentHolder {
    public EmptyDocumentHolder(Context context) {
    public EmptyDocumentHolder(Context context) {
        super(context, new View(context), null);
        super(context, new View(context));
        itemView.setVisibility(View.GONE);
        itemView.setVisibility(View.GONE);
    }
    }


Loading