Switch the FingerprintUiHelper over to SwirlView

This commit is contained in:
Alexander Bakker 2017-08-19 16:48:57 +02:00
parent 76c6840ad6
commit d906c6d9a8
15 changed files with 27 additions and 82 deletions

View file

@ -14,19 +14,14 @@ import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.lang.reflect.UndeclaredThrowableException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import com.mattprecious.swirl.SwirlView;
import java.lang.reflect.UndeclaredThrowableException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import me.impy.aegis.crypto.CryptoUtils;
@ -48,7 +43,7 @@ public class AuthActivity extends AppCompatActivity implements FingerprintUiHelp
private SlotCollection slots;
private LinearLayout boxFingerprint;
private ImageView imgFingerprint;
private SwirlView imgFingerprint;
private TextView textFingerprint;
private FingerprintUiHelper fingerHelper;
private Cipher fingerCipher;
@ -59,7 +54,7 @@ public class AuthActivity extends AppCompatActivity implements FingerprintUiHelp
setContentView(R.layout.activity_auth);
textPassword = (EditText) findViewById(R.id.text_password);
boxFingerprint = (LinearLayout) findViewById(R.id.box_fingerprint);
imgFingerprint = (ImageView) findViewById(R.id.img_fingerprint);
imgFingerprint = (SwirlView) findViewById(R.id.img_fingerprint);
textFingerprint = (TextView) findViewById(R.id.text_fingerprint);
Intent intent = getIntent();

View file

@ -10,12 +10,12 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.github.paolorotolo.appintro.ISlidePolicy;
import com.github.paolorotolo.appintro.ISlideSelectionListener;
import com.mattprecious.swirl.SwirlView;
import java.lang.reflect.UndeclaredThrowableException;
@ -37,7 +37,7 @@ public class CustomAuthenticatedSlide extends Fragment implements FingerprintUiH
private int bgColor;
private LinearLayout boxFingerprint;
private ImageView imgFingerprint;
private SwirlView imgFingerprint;
private TextView textFingerprint;
private FingerprintUiHelper fingerHelper;
private KeyStoreHandle storeHandle;
@ -50,7 +50,7 @@ public class CustomAuthenticatedSlide extends Fragment implements FingerprintUiH
textPassword = (EditText) view.findViewById(R.id.text_password);
textPasswordConfirm = (EditText) view.findViewById(R.id.text_password_confirm);
boxFingerprint = (LinearLayout) view.findViewById(R.id.box_fingerprint);
imgFingerprint = (ImageView) view.findViewById(R.id.img_fingerprint);
imgFingerprint = (SwirlView) view.findViewById(R.id.img_fingerprint);
textFingerprint = (TextView) view.findViewById(R.id.text_fingerprint);
view.findViewById(R.id.main).setBackgroundColor(bgColor);
return view;

View file

@ -23,9 +23,10 @@ import android.hardware.fingerprint.FingerprintManager;
import android.os.Build;
import android.os.CancellationSignal;
import android.support.annotation.RequiresApi;
import android.widget.ImageView;
import android.widget.TextView;
import com.mattprecious.swirl.SwirlView;
import me.impy.aegis.R;
/**
@ -38,7 +39,7 @@ public class FingerprintUiHelper extends FingerprintManager.AuthenticationCallba
private static final long SUCCESS_DELAY_MILLIS = 1300;
private final FingerprintManager mFingerprintManager;
private final ImageView mIcon;
private final SwirlView mIcon;
private final TextView mErrorTextView;
private final Callback mCallback;
private CancellationSignal mCancellationSignal;
@ -49,7 +50,7 @@ public class FingerprintUiHelper extends FingerprintManager.AuthenticationCallba
* Constructor for {@link FingerprintUiHelper}.
*/
public FingerprintUiHelper(FingerprintManager fingerprintManager,
ImageView icon, TextView errorTextView, Callback callback) {
SwirlView icon, TextView errorTextView, Callback callback) {
mFingerprintManager = fingerprintManager;
mIcon = icon;
mErrorTextView = errorTextView;
@ -73,7 +74,7 @@ public class FingerprintUiHelper extends FingerprintManager.AuthenticationCallba
// noinspection ResourceType
mFingerprintManager
.authenticate(cryptoObject, mCancellationSignal, 0 /* flags */, this, null);
mIcon.setImageResource(R.drawable.ic_fp_40px);
mIcon.setState(SwirlView.State.ON);
}
public void stopListening() {
@ -111,7 +112,7 @@ public class FingerprintUiHelper extends FingerprintManager.AuthenticationCallba
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
mErrorTextView.removeCallbacks(mResetErrorTextRunnable);
mIcon.setImageResource(R.drawable.ic_fingerprint_success);
mIcon.setState(SwirlView.State.OFF);
mErrorTextView.setText(
mErrorTextView.getResources().getString(R.string.fingerprint_success));
mIcon.postDelayed(new Runnable() {
@ -123,7 +124,7 @@ public class FingerprintUiHelper extends FingerprintManager.AuthenticationCallba
}
private void showError(CharSequence error) {
mIcon.setImageResource(R.drawable.ic_fingerprint_error);
mIcon.setState(SwirlView.State.ERROR);
mErrorTextView.setText(error);
mErrorTextView.removeCallbacks(mResetErrorTextRunnable);
mErrorTextView.postDelayed(mResetErrorTextRunnable, ERROR_TIMEOUT_MILLIS);
@ -134,7 +135,7 @@ public class FingerprintUiHelper extends FingerprintManager.AuthenticationCallba
public void run() {
mErrorTextView.setText(
mErrorTextView.getResources().getString(R.string.fingerprint_hint));
mIcon.setImageResource(R.drawable.ic_fp_40px);
mIcon.setState(SwirlView.State.ON);
}
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source 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
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40.0dp"
android:height="40.0dp"
android:viewportWidth="40.0"
android:viewportHeight="40.0">
<path
android:pathData="M20.0,0.0C8.96,0.0 0.0,8.95 0.0,20.0s8.96,20.0 20.0,20.0c11.04,0.0 20.0,-8.95 20.0,-20.0S31.04,0.0 20.0,0.0z"
android:fillColor="#F4511E"/>
<path
android:pathData="M21.33,29.33l-2.67,0.0l0.0,-2.67l2.67,0.0L21.33,29.33zM21.33,22.67l-2.67,0.0l0.0,-12.0l2.67,0.0L21.33,22.67z"
android:fillColor="#FFFFFF"/>
</vector>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source 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
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40.0dp"
android:height="40.0dp"
android:viewportWidth="40.0"
android:viewportHeight="40.0">
<path
android:pathData="M20.0,20.0m-20.0,0.0a20.0,20.0 0.0,1.0 1.0,40.0 0.0a20.0,20.0 0.0,1.0 1.0,-40.0 0.0"
android:fillColor="#009688"/>
<path
android:pathData="M11.2,21.41l1.63,-1.619999 4.17,4.169998 10.59,-10.589999 1.619999,1.63 -12.209999,12.209999z"
android:fillColor="#FFFFFF"/>
</vector>

View file

@ -48,10 +48,10 @@
android:layout_marginTop="12dp"
android:visibility="invisible">
<ImageView
<com.mattprecious.swirl.SwirlView
android:id="@+id/img_fingerprint"
android:layout_width="60dp"
android:layout_height="60dp" />
android:layout_height="60dp"/>
<TextView
android:id="@+id/text_fingerprint"

View file

@ -82,10 +82,10 @@
android:layout_height="match_parent"
android:layout_marginTop="12dp">
<ImageView
<com.mattprecious.swirl.SwirlView
android:id="@+id/img_fingerprint"
android:layout_width="60dp"
android:layout_height="60dp" />
android:layout_height="60dp"/>
<TextView
android:id="@+id/text_fingerprint"

View file

@ -15,6 +15,9 @@
<color name="background">#f2f2f2</color>
<color name="card_background">#ffffff</color>
<color name="colorSwirlPrimary">#434343</color>
<color name="colorSwirlError">#FF5252</color>
<color name="card_background_dark">#212121</color>
<color name="primary_text_dark">#ffffff</color>
<color name="secondary_text_dark">#FF5252</color>

View file

@ -25,6 +25,8 @@
</style>
<style name="Theme.Intro" parent="Theme.AppCompat.NoActionBar">
<item name="swirl_ridgeColor">@color/colorSwirlPrimary</item>
<item name="swirl_errorColor">@color/colorSwirlError</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
</style>
@ -44,8 +46,8 @@
<style name="AppTheme.Default">
<item name="android:windowBackground">@color/background</item>
<item name="swirl_ridgeColor">?android:attr/textColorSecondary</item>
<item name="swirl_errorColor">?android:attr/colorAccent</item>
<item name="swirl_ridgeColor">@color/colorSwirlPrimary</item>
<item name="swirl_errorColor">@color/colorSwirlError</item>
<item name="android:textColorPrimary">@color/primary_text</item>
<item name="android:textColorSecondary">@color/secondary_text</item>
<item name="primaryText">@color/primary_text</item>