Skip to content

Commit 3b2b36c

Browse files
author
alex-hermes-agent
committed
feat(v1.16): blur+scrim behind hidden keypad; empty default blocklist
RenderEffect blur (API 31+) on the content behind the summoned keypad, plus a dark clickable scrim — the PIN editor is fully legible now. Default blocked set is empty: the picker starts blank, no SmartTube preset on fresh installs.
1 parent 52c8d47 commit 3b2b36c

6 files changed

Lines changed: 158 additions & 113 deletions

File tree

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ android {
1515
applicationId = "com.alexk.tvlock"
1616
minSdk = 21
1717
targetSdk = 34
18-
versionCode = 15
19-
versionName = "1.14"
18+
versionCode = 17
19+
versionName = "1.16"
2020
}
2121

2222
if (!releaseKeystore.isNullOrBlank()) {

app/src/main/java/com/alexk/tvlock/KeypadHelper.kt

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ import android.view.KeyEvent
55
import android.view.View
66
import android.view.ViewGroup
77
import android.widget.Button
8-
import android.widget.LinearLayout
98

109
/**
1110
* Hidden on-screen keypad for remotes without number buttons.
1211
* Summoned by 3x DPAD_UP within 2 s (the Up key still works normally as a
1312
* navigation key between presses); BACK hides it again.
1413
* The keypad is GONE until summoned — nothing is permanently visible.
14+
* It inflates as a ScrollView overlay into a FrameLayout root, so a short
15+
* screen never clips rows (they become scrollable instead).
1516
*/
1617
class KeypadHelper(
1718
private val activity: Activity,
18-
private val container: LinearLayout,
19+
private val container: ViewGroup,
1920
private val onDigit: (String) -> Unit,
2021
private val onBackspace: () -> Unit,
2122
private val onClear: () -> Unit,
@@ -62,11 +63,29 @@ class KeypadHelper(
6263
root!!.findViewById<Button>(R.id.kx).setOnClickListener { onClear() }
6364
}
6465
root!!.visibility = View.VISIBLE
66+
blurContent(true)
6567
root!!.findViewById<Button>(R.id.k1).requestFocus()
6668
}
6769

6870
fun hide() {
69-
if (visible) root!!.visibility = View.GONE
71+
if (visible) {
72+
root!!.visibility = View.GONE
73+
blurContent(false)
74+
}
75+
}
76+
77+
/** real blur of the screen behind the keypad (API 31+), scrim dim covers older */
78+
private fun blurContent(on: Boolean) {
79+
if (android.os.Build.VERSION.SDK_INT < 31) return
80+
try {
81+
val content = (0 until container.childCount)
82+
.map { container.getChildAt(it) }
83+
.firstOrNull { it !== root }
84+
content?.setRenderEffect(
85+
if (on) android.graphics.RenderEffect.createBlurEffect(25f, 25f,
86+
android.graphics.Shader.TileMode.CLAMP)
87+
else null)
88+
} catch (_: Exception) {}
7089
}
7190

7291
companion object {

app/src/main/java/com/alexk/tvlock/Prefs.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Prefs(context: Context) {
1111
fun setPin(v: String) = sp.edit().putString("pin", v).apply()
1212

1313
fun blockedList(): Set<String> =
14-
sp.getStringSet("blocked", setOf(DEFAULT_BLOCKED)) ?: setOf(DEFAULT_BLOCKED)
14+
sp.getStringSet("blocked", emptySet()) ?: emptySet()
1515

1616
fun setBlocked(pkgs: Set<String>) = sp.edit().putStringSet("blocked", pkgs).apply()
1717

@@ -25,7 +25,6 @@ class Prefs(context: Context) {
2525
fun closeGrace() = sp.edit().putLong("unlock_until", 0L).apply()
2626

2727
companion object {
28-
const val DEFAULT_BLOCKED = "org.smarttube.stable"
2928
val GRACE_CYCLE = listOf(0, 5, 15, 30, 60, -1)
3029
}
3130
}
Lines changed: 63 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,67 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:id="@+id/main_root"
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
6-
android:orientation="vertical"
7-
android:gravity="center"
8-
android:background="#101418"
9-
android:padding="24dp">
10-
11-
<TextView
12-
android:layout_width="wrap_content"
13-
android:layout_height="wrap_content"
14-
android:text="@string/app_title"
15-
android:textSize="28sp"
16-
android:textColor="#FFFFFF" />
17-
18-
<TextView
19-
android:id="@+id/version_text"
20-
android:layout_width="wrap_content"
21-
android:layout_height="wrap_content"
22-
android:layout_marginTop="6dp"
23-
android:textSize="15sp"
24-
android:textColor="#FFC107" />
25-
26-
<TextView
27-
android:id="@+id/status_text"
28-
android:layout_width="wrap_content"
29-
android:layout_height="wrap_content"
30-
android:layout_marginTop="18dp"
31-
android:textSize="16sp"
32-
android:textColor="#B0C4DE"
33-
android:gravity="center" />
34-
35-
<Button
36-
android:id="@+id/btn_setup_pin"
37-
android:layout_width="320dp"
38-
android:layout_height="wrap_content"
39-
android:layout_marginTop="18dp"
40-
android:text="@string/btn_setup_pin" />
41-
42-
<Button
43-
android:id="@+id/btn_grace"
44-
android:layout_width="320dp"
45-
android:layout_height="wrap_content"
46-
android:layout_marginTop="8dp"
47-
android:text="@string/btn_grace" />
48-
49-
<Button
50-
android:id="@+id/btn_blocked"
51-
android:layout_width="320dp"
52-
android:layout_height="wrap_content"
53-
android:layout_marginTop="8dp"
54-
android:text="@string/btn_blocked" />
55-
56-
<Button
57-
android:id="@+id/btn_service"
58-
android:layout_width="320dp"
59-
android:layout_height="wrap_content"
60-
android:layout_marginTop="8dp"
61-
android:text="@string/btn_service" />
62-
</LinearLayout>
6+
android:background="#101418">
7+
8+
<LinearLayout
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent"
11+
android:orientation="vertical"
12+
android:gravity="center"
13+
android:padding="24dp">
14+
15+
<TextView
16+
android:layout_width="wrap_content"
17+
android:layout_height="wrap_content"
18+
android:text="@string/app_title"
19+
android:textSize="28sp"
20+
android:textColor="#FFFFFF" />
21+
22+
<TextView
23+
android:id="@+id/version_text"
24+
android:layout_width="wrap_content"
25+
android:layout_height="wrap_content"
26+
android:layout_marginTop="6dp"
27+
android:textSize="15sp"
28+
android:textColor="#FFC107" />
29+
30+
<TextView
31+
android:id="@+id/status_text"
32+
android:layout_width="wrap_content"
33+
android:layout_height="wrap_content"
34+
android:layout_marginTop="18dp"
35+
android:textSize="16sp"
36+
android:textColor="#B0C4DE"
37+
android:gravity="center" />
38+
39+
<Button
40+
android:id="@+id/btn_setup_pin"
41+
android:layout_width="320dp"
42+
android:layout_height="wrap_content"
43+
android:layout_marginTop="18dp"
44+
android:text="@string/btn_setup_pin" />
45+
46+
<Button
47+
android:id="@+id/btn_grace"
48+
android:layout_width="320dp"
49+
android:layout_height="wrap_content"
50+
android:layout_marginTop="8dp"
51+
android:text="@string/btn_grace" />
52+
53+
<Button
54+
android:id="@+id/btn_blocked"
55+
android:layout_width="320dp"
56+
android:layout_height="wrap_content"
57+
android:layout_marginTop="8dp"
58+
android:text="@string/btn_blocked" />
59+
60+
<Button
61+
android:id="@+id/btn_service"
62+
android:layout_width="320dp"
63+
android:layout_height="wrap_content"
64+
android:layout_marginTop="8dp"
65+
android:text="@string/btn_service" />
66+
</LinearLayout>
67+
</FrameLayout>
Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:id="@+id/pin_root"
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
6-
android:orientation="vertical"
7-
android:gravity="center"
8-
android:background="#101418"
9-
android:padding="48dp">
6+
android:background="#101418">
107

11-
<TextView
12-
android:layout_width="wrap_content"
13-
android:layout_height="wrap_content"
14-
android:text="@string/locked_title"
15-
android:textSize="28sp"
16-
android:textColor="#FFFFFF" />
8+
<LinearLayout
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent"
11+
android:orientation="vertical"
12+
android:gravity="center"
13+
android:padding="48dp">
1714

18-
<TextView
19-
android:id="@+id/pin_display"
20-
android:layout_width="wrap_content"
21-
android:layout_height="wrap_content"
22-
android:layout_marginTop="24dp"
23-
android:textSize="48sp"
24-
android:textColor="#FFC107"
25-
android:minWidth="200dp"
26-
android:gravity="center" />
15+
<TextView
16+
android:layout_width="wrap_content"
17+
android:layout_height="wrap_content"
18+
android:text="@string/locked_title"
19+
android:textSize="28sp"
20+
android:textColor="#FFFFFF" />
2721

28-
<TextView
29-
android:layout_width="wrap_content"
30-
android:layout_height="wrap_content"
31-
android:layout_marginTop="24dp"
32-
android:text="@string/pin_hint"
33-
android:textSize="16sp"
34-
android:textColor="#8899A6" />
35-
</LinearLayout>
22+
<TextView
23+
android:id="@+id/pin_display"
24+
android:layout_width="wrap_content"
25+
android:layout_height="wrap_content"
26+
android:layout_marginTop="24dp"
27+
android:textSize="48sp"
28+
android:textColor="#FFC107"
29+
android:minWidth="200dp"
30+
android:gravity="center" />
31+
32+
<TextView
33+
android:layout_width="wrap_content"
34+
android:layout_height="wrap_content"
35+
android:layout_marginTop="24dp"
36+
android:text="@string/pin_hint"
37+
android:textSize="16sp"
38+
android:textColor="#8899A6" />
39+
</LinearLayout>
40+
</FrameLayout>

app/src/main/res/layout/keypad.xml

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:id="@+id/keypad_root"
4-
android:layout_width="wrap_content"
5-
android:layout_height="wrap_content"
6-
android:layout_marginTop="20dp"
7-
android:columnCount="3"
8-
android:visibility="gone">
2+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:fillViewport="true"
6+
android:background="#B3050708"
7+
android:clickable="true"
8+
android:focusable="true">
99

10-
<Button android:id="@+id/k1" style="@style/KeypadBtn" android:text="1" />
11-
<Button android:id="@+id/k2" style="@style/KeypadBtn" android:text="2" />
12-
<Button android:id="@+id/k3" style="@style/KeypadBtn" android:text="3" />
13-
<Button android:id="@+id/k4" style="@style/KeypadBtn" android:text="4" />
14-
<Button android:id="@+id/k5" style="@style/KeypadBtn" android:text="5" />
15-
<Button android:id="@+id/k6" style="@style/KeypadBtn" android:text="6" />
16-
<Button android:id="@+id/k7" style="@style/KeypadBtn" android:text="7" />
17-
<Button android:id="@+id/k8" style="@style/KeypadBtn" android:text="8" />
18-
<Button android:id="@+id/k9" style="@style/KeypadBtn" android:text="9" />
19-
<Button android:id="@+id/kc" style="@style/KeypadBtn" android:text="" />
20-
<Button android:id="@+id/k0" style="@style/KeypadBtn" android:text="0" />
21-
<Button android:id="@+id/kx" style="@style/KeypadBtn" android:text="C" />
22-
</GridLayout>
10+
<LinearLayout
11+
android:id="@+id/keypad_root"
12+
android:layout_width="match_parent"
13+
android:layout_height="wrap_content"
14+
android:orientation="vertical"
15+
android:gravity="center"
16+
android:paddingBottom="24dp">
17+
18+
<GridLayout
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:layout_gravity="center"
22+
android:layout_marginTop="16dp"
23+
android:columnCount="3">
24+
25+
<Button android:id="@+id/k1" style="@style/KeypadBtn" android:text="1" />
26+
<Button android:id="@+id/k2" style="@style/KeypadBtn" android:text="2" />
27+
<Button android:id="@+id/k3" style="@style/KeypadBtn" android:text="3" />
28+
<Button android:id="@+id/k4" style="@style/KeypadBtn" android:text="4" />
29+
<Button android:id="@+id/k5" style="@style/KeypadBtn" android:text="5" />
30+
<Button android:id="@+id/k6" style="@style/KeypadBtn" android:text="6" />
31+
<Button android:id="@+id/k7" style="@style/KeypadBtn" android:text="7" />
32+
<Button android:id="@+id/k8" style="@style/KeypadBtn" android:text="8" />
33+
<Button android:id="@+id/k9" style="@style/KeypadBtn" android:text="9" />
34+
<Button android:id="@+id/kc" style="@style/KeypadBtn" android:text="" />
35+
<Button android:id="@+id/k0" style="@style/KeypadBtn" android:text="0" />
36+
<Button android:id="@+id/kx" style="@style/KeypadBtn" android:text="C" />
37+
</GridLayout>
38+
</LinearLayout>
39+
</ScrollView>

0 commit comments

Comments
 (0)