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
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ jobs:
path: ~/.m2/repository/org/robolectric
key: robolectric-${{ hashFiles('gradle/libs.versions.toml') }}

# Testler çeşitten bağımsız; play çeşidinde koşar (Play Billing derlenir),
# libre çeşidi aşağıda APK olarak derlenir.
- name: Arayüz testleri (Robolectric + Compose)
run: ./gradlew :app:testDebugUnitTest
run: ./gradlew :app:testPlayDebugUnitTest

# Başarısız testlerin mesajı ve yığın izi kütükte görünsün; rapor artefaktı
# her ortamdan indirilemiyor.
Expand Down Expand Up @@ -87,11 +89,11 @@ jobs:
app/build/reports/tests
app/build/test-results

- name: Debug APK derle
run: ./gradlew :app:assembleDebug
- name: Debug APK derle (play + libre)
run: ./gradlew :app:assemblePlayDebug :app:assembleLibreDebug

- name: APK'yı yükle
uses: actions/upload-artifact@v4
with:
name: za-debug-apk
path: app/build/outputs/apk/debug/*.apk
path: app/build/outputs/apk/*/debug/*.apk
12 changes: 7 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: ./gradlew :games:engineTests

- name: Arayüz testleri (Robolectric + Compose)
run: ./gradlew :app:testDebugUnitTest
run: ./gradlew :app:testPlayDebugUnitTest

- name: Sürümü etiketten türet
id: version
Expand All @@ -60,8 +60,10 @@ jobs:
env:
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}

# APK GitHub'dan indirilir: libre çeşidi (ödeme kodu yok). AAB Play'e
# yüklenir: play çeşidi. Kilit bayrağı (-PzaPaywall) burada verilmedikçe kapalı.
- name: İmzalı release APK ve AAB derle
run: ./gradlew :app:assembleRelease :app:bundleRelease -PzaVersion=${{ steps.version.outputs.version }}
run: ./gradlew :app:assembleLibreRelease :app:bundlePlayRelease -PzaVersion=${{ steps.version.outputs.version }}
env:
ANDROID_KEYSTORE_PATH: ${{ runner.temp }}/za-release.jks
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
Expand All @@ -70,10 +72,10 @@ jobs:
run: |
TAG="${{ steps.version.outputs.tag }}"
mkdir -p dist
cp app/build/outputs/apk/release/app-release.apk "dist/za-$TAG.apk"
cp app/build/outputs/apk/release/app-release.apk dist/za.apk
cp app/build/outputs/apk/libre/release/app-libre-release.apk "dist/za-$TAG.apk"
cp app/build/outputs/apk/libre/release/app-libre-release.apk dist/za.apk
# Play Console'a yüklenen paket; yandan kurulamaz, APK onun için.
cp app/build/outputs/bundle/release/app-release.aab "dist/za-$TAG-play.aab"
cp app/build/outputs/bundle/playRelease/app-play-release.aab "dist/za-$TAG-play.aab"
git archive --format=zip --prefix="za-$TAG/" -o "dist/za-$TAG-source.zip" HEAD
git archive --format=tar.gz --prefix="za-$TAG/" -o "dist/za-$TAG-source.tar.gz" HEAD
cd dist && sha256sum za* > SHA256SUMS.txt && cat SHA256SUMS.txt
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,19 +452,24 @@ kullanıcıya İngilizce açılırdı.

## Derleme

Arayüz testleri JVM'de koşar, emülatör gerekmez: `./gradlew :app:testDebugUnitTest` (Robolectric + Compose test kuralı;
Arayüz testleri JVM'de koşar, emülatör gerekmez: `./gradlew :app:testPlayDebugUnitTest` (Robolectric + Compose test kuralı;
ana menü, gezinme, Sudoku/Kakuro/Mayın Tarlası/Beş Harf etkileşimleri, Hakkında ve 26 oyun ekranının duman testi).
CI her itmede motor testleriyle birlikte koşturur; sürüm iş akışı da bunlar geçmeden APK üretmez.

Gereksinimler: JDK 17+, Android SDK (compileSdk 36). Android Studio ile açıp çalıştırabilir veya komut satırından derleyebilirsiniz:

```bash
./gradlew :app:assembleDebug # APK: app/build/outputs/apk/debug/
./gradlew :app:assembleLibreDebug # APK: app/build/outputs/apk/libre/debug/ (play çeşidi: assemblePlayDebug)
./gradlew :games:engineTests # games/ altındaki bütün motorlar (liste elle tutulmaz)
```

Motor testleri Android SDK gerektirmez. Sürüm `-PzaVersion=X.Y.Z` özelliğiyle geçilir; release iş akışı bunu etiketten türetir (`versionCode` = `major*10000 + minor*100 + patch`).

**İki dağıtım** (`productFlavors`): `play` Google Play içindir ve Play Billing'i içerir; `libre` GitHub ve
F-Droid içindir, ödeme kodu ve Play kütüphanesi taşımaz, her oyun açıktır. Release iş akışı GitHub'a libre
APK'yı, Play'e play AAB'yi koyar. Ücretli katmanın kilidi (`platform/Pack.kt`, `src/play/.../BillingPurchases.kt`)
`-PzaPaywall=true` ile derlenene kadar kapalıdır; kapalıyken play çeşidi de her oyunu açık gösterir.

- minSdk 26 (Android 8.0) · targetSdk 36
- Kotlin 2.1 · Jetpack Compose (Material 3) · AGP 8.10

Expand Down Expand Up @@ -531,4 +536,4 @@ Sürüm çıkarmak: `git tag v0.1.0 && git push origin v0.1.0`

### English summary

**ZA** is an Android platform for truly ad-free games ("zero ad game play"): no ads, no trackers, no permissions (not even INTERNET), no purchases. It ships 26 games — arcade, puzzle, word and board — in 14 languages, following the phone's language with an in-app picker. Game rules live in deterministic, fully unit-tested pure Kotlin modules under `games/`; the Compose UI lives in `app`. Sound effects are tiny procedurally generated WAVs (`tools/gen_sfx.py`) and can be muted from the hub. Add a game by writing an engine module, a Compose screen, and one `GameEntry` in `GameRegistry`. Build with `./gradlew :app:assembleDebug`, test engines with `./gradlew :games:engineTests`. Licensed under GPL-3.0-or-later; the "ZA Games" name and logo are not part of the license.
**ZA** is an Android platform for truly ad-free games ("zero ad game play"): no ads, no trackers, no permissions (not even INTERNET), no purchases. It ships 26 games — arcade, puzzle, word and board — in 14 languages, following the phone's language with an in-app picker. Game rules live in deterministic, fully unit-tested pure Kotlin modules under `games/`; the Compose UI lives in `app`. Sound effects are tiny procedurally generated WAVs (`tools/gen_sfx.py`) and can be muted from the hub. Add a game by writing an engine module, a Compose screen, and one `GameEntry` in `GameRegistry`. Build with `./gradlew :app:assembleLibreDebug`, test engines with `./gradlew :games:engineTests`. Licensed under GPL-3.0-or-later; the "ZA Games" name and logo are not part of the license.
21 changes: 21 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ val zaVersionCode: Int = zaVersion.split('.').map { it.toInt() }.let { (major, m
(major * 10_000 + minor * 100 + patch).coerceAtLeast(1)
}

// Ücretli katmanın kilidi: Play Console'da ürünler hazır olana kadar kapalı.
// Açmak için: ./gradlew :app:bundlePlayRelease -PzaPaywall=true
val zaPaywall: Boolean = (project.findProperty("zaPaywall") as? String)?.toBoolean() ?: false

android {
namespace = "com.aripd.zagames"
compileSdk = 36
Expand Down Expand Up @@ -43,6 +47,20 @@ android {
}
}

// Aynı kaynaktan iki dağıtım (store/checklist.md, §8):
// play — Google Play; Play Billing yalnız burada derlenir
// libre — GitHub ve F-Droid; ödeme kodu yok, her oyun açık
flavorDimensions += "distribution"
productFlavors {
create("play") {
dimension = "distribution"
buildConfigField("boolean", "PAYWALL", zaPaywall.toString())
}
create("libre") {
dimension = "distribution"
}
}

buildTypes {
release {
isMinifyEnabled = true
Expand All @@ -62,6 +80,7 @@ android {

buildFeatures {
compose = true
buildConfig = true
}

// Play, AAB'yi dile göre böler ve cihaza yalnız kendi dilini indirir.
Expand Down Expand Up @@ -132,6 +151,8 @@ dependencies {
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.lifecycle.viewmodel.compose)

"playImplementation"(libs.billing)

debugImplementation(libs.androidx.compose.ui.tooling)
// createComposeRule için ComponentActivity'yi debug manifestine ekler.
debugImplementation(libs.androidx.compose.ui.test.manifest)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.aripd.zagames.platform

import android.content.Context

/**
* Libre dağıtım (GitHub, F-Droid): ödeme kodu ve Play kütüphanesi yok, her
* oyun açık. Manifestte izin yok sözü bu çeşitte birebir geçerli kalır.
*/
@Suppress("UNUSED_PARAMETER")
fun createPurchases(context: Context): Purchases = AllUnlocked
74 changes: 70 additions & 4 deletions app/src/main/kotlin/com/aripd/zagames/ZaApp.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.aripd.zagames

import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import com.aripd.zagames.ui.common.LocalWordLang
import com.aripd.zagames.ui.common.rememberWordLang
import androidx.activity.compose.BackHandler
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.runtime.mutableStateOf
Expand All @@ -15,18 +20,23 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalHapticFeedback
import com.aripd.zagames.platform.Changelog
import com.aripd.zagames.platform.GameEntry
import com.aripd.zagames.platform.GameRegistry
import com.aripd.zagames.platform.LocalZaHaptics
import com.aripd.zagames.platform.LocalZaSound
import com.aripd.zagames.platform.RestoreResult
import com.aripd.zagames.platform.ScoreStore
import com.aripd.zagames.platform.SettingsStore
import com.aripd.zagames.platform.SoundPlayer
import com.aripd.zagames.platform.ZaLocale
import com.aripd.zagames.platform.appLocale
import com.aripd.zagames.platform.createPurchases
import com.aripd.zagames.platform.isUnlocked
import com.aripd.zagames.platform.gatedBy
import com.aripd.zagames.ui.about.AboutScreen
import com.aripd.zagames.ui.hub.HubScreen
import com.aripd.zagames.ui.hub.LanguageScreen
import com.aripd.zagames.ui.unlock.UnlockScreen

/**
* Uygulama kökü: ana menü ile oyunlar arasında geçişi, rekor akışını ve
Expand Down Expand Up @@ -55,6 +65,17 @@ fun ZaApp() {
onDispose { soundPlayer.release() }
}

// Ücretli katman: libre çeşidinde ve bayrak kapalıyken her oyun açık.
val purchases = remember { createPurchases(context) }
DisposableEffect(purchases) {
onDispose { purchases.release() }
}
val owned by purchases.owned.collectAsState()
val prices by purchases.prices.collectAsState()
val unlocked: (GameEntry) -> Boolean = { game ->
!purchases.enabled || game.isUnlocked(owned)
}

var hapticsOn by remember { mutableStateOf(settings.hapticsEnabled) }
val systemHaptics = LocalHapticFeedback.current
val gatedHaptics = remember(systemHaptics) { systemHaptics.gatedBy { hapticsOn } }
Expand All @@ -63,6 +84,9 @@ fun ZaApp() {
val currentGame = GameRegistry.games.firstOrNull { it.id == currentGameId }
var showAbout by rememberSaveable { mutableStateOf(false) }
var showLanguage by rememberSaveable { mutableStateOf(false) }
var unlockGameId by rememberSaveable { mutableStateOf<String?>(null) }
var restoreResult by remember { mutableStateOf<RestoreResult?>(null) }
val unlockGame = GameRegistry.games.firstOrNull { it.id == unlockGameId }

// Kullanıcının açık dil seçimi ve o an çizilen dil. Seçim uygulanınca
// etkinlik yeniden oluşur, ikisi de yeni değerle okunur.
Expand All @@ -88,6 +112,23 @@ fun ZaApp() {

BackHandler(enabled = currentGame != null) { currentGameId = null }

fun openGame(game: GameEntry) {
val now = System.currentTimeMillis()
settings.recordPlay(game.id, now)
lastPlayed[game.id] = now
currentGameId = game.id
}

// Satın alma tamamlanınca açma ekranı kapanır ve oyun doğrudan başlar.
LaunchedEffect(owned, unlockGameId) {
val game = unlockGame ?: return@LaunchedEffect
if (unlocked(game)) {
unlockGameId = null
restoreResult = null
openGame(game)
}
}

// Kelime oyunlarının dili: ekranın derinlerinde klavye sırası, harf büyütme
// ve taş etiketleri için gerekiyor, tek yerden sağlanır. Oyuncunun seçimi
// yoksa arayüzün diline uyar; o dilin listesi yoksa İngilizceye düşer.
Expand All @@ -113,6 +154,22 @@ fun ZaApp() {
},
onExit = { showLanguage = false },
)
} else if (currentGame == null && unlockGame != null) {
UnlockScreen(
game = unlockGame,
games = GameRegistry.games,
prices = prices,
onBuy = { productId -> context.findActivity()?.let { purchases.buy(it, productId) } },
onRestore = {
restoreResult = null
purchases.restore { restoreResult = it }
},
onExit = {
unlockGameId = null
restoreResult = null
},
restoreResult = restoreResult,
)
} else if (currentGame == null) {
HubScreen(
games = GameRegistry.games,
Expand All @@ -124,11 +181,13 @@ fun ZaApp() {
settings.hubCategory = picked
},
onPlay = { game ->
val now = System.currentTimeMillis()
settings.recordPlay(game.id, now)
lastPlayed[game.id] = now
currentGameId = game.id
if (unlocked(game)) {
openGame(game)
} else {
unlockGameId = game.id
}
},
isUnlocked = unlocked,
soundOn = soundOn,
onToggleSound = {
soundOn = !soundOn
Expand Down Expand Up @@ -163,3 +222,10 @@ fun ZaApp() {
}
}
}

/** Satın alma akışı Activity ister; Compose bağlamı onu sarmalayabilir. */
private tailrec fun Context.findActivity(): Activity? = when (this) {
is Activity -> this
is ContextWrapper -> baseContext.findActivity()
else -> null
}
2 changes: 2 additions & 0 deletions app/src/main/kotlin/com/aripd/zagames/platform/GameEntry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ data class GameEntry(
@StringRes val taglineRes: Int,
/** Menüdeki grup (süzgeç). */
val category: GameCategory,
/** Oyunu açan ücretli paket; null = herkese açık (bkz. [Pack]). */
val pack: Pack? = null,
/** Oyunun eklendiği sürüm; güncellemeden sonra "Yeni" rozeti buna göre gösterilir. */
val since: String = "0.1.0",
/** Menü kartında kullanılan vurgu rengi. */
Expand Down
Loading
Loading