Stats settings
This commit is contained in:
@@ -609,6 +609,7 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
|
||||
const val KEY_READING_TIME = "reading_time"
|
||||
const val KEY_PAGES_SAVE_DIR = "pages_dir"
|
||||
const val KEY_PAGES_SAVE_ASK = "pages_dir_ask"
|
||||
const val KEY_STATS = "stats"
|
||||
const val KEY_STATS_ENABLED = "stats_on"
|
||||
const val KEY_APP_UPDATE = "app_update"
|
||||
const val KEY_APP_TRANSLATION = "about_app_translation"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.koitharu.kotatsu.settings
|
||||
|
||||
import android.accounts.AccountManager
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
@@ -17,6 +16,7 @@ import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.core.ui.BasePreferenceFragment
|
||||
import org.koitharu.kotatsu.core.util.ext.getDisplayMessage
|
||||
import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug
|
||||
import org.koitharu.kotatsu.core.util.ext.viewLifecycleScope
|
||||
import org.koitharu.kotatsu.scrobbling.anilist.data.AniListRepository
|
||||
import org.koitharu.kotatsu.scrobbling.common.data.ScrobblerRepository
|
||||
@@ -27,7 +27,6 @@ import org.koitharu.kotatsu.scrobbling.mal.data.MALRepository
|
||||
import org.koitharu.kotatsu.scrobbling.shikimori.data.ShikimoriRepository
|
||||
import org.koitharu.kotatsu.sync.domain.SyncController
|
||||
import org.koitharu.kotatsu.sync.ui.SyncSettingsIntent
|
||||
import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
@@ -51,11 +50,12 @@ class ServicesSettingsFragment : BasePreferenceFragment(R.string.services),
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(R.xml.pref_services)
|
||||
bindSuggestionsSummary()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
bindSuggestionsSummary()
|
||||
bindStatsSummary()
|
||||
settings.subscribe(this)
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ class ServicesSettingsFragment : BasePreferenceFragment(R.string.services),
|
||||
override fun onSharedPreferenceChanged(prefs: SharedPreferences?, key: String?) {
|
||||
when (key) {
|
||||
AppSettings.KEY_SUGGESTIONS -> bindSuggestionsSummary()
|
||||
AppSettings.KEY_STATS_ENABLED -> bindStatsSummary()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,4 +195,10 @@ class ServicesSettingsFragment : BasePreferenceFragment(R.string.services),
|
||||
if (settings.isSuggestionsEnabled) R.string.enabled else R.string.disabled,
|
||||
)
|
||||
}
|
||||
|
||||
private fun bindStatsSummary() {
|
||||
findPreference<Preference>(AppSettings.KEY_STATS)?.setSummary(
|
||||
if (settings.isStatsEnabled) R.string.enabled else R.string.disabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.koitharu.kotatsu.settings
|
||||
|
||||
import android.os.Bundle
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.ui.BasePreferenceFragment
|
||||
|
||||
@AndroidEntryPoint
|
||||
class StatsSettingsFragment : BasePreferenceFragment(R.string.reading_stats) {
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(R.xml.pref_stats)
|
||||
}
|
||||
}
|
||||
@@ -598,4 +598,6 @@
|
||||
<string name="ask_for_dest_dir_every_time">Ask for the destination dir every time</string>
|
||||
<string name="default_page_save_dir">Default page save directory</string>
|
||||
<string name="remove_from_history">Remove from history</string>
|
||||
<string name="stats_enabled">Enable statistics</string>
|
||||
<string name="reading_stats">Reading statistics</string>
|
||||
</resources>
|
||||
|
||||
@@ -28,6 +28,12 @@
|
||||
android:summary="@string/related_manga_summary"
|
||||
android:title="@string/related_manga" />
|
||||
|
||||
<Preference
|
||||
android:fragment="org.koitharu.kotatsu.settings.StatsSettingsFragment"
|
||||
android:key="stats"
|
||||
android:title="@string/reading_stats"
|
||||
app:allowDividerAbove="true" />
|
||||
|
||||
<PreferenceCategory android:title="@string/tracking">
|
||||
|
||||
<Preference
|
||||
|
||||
11
app/src/main/res/xml/pref_stats.xml
Normal file
11
app/src/main/res/xml/pref_stats.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="stats_on"
|
||||
android:layout="@layout/preference_toggle_header"
|
||||
android:title="@string/stats_enabled" />
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
Reference in New Issue
Block a user