mirror of
https://github.com/accelforce/Yuito
synced 2024-12-21 12:34:51 +01:00
Add option to disable quick compose
This commit is contained in:
parent
83025f93c3
commit
10acf4088d
@ -25,14 +25,7 @@ import com.keylesspalace.tusky.components.compose.ComposeActivity.ComposeOptions
|
||||
import com.keylesspalace.tusky.db.AccountManager
|
||||
import com.keylesspalace.tusky.di.Injectable
|
||||
import com.keylesspalace.tusky.entity.Notification
|
||||
import com.keylesspalace.tusky.settings.AppTheme
|
||||
import com.keylesspalace.tusky.settings.PrefKeys
|
||||
import com.keylesspalace.tusky.settings.emojiPreference
|
||||
import com.keylesspalace.tusky.settings.listPreference
|
||||
import com.keylesspalace.tusky.settings.makePreferenceScreen
|
||||
import com.keylesspalace.tusky.settings.preference
|
||||
import com.keylesspalace.tusky.settings.preferenceCategory
|
||||
import com.keylesspalace.tusky.settings.switchPreference
|
||||
import com.keylesspalace.tusky.settings.*
|
||||
import com.keylesspalace.tusky.util.ThemeUtils
|
||||
import com.keylesspalace.tusky.util.deserialize
|
||||
import com.keylesspalace.tusky.util.getNonNullString
|
||||
@ -185,6 +178,13 @@ class PreferencesFragment : PreferenceFragmentCompat(), Injectable {
|
||||
setTitle(R.string.pref_title_animate_custom_emojis)
|
||||
isSingleLineTitle = false
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
setDefaultValue(true)
|
||||
key = PrefKeys.USE_QUICK_TOOT
|
||||
setTitle(R.string.pref_title_use_quick_toot)
|
||||
isSingleLineTitle = false
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory(R.string.pref_title_limited_bandwidth_settings) {
|
||||
|
@ -32,6 +32,7 @@ object PrefKeys {
|
||||
const val CONFIRM_REBLOGS = "confirmReblogs"
|
||||
const val ENABLE_SWIPE_FOR_TABS = "enableSwipeForTabs"
|
||||
const val ANIMATE_CUSTOM_EMOJIS = "animateCustomEmojis"
|
||||
const val USE_QUICK_TOOT = "useQuickToot"
|
||||
|
||||
const val LIMITED_BANDWIDTH_ACTIVE = "limitedBandwidthActive"
|
||||
const val LIMITED_BANDWIDTH_ONLY_MOBILE_NETWORK = "limitedBandwidthOnlyMobileNetwork"
|
||||
|
@ -17,7 +17,9 @@ import com.keylesspalace.tusky.components.compose.ComposeActivity
|
||||
import com.keylesspalace.tusky.components.compose.ComposeActivity.Companion.PREF_DEFAULT_TAG
|
||||
import com.keylesspalace.tusky.components.compose.ComposeActivity.Companion.PREF_USE_DEFAULT_TAG
|
||||
import com.keylesspalace.tusky.databinding.ViewQuickTootBinding
|
||||
import com.keylesspalace.tusky.settings.PrefKeys.USE_QUICK_TOOT
|
||||
import com.keylesspalace.tusky.util.ThemeUtils
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class QuickTootView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
@ -27,10 +29,16 @@ class QuickTootView @JvmOverloads constructor(
|
||||
|
||||
private val binding = ViewQuickTootBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
|
||||
private val preference by lazy { PreferenceManager.getDefaultSharedPreferences(context) }
|
||||
private val preference = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
private lateinit var viewModel: QuickTootViewModel
|
||||
|
||||
private var bypass by Delegates.notNull<Boolean>()
|
||||
|
||||
init {
|
||||
syncBypass()
|
||||
}
|
||||
|
||||
fun attachViewModel(viewModel: QuickTootViewModel, owner: LifecycleOwner) {
|
||||
this.viewModel = viewModel
|
||||
|
||||
@ -79,18 +87,40 @@ class QuickTootView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun syncBypass() {
|
||||
bypass = !preference.getBoolean(USE_QUICK_TOOT, true)
|
||||
visibility = when (bypass) {
|
||||
true -> GONE
|
||||
false -> VISIBLE
|
||||
}
|
||||
if (bypass) {
|
||||
viewModel.reset()
|
||||
}
|
||||
}
|
||||
|
||||
fun onFABClicked(view: View) {
|
||||
val intent = ComposeActivity.startIntent(view.context, viewModel.composeOptions(false))
|
||||
startCompose(view.context)
|
||||
}
|
||||
|
||||
private fun startCompose(context: Context) {
|
||||
val intent = ComposeActivity.startIntent(context, viewModel.composeOptions(false))
|
||||
viewModel.reset()
|
||||
view.context.startActivity(intent)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
fun handleEvent(event: Event?) {
|
||||
when (event) {
|
||||
is QuickReplyEvent -> viewModel.reply(event)
|
||||
is QuickReplyEvent -> {
|
||||
viewModel.reply(event.status.actionableStatus)
|
||||
if (bypass) {
|
||||
startCompose(context)
|
||||
}
|
||||
}
|
||||
is PreferenceChangedEvent -> {
|
||||
if (event.preferenceKey in arrayOf(PREF_DEFAULT_TAG, PREF_USE_DEFAULT_TAG)) {
|
||||
syncDefaultTag()
|
||||
when (event.preferenceKey) {
|
||||
PREF_DEFAULT_TAG,
|
||||
PREF_USE_DEFAULT_TAG -> syncDefaultTag()
|
||||
USE_QUICK_TOOT -> syncBypass()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package net.accelf.yuito
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.keylesspalace.tusky.appstore.QuickReplyEvent
|
||||
import com.keylesspalace.tusky.components.compose.ComposeActivity
|
||||
import com.keylesspalace.tusky.components.compose.ComposeActivity.Companion.CAN_USE_UNLEAKABLE
|
||||
import com.keylesspalace.tusky.components.compose.mutableLiveData
|
||||
@ -57,8 +56,7 @@ class QuickTootViewModel @Inject constructor(
|
||||
visibilityMutable.value = overrideTo
|
||||
}
|
||||
|
||||
fun reply(event: QuickReplyEvent) {
|
||||
val status = event.status.actionableStatus
|
||||
fun reply(status: Status) {
|
||||
inReplyToMutable.value = status
|
||||
overrideVisibility(status.visibility)
|
||||
}
|
||||
|
@ -478,4 +478,5 @@
|
||||
<string name="status_media_audio">音声</string>
|
||||
<string name="mute_domain_warning_dialog_ok">ドメイン全体を非表示</string>
|
||||
<string name="about_powered_by_tusky">Tuskyによって提供されています</string>
|
||||
<string name="pref_title_use_quick_toot">簡易投稿欄を表示</string>
|
||||
</resources>
|
||||
|
@ -271,6 +271,7 @@
|
||||
<string name="pref_title_animate_gif_avatars">Animate GIF avatars</string>
|
||||
<string name="pref_title_gradient_for_media">Show colorful gradients for hidden media</string>
|
||||
<string name="pref_title_animate_custom_emojis">Animate custom emojis</string>
|
||||
<string name="pref_title_use_quick_toot">Use quick compose field</string>
|
||||
|
||||
<string name="pref_title_status_filter">Timeline filtering</string>
|
||||
<string name="pref_title_status_tabs">Tabs</string>
|
||||
|
Loading…
Reference in New Issue
Block a user