mirror of
https://github.com/etesync/android
synced 2025-01-22 21:51:04 +00:00
Log to file: move to use normal preferences.
This commit is contained in:
parent
df315a48ab
commit
1cdad6232e
@ -40,9 +40,12 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
val log = java.util.logging.Logger.getLogger("etesync")!!
|
||||
|
||||
private lateinit var context: Context
|
||||
private lateinit var preferences: SharedPreferences
|
||||
|
||||
fun initialize(someContext: Context) {
|
||||
context = someContext.applicationContext
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
preferences.registerOnSharedPreferenceChangeListener(this)
|
||||
|
||||
reinitialize()
|
||||
}
|
||||
@ -55,10 +58,7 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
}
|
||||
|
||||
private fun reinitialize() {
|
||||
val dbHelper = ServiceDB.OpenHelper(context)
|
||||
val settings = Settings(dbHelper.readableDatabase)
|
||||
|
||||
val logToFile = settings.getBoolean(App.LOG_TO_EXTERNAL_STORAGE, false)
|
||||
val logToFile = preferences.getBoolean(LOG_TO_FILE, false)
|
||||
val logVerbose = logToFile || Log.isLoggable(Logger.log.name, Log.DEBUG)
|
||||
|
||||
log.info("Verbose logging: $logVerbose; to file: $logToFile")
|
||||
|
@ -44,7 +44,6 @@ class AppSettingsActivity : BaseActivity() {
|
||||
internal lateinit var prefResetCertificates: Preference
|
||||
internal lateinit var prefOverrideProxy: SwitchPreferenceCompat
|
||||
internal lateinit var prefDistrustSystemCerts: SwitchPreferenceCompat
|
||||
internal lateinit var prefLogToExternalStorage: SwitchPreferenceCompat
|
||||
|
||||
internal lateinit var prefProxyHost: EditTextPreference
|
||||
internal lateinit var prefProxyPort: EditTextPreference
|
||||
@ -114,9 +113,6 @@ class AppSettingsActivity : BaseActivity() {
|
||||
|
||||
prefResetCertificates = findPreference("reset_certificates")
|
||||
|
||||
prefLogToExternalStorage = findPreference("log_to_external_storage") as SwitchPreferenceCompat
|
||||
prefLogToExternalStorage.isChecked = settings.getBoolean(App.LOG_TO_EXTERNAL_STORAGE, false)
|
||||
|
||||
val prefChangeNotification = findPreference("show_change_notification") as SwitchPreferenceCompat
|
||||
prefChangeNotification.isChecked = context!!.defaultSharedPreferences.getBoolean(App.CHANGE_NOTIFICATION, true)
|
||||
|
||||
@ -135,8 +131,6 @@ class AppSettingsActivity : BaseActivity() {
|
||||
setDistrustSystemCerts(preference.isChecked)
|
||||
else if (preference === prefResetCertificates)
|
||||
resetCertificates()
|
||||
else if (preference === prefLogToExternalStorage)
|
||||
setExternalLogging(preference.isChecked)
|
||||
else
|
||||
return false
|
||||
return true
|
||||
@ -163,17 +157,6 @@ class AppSettingsActivity : BaseActivity() {
|
||||
Snackbar.make(view!!, getString(R.string.app_settings_reset_certificates_success), Snackbar.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
private fun setExternalLogging(externalLogging: Boolean) {
|
||||
settings.putBoolean(App.LOG_TO_EXTERNAL_STORAGE, externalLogging)
|
||||
|
||||
// reinitialize logger of default process
|
||||
val app = context!!.applicationContext as App
|
||||
app.reinitLogger()
|
||||
|
||||
// reinitialize logger of :sync process
|
||||
context!!.sendBroadcast(Intent(App.ReinitSettingsReceiver.ACTION_REINIT_SETTINGS))
|
||||
}
|
||||
|
||||
private inner class LanguageTask internal constructor(private val mListPreference: ListPreference) : AsyncTask<Void, Void, LanguageUtils.LocaleList>() {
|
||||
|
||||
override fun doInBackground(vararg voids: Void): LanguageUtils.LocaleList {
|
||||
|
@ -62,7 +62,7 @@
|
||||
<PreferenceCategory android:title="@string/app_settings_debug">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="log_to_external_storage"
|
||||
android:key="log_to_file"
|
||||
android:title="@string/app_settings_log_to_external_storage"
|
||||
android:summaryOn="@string/app_settings_log_to_external_storage_on"
|
||||
android:summaryOff="@string/app_settings_log_to_external_storage_off"/>
|
||||
|
Loading…
Reference in New Issue
Block a user