Merge "Fix banner tip buttons visibility and update incompatible tip" into udc-dev
This commit is contained in:
@@ -166,6 +166,10 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
||||
if (iconTintColorId != View.NO_ID) {
|
||||
preference.getIcon().setTint(context.getColor(iconTintColorId));
|
||||
}
|
||||
final CardPreference cardPreference = castToCardPreferenceSafely(preference);
|
||||
if (cardPreference != null) {
|
||||
cardPreference.resetLayoutState();
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the color resid for tinting {@link #getIconId()} or {@link View#NO_ID} if none. */
|
||||
|
@@ -73,15 +73,15 @@ public final class IncompatibleChargerTip extends BatteryTip {
|
||||
}
|
||||
|
||||
cardPreference.setSelectable(false);
|
||||
cardPreference.setSecondaryButtonText(context.getString(R.string.learn_more));
|
||||
cardPreference.setSecondaryButtonClickListener(
|
||||
cardPreference.setPrimaryButtonText(context.getString(R.string.learn_more));
|
||||
cardPreference.setPrimaryButtonClickListener(
|
||||
button -> button.startActivityForResult(
|
||||
HelpUtils.getHelpIntent(
|
||||
context,
|
||||
context.getString(R.string.help_url_incompatible_charging),
|
||||
/* backupContext */ ""), /* requestCode */ 0));
|
||||
cardPreference.setSecondaryButtonVisible(true);
|
||||
cardPreference.setSecondaryButtonContentDescription(context.getString(
|
||||
cardPreference.setPrimaryButtonVisible(true);
|
||||
cardPreference.setPrimaryButtonContentDescription(context.getString(
|
||||
R.string.battery_tip_incompatible_charging_content_description));
|
||||
}
|
||||
}
|
||||
|
@@ -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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user