mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 08:24:16 +09:00
Modified asset loading, now checking if translated version exists before loading default.
This commit is contained in:
@@ -11,8 +11,10 @@ package com.freerdp.freerdpcore.presentation;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.IllegalFormatException;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.freerdp.freerdpcore.services.LibFreeRDP;
|
||||
|
||||
@@ -21,10 +23,12 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebView;
|
||||
|
||||
public class AboutActivity extends Activity {
|
||||
|
||||
private static final String TAG = "FreeRDPCore.AboutActivity";
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -47,6 +51,18 @@ public class AboutActivity extends Activity {
|
||||
try
|
||||
{
|
||||
String filename = ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) ? "about.html" : "about_phone.html";
|
||||
Locale def = Locale.getDefault();
|
||||
String prefix = def.getLanguage().toLowerCase(def);
|
||||
|
||||
String file = prefix + "_about_page/" + filename;
|
||||
InputStream is;
|
||||
try {
|
||||
is = getAssets().open(file);
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Missing localized asset " + file, e);
|
||||
file = "about_page/" + filename;
|
||||
}
|
||||
BufferedReader r = new BufferedReader(new InputStreamReader(getAssets().open("about_page/" + filename)));
|
||||
String line;
|
||||
while ((line = r.readLine()) != null) {
|
||||
@@ -70,6 +86,22 @@ public class AboutActivity extends Activity {
|
||||
about_html="Nothing here ;(";
|
||||
}
|
||||
webview.getSettings().setJavaScriptEnabled(true);
|
||||
webview.loadDataWithBaseURL("file:///android_asset/about_page/", about_html, "text/html", null, "about:blank");
|
||||
Locale def = Locale.getDefault();
|
||||
String prefix = def.getLanguage().toLowerCase(def);
|
||||
|
||||
String base = "file:///android_asset/";
|
||||
String dir = prefix + "_about_page/";
|
||||
String file = dir + about_html;
|
||||
try {
|
||||
InputStream is = getAssets().open(dir);
|
||||
is.close();
|
||||
dir = base + dir;
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Missing localized asset " + dir, e);
|
||||
dir = "file:///android_asset/about_page/";
|
||||
}
|
||||
|
||||
webview.loadDataWithBaseURL(dir, about_html, "text/html", null,
|
||||
"about:blank");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,15 @@ package com.freerdp.freerdpcore.presentation;
|
||||
import android.app.Activity;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Locale;
|
||||
public class HelpActivity extends Activity {
|
||||
|
||||
private static final String TAG = "FreeRDPCore.HelpActivity";
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -23,7 +28,28 @@ public class HelpActivity extends Activity {
|
||||
WebView webview = new WebView(this);
|
||||
setContentView(webview);
|
||||
|
||||
String filename = ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) ? "gestures.html" : "gestures_phone.html";
|
||||
webview.loadUrl("file:///android_asset/help_page/" + filename);
|
||||
String filename;
|
||||
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
|
||||
filename = "gestures.html";
|
||||
else
|
||||
filename = "gestures_phone.html";
|
||||
|
||||
webview.getSettings().setJavaScriptEnabled(true);
|
||||
Locale def = Locale.getDefault();
|
||||
String prefix = def.getLanguage().toLowerCase(def);
|
||||
|
||||
String base = "file:///android_asset/";
|
||||
String dir = prefix + "_help_page/"
|
||||
+ filename;
|
||||
try {
|
||||
InputStream is = getAssets().open(dir);
|
||||
is.close();
|
||||
dir = base + dir;
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Missing localized asset " + dir, e);
|
||||
dir = "file:///android_asset/help_page/" + filename;
|
||||
}
|
||||
|
||||
webview.loadUrl(dir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
|
||||
package com.freerdp.freerdpcore.presentation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.freerdp.freerdpcore.R;
|
||||
import com.freerdp.freerdpcore.application.GlobalApp;
|
||||
@@ -111,7 +114,23 @@ public class HomeActivity extends Activity
|
||||
webViewGetStarted = (WebView) findViewById(R.id.webViewWelcome);
|
||||
|
||||
String filename = ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) ? "welcome.html" : "welcome_phone.html";
|
||||
webViewGetStarted.loadUrl("file:///android_asset/welcome_page/" + filename);
|
||||
webViewGetStarted.getSettings().setJavaScriptEnabled(true);
|
||||
Locale def = Locale.getDefault();
|
||||
String prefix = def.getLanguage().toLowerCase(def);
|
||||
|
||||
String base = "file:///android_asset/";
|
||||
String dir = prefix + "_help_page/"
|
||||
+ filename;
|
||||
try {
|
||||
InputStream is = getAssets().open(dir);
|
||||
is.close();
|
||||
dir = base + dir;
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Missing localized asset " + dir, e);
|
||||
dir = "file:///android_asset/help_page/" + filename;
|
||||
}
|
||||
|
||||
webViewGetStarted.loadUrl(dir);
|
||||
|
||||
// set listeners for the list view
|
||||
listViewBookmarks.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
||||
Reference in New Issue
Block a user