|
|
|
@ -1,7 +1,6 @@
|
|
|
|
package org.koitharu.kotatsu.settings
|
|
|
|
package org.koitharu.kotatsu.settings
|
|
|
|
|
|
|
|
|
|
|
|
import android.accounts.AccountManager
|
|
|
|
import android.accounts.AccountManager
|
|
|
|
import android.content.ActivityNotFoundException
|
|
|
|
|
|
|
|
import android.content.Intent
|
|
|
|
import android.content.Intent
|
|
|
|
import android.content.SharedPreferences
|
|
|
|
import android.content.SharedPreferences
|
|
|
|
import android.net.Uri
|
|
|
|
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.prefs.AppSettings
|
|
|
|
import org.koitharu.kotatsu.core.ui.BasePreferenceFragment
|
|
|
|
import org.koitharu.kotatsu.core.ui.BasePreferenceFragment
|
|
|
|
import org.koitharu.kotatsu.core.util.ext.getDisplayMessage
|
|
|
|
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.core.util.ext.viewLifecycleScope
|
|
|
|
import org.koitharu.kotatsu.scrobbling.anilist.data.AniListRepository
|
|
|
|
import org.koitharu.kotatsu.scrobbling.anilist.data.AniListRepository
|
|
|
|
import org.koitharu.kotatsu.scrobbling.common.data.ScrobblerRepository
|
|
|
|
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.scrobbling.shikimori.data.ShikimoriRepository
|
|
|
|
import org.koitharu.kotatsu.sync.domain.SyncController
|
|
|
|
import org.koitharu.kotatsu.sync.domain.SyncController
|
|
|
|
import org.koitharu.kotatsu.sync.ui.SyncSettingsIntent
|
|
|
|
import org.koitharu.kotatsu.sync.ui.SyncSettingsIntent
|
|
|
|
import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug
|
|
|
|
|
|
|
|
import javax.inject.Inject
|
|
|
|
import javax.inject.Inject
|
|
|
|
|
|
|
|
|
|
|
|
@AndroidEntryPoint
|
|
|
|
@AndroidEntryPoint
|
|
|
|
@ -51,11 +50,12 @@ class ServicesSettingsFragment : BasePreferenceFragment(R.string.services),
|
|
|
|
|
|
|
|
|
|
|
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
|
|
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
|
|
|
addPreferencesFromResource(R.xml.pref_services)
|
|
|
|
addPreferencesFromResource(R.xml.pref_services)
|
|
|
|
bindSuggestionsSummary()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
|
|
|
|
bindSuggestionsSummary()
|
|
|
|
|
|
|
|
bindStatsSummary()
|
|
|
|
settings.subscribe(this)
|
|
|
|
settings.subscribe(this)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -76,6 +76,7 @@ class ServicesSettingsFragment : BasePreferenceFragment(R.string.services),
|
|
|
|
override fun onSharedPreferenceChanged(prefs: SharedPreferences?, key: String?) {
|
|
|
|
override fun onSharedPreferenceChanged(prefs: SharedPreferences?, key: String?) {
|
|
|
|
when (key) {
|
|
|
|
when (key) {
|
|
|
|
AppSettings.KEY_SUGGESTIONS -> bindSuggestionsSummary()
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|