Removed folder hiding

This commit is contained in:
M66B 2019-06-05 07:13:15 +02:00
parent ffa7a406f0
commit a3658a869c
10 changed files with 13 additions and 99 deletions

View File

@ -66,7 +66,6 @@ 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;
@ -143,42 +142,20 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
}
private void bindTo(final TupleFolderEx folder) {
boolean hidden = (folder.hide && !show_hidden);
boolean hidden = false;
int level = 0;
TupleFolderEx parent = folder.parent_ref;
while (parent != null) {
level++;
if (parent.collapsed || (parent.hide && !show_hidden))
if (parent.collapsed)
hidden = true;
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.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)
tvName.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
@ -222,9 +199,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
vwLevel.setLayoutParams(lp);
ivExpander.setImageLevel(folder.collapsed ? 1 /* more */ : 0 /* less */);
ivExpander.setVisibility(account < 0 || !root_childs_visible
ivExpander.setVisibility(account < 0
? View.GONE
: childs_visible ? View.VISIBLE : View.INVISIBLE);
: folder.child_refs.size() > 0 ? View.VISIBLE : View.INVISIBLE);
if (listener == null) {
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.inflater = LayoutInflater.from(context);
this.owner = owner;
this.account = account;
this.show_hidden = show_hidden;
this.listener = listener;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@ -794,13 +770,6 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
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 List<TupleFolderEx> prev = 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 p2 = f2.parent_ref;
while (p1 != null && p2 != null) {
if (p1.hide != p2.hide)
return false;
if (p1.collapsed != p2.collapsed)
return false;

View File

@ -2935,7 +2935,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, false,
final AdapterFolder adapter = new AdapterFolder(context, owner, data.message.account,
new AdapterFolder.IFolderSelectedListener() {
@Override
public void onFolderSelected(TupleFolderEx folder) {

View File

@ -221,7 +221,6 @@ public interface DaoFolder {
", unified = :unified" +
", navigation = :navigation" +
", notify = :notify" +
", hide = :hide" +
", synchronize = :synchronize" +
", poll = :poll" +
", download = :download" +
@ -231,7 +230,7 @@ public interface DaoFolder {
" WHERE id = :id")
int setFolderProperties(
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,
int sync_days, int keep_days, boolean auto_delete);

View File

@ -85,7 +85,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
public Boolean auto_delete = false;
public String display;
@NonNull
public Boolean hide = false;
public Boolean hide = false; // obsolete
@NonNull
public Boolean collapsed = false;
@NonNull
@ -290,7 +290,6 @@ 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 &&
@ -323,7 +322,6 @@ 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);
@ -363,8 +361,6 @@ 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");

View File

@ -46,7 +46,6 @@ 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;
@ -88,7 +87,6 @@ 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);
@ -153,7 +151,6 @@ 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());
@ -189,7 +186,6 @@ 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");
@ -227,7 +223,6 @@ public class FragmentFolder extends FragmentBase {
create.account = aid;
create.name = name;
create.display = display;
create.hide = hide;
create.type = EntityFolder.USER;
create.unified = unified;
create.navigation = navigation;
@ -245,7 +240,7 @@ public class FragmentFolder extends FragmentBase {
Log.i("Updating folder=" + name);
db.folder().setFolderProperties(id,
display, unified, navigation, notify, hide,
display, unified, navigation, notify,
synchronize, poll, download,
sync_days, keep_days, auto_delete);
db.folder().setFolderError(id, null);
@ -408,7 +403,6 @@ 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);

View File

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

View File

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

View File

@ -58,15 +58,6 @@
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"
@ -74,7 +65,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/etDisplay" />
<CheckBox
android:id="@+id/cbNavigation"

View File

@ -8,10 +8,4 @@
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>

View File

@ -347,8 +347,6 @@
<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>