Merge "Fix infinite resizing by using RigidWebView." into jb-ub-mail-ur10
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d350098..67ebd10 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -901,11 +901,6 @@
         receiving any new mail. [CHAR LIMIT=250] -->
     <string name="account_sync_off">Account sync is off.</string>
 
-    <!-- Tip for letting user know that airplane mode is enabled on
-        their device, in case they are wondering why they are not
-        receiving any new mail. [CHAR LIMIT=250] -->
-    <string name="airplane_mode_on">Airplane mode is on</string>
-
     <!-- Hint text for user to enable sync in Gmail's account settings.
          The whole string should read "Turn on in Account settings.", but because we need
          "Account settings" to appear as blue link text, it's a parameter here.
diff --git a/src/com/android/mail/preferences/MailPrefs.java b/src/com/android/mail/preferences/MailPrefs.java
index a0f320c..f13e298 100644
--- a/src/com/android/mail/preferences/MailPrefs.java
+++ b/src/com/android/mail/preferences/MailPrefs.java
@@ -451,22 +451,4 @@
                 PreferenceKeys.GLOBAL_SYNC_OFF_DISMISSES, 0);
         getEditor().putInt(PreferenceKeys.GLOBAL_SYNC_OFF_DISMISSES, value + 1).apply();
     }
-
-    public int getNumOfDismissesForAirplaneModeOn() {
-        return getSharedPreferences().getInt(PreferenceKeys.AIRPLANE_MODE_ON_DISMISSES, 0);
-    }
-
-    public void resetNumOfDismissesForAirplaneModeOn() {
-        final int value = getSharedPreferences().getInt(
-                PreferenceKeys.AIRPLANE_MODE_ON_DISMISSES, 0);
-        if (value != 0) {
-            getEditor().putInt(PreferenceKeys.AIRPLANE_MODE_ON_DISMISSES, 0).apply();
-        }
-    }
-
-    public void incNumOfDismissesForAirplaneModeOn() {
-        final int value = getSharedPreferences().getInt(
-                PreferenceKeys.AIRPLANE_MODE_ON_DISMISSES, 0);
-        getEditor().putInt(PreferenceKeys.AIRPLANE_MODE_ON_DISMISSES, value + 1).apply();
-    }
 }
diff --git a/src/com/android/mail/ui/AbstractActivityController.java b/src/com/android/mail/ui/AbstractActivityController.java
index 9a22a60..7bd5e79 100644
--- a/src/com/android/mail/ui/AbstractActivityController.java
+++ b/src/com/android/mail/ui/AbstractActivityController.java
@@ -842,6 +842,12 @@
                 ? DrawerLayout.LOCK_MODE_UNLOCKED : DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
 
         mDrawerContainer.closeDrawers();
+
+        if (mFolder == null || !mFolder.equals(folder)) {
+            // We are actually changing the folder, so exit cab mode
+            exitCabMode();
+        }
+
         changeFolder(folder, null, force);
     }
 
@@ -4128,6 +4134,11 @@
             if (mHasNewAccountOrFolder) {
                 refreshDrawer();
             }
+
+            // When closed, we want to use either the burger, or up, based on where we are
+            final int mode = mViewMode.getMode();
+            final boolean isTopLevel = (mFolder == null) || (mFolder.parent == Uri.EMPTY);
+            mDrawerToggle.setDrawerIndicatorEnabled(getShouldShowDrawerIndicator(mode, isTopLevel));
         }
 
         /**
@@ -4184,6 +4195,9 @@
             }
 
             mOldSlideOffset = slideOffset;
+
+            // If we're sliding, we always want to show the burger
+            mDrawerToggle.setDrawerIndicatorEnabled(true /* enable */);
         }
 
         /**
diff --git a/src/com/android/mail/ui/ConversationListView.java b/src/com/android/mail/ui/ConversationListView.java
index 26e47d3..2a8fe20 100644
--- a/src/com/android/mail/ui/ConversationListView.java
+++ b/src/com/android/mail/ui/ConversationListView.java
@@ -346,14 +346,6 @@
                     mAccountPreferences.incNumOfDismissesForAccountSyncOff();
                 }
                 break;
-            case ReasonSyncOff.AIRPLANE_MODE_ON:
-                num = mMailPrefs.getNumOfDismissesForAirplaneModeOn();
-                if (num > 0 && num <= MAX_NUM_OF_SYNC_TOASTS) {
-                    Toast.makeText(getContext(), R.string.airplane_mode_on, Toast.LENGTH_SHORT)
-                            .show();
-                    mMailPrefs.incNumOfDismissesForAirplaneModeOn();
-                }
-                break;
         }
     }
 
diff --git a/src/com/android/mail/ui/ConversationSyncDisabledTipView.java b/src/com/android/mail/ui/ConversationSyncDisabledTipView.java
index b5f3977..9d37edf 100644
--- a/src/com/android/mail/ui/ConversationSyncDisabledTipView.java
+++ b/src/com/android/mail/ui/ConversationSyncDisabledTipView.java
@@ -91,8 +91,6 @@
         public static final int AUTO_SYNC_OFF = 1;
         // Global auto-sync is on, but Gmail app level sync is disabled for this particular account
         public static final int ACCOUNT_SYNC_OFF = 2;
-        // Auto-sync is enabled at both device and account level, but device is in airplane mode
-        public static final int AIRPLANE_MODE_ON = 3;
     }
 
     public ConversationSyncDisabledTipView(final Context context) {
@@ -207,8 +205,6 @@
                 return (mMailPrefs.getNumOfDismissesForAutoSyncOff() == 0);
             case ReasonSyncOff.ACCOUNT_SYNC_OFF:
                 return (mAccountPreferences.getNumOfDismissesForAccountSyncOff() == 0);
-            case ReasonSyncOff.AIRPLANE_MODE_ON:
-                return (mMailPrefs.getNumOfDismissesForAirplaneModeOn() == 0);
             default:
                 return false;
         }
@@ -219,7 +215,6 @@
         if (!ContentResolver.getMasterSyncAutomatically()) {
             // Global sync is turned off
             accountPreferences.resetNumOfDismissesForAccountSyncOff();
-            mailPrefs.resetNumOfDismissesForAirplaneModeOn();
             // Logging to track down bug where this tip is being showing when it shouldn't be.
             LogUtils.i(LOG_TAG, "getMasterSyncAutomatically() return false");
             return ReasonSyncOff.AUTO_SYNC_OFF;
@@ -235,20 +230,12 @@
             if (!TextUtils.isEmpty(account.syncAuthority) &&
                     !ContentResolver.getSyncAutomatically(acct, account.syncAuthority)) {
                 // Account level sync is off
-                mailPrefs.resetNumOfDismissesForAirplaneModeOn();
                 return ReasonSyncOff.ACCOUNT_SYNC_OFF;
             } else {
                 // Account sync is on, clear the number of times users has dismissed this
                 // warning so that next time sync is off, warning gets displayed again.
                 accountPreferences.resetNumOfDismissesForAccountSyncOff();
-
-                // Now check for whether airplane mode is on
-                if (Utils.isAirplaneModeOnAndDeviceOffline(context)) {
-                    return ReasonSyncOff.AIRPLANE_MODE_ON;
-                } else {
-                    mailPrefs.resetNumOfDismissesForAirplaneModeOn();
-                    return ReasonSyncOff.NONE;
-                }
+                return ReasonSyncOff.NONE;
             }
         }
     }
@@ -271,11 +258,6 @@
                     mTextArea.setClickable(true);
                     mTextArea.setOnClickListener(mAccountSyncOffTextClickedListener);
                     break;
-                case ReasonSyncOff.AIRPLANE_MODE_ON:
-                    mText1.setText(R.string.airplane_mode_on);
-                    mText2.setVisibility(View.GONE);
-                    mTextArea.setClickable(false);
-                    break;
                 default:
                     // Doesn't matter what mText is since this view is not displayed
             }
@@ -342,10 +324,6 @@
                 mAccountPreferences.incNumOfDismissesForAccountSyncOff();
                 reason = "account_sync_off";
                 break;
-            case ReasonSyncOff.AIRPLANE_MODE_ON:
-                mMailPrefs.incNumOfDismissesForAirplaneModeOn();
-                reason = "airplane_mode_on";
-                break;
             default:
                 reason = null;
                 break;
diff --git a/src/com/android/mail/ui/TwoPaneController.java b/src/com/android/mail/ui/TwoPaneController.java
index 976dfa2..e3a88c6 100644
--- a/src/com/android/mail/ui/TwoPaneController.java
+++ b/src/com/android/mail/ui/TwoPaneController.java
@@ -159,12 +159,6 @@
     }
 
     @Override
-    public void onFolderChanged(Folder folder, final boolean force) {
-        super.onFolderChanged(folder, force);
-        exitCabMode();
-    }
-
-    @Override
     public void onFolderSelected(Folder folder) {
         // It's possible that we are not in conversation list mode
         if (mViewMode.getMode() != ViewMode.CONVERSATION_LIST) {
diff --git a/src/com/android/mail/utils/Utils.java b/src/com/android/mail/utils/Utils.java
index 15fb444..f3fd875 100644
--- a/src/com/android/mail/utils/Utils.java
+++ b/src/com/android/mail/utils/Utils.java
@@ -33,14 +33,11 @@
 import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.Typeface;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
 import android.net.Uri;
 import android.os.AsyncTask;
 import android.os.Build;
 import android.os.Bundle;
 import android.provider.Browser;
-import android.provider.Settings;
 import android.text.Spannable;
 import android.text.SpannableString;
 import android.text.SpannableStringBuilder;
@@ -1407,23 +1404,4 @@
         }
     }
 
-    public static boolean isAirplaneModeOnAndDeviceOffline(Context context) {
-        final int airplaneMode;
-        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
-            airplaneMode = Settings.System.getInt(context.getContentResolver(),
-                    Settings.System.AIRPLANE_MODE_ON, 0);
-        } else {
-            airplaneMode = Settings.Global.getInt(context.getContentResolver(),
-                    Settings.Global.AIRPLANE_MODE_ON, 0);
-        }
-        if (airplaneMode == 0) {
-            return false;
-        }
-        // Otherwise check if device is online, since it's possible to still use
-        // wifi when airplane mode is on
-        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(
-                Context.CONNECTIVITY_SERVICE);
-        NetworkInfo info = connectivityManager.getActiveNetworkInfo();
-        return (info == null || !info.isConnected());
-    }
 }