Added default send text color option

This commit is contained in:
M66B 2022-12-12 09:37:24 +01:00
parent fa40e17af2
commit be1ee1d5c5
8 changed files with 74 additions and 2 deletions

View File

@ -20,6 +20,7 @@ For support you can use [the contact form](https://contact.faircode.eu/?product=
### Next version
* Added send option for default text color
* Added display option to swap trash/archive in bottom action bar
* Small improvements and minor bug fixes
* Updated translations

View File

@ -20,6 +20,7 @@ For support you can use [the contact form](https://contact.faircode.eu/?product=
### Next version
* Added send option for default text color
* Added display option to swap trash/archive in bottom action bar
* Small improvements and minor bug fixes
* Updated translations

View File

@ -283,6 +283,7 @@ public class FragmentCompose extends FragmentBase {
private ContentResolver resolver;
private AdapterAttachment adapter;
private int compose_color;
private String compose_font;
private String display_font;
private boolean dsn = true;
@ -348,6 +349,7 @@ public class FragmentCompose extends FragmentBase {
final Context context = getContext();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
compose_color = prefs.getInt("compose_color", Color.TRANSPARENT);
compose_font = prefs.getString("compose_font", "");
display_font = prefs.getString("display_font", "");
style = prefs.getBoolean("compose_style", false);
@ -717,6 +719,8 @@ public class FragmentCompose extends FragmentBase {
}
});
if (compose_color != Color.TRANSPARENT)
tvSignature.setTextColor(compose_color);
tvSignature.setTypeface(StyleHelper.getTypeface(compose_font, getContext()));
cbSignature.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@ -802,6 +806,8 @@ public class FragmentCompose extends FragmentBase {
}
});
if (compose_color != Color.TRANSPARENT)
etBody.setTextColor(compose_color);
etBody.setTypeface(StyleHelper.getTypeface(compose_font, getContext()));
tvReference.setTypeface(StyleHelper.getTypeface(display_font, getContext()));

View File

@ -21,8 +21,11 @@ package eu.faircode.email;
import static android.app.Activity.RESULT_OK;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
@ -49,6 +52,10 @@ import androidx.appcompat.widget.SwitchCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager;
import com.flask.colorpicker.ColorPickerView;
import com.flask.colorpicker.builder.ColorPickerClickListener;
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -74,6 +81,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private Spinner spAnswerAction;
private Button btnSound;
private ViewButtonColor btnComposeColor;
private Spinner spComposeFont;
private SwitchCompat swPrefixOnce;
private SwitchCompat swPrefixCount;
@ -114,7 +122,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
"send_delayed",
"answer_action",
"sound_sent",
"compose_font",
"compose_color", "compose_font",
"prefix_once", "prefix_count", "alt_re", "alt_fwd",
"separate_reply", "extended_reply", "write_below", "quote_reply", "quote_limit", "resize_reply",
"signature_location", "signature_new", "signature_reply", "signature_reply_once", "signature_forward",
@ -153,6 +161,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
spAnswerAction = view.findViewById(R.id.spAnswerAction);
btnSound = view.findViewById(R.id.btnSound);
btnComposeColor = view.findViewById(R.id.btnComposeColor);
spComposeFont = view.findViewById(R.id.spComposeFont);
swPrefixOnce = view.findViewById(R.id.swPrefixOnce);
swPrefixCount = view.findViewById(R.id.swPrefixCount);
@ -356,6 +365,41 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
});
btnComposeColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Context context = getContext();
int editTextColor = Helper.resolveColor(context, android.R.attr.editTextColor);
int compose_color = prefs.getInt("compose_color", Color.TRANSPARENT);
ColorPickerDialogBuilder builder = ColorPickerDialogBuilder
.with(context)
.setTitle(R.string.title_advanced_compose_color)
.initialColor(compose_color == Color.TRANSPARENT ? Color.GRAY : compose_color)
.showColorEdit(true)
.setColorEditTextColor(editTextColor)
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
.density(6)
.lightnessSliderOnly()
.setPositiveButton(android.R.string.ok, new ColorPickerClickListener() {
@Override
public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
prefs.edit().putInt("compose_color", selectedColor).apply();
btnComposeColor.setColor(selectedColor);
}
})
.setNegativeButton(R.string.title_reset, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
prefs.edit().remove("compose_color").apply();
btnComposeColor.setColor(Color.TRANSPARENT);
}
});
builder.build().show();
}
});
spComposeFont.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
@ -678,6 +722,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
break;
}
btnComposeColor.setColor(prefs.getInt("compose_color", Color.TRANSPARENT));
String compose_font = prefs.getString("compose_font", "");
List<StyleHelper.FontDescriptor> fonts = StyleHelper.getFonts(getContext());
for (int pos = 0; pos < fonts.size(); pos++) {

View File

@ -24,6 +24,7 @@ import static android.system.OsConstants.ENOSPC;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.system.ErrnoException;
@ -929,6 +930,7 @@ public class MessageHelper {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean format_flowed = prefs.getBoolean("format_flowed", false);
int compose_color = prefs.getInt("compose_color", Color.TRANSPARENT);
String compose_font = prefs.getString("compose_font", "");
boolean auto_link = prefs.getBoolean("auto_link", false);
@ -960,6 +962,9 @@ public class MessageHelper {
HtmlHelper.autoLink(document, true);
}
if (compose_color != Color.TRANSPARENT)
document.head().append("<style>* {color: " + HtmlHelper.encodeWebColor(compose_color) + ";}</style>");
if (!TextUtils.isEmpty(compose_font)) {
List<Node> childs = new ArrayList<>();
for (Node child : document.body().childNodes())

View File

@ -387,6 +387,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<eu.faircode.email.ViewButtonColor
android:id="@+id/btnComposeColor"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:paddingHorizontal="6dp"
android:text="@string/title_advanced_compose_color"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCaptionMessage" />
<TextView
android:id="@+id/tvComposeFont"
android:layout_width="0dp"
@ -398,7 +409,7 @@
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCaptionMessage" />
app:layout_constraintTop_toBottomOf="@id/btnComposeColor" />
<Spinner
android:id="@+id/spComposeFont"

View File

@ -437,6 +437,7 @@
<string name="title_advanced_auto_save_paragraph">Automatically save a draft after every paragraph</string>
<string name="title_advanced_auto_save_dot">Automatically save a draft after every sentence</string>
<string name="title_advanced_compose_color">Default text color</string>
<string name="title_advanced_compose_font">Default font</string>
<string name="title_advanced_auto_identity">Automatically select identities for new messages</string>
<string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string>

View File

@ -20,6 +20,7 @@ For support you can use the contact form.
Next version
* Added send option for default text color
* Added display option to swap trash/archive in bottom action bar
* Small improvements and minor bug fixes
* Updated translations