mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Merge pull request #472 from vector-im/feature/vectorPref
Dagger for VectorPreferences and /markdown command as a bonus
This commit is contained in:
commit
6d4ee83e65
@ -3,6 +3,7 @@ Changes in RiotX 0.3.0 (2019-XX-XX)
|
|||||||
|
|
||||||
Features:
|
Features:
|
||||||
- Create Direct Room flow
|
- Create Direct Room flow
|
||||||
|
- Handle `/markdown` command
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
- UI for pending edits (#193)
|
- UI for pending edits (#193)
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package im.vector.riotx.fdroid.features.settings.troubleshoot
|
package im.vector.riotx.fdroid.features.settings.troubleshoot
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.resources.StringProvider
|
import im.vector.riotx.core.resources.StringProvider
|
||||||
import im.vector.riotx.features.settings.VectorPreferences
|
import im.vector.riotx.features.settings.VectorPreferences
|
||||||
@ -25,12 +24,12 @@ import javax.inject.Inject
|
|||||||
/**
|
/**
|
||||||
* Test that the application is started on boot
|
* Test that the application is started on boot
|
||||||
*/
|
*/
|
||||||
class TestAutoStartBoot @Inject constructor(private val context: AppCompatActivity,
|
class TestAutoStartBoot @Inject constructor(private val vectorPreferences: VectorPreferences,
|
||||||
private val stringProvider: StringProvider)
|
private val stringProvider: StringProvider)
|
||||||
: TroubleshootTest(R.string.settings_troubleshoot_test_service_boot_title) {
|
: TroubleshootTest(R.string.settings_troubleshoot_test_service_boot_title) {
|
||||||
|
|
||||||
override fun perform() {
|
override fun perform() {
|
||||||
if (VectorPreferences.autoStartOnBoot(context)) {
|
if (vectorPreferences.autoStartOnBoot()) {
|
||||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_service_boot_success)
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_service_boot_success)
|
||||||
status = TestStatus.SUCCESS
|
status = TestStatus.SUCCESS
|
||||||
quickFix = null
|
quickFix = null
|
||||||
@ -38,7 +37,7 @@ class TestAutoStartBoot @Inject constructor(private val context: AppCompatActivi
|
|||||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_service_boot_failed)
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_service_boot_failed)
|
||||||
quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_service_boot_quickfix) {
|
quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_service_boot_quickfix) {
|
||||||
override fun doFix() {
|
override fun doFix() {
|
||||||
VectorPreferences.setAutoStartOnBoot(context, true)
|
vectorPreferences.setAutoStartOnBoot(true)
|
||||||
manager?.retry()
|
manager?.retry()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,9 @@ object FcmHelper {
|
|||||||
AlarmSyncBroadcastReceiver.cancelAlarm(context)
|
AlarmSyncBroadcastReceiver.cancelAlarm(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onEnterBackground(context: Context, activeSessionHolder: ActiveSessionHolder) {
|
fun onEnterBackground(context: Context, vectorPreferences: VectorPreferences, activeSessionHolder: ActiveSessionHolder) {
|
||||||
//We need to use alarm in this mode
|
//We need to use alarm in this mode
|
||||||
if (VectorPreferences.areNotificationEnabledForDevice(context) && activeSessionHolder.hasActiveSession()) {
|
if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) {
|
||||||
val currentSession = activeSessionHolder.getActiveSession()
|
val currentSession = activeSessionHolder.getActiveSession()
|
||||||
AlarmSyncBroadcastReceiver.scheduleAlarm(context, currentSession.myUserId, 4_000L)
|
AlarmSyncBroadcastReceiver.scheduleAlarm(context, currentSession.myUserId, 4_000L)
|
||||||
Timber.i("Alarm scheduled to restart service")
|
Timber.i("Alarm scheduled to restart service")
|
||||||
|
@ -52,6 +52,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
private lateinit var notifiableEventResolver: NotifiableEventResolver
|
private lateinit var notifiableEventResolver: NotifiableEventResolver
|
||||||
private lateinit var pusherManager: PushersManager
|
private lateinit var pusherManager: PushersManager
|
||||||
private lateinit var activeSessionHolder: ActiveSessionHolder
|
private lateinit var activeSessionHolder: ActiveSessionHolder
|
||||||
|
private lateinit var vectorPreferences: VectorPreferences
|
||||||
|
|
||||||
// UI handler
|
// UI handler
|
||||||
private val mUIHandler by lazy {
|
private val mUIHandler by lazy {
|
||||||
@ -64,6 +65,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
notifiableEventResolver = vectorComponent().notifiableEventResolver()
|
notifiableEventResolver = vectorComponent().notifiableEventResolver()
|
||||||
pusherManager = vectorComponent().pusherManager()
|
pusherManager = vectorComponent().pusherManager()
|
||||||
activeSessionHolder = vectorComponent().activeSessionHolder()
|
activeSessionHolder = vectorComponent().activeSessionHolder()
|
||||||
|
vectorPreferences = vectorComponent().vectorPreferences()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +74,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
* @param message the message
|
* @param message the message
|
||||||
*/
|
*/
|
||||||
override fun onMessageReceived(message: RemoteMessage?) {
|
override fun onMessageReceived(message: RemoteMessage?) {
|
||||||
if (!VectorPreferences.areNotificationEnabledForDevice(applicationContext)) {
|
if (!vectorPreferences.areNotificationEnabledForDevice()) {
|
||||||
Timber.i("Notification are disabled for this device")
|
Timber.i("Notification are disabled for this device")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -107,7 +109,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
if (refreshedToken == null) {
|
if (refreshedToken == null) {
|
||||||
Timber.w("onNewToken:received null token")
|
Timber.w("onNewToken:received null token")
|
||||||
} else {
|
} else {
|
||||||
if (VectorPreferences.areNotificationEnabledForDevice(applicationContext) && activeSessionHolder.hasActiveSession()) {
|
if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) {
|
||||||
pusherManager.registerPusherWithFcmKey(refreshedToken)
|
pusherManager.registerPusherWithFcmKey(refreshedToken)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import com.google.firebase.iid.FirebaseInstanceId
|
|||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.di.ActiveSessionHolder
|
import im.vector.riotx.core.di.ActiveSessionHolder
|
||||||
import im.vector.riotx.core.pushers.PushersManager
|
import im.vector.riotx.core.pushers.PushersManager
|
||||||
|
import im.vector.riotx.features.settings.VectorPreferences
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,7 +106,7 @@ object FcmHelper {
|
|||||||
// No op
|
// No op
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onEnterBackground(context: Context, activeSessionHolder: ActiveSessionHolder) {
|
fun onEnterBackground(context: Context, vectorPreferences: VectorPreferences, activeSessionHolder: ActiveSessionHolder) {
|
||||||
// TODO FCM fallback
|
// TODO FCM fallback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ import im.vector.riotx.core.di.DaggerVectorComponent
|
|||||||
import im.vector.riotx.core.di.HasVectorInjector
|
import im.vector.riotx.core.di.HasVectorInjector
|
||||||
import im.vector.riotx.core.di.VectorComponent
|
import im.vector.riotx.core.di.VectorComponent
|
||||||
import im.vector.riotx.core.extensions.configureAndStart
|
import im.vector.riotx.core.extensions.configureAndStart
|
||||||
|
import im.vector.riotx.core.utils.initKnownEmojiHashSet
|
||||||
import im.vector.riotx.features.configuration.VectorConfiguration
|
import im.vector.riotx.features.configuration.VectorConfiguration
|
||||||
import im.vector.riotx.features.lifecycle.VectorActivityLifecycleCallbacks
|
import im.vector.riotx.features.lifecycle.VectorActivityLifecycleCallbacks
|
||||||
import im.vector.riotx.features.notifications.NotificationDrawerManager
|
import im.vector.riotx.features.notifications.NotificationDrawerManager
|
||||||
@ -49,12 +50,12 @@ import im.vector.riotx.features.notifications.NotificationUtils
|
|||||||
import im.vector.riotx.features.notifications.PushRuleTriggerListener
|
import im.vector.riotx.features.notifications.PushRuleTriggerListener
|
||||||
import im.vector.riotx.features.rageshake.VectorFileLogger
|
import im.vector.riotx.features.rageshake.VectorFileLogger
|
||||||
import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler
|
import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler
|
||||||
|
import im.vector.riotx.features.settings.VectorPreferences
|
||||||
import im.vector.riotx.features.version.getVersion
|
import im.vector.riotx.features.version.getVersion
|
||||||
import im.vector.riotx.push.fcm.FcmHelper
|
import im.vector.riotx.push.fcm.FcmHelper
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import im.vector.riotx.core.utils.initKnownEmojiHashSet
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class VectorApplication : Application(), HasVectorInjector, MatrixConfiguration.Provider, androidx.work.Configuration.Provider {
|
class VectorApplication : Application(), HasVectorInjector, MatrixConfiguration.Provider, androidx.work.Configuration.Provider {
|
||||||
@ -69,6 +70,7 @@ class VectorApplication : Application(), HasVectorInjector, MatrixConfiguration.
|
|||||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||||
@Inject lateinit var notificationDrawerManager: NotificationDrawerManager
|
@Inject lateinit var notificationDrawerManager: NotificationDrawerManager
|
||||||
@Inject lateinit var pushRuleTriggerListener: PushRuleTriggerListener
|
@Inject lateinit var pushRuleTriggerListener: PushRuleTriggerListener
|
||||||
|
@Inject lateinit var vectorPreferences: VectorPreferences
|
||||||
lateinit var vectorComponent: VectorComponent
|
lateinit var vectorComponent: VectorComponent
|
||||||
private var fontThreadHandler: Handler? = null
|
private var fontThreadHandler: Handler? = null
|
||||||
|
|
||||||
@ -122,7 +124,7 @@ class VectorApplication : Application(), HasVectorInjector, MatrixConfiguration.
|
|||||||
fun entersBackground() {
|
fun entersBackground() {
|
||||||
Timber.i("App entered background") // call persistInfo
|
Timber.i("App entered background") // call persistInfo
|
||||||
notificationDrawerManager.persistInfo()
|
notificationDrawerManager.persistInfo()
|
||||||
FcmHelper.onEnterBackground(appContext, activeSessionHolder)
|
FcmHelper.onEnterBackground(appContext, vectorPreferences, activeSessionHolder)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
//This should be done as early as possible
|
//This should be done as early as possible
|
||||||
|
@ -59,10 +59,7 @@ import im.vector.riotx.features.roomdirectory.createroom.CreateRoomActivity
|
|||||||
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomFragment
|
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomFragment
|
||||||
import im.vector.riotx.features.roomdirectory.picker.RoomDirectoryPickerFragment
|
import im.vector.riotx.features.roomdirectory.picker.RoomDirectoryPickerFragment
|
||||||
import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewNoPreviewFragment
|
import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewNoPreviewFragment
|
||||||
import im.vector.riotx.features.settings.VectorSettingsActivity
|
import im.vector.riotx.features.settings.*
|
||||||
import im.vector.riotx.features.settings.VectorSettingsNotificationPreferenceFragment
|
|
||||||
import im.vector.riotx.features.settings.VectorSettingsNotificationsTroubleshootFragment
|
|
||||||
import im.vector.riotx.features.settings.VectorSettingsPreferencesFragment
|
|
||||||
import im.vector.riotx.features.settings.push.PushGatewaysFragment
|
import im.vector.riotx.features.settings.push.PushGatewaysFragment
|
||||||
|
|
||||||
@Component(dependencies = [VectorComponent::class], modules = [ViewModelModule::class, HomeModule::class])
|
@Component(dependencies = [VectorComponent::class], modules = [ViewModelModule::class, HomeModule::class])
|
||||||
@ -153,6 +150,10 @@ interface ScreenComponent {
|
|||||||
|
|
||||||
fun inject(vectorSettingsPreferencesFragment: VectorSettingsPreferencesFragment)
|
fun inject(vectorSettingsPreferencesFragment: VectorSettingsPreferencesFragment)
|
||||||
|
|
||||||
|
fun inject(vectorSettingsAdvancedNotificationPreferenceFragment: VectorSettingsAdvancedNotificationPreferenceFragment)
|
||||||
|
|
||||||
|
fun inject(vectorSettingsSecurityPrivacyFragment: VectorSettingsSecurityPrivacyFragment)
|
||||||
|
|
||||||
fun inject(userAvatarPreference: UserAvatarPreference)
|
fun inject(userAvatarPreference: UserAvatarPreference)
|
||||||
|
|
||||||
fun inject(vectorSettingsNotificationsTroubleshootFragment: VectorSettingsNotificationsTroubleshootFragment)
|
fun inject(vectorSettingsNotificationsTroubleshootFragment: VectorSettingsNotificationsTroubleshootFragment)
|
||||||
|
@ -41,6 +41,7 @@ import im.vector.riotx.features.notifications.NotificationDrawerManager
|
|||||||
import im.vector.riotx.features.notifications.PushRuleTriggerListener
|
import im.vector.riotx.features.notifications.PushRuleTriggerListener
|
||||||
import im.vector.riotx.features.rageshake.BugReporter
|
import im.vector.riotx.features.rageshake.BugReporter
|
||||||
import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler
|
import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler
|
||||||
|
import im.vector.riotx.features.settings.VectorPreferences
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Component(modules = [VectorModule::class])
|
@Component(modules = [VectorModule::class])
|
||||||
@ -95,6 +96,8 @@ interface VectorComponent {
|
|||||||
|
|
||||||
fun notifiableEventResolver(): NotifiableEventResolver
|
fun notifiableEventResolver(): NotifiableEventResolver
|
||||||
|
|
||||||
|
fun vectorPreferences(): VectorPreferences
|
||||||
|
|
||||||
@Component.Factory
|
@Component.Factory
|
||||||
interface Factory {
|
interface Factory {
|
||||||
fun create(@BindsInstance context: Context): VectorComponent
|
fun create(@BindsInstance context: Context): VectorComponent
|
||||||
|
@ -16,13 +16,12 @@
|
|||||||
|
|
||||||
package im.vector.riotx.core.resources
|
package im.vector.riotx.core.resources
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import im.vector.riotx.features.settings.VectorPreferences
|
import im.vector.riotx.features.settings.VectorPreferences
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class UserPreferencesProvider @Inject constructor(private val context: Context) {
|
class UserPreferencesProvider @Inject constructor(private val vectorPreferences: VectorPreferences) {
|
||||||
|
|
||||||
fun shouldShowHiddenEvents(): Boolean {
|
fun shouldShowHiddenEvents(): Boolean {
|
||||||
return VectorPreferences.shouldShowHiddenEvents(context)
|
return vectorPreferences.shouldShowHiddenEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -184,6 +184,7 @@ class RoomDetailFragment :
|
|||||||
private lateinit var scrollOnNewMessageCallback: ScrollOnNewMessageCallback
|
private lateinit var scrollOnNewMessageCallback: ScrollOnNewMessageCallback
|
||||||
private lateinit var scrollOnHighlightedEventCallback: ScrollOnHighlightedEventCallback
|
private lateinit var scrollOnHighlightedEventCallback: ScrollOnHighlightedEventCallback
|
||||||
@Inject lateinit var eventHtmlRenderer: EventHtmlRenderer
|
@Inject lateinit var eventHtmlRenderer: EventHtmlRenderer
|
||||||
|
@Inject lateinit var vectorPreferences: VectorPreferences
|
||||||
|
|
||||||
|
|
||||||
override fun getLayoutResId() = R.layout.fragment_room_detail
|
override fun getLayoutResId() = R.layout.fragment_room_detail
|
||||||
@ -389,7 +390,7 @@ class RoomDetailFragment :
|
|||||||
recyclerView.setController(timelineEventController)
|
recyclerView.setController(timelineEventController)
|
||||||
timelineEventController.callback = this
|
timelineEventController.callback = this
|
||||||
|
|
||||||
if (VectorPreferences.swipeToReplyIsEnabled(requireContext())) {
|
if (vectorPreferences.swipeToReplyIsEnabled()) {
|
||||||
val swipeCallback = RoomMessageTouchHelperCallback(requireContext(),
|
val swipeCallback = RoomMessageTouchHelperCallback(requireContext(),
|
||||||
R.drawable.ic_reply,
|
R.drawable.ic_reply,
|
||||||
object : RoomMessageTouchHelperCallback.QuickReplayHandler {
|
object : RoomMessageTouchHelperCallback.QuickReplayHandler {
|
||||||
@ -482,7 +483,7 @@ class RoomDetailFragment :
|
|||||||
composerLayout.sendButton.setOnClickListener {
|
composerLayout.sendButton.setOnClickListener {
|
||||||
val textMessage = composerLayout.composerEditText.text.toString()
|
val textMessage = composerLayout.composerEditText.text.toString()
|
||||||
if (textMessage.isNotBlank()) {
|
if (textMessage.isNotBlank()) {
|
||||||
roomDetailViewModel.process(RoomDetailActions.SendMessage(textMessage, VectorPreferences.isMarkdownEnabled(requireContext())))
|
roomDetailViewModel.process(RoomDetailActions.SendMessage(textMessage, vectorPreferences.isMarkdownEnabled()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
composerLayout.composerRelatedMessageCloseButton.setOnClickListener {
|
composerLayout.composerRelatedMessageCloseButton.setOnClickListener {
|
||||||
@ -507,7 +508,7 @@ class RoomDetailFragment :
|
|||||||
items.add(DialogListItem.SendFile)
|
items.add(DialogListItem.SendFile)
|
||||||
// Send voice
|
// Send voice
|
||||||
|
|
||||||
if (VectorPreferences.isSendVoiceFeatureEnabled(this)) {
|
if (vectorPreferences.isSendVoiceFeatureEnabled()) {
|
||||||
items.add(DialogListItem.SendVoice.INSTANCE)
|
items.add(DialogListItem.SendVoice.INSTANCE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,7 +517,7 @@ class RoomDetailFragment :
|
|||||||
//items.add(DialogListItem.SendSticker)
|
//items.add(DialogListItem.SendSticker)
|
||||||
// Camera
|
// Camera
|
||||||
|
|
||||||
//if (VectorPreferences.useNativeCamera(this)) {
|
//if (vectorPreferences.useNativeCamera()) {
|
||||||
items.add(DialogListItem.TakePhoto)
|
items.add(DialogListItem.TakePhoto)
|
||||||
items.add(DialogListItem.TakeVideo)
|
items.add(DialogListItem.TakeVideo)
|
||||||
//} else {
|
//} else {
|
||||||
@ -638,8 +639,12 @@ class RoomDetailFragment :
|
|||||||
|
|
||||||
private fun renderSendMessageResult(sendMessageResult: SendMessageResult) {
|
private fun renderSendMessageResult(sendMessageResult: SendMessageResult) {
|
||||||
when (sendMessageResult) {
|
when (sendMessageResult) {
|
||||||
is SendMessageResult.MessageSent,
|
is SendMessageResult.MessageSent -> {
|
||||||
|
// Clear composer
|
||||||
|
composerLayout.composerEditText.text = null
|
||||||
|
}
|
||||||
is SendMessageResult.SlashCommandHandled -> {
|
is SendMessageResult.SlashCommandHandled -> {
|
||||||
|
sendMessageResult.messageRes?.let { showSnackWithMessage(getString(it)) }
|
||||||
// Clear composer
|
// Clear composer
|
||||||
composerLayout.composerEditText.text = null
|
composerLayout.composerEditText.text = null
|
||||||
}
|
}
|
||||||
@ -959,7 +964,7 @@ class RoomDetailFragment :
|
|||||||
// vibrate = true
|
// vibrate = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (vibrate && VectorPreferences.vibrateWhenMentioning(context)) {
|
// if (vibrate && vectorPreferences.vibrateWhenMentioning()) {
|
||||||
// val v= context.getSystemService(Context.VIBRATOR_SERVICE) as? Vibrator
|
// val v= context.getSystemService(Context.VIBRATOR_SERVICE) as? Vibrator
|
||||||
// if (v?.hasVibrator() == true) {
|
// if (v?.hasVibrator() == true) {
|
||||||
// v.vibrate(100)
|
// v.vibrate(100)
|
||||||
|
@ -56,6 +56,7 @@ import im.vector.riotx.core.utils.subscribeLogError
|
|||||||
import im.vector.riotx.features.command.CommandParser
|
import im.vector.riotx.features.command.CommandParser
|
||||||
import im.vector.riotx.features.command.ParsedCommand
|
import im.vector.riotx.features.command.ParsedCommand
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineDisplayableEvents
|
import im.vector.riotx.features.home.room.detail.timeline.helper.TimelineDisplayableEvents
|
||||||
|
import im.vector.riotx.features.settings.VectorPreferences
|
||||||
import io.reactivex.rxkotlin.subscribeBy
|
import io.reactivex.rxkotlin.subscribeBy
|
||||||
import org.commonmark.parser.Parser
|
import org.commonmark.parser.Parser
|
||||||
import org.commonmark.renderer.html.HtmlRenderer
|
import org.commonmark.renderer.html.HtmlRenderer
|
||||||
@ -66,6 +67,7 @@ import java.util.concurrent.TimeUnit
|
|||||||
|
|
||||||
class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: RoomDetailViewState,
|
class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: RoomDetailViewState,
|
||||||
userPreferencesProvider: UserPreferencesProvider,
|
userPreferencesProvider: UserPreferencesProvider,
|
||||||
|
private val vectorPreferences: VectorPreferences,
|
||||||
private val session: Session
|
private val session: Session
|
||||||
) : VectorViewModel<RoomDetailViewState>(initialState) {
|
) : VectorViewModel<RoomDetailViewState>(initialState) {
|
||||||
|
|
||||||
@ -243,8 +245,9 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
_sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandNotImplemented)
|
_sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandNotImplemented)
|
||||||
}
|
}
|
||||||
is ParsedCommand.SetMarkdown -> {
|
is ParsedCommand.SetMarkdown -> {
|
||||||
// TODO
|
vectorPreferences.setMarkdownEnabled(slashCommandResult.enable)
|
||||||
_sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandNotImplemented)
|
_sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandHandled(
|
||||||
|
if (slashCommandResult.enable) R.string.markdown_has_been_enabled else R.string.markdown_has_been_disabled))
|
||||||
}
|
}
|
||||||
is ParsedCommand.UnbanUser -> {
|
is ParsedCommand.UnbanUser -> {
|
||||||
// TODO
|
// TODO
|
||||||
@ -268,7 +271,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
}
|
}
|
||||||
is ParsedCommand.SendEmote -> {
|
is ParsedCommand.SendEmote -> {
|
||||||
room.sendTextMessage(slashCommandResult.message, msgType = MessageType.MSGTYPE_EMOTE)
|
room.sendTextMessage(slashCommandResult.message, msgType = MessageType.MSGTYPE_EMOTE)
|
||||||
_sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandHandled)
|
_sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandHandled())
|
||||||
}
|
}
|
||||||
is ParsedCommand.ChangeTopic -> {
|
is ParsedCommand.ChangeTopic -> {
|
||||||
handleChangeTopicSlashCommand(slashCommandResult)
|
handleChangeTopicSlashCommand(slashCommandResult)
|
||||||
@ -348,8 +351,6 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Handle slash command
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun legacyRiotQuoteText(quotedText: String?, myText: String): String {
|
private fun legacyRiotQuoteText(quotedText: String?, myText: String): String {
|
||||||
@ -371,7 +372,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun handleChangeTopicSlashCommand(changeTopic: ParsedCommand.ChangeTopic) {
|
private fun handleChangeTopicSlashCommand(changeTopic: ParsedCommand.ChangeTopic) {
|
||||||
_sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandHandled)
|
_sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandHandled())
|
||||||
|
|
||||||
room.updateTopic(changeTopic.topic, object : MatrixCallback<Unit> {
|
room.updateTopic(changeTopic.topic, object : MatrixCallback<Unit> {
|
||||||
override fun onSuccess(data: Unit) {
|
override fun onSuccess(data: Unit) {
|
||||||
@ -385,7 +386,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun handleInviteSlashCommand(invite: ParsedCommand.Invite) {
|
private fun handleInviteSlashCommand(invite: ParsedCommand.Invite) {
|
||||||
_sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandHandled)
|
_sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandHandled())
|
||||||
|
|
||||||
room.invite(invite.userId, object : MatrixCallback<Unit> {
|
room.invite(invite.userId, object : MatrixCallback<Unit> {
|
||||||
override fun onSuccess(data: Unit) {
|
override fun onSuccess(data: Unit) {
|
||||||
|
@ -16,13 +16,14 @@
|
|||||||
|
|
||||||
package im.vector.riotx.features.home.room.detail
|
package im.vector.riotx.features.home.room.detail
|
||||||
|
|
||||||
|
import androidx.annotation.StringRes
|
||||||
import im.vector.riotx.features.command.Command
|
import im.vector.riotx.features.command.Command
|
||||||
|
|
||||||
sealed class SendMessageResult {
|
sealed class SendMessageResult {
|
||||||
object MessageSent : SendMessageResult()
|
object MessageSent : SendMessageResult()
|
||||||
class SlashCommandError(val command: Command) : SendMessageResult()
|
class SlashCommandError(val command: Command) : SendMessageResult()
|
||||||
class SlashCommandUnknown(val command: String) : SendMessageResult()
|
class SlashCommandUnknown(val command: String) : SendMessageResult()
|
||||||
object SlashCommandHandled : SendMessageResult()
|
data class SlashCommandHandled(@StringRes val messageRes: Int? = null) : SendMessageResult()
|
||||||
object SlashCommandResultOk : SendMessageResult()
|
object SlashCommandResultOk : SendMessageResult()
|
||||||
class SlashCommandResultError(val throwable: Throwable) : SendMessageResult()
|
class SlashCommandResultError(val throwable: Throwable) : SendMessageResult()
|
||||||
// TODO Remove
|
// TODO Remove
|
||||||
|
@ -44,6 +44,7 @@ import javax.inject.Singleton
|
|||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
class NotificationDrawerManager @Inject constructor(private val context: Context,
|
class NotificationDrawerManager @Inject constructor(private val context: Context,
|
||||||
|
private val vectorPreferences: VectorPreferences,
|
||||||
private val activeSessionHolder: ActiveSessionHolder,
|
private val activeSessionHolder: ActiveSessionHolder,
|
||||||
private val iconLoader: IconLoader,
|
private val iconLoader: IconLoader,
|
||||||
private val bitmapLoader: BitmapLoader,
|
private val bitmapLoader: BitmapLoader,
|
||||||
@ -73,7 +74,7 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
|
|||||||
Events might be grouped and there might not be one notification per event!
|
Events might be grouped and there might not be one notification per event!
|
||||||
*/
|
*/
|
||||||
fun onNotifiableEventReceived(notifiableEvent: NotifiableEvent) {
|
fun onNotifiableEventReceived(notifiableEvent: NotifiableEvent) {
|
||||||
if (!VectorPreferences.areNotificationEnabledForDevice(context)) {
|
if (!vectorPreferences.areNotificationEnabledForDevice()) {
|
||||||
Timber.i("Notification are disabled for this device")
|
Timber.i("Notification are disabled for this device")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -326,7 +327,13 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
|
|||||||
globalLastMessageTimestamp = lastMessageTimestamp
|
globalLastMessageTimestamp = lastMessageTimestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationUtils.buildMessagesListNotification(context, style, roomEventGroupInfo, largeBitmap, lastMessageTimestamp, myUserDisplayName)
|
NotificationUtils.buildMessagesListNotification(context,
|
||||||
|
vectorPreferences,
|
||||||
|
style,
|
||||||
|
roomEventGroupInfo,
|
||||||
|
largeBitmap,
|
||||||
|
lastMessageTimestamp,
|
||||||
|
myUserDisplayName)
|
||||||
?.let {
|
?.let {
|
||||||
//is there an id for this room?
|
//is there an id for this room?
|
||||||
notifications.add(it)
|
notifications.add(it)
|
||||||
@ -344,7 +351,7 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
|
|||||||
for (event in simpleEvents) {
|
for (event in simpleEvents) {
|
||||||
//We build a simple event
|
//We build a simple event
|
||||||
if (firstTime || !event.hasBeenDisplayed) {
|
if (firstTime || !event.hasBeenDisplayed) {
|
||||||
NotificationUtils.buildSimpleEventNotification(context, event, null, session.myUserId)?.let {
|
NotificationUtils.buildSimpleEventNotification(context, vectorPreferences, event, null, session.myUserId)?.let {
|
||||||
notifications.add(it)
|
notifications.add(it)
|
||||||
NotificationUtils.showNotificationMessage(context, event.eventId, ROOM_EVENT_NOTIFICATION_ID, it)
|
NotificationUtils.showNotificationMessage(context, event.eventId, ROOM_EVENT_NOTIFICATION_ID, it)
|
||||||
event.hasBeenDisplayed = true //we can consider it as displayed
|
event.hasBeenDisplayed = true //we can consider it as displayed
|
||||||
@ -383,6 +390,7 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
|
|||||||
|
|
||||||
NotificationUtils.buildSummaryListNotification(
|
NotificationUtils.buildSummaryListNotification(
|
||||||
context,
|
context,
|
||||||
|
vectorPreferences,
|
||||||
summaryInboxStyle,
|
summaryInboxStyle,
|
||||||
sumTitle,
|
sumTitle,
|
||||||
noisy = hasNewEvent && summaryIsNoisy,
|
noisy = hasNewEvent && summaryIsNoisy,
|
||||||
|
@ -367,6 +367,7 @@ object NotificationUtils {
|
|||||||
* Build a notification for a Room
|
* Build a notification for a Room
|
||||||
*/
|
*/
|
||||||
fun buildMessagesListNotification(context: Context,
|
fun buildMessagesListNotification(context: Context,
|
||||||
|
vectorPreferences: VectorPreferences,
|
||||||
messageStyle: NotificationCompat.MessagingStyle,
|
messageStyle: NotificationCompat.MessagingStyle,
|
||||||
roomInfo: RoomEventGroupInfo,
|
roomInfo: RoomEventGroupInfo,
|
||||||
largeIcon: Bitmap?,
|
largeIcon: Bitmap?,
|
||||||
@ -420,7 +421,7 @@ object NotificationUtils {
|
|||||||
priority = NotificationCompat.PRIORITY_DEFAULT
|
priority = NotificationCompat.PRIORITY_DEFAULT
|
||||||
if (roomInfo.shouldBing) {
|
if (roomInfo.shouldBing) {
|
||||||
//Compat
|
//Compat
|
||||||
VectorPreferences.getNotificationRingTone(context)?.let {
|
vectorPreferences.getNotificationRingTone()?.let {
|
||||||
setSound(it)
|
setSound(it)
|
||||||
}
|
}
|
||||||
setLights(accentColor, 500, 500)
|
setLights(accentColor, 500, 500)
|
||||||
@ -476,7 +477,11 @@ object NotificationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun buildSimpleEventNotification(context: Context, simpleNotifiableEvent: NotifiableEvent, largeIcon: Bitmap?, matrixId: String): Notification? {
|
fun buildSimpleEventNotification(context: Context,
|
||||||
|
vectorPreferences: VectorPreferences,
|
||||||
|
simpleNotifiableEvent: NotifiableEvent,
|
||||||
|
largeIcon: Bitmap?,
|
||||||
|
matrixId: String): Notification? {
|
||||||
val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color)
|
val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color)
|
||||||
// Build the pending intent for when the notification is clicked
|
// Build the pending intent for when the notification is clicked
|
||||||
val smallIcon = R.drawable.ic_status_bar
|
val smallIcon = R.drawable.ic_status_bar
|
||||||
@ -534,7 +539,7 @@ object NotificationUtils {
|
|||||||
if (simpleNotifiableEvent.noisy) {
|
if (simpleNotifiableEvent.noisy) {
|
||||||
//Compat
|
//Compat
|
||||||
priority = NotificationCompat.PRIORITY_DEFAULT
|
priority = NotificationCompat.PRIORITY_DEFAULT
|
||||||
VectorPreferences.getNotificationRingTone(context)?.let {
|
vectorPreferences.getNotificationRingTone()?.let {
|
||||||
setSound(it)
|
setSound(it)
|
||||||
}
|
}
|
||||||
setLights(accentColor, 500, 500)
|
setLights(accentColor, 500, 500)
|
||||||
@ -606,6 +611,7 @@ object NotificationUtils {
|
|||||||
* Build the summary notification
|
* Build the summary notification
|
||||||
*/
|
*/
|
||||||
fun buildSummaryListNotification(context: Context,
|
fun buildSummaryListNotification(context: Context,
|
||||||
|
vectorPreferences: VectorPreferences,
|
||||||
style: NotificationCompat.InboxStyle,
|
style: NotificationCompat.InboxStyle,
|
||||||
compatSummary: String,
|
compatSummary: String,
|
||||||
noisy: Boolean,
|
noisy: Boolean,
|
||||||
@ -630,7 +636,7 @@ object NotificationUtils {
|
|||||||
if (noisy) {
|
if (noisy) {
|
||||||
//Compat
|
//Compat
|
||||||
priority = NotificationCompat.PRIORITY_DEFAULT
|
priority = NotificationCompat.PRIORITY_DEFAULT
|
||||||
VectorPreferences.getNotificationRingTone(context)?.let {
|
vectorPreferences.getNotificationRingTone()?.let {
|
||||||
setSound(it)
|
setSound(it)
|
||||||
}
|
}
|
||||||
setLights(accentColor, 500, 500)
|
setLights(accentColor, 500, 500)
|
||||||
|
@ -31,9 +31,11 @@ import im.vector.riotx.features.themes.ThemeUtils
|
|||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
object VectorPreferences {
|
class VectorPreferences @Inject constructor(private val context: Context) {
|
||||||
|
|
||||||
|
companion object {
|
||||||
const val SETTINGS_MESSAGES_SENT_BY_BOT_PREFERENCE_KEY = "SETTINGS_MESSAGES_SENT_BY_BOT_PREFERENCE_KEY_2"
|
const val SETTINGS_MESSAGES_SENT_BY_BOT_PREFERENCE_KEY = "SETTINGS_MESSAGES_SENT_BY_BOT_PREFERENCE_KEY_2"
|
||||||
const val SETTINGS_CHANGE_PASSWORD_PREFERENCE_KEY = "SETTINGS_CHANGE_PASSWORD_PREFERENCE_KEY"
|
const val SETTINGS_CHANGE_PASSWORD_PREFERENCE_KEY = "SETTINGS_CHANGE_PASSWORD_PREFERENCE_KEY"
|
||||||
const val SETTINGS_VERSION_PREFERENCE_KEY = "SETTINGS_VERSION_PREFERENCE_KEY"
|
const val SETTINGS_VERSION_PREFERENCE_KEY = "SETTINGS_VERSION_PREFERENCE_KEY"
|
||||||
@ -205,13 +207,16 @@ object VectorPreferences {
|
|||||||
|
|
||||||
SETTINGS_USE_RAGE_SHAKE_KEY
|
SETTINGS_USE_RAGE_SHAKE_KEY
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val defaultPrefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the preferences.
|
* Clear the preferences.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param context the context
|
||||||
*/
|
*/
|
||||||
fun clearPreferences(context: Context) {
|
fun clearPreferences() {
|
||||||
val keysToKeep = HashSet(mKeysToKeepAfterLogout)
|
val keysToKeep = HashSet(mKeysToKeepAfterLogout)
|
||||||
|
|
||||||
// home server urls
|
// home server urls
|
||||||
@ -221,37 +226,35 @@ object VectorPreferences {
|
|||||||
// theme
|
// theme
|
||||||
keysToKeep.add(ThemeUtils.APPLICATION_THEME_KEY)
|
keysToKeep.add(ThemeUtils.APPLICATION_THEME_KEY)
|
||||||
|
|
||||||
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
preferences.edit {
|
|
||||||
// get all the existing keys
|
// get all the existing keys
|
||||||
val keys = preferences.all.keys
|
val keys = defaultPrefs.all.keys
|
||||||
// remove the one to keep
|
|
||||||
|
|
||||||
|
// remove the one to keep
|
||||||
keys.removeAll(keysToKeep)
|
keys.removeAll(keysToKeep)
|
||||||
|
|
||||||
|
defaultPrefs.edit {
|
||||||
for (key in keys) {
|
for (key in keys) {
|
||||||
remove(key)
|
remove(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun areNotificationEnabledForDevice(context: Context): Boolean {
|
fun areNotificationEnabledForDevice(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setNotificationEnabledForDevice(context: Context, enabled: Boolean?) {
|
fun setNotificationEnabledForDevice(enabled: Boolean?) {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
defaultPrefs.edit {
|
||||||
.edit {
|
|
||||||
putBoolean(SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY, enabled!!)
|
putBoolean(SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY, enabled!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun shouldShowHiddenEvents(context: Context): Boolean {
|
fun shouldShowHiddenEvents(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY, false)
|
return defaultPrefs.getBoolean(SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun swipeToReplyIsEnabled(context: Context): Boolean {
|
fun swipeToReplyIsEnabled(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY, true)
|
return defaultPrefs.getBoolean(SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -260,8 +263,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if it was already requested
|
* @return true if it was already requested
|
||||||
*/
|
*/
|
||||||
fun didAskUserToIgnoreBatteryOptimizations(context: Context): Boolean {
|
fun didAskUserToIgnoreBatteryOptimizations(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(DID_ASK_TO_IGNORE_BATTERY_OPTIMIZATIONS_KEY, false)
|
return defaultPrefs.getBoolean(DID_ASK_TO_IGNORE_BATTERY_OPTIMIZATIONS_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -269,20 +272,18 @@ object VectorPreferences {
|
|||||||
*
|
*
|
||||||
* @param context the context
|
* @param context the context
|
||||||
*/
|
*/
|
||||||
fun setDidAskUserToIgnoreBatteryOptimizations(context: Context) {
|
fun setDidAskUserToIgnoreBatteryOptimizations() {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
defaultPrefs.edit {
|
||||||
.edit {
|
|
||||||
putBoolean(DID_ASK_TO_IGNORE_BATTERY_OPTIMIZATIONS_KEY, true)
|
putBoolean(DID_ASK_TO_IGNORE_BATTERY_OPTIMIZATIONS_KEY, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun didMigrateToNotificationRework(context: Context): Boolean {
|
fun didMigrateToNotificationRework(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(DID_MIGRATE_TO_NOTIFICATION_REWORK, false)
|
return defaultPrefs.getBoolean(DID_MIGRATE_TO_NOTIFICATION_REWORK, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setDidMigrateToNotificationRework(context: Context) {
|
fun setDidMigrateToNotificationRework() {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
defaultPrefs.edit {
|
||||||
.edit {
|
|
||||||
putBoolean(DID_MIGRATE_TO_NOTIFICATION_REWORK, true)
|
putBoolean(DID_MIGRATE_TO_NOTIFICATION_REWORK, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,8 +294,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the time must be displayed in 12h format
|
* @return true if the time must be displayed in 12h format
|
||||||
*/
|
*/
|
||||||
fun displayTimeIn12hFormat(context: Context): Boolean {
|
fun displayTimeIn12hFormat(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_12_24_TIMESTAMPS_KEY, false)
|
return defaultPrefs.getBoolean(SETTINGS_12_24_TIMESTAMPS_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -303,8 +304,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the join and leave membership events should be shown in the messages list
|
* @return true if the join and leave membership events should be shown in the messages list
|
||||||
*/
|
*/
|
||||||
fun showJoinLeaveMessages(context: Context): Boolean {
|
fun showJoinLeaveMessages(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_SHOW_JOIN_LEAVE_MESSAGES_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_SHOW_JOIN_LEAVE_MESSAGES_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -313,8 +314,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true true if the avatar and display name events should be shown in the messages list.
|
* @return true true if the avatar and display name events should be shown in the messages list.
|
||||||
*/
|
*/
|
||||||
fun showAvatarDisplayNameChangeMessages(context: Context): Boolean {
|
fun showAvatarDisplayNameChangeMessages(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_SHOW_AVATAR_DISPLAY_NAME_CHANGES_MESSAGES_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_SHOW_AVATAR_DISPLAY_NAME_CHANGES_MESSAGES_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -323,8 +324,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true to use the native camera app to record video or take photo.
|
* @return true to use the native camera app to record video or take photo.
|
||||||
*/
|
*/
|
||||||
fun useNativeCamera(context: Context): Boolean {
|
fun useNativeCamera(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_USE_NATIVE_CAMERA_PREFERENCE_KEY, false)
|
return defaultPrefs.getBoolean(SETTINGS_USE_NATIVE_CAMERA_PREFERENCE_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -333,8 +334,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the send voice feature is enabled.
|
* @return true if the send voice feature is enabled.
|
||||||
*/
|
*/
|
||||||
fun isSendVoiceFeatureEnabled(context: Context): Boolean {
|
fun isSendVoiceFeatureEnabled(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_ENABLE_SEND_VOICE_FEATURE_PREFERENCE_KEY, false)
|
return defaultPrefs.getBoolean(SETTINGS_ENABLE_SEND_VOICE_FEATURE_PREFERENCE_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -343,8 +344,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return the selected compression level
|
* @return the selected compression level
|
||||||
*/
|
*/
|
||||||
fun getSelectedDefaultMediaCompressionLevel(context: Context): Int {
|
fun getSelectedDefaultMediaCompressionLevel(): Int {
|
||||||
return Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString(SETTINGS_DEFAULT_MEDIA_COMPRESSION_KEY, "0")!!)
|
return Integer.parseInt(defaultPrefs.getString(SETTINGS_DEFAULT_MEDIA_COMPRESSION_KEY, "0")!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -353,8 +354,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return the selected media source
|
* @return the selected media source
|
||||||
*/
|
*/
|
||||||
fun getSelectedDefaultMediaSource(context: Context): Int {
|
fun getSelectedDefaultMediaSource(): Int {
|
||||||
return Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString(SETTINGS_DEFAULT_MEDIA_SOURCE_KEY, "0")!!)
|
return Integer.parseInt(defaultPrefs.getString(SETTINGS_DEFAULT_MEDIA_SOURCE_KEY, "0")!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -363,8 +364,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if shutter sound should play
|
* @return true if shutter sound should play
|
||||||
*/
|
*/
|
||||||
fun useShutterSound(context: Context): Boolean {
|
fun useShutterSound(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_PLAY_SHUTTER_SOUND_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_PLAY_SHUTTER_SOUND_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -373,9 +374,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @param uri the new notification ringtone, or null for no RingTone
|
* @param uri the new notification ringtone, or null for no RingTone
|
||||||
*/
|
*/
|
||||||
fun setNotificationRingTone(context: Context, uri: Uri?) {
|
fun setNotificationRingTone(uri: Uri?) {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context).edit {
|
defaultPrefs.edit {
|
||||||
|
|
||||||
var value = ""
|
var value = ""
|
||||||
|
|
||||||
if (null != uri) {
|
if (null != uri) {
|
||||||
@ -399,8 +399,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return the selected ring tone or null for no RingTone
|
* @return the selected ring tone or null for no RingTone
|
||||||
*/
|
*/
|
||||||
fun getNotificationRingTone(context: Context): Uri? {
|
fun getNotificationRingTone(): Uri? {
|
||||||
val url = PreferenceManager.getDefaultSharedPreferences(context).getString(SETTINGS_NOTIFICATION_RINGTONE_PREFERENCE_KEY, null)
|
val url = defaultPrefs.getString(SETTINGS_NOTIFICATION_RINGTONE_PREFERENCE_KEY, null)
|
||||||
|
|
||||||
// the user selects "None"
|
// the user selects "None"
|
||||||
if (TextUtils.equals(url, "")) {
|
if (TextUtils.equals(url, "")) {
|
||||||
@ -433,8 +433,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return the filename or null if "None" is selected
|
* @return the filename or null if "None" is selected
|
||||||
*/
|
*/
|
||||||
fun getNotificationRingToneName(context: Context): String? {
|
fun getNotificationRingToneName(): String? {
|
||||||
val toneUri = getNotificationRingTone(context) ?: return null
|
val toneUri = getNotificationRingTone() ?: return null
|
||||||
|
|
||||||
var name: String? = null
|
var name: String? = null
|
||||||
|
|
||||||
@ -467,9 +467,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @param newValue true to enable lazy loading, false to disable it
|
* @param newValue true to enable lazy loading, false to disable it
|
||||||
*/
|
*/
|
||||||
fun setUseLazyLoading(context: Context, newValue: Boolean) {
|
fun setUseLazyLoading(newValue: Boolean) {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
defaultPrefs.edit {
|
||||||
.edit {
|
|
||||||
putBoolean(SETTINGS_LAZY_LOADING_PREFERENCE_KEY, newValue)
|
putBoolean(SETTINGS_LAZY_LOADING_PREFERENCE_KEY, newValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -480,8 +479,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the lazy loading of room members is enabled
|
* @return true if the lazy loading of room members is enabled
|
||||||
*/
|
*/
|
||||||
fun useLazyLoading(context: Context): Boolean {
|
fun useLazyLoading(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_LAZY_LOADING_PREFERENCE_KEY, false)
|
return defaultPrefs.getBoolean(SETTINGS_LAZY_LOADING_PREFERENCE_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -489,9 +488,8 @@ object VectorPreferences {
|
|||||||
*
|
*
|
||||||
* @param context the context
|
* @param context the context
|
||||||
*/
|
*/
|
||||||
fun setUserRefuseLazyLoading(context: Context) {
|
fun setUserRefuseLazyLoading() {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
defaultPrefs.edit {
|
||||||
.edit {
|
|
||||||
putBoolean(SETTINGS_USER_REFUSED_LAZY_LOADING_PREFERENCE_KEY, true)
|
putBoolean(SETTINGS_USER_REFUSED_LAZY_LOADING_PREFERENCE_KEY, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -502,8 +500,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the user has explicitly refuse the lazy loading of room members
|
* @return true if the user has explicitly refuse the lazy loading of room members
|
||||||
*/
|
*/
|
||||||
fun hasUserRefusedLazyLoading(context: Context): Boolean {
|
fun hasUserRefusedLazyLoading(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_USER_REFUSED_LAZY_LOADING_PREFERENCE_KEY, false)
|
return defaultPrefs.getBoolean(SETTINGS_USER_REFUSED_LAZY_LOADING_PREFERENCE_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -512,8 +510,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the data save mode is enabled
|
* @return true if the data save mode is enabled
|
||||||
*/
|
*/
|
||||||
fun useDataSaveMode(context: Context): Boolean {
|
fun useDataSaveMode(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_DATA_SAVE_MODE_PREFERENCE_KEY, false)
|
return defaultPrefs.getBoolean(SETTINGS_DATA_SAVE_MODE_PREFERENCE_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -522,8 +520,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the conference call must be done with jitsi.
|
* @return true if the conference call must be done with jitsi.
|
||||||
*/
|
*/
|
||||||
fun useJitsiConfCall(context: Context): Boolean {
|
fun useJitsiConfCall(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_USE_JITSI_CONF_PREFERENCE_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_USE_JITSI_CONF_PREFERENCE_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -532,8 +530,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the application must be started on boot
|
* @return true if the application must be started on boot
|
||||||
*/
|
*/
|
||||||
fun autoStartOnBoot(context: Context): Boolean {
|
fun autoStartOnBoot(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_START_ON_BOOT_PREFERENCE_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_START_ON_BOOT_PREFERENCE_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -542,9 +540,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @param value true to start the application on boot
|
* @param value true to start the application on boot
|
||||||
*/
|
*/
|
||||||
fun setAutoStartOnBoot(context: Context, value: Boolean) {
|
fun setAutoStartOnBoot(value: Boolean) {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
defaultPrefs.edit {
|
||||||
.edit {
|
|
||||||
putBoolean(SETTINGS_START_ON_BOOT_PREFERENCE_KEY, value)
|
putBoolean(SETTINGS_START_ON_BOOT_PREFERENCE_KEY, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -555,8 +552,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return the selected period
|
* @return the selected period
|
||||||
*/
|
*/
|
||||||
fun getSelectedMediasSavingPeriod(context: Context): Int {
|
fun getSelectedMediasSavingPeriod(): Int {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getInt(SETTINGS_MEDIA_SAVING_PERIOD_SELECTED_KEY, MEDIA_SAVING_1_WEEK)
|
return defaultPrefs.getInt(SETTINGS_MEDIA_SAVING_PERIOD_SELECTED_KEY, MEDIA_SAVING_1_WEEK)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -565,9 +562,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @param index the selected period index
|
* @param index the selected period index
|
||||||
*/
|
*/
|
||||||
fun setSelectedMediasSavingPeriod(context: Context, index: Int) {
|
fun setSelectedMediasSavingPeriod(index: Int) {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
defaultPrefs.edit {
|
||||||
.edit {
|
|
||||||
putInt(SETTINGS_MEDIA_SAVING_PERIOD_SELECTED_KEY, index)
|
putInt(SETTINGS_MEDIA_SAVING_PERIOD_SELECTED_KEY, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -578,8 +574,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return the min last access time (in seconds)
|
* @return the min last access time (in seconds)
|
||||||
*/
|
*/
|
||||||
fun getMinMediasLastAccessTime(context: Context): Long {
|
fun getMinMediasLastAccessTime(): Long {
|
||||||
val selection = getSelectedMediasSavingPeriod(context)
|
val selection = getSelectedMediasSavingPeriod()
|
||||||
|
|
||||||
when (selection) {
|
when (selection) {
|
||||||
MEDIA_SAVING_3_DAYS -> return System.currentTimeMillis() / 1000 - 3 * 24 * 60 * 60
|
MEDIA_SAVING_3_DAYS -> return System.currentTimeMillis() / 1000 - 3 * 24 * 60 * 60
|
||||||
@ -597,8 +593,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return the selected period
|
* @return the selected period
|
||||||
*/
|
*/
|
||||||
fun getSelectedMediasSavingPeriodString(context: Context): String {
|
fun getSelectedMediasSavingPeriodString(): String {
|
||||||
val selection = getSelectedMediasSavingPeriod(context)
|
val selection = getSelectedMediasSavingPeriod()
|
||||||
|
|
||||||
when (selection) {
|
when (selection) {
|
||||||
MEDIA_SAVING_3_DAYS -> return context.getString(R.string.media_saving_period_3_days)
|
MEDIA_SAVING_3_DAYS -> return context.getString(R.string.media_saving_period_3_days)
|
||||||
@ -612,7 +608,7 @@ object VectorPreferences {
|
|||||||
/**
|
/**
|
||||||
* Fix some migration issues
|
* Fix some migration issues
|
||||||
*/
|
*/
|
||||||
fun fixMigrationIssues(context: Context) {
|
fun fixMigrationIssues() {
|
||||||
// Nothing to do for the moment
|
// Nothing to do for the moment
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,8 +618,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the markdown is enabled
|
* @return true if the markdown is enabled
|
||||||
*/
|
*/
|
||||||
fun isMarkdownEnabled(context: Context): Boolean {
|
fun isMarkdownEnabled(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_ENABLE_MARKDOWN_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_ENABLE_MARKDOWN_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -632,9 +628,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @param isEnabled true to enable the markdown
|
* @param isEnabled true to enable the markdown
|
||||||
*/
|
*/
|
||||||
fun setMarkdownEnabled(context: Context, isEnabled: Boolean) {
|
fun setMarkdownEnabled(isEnabled: Boolean) {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
defaultPrefs.edit {
|
||||||
.edit {
|
|
||||||
putBoolean(SETTINGS_ENABLE_MARKDOWN_KEY, isEnabled)
|
putBoolean(SETTINGS_ENABLE_MARKDOWN_KEY, isEnabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -645,8 +640,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the read receipts should be shown
|
* @return true if the read receipts should be shown
|
||||||
*/
|
*/
|
||||||
fun showReadReceipts(context: Context): Boolean {
|
fun showReadReceipts(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_SHOW_READ_RECEIPTS_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_SHOW_READ_RECEIPTS_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -655,8 +650,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the message timestamps must be always shown
|
* @return true if the message timestamps must be always shown
|
||||||
*/
|
*/
|
||||||
fun alwaysShowTimeStamps(context: Context): Boolean {
|
fun alwaysShowTimeStamps(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_ALWAYS_SHOW_TIMESTAMPS_KEY, false)
|
return defaultPrefs.getBoolean(SETTINGS_ALWAYS_SHOW_TIMESTAMPS_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -665,8 +660,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true to send the typing notifs
|
* @return true to send the typing notifs
|
||||||
*/
|
*/
|
||||||
fun sendTypingNotifs(context: Context): Boolean {
|
fun sendTypingNotifs(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_SEND_TYPING_NOTIF_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_SEND_TYPING_NOTIF_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -675,8 +670,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true to move the missed notifications to the left side
|
* @return true to move the missed notifications to the left side
|
||||||
*/
|
*/
|
||||||
fun pinMissedNotifications(context: Context): Boolean {
|
fun pinMissedNotifications(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_PIN_MISSED_NOTIFICATIONS_PREFERENCE_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_PIN_MISSED_NOTIFICATIONS_PREFERENCE_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -685,8 +680,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true to move the unread room to the left side
|
* @return true to move the unread room to the left side
|
||||||
*/
|
*/
|
||||||
fun pinUnreadMessages(context: Context): Boolean {
|
fun pinUnreadMessages(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_PIN_UNREAD_MESSAGES_PREFERENCE_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_PIN_UNREAD_MESSAGES_PREFERENCE_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -695,8 +690,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
fun vibrateWhenMentioning(context: Context): Boolean {
|
fun vibrateWhenMentioning(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_VIBRATE_ON_MENTION_KEY, false)
|
return defaultPrefs.getBoolean(SETTINGS_VIBRATE_ON_MENTION_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -705,8 +700,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if a dialog has been displayed to ask to use the analytics tracking
|
* @return true if a dialog has been displayed to ask to use the analytics tracking
|
||||||
*/
|
*/
|
||||||
fun didAskToUseAnalytics(context: Context): Boolean {
|
fun didAskToUseAnalytics(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(DID_ASK_TO_USE_ANALYTICS_TRACKING_KEY, false)
|
return defaultPrefs.getBoolean(DID_ASK_TO_USE_ANALYTICS_TRACKING_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -714,9 +709,8 @@ object VectorPreferences {
|
|||||||
*
|
*
|
||||||
* @param context the context
|
* @param context the context
|
||||||
*/
|
*/
|
||||||
fun setDidAskToUseAnalytics(context: Context) {
|
fun setDidAskToUseAnalytics() {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
defaultPrefs.edit {
|
||||||
.edit {
|
|
||||||
putBoolean(DID_ASK_TO_USE_ANALYTICS_TRACKING_KEY, true)
|
putBoolean(DID_ASK_TO_USE_ANALYTICS_TRACKING_KEY, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -727,8 +721,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the analytics tracking is authorized
|
* @return true if the analytics tracking is authorized
|
||||||
*/
|
*/
|
||||||
fun useAnalytics(context: Context): Boolean {
|
fun useAnalytics(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_USE_ANALYTICS_KEY, false)
|
return defaultPrefs.getBoolean(SETTINGS_USE_ANALYTICS_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -737,9 +731,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @param useAnalytics true to enable the analytics tracking
|
* @param useAnalytics true to enable the analytics tracking
|
||||||
*/
|
*/
|
||||||
fun setUseAnalytics(context: Context, useAnalytics: Boolean) {
|
fun setUseAnalytics(useAnalytics: Boolean) {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
defaultPrefs.edit {
|
||||||
.edit {
|
|
||||||
putBoolean(SETTINGS_USE_ANALYTICS_KEY, useAnalytics)
|
putBoolean(SETTINGS_USE_ANALYTICS_KEY, useAnalytics)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -750,8 +743,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true to preview media
|
* @return true to preview media
|
||||||
*/
|
*/
|
||||||
fun previewMediaWhenSending(context: Context): Boolean {
|
fun previewMediaWhenSending(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_PREVIEW_MEDIA_BEFORE_SENDING_KEY, false)
|
return defaultPrefs.getBoolean(SETTINGS_PREVIEW_MEDIA_BEFORE_SENDING_KEY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -760,8 +753,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true to send message with enter
|
* @return true to send message with enter
|
||||||
*/
|
*/
|
||||||
fun sendMessageWithEnter(context: Context): Boolean {
|
fun sendMessageWithEnter(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_SEND_MESSAGE_WITH_ENTER, false)
|
return defaultPrefs.getBoolean(SETTINGS_SEND_MESSAGE_WITH_ENTER, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -770,8 +763,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true if the rage shake is used
|
* @return true if the rage shake is used
|
||||||
*/
|
*/
|
||||||
fun useRageshake(context: Context): Boolean {
|
fun useRageshake(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_USE_RAGE_SHAKE_KEY, true)
|
return defaultPrefs.getBoolean(SETTINGS_USE_RAGE_SHAKE_KEY, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -780,9 +773,8 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @param isEnabled true to enable the rage shake
|
* @param isEnabled true to enable the rage shake
|
||||||
*/
|
*/
|
||||||
fun setUseRageshake(context: Context, isEnabled: Boolean) {
|
fun setUseRageshake(isEnabled: Boolean) {
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
defaultPrefs.edit {
|
||||||
.edit {
|
|
||||||
putBoolean(SETTINGS_USE_RAGE_SHAKE_KEY, isEnabled)
|
putBoolean(SETTINGS_USE_RAGE_SHAKE_KEY, isEnabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -793,7 +785,7 @@ object VectorPreferences {
|
|||||||
* @param context the context
|
* @param context the context
|
||||||
* @return true to display all the events even the redacted ones.
|
* @return true to display all the events even the redacted ones.
|
||||||
*/
|
*/
|
||||||
fun displayAllEvents(context: Context): Boolean {
|
fun displayAllEvents(): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTINGS_DISPLAY_ALL_EVENTS_KEY, false)
|
return defaultPrefs.getBoolean(SETTINGS_DISPLAY_ALL_EVENTS_KEY, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,13 @@ import androidx.core.content.edit
|
|||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
|
import im.vector.riotx.core.di.ScreenComponent
|
||||||
import im.vector.riotx.core.extensions.withArgs
|
import im.vector.riotx.core.extensions.withArgs
|
||||||
import im.vector.riotx.core.preference.BingRule
|
import im.vector.riotx.core.preference.BingRule
|
||||||
import im.vector.riotx.core.preference.BingRulePreference
|
import im.vector.riotx.core.preference.BingRulePreference
|
||||||
import im.vector.riotx.features.notifications.NotificationUtils
|
import im.vector.riotx.features.notifications.NotificationUtils
|
||||||
import im.vector.riotx.features.notifications.supportNotificationChannels
|
import im.vector.riotx.features.notifications.supportNotificationChannels
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseFragment() {
|
class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseFragment() {
|
||||||
|
|
||||||
@ -45,6 +47,13 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF
|
|||||||
|
|
||||||
override val preferenceXmlRes = R.xml.vector_settings_notification_advanced_preferences
|
override val preferenceXmlRes = R.xml.vector_settings_notification_advanced_preferences
|
||||||
|
|
||||||
|
@Inject lateinit var vectorPreferences: VectorPreferences
|
||||||
|
|
||||||
|
override fun injectWith(injector: ScreenComponent) {
|
||||||
|
injector.inject(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun bindPref() {
|
override fun bindPref() {
|
||||||
val callNotificationsSystemOptions = findPreference(VectorPreferences.SETTINGS_SYSTEM_CALL_NOTIFICATION_PREFERENCE_KEY)
|
val callNotificationsSystemOptions = findPreference(VectorPreferences.SETTINGS_SYSTEM_CALL_NOTIFICATION_PREFERENCE_KEY)
|
||||||
if (supportNotificationChannels()) {
|
if (supportNotificationChannels()) {
|
||||||
@ -83,13 +92,13 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF
|
|||||||
if (supportNotificationChannels()) {
|
if (supportNotificationChannels()) {
|
||||||
ringtonePreference.isVisible = false
|
ringtonePreference.isVisible = false
|
||||||
} else {
|
} else {
|
||||||
ringtonePreference.summary = VectorPreferences.getNotificationRingToneName(requireContext())
|
ringtonePreference.summary = vectorPreferences.getNotificationRingToneName()
|
||||||
ringtonePreference.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
ringtonePreference.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||||
val intent = Intent(RingtoneManager.ACTION_RINGTONE_PICKER)
|
val intent = Intent(RingtoneManager.ACTION_RINGTONE_PICKER)
|
||||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION)
|
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION)
|
||||||
|
|
||||||
if (null != VectorPreferences.getNotificationRingTone(requireContext())) {
|
if (null != vectorPreferences.getNotificationRingTone()) {
|
||||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, VectorPreferences.getNotificationRingTone(requireContext()))
|
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, vectorPreferences.getNotificationRingTone())
|
||||||
}
|
}
|
||||||
|
|
||||||
startActivityForResult(intent, REQUEST_NOTIFICATION_RINGTONE)
|
startActivityForResult(intent, REQUEST_NOTIFICATION_RINGTONE)
|
||||||
@ -152,13 +161,12 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF
|
|||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
REQUEST_NOTIFICATION_RINGTONE -> {
|
REQUEST_NOTIFICATION_RINGTONE -> {
|
||||||
VectorPreferences.setNotificationRingTone(requireContext(),
|
vectorPreferences.setNotificationRingTone(data?.getParcelableExtra<Parcelable>(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) as Uri?)
|
||||||
data?.getParcelableExtra<Parcelable>(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) as Uri?)
|
|
||||||
|
|
||||||
// test if the selected ring tone can be played
|
// test if the selected ring tone can be played
|
||||||
val notificationRingToneName = VectorPreferences.getNotificationRingToneName(requireContext())
|
val notificationRingToneName = vectorPreferences.getNotificationRingToneName()
|
||||||
if (null != notificationRingToneName) {
|
if (null != notificationRingToneName) {
|
||||||
VectorPreferences.setNotificationRingTone(requireContext(), VectorPreferences.getNotificationRingTone(requireContext()))
|
vectorPreferences.setNotificationRingTone(vectorPreferences.getNotificationRingTone())
|
||||||
findPreference(VectorPreferences.SETTINGS_NOTIFICATION_RINGTONE_SELECTION_PREFERENCE_KEY).summary = notificationRingToneName
|
findPreference(VectorPreferences.SETTINGS_NOTIFICATION_RINGTONE_SELECTION_PREFERENCE_KEY).summary = notificationRingToneName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ class VectorSettingsNotificationPreferenceFragment : VectorSettingsBaseFragment(
|
|||||||
|
|
||||||
@Inject lateinit var pushManager: PushersManager
|
@Inject lateinit var pushManager: PushersManager
|
||||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||||
|
@Inject lateinit var vectorPreferences: VectorPreferences
|
||||||
|
|
||||||
override fun bindPref() {
|
override fun bindPref() {
|
||||||
findPreference(VectorPreferences.SETTINGS_ENABLE_ALL_NOTIF_PREFERENCE_KEY).let { pref ->
|
findPreference(VectorPreferences.SETTINGS_ENABLE_ALL_NOTIF_PREFERENCE_KEY).let { pref ->
|
||||||
@ -84,7 +85,7 @@ class VectorSettingsNotificationPreferenceFragment : VectorSettingsBaseFragment(
|
|||||||
val switchPref = preference as SwitchPreference
|
val switchPref = preference as SwitchPreference
|
||||||
if (switchPref.isChecked) {
|
if (switchPref.isChecked) {
|
||||||
FcmHelper.getFcmToken(requireContext())?.let {
|
FcmHelper.getFcmToken(requireContext())?.let {
|
||||||
if (VectorPreferences.areNotificationEnabledForDevice(requireContext())) {
|
if (vectorPreferences.areNotificationEnabledForDevice()) {
|
||||||
pushManager.registerPusherWithFcmKey(it)
|
pushManager.registerPusherWithFcmKey(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ class VectorSettingsPreferencesFragment : VectorSettingsBaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject lateinit var vectorConfiguration: VectorConfiguration
|
@Inject lateinit var vectorConfiguration: VectorConfiguration
|
||||||
|
@Inject lateinit var vectorPreferences: VectorPreferences
|
||||||
|
|
||||||
override fun injectWith(injector: ScreenComponent) {
|
override fun injectWith(injector: ScreenComponent) {
|
||||||
injector.inject(this)
|
injector.inject(this)
|
||||||
@ -113,17 +114,17 @@ class VectorSettingsPreferencesFragment : VectorSettingsBaseFragment() {
|
|||||||
|
|
||||||
// update keep medias period
|
// update keep medias period
|
||||||
findPreference(VectorPreferences.SETTINGS_MEDIA_SAVING_PERIOD_KEY).let {
|
findPreference(VectorPreferences.SETTINGS_MEDIA_SAVING_PERIOD_KEY).let {
|
||||||
it.summary = VectorPreferences.getSelectedMediasSavingPeriodString(requireContext())
|
it.summary = vectorPreferences.getSelectedMediasSavingPeriodString()
|
||||||
|
|
||||||
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||||
context?.let { context: Context ->
|
context?.let { context: Context ->
|
||||||
AlertDialog.Builder(context)
|
AlertDialog.Builder(context)
|
||||||
.setSingleChoiceItems(R.array.media_saving_choice,
|
.setSingleChoiceItems(R.array.media_saving_choice,
|
||||||
VectorPreferences.getSelectedMediasSavingPeriod(context)) { d, n ->
|
vectorPreferences.getSelectedMediasSavingPeriod()) { d, n ->
|
||||||
VectorPreferences.setSelectedMediasSavingPeriod(context, n)
|
vectorPreferences.setSelectedMediasSavingPeriod(n)
|
||||||
d.cancel()
|
d.cancel()
|
||||||
|
|
||||||
it.summary = VectorPreferences.getSelectedMediasSavingPeriodString(context)
|
it.summary = vectorPreferences.getSelectedMediasSavingPeriodString()
|
||||||
}
|
}
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ import im.vector.matrix.android.internal.crypto.model.ImportRoomKeysResult
|
|||||||
import im.vector.matrix.android.internal.crypto.model.rest.DeviceInfo
|
import im.vector.matrix.android.internal.crypto.model.rest.DeviceInfo
|
||||||
import im.vector.matrix.android.internal.crypto.model.rest.DevicesListResponse
|
import im.vector.matrix.android.internal.crypto.model.rest.DevicesListResponse
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
|
import im.vector.riotx.core.di.ScreenComponent
|
||||||
import im.vector.riotx.core.dialogs.ExportKeysDialog
|
import im.vector.riotx.core.dialogs.ExportKeysDialog
|
||||||
import im.vector.riotx.core.intent.ExternalIntentData
|
import im.vector.riotx.core.intent.ExternalIntentData
|
||||||
import im.vector.riotx.core.intent.analyseIntent
|
import im.vector.riotx.core.intent.analyseIntent
|
||||||
@ -57,6 +58,7 @@ import timber.log.Timber
|
|||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() {
|
class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() {
|
||||||
|
|
||||||
@ -127,6 +129,12 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() {
|
|||||||
findPreference(VectorPreferences.SETTINGS_ENCRYPTION_NEVER_SENT_TO_PREFERENCE_KEY) as SwitchPreference
|
findPreference(VectorPreferences.SETTINGS_ENCRYPTION_NEVER_SENT_TO_PREFERENCE_KEY) as SwitchPreference
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject lateinit var vectorPreferences: VectorPreferences
|
||||||
|
|
||||||
|
override fun injectWith(injector: ScreenComponent) {
|
||||||
|
injector.inject(this)
|
||||||
|
}
|
||||||
|
|
||||||
override fun bindPref() {
|
override fun bindPref() {
|
||||||
// Push target
|
// Push target
|
||||||
refreshPushersList()
|
refreshPushersList()
|
||||||
@ -142,20 +150,20 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() {
|
|||||||
// Analytics tracking management
|
// Analytics tracking management
|
||||||
(findPreference(VectorPreferences.SETTINGS_USE_ANALYTICS_KEY) as SwitchPreference).let {
|
(findPreference(VectorPreferences.SETTINGS_USE_ANALYTICS_KEY) as SwitchPreference).let {
|
||||||
// On if the analytics tracking is activated
|
// On if the analytics tracking is activated
|
||||||
it.isChecked = VectorPreferences.useAnalytics(requireContext())
|
it.isChecked = vectorPreferences.useAnalytics()
|
||||||
|
|
||||||
it.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
it.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
VectorPreferences.setUseAnalytics(requireContext(), newValue as Boolean)
|
vectorPreferences.setUseAnalytics(newValue as Boolean)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rageshake Management
|
// Rageshake Management
|
||||||
(findPreference(VectorPreferences.SETTINGS_USE_RAGE_SHAKE_KEY) as SwitchPreference).let {
|
(findPreference(VectorPreferences.SETTINGS_USE_RAGE_SHAKE_KEY) as SwitchPreference).let {
|
||||||
it.isChecked = VectorPreferences.useRageshake(requireContext())
|
it.isChecked = vectorPreferences.useRageshake()
|
||||||
|
|
||||||
it.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
it.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
VectorPreferences.setUseRageshake(requireContext(), newValue as Boolean)
|
vectorPreferences.setUseRageshake(newValue as Boolean)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package im.vector.riotx.features.settings.troubleshoot
|
package im.vector.riotx.features.settings.troubleshoot
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.resources.StringProvider
|
import im.vector.riotx.core.resources.StringProvider
|
||||||
import im.vector.riotx.features.settings.VectorPreferences
|
import im.vector.riotx.features.settings.VectorPreferences
|
||||||
@ -24,20 +23,20 @@ import javax.inject.Inject
|
|||||||
/**
|
/**
|
||||||
* Checks if notifications are enable in the system settings for this app.
|
* Checks if notifications are enable in the system settings for this app.
|
||||||
*/
|
*/
|
||||||
class TestDeviceSettings @Inject constructor(private val context: AppCompatActivity,
|
class TestDeviceSettings @Inject constructor(private val vectorPreferences: VectorPreferences,
|
||||||
private val stringProvider: StringProvider)
|
private val stringProvider: StringProvider)
|
||||||
: TroubleshootTest(R.string.settings_troubleshoot_test_device_settings_title) {
|
: TroubleshootTest(R.string.settings_troubleshoot_test_device_settings_title) {
|
||||||
|
|
||||||
override fun perform() {
|
override fun perform() {
|
||||||
|
|
||||||
if (VectorPreferences.areNotificationEnabledForDevice(context)) {
|
if (vectorPreferences.areNotificationEnabledForDevice()) {
|
||||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_device_settings_success)
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_device_settings_success)
|
||||||
quickFix = null
|
quickFix = null
|
||||||
status = TestStatus.SUCCESS
|
status = TestStatus.SUCCESS
|
||||||
} else {
|
} else {
|
||||||
quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_device_settings_quickfix) {
|
quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_device_settings_quickfix) {
|
||||||
override fun doFix() {
|
override fun doFix() {
|
||||||
VectorPreferences.setNotificationEnabledForDevice(context, true)
|
vectorPreferences.setNotificationEnabledForDevice(true)
|
||||||
manager?.retry()
|
manager?.retry()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user