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

Commit e78ce12f authored by Wenbo Jie's avatar Wenbo Jie
Browse files

[DocsUI M3] Add tooltip for the file names in list mode

Check the attached bug for demo.

Bug: 406305754
Test: m DocumentsUIGoogle && manual inspection
Flag: com.android.documentsui.flags.use_material3
Change-Id: I97f1d794cb5f53fab9ec69dc25bc8bced617d6d5
parent c6c97f12
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@
                    android:id="@android:id/title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:ellipsize="middle"
                    android:singleLine="true"
                    android:textAlignment="viewStart"
                    android:textAppearance="@style/FileItemLabelText"/>
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@
              android:id="@android:id/title"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:ellipsize="end"
              android:ellipsize="middle"
              android:singleLine="true"
              android:textAlignment="viewStart"
              android:textAppearance="@style/FileItemLabelText" />
+17 −1
Original line number Diff line number Diff line
@@ -290,7 +290,23 @@ final class ListDocumentHolder extends DocumentHolder {
                    }
                });

        if (isUseMaterial3FlagEnabled()) {
            // Only Normal type work with ellipsize=middle.
            mTitle.setText(mDoc.displayName, TextView.BufferType.NORMAL);
            // Doing this hacky way instead of just "mTitle.setTooltipText()" because calling
            // "mTitle.setTooltipText()" directly will break the ripple effects on the title area.
            itemView.setOnHoverListener(
                    (v, event) -> {
                        if (event.getAction() == MotionEvent.ACTION_HOVER_ENTER) {
                            mTitle.setTooltipText(mDoc.displayName);
                        } else if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT) {
                            mTitle.setTooltipText(null);
                        }
                        return false;
                    });
        } else {
            mTitle.setText(mDoc.displayName, TextView.BufferType.SPANNABLE);
        }
        mTitle.setVisibility(View.VISIBLE);

        if (mDoc.isDirectory()) {