Merge "KeyguardIndication: Allow no message as long as there's an icon" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-02-17 15:08:24 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 5 deletions

View File

@@ -29,7 +29,7 @@ import android.view.View;
* See {@link com.android.systemui.statusbar.phone.KeyguardBottomAreaView}.
*/
public class KeyguardIndication {
@NonNull
@Nullable
private final CharSequence mMessage;
@NonNull
private final ColorStateList mTextColor;
@@ -146,8 +146,13 @@ public class KeyguardIndication {
* Build the KeyguardIndication.
*/
public KeyguardIndication build() {
if (mMessage == null) throw new IllegalStateException("message must be set");
if (mTextColor == null) throw new IllegalStateException("text color must be set");
if (mMessage == null && mIcon == null) {
throw new IllegalStateException("message or icon must be set");
}
if (mTextColor == null) {
throw new IllegalStateException("text color must be set");
}
return new KeyguardIndication(
mMessage, mTextColor, mIcon, mOnClickListener, mBackground);
}

View File

@@ -106,7 +106,8 @@ public class KeyguardIndicationRotateTextViewController extends
boolean showImmediately) {
final boolean hasPreviousIndication = mIndicationMessages.get(type) != null;
final boolean hasNewIndication = newIndication != null
&& !TextUtils.isEmpty(newIndication.getMessage());
&& (!TextUtils.isEmpty(newIndication.getMessage())
|| newIndication.getIcon() != null);
if (!hasNewIndication) {
mIndicationMessages.remove(type);
mIndicationQueue.removeIf(x -> x == type);
@@ -203,7 +204,6 @@ public class KeyguardIndicationRotateTextViewController extends
mIndicationQueue.add(type); // re-add to show later
}
// pass the style update to be run right before our new indication is shown:
mView.switchIndication(mIndicationMessages.get(type));
// only schedule next indication if there's more than just this indication in the queue