Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed6f9576 authored by 2bllw8's avatar 2bllw8 Committed by luca020400
Browse files

Recorder: play/pause animation for pause/resume button

Taken from the Eleven app

Change-Id: I0f3641d18795390fb4bb158de7b6880deca4c4f1
parent a69487e3
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -42,6 +44,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;

import com.google.android.material.floatingactionbutton.FloatingActionButton;

@@ -286,14 +289,20 @@ public class RecorderActivity extends AppCompatActivity {
            mRecordingVisualizer.setVisibility(View.VISIBLE);
            mRecordingVisualizer.setAmplitude(0);
            mPauseResume.setVisibility(View.VISIBLE);
            final Drawable prDrawable;
            if (UiStatus.PAUSED == status) {
                mRecordingText.setText(getString(R.string.sound_recording_title_paused));
                mPauseResume.setImageResource(R.drawable.ic_resume);
                mPauseResume.setContentDescription(getString(R.string.resume));
                prDrawable = ContextCompat.getDrawable(this, R.drawable.avd_play_to_pause);
            } else {
                mRecordingText.setText(getString(R.string.sound_recording_title_working));
                mPauseResume.setImageResource(R.drawable.ic_pause);
                mPauseResume.setContentDescription(getString(R.string.pause));
                prDrawable = ContextCompat.getDrawable(this, R.drawable.avd_pause_to_play);
            }
            mPauseResume.setTooltipText(mPauseResume.getContentDescription());
            mPauseResume.setImageDrawable(prDrawable);
            if (prDrawable instanceof AnimatedVectorDrawable) {
                ((AnimatedVectorDrawable) prDrawable).start();
            }
        }
    }
+59 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2022 The LineageOS Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<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:width="24dp"
            android:height="24dp"
            android:viewportWidth="24"
            android:viewportHeight="24">
            <group
                android:name="group"
                android:pivotX="12"
                android:pivotY="12">
                <path
                    android:name="path"
                    android:fillColor="?android:attr/textColorPrimary"
                    android:pathData="M 8 5 L 8 19 L 19 12 Z"
                    android:strokeWidth="1" />
            </group>
        </vector>
    </aapt:attr>
    <target android:name="path">
        <aapt:attr name="android:animation">
            <objectAnimator
                android:duration="300"
                android:interpolator="@android:interpolator/fast_out_slow_in"
                android:propertyName="pathData"
                android:valueFrom="M 8 5 L 8 12 L 19 12 L 19 12 L 8 5 M 8 12 L 8 19 L 19 12 L 19 12 L 8 12"
                android:valueTo="M 5 6 L 5 10 L 19 10 L 19 6 L 5 6 M 5 14 L 5 18 L 19 18 L 19 14 L 5 14"
                android:valueType="pathType" />
        </aapt:attr>
    </target>
    <target android:name="group">
        <aapt:attr name="android:animation">
            <objectAnimator
                android:duration="300"
                android:interpolator="@android:interpolator/fast_out_slow_in"
                android:propertyName="rotation"
                android:valueFrom="0"
                android:valueTo="90"
                android:valueType="floatType" />
        </aapt:attr>
    </target>
</animated-vector>
+59 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2022 The LineageOS Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<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:width="24dp"
            android:height="24dp"
            android:viewportWidth="24"
            android:viewportHeight="24">
            <group
                android:name="group"
                android:pivotX="12"
                android:pivotY="12">
                <path
                    android:name="path"
                    android:fillColor="?android:attr/textColorPrimary"
                    android:pathData="M 8 5 L 8 19 L 19 12 Z"
                    android:strokeWidth="1" />
            </group>
        </vector>
    </aapt:attr>
    <target android:name="path">
        <aapt:attr name="android:animation">
            <objectAnimator
                android:duration="300"
                android:interpolator="@android:interpolator/fast_out_slow_in"
                android:propertyName="pathData"
                android:valueFrom="M 5 6 L 5 10 L 19 10 L 19 6 L 5 6 M 5 14 L 5 18 L 19 18 L 19 14 L 5 14"
                android:valueTo="M 8 5 L 8 12 L 19 12 L 19 12 L 8 5 M 8 12 L 8 19 L 19 12 L 19 12 L 8 12"
                android:valueType="pathType" />
        </aapt:attr>
    </target>
    <target android:name="group">
        <aapt:attr name="android:animation">
            <objectAnimator
                android:duration="300"
                android:interpolator="@android:interpolator/fast_out_slow_in"
                android:propertyName="rotation"
                android:valueFrom="90"
                android:valueTo="0"
                android:valueType="floatType" />
        </aapt:attr>
    </target>
</animated-vector>
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@
        app:layout_constraintBottom_toBottomOf="@id/sound_fab"
        app:layout_constraintEnd_toStartOf="@id/sound_fab"
        app:layout_constraintTop_toTopOf="@id/sound_fab"
        tools:src="@drawable/ic_pause"
        tools:src="@drawable/avd_pause_to_play"
        tools:visibility="visible" />

    <ImageView