Optional color reset

pull/162/head
M66B 5 years ago
parent b30a8988f6
commit 2974d17f60

@ -306,6 +306,7 @@ public class FragmentAccount extends FragmentBase {
Bundle args = new Bundle();
args.putInt("color", btnColor.getColor());
args.putString("title", getString(R.string.title_color));
args.putBoolean("reset", true);
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.setArguments(args);

@ -37,13 +37,15 @@ public class FragmentDialogColor extends FragmentDialogBase {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
int color = getArguments().getInt("color");
String title = getArguments().getString("title");
Bundle args = getArguments();
int color = args.getInt("color");
String title = args.getString("title");
boolean reset = args.getBoolean("reset", false);
if (color == Color.TRANSPARENT)
color = Color.BLUE;
return ColorPickerDialogBuilder
ColorPickerDialogBuilder builder = ColorPickerDialogBuilder
.with(getContext())
.setTitle(title)
.initialColor(color)
@ -56,14 +58,17 @@ public class FragmentDialogColor extends FragmentDialogBase {
getArguments().putInt("color", selectedColor);
sendResult(RESULT_OK);
}
})
.setNegativeButton(R.string.title_reset, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
getArguments().putInt("color", Color.TRANSPARENT);
sendResult(RESULT_OK);
}
})
.build();
});
if (reset)
builder.setNegativeButton(R.string.title_reset, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
getArguments().putInt("color", Color.TRANSPARENT);
sendResult(RESULT_OK);
}
});
return builder.build();
}
}

@ -289,6 +289,7 @@ public class FragmentIdentity extends FragmentBase {
Bundle args = new Bundle();
args.putInt("color", btnColor.getColor());
args.putString("title", getString(R.string.title_color));
args.putBoolean("reset", true);
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.setArguments(args);

@ -135,6 +135,7 @@ public class FragmentPop extends FragmentBase {
Bundle args = new Bundle();
args.putInt("color", btnColor.getColor());
args.putString("title", getString(R.string.title_color));
args.putBoolean("reset", true);
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.setArguments(args);

@ -369,6 +369,7 @@ public class FragmentRule extends FragmentBase {
Bundle args = new Bundle();
args.putInt("color", btnColor.getColor());
args.putString("title", getString(R.string.title_flag_color));
args.putBoolean("reset", true);
FragmentDialogColor fragment = new FragmentDialogColor();
fragment.setArguments(args);

Loading…
Cancel
Save