mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-17 04:20:00 +03:00
Dagger: fix some merging issues
This commit is contained in:
parent
f18bc9bd00
commit
604de7eebc
7 changed files with 80 additions and 66 deletions
|
@ -15,26 +15,29 @@
|
|||
*/
|
||||
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.core.resources.StringProvider
|
||||
import im.vector.riotredesign.features.settings.PreferencesManager
|
||||
import im.vector.riotredesign.features.settings.troubleshoot.TroubleshootTest
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (PreferencesManager.autoStartOnBoot(fragment.context)) {
|
||||
description = fragment.getString(R.string.settings_troubleshoot_test_service_boot_success)
|
||||
if (PreferencesManager.autoStartOnBoot(context)) {
|
||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_service_boot_success)
|
||||
status = TestStatus.SUCCESS
|
||||
quickFix = null
|
||||
} 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) {
|
||||
override fun doFix() {
|
||||
PreferencesManager.setAutoStartOnBoot(fragment.context, true)
|
||||
PreferencesManager.setAutoStartOnBoot(context, true)
|
||||
manager?.retry()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,24 +17,27 @@ package im.vector.riotredesign.fdroid.features.settings.troubleshoot
|
|||
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.net.ConnectivityManagerCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.resources.StringProvider
|
||||
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() {
|
||||
(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
|
||||
if (isActiveNetworkMetered) {
|
||||
// Checks user’s Data Saver settings.
|
||||
val restrictBackgroundStatus = ConnectivityManagerCompat.getRestrictBackgroundStatus(this)
|
||||
when (restrictBackgroundStatus) {
|
||||
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED -> {
|
||||
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED -> {
|
||||
// Background data usage is blocked for this app. Wherever possible,
|
||||
// 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")
|
||||
status = TestStatus.FAILED
|
||||
quickFix = null
|
||||
|
@ -42,15 +45,15 @@ class TestBackgroundRestrictions(val fragment: Fragment) : TroubleshootTest(R.st
|
|||
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_WHITELISTED -> {
|
||||
// The app is whitelisted. Wherever possible,
|
||||
// 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")
|
||||
status = TestStatus.SUCCESS
|
||||
quickFix = null
|
||||
}
|
||||
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_DISABLED -> {
|
||||
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_DISABLED -> {
|
||||
// Data Saver is disabled. Since the device is connected to a
|
||||
// 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")
|
||||
status = TestStatus.SUCCESS
|
||||
quickFix = null
|
||||
|
@ -61,7 +64,7 @@ class TestBackgroundRestrictions(val fragment: Fragment) : TroubleshootTest(R.st
|
|||
} else {
|
||||
// The device is not on a metered network.
|
||||
// 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
|
||||
quickFix = null
|
||||
}
|
||||
|
|
|
@ -16,31 +16,27 @@
|
|||
package im.vector.riotredesign.push.fcm
|
||||
|
||||
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.TestBackgroundRestrictions
|
||||
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 createTestManager(fragment: Fragment, session: Session?): NotificationTroubleshootTestManager {
|
||||
val mgr = NotificationTroubleshootTestManager(fragment)
|
||||
mgr.addTest(TestSystemSettings(fragment))
|
||||
if (session != null) {
|
||||
mgr.addTest(TestAccountSettings(fragment, session))
|
||||
}
|
||||
mgr.addTest(TestDeviceSettings(fragment))
|
||||
if (session != null) {
|
||||
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
|
||||
}
|
||||
fun create(fragment: Fragment): NotificationTroubleshootTestManager {
|
||||
val mgr = NotificationTroubleshootTestManager(fragment)
|
||||
mgr.addTest(testSystemSettings)
|
||||
mgr.addTest(testAccountSettings)
|
||||
mgr.addTest(testDeviceSettings)
|
||||
mgr.addTest(testBingRulesSettings)
|
||||
mgr.addTest(testAutoStartBoot)
|
||||
mgr.addTest(testBackgroundRestrictions)
|
||||
return mgr
|
||||
}
|
||||
|
||||
}
|
|
@ -49,10 +49,10 @@ import javax.inject.Inject
|
|||
*/
|
||||
class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
||||
|
||||
@Inject lateinit var notificationDrawerManager: NotificationDrawerManager
|
||||
@Inject lateinit var notifiableEventResolver: NotifiableEventResolver
|
||||
@Inject lateinit var pusherManager: PushersManager
|
||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
private lateinit var notificationDrawerManager: NotificationDrawerManager
|
||||
private lateinit var notifiableEventResolver: NotifiableEventResolver
|
||||
private lateinit var pusherManager: PushersManager
|
||||
private lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
|
||||
// UI handler
|
||||
private val mUIHandler by lazy {
|
||||
|
@ -61,7 +61,10 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
|||
|
||||
override fun 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.riotredesign.EmojiCompatFontProvider
|
||||
import im.vector.riotredesign.VectorApplication
|
||||
import im.vector.riotredesign.core.pushers.PushersManager
|
||||
import im.vector.riotredesign.features.configuration.VectorConfiguration
|
||||
import im.vector.riotredesign.features.crypto.keysrequest.KeyRequestHandler
|
||||
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.group.SelectedGroupStore
|
||||
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.NotificationDrawerManager
|
||||
import im.vector.riotredesign.features.notifications.PushRuleTriggerListener
|
||||
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.gplay.push.fcm.VectorFirebaseMessagingService
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Component(modules = [VectorModule::class])
|
||||
|
@ -50,8 +50,6 @@ interface VectorComponent {
|
|||
|
||||
fun inject(vectorApplication: VectorApplication)
|
||||
|
||||
fun inject(vectorFirebaseMessagingService: VectorFirebaseMessagingService)
|
||||
|
||||
fun matrix(): Matrix
|
||||
|
||||
fun currentSession(): Session
|
||||
|
@ -90,6 +88,10 @@ interface VectorComponent {
|
|||
|
||||
fun pushRuleTriggerListener(): PushRuleTriggerListener
|
||||
|
||||
fun pusherManager(): PushersManager
|
||||
|
||||
fun notifiableEventResolver(): NotifiableEventResolver
|
||||
|
||||
@Component.Factory
|
||||
interface Factory {
|
||||
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)))
|
||||
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 {
|
||||
JSONObject(it).toString(4)
|
||||
} ?: 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.AssistedInject
|
||||
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.riotredesign.core.extensions.localDateTime
|
||||
import im.vector.riotredesign.core.platform.VectorViewModel
|
||||
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineDateFormatter
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Single
|
||||
|
||||
|
||||
data class DisplayReactionsViewState(
|
||||
|
@ -46,19 +48,17 @@ class ViewReactionViewModel @AssistedInject constructor(@Assisted
|
|||
@AssistedInject.Factory
|
||||
interface Factory {
|
||||
fun create(initialState: DisplayReactionsViewState): ViewReactionViewModel
|
||||
}
|
||||
|
||||
companion object : MvRxViewModelFactory<ViewReactionViewModel, DisplayReactionsViewState> {
|
||||
|
||||
override fun create(viewModelContext: ViewModelContext, state: DisplayReactionsViewState): ViewReactionViewModel? {
|
||||
val fragment: ViewReactionBottomSheet = (viewModelContext as FragmentViewModelContext).fragment()
|
||||
return fragment.viewReactionViewModelFactory.create(state)
|
||||
}
|
||||
companion object : MvRxViewModelFactory<ViewReactionViewModel, DisplayReactionsViewState> {
|
||||
|
||||
override fun create(viewModelContext: ViewModelContext, state: DisplayReactionsViewState): ViewReactionViewModel? {
|
||||
val fragment: ViewReactionBottomSheet = (viewModelContext as FragmentViewModelContext).fragment()
|
||||
return fragment.viewReactionViewModelFactory.create(state)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
observeEventAnnotationSummaries()
|
||||
}
|
||||
|
@ -69,23 +69,31 @@ class ViewReactionViewModel @AssistedInject constructor(@Assisted
|
|||
.flatMapSingle { summaries ->
|
||||
Observable
|
||||
.fromIterable(summaries)
|
||||
.flatMapIterable { it.reactionsSummary }
|
||||
.map {
|
||||
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()
|
||||
.flatMapIterable {it.reactionsSummary}
|
||||
.toReactionInfoList()
|
||||
}
|
||||
.execute {
|
||||
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…
Add table
Reference in a new issue