mirror of https://github.com/M66B/FairEmail.git
Dismiss color picker on pause
Signed-off-by: M66B <M66B@users.noreply.github.com>
This commit is contained in:
parent
ea1f85e712
commit
29ec1ef5bc
|
@ -1092,7 +1092,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
private void onColor(final Intent intent) {
|
||||
int color = intent.getIntExtra("color", -1);
|
||||
int[] colors = getResources().getIntArray(R.array.colorPicker);
|
||||
ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
|
||||
ColorPickerDialog colorPickerDialog = new ColorPickerDialogEx(this);
|
||||
colorPickerDialog.initialize(R.string.title_flag_color, colors, color, 4, colors.length);
|
||||
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package eu.faircode.email;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
|
||||
import com.android.colorpicker.ColorPickerDialog;
|
||||
|
||||
public class ColorPickerDialogEx extends ColorPickerDialog implements LifecycleObserver {
|
||||
private LifecycleOwner owner;
|
||||
|
||||
private ColorPickerDialogEx() {
|
||||
}
|
||||
|
||||
ColorPickerDialogEx(LifecycleOwner owner) {
|
||||
super();
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(@NonNull FragmentManager manager, @Nullable String tag) {
|
||||
owner.getLifecycle().addObserver(this);
|
||||
super.show(manager, tag);
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
||||
public void onOwnerPause() {
|
||||
dismiss();
|
||||
this.owner = null;
|
||||
}
|
||||
}
|
|
@ -291,7 +291,7 @@ public class FragmentAccount extends FragmentBase {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
int[] colors = getContext().getResources().getIntArray(R.array.colorPicker);
|
||||
ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
|
||||
ColorPickerDialog colorPickerDialog = new ColorPickerDialogEx(getViewLifecycleOwner());
|
||||
colorPickerDialog.initialize(R.string.title_account_color, colors, color, 4, colors.length);
|
||||
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
|
||||
@Override
|
||||
|
|
|
@ -3220,7 +3220,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
int color = (spans.length > 0 ? spans[0].getForegroundColor() : Color.TRANSPARENT);
|
||||
|
||||
int[] colors = getContext().getResources().getIntArray(R.array.colorPicker);
|
||||
ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
|
||||
ColorPickerDialog colorPickerDialog = new ColorPickerDialogEx(getViewLifecycleOwner());
|
||||
colorPickerDialog.initialize(R.string.title_style_color, colors, color, 4, colors.length);
|
||||
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
|
||||
@Override
|
||||
|
|
|
@ -262,7 +262,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
int[] colors = getContext().getResources().getIntArray(R.array.colorPicker);
|
||||
ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
|
||||
ColorPickerDialog colorPickerDialog = new ColorPickerDialogEx(getViewLifecycleOwner());
|
||||
colorPickerDialog.initialize(R.string.title_account_color, colors, color, 4, colors.length);
|
||||
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
|
||||
@Override
|
||||
|
|
|
@ -1806,7 +1806,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
|
||||
private void onActionFlagColorSelection(int color, final Long id) {
|
||||
int[] colors = getResources().getIntArray(R.array.colorPicker);
|
||||
ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
|
||||
ColorPickerDialog colorPickerDialog = new ColorPickerDialogEx(getViewLifecycleOwner());
|
||||
colorPickerDialog.initialize(R.string.title_flag_color, colors, color, 4, colors.length);
|
||||
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
|
||||
@Override
|
||||
|
|
|
@ -296,7 +296,7 @@ public class FragmentRule extends FragmentBase {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
int[] colors = getContext().getResources().getIntArray(R.array.colorPicker);
|
||||
ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
|
||||
ColorPickerDialog colorPickerDialog = new ColorPickerDialogEx(getViewLifecycleOwner());
|
||||
colorPickerDialog.initialize(R.string.title_flag_color, colors, color, 4, colors.length);
|
||||
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue