1 package com.freerdp.freerdpcore.presentation;
3 import android.content.pm.PackageManager;
4 import android.content.res.Configuration;
5 import android.nfc.FormatException;
6 import android.os.Build;
7 import android.os.Bundle;
8 import androidx.core.text.TextUtilsCompat;
9 import androidx.appcompat.app.AppCompatActivity;
10 import android.util.Log;
11 import android.webkit.WebSettings;
12 import android.webkit.WebView;
14 import com.freerdp.freerdpcore.R;
15 import com.freerdp.freerdpcore.services.LibFreeRDP;
17 import java.io.BufferedReader;
18 import java.io.IOException;
19 import java.io.InputStream;
20 import java.io.InputStreamReader;
21 import java.util.Formatter;
22 import java.util.IllegalFormatException;
23 import java.util.Locale;
27 private static final String TAG =
AboutActivity.class.toString();
28 private WebView mWebView;
30 @Override
protected void onCreate(Bundle savedInstanceState)
32 super.onCreate(savedInstanceState);
33 setContentView(R.layout.activity_about);
34 mWebView = (WebView)findViewById(R.id.activity_about_webview);
37 @Override
protected void onResume()
43 private void populate()
45 StringBuilder total =
new StringBuilder();
47 String filename =
"about_phone.html";
48 if ((getResources().getConfiguration().screenLayout &
49 Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
51 filename =
"about.html";
53 Locale def = Locale.getDefault();
54 String prefix = def.getLanguage().toLowerCase(def);
56 String dir = prefix +
"_about_page/";
57 String file = dir + filename;
61 is = getAssets().open(file);
66 Log.e(TAG,
"Missing localized asset " + file, e);
68 file = dir + filename;
73 try (BufferedReader r =
74 new BufferedReader(
new InputStreamReader(getAssets().open(file))))
77 while ((line = r.readLine()) !=
null)
86 Log.e(TAG,
"Could not read about page " + file, e);
94 version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
96 catch (PackageManager.NameNotFoundException e)
100 version = version +
" (" +
LibFreeRDP.getVersion() +
")";
102 WebSettings settings = mWebView.getSettings();
103 settings.setDomStorageEnabled(
true);
104 settings.setUseWideViewPort(
true);
105 settings.setLoadWithOverviewMode(
true);
106 settings.setSupportZoom(
true);
108 final String base =
"file:///android_asset/" + dir;
110 final String rawHtml = total.toString();
111 final String html = rawHtml.replaceAll(
"%AFREERDP_VERSION%", version)
112 .replaceAll(
"%SYSTEM_VERSION%", Build.VERSION.RELEASE)
113 .replaceAll(
"%DEVICE_MODEL%", Build.MODEL);
115 mWebView.loadDataWithBaseURL(base, html,
"text/html",
null,
"about:blank");