diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt
index cb98768781..edb7f97415 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt
@@ -153,13 +153,7 @@ object PreferenceKeys {
const val alwaysShowChapterTransition = "always_show_chapter_transition"
- @Deprecated("Use the preferences of the source")
- fun sourceUsername(sourceId: Long) = "pref_source_username_$sourceId"
-
- @Deprecated("Use the preferences of the source")
- fun sourcePassword(sourceId: Long) = "pref_source_password_$sourceId"
-
- fun sourceSharedPref(sourceId: Long) = "source_$sourceId"
+ const val enableDoh = "enable_doh"
fun trackUsername(syncId: Int) = "pref_mangasync_username_$syncId"
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
index 869edbfc57..f4a333160e 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
@@ -10,7 +10,6 @@ import com.f2prateek.rx.preferences.RxSharedPreferences
import com.tfcporciuncula.flow.FlowSharedPreferences
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.track.TrackService
-import eu.kanade.tachiyomi.source.Source
import java.io.File
import java.text.DateFormat
import java.text.SimpleDateFormat
@@ -125,17 +124,6 @@ class PreferencesHelper(val context: Context) {
fun sourceSorting() = rxPrefs.getInteger(Keys.sourcesSort, 0)
- fun sourceUsername(source: Source) = prefs.getString(Keys.sourceUsername(source.id), "")
-
- fun sourcePassword(source: Source) = prefs.getString(Keys.sourcePassword(source.id), "")
-
- fun setSourceCredentials(source: Source, username: String, password: String) {
- prefs.edit()
- .putString(Keys.sourceUsername(source.id), username)
- .putString(Keys.sourcePassword(source.id), password)
- .apply()
- }
-
fun trackUsername(sync: TrackService) = prefs.getString(Keys.trackUsername(sync.id), "")
fun trackPassword(sync: TrackService) = prefs.getString(Keys.trackPassword(sync.id), "")
@@ -292,4 +280,6 @@ class PreferencesHelper(val context: Context) {
fun shownLongPressCategoryTutorial() = flowPrefs.getBoolean("shown_long_press_category", false)
fun shownHopperSwipeTutorial() = flowPrefs.getBoolean("shown_hopper_swipe", false)
+
+ fun enableDoh() = prefs.getBoolean(Keys.enableDoh, false)
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt
index b0a0a27c50..c898835a1c 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt
@@ -2,23 +2,52 @@ package eu.kanade.tachiyomi.network
import android.content.Context
import com.chuckerteam.chucker.api.ChuckerInterceptor
+import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import okhttp3.Cache
+import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
+import okhttp3.dnsoverhttps.DnsOverHttps
+import uy.kohesive.injekt.injectLazy
import java.io.File
+import java.net.InetAddress
class NetworkHelper(context: Context) {
+ private val preferences: PreferencesHelper by injectLazy()
+
private val cacheDir = File(context.cacheDir, "network_cache")
private val cacheSize = 5L * 1024 * 1024 // 5 MiB
val cookieManager = AndroidCookieJar()
- val client = OkHttpClient.Builder()
- .cookieJar(cookieManager)
- .cache(Cache(cacheDir, cacheSize))
- .addInterceptor(ChuckerInterceptor(context))
- .build()
+ val client by lazy {
+ OkHttpClient.Builder()
+ .cookieJar(cookieManager)
+ .cache(Cache(cacheDir, cacheSize))
+ .addInterceptor(ChuckerInterceptor(context))
+ .apply {
+ if (preferences.enableDoh()) {
+ dns(
+ DnsOverHttps.Builder().client(build())
+ .url("https://cloudflare-dns.com/dns-query".toHttpUrl())
+ .bootstrapDnsHosts(
+ listOf(
+ InetAddress.getByName("162.159.36.1"),
+ InetAddress.getByName("162.159.46.1"),
+ InetAddress.getByName("1.1.1.1"),
+ InetAddress.getByName("1.0.0.1"),
+ InetAddress.getByName("162.159.132.53"),
+ InetAddress.getByName("2606:4700:4700::1111"),
+ InetAddress.getByName("2606:4700:4700::1001"),
+ InetAddress.getByName("2606:4700:4700::0064"),
+ InetAddress.getByName("2606:4700:4700::6400")
+ )
+ ).build()
+ )
+ }
+ }.build()
+ }
val cloudflareClient = client.newBuilder()
.addInterceptor(UserAgentInterceptor())
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt
index e33389d510..bc7d37f6bb 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt
@@ -21,6 +21,7 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.data.download.DownloadProvider
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Target
+import eu.kanade.tachiyomi.data.preference.PreferenceKeys
import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.ui.base.controller.DialogController
@@ -71,8 +72,7 @@ class SettingsAdvancedController : SettingsController() {
preference {
titleRes = R.string.clean_up_cached_covers
summary = context.getString(
- R.string.delete_old_covers_in_library_used_,
- coverCache.getChapterCacheSize()
+ R.string.delete_old_covers_in_library_used_, coverCache.getChapterCacheSize()
)
onClick {
@@ -81,7 +81,7 @@ class SettingsAdvancedController : SettingsController() {
}
}
preference {
- titleRes = R.string.clean_up_cached_covers_non_library
+ titleRes = R.string.clear_cached_covers_non_library
summary = context.getString(
R.string.delete_all_covers__not_in_library_used_,
coverCache.getOnlineCoverCacheSize()
@@ -114,6 +114,26 @@ class SettingsAdvancedController : SettingsController() {
}
}
}
+
+ preferenceCategory {
+ titleRes = R.string.network
+ preference {
+ titleRes = R.string.clear_cookies
+
+ onClick {
+ network.cookieManager.removeAll()
+ activity?.toast(R.string.cookies_cleared)
+ }
+ }
+
+ switchPreference {
+ key = PreferenceKeys.enableDoh
+ titleRes = R.string.dns_over_https
+ summaryRes = R.string.requires_app_restart
+ defaultValue = false
+ }
+ }
+
preferenceCategory {
titleRes = R.string.library
preference {
@@ -131,15 +151,6 @@ class SettingsAdvancedController : SettingsController() {
}
preferenceCategory {
- preference {
- titleRes = R.string.clear_cookies
-
- onClick {
- network.cookieManager.removeAll()
- activity?.toast(R.string.cookies_cleared)
- }
- }
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val pm = context.getSystemService(Context.POWER_SERVICE) as? PowerManager?
if (pm != null) preference {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 82a5dccba9..8e4ea7b555 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -528,6 +528,9 @@
Clear chapter cache
Data Management
+ Network
+ DNS over HTTPS (Cloudflare)
+ Requires app restart to take effect
Used: %1$s
- Cache cleared. %d file has been deleted
@@ -563,8 +566,7 @@
Clean up cached covers
Delete old and unused cached covers of
manga in your library that has been updated.\nCurrently using: %1$s
- Clean up cached covers not in
- library
+ Clear cached covers not in library
Delete all covers cached that are
not in your library \nCurrently using: %1$s
diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt
index b974130e24..95e26b4de3 100644
--- a/buildSrc/src/main/kotlin/Dependencies.kt
+++ b/buildSrc/src/main/kotlin/Dependencies.kt
@@ -6,7 +6,7 @@ object Versions {
const val FASTADAPTER = "5.0.0"
const val HYPERION = "0.9.27"
const val NUCLEUS = "3.0.0"
- const val OKHTTP = "4.5.0"
+ const val OKHTTP = "4.8.1"
const val OSS_LICENSE = "17.0.0"
const val RETROFIT = "2.7.2"
const val ROBO_ELECTRIC = "3.1.4"