Example #1
0
 @Override
 protected void onFinishInflate() {
   super.onFinishInflate();
   mLockPatternUtils = new LockPatternUtils(mContext);
   mPreviewContainer = (ViewGroup) findViewById(R.id.preview_container);
   mCameraImageView = (KeyguardAffordanceView) findViewById(R.id.camera_button);
   mPhoneImageView = (KeyguardAffordanceView) findViewById(R.id.phone_button);
   mLockIcon = (KeyguardAffordanceView) findViewById(R.id.lock_icon);
   mIndicationText = (TextView) findViewById(R.id.keyguard_indication_text);
   watchForCameraPolicyChanges();
   updateCameraVisibility();
   updatePhoneVisibility();
   mUnlockMethodCache = UnlockMethodCache.getInstance(getContext());
   mUnlockMethodCache.addListener(this);
   updateLockIcon();
   setClipChildren(false);
   setClipToPadding(false);
   mPreviewInflater = new PreviewInflater(mContext, new LockPatternUtils(mContext));
   inflatePreviews();
   mLockIcon.setOnClickListener(this);
   mLockIcon.setBackground(mTrustDrawable);
   mLockIcon.setOnLongClickListener(this);
   mCameraImageView.setOnClickListener(this);
   mPhoneImageView.setOnClickListener(this);
   initAccessibility();
 }
Example #2
0
 @Override
 public void onStateChanged(boolean accessibilityEnabled, boolean touchExplorationEnabled) {
   mCameraImageView.setClickable(touchExplorationEnabled);
   mPhoneImageView.setClickable(touchExplorationEnabled);
   mCameraImageView.setFocusable(accessibilityEnabled);
   mPhoneImageView.setFocusable(accessibilityEnabled);
   updateLockIconClickability();
 }
Example #3
0
 private void updateLockIconClickability() {
   if (mAccessibilityController == null) {
     return;
   }
   boolean clickToUnlock = mAccessibilityController.isTouchExplorationEnabled();
   boolean clickToForceLock =
       mUnlockMethodCache.isTrustManaged() && !mAccessibilityController.isAccessibilityEnabled();
   boolean longClickToForceLock = mUnlockMethodCache.isTrustManaged() && !clickToForceLock;
   mLockIcon.setClickable(clickToForceLock || clickToUnlock);
   mLockIcon.setLongClickable(longClickToForceLock);
   mLockIcon.setFocusable(mAccessibilityController.isAccessibilityEnabled());
 }
Example #4
0
 private void updateLockIcon() {
   boolean visible = isShown() && KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
   if (visible) {
     mTrustDrawable.start();
   } else {
     mTrustDrawable.stop();
   }
   if (!visible) {
     return;
   }
   // TODO: Real icon for facelock.
   int iconRes =
       mUnlockMethodCache.isFaceUnlockRunning()
           ? com.android.internal.R.drawable.ic_account_circle
           : mUnlockMethodCache.isMethodInsecure()
               ? R.drawable.ic_lock_open_24dp
               : R.drawable.ic_lock_24dp;
   if (mLastUnlockIconRes != iconRes) {
     Drawable icon = mContext.getDrawable(iconRes);
     int iconHeight =
         getResources().getDimensionPixelSize(R.dimen.keyguard_affordance_icon_height);
     int iconWidth = getResources().getDimensionPixelSize(R.dimen.keyguard_affordance_icon_width);
     if (icon.getIntrinsicHeight() != iconHeight || icon.getIntrinsicWidth() != iconWidth) {
       icon = new IntrinsicSizeDrawable(icon, iconWidth, iconHeight);
     }
     mLockIcon.setImageDrawable(icon);
   }
   boolean trustManaged = mUnlockMethodCache.isTrustManaged();
   mTrustDrawable.setTrustManaged(trustManaged);
   updateLockIconClickability();
 }
Example #5
0
 private void updateCameraVisibility() {
   ResolveInfo resolved =
       mContext
           .getPackageManager()
           .resolveActivityAsUser(
               getCameraIntent(),
               PackageManager.MATCH_DEFAULT_ONLY,
               mLockPatternUtils.getCurrentUser());
   boolean visible =
       !isCameraDisabledByDpm()
           && resolved != null
           && getResources().getBoolean(R.bool.config_keyguardShowCameraAffordance);
   mCameraImageView.setVisibility(visible ? View.VISIBLE : View.GONE);
 }
Example #6
0
 private void updatePhoneVisibility() {
   boolean visible = isPhoneVisible();
   mPhoneImageView.setVisibility(visible ? View.VISIBLE : View.GONE);
 }
Example #7
0
 private void initAccessibility() {
   mLockIcon.setAccessibilityDelegate(mAccessibilityDelegate);
   mPhoneImageView.setAccessibilityDelegate(mAccessibilityDelegate);
   mCameraImageView.setAccessibilityDelegate(mAccessibilityDelegate);
 }