Added option to enable folder subscription management

pull/155/head
M66B 6 years ago
parent d38027eabe
commit 7f53380f63

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

@ -21,8 +21,10 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -290,8 +292,11 @@ public class FragmentFolder extends FragmentBase {
@Override @Override
public void onPrepareOptionsMenu(Menu menu) { 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).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); menu.findItem(R.id.menu_delete).setVisible(id > 0 && !saving && deletable);
super.onPrepareOptionsMenu(menu); super.onPrepareOptionsMenu(menu);
} }

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

@ -789,6 +789,31 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swBadge" /> 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 <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyPreview" android:id="@+id/swNotifyPreview"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -798,7 +823,7 @@
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:text="@string/title_advanced_notify_preview" android:text="@string/title_advanced_notify_preview"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBadgeHint" app:layout_constraintTop_toBottomOf="@id/tvSubscriptionsHint"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<TextView <TextView

@ -194,6 +194,7 @@
<string name="title_advanced_autosend">Confirm sending messages</string> <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_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_notify_preview">Show message preview in notifications</string>
<string name="title_advanced_search_local">External search on device</string> <string name="title_advanced_search_local">External search on device</string>
<string name="title_advanced_light">Use notification light</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_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_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_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_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> <string name="title_advanced_autoexpand_hint">Automatically open message when there is just one message or just one unread message in a conversation</string>

Loading…
Cancel
Save