Skip to content
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

Camera UI fixes #348

Merged
merged 10 commits into from Oct 6, 2022
Merged

Camera UI fixes #348

merged 10 commits into from Oct 6, 2022

Conversation

KryptKode
Copy link
Contributor

Notes

  • fix the back button bug that prevented exiting the app
  • remove change bounds animation
  • handle storage permissions
    • handle requesting READ_MEDIA_IMAGES and READ_MEDIA_VIDEO for Android 13+
    • request WRITE_EXTERNAL_STORAGE for Android 12 and below
    • set the permission WRITE_EXTERNAL_STORAGE to maxSdkVersion=32 in the AndroidManifest
  • update CameraX to 1.2.0-beta02
  • update top layout and 1x1 and full screen icons

- handle requesting READ_MEDIA_IMAGES and READ_MEDIA_VIDEO for Android 13+
- request WRITE_EXTERNAL_STORAGE for Android 12 and below
- set the permission WRITE_EXTERNAL_STORAGE to maxSdkVersion=32 in the AndroidManifest
@tibbi
Copy link
Member

tibbi commented Sep 29, 2022

the shutter sound plays way too early, before the actual photo is taken. And the top menu after extending the aspect ratio or flashlight are still a bit lower than the main buttons on the main screen. Cant you just use the same margin there? I can see the 4:3 moving a bit after reselectingi t.

@tibbi
Copy link
Member

tibbi commented Sep 29, 2022

and capturing a video crashes right after start on my Android 11,
java.lang.IllegalArgumentException: Failed to determine if primary:DCIM/Camera/VID_20220929_091104.mp4 is child of primary:DCIM: java.io.FileNotFoundException: Missing file for primary:DCIM/Camera/VID_20220929_091104.mp4 at /storage/emulated/0/DCIM/Camera/VID_20220929_091104.mp4
at com.android.internal.content.FileSystemProvider.isChildDocument(FileSystemProvider.java:143)
at android.provider.DocumentsProvider.enforceTree(DocumentsProvider.java:228)
at android.provider.DocumentsProvider.openAssetFile(DocumentsProvider.java:1343)
at android.content.ContentProvider$Transport.openAssetFile(ContentProvider.java:543)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:286)
at android.os.Binder.execTransactInternal(Binder.java:1165)
at android.os.Binder.execTransact(Binder.java:1134)
2022-09-29 09:11:04.124 22913-22913/com.simplemobiletools.camera.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.simplemobiletools.camera.debug, PID: 22913
java.lang.IllegalArgumentException: Failed to determine if primary:DCIM/Camera/VID_20220929_091104.mp4 is child of primary:DCIM: java.io.FileNotFoundException: Missing file for primary:DCIM/Camera/VID_20220929_091104.mp4 at /storage/emulated/0/DCIM/Camera/VID_20220929_091104.mp4
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:153)
at android.content.ContentProviderProxy.openAssetFile(ContentProviderNative.java:727)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1835)
at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1650)
at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1597)
at com.simplemobiletools.camera.helpers.MediaOutputHelper.getFileDescriptorMediaOutput(MediaOutputHelper.kt:140)
at com.simplemobiletools.camera.helpers.MediaOutputHelper.getVideoMediaOutput(MediaOutputHelper.kt:79)
at com.simplemobiletools.camera.implementations.CameraXPreview.startRecording(CameraXPreview.kt:517)
at com.simplemobiletools.camera.implementations.CameraXPreview.toggleRecording(CameraXPreview.kt:506)
at com.simplemobiletools.camera.activities.MainActivity.handleShutter(MainActivity.kt:423)
at com.simplemobiletools.camera.activities.MainActivity.shutterPressed(MainActivity.kt:411)
at com.simplemobiletools.camera.activities.MainActivity.initButtons$lambda-6(MainActivity.kt:362)
at com.simplemobiletools.camera.activities.MainActivity.$r8$lambda$lY85W6e3V0bThE5d6acXvA3oJAM(Unknown Source:0)
at com.simplemobiletools.camera.activities.MainActivity$$ExternalSyntheticLambda11.onClick(Unknown Source:2)
at android.view.View.performClick(View.java:7520)
at android.view.View.performClickInternal(View.java:7489)
at android.view.View.access$3600(View.java:826)
at android.view.View$PerformClick.run(View.java:28555)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:233)
at android.app.ActivityThread.main(ActivityThread.java:8068)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)

@tibbi
Copy link
Member

tibbi commented Sep 29, 2022

it actually isnt crashing on a fresh install, try checking an upgrade from the old to new version, there are still many people using the old one. That bottom shadow seems to be higher during videos without a reason than at photos. Guess moving the recording time above the shutter button would help, theres still enough place.

@KryptKode
Copy link
Contributor Author

Hi @tibbi,

  1. About the top margin
    It is not very visible on my end. Both the main icons and the aspect ratio and flashlight selector icons have been added to a root FrameLayout and the top margin is applied to that.

The only difference I noticed is in the height. So I will set them to be the same height and hopefully, this would correct what you observed.

  1. Shutter sound
    Would you want the shutter sound to play at the point when the picture is saved? I am afraid that would be too late. OnePlus app plays it as soon as the capture button is clicked alongside the blinking animation of the screen.

- handle exception when creating media output
- if only one resolution is supported, no need to restart the camera
@tibbi
Copy link
Member

tibbi commented Sep 30, 2022

shutter sound has to be played at exact same time as the photo is captured. I moved the phone after hearing the sound and the images were blurry.

@tibbi
Copy link
Member

tibbi commented Oct 5, 2022

it crashes if I use Video mode and click on HD and pick any resolution (4 items available), then click on Photo and click on the aspect ratio picker. Guess it will be because the 16:9 ratio is hidden and you count on 4 items being visible or so.
Process: com.simplemobiletools.camera.debug, PID: 31898
java.lang.IndexOutOfBoundsException: getChildDrawingOrder() returned invalid index 3 (child count is 3)
at android.view.ViewGroup.getAndVerifyPreorderedIndex(ViewGroup.java:2125)
at android.view.ViewGroup.gatherTransparentRegion(ViewGroup.java:7285)
at android.view.ViewGroup.gatherTransparentRegion(ViewGroup.java:7288)
at android.view.ViewGroup.gatherTransparentRegion(ViewGroup.java:7288)
at android.view.ViewGroup.gatherTransparentRegion(ViewGroup.java:7288)
at android.view.ViewGroup.gatherTransparentRegion(ViewGroup.java:7288)
at android.view.ViewGroup.gatherTransparentRegion(ViewGroup.java:7288)
at android.view.ViewGroup.gatherTransparentRegion(ViewGroup.java:7288)
at android.view.ViewGroup.gatherTransparentRegion(ViewGroup.java:7288)
at com.android.internal.policy.DecorView.gatherTransparentRegion(DecorView.java:361)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3271)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2206)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8763)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1352)
at android.view.Choreographer.doCallbacks(Choreographer.java:1149)
at android.view.Choreographer.doFrame(Choreographer.java:1049)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1333)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:233)
at android.app.ActivityThread.main(ActivityThread.java:8068)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)

@@ -606,7 +631,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
toggle_flash.beVisible()
} else {
toggle_flash.beInvisible()
toggle_flash.setImageResource(R.drawable.ic_flash_off_vector)
toggle_flash.icon = AppCompatResources.getDrawable(this, R.drawable.ic_flash_off_vector)
Copy link
Member

@tibbi tibbi Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any specific reason for using compat on some places? Just removing Android Studio warnings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No specific reason. Just an old habit.
Since we have minSDK 29, we can just call getDrawable but then we have the warning on Android Studio.
Do you want me to change this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you dont need to call any drawable, just set image resource directly, like it used to be

- this seems like a bug on the MaterialToggleGroup; for example, when 4 items are added to it and removed and later on 3 items added, it will crash
- the only feasible fix is to create a new MaterialToggleGroup when displaying the options
- calling invalidate, removeAllViews, etc do not work
@tibbi
Copy link
Member

tibbi commented Oct 6, 2022

alright, looks good now, will do more testing on different devices and see how it goes :) Thanks

@tibbi tibbi merged commit 879251e into SimpleMobileTools:master Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants