Info about background restrictions

This commit is contained in:
Koitharu
2021-07-07 07:13:02 +03:00
parent 3804896788
commit d8db89326f
8 changed files with 52 additions and 2 deletions

View File

@@ -166,6 +166,7 @@ class AppSettings private constructor(private val prefs: SharedPreferences) :
const val KEY_LOCAL_STORAGE = "local_storage"
const val KEY_READER_SWITCHERS = "reader_switchers"
const val KEY_TRACK_SOURCES = "track_sources"
const val KEY_TRACK_WARNING = "track_warning"
const val KEY_APP_UPDATE = "app_update"
const val KEY_APP_UPDATE_AUTO = "app_update_auto"
const val KEY_TRACKER_NOTIFICATIONS = "tracker_notifications"

View File

@@ -4,6 +4,9 @@ import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.text.style.URLSpan
import androidx.core.text.buildSpannedString
import androidx.core.text.inSpans
import androidx.preference.MultiSelectListPreference
import androidx.preference.Preference
import org.koitharu.kotatsu.R
@@ -19,6 +22,17 @@ class TrackerSettingsFragment : BasePreferenceFragment(R.string.new_chapters_che
findPreference<MultiSelectListPreference>(AppSettings.KEY_TRACK_SOURCES)
?.summaryProvider = MultiSummaryProvider(R.string.dont_check)
val warningPreference = findPreference<Preference>(AppSettings.KEY_TRACK_WARNING)
if (warningPreference != null) {
warningPreference.summary = buildSpannedString {
append(getString(R.string.tracker_warning))
append(" ")
inSpans(URLSpan("https://dontkillmyapp.com/")) {
append(getString(R.string.read_more))
}
}
warningPreference
}
}
override fun onPreferenceTreeClick(preference: Preference?): Boolean {

View File

@@ -0,0 +1,23 @@
package org.koitharu.kotatsu.settings.utils
import android.content.Context
import android.text.method.LinkMovementMethod
import android.util.AttributeSet
import android.widget.TextView
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
class LinksPreference @JvmOverloads constructor(
context: Context?,
attrs: AttributeSet? = null,
defStyleAttr: Int = androidx.preference.R.attr.preferenceStyle,
defStyleRes: Int = 0,
) : Preference(context, attrs, defStyleAttr, defStyleRes) {
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
val summaryView = holder.findViewById(android.R.id.summary) as TextView
summaryView.movementMethod = LinkMovementMethod.getInstance()
}
}

View File

@@ -212,4 +212,6 @@
<string name="welcome">Добро пожаловать</string>
<string name="text_clear_search_history_prompt">Вы действительно хотите удалить все недавние поисковые запросы? Это действие не может быть отменено.</string>
<string name="backup_saved">Резервная копия успешно сохранена</string>
<string name="tracker_warning">Некоторые производители могут изменять поведение системы, нарушая работу фоновых задач.</string>
<string name="read_more">Подробнее</string>
</resources>

View File

@@ -213,5 +213,7 @@
<string name="other">Other</string>
<string name="languages">Languages</string>
<string name="welcome">Welcome</string>
<string name="backup_saved">Backup saved succesfully</string>
<string name="backup_saved">Backup saved successfully</string>
<string name="tracker_warning">Some manufacturers can change the system behavior, which may breaks background tasks.</string>
<string name="read_more">Read more</string>
</resources>

View File

@@ -16,7 +16,7 @@
app:iconSpaceReserved="false" />
<Preference
android:icon="@drawable/ic_info_outilne"
android:icon="@drawable/ic_info_outline"
android:persistent="false"
android:selectable="false"
android:summary="@string/backup_information"

View File

@@ -24,4 +24,12 @@
android:title="@string/notifications_settings"
app:iconSpaceReserved="false" />
<org.koitharu.kotatsu.settings.utils.LinksPreference
android:key="track_warning"
android:icon="@drawable/ic_info_outline"
android:persistent="false"
android:selectable="false"
android:summary="@string/tracker_warning"
app:allowDividerAbove="true" />
</PreferenceScreen>