mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-02 07:02:27 +00:00
Added failure callback to fingerprint dialog
This commit is contained in:
parent
15aa813416
commit
8a8441c875
@ -16,15 +16,18 @@ import com.topjohnwu.magisk.utils.FingerprintHelper;
|
|||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.M)
|
@TargetApi(Build.VERSION_CODES.M)
|
||||||
public class FingerprintAuthDialog extends CustomAlertDialog {
|
public class FingerprintAuthDialog extends CustomAlertDialog {
|
||||||
|
|
||||||
private Runnable callback;
|
private final Runnable callback;
|
||||||
|
@Nullable
|
||||||
|
private Runnable failureCallback;
|
||||||
private DialogFingerprintHelper helper;
|
private DialogFingerprintHelper helper;
|
||||||
|
|
||||||
public FingerprintAuthDialog(@NonNull Activity activity, Runnable onSuccess) {
|
public FingerprintAuthDialog(@NonNull Activity activity, @NonNull Runnable onSuccess) {
|
||||||
super(activity);
|
super(activity);
|
||||||
callback = onSuccess;
|
callback = onSuccess;
|
||||||
Drawable fingerprint = activity.getResources().getDrawable(R.drawable.ic_fingerprint);
|
Drawable fingerprint = activity.getResources().getDrawable(R.drawable.ic_fingerprint);
|
||||||
@ -37,13 +40,28 @@ public class FingerprintAuthDialog extends CustomAlertDialog {
|
|||||||
vh.messageView.setCompoundDrawablePadding(Utils.dpInPx(20));
|
vh.messageView.setCompoundDrawablePadding(Utils.dpInPx(20));
|
||||||
vh.messageView.setGravity(Gravity.CENTER);
|
vh.messageView.setGravity(Gravity.CENTER);
|
||||||
setMessage(R.string.auth_fingerprint);
|
setMessage(R.string.auth_fingerprint);
|
||||||
setNegativeButton(R.string.close, (d, w) -> helper.cancel());
|
setNegativeButton(R.string.close, (d, w) -> {
|
||||||
setOnCancelListener(d -> helper.cancel());
|
helper.cancel();
|
||||||
|
if (failureCallback != null) {
|
||||||
|
failureCallback.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setOnCancelListener(d -> {
|
||||||
|
helper.cancel();
|
||||||
|
if (failureCallback != null) {
|
||||||
|
failureCallback.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
helper = new DialogFingerprintHelper();
|
helper = new DialogFingerprintHelper();
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FingerprintAuthDialog(@NonNull Activity activity, @NonNull Runnable onSuccess, @NonNull Runnable onFailure) {
|
||||||
|
this(activity, onSuccess);
|
||||||
|
failureCallback = onFailure;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlertDialog show() {
|
public AlertDialog show() {
|
||||||
create();
|
create();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user