mirror of
https://github.com/kalarina-bit/Sparkledns.git
synced 2026-11-22 15:46:09 +00:00
Add app source for F-Droid release (v1.0.6)
Adds the full Android source tree, Gradle wrapper, fastlane store metadata and the fdroiddata build recipe so F-Droid can build from source. README gains build instructions and an updated structure tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015g6ECVSKcBG8CJPrqC3G5o
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package cc.skysparkle.sparkledns
|
||||
|
||||
import android.content.Context
|
||||
|
||||
class Prefs(context: Context) {
|
||||
private val sp = context.applicationContext.getSharedPreferences("doh", Context.MODE_PRIVATE)
|
||||
|
||||
var providerId: String
|
||||
get() = sp.getString(KEY_PROVIDER, null) ?: Providers.default.id
|
||||
set(value) = sp.edit().putString(KEY_PROVIDER, value).apply()
|
||||
|
||||
var customUrl: String
|
||||
get() = sp.getString(KEY_URL, null) ?: "https://"
|
||||
set(value) = sp.edit().putString(KEY_URL, value).apply()
|
||||
|
||||
var customBootstrap: String
|
||||
get() = sp.getString(KEY_BOOTSTRAP, null) ?: ""
|
||||
set(value) = sp.edit().putString(KEY_BOOTSTRAP, value).apply()
|
||||
|
||||
var customHttp3: Boolean
|
||||
get() = sp.getBoolean(KEY_HTTP3, false)
|
||||
set(value) = sp.edit().putBoolean(KEY_HTTP3, value).apply()
|
||||
|
||||
var excludedApps: Set<String>
|
||||
get() = sp.getStringSet(KEY_EXCLUDED, null)?.toSet() ?: emptySet()
|
||||
set(value) = sp.edit().putStringSet(KEY_EXCLUDED, value).apply()
|
||||
|
||||
fun resolve(): DohProvider =
|
||||
if (providerId == Providers.CUSTOM_ID) {
|
||||
DohProvider(Providers.CUSTOM_ID, "Custom", customUrl.trim(), parseIps(customBootstrap), customHttp3)
|
||||
} else {
|
||||
Providers.byId(providerId)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val KEY_PROVIDER = "provider"
|
||||
const val KEY_URL = "custom_url"
|
||||
const val KEY_BOOTSTRAP = "custom_bootstrap"
|
||||
const val KEY_HTTP3 = "custom_http3"
|
||||
const val KEY_EXCLUDED = "excluded_apps"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user