Added optional message print icon button

This commit is contained in:
M66B 2020-06-28 14:48:47 +02:00
parent 0de66f8bf8
commit 22612c08ce
4 changed files with 47 additions and 5 deletions

View File

@ -412,6 +412,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ImageButton ibUndo; private ImageButton ibUndo;
private ImageButton ibRule; private ImageButton ibRule;
private ImageButton ibUnsubscribe; private ImageButton ibUnsubscribe;
private ImageButton ibPrint;
private ImageButton ibAnswer; private ImageButton ibAnswer;
private ImageButton ibLabels; private ImageButton ibLabels;
private ImageButton ibCopy; private ImageButton ibCopy;
@ -616,6 +617,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibUndo = vsBody.findViewById(R.id.ibUndo); ibUndo = vsBody.findViewById(R.id.ibUndo);
ibRule = vsBody.findViewById(R.id.ibRule); ibRule = vsBody.findViewById(R.id.ibRule);
ibUnsubscribe = vsBody.findViewById(R.id.ibUnsubscribe); ibUnsubscribe = vsBody.findViewById(R.id.ibUnsubscribe);
ibPrint = vsBody.findViewById(R.id.ibPrint);
ibAnswer = vsBody.findViewById(R.id.ibAnswer); ibAnswer = vsBody.findViewById(R.id.ibAnswer);
ibLabels = vsBody.findViewById(R.id.ibLabels); ibLabels = vsBody.findViewById(R.id.ibLabels);
ibCopy = vsBody.findViewById(R.id.ibCopy); ibCopy = vsBody.findViewById(R.id.ibCopy);
@ -703,11 +705,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibFull.setOnClickListener(this); ibFull.setOnClickListener(this);
ibImages.setOnClickListener(this); ibImages.setOnClickListener(this);
ibRule.setOnClickListener(this);
ibUnsubscribe.setOnClickListener(this);
ibDecrypt.setOnClickListener(this); ibDecrypt.setOnClickListener(this);
ibVerify.setOnClickListener(this); ibVerify.setOnClickListener(this);
ibUndo.setOnClickListener(this); ibUndo.setOnClickListener(this);
ibRule.setOnClickListener(this);
ibUnsubscribe.setOnClickListener(this);
ibPrint.setOnClickListener(this);
ibAnswer.setOnClickListener(this); ibAnswer.setOnClickListener(this);
ibLabels.setOnClickListener(this); ibLabels.setOnClickListener(this);
ibCopy.setOnClickListener(this); ibCopy.setOnClickListener(this);
@ -792,11 +795,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibFull.setOnClickListener(null); ibFull.setOnClickListener(null);
ibImages.setOnClickListener(null); ibImages.setOnClickListener(null);
ibRule.setOnClickListener(null);
ibUnsubscribe.setOnClickListener(null);
ibDecrypt.setOnClickListener(null); ibDecrypt.setOnClickListener(null);
ibVerify.setOnClickListener(null); ibVerify.setOnClickListener(null);
ibUndo.setOnClickListener(null); ibUndo.setOnClickListener(null);
ibRule.setOnClickListener(null);
ibUnsubscribe.setOnClickListener(null);
ibPrint.setOnClickListener(null);
ibAnswer.setOnClickListener(null); ibAnswer.setOnClickListener(null);
ibLabels.setOnClickListener(null); ibLabels.setOnClickListener(null);
ibCopy.setOnClickListener(null); ibCopy.setOnClickListener(null);
@ -1267,6 +1271,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibUndo.setVisibility(View.GONE); ibUndo.setVisibility(View.GONE);
ibRule.setVisibility(View.GONE); ibRule.setVisibility(View.GONE);
ibUnsubscribe.setVisibility(View.GONE); ibUnsubscribe.setVisibility(View.GONE);
ibPrint.setVisibility(View.GONE);
ibAnswer.setVisibility(View.GONE); ibAnswer.setVisibility(View.GONE);
ibLabels.setVisibility(View.GONE); ibLabels.setVisibility(View.GONE);
ibCopy.setVisibility(View.GONE); ibCopy.setVisibility(View.GONE);
@ -1399,6 +1404,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibUndo.setVisibility(View.GONE); ibUndo.setVisibility(View.GONE);
ibRule.setVisibility(View.GONE); ibRule.setVisibility(View.GONE);
ibUnsubscribe.setVisibility(View.GONE); ibUnsubscribe.setVisibility(View.GONE);
ibPrint.setVisibility(View.GONE);
ibAnswer.setVisibility(View.GONE); ibAnswer.setVisibility(View.GONE);
ibLabels.setVisibility(View.GONE); ibLabels.setVisibility(View.GONE);
ibCopy.setVisibility(View.GONE); ibCopy.setVisibility(View.GONE);
@ -1536,6 +1542,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean button_archive = prefs.getBoolean("button_archive", true); boolean button_archive = prefs.getBoolean("button_archive", true);
boolean button_move = prefs.getBoolean("button_move", true); boolean button_move = prefs.getBoolean("button_move", true);
boolean button_copy = prefs.getBoolean("button_copy", false); boolean button_copy = prefs.getBoolean("button_copy", false);
boolean button_print = prefs.getBoolean("button_print", false);
boolean button_unsubscribe = prefs.getBoolean("button_unsubscribe", true); boolean button_unsubscribe = prefs.getBoolean("button_unsubscribe", true);
boolean button_rule = prefs.getBoolean("button_rule", false); boolean button_rule = prefs.getBoolean("button_rule", false);
@ -1545,6 +1552,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibRule.setVisibility(tools && button_rule && !outbox && ibRule.setVisibility(tools && button_rule && !outbox &&
message.accountProtocol == EntityAccount.TYPE_IMAP ? View.VISIBLE : View.GONE); message.accountProtocol == EntityAccount.TYPE_IMAP ? View.VISIBLE : View.GONE);
ibUnsubscribe.setVisibility(tools && button_unsubscribe && message.unsubscribe != null ? View.VISIBLE : View.GONE); ibUnsubscribe.setVisibility(tools && button_unsubscribe && message.unsubscribe != null ? View.VISIBLE : View.GONE);
ibPrint.setVisibility(tools && button_print && hasWebView && message.content && Helper.canPrint(context) ? View.VISIBLE : View.GONE);
ibAnswer.setVisibility(!tools || outbox || (!expand_all && expand_one) ? View.GONE : View.VISIBLE); ibAnswer.setVisibility(!tools || outbox || (!expand_all && expand_one) ? View.GONE : View.VISIBLE);
ibLabels.setVisibility(tools && labels_header && labels && !inTrash && !inJunk && !outbox ? View.VISIBLE : View.GONE); ibLabels.setVisibility(tools && labels_header && labels && !inTrash && !inJunk && !outbox ? View.VISIBLE : View.GONE);
ibCopy.setVisibility(tools && button_copy && move ? View.VISIBLE : View.GONE); ibCopy.setVisibility(tools && button_copy && move ? View.VISIBLE : View.GONE);
@ -2750,6 +2758,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
case R.id.ibUnsubscribe: case R.id.ibUnsubscribe:
onActionUnsubscribe(message); onActionUnsubscribe(message);
break; break;
case R.id.ibPrint:
onMenuPrint(message);
break;
case R.id.ibAnswer: case R.id.ibAnswer:
onActionAnswer(message, ibAnswer); onActionAnswer(message, ibAnswer);
break; break;
@ -3745,6 +3756,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean button_archive = prefs.getBoolean("button_archive", true); boolean button_archive = prefs.getBoolean("button_archive", true);
boolean button_move = prefs.getBoolean("button_move", true); boolean button_move = prefs.getBoolean("button_move", true);
boolean button_copy = prefs.getBoolean("button_copy", false); boolean button_copy = prefs.getBoolean("button_copy", false);
boolean button_print = prefs.getBoolean("button_print", false);
boolean button_unsubscribe = prefs.getBoolean("button_unsubscribe", true); boolean button_unsubscribe = prefs.getBoolean("button_unsubscribe", true);
boolean button_rule = prefs.getBoolean("button_rule", false); boolean button_rule = prefs.getBoolean("button_rule", false);
@ -3757,6 +3769,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu.getMenu().findItem(R.id.menu_button_archive).setChecked(button_archive); popupMenu.getMenu().findItem(R.id.menu_button_archive).setChecked(button_archive);
popupMenu.getMenu().findItem(R.id.menu_button_move).setChecked(button_move); popupMenu.getMenu().findItem(R.id.menu_button_move).setChecked(button_move);
popupMenu.getMenu().findItem(R.id.menu_button_copy).setChecked(button_copy); popupMenu.getMenu().findItem(R.id.menu_button_copy).setChecked(button_copy);
popupMenu.getMenu().findItem(R.id.menu_button_print).setChecked(button_print);
popupMenu.getMenu().findItem(R.id.menu_button_unsubscribe).setChecked(button_unsubscribe); popupMenu.getMenu().findItem(R.id.menu_button_unsubscribe).setChecked(button_unsubscribe);
popupMenu.getMenu().findItem(R.id.menu_button_rule).setChecked(button_rule); popupMenu.getMenu().findItem(R.id.menu_button_rule).setChecked(button_rule);
@ -3830,6 +3843,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
case R.id.menu_button_copy: case R.id.menu_button_copy:
onMenuButton(message, "copy", target.isChecked()); onMenuButton(message, "copy", target.isChecked());
return true; return true;
case R.id.menu_button_print:
onMenuButton(message, "print", target.isChecked());
return true;
case R.id.menu_button_unsubscribe: case R.id.menu_button_unsubscribe:
onMenuButton(message, "unsubscribe", target.isChecked()); onMenuButton(message, "unsubscribe", target.isChecked());
return true; return true;

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M19,8L5,8c-1.66,0 -3,1.34 -3,3v6h4v4h12v-4h4v-6c0,-1.66 -1.34,-3 -3,-3zM16,19L8,19v-5h8v5zM19,12c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1zM18,3L6,3v4h12L18,3z"/>
</vector>

View File

@ -41,7 +41,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="3dp" android:layout_marginEnd="3dp"
app:constraint_referenced_ids="ibMore,ibInbox,ibJunk,ibTrash,ibArchive,ibMove,ibCopy,ibLabels,ibAnswer,ibUnsubscribe,ibRule,ibUndo" app:constraint_referenced_ids="ibMore,ibInbox,ibJunk,ibTrash,ibArchive,ibMove,ibCopy,ibLabels,ibAnswer,ibPrint,ibUnsubscribe,ibRule,ibUndo"
app:flow_horizontalBias="0" app:flow_horizontalBias="0"
app:flow_horizontalGap="3dp" app:flow_horizontalGap="3dp"
app:flow_horizontalStyle="packed" app:flow_horizontalStyle="packed"
@ -156,6 +156,18 @@
app:srcCompat="@drawable/baseline_reply_24" app:srcCompat="@drawable/baseline_reply_24"
tools:ignore="MissingConstraints" /> tools:ignore="MissingConstraints" />
<ImageButton
android:id="@+id/ibPrint"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_print"
android:padding="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_print"
app:srcCompat="@drawable/baseline_print_24"
tools:ignore="MissingConstraints" />
<ImageButton <ImageButton
android:id="@+id/ibUnsubscribe" android:id="@+id/ibUnsubscribe"
android:layout_width="36dp" android:layout_width="36dp"

View File

@ -28,6 +28,10 @@
android:id="@+id/menu_button_copy" android:id="@+id/menu_button_copy"
android:checkable="true" android:checkable="true"
android:title="@string/title_copy_btn" /> android:title="@string/title_copy_btn" />
<item
android:id="@+id/menu_button_print"
android:checkable="true"
android:title="@string/title_print" />
<item <item
android:id="@+id/menu_button_unsubscribe" android:id="@+id/menu_button_unsubscribe"
android:checkable="true" android:checkable="true"