diff --git a/README.md b/README.md index 6d244b5992..cc1db0ff5b 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ This app starts a foreground service with a low priority status bar notification * Snooze messages * Send messages after selected time * Reply templates +* Filter rules * Search on server * Keyword management * Encryption/decryption ([OpenPGP](https://www.openpgp.org/)) diff --git a/app/src/main/java/eu/faircode/email/AdapterRule.java b/app/src/main/java/eu/faircode/email/AdapterRule.java index 4cf632b8a6..ec5598932c 100644 --- a/app/src/main/java/eu/faircode/email/AdapterRule.java +++ b/app/src/main/java/eu/faircode/email/AdapterRule.java @@ -24,6 +24,7 @@ import android.content.Intent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; import java.text.Collator; @@ -52,6 +53,7 @@ public class AdapterRule extends RecyclerView.Adapter { private View itemView; private TextView tvName; private TextView tvOrder; + private ImageView ivStop; ViewHolder(View itemView) { super(itemView); @@ -59,6 +61,7 @@ public class AdapterRule extends RecyclerView.Adapter { this.itemView = itemView.findViewById(R.id.clItem); tvName = itemView.findViewById(R.id.tvName); tvOrder = itemView.findViewById(R.id.tvOrder); + ivStop = itemView.findViewById(R.id.ivStop); } private void wire() { @@ -73,6 +76,7 @@ public class AdapterRule extends RecyclerView.Adapter { itemView.setActivated(!rule.enabled); tvName.setText(rule.name); tvOrder.setText(Integer.toString(rule.order)); + ivStop.setVisibility(rule.stop ? View.VISIBLE : View.INVISIBLE); } @Override diff --git a/app/src/main/java/eu/faircode/email/EntityRule.java b/app/src/main/java/eu/faircode/email/EntityRule.java index 596f2be288..f12466e99d 100644 --- a/app/src/main/java/eu/faircode/email/EntityRule.java +++ b/app/src/main/java/eu/faircode/email/EntityRule.java @@ -134,7 +134,7 @@ public class EntityRule { try { JSONObject jargs = new JSONObject(action); int type = jargs.getInt("type"); - Log.i("Executing rule=" + type + " message=" + message.id); + Log.i("Executing rule=" + type + ":" + name + " message=" + message.id); switch (type) { case TYPE_SEEN: diff --git a/app/src/main/java/eu/faircode/email/FragmentAnswer.java b/app/src/main/java/eu/faircode/email/FragmentAnswer.java index 027a4e8459..760131fe6b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAnswer.java +++ b/app/src/main/java/eu/faircode/email/FragmentAnswer.java @@ -34,7 +34,6 @@ import com.google.android.material.bottomnavigation.BottomNavigationView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.Group; -import androidx.lifecycle.Lifecycle; public class FragmentAnswer extends FragmentBase { private ViewGroup view; @@ -70,7 +69,7 @@ public class FragmentAnswer extends FragmentBase { bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override - public boolean onNavigationItemSelected(MenuItem menuItem) { + public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.action_delete: onActionDelete(); @@ -84,8 +83,6 @@ public class FragmentAnswer extends FragmentBase { } }); - ((ActivityBase) getActivity()).addBackPressedListener(onBackPressedListener); - // Initialize grpReady.setVisibility(View.GONE); pbWait.setVisibility(View.VISIBLE); @@ -93,12 +90,6 @@ public class FragmentAnswer extends FragmentBase { return view; } - @Override - public void onDestroyView() { - ((ActivityBase) getActivity()).removeBackPressedListener(onBackPressedListener); - super.onDestroyView(); - } - @Override public void onActivityCreated(@Nullable final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -223,31 +214,4 @@ public class FragmentAnswer extends FragmentBase { } }.execute(this, args, "answer:save"); } - - private void handleExit() { - if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) - new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner()) - .setMessage(R.string.title_ask_save) - .setPositiveButton(R.string.title_yes, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - onActionSave(); - } - }) - .setNegativeButton(R.string.title_no, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - finish(); - } - }) - .show(); - } - - ActivityBase.IBackPressedListener onBackPressedListener = new ActivityBase.IBackPressedListener() { - @Override - public boolean onBackPressed() { - handleExit(); - return true; - } - }; } diff --git a/app/src/main/java/eu/faircode/email/FragmentRule.java b/app/src/main/java/eu/faircode/email/FragmentRule.java index f79944a096..453ccd1bd3 100644 --- a/app/src/main/java/eu/faircode/email/FragmentRule.java +++ b/app/src/main/java/eu/faircode/email/FragmentRule.java @@ -45,7 +45,6 @@ import java.util.List; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.Group; -import androidx.lifecycle.Lifecycle; public class FragmentRule extends FragmentBase { private ViewGroup view; @@ -136,7 +135,7 @@ public class FragmentRule extends FragmentBase { bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override - public boolean onNavigationItemSelected(MenuItem menuItem) { + public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.action_delete: onActionTrash(); @@ -150,8 +149,6 @@ public class FragmentRule extends FragmentBase { } }); - ((ActivityBase) getActivity()).addBackPressedListener(onBackPressedListener); - // Initialize bottom_navigation.setVisibility(View.GONE); grpReady.setVisibility(View.GONE); @@ -161,12 +158,6 @@ public class FragmentRule extends FragmentBase { return view; } - @Override - public void onDestroyView() { - ((ActivityBase) getActivity()).removeBackPressedListener(onBackPressedListener); - super.onDestroyView(); - } - @Override public void onActivityCreated(@Nullable final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -388,8 +379,7 @@ public class FragmentRule extends FragmentBase { JSONObject jsender = jcondition.optJSONObject("sender"); JSONObject jsubject = jcondition.optJSONObject("subject"); - if (TextUtils.isEmpty(jsender.optString("value")) && - TextUtils.isEmpty(jsubject.optString("value"))) + if (jsender == null && jsubject == null) throw new IllegalArgumentException(context.getString(R.string.title_rule_condition_missing)); if (TextUtils.isEmpty(order)) @@ -439,33 +429,6 @@ public class FragmentRule extends FragmentBase { } } - private void handleExit() { - if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) - new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner()) - .setMessage(R.string.title_ask_save) - .setPositiveButton(R.string.title_yes, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - onActionSave(); - } - }) - .setNegativeButton(R.string.title_no, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - finish(); - } - }) - .show(); - } - - ActivityBase.IBackPressedListener onBackPressedListener = new ActivityBase.IBackPressedListener() { - @Override - public boolean onBackPressed() { - handleExit(); - return true; - } - }; - private class Action { int type; String name; diff --git a/app/src/main/res/drawable/baseline_stop_24.xml b/app/src/main/res/drawable/baseline_stop_24.xml new file mode 100644 index 0000000000..dfba4dff22 --- /dev/null +++ b/app/src/main/res/drawable/baseline_stop_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_rule.xml b/app/src/main/res/layout/fragment_rule.xml index 384e15c463..919c51dd1f 100644 --- a/app/src/main/res/layout/fragment_rule.xml +++ b/app/src/main/res/layout/fragment_rule.xml @@ -117,6 +117,7 @@ android:layout_marginTop="12dp" android:text="@string/title_rule_and" android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium" + android:textColor="?android:attr/textColorPrimary" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/etSender" /> diff --git a/app/src/main/res/layout/item_rule.xml b/app/src/main/res/layout/item_rule.xml index 406a19dea9..9ad386a8ff 100644 --- a/app/src/main/res/layout/item_rule.xml +++ b/app/src/main/res/layout/item_rule.xml @@ -15,25 +15,35 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="6dp" - android:layout_marginTop="6dp" android:layout_marginEnd="6dp" android:ellipsize="end" android:maxLines="1" android:text="Name" android:textAppearance="@style/TextAppearance.AppCompat.Medium" + app:layout_constraintBottom_toBottomOf="@+id/ivStop" app:layout_constraintEnd_toStartOf="@+id/tvOrder" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="@+id/ivStop" /> + + @@ -45,6 +55,6 @@ android:layout_marginBottom="6dp" android:background="?attr/colorSeparator" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/tvName" /> + app:layout_constraintTop_toBottomOf="@id/ivStop" /> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e17d2e92f3..bf003bcbf4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -308,7 +308,6 @@ Delete reply template permanently? Delete rule permanently? Discard draft? - Save changes? Report as spam? Showing the original message can leak privacy sensitive information Showing images can leak privacy sensitive information