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(); Bundle args = new Bundle();
args.putInt("color", btnColor.getColor()); args.putInt("color", btnColor.getColor());
args.putString("title", getString(R.string.title_color)); args.putString("title", getString(R.string.title_color));
args.putBoolean("reset", true);
FragmentDialogColor fragment = new FragmentDialogColor(); FragmentDialogColor fragment = new FragmentDialogColor();
fragment.setArguments(args); fragment.setArguments(args);

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

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

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

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

Loading…
Cancel
Save