Merge "Folder Previews Show Grey Pending Icon" into main

This commit is contained in:
Andrew Cole
2024-02-21 20:37:17 +00:00
committed by Android (Google) Code Review
5 changed files with 125 additions and 42 deletions

View File

@@ -425,7 +425,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
}
/**
* Only if actual text can be displayed in two line, the {@code true} value will be effective.
* Only if actual text can be displayed in two line, the {@code true} value will be effective.
*/
protected boolean shouldUseTwoLine() {
return FeatureFlags.enableTwolineAllapps() && isCurrentLanguageEnglish()
@@ -583,12 +583,12 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
/**
* Find the appropriate text spacing to display the provided text
* @param paint the paint used by the text view
* @param text the text to display
* @param allowedWidthPx available space to render the text
* @param minSpacingEm minimum spacing allowed between characters
* @return the final textSpacing value
*
* @param paint the paint used by the text view
* @param text the text to display
* @param allowedWidthPx available space to render the text
* @param minSpacingEm minimum spacing allowed between characters
* @return the final textSpacing value
* @see #setLetterSpacing(float)
*/
private float findBestSpacingValue(TextPaint paint, String text, float allowedWidthPx,
@@ -816,13 +816,13 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
* iterating through the list of break points and determining if the strings between the break
* points can fit within the line it is in. We will show the modified string if there is enough
* horizontal and vertical space, otherwise this method will just return the original string.
* Example assuming each character takes up one spot:
* title = "Battery Stats", breakpoint = [6], stringPtr = 0, limitedWidth = 7
* We get the current word -> from sublist(0, breakpoint[i]+1) so sublist (0,7) -> Battery,
* now stringPtr = 7 then from sublist(7) the current string is " Stats" and the runningWidth
* at this point exceeds limitedWidth and so we put " Stats" onto the next line (after checking
* if the first char is a SPACE, we trim to append "Stats". So resulting string would be
* "Battery\nStats"
* Example assuming each character takes up one spot:
* title = "Battery Stats", breakpoint = [6], stringPtr = 0, limitedWidth = 7
* We get the current word -> from sublist(0, breakpoint[i]+1) so sublist (0,7) -> Battery,
* now stringPtr = 7 then from sublist(7) the current string is " Stats" and the runningWidth
* at this point exceeds limitedWidth and so we put " Stats" onto the next line (after checking
* if the first char is a SPACE, we trim to append "Stats". So resulting string would be
* "Battery\nStats"
*/
public static CharSequence modifyTitleToSupportMultiLine(int limitedWidth, int limitedHeight,
CharSequence title, TextPaint paint, IntArray breakPoints, float spacingMultiplier,
@@ -836,25 +836,25 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
StringBuilder newString = new StringBuilder();
paint.setLetterSpacing(MIN_LETTER_SPACING);
int stringPtr = 0;
for (int i = 0; i < breakPoints.size()+1; i++) {
for (int i = 0; i < breakPoints.size() + 1; i++) {
if (i < breakPoints.size()) {
currentWord = title.subSequence(stringPtr, breakPoints.get(i)+1);
currentWord = title.subSequence(stringPtr, breakPoints.get(i) + 1);
} else {
// last word from recent breakpoint until the end of the string
currentWord = title.subSequence(stringPtr, title.length());
}
currentWordWidth = paint.measureText(currentWord,0, currentWord.length());
currentWordWidth = paint.measureText(currentWord, 0, currentWord.length());
runningWidth += currentWordWidth;
if (runningWidth <= limitedWidth) {
newString.append(currentWord);
} else {
if (i != 0) {
if (i != 0) {
// If putting word onto a new line, make sure there is no space or new line
// character in the beginning of the current word and just put in the rest of
// the characters.
CharSequence lastCharacters = title.subSequence(stringPtr, title.length());
int beginningLetterType =
Character.getType(Character.codePointAt(lastCharacters,0));
Character.getType(Character.codePointAt(lastCharacters, 0));
if (beginningLetterType == Character.SPACE_SEPARATOR
|| beginningLetterType == Character.LINE_SEPARATOR) {
lastCharacters = lastCharacters.length() > 1
@@ -875,7 +875,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
// no need to look forward into the string if we've already finished processing
break;
}
stringPtr = breakPoints.get(i)+1;
stringPtr = breakPoints.get(i) + 1;
}
return newString.toString();
}
@@ -965,12 +965,12 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
return preloadDrawable;
}
private boolean isIconDisabled(ItemInfoWithIcon info) {
if (info.isArchived()) {
return info.getProgressLevel() == 0
&& (info.runtimeStatusFlags & FLAG_INSTALL_SESSION_ACTIVE) != 0;
}
return info.getProgressLevel() == 0;
/**
* Returns true to grey the icon if the icon is either suspended or if the icon is pending
* download
*/
public boolean isIconDisabled(ItemInfoWithIcon info) {
return info.isDisabled() || info.isPendingDownload();
}
public void applyDotState(ItemInfo itemInfo, boolean animate) {
@@ -1017,12 +1017,12 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
if ((info.runtimeStatusFlags & FLAG_INSTALL_SESSION_ACTIVE) != 0) {
setContentDescription(getContext()
.getString(
R.string.app_installing_title, info.title, percentageString));
R.string.app_installing_title, info.title, percentageString));
} else if ((info.runtimeStatusFlags
& FLAG_INCREMENTAL_DOWNLOAD_ACTIVE) != 0) {
setContentDescription(getContext()
.getString(
R.string.app_downloading_title, info.title, percentageString));
R.string.app_downloading_title, info.title, percentageString));
}
}
}
@@ -1189,7 +1189,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
public SafeCloseable prepareDrawDragView() {
resetIconScale();
setForceHideDot(true);
return () -> { };
return () -> {
};
}
private void resetIconScale() {