|
|
@ -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,18 +33,21 @@ 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 |
|
|
|
|
|
|
|
val baseUrl = NetworkUtils.getBaseUrl(url) |
|
|
|
|
|
|
|
baseUrl ?: return false |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
val host = baseUrl.split("//", ".") |
|
|
|
|
|
|
|
val base64Url = EncoderUtils.base64Encode("${host[host.lastIndex - 1]}.${host.last()}") |
|
|
|
list18Plus.forEach { |
|
|
|
list18Plus.forEach { |
|
|
|
if (url.contains(it)) { |
|
|
|
if (base64Url == it) { |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
} |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|