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

Commit ae730b1f authored by Mike Digman's avatar Mike Digman
Browse files

Sharesheet - add a-z list label

New users may not understand what the a-z list is, as demoed in
user testing. Add a label above the list that describes the
contents.

Bug: 130349817
Test: manual
Change-Id: I64bee605ab33dd486ef6cd95346c46f4eff62269
parent a2f8ee47
Loading
Loading
Loading
Loading
+42 −15
Original line number Diff line number Diff line
@@ -2496,6 +2496,7 @@ public class ChooserActivity extends ResolverActivity {
        private static final int VIEW_TYPE_NORMAL = 1;
        private static final int VIEW_TYPE_CONTENT_PREVIEW = 2;
        private static final int VIEW_TYPE_PROFILE = 3;
        private static final int VIEW_TYPE_AZ_LABEL = 4;

        private static final int MAX_TARGETS_PER_ROW_PORTRAIT = 4;
        private static final int MAX_TARGETS_PER_ROW_LANDSCAPE = 8;
@@ -2556,6 +2557,7 @@ public class ChooserActivity extends ResolverActivity {
                            + getProfileRowCount()
                            + getServiceTargetRowCount()
                            + getCallerAndRankedTargetRowCount()
                            + getAzLabelRowCount()
                            + Math.ceil(
                            (float) mChooserListAdapter.getAlphaTargetCount()
                                    / getMaxTargetsPerRow())
@@ -2593,6 +2595,11 @@ public class ChooserActivity extends ResolverActivity {
            return 0;
        }

        public int getAzLabelRowCount() {
            // Only show a label if the a-z list is showing
            return mChooserListAdapter.getAlphaTargetCount() > 0 ? 1 : 0;
        }

        @Override
        public Object getItem(int position) {
            // We have nothing useful to return here.
@@ -2617,6 +2624,10 @@ public class ChooserActivity extends ResolverActivity {
                return createProfileView(convertView, parent);
            }

            if (viewType == VIEW_TYPE_AZ_LABEL) {
                return createAzLabelView(parent);
            }

            if (convertView == null) {
                holder = createViewHolder(viewType, parent);
            } else {
@@ -2630,27 +2641,29 @@ public class ChooserActivity extends ResolverActivity {

        @Override
        public int getItemViewType(int position) {
            if (position == 0 && getContentPreviewRowCount() == 1) {
                return VIEW_TYPE_CONTENT_PREVIEW;
            }
            int count;

            if (getProfileRowCount() == 1 && position == getContentPreviewRowCount()) {
                return VIEW_TYPE_PROFILE;
            }
            int countSum = (count = getContentPreviewRowCount());
            if (count > 0 && position < countSum) return VIEW_TYPE_CONTENT_PREVIEW;

            final int start = getFirstRowPosition(position);
            final int startType = mChooserListAdapter.getPositionTargetType(start);
            countSum += (count = getProfileRowCount());
            if (count > 0 && position < countSum) return VIEW_TYPE_PROFILE;

            if (startType == ChooserListAdapter.TARGET_SERVICE) {
                return VIEW_TYPE_DIRECT_SHARE;
            }
            countSum += (count = getServiceTargetRowCount());
            if (count > 0 && position < countSum) return VIEW_TYPE_DIRECT_SHARE;

            countSum += (count = getCallerAndRankedTargetRowCount());
            if (count > 0 && position < countSum) return VIEW_TYPE_NORMAL;

            countSum += (count = getAzLabelRowCount());
            if (count > 0 && position < countSum) return VIEW_TYPE_AZ_LABEL;

            return VIEW_TYPE_NORMAL;
        }

        @Override
        public int getViewTypeCount() {
            return 4;
            return 5;
        }

        private ViewGroup createContentPreviewView(View convertView, ViewGroup parent) {
@@ -2677,6 +2690,10 @@ public class ChooserActivity extends ResolverActivity {
            return profileRow;
        }

        private View createAzLabelView(ViewGroup parent) {
            return mLayoutInflater.inflate(R.layout.chooser_az_label_row, parent, false);
        }

        private RowViewHolder loadViewsIntoRow(RowViewHolder holder) {
            final int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
            final int exactSpec = MeasureSpec.makeMeasureSpec(mChooserTargetWidth,
@@ -2775,16 +2792,24 @@ public class ChooserActivity extends ResolverActivity {
        }

        /**
         * Need to merge CALLER + ranked STANDARD into a single row. All other types
         * are placed into their own row as determined by their target type, and dividers
         * are added in the list to separate each type.
         * Need to merge CALLER + ranked STANDARD into a single row and prevent a separator from
         * showing on top of the AZ list if the AZ label is visible. All other types are placed into
         * their own row as determined by their target type, and dividers are added in the list to
         * separate each type.
         */
        int getRowType(int rowPosition) {
            // Merge caller and ranked standard into a single row
            int positionType = mChooserListAdapter.getPositionTargetType(rowPosition);
            if (positionType == ChooserListAdapter.TARGET_CALLER) {
                return ChooserListAdapter.TARGET_STANDARD;
            }

            // If an the A-Z label is shown, prevent a separator from appearing by making the A-Z
            // row type the same as the suggestion row type
            if (getAzLabelRowCount() > 0 && positionType == ChooserListAdapter.TARGET_STANDARD_AZ) {
                return ChooserListAdapter.TARGET_STANDARD;
            }

            return positionType;
        }

@@ -2864,6 +2889,8 @@ public class ChooserActivity extends ResolverActivity {
                return serviceCount + (row - serviceRows) * getMaxTargetsPerRow();
            }

            row -= getAzLabelRowCount();

            return callerAndRankedCount + serviceCount
                    + (row - callerAndRankedRows - serviceRows) * getMaxTargetsPerRow();
        }
+31 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2019 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
  -->

<!-- Separator applied as background -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
          android:text="@string/chooser_all_apps_button_label"
          android:contentDescription="@string/chooser_all_apps_button_label"
          android:background="@drawable/chooser_row_layer_list"
          android:textAppearance="?attr/textAppearanceSmall"
          android:textColor="?attr/textColorSecondary"
          android:textSize="14sp"
          android:singleLine="true"
          android:paddingTop="16dp"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="center"/>
+3 −0
Original line number Diff line number Diff line
@@ -5373,4 +5373,7 @@
    <!-- ChooserActivity - No direct share targets are available. [CHAR LIMIT=NONE] -->
    <string name="chooser_no_direct_share_targets">Direct share not available</string>

    <!-- ChooserActivity - Alphabetically sorted apps list label. [CHAR LIMIT=NONE] -->
    <string name="chooser_all_apps_button_label">Apps list</string>

</resources>
+2 −0
Original line number Diff line number Diff line
@@ -3771,4 +3771,6 @@
  <java-symbol type="color" name="chooser_gradient_highlight" />
  <java-symbol type="drawable" name="chooser_direct_share_label_placeholder" />
  <java-symbol type="dimen" name="chooser_direct_share_label_placeholder_max_width" />
  <java-symbol type="layout" name="chooser_az_label_row" />
  <java-symbol type="string" name="chooser_all_apps_button_label" />
</resources>