Small behavior/display fixes/improvements

pull/162/head
M66B 5 years ago
parent 725c4d9202
commit 708ea16296

@ -1228,6 +1228,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void bindBody(TupleMessageEx message) {
tvBody.setText(null);
if (!message.content)
return;
@ -1252,6 +1254,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Pair<Integer, Integer> position = properties.getPosition(message.id);
Log.i("Bind size=" + size + " height=" + height);
ibFull.setEnabled(hasWebView);
ibFull.setImageResource(show_full ? R.drawable.baseline_fullscreen_exit_24 : R.drawable.baseline_fullscreen_24);
if (show_full) {
// Create web view
WebView webView;
@ -1362,7 +1367,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
WebSettings settings = webView.getSettings();
settings.setUseWideViewPort(true);
settings.setUseWideViewPort(false);
settings.setLoadWithOverviewMode(true);
settings.setBuiltInZoomControls(true);
@ -1371,8 +1376,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
if (textSize != 0) {
settings.setDefaultFontSize(Math.round(textSize));
settings.setDefaultFixedFontSize(Math.round(textSize));
int dp = Helper.pixels2dp(context, textSize);
settings.setDefaultFontSize(Math.round(dp));
settings.setDefaultFixedFontSize(Math.round(dp));
}
if (monospaced)
settings.setStandardFontFamily("monospace");
@ -1454,7 +1460,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (show_full) {
HtmlHelper.removeViewportLimitations(document);
if (inline)
if (inline || show_images)
HtmlHelper.embedImages(context, message.id, document);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@ -1553,20 +1559,15 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvBody.setTextIsSelectable(false);
tvBody.setTextIsSelectable(true);
tvBody.setMovementMethod(new TouchHandler(message));
ibFull.setImageResource(R.drawable.baseline_fullscreen_24);
} else if (result instanceof String) {
} else if (result instanceof String)
((WebView) wvBody).loadDataWithBaseURL(null, (String) result, "text/html", "UTF-8", null);
ibFull.setImageResource(R.drawable.baseline_fullscreen_exit_24);
} else
else
throw new IllegalStateException("Result=" + result);
pbBody.setVisibility(View.GONE);
// Show attachments/images
cowner.start();
ibFull.setEnabled(hasWebView);
ibImages.setVisibility(has_images && !show_images ? View.VISIBLE : View.GONE);
}
@ -3957,6 +3958,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
public void onViewDetachedFromWindow(@NonNull ViewHolder holder) {
if (holder.wvBody instanceof WebView)
((WebView) holder.wvBody).loadDataWithBaseURL(null, "", "text/html", "UTF-8", null);
holder.cowner.stop();
holder.powner.recreate();
}

@ -280,6 +280,11 @@ public class Helper {
return Math.round(dp * scale);
}
static int pixels2dp(Context context, float pixels) {
float scale = context.getResources().getDisplayMetrics().density;
return Math.round(pixels / scale);
}
static float getTextSize(Context context, int zoom) {
TypedArray ta = null;
try {

@ -559,7 +559,7 @@ public class HtmlHelper {
return d;
} else if (!attachment.available) {
Log.i("Image not available CID=" + cid);
Drawable d = res.getDrawable(R.drawable.baseline_photo_library_24, theme);
Drawable d = res.getDrawable(R.drawable.baseline_hourglass_empty_24, theme);
d.setBounds(0, 0, px, px);
return d;
} else {

@ -40,17 +40,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/inAttachments" />
<eu.faircode.email.ContentLoadingProgressBar
android:id="@+id/pbBody"
style="@style/Base.Widget.AppCompat.ProgressBar"
android:layout_width="48dp"
android:layout_height="48dp"
android:indeterminate="true"
android:padding="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/inNavigation" />
<TextView
android:id="@+id/tvNoInternetBody"
android:layout_width="wrap_content"

@ -18,6 +18,17 @@
app:layout_constraintTop_toTopOf="parent"
app:menu="@menu/action_message" />
<eu.faircode.email.ContentLoadingProgressBar
android:id="@+id/pbBody"
style="@style/Base.Widget.AppCompat.ProgressBar"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="6dp"
android:indeterminate="true"
app:layout_constraintBottom_toBottomOf="@+id/ibFull"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/ibFull" />
<ImageButton
android:id="@+id/ibDecrypt"
android:layout_width="wrap_content"

Loading…
Cancel
Save