Added icon button to create rule

pull/182/head
M66B 5 years ago
parent 1e5105a41a
commit 52f1efc2e0

@ -407,6 +407,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ImageButton ibDecrypt; private ImageButton ibDecrypt;
private ImageButton ibVerify; private ImageButton ibVerify;
private ImageButton ibUndo; private ImageButton ibUndo;
private ImageButton ibRule;
private ImageButton ibUnsubscribe; private ImageButton ibUnsubscribe;
private ImageButton ibAnswer; private ImageButton ibAnswer;
private ImageButton ibMove; private ImageButton ibMove;
@ -606,6 +607,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibDecrypt = vsBody.findViewById(R.id.ibDecrypt); ibDecrypt = vsBody.findViewById(R.id.ibDecrypt);
ibVerify = vsBody.findViewById(R.id.ibVerify); ibVerify = vsBody.findViewById(R.id.ibVerify);
ibUndo = vsBody.findViewById(R.id.ibUndo); ibUndo = vsBody.findViewById(R.id.ibUndo);
ibRule = vsBody.findViewById(R.id.ibRule);
ibUnsubscribe = vsBody.findViewById(R.id.ibUnsubscribe); ibUnsubscribe = vsBody.findViewById(R.id.ibUnsubscribe);
ibAnswer = vsBody.findViewById(R.id.ibAnswer); ibAnswer = vsBody.findViewById(R.id.ibAnswer);
ibMove = vsBody.findViewById(R.id.ibMove); ibMove = vsBody.findViewById(R.id.ibMove);
@ -691,6 +693,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibFull.setOnClickListener(this); ibFull.setOnClickListener(this);
ibImages.setOnClickListener(this); ibImages.setOnClickListener(this);
ibRule.setOnClickListener(this);
ibUnsubscribe.setOnClickListener(this); ibUnsubscribe.setOnClickListener(this);
ibDecrypt.setOnClickListener(this); ibDecrypt.setOnClickListener(this);
ibVerify.setOnClickListener(this); ibVerify.setOnClickListener(this);
@ -776,6 +779,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibFull.setOnClickListener(null); ibFull.setOnClickListener(null);
ibImages.setOnClickListener(null); ibImages.setOnClickListener(null);
ibRule.setOnClickListener(null);
ibUnsubscribe.setOnClickListener(null); ibUnsubscribe.setOnClickListener(null);
ibDecrypt.setOnClickListener(null); ibDecrypt.setOnClickListener(null);
ibVerify.setOnClickListener(null); ibVerify.setOnClickListener(null);
@ -1271,6 +1275,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibDecrypt.setVisibility(View.GONE); ibDecrypt.setVisibility(View.GONE);
ibVerify.setVisibility(View.GONE); ibVerify.setVisibility(View.GONE);
ibUndo.setVisibility(View.GONE); ibUndo.setVisibility(View.GONE);
ibRule.setVisibility(View.GONE);
ibUnsubscribe.setVisibility(View.GONE); ibUnsubscribe.setVisibility(View.GONE);
ibAnswer.setVisibility(View.GONE); ibAnswer.setVisibility(View.GONE);
ibMove.setVisibility(View.GONE); ibMove.setVisibility(View.GONE);
@ -1399,6 +1404,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibDecrypt.setVisibility(View.GONE); ibDecrypt.setVisibility(View.GONE);
ibVerify.setVisibility(View.GONE); ibVerify.setVisibility(View.GONE);
ibUndo.setVisibility(EntityFolder.OUTBOX.equals(message.folderType) ? View.VISIBLE : View.GONE); ibUndo.setVisibility(EntityFolder.OUTBOX.equals(message.folderType) ? View.VISIBLE : View.GONE);
ibRule.setVisibility(View.GONE);
ibUnsubscribe.setVisibility(View.GONE); ibUnsubscribe.setVisibility(View.GONE);
ibAnswer.setVisibility(View.GONE); ibAnswer.setVisibility(View.GONE);
ibMove.setVisibility(View.GONE); ibMove.setVisibility(View.GONE);
@ -1516,11 +1522,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean button_archive_trash = prefs.getBoolean("button_archive_trash", true); boolean button_archive_trash = prefs.getBoolean("button_archive_trash", true);
boolean button_move = prefs.getBoolean("button_move", true); boolean button_move = prefs.getBoolean("button_move", true);
boolean button_rule = prefs.getBoolean("button_rule", true);
boolean expand_all = prefs.getBoolean("expand_all", false); boolean expand_all = prefs.getBoolean("expand_all", false);
boolean expand_one = prefs.getBoolean("expand_one", true); boolean expand_one = prefs.getBoolean("expand_one", true);
ibTrash.setTag(delete); ibTrash.setTag(delete);
ibRule.setVisibility(button_rule && !outbox &&
message.accountProtocol == EntityAccount.TYPE_IMAP ? View.VISIBLE : View.GONE);
ibUnsubscribe.setVisibility(message.unsubscribe == null ? View.GONE : View.VISIBLE); ibUnsubscribe.setVisibility(message.unsubscribe == null ? View.GONE : View.VISIBLE);
ibAnswer.setVisibility(outbox || (!expand_all && expand_one) ? View.GONE : View.VISIBLE); ibAnswer.setVisibility(outbox || (!expand_all && expand_one) ? View.GONE : View.VISIBLE);
ibMove.setVisibility(move && button_move ? View.VISIBLE : View.GONE); ibMove.setVisibility(move && button_move ? View.VISIBLE : View.GONE);
@ -2692,6 +2701,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
case R.id.ibImages: case R.id.ibImages:
onShow(message, false); onShow(message, false);
break; break;
case R.id.ibRule:
onMenuCreateRule(message);
break;
case R.id.ibUnsubscribe: case R.id.ibUnsubscribe:
onActionUnsubscribe(message); onActionUnsubscribe(message);
break; break;

@ -84,7 +84,7 @@ public class FragmentOptions extends FragmentBase {
"name_email", "prefer_contact", "distinguish_contacts", "show_recipients", "authentication", "name_email", "prefer_contact", "distinguish_contacts", "show_recipients", "authentication",
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize", "subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize",
"keywords_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines", "keywords_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines",
"addresses", "button_archive_trash", "button_move", "attachments_alt", "addresses", "button_archive_trash", "button_move", "button_rule", "attachments_alt",
"contrast", "monospaced", "text_color", "text_size", "contrast", "monospaced", "text_color", "text_size",
"inline_images", "collapse_quotes", "seekbar", "actionbar", "actionbar_color", "navbar_colorize", "inline_images", "collapse_quotes", "seekbar", "actionbar", "actionbar_color", "navbar_colorize",
"autoscroll", "swipenav", "autoexpand", "autoclose", "onclose", "autoscroll", "swipenav", "autoexpand", "autoclose", "onclose",

@ -104,6 +104,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swAddresses; private SwitchCompat swAddresses;
private SwitchCompat swArchiveTrash; private SwitchCompat swArchiveTrash;
private SwitchCompat swMove; private SwitchCompat swMove;
private SwitchCompat swRule;
private SwitchCompat swContrast; private SwitchCompat swContrast;
private SwitchCompat swMonospaced; private SwitchCompat swMonospaced;
@ -126,7 +127,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize", "subject_top", "font_size_sender", "font_size_subject", "subject_italic", "highlight_subject", "subject_ellipsize",
"keywords_header", "flags", "flags_background", "keywords_header", "flags", "flags_background",
"preview", "preview_italic", "preview_lines", "preview", "preview_italic", "preview_lines",
"addresses", "button_archive_trash", "button_move", "addresses", "button_archive_trash", "button_move", "button_rule",
"contrast", "monospaced", "text_color", "text_size", "text_align", "contrast", "monospaced", "text_color", "text_size", "text_align",
"inline_images", "collapse_quotes", "attachments_alt", "inline_images", "collapse_quotes", "attachments_alt",
"parse_classes", "authentication" "parse_classes", "authentication"
@ -190,6 +191,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swAddresses = view.findViewById(R.id.swAddresses); swAddresses = view.findViewById(R.id.swAddresses);
swArchiveTrash = view.findViewById(R.id.swArchiveTrash); swArchiveTrash = view.findViewById(R.id.swArchiveTrash);
swMove = view.findViewById(R.id.swMove); swMove = view.findViewById(R.id.swMove);
swRule = view.findViewById(R.id.swRule);
swContrast = view.findViewById(R.id.swContrast); swContrast = view.findViewById(R.id.swContrast);
swMonospaced = view.findViewById(R.id.swMonospaced); swMonospaced = view.findViewById(R.id.swMonospaced);
swTextColor = view.findViewById(R.id.swTextColor); swTextColor = view.findViewById(R.id.swTextColor);
@ -596,6 +598,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
} }
}); });
swRule.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("button_rule", checked).apply();
}
});
swContrast.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swContrast.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -804,6 +813,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swAddresses.setChecked(prefs.getBoolean("addresses", false)); swAddresses.setChecked(prefs.getBoolean("addresses", false));
swArchiveTrash.setChecked(prefs.getBoolean("button_archive_trash", true)); swArchiveTrash.setChecked(prefs.getBoolean("button_archive_trash", true));
swMove.setChecked(prefs.getBoolean("button_move", true)); swMove.setChecked(prefs.getBoolean("button_move", true));
swRule.setChecked(prefs.getBoolean("button_rule", true));
swContrast.setChecked(prefs.getBoolean("contrast", false)); swContrast.setChecked(prefs.getBoolean("contrast", false));
swMonospaced.setChecked(prefs.getBoolean("monospaced", false)); swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
swTextColor.setChecked(prefs.getBoolean("text_color", true)); swTextColor.setChecked(prefs.getBoolean("text_color", true));

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M16.54,11L13,7.46l1.41,-1.41l2.12,2.12l4.24,-4.24l1.41,1.41L16.54,11zM11,7H2v2h9V7zM21,13.41L19.59,12L17,14.59L14.41,12L13,13.41L15.59,16L13,18.59L14.41,20L17,17.41L19.59,20L21,18.59L18.41,16L21,13.41zM11,15H2v2h9V15z"/>
</vector>

@ -521,13 +521,35 @@
app:layout_constraintTop_toTopOf="@id/ivDownload" /> app:layout_constraintTop_toTopOf="@id/ivDownload" />
<ImageView <ImageView
android:id="@+id/ivUnsubscribe" android:id="@+id/ivRule"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_zoom" android:contentDescription="@string/title_legend_create_rule"
android:padding="12dp" android:padding="12dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivDownload" app:layout_constraintTop_toBottomOf="@id/ivDownload"
app:srcCompat="@drawable/baseline_rule_24" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvRule"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center_vertical"
android:text="@string/title_legend_create_rule"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="@id/ivRule"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ivRule"
app:layout_constraintTop_toTopOf="@id/ivRule" />
<ImageView
android:id="@+id/ivUnsubscribe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/title_legend_show_unsubscribe"
android:padding="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivRule"
app:srcCompat="@drawable/baseline_unsubscribe_24" /> app:srcCompat="@drawable/baseline_unsubscribe_24" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView

@ -800,6 +800,18 @@
app:layout_constraintTop_toBottomOf="@id/swArchiveTrash" app:layout_constraintTop_toBottomOf="@id/swArchiveTrash"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swRule"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_create_rule"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swMove"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swContrast" android:id="@+id/swContrast"
android:layout_width="0dp" android:layout_width="0dp"
@ -808,7 +820,7 @@
android:text="@string/title_advanced_contrast" android:text="@string/title_advanced_contrast"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swMove" app:layout_constraintTop_toBottomOf="@id/swRule"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat

@ -27,7 +27,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="3dp" android:layout_marginEnd="3dp"
app:constraint_referenced_ids="ibMore,ibInbox,ibJunk,ibTrash,ibArchive,ibMove,ibAnswer,ibUnsubscribe,ibUndo" app:constraint_referenced_ids="ibMore,ibInbox,ibJunk,ibTrash,ibArchive,ibMove,ibAnswer,ibUnsubscribe,ibRule,ibUndo"
app:flow_horizontalBias="0" app:flow_horizontalBias="0"
app:flow_horizontalGap="3dp" app:flow_horizontalGap="3dp"
app:flow_horizontalStyle="packed" app:flow_horizontalStyle="packed"
@ -132,6 +132,18 @@
app:srcCompat="@drawable/baseline_unsubscribe_24" app:srcCompat="@drawable/baseline_unsubscribe_24"
tools:ignore="MissingConstraints" /> tools:ignore="MissingConstraints" />
<ImageButton
android:id="@+id/ibRule"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_legend_create_rule"
android:padding="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_legend_create_rule"
app:srcCompat="@drawable/baseline_rule_24"
tools:ignore="MissingConstraints" />
<ImageButton <ImageButton
android:id="@+id/ibUndo" android:id="@+id/ibUndo"
android:layout_width="36dp" android:layout_width="36dp"

@ -356,6 +356,7 @@
<string name="title_advanced_preview_lines">Number of preview lines</string> <string name="title_advanced_preview_lines">Number of preview lines</string>
<string name="title_advanced_archive_trash">Show buttons to archive or trash a message</string> <string name="title_advanced_archive_trash">Show buttons to archive or trash a message</string>
<string name="title_advanced_move">Show button to move a message</string> <string name="title_advanced_move">Show button to move a message</string>
<string name="title_advanced_create_rule">Show button to create a rule for a message</string>
<string name="title_advanced_addresses">Expand address details by default</string> <string name="title_advanced_addresses">Expand address details by default</string>
<string name="title_advanced_attachments_alt">Show attachments after the message text</string> <string name="title_advanced_attachments_alt">Show attachments after the message text</string>
<string name="title_advanced_contrast">Use high contrast for message text</string> <string name="title_advanced_contrast">Use high contrast for message text</string>
@ -1166,6 +1167,7 @@
<string name="title_legend_avatar">Avatar</string> <string name="title_legend_avatar">Avatar</string>
<string name="title_legend_show_quotes">Show quotes</string> <string name="title_legend_show_quotes">Show quotes</string>
<string name="title_legend_show_junk">Treat as spam</string> <string name="title_legend_show_junk">Treat as spam</string>
<string name="title_legend_create_rule">Create rule</string>
<string name="title_legend_show_unsubscribe">Unsubscribe from list</string> <string name="title_legend_show_unsubscribe">Unsubscribe from list</string>
<string name="title_legend_show_images">Show images</string> <string name="title_legend_show_images">Show images</string>
<string name="title_legend_show_full">Show original message</string> <string name="title_legend_show_full">Show original message</string>

Loading…
Cancel
Save