• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.settings.fingerprint;
18 
19 import android.content.Context;
20 import android.content.Intent;
21 import android.hardware.fingerprint.FingerprintManager;
22 import android.os.Bundle;
23 import android.os.UserHandle;
24 import android.view.View;
25 import android.widget.Button;
26 
27 import com.android.internal.logging.MetricsProto.MetricsEvent;
28 import com.android.settings.R;
29 
30 /**
31  * Activity which concludes fingerprint enrollment.
32  */
33 public class FingerprintEnrollFinish extends FingerprintEnrollBase {
34 
35     @Override
onCreate(Bundle savedInstanceState)36     protected void onCreate(Bundle savedInstanceState) {
37         super.onCreate(savedInstanceState);
38         setContentView(R.layout.fingerprint_enroll_finish);
39         setHeaderText(R.string.security_settings_fingerprint_enroll_finish_title);
40         Button addButton = (Button) findViewById(R.id.add_another_button);
41 
42         FingerprintManager fpm = (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE);
43         int enrolled = fpm.getEnrolledFingerprints(mUserId).size();
44         int max = getResources().getInteger(
45                 com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
46         if (enrolled >= max) {
47             /* Don't show "Add" button if too many fingerprints already added */
48             addButton.setVisibility(View.INVISIBLE);
49         } else {
50             addButton.setOnClickListener(this);
51         }
52     }
53 
54     @Override
onNextButtonClick()55     protected void onNextButtonClick() {
56         setResult(RESULT_FINISHED);
57         finish();
58     }
59 
60     @Override
onClick(View v)61     public void onClick(View v) {
62         if (v.getId() == R.id.add_another_button) {
63             final Intent intent = getEnrollingIntent();
64             intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
65             startActivity(intent);
66             finish();
67         }
68         super.onClick(v);
69     }
70 
71     @Override
getMetricsCategory()72     protected int getMetricsCategory() {
73         return MetricsEvent.FINGERPRINT_ENROLL_FINISH;
74     }
75 }
76