diff --git a/app/src/main/java/app/pachli/StatusListActivity.kt b/app/src/main/java/app/pachli/StatusListActivity.kt
index a4278f422..3a485fbe4 100644
--- a/app/src/main/java/app/pachli/StatusListActivity.kt
+++ b/app/src/main/java/app/pachli/StatusListActivity.kt
@@ -26,15 +26,19 @@ import androidx.fragment.app.commit
import androidx.lifecycle.lifecycleScope
import app.pachli.appstore.EventHub
import app.pachli.appstore.FilterChangedEvent
+import app.pachli.components.compose.ComposeActivity
import app.pachli.components.timeline.TimelineFragment
import app.pachli.components.timeline.TimelineKind
import app.pachli.databinding.ActivityStatuslistBinding
import app.pachli.entity.Filter
import app.pachli.entity.FilterV1
+import app.pachli.interfaces.ActionButtonActivity
import app.pachli.interfaces.AppBarLayoutHost
+import app.pachli.util.unsafeLazy
import app.pachli.util.viewBinding
import at.connyduck.calladapter.networkresult.fold
import com.google.android.material.appbar.AppBarLayout
+import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
@@ -47,7 +51,7 @@ import javax.inject.Inject
* the user's favourites, bookmarks, etc.
*/
@AndroidEntryPoint
-class StatusListActivity : BottomSheetActivity(), AppBarLayoutHost {
+class StatusListActivity : BottomSheetActivity(), AppBarLayoutHost, ActionButtonActivity {
@Inject
lateinit var eventHub: EventHub
@@ -57,6 +61,8 @@ class StatusListActivity : BottomSheetActivity(), AppBarLayoutHost {
override val appBarLayout: AppBarLayout
get() = binding.includedToolbar.appbar
+ override val actionButton: FloatingActionButton? by unsafeLazy { binding.composeButton }
+
/**
* If showing statuses with a hashtag, the hashtag being used, without the
* leading `#`.
@@ -103,6 +109,27 @@ class StatusListActivity : BottomSheetActivity(), AppBarLayoutHost {
replace(R.id.fragmentContainer, fragment)
}
}
+
+ val composeIntent = when (timelineKind) {
+ is TimelineKind.Tag -> {
+ val tag = (timelineKind as TimelineKind.Tag).tags.first()
+ ComposeActivity.startIntent(
+ this,
+ ComposeActivity.ComposeOptions(
+ content = getString(R.string.title_tag_with_initial_position).format(tag),
+ initialCursorPosition = ComposeActivity.InitialCursorPosition.START,
+ ),
+ )
+ }
+ else -> null
+ }
+
+ if (composeIntent == null) {
+ binding.composeButton.hide()
+ } else {
+ binding.composeButton.setOnClickListener { startActivity(composeIntent) }
+ binding.composeButton.show()
+ }
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
diff --git a/app/src/main/java/app/pachli/components/compose/ComposeActivity.kt b/app/src/main/java/app/pachli/components/compose/ComposeActivity.kt
index cad6a7b5a..5c143c3a9 100644
--- a/app/src/main/java/app/pachli/components/compose/ComposeActivity.kt
+++ b/app/src/main/java/app/pachli/components/compose/ComposeActivity.kt
@@ -260,7 +260,7 @@ class ComposeActivity :
}
setupLanguageSpinner(getInitialLanguages(composeOptions?.language, activeAccount))
- setupComposeField(sharedPreferencesRepository, viewModel.startingText)
+ setupComposeField(sharedPreferencesRepository, viewModel.startingText, composeOptions)
setupContentWarningField(composeOptions?.contentWarning)
setupPollView()
applyShareIntent(intent, savedInstanceState)
@@ -364,7 +364,11 @@ class ComposeActivity :
binding.composeContentWarningField.doOnTextChanged { _, _, _, _ -> updateVisibleCharactersLeft() }
}
- private fun setupComposeField(preferences: SharedPreferencesRepository, startingText: String?) {
+ private fun setupComposeField(
+ preferences: SharedPreferencesRepository,
+ startingText: String?,
+ composeOptions: ComposeOptions?,
+ ) {
binding.composeEditField.setOnReceiveContentListener(this)
binding.composeEditField.setOnKeyListener { _, keyCode, event -> this.onKeyDown(keyCode, event) }
@@ -380,7 +384,13 @@ class ComposeActivity :
binding.composeEditField.setTokenizer(ComposeTokenizer())
binding.composeEditField.setText(startingText)
- binding.composeEditField.setSelection(binding.composeEditField.length())
+
+ when (composeOptions?.initialCursorPosition ?: InitialCursorPosition.END) {
+ InitialCursorPosition.START -> binding.composeEditField.setSelection(0)
+ InitialCursorPosition.END -> binding.composeEditField.setSelection(
+ binding.composeEditField.length(),
+ )
+ }
val mentionColour = binding.composeEditField.linkTextColors.defaultColor
highlightSpans(binding.composeEditField.text, mentionColour)
@@ -1305,6 +1315,15 @@ class ComposeActivity :
EDIT_SCHEDULED,
}
+ /**
+ * Initial position of the cursor in EditText when the compose button is clicked
+ * in a hashtag timeline
+ */
+ enum class InitialCursorPosition {
+ START,
+ END,
+ }
+
@Parcelize
data class ComposeOptions(
// Let's keep fields var until all consumers are Kotlin
@@ -1329,6 +1348,7 @@ class ComposeActivity :
var language: String? = null,
var statusId: String? = null,
var kind: ComposeKind? = null,
+ var initialCursorPosition: InitialCursorPosition = InitialCursorPosition.END,
) : Parcelable
companion object {
diff --git a/app/src/main/res/layout/activity_statuslist.xml b/app/src/main/res/layout/activity_statuslist.xml
index 398f9a893..b92513ae9 100644
--- a/app/src/main/res/layout/activity_statuslist.xml
+++ b/app/src/main/res/layout/activity_statuslist.xml
@@ -16,6 +16,15 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+
diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml
index da498e603..52babbfb9 100644
--- a/app/src/main/res/values/donottranslate.xml
+++ b/app/src/main/res/values/donottranslate.xml
@@ -9,6 +9,7 @@
\@
#
#%s
+ " #%s"
:%s:
%s *
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d92961ec4..09b1812a4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -841,7 +841,7 @@
An update is available
Don\'t remind me for this version
Never remind me
-
+
Translating…
- %1$s
+ %1$s