commit
bf5feaacd1
18 files changed
+215
-5
No files matched your search
Regular → Executable
+1
@@ -22,6 +22,7 @@
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
|
||||
|
||||
|
||||
Regular → Executable
+10
@@ -911,6 +911,16 @@ public class Settings {
|
||||
putString(KEY_SECURITY, value);
|
||||
}
|
||||
|
||||
public static final String KEY_ENABLE_FINGERPRINT = "enable_fingerprint";
|
||||
|
||||
public static boolean getEnableFingerprint() {
|
||||
return getBoolean(KEY_ENABLE_FINGERPRINT, false);
|
||||
}
|
||||
|
||||
public static void putEnableFingerprint(boolean value) {
|
||||
putBoolean(KEY_ENABLE_FINGERPRINT, value);
|
||||
}
|
||||
|
||||
public static final String KEY_READ_CACHE_SIZE = "read_cache_size";
|
||||
public static final int DEFAULT_READ_CACHE_SIZE = 160;
|
||||
|
||||
|
||||
Regular → Executable
+18
-1
@@ -16,11 +16,13 @@
|
||||
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
@@ -36,6 +38,8 @@ public class SetSecurityActivity extends ToolbarActivity implements View.OnClick
|
||||
private View mCancel;
|
||||
@Nullable
|
||||
private View mSet;
|
||||
@Nullable
|
||||
private CheckBox mFingerprint;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -46,6 +50,7 @@ public class SetSecurityActivity extends ToolbarActivity implements View.OnClick
|
||||
mPatternView = (LockPatternView) ViewUtils.$$(this, R.id.pattern_view);
|
||||
mCancel = ViewUtils.$$(this, R.id.cancel);
|
||||
mSet = ViewUtils.$$(this, R.id.set);
|
||||
mFingerprint = (CheckBox) ViewUtils.$$(this, R.id.fingerprint_checkbox);
|
||||
|
||||
String pattern = Settings.getSecurity();
|
||||
if (!TextUtils.isEmpty(pattern)) {
|
||||
@@ -53,6 +58,16 @@ public class SetSecurityActivity extends ToolbarActivity implements View.OnClick
|
||||
LockPatternUtils.stringToPattern(pattern));
|
||||
}
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
||||
FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class);
|
||||
// The line below prevents the false positive inspection from Android Studio
|
||||
// noinspection ResourceType
|
||||
if (fingerprintManager.hasEnrolledFingerprints()) {
|
||||
mFingerprint.setVisibility(View.VISIBLE);
|
||||
mFingerprint.setChecked(Settings.getEnableFingerprint());
|
||||
}
|
||||
}
|
||||
|
||||
mCancel.setOnClickListener(this);
|
||||
mSet.setOnClickListener(this);
|
||||
}
|
||||
@@ -79,7 +94,7 @@ public class SetSecurityActivity extends ToolbarActivity implements View.OnClick
|
||||
if (v == mCancel) {
|
||||
finish();
|
||||
} else if (v == mSet) {
|
||||
if (null != mPatternView) {
|
||||
if (null != mPatternView && null != mFingerprint) {
|
||||
String security;
|
||||
if (mPatternView.getCellSize() <= 1) {
|
||||
security = "";
|
||||
@@ -87,6 +102,8 @@ public class SetSecurityActivity extends ToolbarActivity implements View.OnClick
|
||||
security = mPatternView.getPatternString();
|
||||
}
|
||||
Settings.putSecurity(security);
|
||||
Settings.putEnableFingerprint(mFingerprint.getVisibility() == View.VISIBLE &&
|
||||
mFingerprint.isChecked() && !security.isEmpty());
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
Regular → Executable
+88
@@ -19,11 +19,15 @@ package com.hippo.ehviewer.ui.scene;
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CancellationSignal;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
@@ -42,15 +46,21 @@ public class SecurityScene extends SolidScene implements
|
||||
LockPatternView.OnPatternListener, ShakeDetector.OnShakeListener {
|
||||
|
||||
private static final int MAX_RETRY_TIMES = 5;
|
||||
private static final long ERROR_TIMEOUT_MILLIS = 1200;
|
||||
private static final long SUCCESS_DELAY_MILLIS = 100;
|
||||
|
||||
private static final String KEY_RETRY_TIMES = "retry_times";
|
||||
|
||||
@Nullable
|
||||
private LockPatternView mPatternView;
|
||||
private ImageView mFingerprintIcon;
|
||||
|
||||
private SensorManager mSensorManager;
|
||||
private Sensor mAccelerometer;
|
||||
private ShakeDetector mShakeDetector;
|
||||
private FingerprintManager mFingerprintManager;
|
||||
|
||||
private CancellationSignal mFingerprintCancellationSignal;
|
||||
|
||||
private int mRetryTimes;
|
||||
|
||||
@@ -73,6 +83,9 @@ public class SecurityScene extends SolidScene implements
|
||||
mShakeDetector.setOnShakeListener(this);
|
||||
}
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mFingerprintManager = context.getSystemService(FingerprintManager.class);
|
||||
}
|
||||
|
||||
if (null == savedInstanceState) {
|
||||
mRetryTimes = MAX_RETRY_TIMES;
|
||||
@@ -97,6 +110,38 @@ public class SecurityScene extends SolidScene implements
|
||||
if (null != mShakeDetector) {
|
||||
mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI);
|
||||
}
|
||||
|
||||
if (isFingerprintAuthAvailable()) {
|
||||
mFingerprintCancellationSignal = new CancellationSignal();
|
||||
// The line below prevents the false positive inspection from Android Studio
|
||||
// noinspection ResourceType
|
||||
mFingerprintManager.authenticate(null, mFingerprintCancellationSignal, 0,
|
||||
new FingerprintManager.AuthenticationCallback() {
|
||||
@Override
|
||||
public void onAuthenticationError(int errMsgId, CharSequence errString) {
|
||||
fingerprintError(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationFailed() {
|
||||
fingerprintError(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationSucceeded(
|
||||
FingerprintManager.AuthenticationResult result) {
|
||||
mFingerprintIcon.setImageResource(R.drawable.ic_fingerprint_success);
|
||||
mFingerprintIcon.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startSceneForCheckStep(CHECK_STEP_SECURITY, getArguments());
|
||||
finish();
|
||||
}
|
||||
}, SUCCESS_DELAY_MILLIS);
|
||||
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,6 +151,10 @@ public class SecurityScene extends SolidScene implements
|
||||
if (null != mShakeDetector) {
|
||||
mSensorManager.unregisterListener(mShakeDetector);
|
||||
}
|
||||
if (isFingerprintAuthAvailable() && mFingerprintCancellationSignal != null) {
|
||||
mFingerprintCancellationSignal.cancel();
|
||||
mFingerprintCancellationSignal = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,6 +172,11 @@ public class SecurityScene extends SolidScene implements
|
||||
mPatternView = (LockPatternView) ViewUtils.$$(view, R.id.pattern_view);
|
||||
mPatternView.setOnPatternListener(this);
|
||||
|
||||
mFingerprintIcon = (ImageView) ViewUtils.$$(view, R.id.fingerprint_icon);
|
||||
if (Settings.getEnableFingerprint() && isFingerprintAuthAvailable()) {
|
||||
mFingerprintIcon.setVisibility(View.VISIBLE);
|
||||
mFingerprintIcon.setImageResource(R.drawable.ic_fp_40px);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -176,4 +230,38 @@ public class SecurityScene extends SolidScene implements
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isFingerprintAuthAvailable() {
|
||||
// The line below prevents the false positive inspection from Android Studio
|
||||
// noinspection ResourceType
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
&& Settings.getEnableFingerprint()
|
||||
&& mFingerprintManager != null
|
||||
&& mFingerprintManager.isHardwareDetected()
|
||||
&& mFingerprintManager.hasEnrolledFingerprints();
|
||||
}
|
||||
|
||||
private Runnable mResetFingerprintRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mFingerprintIcon != null)
|
||||
mFingerprintIcon.setImageResource(R.drawable.ic_fp_40px);
|
||||
}
|
||||
};
|
||||
|
||||
private void fingerprintError(boolean unrecoverable) {
|
||||
// Do not decrease mRetryTimes here since Android system will handle it :)
|
||||
mFingerprintIcon.setImageResource(R.drawable.ic_fingerprint_error);
|
||||
mFingerprintIcon.removeCallbacks(mResetFingerprintRunnable);
|
||||
if (unrecoverable) {
|
||||
mFingerprintIcon.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mFingerprintIcon.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}, ERROR_TIMEOUT_MILLIS);
|
||||
} else {
|
||||
mFingerprintIcon.postDelayed(mResetFingerprintRunnable, ERROR_TIMEOUT_MILLIS);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
+28
@@ -0,0 +1,28 @@
|
||||
<?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>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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>
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Regular → Executable
+9
@@ -40,6 +40,15 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/fingerprint_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:visibility="gone"
|
||||
android:text="@string/enable_fingerprint" />
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/buttonPanel"
|
||||
|
||||
Regular → Executable
+9
@@ -51,6 +51,15 @@
|
||||
</com.hippo.widget.MaxSizeContainer>
|
||||
</FrameLayout>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/fingerprint_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:visibility="gone"
|
||||
android:text="@string/enable_fingerprint" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttonPanel"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
Regular → Executable
+19
-4
@@ -27,12 +27,27 @@
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="32dp"
|
||||
app:maxWidth="320dp"
|
||||
app:maxHeight="320dp">
|
||||
app:maxHeight="360dp">
|
||||
|
||||
<com.hippo.widget.lockpattern.LockPatternView
|
||||
android:id="@+id/pattern_view"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.hippo.widget.lockpattern.LockPatternView
|
||||
android:id="@+id/pattern_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/fingerprint_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_fp_40px"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.hippo.widget.MaxSizeContainer>
|
||||
</FrameLayout>
|
||||
Regular → Executable
+1
@@ -334,6 +334,7 @@
|
||||
<string name="set_pattern_protection">Establecer Proteccion po Patrón</string>
|
||||
<string name="set_pattern_protection_tip">Dibujar un patrón para establecer la proteccion por patrón. \nDejar en blanco para quitar la proteccion por patrón.</string>
|
||||
<string name="set">Establecer</string>
|
||||
<string name="enable_fingerprint">Permitir desbloquear con huella dactilar</string>
|
||||
|
||||
<!-- Gallery Activity -->
|
||||
<string name="page_menu_title">Pagina %d</string>
|
||||
|
||||
Regular → Executable
+1
@@ -341,6 +341,7 @@
|
||||
<string name="set_pattern_protection">设置图案保护</string>
|
||||
<string name="set_pattern_protection_tip">绘制图案来设置图案保护\n留空来取消图案保护</string>
|
||||
<string name="set">设置</string>
|
||||
<string name="enable_fingerprint">允许使用指纹解锁</string>
|
||||
|
||||
<!-- Gallery Activity -->
|
||||
<string name="page_menu_title">第 %d 页</string>
|
||||
|
||||
Regular → Executable
+1
@@ -341,6 +341,7 @@
|
||||
<string name="set_pattern_protection">設置圖案保護</string>
|
||||
<string name="set_pattern_protection_tip">繪製圖案來設置圖案保護\n留空來取消圖案保護</string>
|
||||
<string name="set">設置</string>
|
||||
<string name="enable_fingerprint">允許使用指紋解鎖</string>
|
||||
|
||||
<!-- Gallery Activity -->
|
||||
<string name="page_menu_title">第 %d 頁</string>
|
||||
|
||||
Regular → Executable
+1
@@ -341,6 +341,7 @@
|
||||
<string name="set_pattern_protection">設定圖案保護</string>
|
||||
<string name="set_pattern_protection_tip">繪製圖案來設定圖案保護\n留空來取消圖案保護</string>
|
||||
<string name="set">設定</string>
|
||||
<string name="enable_fingerprint">允許使用指紋解鎖</string>
|
||||
|
||||
<!-- Gallery Activity -->
|
||||
<string name="page_menu_title">第 %d 頁</string>
|
||||
|
||||
Regular → Executable
+1
@@ -385,6 +385,7 @@
|
||||
<string name="set_pattern_protection">Set pattern protection</string>
|
||||
<string name="set_pattern_protection_tip">Draw a pattern to set pattern protection\nLeave blank to clear pattern protection</string>
|
||||
<string name="set">Set</string>
|
||||
<string name="enable_fingerprint">Also allow unlock with fingerprint</string>
|
||||
|
||||
<!-- Gallery Activity -->
|
||||
<string name="page_menu_title">Page %d</string>
|
||||
|
||||
Reference in new issue
Block a user