diff --git a/app/src/main/java/org/pixeldroid/app/postCreation/PostCreationActivity.kt b/app/src/main/java/org/pixeldroid/app/postCreation/PostCreationActivity.kt index 72f7bbdc..9a4f50bc 100644 --- a/app/src/main/java/org/pixeldroid/app/postCreation/PostCreationActivity.kt +++ b/app/src/main/java/org/pixeldroid/app/postCreation/PostCreationActivity.kt @@ -93,6 +93,8 @@ class PostCreationActivity : BaseThemedWithoutBarActivity() { ) } + model.setExistingDescription(intent.getStringExtra(PICTURE_DESCRIPTION)) + lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { model.uiState.collect { uiState -> diff --git a/app/src/main/java/org/pixeldroid/app/postCreation/PostCreationViewModel.kt b/app/src/main/java/org/pixeldroid/app/postCreation/PostCreationViewModel.kt index 47d54d9c..1fbcbeb3 100644 --- a/app/src/main/java/org/pixeldroid/app/postCreation/PostCreationViewModel.kt +++ b/app/src/main/java/org/pixeldroid/app/postCreation/PostCreationViewModel.kt @@ -23,6 +23,7 @@ import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import kotlinx.parcelize.Parcelize import org.pixeldroid.app.R +import org.pixeldroid.app.posts.fromHtml import org.pixeldroid.app.utils.PixelDroidApplication import org.pixeldroid.app.utils.db.entities.InstanceDatabaseEntity import org.pixeldroid.app.utils.di.PixelfedAPIHolder @@ -80,6 +81,7 @@ class PostCreationViewModel(application: Application, clipdata: ClipData? = null it.value = clipdata?.let { it1 -> addPossibleImages(it1, mutableListOf()) } } } + private var existingDescription: String? = null @Inject lateinit var apiHolder: PixelfedAPIHolder @@ -92,7 +94,7 @@ class PostCreationViewModel(application: Application, clipdata: ClipData? = null PreferenceManager.getDefaultSharedPreferences(application) val initialDescription = sharedPreferences.getString("prefill_description", "") ?: "" - _uiState = MutableStateFlow(PostCreationActivityUiState(newPostDescriptionText = initialDescription)) + _uiState = MutableStateFlow(PostCreationActivityUiState(newPostDescriptionText = existingDescription ?: initialDescription)) } val uiState: StateFlow = _uiState @@ -193,6 +195,10 @@ class PostCreationViewModel(application: Application, clipdata: ClipData? = null photoData.value = photoData.value } + fun setExistingDescription(description: String?) { + existingDescription = description + } + fun removeAt(currentPosition: Int) { photoData.value?.removeAt(currentPosition) _uiState.update { @@ -209,6 +215,7 @@ class PostCreationViewModel(application: Application, clipdata: ClipData? = null fun nextStep(context: Context) { val intent = Intent(context, PostSubmissionActivity::class.java) intent.putExtra(PostSubmissionActivity.PHOTO_DATA, getPhotoData().value?.let { ArrayList(it) }) + intent.putExtra(PostSubmissionActivity.PICTURE_DESCRIPTION, existingDescription) ContextCompat.startActivity(context, intent, null) } diff --git a/app/src/main/java/org/pixeldroid/app/postCreation/PostSubmissionActivity.kt b/app/src/main/java/org/pixeldroid/app/postCreation/PostSubmissionActivity.kt index 6ead56d7..adf0cafc 100644 --- a/app/src/main/java/org/pixeldroid/app/postCreation/PostSubmissionActivity.kt +++ b/app/src/main/java/org/pixeldroid/app/postCreation/PostSubmissionActivity.kt @@ -69,6 +69,8 @@ class PostSubmissionActivity : BaseThemedWithoutBarActivity() { } model = _model + model.setExistingDescription(intent.getStringExtra(PICTURE_DESCRIPTION)) + lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { model.uiState.collect { uiState -> diff --git a/app/src/main/java/org/pixeldroid/app/postCreation/PostSubmissionViewModel.kt b/app/src/main/java/org/pixeldroid/app/postCreation/PostSubmissionViewModel.kt index 816046f1..02e8c677 100644 --- a/app/src/main/java/org/pixeldroid/app/postCreation/PostSubmissionViewModel.kt +++ b/app/src/main/java/org/pixeldroid/app/postCreation/PostSubmissionViewModel.kt @@ -62,6 +62,7 @@ class PostSubmissionViewModel(application: Application, photodata: ArrayList = _uiState @@ -288,6 +289,10 @@ class PostSubmissionViewModel(application: Application, photodata: ArrayList