Fix title clipped for "Custom settings for schedule"

Set rule to header, switch and action buttons controllers before their
isAvailable() is called in onCreate().

Fix: 228262001
Test: manual
Change-Id: Idc0ea779ab768497a8426ac847c4bbb2c6c4faea
This commit is contained in:
Chaohui Wang
2022-04-06 12:06:08 +08:00
parent ab8467e872
commit 5d0057615a
5 changed files with 40 additions and 63 deletions

View File

@@ -39,11 +39,9 @@ public class ZenRuleButtonsPreferenceController extends AbstractZenModePreferenc
implements PreferenceControllerMixin {
public static final String KEY = "zen_action_buttons";
private AutomaticZenRule mRule;
private final PreferenceFragmentCompat mFragment;
private String mId;
private PreferenceFragmentCompat mFragment;
private ActionButtonsPreference mButtonsPref;
private AutomaticZenRule mRule;
public ZenRuleButtonsPreferenceController(Context context, PreferenceFragmentCompat fragment,
Lifecycle lc) {
@@ -51,6 +49,10 @@ public class ZenRuleButtonsPreferenceController extends AbstractZenModePreferenc
mFragment = fragment;
}
void setIdAndRule(String id, AutomaticZenRule rule) {
mId = id;
mRule = rule;
}
@Override
public boolean isAvailable() {
@@ -60,7 +62,7 @@ public class ZenRuleButtonsPreferenceController extends AbstractZenModePreferenc
@Override
public void displayPreference(PreferenceScreen screen) {
if (isAvailable()) {
mButtonsPref = ((ActionButtonsPreference) screen.findPreference(KEY))
((ActionButtonsPreference) screen.findPreference(KEY))
.setButton1Text(R.string.zen_mode_rule_name_edit)
.setButton1Icon(com.android.internal.R.drawable.ic_mode_edit)
.setButton1OnClickListener(new EditRuleNameClickListener())
@@ -116,9 +118,4 @@ public class ZenRuleButtonsPreferenceController extends AbstractZenModePreferenc
});
}
}
protected void onResume(AutomaticZenRule rule, String id) {
mRule = rule;
mId = id;
}
}