Skip to content

Commit

Permalink
add notification filters
Browse files Browse the repository at this point in the history
UI fixes
  • Loading branch information
mr-wolf-gb committed Aug 31, 2021
1 parent 2b32118 commit 1bac28d
Show file tree
Hide file tree
Showing 28 changed files with 620 additions and 94 deletions.
31 changes: 25 additions & 6 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.dev.wolf.exploit_db"
minSdk 22
targetSdk 30
versionCode 3
versionName "1.1.2"
versionCode 4
versionName "1.1.3"
generatedDensities = []
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", "exploit-db_v$versionName")
Expand All @@ -25,9 +25,7 @@ android {
}

buildTypes {
debug {
//applicationIdSuffix = '.debug'
}

release {
multiDexEnabled false
minifyEnabled true
Expand Down
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public static void checkFieldIsNotNull(...);
public static void checkParameterIsNotNull(...);
}
-keep class org.koitharu.kotatsu.core.db.entity.* { *; }
-keep class com.dev.wolf.exploit_db.core.database.entity.* { *; }
-keepclassmembers public class * extends com.dev.wolf.exploit_db.core.parser.ExploitRepository {
public <init>(...);
}
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<application
Expand All @@ -22,6 +23,9 @@
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:ignore="UnusedAttribute">
<activity
android:name=".settings.SettingsActivity"
android:exported="false" />
<activity
android:name=".ui.detail.ui.ExploitCodeActivity"
android:exported="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ class AndroidCookieJar : CookieJar {
suspend fun clear() = suspendCoroutine<Boolean> { continuation ->
cookieManager.removeAllCookies(continuation::resume)
}

fun clearAsync() {
cookieManager.removeAllCookies {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.dev.wolf.exploit_db.core.network

import com.dev.wolf.exploit_db.BuildConfig
import com.dev.wolf.exploit_db.core.prefs.AppSettings
import com.dev.wolf.exploit_db.core.prefs.DNS_CLIENT_TYPE
import com.dev.wolf.exploit_db.core.prefs.DnsClientType
import com.dev.wolf.exploit_db.utils.CacheUtils
import okhttp3.CookieJar
import okhttp3.OkHttpClient
Expand All @@ -18,8 +18,8 @@ val networkModule
single(named(CacheUtils.QUALIFIER_HTTP)) { CacheUtils.createHttpCache(androidContext()) }
single {
OkHttpClient.Builder().apply {
if (AppSettings(get()).dnsClient == DNS_CLIENT_TYPE.CLOUDFLARE) dnsCloudflare()
else if (AppSettings(get()).dnsClient == DNS_CLIENT_TYPE.GOOGLE) dnsGoogle()
if (AppSettings(get()).dnsClient == DnsClientType.CLOUDFLARE) dnsCloudflare()
else if (AppSettings(get()).dnsClient == DnsClientType.GOOGLE) dnsGoogle()
connectTimeout(20, TimeUnit.SECONDS)
readTimeout(60, TimeUnit.SECONDS)
writeTimeout(20, TimeUnit.SECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.channels.sendBlocking
import kotlinx.coroutines.flow.callbackFlow
import android.provider.Settings
import com.dev.wolf.exploit_db.R
import com.dev.wolf.exploit_db.utils.delegates.prefs.*

class AppSettings private constructor(private val prefs: SharedPreferences) :
SharedPreferences by prefs {

private var _context: Context? = null

constructor(context: Context) : this(
PreferenceManager.getDefaultSharedPreferences(context)
)
){ _context = context }

val theme by StringIntPreferenceDelegate(
KEY_THEME,
Expand All @@ -26,8 +29,6 @@ class AppSettings private constructor(private val prefs: SharedPreferences) :

val isToolbarHideWhenScrolling by BoolPreferenceDelegate(KEY_HIDE_TOOLBAR, defaultValue = true)

var isTrafficWarningEnabled by BoolPreferenceDelegate(KEY_TRAFFIC_WARNING, defaultValue = true)

val appUpdateAuto by BoolPreferenceDelegate(KEY_APP_UPDATE_AUTO, defaultValue = true)

var appUpdate by LongPreferenceDelegate(KEY_APP_UPDATE, defaultValue = 0L)
Expand All @@ -48,7 +49,7 @@ class AppSettings private constructor(private val prefs: SharedPreferences) :

val codeViewZoom by BoolPreferenceDelegate(KEY_CODEVIEW_ZOOM, true)

val codeViewWrapLine by BoolPreferenceDelegate(KEY_CODEVIEW_WRAP_LINE, true)
val codeViewWrapLine by BoolPreferenceDelegate(KEY_CODEVIEW_WRAP_LINE, false)

val codeViewLineNumber by BoolPreferenceDelegate(KEY_CODEVIEW_LINE_NUMBER, true)

Expand All @@ -62,8 +63,16 @@ class AppSettings private constructor(private val prefs: SharedPreferences) :
defValue = "atom-one-dark"
)

var notificationFilterTypes by StringSetPreferenceDelegate(
KEY_NOTIFICATION_FILTER_TYPE,
_context?.resources?.getStringArray(R.array.exploit_types_values)?.toSet() ?: emptySet()
)

var notificationFilterPlatforms by StringSetPreferenceDelegate(
KEY_NOTIFICATION_FILTER_PLATFORM,
_context?.resources?.getStringArray(R.array.exploit_platforms_values)?.toSet() ?: emptySet()
)

@Deprecated("Use observe()")
fun subscribe(listener: SharedPreferences.OnSharedPreferenceChangeListener) {
prefs.registerOnSharedPreferenceChangeListener(listener)
}
Expand All @@ -82,17 +91,15 @@ class AppSettings private constructor(private val prefs: SharedPreferences) :
}
}

val dnsClient by EnumPreferenceDelegate(DNS_CLIENT_TYPE::class.java,
val dnsClient by EnumPreferenceDelegate(DnsClientType::class.java,
PREFERRED_DNS_CLIENT,
DNS_CLIENT_TYPE.NONE
DnsClientType.NONE
)

companion object {

const val KEY_THEME = "theme"
const val KEY_THEME_AMOLED = "amoled_theme"
const val KEY_HIDE_TOOLBAR = "hide_toolbar"
const val KEY_TRAFFIC_WARNING = "traffic_warning"
const val KEY_COOKIES_CLEAR = "cookies_clear"
const val KEY_APP_UPDATE = "app_update"
const val KEY_APP_UPDATE_AUTO = "app_update_auto"
Expand All @@ -109,5 +116,7 @@ class AppSettings private constructor(private val prefs: SharedPreferences) :
const val KEY_CODEVIEW_ZOOM = "code_view_zoom"
const val KEY_CODEVIEW_WRAP_LINE = "code_view_wrap"
const val KEY_CODEVIEW_LINE_NUMBER = "code_view_line_number"
const val KEY_NOTIFICATION_FILTER_TYPE = "notifications_filter_type"
const val KEY_NOTIFICATION_FILTER_PLATFORM = "notifications_filter_platform"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.dev.wolf.exploit_db.core.prefs

enum class DNS_CLIENT_TYPE {
enum class DnsClientType {
NONE,CLOUDFLARE,GOOGLE
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dev.wolf.exploit_db.core.ui

import android.annotation.SuppressLint
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Intent
Expand All @@ -11,17 +12,22 @@ import android.view.View
import com.dev.wolf.exploit_db.ui.MainActivity
import com.dev.wolf.exploit_db.R
import com.dev.wolf.exploit_db.databinding.ActivityCrashBinding
import com.dev.wolf.exploit_db.utils.DeviceInfoHelper
import com.dev.wolf.exploit_db.utils.ShareHelper
import org.koin.android.ext.android.get
import org.koin.android.ext.android.inject

class CrashActivity : Activity(), View.OnClickListener {

private lateinit var binding: ActivityCrashBinding
private val deviceLogInfo by inject<DeviceInfoHelper>()

@SuppressLint("SetTextI18n")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityCrashBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.textView.text = intent.getStringExtra(Intent.EXTRA_TEXT)
binding.textView.text = deviceLogInfo.getDeviceInfoLog() + intent.getStringExtra(Intent.EXTRA_TEXT)
binding.buttonClose.setOnClickListener(this)
binding.buttonRestart.setOnClickListener(this)
binding.buttonReport.setOnClickListener(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,24 @@ import com.dev.wolf.exploit_db.R
import com.dev.wolf.exploit_db.base.BasePreferenceFragment
import com.dev.wolf.exploit_db.core.prefs.AppSettings
import android.provider.Settings
import androidx.preference.ListPreference
import com.dev.wolf.exploit_db.core.network.AndroidCookieJar
import com.dev.wolf.exploit_db.core.prefs.DnsClientType
import com.dev.wolf.exploit_db.tracker.TrackWorker
import com.dev.wolf.exploit_db.ui.MainActivity
import org.koin.android.ext.android.get
import com.dev.wolf.exploit_db.utils.ext.names
import com.dev.wolf.exploit_db.utils.ext.setDefaultValueCompat
import com.google.android.material.snackbar.Snackbar

class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
SharedPreferences.OnSharedPreferenceChangeListener {

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.pref_main)
preferenceScreen?.findPreference<ListPreference>(AppSettings.PREFERRED_DNS_CLIENT)?.run {
entryValues = DnsClientType.values().names()
setDefaultValueCompat(DnsClientType.NONE.name)
}
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -55,16 +65,22 @@ class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
.putExtra(Settings.EXTRA_CHANNEL_ID, TrackWorker.CHANNEL_ID)
startActivity(intent)
} else {
(activity as? MainActivity)?.openNotificationSettingsLegacy()
(activity as? SettingsActivity)?.openNotificationSettingsLegacy()
}
true
}
AppSettings.KEY_COOKIES_CLEAR -> {
val cookieJar = get<AndroidCookieJar>()
cookieJar.clearAsync()
Snackbar.make(
listView,
R.string.cookies_cleared,
Snackbar.LENGTH_SHORT
).show()
true
}
else -> super.onPreferenceTreeClick(preference)
}
}

companion object {

fun newInstance() = MainSettingsFragment()
}
}
Loading

0 comments on commit 1bac28d

Please sign in to comment.