Added option to enable folder subscription management

This commit is contained in:
M66B 2019-04-25 19:02:37 +02:00
parent d38027eabe
commit 7f53380f63
5 changed files with 49 additions and 4 deletions

View File

@ -73,6 +73,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private EntityFolder parent;
private boolean collapsable;
private IProperties properties;
private boolean subscriptions;
private boolean debug;
private int dp12;
private float textSize;
@ -227,7 +228,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
ivExpander.setVisibility(account < 0 || !collapsable ? View.GONE : (folder.childs > 0 ? View.VISIBLE : View.INVISIBLE));
ivNotify.setVisibility(folder.notify ? View.VISIBLE : View.GONE);
ivSubscribed.setVisibility(BuildConfig.DEBUG && folder.subscribed != null && folder.subscribed ? View.VISIBLE : View.GONE);
ivSubscribed.setVisibility(subscriptions && folder.subscribed != null && folder.subscribed ? View.VISIBLE : View.GONE);
if (folder.unseen > 0)
tvName.setText(context.getString(R.string.title_name_count,
@ -593,6 +594,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
if (zoom == 0)
zoom = 1;
this.subscriptions = prefs.getBoolean("subscriptions", false);
this.debug = prefs.getBoolean("debug", false);
this.dp12 = Helper.dp2pixels(context, 12);

View File

@ -21,8 +21,10 @@ package eu.faircode.email;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
@ -290,8 +292,11 @@ public class FragmentFolder extends FragmentBase {
@Override
public void onPrepareOptionsMenu(Menu menu) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean subscriptions = prefs.getBoolean("subscriptions", false);
menu.findItem(R.id.menu_subscribe).setChecked(subscribed != null && subscribed);
menu.findItem(R.id.menu_subscribe).setVisible(id > 0 && subscribed != null);
menu.findItem(R.id.menu_subscribe).setVisible(subscriptions && id > 0 && subscribed != null);
menu.findItem(R.id.menu_delete).setVisible(id > 0 && !saving && deletable);
super.onPrepareOptionsMenu(menu);
}

View File

@ -104,6 +104,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private SwitchCompat swAutoSend;
private SwitchCompat swBadge;
private SwitchCompat swSubscriptions;
private SwitchCompat swNotifyPreview;
private SwitchCompat swSearchLocal;
private SwitchCompat swLight;
@ -124,6 +125,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
"startup", "date", "threading", "avatars", "identicons", "circular", "name_email", "subject_italic", "flags", "preview",
"addresses", "monospaced", "autohtml", "autoimages", "actionbar",
"pull", "swipenav", "autoexpand", "autoclose", "autonext",
"subscriptions",
"authentication", "debug"
};
@ -134,7 +136,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
"addresses", "monospaced", "autohtml", "autoimages", "actionbar",
"pull", "swipenav", "autoexpand", "autoclose", "autonext", "collapse", "autoread", "automove",
"autoresize", "resize", "prefix_once", "autosend",
"notify_preview", "search_local", "light", "sound",
"subscriptions", "notify_preview", "search_local", "light", "sound",
"authentication", "paranoid", "english", "updates", "debug",
"first", "why", "last_update_check", "app_support", "message_swipe", "message_select", "folder_actions", "folder_sync",
"edit_ref_confirmed", "show_html_confirmed", "show_images_confirmed", "print_html_confirmed", "show_organization", "style_toolbar"
@ -191,6 +193,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swAutoSend = view.findViewById(R.id.swAutoSend);
swBadge = view.findViewById(R.id.swBadge);
swSubscriptions = view.findViewById(R.id.swSubscriptions);
swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
swSearchLocal = view.findViewById(R.id.swSearchLocal);
swLight = view.findViewById(R.id.swLight);
@ -509,6 +512,13 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
}
});
swSubscriptions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("subscriptions", checked).apply();
}
});
swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -731,6 +741,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swAutoSend.setChecked(!prefs.getBoolean("autosend", false));
swBadge.setChecked(prefs.getBoolean("badge", true));
swSubscriptions.setChecked(prefs.getBoolean("subscriptions", false));
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
swNotifyPreview.setEnabled(Helper.isPro(getContext()));
swSearchLocal.setChecked(prefs.getBoolean("search_local", false));

View File

@ -789,6 +789,31 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swBadge" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSubscriptions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_subscriptions"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBadgeHint"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvSubscriptionsHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="60dp"
android:text="@string/title_advanced_subscriptions_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSubscriptions" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyPreview"
android:layout_width="match_parent"
@ -798,7 +823,7 @@
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_notify_preview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBadgeHint"
app:layout_constraintTop_toBottomOf="@id/tvSubscriptionsHint"
app:switchPadding="12dp" />
<TextView

View File

@ -194,6 +194,7 @@
<string name="title_advanced_autosend">Confirm sending messages</string>
<string name="title_advanced_badge">Show launcher icon with number of new messages</string>
<string name="title_advanced_subscriptions">Manage folder subscriptions</string>
<string name="title_advanced_notify_preview">Show message preview in notifications</string>
<string name="title_advanced_search_local">External search on device</string>
<string name="title_advanced_light">Use notification light</string>
@ -214,6 +215,7 @@
<string name="title_advanced_threading_hint">Group messages related to each other</string>
<string name="title_advanced_name_email_hint">When disabled only names will be shown when available</string>
<string name="title_advanced_flags_hint">Note that starred messages will always be kept locally</string>
<string name="title_advanced_subscriptions_hint">Folders not subscribed to will be hidden</string>
<string name="title_advanced_preview_hint">Only available when message text was downloaded</string>
<string name="title_advanced_autoexpand_hint">Automatically open message when there is just one message or just one unread message in a conversation</string>