Removed folder hiding

pull/156/head
M66B 6 years ago
parent ffa7a406f0
commit a3658a869c

@ -66,7 +66,6 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private Context context; private Context context;
private LayoutInflater inflater; private LayoutInflater inflater;
private LifecycleOwner owner; private LifecycleOwner owner;
private boolean show_hidden;
private long account; private long account;
private IFolderSelectedListener listener; private IFolderSelectedListener listener;
@ -143,42 +142,20 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
} }
private void bindTo(final TupleFolderEx folder) { private void bindTo(final TupleFolderEx folder) {
boolean hidden = (folder.hide && !show_hidden); boolean hidden = false;
int level = 0; int level = 0;
TupleFolderEx parent = folder.parent_ref; TupleFolderEx parent = folder.parent_ref;
while (parent != null) { while (parent != null) {
level++; level++;
if (parent.collapsed || (parent.hide && !show_hidden)) if (parent.collapsed)
hidden = true; hidden = true;
parent = parent.parent_ref; parent = parent.parent_ref;
} }
boolean root_childs_visible = false;
if (folder.parent_ref != null &&
folder.parent_ref.parent_ref == null &&
folder.parent_ref.child_refs != null) {
for (TupleFolderEx root : folder.parent_ref.child_refs)
if ((!root.hide || show_hidden) && root.child_refs != null)
for (TupleFolderEx child : root.child_refs)
if (!child.hide || show_hidden) {
root_childs_visible = true;
break;
}
} else
root_childs_visible = true;
boolean childs_visible = false;
if (folder.child_refs != null)
for (TupleFolderEx child : folder.child_refs)
if (!child.hide || show_hidden) {
childs_visible = true;
break;
}
view.setVisibility(hidden ? View.GONE : View.VISIBLE); view.setVisibility(hidden ? View.GONE : View.VISIBLE);
view.setActivated(folder.tbc != null || folder.tbd != null); view.setActivated(folder.tbc != null || folder.tbd != null);
view.setAlpha(folder.hide || disabledIds.contains(folder.id) ? Helper.LOW_LIGHT : 1.0f); view.setAlpha(disabledIds.contains(folder.id) ? Helper.LOW_LIGHT : 1.0f);
if (textSize != 0) if (textSize != 0)
tvName.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); tvName.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
@ -222,9 +199,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
vwLevel.setLayoutParams(lp); vwLevel.setLayoutParams(lp);
ivExpander.setImageLevel(folder.collapsed ? 1 /* more */ : 0 /* less */); ivExpander.setImageLevel(folder.collapsed ? 1 /* more */ : 0 /* less */);
ivExpander.setVisibility(account < 0 || !root_childs_visible ivExpander.setVisibility(account < 0
? View.GONE ? View.GONE
: childs_visible ? View.VISIBLE : View.INVISIBLE); : folder.child_refs.size() > 0 ? View.VISIBLE : View.INVISIBLE);
if (listener == null) { if (listener == null) {
ivNotify.setVisibility(folder.notify ? View.VISIBLE : View.GONE); ivNotify.setVisibility(folder.notify ? View.VISIBLE : View.GONE);
@ -685,12 +662,11 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
} }
} }
AdapterFolder(Context context, LifecycleOwner owner, long account, boolean show_hidden, IFolderSelectedListener listener) { AdapterFolder(Context context, LifecycleOwner owner, long account, IFolderSelectedListener listener) {
this.context = context; this.context = context;
this.inflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.owner = owner; this.owner = owner;
this.account = account; this.account = account;
this.show_hidden = show_hidden;
this.listener = listener; this.listener = listener;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@ -794,13 +770,6 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
return result; return result;
} }
void setShowHidden(boolean show_hidden) {
if (this.show_hidden != show_hidden) {
this.show_hidden = show_hidden;
notifyDataSetChanged();
}
}
private class DiffCallback extends DiffUtil.Callback { private class DiffCallback extends DiffUtil.Callback {
private List<TupleFolderEx> prev = new ArrayList<>(); private List<TupleFolderEx> prev = new ArrayList<>();
private List<TupleFolderEx> next = new ArrayList<>(); private List<TupleFolderEx> next = new ArrayList<>();
@ -837,9 +806,6 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
TupleFolderEx p1 = f1.parent_ref; TupleFolderEx p1 = f1.parent_ref;
TupleFolderEx p2 = f2.parent_ref; TupleFolderEx p2 = f2.parent_ref;
while (p1 != null && p2 != null) { while (p1 != null && p2 != null) {
if (p1.hide != p2.hide)
return false;
if (p1.collapsed != p2.collapsed) if (p1.collapsed != p2.collapsed)
return false; return false;

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

@ -221,7 +221,6 @@ public interface DaoFolder {
", unified = :unified" + ", unified = :unified" +
", navigation = :navigation" + ", navigation = :navigation" +
", notify = :notify" + ", notify = :notify" +
", hide = :hide" +
", synchronize = :synchronize" + ", synchronize = :synchronize" +
", poll = :poll" + ", poll = :poll" +
", download = :download" + ", download = :download" +
@ -231,7 +230,7 @@ public interface DaoFolder {
" WHERE id = :id") " WHERE id = :id")
int setFolderProperties( int setFolderProperties(
long id, long id,
String display, boolean unified, boolean navigation, boolean notify, boolean hide, String display, boolean unified, boolean navigation, boolean notify,
boolean synchronize, boolean poll, boolean download, boolean synchronize, boolean poll, boolean download,
int sync_days, int keep_days, boolean auto_delete); 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 Boolean auto_delete = false;
public String display; public String display;
@NonNull @NonNull
public Boolean hide = false; public Boolean hide = false; // obsolete
@NonNull @NonNull
public Boolean collapsed = false; public Boolean collapsed = false;
@NonNull @NonNull
@ -290,7 +290,6 @@ public class EntityFolder extends EntityOrder implements Serializable {
this.keep_days.equals(other.keep_days) && this.keep_days.equals(other.keep_days) &&
Objects.equals(this.display, other.display) && Objects.equals(this.display, other.display) &&
Objects.equals(this.order, other.order) && Objects.equals(this.order, other.order) &&
this.hide == other.hide &&
this.collapsed == other.collapsed && this.collapsed == other.collapsed &&
this.unified == other.unified && this.unified == other.unified &&
this.notify == other.notify && this.notify == other.notify &&
@ -323,7 +322,6 @@ public class EntityFolder extends EntityOrder implements Serializable {
json.put("keep_days", keep_days); json.put("keep_days", keep_days);
json.put("auto_delete", auto_delete); json.put("auto_delete", auto_delete);
json.put("display", display); json.put("display", display);
json.put("hide", hide);
json.put("collapsed", collapsed); json.put("collapsed", collapsed);
json.put("unified", unified); json.put("unified", unified);
json.put("navigation", navigation); json.put("navigation", navigation);
@ -363,8 +361,6 @@ public class EntityFolder extends EntityOrder implements Serializable {
if (json.has("display") && !json.isNull("display")) if (json.has("display") && !json.isNull("display"))
folder.display = json.getString("display"); folder.display = json.getString("display");
if (json.has("hide"))
folder.hide = json.getBoolean("hide");
if (json.has("collapsed")) if (json.has("collapsed"))
folder.collapsed = json.getBoolean("collapsed"); folder.collapsed = json.getBoolean("collapsed");

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

@ -66,7 +66,6 @@ public class FragmentFolders extends FragmentBase {
private FloatingActionButton fabError; private FloatingActionButton fabError;
private long account; private long account;
private boolean show_hidden = false;
private String searching = null; private String searching = null;
private AdapterFolder adapter; private AdapterFolder adapter;
@ -144,7 +143,7 @@ public class FragmentFolders extends FragmentBase {
itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider)); itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider));
rvFolder.addItemDecoration(itemDecorator); rvFolder.addItemDecoration(itemDecorator);
adapter = new AdapterFolder(getContext(), getViewLifecycleOwner(), account, show_hidden, null); adapter = new AdapterFolder(getContext(), getViewLifecycleOwner(), account, null);
rvFolder.setAdapter(adapter); rvFolder.setAdapter(adapter);
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
@ -384,27 +383,4 @@ public class FragmentFolders extends FragmentBase {
super.onCreateOptionsMenu(menu, inflater); 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);
}
} }

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

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

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

@ -347,8 +347,6 @@
<string name="title_folder_name">Folder name</string> <string name="title_folder_name">Folder name</string>
<string name="title_display_name">Display 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_unified_folder">Show in unified inbox</string>
<string name="title_navigation_folder">Show in navigation menu</string> <string name="title_navigation_folder">Show in navigation menu</string>
<string name="title_synchronize_folder">Synchronize (receive messages)</string> <string name="title_synchronize_folder">Synchronize (receive messages)</string>

Loading…
Cancel
Save