Settings: animate the Bluetooth icon.

Fixes #314.
This commit is contained in:
Dennis Guse
2020-08-06 12:35:02 +02:00
parent a5594fbb7a
commit b8088169ee
4 changed files with 47 additions and 1 deletions
@@ -8,6 +8,8 @@ import android.bluetooth.le.ScanResult;
import android.bluetooth.le.ScanSettings;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.ParcelUuid;
import android.text.TextUtils;
@@ -16,6 +18,7 @@ import android.util.Log;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.preference.DialogPreference;
import androidx.preference.PreferenceDialogFragmentCompat;
@@ -189,7 +192,11 @@ public abstract class BluetoothLeSensorPreference extends DialogPreference {
BluetoothLeSensorPreferenceDialog.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
dialog.dismiss();
});
builder.setIcon(R.drawable.ic_bluetooth_searching_24dp);
Drawable icon = ContextCompat.getDrawable(getContext(), R.drawable.ic_bluetooth_searching_animated_24dp);
((Animatable) icon).start();
builder.setIcon(icon);
builder.setPositiveButton(null, null);
}
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="sequentially">
<objectAnimator
android:duration="650"
android:interpolator="@android:interpolator/linear"
android:propertyName="fillAlpha"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:startOffset="400"
android:valueFrom="0"
android:valueTo="1"
android:valueType="floatType" />
</set>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="sequentially">
<objectAnimator
android:duration="650"
android:interpolator="@android:interpolator/linear"
android:propertyName="fillAlpha"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueFrom="0"
android:valueTo="1"
android:valueType="floatType" />
</set>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_bluetooth_searching_24dp">
<target
android:name="smallDot"
android:animation="@anim/bluetooth_searching_smalldot" />
<target
android:name="bigDot"
android:animation="@anim/bluetooth_searching_bigdot" />
</animated-vector>