|
|
@ -3,8 +3,9 @@ package io.legado.app.help |
|
|
|
import android.os.Handler |
|
|
|
import android.os.Handler |
|
|
|
import android.os.Looper |
|
|
|
import android.os.Looper |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.data.entities.BookSource |
|
|
|
|
|
|
|
import io.legado.app.data.entities.RssSource |
|
|
|
import io.legado.app.data.entities.RssSource |
|
|
|
|
|
|
|
import io.legado.app.utils.EncoderUtils |
|
|
|
|
|
|
|
import io.legado.app.utils.NetworkUtils |
|
|
|
import io.legado.app.utils.splitNotBlank |
|
|
|
import io.legado.app.utils.splitNotBlank |
|
|
|
import org.jetbrains.anko.toast |
|
|
|
import org.jetbrains.anko.toast |
|
|
|
|
|
|
|
|
|
|
@ -32,17 +33,20 @@ object SourceHelp { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun insertBookSource(vararg bookSources: BookSource) { |
|
|
|
|
|
|
|
App.db.bookSourceDao().insert(*bookSources) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun is18Plus(url: String?): Boolean { |
|
|
|
private fun is18Plus(url: String?): Boolean { |
|
|
|
url ?: return false |
|
|
|
url ?: return false |
|
|
|
if (AppConfig.isGooglePlay) return false |
|
|
|
if (AppConfig.isGooglePlay) return false |
|
|
|
list18Plus.forEach { |
|
|
|
val baseUrl = NetworkUtils.getBaseUrl(url) |
|
|
|
if (url.contains(it)) { |
|
|
|
baseUrl ?: return false |
|
|
|
return true |
|
|
|
try { |
|
|
|
|
|
|
|
val host = baseUrl.split("//", ".") |
|
|
|
|
|
|
|
val base64Url = EncoderUtils.base64Encode("${host[host.lastIndex - 1]}.${host.last()}") |
|
|
|
|
|
|
|
list18Plus.forEach { |
|
|
|
|
|
|
|
if (base64Url == it) { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
} |
|
|
|
} |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|