Skip to content

Commit

Permalink
feat: update LoggingViewModel.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Aug 13, 2024
1 parent 3470778 commit 180443f
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 267 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class EncryptedSettingsPreference @Inject constructor(val preference: Preference
private const val IS_MIGRATED = "IS_MIGRATED"

private const val SETTINGS_LOGGING = "SETTINGS_LOGGING"
private const val SETTINGS_SENTRY = "SETTINGS_SENTRY"
private const val SETTINGS_MULTI_HOP = "SETTINGS_MULTI_HOP"
private const val SETTINGS_MULTI_HOP_SAME_PROVIDER_ALLOWED = "SETTINGS_MULTI_HOP_SAME_PROVIDER_ALLOWED"
private const val SETTINGS_KILL_SWITCH = "SETTINGS_KILL_SWITCH"
Expand Down Expand Up @@ -452,16 +451,6 @@ class EncryptedSettingsPreference @Inject constructor(val preference: Preference
return sharedPreferences.getString(LAST_USED_IP, null)
}

fun enableSentry(value: Boolean) {
sharedPreferences.edit()
.putBoolean(SETTINGS_SENTRY, value)
.apply()
}

fun isSentryEnabled(): Boolean {
return sharedPreferences.getBoolean(SETTINGS_SENTRY, false)
}

fun getFilter(): String? {
return sharedPreferences.getString(SETTINGS_FILTER, null)
}
Expand Down Expand Up @@ -515,9 +504,6 @@ class EncryptedSettingsPreference @Inject constructor(val preference: Preference
if (oldPreference.contains(SETTINGS_LOGGING)) {
putSettingLogging(oldPreference.getBoolean(SETTINGS_LOGGING, false))
}
if (oldPreference.contains(SETTINGS_SENTRY)) {
enableSentry(oldPreference.getBoolean(SETTINGS_SENTRY, true))
}
if (oldPreference.contains(SETTINGS_MULTI_HOP)) {
putSettingMultiHop(oldPreference.getBoolean(SETTINGS_MULTI_HOP, false))
}
Expand Down
6 changes: 0 additions & 6 deletions core/src/main/java/net/ivpn/core/common/prefs/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ class Settings @Inject constructor(
settingsPreference.putSettingStartOnBoot(value)
}

var isSentryEnabled: Boolean
get() = settingsPreference.isSentryEnabled()
set(value) {
settingsPreference.enableSentry(value)
}

var isAntiSurveillanceEnabled: Boolean
get() = settingsPreference.getIsAntiSurveillanceEnabled()
set(value) {
Expand Down
20 changes: 0 additions & 20 deletions core/src/main/java/net/ivpn/core/v2/viewmodel/LoggingViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,14 @@ class LoggingViewModel @Inject constructor(
) : ViewModel() {

val isLoggingEnabled = ObservableBoolean()
val isCrashLoggingEnabled = ObservableBoolean()
val isSentrySupported = ObservableBoolean()

var enableLoggingListener = CompoundButton.OnCheckedChangeListener { _: CompoundButton?, value: Boolean -> enableLogging(value) }
var enableCrashLoggingListener = CompoundButton.OnCheckedChangeListener { _: CompoundButton?, value: Boolean -> enableCrashLogging(value) }

init {
}

fun onResume() {
isLoggingEnabled.set(getLoggingValue())
isCrashLoggingEnabled.set(isSentryEnabled())
isSentrySupported.set(getSentrySupport())
}

fun getLogFileUri(context: Context?): Uri {
Expand All @@ -60,29 +55,14 @@ class LoggingViewModel @Inject constructor(

fun reset() {
isLoggingEnabled.set(getLoggingValue())
isCrashLoggingEnabled.set(isSentryEnabled())
isSentrySupported.set(getSentrySupport())
}

private fun getLoggingValue(): Boolean {
return logUtil.isLoggingEnabled
}

private fun isSentryEnabled(): Boolean {
return IVPNApplication.crashLoggingController.isEnabled
}

private fun getSentrySupport(): Boolean {
return IVPNApplication.crashLoggingController.isSupported
}

private fun enableLogging(value: Boolean) {
isLoggingEnabled.set(value)
logUtil.enableLogging(value)
}

private fun enableCrashLogging(value: Boolean) {
isCrashLoggingEnabled.set(value)
IVPNApplication.crashLoggingController.setState(value)
}
}
53 changes: 0 additions & 53 deletions core/src/main/res/layout/settings_section_logging.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,59 +27,6 @@
android:layout_height="wrap_content"
android:text="@string/settings_logging" />

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="@{logging.isSentrySupported ? View.VISIBLE : View.GONE}">

<TextView
android:id="@+id/textView9"
style="@style/SettingsOptionTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:text="@string/settings_enable_crashes"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
style="@style/SettingsOptionDescription"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="12dp"
android:text="@string/settings_crash_logging_description"
android:textAlignment="viewStart"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/enable_crashes"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView9" />

<androidx.appcompat.widget.SwitchCompat
android:id="@+id/enable_crashes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:checked="@{logging.isCrashLoggingEnabled()}"
android:thumb="@drawable/common_thumb_selector"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:onChanged="@{logging.enableCrashLoggingListener}"
app:track="@drawable/common_track_selector" />
</androidx.constraintlayout.widget.ConstraintLayout>


<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/color_section_divider"
android:visibility="@{logging.isSentrySupported ? View.VISIBLE : View.GONE}" />

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand Down
11 changes: 0 additions & 11 deletions site/src/main/java/net/ivpn/client/SiteIVPNApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import androidx.multidex.MultiDexApplication
import net.ivpn.client.dagger.DaggerSiteComponent
import net.ivpn.client.dagger.SiteComponent
import net.ivpn.client.navigation.SiteNavigation
import net.ivpn.client.sentry.SentryController
import net.ivpn.client.signup.SiteSignUpViewModel
import net.ivpn.client.updates.UpdatesViewModel
import net.ivpn.core.IVPNApplication
Expand All @@ -44,9 +43,6 @@ class SiteIVPNApplication: MultiDexApplication() {
@Inject
lateinit var viewModel: SiteSignUpViewModel

@Inject
lateinit var sentry: SentryController

@Inject
lateinit var updates: UpdatesViewModel

Expand All @@ -56,8 +52,6 @@ class SiteIVPNApplication: MultiDexApplication() {
val appComponent = IVPNApplication.initBy(this)
initFeatureConfig()
initComponents(appComponent)
//Init crash controller at first
initCrashLogging()
initUpdatesController()
IVPNApplication.initBaseComponents()
initSignUpController()
Expand All @@ -80,9 +74,4 @@ class SiteIVPNApplication: MultiDexApplication() {
private fun initFeatureConfig() {
IVPNApplication.applyFeatureConfig(SiteFeatureConfig())
}

private fun initCrashLogging() {
sentry.init()
IVPNApplication.crashLoggingController = sentry
}
}
76 changes: 0 additions & 76 deletions site/src/main/java/net/ivpn/client/sentry/SentryController.kt

This file was deleted.

11 changes: 0 additions & 11 deletions store/src/main/java/net/ivpn/client/StoreIVPNApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import net.ivpn.client.config.StoreFeatureConfig
import net.ivpn.client.dagger.BillingComponent
import net.ivpn.client.dagger.DaggerBillingComponent
import net.ivpn.client.navigation.StoreNavigation
import net.ivpn.client.sentry.SentryController
import net.ivpn.client.signup.SignUpViewModel
import net.ivpn.client.updates.UpdatesStubViewModel
import net.ivpn.core.IVPNApplication
Expand All @@ -45,9 +44,6 @@ class StoreIVPNApplication: MultiDexApplication() {
@Inject
lateinit var viewModel: SignUpViewModel

@Inject
lateinit var sentry: SentryController

var updates = UpdatesStubViewModel()

override fun onCreate() {
Expand All @@ -57,8 +53,6 @@ class StoreIVPNApplication: MultiDexApplication() {
initFeatureConfig()
initComponents(appComponent)
initUpdatesController()
//Init crash controller at first
initCrashLogging()
IVPNApplication.initBaseComponents()
initSignUpController()
IVPNApplication.customNavigation = StoreNavigation
Expand All @@ -80,9 +74,4 @@ class StoreIVPNApplication: MultiDexApplication() {
private fun initFeatureConfig() {
IVPNApplication.applyFeatureConfig(StoreFeatureConfig())
}

private fun initCrashLogging() {
sentry.init()
IVPNApplication.crashLoggingController = sentry
}
}
76 changes: 0 additions & 76 deletions store/src/main/java/net/ivpn/client/sentry/SentryController.kt

This file was deleted.

0 comments on commit 180443f

Please sign in to comment.