Fixed color picker edit text color

pull/187/head
M66B 4 years ago
parent f4158c4e66
commit 757b0482eb

@ -108,10 +108,13 @@ public class ActivityWidget extends ActivityBase {
btnColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int editTextColor = Helper.resolveColor(ActivityWidget.this, android.R.attr.editTextColor);
ColorPickerDialogBuilder
.with(ActivityWidget.this)
.setTitle(R.string.title_widget_background)
.showColorEdit(true)
.setColorEditTextColor(editTextColor)
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
.density(6)
.lightnessSliderOnly()

@ -114,10 +114,13 @@ public class ActivityWidgetUnified extends ActivityBase {
btnColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int editTextColor = Helper.resolveColor(ActivityWidgetUnified.this, android.R.attr.editTextColor);
ColorPickerDialogBuilder
.with(ActivityWidgetUnified.this)
.setTitle(R.string.title_widget_background)
.showColorEdit(true)
.setColorEditTextColor(editTextColor)
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
.density(6)
.lightnessSliderOnly()

@ -132,10 +132,13 @@ public class AdapterKeyword extends RecyclerView.Adapter<AdapterKeyword.ViewHold
final TupleKeyword keyword = all.get(pos);
int editTextColor = Helper.resolveColor(context, android.R.attr.editTextColor);
ColorPickerDialogBuilder builder = ColorPickerDialogBuilder
.with(context)
.setTitle(context.getString(R.string.title_color))
.showColorEdit(true)
.setColorEditTextColor(editTextColor)
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
.density(6)
.lightnessSliderOnly()

@ -20,10 +20,10 @@ package eu.faircode.email;
*/
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -33,8 +33,6 @@ import com.flask.colorpicker.OnColorChangedListener;
import com.flask.colorpicker.builder.ColorPickerClickListener;
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
import java.lang.reflect.Field;
import static android.app.Activity.RESULT_OK;
public class FragmentDialogColor extends FragmentDialogBase {
@ -56,10 +54,14 @@ public class FragmentDialogColor extends FragmentDialogBase {
String title = args.getString("title");
boolean reset = args.getBoolean("reset", false);
Context context = getContext();
int editTextColor = Helper.resolveColor(context, android.R.attr.editTextColor);
ColorPickerDialogBuilder builder = ColorPickerDialogBuilder
.with(getContext())
.with(context)
.setTitle(title)
.showColorEdit(true)
.setColorEditTextColor(editTextColor)
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
.density(6)
.lightnessSliderOnly()
@ -89,17 +91,6 @@ public class FragmentDialogColor extends FragmentDialogBase {
}
});
Dialog dialog = builder.build();
try {
Field fColorEdit = builder.getClass().getDeclaredField("colorEdit");
fColorEdit.setAccessible(true);
EditText colorEdit = (EditText) fColorEdit.get(builder);
colorEdit.setTextColor(Helper.resolveColor(getContext(), android.R.attr.textColorPrimary));
} catch (Throwable ex) {
Log.w(ex);
}
return dialog;
return builder.build();
}
}

@ -1,7 +1,6 @@
package eu.faircode.email;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
@ -33,7 +32,6 @@ import com.flask.colorpicker.ColorPickerView;
import com.flask.colorpicker.builder.ColorPickerClickListener;
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
@ -163,10 +161,14 @@ public class StyleHelper {
if (imm != null)
imm.hideSoftInputFromWindow(etBody.getWindowToken(), 0);
Context context = etBody.getContext();
int editTextColor = Helper.resolveColor(context, android.R.attr.editTextColor);
ColorPickerDialogBuilder builder = ColorPickerDialogBuilder
.with(etBody.getContext())
.with(context)
.setTitle(R.string.title_color)
.showColorEdit(true)
.setColorEditTextColor(editTextColor)
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
.density(6)
.lightnessSliderOnly()
@ -183,18 +185,7 @@ public class StyleHelper {
}
});
Dialog dialog = builder.build();
try {
Field fColorEdit = builder.getClass().getDeclaredField("colorEdit");
fColorEdit.setAccessible(true);
EditText colorEdit = (EditText) fColorEdit.get(builder);
colorEdit.setTextColor(Helper.resolveColor(etBody.getContext(), android.R.attr.textColorPrimary));
} catch (Throwable ex) {
Log.w(ex);
}
dialog.show();
builder.build().show();
return true;
}

Loading…
Cancel
Save