From b32a7523d1caa8e4f05f459520d117740aad3e18 Mon Sep 17 00:00:00 2001 From: Levi Bard Date: Fri, 2 Oct 2020 18:32:46 +0200 Subject: [PATCH] Save draft when redrafting a post (#1744) --- .../java/com/keylesspalace/tusky/SavedTootActivity.java | 3 ++- .../tusky/components/compose/ComposeActivity.kt | 3 ++- .../tusky/components/compose/ComposeViewModel.kt | 7 ++++--- .../java/com/keylesspalace/tusky/fragment/SFragment.java | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java b/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java index 1119a819..7b9e192a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/SavedTootActivity.java @@ -179,7 +179,8 @@ public final class SavedTootActivity extends BaseActivity implements SavedTootAd /*scheduledAt*/null, /*sensitive*/null, /*poll*/null, - item.getFormattingSyntax() + item.getFormattingSyntax(), + /* modifiedInitialState */ true ); Intent intent = ComposeActivity.startIntent(this, composeOptions); startActivity(intent); diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt index cc22ccd1..36f68b7c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt @@ -1317,7 +1317,8 @@ class ComposeActivity : BaseActivity(), var scheduledAt: String? = null, var sensitive: Boolean? = null, var poll: NewPoll? = null, - var formattingSyntax: String? = null + var formattingSyntax: String? = null, + var modifiedInitialState: Boolean? = null ) : Parcelable companion object { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt index 1eed870b..a0457f68 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt @@ -63,6 +63,7 @@ class ComposeViewModel private var startingVisibility: Status.Visibility = Status.Visibility.UNKNOWN private var contentWarningStateChanged: Boolean = false public var formattingSyntax: String = "" + private var modifiedInitialState: Boolean = false val markMediaAsSensitive = mutableLiveData(accountManager.activeAccount?.defaultMediaSensitivity ?: false) @@ -88,7 +89,7 @@ class ComposeViewModel val mediaChanged = !media.value.isNullOrEmpty() val pollChanged = poll.value != null - return textChanged || contentWarningChanged || mediaChanged || pollChanged + return modifiedInitialState || textChanged || contentWarningChanged || mediaChanged || pollChanged } fun contentWarningChanged(value: Boolean) { @@ -186,7 +187,7 @@ class ComposeViewModel preferredVisibility.num.coerceAtLeast(replyVisibility.num)) inReplyToId = composeOptions?.inReplyToId - + modifiedInitialState = composeOptions?.modifiedInitialState == true val contentWarning = composeOptions?.contentWarning if (contentWarning != null) { @@ -266,4 +267,4 @@ class ComposeViewModel private companion object { const val TAG = "ComposeViewModel" } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java index bc7dba69..2d7935db 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java @@ -487,6 +487,7 @@ public abstract class SFragment extends BaseFragment implements Injectable { composeOptions.setContentWarning(deletedStatus.getSpoilerText()); composeOptions.setMediaAttachments(deletedStatus.getAttachments()); composeOptions.setSensitive(deletedStatus.getSensitive()); + composeOptions.setModifiedInitialState(true); if (deletedStatus.getPoll() != null) { composeOptions.setPoll(deletedStatus.getPoll().toNewPoll(deletedStatus.getCreatedAt())); }