Bring back folder hiding

pull/156/head
M66B 6 years ago
parent 61b8df8fa8
commit 3d6ffadc5e

@ -66,6 +66,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private Context context;
private LayoutInflater inflater;
private LifecycleOwner owner;
private boolean show_hidden;
private long account;
private IFolderSelectedListener listener;
@ -152,7 +153,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private void bindTo(final TupleFolderEx folder) {
view.setActivated(folder.tbc != null || folder.tbd != null);
view.setAlpha(disabledIds.contains(folder.id) ? Helper.LOW_LIGHT : 1.0f);
view.setAlpha(folder.hide || disabledIds.contains(folder.id) ? Helper.LOW_LIGHT : 1.0f);
if (textSize != 0)
tvName.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
@ -675,10 +676,11 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
}
}
AdapterFolder(Context context, LifecycleOwner owner, long account, IFolderSelectedListener listener) {
AdapterFolder(Context context, LifecycleOwner owner, long account, boolean show_hidden, IFolderSelectedListener listener) {
this.context = context;
this.inflater = LayoutInflater.from(context);
this.owner = owner;
this.show_hidden = show_hidden;
this.account = account;
this.listener = listener;
@ -699,6 +701,13 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
setHasStableIds(true);
}
void setShowHidden(boolean show_hidden) {
if (this.show_hidden != show_hidden) {
this.show_hidden = show_hidden;
set(all);
}
}
void setDisabled(List<Long> ids) {
disabledIds = ids;
}
@ -790,12 +799,13 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
List<TupleFolderEx> getHierarchical(List<TupleFolderEx> parents, int indentation) {
List<TupleFolderEx> result = new ArrayList<>();
for (TupleFolderEx parent : parents) {
parent.indentation = indentation;
result.add(parent);
if (!parent.collapsed && parent.child_refs != null)
result.addAll(getHierarchical(parent.child_refs, indentation + 1));
}
for (TupleFolderEx parent : parents)
if (!parent.hide || show_hidden) {
parent.indentation = indentation;
result.add(parent);
if (!parent.collapsed && parent.child_refs != null)
result.addAll(getHierarchical(parent.child_refs, indentation + 1));
}
return result;
}
@ -836,6 +846,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
TupleFolderEx p1 = f1.parent_ref;
TupleFolderEx p2 = f2.parent_ref;
while (p1 != null && p2 != null) {
if (p1.hide != p2.hide)
return false;
if (p1.collapsed != p2.collapsed)
return false;

@ -2961,7 +2961,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
LinearLayoutManager llm = new LinearLayoutManager(context);
rvFolder.setLayoutManager(llm);
final AdapterFolder adapter = new AdapterFolder(context, owner, data.message.account,
final AdapterFolder adapter = new AdapterFolder(context, owner, data.message.account, false,
new AdapterFolder.IFolderSelectedListener() {
@Override
public void onFolderSelected(TupleFolderEx folder) {

@ -221,6 +221,7 @@ public interface DaoFolder {
", unified = :unified" +
", navigation = :navigation" +
", notify = :notify" +
", hide = :hide" +
", synchronize = :synchronize" +
", poll = :poll" +
", download = :download" +
@ -230,7 +231,7 @@ public interface DaoFolder {
" WHERE id = :id")
int setFolderProperties(
long id,
String display, boolean unified, boolean navigation, boolean notify,
String display, boolean unified, boolean navigation, boolean notify, boolean hide,
boolean synchronize, boolean poll, boolean download,
int sync_days, int keep_days, boolean auto_delete);

@ -85,7 +85,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
public Boolean auto_delete = false;
public String display;
@NonNull
public Boolean hide = false; // obsolete
public Boolean hide = false;
@NonNull
public Boolean collapsed = false;
@NonNull
@ -289,6 +289,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
this.keep_days.equals(other.keep_days) &&
Objects.equals(this.display, other.display) &&
Objects.equals(this.order, other.order) &&
this.hide == other.hide &&
this.collapsed == other.collapsed &&
this.unified == other.unified &&
this.notify == other.notify &&
@ -322,6 +323,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
json.put("keep_days", keep_days);
json.put("auto_delete", auto_delete);
json.put("display", display);
json.put("hide", hide);
json.put("collapsed", collapsed);
json.put("unified", unified);
json.put("navigation", navigation);
@ -364,6 +366,9 @@ public class EntityFolder extends EntityOrder implements Serializable {
if (json.has("display") && !json.isNull("display"))
folder.display = json.getString("display");
if (json.has("hide"))
folder.hide = json.getBoolean("hide");
if (json.has("collapsed"))
folder.collapsed = json.getBoolean("collapsed");

@ -46,6 +46,7 @@ public class FragmentFolder extends FragmentBase {
private ViewGroup view;
private EditText etName;
private EditText etDisplay;
private CheckBox cbHide;
private CheckBox cbUnified;
private CheckBox cbNavigation;
private CheckBox cbNotify;
@ -87,6 +88,7 @@ public class FragmentFolder extends FragmentBase {
// Get controls
etName = view.findViewById(R.id.etName);
etDisplay = view.findViewById(R.id.etDisplay);
cbHide = view.findViewById(R.id.cbHide);
cbUnified = view.findViewById(R.id.cbUnified);
cbNavigation = view.findViewById(R.id.cbNavigation);
cbNotify = view.findViewById(R.id.cbNotify);
@ -151,6 +153,7 @@ public class FragmentFolder extends FragmentBase {
args.putLong("account", account);
args.putString("name", etName.getText().toString());
args.putString("display", etDisplay.getText().toString());
args.putBoolean("hide", cbHide.isChecked());
args.putBoolean("unified", cbUnified.isChecked());
args.putBoolean("navigation", cbNavigation.isChecked());
args.putBoolean("notify", cbNotify.getVisibility() == View.VISIBLE && cbNotify.isChecked());
@ -186,6 +189,7 @@ public class FragmentFolder extends FragmentBase {
long aid = args.getLong("account");
String name = args.getString("name");
String display = args.getString("display");
boolean hide = args.getBoolean("hide");
boolean unified = args.getBoolean("unified");
boolean navigation = args.getBoolean("navigation");
boolean notify = args.getBoolean("notify");
@ -224,6 +228,7 @@ public class FragmentFolder extends FragmentBase {
create.name = name;
create.display = display;
create.type = EntityFolder.USER;
create.hide = hide;
create.unified = unified;
create.navigation = navigation;
create.notify = notify;
@ -240,7 +245,7 @@ public class FragmentFolder extends FragmentBase {
Log.i("Updating folder=" + name);
db.folder().setFolderProperties(id,
display, unified, navigation, notify,
display, unified, navigation, notify, hide,
synchronize, poll, download,
sync_days, keep_days, auto_delete);
db.folder().setFolderError(id, null);
@ -403,6 +408,7 @@ public class FragmentFolder extends FragmentBase {
etName.setText(folder == null ? null : folder.name);
etDisplay.setText(folder == null ? null : folder.display);
etDisplay.setHint(folder == null ? null : Helper.localizeFolderName(getContext(), folder.name));
cbHide.setChecked(folder == null ? false : folder.hide);
cbUnified.setChecked(folder == null ? false : folder.unified);
cbNavigation.setChecked(folder == null ? false : folder.navigation);
cbNotify.setChecked(folder == null ? false : folder.notify);

@ -66,6 +66,7 @@ public class FragmentFolders extends FragmentBase {
private FloatingActionButton fabError;
private long account;
private boolean show_hidden = false;
private String searching = null;
private AdapterFolder adapter;
@ -143,7 +144,7 @@ public class FragmentFolders extends FragmentBase {
itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider));
rvFolder.addItemDecoration(itemDecorator);
adapter = new AdapterFolder(getContext(), getViewLifecycleOwner(), account, null);
adapter = new AdapterFolder(getContext(), getViewLifecycleOwner(), account, show_hidden, null);
rvFolder.setAdapter(adapter);
fab.setOnClickListener(new View.OnClickListener() {
@ -394,4 +395,27 @@ public class FragmentFolders extends FragmentBase {
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.menu_show_hidden).setChecked(show_hidden);
super.onPrepareOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_show_hidden:
onMenuShowHidden();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void onMenuShowHidden() {
show_hidden = !show_hidden;
getActivity().invalidateOptionsMenu();
adapter.setShowHidden(show_hidden);
}
}

@ -1869,7 +1869,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
LinearLayoutManager llm = new LinearLayoutManager(getContext());
rvFolder.setLayoutManager(llm);
final AdapterFolder adapter = new AdapterFolder(getContext(), getViewLifecycleOwner(), account,
final AdapterFolder adapter = new AdapterFolder(getContext(), getViewLifecycleOwner(), account, false,
new AdapterFolder.IFolderSelectedListener() {
@Override
public void onFolderSelected(TupleFolderEx folder) {

@ -58,6 +58,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDisplay" />
<CheckBox
android:id="@+id/cbHide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_hide_folder"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etDisplay" />
<CheckBox
android:id="@+id/cbUnified"
android:layout_width="wrap_content"
@ -65,7 +74,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_unified_folder"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etDisplay" />
app:layout_constraintTop_toBottomOf="@id/cbHide" />
<CheckBox
android:id="@+id/cbNavigation"

@ -8,4 +8,10 @@
android:title="@string/title_search"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="collapseActionView|always" />
<item
android:id="@+id/menu_show_hidden"
android:checkable="true"
android:title="@string/title_show_folders"
app:showAsAction="never" />
</menu>

@ -357,6 +357,8 @@
<string name="title_folder_name">Folder name</string>
<string name="title_display_name">Display name</string>
<string name="title_show_folders">Show hidden folders</string>
<string name="title_hide_folder">Hide folder</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…
Cancel
Save