animate shutter icon

This commit is contained in:
darthpaul 2022-09-20 16:51:23 +01:00
parent f02d0b3ae7
commit d9fbc17bff
8 changed files with 82 additions and 16 deletions

View File

@ -460,7 +460,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
}
private fun initPhotoMode() {
shutter.setImageResource(R.drawable.ic_shutter_vector)
shutter.setImageResource(R.drawable.ic_shutter_animated)
mPreview?.initPhotoMode()
setupPreviewImage(true)
selectPhotoTab()

View File

@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="@dimen/icon_size"
android:height="@dimen/icon_size"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:fillColor="#ffffff"
android:fillType="evenOdd"
android:pathData="M256,485C382.47,485 485,382.47 485,256C485,129.53 382.47,27 256,27C129.53,27 27,129.53 27,256C27,382.47 129.53,485 256,485ZM256,465C370.32,465 463,371.43 463,256C463,140.57 370.32,47 256,47C141.68,47 49,140.57 49,256C49,371.43 141.68,465 256,465Z" />
<path
android:name="inner"
android:fillColor="#ffffff"
android:fillType="evenOdd"
android:pathData="M255.5,426C349.67,426 426,349.67 426,255.5C426,161.34 349.67,85 255.5,85C161.34,85 85,161.34 85,255.5C85,349.67 161.34,426 255.5,426ZM255.5,402C336.41,402 402,336.41 402,255.5C402,174.59 336.41,109 255.5,109C174.59,109 109,174.59 109,255.5C109,336.41 174.59,402 255.5,402Z" />
<path
android:fillColor="#ffffff"
android:pathData="M105,255.5a150.5,147.5 0,1 0,301 0a150.5,147.5 0,1 0,-301 0z" />
</vector>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<animated-selector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="@dimen/icon_size"
android:height="@dimen/icon_size"
android:viewportWidth="168"
android:viewportHeight="168">
<item
android:id="@+id/pressed"
android:drawable="@drawable/ic_shutter"
android:state_pressed="true" />
<item
android:id="@+id/unpressed"
android:drawable="@drawable/ic_shutter" />
<transition
android:drawable="@drawable/shutter_pressed_to_unpressed"
android:fromId="@id/pressed"
android:toId="@id/unpressed" />
<transition
android:drawable="@drawable/shutter_unpressed_to_pressed"
android:fromId="@id/unpressed"
android:toId="@id/pressed" />
</animated-selector>

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M9.4,10.5l4.77,-8.26C13.47,2.09 12.75,2 12,2c-2.4,0 -4.6,0.85 -6.32,2.25l3.66,6.35 0.06,-0.1zM21.54,9c-0.92,-2.92 -3.15,-5.26 -6,-6.34L11.88,9h9.66zM21.8,10h-7.49l0.29,0.5 4.76,8.25C21,16.97 22,14.61 22,12c0,-0.69 -0.07,-1.35 -0.2,-2zM8.54,12l-3.9,-6.75C3.01,7.03 2,9.39 2,12c0,0.69 0.07,1.35 0.2,2h7.49l-1.15,-2zM2.46,15c0.92,2.92 3.15,5.26 6,6.34L12.12,15L2.46,15zM13.73,15l-3.9,6.76c0.7,0.15 1.42,0.24 2.17,0.24 2.4,0 4.6,-0.85 6.32,-2.25l-3.66,-6.35 -0.93,1.6z"/>
</vector>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:drawable="@drawable/ic_shutter">
<target android:name="inner">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="3"
android:interpolator="@android:interpolator/decelerate_cubic"
android:propertyName="fillColor"
android:valueFrom="@android:color/transparent"
android:valueTo="@android:color/white"
android:valueType="colorType" />
</aapt:attr>
</target>
</animated-vector>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:drawable="@drawable/ic_shutter">
<target android:name="inner">
<aapt:attr name="android:animation">
<objectAnimator
android:duration="3"
android:interpolator="@android:interpolator/decelerate_cubic"
android:propertyName="fillColor"
android:valueFrom="@android:color/white"
android:valueTo="@android:color/transparent"
android:valueType="colorType" />
</aapt:attr>
</target>
</animated-vector>

View File

@ -32,9 +32,7 @@
<include layout="@layout/layout_top" />
<include
layout="@layout/layout_media_size"
/>
<include layout="@layout/layout_media_size" />
<include
layout="@layout/layout_flash"
@ -98,11 +96,11 @@
<ImageView
android:id="@+id/shutter"
android:layout_width="@dimen/icon_size"
android:layout_height="@dimen/icon_size"
android:layout_width="@dimen/large_icon_size"
android:layout_height="@dimen/large_icon_size"
android:layout_marginBottom="@dimen/small_margin"
android:contentDescription="@string/shutter"
android:src="@drawable/ic_shutter_vector"
android:src="@drawable/ic_shutter_animated"
app:layout_constraintBottom_toTopOf="@id/video_rec_curr_timer"
app:layout_constraintEnd_toStartOf="@id/last_photo_video_preview"
app:layout_constraintStart_toEndOf="@id/toggle_camera"

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="icon_size">56dp</dimen>
<dimen name="large_icon_size">72dp</dimen>
<dimen name="top_icon_size">48dp</dimen>
<dimen name="toggle_icon_size">24dp</dimen>
<dimen name="tab_indicator_margin">10dp</dimen>