mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 09:06:47 -06:00
Add language event (#1052)
* Add log event to language * Add log event to app
This commit is contained in:
parent
c052f31424
commit
295fd0fd90
@ -11,8 +11,10 @@ import androidx.work.Configuration
|
|||||||
import com.yariksoffice.lingver.Lingver
|
import com.yariksoffice.lingver.Lingver
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
import fr.bipi.tressence.file.FileLoggerTree
|
import fr.bipi.tressence.file.FileLoggerTree
|
||||||
|
import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository
|
||||||
import io.github.wulkanowy.ui.base.ThemeManager
|
import io.github.wulkanowy.ui.base.ThemeManager
|
||||||
import io.github.wulkanowy.utils.ActivityLifecycleLogger
|
import io.github.wulkanowy.utils.ActivityLifecycleLogger
|
||||||
|
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import io.github.wulkanowy.utils.CrashLogExceptionTree
|
import io.github.wulkanowy.utils.CrashLogExceptionTree
|
||||||
import io.github.wulkanowy.utils.CrashLogTree
|
import io.github.wulkanowy.utils.CrashLogTree
|
||||||
@ -32,6 +34,12 @@ class WulkanowyApp : Application(), Configuration.Provider {
|
|||||||
@Inject
|
@Inject
|
||||||
lateinit var appInfo: AppInfo
|
lateinit var appInfo: AppInfo
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var preferencesRepository: PreferencesRepository
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var analyticsHelper: AnalyticsHelper
|
||||||
|
|
||||||
override fun attachBaseContext(base: Context?) {
|
override fun attachBaseContext(base: Context?) {
|
||||||
super.attachBaseContext(base)
|
super.attachBaseContext(base)
|
||||||
MultiDex.install(this)
|
MultiDex.install(this)
|
||||||
@ -43,6 +51,7 @@ class WulkanowyApp : Application(), Configuration.Provider {
|
|||||||
themeManager.applyDefaultTheme()
|
themeManager.applyDefaultTheme()
|
||||||
|
|
||||||
initLogging()
|
initLogging()
|
||||||
|
logCurrentLanguage()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initLogging() {
|
private fun initLogging() {
|
||||||
@ -62,6 +71,16 @@ class WulkanowyApp : Application(), Configuration.Provider {
|
|||||||
registerActivityLifecycleCallbacks(ActivityLifecycleLogger())
|
registerActivityLifecycleCallbacks(ActivityLifecycleLogger())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun logCurrentLanguage() {
|
||||||
|
val newLang = if (preferencesRepository.appLanguage == "system") {
|
||||||
|
appInfo.systemLanguage
|
||||||
|
} else {
|
||||||
|
preferencesRepository.appLanguage
|
||||||
|
}
|
||||||
|
|
||||||
|
analyticsHelper.logEvent("language", "startup" to newLang)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getWorkManagerConfiguration() = Configuration.Builder()
|
override fun getWorkManagerConfiguration() = Configuration.Builder()
|
||||||
.setWorkerFactory(workerFactory)
|
.setWorkerFactory(workerFactory)
|
||||||
.setMinimumLoggingLevel(if (appInfo.isDebug) VERBOSE else INFO)
|
.setMinimumLoggingLevel(if (appInfo.isDebug) VERBOSE else INFO)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package io.github.wulkanowy.ui.modules.settings
|
package io.github.wulkanowy.ui.modules.settings
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
@ -42,10 +41,6 @@ class SettingsFragment : PreferenceFragmentCompat(),
|
|||||||
|
|
||||||
override val syncFailedString get() = getString(R.string.pref_services_message_sync_failed)
|
override val syncFailedString get() = getString(R.string.pref_services_message_sync_failed)
|
||||||
|
|
||||||
override fun onAttach(context: Context) {
|
|
||||||
super.onAttach(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
findPreference<Preference>(getString(R.string.pref_key_services_force_sync))?.run {
|
findPreference<Preference>(getString(R.string.pref_key_services_force_sync))?.run {
|
||||||
onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||||
|
@ -8,8 +8,8 @@ import io.github.wulkanowy.services.alarm.TimetableNotificationSchedulerHelper
|
|||||||
import io.github.wulkanowy.services.sync.SyncManager
|
import io.github.wulkanowy.services.sync.SyncManager
|
||||||
import io.github.wulkanowy.ui.base.BasePresenter
|
import io.github.wulkanowy.ui.base.BasePresenter
|
||||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||||
import io.github.wulkanowy.utils.AppInfo
|
|
||||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||||
|
import io.github.wulkanowy.utils.AppInfo
|
||||||
import io.github.wulkanowy.utils.isHolidays
|
import io.github.wulkanowy.utils.isHolidays
|
||||||
import kotlinx.coroutines.flow.catch
|
import kotlinx.coroutines.flow.catch
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
@ -46,7 +46,10 @@ class SettingsPresenter @Inject constructor(
|
|||||||
appThemeKey -> view?.recreateView()
|
appThemeKey -> view?.recreateView()
|
||||||
isUpcomingLessonsNotificationsEnableKey -> if (!isUpcomingLessonsNotificationsEnable) timetableNotificationHelper.cancelNotification()
|
isUpcomingLessonsNotificationsEnableKey -> if (!isUpcomingLessonsNotificationsEnable) timetableNotificationHelper.cancelNotification()
|
||||||
appLanguageKey -> view?.run {
|
appLanguageKey -> view?.run {
|
||||||
updateLanguage(if (appLanguage == "system") appInfo.systemLanguage else appLanguage)
|
val newLang = if (appLanguage == "system") appInfo.systemLanguage else appLanguage
|
||||||
|
analytics.logEvent("language", "setting_changed" to newLang)
|
||||||
|
|
||||||
|
updateLanguage(newLang)
|
||||||
recreateView()
|
recreateView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user