-
Notifications
You must be signed in to change notification settings - Fork 71
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
Refactor - Camera UI Adaptation for Foldable Devices and Camera Initialization #52
Open
yongsuk44
wants to merge
19
commits into
android:main
Choose a base branch
from
yongsuk44:refactor/fold-camera
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d294974
Refactor navigation logic on the cameraScreen
yongsuk44 b649798
Merge branch 'main' into refactor/camera
yongsuk44 c646e8f
Refactor camera initialization and adapt camera for foldable devices
yongsuk44 2198cf3
Merge branch 'main' into refactor/fold-camera
yongsuk44 93b33e0
Refactoring Camera Ratio and CameraEvent Based on Device Display Status
yongsuk44 3fd7617
Fixed Spotless
yongsuk44 e4a5f4b
Remove code that locks screen orientation in camera composable
yongsuk44 9daf0dc
Added ROTATION_ANIMATION_SEAMLESS
romanofranz be4b51f
Changed rotation to JUMPCUT
romanofranz dea1ac9
Add WindowManager missing dependency
romanofranz 89539ae
Modify support four orientation
yongsuk44 4d79351
Optimize ReComposition for
yongsuk44 24aae54
Merge branch 'main' into refactor/fold-camera
yongsuk44 5af11c1
Move screenOrientation from Manifest to MainActivity
yongsuk44 fa637d1
Merge branch 'main' into refactor/fold-camera
yongsuk44 005fc7f
Strong skipping mode enable
yongsuk44 a18b2d3
Refactor Camera logic
yongsuk44 c522faf
Refactor CameraUseCase init logic
yongsuk44 4c3d1ea
Remove empty files and compiler modes
yongsuk44 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
app/src/main/java/com/google/android/samples/socialite/di/CameraModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright (C) 2024 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.android.samples.socialite.di | ||
|
||
import android.content.ContentValues | ||
import android.content.Context | ||
import android.os.Build | ||
import android.provider.MediaStore | ||
import androidx.camera.core.ImageCapture.OutputFileOptions | ||
import androidx.camera.video.MediaStoreOutputOptions | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
import java.text.SimpleDateFormat | ||
import java.util.Locale | ||
import javax.inject.Qualifier | ||
import javax.inject.Singleton | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class ImageContentValues | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class VideoContentValues | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object CameraModule { | ||
|
||
@Provides | ||
@ImageContentValues | ||
fun providesImageContentValues(): ContentValues = ContentValues().apply { | ||
val name = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS", Locale.US) | ||
.format(System.currentTimeMillis()) | ||
|
||
put(MediaStore.Images.Media.DISPLAY_NAME, name) | ||
put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg") | ||
|
||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) { | ||
put(MediaStore.Images.Media.RELATIVE_PATH, "Pictures/SociaLite") | ||
} | ||
} | ||
|
||
@Provides | ||
@VideoContentValues | ||
fun providesVideoContentValues(): ContentValues = ContentValues().apply { | ||
val name = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS", Locale.US) | ||
.format(System.currentTimeMillis()) + ".mp4" | ||
|
||
put(MediaStore.Video.Media.DISPLAY_NAME, name) | ||
put(MediaStore.Video.Media.MIME_TYPE, "video/mp4") | ||
|
||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) { | ||
put(MediaStore.Video.Media.RELATIVE_PATH, "Movies/SociaLite") | ||
} | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun providesImageCaptureOutputFileOptions( | ||
@ApplicationContext context: Context, | ||
@ImageContentValues contentValues: ContentValues, | ||
): OutputFileOptions = | ||
OutputFileOptions.Builder( | ||
context.contentResolver, | ||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, | ||
contentValues, | ||
).build() | ||
|
||
@Provides | ||
@Singleton | ||
fun providesMediaStoreOutputOptions( | ||
@ApplicationContext context: Context, | ||
@VideoContentValues contentValues: ContentValues, | ||
): MediaStoreOutputOptions = | ||
MediaStoreOutputOptions.Builder( | ||
context.contentResolver, | ||
MediaStore.Video.Media.EXTERNAL_CONTENT_URI, | ||
) | ||
.setContentValues(contentValues) | ||
.build() | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/google/android/samples/socialite/di/ManagerModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2024 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.android.samples.socialite.di | ||
|
||
import com.google.android.samples.socialite.util.DisplayFeaturesMonitor | ||
import com.google.android.samples.socialite.util.DisplayFeaturesMonitorImpl | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.components.ActivityComponent | ||
|
||
@Module | ||
@InstallIn(ActivityComponent::class) | ||
abstract class ManagerModule { | ||
|
||
@Binds | ||
abstract fun bindDisplayFeaturesMonitor(displayFeaturesMonitor: DisplayFeaturesMonitorImpl): DisplayFeaturesMonitor | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/google/android/samples/socialite/di/UseCaseModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2024 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.android.samples.socialite.di | ||
|
||
import com.google.android.samples.socialite.domain.CameraUseCase | ||
import com.google.android.samples.socialite.domain.CameraXUseCase | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.components.ViewModelComponent | ||
|
||
@Module | ||
@InstallIn(ViewModelComponent::class) | ||
interface UseCaseModule { | ||
|
||
@Binds | ||
fun bindsCameraUseCase(cameraXUseCase: CameraXUseCase): CameraUseCase | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is this change related to this PR on Camera UI? If not, I'd prefer it not be part of this PR.
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.
It wasn't related to the Camera UI.
Thank you for your feedback. 😀