Fix banner tip buttons visibility and update incompatible tip

Fix the battery settings banner tip buttons visibility not reset issue
and update the incompatible charging tip into the colored primary button

Bug: 246960554
Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.fuelgauge.*
Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.widget.CardPreferenceTest
Change-Id: I9b72fccc7838d974d3b60d0f9684780841623cbb
This commit is contained in:
ykhung
2023-04-18 18:05:08 +08:00
committed by YK Hung
parent 2a0d6ead1a
commit ab07b53ea1
7 changed files with 81 additions and 36 deletions

View File

@@ -30,9 +30,7 @@ import com.google.android.material.card.MaterialCardView;
import java.util.Optional;
/**
* Preference that wrapped by {@link MaterialCardView}, only support to set icon, title and summary
*/
/** Preference that wrapped by {@link MaterialCardView} */
public class CardPreference extends Preference {
private View.OnClickListener mPrimaryBtnClickListener = null;
@@ -76,6 +74,12 @@ public class CardPreference extends Preference {
setSecondaryButtonVisible(mSecondaryButtonVisible);
}
/** Clear layout state if needed */
public void resetLayoutState() {
setPrimaryButtonVisible(false);
setSecondaryButtonVisible(false);
}
/**
* Register a callback to be invoked when the primary button is clicked.
*
@@ -140,6 +144,15 @@ public class CardPreference extends Preference {
updateButtonGroupsVisibility();
}
/**
* Sets the text of content description on primary button.
*
* @param text text for the content description
*/
public void setPrimaryButtonContentDescription(String text) {
mPrimaryButton.ifPresent(button -> button.setContentDescription(text));
}
/**
* Sets the text of content description on secondary button.
*