Quick rule edit

This commit is contained in:
M66B 2020-12-04 12:15:41 +01:00
parent 5645ad4f12
commit 16cb2e9b31
2 changed files with 25 additions and 17 deletions

View File

@ -117,7 +117,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private ImageView ivUnified;
private ImageView ivSubscribed;
private ImageView ivRule;
private ImageButton ibRule;
private ImageView ivNotify;
private TextView tvName;
private TextView tvMessages;
@ -155,7 +155,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
ivUnified = itemView.findViewById(R.id.ivUnified);
ivSubscribed = itemView.findViewById(R.id.ivSubscribed);
ivRule = itemView.findViewById(R.id.ivRule);
ibRule = itemView.findViewById(R.id.ibRule);
ivNotify = itemView.findViewById(R.id.ivNotify);
tvName = itemView.findViewById(R.id.tvName);
tvMessages = itemView.findViewById(R.id.tvMessages);
@ -181,6 +181,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private void wire() {
view.setOnClickListener(this);
ibExpander.setOnClickListener(this);
if (ibRule != null)
ibRule.setOnClickListener(this);
if (tvFlagged != null)
tvFlagged.setOnClickListener(this);
if (ibFlagged != null)
@ -194,6 +196,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private void unwire() {
view.setOnClickListener(null);
ibExpander.setOnClickListener(null);
if (ibRule != null)
ibRule.setOnClickListener(null);
if (tvFlagged != null)
tvFlagged.setOnClickListener(null);
if (ibFlagged != null)
@ -270,7 +274,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
if (listener == null && folder.selectable) {
ivUnified.setVisibility((account > 0 || primary) && folder.unified ? View.VISIBLE : View.GONE);
ivSubscribed.setVisibility(subscriptions && folder.subscribed != null && folder.subscribed ? View.VISIBLE : View.GONE);
ivRule.setVisibility(folder.rules > 0 ? View.VISIBLE : View.GONE);
ibRule.setVisibility(folder.rules > 0 ? View.VISIBLE : View.GONE);
ivNotify.setVisibility(folder.notify ? View.VISIBLE : View.GONE);
}
@ -389,6 +393,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
case R.id.ibExpander:
onCollapse(folder);
break;
case R.id.ibRule:
onActionEditRules(folder);
break;
case R.id.tvFlagged:
case R.id.ibFlagged:
onFlagged(folder);
@ -445,6 +452,16 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
}.execute(context, owner, args, "folder:collapse");
}
private void onActionEditRules(TupleFolderEx folder) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_EDIT_RULES)
.putExtra("account", folder.account)
.putExtra("protocol", folder.accountProtocol)
.putExtra("folder", folder.id)
.putExtra("type", folder.type));
}
private void onFlagged(TupleFolderEx folder) {
BoundaryCallbackMessages.SearchCriteria criteria = new BoundaryCallbackMessages.SearchCriteria();
criteria.in_senders = false;
@ -626,7 +643,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
return true;
case R.string.title_edit_rules:
onActionEditRules();
onActionEditRules(folder);
return true;
case R.string.title_edit_properties:
@ -822,16 +839,6 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
ask.show(parentFragment.getParentFragmentManager(), "folder:empty");
}
private void onActionEditRules() {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_EDIT_RULES)
.putExtra("account", folder.account)
.putExtra("protocol", folder.accountProtocol)
.putExtra("folder", folder.id)
.putExtra("type", folder.type));
}
private void onActionEditProperties() {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(

View File

@ -89,10 +89,11 @@
app:layout_constraintTop_toTopOf="@+id/tvName"
app:srcCompat="@drawable/twotone_bookmark_24" />
<ImageView
android:id="@+id/ivRule"
<ImageButton
android:id="@+id/ibRule"
android:layout_width="30dp"
android:layout_height="24dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_edit_rules"
android:paddingEnd="6dp"
app:layout_constraintBottom_toBottomOf="@+id/tvName"
@ -107,7 +108,7 @@
android:contentDescription="@string/title_legend_notify"
android:paddingEnd="6dp"
app:layout_constraintBottom_toBottomOf="@+id/tvName"
app:layout_constraintStart_toEndOf="@id/ivRule"
app:layout_constraintStart_toEndOf="@id/ibRule"
app:layout_constraintTop_toTopOf="@+id/tvName"
app:srcCompat="@drawable/twotone_notifications_24" />