-
Notifications
You must be signed in to change notification settings - Fork 74
Fix blank Settings screen after process recreation #576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
12bc536
7ef0a53
5622123
84277bf
684fb6c
4124f93
477a4b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,7 @@ import com.google.jetpackcamera.core.common.FilePathGenerator | |||||||||||||||||||||||||||||||||||||
| import com.google.jetpackcamera.data.camera.CameraLaunchConfigProvider | ||||||||||||||||||||||||||||||||||||||
| import com.google.jetpackcamera.data.camera.CameraSystemRepository | ||||||||||||||||||||||||||||||||||||||
| import com.google.jetpackcamera.data.camera.CameraXCameraSystemRepository | ||||||||||||||||||||||||||||||||||||||
| import com.google.jetpackcamera.settings.ConstraintsRepository | ||||||||||||||||||||||||||||||||||||||
| import com.google.jetpackcamera.settings.SettingsRepository | ||||||||||||||||||||||||||||||||||||||
| import dagger.Module | ||||||||||||||||||||||||||||||||||||||
| import dagger.Provides | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -49,18 +50,28 @@ internal object CameraModule { | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| @Provides | ||||||||||||||||||||||||||||||||||||||
| @ActivityRetainedScoped | ||||||||||||||||||||||||||||||||||||||
| fun providesCameraSystemRepository( | ||||||||||||||||||||||||||||||||||||||
| fun providesCameraXCameraSystemRepository( | ||||||||||||||||||||||||||||||||||||||
| cameraXCameraSystemProvider: Provider<CameraXCameraSystem>, | ||||||||||||||||||||||||||||||||||||||
| settingsRepository: SettingsRepository, | ||||||||||||||||||||||||||||||||||||||
| launchConfigProvider: CameraLaunchConfigProvider, | ||||||||||||||||||||||||||||||||||||||
| @DefaultCoroutineScope scope: CoroutineScope | ||||||||||||||||||||||||||||||||||||||
| ): CameraSystemRepository = CameraXCameraSystemRepository( | ||||||||||||||||||||||||||||||||||||||
| ): CameraXCameraSystemRepository = CameraXCameraSystemRepository( | ||||||||||||||||||||||||||||||||||||||
| cameraXCameraSystemProvider = cameraXCameraSystemProvider, | ||||||||||||||||||||||||||||||||||||||
| settingsRepository = settingsRepository, | ||||||||||||||||||||||||||||||||||||||
| launchConfigProvider = launchConfigProvider, | ||||||||||||||||||||||||||||||||||||||
| scope = scope | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| @Provides | ||||||||||||||||||||||||||||||||||||||
| fun providesCameraSystemRepository( | ||||||||||||||||||||||||||||||||||||||
| repository: CameraXCameraSystemRepository | ||||||||||||||||||||||||||||||||||||||
| ): CameraSystemRepository = repository | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| @Provides | ||||||||||||||||||||||||||||||||||||||
| fun providesConstraintsRepository( | ||||||||||||||||||||||||||||||||||||||
| repository: CameraXCameraSystemRepository | ||||||||||||||||||||||||||||||||||||||
| ): ConstraintsRepository = repository | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+65
to
+73
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following the repository style guide, these new provides methods should also be marked
Suggested change
References
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| @Provides | ||||||||||||||||||||||||||||||||||||||
| @ActivityRetainedScoped | ||||||||||||||||||||||||||||||||||||||
| fun providesCameraXCameraSystem( | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
| package com.google.jetpackcamera.settings.testing | ||
|
|
||
| import com.google.jetpackcamera.settings.ConstraintsRepository | ||
| import com.google.jetpackcamera.settings.model.CameraSystemConstraints | ||
| import kotlinx.coroutines.flow.MutableStateFlow | ||
| import kotlinx.coroutines.flow.StateFlow | ||
| import kotlinx.coroutines.flow.asStateFlow | ||
|
|
||
| class FakeConstraintsRepository( | ||
| initialConstraints: CameraSystemConstraints? = null | ||
| ) : ConstraintsRepository { | ||
| private val _systemConstraints = MutableStateFlow(initialConstraints) | ||
| override val systemConstraints: StateFlow<CameraSystemConstraints?> = | ||
| _systemConstraints.asStateFlow() | ||
|
|
||
| fun setSystemConstraints(systemConstraints: CameraSystemConstraints?) { | ||
| _systemConstraints.value = systemConstraints | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ package com.google.jetpackcamera.permissions.navigation | |
|
|
||
| import androidx.lifecycle.SavedStateHandle | ||
| import androidx.navigation.NavController | ||
| import androidx.navigation.NavDestination | ||
| import androidx.navigation.NavGraphBuilder | ||
| import androidx.navigation.NavOptionsBuilder | ||
| import androidx.navigation.NavType | ||
|
|
@@ -79,6 +80,8 @@ fun NavGraphBuilder.permissionsScreen( | |
| } | ||
| } | ||
|
|
||
| fun NavDestination.isPermissionsRoute(): Boolean = route?.substringBefore('?') == BASE_ROUTE_DEF | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the repository style guide, all non-private members must have KDoc documentation. Please add a KDoc comment for /**
* Returns whether this [NavDestination] corresponds to the permissions route.
*/
fun NavDestination.isPermissionsRoute(): Boolean = route?.substringBefore('?') == BASE_ROUTE_DEFReferences
|
||
|
|
||
| fun NavOptionsBuilder.popUpToPermissions() { | ||
| popUpTo(BASE_ROUTE_DEF) { | ||
| inclusive = true | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the repository style guide, we should use the most restrictive visibility modifier possible. Since
CameraModuleis aninternal object, this provides method should be markedinternal.References