1/*
2 * Copyright (C) 2012 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.keyguard;
18
19/**
20 * Interface implemented by ViewGroup-derived layouts that implement
21 * special logic for presenting security challenges to the user.
22 */
23public interface ChallengeLayout {
24    /**
25     * @return true if the security challenge area of this layout is currently visible
26     */
27    boolean isChallengeShowing();
28
29    /**
30     * @return true if the challenge area significantly overlaps other content
31     */
32    boolean isChallengeOverlapping();
33
34    /**
35     * Show or hide the challenge layout.
36     *
37     * If you want to show the challenge layout in bouncer mode where applicable,
38     * use {@link #showBouncer()} instead.
39     *
40     * @param b true to show, false to hide
41     */
42    void showChallenge(boolean show);
43
44    /**
45     * Show the bouncer challenge. This may block access to other child views.
46     */
47    void showBouncer();
48
49    /**
50     * Hide the bouncer challenge if it is currently showing.
51     * This may restore previously blocked access to other child views.
52     */
53    void hideBouncer();
54
55    /**
56     * Returns true if the challenge is currently in bouncer mode,
57     * potentially blocking access to other child views.
58     */
59    boolean isBouncing();
60
61    /**
62     * Returns the duration of the bounce animation.
63     */
64    int getBouncerAnimationDuration();
65
66    /**
67     * Set a listener that will respond to changes in bouncer state.
68     *
69     * @param listener listener to register
70     */
71    void setOnBouncerStateChangedListener(OnBouncerStateChangedListener listener);
72
73    /**
74     * Listener interface that reports changes in bouncer state.
75     * The bouncer is
76     */
77    public interface OnBouncerStateChangedListener {
78        /**
79         * Called when the bouncer state changes.
80         * The bouncer is activated when the user must pass a security challenge
81         * to proceed with the requested action.
82         *
83         * <p>This differs from simply showing or hiding the security challenge
84         * as the bouncer will prevent interaction with other elements of the UI.
85         * If the user attempts to escape from the bouncer, it will be dismissed,
86         * this method will be called with false as the parameter, and the action
87         * should be canceled. If the security component reports a successful
88         * authentication and the containing code calls hideBouncer() as a result,
89         * this method will also be called with a false parameter. It is up to the
90         * caller of hideBouncer to be ready for this.</p>
91         *
92         * @param bouncerActive true if the bouncer is now active,
93         *                      false if the bouncer was dismissed.
94         */
95        public void onBouncerStateChanged(boolean bouncerActive);
96    }
97}
98