Bug 735137 - Strict mode violation in TabsTray.onCreate. r=mfinkle
authorRichard Newman <rnewman@mozilla.com>
Tue, 13 Mar 2012 08:15:43 -0700
changeset 91883 4adb8d45aff425701825d94a896c346e3d25461d
parent 91882 bccdef36473e6d3a2d26177b47637e05eec22a53
child 91884 62a7efdac3ddf9b3aa766e81a95c3ebf1bc25e88
push idunknown
push userunknown
push dateunknown
reviewersmfinkle
bugs735137
milestone13.0a2
Bug 735137 - Strict mode violation in TabsTray.onCreate. r=mfinkle
mobile/android/base/TabsTray.java
--- a/mobile/android/base/TabsTray.java
+++ b/mobile/android/base/TabsTray.java
@@ -1,44 +1,12 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Android code.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2011
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Sriram Ramasubramanian <sriram@mozilla.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import java.util.ArrayList;
 
 import android.accounts.AccountManager;
 import android.app.Activity;
 import android.content.Context;
@@ -55,16 +23,18 @@ import android.widget.BaseAdapter;
 import android.widget.Button;
 import android.widget.ImageButton;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.ListView;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
+import org.mozilla.gecko.sync.setup.SyncAccounts;
+
 public class TabsTray extends Activity implements Tabs.OnTabsChangedListener {
 
     private static int sPreferredHeight;
     private static int sMaxHeight;
     private static int sListItemHeight;
     private static int sAddTabHeight;
     private static ListView mList;
     private static TabsListContainer mListContainer;
@@ -117,29 +87,33 @@ public class TabsTray extends Activity i
         sPreferredHeight = (int) (0.67 * metrics.heightPixels);
         sMaxHeight = (int) (sPreferredHeight + (0.33 * sListItemHeight));
 
         Tabs tabs = Tabs.getInstance();
         tabs.registerOnTabsChangedListener(this);
         tabs.refreshThumbnails();
         onTabChanged(null, null);
 
-         // If sync is set up, query the database for remote clients
-         // Cleanup after Bug: 734211 is fixed
-         if (AccountManager.get(getApplicationContext()).getAccountsByType("org.mozilla.firefox_sync").length > 0) {
-             TabsAccessor.areClientsAvailable(getApplicationContext(), new TabsAccessor.OnClientsAvailableListener() {
-                 @Override
-                 public void areAvailable(boolean available) {
-                     if (available)
-                         mRemoteTabs.setVisibility(View.VISIBLE);
-                     else
-                         mRemoteTabs.setVisibility(View.GONE);
-                 }
-             });
-        }
+        // If Sync is set up, query the database for remote clients.
+        final Context context = getApplicationContext();
+        new SyncAccounts.AccountsExistTask() {
+            @Override
+            protected void onPostExecute(Boolean result) {
+                if (!result.booleanValue()) {
+                    return;
+                }
+                TabsAccessor.areClientsAvailable(context, new TabsAccessor.OnClientsAvailableListener() {
+                    @Override
+                    public void areAvailable(boolean available) {
+                        final int visibility = available ? View.VISIBLE : View.GONE;
+                        mRemoteTabs.setVisibility(visibility);
+                    }
+                });
+            }
+        }.execute(context);
     }
 
     @Override
     public void onDestroy() {
         super.onDestroy();
         Tabs.getInstance().unregisterOnTabsChangedListener(this);
     }