Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Turn your GitHub contribution graph into a phone wallpaper.
- **Android** support: 70+ devices across Samsung, Google Pixel, OnePlus, Xiaomi, Nothing, Motorola, Sony, ASUS, OPPO, vivo, Realme, and Honor
- Shows contribution stats: total count and current streak
- iOS Shortcut-compatible URL for daily auto-updating wallpapers (iPhone)
- GitWall Android app (`android/`) that sets the lock screen from the same URL and refreshes daily
- GitWall Android app (`android/`) that sets the lock screen and/or home screen from the same URL and refreshes daily
- In-memory caching with 5-minute TTL

## Setup
Expand Down Expand Up @@ -69,14 +69,14 @@ The API returns proper status codes: `400` for a missing or malformed username,
1. Generate your wallpaper and copy the Shortcut URL
2. Open iOS Shortcuts → New Shortcut
3. Add **Get Contents of URL** with the copied URL
4. Add **Set Wallpaper** using the result
4. Add **Set Wallpaper Photo** using the result and choose Lock Screen, Home Screen, or both
5. Automate it: Automation → Time of Day → run daily

**Android (GitWall app)**
1. Generate your wallpaper and copy the URL (no phone model needed)
2. Install the GitWall app from the website's **Download APK** button (`/download/android`)
3. Tap **Open in GitWall app**, or paste the URL into the app
4. Tap **Set lock screen wallpaper**. The app appends your phone's real resolution, sets the lock screen directly through Android's wallpaper API, and refreshes daily at a time you pick (06:00 by default)
4. Choose Lock screen, Home screen, or both, then tap **Set wallpaper**. The app appends your phone's real resolution, sets the wallpaper directly through Android's wallpaper API, and refreshes daily at a time you pick (06:00 by default)

Task-automation apps such as MacroDroid cannot do this reliably: Android copies wallpapers into private system storage, so replacing a file on disk never changes the lock screen, and newer Android versions block writes to shared folders.

Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
applicationId = "space.gitwall.app"
minSdk = 26
targetSdk = 35
versionCode = 2
versionName = "1.1.0"
versionCode = 3
versionName = "1.2.0"
}

signingConfigs {
Expand Down
42 changes: 38 additions & 4 deletions android/app/src/main/java/space/gitwall/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.material3.SwitchDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.darkColorScheme
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -167,6 +169,10 @@ private fun Screen(incomingUrl: String?, onIncomingConsumed: () -> Unit) {
}

fun apply() {
if (!settings.lockScreen && !settings.homeScreen) {
message = "Turn on Lock screen, Home screen, or both."
return
}
when (val check = prepareWallpaperUrl(url, size)) {
is UrlCheck.Invalid -> message = check.reason
is UrlCheck.Ok -> {
Expand Down Expand Up @@ -238,6 +244,15 @@ private fun Screen(incomingUrl: String?, onIncomingConsumed: () -> Unit) {
}
}

Spacer(Modifier.height(14.dp))
Card {
Label("Apply to")
Spacer(Modifier.height(4.dp))
ToggleRow("Lock screen", settings.lockScreen) { store.saveTargets(it, settings.homeScreen); message = null }
Divider()
ToggleRow("Home screen", settings.homeScreen) { store.saveTargets(settings.lockScreen, it); message = null }
}

Spacer(Modifier.height(14.dp))
Button(
onClick = ::apply,
Expand All @@ -253,7 +268,7 @@ private fun Screen(incomingUrl: String?, onIncomingConsumed: () -> Unit) {
}
RunState.WAITING_NETWORK -> Text("Waiting for internet", fontWeight = FontWeight.Bold, fontSize = 15.sp)
RunState.IDLE -> Text(
if (settings.lastSuccessAt > 0L) "Update lock screen now" else "Set lock screen wallpaper",
if (settings.lastSuccessAt > 0L) "Update wallpaper now" else "Set wallpaper",
fontWeight = FontWeight.Bold, fontSize = 15.sp,
)
}
Expand Down Expand Up @@ -305,7 +320,7 @@ private fun Header() {
Spacer(Modifier.width(12.dp))
Column {
Text("GitWall", color = TextPrimary, fontSize = 24.sp, fontWeight = FontWeight.ExtraBold, letterSpacing = (-0.5).sp)
Text("Your contribution graph, on your lock screen.", color = TextMuted, fontSize = 13.sp)
Text("Your contribution graph, as your wallpaper.", color = TextMuted, fontSize = 13.sp)
}
}
}
Expand Down Expand Up @@ -390,10 +405,10 @@ private fun UrlField(value: String, onChange: (String) -> Unit) {
private fun StatusCard(settings: Settings, runState: RunState, size: ScreenSize) {
val context = LocalContext.current
val (tone, headline) = when {
runState == RunState.RUNNING -> Green to "Setting your lock screen…"
runState == RunState.RUNNING -> Green to "Setting your wallpaper…"
runState == RunState.WAITING_NETWORK -> Amber to "Waiting for an internet connection."
settings.lastError != null -> Danger to "Last attempt failed"
settings.lastSuccessAt > 0L -> Green to "Lock screen updated " + relative(settings.lastSuccessAt)
settings.lastSuccessAt > 0L -> Green to "Wallpaper updated " + relative(settings.lastSuccessAt)
else -> TextMuted to "Not set yet"
}
Card {
Expand All @@ -420,6 +435,25 @@ private fun StatusCard(settings: Settings, runState: RunState, size: ScreenSize)
}
}

@Composable
private fun ToggleRow(label: String, checked: Boolean, onChange: (Boolean) -> Unit) {
Row(
Modifier.fillMaxWidth().clip(RoundedCornerShape(10.dp)).clickable { onChange(!checked) }.padding(vertical = 6.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
) {
Text(label, color = TextPrimary, fontSize = 14.sp)
Switch(
checked = checked,
onCheckedChange = onChange,
colors = SwitchDefaults.colors(
checkedThumbColor = Ink, checkedTrackColor = Green,
uncheckedThumbColor = TextMuted, uncheckedTrackColor = PanelRaised, uncheckedBorderColor = Line,
),
)
}
}

@Composable
private fun InfoRow(key: String, value: String) {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
Expand Down
4 changes: 2 additions & 2 deletions android/app/src/main/java/space/gitwall/app/RefreshWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import kotlinx.coroutines.withContext
import java.util.concurrent.TimeUnit

/**
* Downloads the wallpaper and sets the lock screen. Three things enqueue it:
* Downloads the wallpaper and sets the chosen screens. Three things enqueue it:
* the exact daily alarm, the user tapping the button, and the periodic
* safety net. The periodic run steps aside when the alarm already did the job.
*/
Expand All @@ -38,7 +38,7 @@ class RefreshWorker(context: Context, params: WorkerParameters) : CoroutineWorke
return@withContext Result.failure()
}
try {
WallpaperApplier.applyLockScreen(applicationContext, prepared.url)
WallpaperApplier.apply(applicationContext, prepared.url, settings.lockScreen, settings.homeScreen)
store.recordSuccess()
Result.success()
} catch (e: WallpaperException) {
Expand Down
11 changes: 11 additions & 0 deletions android/app/src/main/java/space/gitwall/app/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ data class Settings(
/** Daily refresh time, local clock. */
val refreshHour: Int = 6,
val refreshMinute: Int = 0,
/** Which wallpapers to set. At least one is always on. */
val lockScreen: Boolean = true,
val homeScreen: Boolean = false,
val lastSuccessAt: Long = 0L,
val lastAttemptAt: Long = 0L,
val lastError: String? = null,
Expand All @@ -27,6 +30,8 @@ class SettingsStore(context: Context) {
url = prefs.getString(KEY_URL, "") ?: "",
refreshHour = prefs.getInt(KEY_HOUR, 6),
refreshMinute = prefs.getInt(KEY_MINUTE, 0),
lockScreen = prefs.getBoolean(KEY_LOCK, true),
homeScreen = prefs.getBoolean(KEY_HOME, false),
lastSuccessAt = prefs.getLong(KEY_LAST_SUCCESS, 0L),
lastAttemptAt = prefs.getLong(KEY_LAST_ATTEMPT, 0L),
lastError = prefs.getString(KEY_LAST_ERROR, null),
Expand All @@ -48,6 +53,10 @@ class SettingsStore(context: Context) {
prefs.edit().putInt(KEY_HOUR, hour.coerceIn(0, 23)).putInt(KEY_MINUTE, minute.coerceIn(0, 59)).apply()
}

fun saveTargets(lockScreen: Boolean, homeScreen: Boolean) {
prefs.edit().putBoolean(KEY_LOCK, lockScreen).putBoolean(KEY_HOME, homeScreen).apply()
}

fun saveNextRun(at: Long) {
prefs.edit().putLong(KEY_NEXT_RUN, at).apply()
}
Expand All @@ -65,6 +74,8 @@ class SettingsStore(context: Context) {
const val KEY_URL = "url"
const val KEY_HOUR = "refresh_hour"
const val KEY_MINUTE = "refresh_minute"
const val KEY_LOCK = "target_lock"
const val KEY_HOME = "target_home"
const val KEY_LAST_SUCCESS = "last_success"
const val KEY_LAST_ATTEMPT = "last_attempt"
const val KEY_LAST_ERROR = "last_error"
Expand Down
13 changes: 9 additions & 4 deletions android/app/src/main/java/space/gitwall/app/WallpaperApplier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ class WallpaperException(message: String) : Exception(message)

/**
* Downloads the PNG into memory and hands it to WallpaperManager for the lock
* screen. Nothing is written to shared storage, so it does not matter how a
* manufacturer stores or copies wallpapers internally.
* screen, the home screen, or both. Nothing is written to shared storage, so it
* does not matter how a manufacturer stores or copies wallpapers internally.
*/
object WallpaperApplier {
private const val MAX_BYTES = 40L * 1024 * 1024

fun applyLockScreen(context: Context, url: String) {
fun apply(context: Context, url: String, lockScreen: Boolean, homeScreen: Boolean) {
var flags = 0
if (lockScreen) flags = flags or WallpaperManager.FLAG_LOCK
if (homeScreen) flags = flags or WallpaperManager.FLAG_SYSTEM
if (flags == 0) throw WallpaperException("Choose at least one screen to set.")

val bytes = download(url)
val bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
?: throw WallpaperException("The server did not return an image.")
Expand All @@ -27,7 +32,7 @@ object WallpaperApplier {
throw WallpaperException("This device or profile does not allow apps to change the wallpaper.")
}
try {
manager.setBitmap(bitmap, null, true, WallpaperManager.FLAG_LOCK)
manager.setBitmap(bitmap, null, true, flags)
} catch (e: IOException) {
throw WallpaperException("Android refused the wallpaper: ${e.message ?: "unknown error"}")
} finally {
Expand Down
Binary file modified public/gitwall.apk
Binary file not shown.
6 changes: 3 additions & 3 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ export default function Home() {
<UrlBox url={wallpaperUrl} />
</SubStep>
<SubStep num="3.2">
<p><b className="font-semibold text-white/75">“Set Wallpaper Photo”</b> → choose <b className="font-semibold text-white/75">Lock Screen</b>.</p>
<p><b className="font-semibold text-white/75">“Set Wallpaper Photo”</b> → under <b className="font-semibold text-white/75">Set</b>, choose <b className="font-semibold text-white/75">Lock Screen</b>, <b className="font-semibold text-white/75">Home Screen</b>, or <b className="font-semibold text-white/75">Lock Screen and Home Screen</b>.</p>
</SubStep>
<ImportantNote>
<b className="font-semibold text-amber-300/90">Important:</b> In “Set Wallpaper Photo”, tap the arrow (→) to show options → disable both <b className="font-semibold text-amber-200/90">“Crop to Subject”</b> and <b className="font-semibold text-amber-200/90">“Show Preview”</b>. This stops iOS from cropping the image and asking for confirmation every day.
Expand All @@ -508,7 +508,7 @@ export default function Home() {
<p>Enter your GitHub username, choose a theme above, then tap <b className="font-semibold text-white/75">Generate</b>. No phone model needed: the app measures your screen.</p>
</StepCard>
<StepCard num="2" title="Install the GitWall app">
<p>A small app that does one thing: fetches your wallpaper and sets it as the lock screen, then repeats every day at a time you choose.</p>
<p>A small app that does one thing: fetches your wallpaper and sets it on your lock screen, home screen, or both, then repeats every day at a time you choose.</p>
<a
href={ANDROID_APP_PATH}
className="inline-flex items-center gap-2 mt-1 px-3.5 py-2 rounded-md border border-[#3ddc84]/30 bg-[#3ddc84]/[0.06] text-[#3ddc84] text-[12px] font-semibold hover:bg-[#3ddc84]/[0.12] transition-colors"
Expand Down Expand Up @@ -538,7 +538,7 @@ export default function Home() {
<UrlBox url={wallpaperUrl} />
</StepCard>
<StepCard num="4" title="Set it">
<p>In the app tap <b className="font-semibold text-white/75">Set lock screen wallpaper</b>. Your lock screen updates right away and refreshes every day at the time you choose (6:00 by default).</p>
<p>In the app, turn on <b className="font-semibold text-white/75">Lock screen</b>, <b className="font-semibold text-white/75">Home screen</b>, or both, then tap <b className="font-semibold text-white/75">Set wallpaper</b>. It updates right away and refreshes every day at the time you choose (6:00 by default).</p>
<p>Tap <b className="font-semibold text-white/75">Allow</b> next to Background refresh so Android lets the app fetch while the phone sleeps.</p>
<ImportantNote>
If your phone has a rotating lock screen feature such as Samsung <b className="font-semibold text-amber-200/90">Dynamic Lock screen</b> or Xiaomi <b className="font-semibold text-amber-200/90">Wallpaper Carousel</b>, turn it off or it will replace GitWall.
Expand Down
Loading