Skip to content

Commit 1f971a8

Browse files
committed
fix Reset button behavior
1 parent 344e94c commit 1f971a8

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

extensions/shared/library/src/main/java/app/revanced/extension/shared/settings/preference/ColorPickerPreference.java

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
232232
builder.setView(dialogLayout);
233233

234234
builder.setNeutralButton(str("revanced_settings_reset"), (dialog, which) -> {
235-
EditText editText = getEditText();
236-
resetToDefault(editText);
235+
setText(colorSetting.resetToDefault());
237236
});
238237

239238
builder.setPositiveButton(android.R.string.ok, (dialog, which) -> {
@@ -253,28 +252,6 @@ protected void showDialog(Bundle state) {
253252
dialog.setCanceledOnTouchOutside(false);
254253
}
255254

256-
/**
257-
* Resets the color to the default value and updates the UI.
258-
*
259-
* @param editText The EditText to update with the default color.
260-
*/
261-
private void resetToDefault(EditText editText) {
262-
try {
263-
String defaultValue = colorSetting.defaultValue;
264-
editText.setText(defaultValue);
265-
editText.setSelection(defaultValue.length());
266-
currentColor = Color.parseColor(defaultValue) & 0xFFFFFF;
267-
updateColorPreview();
268-
View dialogView = ((AlertDialog) getDialog()).findViewById(
269-
getResourceIdentifier("color_picker_view", "id"));
270-
if (dialogView instanceof CustomColorPickerView) {
271-
((CustomColorPickerView) dialogView).setColor(currentColor);
272-
}
273-
} catch (Exception ex) {
274-
Logger.printException(() -> "Reset color failure", ex);
275-
}
276-
}
277-
278255
/**
279256
* Saves the color from the EditText and dismisses the dialog.
280257
*

0 commit comments

Comments
 (0)