launcher: Round-trip gesture animation

This commit is contained in:
Jules Aguillon 2024-12-14 12:20:50 +01:00
parent 855b5359be
commit c59af9cf89
5 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,33 @@
<?xml version="1.0"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector android:name="vector" android:width="35dp" android:height="40dp" android:viewportWidth="35" android:viewportHeight="40">
<path android:name="trace" android:pathData="M 0 0" android:fillColor="#09b3f1" android:strokeColor="#09b3f1" android:strokeWidth="2" android:strokeLineCap="round"/>
</vector>
</aapt:attr>
<target android:name="trace">
<aapt:attr name="android:animation">
<set>
<objectAnimator android:propertyName="fillAlpha" android:duration="100" android:valueFrom="0" android:valueTo="1" android:valueType="floatType" android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator android:propertyName="strokeAlpha" android:duration="100" android:valueFrom="0" android:valueTo="1" android:valueType="floatType" android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:duration="350"
android:valueFrom="M 17.5 20.0 m 2,0 a 2,2 0 1,1 -4,0 a 2,2 0 1,1 4,0 M 17.5 20.0 L 17.5,20.0"
android:valueTo="M 31 4 m 2,0 a 2,2 0 1,1 -4,0 a 2,2 0 1,1 4,0 M 17.5 20.0 L 31,4"
android:valueType="pathType"
android:interpolator="@android:interpolator/linear_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="400"
android:duration="800"
android:valueFrom="M 31 4 m 2,0 a 2,2 0 1,1 -4,0 a 2,2 0 1,1 4,0 M 17.5 20.0 L 31,4"
android:valueTo="M 17.5 20.0 m 2,0 a 2,2 0 1,1 -4,0 a 2,2 0 1,1 4,0 M 17.5 20.0 L 31,4"
android:valueType="pathType"
android:interpolator="@android:interpolator/linear_out_slow_in"/>
<objectAnimator android:propertyName="fillAlpha" android:startOffset="900" android:duration="400" android:valueFrom="1" android:valueTo="0" android:valueType="floatType" android:interpolator="@android:interpolator/linear_out_slow_in"/>
<objectAnimator android:propertyName="strokeAlpha" android:startOffset="900" android:duration="400" android:valueFrom="1" android:valueTo="0" android:valueType="floatType" android:interpolator="@android:interpolator/linear_out_slow_in"/>
</set>
</aapt:attr>
</target>
</animated-vector>

View File

@ -0,0 +1,25 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="35dp"
android:height="40dp"
android:viewportWidth="35.0"
android:viewportHeight="40.0">
<path
android:pathData="M11.26,10.13L23.74,10.13A1.13,1.13 0,0 1,24.87 11.26L24.87,28.74A1.13,1.13 0,0 1,23.74 29.88L11.26,29.88A1.13,1.13 0,0 1,10.13 28.74L10.13,11.26A1.13,1.13 0,0 1,11.26 10.13z"
android:fillAlpha="1"
android:strokeColor="#404040"
android:fillColor="#333333"
android:strokeWidth="0.251"
android:strokeAlpha="1"/>
<path
android:pathData="m11.18,28.83l0,-0.54l2.9,0l0,0.54z"
android:fillColor="#cccccc"
android:strokeWidth="0.265729"/>
<path
android:pathData="m19.52,17.02 l0.26,0.81q-0.27,0.09 -0.61,0.12 -0.33,0.03 -0.73,0.03 0.41,0.18 0.62,0.47 0.21,0.28 0.21,0.7 0,0.45 -0.22,0.8 -0.22,0.35 -0.62,0.55 -0.41,0.2 -0.97,0.2 -0.2,0 -0.35,-0.02 -0.14,-0.02 -0.28,-0.06 -0.09,0.06 -0.15,0.17 -0.06,0.1 -0.06,0.21 0,0.14 0.11,0.24 0.12,0.1 0.46,0.1l0.8,0q0.49,0 0.87,0.17 0.38,0.17 0.59,0.46 0.22,0.29 0.22,0.65 0,0.69 -0.59,1.07 -0.59,0.38 -1.71,0.38 -0.79,0 -1.24,-0.16 -0.45,-0.16 -0.63,-0.48 -0.18,-0.32 -0.18,-0.78l0.88,0q0,0.24 0.09,0.4 0.1,0.16 0.35,0.24 0.26,0.08 0.74,0.08 0.48,0 0.77,-0.08 0.29,-0.08 0.41,-0.23 0.13,-0.15 0.13,-0.36 0,-0.28 -0.24,-0.43 -0.24,-0.15 -0.65,-0.15l-0.79,0q-0.65,0 -0.96,-0.27 -0.3,-0.27 -0.3,-0.62 0,-0.24 0.13,-0.45 0.14,-0.22 0.38,-0.38 -0.41,-0.22 -0.61,-0.53 -0.19,-0.31 -0.19,-0.76 0,-0.49 0.24,-0.85 0.24,-0.37 0.68,-0.57 0.44,-0.2 1,-0.2 0.55,0 0.92,-0.06 0.37,-0.06 0.64,-0.17 0.28,-0.11 0.55,-0.24zM17.41,18.15q-0.47,0 -0.7,0.27 -0.24,0.26 -0.24,0.68 0,0.44 0.24,0.7 0.24,0.26 0.71,0.26 0.43,0 0.66,-0.25 0.23,-0.25 0.23,-0.72 0,-0.47 -0.23,-0.71 -0.23,-0.24 -0.68,-0.24z"
android:fillColor="#fdfdfd"
android:strokeWidth="0.265729"/>
<path
android:pathData="m21.24,13.59l0,-0.53l2.4,0l0,0.53z"
android:fillColor="#cccccc"
android:strokeWidth="0.265729"/>
</vector>

View File

@ -5,6 +5,7 @@
<Button style="@style/paragraph" android:text="@string/launcher_button_imesettings" android:onClick="launch_imesettings" android:layout_width="wrap_content"/>
<Button style="@style/paragraph" android:text="@string/launcher_button_imepicker" android:onClick="launch_imepicker" android:layout_width="wrap_content"/>
<ImageView style="@style/anim" android:id="@+id/launcher_anim_swipe" android:background="@drawable/doc_key_u" android:src="@drawable/doc_anim_swipe"/>
<ImageView style="@style/anim" android:id="@+id/launcher_anim_round_trip" android:background="@drawable/doc_key_g" android:src="@drawable/doc_anim_round_trip"/>
<TextView android:id="@+id/launcher_tryhere_text" style="@style/paragraph" android:text="@string/launcher_tryhere"/>
<EditText android:id="@+id/launcher_tryhere_area" style="@style/paragraph" android:inputType="text" android:hint="@string/launcher_tryhere_hint" android:importantForAutofill="no"/>
<TextView style="@style/paragraph" android:text="@string/launcher_sourcecode"/>

View File

@ -50,6 +50,7 @@ public class LauncherActivity extends Activity implements Handler.Callback
super.onStart();
_animations = new ArrayList<Animatable>();
_animations.add(find_anim(R.id.launcher_anim_swipe));
_animations.add(find_anim(R.id.launcher_anim_round_trip));
_handler = new Handler(getMainLooper(), this);
_handler.sendEmptyMessageDelayed(0, 500);
}

View File

@ -20,6 +20,8 @@ TMP=`mktemp -d`
trap "rm -r '$TMP'" EXIT
set -x
inkscape doc_key.svg -o "$TMP/doc_key_g.svg" -C --export-page 1 --export-plain-svg --export-text-to-path
inkscape doc_key.svg -o "$TMP/doc_key_u.svg" -C --export-page 2 --export-plain-svg --export-text-to-path
svg_to_vector "$TMP/doc_key_g.svg" "$DRAWABLE_DIR/doc_key_g.xml"
svg_to_vector "$TMP/doc_key_u.svg" "$DRAWABLE_DIR/doc_key_u.xml"