Remove google services

This commit is contained in:
世界
2023-11-07 22:25:36 +08:00
parent fb705ed8a4
commit 56a27728b9
9 changed files with 2 additions and 103 deletions

View File

@@ -4,7 +4,6 @@ object SettingsKey {
const val SELECTED_PROFILE = "selected_profile"
const val SERVICE_MODE = "service_mode"
const val ERROR_REPORTING_ENABLED = "error_reporting_enabled"
const val CHECK_UPDATE_ENABLED = "check_update_enabled"
const val DISABLE_MEMORY_LIMIT = "disable_memory_limit"

View File

@@ -38,11 +38,6 @@ object Settings {
var serviceMode by dataStore.string(SettingsKey.SERVICE_MODE) { ServiceMode.NORMAL }
var startedByUser by dataStore.boolean(SettingsKey.STARTED_BY_USER)
const val ERROR_REPORTING_UNKNOWN = -1
const val ERROR_REPORTING_ALLOWED = 0
const val ERROR_REPORTING_DISALLOWED = 1
var errorReportingEnabled by dataStore.int(SettingsKey.ERROR_REPORTING_ENABLED) { ERROR_REPORTING_UNKNOWN }
var checkUpdateEnabled by dataStore.boolean(SettingsKey.CHECK_UPDATE_ENABLED) { true }
var disableMemoryLimit by dataStore.boolean(SettingsKey.DISABLE_MEMORY_LIMIT)

View File

@@ -22,8 +22,6 @@ import com.google.android.play.core.appupdate.AppUpdateOptions
import com.google.android.play.core.install.model.AppUpdateType
import com.google.android.play.core.install.model.InstallStatus
import com.google.android.play.core.install.model.UpdateAvailability
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import io.nekohasekai.libbox.Libbox
import io.nekohasekai.libbox.ProfileContent
import io.nekohasekai.sfa.Application
@@ -180,11 +178,7 @@ class MainActivity : AbstractActivity(), ServiceConnection.Callback {
private fun startIntegration() {
lifecycleScope.launch(Dispatchers.IO) {
if (Settings.errorReportingEnabled == Settings.ERROR_REPORTING_UNKNOWN) {
withContext(Dispatchers.Main) {
confirmErrorReportingIntegration()
}
} else if (Settings.checkUpdateEnabled) {
if (Settings.checkUpdateEnabled) {
checkUpdate()
}
}
@@ -232,22 +226,6 @@ class MainActivity : AbstractActivity(), ServiceConnection.Callback {
}
}
private fun confirmErrorReportingIntegration() {
val builder = MaterialAlertDialogBuilder(this).setTitle(getString(R.string.error_reporting))
.setMessage(R.string.error_reporting_message)
.setPositiveButton(getString(R.string.ok)) { _, _ ->
lifecycleScope.launch(Dispatchers.IO) {
Settings.errorReportingEnabled = Settings.ERROR_REPORTING_ALLOWED
Firebase.crashlytics.setCrashlyticsCollectionEnabled(true)
}
}.setNegativeButton(getString(R.string.no_thanks)) { _, _ ->
lifecycleScope.launch(Dispatchers.IO) {
Settings.errorReportingEnabled = Settings.ERROR_REPORTING_DISALLOWED
}
}
runCatching { builder.show() }
}
@SuppressLint("NewApi")
fun startService() {
if (!ServiceNotification.checkPermission()) {

View File

@@ -11,8 +11,6 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.view.isGone
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import io.nekohasekai.libbox.Libbox
import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.R
@@ -66,14 +64,6 @@ class SettingsFragment : Fragment() {
Settings.checkUpdateEnabled = newValue
}
}
binding.errorReportingEnabled.addTextChangedListener {
lifecycleScope.launch(Dispatchers.IO) {
val newValue = EnabledType.valueOf(it).boolValue
Settings.errorReportingEnabled =
if (newValue) Settings.ERROR_REPORTING_ALLOWED else Settings.ERROR_REPORTING_DISALLOWED
Firebase.crashlytics.setCrashlyticsCollectionEnabled(newValue)
}
}
binding.disableMemoryLimit.addTextChangedListener {
lifecycleScope.launch(Dispatchers.IO) {
val newValue = EnabledType.valueOf(it).boolValue
@@ -115,7 +105,6 @@ class SettingsFragment : Fragment() {
(activity.getExternalFilesDir(null) ?: activity.filesDir)
.walkTopDown().filter { it.isFile }.map { it.length() }.sum()
)
val errorReportingEnabled = Settings.errorReportingEnabled == Settings.ERROR_REPORTING_ALLOWED
val checkUpdateEnabled = Settings.checkUpdateEnabled
val removeBackgroundPermissionPage = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Application.powerManager.isIgnoringBatteryOptimizations(Application.application.packageName)
@@ -124,8 +113,6 @@ class SettingsFragment : Fragment() {
}
withContext(Dispatchers.Main) {
binding.dataSizeText.text = dataSize
binding.errorReportingEnabled.text = EnabledType.from(errorReportingEnabled).name
binding.errorReportingEnabled.setSimpleItems(R.array.enabled)
binding.checkUpdateEnabled.text = EnabledType.from(checkUpdateEnabled).name
binding.checkUpdateEnabled.setSimpleItems(R.array.enabled)
binding.disableMemoryLimit.text = EnabledType.from(!Settings.disableMemoryLimit).name