From f3a64cd98c0c6111d9be1a234177414f6ce739f7 Mon Sep 17 00:00:00 2001 From: Matthew Morrone Date: Tue, 15 Dec 2020 18:18:50 -0500 Subject: [PATCH 1/2] move clear button to button row, add settings to clear recents and favorites --- .idea/codeStyleSettings.xml | 228 ------------------ .idea/codeStyles/Project.xml | 184 -------------- .idea/codeStyles/codeStyleConfig.xml | 5 - .idea/gradle.xml | 3 +- .idea/inspectionProfiles/Project_Default.xml | 10 + .idea/jarRepositories.xml | 30 +++ .idea/runConfigurations.xml | 15 -- .../hotmist/unicodepad/FavoriteAdapter.java | 5 + .../ddo/hotmist/unicodepad/PageAdapter.java | 9 + .../ddo/hotmist/unicodepad/RecentAdapter.java | 10 + .../hotmist/unicodepad/SettingActivity.java | 24 +- .../hotmist/unicodepad/UnicodeActivity.java | 21 +- app/src/main/res/layout/main.xml | 21 +- app/src/main/res/layout/main_emojicompat.xml | 20 +- app/src/main/res/values/strings.xml | 2 +- app/src/main/res/xml/setting.xml | 6 + 16 files changed, 131 insertions(+), 462 deletions(-) delete mode 100644 .idea/codeStyleSettings.xml delete mode 100644 .idea/codeStyles/Project.xml delete mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/jarRepositories.xml delete mode 100644 .idea/runConfigurations.xml 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 @@ - - - - - - \ 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..fbe509c 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,12 +1,12 @@ - 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/src/main/java/jp/ddo/hotmist/unicodepad/FavoriteAdapter.java b/app/src/main/java/jp/ddo/hotmist/unicodepad/FavoriteAdapter.java index f8788f3..38693a3 100644 --- a/app/src/main/java/jp/ddo/hotmist/unicodepad/FavoriteAdapter.java +++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/FavoriteAdapter.java @@ -86,6 +86,11 @@ void remove(int code) list.remove(Integer.valueOf(code)); } + void clear() + { + list.clear(); + } + private void commit() { if (list != temp) 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..37a1ae7 100644 --- a/app/src/main/java/jp/ddo/hotmist/unicodepad/RecentAdapter.java +++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/RecentAdapter.java @@ -102,6 +102,16 @@ void remove(int code) grid.invalidateViews(); } + void clear() + { + temp.clear(); + list.clear(); + if (grid != null) + { + grid.invalidateViews(); + } + } + private void commit() { if (list != temp) 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..28553e9 100644 --- a/app/src/main/java/jp/ddo/hotmist/unicodepad/SettingActivity.java +++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/SettingActivity.java @@ -33,10 +33,12 @@ @SuppressWarnings("deprecation") public class SettingActivity extends PreferenceActivity implements OnPreferenceClickListener, OnPreferenceChangeListener { + SharedPreferences pref; + @Override protected void onCreate(Bundle savedInstanceState) { - SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); + pref = PreferenceManager.getDefaultSharedPreferences(this); int[] themelist = { androidx.appcompat.R.style.Theme_AppCompat, @@ -78,6 +80,12 @@ protected void onCreate(Bundle savedInstanceState) 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()); @@ -175,6 +183,20 @@ public boolean onPreferenceClick(Preference arg0) 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"); 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..c9741c6 100644 --- a/app/src/main/java/jp/ddo/hotmist/unicodepad/UnicodeActivity.java +++ b/app/src/main/java/jp/ddo/hotmist/unicodepad/UnicodeActivity.java @@ -79,11 +79,11 @@ public class UnicodeActivity extends AppCompatActivity implements OnClickListene private static final String PID_KEY = "pid_key"; private boolean isMush; private EditText editText; - private ImageButton btnClear; private ImageButton btnDelete; + private Button btnPaste; private Button btnCopy; + private Button btnClear; private Button btnFind; - private Button btnPaste; private Button btnFinish; FontChooser chooser; private LockableScrollView scroll; @@ -141,7 +141,7 @@ public void onInitialized() editText = (EditText)findViewById(R.id.text); editText.setOnTouchListener(this); editText.setTextSize(fontsize); - btnClear = (ImageButton)findViewById(R.id.clear); + btnClear = (Button)findViewById(R.id.clear); btnClear.setOnClickListener(this); btnClear.setVisibility(pref.getBoolean("clear", false) ? View.VISIBLE : View.GONE); btnDelete = (ImageButton)findViewById(R.id.delete); @@ -442,6 +442,21 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) 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.valueOf(pref.getString("textsize", "24.0")); diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml index 38a10b9..3a2a0b3 100644 --- a/app/src/main/res/layout/main.xml +++ b/app/src/main/res/layout/main.xml @@ -42,18 +42,6 @@ - - +