kopia lustrzana https://github.com/ryukoposting/Signal-Android
Add internal prefs page for launching stories dialogs.
rodzic
a39b09c314
commit
9e094dfc2b
|
@ -463,14 +463,6 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
|||
|
||||
sectionHeaderPref(R.string.ConversationListTabs__stories)
|
||||
|
||||
switchPref(
|
||||
title = DSLSettingsText.from(R.string.preferences__internal_disable_stories),
|
||||
isChecked = state.disableStories,
|
||||
onClick = {
|
||||
viewModel.toggleStories()
|
||||
}
|
||||
)
|
||||
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.preferences__internal_clear_onboarding_state),
|
||||
summary = DSLSettingsText.from(R.string.preferences__internal_clears_onboarding_flag_and_triggers_download_of_onboarding_stories),
|
||||
|
@ -479,6 +471,13 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
|||
viewModel.onClearOnboardingState()
|
||||
}
|
||||
)
|
||||
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.preferences__internal_stories_dialog_launcher),
|
||||
onClick = {
|
||||
findNavController().safeNavigate(InternalSettingsFragmentDirections.actionInternalSettingsFragmentToStoryDialogsLauncherFragment())
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,5 @@ data class InternalSettingsState(
|
|||
val removeSenderKeyMinimium: Boolean,
|
||||
val delayResends: Boolean,
|
||||
val disableStorageService: Boolean,
|
||||
val disableStories: Boolean,
|
||||
val canClearOnboardingState: Boolean
|
||||
)
|
||||
|
|
|
@ -94,12 +94,6 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
|||
refresh()
|
||||
}
|
||||
|
||||
fun toggleStories() {
|
||||
val newState = !SignalStore.storyValues().isFeatureDisabled
|
||||
SignalStore.storyValues().isFeatureDisabled = newState
|
||||
store.update { getState().copy(disableStories = newState) }
|
||||
}
|
||||
|
||||
fun addSampleReleaseNote() {
|
||||
repository.addSampleReleaseNote()
|
||||
}
|
||||
|
@ -124,7 +118,6 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
|||
removeSenderKeyMinimium = SignalStore.internalValues().removeSenderKeyMinimum(),
|
||||
delayResends = SignalStore.internalValues().delayResends(),
|
||||
disableStorageService = SignalStore.internalValues().storageServiceDisabled(),
|
||||
disableStories = SignalStore.storyValues().isFeatureDisabled,
|
||||
canClearOnboardingState = SignalStore.storyValues().hasDownloadedOnboardingStory && Stories.isFeatureEnabled()
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.thoughtcrime.securesms.components.settings.app.internal
|
||||
|
||||
import android.widget.Toast
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.settings.DSLConfiguration
|
||||
import org.thoughtcrime.securesms.components.settings.DSLSettingsFragment
|
||||
import org.thoughtcrime.securesms.components.settings.DSLSettingsText
|
||||
import org.thoughtcrime.securesms.components.settings.configure
|
||||
import org.thoughtcrime.securesms.stories.dialogs.StoryDialogs
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingAdapter
|
||||
|
||||
class StoryDialogLauncherFragment : DSLSettingsFragment(titleId = R.string.preferences__internal_stories_dialog_launcher) {
|
||||
override fun bindAdapter(adapter: MappingAdapter) {
|
||||
adapter.submitList(getConfiguration().toMappingModelList())
|
||||
}
|
||||
|
||||
private fun getConfiguration(): DSLConfiguration {
|
||||
return configure {
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.preferences__internal_retry_send),
|
||||
onClick = {
|
||||
StoryDialogs.resendStory(requireContext()) {
|
||||
Toast.makeText(requireContext(), R.string.preferences__internal_retry_send, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.preferences__internal_story_or_profile_selector),
|
||||
onClick = {
|
||||
StoryDialogs.displayStoryOrProfileImage(
|
||||
context = requireContext(),
|
||||
onViewStory = { Toast.makeText(requireContext(), R.string.StoryDialogs__view_story, Toast.LENGTH_SHORT).show() },
|
||||
onViewAvatar = { Toast.makeText(requireContext(), R.string.StoryDialogs__view_profile_photo, Toast.LENGTH_SHORT).show() }
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.preferences__internal_hide_story),
|
||||
onClick = {
|
||||
StoryDialogs.hideStory(requireContext(), "Spiderman") {
|
||||
Toast.makeText(requireContext(), R.string.preferences__internal_hide_story, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -493,6 +493,9 @@
|
|||
<action
|
||||
android:id="@+id/action_internalSettingsFragment_to_donorErrorConfigurationFragment"
|
||||
app:destination="@id/donorErrorConfigurationFragment" />
|
||||
<action
|
||||
android:id="@+id/action_internalSettingsFragment_to_storyDialogsLauncherFragment"
|
||||
app:destination="@id/storyDialogsLauncherFragment" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
|
@ -500,6 +503,11 @@
|
|||
android:name="org.thoughtcrime.securesms.components.settings.app.internal.donor.DonorErrorConfigurationFragment"
|
||||
android:label="donor_error_configuration_fragment" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/storyDialogsLauncherFragment"
|
||||
android:name="org.thoughtcrime.securesms.components.settings.app.internal.StoryDialogLauncherFragment"
|
||||
android:label="story_dialogs_launcher_fragment" />
|
||||
|
||||
<!-- endregion -->
|
||||
|
||||
<!-- Subscriptions -->
|
||||
|
|
|
@ -2749,6 +2749,10 @@
|
|||
<string name="configurable_single_select__customize_option">Customize option</string>
|
||||
|
||||
<!-- Internal only preferences -->
|
||||
<string name="preferences__internal_hide_story" translatable="false">Hide story</string>
|
||||
<string name="preferences__internal_story_or_profile_selector" translatable="false">Story or profile selector</string>
|
||||
<string name="preferences__internal_stories_dialog_launcher" translatable="false">Stories dialog launcher</string>
|
||||
<string name="preferences__internal_retry_send" translatable="false">Retry send</string>
|
||||
<string name="preferences__internal_clear_onboarding_state" translatable="false">Clear onboarding state</string>
|
||||
<string name="preferences__internal_clears_onboarding_flag_and_triggers_download_of_onboarding_stories" translatable="false">Clears onboarding flag and triggers download of onboarding stories.</string>
|
||||
<string name="preferences__internal_preferences" translatable="false">Internal Preferences</string>
|
||||
|
|
Ładowanie…
Reference in New Issue