forked from GitHub-Mirror/riotX-android
Dagger: fix some merging issues
This commit is contained in:
parent
f18bc9bd00
commit
604de7eebc
@ -15,26 +15,29 @@
|
|||||||
*/
|
*/
|
||||||
package im.vector.riotredesign.fdroid.features.settings.troubleshoot
|
package im.vector.riotredesign.fdroid.features.settings.troubleshoot
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import im.vector.riotredesign.R
|
import im.vector.riotredesign.R
|
||||||
|
import im.vector.riotredesign.core.resources.StringProvider
|
||||||
import im.vector.riotredesign.features.settings.PreferencesManager
|
import im.vector.riotredesign.features.settings.PreferencesManager
|
||||||
import im.vector.riotredesign.features.settings.troubleshoot.TroubleshootTest
|
import im.vector.riotredesign.features.settings.troubleshoot.TroubleshootTest
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that the application is started on boot
|
* Test that the application is started on boot
|
||||||
*/
|
*/
|
||||||
class TestAutoStartBoot(val fragment: Fragment) : TroubleshootTest(R.string.settings_troubleshoot_test_service_boot_title) {
|
class TestAutoStartBoot @Inject constructor(private val context: AppCompatActivity,
|
||||||
|
private val stringProvider: StringProvider) : TroubleshootTest(R.string.settings_troubleshoot_test_service_boot_title) {
|
||||||
|
|
||||||
override fun perform() {
|
override fun perform() {
|
||||||
if (PreferencesManager.autoStartOnBoot(fragment.context)) {
|
if (PreferencesManager.autoStartOnBoot(context)) {
|
||||||
description = fragment.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
|
||||||
} else {
|
} else {
|
||||||
description = fragment.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() {
|
||||||
PreferencesManager.setAutoStartOnBoot(fragment.context, true)
|
PreferencesManager.setAutoStartOnBoot(context, true)
|
||||||
manager?.retry()
|
manager?.retry()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,15 +17,18 @@ package im.vector.riotredesign.fdroid.features.settings.troubleshoot
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.net.ConnectivityManagerCompat
|
import androidx.core.net.ConnectivityManagerCompat
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import im.vector.riotredesign.R
|
import im.vector.riotredesign.R
|
||||||
|
import im.vector.riotredesign.core.resources.StringProvider
|
||||||
import im.vector.riotredesign.features.settings.troubleshoot.TroubleshootTest
|
import im.vector.riotredesign.features.settings.troubleshoot.TroubleshootTest
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class TestBackgroundRestrictions(val fragment: Fragment) : TroubleshootTest(R.string.settings_troubleshoot_test_bg_restricted_title) {
|
class TestBackgroundRestrictions @Inject constructor(private val context: AppCompatActivity,
|
||||||
|
private val stringProvider: StringProvider) : TroubleshootTest(R.string.settings_troubleshoot_test_bg_restricted_title) {
|
||||||
|
|
||||||
override fun perform() {
|
override fun perform() {
|
||||||
(fragment.context!!.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager).apply {
|
(context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager).apply {
|
||||||
// Checks if the device is on a metered network
|
// Checks if the device is on a metered network
|
||||||
if (isActiveNetworkMetered) {
|
if (isActiveNetworkMetered) {
|
||||||
// Checks user’s Data Saver settings.
|
// Checks user’s Data Saver settings.
|
||||||
@ -34,7 +37,7 @@ class TestBackgroundRestrictions(val fragment: Fragment) : TroubleshootTest(R.st
|
|||||||
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED -> {
|
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED -> {
|
||||||
// Background data usage is blocked for this app. Wherever possible,
|
// Background data usage is blocked for this app. Wherever possible,
|
||||||
// the app should also use less data in the foreground.
|
// the app should also use less data in the foreground.
|
||||||
description = fragment.getString(R.string.settings_troubleshoot_test_bg_restricted_failed,
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_bg_restricted_failed,
|
||||||
"RESTRICT_BACKGROUND_STATUS_ENABLED")
|
"RESTRICT_BACKGROUND_STATUS_ENABLED")
|
||||||
status = TestStatus.FAILED
|
status = TestStatus.FAILED
|
||||||
quickFix = null
|
quickFix = null
|
||||||
@ -42,7 +45,7 @@ class TestBackgroundRestrictions(val fragment: Fragment) : TroubleshootTest(R.st
|
|||||||
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_WHITELISTED -> {
|
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_WHITELISTED -> {
|
||||||
// The app is whitelisted. Wherever possible,
|
// The app is whitelisted. Wherever possible,
|
||||||
// the app should use less data in the foreground and background.
|
// the app should use less data in the foreground and background.
|
||||||
description = fragment.getString(R.string.settings_troubleshoot_test_bg_restricted_success,
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_bg_restricted_success,
|
||||||
"RESTRICT_BACKGROUND_STATUS_WHITELISTED")
|
"RESTRICT_BACKGROUND_STATUS_WHITELISTED")
|
||||||
status = TestStatus.SUCCESS
|
status = TestStatus.SUCCESS
|
||||||
quickFix = null
|
quickFix = null
|
||||||
@ -50,7 +53,7 @@ class TestBackgroundRestrictions(val fragment: Fragment) : TroubleshootTest(R.st
|
|||||||
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_DISABLED -> {
|
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_DISABLED -> {
|
||||||
// Data Saver is disabled. Since the device is connected to a
|
// Data Saver is disabled. Since the device is connected to a
|
||||||
// metered network, the app should use less data wherever possible.
|
// metered network, the app should use less data wherever possible.
|
||||||
description = fragment.getString(R.string.settings_troubleshoot_test_bg_restricted_success,
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_bg_restricted_success,
|
||||||
"RESTRICT_BACKGROUND_STATUS_DISABLED")
|
"RESTRICT_BACKGROUND_STATUS_DISABLED")
|
||||||
status = TestStatus.SUCCESS
|
status = TestStatus.SUCCESS
|
||||||
quickFix = null
|
quickFix = null
|
||||||
@ -61,7 +64,7 @@ class TestBackgroundRestrictions(val fragment: Fragment) : TroubleshootTest(R.st
|
|||||||
} else {
|
} else {
|
||||||
// The device is not on a metered network.
|
// The device is not on a metered network.
|
||||||
// Use data as required to perform syncs, downloads, and updates.
|
// Use data as required to perform syncs, downloads, and updates.
|
||||||
description = fragment.getString(R.string.settings_troubleshoot_test_bg_restricted_success, "")
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_bg_restricted_success, "")
|
||||||
status = TestStatus.SUCCESS
|
status = TestStatus.SUCCESS
|
||||||
quickFix = null
|
quickFix = null
|
||||||
}
|
}
|
||||||
|
@ -16,31 +16,27 @@
|
|||||||
package im.vector.riotredesign.push.fcm
|
package im.vector.riotredesign.push.fcm
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import im.vector.matrix.android.api.session.Session
|
|
||||||
import im.vector.riotredesign.fdroid.features.settings.troubleshoot.TestAutoStartBoot
|
import im.vector.riotredesign.fdroid.features.settings.troubleshoot.TestAutoStartBoot
|
||||||
import im.vector.riotredesign.fdroid.features.settings.troubleshoot.TestBackgroundRestrictions
|
import im.vector.riotredesign.fdroid.features.settings.troubleshoot.TestBackgroundRestrictions
|
||||||
import im.vector.riotredesign.features.settings.troubleshoot.*
|
import im.vector.riotredesign.features.settings.troubleshoot.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class NotificationTroubleshootTestManagerFactory {
|
class NotificationTroubleshootTestManagerFactory @Inject constructor(private val testSystemSettings: TestSystemSettings,
|
||||||
|
private val testAccountSettings: TestAccountSettings,
|
||||||
|
private val testDeviceSettings: TestDeviceSettings,
|
||||||
|
private val testBingRulesSettings: TestBingRulesSettings,
|
||||||
|
private val testAutoStartBoot: TestAutoStartBoot,
|
||||||
|
private val testBackgroundRestrictions: TestBackgroundRestrictions) {
|
||||||
|
|
||||||
companion object {
|
fun create(fragment: Fragment): NotificationTroubleshootTestManager {
|
||||||
fun createTestManager(fragment: Fragment, session: Session?): NotificationTroubleshootTestManager {
|
|
||||||
val mgr = NotificationTroubleshootTestManager(fragment)
|
val mgr = NotificationTroubleshootTestManager(fragment)
|
||||||
mgr.addTest(TestSystemSettings(fragment))
|
mgr.addTest(testSystemSettings)
|
||||||
if (session != null) {
|
mgr.addTest(testAccountSettings)
|
||||||
mgr.addTest(TestAccountSettings(fragment, session))
|
mgr.addTest(testDeviceSettings)
|
||||||
}
|
mgr.addTest(testBingRulesSettings)
|
||||||
mgr.addTest(TestDeviceSettings(fragment))
|
mgr.addTest(testAutoStartBoot)
|
||||||
if (session != null) {
|
mgr.addTest(testBackgroundRestrictions)
|
||||||
mgr.addTest(TestBingRulesSettings(fragment, session))
|
|
||||||
}
|
|
||||||
// mgr.addTest(TestNotificationServiceRunning(fragment))
|
|
||||||
// mgr.addTest(TestServiceRestart(fragment))
|
|
||||||
mgr.addTest(TestAutoStartBoot(fragment))
|
|
||||||
mgr.addTest(TestBackgroundRestrictions(fragment))
|
|
||||||
// mgr.addTest(TestBatteryOptimization(fragment))
|
|
||||||
return mgr
|
return mgr
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -49,10 +49,10 @@ import javax.inject.Inject
|
|||||||
*/
|
*/
|
||||||
class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
||||||
|
|
||||||
@Inject lateinit var notificationDrawerManager: NotificationDrawerManager
|
private lateinit var notificationDrawerManager: NotificationDrawerManager
|
||||||
@Inject lateinit var notifiableEventResolver: NotifiableEventResolver
|
private lateinit var notifiableEventResolver: NotifiableEventResolver
|
||||||
@Inject lateinit var pusherManager: PushersManager
|
private lateinit var pusherManager: PushersManager
|
||||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
private lateinit var activeSessionHolder: ActiveSessionHolder
|
||||||
|
|
||||||
// UI handler
|
// UI handler
|
||||||
private val mUIHandler by lazy {
|
private val mUIHandler by lazy {
|
||||||
@ -61,7 +61,10 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
vectorComponent().inject(this)
|
notificationDrawerManager = vectorComponent().notificationDrawerManager()
|
||||||
|
notifiableEventResolver = vectorComponent().notifiableEventResolver()
|
||||||
|
pusherManager = vectorComponent().pusherManager()
|
||||||
|
activeSessionHolder = vectorComponent().activeSessionHolder()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,6 +25,7 @@ import im.vector.matrix.android.api.auth.Authenticator
|
|||||||
import im.vector.matrix.android.api.session.Session
|
import im.vector.matrix.android.api.session.Session
|
||||||
import im.vector.riotredesign.EmojiCompatFontProvider
|
import im.vector.riotredesign.EmojiCompatFontProvider
|
||||||
import im.vector.riotredesign.VectorApplication
|
import im.vector.riotredesign.VectorApplication
|
||||||
|
import im.vector.riotredesign.core.pushers.PushersManager
|
||||||
import im.vector.riotredesign.features.configuration.VectorConfiguration
|
import im.vector.riotredesign.features.configuration.VectorConfiguration
|
||||||
import im.vector.riotredesign.features.crypto.keysrequest.KeyRequestHandler
|
import im.vector.riotredesign.features.crypto.keysrequest.KeyRequestHandler
|
||||||
import im.vector.riotredesign.features.crypto.verification.IncomingVerificationRequestHandler
|
import im.vector.riotredesign.features.crypto.verification.IncomingVerificationRequestHandler
|
||||||
@ -33,13 +34,12 @@ import im.vector.riotredesign.features.home.HomeNavigator
|
|||||||
import im.vector.riotredesign.features.home.HomeRoomListObservableStore
|
import im.vector.riotredesign.features.home.HomeRoomListObservableStore
|
||||||
import im.vector.riotredesign.features.home.group.SelectedGroupStore
|
import im.vector.riotredesign.features.home.group.SelectedGroupStore
|
||||||
import im.vector.riotredesign.features.navigation.Navigator
|
import im.vector.riotredesign.features.navigation.Navigator
|
||||||
|
import im.vector.riotredesign.features.notifications.NotifiableEventResolver
|
||||||
import im.vector.riotredesign.features.notifications.NotificationBroadcastReceiver
|
import im.vector.riotredesign.features.notifications.NotificationBroadcastReceiver
|
||||||
import im.vector.riotredesign.features.notifications.NotificationDrawerManager
|
import im.vector.riotredesign.features.notifications.NotificationDrawerManager
|
||||||
import im.vector.riotredesign.features.notifications.PushRuleTriggerListener
|
import im.vector.riotredesign.features.notifications.PushRuleTriggerListener
|
||||||
import im.vector.riotredesign.features.rageshake.BugReporter
|
import im.vector.riotredesign.features.rageshake.BugReporter
|
||||||
import im.vector.riotredesign.features.rageshake.RageShake
|
|
||||||
import im.vector.riotredesign.features.rageshake.VectorUncaughtExceptionHandler
|
import im.vector.riotredesign.features.rageshake.VectorUncaughtExceptionHandler
|
||||||
import im.vector.riotredesign.gplay.push.fcm.VectorFirebaseMessagingService
|
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Component(modules = [VectorModule::class])
|
@Component(modules = [VectorModule::class])
|
||||||
@ -50,8 +50,6 @@ interface VectorComponent {
|
|||||||
|
|
||||||
fun inject(vectorApplication: VectorApplication)
|
fun inject(vectorApplication: VectorApplication)
|
||||||
|
|
||||||
fun inject(vectorFirebaseMessagingService: VectorFirebaseMessagingService)
|
|
||||||
|
|
||||||
fun matrix(): Matrix
|
fun matrix(): Matrix
|
||||||
|
|
||||||
fun currentSession(): Session
|
fun currentSession(): Session
|
||||||
@ -90,6 +88,10 @@ interface VectorComponent {
|
|||||||
|
|
||||||
fun pushRuleTriggerListener(): PushRuleTriggerListener
|
fun pushRuleTriggerListener(): PushRuleTriggerListener
|
||||||
|
|
||||||
|
fun pusherManager(): PushersManager
|
||||||
|
|
||||||
|
fun notifiableEventResolver(): NotifiableEventResolver
|
||||||
|
|
||||||
@Component.Factory
|
@Component.Factory
|
||||||
interface Factory {
|
interface Factory {
|
||||||
fun create(@BindsInstance context: Context): VectorComponent
|
fun create(@BindsInstance context: Context): VectorComponent
|
||||||
|
@ -160,7 +160,6 @@ class MessageMenuViewModel @AssistedInject constructor(@Assisted initialState: M
|
|||||||
|
|
||||||
this.add(SimpleAction(VIEW_SOURCE, R.string.view_source, R.drawable.ic_view_source, JSONObject(event.root.toContent()).toString(4)))
|
this.add(SimpleAction(VIEW_SOURCE, R.string.view_source, R.drawable.ic_view_source, JSONObject(event.root.toContent()).toString(4)))
|
||||||
if (event.isEncrypted()) {
|
if (event.isEncrypted()) {
|
||||||
this.add(SimpleAction(VIEW_DECRYPTED_SOURCE, R.string.view_decrypted_source, R.drawable.ic_view_source, state.eventId))
|
|
||||||
val decryptedContent = event.root.mClearEvent?.toContent()?.let {
|
val decryptedContent = event.root.mClearEvent?.toContent()?.let {
|
||||||
JSONObject(it).toString(4)
|
JSONObject(it).toString(4)
|
||||||
} ?: stringProvider.getString(R.string.encryption_information_decryption_error)
|
} ?: stringProvider.getString(R.string.encryption_information_decryption_error)
|
||||||
|
@ -4,11 +4,13 @@ import com.airbnb.mvrx.*
|
|||||||
import com.squareup.inject.assisted.Assisted
|
import com.squareup.inject.assisted.Assisted
|
||||||
import com.squareup.inject.assisted.AssistedInject
|
import com.squareup.inject.assisted.AssistedInject
|
||||||
import im.vector.matrix.android.api.session.Session
|
import im.vector.matrix.android.api.session.Session
|
||||||
|
import im.vector.matrix.android.api.session.room.model.ReactionAggregatedSummary
|
||||||
import im.vector.matrix.rx.RxRoom
|
import im.vector.matrix.rx.RxRoom
|
||||||
import im.vector.riotredesign.core.extensions.localDateTime
|
import im.vector.riotredesign.core.extensions.localDateTime
|
||||||
import im.vector.riotredesign.core.platform.VectorViewModel
|
import im.vector.riotredesign.core.platform.VectorViewModel
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineDateFormatter
|
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineDateFormatter
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
|
import io.reactivex.Single
|
||||||
|
|
||||||
|
|
||||||
data class DisplayReactionsViewState(
|
data class DisplayReactionsViewState(
|
||||||
@ -46,6 +48,7 @@ class ViewReactionViewModel @AssistedInject constructor(@Assisted
|
|||||||
@AssistedInject.Factory
|
@AssistedInject.Factory
|
||||||
interface Factory {
|
interface Factory {
|
||||||
fun create(initialState: DisplayReactionsViewState): ViewReactionViewModel
|
fun create(initialState: DisplayReactionsViewState): ViewReactionViewModel
|
||||||
|
}
|
||||||
|
|
||||||
companion object : MvRxViewModelFactory<ViewReactionViewModel, DisplayReactionsViewState> {
|
companion object : MvRxViewModelFactory<ViewReactionViewModel, DisplayReactionsViewState> {
|
||||||
|
|
||||||
@ -56,9 +59,6 @@ class ViewReactionViewModel @AssistedInject constructor(@Assisted
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
observeEventAnnotationSummaries()
|
observeEventAnnotationSummaries()
|
||||||
}
|
}
|
||||||
@ -69,23 +69,31 @@ class ViewReactionViewModel @AssistedInject constructor(@Assisted
|
|||||||
.flatMapSingle { summaries ->
|
.flatMapSingle { summaries ->
|
||||||
Observable
|
Observable
|
||||||
.fromIterable(summaries)
|
.fromIterable(summaries)
|
||||||
.flatMapIterable { it.reactionsSummary }
|
.flatMapIterable {it.reactionsSummary}
|
||||||
.map {
|
.toReactionInfoList()
|
||||||
val event = room.getTimeLineEvent(eventId)
|
|
||||||
?: throw RuntimeException("Your eventId is not valid")
|
|
||||||
val localDate = event.root.localDateTime()
|
|
||||||
ReactionInfo(
|
|
||||||
event.root.eventId!!,
|
|
||||||
it.key,
|
|
||||||
event.root.senderId ?: "",
|
|
||||||
event.senderName,
|
|
||||||
timelineDateFormatter.formatMessageHour(localDate)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
.toList()
|
|
||||||
}
|
}
|
||||||
.execute {
|
.execute {
|
||||||
copy(mapReactionKeyToMemberList = it)
|
copy(mapReactionKeyToMemberList = it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Observable<ReactionAggregatedSummary>.toReactionInfoList(): Single<List<ReactionInfo>> {
|
||||||
|
return flatMap { summary ->
|
||||||
|
Observable
|
||||||
|
.fromIterable(summary.sourceEvents)
|
||||||
|
.map {
|
||||||
|
val event = room.getTimeLineEvent(it)
|
||||||
|
?: throw RuntimeException("Your eventId is not valid")
|
||||||
|
val localDate = event.root.localDateTime()
|
||||||
|
ReactionInfo(
|
||||||
|
event.root.eventId!!,
|
||||||
|
summary.key,
|
||||||
|
event.root.senderId ?: "",
|
||||||
|
event.getDisambiguatedDisplayName(),
|
||||||
|
timelineDateFormatter.formatMessageHour(localDate)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.toList()
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user