Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c9e1b61
Refactor: Decouple DataStore from Settings Module
Kimblebee Feb 13, 2026
caaca00
add settings datastore dependency to settings feature
Kimblebee Feb 17, 2026
c4cb9d0
Merge branch 'main' into kim/refactor/datastore-module
Kimblebee Feb 25, 2026
5041648
Merge branch 'main' into kim/refactor/datastore-module
Kimblebee Mar 2, 2026
83160c3
remove obsolete testInstrumentationRunner declaration from settings b…
Kimblebee Mar 2, 2026
f7f2b28
correct imports and package names
Kimblebee Mar 2, 2026
d3a67a8
* remove underscore from settings datastore package name
Kimblebee Mar 3, 2026
767185e
Merge branch 'main' into kim/refactor/datastore-module
Kimblebee Mar 17, 2026
7fa786e
address pr comments
Kimblebee Mar 20, 2026
8d43add
reinstate protoconversiontest
Kimblebee Mar 20, 2026
1666a10
spotless
Kimblebee Mar 20, 2026
f172dc1
Merge branch 'main' into kim/refactor/datastore-module
Kimblebee Mar 20, 2026
ef9c9e0
Merge branch 'main' into kim/refactor/datastore-module
Kimblebee Apr 23, 2026
47ac2a7
restore test dependencies
Kimblebee Apr 23, 2026
2f5827d
Merge branch 'main' into kim/refactor/datastore-module
Kimblebee Apr 27, 2026
7dde910
Merge branch 'main' into kim/refactor/datastore-module
Kimblebee Apr 28, 2026
e6033d7
Delete stream configuration quick setting
Kimblebee May 11, 2026
83e936d
Merge branch 'main' into kim/refactor/datastore-module
Kimblebee May 11, 2026
f2a705b
Move settings-datastore test helpers to dedicated testing module
Kimblebee May 12, 2026
d8f08e0
increase timeout for flaky emulator tests
Kimblebee May 13, 2026
e5fa7cf
Revert "Delete stream configuration quick setting"
Kimblebee May 29, 2026
fad12e9
build: fix datastore dependency leaks and Hilt assembly
Kimblebee May 29, 2026
35b504c
separate model and datastore proto conveersion tests
Kimblebee May 29, 2026
9bde9a6
restore main scoping/manifests and update styleguide with
Kimblebee May 29, 2026
82fe4e0
Merge branch 'main' into kim/refactor/datastore-module
Kimblebee May 29, 2026
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
2 changes: 2 additions & 0 deletions .gemini/styleguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ When reviewing a pull request, focus on the following key areas:
* Does the new code align with the existing MVVM architecture?
* Are ViewModels, Repositories, and UI components used correctly?
* Does it introduce any anti-patterns or deviate from established conventions in the codebase?
* **Hilt Scoping Hygiene:** Verify Hilt dependency scopes are appropriate for their lifecycle (e.g., `SingletonComponent` vs `ActivityRetainedComponent`). Avoid over-scoping (such as using `Singleton` when the component state should be isolated per activity/test session to prevent state leaks between tests).
* **Git Merge & Diff Hygiene:** During merges from `main`, verify that recent `main` changes (such as scoping fixes or newly added configuration files like module `AndroidManifest.xml`s) are not accidentally reverted or lost in conflicts. Ensure the PR diff against `main` is minimal and contains zero unrelated "merge noise" or unintended file reversions.

2. **Code Quality and Best Practices**
* Check for adherence to official Kotlin style guides and Android best practices.
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ dependencies {

// Access settings & model data
implementation(project(":data:settings"))
implementation(project(":data:settings-datastore"))
implementation(project(":core:model"))

// Camera Preview
Expand Down
1 change: 1 addition & 0 deletions data/settings-datastore/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
122 changes: 122 additions & 0 deletions data/settings-datastore/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.google.protobuf)
alias(libs.plugins.kotlin.kapt)
}

android {
namespace = "com.google.jetpackcamera.data.settingsdatastore"
compileSdk = libs.versions.compileSdk.get().toInt()

defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
testOptions.targetSdk = libs.versions.targetSdk.get().toInt()
lint.targetSdk = libs.versions.targetSdk.get().toInt()

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
}
Comment thread
Kimblebee marked this conversation as resolved.

@Suppress("UnstableApiUsage")
testOptions {
managedDevices {
localDevices {
create("pixel2Api28") {
device = "Pixel 2"
apiLevel = 28
}
create("pixel8Api34") {
device = "Pixel 8"
apiLevel = 34
systemImageSource = "aosp_atd"
}
}
}
}
}

dependencies {
implementation(libs.androidx.core.ktx)

// Hilt
implementation(libs.dagger.hilt.android)
kapt(libs.dagger.hilt.compiler)

// proto datastore
implementation(libs.protobuf.kotlin.lite)
implementation(libs.androidx.datastore)

// Access Model data
implementation(project(":core:common"))
implementation(project(":core:model"))
implementation(project(":data:settings"))

// Testing
testImplementation(libs.junit)
testImplementation(libs.truth)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.truth)
androidTestImplementation(libs.kotlinx.coroutines.test)
androidTestImplementation(project(":data:settings-datastore:testing"))
}

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.21.12"
}

generateProtoTasks {
all().forEach { task ->
task.builtins {
create("java") {
option("lite")
}
}

task.builtins {
create("kotlin") {
option("lite")
}
}
}
}
}

// Allow references to generated code
kapt {
correctErrorTypes = true
}
Empty file.
21 changes: 21 additions & 0 deletions data/settings-datastore/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.jetpackcamera.settings
package com.google.jetpackcamera.data.settingsdatastore

import androidx.datastore.core.DataStore
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import com.google.jetpackcamera.settings.testing.FakeDataStoreModule
import com.google.jetpackcamera.settings.testing.FakeJcaSettingsSerializer
import com.google.jetpackcamera.settings.JcaSettings
import com.google.jetpackcamera.settingsdatastore.testing.FakeDataStoreModule
import com.google.jetpackcamera.settingsdatastore.testing.FakeJcaSettingsSerializer
import java.io.File
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest
Expand All @@ -31,7 +33,7 @@ import org.junit.rules.TemporaryFolder
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
@OptIn(ExperimentalCoroutinesApi::class)
class DataStoreModuleTest {
@get:Rule
val tempFolder = TemporaryFolder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.jetpackcamera.settings
package com.google.jetpackcamera.data.settingsdatastore

import android.content.Context
import androidx.datastore.core.DataStore
Expand All @@ -22,13 +22,14 @@ import androidx.datastore.dataStoreFile
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import com.google.jetpackcamera.data.settingsdatastore.DataStoreModule.provideDataStore
import com.google.jetpackcamera.model.CaptureMode
import com.google.jetpackcamera.model.DarkMode
import com.google.jetpackcamera.model.DynamicRange
import com.google.jetpackcamera.model.FlashMode
import com.google.jetpackcamera.model.ImageOutputFormat
import com.google.jetpackcamera.model.LensFacing
import com.google.jetpackcamera.settings.DataStoreModule.provideDataStore
import com.google.jetpackcamera.settings.JcaSettings
import com.google.jetpackcamera.settings.model.CameraAppSettings
import com.google.jetpackcamera.settings.model.DEFAULT_CAMERA_APP_SETTINGS
import java.io.File
Expand Down
19 changes: 19 additions & 0 deletions data/settings-datastore/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2026 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 The Android Open Source Project
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.jetpackcamera.settings
package com.google.jetpackcamera.data.settingsdatastore

import android.content.Context
import androidx.datastore.core.DataStore
import androidx.datastore.core.DataStoreFactory
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
import androidx.datastore.dataStoreFile
import com.google.jetpackcamera.settings.JcaSettings
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand All @@ -30,7 +31,6 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob

// with hilt will ensure datastore instance access is unique per file
@Module
@InstallIn(SingletonComponent::class)
object DataStoreModule {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 The Android Open Source Project
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.jetpackcamera.settings
package com.google.jetpackcamera.data.settingsdatastore

import androidx.datastore.core.CorruptionException
import androidx.datastore.core.Serializer
Expand All @@ -27,6 +27,7 @@ import com.google.jetpackcamera.model.proto.LensFacing
import com.google.jetpackcamera.model.proto.StabilizationMode
import com.google.jetpackcamera.model.proto.StreamConfig
import com.google.jetpackcamera.model.proto.VideoQuality
import com.google.jetpackcamera.settings.JcaSettings
import com.google.protobuf.InvalidProtocolBufferException
import java.io.InputStream
import java.io.OutputStream
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 The Android Open Source Project
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.jetpackcamera.settings
package com.google.jetpackcamera.data.settingsdatastore

import androidx.datastore.core.DataStore
import com.google.jetpackcamera.core.common.DefaultCaptureModeOverride
Expand All @@ -39,13 +39,14 @@ import com.google.jetpackcamera.model.proto.DarkMode as DarkModeProto
import com.google.jetpackcamera.model.proto.FlashMode as FlashModeProto
import com.google.jetpackcamera.model.proto.StabilizationMode as StabilizationModeProto
import com.google.jetpackcamera.model.proto.StreamConfig as StreamConfigProto
import com.google.jetpackcamera.settings.JcaSettings
import com.google.jetpackcamera.settings.SettingsRepository
import com.google.jetpackcamera.settings.model.CameraAppSettings
import javax.inject.Inject
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map

/**
* Implementation of [SettingsRepository] with locally stored settings.
* Implementation of [com.google.jetpackcamera.settings.SettingsRepository] with locally stored settings.
*/
class LocalSettingsRepository @Inject constructor(
private val jcaSettings: DataStore<JcaSettings>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 The Android Open Source Project
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.jetpackcamera.settings
package com.google.jetpackcamera.data.settingsdatastore

import com.google.jetpackcamera.settings.SettingsRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand Down
Loading
Loading