Aperture: Import new shutter AVDs
Change-Id: I8fa1064583eb12c3c50906bb58da1475adfd6532
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index 75e324d..e9cf14e 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -198,6 +198,18 @@
}
}
+ enum class ShutterAnimation(val resourceId: Int) {
+ InitPhoto(R.drawable.avd_photo_capture),
+ InitVideo(R.drawable.avd_mode_video_photo),
+
+ PhotoCapture(R.drawable.avd_photo_capture),
+ PhotoToVideo(R.drawable.avd_mode_photo_video),
+
+ VideoToPhoto(R.drawable.avd_mode_video_photo),
+ VideoStart(R.drawable.avd_video_start),
+ VideoEnd(R.drawable.avd_video_end),
+ }
+
@SuppressLint("ClickableViewAccessibility")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -343,13 +355,25 @@
flipCameraButton.setOnClickListener { flipCamera() }
+ // Initialize shutter drawable
+ if (cameraMode == CameraMode.PHOTO) {
+ startShutterAnimation(ShutterAnimation.InitPhoto)
+ } else if (cameraMode == CameraMode.VIDEO) {
+ startShutterAnimation(ShutterAnimation.InitVideo)
+ }
+
shutterButton.setOnClickListener {
// Shutter animation
- ValueAnimator.ofInt(convertDpToPx(4), convertDpToPx(16), convertDpToPx(4)).apply {
- addUpdateListener {
- shutterButton.setPadding(it.animatedValue as Int)
+ when (cameraMode) {
+ CameraMode.PHOTO -> startShutterAnimation(ShutterAnimation.PhotoCapture)
+ CameraMode.VIDEO -> {
+ if (!cameraController.isRecording) {
+ // TODO: This animation doesn't work
+// startShutterAnimation(ShutterAnimation.VideoStart)
+ }
}
- }.start()
+ else -> {}
+ }
startTimerAndRun {
when (cameraMode) {
@@ -438,6 +462,23 @@
}
}
+ private fun startShutterAnimation(shutterAnimation: ShutterAnimation) {
+ // Get appropriate drawable
+ val drawable = ContextCompat.getDrawable(
+ this, shutterAnimation.resourceId
+ ) as AnimatedVectorDrawable
+
+ // Update current drawable
+ shutterButton.setImageDrawable(drawable)
+
+ // Start or reset animation
+ when (shutterAnimation) {
+ ShutterAnimation.InitPhoto,
+ ShutterAnimation.InitVideo -> drawable.reset()
+ else -> drawable.start()
+ }
+ }
+
private fun takePhoto() {
// Bail out if a photo is already being taken
if (isTakingPhoto) {
@@ -516,6 +557,8 @@
}
} else if (it is VideoRecordEvent.Finalize) {
runOnUiThread {
+ // TODO: This animation doesn't work
+// startShutterAnimation(ShutterAnimation.VideoEnd)
recordChip.isVisible = false
}
cameraSoundsUtils.playStopVideoRecording()
@@ -665,6 +708,24 @@
return
}
+ when (cameraMode) {
+ CameraMode.PHOTO -> {
+ if (this.cameraMode == CameraMode.VIDEO) {
+ startShutterAnimation(ShutterAnimation.VideoToPhoto)
+ } else {
+ startShutterAnimation(ShutterAnimation.InitPhoto)
+ }
+ }
+ CameraMode.VIDEO -> {
+ if (this.cameraMode == CameraMode.PHOTO) {
+ startShutterAnimation(ShutterAnimation.PhotoToVideo)
+ } else {
+ startShutterAnimation(ShutterAnimation.InitVideo)
+ }
+ }
+ else -> {}
+ }
+
sharedPreferences.lastCameraMode = cameraMode
bindCameraUseCases()
}
diff --git a/app/src/main/res/animator/photo_capture.xml b/app/src/main/res/animator/photo_capture.xml
new file mode 100644
index 0000000..9dabab9
--- /dev/null
+++ b/app/src/main/res/animator/photo_capture.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <objectAnimator
+ android:duration="100"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="scaleX"
+ android:repeatCount="1"
+ android:repeatMode="reverse"
+ android:valueFrom="1.0"
+ android:valueTo="0.625" />
+
+ <objectAnimator
+ android:duration="100"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="scaleY"
+ android:repeatCount="1"
+ android:repeatMode="reverse"
+ android:valueFrom="1.0"
+ android:valueTo="0.625" />
+</set>
diff --git a/app/src/main/res/animator/photo_video_color.xml b/app/src/main/res/animator/photo_video_color.xml
new file mode 100644
index 0000000..41b1c6b
--- /dev/null
+++ b/app/src/main/res/animator/photo_video_color.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <objectAnimator
+ android:duration="300"
+ android:propertyName="fillColor"
+ android:valueFrom="@color/gray_60"
+ android:valueTo="@color/white" />
+</set>
diff --git a/app/src/main/res/animator/photo_video_scale.xml b/app/src/main/res/animator/photo_video_scale.xml
new file mode 100644
index 0000000..122e1c1
--- /dev/null
+++ b/app/src/main/res/animator/photo_video_scale.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <objectAnimator
+ android:duration="300"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="scaleX"
+ android:valueFrom="1.0"
+ android:valueTo="0.3125" />
+
+ <objectAnimator
+ android:duration="300"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="scaleY"
+ android:valueFrom="1.0"
+ android:valueTo="0.3125" />
+</set>
diff --git a/app/src/main/res/animator/video_end_cap_alpha.xml b/app/src/main/res/animator/video_end_cap_alpha.xml
new file mode 100644
index 0000000..1384750
--- /dev/null
+++ b/app/src/main/res/animator/video_end_cap_alpha.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <objectAnimator
+ android:duration="300"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="fillAlpha"
+ android:valueFrom="0"
+ android:valueTo="1" />
+</set>
diff --git a/app/src/main/res/animator/video_end_cap_scale.xml b/app/src/main/res/animator/video_end_cap_scale.xml
new file mode 100644
index 0000000..9eaed72
--- /dev/null
+++ b/app/src/main/res/animator/video_end_cap_scale.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <objectAnimator
+ android:duration="300"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="scaleX"
+ android:valueFrom="0.0625"
+ android:valueTo="0.3125" />
+
+ <objectAnimator
+ android:duration="300"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="scaleY"
+ android:valueFrom="0.0625"
+ android:valueTo="0.3125" />
+</set>
diff --git a/app/src/main/res/animator/video_end_rec_square.xml b/app/src/main/res/animator/video_end_rec_square.xml
new file mode 100644
index 0000000..048f18c
--- /dev/null
+++ b/app/src/main/res/animator/video_end_rec_square.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <objectAnimator
+ android:duration="300"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="pathData"
+ android:valueFrom="M27 27H45V45H27V27Z"
+ android:valueTo="M 13.373 13.373 C 25.869 0.876 46.131 0.876 58.627 13.373 C 71.124 25.869 71.124 46.131 58.627 58.627 C 46.131 71.124 25.869 71.124 13.373 58.627 C 0.876 46.131 0.876 25.869 13.373 13.373 Z"
+ android:valueType="pathType" />
+</set>
diff --git a/app/src/main/res/animator/video_photo_color.xml b/app/src/main/res/animator/video_photo_color.xml
new file mode 100644
index 0000000..159cd19
--- /dev/null
+++ b/app/src/main/res/animator/video_photo_color.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <objectAnimator
+ android:duration="300"
+ android:propertyName="fillColor"
+ android:valueFrom="@color/white"
+ android:valueTo="@color/gray_60" />
+</set>
diff --git a/app/src/main/res/animator/video_photo_scale.xml b/app/src/main/res/animator/video_photo_scale.xml
new file mode 100644
index 0000000..51cb26c
--- /dev/null
+++ b/app/src/main/res/animator/video_photo_scale.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <objectAnimator
+ android:duration="300"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="scaleX"
+ android:valueFrom="0.3125"
+ android:valueTo="1.0" />
+
+ <objectAnimator
+ android:duration="300"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="scaleY"
+ android:valueFrom="0.3125"
+ android:valueTo="1.0" />
+</set>
diff --git a/app/src/main/res/animator/video_start_cap_alpha.xml b/app/src/main/res/animator/video_start_cap_alpha.xml
new file mode 100644
index 0000000..df92c47
--- /dev/null
+++ b/app/src/main/res/animator/video_start_cap_alpha.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <objectAnimator
+ android:duration="300"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="fillAlpha"
+ android:valueFrom="1"
+ android:valueTo="0" />
+</set>
diff --git a/app/src/main/res/animator/video_start_cap_scale.xml b/app/src/main/res/animator/video_start_cap_scale.xml
new file mode 100644
index 0000000..81a25ea
--- /dev/null
+++ b/app/src/main/res/animator/video_start_cap_scale.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <objectAnimator
+ android:duration="300"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="scaleX"
+ android:valueFrom="0.3125"
+ android:valueTo="0.0625" />
+
+ <objectAnimator
+ android:duration="300"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="scaleY"
+ android:valueFrom="0.3125"
+ android:valueTo="0.0625" />
+</set>
diff --git a/app/src/main/res/animator/video_start_rec_square.xml b/app/src/main/res/animator/video_start_rec_square.xml
new file mode 100644
index 0000000..f92bb8c
--- /dev/null
+++ b/app/src/main/res/animator/video_start_rec_square.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <objectAnimator
+ android:duration="300"
+ android:interpolator="@android:interpolator/fast_out_slow_in"
+ android:propertyName="pathData"
+ android:valueFrom="M 13.373 13.373 C 25.869 0.876 46.131 0.876 58.627 13.373 C 71.124 25.869 71.124 46.131 58.627 58.627 C 46.131 71.124 25.869 71.124 13.373 58.627 C 0.876 46.131 0.876 25.869 13.373 13.373 Z"
+ android:valueTo="M27 27H45V45H27V27Z"
+ android:valueType="pathType" />
+</set>
diff --git a/app/src/main/res/drawable/avd_mode_photo_video.xml b/app/src/main/res/drawable/avd_mode_photo_video.xml
new file mode 100644
index 0000000..995ed6a
--- /dev/null
+++ b/app/src/main/res/drawable/avd_mode_photo_video.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:drawable="@drawable/ic_shutter_base">
+ <target
+ android:name="capture"
+ android:animation="@animator/photo_video_scale"/>
+ <target
+ android:name="capture_src"
+ android:animation="@animator/photo_video_color"/>
+</animated-vector>
diff --git a/app/src/main/res/drawable/avd_mode_video_photo.xml b/app/src/main/res/drawable/avd_mode_video_photo.xml
new file mode 100644
index 0000000..48e8059
--- /dev/null
+++ b/app/src/main/res/drawable/avd_mode_video_photo.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:drawable="@drawable/ic_shutter_base">
+ <target
+ android:name="capture"
+ android:animation="@animator/video_photo_scale" />
+ <target
+ android:name="capture_src"
+ android:animation="@animator/video_photo_color" />
+</animated-vector>
diff --git a/app/src/main/res/drawable/avd_photo_capture.xml b/app/src/main/res/drawable/avd_photo_capture.xml
new file mode 100644
index 0000000..0495155
--- /dev/null
+++ b/app/src/main/res/drawable/avd_photo_capture.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:drawable="@drawable/ic_shutter_base">
+ <target
+ android:name="capture"
+ android:animation="@animator/photo_capture"/>
+ <target
+ android:name="record"
+ android:animation="@animator/photo_capture"/>
+</animated-vector>
diff --git a/app/src/main/res/drawable/avd_video_end.xml b/app/src/main/res/drawable/avd_video_end.xml
new file mode 100644
index 0000000..fcbe2f0
--- /dev/null
+++ b/app/src/main/res/drawable/avd_video_end.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:drawable="@drawable/ic_shutter_base">
+ <target
+ android:name="capture"
+ android:animation="@animator/video_end_cap_scale" />
+ <target
+ android:name="capture_src"
+ android:animation="@animator/video_end_cap_alpha" />
+ <target
+ android:name="record_src"
+ android:animation="@animator/video_end_rec_square" />
+</animated-vector>
diff --git a/app/src/main/res/drawable/avd_video_start.xml b/app/src/main/res/drawable/avd_video_start.xml
new file mode 100644
index 0000000..37a2185
--- /dev/null
+++ b/app/src/main/res/drawable/avd_video_start.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:drawable="@drawable/ic_shutter_base">
+ <target
+ android:name="capture"
+ android:animation="@animator/video_start_cap_scale" />
+ <target
+ android:name="capture_src"
+ android:animation="@animator/video_start_cap_alpha" />
+ <target
+ android:name="record_src"
+ android:animation="@animator/video_start_rec_square" />
+</animated-vector>
diff --git a/app/src/main/res/drawable/ic_circle.xml b/app/src/main/res/drawable/ic_circle.xml
deleted file mode 100644
index 7719e6e..0000000
--- a/app/src/main/res/drawable/ic_circle.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
- <solid android:color="#000000" />
-</shape>
diff --git a/app/src/main/res/drawable/ic_shutter_base.xml b/app/src/main/res/drawable/ic_shutter_base.xml
new file mode 100644
index 0000000..8dde9fc
--- /dev/null
+++ b/app/src/main/res/drawable/ic_shutter_base.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ SPDX-FileCopyrightText: 2022 The LineageOS Project
+ SPDX-License-Identifier: Apache-2.0
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="72dp"
+ android:height="72dp"
+ android:viewportWidth="72"
+ android:viewportHeight="72">
+ <group android:name="backplate">
+ <path
+ android:fillColor="@color/gray_10"
+ android:fillType="evenOdd"
+ android:pathData="M70 36C70 54.7777 54.7777 70 36 70C17.2223 70 2 54.7777 2 36C2 17.2223 17.2223 2 36 2C54.7777 2 70 17.2223 70 36Z"
+ android:strokeWidth="4"
+ android:strokeColor="@android:color/white" />
+ </group>
+ <group
+ android:name="record"
+ android:pivotX="36"
+ android:pivotY="36"
+ android:scaleX="1.0"
+ android:scaleY="1.0">
+ <path
+ android:name="record_src"
+ android:fillColor="@color/rec_red"
+ android:fillType="evenOdd"
+ android:pathData="M4 36C4 18.3269 18.3269 4 36 4C53.6731 4 68 18.3269 68 36C68 53.6731 53.6731 68 36 68C18.3269 68 4 53.6731 4 36Z" />
+ </group>
+ <group
+ android:name="capture"
+ android:pivotX="36"
+ android:pivotY="36"
+ android:scaleX="1.0"
+ android:scaleY="1.0">
+ <path
+ android:name="capture_src"
+ android:fillColor="@color/gray_60"
+ android:fillType="evenOdd"
+ android:pathData="M68 36C68 53.6731 53.6731 68 36 68C18.3269 68 4 53.6731 4 36C4 18.3269 18.3269 4 36 4C53.6731 4 68 18.3269 68 36Z" />
+ </group>
+</vector>
diff --git a/app/src/main/res/drawable/shutter_button_background.xml b/app/src/main/res/drawable/shutter_button_background.xml
deleted file mode 100644
index 5ade199..0000000
--- a/app/src/main/res/drawable/shutter_button_background.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <solid android:color="?attr/colorPrimary" />
- <corners android:radius="50dp" />
-</shape>
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 287d1a4..ef25774 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -231,18 +231,15 @@
<ImageButton
android:id="@+id/shutterButton"
- style="@style/ApertureShutterButton"
+ android:background="@null"
android:layout_width="75dp"
android:layout_height="75dp"
android:contentDescription="@string/shutter_button_description"
- android:padding="4dp"
- android:scaleType="center"
- android:src="@drawable/ic_circle"
+ android:src="@drawable/avd_photo_capture"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- app:tint="?colorSecondaryContainer" />
+ app:layout_constraintTop_toTopOf="parent" />
<androidx.cardview.widget.CardView
android:layout_width="60dp"
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 79c8f5a..2a71369 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -8,5 +8,8 @@
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="grey">#FF888888</color>
+ <color name="gray_10">#FFF6FAFA</color>
+ <color name="gray_60">#FF2A3232</color>
<color name="dark_grey">#FF444444</color>
+ <color name="rec_red">#FFE95950</color>
</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 58ca9f0..675fb2b 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -58,9 +58,4 @@
<style name="ApertureModeSelectorButtonHighlight" parent="@style/ApertureModeSelectorButton">
<item name="android:backgroundTint">@color/camera_mode_selector_icon_highlight</item>
</style>
-
- <!-- Shutter button theme -->
- <style name="ApertureShutterButton">
- <item name="android:background">@drawable/shutter_button_background</item>
- </style>
</resources>
\ No newline at end of file