Merge "Updating Settings icons in side menu Bug: 3362749" into honeycomb
diff --git a/res/drawable-hdpi/icon.png b/res/drawable-hdpi/icon.png
deleted file mode 100644
index 36ace47..0000000
--- a/res/drawable-hdpi/icon.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/icon.png b/res/drawable-mdpi/icon.png
deleted file mode 100644
index a8cddf3..0000000
--- a/res/drawable-mdpi/icon.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/crypt_keeper_confirm.xml b/res/layout/crypt_keeper_confirm.xml
index a121caa..b197aa6 100644
--- a/res/layout/crypt_keeper_confirm.xml
+++ b/res/layout/crypt_keeper_confirm.xml
@@ -19,18 +19,28 @@
     android:orientation="vertical"
     >
 
-    <TextView
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginLeft="12dp"
-        android:layout_marginRight="12dp"
-        android:layout_marginTop="12dp"
-        android:textSize="20sp"
-        android:text="@string/crypt_keeper_final_desc" />
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="0dip"
+        android:layout_marginLeft="16dp"
+        android:layout_marginRight="16dp"
+        android:layout_marginTop="16dp"
+        android:layout_weight="1"
+    >
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="8dip"
+            android:layout_marginBottom="16dip"
+            android:textAppearance="?android:attr/textAppearanceMedium"
+            android:text="@string/crypt_keeper_final_desc"
+        />
+    </ScrollView>
 
     <Button android:id="@+id/execute_encrypt"
         android:layout_gravity="center_horizontal"
-        android:layout_marginTop="40dip"
+        android:layout_marginTop="16dip"
+        android:layout_marginBottom="16dip"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/crypt_keeper_button_text"
diff --git a/res/layout/crypt_keeper_settings.xml b/res/layout/crypt_keeper_settings.xml
index 6428719..3239aa9 100644
--- a/res/layout/crypt_keeper_settings.xml
+++ b/res/layout/crypt_keeper_settings.xml
@@ -21,31 +21,58 @@
 >
 
     <ScrollView
-		android:layout_width="match_parent"
-		android:layout_height="0dip"
-		android:layout_marginLeft="12dp"
-		android:layout_marginRight="12dp"
-		android:layout_marginTop="12dp"
-		android:layout_weight="1"
+        android:layout_width="match_parent"
+        android:layout_height="0dip"
+        android:layout_marginLeft="16dp"
+        android:layout_marginRight="16dp"
+        android:layout_marginTop="16dp"
+        android:layout_weight="1"
     >
-		
-		<TextView
-		    android:layout_width="match_parent"
-		    android:layout_height="wrap_content"
-		    android:textSize="18sp"
-		    android:text="@string/crypt_keeper_desc"
-		/>
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+        >
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="8dip"
+                android:layout_marginBottom="16dip"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="@string/crypt_keeper_desc"
+            />
+            <TextView
+                android:id="@+id/warning_low_charge"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="16dip"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:textStyle="bold"
+                android:text="@string/crypt_keeper_low_charge_text"
+                android:visibility="gone"
+            />
+            <TextView
+                android:id="@+id/warning_unplugged"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="16dip"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:textStyle="bold"
+                android:text="@string/crypt_keeper_unplugged_text"
+                android:visibility="gone"
+            />
+        </LinearLayout>
 
     </ScrollView>
     <Button
-		android:id="@+id/initiate_encrypt"
-		android:layout_gravity="center_horizontal"
-		android:layout_marginTop="20dip"
-		android:layout_marginBottom="12dip"
-		android:layout_width="wrap_content"
-		android:layout_height="wrap_content"
-		android:text="@string/crypt_keeper_button_text"
-		android:gravity="center" 
+        android:id="@+id/initiate_encrypt"
+        android:layout_gravity="center_horizontal"
+        android:layout_marginTop="16dip"
+        android:layout_marginBottom="16dip"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/crypt_keeper_button_text"
+        android:gravity="center" 
     />
 
 </LinearLayout>
diff --git a/res/layout/preference_bluetooth_profile.xml b/res/layout/preference_bluetooth_profile.xml
index 4b6f1dd..1ed971e 100644
--- a/res/layout/preference_bluetooth_profile.xml
+++ b/res/layout/preference_bluetooth_profile.xml
@@ -36,6 +36,6 @@
         android:layout_gravity="center_vertical"
         android:padding="8dip"
         android:background="?android:attr/selectableItemBackground"
-        android:src="@drawable/icon" />
+        android:src="@drawable/ic_bt_config" />
 
 </LinearLayout>
diff --git a/res/mipmap-hdpi/ic_launcher_settings.png b/res/mipmap-hdpi/ic_launcher_settings.png
index ff34a7f..0cf5e46 100644
--- a/res/mipmap-hdpi/ic_launcher_settings.png
+++ b/res/mipmap-hdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/mipmap-mdpi/ic_launcher_settings.png b/res/mipmap-mdpi/ic_launcher_settings.png
index a8cddf3..3c1eddf 100644
--- a/res/mipmap-mdpi/ic_launcher_settings.png
+++ b/res/mipmap-mdpi/ic_launcher_settings.png
Binary files differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5122d78..270041d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -582,22 +582,26 @@
     <!-- In the security screen, the header title for settings related to  Passwords-->
     <string name="security_passwords_title">Passwords</string>
 
+    <!-- Title of the preferences category for preference items to control encryption -->
     <string name="crypt_keeper_settings_title">Encryption</string>
 
+    <!-- Title of the preferences item to control encryption -->
     <string name="crypt_keeper_encrypt_title" product="tablet">Encrypt tablet</string>
+    <!-- Title of the preferences item to control encryption -->
     <string name="crypt_keeper_encrypt_title" product="default">Encrypt phone</string>
 
+    <!-- Summary of the preferences item to control encryption, when encryption is inactive -->
     <string name="crypt_keeper_encrypt_summary" product="tablet">
     Require a numeric PIN or password to decrypt your tablet each time you
     power it on</string>
+    <!-- Summary of the preferences item to control encryption, when encryption is inactive -->
     <string name="crypt_keeper_encrypt_summary" product="default">
     Require a numeric PIN or password to decrypt your phone each time you
     power it on</string>
+    <!-- Summary of the preferences item to control encryption, when encryption is active -->
     <string name="crypt_keeper_encrypted_summary">Encrypted</string>
 
-    <string name="crypt_keeper_confirm_title">Confirm encryption</string>
-
-    
+    <!-- Informational text in the first confirmation screen before starting device encryption -->
     <string name="crypt_keeper_desc" product="tablet">
     You can encrypt your accounts, settings, downloaded applications and their data,
     media, and other files. Once you encrypt your tablet, you must enter a numeric PIN
@@ -606,6 +610,7 @@
     an hour or more. You must start with a charged battery and keep your tablet plugged in
     until encryption is complete. If you interrupt the encryption process, you will lose
     some or all of your data.</string>
+    <!-- Informational text in the first confirmation screen before starting device encryption -->
     <string name="crypt_keeper_desc" product="default">
     You can encrypt your accounts, settings, downloaded applications and their data,
     media, and other files. Once you encrypt your phone, you must enter a numeric PIN or
@@ -615,24 +620,40 @@
     until encryption is complete. If you interrupt the encryption process, you will lose
     some or all of your data.</string>
     
+    <!-- Button text to start encryption process -->
     <string name="crypt_keeper_button_text" product="tablet">Encrypt tablet</string>
+    <!-- Button text to start encryption process -->
     <string name="crypt_keeper_button_text" product="default">Encrypt phone</string>
 
+    <!-- Warning string that will be displayed when encryption cannot be started -->
     <string name="crypt_keeper_low_charge_text">Please charge your battery and try again.</string>
+    <!-- Warning string that will be displayed when encryption cannot be started -->
     <string name="crypt_keeper_unplugged_text">Please plug in your charger and try again.</string>
 
+    <!-- Title of the final confirmation screen before starting device encryption -->
+    <string name="crypt_keeper_confirm_title">Confirm encryption</string>
+    <!-- Warning text in the final confirmation screen before starting device encryption -->
     <string name="crypt_keeper_final_desc" product="tablet">
-    Encrypt tablet? This operation is irreversible and if you interrupt it,
-    you will lose data! Encryption takes an hour or more.</string>
+    Encrypt tablet? This operation is irreversible and if you interrupt it, you will lose data.
+    Encryption takes an hour or more, during which the tablet will restart several times.
+    </string>
+    <!-- Warning text in the final confirmation screen before starting device encryption -->
     <string name="crypt_keeper_final_desc" product="default">
-    Encrypt phone? This operation is irreversible and if you interrupt it,
-    you will lose data! Encryption takes an hour or more.</string>
-    
+    Encrypt phone? This operation is irreversible and if you interrupt it, you will lose data.
+    Encryption takes an hour or more, during which the phone will restart several times.
+    </string>
+
+    <!-- Title of the progress screen while encrypting the device -->
     <string name="crypt_keeper_setup_title">Encrypting</string>
 
-    <string name="crypt_keeper_setup_description" product="tablet">Please wait while your tablet is being encrypted. ^1% complete.</string>
-    <string name="crypt_keeper_setup_description" product="default">Please wait while your phone is being encrypted. ^1% complete.</string>
+    <!-- Informational text on the progress screen while encrypting the device -->
+    <string name="crypt_keeper_setup_description" product="tablet">Please wait while your tablet
+    is being encrypted. ^1% complete.</string>
+    <!-- Informational text on the progress screen while encrypting the device -->
+    <string name="crypt_keeper_setup_description" product="default">Please wait while your phone
+    is being encrypted. ^1% complete.</string>
 
+    <!-- Informational text on the progress screen when encrypting the device has a problem -->
     <string name="crypt_keeper_cooldown">Try again in ^1 seconds.</string>
     
     <!-- Unlock Picker Settings --><skip />
@@ -982,7 +1003,7 @@
     <!-- Checkbox summary for option to notify user when open networks are nearby -->
     <string name="wifi_notify_open_networks_summary">Notify me when an open network is available</string>
     <!-- Setting title for setting the wifi sleep policy -->
-    <string name="wifi_setting_sleep_policy_title">Disconnect from Wi-Fi</string>
+    <string name="wifi_setting_sleep_policy_title">Wi-Fi disconnect policy</string>
     <!-- Setting summary for setting the wifi sleep policy -->
     <string name="wifi_setting_sleep_policy_summary">Specify when to switch from Wi-Fi to mobile data</string>
     <!-- Generic error message when the sleep policy could not be set. -->
diff --git a/src/com/android/settings/CryptKeeperSettings.java b/src/com/android/settings/CryptKeeperSettings.java
index e584a3d..02982b7 100644
--- a/src/com/android/settings/CryptKeeperSettings.java
+++ b/src/com/android/settings/CryptKeeperSettings.java
@@ -16,6 +16,8 @@
 
 package com.android.settings;
 
+import com.android.internal.widget.LockPatternUtils;
+
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.Fragment;
@@ -49,8 +51,18 @@
 
     private static final int KEYGUARD_REQUEST = 55;
 
+    // This is the minimum acceptable password quality.  If the current password quality is
+    // lower than this, encryption should not be activated.
+    private static final int MIN_PASSWORD_QUALITY = DevicePolicyManager.PASSWORD_QUALITY_NUMERIC;
+
+    // Minimum battery charge level (in percent) to launch encryption.  If the battery charge is
+    // lower than this, encryption should not be activated.
+    private static final int MIN_BATTERY_LEVEL = 80;
+
     private View mContentView;
     private Button mInitiateButton;
+    private View mPowerWarning;
+    private View mBatteryWarning;
     private IntentFilter mIntentFilter;
 
     private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@@ -60,12 +72,12 @@
             if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
                 int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
                 int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
-
-                if (plugged == BatteryManager.BATTERY_PLUGGED_AC && level >= 80) {
-                    mInitiateButton.setEnabled(true);
-                } else {
-                    mInitiateButton.setEnabled(false);
-                }
+                boolean levelOk = level >= MIN_BATTERY_LEVEL;
+                boolean pluggedOk = plugged == BatteryManager.BATTERY_PLUGGED_AC;
+                // Update UI elements based on power/battery status
+                mInitiateButton.setEnabled(levelOk && pluggedOk);
+                mPowerWarning.setVisibility(pluggedOk ? View.GONE : View.VISIBLE );
+                mBatteryWarning.setVisibility(levelOk ? View.GONE : View.VISIBLE);
             }
         }
     };
@@ -102,6 +114,9 @@
         mInitiateButton.setOnClickListener(mInitiateListener);
         mInitiateButton.setEnabled(false);
 
+        mPowerWarning = mContentView.findViewById(R.id.warning_unplugged);
+        mBatteryWarning = mContentView.findViewById(R.id.warning_low_charge);
+
         return mContentView;
     }
 
@@ -146,6 +161,12 @@
      * @return true if confirmation launched
      */
     private boolean runKeyguardConfirmation(int request) {
+        // 1.  Confirm that we have a sufficient PIN/Password to continue
+        int quality = new LockPatternUtils(getActivity()).getKeyguardStoredPasswordQuality();
+        if (quality < MIN_PASSWORD_QUALITY) {
+            return false;
+        }
+        // 2.  Ask the user to confirm the current PIN/Password
         Resources res = getActivity().getResources();
         return new ChooseLockSettingsHelper(getActivity(), this)
                 .launchConfirmationActivity(request,