Added view original signature

This commit is contained in:
M66B 2022-02-06 11:03:36 +01:00
parent 823b2fde92
commit 9d87fe8f6c
7 changed files with 143 additions and 60 deletions

View File

@ -7,6 +7,7 @@
### Next version
* Added option to disable divider lines for tabular layout
* Added view original signature
### 1.1832 - 2022-02-05

View File

@ -7,6 +7,7 @@
### Next version
* Added option to disable divider lines for tabular layout
* Added view original signature
### 1.1832 - 2022-02-05

View File

@ -43,6 +43,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import androidx.annotation.NonNull;
@ -61,6 +62,7 @@ public class ActivitySignature extends ActivityBase {
private ViewGroup view;
private TextView tvHtmlRemark;
private EditTextCompose etText;
private ImageButton ibFull;
private BottomNavigationView style_bar;
private BottomNavigationView bottom_navigation;
@ -84,6 +86,7 @@ public class ActivitySignature extends ActivityBase {
tvHtmlRemark = findViewById(R.id.tvHtmlRemark);
etText = findViewById(R.id.etText);
ibFull = findViewById(R.id.ibFull);
style_bar = findViewById(R.id.style_bar);
bottom_navigation = findViewById(R.id.bottom_navigation);
@ -114,6 +117,21 @@ public class ActivitySignature extends ActivityBase {
}
});
ibFull.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle args = new Bundle();
args.putString("html", getHtml());
args.putBoolean("overview_mode", false);
args.putBoolean("safe_browsing", false);
args.putBoolean("force_light", true);
FragmentDialogOpenFull dialog = new FragmentDialogOpenFull();
dialog.setArguments(args);
dialog.show(getSupportFragmentManager(), "signature");
}
});
style_bar.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {

View File

@ -4796,8 +4796,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
protected void onExecuted(Bundle args, String html) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean overview_mode = prefs.getBoolean("overview_mode", false);
boolean safe_browsing = prefs.getBoolean("safe_browsing", false);
Bundle fargs = new Bundle();
fargs.putString("html", html);
fargs.putBoolean("overview_mode", overview_mode);
fargs.putBoolean("safe_browsing", safe_browsing);
fargs.putBoolean("force_light", args.getBoolean("force_light"));
FragmentDialogOpenFull dialog = new FragmentDialogOpenFull();
@ -7858,66 +7864,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
}
public static class FragmentDialogOpenFull extends FragmentDialogBase {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NORMAL, R.style.fullScreenDialog);
}
@Override
public void onStart() {
super.onStart();
Dialog dialog = getDialog();
if (dialog != null)
dialog.getWindow().setLayout(MATCH_PARENT, MATCH_PARENT);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle args = getArguments();
String html = args.getString("html");
boolean force_light = args.getBoolean("force_light");
final Context context = getContext();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean overview_mode = prefs.getBoolean("overview_mode", false);
boolean safe_browsing = prefs.getBoolean("safe_browsing", false);
View view = inflater.inflate(R.layout.fragment_open_full, container, false);
WebView wv = view.findViewById(R.id.wv);
WebSettings settings = wv.getSettings();
settings.setUserAgentString(WebViewEx.getUserAgent(context, wv));
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(overview_mode);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
settings.setAllowFileAccess(false);
settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
settings.setSafeBrowsingEnabled(safe_browsing);
boolean dark = (Helper.isDarkTheme(context) && !force_light);
if (WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK))
WebSettingsCompat.setForceDark(settings, dark ? FORCE_DARK_ON : FORCE_DARK_OFF);
settings.setLoadsImagesAutomatically(true);
settings.setBlockNetworkLoads(false);
settings.setBlockNetworkImage(false);
wv.loadDataWithBaseURL(null, html, "text/html", StandardCharsets.UTF_8.name(), null);
return view;
}
}
public static class FragmentDialogPrint extends FragmentDialogBase {
@NonNull
@Override

View File

@ -0,0 +1,102 @@
package eu.faircode.email;
/*
This file is part of FairEmail.
FairEmail is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FairEmail is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
Copyright 2018-2022 by Marcel Bokhorst (M66B)
*/
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static androidx.webkit.WebSettingsCompat.FORCE_DARK_OFF;
import static androidx.webkit.WebSettingsCompat.FORCE_DARK_ON;
import android.app.Dialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.preference.PreferenceManager;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;
import java.nio.charset.StandardCharsets;
public class FragmentDialogOpenFull extends FragmentDialogBase {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NORMAL, R.style.fullScreenDialog);
}
@Override
public void onStart() {
super.onStart();
Dialog dialog = getDialog();
if (dialog != null)
dialog.getWindow().setLayout(MATCH_PARENT, MATCH_PARENT);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle args = getArguments();
String html = args.getString("html");
boolean overview_mode = args.getBoolean("overview_mode");
boolean safe_browsing = args.getBoolean("safe_browsing");
boolean force_light = args.getBoolean("force_light");
final Context context = getContext();
View view = inflater.inflate(R.layout.fragment_open_full, container, false);
WebView wv = view.findViewById(R.id.wv);
WebSettings settings = wv.getSettings();
settings.setUserAgentString(WebViewEx.getUserAgent(context, wv));
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(overview_mode);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
settings.setAllowFileAccess(false);
settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
settings.setSafeBrowsingEnabled(safe_browsing);
boolean dark = (Helper.isDarkTheme(context) && !force_light);
if (WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK))
WebSettingsCompat.setForceDark(settings, dark ? FORCE_DARK_ON : FORCE_DARK_OFF);
settings.setLoadsImagesAutomatically(true);
settings.setBlockNetworkLoads(false);
settings.setBlockNetworkImage(false);
wv.loadDataWithBaseURL(null, html, "text/html", StandardCharsets.UTF_8.name(), null);
return view;
}
}

View File

@ -39,6 +39,20 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHtmlRemark" />
<eu.faircode.email.FixedImageButton
android:id="@+id/ibFull"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_legend_show_full"
android:padding="3dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_legend_show_full"
app:layout_constraintEnd_toEndOf="@+id/etText"
app:layout_constraintTop_toTopOf="@+id/etText"
app:srcCompat="@drawable/twotone_fullscreen_24"
app:tint="?attr/colorAccent" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/style_bar"
android:layout_width="0dp"

View File

@ -7,6 +7,7 @@
### Next version
* Added option to disable divider lines for tabular layout
* Added view original signature
### 1.1832 - 2022-02-05