Improved WebView test

pull/147/head
M66B 7 years ago
parent 7758cdf2c6
commit 83931fabec

@ -2223,9 +2223,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);
this.colorUnread = Helper.resolveColor(context, R.attr.colorUnread);
PackageManager pm = context.getPackageManager();
this.hasWebView = pm.hasSystemFeature("android.software.webview");
this.hasWebView = Helper.hasWebView(context);
}
void submitList(PagedList<TupleMessageEx> pagedList) {

@ -28,7 +28,6 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Base64;
import android.view.ContextMenu;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@ -65,15 +64,7 @@ public class FragmentWebView extends FragmentBase {
@Override
@Nullable
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = null;
try {
view = inflater.inflate(R.layout.fragment_webview, container, false);
} catch (InflateException ex) {
Toast.makeText(getContext(),
getString(R.string.title_no_viewer, Helper.formatThrowable(ex)),
Toast.LENGTH_LONG).show();
return null;
}
View view = inflater.inflate(R.layout.fragment_webview, container, false);
progressBar = view.findViewById(R.id.progressbar);
webview = view.findViewById(R.id.webview);

@ -44,6 +44,7 @@ import android.text.TextUtils;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
@ -861,6 +862,19 @@ public class Helper {
}
}
static boolean hasWebView(Context context) {
PackageManager pm = context.getPackageManager();
if (pm.hasSystemFeature("android.software.webview"))
try {
new WebView(context);
return true;
} catch (Throwable ex) {
return false;
}
else
return false;
}
public static String getFingerprint(Context context) {
try {
PackageManager pm = context.getPackageManager();

Loading…
Cancel
Save