mirror of https://github.com/M66B/FairEmail.git
Added option: hide folder if all messages seen
This commit is contained in:
parent
2c86db0d6f
commit
1479617df8
File diff suppressed because it is too large
Load Diff
|
@ -226,11 +226,12 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
|
||||
private void bindTo(final TupleFolderEx folder) {
|
||||
boolean disabled = isDisabled(folder);
|
||||
boolean hide_seen = (folder.hide_seen && folder.unseen + folder.childs_unseen == 0);
|
||||
|
||||
int p = (show_compact && all.size() < DENSE_ITEMS_THRESHOLD ? dp3 : 0);
|
||||
view.setPadding(p, p, p, p);
|
||||
view.setActivated(folder.tbc != null || folder.rename != null || folder.tbd != null);
|
||||
view.setAlpha(folder.hide || disabled ? Helper.LOW_LIGHT : 1.0f);
|
||||
view.setAlpha(folder.hide || hide_seen || disabled ? Helper.LOW_LIGHT : 1.0f);
|
||||
|
||||
if (listener == null && selectedModel != null)
|
||||
itemView.setBackgroundColor(
|
||||
|
@ -1262,17 +1263,25 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
|
||||
List<TupleFolderEx> hierarchical;
|
||||
if (account < 0 && !primary) {
|
||||
if (folders.size() > 0)
|
||||
Collections.sort(folders, folders.get(0).getComparator(context));
|
||||
hierarchical = folders;
|
||||
List<TupleFolderEx> filtered = new ArrayList<>();
|
||||
for (TupleFolderEx folder : folders)
|
||||
if (show_hidden ||
|
||||
!(folder.hide ||
|
||||
(folder.hide_seen && folder.unseen + folder.childs_unseen == 0)))
|
||||
filtered.add(folder);
|
||||
|
||||
if (filtered.size() > 0)
|
||||
Collections.sort(filtered, filtered.get(0).getComparator(context));
|
||||
|
||||
if (sort_unread_atop)
|
||||
Collections.sort(hierarchical, new Comparator<TupleFolderEx>() {
|
||||
Collections.sort(filtered, new Comparator<TupleFolderEx>() {
|
||||
@Override
|
||||
public int compare(TupleFolderEx f1, TupleFolderEx f2) {
|
||||
return -Boolean.compare(f1.unseen > 0, f2.unseen > 0);
|
||||
}
|
||||
});
|
||||
|
||||
hierarchical = filtered;
|
||||
} else {
|
||||
List<TupleFolderEx> parents = new ArrayList<>();
|
||||
Map<Long, TupleFolderEx> idFolder = new HashMap<>();
|
||||
|
@ -1464,6 +1473,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
}
|
||||
}
|
||||
|
||||
if (parent.hide_seen && parent.unseen + parent.childs_unseen == 0 && !show_hidden)
|
||||
continue;
|
||||
|
||||
if (!subscribed_only ||
|
||||
EntityFolder.INBOX.equals(parent.type) ||
|
||||
parent.accountProtocol != EntityAccount.TYPE_IMAP ||
|
||||
|
@ -1521,6 +1533,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
while (p1 != null && p2 != null) {
|
||||
if (p1.hide != p2.hide)
|
||||
return false;
|
||||
if ((p1.hide_seen && p1.unseen + p1.childs_unseen == 0) !=
|
||||
(p2.hide_seen && p2.unseen + p2.childs_unseen == 0))
|
||||
return false;
|
||||
|
||||
if (p1.collapsed != p2.collapsed)
|
||||
return false;
|
||||
|
|
|
@ -71,7 +71,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
|
|||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 229,
|
||||
version = 230,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
|
@ -2300,6 +2300,13 @@ public abstract class DB extends RoomDatabase {
|
|||
db.execSQL("DROP VIEW IF EXISTS `identity_view`");
|
||||
db.execSQL("CREATE VIEW IF NOT EXISTS `identity_view` AS " + TupleIdentityView.query);
|
||||
}
|
||||
}).addMigrations(new Migration(229, 230) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
logMigration(startVersion, endVersion);
|
||||
db.execSQL("ALTER TABLE `folder` ADD COLUMN `hide_seen` INTEGER NOT NULL DEFAULT 0");
|
||||
db.execSQL("UPDATE `folder` SET hide = 0 WHERE unified");
|
||||
}
|
||||
}).addMigrations(new Migration(998, 999) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
|
|
|
@ -316,6 +316,7 @@ public interface DaoFolder {
|
|||
", navigation = :navigation" +
|
||||
", notify = :notify" +
|
||||
", hide = :hide" +
|
||||
", hide_seen = :hide_seen" +
|
||||
", synchronize = :synchronize" +
|
||||
", poll = :poll" +
|
||||
", poll_factor = :poll_factor" +
|
||||
|
@ -328,7 +329,8 @@ public interface DaoFolder {
|
|||
" WHERE id = :id")
|
||||
int setFolderProperties(
|
||||
long id, String rename,
|
||||
String display, Integer color, boolean unified, boolean navigation, boolean notify, boolean hide,
|
||||
String display, Integer color, boolean unified, boolean navigation, boolean notify,
|
||||
boolean hide, boolean hide_seen,
|
||||
boolean synchronize, boolean poll, int poll_factor, boolean download,
|
||||
boolean auto_classify_source, boolean auto_classify_target,
|
||||
int sync_days, int keep_days, boolean auto_delete);
|
||||
|
|
|
@ -108,6 +108,8 @@ public class EntityFolder extends EntityOrder implements Serializable {
|
|||
@NonNull
|
||||
public Boolean hide = false;
|
||||
@NonNull
|
||||
public Boolean hide_seen = false;
|
||||
@NonNull
|
||||
public Boolean collapsed = false;
|
||||
@NonNull
|
||||
public Boolean unified = false;
|
||||
|
@ -605,6 +607,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
|
|||
Objects.equals(this.color, other.color) &&
|
||||
Objects.equals(this.order, other.order) &&
|
||||
this.hide == other.hide &&
|
||||
this.hide_seen == other.hide_seen &&
|
||||
this.collapsed == other.collapsed &&
|
||||
this.unified == other.unified &&
|
||||
this.navigation == other.navigation &&
|
||||
|
@ -652,6 +655,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
|
|||
json.put("display", display);
|
||||
json.put("color", color);
|
||||
json.put("hide", hide);
|
||||
json.put("hide_seen", hide_seen);
|
||||
json.put("collapsed", collapsed);
|
||||
json.put("unified", unified);
|
||||
json.put("navigation", navigation);
|
||||
|
@ -716,6 +720,9 @@ public class EntityFolder extends EntityOrder implements Serializable {
|
|||
if (json.has("hide"))
|
||||
folder.hide = json.getBoolean("hide");
|
||||
|
||||
if (json.has("hide_seen"))
|
||||
folder.hide_seen = json.getBoolean("hide_seen");
|
||||
|
||||
if (json.has("collapsed"))
|
||||
folder.collapsed = json.getBoolean("collapsed");
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ public class FragmentFolder extends FragmentBase {
|
|||
private EditText etDisplay;
|
||||
private ViewButtonColor btnColor;
|
||||
private CheckBox cbHide;
|
||||
private CheckBox cbHideSeen;
|
||||
private CheckBox cbUnified;
|
||||
private CheckBox cbNavigation;
|
||||
private CheckBox cbNotify;
|
||||
|
@ -127,6 +128,7 @@ public class FragmentFolder extends FragmentBase {
|
|||
etDisplay = view.findViewById(R.id.etDisplay);
|
||||
btnColor = view.findViewById(R.id.btnColor);
|
||||
cbHide = view.findViewById(R.id.cbHide);
|
||||
cbHideSeen = view.findViewById(R.id.cbHideSeen);
|
||||
cbUnified = view.findViewById(R.id.cbUnified);
|
||||
cbNavigation = view.findViewById(R.id.cbNavigation);
|
||||
cbNotify = view.findViewById(R.id.cbNotify);
|
||||
|
@ -169,6 +171,13 @@ public class FragmentFolder extends FragmentBase {
|
|||
}
|
||||
});
|
||||
|
||||
cbHide.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
|
||||
cbHideSeen.setEnabled(!isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
cbSynchronize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
|
@ -307,6 +316,7 @@ public class FragmentFolder extends FragmentBase {
|
|||
etDisplay.setHint(folder == null ? null : EntityFolder.localizeName(getContext(), folder.name));
|
||||
btnColor.setColor(folder == null ? null : folder.color);
|
||||
cbHide.setChecked(folder == null ? false : folder.hide);
|
||||
cbHideSeen.setChecked(folder == null ? false : folder.hide_seen);
|
||||
cbUnified.setChecked(folder == null ? false : folder.unified);
|
||||
cbNavigation.setChecked(folder == null ? false : folder.navigation);
|
||||
cbNotify.setChecked(folder == null ? false : folder.notify);
|
||||
|
@ -327,6 +337,8 @@ public class FragmentFolder extends FragmentBase {
|
|||
|
||||
Helper.setViewsEnabled(view, true);
|
||||
|
||||
cbHideSeen.setEnabled(!cbHide.isChecked());
|
||||
|
||||
boolean canAutoClassify = (imap && MessageClassifier.isEnabled(getContext()));
|
||||
boolean canAutoDelete = (imap && (folder == null || !folder.read_only));
|
||||
boolean isArchive = (folder != null && EntityFolder.ARCHIVE.equals(folder.type));
|
||||
|
@ -449,6 +461,7 @@ public class FragmentFolder extends FragmentBase {
|
|||
args.putString("display", etDisplay.getText().toString());
|
||||
args.putInt("color", btnColor.getColor());
|
||||
args.putBoolean("hide", cbHide.isChecked());
|
||||
args.putBoolean("hide_seen", cbHideSeen.isChecked());
|
||||
args.putBoolean("unified", cbUnified.isChecked());
|
||||
args.putBoolean("navigation", cbNavigation.isChecked());
|
||||
args.putBoolean("notify", cbNotify.isChecked());
|
||||
|
@ -493,6 +506,7 @@ public class FragmentFolder extends FragmentBase {
|
|||
String display = args.getString("display");
|
||||
Integer color = args.getInt("color");
|
||||
boolean hide = args.getBoolean("hide");
|
||||
boolean hide_seen = args.getBoolean("hide_seen");
|
||||
boolean unified = args.getBoolean("unified");
|
||||
boolean navigation = args.getBoolean("navigation");
|
||||
boolean notify = args.getBoolean("notify");
|
||||
|
@ -553,6 +567,8 @@ public class FragmentFolder extends FragmentBase {
|
|||
return true;
|
||||
if (!Objects.equals(folder.hide, hide))
|
||||
return true;
|
||||
if (!Objects.equals(folder.hide_seen, hide_seen))
|
||||
return true;
|
||||
if (!Objects.equals(folder.synchronize, synchronize))
|
||||
return true;
|
||||
if (imap) {
|
||||
|
@ -605,6 +621,7 @@ public class FragmentFolder extends FragmentBase {
|
|||
create.navigation = navigation;
|
||||
create.notify = notify;
|
||||
create.hide = hide;
|
||||
create.hide_seen = hide;
|
||||
create.synchronize = synchronize;
|
||||
create.poll = poll;
|
||||
create.poll_factor = poll_factor;
|
||||
|
@ -631,7 +648,8 @@ public class FragmentFolder extends FragmentBase {
|
|||
Log.i("Updating folder=" + folder.name);
|
||||
db.folder().setFolderProperties(id,
|
||||
folder.name.equals(name) ? null : name,
|
||||
display, color, unified, navigation, notify, hide,
|
||||
display, color, unified, navigation, notify,
|
||||
hide, hide_seen,
|
||||
synchronize, poll, poll_factor, download,
|
||||
auto_classify_source, auto_classify_target,
|
||||
sync_days, keep_days, auto_delete);
|
||||
|
|
|
@ -109,6 +109,15 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnColor" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbHideSeen"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_hide_seen_folder"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbHide" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbUnified"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -116,7 +125,7 @@
|
|||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_unified_folder"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbHide" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cbHideSeen" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbNavigation"
|
||||
|
|
|
@ -1064,6 +1064,7 @@
|
|||
<string name="title_apply_to_all">Apply to all</string>
|
||||
<string name="title_edit_account_name">Edit account name</string>
|
||||
<string name="title_hide_folder">Hide folder</string>
|
||||
<string name="title_hide_seen_folder">Hide if all messages are read</string>
|
||||
<string name="title_unified_folder">Show in unified inbox</string>
|
||||
<string name="title_navigation_folder">Show in navigation menu</string>
|
||||
<string name="title_synchronize_folder">Synchronize (receive messages)</string>
|
||||
|
|
Loading…
Reference in New Issue