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

Commit 1f50c724 authored by Tony Huang's avatar Tony Huang
Browse files

Fine tune the UI about header message

We add horizontal padding on list mode for solving header message
moving issue when mode switch, but it still have some display issue.

Fix it only on header message layout, use different horizontal
padding to keep same position on both mode.

Bug: 134308835
Test: manual
Test: atest DocumentsUIGoogleTests
Change-Id: I0f5b0c92e42da8b6916961a5da97584b3d1d2fa0
parent 39b8ead9
Loading
Loading
Loading
Loading
+48 −41
Original line number Diff line number Diff line
@@ -13,9 +13,15 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<com.google.android.material.card.MaterialCardView

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/item_root"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <com.google.android.material.card.MaterialCardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="4dp"
@@ -62,3 +68,4 @@
                style="@style/DialogTextButton"/>
        </RelativeLayout>
    </com.google.android.material.card.MaterialCardView>
</FrameLayout>
+2 −0
Original line number Diff line number Diff line
@@ -131,6 +131,8 @@ final class DirectoryAddonsAdapter extends DocumentsAdapter {
                break;
            case ITEM_TYPE_HEADER_MESSAGE:
                ((HeaderMessageDocumentHolder) holder).bind(mHeaderMessage);
                ((HeaderMessageDocumentHolder) holder).setPadding(
                        mEnv.getDisplayState().derivedMode);
                break;
            case ITEM_TYPE_INFLATED_MESSAGE:
                ((InflateMessageDocumentHolder) holder).bind(mInflateMessage);
+16 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.documentsui.dirlist;

import static com.android.documentsui.base.State.MODE_GRID;

import android.content.Context;
import android.database.Cursor;
import android.view.View;
@@ -25,6 +27,7 @@ import android.widget.ImageView;
import android.widget.TextView;

import com.android.documentsui.R;
import com.android.documentsui.base.State.ViewMode;

/**
 * RecyclerView.ViewHolder class that displays at the top of the directory list when there
@@ -32,6 +35,7 @@ import com.android.documentsui.R;
 * Used by {@link DirectoryAddonsAdapter}.
 */
final class HeaderMessageDocumentHolder extends MessageHolder {
    private final View mRoot;
    private final ImageView mIcon;
    private final TextView mTextView;
    private final Button mButton;
@@ -40,6 +44,7 @@ final class HeaderMessageDocumentHolder extends MessageHolder {
    public HeaderMessageDocumentHolder(Context context, ViewGroup parent) {
        super(context, parent, R.layout.item_doc_header_message);

        mRoot = itemView.findViewById(R.id.item_root);
        mIcon = (ImageView) itemView.findViewById(R.id.message_icon);
        mTextView = (TextView) itemView.findViewById(R.id.message_textview);
        mButton = (Button) itemView.findViewById(R.id.button_dismiss);
@@ -51,6 +56,17 @@ final class HeaderMessageDocumentHolder extends MessageHolder {
        bind(null, null);
    }

    /**
     * We set different padding on directory parent in different mode by
     * {@link DirectoryFragment#onViewModeChanged()}. To avoid the layout shifting when
     * display mode changed, we set the opposite padding on the item.
     */
    public void setPadding(@ViewMode int mode) {
        int padding = itemView.getResources().getDimensionPixelSize(mode == MODE_GRID
                ? R.dimen.list_container_padding : R.dimen.grid_container_padding);
        mRoot.setPadding(padding, 0, padding, 0);
    }

    private void onButtonClick(View button) {
        mMessage.runCallback();
    }