Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId = "com.haodustudio.DailyNotes"
minSdk = 24
targetSdk = 33
versionCode = 5
versionName = "1.0.4"
versionCode = 6
versionName = "1.0.5"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down Expand Up @@ -68,6 +68,7 @@ dependencies {
implementation("com.squareup.retrofit2:converter-gson:2.6.2")
implementation("de.hdodenhof:circleimageview:3.1.0")
implementation("com.google.android.material:material:1.11.0")
implementation("io.sentry:sentry-android:7.13.0")
}

sentry {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<activity
android:name=".view.activities.AboutSoftware"
android:exported="false" />
<activity
android:name=".view.activities.PrivacySettingsActivity"
android:exported="false" />
<activity
android:name=".view.activities.ShowFindResult"
android:exported="false" />
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/java/com/haodustudio/DailyNotes/BaseApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStore
import androidx.lifecycle.ViewModelStoreOwner
import com.haodustudio.DailyNotes.helper.PrivacySettingsManager
import com.haodustudio.DailyNotes.utils.BitmapUtils
import com.haodustudio.DailyNotes.viewModel.viewModels.GlobalViewModel
import io.sentry.Sentry
import io.sentry.android.core.SentryAndroid
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
Expand All @@ -29,6 +32,8 @@ class BaseApplication : Application(), ViewModelStoreOwner {
override val viewModelStore: ViewModelStore
get() = appViewModelStore

private var sentryInitialized = false

companion object {
lateinit var instance: BaseApplication
private set
Expand Down Expand Up @@ -135,6 +140,27 @@ class BaseApplication : Application(), ViewModelStoreOwner {
NOTES_PATH = filesDir.absolutePath + "/notes/"
TEMPLATE_DOWNLOAD_FROM_URI_PATH = filesDir.absolutePath + "/uri_template/"
BACKGROUND_DOWNLOAD_FROM_URI_PATH = filesDir.absolutePath + "/uri_background/"

updateSentryState(PrivacySettingsManager.isCrashReportingEnabled())
}

fun updateSentryState(enabled: Boolean) {
if (enabled) {
if (!sentryInitialized) {
runCatching {
SentryAndroid.init(this)
}.onSuccess {
sentryInitialized = true
}.onFailure {
sentryInitialized = false
}
}
} else {
if (sentryInitialized) {
Sentry.close()
sentryInitialized = false
}
}
}

override fun onTerminate() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.haodustudio.DailyNotes.helper

import android.content.Context
import android.content.SharedPreferences
import androidx.core.content.edit
import com.haodustudio.DailyNotes.BaseApplication

object PrivacySettingsManager {
private const val KEY_CRASH_REPORTING = "privacy_crash_reporting_enabled"
private const val KEY_LOCATION = "privacy_location_enabled"
private const val KEY_CLOUD_RESOURCES = "privacy_cloud_resources_enabled"

private val prefs: SharedPreferences by lazy {
BaseApplication.instance.getSharedPreferences(
BaseApplication.APP_SHARED_PREFERENCES_NAME,
Context.MODE_PRIVATE
)
}

fun isCrashReportingEnabled(): Boolean = prefs.getBoolean(KEY_CRASH_REPORTING, true)

fun updateCrashReportingEnabled(enabled: Boolean) {
prefs.edit { putBoolean(KEY_CRASH_REPORTING, enabled) }
BaseApplication.instance.updateSentryState(enabled)
}

fun isLocationEnabled(): Boolean = prefs.getBoolean(KEY_LOCATION, true)

fun updateLocationEnabled(enabled: Boolean) {
prefs.edit {
putBoolean(KEY_LOCATION, enabled)
if (!enabled && prefs.getBoolean("app_background_is_weather", false)) {
putBoolean("app_background_is_weather", false)
}
}
}

fun isCloudResourcesEnabled(): Boolean = prefs.getBoolean(KEY_CLOUD_RESOURCES, true)

fun updateCloudResourcesEnabled(enabled: Boolean) {
prefs.edit { putBoolean(KEY_CLOUD_RESOURCES, enabled) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import com.haodustudio.DailyNotes.BaseApplication
import com.haodustudio.DailyNotes.R
import com.haodustudio.DailyNotes.databinding.ActivityAboutSoftwareBinding
import com.haodustudio.DailyNotes.helper.makeToast
import com.haodustudio.DailyNotes.view.activities.ViewImage
import com.haodustudio.DailyNotes.view.activities.base.BaseActivity
import com.haodustudio.DailyNotes.view.activities.ViewImage
import com.haodustudio.DailyNotes.view.activities.PrivacySettingsActivity

class AboutSoftware : BaseActivity() {
private val binding by lazy { ActivityAboutSoftwareBinding.inflate(layoutInflater) }
Expand Down Expand Up @@ -90,7 +91,7 @@ class AboutSoftware : BaseActivity() {
icon.setImageResource(R.drawable.ic_about_privacy)
root.contentDescription = getString(R.string.about_section_privacy_desc)
root.setOnClickListener {
makeToast(getString(R.string.about_feature_placeholder))
startActivity(Intent(this@AboutSoftware, PrivacySettingsActivity::class.java))
}
}
}
Expand Down
Loading
Loading