From 8900e45015d50153664e9236ea6490db1b302de8 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 9 Dec 2019 02:26:54 +0300 Subject: [PATCH] markdown: now markdown mode is restored from drafts --- .../java/com/keylesspalace/tusky/ComposeActivity.java | 11 ++++++++--- .../com/keylesspalace/tusky/SavedTootActivity.java | 1 + .../keylesspalace/tusky/service/SendTootService.kt | 3 ++- .../com/keylesspalace/tusky/util/SaveTootHelper.java | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index e775e858..f2b22a07 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -561,7 +561,8 @@ public final class ComposeActivity } if(intent.hasExtra(MARKDOWN_MODE_EXTRA)) { - enableMarkdownMode(intent.getBooleanExtra(MARKDOWN_MODE_EXTRA, false)); + // button will be activated later, when we get instance info + markdownMode = intent.getBooleanExtra(MARKDOWN_MODE_EXTRA, false); } } @@ -809,7 +810,7 @@ public final class ComposeActivity private void enableMarkdownMode(boolean enable) { markdownMode = enable; - + TransitionManager.beginDelayedTransition((ViewGroup) markdownButton.getParent()); @ColorInt int color; @@ -865,6 +866,7 @@ public final class ComposeActivity emojiButton.setClickable(false); hideMediaToggle.setClickable(false); scheduleButton.setClickable(false); + markdownButton.setClickable(false); tootButton.setEnabled(false); } @@ -874,6 +876,7 @@ public final class ComposeActivity emojiButton.setClickable(true); hideMediaToggle.setClickable(true); scheduleButton.setClickable(true); + markdownButton.setClickable(true); tootButton.setEnabled(true); } @@ -1903,7 +1906,8 @@ public final class ComposeActivity getIntent().getStringExtra(REPLYING_STATUS_CONTENT_EXTRA), getIntent().getStringExtra(REPLYING_STATUS_AUTHOR_USERNAME_EXTRA), statusVisibility, - poll); + poll, + markdownMode); finishWithoutSlideOutAnimation(); } @@ -2040,6 +2044,7 @@ public final class ComposeActivity if ((isPleroma = instance.isPleroma())) { // TODO: implement nodeinfo later enableButton(markdownButton, true, true); + enableMarkdownMode(markdownMode); // we always can add new poll but only one if (poll == null) diff --git a/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java b/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java index 8bf6565b..614bb459 100644 --- a/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java @@ -164,6 +164,7 @@ public final class SavedTootActivity extends BaseActivity implements SavedTootAd .replyingStatusContent(item.getInReplyToText()) .visibility(item.getVisibility()) .poll(item.getPoll()) + .markdownMode(item.getMarkdownMode()) .build(this); startActivity(intent); } diff --git a/app/src/main/java/com/keylesspalace/tusky/service/SendTootService.kt b/app/src/main/java/com/keylesspalace/tusky/service/SendTootService.kt index 459935ce..9652e2e0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/service/SendTootService.kt +++ b/app/src/main/java/com/keylesspalace/tusky/service/SendTootService.kt @@ -261,7 +261,8 @@ class SendTootService : Service(), Injectable { toot.replyingStatusContent, toot.replyingStatusAuthorUsername, Status.Visibility.byString(toot.visibility), - toot.poll) + toot.poll, + toot.markdownMode) } private fun cancelSendingIntent(tootId: Int): PendingIntent { diff --git a/app/src/main/java/com/keylesspalace/tusky/util/SaveTootHelper.java b/app/src/main/java/com/keylesspalace/tusky/util/SaveTootHelper.java index edc8ab92..649389e9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/SaveTootHelper.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/SaveTootHelper.java @@ -51,7 +51,8 @@ public final class SaveTootHelper { @Nullable String replyingStatusContent, @Nullable String replyingStatusAuthorUsername, @NonNull Status.Visibility statusVisibility, - @Nullable NewPoll poll) { + @Nullable NewPoll poll, + @Nullable Boolean markdownMode) { if (TextUtils.isEmpty(content) && mediaUris.isEmpty() && poll == null) { return false; @@ -89,7 +90,7 @@ public final class SaveTootHelper { replyingStatusContent, replyingStatusAuthorUsername, statusVisibility, - poll); + poll, markdownMode); new AsyncTask() { @Override