35 private static final String TAG =
AboutActivity.class.toString();
36 private WebView mWebView;
38 @Override
protected void onCreate(Bundle savedInstanceState)
40 super.onCreate(savedInstanceState);
41 setContentView(R.layout.activity_about);
43 if (getSupportActionBar() !=
null)
44 getSupportActionBar().setDisplayHomeAsUpEnabled(
true);
46 mWebView = findViewById(R.id.activity_about_webview);
48 WebSettings settings = mWebView.getSettings();
49 settings.setDomStorageEnabled(
true);
50 settings.setUseWideViewPort(
true);
51 settings.setLoadWithOverviewMode(
true);
52 settings.setSupportZoom(
true);
54 mWebView.setWebViewClient(
new WebViewClient() {
55 @Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
57 if (url.startsWith(
"file:///android_asset/"))
69 @Override
public boolean onSupportNavigateUp()
75 private void populate()
77 String filename =
"about_phone.html";
78 if ((getResources().getConfiguration().screenLayout &
79 Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
80 filename =
"about.html";
82 Locale def = Locale.getDefault();
83 String prefix = def.getLanguage().toLowerCase(def);
84 String dir = prefix +
"_about_page/";
85 String file = dir + filename;
89 InputStream is = getAssets().open(file);
94 Log.d(TAG,
"No localized asset " + file +
", falling back to default");
96 file = dir + filename;
99 StringBuilder total =
new StringBuilder();
100 try (BufferedReader r =
new BufferedReader(
new InputStreamReader(getAssets().open(file))))
103 while ((line = r.readLine()) !=
null)
109 catch (IOException e)
111 Log.e(TAG,
"Could not read about page " + file, e);
117 version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
119 catch (PackageManager.NameNotFoundException e)
123 version = version +
" (" + LibFreeRDP.getVersion() +
")";
125 final String base =
"file:///android_asset/" + dir;
126 final String html = total.toString()
127 .replaceAll(
"%AFREERDP_VERSION%", version)
128 .replaceAll(
"%SYSTEM_VERSION%", Build.VERSION.RELEASE)
129 .replaceAll(
"%DEVICE_MODEL%", Build.MODEL);
131 mWebView.loadDataWithBaseURL(base, html,
"text/html",
null,
"about:blank");