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.internal.logging.MetricsLogger;
29import com.android.settings.R;
30import com.android.settings.fingerprint.FingerprintSettings.FingerprintPreference;
31
32import java.util.List;
33
34/**
35 * Activity which concludes fingerprint enrollment.
36 */
37public class FingerprintEnrollFinish extends FingerprintEnrollBase {
38
39    @Override
40    protected void onCreate(Bundle savedInstanceState) {
41        super.onCreate(savedInstanceState);
42        setContentView(R.layout.fingerprint_enroll_finish);
43        setHeaderText(R.string.security_settings_fingerprint_enroll_finish_title);
44        Button addButton = (Button) findViewById(R.id.add_another_button);
45
46        FingerprintManager fpm = (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE);
47        int enrolled = fpm.getEnrolledFingerprints().size();
48        int max = getResources().getInteger(
49                com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
50        if (enrolled >= max) {
51            /* Don't show "Add" button if too many fingerprints already added */
52            addButton.setVisibility(View.INVISIBLE);
53        } else {
54            addButton.setOnClickListener(this);
55        }
56    }
57
58    @Override
59    protected void onNextButtonClick() {
60        setResult(RESULT_FINISHED);
61        finish();
62    }
63
64    @Override
65    public void onClick(View v) {
66        if (v.getId() == R.id.add_another_button) {
67            final Intent intent = getEnrollingIntent();
68            intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
69            startActivity(intent);
70            finish();
71        }
72        super.onClick(v);
73    }
74
75    @Override
76    protected int getMetricsCategory() {
77        return MetricsLogger.FINGERPRINT_ENROLL_FINISH;
78    }
79}
80