Aperture: Add custom shutter button style and animation
Change-Id: Id5d6d158ade0ff730dd4995d78c485f667389015
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index d95ec77..00569e5 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -305,6 +305,13 @@
flipCameraButton.setOnClickListener { flipCamera() }
shutterButton.setOnClickListener {
+ // Shutter animation
+ ValueAnimator.ofInt(convertDpToPx(4), convertDpToPx(16), convertDpToPx(4)).apply {
+ addUpdateListener {
+ shutterButton.setPadding(it.animatedValue as Int)
+ }
+ }.start()
+
startTimerAndRun {
when (cameraMode) {
CameraMode.PHOTO -> takePhoto()
diff --git a/app/src/main/res/drawable/ic_circle.xml b/app/src/main/res/drawable/ic_circle.xml
index 55d5d65..7719e6e 100644
--- a/app/src/main/res/drawable/ic_circle.xml
+++ b/app/src/main/res/drawable/ic_circle.xml
@@ -1,10 +1,4 @@
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:tint="#000000"
- android:viewportWidth="24"
- android:viewportHeight="24">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2z" />
-</vector>
+<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/shutter_button_background.xml b/app/src/main/res/drawable/shutter_button_background.xml
new file mode 100644
index 0000000..5ade199
--- /dev/null
+++ b/app/src/main/res/drawable/shutter_button_background.xml
@@ -0,0 +1,5 @@
+<?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 a309bf0..ba2e0a1 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -203,17 +203,18 @@
<ImageButton
android:id="@+id/shutterButton"
- style="@style/ApertureBottomBarButton"
- android:layout_width="100dp"
- android:layout_height="100dp"
- android:background="?attr/selectableItemBackgroundBorderless"
+ style="@style/ApertureShutterButton"
+ android:layout_width="75dp"
+ android:layout_height="75dp"
android:contentDescription="@string/shutter_button_description"
- android:scaleType="fitXY"
+ android:padding="4dp"
+ android:scaleType="center"
+ android:src="@drawable/ic_circle"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
- app:srcCompat="@drawable/ic_circle" />
+ app:tint="?colorSecondaryContainer" />
<androidx.cardview.widget.CardView
android:layout_width="60dp"
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 0b00a1f..44834fc 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -31,12 +31,9 @@
<item name="android:padding">0dp</item>
</style>
- <!-- Bottom bar icons theme -->
- <style name="ApertureBottomBarButton">
- <item name="tint">?attr/colorPrimary</item>
- <item name="backgroundTint">?attr/colorOnPrimary</item>
- <item name="android:padding">0dp</item>
- <item name="android:scaleType">fitXY</item>
+ <!-- Shutter button theme -->
+ <style name="ApertureShutterButton">
+ <item name="android:background">@drawable/shutter_button_background</item>
</style>
<!-- Flip camera button theme -->