diff options
| author | 2023-05-09 18:08:38 +0000 | |
|---|---|---|
| committer | 2023-05-09 18:08:38 +0000 | |
| commit | 5365337bba704796dfadb0f0ea251795fcfae73f (patch) | |
| tree | 2f4d0cb7f009882931b95d71e2b7d427d02f15b4 /java/src | |
| parent | e83421558c82ea0838d8a2ce0637608edc6da2b7 (diff) | |
Allow chooser targets to use two lines
Previous behavior is that direct share would get two lines
but app targets got one line for the label and one line for
the sub-label.
This forced truncation of labels even when no sub-label was
present (see bug).
This change evolves that by making the following changes:
1. Set the maxLines of the label instead of lines directly.
2. If there's no sublabel, set maxLines to 2.
3. Change the grid item's gravity so they're top-aligned
(previously they were all the same height yet centered).
Setting the line count directly didn't work because the
compound drawable would always be drawn as if there were two
lines.
One subtlety here is that a row of targets that all fit
within a single line will have less space between icons.
Bug: 280289219
Test: atest UnbundledChooserActivityTest
Test: manual review how a variety of targets render.
Change-Id: Id9831a310738631c9f767827fec595117ac3a487
Diffstat (limited to 'java/src')
| -rw-r--r-- | java/src/com/android/intentresolver/ChooserListAdapter.java | 8 | ||||
| -rw-r--r-- | java/src/com/android/intentresolver/ResolverListAdapter.java | 19 |
2 files changed, 9 insertions, 18 deletions
diff --git a/java/src/com/android/intentresolver/ChooserListAdapter.java b/java/src/com/android/intentresolver/ChooserListAdapter.java index ceeed6f0..ebbf5515 100644 --- a/java/src/com/android/intentresolver/ChooserListAdapter.java +++ b/java/src/com/android/intentresolver/ChooserListAdapter.java @@ -276,7 +276,7 @@ public class ChooserListAdapter extends ResolverListAdapter { return; } - holder.bindLabel(info.getDisplayLabel(), info.getExtendedInfo(), alwaysShowSubLabel()); + holder.bindLabel(info.getDisplayLabel(), info.getExtendedInfo()); mAnimationTracker.animateLabel(holder.text, info); if (holder.text2.getVisibility() == View.VISIBLE) { mAnimationTracker.animateLabel(holder.text2, info); @@ -630,12 +630,6 @@ public class ChooserListAdapter extends ResolverListAdapter { notifyDataSetChanged(); } - protected boolean alwaysShowSubLabel() { - // Always show a subLabel for visual consistency across list items. Show an empty - // subLabel if the subLabel is the same as the label - return true; - } - /** * Rather than fully sorting the input list, this sorting task will put the top k elements * in the head of input list and fill the tail with other elements in undetermined order. diff --git a/java/src/com/android/intentresolver/ResolverListAdapter.java b/java/src/com/android/intentresolver/ResolverListAdapter.java index f090f3a2..fb7641b3 100644 --- a/java/src/com/android/intentresolver/ResolverListAdapter.java +++ b/java/src/com/android/intentresolver/ResolverListAdapter.java @@ -682,7 +682,7 @@ public class ResolverListAdapter extends BaseAdapter { final ViewHolder holder = (ViewHolder) view.getTag(); if (info == null) { holder.icon.setImageDrawable(loadIconPlaceholder()); - holder.bindLabel("", "", false); + holder.bindLabel("", ""); return; } @@ -691,10 +691,9 @@ public class ResolverListAdapter extends BaseAdapter { if (dri.hasDisplayLabel()) { holder.bindLabel( dri.getDisplayLabel(), - dri.getExtendedInfo(), - alwaysShowSubLabel()); + dri.getExtendedInfo()); } else { - holder.bindLabel("", "", false); + holder.bindLabel("", ""); loadLabel(dri); } holder.bindIcon(info); @@ -830,10 +829,6 @@ public class ResolverListAdapter extends BaseAdapter { mIsTabLoaded = true; } - protected boolean alwaysShowSubLabel() { - return false; - } - /** * Find the first element in a list of {@code ResolvedComponentInfo} objects whose * {@code ResolveInfo} specifies a {@code targetUserId} other than the current user. @@ -940,17 +935,19 @@ public class ResolverListAdapter extends BaseAdapter { icon = (ImageView) view.findViewById(com.android.internal.R.id.icon); } - public void bindLabel(CharSequence label, CharSequence subLabel, boolean showSubLabel) { + public void bindLabel(CharSequence label, CharSequence subLabel) { text.setText(label); if (TextUtils.equals(label, subLabel)) { subLabel = null; } - text2.setText(subLabel); - if (showSubLabel || subLabel != null) { + if (!TextUtils.isEmpty(subLabel)) { + text.setMaxLines(1); + text2.setText(subLabel); text2.setVisibility(View.VISIBLE); } else { + text.setMaxLines(2); text2.setVisibility(View.GONE); } |