Merge "Set the bidi flags on Paints in DonutView" into oc-mr1-dev
diff --git a/src/com/android/settings/notification/ZenModeRuleSettingsBase.java b/src/com/android/settings/notification/ZenModeRuleSettingsBase.java
index 5629b17..4abdd7e 100644
--- a/src/com/android/settings/notification/ZenModeRuleSettingsBase.java
+++ b/src/com/android/settings/notification/ZenModeRuleSettingsBase.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.notification;
 
+import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.AutomaticZenRule;
 import android.app.NotificationManager;
@@ -262,8 +263,14 @@
     }
 
     private void updateRuleName() {
-        getActivity().setTitle(mRule.getName());
-        mRuleName.setSummary(mRule.getName());
+        Activity activity = getActivity();
+        if (activity != null) {
+            activity.setTitle(mRule.getName());
+            mRuleName.setSummary(mRule.getName());
+        } else {
+            if (DEBUG) Log.d(TAG, "updateRuleName - activity title and mRuleName "
+                    + "not updated; getActivity() returned null");
+        }
     }
 
     private AutomaticZenRule getZenRule() {
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
index 64f3a6f..a67184a 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
@@ -77,6 +77,9 @@
     protected static final int USER_TYPE_MANAGED_PROFILE = 2;
     protected static final int USER_TYPE_SECONDARY = 3;
 
+    /** Time we wait before clearing a wrong input attempt (e.g. pattern) and the error message. */
+    protected static final long CLEAR_WRONG_ATTEMPT_TIMEOUT_MS = 3000;
+
     private FingerprintUiHelper mFingerprintHelper;
     protected boolean mReturnCredentials = false;
     protected Button mCancelButton;
diff --git a/src/com/android/settings/password/ConfirmLockPassword.java b/src/com/android/settings/password/ConfirmLockPassword.java
index dcb7b66..20182cb 100644
--- a/src/com/android/settings/password/ConfirmLockPassword.java
+++ b/src/com/android/settings/password/ConfirmLockPassword.java
@@ -93,7 +93,6 @@
     public static class ConfirmLockPasswordFragment extends ConfirmDeviceCredentialBaseFragment
             implements OnClickListener, OnEditorActionListener,
             CredentialCheckResultTracker.Listener {
-        private static final long ERROR_MESSAGE_TIMEOUT = 3000;
         private static final String FRAGMENT_TAG_CHECK_LOCK_RESULT = "check_lock_result";
         private ImeAwareEditText mPasswordEntry;
         private TextViewInputDisabler mPasswordEntryInputDisabler;
@@ -460,7 +459,7 @@
                             effectiveUserId, timeoutMs);
                     handleAttemptLockout(deadline);
                 } else {
-                    showError(getErrorMessage(), ERROR_MESSAGE_TIMEOUT);
+                    showError(getErrorMessage(), CLEAR_WRONG_ATTEMPT_TIMEOUT_MS);
                 }
                 if (newResult) {
                     reportFailedAttempt();
diff --git a/src/com/android/settings/password/ConfirmLockPattern.java b/src/com/android/settings/password/ConfirmLockPattern.java
index 60d5a01..1e88150 100644
--- a/src/com/android/settings/password/ConfirmLockPattern.java
+++ b/src/com/android/settings/password/ConfirmLockPattern.java
@@ -79,9 +79,6 @@
     public static class ConfirmLockPatternFragment extends ConfirmDeviceCredentialBaseFragment
             implements AppearAnimationCreator<Object>, CredentialCheckResultTracker.Listener {
 
-        // how long we wait to clear a wrong pattern
-        private static final int WRONG_PATTERN_CLEAR_TIMEOUT_MS = 2000;
-
         private static final String FRAGMENT_TAG_CHECK_LOCK_RESULT = "check_lock_result";
 
         private LockPatternView mLockPatternView;
@@ -315,7 +312,8 @@
                     mLockPatternView.clearPattern();
                     break;
                 case NeedToUnlockWrong:
-                    mErrorTextView.setText(R.string.lockpattern_need_to_unlock_wrong);
+                    showError(R.string.lockpattern_need_to_unlock_wrong,
+                            CLEAR_WRONG_ATTEMPT_TIMEOUT_MS);
 
                     mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
                     mLockPatternView.setEnabled(true);
@@ -349,7 +347,7 @@
         // already
         private void postClearPatternRunnable() {
             mLockPatternView.removeCallbacks(mClearPatternRunnable);
-            mLockPatternView.postDelayed(mClearPatternRunnable, WRONG_PATTERN_CLEAR_TIMEOUT_MS);
+            mLockPatternView.postDelayed(mClearPatternRunnable, CLEAR_WRONG_ATTEMPT_TIMEOUT_MS);
         }
 
         @Override
diff --git a/src/com/android/settings/widget/LabeledSeekBar.java b/src/com/android/settings/widget/LabeledSeekBar.java
index f1a6788..8e5a30b 100644
--- a/src/com/android/settings/widget/LabeledSeekBar.java
+++ b/src/com/android/settings/widget/LabeledSeekBar.java
@@ -201,6 +201,7 @@
             int posBase = Math.max(0,
                     ((int) x - LabeledSeekBar.this.getPaddingStart()) / getHalfVirtualViewWidth());
             posBase = (posBase + 1) / 2;
+            posBase = Math.min(posBase, LabeledSeekBar.this.getMax());
             return mIsLayoutRtl ? LabeledSeekBar.this.getMax() - posBase : posBase;
         }