Commit 75e1873c authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Merge branch 'master' of...

Merge branch 'master' of https://git.frostnerd.com/PublicAndroidApps/smokescreen into 227-enable-users-to-just-start-a-local-dns-server
parents dd3c6dba de125676
......@@ -34,6 +34,11 @@ captures/
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
.idea/markdown-navigator.xml
.idea/markdown-navigator-enh.xml
.idea/navEditor.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
......
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SSBasedInspection" enabled="true" level="WARNING" enabled_by_default="true">
<searchConfiguration name="Use Preferences (from AndroidUtils) instead of SharedPreferences" text="SharedPreferences" recursive="false" caseInsensitive="true" type="JAVA" />
<searchConfiguration name="Use Preferences (from AndroidUtils) instead of SharedPreferences" text="PreferenceManager.getDefaultSharedPreferences();" recursive="false" caseInsensitive="true" type="JAVA" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
......@@ -9,6 +9,9 @@ I host my [own instance of Weblate](https://weblate.frostnerd.com) -- [creating
See below for a quick tutorial on how to use Weblate.
**Important!**<br>
I have both a DeepL and a Google Translate API key which I can use to automatically translate the texts to add suggestions to Weblate. Those suggestions won't be used as translations util they are approved. Suggestions fasten the process of translating tremendously as the automatic translation in some cases is already very good or just requires manual edits. Let me know if you want to translate into a new language and I can add the automatic suggestions for those languages to make it faster for you!<br>
## Credentials
If for whatever reason you don't want to create an account you can contact me. I'll then provide you with credentials.
This can for example be useful if you don't want your Name to be assigned with the commit and instead want to remain anonymous.
......
......@@ -110,6 +110,11 @@ android {
disable 'MissingTranslation'
disable 'InvalidPeriodicWorkRequestInterval'
}
dependenciesInfo {
includeInApk = false
includeInBundle = false
}
}
dependencies {
......@@ -131,7 +136,7 @@ dependencies {
implementation 'androidx.work:work-runtime:2.3.4'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation "androidx.preference:preference:1.1.1"
implementation "com.google.android.material:material:1.2.0-alpha06"
implementation "com.google.android.material:material:1.2.0-beta01"
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0-alpha01'
implementation "androidx.room:room-runtime:$room_version"
......
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
\ No newline at end of file
<resources>
<string name="changelog_build_41_adblocker_1">Añadió dos nuevas fuentes de reglas del DNS</string>
<string name="changelog_build_29_2">Añadido AdGuard DNS</string>
<string name="changelog_build_29_1">Los servidores que bloquean los anuncios se muestran ahora en edificios que no son de juguete (¡incluyendo éste!)</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
\ No newline at end of file
<resources>
<string name="changelog_build_41_adblocker_1">Ajout de deux nouvelles sources de règles DNS</string>
<string name="changelog_build_29_2">Ajout du DNS AdGuard</string>
<string name="changelog_build_29_1">Les serveurs qui bloquent les publicités sont maintenant affichés dans des constructions autres que celles des Playstores (y compris celle-ci !)</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
\ No newline at end of file
......@@ -177,22 +177,6 @@ fun Context.isAppBatteryOptimized(): Boolean {
return !pwrm.isIgnoringBatteryOptimizations(packageName)
}
fun Array<*>.toStringArray(): Array<String> {
val stringArray = arrayOfNulls<String>(size)
for ((index, value) in withIndex()) {
stringArray[index] = value.toString()
}
return stringArray as Array<String>
}
fun IntArray.toStringArray(): Array<String> {
val stringArray = arrayOfNulls<String>(size)
for ((index, value) in withIndex()) {
stringArray[index] = value.toString()
}
return stringArray as Array<String>
}
fun <T:Activity>Activity.restart(activityClass:Class<T>? = null) {
val intent = (if(activityClass != null) Intent(this, activityClass) else intent)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION)
......@@ -208,16 +192,6 @@ fun Context.showEmailChooser(chooserTitle: String, subject: String, recipent: St
startActivity(Intent.createChooser(intent, chooserTitle))
}
fun ConnectivityManager.isMobileNetwork(network: Network): Boolean {
val capabilities = getNetworkCapabilities(network)
return capabilities != null && capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
}
fun ConnectivityManager.isWifiNetwork(network: Network): Boolean {
val capabilities = getNetworkCapabilities(network)
return capabilities != null && capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
}
fun ConnectivityManager.isVpnNetwork(network: Network): Boolean {
val capabilities = getNetworkCapabilities(network)
return capabilities != null && capabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)
......
......@@ -148,11 +148,6 @@ fun Fragment.log(e: Throwable) {
if (context != null) requireContext().log(e)
}
fun Fragment.closeLogger() {
if (Logger.isOpen())
Logger.getInstance(requireContext()).destroy()
}
class Logger private constructor(context: Context) {
private val logFile: File
private val fileWriter: BufferedWriter
......
......@@ -297,10 +297,6 @@ class MainActivity : NavigationDrawerActivity() {
}
}
private fun askRateApp() {
}
private fun rateApp() {
val appPackageName = this.packageName
try {
......
......@@ -65,8 +65,8 @@ class QueryImportActivity: AppCompatActivity() {
val source = if(split[5].equals("false", true) || split[5].equals("true", true)) {
if (split[5].toBoolean()) QueryListener.Source.CACHE
else QueryListener.Source.UPSTREAM
} else QueryListener.Source.values().find {
it.name.equals(split[5], true)
} else QueryListener.Source.values().find { source ->
source.name.equals(split[5], true)
} ?: QueryListener.Source.UPSTREAM
queries.add(DnsQuery(
name=split[0],
......
......@@ -148,12 +148,12 @@ class ServerImportActivity : BaseActivity() {
else reader.skipValue()
}
if (reader.readJsonArray {
if (!reader.readJsonArray {
val previousSize = serverTypes.size
if (reader.readJsonObject(block = readServerType) && serverTypes.size == previousSize) serverTypes.add(
true
)
}) else {
}){
val previousSize = serverTypes.size
if (reader.readJsonObject(block = readServerType) && serverTypes.size == previousSize) serverTypes.add(true)
}
......
......@@ -31,30 +31,12 @@ import java.io.FileWriter
class DnsQueryRepository(private val dnsQueryDao: DnsQueryDao) {
fun updateAsync(dnsQuery: DnsQuery): Job {
return GlobalScope.launch(Dispatchers.IO) {
dnsQueryDao.update(dnsQuery)
}
}
fun insertAllAsync(dnsQueries:List<DnsQuery>): Job {
return GlobalScope.launch(Dispatchers.IO) {
dnsQueryDao.insertAll(dnsQueries)
}
}
fun insertAsync(dnsQuery:DnsQuery): Job {
return GlobalScope.launch(Dispatchers.IO) {
dnsQueryDao.insert(dnsQuery)
}
}
suspend fun getAllAsync(coroutineScope: CoroutineScope): List<DnsQuery> {
return coroutineScope.async(Dispatchers.IO, start = CoroutineStart.DEFAULT) {
dnsQueryDao.getAll()
}.await()
}
fun exportQueriesAsCsvAsync(context: Context,
fileReadyCallback:(createdFile: File) ->Unit,
countUpdateCallback:(count:Long, total:Int) -> Unit):Job {
......
......@@ -27,42 +27,12 @@ import kotlinx.coroutines.launch
*/
class DnsRuleRepository(private val dnsRuleDao: DnsRuleDao) {
fun updateAsync(dnsRule: DnsRule, coroutineScope: CoroutineScope = GlobalScope) {
coroutineScope.launch {
dnsRuleDao.update(dnsRule)
}
}
fun insertAsync(dnsRule: DnsRule, coroutineScope: CoroutineScope = GlobalScope) {
coroutineScope.launch {
dnsRuleDao.insert(dnsRule)
}
}
fun deleteAllUserRulesAsync(coroutineScope: CoroutineScope = GlobalScope) {
coroutineScope.launch {
dnsRuleDao.deleteAllUserRules()
}
}
fun deleteAllFromSourceAsync(hostSource: HostSource, coroutineScope: CoroutineScope = GlobalScope) {
coroutineScope.launch {
dnsRuleDao.deleteAllFromSource(hostSource.id)
}
}
fun getUserCountAsync(block:(count:Long) -> Unit,coroutineScope: CoroutineScope = GlobalScope) {
coroutineScope.launch {
block(dnsRuleDao.getUserCount())
}
}
fun getUserRulesAsnc(block:(List<DnsRule>) -> Unit, coroutineScope: CoroutineScope = GlobalScope) {
coroutineScope.launch {
block(dnsRuleDao.getAllUserRules())
}
}
fun removeAsync(rule:DnsRule, coroutineScope: CoroutineScope = GlobalScope) {
coroutineScope.launch {
dnsRuleDao.remove(rule)
......
......@@ -18,13 +18,6 @@ import kotlinx.coroutines.launch
*/
class HostSourceRepository(private val hostSourceDao: HostSourceDao) {
@Delete
fun deleteAsync(hostSource: HostSource, coroutineScope: CoroutineScope = GlobalScope) {
coroutineScope.launch {
hostSourceDao.delete(hostSource)
}
}
fun insertAllAsync(sources:Collection<HostSource>, coroutineScope: CoroutineScope = GlobalScope) {
coroutineScope.launch {
hostSourceDao.insertAll(sources)
......
......@@ -21,6 +21,8 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.util.*
import kotlin.collections.HashSet
/*
* Copyright (C) 2019 Daniel Wolf (Ch4t4r)
......@@ -58,7 +60,7 @@ class AppChoosalDialog(
packageManager.getInstalledApplications(PackageManager.GET_META_DATA).filter {
!hiddenAppPackages.contains(it.packageName)
}.sortedBy {
labels.getOrPut(it.packageName) { it.loadLabel(packageManager).toString() }.toLowerCase()
labels.getOrPut(it.packageName) { it.loadLabel(packageManager).toString() }.toLowerCase(Locale.ROOT)
}.toMutableList()
}
private val filteredPackets: MutableList<ApplicationInfo> = emptyList<ApplicationInfo>().toMutableList()
......
......@@ -10,7 +10,6 @@ import com.frostnerd.lifecyclemanagement.BaseDialog
import com.frostnerd.smokescreen.*
import com.frostnerd.smokescreen.util.preferences.AppSettings
import com.frostnerd.smokescreen.util.preferences.Crashreporting
import io.sentry.Sentry
import kotlinx.android.synthetic.main.dialog_crashreportingusages.view.*
import kotlinx.android.synthetic.main.dialog_crashreportingusages_listgroup.view.*
......
......@@ -146,16 +146,16 @@ class DnsRuleDialog(context: Context, dnsRule: DnsRule? = null, onRuleCreated: (
view.ipv6Til.visibility = View.GONE
} else {
view.host.setText(printableHost(dnsRule.host))
when {
dnsRule.type == Record.TYPE.A -> {
when (dnsRule.type) {
Record.TYPE.A -> {
view.ipv4Address.setText(dnsRule.target)
view.ipv6Address.text = null
}
dnsRule.type == Record.TYPE.AAAA -> {
Record.TYPE.AAAA -> {
view.ipv4Address.text = null
view.ipv6Address.setText(dnsRule.target)
}
dnsRule.type == Record.TYPE.ANY -> {
Record.TYPE.ANY -> {
view.ipv4Address.setText(dnsRule.target)
view.ipv6Address.setText(dnsRule.ipv6Target)
}
......
......@@ -30,7 +30,6 @@ import kotlinx.android.synthetic.main.dialog_loading.view.*
class LoadingDialog(context:Context, title:String, private var message: String?) :BaseDialog(context, context.getPreferences().theme.dialogStyle) {
constructor(context: Context, @StringRes title:Int):this(context, context.getString(title), null)
constructor(context: Context, @StringRes title:Int, @StringRes message:Int):this(context, context.getString(title), context.getString(message))
constructor(context: Context, title:String):this(context, title, null)
private val messageView:TextView
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment