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

Commit 263283f7 authored by Wenbo Jie's avatar Wenbo Jie
Browse files

[DocsUI M3] Use GridDocumentHolder for photo picking

Previously there was a GridPhotoHolder class for image grid items
in photo picking mode (e.g. ACTION_OPEN_DOCUMENT intent with
"image/*" Mime type), which creates style inconsistencies
especially when images and directories are shown together. To
enforce style consistency, this CL stops using GridPhotoHolder
and all specific setup for grid photo picking and use
GridDocumentHolder instead, same as other grid items.

Note: previously in GridPhotoHolder there's no selection region,
after replacing to GridDocumentHolder it has the same selection
region logic as other items for consistency.

Check the attached bug for the before/after comparison.

Bug: 401107792
Test: m DocumentsUIGoogle && manual inspection
Flag: com.android.documentsui.flags.use_material3
Change-Id: I2ba8b8157ff13949875350914269718db55714ce
parent befca12b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -103,7 +103,8 @@ final class DirectoryAddonsAdapter extends DocumentsAdapter {
                        || getItemViewType(position) == ITEM_TYPE_HEADER_MESSAGE
                        || getItemViewType(position) == ITEM_TYPE_INFLATED_MESSAGE) {
                    return columnCount;
                } else if (mEnv.getDisplayState().isPhotoPicking()
                } else if (!isUseMaterial3FlagEnabled()
                        && mEnv.getDisplayState().isPhotoPicking()
                        && mEnv.getDisplayState().derivedMode == State.MODE_GRID) {
                    // If on photo picking state and grid mode,
                    // the UI should show 3 images a row or 2 folders a row.
+1 −1
Original line number Diff line number Diff line
@@ -922,7 +922,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
        // Clamp so that we always lay out the grid with at least 2 columns by default.
        // If on photo picking state, the UI should show 3 images a row or 2 folders a row,
        // so use 6 columns by default and set folder size to 3 and document size is to 2.
        mColumnUnit = mState.isPhotoPicking() ? 3 : 1;
        mColumnUnit = (!isUseMaterial3FlagEnabled() && mState.isPhotoPicking()) ? 3 : 1;
        int columnCount = mColumnUnit * Math.max(2,
                (mRecView.getWidth() - viewPadding) / (cellWidth + cellMargin));

+2 −0
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ import com.android.modules.utils.build.SdkLevel;
import java.util.Map;
import java.util.function.Function;

// TODO(b/379776735): remove this file after use_material3 flag is launched.
// GridDocumentHolder is used for all types of grid items.
final class GridPhotoHolder extends DocumentHolder {

    private final ImageView mIconMimeLg;
+12 −5
Original line number Diff line number Diff line
@@ -105,10 +105,17 @@ final class ModelBackedDocumentsAdapter extends DocumentsAdapter {
                                        mEnv.getContext(), parent, mIconHelper, mConfigStore);
                        break;
                    case ITEM_TYPE_DOCUMENT:
                        holder = state.isPhotoPicking()
                                ? new GridPhotoHolder(mEnv.getContext(), parent, mIconHelper,
                        holder =
                                (!isUseMaterial3FlagEnabled() && state.isPhotoPicking())
                                        ? new GridPhotoHolder(
                                                mEnv.getContext(),
                                                parent,
                                                mIconHelper,
                                                mConfigStore)
                                : new GridDocumentHolder(mEnv.getContext(), parent, mIconHelper,
                                        : new GridDocumentHolder(
                                                mEnv.getContext(),
                                                parent,
                                                mIconHelper,
                                                mConfigStore);
                        break;
                    default: