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

Fix crash when capture button drawable has an unexpected type #514

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Changes from all commits
Commits
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
17 changes: 15 additions & 2 deletions app/src/main/java/app/grapheneos/camera/capturer/VideoCapturer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.content.Context
import android.content.pm.PackageManager.PERMISSION_GRANTED
import android.graphics.Bitmap
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.StateListDrawable
import android.location.Location
import android.media.MediaMetadataRetriever
import android.net.Uri
Expand Down Expand Up @@ -273,7 +274,13 @@ class VideoCapturer(private val mActivity: MainActivity) {
// TODO: Uncomment this once the main indicator UI gets implemented
// mActivity.micOffIcon.visibility = View.GONE

val gd: GradientDrawable = mActivity.captureButton.drawable as GradientDrawable
val drawable = mActivity.captureButton.drawable

val gd: GradientDrawable = if (drawable is StateListDrawable) {
drawable.current as GradientDrawable
} else {
drawable as GradientDrawable
}

val animator = ValueAnimator.ofFloat(dp16, dp8)

Expand Down Expand Up @@ -317,7 +324,13 @@ class VideoCapturer(private val mActivity: MainActivity) {

private fun afterRecordingStops() {

val gd: GradientDrawable = mActivity.captureButton.drawable as GradientDrawable
val drawable = mActivity.captureButton.drawable

val gd: GradientDrawable = if (drawable is StateListDrawable) {
drawable.current as GradientDrawable
} else {
drawable as GradientDrawable
}

val animator = ValueAnimator.ofFloat(dp8, dp16)

Expand Down