Bug 1178378 - Enable profile click action based on native accounts UI r=nalexander
authorvivek <vivekb.balakrishnan@gmail.com>
Tue, 22 Sep 2015 22:02:40 +0300
changeset 263965 b9cb665a797d20443c3be688d019933d24cdf178
parent 263964 f80d1207c76c601f9165a44173b0b042c7566340
child 263966 faacd1e73967ff77138806ca5e9d833990b4238f
push id65484
push usercbook@mozilla.com
push dateWed, 23 Sep 2015 10:47:13 +0000
treeherdermozilla-inbound@88067e5193f0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1178378
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1178378 - Enable profile click action based on native accounts UI r=nalexander
mobile/android/base/fxa/FxAccountConstants.java
mobile/android/base/fxa/activities/FxAccountStatusFragment.java
mobile/android/base/resources/xml/fxaccount_status_prefscreen.xml
--- a/mobile/android/base/fxa/FxAccountConstants.java
+++ b/mobile/android/base/fxa/FxAccountConstants.java
@@ -27,17 +27,17 @@ public class FxAccountConstants {
   public static final String ACCOUNT_PROFILE_JSON_UPDATED_ACTION = "org.mozilla.gecko.fxa.profile.JSON.updated";
 
   // You must be at least 13 years old, on the day of creation, to create a Firefox Account.
   public static final int MINIMUM_AGE_TO_CREATE_AN_ACCOUNT = 13;
 
   // Key for avatar URI in profile JSON.
   public static final String KEY_PROFILE_JSON_AVATAR = "avatar";
   // Key for username in profile JSON.
-  public static final String KEY_PROFILE_JSON_USERNAME = "username";
+  public static final String KEY_PROFILE_JSON_USERNAME = "displayName";
 
   // You must wait 15 minutes after failing an age check before trying to create a different account.
   public static final long MINIMUM_TIME_TO_WAIT_AFTER_AGE_CHECK_FAILED_IN_MILLISECONDS = 15 * 60 * 1000;
 
   public static final String USER_AGENT = "Firefox-Android-FxAccounts/" + AppConstants.MOZ_APP_VERSION + " (" + AppConstants.MOZ_APP_DISPLAYNAME + ")";
 
   public static final String ACCOUNT_PICKLE_FILENAME = "fxa.account.json";
 
--- a/mobile/android/base/fxa/activities/FxAccountStatusFragment.java
+++ b/mobile/android/base/fxa/activities/FxAccountStatusFragment.java
@@ -237,16 +237,23 @@ public class FxAccountStatusFragment
    */
   @Override
   public void onResume() {
     super.onResume();
   }
 
   @Override
   public boolean onPreferenceClick(Preference preference) {
+    if (preference == profilePreference) {
+      if (!AppConstants.MOZ_ANDROID_NATIVE_ACCOUNT_UI) {
+        // There is no native equivalent, bind the click action to fire an intent.
+        ActivityUtils.openURLInFennec(getActivity().getApplicationContext(), "about:accounts?action=avatar");
+      }
+    }
+
     if (preference == manageAccountPreference) {
       // There's no native equivalent, so no need to re-direct through an Intent filter.
       ActivityUtils.openURLInFennec(getActivity().getApplicationContext(), "about:accounts?action=manage");
       return true;
     }
 
     if (preference == needsPasswordPreference) {
       final Intent intent = new Intent(FxAccountConstants.ACTION_FXA_UPDATE_CREDENTIALS);
@@ -477,17 +484,16 @@ public class FxAccountStatusFragment
     // onResume/onPause calls, but because the Fragment gets onResume during the
     // Activity's super.onResume, it hasn't yet been told its Firefox Account.
     // So we register the observer here (and remove it in onPause), and open
     // ourselves to the possibility that we don't have properly paired
     // register/unregister calls.
     FxAccountSyncStatusHelper.getInstance().startObserving(syncStatusDelegate);
 
     if (AppConstants.MOZ_ANDROID_FIREFOX_ACCOUNT_PROFILES) {
-      profilePreference.getIntent().setData(Uri.parse("about:accounts?action=avatar"));
       // Register a local broadcast receiver to get profile cached notification.
       final IntentFilter intentFilter = new IntentFilter();
       intentFilter.addAction(FxAccountConstants.ACCOUNT_PROFILE_JSON_UPDATED_ACTION);
       accountProfileInformationReceiver = new FxAccountProfileInformationReceiver();
       LocalBroadcastManager.getInstance(getActivity()).registerReceiver(accountProfileInformationReceiver, intentFilter);
 
       // profilePreference is set during onCreate, so it's definitely not null here.
       final float cornerRadius = getResources().getDimension(R.dimen.fxaccount_profile_image_width) / 2;
--- a/mobile/android/base/resources/xml/fxaccount_status_prefscreen.xml
+++ b/mobile/android/base/resources/xml/fxaccount_status_prefscreen.xml
@@ -5,22 +5,17 @@
     <PreferenceCategory
         android:key="signed_in_as_category"
         android:title="@string/fxaccount_status_signed_in_as" >
         <Preference
             android:editable="false"
             android:key="profile"
             android:icon="@drawable/sync_avatar_default"
             android:persistent="false"
-            android:title="" >
-            <intent
-                android:action="android.intent.action.VIEW"
-                android:targetClass="@string/browser_intent_class"
-                android:targetPackage="@string/browser_intent_package" />
-        </Preference>
+            android:title="" />
         <Preference
             android:editable="false"
             android:key="email"
             android:persistent="false"
             android:title="@string/fxaccount_email_hint" />
         <Preference
             android:editable="false"
             android:key="manage_account"