Skip to content

Commit

Permalink
Readd emoji lmao
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamantcheese committed Jun 20, 2019
1 parent 4b95143 commit dd4a9f6
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions Kuroba/app/build.gradle
Expand Up @@ -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'
}
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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")) {
Expand Down
Expand Up @@ -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());
}
Expand Down
Expand Up @@ -203,6 +203,8 @@ public Long getTimeoutValue() {

public static final OptionsSetting<PostingTimeout> postingTimeout;

public static final BooleanSetting autoCrashEmoji;

static {
SettingProvider p = new SharedPreferencesSettingProvider(AndroidUtils.getPreferences());

Expand Down Expand Up @@ -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() {
Expand Down
Expand Up @@ -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);
Expand Down
Expand Up @@ -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);
Expand Down

0 comments on commit dd4a9f6

Please sign in to comment.