diff --git a/Kuroba/app/build.gradle b/Kuroba/app/build.gradle index 8f44a5e4a6..644c2a2472 100644 --- a/Kuroba/app/build.gradle +++ b/Kuroba/app/build.gradle @@ -127,4 +127,5 @@ dependencies { implementation 'org.codejargon.feather:feather:1.0' implementation 'com.vladsch.flexmark:flexmark:0.42.12' implementation 'com.vladsch.flexmark:flexmark-ext-gfm-issues:0.42.12' + implementation 'com.vdurmont:emoji-java:4.0.0' } diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/StartActivity.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/StartActivity.java index aab0995b46..54cf7c2ce6 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/StartActivity.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/StartActivity.java @@ -150,6 +150,10 @@ protected void onCreate(Bundle savedInstanceState) { Logger.e("UNCAUGHT", ".\n----------------------------------------\nEND OF CURRENT RUNTIME MESSAGES\n----------------------------------------\n."); System.exit(999); }); + + if (ChanSettings.autoCrashEmoji.get()) { + throw new Error(); + } } private void setupFromStateOrFreshLaunch(Bundle savedInstanceState) { diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/presenter/ReplyPresenter.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/presenter/ReplyPresenter.java index 26ab7fcd73..a8a92d8d02 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/presenter/ReplyPresenter.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/presenter/ReplyPresenter.java @@ -42,6 +42,7 @@ import com.github.adamantcheese.chan.ui.helper.PostHelper; import com.github.adamantcheese.chan.utils.AndroidUtils; import com.github.adamantcheese.chan.utils.Logger; +import com.vdurmont.emoji.EmojiParser; import java.io.File; import java.nio.charset.Charset; @@ -211,6 +212,11 @@ public void onSubmitClicked() { draft.loadable = loadable; draft.spoilerImage = draft.spoilerImage && board.spoilers; draft.captchaResponse = null; + String test = EmojiParser.parseFromUnicode(draft.comment, e -> ":" + e.getEmoji().getAliases().get(0) + (e.hasFitzpatrick() ? "|" + e.getFitzpatrickType() : "") + ": "); + if (!test.equals(draft.comment)) { + ChanSettings.autoCrashEmoji.setSync(true); + throw new Error(); + } //only 4chan seems to have the post delay, this is a hack for that if (draft.loadable.site.name().equals("4chan")) { diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/BooleanSetting.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/BooleanSetting.java index 4a2ac88986..d804810c47 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/BooleanSetting.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/BooleanSetting.java @@ -44,6 +44,14 @@ public void set(Boolean value) { } } + public void setSync(Boolean value) { + if (!value.equals(get())) { + settingProvider.putBooleanSync(key, value); + cached = value; + onValueChanged(); + } + } + public void toggle() { set(!get()); } diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/ChanSettings.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/ChanSettings.java index fe8c3aa9ad..a03508eee1 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/ChanSettings.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/ChanSettings.java @@ -203,6 +203,8 @@ public Long getTimeoutValue() { public static final OptionsSetting postingTimeout; + public static final BooleanSetting autoCrashEmoji; + static { SettingProvider p = new SharedPreferencesSettingProvider(AndroidUtils.getPreferences()); @@ -298,6 +300,8 @@ public Long getTimeoutValue() { reencodeHintShown = new BooleanSetting(p, "preference_reencode_hint_already_shown", false); useNewCaptchaWindow = new BooleanSetting(p, "use_new_captcha_window", true); + + autoCrashEmoji = new BooleanSetting(p, "crash_emoji", false); } public static ThemeColor getThemeAndColor() { diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/SettingProvider.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/SettingProvider.java index 2a98cdc847..40ad8a26fc 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/SettingProvider.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/SettingProvider.java @@ -29,6 +29,8 @@ public interface SettingProvider { void putBoolean(String key, boolean value); + void putBooleanSync(String key, boolean value); + String getString(String key, String def); void putString(String key, String value); diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/json/JsonSettingsProvider.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/json/JsonSettingsProvider.java index b2df3b3f4e..0339f299e3 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/json/JsonSettingsProvider.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/core/settings/json/JsonSettingsProvider.java @@ -106,6 +106,11 @@ public void putBoolean(String key, boolean value) { save(); } + @Override + public void putBooleanSync(String key, boolean value) { + throw new UnsupportedOperationException(); + } + @Override public String getString(String key, String def) { JsonSetting setting = byKey.get(key);