1/* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17package com.android.settings.fingerprint; 18 19import android.content.Context; 20import android.content.Intent; 21import android.hardware.fingerprint.Fingerprint; 22import android.hardware.fingerprint.FingerprintManager; 23import android.os.Bundle; 24import android.preference.Preference; 25import android.view.View; 26import android.widget.Button; 27 28import com.android.settings.R; 29import com.android.settings.fingerprint.FingerprintSettings.FingerprintPreference; 30 31import java.util.List; 32 33/** 34 * Activity which concludes fingerprint enrollment. 35 */ 36public class FingerprintEnrollFinish extends FingerprintEnrollBase { 37 38 @Override 39 protected void onCreate(Bundle savedInstanceState) { 40 super.onCreate(savedInstanceState); 41 setContentView(R.layout.fingerprint_enroll_finish); 42 setHeaderText(R.string.security_settings_fingerprint_enroll_finish_title); 43 Button addButton = (Button) findViewById(R.id.add_another_button); 44 45 FingerprintManager fpm = (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE); 46 int enrolled = fpm.getEnrolledFingerprints().size(); 47 int max = getResources().getInteger( 48 com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser); 49 if (enrolled >= max) { 50 /* Don't show "Add" button if too many fingerprints already added */ 51 addButton.setVisibility(View.INVISIBLE); 52 } else { 53 addButton.setOnClickListener(this); 54 } 55 } 56 57 @Override 58 protected void onNextButtonClick() { 59 setResult(RESULT_FINISHED); 60 finish(); 61 } 62 63 @Override 64 public void onClick(View v) { 65 if (v.getId() == R.id.add_another_button) { 66 final Intent intent = getEnrollingIntent(); 67 intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); 68 startActivity(intent); 69 finish(); 70 } 71 super.onClick(v); 72 } 73} 74