mirror of https://github.com/M66B/FairEmail.git
70 lines
2.5 KiB
Java
70 lines
2.5 KiB
Java
package eu.faircode.email;
|
|
|
|
/*
|
|
This file is part of FairEmail.
|
|
|
|
FairEmail is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
FairEmail is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
|
*/
|
|
|
|
import android.app.Dialog;
|
|
import android.content.DialogInterface;
|
|
import android.graphics.Color;
|
|
import android.os.Bundle;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
|
|
import com.flask.colorpicker.ColorPickerView;
|
|
import com.flask.colorpicker.builder.ColorPickerClickListener;
|
|
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
|
|
|
|
import static android.app.Activity.RESULT_OK;
|
|
|
|
public class FragmentDialogColor extends FragmentDialogBase {
|
|
@NonNull
|
|
@Override
|
|
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
|
int color = getArguments().getInt("color");
|
|
String title = getArguments().getString("title");
|
|
|
|
if (color == Color.TRANSPARENT)
|
|
color = Color.BLUE;
|
|
|
|
return ColorPickerDialogBuilder
|
|
.with(getContext())
|
|
.setTitle(title)
|
|
.initialColor(color)
|
|
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
|
|
.density(12)
|
|
.lightnessSliderOnly()
|
|
.setPositiveButton(android.R.string.ok, new ColorPickerClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
|
|
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();
|
|
}
|
|
}
|