mirror of https://github.com/M66B/FairEmail.git
Added collapsing of nav menu folders
This commit is contained in:
parent
d440f2562f
commit
957301bf43
|
@ -6,6 +6,7 @@
|
|||
|
||||
### Next version
|
||||
|
||||
* Added collapsing of navigation menu folders
|
||||
* Added theme option for default light original message view
|
||||
* Unified color based on account folder colors
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ apply plugin: 'kotlin-android'
|
|||
apply plugin: 'de.undercouch.download'
|
||||
|
||||
def getVersionCode = { -> return 1731 }
|
||||
def getRevision = { -> "\"a\"" }
|
||||
def getRevision = { -> "\"e\"" }
|
||||
def getReleaseName = { -> return "\"Yaverlandia\"" }
|
||||
// https://en.wikipedia.org/wiki/List_of_dinosaur_genera
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
### Next version
|
||||
|
||||
* Added collapsing of navigation menu folders
|
||||
* Added theme option for default light original message view
|
||||
* Unified color based on account folder colors
|
||||
|
||||
|
|
|
@ -427,13 +427,30 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
public void onClick(View v) {
|
||||
boolean nav_account = prefs.getBoolean("nav_account", true);
|
||||
boolean nav_folder = prefs.getBoolean("nav_folder", true);
|
||||
nav_account = !(nav_account || nav_folder);
|
||||
boolean nav_quick = prefs.getBoolean("nav_quick", true);
|
||||
boolean expanded = (nav_account || nav_folder);
|
||||
|
||||
if (expanded && nav_quick && adapterNavAccount.hasFolders())
|
||||
nav_quick = false;
|
||||
else {
|
||||
expanded = !expanded;
|
||||
if (expanded)
|
||||
nav_quick = true;
|
||||
}
|
||||
|
||||
prefs.edit()
|
||||
.putBoolean("nav_account", nav_account)
|
||||
.putBoolean("nav_folder", false)
|
||||
.putBoolean("nav_account", expanded)
|
||||
.putBoolean("nav_folder", expanded)
|
||||
.putBoolean("nav_quick", nav_quick)
|
||||
.apply();
|
||||
ibExpanderAccount.setImageLevel(nav_account ? 0 /* less */ : 1 /* more */);
|
||||
rvAccount.setVisibility(nav_account ? View.VISIBLE : View.GONE);
|
||||
|
||||
adapterNavAccount.setFolders(nav_quick);
|
||||
|
||||
if (expanded && nav_quick && adapterNavAccount.hasFolders())
|
||||
ibExpanderAccount.setImageLevel(2 /* unfold less */);
|
||||
else
|
||||
ibExpanderAccount.setImageLevel(expanded ? 0 /* less */ : 1 /* more */);
|
||||
rvAccount.setVisibility(expanded ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -736,13 +753,25 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
// Live data
|
||||
|
||||
DB db = DB.getInstance(this);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
db.account().liveAccountFolder().observe(owner, new Observer<List<TupleAccountFolder>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<TupleAccountFolder> accounts) {
|
||||
if (accounts == null)
|
||||
accounts = new ArrayList<>();
|
||||
adapterNavAccount.set(accounts, nav_expanded);
|
||||
|
||||
boolean nav_account = prefs.getBoolean("nav_account", true);
|
||||
boolean nav_folder = prefs.getBoolean("nav_folder", true);
|
||||
boolean nav_quick = prefs.getBoolean("nav_quick", true);
|
||||
boolean expanded = (nav_account || nav_folder);
|
||||
|
||||
adapterNavAccount.set(accounts, nav_expanded, nav_quick);
|
||||
|
||||
if (expanded && nav_quick && adapterNavAccount.hasFolders())
|
||||
ibExpanderAccount.setImageLevel(2 /* unfold less */);
|
||||
else
|
||||
ibExpanderAccount.setImageLevel(expanded ? 0 /* less */ : 1 /* more */);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@ public class AdapterNavAccountFolder extends RecyclerView.Adapter<AdapterNavAcco
|
|||
private int colorWarning;
|
||||
|
||||
private boolean expanded = true;
|
||||
private boolean folders = true;
|
||||
private List<TupleAccountFolder> all = new ArrayList<>();
|
||||
private List<TupleAccountFolder> items = new ArrayList<>();
|
||||
|
||||
private NumberFormat NF = NumberFormat.getNumberInstance();
|
||||
|
@ -276,7 +278,7 @@ public class AdapterNavAccountFolder extends RecyclerView.Adapter<AdapterNavAcco
|
|||
setHasStableIds(false);
|
||||
}
|
||||
|
||||
public void set(@NonNull List<TupleAccountFolder> accounts, boolean expanded) {
|
||||
public void set(@NonNull List<TupleAccountFolder> accounts, boolean expanded, boolean folders) {
|
||||
Log.i("Set nav accounts=" + accounts.size());
|
||||
|
||||
if (accounts.size() > 0) {
|
||||
|
@ -328,6 +330,14 @@ public class AdapterNavAccountFolder extends RecyclerView.Adapter<AdapterNavAcco
|
|||
});
|
||||
}
|
||||
|
||||
all = accounts;
|
||||
if (!folders) {
|
||||
accounts = new ArrayList<>();
|
||||
for (TupleAccountFolder item : all)
|
||||
if (item.folderName == null)
|
||||
accounts.add(item);
|
||||
}
|
||||
|
||||
DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(items, accounts), false);
|
||||
|
||||
this.expanded = expanded;
|
||||
|
@ -362,6 +372,20 @@ public class AdapterNavAccountFolder extends RecyclerView.Adapter<AdapterNavAcco
|
|||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setFolders(boolean folders) {
|
||||
if (this.folders != folders) {
|
||||
this.folders = folders;
|
||||
set(all, expanded, folders);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasFolders() {
|
||||
for (TupleAccountFolder item : all)
|
||||
if (item.folderName != null)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class DiffCallback extends DiffUtil.Callback {
|
||||
private List<TupleAccountFolder> prev = new ArrayList<>();
|
||||
private List<TupleAccountFolder> next = new ArrayList<>();
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:drawable="@drawable/twotone_expand_less_24"
|
||||
android:maxLevel="0" />
|
||||
<item
|
||||
android:drawable="@drawable/twotone_expand_more_24"
|
||||
android:maxLevel="1" />
|
||||
<item
|
||||
android:drawable="@drawable/outline_unfold_less_24"
|
||||
android:maxLevel="2" />
|
||||
</level-list>
|
|
@ -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="M7.41,18.59L8.83,20 12,16.83 15.17,20l1.41,-1.41L12,14l-4.59,4.59zM16.59,5.41L15.17,4 12,7.17 8.83,4 7.41,5.41 12,10l4.59,-4.59z"/>
|
||||
</vector>
|
|
@ -107,7 +107,7 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorOptions"
|
||||
app:srcCompat="@drawable/expander" />
|
||||
app:srcCompat="@drawable/expander3" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rvAccount"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
### Next version
|
||||
|
||||
* Added collapsing of navigation menu folders
|
||||
* Added theme option for default light original message view
|
||||
* Unified color based on account folder colors
|
||||
|
||||
|
|
Loading…
Reference in New Issue