abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
-rw-r--r--srcs/juloo.keyboard2/LayoutsPreference.java3
-rw-r--r--srcs/juloo.keyboard2/Utils.java14
2 files changed, 15 insertions, 2 deletions
diff --git a/srcs/juloo.keyboard2/LayoutsPreference.java b/srcs/juloo.keyboard2/LayoutsPreference.java
index a9405e6..e2bc243 100644
--- a/srcs/juloo.keyboard2/LayoutsPreference.java
+++ b/srcs/juloo.keyboard2/LayoutsPreference.java
@@ -210,8 +210,7 @@ public class LayoutsPreference extends ListGroupPreference<LayoutsPreference.Lay
try
{
Resources res = getContext().getResources();
- byte[] raw = res.openRawResource(R.raw.latn_qwerty_us).readAllBytes();
- return new String(raw, "UTF-8");
+ return Utils.read_all_utf8(res.openRawResource(R.raw.latn_qwerty_us));
}
catch (Exception _e)
{
diff --git a/srcs/juloo.keyboard2/Utils.java b/srcs/juloo.keyboard2/Utils.java
index cd28dfa..28bd9e3 100644
--- a/srcs/juloo.keyboard2/Utils.java
+++ b/srcs/juloo.keyboard2/Utils.java
@@ -4,6 +4,8 @@ import android.app.AlertDialog;
import android.os.IBinder;
import android.view.Window;
import android.view.WindowManager;
+import java.io.InputStream;
+import java.io.InputStreamReader;
class Utils
{
@@ -27,4 +29,16 @@ class Utils
win.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
dialog.show();
}
+
+ public static String read_all_utf8(InputStream inp) throws Exception
+ {
+ InputStreamReader reader = new InputStreamReader(inp, "UTF-8");
+ StringBuilder out = new StringBuilder();
+ int buff_length = 8000;
+ char[] buff = new char[buff_length];
+ int l;
+ while ((l = reader.read(buff, 0, buff_length)) != -1)
+ out.append(buff, 0, l);
+ return out.toString();
+ }
}