Skip to content

Commit 8c8714e

Browse files
committed
Fix moon phase graphics, first-run crash, and enhance app icons with craters
1 parent db80967 commit 8c8714e

12 files changed

Lines changed: 135 additions & 20 deletions

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.2] - 2026-05-11
9+
10+
### Fixed
11+
- **Moon Graphics**: Corrected drawing logic for waning phases in the UI. Waning crescents and gibbouses now display their correct concave/convex curves.
12+
- **App Icon Shapes**: Fixed inverted sweep flags in vector drawables that caused crescents to appear as gibbouses.
13+
- **First-Run Exit**: Resolved an issue where the app would quit immediately on the first run. Dynamic icon swapping is now deferred until the application is moved to the background (`onStop`), preventing the system from killing the active foreground process.
14+
- **App Icon Visibility**: Enhanced all moon icons with crater details and set the default app icon to a detailed Full Moon for better visibility in system settings and the app drawer.
15+
816
## [0.0.1] - 2026-05-10
917

18+
1019
### Added
1120
- **Moon Oracle App**: Initial release of the Android client.
1221
- **Zero-Split-Brain Architecture**: Ported lunar math to a Rust WASM core for cross-platform consistency.

android/app/src/main/java/com/useless/moonphase/LunarIconManager.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import android.content.ComponentName
44
import android.content.Context
55
import android.content.pm.PackageManager
66

7+
import android.util.Log
8+
79
/**
810
* Handles the swapping of app icons based on the moon phase.
911
*/
@@ -25,19 +27,22 @@ object LunarIconManager {
2527
val currentPackage = context.packageName
2628
val pm = context.packageManager
2729

30+
Log.d("MoonPhase", "Updating icon to: $targetAlias for phase: $phaseName")
31+
2832
// Ensure the absolute target alias path
2933
val targetComponentName = ComponentName(currentPackage, "$currentPackage$targetAlias")
3034

31-
// Check if the target is already enabled. If so, do nothing.
35+
// Check if the target is already enabled.
3236
if (pm.getComponentEnabledSetting(targetComponentName) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
37+
Log.d("MoonPhase", "Icon already set to $targetAlias")
3338
return
3439
}
3540

36-
// Enable the new alias first
41+
// Enable the new alias
3742
pm.setComponentEnabledSetting(
3843
targetComponentName,
3944
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
40-
PackageManager.DONT_KILL_APP
45+
0
4146
)
4247

4348
// Disable all other aliases
@@ -47,9 +52,10 @@ object LunarIconManager {
4752
pm.setComponentEnabledSetting(
4853
comp,
4954
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
50-
PackageManager.DONT_KILL_APP
55+
0
5156
)
5257
}
5358
}
59+
Log.d("MoonPhase", "Icon swap triggered.")
5460
}
5561
}

android/app/src/main/java/com/useless/moonphase/MainActivity.kt

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import androidx.compose.ui.unit.sp
2121
import org.json.JSONObject
2222

2323
class MainActivity : ComponentActivity() {
24+
private var currentPhaseName: String? = null
25+
2426
override fun onCreate(savedInstanceState: Bundle?) {
2527
super.onCreate(savedInstanceState)
2628

@@ -36,18 +38,28 @@ class MainActivity : ComponentActivity() {
3638
modifier = Modifier.fillMaxSize(),
3739
color = Color(0xFF0D0D0D)
3840
) {
39-
MoonPhaseScreen(wasmEngine)
41+
MoonPhaseScreen(wasmEngine) { phase ->
42+
currentPhaseName = phase
43+
}
4044
}
4145
}
4246
}
4347
}
48+
49+
override fun onStop() {
50+
super.onStop()
51+
// Update the app icon only when the user leaves the app to prevent the system
52+
// from killing the process while the app is in the foreground.
53+
currentPhaseName?.let { phase ->
54+
LunarIconManager.updateIcon(this, phase)
55+
}
56+
}
4457
}
4558

4659
@Composable
47-
fun MoonPhaseScreen(engine: WasmEngine?) {
60+
fun MoonPhaseScreen(engine: WasmEngine?, onPhaseCalculated: (String) -> Unit) {
4861
var moonData by remember { mutableStateOf<JSONObject?>(null) }
4962
var error by remember { mutableStateOf<String?>(null) }
50-
val context = LocalContext.current
5163

5264
LaunchedEffect(Unit) {
5365
if (engine == null) {
@@ -57,11 +69,12 @@ fun MoonPhaseScreen(engine: WasmEngine?) {
5769
try {
5870
val now = System.currentTimeMillis() / 1000.0
5971
val result = engine.calculatePhase(now)
60-
moonData = JSONObject(result)
72+
val data = JSONObject(result)
73+
moonData = data
6174

62-
// Update the app icon based on the current phase
63-
moonData?.getString("phase_name")?.let { phase ->
64-
LunarIconManager.updateIcon(context, phase)
75+
// Notify the activity of the current phase
76+
data.optString("phase_name")?.let { phase ->
77+
onPhaseCalculated(phase)
6578
}
6679
} catch (e: Exception) {
6780
error = e.message
@@ -213,14 +226,14 @@ fun MoonView(illumination: Float, phaseName: String, modifier: Modifier = Modifi
213226
path.addArc(
214227
androidx.compose.ui.geometry.Rect(center.x - innerWidth, center.y - radius, center.x + innerWidth, center.y + radius),
215228
-90f,
216-
180f
229+
-180f
217230
)
218231
} else {
219232
val innerWidth = radius * (2f * illumination - 1f)
220233
path.addArc(
221234
androidx.compose.ui.geometry.Rect(center.x - innerWidth, center.y - radius, center.x + innerWidth, center.y + radius),
222235
-90f,
223-
-180f
236+
180f
224237
)
225238
}
226239
}

android/app/src/main/res/drawable/ic_moon_first_quarter.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,18 @@
1212
<path
1313
android:fillColor="#FFFFFF"
1414
android:pathData="M54,14 A40,40 0 0 1 54,94 L54,14" />
15+
<path
16+
android:fillColor="#FFFFFF"
17+
android:pathData="M54,14 A40,40 0 0 1 54,94 A0,40 0 0 1 54,14" />
18+
<!-- Simplify: Quarter moon is just a semi circle -->
19+
<path
20+
android:fillColor="#FFFFFF"
21+
android:pathData="M54,14 A40,40 0 0 1 54,94 L54,14 Z" />
22+
<!-- Craters -->
23+
<path android:fillColor="#252525" android:pathData="M42,50m-6,0a6,6 0,1 1,12 0a6,6 0,1 1,-12 0" />
24+
<path android:fillColor="#252525" android:pathData="M50,62m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
25+
<path android:fillColor="#252525" android:pathData="M34,38m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
26+
<path android:fillColor="#E0E0E0" android:pathData="M58,74m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0" />
27+
<path android:fillColor="#E0E0E0" android:pathData="M70,42m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
28+
<path android:fillColor="#E0E0E0" android:pathData="M74,58m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0" />
1529
</vector>

android/app/src/main/res/drawable/ic_moon_full.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,23 @@
99
<path
1010
android:fillColor="#FFFFFF"
1111
android:pathData="M54,54m-40,0a40,40 0,1 1,80 0a40,40 0,1 1,-80 0" />
12+
<!-- Craters -->
13+
<path
14+
android:fillColor="#E0E0E0"
15+
android:pathData="M58,74m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0" />
16+
<path
17+
android:fillColor="#E0E0E0"
18+
android:pathData="M42,50m-6,0a6,6 0,1 1,12 0a6,6 0,1 1,-12 0" />
19+
<path
20+
android:fillColor="#E0E0E0"
21+
android:pathData="M70,42m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
22+
<path
23+
android:fillColor="#E0E0E0"
24+
android:pathData="M50,62m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
25+
<path
26+
android:fillColor="#E0E0E0"
27+
android:pathData="M74,58m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0" />
28+
<path
29+
android:fillColor="#E0E0E0"
30+
android:pathData="M34,38m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
1231
</vector>

android/app/src/main/res/drawable/ic_moon_last_quarter.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,12 @@
1111
android:pathData="M54,54m-40,0a40,40 0,1 1,80 0a40,40 0,1 1,-80 0" />
1212
<path
1313
android:fillColor="#FFFFFF"
14-
android:pathData="M54,14 A40,40 0 0 0 54,94 L54,14" />
14+
android:pathData="M54,14 A40,40 0 0 0 54,94 L54,14 Z" />
15+
<!-- Craters -->
16+
<path android:fillColor="#252525" android:pathData="M70,42m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
17+
<path android:fillColor="#252525" android:pathData="M74,58m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0" />
18+
<path android:fillColor="#252525" android:pathData="M58,74m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0" />
19+
<path android:fillColor="#E0E0E0" android:pathData="M42,50m-6,0a6,6 0,1 1,12 0a6,6 0,1 1,-12 0" />
20+
<path android:fillColor="#E0E0E0" android:pathData="M50,62m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
21+
<path android:fillColor="#E0E0E0" android:pathData="M34,38m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
1522
</vector>

android/app/src/main/res/drawable/ic_moon_new.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,23 @@
99
<path
1010
android:fillColor="#1A1A1A"
1111
android:pathData="M54,54m-40,0a40,40 0,1 1,80 0a40,40 0,1 1,-80 0" />
12+
<!-- Craters (Subtle on dark side) -->
13+
<path
14+
android:fillColor="#252525"
15+
android:pathData="M58,74m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0" />
16+
<path
17+
android:fillColor="#252525"
18+
android:pathData="M42,50m-6,0a6,6 0,1 1,12 0a6,6 0,1 1,-12 0" />
19+
<path
20+
android:fillColor="#252525"
21+
android:pathData="M70,42m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
22+
<path
23+
android:fillColor="#252525"
24+
android:pathData="M50,62m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
25+
<path
26+
android:fillColor="#252525"
27+
android:pathData="M74,58m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0" />
28+
<path
29+
android:fillColor="#252525"
30+
android:pathData="M34,38m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
1231
</vector>

android/app/src/main/res/drawable/ic_moon_waning_crescent.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,12 @@
1111
android:pathData="M54,54m-40,0a40,40 0,1 1,80 0a40,40 0,1 1,-80 0" />
1212
<path
1313
android:fillColor="#FFFFFF"
14-
android:pathData="M54,14 A40,40 0 0 0 54,94 A20,40 0 0 0 54,14" />
14+
android:pathData="M54,14 A40,40 0 0 0 54,94 A20,40 0 0 1 54,14" />
15+
<!-- Craters -->
16+
<path android:fillColor="#252525" android:pathData="M58,74m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0" />
17+
<path android:fillColor="#252525" android:pathData="M42,50m-6,0a6,6 0,1 1,12 0a6,6 0,1 1,-12 0" />
18+
<path android:fillColor="#252525" android:pathData="M70,42m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
19+
<path android:fillColor="#252525" android:pathData="M50,62m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
20+
<path android:fillColor="#252525" android:pathData="M74,58m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0" />
21+
<path android:fillColor="#E0E0E0" android:pathData="M34,38m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
1522
</vector>

android/app/src/main/res/drawable/ic_moon_waning_gibbous.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,12 @@
1111
android:pathData="M54,54m-40,0a40,40 0,1 1,80 0a40,40 0,1 1,-80 0" />
1212
<path
1313
android:fillColor="#FFFFFF"
14-
android:pathData="M54,14 A40,40 0 0 0 54,94 A20,40 0 0 1 54,14" />
14+
android:pathData="M54,14 A40,40 0 0 0 54,94 A20,40 0 0 0 54,14" />
15+
<!-- Craters -->
16+
<path android:fillColor="#252525" android:pathData="M70,42m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
17+
<path android:fillColor="#252525" android:pathData="M74,58m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0" />
18+
<path android:fillColor="#E0E0E0" android:pathData="M58,74m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0" />
19+
<path android:fillColor="#E0E0E0" android:pathData="M42,50m-6,0a6,6 0,1 1,12 0a6,6 0,1 1,-12 0" />
20+
<path android:fillColor="#E0E0E0" android:pathData="M50,62m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
21+
<path android:fillColor="#E0E0E0" android:pathData="M34,38m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
1522
</vector>

android/app/src/main/res/drawable/ic_moon_waxing_crescent.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,12 @@
1111
android:pathData="M54,54m-40,0a40,40 0,1 1,80 0a40,40 0,1 1,-80 0" />
1212
<path
1313
android:fillColor="#FFFFFF"
14-
android:pathData="M54,14 A40,40 0 0 1 54,94 A20,40 0 0 1 54,14" />
14+
android:pathData="M54,14 A40,40 0 0 1 54,94 A20,40 0 0 0 54,14" />
15+
<!-- Craters -->
16+
<path android:fillColor="#252525" android:pathData="M42,50m-6,0a6,6 0,1 1,12 0a6,6 0,1 1,-12 0" />
17+
<path android:fillColor="#252525" android:pathData="M50,62m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
18+
<path android:fillColor="#252525" android:pathData="M34,38m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
19+
<path android:fillColor="#E0E0E0" android:pathData="M58,74m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0" />
20+
<path android:fillColor="#E0E0E0" android:pathData="M70,42m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0" />
21+
<path android:fillColor="#E0E0E0" android:pathData="M74,58m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0" />
1522
</vector>

0 commit comments

Comments
 (0)