Skip to content

Commit 09da285

Browse files
authored
Merge pull request #1 from britty04/dev
Refactor drawable resources and update splash screen configuration
2 parents 43a8eee + ab97430 commit 09da285

56 files changed

Lines changed: 427 additions & 636 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/src/main/java/com/brittytino/patchwork/FeatureSettingsActivity.kt

Lines changed: 258 additions & 141 deletions
Large diffs are not rendered by default.

app/src/main/java/com/brittytino/patchwork/MainActivity.kt

Lines changed: 14 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ class MainActivity : FragmentActivity() {
6464
override fun onCreate(savedInstanceState: Bundle?) {
6565
// Install and configure the splash screen
6666
val splashScreen = installSplashScreen()
67+
68+
// Force splash screen to dismiss after 2 seconds no matter what
69+
// to prevent getting stuck if Compose has an issue on this device/OS
70+
window.decorView.postDelayed({ isAppReady = true }, 2000)
71+
splashScreen.setKeepOnScreenCondition { !isAppReady }
6772

6873
WindowCompat.setDecorFitsSystemWindows(window, false)
6974
super.onCreate(savedInstanceState)
@@ -73,84 +78,24 @@ class MainActivity : FragmentActivity() {
7378
window.isNavigationBarContrastEnforced = false
7479
}
7580

76-
// Keep splash screen visible while app is loading
77-
splashScreen.setKeepOnScreenCondition { !isAppReady }
78-
79-
// Customize the exit animation - scale up and fade out
80-
// Safe implementation for OEM devices that may not provide iconView
81-
splashScreen.setOnExitAnimationListener { splashScreenViewProvider ->
82-
try {
83-
val splashScreenView = splashScreenViewProvider.view
84-
val splashIcon = try { splashScreenViewProvider.iconView } catch (e: Exception) { null }
85-
86-
// Animate the splash screen view fade out
87-
val fadeOut = ObjectAnimator.ofFloat(splashScreenView, "alpha", 1f, 0f).apply {
88-
interpolator = AnticipateInterpolator()
89-
duration = 750
90-
}
91-
fadeOut.doOnEnd {
92-
splashScreenViewProvider.remove()
93-
// Re-apply edge to edge AFTER the splash screen view is removed
94-
// to ensure it's not overridden by splash screen cleanup
95-
enableEdgeToEdge()
96-
}
97-
98-
// Safely animate the icon if it exists
99-
// Known issue: Some OEM devices (Samsung One UI 8, Xiaomi on Android 16)
100-
// may not provide iconView, causing NullPointerException
101-
try {
102-
@Suppress("SENSELESS_COMPARISON")
103-
if (splashIcon != null) {
104-
// Scale down animation
105-
val scaleUp = ObjectAnimator.ofFloat(splashIcon, "scaleX", 1f, 0.5f).apply {
106-
interpolator = AnticipateInterpolator()
107-
duration = 750
108-
}
109-
110-
val scaleUpY = ObjectAnimator.ofFloat(splashIcon, "scaleY", 1f, 0.5f).apply {
111-
interpolator = AnticipateInterpolator()
112-
duration = 750
113-
}
114-
115-
// rotate
116-
val rotate360 = ObjectAnimator.ofFloat(splashIcon, "rotation", 0f, -90f).apply {
117-
interpolator = AnticipateInterpolator()
118-
duration = 750
119-
}
120-
121-
scaleUp.start()
122-
scaleUpY.start()
123-
rotate360.start()
124-
} else {
125-
Log.w("SplashScreen", "iconView is null - OEM device detected")
126-
}
127-
} catch (e: NullPointerException) {
128-
// Handle the edge case where iconView becomes null between check and animation
129-
Log.w("SplashScreen", "NullPointerException on iconView animation - likely OEM device", e)
130-
}
131-
132-
fadeOut.start()
133-
} catch (e: Exception) {
134-
// Fallback for any unexpected exceptions during animation
135-
Log.e("SplashScreen", "Exception during splash screen animation", e)
136-
try {
137-
splashScreenViewProvider.remove()
138-
} catch (e2: Exception) {
139-
Log.e("SplashScreen", "Exception during splash screen removal", e2)
140-
}
141-
}
142-
}
143-
14481
Log.d("MainActivity", "onCreate with action: ${intent?.action}")
14582
handleLocationIntent(intent)
14683

14784
// Initialize HapticUtil with saved preferences
14885
HapticUtil.initialize(this)
14986
// initialize permission registry
15087
initPermissionRegistry()
151-
// Initialize viewModel state early for correct initial composition
88+
89+
// viewModel.check is also called in LaunchedEffect inside setContent.
15290
viewModel.check(this)
91+
15392
setContent {
93+
// Confirm composition started and mark app as ready
94+
LaunchedEffect(Unit) {
95+
isAppReady = true
96+
Log.d("MainActivity", "Composition started")
97+
}
98+
15499
val isPitchBlackThemeEnabled by viewModel.isPitchBlackThemeEnabled
155100
PatchworkTheme(pitchBlackTheme = isPitchBlackThemeEnabled) {
156101
val context = LocalContext.current
@@ -286,12 +231,6 @@ class MainActivity : FragmentActivity() {
286231
}
287232
}
288233
}
289-
290-
291-
// Mark app as ready after composing (happens very quickly)
292-
LaunchedEffect(Unit) {
293-
isAppReady = true
294-
}
295234
}
296235
}
297236
}

app/src/main/java/com/brittytino/patchwork/domain/registry/FeatureRegistry.kt

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,70 @@ object FeatureRegistry {
520520
override fun onToggle(viewModel: MainViewModel, context: Context, enabled: Boolean) {}
521521
},
522522

523+
object : Feature(
524+
id = "App Behavior Controller",
525+
title = R.string.feat_app_behavior_title,
526+
iconRes = R.drawable.rounded_settings_accessibility_24,
527+
category = R.string.cat_tools,
528+
description = R.string.feat_app_behavior_desc,
529+
permissionKeys = listOf("ACCESSIBILITY"),
530+
showToggle = false
531+
) {
532+
override fun isEnabled(viewModel: MainViewModel) = true
533+
override fun onToggle(viewModel: MainViewModel, context: Context, enabled: Boolean) {}
534+
},
535+
536+
object : Feature(
537+
id = "Smart App Cooldown",
538+
title = R.string.feat_app_cooldown_title,
539+
iconRes = R.drawable.rounded_timer_24,
540+
category = R.string.cat_tools,
541+
description = R.string.feat_app_cooldown_desc,
542+
permissionKeys = listOf("ACCESSIBILITY", "DRAW_OVERLAYS"),
543+
showToggle = false
544+
) {
545+
override fun isEnabled(viewModel: MainViewModel) = true
546+
override fun onToggle(viewModel: MainViewModel, context: Context, enabled: Boolean) {}
547+
},
548+
549+
object : Feature(
550+
id = "Idle App Auto-Action",
551+
title = R.string.feat_idle_app_title,
552+
iconRes = R.drawable.rounded_av_timer_24,
553+
category = R.string.cat_tools,
554+
description = R.string.feat_idle_app_desc,
555+
permissionKeys = listOf("USAGE_STATS"),
556+
showToggle = false
557+
) {
558+
override fun isEnabled(viewModel: MainViewModel) = true
559+
override fun onToggle(viewModel: MainViewModel, context: Context, enabled: Boolean) {}
560+
},
561+
562+
object : Feature(
563+
id = "Action History Timeline",
564+
title = R.string.feat_action_history_title,
565+
iconRes = R.drawable.rounded_fiber_smart_record_24,
566+
category = R.string.cat_tools,
567+
description = R.string.feat_action_history_desc,
568+
showToggle = false
569+
) {
570+
override fun isEnabled(viewModel: MainViewModel) = true
571+
override fun onToggle(viewModel: MainViewModel, context: Context, enabled: Boolean) {}
572+
},
573+
574+
object : Feature(
575+
id = "System State Snapshots",
576+
title = R.string.feat_system_snapshots_title,
577+
iconRes = R.drawable.rounded_save_24,
578+
category = R.string.cat_tools,
579+
description = R.string.feat_system_snapshots_desc,
580+
permissionKeys = listOf("WRITE_SECURE_SETTINGS"),
581+
showToggle = false
582+
) {
583+
override fun isEnabled(viewModel: MainViewModel) = true
584+
override fun onToggle(viewModel: MainViewModel, context: Context, enabled: Boolean) {}
585+
},
586+
523587
object : Feature(
524588
id = "Watermarks",
525589
title = R.string.feat_watermark_title,

app/src/main/java/com/brittytino/patchwork/domain/registry/PermissionRegistry.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,11 @@ fun initPermissionRegistry() {
6868

6969
// Modify system settings permission
7070
PermissionRegistry.register("WRITE_SETTINGS", R.string.feat_qs_tiles_title)
71+
72+
// New Features
73+
PermissionRegistry.register("USAGE_STATS", R.string.feat_idle_app_title)
74+
PermissionRegistry.register("ACCESSIBILITY", R.string.feat_app_behavior_title)
75+
PermissionRegistry.register("ACCESSIBILITY", R.string.feat_app_cooldown_title)
76+
PermissionRegistry.register("DRAW_OVERLAYS", R.string.feat_app_cooldown_title)
77+
PermissionRegistry.register("WRITE_SECURE_SETTINGS", R.string.feat_system_snapshots_title)
7178
}

app/src/main/java/com/brittytino/patchwork/ui/components/dialogs/AboutSection.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ fun AboutSection(
119119
modifier = Modifier.padding(horizontal = 4.dp)
120120
) {
121121
Icon(
122-
painter = painterResource(id = R.drawable.brand_github),
122+
painter = painterResource(id = R.drawable.rounded_globe_24),
123123
contentDescription = null,
124124
modifier = Modifier.size(18.dp)
125125
)
@@ -161,7 +161,7 @@ fun AboutSection(
161161
modifier = Modifier.padding(horizontal = 4.dp)
162162
) {
163163
Icon(
164-
painter = painterResource(id = R.drawable.brand_telegram),
164+
painter = painterResource(id = R.drawable.rounded_globe_24),
165165
contentDescription = null,
166166
modifier = Modifier.size(18.dp)
167167
)

app/src/main/java/com/brittytino/patchwork/ui/components/sheets/BugReportBottomSheet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ fun BugReportBottomSheet(
224224
},
225225
modifier = Modifier.fillMaxWidth()
226226
) {
227-
Icon(painter = painterResource(R.drawable.brand_github), contentDescription = null, modifier = Modifier.size(18.dp))
227+
Icon(painter = painterResource(R.drawable.rounded_globe_24), contentDescription = null, modifier = Modifier.size(18.dp))
228228
Spacer(modifier = Modifier.width(8.dp))
229229
Text(stringResource(R.string.action_report_github))
230230
}

app/src/main/java/com/brittytino/patchwork/ui/components/sheets/InstructionsBottomSheet.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fun InstructionsBottomSheet(
182182
modifier = Modifier.padding(horizontal = 4.dp)
183183
) {
184184
Icon(
185-
painter = painterResource(id = R.drawable.brand_github),
185+
painter = painterResource(id = R.drawable.rounded_globe_24),
186186
contentDescription = null,
187187
modifier = Modifier.size(18.dp)
188188
)
@@ -222,7 +222,7 @@ fun InstructionsBottomSheet(
222222
modifier = Modifier.padding(horizontal = 4.dp)
223223
) {
224224
Icon(
225-
painter = painterResource(id = R.drawable.brand_telegram),
225+
painter = painterResource(id = R.drawable.rounded_globe_24),
226226
contentDescription = null,
227227
modifier = Modifier.size(18.dp)
228228
)
@@ -336,7 +336,7 @@ fun ExpandableGuideSection(section: InstructionSection) {
336336
shape = RoundedCornerShape(12.dp)
337337
) {
338338
Icon(
339-
painter = painterResource(id = R.drawable.brand_github),
339+
painter = painterResource(id = R.drawable.rounded_globe_24),
340340
contentDescription = null,
341341
modifier = Modifier.size(18.dp)
342342
)

app/src/main/java/com/brittytino/patchwork/ui/components/sheets/UpdateBottomSheet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fun UpdateBottomSheet(
157157
modifier = Modifier.fillMaxWidth()
158158
) {
159159
Icon(
160-
painter = painterResource(id = R.drawable.brand_github),
160+
painter = painterResource(id = R.drawable.rounded_globe_24),
161161
contentDescription = null,
162162
modifier = Modifier.size(18.dp)
163163
)

app/src/main/java/com/brittytino/patchwork/ui/composables/watermark/WatermarkScreen.kt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -967,16 +967,7 @@ private fun LogoCarouselPicker(
967967
modifier: Modifier = Modifier
968968
) {
969969
val logos = listOf(
970-
R.drawable.apple,
971-
R.drawable.cmf,
972-
R.drawable.google,
973-
R.drawable.moto,
974-
R.drawable.nothing,
975-
R.drawable.oppo,
976-
R.drawable.samsung,
977-
R.drawable.sony,
978-
R.drawable.vivo,
979-
R.drawable.xiaomi
970+
R.mipmap.ic_launcher
980971
)
981972

982973
val carouselState = androidx.compose.material3.carousel.rememberCarouselState { logos.size }

app/src/main/java/com/brittytino/patchwork/ui/ime/KeyboardInputView.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,11 @@ fun KeyboardInputView(
402402
content = {
403403
val functions = remember(isClipboardEnabled) {
404404
val list = mutableListOf(
405-
R.drawable.ic_emoji to "Emoji",
406-
R.drawable.ic_undo to "Undo"
405+
R.drawable.rounded_heart_smile_24 to "Emoji",
406+
R.drawable.rounded_arrow_back_24 to "Undo"
407407
)
408408
if (isClipboardEnabled) {
409-
list.add(1, R.drawable.ic_clipboard to "Clipboard")
409+
list.add(1, R.drawable.rounded_content_paste_24 to "Clipboard")
410410
}
411411
list
412412
}
@@ -644,7 +644,7 @@ fun KeyboardInputView(
644644
.fillMaxHeight()
645645
) {
646646
Icon(
647-
painter = painterResource(id = R.drawable.key_shift),
647+
painter = painterResource(id = R.drawable.rounded_keyboard_arrow_up_24),
648648
contentDescription = "Shift",
649649
modifier = Modifier.size(24.dp),
650650
tint = if (shiftState != ShiftState.OFF) MaterialTheme.colorScheme.onPrimary

0 commit comments

Comments
 (0)