diff options
author | Dave Mankoff <mankoff@google.com> | 2020-09-02 15:26:42 -0400 |
---|---|---|
committer | Dave Mankoff <mankoff@google.com> | 2020-09-16 16:24:11 -0400 |
commit | 8f75cf99445bae63bb46602de9b6a0a3b6fad2bf (patch) | |
tree | ee4924cf114953b3a22545037081c4782ce3e881 /packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java | |
parent | e1e67c57a67fd3d742df254c34745a31d5eb4400 (diff) |
4/N Setup Controller fo KeyguardSecurityContainer.
Move the guts of KeyguardSecurityContainer into
KeyguardSecurityContainerController. This removes a lot of
Dependency#get calls, and is another step towards simplifying our
view inflation process.
CustomViews that previously implemented KeyguardSecurityView now
all extend KeyguardInputView, allowing them to be simultaneously
treated as one while also being recognized as a View (the interface
required a lot of casting back and forth to a View).
LockscreenUtil is made a Singleton in this CL.
Bug: 166448040
Test: atest SystemUITests && manual
Change-Id: I6fa05012c55f5e003ab551d2f8360891a62fa2a7
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java')
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java new file mode 100644 index 000000000000..b0b2cd8c74d9 --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2020 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. + */ + +package com.android.keyguard; + +import android.content.res.ColorStateList; +import android.view.MotionEvent; + +import com.android.internal.widget.LockPatternUtils; +import com.android.keyguard.KeyguardSecurityModel.SecurityMode; +import com.android.systemui.util.ViewController; + +import javax.inject.Inject; + + +/** Controller for a {@link KeyguardSecurityView}. */ +public class KeyguardInputViewController extends ViewController<KeyguardInputView> + implements KeyguardSecurityView { + + private final SecurityMode mSecurityMode; + private final LockPatternUtils mLockPatternUtils; + + private KeyguardInputViewController(KeyguardInputView view, SecurityMode securityMode, + LockPatternUtils lockPatternUtils, + KeyguardSecurityCallback keyguardSecurityCallback) { + super(view); + mSecurityMode = securityMode; + mLockPatternUtils = lockPatternUtils; + mView.setKeyguardCallback(keyguardSecurityCallback); + } + + @Override + public void init() { + super.init(); + mView.reset(); + } + + @Override + protected void onViewAttached() { + } + + @Override + protected void onViewDetached() { + } + + SecurityMode getSecurityMode() { + return mSecurityMode; + } + + + @Override + public void setKeyguardCallback(KeyguardSecurityCallback callback) { + mView.setKeyguardCallback(callback); + } + + @Override + public void setLockPatternUtils(LockPatternUtils utils) { + mView.setLockPatternUtils(utils); + } + + @Override + public void reset() { + mView.reset(); + } + + @Override + public void onPause() { + mView.onPause(); + } + + @Override + public void onResume(int reason) { + mView.onResume(reason); + } + + @Override + public boolean needsInput() { + return mView.needsInput(); + } + + @Override + public KeyguardSecurityCallback getCallback() { + return mView.getCallback(); + } + + @Override + public void showPromptReason(int reason) { + mView.showPromptReason(reason); + } + + @Override + public void showMessage(CharSequence message, ColorStateList colorState) { + mView.showMessage(message, colorState); + } + + @Override + public void showUsabilityHint() { + mView.showUsabilityHint(); + } + + @Override + public void startAppearAnimation() { + mView.startAppearAnimation(); + } + + @Override + public boolean startDisappearAnimation(Runnable finishRunnable) { + return mView.startDisappearAnimation(finishRunnable); + } + + @Override + public CharSequence getTitle() { + return mView.getTitle(); + } + + @Override + public boolean disallowInterceptTouch(MotionEvent event) { + return mView.disallowInterceptTouch(event); + } + + @Override + public void onStartingToHide() { + mView.onStartingToHide(); + } + + public void showSelf() { + KeyguardSecurityViewFlipper flipper = (KeyguardSecurityViewFlipper) mView.getParent(); + flipper.setDisplayedChild(flipper.indexOfChild(mView)); + } + + /** Factory for a {@link KeyguardInputViewController}. */ + public static class Factory { + private final LockPatternUtils mLockPatternUtils; + + @Inject + public Factory(LockPatternUtils lockPatternUtils) { + mLockPatternUtils = lockPatternUtils; + } + + /** Create a new {@link KeyguardInputViewController}. */ + public KeyguardInputViewController create(KeyguardInputView keyguardInputView, + SecurityMode securityMode, KeyguardSecurityCallback keyguardSecurityCallback) { + return new KeyguardInputViewController(keyguardInputView, securityMode, + mLockPatternUtils, keyguardSecurityCallback); + } + } +} |