Added button to hide message tools

This commit is contained in:
M66B 2020-06-24 20:18:08 +02:00
parent 2301ce32f2
commit 3767cd121d
5 changed files with 104 additions and 26 deletions

View File

@ -415,6 +415,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ImageButton ibTrash;
private ImageButton ibJunk;
private ImageButton ibInbox;
private ImageButton ibTools;
private ImageButton ibMore;
private TextView tvSignedData;
@ -615,6 +616,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibTrash = vsBody.findViewById(R.id.ibTrash);
ibJunk = vsBody.findViewById(R.id.ibJunk);
ibInbox = vsBody.findViewById(R.id.ibInbox);
ibTools = vsBody.findViewById(R.id.ibTools);
ibMore = vsBody.findViewById(R.id.ibMore);
tvSignedData = vsBody.findViewById(R.id.tvSignedData);
@ -704,6 +706,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibTrash.setOnClickListener(this);
ibJunk.setOnClickListener(this);
ibInbox.setOnClickListener(this);
ibTools.setOnClickListener(this);
ibMore.setOnClickListener(this);
ibDownloading.setOnClickListener(this);
@ -790,6 +793,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibTrash.setOnClickListener(null);
ibJunk.setOnClickListener(null);
ibInbox.setOnClickListener(null);
ibTools.setOnClickListener(null);
ibMore.setOnClickListener(null);
ibDownloading.setOnClickListener(null);
@ -1283,6 +1287,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibTrash.setVisibility(View.GONE);
ibJunk.setVisibility(View.GONE);
ibInbox.setVisibility(View.GONE);
ibTools.setVisibility(View.GONE);
ibMore.setVisibility(View.GONE);
tvSignedData.setVisibility(View.GONE);
@ -1412,6 +1417,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibTrash.setVisibility(View.GONE);
ibJunk.setVisibility(View.GONE);
ibInbox.setVisibility(View.GONE);
ibTools.setVisibility(View.GONE);
ibMore.setVisibility(EntityFolder.OUTBOX.equals(message.folderType) ? View.GONE : View.VISIBLE);
tvSignedData.setVisibility(View.GONE);
@ -1468,6 +1474,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
});
// Setup actions
setupTools(message, scroll, true);
}
private void setupTools(final TupleMessageEx message, final boolean scroll, final boolean bind) {
Bundle sargs = new Bundle();
sargs.putLong("id", message.id);
sargs.putLong("account", message.account);
@ -1525,23 +1535,27 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean button_rule = prefs.getBoolean("button_rule", false);
boolean expand_all = prefs.getBoolean("expand_all", false);
boolean expand_one = prefs.getBoolean("expand_one", true);
boolean tools = prefs.getBoolean("message_tools", true);
ibTrash.setTag(delete);
ibRule.setVisibility(button_rule && !outbox &&
ibRule.setVisibility(tools && button_rule && !outbox &&
message.accountProtocol == EntityAccount.TYPE_IMAP ? View.VISIBLE : View.GONE);
ibUnsubscribe.setVisibility(message.unsubscribe == null ? View.GONE : View.VISIBLE);
ibAnswer.setVisibility(outbox || (!expand_all && expand_one) ? View.GONE : View.VISIBLE);
ibMove.setVisibility(move && button_move ? View.VISIBLE : View.GONE);
ibArchive.setVisibility(archive && button_archive_trash ? View.VISIBLE : View.GONE);
ibTrash.setVisibility(trash && button_archive_trash ? View.VISIBLE : View.GONE);
ibJunk.setVisibility(junk ? View.VISIBLE : View.GONE);
ibInbox.setVisibility(inbox ? View.VISIBLE : View.GONE);
ibUnsubscribe.setVisibility(!tools || message.unsubscribe == null ? View.GONE : View.VISIBLE);
ibAnswer.setVisibility(!tools || outbox || (!expand_all && expand_one) ? View.GONE : View.VISIBLE);
ibMove.setVisibility(tools && move && button_move ? View.VISIBLE : View.GONE);
ibArchive.setVisibility(tools && archive && button_archive_trash ? View.VISIBLE : View.GONE);
ibTrash.setVisibility(tools && trash && button_archive_trash ? View.VISIBLE : View.GONE);
ibJunk.setVisibility(tools && junk ? View.VISIBLE : View.GONE);
ibInbox.setVisibility(tools && inbox ? View.VISIBLE : View.GONE);
ibTools.setImageLevel(tools ? 0 : 1);
ibTools.setVisibility(View.VISIBLE);
ibTrashBottom.setVisibility(trash && button_archive_trash ? View.VISIBLE : View.GONE);
ibArchiveBottom.setVisibility(archive && button_archive_trash ? View.VISIBLE : View.GONE);
ibTrashBottom.setVisibility(tools && trash && button_archive_trash ? View.VISIBLE : View.GONE);
ibArchiveBottom.setVisibility(tools && archive && button_archive_trash ? View.VISIBLE : View.GONE);
bindBody(message, scroll);
if (bind)
bindBody(message, scroll);
}
@Override
@ -2745,6 +2759,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
case R.id.ibInbox:
onActionInbox(message);
break;
case R.id.ibTools:
onActionTools(message);
break;
case R.id.ibMore:
onActionMore(message);
break;
@ -3634,6 +3651,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
properties.move(message.id, EntityFolder.INBOX);
}
private void onActionTools(TupleMessageEx message) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean message_tools = !prefs.getBoolean("message_tools", true);
prefs.edit().putBoolean("message_tools", message_tools).apply();
setupTools(message, false, false);
}
private void onActionMore(TupleMessageEx message) {
boolean show_headers = properties.getValue("headers", message.id);
boolean full = properties.getValue("full", message.id);

View File

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<group
android:pivotX="12.0"
android:pivotY="12.0"
android:rotation="-90">
<path
android:fillColor="@android:color/white"
android:pathData="M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14z" />
</group>
</vector>

View File

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<group
android:pivotX="12.0"
android:pivotY="12.0"
android:rotation="-90">
<path
android:fillColor="@android:color/white"
android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z" />
</group>
</vector>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/baseline_expand_hor_less_24"
android:maxLevel="0" />
<item
android:drawable="@drawable/baseline_expand_hor_more_24"
android:maxLevel="1" />
</level-list>

View File

@ -23,19 +23,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparator" />
<androidx.constraintlayout.helper.widget.Flow
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="3dp"
app:constraint_referenced_ids="ibMore,ibInbox,ibJunk,ibTrash,ibArchive,ibMove,ibAnswer,ibUnsubscribe,ibRule,ibUndo"
app:flow_horizontalBias="0"
app:flow_horizontalGap="3dp"
app:flow_horizontalStyle="packed"
app:flow_wrapMode="chain"
app:layout_constraintEnd_toStartOf="@+id/ibVerify"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparator" />
<ImageButton
android:id="@+id/ibMore"
android:layout_width="36dp"
@ -45,8 +32,36 @@
android:padding="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_more"
app:srcCompat="@drawable/baseline_more_horiz_24"
tools:ignore="MissingConstraints" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparator"
app:srcCompat="@drawable/baseline_more_horiz_24" />
<ImageButton
android:id="@+id/ibTools"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_more"
android:padding="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_legend_expander"
app:layout_constraintStart_toEndOf="@+id/ibMore"
app:layout_constraintTop_toBottomOf="@id/vSeparator"
app:srcCompat="@drawable/expander_hor" />
<androidx.constraintlayout.helper.widget.Flow
android:id="@+id/ibFlow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="3dp"
app:constraint_referenced_ids="ibInbox,ibJunk,ibTrash,ibArchive,ibMove,ibAnswer,ibUnsubscribe,ibRule,ibUndo"
app:flow_horizontalBias="0"
app:flow_horizontalGap="3dp"
app:flow_horizontalStyle="packed"
app:flow_wrapMode="chain"
app:layout_constraintEnd_toStartOf="@+id/ibVerify"
app:layout_constraintStart_toEndOf="@+id/ibTools"
app:layout_constraintTop_toBottomOf="@id/vSeparator" />
<ImageButton
android:id="@+id/ibJunk"