neiam
/apollos_crib
It's Apollo's Crib
public · Issues · Pulls 1 · Labels · Forks · Compare · Actions failure · Badges · Packages
⭐
Log in to mark this repository.
Tell the widget when the palette changes
b9f203c · Gabriel Morell · 2026-09-03 15:39
Message
{commit_body(@commit)}
Files changed
modified
clients/android/app/src/debug/java/io/neiam/apolloscrib/feed/OverlayHarnessActivity.kt
+17
−0
@@ -77,6 +77,7 @@ class OverlayHarnessActivity : Activity() {
| 77 | 77 | addView(button("open") { client?.openOverlay(0) }) |
| 78 | 78 | addView(button("close") { client?.closeOverlay(0) }) |
| 79 | 79 | addView(button("detach") { client?.windowDetached(false) }) |
| 80 | + addView(button("pin the board widget") { pinWidget() }) | |
| 80 | 81 | } |
| 81 | 82 | ) |
| 82 | 83 |
@@ -92,6 +93,22 @@ class OverlayHarnessActivity : Activity() {
| 92 | 93 | setOnClickListener { runCatching(onClick).onFailure { Log.e(TAG, label, it) } } |
| 93 | 94 | } |
| 94 | 95 | |
| 96 | + /** | |
| 97 | + * Ask the launcher to place the board widget. | |
| 98 | + * | |
| 99 | + * Dragging one out of a widget picker is not something adb does well, and | |
| 100 | + * the pin request ends in a dialog with a button, which it does. | |
| 101 | + */ | |
| 102 | + private fun pinWidget() { | |
| 103 | + val manager = getSystemService(android.appwidget.AppWidgetManager::class.java) | |
| 104 | + val provider = ComponentName(this, io.neiam.apolloscrib.widget.BoardWidget::class.java) | |
| 105 | + if (manager?.isRequestPinAppWidgetSupported == true) { | |
| 106 | + manager.requestPinAppWidget(provider, null, null) | |
| 107 | + } else { | |
| 108 | + status.text = "launcher will not take a pin request" | |
| 109 | + } | |
| 110 | + } | |
| 111 | + | |
| 95 | 112 | /** |
| 96 | 113 | * The launcher's half of the handshake: its own window's LayoutParams, |
| 97 | 114 | * whose token is what lets the service put a window over this one. |
modified
clients/android/app/src/main/java/io/neiam/apolloscrib/ui/MainActivity.kt
+7
−0
@@ -42,6 +42,7 @@ import androidx.compose.foundation.text.KeyboardOptions
| 42 | 42 | import androidx.compose.ui.platform.LocalContext |
| 43 | 43 | import io.neiam.apolloscrib.data.Pairing |
| 44 | 44 | import io.neiam.apolloscrib.feed.FeedProvider |
| 45 | +import io.neiam.apolloscrib.widget.BoardWidget | |
| 45 | 46 | import io.neiam.apolloscrib.data.Settings |
| 46 | 47 | import io.neiam.apolloscrib.ui.theme.ALL_THEMES |
| 47 | 48 | import io.neiam.apolloscrib.ui.theme.CribTheme |
@@ -97,6 +98,12 @@ class MainActivity : ComponentActivity() {
| 97 | 98 | onThemeChange = { |
| 98 | 99 | settings.themeKey = it |
| 99 | 100 | themeKey = it |
| 101 | + // The widget reads the palette when it redraws, | |
| 102 | + // and it redraws when a board lands -- which | |
| 103 | + // could be minutes. Tell it now, or the home | |
| 104 | + // screen keeps the old colours until something | |
| 105 | + // unrelated happens. | |
| 106 | + BoardWidget.refresh(this) | |
| 100 | 107 | }, |
| 101 | 108 | onConnect = { |
| 102 | 109 | AnkyraService.start(this) |
Parents: 5b1fbaa