Skip to content

Commit e331fbb

Browse files
committed
add DebugShortcutsFragment
1 parent 2b8aa28 commit e331fbb

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

app/src/main/kotlin/de/binarynoise/captiveportalautologin/preferences/MainFragment.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ class MainFragment : AutoCleanupPreferenceFragment() {
223223
fragment = LogsFragment::class.qualifiedName
224224
}
225225

226+
if (BuildConfig.DEBUG) {
227+
addPreference(Preference(ctx)) {
228+
title = "Debug Activities"
229+
fragment = DebugShortcutsFragment::class.qualifiedName
230+
}
231+
}
226232
setIconSpaceReservedRecursively(false)
227233
}
228234
}

app/src/main/kotlin/de/binarynoise/captiveportalautologin/util/Context.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import android.annotation.SuppressLint
44
import android.app.Application
55
import android.content.Context
66
import android.content.Intent
7+
import android.util.TypedValue
8+
import androidx.annotation.AttrRes
9+
import androidx.annotation.ColorInt
710

811
@SuppressLint("PrivateApi")
912
internal var applicationContext: Application =
@@ -21,3 +24,13 @@ inline fun Context.startActivity(setup: Intent.() -> Unit = {}) {
2124
inline fun <reified T> Context.startService(setup: Intent.() -> Unit = {}) {
2225
startService(Intent(this, T::class.java).apply(setup))
2326
}
27+
28+
@ColorInt
29+
fun Context.getColorFromAttr(
30+
@AttrRes attrColor: Int,
31+
typedValue: TypedValue = TypedValue(),
32+
resolveRefs: Boolean = true,
33+
): Int {
34+
check(theme.resolveAttribute(attrColor, typedValue, resolveRefs))
35+
return typedValue.data
36+
}

0 commit comments

Comments
 (0)