Loading core/java/android/hardware/biometrics/PromptContentViewWithMoreOptionsButton.java +3 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.DialogInterface; import android.hardware.biometrics.BiometricPrompt.ButtonInfo; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -62,6 +63,7 @@ import java.util.concurrent.Executor; */ @FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT) public final class PromptContentViewWithMoreOptionsButton implements PromptContentViewParcelable { private static final String TAG = "PromptContentViewWithMoreOptionsButton"; @VisibleForTesting static final int MAX_DESCRIPTION_CHARACTER_NUMBER = 225; Loading Loading @@ -149,13 +151,12 @@ public final class PromptContentViewWithMoreOptionsButton implements PromptConte * * @param description The description to display. * @return This builder. * @throws IllegalArgumentException If description exceeds certain character limit. */ @NonNull @RequiresPermission(SET_BIOMETRIC_DIALOG_ADVANCED) public Builder setDescription(@NonNull String description) { if (description.length() > MAX_DESCRIPTION_CHARACTER_NUMBER) { throw new IllegalArgumentException("The character number of description exceeds " Log.w(TAG, "The character number of description exceeds " + MAX_DESCRIPTION_CHARACTER_NUMBER); } mDescription = description; Loading core/java/android/hardware/biometrics/PromptVerticalListContentView.java +7 −9 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; Loading @@ -49,6 +50,7 @@ import java.util.List; */ @FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT) public final class PromptVerticalListContentView implements PromptContentViewParcelable { private static final String TAG = "PromptVerticalListContentView"; @VisibleForTesting static final int MAX_ITEM_NUMBER = 20; @VisibleForTesting Loading Loading @@ -155,12 +157,11 @@ public final class PromptVerticalListContentView implements PromptContentViewPar * * @param description The description to display. * @return This builder. * @throws IllegalArgumentException If description exceeds certain character limit. */ @NonNull public Builder setDescription(@NonNull String description) { if (description.length() > MAX_DESCRIPTION_CHARACTER_NUMBER) { throw new IllegalArgumentException("The character number of description exceeds " Log.w(TAG, "The character number of description exceeds " + MAX_DESCRIPTION_CHARACTER_NUMBER); } mDescription = description; Loading @@ -172,8 +173,7 @@ public final class PromptVerticalListContentView implements PromptContentViewPar * * @param listItem The list item view to display * @return This builder. * @throws IllegalArgumentException If this list item exceeds certain character limits or * the number of list items exceeds certain limit. * @throws IllegalArgumentException If the number of list items exceeds certain limit. */ @NonNull public Builder addListItem(@NonNull PromptContentItem listItem) { Loading @@ -188,8 +188,7 @@ public final class PromptVerticalListContentView implements PromptContentViewPar * @param listItem The list item view to display * @param index The position at which to add the item * @return This builder. * @throws IllegalArgumentException If this list item exceeds certain character limits or * the number of list items exceeds certain limit. * @throws IllegalArgumentException If the number of list items exceeds certain limit. */ @NonNull public Builder addListItem(@NonNull PromptContentItem listItem, int index) { Loading @@ -200,8 +199,7 @@ public final class PromptVerticalListContentView implements PromptContentViewPar private void checkItemLimits(@NonNull PromptContentItem listItem) { if (doesListItemExceedsCharLimit(listItem)) { throw new IllegalArgumentException( "The character number of list item exceeds " Log.w(TAG, "The character number of list item exceeds " + MAX_EACH_ITEM_CHARACTER_NUMBER); } if (mContentList.size() > MAX_ITEM_NUMBER) { Loading core/tests/coretests/src/android/hardware/biometrics/BiometricPromptTest.java +0 −36 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ package android.hardware.biometrics; import static android.hardware.biometrics.PromptContentViewWithMoreOptionsButton.MAX_DESCRIPTION_CHARACTER_NUMBER; import static android.hardware.biometrics.PromptVerticalListContentView.MAX_EACH_ITEM_CHARACTER_NUMBER; import static android.hardware.biometrics.PromptVerticalListContentView.MAX_ITEM_NUMBER; import static com.google.common.truth.Truth.assertThat; Loading Loading @@ -118,17 +116,6 @@ public class BiometricPromptTest { assertThat(e).hasMessageThat().isEqualTo("Logo description passed in can not be null"); } @Test public void testMoreOptionsButton_descriptionCharLimit() { IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> new PromptContentViewWithMoreOptionsButton.Builder().setDescription( generateRandomString(MAX_DESCRIPTION_CHARACTER_NUMBER + 1)) ); assertThat(e).hasMessageThat().contains( "The character number of description exceeds "); } @Test public void testMoreOptionsButton_ExecutorNull() { PromptContentViewWithMoreOptionsButton.Builder builder = Loading Loading @@ -156,29 +143,6 @@ public class BiometricPromptTest { "The listener of more options button on prompt content must be set"); } @Test public void testVerticalList_descriptionCharLimit() { IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> new PromptVerticalListContentView.Builder().setDescription( generateRandomString(MAX_DESCRIPTION_CHARACTER_NUMBER + 1)) ); assertThat(e).hasMessageThat().contains( "The character number of description exceeds "); } @Test public void testVerticalList_itemCharLimit() { IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> new PromptVerticalListContentView.Builder().addListItem( new PromptContentItemBulletedText( generateRandomString(MAX_EACH_ITEM_CHARACTER_NUMBER + 1))) ); assertThat(e).hasMessageThat().contains( "The character number of list item exceeds "); } @Test public void testVerticalList_itemNumLimit() { PromptVerticalListContentView.Builder builder = new PromptVerticalListContentView.Builder(); Loading packages/SystemUI/shared/biometrics/src/com/android/systemui/biometrics/Utils.kt +4 −0 Original line number Diff line number Diff line Loading @@ -148,4 +148,8 @@ object Utils { draw(canvas) return bitmap } @JvmStatic fun String.ellipsize(cutOffLength: Int) = if (length <= cutOffLength) this else replaceRange(cutOffLength, length, "...") } packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricCustomizedViewBinder.kt +8 −3 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.widget.Space import android.widget.TextView import com.android.settingslib.Utils import com.android.systemui.biometrics.ui.BiometricPromptLayout import com.android.systemui.biometrics.Utils.ellipsize import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.res.R import kotlin.math.ceil Loading @@ -47,6 +48,8 @@ private const val TAG = "BiometricCustomizedViewBinder" /** Sub-binder for [BiometricPromptLayout.customized_view_container]. */ object BiometricCustomizedViewBinder { const val MAX_DESCRIPTION_CHARACTER_NUMBER = 225 fun bind( customizedViewContainer: LinearLayout, contentView: PromptContentView?, Loading Loading @@ -91,7 +94,8 @@ private fun LayoutInflater.inflateContentView(id: Int, description: String?): Li val descriptionView = contentView.requireViewById<TextView>(R.id.customized_view_description) if (!description.isNullOrEmpty()) { descriptionView.text = description descriptionView.text = description.ellipsize(BiometricCustomizedViewBinder.MAX_DESCRIPTION_CHARACTER_NUMBER) } else { descriptionView.visibility = View.GONE } Loading Loading @@ -219,13 +223,14 @@ private fun PromptContentItem.toView( inflater.inflate(R.layout.biometric_prompt_content_row_item_text_view, null) as TextView val lp = LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f) textView.layoutParams = lp val maxCharNumber = PromptVerticalListContentView.getMaxEachItemCharacterNumber() when (this) { is PromptContentItemPlainText -> { textView.text = text textView.text = text.ellipsize(maxCharNumber) } is PromptContentItemBulletedText -> { val bulletedText = SpannableString(text) val bulletedText = SpannableString(text.ellipsize(maxCharNumber)) val span = BulletSpan( getListItemBulletGapWidth(resources), Loading Loading
core/java/android/hardware/biometrics/PromptContentViewWithMoreOptionsButton.java +3 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.DialogInterface; import android.hardware.biometrics.BiometricPrompt.ButtonInfo; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -62,6 +63,7 @@ import java.util.concurrent.Executor; */ @FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT) public final class PromptContentViewWithMoreOptionsButton implements PromptContentViewParcelable { private static final String TAG = "PromptContentViewWithMoreOptionsButton"; @VisibleForTesting static final int MAX_DESCRIPTION_CHARACTER_NUMBER = 225; Loading Loading @@ -149,13 +151,12 @@ public final class PromptContentViewWithMoreOptionsButton implements PromptConte * * @param description The description to display. * @return This builder. * @throws IllegalArgumentException If description exceeds certain character limit. */ @NonNull @RequiresPermission(SET_BIOMETRIC_DIALOG_ADVANCED) public Builder setDescription(@NonNull String description) { if (description.length() > MAX_DESCRIPTION_CHARACTER_NUMBER) { throw new IllegalArgumentException("The character number of description exceeds " Log.w(TAG, "The character number of description exceeds " + MAX_DESCRIPTION_CHARACTER_NUMBER); } mDescription = description; Loading
core/java/android/hardware/biometrics/PromptVerticalListContentView.java +7 −9 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; Loading @@ -49,6 +50,7 @@ import java.util.List; */ @FlaggedApi(FLAG_CUSTOM_BIOMETRIC_PROMPT) public final class PromptVerticalListContentView implements PromptContentViewParcelable { private static final String TAG = "PromptVerticalListContentView"; @VisibleForTesting static final int MAX_ITEM_NUMBER = 20; @VisibleForTesting Loading Loading @@ -155,12 +157,11 @@ public final class PromptVerticalListContentView implements PromptContentViewPar * * @param description The description to display. * @return This builder. * @throws IllegalArgumentException If description exceeds certain character limit. */ @NonNull public Builder setDescription(@NonNull String description) { if (description.length() > MAX_DESCRIPTION_CHARACTER_NUMBER) { throw new IllegalArgumentException("The character number of description exceeds " Log.w(TAG, "The character number of description exceeds " + MAX_DESCRIPTION_CHARACTER_NUMBER); } mDescription = description; Loading @@ -172,8 +173,7 @@ public final class PromptVerticalListContentView implements PromptContentViewPar * * @param listItem The list item view to display * @return This builder. * @throws IllegalArgumentException If this list item exceeds certain character limits or * the number of list items exceeds certain limit. * @throws IllegalArgumentException If the number of list items exceeds certain limit. */ @NonNull public Builder addListItem(@NonNull PromptContentItem listItem) { Loading @@ -188,8 +188,7 @@ public final class PromptVerticalListContentView implements PromptContentViewPar * @param listItem The list item view to display * @param index The position at which to add the item * @return This builder. * @throws IllegalArgumentException If this list item exceeds certain character limits or * the number of list items exceeds certain limit. * @throws IllegalArgumentException If the number of list items exceeds certain limit. */ @NonNull public Builder addListItem(@NonNull PromptContentItem listItem, int index) { Loading @@ -200,8 +199,7 @@ public final class PromptVerticalListContentView implements PromptContentViewPar private void checkItemLimits(@NonNull PromptContentItem listItem) { if (doesListItemExceedsCharLimit(listItem)) { throw new IllegalArgumentException( "The character number of list item exceeds " Log.w(TAG, "The character number of list item exceeds " + MAX_EACH_ITEM_CHARACTER_NUMBER); } if (mContentList.size() > MAX_ITEM_NUMBER) { Loading
core/tests/coretests/src/android/hardware/biometrics/BiometricPromptTest.java +0 −36 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ package android.hardware.biometrics; import static android.hardware.biometrics.PromptContentViewWithMoreOptionsButton.MAX_DESCRIPTION_CHARACTER_NUMBER; import static android.hardware.biometrics.PromptVerticalListContentView.MAX_EACH_ITEM_CHARACTER_NUMBER; import static android.hardware.biometrics.PromptVerticalListContentView.MAX_ITEM_NUMBER; import static com.google.common.truth.Truth.assertThat; Loading Loading @@ -118,17 +116,6 @@ public class BiometricPromptTest { assertThat(e).hasMessageThat().isEqualTo("Logo description passed in can not be null"); } @Test public void testMoreOptionsButton_descriptionCharLimit() { IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> new PromptContentViewWithMoreOptionsButton.Builder().setDescription( generateRandomString(MAX_DESCRIPTION_CHARACTER_NUMBER + 1)) ); assertThat(e).hasMessageThat().contains( "The character number of description exceeds "); } @Test public void testMoreOptionsButton_ExecutorNull() { PromptContentViewWithMoreOptionsButton.Builder builder = Loading Loading @@ -156,29 +143,6 @@ public class BiometricPromptTest { "The listener of more options button on prompt content must be set"); } @Test public void testVerticalList_descriptionCharLimit() { IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> new PromptVerticalListContentView.Builder().setDescription( generateRandomString(MAX_DESCRIPTION_CHARACTER_NUMBER + 1)) ); assertThat(e).hasMessageThat().contains( "The character number of description exceeds "); } @Test public void testVerticalList_itemCharLimit() { IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> new PromptVerticalListContentView.Builder().addListItem( new PromptContentItemBulletedText( generateRandomString(MAX_EACH_ITEM_CHARACTER_NUMBER + 1))) ); assertThat(e).hasMessageThat().contains( "The character number of list item exceeds "); } @Test public void testVerticalList_itemNumLimit() { PromptVerticalListContentView.Builder builder = new PromptVerticalListContentView.Builder(); Loading
packages/SystemUI/shared/biometrics/src/com/android/systemui/biometrics/Utils.kt +4 −0 Original line number Diff line number Diff line Loading @@ -148,4 +148,8 @@ object Utils { draw(canvas) return bitmap } @JvmStatic fun String.ellipsize(cutOffLength: Int) = if (length <= cutOffLength) this else replaceRange(cutOffLength, length, "...") }
packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricCustomizedViewBinder.kt +8 −3 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.widget.Space import android.widget.TextView import com.android.settingslib.Utils import com.android.systemui.biometrics.ui.BiometricPromptLayout import com.android.systemui.biometrics.Utils.ellipsize import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.res.R import kotlin.math.ceil Loading @@ -47,6 +48,8 @@ private const val TAG = "BiometricCustomizedViewBinder" /** Sub-binder for [BiometricPromptLayout.customized_view_container]. */ object BiometricCustomizedViewBinder { const val MAX_DESCRIPTION_CHARACTER_NUMBER = 225 fun bind( customizedViewContainer: LinearLayout, contentView: PromptContentView?, Loading Loading @@ -91,7 +94,8 @@ private fun LayoutInflater.inflateContentView(id: Int, description: String?): Li val descriptionView = contentView.requireViewById<TextView>(R.id.customized_view_description) if (!description.isNullOrEmpty()) { descriptionView.text = description descriptionView.text = description.ellipsize(BiometricCustomizedViewBinder.MAX_DESCRIPTION_CHARACTER_NUMBER) } else { descriptionView.visibility = View.GONE } Loading Loading @@ -219,13 +223,14 @@ private fun PromptContentItem.toView( inflater.inflate(R.layout.biometric_prompt_content_row_item_text_view, null) as TextView val lp = LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f) textView.layoutParams = lp val maxCharNumber = PromptVerticalListContentView.getMaxEachItemCharacterNumber() when (this) { is PromptContentItemPlainText -> { textView.text = text textView.text = text.ellipsize(maxCharNumber) } is PromptContentItemBulletedText -> { val bulletedText = SpannableString(text) val bulletedText = SpannableString(text.ellipsize(maxCharNumber)) val span = BulletSpan( getListItemBulletGapWidth(resources), Loading