Set minSdkVersion to 21

This commit is contained in:
topjohnwu 2021-04-09 20:01:32 -07:00
parent 2b9b019093
commit 1f0a35f073
33 changed files with 44 additions and 212 deletions

View File

@ -221,12 +221,8 @@ dependencies {
implementation("com.squareup.retrofit2:converter-moshi:${vRetrofit}")
implementation("com.squareup.retrofit2:converter-scalars:${vRetrofit}")
val vOkHttp = "3.12.12"
implementation("com.squareup.okhttp3:okhttp") {
version {
strictly(vOkHttp)
}
}
val vOkHttp = "4.9.1"
implementation("com.squareup.okhttp3:okhttp:${vOkHttp}")
implementation("com.squareup.okhttp3:logging-interceptor:${vOkHttp}")
implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:${vOkHttp}")
@ -234,7 +230,7 @@ dependencies {
implementation("com.squareup.moshi:moshi:${vMoshi}")
kapt("com.squareup.moshi:moshi-kotlin-codegen:${vMoshi}")
val vRoom = "2.3.0-beta03"
val vRoom = "2.3.0-rc01"
implementation("androidx.room:room-runtime:${vRoom}")
implementation("androidx.room:room-ktx:${vRoom}")
kapt("androidx.room:room-compiler:${vRoom}")
@ -248,11 +244,10 @@ dependencies {
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("androidx.browser:browser:1.3.0")
implementation("androidx.preference:preference:1.1.1")
implementation("androidx.recyclerview:recyclerview:1.1.0")
implementation("androidx.fragment:fragment-ktx:1.3.1")
implementation("androidx.recyclerview:recyclerview:1.2.0")
implementation("androidx.fragment:fragment-ktx:1.3.2")
implementation("androidx.work:work-runtime-ktx:2.5.0")
implementation("androidx.transition:transition:1.4.0")
implementation("androidx.multidex:multidex:2.0.1")
implementation("androidx.core:core-ktx:1.3.2")
implementation("com.google.android.material:material:1.3.0")
}

View File

@ -1,14 +1,13 @@
package com.topjohnwu.magisk.core
import android.annotation.SuppressLint
import android.app.Activity
import android.app.Application
import android.content.Context
import android.content.res.Configuration
import android.os.Bundle
import androidx.appcompat.app.AppCompatDelegate
import androidx.multidex.MultiDex
import androidx.work.WorkManager
import com.topjohnwu.magisk.BuildConfig
import com.topjohnwu.magisk.DynAPK
import com.topjohnwu.magisk.core.utils.AppShellInit
import com.topjohnwu.magisk.core.utils.BusyBoxInit
@ -46,10 +45,6 @@ open class App() : Application() {
}
override fun attachBaseContext(base: Context) {
// Basic setup
if (BuildConfig.DEBUG)
MultiDex.install(base)
// Some context magic
val app: Application
val impl: Context
@ -91,6 +86,7 @@ open class App() : Application() {
}
}
@SuppressLint("StaticFieldLeak")
object ForegroundTracker : Application.ActivityLifecycleCallbacks {
@Volatile

View File

@ -63,7 +63,6 @@ object Const {
const val GITHUB_RAW_URL = "https://raw.githubusercontent.com/"
const val GITHUB_API_URL = "https://api.github.com/"
const val GITHUB_PAGE_URL = "https://topjohnwu.github.io/magisk-files/"
const val GITHUB_OLD_PAGE_URL = "https://topjohnwu.github.io/magisk_files/"
const val JS_DELIVR_URL = "https://cdn.jsdelivr.net/gh/"
const val OFFICIAL_REPO = "https://magisk-modules-repo.github.io/submission/modules.json"
}

View File

@ -8,8 +8,6 @@ import android.content.res.Resources
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.core.AssetHack
import com.topjohnwu.magisk.core.Config
import com.topjohnwu.magisk.ktx.langTagToLocale
import com.topjohnwu.magisk.ktx.toLangTag
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.util.*
@ -40,7 +38,7 @@ withContext(Dispatchers.Default) {
// Then add all supported locales
addAll(Resources.getSystem().assets.locales)
}.map {
it.langTagToLocale()
Locale.forLanguageTag(it)
}.distinctBy {
res.updateLocale(it)
res.getString(compareId)
@ -59,7 +57,7 @@ withContext(Dispatchers.Default) {
locales.forEach { locale ->
names.add(locale.getDisplayName(locale))
values.add(locale.toLangTag())
values.add(locale.toLanguageTag())
}
(names.toTypedArray() to values.toTypedArray()).also { cachedLocales = it }
@ -79,7 +77,7 @@ fun refreshLocale() {
val localeConfig = Config.locale
currentLocale = when {
localeConfig.isEmpty() -> defaultLocale
else -> localeConfig.langTagToLocale()
else -> Locale.forLanguageTag(localeConfig)
}
Locale.setDefault(currentLocale)
AssetHack.resource.updateConfig()

View File

@ -21,10 +21,6 @@ class NetworkService(
private val api: GithubApiServices
) {
suspend fun fetchUpdate() = safe {
// Pre SDK 21 no longer receives any major updates
if (Build.VERSION.SDK_INT < 21)
return fetchStableUpdate()
var info = when (Config.updateChannel) {
DEFAULT_CHANNEL, STABLE_CHANNEL -> fetchStableUpdate()
BETA_CHANNEL -> fetchBetaUpdate()

View File

@ -1,7 +1,6 @@
package com.topjohnwu.magisk.di
import android.content.Context
import android.os.Build
import com.squareup.moshi.Moshi
import com.topjohnwu.magisk.BuildConfig
import com.topjohnwu.magisk.core.Config
@ -13,12 +12,11 @@ import com.topjohnwu.magisk.data.network.JSDelivrServices
import com.topjohnwu.magisk.data.network.RawServices
import com.topjohnwu.magisk.ktx.precomputedText
import com.topjohnwu.magisk.net.Networking
import com.topjohnwu.magisk.net.NoSSLv3SocketFactory
import com.topjohnwu.magisk.utils.MarkwonImagePlugin
import io.noties.markwon.Markwon
import io.noties.markwon.html.HtmlPlugin
import okhttp3.Dns
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.dnsoverhttps.DnsOverHttps
import okhttp3.logging.HttpLoggingInterceptor
@ -34,10 +32,7 @@ val networkingModule = module {
single { createRetrofit(get()) }
single { createApiService<RawServices>(get(), Const.Url.GITHUB_RAW_URL) }
single { createApiService<GithubApiServices>(get(), Const.Url.GITHUB_API_URL) }
single { createApiService<GithubPageServices>(get(),
if (Build.VERSION.SDK_INT < 21) Const.Url.GITHUB_OLD_PAGE_URL
else Const.Url.GITHUB_PAGE_URL
) }
single { createApiService<GithubPageServices>(get(), Const.Url.GITHUB_PAGE_URL) }
single { createApiService<JSDelivrServices>(get(), Const.Url.JS_DELIVR_URL) }
single { createMarkwon(get(), get()) }
}
@ -46,7 +41,7 @@ private class DnsResolver(client: OkHttpClient) : Dns {
private val doh by lazy {
DnsOverHttps.Builder().client(client)
.url(HttpUrl.get("https://cloudflare-dns.com/dns-query"))
.url("https://cloudflare-dns.com/dns-query".toHttpUrl())
.bootstrapDnsHosts(listOf(
InetAddress.getByName("162.159.36.1"),
InetAddress.getByName("162.159.46.1"),
@ -84,8 +79,6 @@ fun createOkHttpClient(context: Context): OkHttpClient {
if (!Networking.init(context)) {
Info.hasGMS = false
if (Build.VERSION.SDK_INT < 21)
builder.sslSocketFactory(NoSSLv3SocketFactory())
}
builder.dns(DnsResolver(builder.build()))

View File

@ -339,16 +339,6 @@ var TextView.precomputedText: CharSequence
set(value) {
val callback = tag as? Runnable
// Don't even bother pre 21
if (SDK_INT < 21) {
post {
text = value
isGone = false
callback?.run()
}
return
}
coroutineScope.launch(Dispatchers.IO) {
if (SDK_INT >= 29) {
// Internally PrecomputedTextCompat will use platform API on API 29+

View File

@ -1,6 +1,5 @@
package com.topjohnwu.magisk.ktx
import android.os.Build
import androidx.collection.SparseArrayCompat
import timber.log.Timber
import java.io.File
@ -47,64 +46,5 @@ fun <T> MutableList<T>.synchronized() = Collections.synchronizedList(this)
fun <T> MutableSet<T>.synchronized() = Collections.synchronizedSet(this)
fun <K, V> MutableMap<K, V>.synchronized() = Collections.synchronizedMap(this)
fun String.langTagToLocale(): Locale {
if (Build.VERSION.SDK_INT >= 21) {
return Locale.forLanguageTag(this)
} else {
val tok = split("[-_]".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
if (tok.isEmpty()) {
return Locale("")
}
val language = when (tok[0]) {
"und" -> "" // Undefined
"fil" -> "tl" // Filipino
else -> tok[0]
}
if (language.length != 2 && language.length != 3)
return Locale("")
if (tok.size == 1)
return Locale(language)
val country = tok[1]
return if (country.length != 2 && country.length != 3) Locale(language)
else Locale(language, country)
}
}
fun Locale.toLangTag(): String {
if (Build.VERSION.SDK_INT >= 21) {
return toLanguageTag()
} else {
var language = language
var country = country
var variant = variant
when {
language.isEmpty() || !language.matches("\\p{Alpha}{2,8}".toRegex()) ->
language = "und" // Follow the Locale#toLanguageTag() implementation
language == "iw" -> language = "he" // correct deprecated "Hebrew"
language == "in" -> language = "id" // correct deprecated "Indonesian"
language == "ji" -> language = "yi" // correct deprecated "Yiddish"
}
// ensure valid country code, if not well formed, it's omitted
// variant subtags that begin with a letter must be at least 5 characters long
// ensure valid country code, if not well formed, it's omitted
if (!country.matches("\\p{Alpha}{2}|\\p{Digit}{3}".toRegex())) {
country = ""
}
// variant subtags that begin with a letter must be at least 5 characters long
if (!variant.matches("\\p{Alnum}{5,8}|\\p{Digit}\\p{Alnum}{3}".toRegex())) {
variant = ""
}
val tag = StringBuilder(language)
if (country.isNotEmpty())
tag.append('-').append(country)
if (variant.isNotEmpty())
tag.append('-').append(variant)
return tag.toString()
}
}
fun SimpleDateFormat.parseOrNull(date: String) =
runCatching { parse(date) }.onFailure { Timber.e(it) }.getOrNull()

View File

@ -1,7 +1,6 @@
package com.topjohnwu.magisk.ktx
import android.content.res.Resources
import android.os.Build
val specialChars = arrayOf('!', '@', '#', '$', '%', '&', '?')
val fullSpecialChars = arrayOf('', '', '', '', '', '', '')
@ -13,10 +12,7 @@ fun String.isCJK(): Boolean {
return false
}
fun isCJK(codepoint: Int): Boolean {
return if (Build.VERSION.SDK_INT < 19) false /* Pre 5.0 don't need to be pretty.. */
else Character.isIdeographic(codepoint)
}
fun isCJK(codepoint: Int) = Character.isIdeographic(codepoint)
fun String.replaceRandomWithSpecial(passes: Int): String {
var string = this

View File

@ -2,7 +2,6 @@ package com.topjohnwu.magisk.ui
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.os.Build
import android.os.Bundle
import android.view.MenuItem
import android.view.View
@ -123,10 +122,7 @@ open class MainActivity : BaseUIActivity<MainViewModel, ActivityMainMd2Binding>(
val topView = binding.mainToolbarWrapper
val bottomView = binding.mainBottomBar
if (
Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
!binding.mainBottomBar.isAttachedToWindow
) {
if (!binding.mainBottomBar.isAttachedToWindow) {
binding.mainBottomBar.viewTreeObserver.addOnWindowAttachListener(object :
ViewTreeObserver.OnWindowAttachListener {

View File

@ -74,10 +74,6 @@ class SettingsViewModel(
Magisk,
MagiskHide, SystemlessHosts
))
if (Build.VERSION.SDK_INT < 19) {
// MagiskHide is only available on 4.4+
list.remove(MagiskHide)
}
}
// Superuser

View File

@ -3,7 +3,6 @@ package com.topjohnwu.magisk.ui.surequest
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.res.Resources
import android.os.Build
import android.os.Bundle
import android.view.Window
import android.view.WindowManager
@ -62,9 +61,6 @@ open class SuRequestActivity : BaseUIActivity<SuRequestViewModel, ActivityReques
}
private fun lockOrientation() {
requestedOrientation = if (Build.VERSION.SDK_INT < 18)
resources.configuration.orientation
else
ActivityInfo.SCREEN_ORIENTATION_LOCKED
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LOCKED
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 893 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Base.V19.Theme.Splash.Light" parent="Base.V17.Theme.Splash.Light">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="Base.V19.Theme.Splash" parent="Base.V17.Theme.Splash">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="Theme.Splash.Light" parent="Base.V19.Theme.Splash.Light" />
<style name="Theme.Splash" parent="Base.V19.Theme.Splash" />
</resources>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="WidgetFoundation.ProgressBar.Indeterminate" parent="Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:indeterminate">true</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">100dp</item>
<item name="android:indeterminateTint">?colorPrimary</item>
</style>
<style name="WidgetFoundation.ProgressBar.Indeterminate.Circular" parent="Widget.AppCompat.ProgressBar">
<item name="android:indeterminate">true</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:indeterminateTint">?colorPrimary</item>
</style>
</resources>

View File

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Base.V21.Theme.Foundation.Light" parent="Base.V17.Theme.Foundation.Light">
<item name="android:statusBarColor">#38000000</item>
<item name="android:navigationBarColor">#38000000</item>
</style>
<style name="Base.V21.Theme.Foundation" parent="Base.V17.Theme.Foundation">
<item name="android:statusBarColor">#60000000</item>
<item name="android:navigationBarColor">#60000000</item>
</style>
<style name="Theme.Foundation.Light" parent="Base.V21.Theme.Foundation.Light" />
<style name="Theme.Foundation" parent="Base.V21.Theme.Foundation" />
<style name="Base.V21.Theme.Splash.Light" parent="Base.V19.Theme.Splash.Light">
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
<style name="Base.V21.Theme.Splash" parent="Base.V19.Theme.Splash">
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
<style name="Theme.Splash.Light" parent="Base.V21.Theme.Splash.Light" />
<style name="Theme.Splash" parent="Base.V21.Theme.Splash" />
</resources>

View File

@ -174,12 +174,14 @@
<item name="android:indeterminate">true</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">100dp</item>
<item name="android:indeterminateTint">?colorPrimary</item>
</style>
<style name="WidgetFoundation.ProgressBar.Indeterminate.Circular" parent="Widget.AppCompat.ProgressBar">
<item name="android:indeterminate">true</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:indeterminateTint">?colorPrimary</item>
</style>

View File

@ -1,41 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Base.V17.Theme.Foundation.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
<style name="Base.V21.Theme.Foundation.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowBackground">?colorSurface</item>
<item name="android:windowContentOverlay">@null</item>
<item name="dialogTheme">@style/ThemeOverlay.Foundation.Dialog</item>
<item name="android:statusBarColor">#38000000</item>
<item name="android:navigationBarColor">#38000000</item>
</style>
<style name="Base.V17.Theme.Foundation" parent="Theme.MaterialComponents.NoActionBar">
<style name="Base.V21.Theme.Foundation" parent="Theme.MaterialComponents.NoActionBar">
<item name="android:windowBackground">?colorSurface</item>
<item name="android:windowContentOverlay">@null</item>
<item name="dialogTheme">@style/ThemeOverlay.Foundation.Dialog</item>
<item name="android:statusBarColor">#60000000</item>
<item name="android:navigationBarColor">#60000000</item>
</style>
<style name="Theme.Foundation.Light" parent="Base.V17.Theme.Foundation.Light" />
<style name="Theme.Foundation.Light" parent="Base.V21.Theme.Foundation.Light" />
<style name="Theme.Foundation" parent="Base.V17.Theme.Foundation" />
<style name="Theme.Foundation" parent="Base.V21.Theme.Foundation" />
<style name="Base.V17.Theme.Splash.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
<style name="Base.V21.Theme.Splash.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowBackground">@drawable/ic_splash_activity</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
<style name="Base.V17.Theme.Splash" parent="Theme.MaterialComponents.NoActionBar">
<style name="Base.V21.Theme.Splash" parent="Theme.MaterialComponents.NoActionBar">
<item name="android:windowBackground">@drawable/ic_splash_activity</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
<style name="Theme.Splash.Light" parent="Base.V17.Theme.Splash.Light" />
<style name="Theme.Splash.Light" parent="Base.V21.Theme.Splash.Light" />
<style name="Theme.Splash" parent="Base.V17.Theme.Splash" />
<style name="Theme.Splash" parent="Base.V21.Theme.Splash" />
<style name="Base.V17.ThemeOverlay.Foundation.Dialog" parent="ThemeOverlay.MaterialComponents.Dialog">
<style name="Base.V21.ThemeOverlay.Foundation.Dialog" parent="ThemeOverlay.MaterialComponents.Dialog">
<item name="android:windowMinWidthMajor">@dimen/abc_dialog_min_width_major</item>
<item name="android:windowMinWidthMinor">@dimen/abc_dialog_min_width_minor</item>
</style>
<style name="ThemeOverlay.Foundation.Dialog" parent="Base.V17.ThemeOverlay.Foundation.Dialog" />
<style name="ThemeOverlay.Foundation.Dialog" parent="Base.V21.ThemeOverlay.Foundation.Dialog" />
</resources>

View File

@ -14,7 +14,7 @@ buildscript {
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
}
val vNav = "2.3.4"
val vNav = "2.3.5"
extra["vNav"] = vNav
dependencies {
@ -68,7 +68,7 @@ subprojects {
defaultConfig {
if (minSdkVersion == null)
minSdkVersion(17)
minSdkVersion(21)
targetSdkVersion(30)
}

View File

@ -10,7 +10,6 @@ android {
defaultConfig {
applicationId = "com.topjohnwu.magisk"
minSdkVersion(21)
versionCode = 1
versionName = Config.version
buildConfigField("int", "STUB_VERSION", Config.stubVersion)