diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
deleted file mode 100644
index 45b2f78..0000000
--- a/.idea/codeStyleSettings.xml
+++ /dev/null
@@ -1,228 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- xmlns:android
- ^$
-
-
-
-
-
-
-
-
- xmlns:.*
- ^$
-
-
- BY_NAME
-
-
-
-
-
-
- .*:id
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:name
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- name
- ^$
-
-
-
-
-
-
-
-
- style
- ^$
-
-
-
-
-
-
-
-
- .*
- ^$
-
-
- BY_NAME
-
-
-
-
-
-
- .*:layout_width
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_height
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_.*
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
-
-
- .*:width
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
-
-
- .*:height
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
-
-
- .*
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
-
-
- .*
- .*
-
-
- BY_NAME
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
deleted file mode 100644
index 9570c35..0000000
--- a/.idea/codeStyles/Project.xml
+++ /dev/null
@@ -1,184 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- xmlns:android
- ^$
-
-
-
-
-
-
-
-
- xmlns:.*
- ^$
-
-
- BY_NAME
-
-
-
-
-
-
- .*:id
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:name
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- name
- ^$
-
-
-
-
-
-
-
-
- style
- ^$
-
-
-
-
-
-
-
-
- .*
- ^$
-
-
- BY_NAME
-
-
-
-
-
-
- .*:layout_width
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_height
- http://schemas.android.com/apk/res/android
-
-
-
-
-
-
-
-
- .*:layout_.*
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
-
-
- .*:width
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
-
-
- .*:height
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
-
-
- .*
- http://schemas.android.com/apk/res/android
-
-
- BY_NAME
-
-
-
-
-
-
- .*
- .*
-
-
- BY_NAME
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
deleted file mode 100644
index 4daf1b2..0000000
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 5cd135a..7e46edd 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -7,6 +7,7 @@
+
@@ -14,6 +15,7 @@
+
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..146ab09
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..1593062
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 6710e2d..0000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index db73377..33d5696 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -11,7 +11,11 @@ android {
versionCode 43
versionName "2.8.0"
}
-
+ applicationVariants.all { variant ->
+ variant.outputs.all {
+ outputFileName = "unicode-pad.apk"
+ }
+ }
buildTypes {
release {
shrinkResources true
diff --git a/app/src/main/java/jp/ddo/hotmist/unicodepad/CharacterAdapter.java b/app/src/main/java/jp/ddo/hotmist/unicodepad/CharacterAdapter.java
index 2ae9733..e0ed3fe 100644
--- a/app/src/main/java/jp/ddo/hotmist/unicodepad/CharacterAdapter.java
+++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/CharacterAdapter.java
@@ -20,10 +20,9 @@
import java.util.Locale;
import java.util.Scanner;
-import android.annotation.SuppressLint;
import android.graphics.Color;
import android.graphics.Typeface;
-import android.os.Build;
+
import androidx.viewpager.widget.PagerAdapter;
import android.util.TypedValue;
import android.view.Gravity;
@@ -171,7 +170,7 @@ public boolean onLongClick(View arg0)
CheckBox fav = new CheckBox(context);
fav.setButtonDrawable(android.R.drawable.btn_star);
fav.setGravity(Gravity.TOP);
- fav.setChecked(afav.isfavorited(itemid));
+ fav.setChecked(afav.isFavorited(itemid));
fav.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton arg0, boolean arg1)
diff --git a/app/src/main/java/jp/ddo/hotmist/unicodepad/FavoriteAdapter.java b/app/src/main/java/jp/ddo/hotmist/unicodepad/FavoriteAdapter.java
index f8788f3..7229066 100644
--- a/app/src/main/java/jp/ddo/hotmist/unicodepad/FavoriteAdapter.java
+++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/FavoriteAdapter.java
@@ -1,117 +1,102 @@
-/*
- Copyright 2018 Ryosuke839
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
package jp.ddo.hotmist.unicodepad;
-import java.util.ArrayList;
-
import android.content.SharedPreferences;
-class FavoriteAdapter extends UnicodeAdapter
-{
- private ArrayList list;
- private ArrayList temp;
-
- FavoriteAdapter(SharedPreferences pref, NameDatabase db, boolean single)
- {
- super(db, single);
-
- list = new ArrayList<>();
- temp = list;
- String str = pref.getString("fav", "");
- for (int i = 0; i < str.length(); ++i)
- {
- int code = str.codePointAt(i);
- if (code > 0xFFFF)
- ++i;
- list.add(code);
- }
- }
-
- @Override
- int name()
- {
- return R.string.favorite;
- }
-
- @Override
- void show()
- {
- trunc();
- if (grid != null)
- grid.invalidateViews();
- }
-
- @Override
- void leave()
- {
- commit();
- if (grid != null)
- grid.invalidateViews();
- }
-
- @Override
- public int getCount()
- {
- return temp.size();
- }
-
- @Override
- public long getItemId(int arg0)
- {
- return temp.get(arg0);
- }
-
- void add(int code)
- {
- list.remove(Integer.valueOf(code));
- list.add(code);
- }
-
- void remove(int code)
- {
- list.remove(Integer.valueOf(code));
- }
-
- private void commit()
- {
- if (list != temp)
- {
- temp = list;
- }
- }
-
- private void trunc()
- {
- if (list == temp)
- temp = new ArrayList<>(list);
- }
-
- boolean isfavorited(int code)
- {
- return list.contains(code);
- }
-
- @Override
- void save(SharedPreferences.Editor edit)
- {
- String str = "";
- for (Integer i : list)
- str += String.valueOf(Character.toChars(i));
- edit.putString("fav", str);
- }
+import java.util.ArrayList;
+import java.util.Collections;
+
+class FavoriteAdapter extends UnicodeAdapter {
+ private ArrayList list;
+ private ArrayList temp;
+ boolean sorted;
+
+ FavoriteAdapter(SharedPreferences pref, NameDatabase db, boolean single) {
+ super(db, single);
+ sorted = pref.getBoolean("sort_favorites", true);
+
+ list = new ArrayList<>();
+ temp = list;
+ String fav = pref.getString("fav", "");
+ for (int i = 0; i < fav.length(); ++i) {
+ int code = fav.codePointAt(i);
+ if (code > 0xFFFF) {
+ ++i;
+ }
+ list.add(code);
+ }
+ }
+
+ @Override
+ int name() {
+ return R.string.favorite;
+ }
+
+ @Override
+ void show() {
+ truncate();
+ if (grid != null) {
+ grid.invalidateViews();
+ }
+ }
+
+ @Override
+ void leave() {
+ commit();
+ if (grid != null) {
+ grid.invalidateViews();
+ }
+ }
+
+ @Override
+ public int getCount() {
+ return temp.size();
+ }
+
+ @Override
+ public long getItemId(int arg0) {
+ return temp.get(arg0);
+ }
+
+ void add(int code) {
+ list.remove(Integer.valueOf(code));
+ list.add(code);
+ if (sorted) {
+ Collections.sort(list);
+ // Collections.reverse(list);
+ }
+ }
+
+ void remove(int code) {
+ list.remove(Integer.valueOf(code));
+ }
+
+ void clear() {
+ list.clear();
+ }
+
+ private void commit() {
+ if (list != temp) {
+ temp = list;
+ }
+ }
+
+ private void truncate() {
+ if (list == temp) {
+ temp = new ArrayList<>(list);
+ }
+ }
+
+ boolean isFavorited(int code) {
+ return list.contains(code);
+ }
+
+ @Override
+ void save(SharedPreferences.Editor editor) {
+ StringBuilder str = new StringBuilder();
+ for (Integer i : list) {
+ str.append(String.valueOf(Character.toChars(i)));
+ }
+ editor.putString("fav", str.toString());
+ }
}
diff --git a/app/src/main/java/jp/ddo/hotmist/unicodepad/FontChooser.java b/app/src/main/java/jp/ddo/hotmist/unicodepad/FontChooser.java
index 19de828..2bf7940 100644
--- a/app/src/main/java/jp/ddo/hotmist/unicodepad/FontChooser.java
+++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/FontChooser.java
@@ -32,214 +32,199 @@
import java.io.IOException;
import java.util.ArrayList;
-public class FontChooser implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener, AdapterView.OnItemSelectedListener, FileChooser.Listener
-{
- private final Activity activity;
- private final Spinner spinner;
- private final Listener listener;
- private final ArrayAdapter adapter;
- private int fidx;
- private final ArrayList fontpath;
-
- static int FONT_REQUEST_CODE = 42;
-
- interface Listener
- {
- void onTypefaceChosen(Typeface typeface);
- }
-
- FontChooser(Activity activity, Spinner spinner, Listener listener)
- {
- this.activity = activity;
- this.spinner = spinner;
- this.listener = listener;
-
- adapter = new ArrayAdapter<>(activity, android.R.layout.simple_spinner_item);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- adapter.add(activity.getResources().getString(R.string.normal));
- adapter.add(activity.getResources().getString(R.string.add));
- spinner.setAdapter(adapter);
- spinner.setOnItemSelectedListener(this);
-
- SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(activity);
- fontpath = new ArrayList<>();
- String fs = pref.getString("fontpath", "");
- for (String s : fs.split("\n"))
- {
- if (s.length() == 0)
- continue;
- Add(s);
- }
- fidx = pref.getInt("fontidx", 0);
- if (fidx > fontpath.size())
- fidx = 0;
- spinner.setSelection(fidx == 0 ? 0 : fidx + 2);
- }
-
- void Save(SharedPreferences.Editor edit)
- {
- String fs = "";
- for (String s : fontpath)
- fs += s + "\n";
- edit.putString("fontpath", fs);
- edit.putInt("fontidx", spinner.getSelectedItemId() > 2 ? (int)spinner.getSelectedItemId() - 2 : 0);
- }
-
- private boolean Add(String path)
- {
- if (Load(path) == null)
- return false;
-
- // Add remove item
- if (adapter.getCount() < 3)
- adapter.add(activity.getResources().getString(R.string.rem));
-
- // Remove duplicated items
- for (int i = 0; i < fontpath.size(); ++i)
- {
- if (!path.equals(fontpath.get(i)))
- continue;
- adapter.remove(adapter.getItem(i + 3));
- fontpath.remove(i);
- }
-
- adapter.add(new File(path).getName());
- fontpath.add(path);
-
- return true;
- }
-
- private Typeface Load(String path)
- {
- try
- {
- return Typeface.createFromFile(path);
- }
- catch (RuntimeException e)
- {
- return null;
- }
- }
-
- private void Remove(int which)
- {
- adapter.remove(adapter.getItem(which + 3));
- //noinspection EmptyCatchBlock
- try
- {
- if (fontpath.get(which).startsWith(activity.getFilesDir().getCanonicalPath()))
- //noinspection ResultOfMethodCallIgnored
- new File(fontpath.get(which)).delete();
- }
- catch (IOException e)
- {
- }
- fontpath.remove(which);
- if (fidx == which + 1)
- fidx = 0;
- if (fidx > which + 1)
- --fidx;
-
- // Remove remove item
- if (fontpath.size() == 0)
- adapter.remove(adapter.getItem(2));
- spinner.setSelection(fidx == 0 ? 0 : fidx + 2);
- }
-
- @SuppressLint("InlinedApi")
- @Override
- public void onItemSelected(AdapterView> parent, View view, int position, long id)
- {
- if (parent != spinner)
- return;
- switch (position)
- {
- case 0:
- listener.onTypefaceChosen(Typeface.DEFAULT);
- fidx = 0;
- break;
- case 1:
- if (Build.VERSION.SDK_INT >= 19)
- {
- Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
- intent.addCategory(Intent.CATEGORY_OPENABLE);
- intent.setType("*/*");
- activity.startActivityForResult(intent, FONT_REQUEST_CODE);
- } else
- new FileChooser(activity, this, "/").show();
- break;
- case 2:
- onClick(null, -1);
- break;
- default:
- fidx = position - 2;
- Typeface tf = Load(fontpath.get(position - 3));
- if (tf != null)
- listener.onTypefaceChosen(tf);
- else
- Remove(position - 3);
- break;
- }
- }
-
- @Override
- public void onNothingSelected(AdapterView> parent)
- {
- }
-
- @Override
- public void onClick(DialogInterface dialog, int which)
- {
- if (which == -1)
- {
- String[] str;
- str = new String[fontpath.size()];
- for (int i = 0; i < str.length; ++i)
- str[i] = adapter.getItem(i + 3);
- new AlertDialog.Builder(activity).setTitle(R.string.rem).setItems(str, this).setOnCancelListener(this).show();
- }
- else
- {
- Remove(which);
- }
- }
-
- @Override
- public void onCancel(DialogInterface dialog)
- {
- spinner.setSelection(fidx == 0 ? 0 : fidx + 2);
- }
-
- public void onFileChosen(String path)
- {
- if (path.endsWith(".zip"))
- {
- new FileChooser(activity, this, path).onClick(null, -1);
- return;
- }
- if (Add(path))
- {
- spinner.setSelection(adapter.getCount() - 1);
- }
- else
- {
- Toast.makeText(activity, R.string.cantopen, Toast.LENGTH_SHORT).show();
- //noinspection EmptyCatchBlock
- try
- {
- if (path.startsWith(activity.getFilesDir().getCanonicalPath()))
- //noinspection ResultOfMethodCallIgnored
- new File(path).delete();
- }
- catch (IOException e2)
- {
- }
- spinner.setSelection(0);
- }
- }
-
- public void onFileCancel()
- {
- spinner.setSelection(fidx == 0 ? 0 : fidx + 2);
- }
+public class FontChooser implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener, AdapterView.OnItemSelectedListener, FileChooser.Listener {
+ private final Activity activity;
+ private final Spinner spinner;
+ private final Listener listener;
+ private final ArrayAdapter adapter;
+ private int fidx;
+ private final ArrayList fontpath;
+
+ static int FONT_REQUEST_CODE = 42;
+
+ interface Listener {
+ void onTypefaceChosen(Typeface typeface);
+ }
+
+ FontChooser(Activity activity, Spinner spinner, Listener listener) {
+ this.activity = activity;
+ this.spinner = spinner;
+ this.listener = listener;
+
+ adapter = new ArrayAdapter<>(activity, android.R.layout.simple_spinner_item);
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ adapter.add(activity.getResources().getString(R.string.normal));
+ adapter.add(activity.getResources().getString(R.string.add));
+ spinner.setAdapter(adapter);
+ spinner.setOnItemSelectedListener(this);
+
+ SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(activity);
+ fontpath = new ArrayList<>();
+ String fs = pref.getString("fontpath", "");
+ for (String s : fs.split("\n")) {
+ if (s.length() == 0) {
+ continue;
+ }
+ add(s);
+ }
+ fidx = pref.getInt("fontidx", 0);
+ if (fidx > fontpath.size()) {
+ fidx = 0;
+ }
+ spinner.setSelection(fidx == 0 ? 0 : fidx + 2);
+ }
+
+ void save(SharedPreferences.Editor edit) {
+ String fs = "";
+ for (String s : fontpath) {
+ fs += s + "\n";
+ }
+ edit.putString("fontpath", fs);
+ edit.putInt("fontidx", spinner.getSelectedItemId() > 2 ? (int)spinner.getSelectedItemId() - 2 : 0);
+ }
+
+ private boolean add(String path) {
+ if (load(path) == null) {
+ return false;
+ }
+
+ // Add remove item
+ if (adapter.getCount() < 3) {
+ adapter.add(activity.getResources().getString(R.string.rem));
+ }
+
+ // Remove duplicated items
+ for (int i = 0; i < fontpath.size(); ++i) {
+ if (!path.equals(fontpath.get(i))) {
+ continue;
+ }
+ adapter.remove(adapter.getItem(i + 3));
+ fontpath.remove(i);
+ }
+
+ adapter.add(new File(path).getName());
+ fontpath.add(path);
+
+ return true;
+ }
+
+ private Typeface load(String path) {
+ try {
+ return Typeface.createFromFile(path);
+ }
+ catch (RuntimeException e) {
+ return null;
+ }
+ }
+
+ private void remove(int which) {
+ adapter.remove(adapter.getItem(which + 3));
+ //noinspection EmptyCatchBlock
+ try {
+ if (fontpath.get(which).startsWith(activity.getFilesDir().getCanonicalPath())) {
+ new File(fontpath.get(which)).delete();
+ }
+ }
+ catch (IOException e) {
+ }
+ fontpath.remove(which);
+ if (fidx == which + 1) {
+ fidx = 0;
+ }
+ if (fidx > which + 1) {
+ --fidx;
+ }
+
+ // Remove remove item
+ if (fontpath.size() == 0) {
+ adapter.remove(adapter.getItem(2));
+ }
+ spinner.setSelection(fidx == 0 ? 0 : fidx + 2);
+ }
+
+ @SuppressLint("InlinedApi")
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ if (parent != spinner) {
+ return;
+ }
+ switch (position) {
+ case 0:
+ listener.onTypefaceChosen(Typeface.DEFAULT);
+ fidx = 0;
+ break;
+ case 1:
+ if (Build.VERSION.SDK_INT >= 19) {
+ Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
+ intent.setType("*/*");
+ activity.startActivityForResult(intent, FONT_REQUEST_CODE);
+ }
+ else {
+ new FileChooser(activity, this, "/").show();
+ }
+ break;
+ case 2:
+ onClick(null, -1);
+ break;
+ default:
+ fidx = position - 2;
+ Typeface tf = load(fontpath.get(position - 3));
+ if (tf != null) {
+ listener.onTypefaceChosen(tf);
+ }
+ else {
+ remove(position - 3);
+ }
+ break;
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == -1) {
+ String[] str;
+ str = new String[fontpath.size()];
+ for (int i = 0; i < str.length; ++i) {
+ str[i] = adapter.getItem(i + 3);
+ }
+ new AlertDialog.Builder(activity).setTitle(R.string.rem).setItems(str, this).setOnCancelListener(this).show();
+ }
+ else {
+ remove(which);
+ }
+ }
+
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ spinner.setSelection(fidx == 0 ? 0 : fidx + 2);
+ }
+
+ public void onFileChosen(String path) {
+ if (path.endsWith(".zip")) {
+ new FileChooser(activity, this, path).onClick(null, -1);
+ return;
+ }
+ if (add(path)) {
+ spinner.setSelection(adapter.getCount() - 1);
+ }
+ else {
+ Toast.makeText(activity, R.string.cantopen, Toast.LENGTH_SHORT).show();
+ try {
+ if (path.startsWith(activity.getFilesDir().getCanonicalPath())) {
+ new File(path).delete();
+ }
+ }
+ catch (IOException ignored) {}
+ spinner.setSelection(0);
+ }
+ }
+
+ public void onFileCancel() {
+ spinner.setSelection(fidx == 0 ? 0 : fidx + 2);
+ }
}
diff --git a/app/src/main/java/jp/ddo/hotmist/unicodepad/PageAdapter.java b/app/src/main/java/jp/ddo/hotmist/unicodepad/PageAdapter.java
index 6f050aa..442e919 100644
--- a/app/src/main/java/jp/ddo/hotmist/unicodepad/PageAdapter.java
+++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/PageAdapter.java
@@ -186,6 +186,15 @@ public boolean onItemLongClick(final AdapterView> arg0, final View arg1, final
return true;
}
+ public void clearRecents()
+ {
+ arec.clear();
+ }
+ public void clearFavorites()
+ {
+ afav.clear();
+ }
+
private AlertDialog dlg;
void showDesc(final View view, int index, final UnicodeAdapter ua)
diff --git a/app/src/main/java/jp/ddo/hotmist/unicodepad/RecentAdapter.java b/app/src/main/java/jp/ddo/hotmist/unicodepad/RecentAdapter.java
index b775da8..309f44b 100644
--- a/app/src/main/java/jp/ddo/hotmist/unicodepad/RecentAdapter.java
+++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/RecentAdapter.java
@@ -1,126 +1,121 @@
-/*
- Copyright 2018 Ryosuke839
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
package jp.ddo.hotmist.unicodepad;
-import java.util.ArrayList;
-
import android.content.SharedPreferences;
-class RecentAdapter extends UnicodeAdapter
-{
- private ArrayList list;
- private ArrayList temp;
- static int maxitems = 16;
-
- RecentAdapter(SharedPreferences pref, NameDatabase db, boolean single)
- {
- super(db, single);
-
- list = new ArrayList<>();
- temp = list;
- String str = pref.getString("rec", "");
- int num = 0;
- for (int i = 0; i < str.length(); ++i)
- {
- if (str.codePointAt(i) > 0xFFFF)
- ++i;
- ++num;
- }
- for (int i = 0; i < str.length(); ++i)
- {
- int code = str.codePointAt(i);
- if (code > 0xFFFF)
- ++i;
- if (--num < maxitems)
- list.add(code);
- }
- }
-
- @Override
- int name()
- {
- return R.string.recent;
- }
-
- @Override
- void show()
- {
- trunc();
- if (grid != null)
- grid.invalidateViews();
- }
-
- @Override
- void leave()
- {
- commit();
- if (grid != null)
- grid.invalidateViews();
- }
-
- @Override
- public int getCount()
- {
- return temp.size();
- }
-
- @Override
- public long getItemId(int arg0)
- {
- return temp.get(temp.size() - arg0 - 1);
- }
-
- void add(int code)
- {
- list.remove(Integer.valueOf(code));
- list.add(code);
- if (list.size() >= maxitems)
- list.remove(0);
- }
-
- void remove(int code)
- {
- list.remove(Integer.valueOf(code));
- if (list != temp)
- temp.remove(Integer.valueOf(code));
-
- if (grid != null)
- grid.invalidateViews();
- }
-
- private void commit()
- {
- if (list != temp)
- temp = list;
- }
-
- private void trunc()
- {
- if (list == temp)
- temp = new ArrayList<>(list);
- }
-
- @Override
- void save(SharedPreferences.Editor edit)
- {
- String str = "";
- for (Integer i : list)
- str += String.valueOf(Character.toChars(i));
- edit.putString("rec", str);
- }
+import java.util.ArrayList;
+import java.util.Collections;
+
+class RecentAdapter extends UnicodeAdapter {
+ private ArrayList list;
+ private ArrayList temp;
+ boolean sorted;
+ static int maxitems = 16;
+
+ RecentAdapter(SharedPreferences pref, NameDatabase db, boolean single) {
+ super(db, single);
+ sorted = pref.getBoolean("sort_recents", true);
+
+ list = new ArrayList<>();
+ temp = list;
+ String rec = pref.getString("rec", "");
+ int num = 0;
+ for (int i = 0; i < rec.length(); ++i) {
+ if (rec.codePointAt(i) > 0xFFFF) {
+ ++i;
+ }
+ ++num;
+ }
+ for (int i = 0; i < rec.length(); ++i) {
+ int code = rec.codePointAt(i);
+ if (code > 0xFFFF) {
+ ++i;
+ }
+ if (--num < maxitems) {
+ list.add(code);
+ }
+ }
+ }
+
+ @Override
+ int name() {
+ return R.string.recent;
+ }
+
+ @Override
+ void show() {
+ trunc();
+ if (grid != null) {
+ grid.invalidateViews();
+ }
+ }
+
+ @Override
+ void leave() {
+ commit();
+ if (grid != null) {
+ grid.invalidateViews();
+ }
+ }
+
+ @Override
+ public int getCount() {
+ return temp.size();
+ }
+
+ @Override
+ public long getItemId(int arg0) {
+ return temp.get(temp.size() - arg0 - 1);
+ }
+
+ void add(int code) {
+ list.remove(Integer.valueOf(code));
+ list.add(code);
+ if (sorted) {
+ Collections.sort(list);
+ Collections.reverse(list);
+ }
+ if (list.size() >= maxitems) {
+ list.remove(0);
+ }
+ }
+
+ void remove(int code) {
+ list.remove(Integer.valueOf(code));
+ if (list != temp) {
+ temp.remove(Integer.valueOf(code));
+ }
+ if (grid != null) {
+ grid.invalidateViews();
+ }
+ }
+
+ void clear() {
+ temp.clear();
+ list.clear();
+ if (grid != null) {
+ grid.invalidateViews();
+ }
+ }
+
+ private void commit() {
+ if (list != temp) {
+ temp = list;
+ }
+ }
+
+ private void trunc() {
+ if (list == temp) {
+ temp = new ArrayList<>(list);
+ }
+ }
+
+ @Override
+ void save(SharedPreferences.Editor edit) {
+ StringBuilder str = new StringBuilder();
+ for (Integer i : list) {
+ str.append(String.valueOf(Character.toChars(i)));
+ }
+ edit.putString("rec", str.toString());
+ }
}
diff --git a/app/src/main/java/jp/ddo/hotmist/unicodepad/SettingActivity.java b/app/src/main/java/jp/ddo/hotmist/unicodepad/SettingActivity.java
index 6b8a8a0..490b5dd 100644
--- a/app/src/main/java/jp/ddo/hotmist/unicodepad/SettingActivity.java
+++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/SettingActivity.java
@@ -1,19 +1,3 @@
-/*
- Copyright 2018 Ryosuke839
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
package jp.ddo.hotmist.unicodepad;
import android.content.Intent;
@@ -23,168 +7,165 @@
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
-import android.preference.Preference.OnPreferenceClickListener;
-import android.preference.PreferenceManager;
import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
+import android.preference.PreferenceManager;
import android.text.ClipboardManager;
import android.widget.Toast;
@SuppressWarnings("deprecation")
-public class SettingActivity extends PreferenceActivity implements OnPreferenceClickListener, OnPreferenceChangeListener
-{
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
- int[] themelist =
- {
- androidx.appcompat.R.style.Theme_AppCompat,
- androidx.appcompat.R.style.Theme_AppCompat_Light,
- androidx.appcompat.R.style.Theme_AppCompat_Light_DarkActionBar,
- };
- setTheme(themelist[Integer.valueOf(pref.getString("theme", "2131492983")) - 2131492983]);
- super.onCreate(savedInstanceState);
-
- addPreferencesFromResource(R.xml.setting);
-
- ListPreference univer = (ListPreference)findPreference("universion");
- univer.setOnPreferenceChangeListener(this);
- univer.setSummary(univer.getEntry());
-
- ListPreference emojicompat = (ListPreference)findPreference("emojicompat");
- emojicompat.setOnPreferenceChangeListener(this);
- emojicompat.setSummary(emojicompat.getEntry());
-
- Preference download = findPreference("download");
- download.setOnPreferenceClickListener(this);
-
- ListPreference theme = (ListPreference)findPreference("theme");
- theme.setOnPreferenceChangeListener(this);
- theme.setSummary(theme.getEntry());
-
- EditTextPreference textsize = (EditTextPreference)findPreference("textsize");
- textsize.setOnPreferenceChangeListener(this);
- textsize.setSummary(textsize.getText());
-
- ListPreference column = (ListPreference)findPreference("column");
- column.setOnPreferenceChangeListener(this);
- column.setSummary(column.getValue());
-
- ListPreference columnl = (ListPreference)findPreference("columnl");
- columnl.setOnPreferenceChangeListener(this);
- columnl.setSummary(columnl.getValue());
-
- Preference tabs = findPreference("tabs");
- tabs.setOnPreferenceClickListener(this);
-
- EditTextPreference padding = (EditTextPreference)findPreference("padding");
- padding.setOnPreferenceChangeListener(this);
- padding.setSummary(padding.getText());
-
- EditTextPreference gridsize = (EditTextPreference)findPreference("gridsize");
- gridsize.setOnPreferenceChangeListener(this);
- gridsize.setSummary(gridsize.getText());
-
- EditTextPreference viewsize = (EditTextPreference)findPreference("viewsize");
- viewsize.setOnPreferenceChangeListener(this);
- viewsize.setSummary(viewsize.getText());
-
- EditTextPreference checker = (EditTextPreference)findPreference("checker");
- checker.setOnPreferenceChangeListener(this);
- checker.setSummary(checker.getText());
-
- EditTextPreference recentsize = (EditTextPreference)findPreference("recentsize");
- recentsize.setOnPreferenceChangeListener(this);
- recentsize.setSummary(recentsize.getText());
-
- ListPreference scroll = (ListPreference)findPreference("scroll");
- scroll.setOnPreferenceChangeListener(this);
- scroll.setSummary(scroll.getEntry());
-
- Preference legal_app = findPreference("legal_app");
- legal_app.setOnPreferenceClickListener(this);
-
- Preference legal_uni = findPreference("legal_uni");
- legal_uni.setOnPreferenceClickListener(this);
-
- setResult(RESULT_OK);
- }
-
- @Override
- public boolean onPreferenceChange(Preference arg0, Object arg1)
- {
- if (arg0.hasKey())
- {
- String key = arg0.getKey();
- try
- {
- if (key.equals("column") ||
- key.equals("padding") ||
- key.equals("recentsize"))
- //noinspection ResultOfMethodCallIgnored: check string with exception
- Integer.valueOf(arg1.toString());
- if (key.equals("textsize") ||
- key.equals("gridsize") ||
- key.equals("viewsize") ||
- key.equals("checker"))
- //noinspection ResultOfMethodCallIgnored: check string with exception
- Float.valueOf(arg1.toString());
- }
- catch (NumberFormatException e)
- {
- return false;
- }
- if (key.equals("theme") || key.equals("emojicompat"))
- {
- Toast.makeText(this, R.string.theme_title, Toast.LENGTH_SHORT).show();
- setResult(RESULT_FIRST_USER);
- }
- }
- arg0.setSummary(arg0 instanceof ListPreference ? ((ListPreference)arg0).getEntries()[((ListPreference)arg0).findIndexOfValue(arg1.toString())] : arg1.toString());
- return true;
- }
-
- private boolean openPage(String uri)
- {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
- if (this.getPackageManager().queryIntentActivities(intent, 0).size() > 0)
- {
- // Show webpage
- startActivity(intent);
- }
- else
- {
- // Copy URI
- ((ClipboardManager)getSystemService(CLIPBOARD_SERVICE)).setText(uri);
- Toast.makeText(this, R.string.copied, Toast.LENGTH_SHORT).show();
- }
- return true;
- }
-
- @Override
- public boolean onPreferenceClick(Preference arg0)
- {
- String key = arg0.getKey();
- if (key.equals("download"))
- {
- return openPage(getString(R.string.download_uri));
- }
- if (key.equals("tabs"))
- {
- startActivity(new Intent(this, TabsActivity.class));
- return true;
- }
- if (key.equals("legal_app"))
- {
- return openPage("https://github.com/Ryosuke839/UnicodePad");
- }
- if (key.equals("legal_uni"))
- {
- return openPage("https://unicode.org/");
- }
-
- return false;
- }
+public class SettingActivity extends PreferenceActivity implements OnPreferenceClickListener, OnPreferenceChangeListener {
+ SharedPreferences pref;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ pref = PreferenceManager.getDefaultSharedPreferences(this);
+ int[] themelist = {
+ androidx.appcompat.R.style.Theme_AppCompat, androidx.appcompat.R.style.Theme_AppCompat_Light, androidx.appcompat.R.style.Theme_AppCompat_Light_DarkActionBar,
+ };
+ setTheme(themelist[Integer.parseInt(pref.getString("theme", "2131492983")) - 2131492983]);
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.settings);
+
+ ListPreference univer = (ListPreference)findPreference("universion");
+ univer.setOnPreferenceChangeListener(this);
+ univer.setSummary(univer.getEntry());
+
+ ListPreference emojicompat = (ListPreference)findPreference("emojicompat");
+ emojicompat.setOnPreferenceChangeListener(this);
+ emojicompat.setSummary(emojicompat.getEntry());
+
+ Preference download = findPreference("download");
+ download.setOnPreferenceClickListener(this);
+
+ ListPreference theme = (ListPreference)findPreference("theme");
+ theme.setOnPreferenceChangeListener(this);
+ theme.setSummary(theme.getEntry());
+
+ EditTextPreference textsize = (EditTextPreference)findPreference("textsize");
+ textsize.setOnPreferenceChangeListener(this);
+ textsize.setSummary(textsize.getText());
+
+ ListPreference column = (ListPreference)findPreference("column");
+ column.setOnPreferenceChangeListener(this);
+ column.setSummary(column.getValue());
+
+ ListPreference columnl = (ListPreference)findPreference("columnl");
+ columnl.setOnPreferenceChangeListener(this);
+ columnl.setSummary(columnl.getValue());
+
+ Preference tabs = findPreference("tabs");
+ tabs.setOnPreferenceClickListener(this);
+
+ Preference clearRecents = findPreference("clear_recents");
+ clearRecents.setOnPreferenceClickListener(this);
+
+ Preference clearFavorites = findPreference("clear_favorites");
+ clearFavorites.setOnPreferenceClickListener(this);
+
+ EditTextPreference padding = (EditTextPreference)findPreference("padding");
+ padding.setOnPreferenceChangeListener(this);
+ padding.setSummary(padding.getText());
+
+ EditTextPreference gridsize = (EditTextPreference)findPreference("gridsize");
+ gridsize.setOnPreferenceChangeListener(this);
+ gridsize.setSummary(gridsize.getText());
+
+ EditTextPreference viewsize = (EditTextPreference)findPreference("viewsize");
+ viewsize.setOnPreferenceChangeListener(this);
+ viewsize.setSummary(viewsize.getText());
+
+ EditTextPreference checker = (EditTextPreference)findPreference("checker");
+ checker.setOnPreferenceChangeListener(this);
+ checker.setSummary(checker.getText());
+
+ EditTextPreference recentsize = (EditTextPreference)findPreference("recentsize");
+ recentsize.setOnPreferenceChangeListener(this);
+ recentsize.setSummary(recentsize.getText());
+
+ ListPreference scroll = (ListPreference)findPreference("scroll");
+ scroll.setOnPreferenceChangeListener(this);
+ scroll.setSummary(scroll.getEntry());
+
+ Preference legal_app = findPreference("legal_app");
+ legal_app.setOnPreferenceClickListener(this);
+
+ Preference legal_uni = findPreference("legal_uni");
+ legal_uni.setOnPreferenceClickListener(this);
+
+ setResult(RESULT_OK);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference arg0, Object arg1) {
+ if (arg0.hasKey()) {
+ String key = arg0.getKey();
+ try {
+ if (key.equals("column") || key.equals("padding") || key.equals("recentsize")) {
+ Integer.valueOf(arg1.toString());
+ }
+ if (key.equals("textsize") || key.equals("gridsize") || key.equals("viewsize") || key.equals("checker")) {
+ Float.valueOf(arg1.toString());
+ }
+ }
+ catch (NumberFormatException e) {
+ return false;
+ }
+ if (key.equals("theme") || key.equals("emojicompat")) {
+ Toast.makeText(this, R.string.theme_title, Toast.LENGTH_SHORT).show();
+ setResult(RESULT_FIRST_USER);
+ }
+ }
+ arg0.setSummary(arg0 instanceof ListPreference ? ((ListPreference)arg0).getEntries()[((ListPreference)arg0).findIndexOfValue(arg1.toString())] : arg1.toString());
+ return true;
+ }
+
+ private boolean openPage(String uri) {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
+ if (this.getPackageManager().queryIntentActivities(intent, 0).size() > 0) {
+ // Show webpage
+ startActivity(intent);
+ }
+ else {
+ // Copy URI
+ ((ClipboardManager)getSystemService(CLIPBOARD_SERVICE)).setText(uri);
+ Toast.makeText(this, R.string.copied, Toast.LENGTH_SHORT).show();
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference arg0) {
+ String key = arg0.getKey();
+ if (key.equals("download")) {
+ return openPage(getString(R.string.download_uri));
+ }
+ if (key.equals("tabs")) {
+ startActivity(new Intent(this, TabsActivity.class));
+ return true;
+ }
+ if (key.equals("clear_recents")) {
+ Toast.makeText(this, "Recents Cleared", Toast.LENGTH_SHORT).show();
+ pref.edit().putString("rec", "").apply();
+ startActivityForResult(new Intent(this, UnicodeActivity.class), -3);
+ return true;
+ }
+ if (key.equals("clear_favorites")) {
+ Toast.makeText(this, "Favorites Cleared", Toast.LENGTH_SHORT).show();
+ pref.edit().putString("fav", "").apply();
+ startActivityForResult(new Intent(this, UnicodeActivity.class), -4);
+ return true;
+ }
+ if (key.equals("legal_app")) {
+ return openPage("https://github.com/Ryosuke839/UnicodePad");
+ }
+ if (key.equals("legal_uni")) {
+ return openPage("https://unicode.org/");
+ }
+
+ return false;
+ }
}
diff --git a/app/src/main/java/jp/ddo/hotmist/unicodepad/UnicodeActivity.java b/app/src/main/java/jp/ddo/hotmist/unicodepad/UnicodeActivity.java
index 4ed2b22..a9904d4 100644
--- a/app/src/main/java/jp/ddo/hotmist/unicodepad/UnicodeActivity.java
+++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/UnicodeActivity.java
@@ -17,27 +17,19 @@
package jp.ddo.hotmist.unicodepad;
import android.annotation.SuppressLint;
-
-import androidx.core.provider.FontRequest;
-import androidx.core.view.MenuItemCompat;
-import androidx.emoji.text.EmojiCompat;
-import androidx.emoji.text.FontRequestEmojiCompatConfig;
-import androidx.viewpager.widget.ViewPager;
-import androidx.appcompat.app.AppCompatActivity;
-
import android.app.Activity;
-import android.database.Cursor;
-import android.net.Uri;
-import android.provider.OpenableColumns;
-import android.text.ClipboardManager;
-import android.util.AttributeSet;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
+import android.database.Cursor;
import android.graphics.Typeface;
+import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import android.provider.OpenableColumns;
+import android.text.ClipboardManager;
+import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.Menu;
@@ -58,12 +50,19 @@
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.provider.FontRequest;
+import androidx.core.view.MenuItemCompat;
+import androidx.emoji.text.EmojiCompat;
+import androidx.emoji.text.FontRequestEmojiCompatConfig;
+import androidx.viewpager.widget.ViewPager;
+
+import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
+import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
-import com.google.android.gms.ads.AdRequest;
-import com.google.android.gms.ads.AdView;
import java.io.File;
import java.io.FileOutputStream;
@@ -72,523 +71,483 @@
import java.io.OutputStream;
import java.util.zip.CRC32;
-public class UnicodeActivity extends AppCompatActivity implements OnClickListener, OnTouchListener, OnEditorActionListener, FontChooser.Listener
-{
- private static final String ACTION_INTERCEPT = "com.adamrocker.android.simeji.ACTION_INTERCEPT";
- private static final String REPLACE_KEY = "replace_key";
- private static final String PID_KEY = "pid_key";
- private boolean isMush;
- private EditText editText;
- private ImageButton btnClear;
- private ImageButton btnDelete;
- private Button btnCopy;
- private Button btnFind;
- private Button btnPaste;
- private Button btnFinish;
- FontChooser chooser;
- private LockableScrollView scroll;
- private ViewPager pager;
- PageAdapter adpPage;
- private AdView adView;
- @SuppressWarnings("deprecation")
- private ClipboardManager cm;
- private SharedPreferences pref;
- private boolean disableime;
- private static float fontsize = 24.0f;
- static int univer = 1000;
-
- public View onCreateView(View parent, String name, Context context, AttributeSet attrs)
- {
- return super.onCreateView(parent, name, context, attrs);
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- pref = PreferenceManager.getDefaultSharedPreferences(this);
- onActivityResult(-1, 0, null);
- String useEmoji = pref.getString("emojicompat", "false");
- if (!useEmoji.equals("null"))
- {
- EmojiCompat.init(new FontRequestEmojiCompatConfig(this, new FontRequest(
- "com.google.android.gms.fonts",
- "com.google.android.gms",
- "Noto Color Emoji Compat",
- R.array.com_google_android_gms_fonts_certs))
- .setReplaceAll(useEmoji.equals("true"))
- .registerInitCallback(new EmojiCompat.InitCallback()
- {
- @Override
- public void onInitialized()
- {
- super.onInitialized();
- Typeface tf = oldtf;
- oldtf = null;
- setTypeface(tf);
- }
- }));
- }
- int[] themelist =
- {
- R.style.Theme,
- R.style.Theme_Light,
- R.style.Theme_Light_DarkActionBar,
- };
- setTheme(themelist[Integer.valueOf(pref.getString("theme", "2131492983")) - 2131492983]);
- super.onCreate(savedInstanceState);
- getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
- setContentView(useEmoji.equals("null") ? R.layout.main : R.layout.main_emojicompat);
- editText = (EditText)findViewById(R.id.text);
- editText.setOnTouchListener(this);
- editText.setTextSize(fontsize);
- btnClear = (ImageButton)findViewById(R.id.clear);
- btnClear.setOnClickListener(this);
- btnClear.setVisibility(pref.getBoolean("clear", false) ? View.VISIBLE : View.GONE);
- btnDelete = (ImageButton)findViewById(R.id.delete);
- btnDelete.setOnTouchListener(this);
- btnCopy = (Button)findViewById(R.id.copy);
- btnCopy.setOnClickListener(this);
- btnFind = (Button)findViewById(R.id.find);
- btnFind.setOnClickListener(this);
- btnPaste = (Button)findViewById(R.id.paste);
- btnPaste.setOnClickListener(this);
- btnFinish = (Button)findViewById(R.id.finish);
- btnFinish.setOnClickListener(this);
- chooser = new FontChooser(this, (Spinner)findViewById(R.id.font), this);
- scroll = (LockableScrollView)findViewById(R.id.scrollView);
- pager = (ViewPager)findViewById(R.id.cpager);
- pager.setOffscreenPageLimit(3);
- adpPage = new PageAdapter(this, pref, editText);
- pager.setAdapter(adpPage);
- scroll.setAdapter(adpPage);
- scroll.setLockView(pager, Integer.valueOf(pref.getString("scroll", "1")) + (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 0) > 1);
-
- //noinspection deprecation
- cm = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
- disableime = pref.getBoolean("ime", true);
-
- pager.setCurrentItem(Math.min(pref.getInt("page", 1), adpPage.getCount() - 1), false);
-
- Intent it = getIntent();
- String action = it.getAction();
- editText.setImeOptions(action != null && ACTION_INTERCEPT.equals(action) ? EditorInfo.IME_ACTION_DONE : EditorInfo.IME_ACTION_SEND);
- if (action != null && ACTION_INTERCEPT.equals(action))
- {
- isMush = true;
- String str = it.getStringExtra(REPLACE_KEY);
- if (str != null)
- editText.append(str);
- btnFinish.setText(R.string.finish);
- }
- else
- {
- isMush = false;
- btnFinish.setText(R.string.share);
- }
- if (action != null && Intent.ACTION_SEND.equals(action))
- {
- String str = it.getStringExtra(Intent.EXTRA_TEXT);
- if (str != null)
- editText.append(str);
- }
-
- if (!pref.getBoolean("no-ad", false))
- {
- try
- {
- MobileAds.initialize(this, new OnInitializationCompleteListener()
- {
- @Override
- public void onInitializationComplete(InitializationStatus initializationStatus)
- {
- }
- });
- adView = new AdView(this);
- DisplayMetrics outMetrics = new DisplayMetrics();
- getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
- adView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, (int)(outMetrics.widthPixels / outMetrics.density)));
- adView.setAdUnitId("ca-app-pub-8779692709020298/6882844952");
- ((LinearLayout)findViewById(R.id.adContainer)).addView(adView);
- AdRequest adRequest = new AdRequest.Builder().build();
- adView.loadAd(adRequest);
- }
- catch (NullPointerException e)
- {
- }
- }
- }
-
- @Override
- public void onWindowFocusChanged(boolean hasFocus)
- {
- super.onWindowFocusChanged(hasFocus);
-
- scroll.setLockView(pager, Integer.valueOf(pref.getString("scroll", "1")) + (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 0) > 1);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu)
- {
- MenuItem actionItem = menu.add("Setting");
- MenuItemCompat.setShowAsAction(actionItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
- actionItem.setIcon(android.R.drawable.ic_menu_preferences);
-
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item)
- {
- startActivityForResult(new Intent(this, SettingActivity.class), 0);
-
- return true;
- }
-
- @Override
- public void onPause()
- {
- SharedPreferences.Editor edit = pref.edit();
- adpPage.save(edit);
- chooser.Save(edit);
- edit.putInt("page", pager.getCurrentItem());
- edit.apply();
- super.onPause();
- }
-
- @Override
- public void onClick(View v)
- {
- if (v == btnClear)
- {
- editText.setText("");
- }
- if (v == btnCopy)
- {
- cm.setText(editText.getText().toString());
- Toast.makeText(this, R.string.copied, Toast.LENGTH_SHORT).show();
- }
- if (v == btnFind)
- {
- String str = editText.getEditableText().toString();
- if (str.length() == 0)
- return;
- int start = editText.getSelectionStart();
- if (start == -1)
- return;
- int end = editText.getSelectionEnd();
- adpPage.showDesc(null, str.codePointCount(0, start == end ? start == 0 ? 0 : start - 1 : Math.min(start, end)), new StringAdapter(str));
- }
- if (v == btnPaste)
- {
- editText.setText(cm.getText());
- }
- if (v == btnFinish)
- {
- if (isMush)
- {
- replace(editText.getText().toString());
- }
- else
- {
- Intent intent = new Intent();
- intent.setAction(Intent.ACTION_SEND);
- intent.setType("text/plain");
- intent.putExtra(Intent.EXTRA_TEXT, editText.getText().toString());
- startActivity(intent);
- }
- }
- }
-
- private Runnable delay = null;
- private int timer = 500;
-
- @SuppressLint("ClickableViewAccessibility")
- @Override
- public boolean onTouch(View v, MotionEvent event)
- {
- v.onTouchEvent(event);
- if (v == btnDelete)
- {
- switch (event.getAction())
- {
- case MotionEvent.ACTION_DOWN:
- if (delay == null)
- {
- delay = new Runnable()
- {
- @Override
- public void run()
- {
- String str = editText.getEditableText().toString();
- if (str.length() == 0)
- return;
- int start = editText.getSelectionStart();
- if (start < 1)
- return;
- int end = editText.getSelectionEnd();
- if (start < 1)
- return;
- if (start != end)
- editText.getEditableText().delete(Math.min(start, end), Math.max(start, end));
- else if (start > 1 && Character.isSurrogatePair(str.charAt(start - 2), str.charAt(start - 1)))
- editText.getEditableText().delete(start - 2, start);
- else
- editText.getEditableText().delete(start - 1, start);
-// editText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
- if (delay != null)
- {
- editText.postDelayed(delay, timer);
- if (timer > 100)
- timer -= 200;
- }
- }
- };
- editText.post(delay);
- }
- break;
- case MotionEvent.ACTION_UP:
- editText.removeCallbacks(delay);
- delay = null;
- timer = 500;
- break;
- }
- }
- if (v == editText)
- {
- if (disableime)
- ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(v.getWindowToken(), 0);
- }
- return true;
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent e)
- {
- if (e.getKeyCode() == KeyEvent.KEYCODE_MENU && e.getAction() == KeyEvent.ACTION_UP)
- {
- startActivityForResult(new Intent(this, SettingActivity.class), 0);
- return true;
- }
- return super.dispatchKeyEvent(e);
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data)
- {
- if (requestCode == FontChooser.FONT_REQUEST_CODE)
- if (resultCode == Activity.RESULT_OK && data != null)
- {
- Uri uri = data.getData();
- String name = uri.getPath();
- while (name.endsWith("/"))
- name = name.substring(0, name.length() - 1);
- if (name.contains(("/")))
- name = name.substring(name.lastIndexOf("/") + 1);
- Cursor cursor = getContentResolver().query( data.getData(), null, null, null, null);
- if (cursor != null)
- {
- if (cursor.moveToFirst())
- name = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
- cursor.close();
- }
- name.replaceAll("[?:\"*|/\\\\<>]", "_");
-
- try
- {
- InputStream is = getContentResolver().openInputStream(uri);
- File of = new File(getFilesDir(), "00000000/" + name);
- of.getParentFile().mkdirs();
- try
- {
- OutputStream os = new FileOutputStream(of);
- CRC32 crc = new CRC32();
- byte[] buf = new byte[256];
- int size;
- while ((size = is.read(buf)) > 0)
- {
- os.write(buf, 0, size);
- crc.update(buf, 0, size);
- }
- os.close();
- File mf = new File(getFilesDir(), String.format("%08x", crc.getValue()) + "/" + name);
- mf.getParentFile().mkdirs();
- of.renameTo(mf);
- chooser.onFileChosen(mf.getCanonicalPath());
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- is.close();
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- else
- chooser.onFileCancel();
- if (requestCode != -1)
- super.onActivityResult(requestCode, resultCode, data);
-
- if (resultCode == RESULT_FIRST_USER)
- {
- Intent intent = new Intent();
- intent.setClassName(getPackageName(), RestartActivity.class.getName());
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(PID_KEY, android.os.Process.myPid());
- startActivity(intent);
- finish();
- return;
- }
-
- try
- {
- fontsize = Float.valueOf(pref.getString("textsize", "24.0"));
- }
- catch (NumberFormatException e)
- {
- }
- try
- {
- univer = Integer.valueOf(pref.getString("universion", "Latest").replace(".", ""));
- }
- catch (NumberFormatException e)
- {
- univer = Integer.MAX_VALUE;
- }
- try
- {
- PageAdapter.column = Integer.valueOf(pref.getString("column", "8"));
- if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
- PageAdapter.column = Integer.valueOf(pref.getString("columnl", String.valueOf(PageAdapter.column)));
- }
- catch (NumberFormatException e)
- {
- }
- try
- {
- UnicodeAdapter.padding = Integer.valueOf(pref.getString("padding", "4"));
- }
- catch (NumberFormatException e)
- {
- }
- try
- {
- UnicodeAdapter.fontsize = Float.valueOf(pref.getString("gridsize", "24.0"));
- }
- catch (NumberFormatException e)
- {
- }
- try
- {
- CharacterAdapter.fontsize = Float.valueOf(pref.getString("viewsize", "120.0"));
- }
- catch (NumberFormatException e)
- {
- }
- try
- {
- CharacterAdapter.checker = Float.valueOf(pref.getString("checker", "15.0"));
- }
- catch (NumberFormatException e)
- {
- }
- CharacterAdapter.lines = pref.getBoolean("lines", true);
- UnicodeAdapter.shrink = pref.getBoolean("shrink", true);
- CharacterAdapter.shrink = pref.getBoolean("shrink", true);
- try
- {
- RecentAdapter.maxitems = Integer.valueOf(pref.getString("recentsize", "256"));
- }
- catch (NumberFormatException e)
- {
- }
- disableime = pref.getBoolean("ime", true);
- if (btnClear != null)
- btnClear.setVisibility(pref.getBoolean("clear", false) ? View.VISIBLE : View.GONE);
- if (editText != null)
- editText.setTextSize(fontsize);
- if (adpPage != null)
- adpPage.notifyDataSetChanged();
- if (scroll != null)
- scroll.setLockView(pager, Integer.valueOf(pref.getString("scroll", "1")) + (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 0) > 1);
- if (requestCode != -1)
- {
- LinearLayout adConteiner = (LinearLayout)findViewById(R.id.adContainer);
- if (adConteiner != null)
- {
- if (!pref.getBoolean("no-ad", false))
- {
- if (adConteiner.getChildCount() == 0)
- {
- MobileAds.initialize(this, new OnInitializationCompleteListener()
- {
- @Override
- public void onInitializationComplete(InitializationStatus initializationStatus)
- {
- }
- });
- adView = new AdView(this);
- DisplayMetrics outMetrics = new DisplayMetrics();
- getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
- adView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, (int)(outMetrics.widthPixels / outMetrics.density)));
- adView.setAdUnitId("ca-app-pub-8779692709020298/6882844952");
- ((LinearLayout)findViewById(R.id.adContainer)).addView(adView);
- AdRequest adRequest = new AdRequest.Builder().build();
- adView.loadAd(adRequest);
- }
- }
- else
- {
- if (adConteiner.getChildCount() > 0)
- {
- adConteiner.removeAllViews();
- }
- }
- }
- }
- }
-
- private void replace(String result)
- {
- Intent data = new Intent();
- data.putExtra(REPLACE_KEY, result);
- setResult(RESULT_OK, data);
- finish();
- }
-
- void setPage(int page)
- {
- pager.setCurrentItem(page);
- }
-
- public void onTypefaceChosen(Typeface typeface)
- {
- setTypeface(typeface);
- }
-
- private Typeface oldtf = null;
-
- private void setTypeface(Typeface tf)
- {
- if (tf == oldtf)
- return;
- oldtf = tf;
- editText.setTypeface(tf);
- adpPage.setTypeface(tf);
- }
-
- @Override
- public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2)
- {
- if (arg0 == editText && arg2 != null && arg2.getKeyCode() == KeyEvent.KEYCODE_ENTER)
- {
- if (arg2.getAction() == KeyEvent.ACTION_DOWN)
- btnFinish.performClick();
- return true;
- }
- return false;
- }
+public class UnicodeActivity extends AppCompatActivity implements OnClickListener, OnTouchListener, OnEditorActionListener, FontChooser.Listener {
+ private static final String ACTION_INTERCEPT = "com.adamrocker.android.simeji.ACTION_INTERCEPT";
+ private static final String REPLACE_KEY = "replace_key";
+ private static final String PID_KEY = "pid_key";
+ private boolean isMush;
+ private EditText editText;
+ private ImageButton btnDelete;
+ private Button btnPaste;
+ private Button btnCopy;
+ private Button btnClear;
+ private Button btnFind;
+ private Button btnShare;
+ FontChooser chooser;
+ private LockableScrollView scroll;
+ private ViewPager pager;
+ PageAdapter adpPage;
+ private AdView adView;
+ @SuppressWarnings("deprecation")
+ private ClipboardManager cm;
+ private SharedPreferences pref;
+ private boolean disableime;
+ private static float fontsize = 24.0f;
+ static int univer = 1000;
+
+ public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
+ return super.onCreateView(parent, name, context, attrs);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ pref = PreferenceManager.getDefaultSharedPreferences(this);
+ onActivityResult(-1, 0, null);
+ String useEmoji = pref.getString("emojicompat", "false");
+ if (!useEmoji.equals("null")) {
+ EmojiCompat.init(new FontRequestEmojiCompatConfig(this, new FontRequest("com.google.android.gms.fonts", "com.google.android.gms", "Noto Color Emoji Compat", R.array.com_google_android_gms_fonts_certs)).setReplaceAll(useEmoji.equals("true")).registerInitCallback(new EmojiCompat.InitCallback() {
+ @Override
+ public void onInitialized() {
+ super.onInitialized();
+ Typeface tf = oldtf;
+ oldtf = null;
+ setTypeface(tf);
+ }
+ }));
+ }
+ int[] themelist = {
+ R.style.Theme, R.style.Theme_Light, R.style.Theme_Light_DarkActionBar
+ };
+ setTheme(themelist[Integer.parseInt(pref.getString("theme", "2131492983")) - 2131492983]);
+ super.onCreate(savedInstanceState);
+ getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
+ setContentView(useEmoji.equals("null") ? R.layout.main : R.layout.main_emojicompat);
+ editText = findViewById(R.id.text);
+ editText.setOnTouchListener(this);
+ editText.setTextSize(fontsize);
+ btnClear = findViewById(R.id.clear);
+ btnClear.setOnClickListener(this);
+ btnClear.setVisibility(pref.getBoolean("clear", false) ? View.VISIBLE : View.GONE);
+ btnDelete = findViewById(R.id.delete);
+ btnDelete.setOnTouchListener(this);
+ btnCopy = findViewById(R.id.copy);
+ btnCopy.setOnClickListener(this);
+ btnFind = findViewById(R.id.find);
+ btnFind.setOnClickListener(this);
+ btnPaste = findViewById(R.id.paste);
+ btnPaste.setOnClickListener(this);
+ btnShare = findViewById(R.id.share);
+ btnShare.setOnClickListener(this);
+ chooser = new FontChooser(this, (Spinner)findViewById(R.id.font), this);
+ scroll = findViewById(R.id.scrollView);
+ pager = findViewById(R.id.cpager);
+ pager.setOffscreenPageLimit(3);
+ adpPage = new PageAdapter(this, pref, editText);
+ pager.setAdapter(adpPage);
+ scroll.setAdapter(adpPage);
+ scroll.setLockView(pager, Integer.parseInt(pref.getString("scroll", "1")) + (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 0) > 1);
+
+ //noinspection deprecation
+ cm = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
+ disableime = pref.getBoolean("ime", true);
+
+ pager.setCurrentItem(Math.min(pref.getInt("page", 1), adpPage.getCount() - 1), false);
+
+ Intent it = getIntent();
+ String action = it.getAction();
+ editText.setImeOptions(ACTION_INTERCEPT.equals(action) ? EditorInfo.IME_ACTION_DONE : EditorInfo.IME_ACTION_SEND);
+ if (ACTION_INTERCEPT.equals(action)) {
+ isMush = true;
+ String str = it.getStringExtra(REPLACE_KEY);
+ if (str != null) {
+ editText.append(str);
+ }
+ btnShare.setText(R.string.finish);
+ }
+ else {
+ isMush = false;
+ btnShare.setText(R.string.share);
+ }
+ if (Intent.ACTION_SEND.equals(action)) {
+ String str = it.getStringExtra(Intent.EXTRA_TEXT);
+ if (str != null) {
+ editText.append(str);
+ }
+ }
+
+ if (!pref.getBoolean("no-ad", false)) {
+ try {
+ MobileAds.initialize(this, new OnInitializationCompleteListener() {
+ @Override
+ public void onInitializationComplete(InitializationStatus initializationStatus) {
+ }
+ });
+ adView = new AdView(this);
+ DisplayMetrics outMetrics = new DisplayMetrics();
+ getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
+ adView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, (int)(outMetrics.widthPixels / outMetrics.density)));
+ adView.setAdUnitId("ca-app-pub-8779692709020298/6882844952");
+ ((LinearLayout)findViewById(R.id.adContainer)).addView(adView);
+ AdRequest adRequest = new AdRequest.Builder().build();
+ adView.loadAd(adRequest);
+ }
+ catch (NullPointerException ignored) {}
+ }
+ }
+
+ @Override
+ public void onWindowFocusChanged(boolean hasFocus) {
+ super.onWindowFocusChanged(hasFocus);
+ scroll.setLockView(pager, Integer.parseInt(pref.getString("scroll", "1")) + (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 0) > 1);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuItem actionItem = menu.add("Setting");
+ MenuItemCompat.setShowAsAction(actionItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
+ actionItem.setIcon(android.R.drawable.ic_menu_preferences);
+
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ startActivityForResult(new Intent(this, SettingActivity.class), 0);
+ return true;
+ }
+
+ @Override
+ public void onPause() {
+ SharedPreferences.Editor edit = pref.edit();
+ adpPage.save(edit);
+ chooser.save(edit);
+ edit.putInt("page", pager.getCurrentItem());
+ edit.apply();
+ super.onPause();
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (v == btnClear) {
+ editText.setText("");
+ }
+ if (v == btnCopy) {
+ cm.setText(editText.getText().toString());
+ Toast.makeText(this, R.string.copied, Toast.LENGTH_SHORT).show();
+ }
+ if (v == btnFind) {
+ String str = editText.getEditableText().toString();
+ if (str.length() == 0) {
+ return;
+ }
+ int start = editText.getSelectionStart();
+ if (start == -1) {
+ return;
+ }
+ int end = editText.getSelectionEnd();
+ adpPage.showDesc(null, str.codePointCount(0, start == end ? start == 0 ? 0 : start - 1 : Math.min(start, end)), new StringAdapter(str));
+ }
+ if (v == btnPaste) {
+ editText.setText(cm.getText());
+ }
+ if (v == btnShare) {
+ SharedPreferences.Editor edit = pref.edit();
+ adpPage.save(edit);
+ chooser.save(edit);
+
+ if (adpPage.getPageTitle(pager.getCurrentItem()) != null) {
+ if (adpPage.getPageTitle(pager.getCurrentItem()).equals("Favorite")) {
+ editText.setText(pref.getString("fav", ""));
+ }
+ if (adpPage.getPageTitle(pager.getCurrentItem()).equals("Recent")) {
+ String rec = new StringBuilder(pref.getString("rec", "")).reverse().toString();
+ editText.setText(rec);
+ }
+ editText.setSelection(editText.getText().length());
+ }
+ /*
+ if (isMush) {
+ replace(editText.getText().toString());
+ }
+ else {
+ Intent intent = new Intent();
+ intent.setAction(Intent.ACTION_SEND);
+ intent.setType("text/plain");
+ intent.putExtra(Intent.EXTRA_TEXT, editText.getText().toString());
+ startActivity(intent);
+ }
+ */
+ }
+ }
+
+ private Runnable delay = null;
+ private int timer = 500;
+
+ @SuppressLint("ClickableViewAccessibility")
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ v.onTouchEvent(event);
+ if (v == btnDelete) {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ if (delay == null) {
+ delay = new Runnable() {
+ @Override
+ public void run() {
+ String str = editText.getEditableText().toString();
+ if (str.length() == 0) {
+ return;
+ }
+ int start = editText.getSelectionStart();
+ if (start < 1) {
+ return;
+ }
+ int end = editText.getSelectionEnd();
+ if (start < 1) {
+ return;
+ }
+ if (start != end) {
+ editText.getEditableText().delete(Math.min(start, end), Math.max(start, end));
+ }
+ else if (start > 1 && Character.isSurrogatePair(str.charAt(start - 2), str.charAt(start - 1))) {
+ editText.getEditableText().delete(start - 2, start);
+ }
+ else {
+ editText.getEditableText().delete(start - 1, start);
+ }
+ // editText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
+ if (delay != null) {
+ editText.postDelayed(delay, timer);
+ if (timer > 100) {
+ timer -= 200;
+ }
+ }
+ }
+ };
+ editText.post(delay);
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ editText.removeCallbacks(delay);
+ delay = null;
+ timer = 500;
+ break;
+ }
+ }
+ if (v == editText) {
+ if (disableime) {
+ ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(v.getWindowToken(), 0);
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.KEYCODE_MENU && e.getAction() == KeyEvent.ACTION_UP) {
+ startActivityForResult(new Intent(this, SettingActivity.class), 0);
+ return true;
+ }
+ return super.dispatchKeyEvent(e);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == FontChooser.FONT_REQUEST_CODE) {
+ if (resultCode == Activity.RESULT_OK && data != null) {
+ Uri uri = data.getData();
+ String name = uri.getPath();
+ while (name.endsWith("/")) {
+ name = name.substring(0, name.length() - 1);
+ }
+ if (name.contains(("/"))) {
+ name = name.substring(name.lastIndexOf("/") + 1);
+ }
+ Cursor cursor = getContentResolver().query(data.getData(), null, null, null, null);
+ if (cursor != null) {
+ if (cursor.moveToFirst()) {
+ name = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
+ }
+ cursor.close();
+ }
+ name.replaceAll("[?:\"*|/\\\\<>]", "_");
+
+ try {
+ InputStream is = getContentResolver().openInputStream(uri);
+ File of = new File(getFilesDir(), "00000000/" + name);
+ of.getParentFile().mkdirs();
+ try {
+ OutputStream os = new FileOutputStream(of);
+ CRC32 crc = new CRC32();
+ byte[] buf = new byte[256];
+ int size;
+ while ((size = is.read(buf)) > 0) {
+ os.write(buf, 0, size);
+ crc.update(buf, 0, size);
+ }
+ os.close();
+ File mf = new File(getFilesDir(), String.format("%08x", crc.getValue()) + "/" + name);
+ mf.getParentFile().mkdirs();
+ of.renameTo(mf);
+ chooser.onFileChosen(mf.getCanonicalPath());
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ is.close();
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ else {
+ chooser.onFileCancel();
+ }
+ }
+ if (requestCode != -1) {
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
+ if (resultCode == RESULT_FIRST_USER) {
+ Intent intent = new Intent();
+ intent.setClassName(getPackageName(), RestartActivity.class.getName());
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.putExtra(PID_KEY, android.os.Process.myPid());
+ startActivity(intent);
+ finish();
+ return;
+ }
+
+ if (requestCode == -3) {
+ SharedPreferences.Editor editor = pref.edit();
+ adpPage.clearRecents();
+ adpPage.save(editor);
+ editor.apply();
+ }
+ if (requestCode == -4) {
+ SharedPreferences.Editor editor = pref.edit();
+ adpPage.clearFavorites();
+ adpPage.save(editor);
+ editor.apply();
+ }
+
+ try {
+ fontsize = Float.parseFloat(pref.getString("textsize", "24.0"));
+ }
+ catch (NumberFormatException ignored) {}
+ try {
+ univer = Integer.parseInt(pref.getString("universion", "Latest").replace(".", ""));
+ }
+ catch (NumberFormatException e) {
+ univer = Integer.MAX_VALUE;
+ }
+ try {
+ PageAdapter.column = Integer.parseInt(pref.getString("column", "8"));
+ if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ PageAdapter.column = Integer.parseInt(pref.getString("columnl", String.valueOf(PageAdapter.column)));
+ }
+ }
+ catch (NumberFormatException ignored) {}
+ try {
+ UnicodeAdapter.padding = Integer.parseInt(pref.getString("padding", "4"));
+ }
+ catch (NumberFormatException ignored) {}
+ try {
+ UnicodeAdapter.fontsize = Float.parseFloat(pref.getString("gridsize", "24.0"));
+ }
+ catch (NumberFormatException ignored) {}
+ try {
+ CharacterAdapter.fontsize = Float.parseFloat(pref.getString("viewsize", "120.0"));
+ }
+ catch (NumberFormatException ignored) {}
+ try {
+ CharacterAdapter.checker = Float.parseFloat(pref.getString("checker", "15.0"));
+ }
+ catch (NumberFormatException ignored) {}
+ CharacterAdapter.lines = pref.getBoolean("lines", true);
+ UnicodeAdapter.shrink = pref.getBoolean("shrink", true);
+ CharacterAdapter.shrink = pref.getBoolean("shrink", true);
+ try {
+ RecentAdapter.maxitems = Integer.parseInt(pref.getString("recentsize", "256"));
+ }
+ catch (NumberFormatException ignored) {}
+ disableime = pref.getBoolean("ime", true);
+ if (btnClear != null) {
+ btnClear.setVisibility(pref.getBoolean("clear", false) ? View.VISIBLE : View.GONE);
+ }
+ if (editText != null) {
+ editText.setTextSize(fontsize);
+ }
+ if (adpPage != null) {
+ adpPage.notifyDataSetChanged();
+ }
+ if (scroll != null) {
+ scroll.setLockView(pager, Integer.valueOf(pref.getString("scroll", "1")) + (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 0) > 1);
+ }
+ if (requestCode != -1) {
+ LinearLayout adConteiner = (LinearLayout)findViewById(R.id.adContainer);
+ if (adConteiner != null) {
+ if (!pref.getBoolean("no-ad", false)) {
+ if (adConteiner.getChildCount() == 0) {
+ MobileAds.initialize(this, new OnInitializationCompleteListener() {
+ @Override
+ public void onInitializationComplete(InitializationStatus initializationStatus) {
+ }
+ });
+ adView = new AdView(this);
+ DisplayMetrics outMetrics = new DisplayMetrics();
+ getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
+ adView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, (int)(outMetrics.widthPixels / outMetrics.density)));
+ adView.setAdUnitId("ca-app-pub-8779692709020298/6882844952");
+ ((LinearLayout)findViewById(R.id.adContainer)).addView(adView);
+ AdRequest adRequest = new AdRequest.Builder().build();
+ adView.loadAd(adRequest);
+ }
+ }
+ else {
+ if (adConteiner.getChildCount() > 0) {
+ adConteiner.removeAllViews();
+ }
+ }
+ }
+ }
+ }
+
+ private void replace(String result) {
+ Intent data = new Intent();
+ data.putExtra(REPLACE_KEY, result);
+ setResult(RESULT_OK, data);
+ finish();
+ }
+
+ void setPage(int page) {
+ pager.setCurrentItem(page);
+ }
+
+ public void onTypefaceChosen(Typeface typeface) {
+ setTypeface(typeface);
+ }
+
+ private Typeface oldtf = null;
+
+ private void setTypeface(Typeface tf) {
+ if (tf == oldtf) {
+ return;
+ }
+ oldtf = tf;
+ editText.setTypeface(tf);
+ adpPage.setTypeface(tf);
+ }
+
+ @Override
+ public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
+ if (arg0 == editText && arg2 != null && arg2.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
+ if (arg2.getAction() == KeyEvent.ACTION_DOWN) {
+ btnShare.performClick();
+ }
+ return true;
+ }
+ return false;
+ }
}
diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml
index 38a10b9..46d1450 100644
--- a/app/src/main/res/layout/main.xml
+++ b/app/src/main/res/layout/main.xml
@@ -1,35 +1,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+ android:text="@string/share" />
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/main_emojicompat.xml b/app/src/main/res/layout/main_emojicompat.xml
index e39841c..4976142 100644
--- a/app/src/main/res/layout/main_emojicompat.xml
+++ b/app/src/main/res/layout/main_emojicompat.xml
@@ -1,13 +1,9 @@
-
-
-
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:gravity="center_vertical"
+ android:orientation="vertical">
-
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
-
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1">
-
+ android:id="@+id/text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:ems="10"
+ android:inputType="text"
+ android:maxLines="1">
-
-
-
-
-
+ android:id="@+id/delete"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="center_vertical"
+ android:adjustViewBounds="false"
+ android:contentDescription="@string/erase"
+ android:cropToPadding="false"
+ android:scaleType="centerInside"
+ app:srcCompat="?attr/backspace" />
-
-
+ android:id="@+id/scrollView"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1">
-
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
-
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
-
+ android:id="@+id/paste"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:maxLines="1"
+ android:text="@android:string/paste" />
-
+ android:id="@+id/clear"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:maxLines="1"
+ android:text="@string/clear" />
-
+ android:id="@+id/find"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:maxLines="1"
+ android:text="@string/desc" />
+ android:id="@+id/copy"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:maxLines="1"
+ android:text="@android:string/copy" />
+
-
-
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
-
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:paddingStart="8dp"
+ android:paddingLeft="8dp"
+ android:paddingEnd="0dp"
+ android:paddingRight="0dp"
+ android:text="@string/font"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
-
+ android:id="@+id/font"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1" />
-
-
+ android:id="@+id/cpager"
+ android:layout_width="match_parent"
+ android:layout_height="128dp">
+ android:id="@+id/ctab"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top" />
-
-
+ android:id="@+id/adContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
-
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b2a7c34..c15a3f2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -420,7 +420,7 @@
Disable IME
Show clear button
- ⌧
+ Clear
⌫
⚙
⌃
diff --git a/app/src/main/res/xml/setting.xml b/app/src/main/res/xml/settings.xml
similarity index 87%
rename from app/src/main/res/xml/setting.xml
rename to app/src/main/res/xml/settings.xml
index 712aa03..6b2b0be 100644
--- a/app/src/main/res/xml/setting.xml
+++ b/app/src/main/res/xml/settings.xml
@@ -1,21 +1,5 @@
-
-
@@ -52,7 +36,7 @@
android:summary="@string/theme_title"
android:title="@string/theme_desc" />
+
+
+
+
-