forked from GitHub-Mirror/riotX-android
Dagger: fix some merging issues
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user