diff --git a/sample/android-app/build.gradle.kts b/sample/android-app/build.gradle.kts new file mode 100644 index 0000000..7ec60e0 --- /dev/null +++ b/sample/android-app/build.gradle.kts @@ -0,0 +1,48 @@ +plugins { + alias(libs.plugins.androidApplication) + alias(libs.plugins.composeCompiler) +} + +android { + namespace = "dev.androidbroadcast.featured.sample.app" + compileSdk = + libs.versions.android.compileSdk + .get() + .toInt() + + defaultConfig { + applicationId = "dev.androidbroadcast.featured.sample" + minSdk = + libs.versions.android.minSdk + .get() + .toInt() + targetSdk = + libs.versions.android.targetSdk + .get() + .toInt() + versionCode = 1 + versionName = "1.0.0" + } + + buildFeatures { + compose = true + } + + buildTypes { + release { + isMinifyEnabled = true + isShrinkResources = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + ) + } + } +} + +dependencies { + implementation(project(":sample")) + implementation(project(":featured-debug-ui")) + implementation(project(":featured-platform")) + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.appcompat) +} diff --git a/sample/android-app/src/main/AndroidManifest.xml b/sample/android-app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..caea1b2 --- /dev/null +++ b/sample/android-app/src/main/AndroidManifest.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/sample/android-app/src/main/kotlin/dev/androidbroadcast/featured/sample/MainActivity.kt b/sample/android-app/src/main/kotlin/dev/androidbroadcast/featured/sample/MainActivity.kt new file mode 100644 index 0000000..e9f0813 --- /dev/null +++ b/sample/android-app/src/main/kotlin/dev/androidbroadcast/featured/sample/MainActivity.kt @@ -0,0 +1,42 @@ +package dev.androidbroadcast.featured.sample + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.BackHandler +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import dev.androidbroadcast.featured.ConfigValues +import dev.androidbroadcast.featured.SampleApp +import dev.androidbroadcast.featured.debugui.FeatureFlagsDebugScreen +import dev.androidbroadcast.featured.platform.defaultLocalProvider + +class MainActivity : ComponentActivity() { + // ConfigValues is held at Activity scope for this sample. + // In production, move to Application or a DI singleton to avoid + // recreating (and re-opening) the DataStore file on every rotation. + private val configValues by lazy { + ConfigValues(localProvider = defaultLocalProvider(applicationContext)) + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContent { + var showDebug by rememberSaveable { mutableStateOf(false) } + + if (showDebug) { + BackHandler { showDebug = false } + FeatureFlagsDebugScreen(configValues = configValues) + } else { + SampleApp( + configValues = configValues, + onOpenDebugUi = { showDebug = true }, + ) + } + } + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 1bfaa11..7556a0c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -38,6 +38,7 @@ plugins { include(":featured-gradle-plugin") include(":sample") +include(":sample:android-app") include(":core") include(":featured-compose") include(":featured-registry")