Show original button instead of menu

This commit is contained in:
M66B 2018-10-31 17:19:07 +00:00
parent 6cb02410b6
commit 4ccc417f9d
4 changed files with 45 additions and 20 deletions

View File

@ -156,6 +156,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
private BottomNavigationView bnvActions; private BottomNavigationView bnvActions;
private View vSeparatorBody; private View vSeparatorBody;
private Button btnHtml;
private Button btnImages; private Button btnImages;
private TextView tvBody; private TextView tvBody;
private ProgressBar pbBody; private ProgressBar pbBody;
@ -203,6 +204,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
bnvActions = itemView.findViewById(R.id.bnvActions); bnvActions = itemView.findViewById(R.id.bnvActions);
vSeparatorBody = itemView.findViewById(R.id.vSeparatorBody); vSeparatorBody = itemView.findViewById(R.id.vSeparatorBody);
btnHtml = itemView.findViewById(R.id.btnHtml);
btnImages = itemView.findViewById(R.id.btnImages); btnImages = itemView.findViewById(R.id.btnImages);
tvBody = itemView.findViewById(R.id.tvBody); tvBody = itemView.findViewById(R.id.tvBody);
pbBody = itemView.findViewById(R.id.pbBody); pbBody = itemView.findViewById(R.id.pbBody);
@ -227,6 +229,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
ivAddContact.setOnClickListener(this); ivAddContact.setOnClickListener(this);
bnvActions.setOnNavigationItemSelectedListener(this); bnvActions.setOnNavigationItemSelectedListener(this);
btnHtml.setOnClickListener(this);
btnImages.setOnClickListener(this); btnImages.setOnClickListener(this);
} }
@ -234,6 +237,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
itemView.setOnClickListener(null); itemView.setOnClickListener(null);
ivAddContact.setOnClickListener(null); ivAddContact.setOnClickListener(null);
bnvActions.setOnNavigationItemSelectedListener(null); bnvActions.setOnNavigationItemSelectedListener(null);
btnHtml.setOnClickListener(null);
btnImages.setOnClickListener(null); btnImages.setOnClickListener(null);
} }
@ -256,6 +260,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
pbHeaders.setVisibility(View.GONE); pbHeaders.setVisibility(View.GONE);
bnvActions.setVisibility(View.GONE); bnvActions.setVisibility(View.GONE);
vSeparatorBody.setVisibility(View.GONE); vSeparatorBody.setVisibility(View.GONE);
btnHtml.setVisibility(View.GONE);
btnImages.setVisibility(View.GONE); btnImages.setVisibility(View.GONE);
pbBody.setVisibility(View.GONE); pbBody.setVisibility(View.GONE);
grpHeaders.setVisibility(View.GONE); grpHeaders.setVisibility(View.GONE);
@ -366,6 +371,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
grpHeaders.setVisibility(show_headers && show_expanded ? View.VISIBLE : View.GONE); grpHeaders.setVisibility(show_headers && show_expanded ? View.VISIBLE : View.GONE);
bnvActions.setVisibility(View.GONE); bnvActions.setVisibility(View.GONE);
vSeparatorBody.setVisibility(View.GONE); vSeparatorBody.setVisibility(View.GONE);
btnHtml.setVisibility(View.GONE);
btnImages.setVisibility(View.GONE); btnImages.setVisibility(View.GONE);
pbBody.setVisibility(View.GONE); pbBody.setVisibility(View.GONE);
grpAttachments.setVisibility(message.attachments > 0 && show_expanded ? View.VISIBLE : View.GONE); grpAttachments.setVisibility(message.attachments > 0 && show_expanded ? View.VISIBLE : View.GONE);
@ -483,7 +489,13 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
if (view.getId() == R.id.ivAddContact) if (view.getId() == R.id.ivAddContact)
onAddContact(message); onAddContact(message);
else if (viewType == ViewType.THREAD) { else if (viewType == ViewType.THREAD) {
if (view.getId() == R.id.btnImages) if (view.getId() == R.id.btnHtml) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_FULL)
.putExtra("id", message.id)
.putExtra("from", MessageHelper.getFormattedAddresses(message.from, true)));
} else if (view.getId() == R.id.btnImages)
onShowImages(message); onShowImages(message);
else else
onExpandMessage(pos, message); onExpandMessage(pos, message);
@ -567,6 +579,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
private SimpleTask<Spanned> bodyTask = new SimpleTask<Spanned>() { private SimpleTask<Spanned> bodyTask = new SimpleTask<Spanned>() {
@Override @Override
protected void onInit(Bundle args) { protected void onInit(Bundle args) {
btnHtml.setHasTransientState(true);
btnImages.setHasTransientState(true); btnImages.setHasTransientState(true);
tvBody.setHasTransientState(true); tvBody.setHasTransientState(true);
pbBody.setHasTransientState(true); pbBody.setHasTransientState(true);
@ -588,10 +601,12 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
boolean show_expanded = properties.isExpanded(message.id); boolean show_expanded = properties.isExpanded(message.id);
boolean show_images = properties.showImages(message.id); boolean show_images = properties.showImages(message.id);
btnHtml.setVisibility(Helper.classExists("android.webkit.WebView") && show_expanded ? View.VISIBLE : View.GONE);
btnImages.setVisibility(has_images && show_expanded && !show_images ? View.VISIBLE : View.GONE); btnImages.setVisibility(has_images && show_expanded && !show_images ? View.VISIBLE : View.GONE);
tvBody.setText(body); tvBody.setText(body);
pbBody.setVisibility(View.GONE); pbBody.setVisibility(View.GONE);
btnHtml.setHasTransientState(false);
btnImages.setHasTransientState(false); btnImages.setHasTransientState(false);
tvBody.setHasTransientState(false); tvBody.setHasTransientState(false);
pbBody.setHasTransientState(false); pbBody.setHasTransientState(false);
@ -599,6 +614,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
btnHtml.setHasTransientState(false);
btnImages.setHasTransientState(false); btnImages.setHasTransientState(false);
tvBody.setHasTransientState(false); tvBody.setHasTransientState(false);
pbBody.setHasTransientState(false); pbBody.setHasTransientState(false);
@ -1063,14 +1079,6 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
notifyDataSetChanged(); notifyDataSetChanged();
} }
private void onShowHtml(ActionData data) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_FULL)
.putExtra("id", data.message.id)
.putExtra("from", MessageHelper.getFormattedAddresses(data.message.from, true)));
}
private void onDecrypt(ActionData data) { private void onDecrypt(ActionData data) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast( lbm.sendBroadcast(
@ -1105,8 +1113,6 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
popupMenu.getMenu().findItem(R.id.menu_show_headers).setChecked(show_headers); popupMenu.getMenu().findItem(R.id.menu_show_headers).setChecked(show_headers);
popupMenu.getMenu().findItem(R.id.menu_show_headers).setVisible(data.message.uid != null); popupMenu.getMenu().findItem(R.id.menu_show_headers).setVisible(data.message.uid != null);
popupMenu.getMenu().findItem(R.id.menu_show_html).setEnabled(data.message.content && Helper.classExists("android.webkit.WebView"));
popupMenu.getMenu().findItem(R.id.menu_decrypt).setEnabled(data.message.to != null && data.message.to.length > 0); popupMenu.getMenu().findItem(R.id.menu_decrypt).setEnabled(data.message.to != null && data.message.to.length > 0);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@ -1134,9 +1140,6 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
case R.id.menu_show_headers: case R.id.menu_show_headers:
onShowHeaders(data); onShowHeaders(data);
return true; return true;
case R.id.menu_show_html:
onShowHtml(data);
return true;
case R.id.menu_decrypt: case R.id.menu_decrypt:
onDecrypt(data); onDecrypt(data);
return true; return true;

View File

@ -427,6 +427,19 @@
app:layout_constraintStart_toEndOf="@id/vwColor" app:layout_constraintStart_toEndOf="@id/vwColor"
app:layout_constraintTop_toBottomOf="@id/bnvActions" /> app:layout_constraintTop_toBottomOf="@id/bnvActions" />
<Button
android:id="@+id/btnHtml"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="3dp"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/title_show_html"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorBody" />
<Button <Button
android:id="@+id/btnImages" android:id="@+id/btnImages"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
@ -454,7 +467,7 @@
android:textIsSelectable="true" android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/vwColor" app:layout_constraintStart_toEndOf="@id/vwColor"
app:layout_constraintTop_toBottomOf="@id/btnImages" /> app:layout_constraintTop_toBottomOf="@id/btnHtml" />
<ProgressBar <ProgressBar
android:id="@+id/pbBody" android:id="@+id/pbBody"

View File

@ -423,6 +423,19 @@
app:layout_constraintStart_toEndOf="@id/vwColor" app:layout_constraintStart_toEndOf="@id/vwColor"
app:layout_constraintTop_toBottomOf="@id/bnvActions" /> app:layout_constraintTop_toBottomOf="@id/bnvActions" />
<Button
android:id="@+id/btnHtml"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="3dp"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/title_show_html"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorBody" />
<Button <Button
android:id="@+id/btnImages" android:id="@+id/btnImages"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
@ -450,7 +463,7 @@
android:textIsSelectable="true" android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/vwColor" app:layout_constraintStart_toEndOf="@id/vwColor"
app:layout_constraintTop_toBottomOf="@id/btnImages" /> app:layout_constraintTop_toBottomOf="@id/btnHtml" />
<ProgressBar <ProgressBar
android:id="@+id/pbBody" android:id="@+id/pbBody"

View File

@ -30,10 +30,6 @@
android:checkable="true" android:checkable="true"
android:title="@string/title_show_headers" /> android:title="@string/title_show_headers" />
<item
android:id="@+id/menu_show_html"
android:title="@string/title_show_html" />
<item <item
android:id="@+id/menu_decrypt" android:id="@+id/menu_decrypt"
android:title="@string/title_decrypt" /> android:title="@string/title_decrypt" />