From 734fdf12029e19e3bd4f9b612f540a75b2bd6147 Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Tue, 19 Sep 2017 20:07:03 +0200 Subject: [PATCH] Backed out changeset 0408636c7ea9 (bug 1398283) --- .../base/locales/en-US/sync_strings.dtd | 6 +- .../activities/FxAccountStatusFragment.java | 155 +++++++++--------- .../fxaccount_status_error_preference.xml | 8 +- .../res/xml/fxaccount_status_prefscreen.xml | 122 +++++++------- mobile/android/services/strings.xml.in | 6 +- 5 files changed, 148 insertions(+), 149 deletions(-) diff --git a/mobile/android/base/locales/en-US/sync_strings.dtd b/mobile/android/base/locales/en-US/sync_strings.dtd index 39aaaf34d035..23ae06862bc8 100644 --- a/mobile/android/base/locales/en-US/sync_strings.dtd +++ b/mobile/android/base/locales/en-US/sync_strings.dtd @@ -51,24 +51,25 @@ + + + - - + diff --git a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java index 6792883fa5ae..734b5596ad51 100644 --- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java +++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java @@ -13,13 +13,13 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; +import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; -import android.preference.SwitchPreference; import android.support.v4.content.LocalBroadcastManager; import android.text.TextUtils; import android.text.format.DateUtils; @@ -86,10 +86,17 @@ public class FxAccountStatusFragment private static final String[] STAGES_TO_SYNC_ON_DEVICE_NAME_CHANGE = new String[] { "clients" }; - protected PreferenceCategory additionalSettingsCategory; - protected PreferenceCategory errorStatesCategory; + // By default, the auth/account server preference is only shown when the + // account is configured to use a custom server. In debug mode, this is set. + private static boolean ALWAYS_SHOW_AUTH_SERVER = false; + // By default, the Sync server preference is only shown when the account is + // configured to use a custom Sync server. In debug mode, this is set. + private static boolean ALWAYS_SHOW_SYNC_SERVER = false; + + protected PreferenceCategory accountCategory; protected Preference profilePreference; + protected Preference manageAccountPreference; protected Preference authServerPreference; protected Preference removeAccountPreference; @@ -99,13 +106,17 @@ public class FxAccountStatusFragment protected Preference needsMasterSyncAutomaticallyEnabledPreference; protected Preference needsFinishMigratingPreference; - protected SwitchPreference bookmarksPreference; - protected SwitchPreference historyPreference; - protected SwitchPreference tabsPreference; - protected SwitchPreference passwordsPreference; + protected PreferenceCategory syncCategory; + + protected CheckBoxPreference bookmarksPreference; + protected CheckBoxPreference historyPreference; + protected CheckBoxPreference tabsPreference; + protected CheckBoxPreference passwordsPreference; + protected CheckBoxPreference readingListPreference; protected EditTextPreference deviceNamePreference; protected Preference syncServerPreference; + protected Preference morePreference; protected Preference syncNowPreference; protected volatile AndroidFxAccount fxAccount; @@ -154,10 +165,9 @@ public class FxAccountStatusFragment protected void addPreferences() { addPreferencesFromResource(R.xml.fxaccount_status_prefscreen); - errorStatesCategory = (PreferenceCategory) ensureFindPreference("error_state"); - additionalSettingsCategory = (PreferenceCategory) ensureFindPreference("additional_settings"); - + accountCategory = (PreferenceCategory) ensureFindPreference("signed_in_as_category"); profilePreference = ensureFindPreference("profile"); + manageAccountPreference = ensureFindPreference("manage_account"); authServerPreference = ensureFindPreference("auth_server"); removeAccountPreference = ensureFindPreference("remove_account"); @@ -167,12 +177,23 @@ public class FxAccountStatusFragment needsMasterSyncAutomaticallyEnabledPreference = ensureFindPreference("needs_master_sync_automatically_enabled"); needsFinishMigratingPreference = ensureFindPreference("needs_finish_migrating"); - bookmarksPreference = (SwitchPreference) ensureFindPreference("bookmarks"); - historyPreference = (SwitchPreference) ensureFindPreference("history"); - tabsPreference = (SwitchPreference) ensureFindPreference("tabs"); - passwordsPreference = (SwitchPreference) ensureFindPreference("passwords"); + syncCategory = (PreferenceCategory) ensureFindPreference("sync_category"); + + bookmarksPreference = (CheckBoxPreference) ensureFindPreference("bookmarks"); + historyPreference = (CheckBoxPreference) ensureFindPreference("history"); + tabsPreference = (CheckBoxPreference) ensureFindPreference("tabs"); + passwordsPreference = (CheckBoxPreference) ensureFindPreference("passwords"); + + if (!FxAccountUtils.LOG_PERSONAL_INFORMATION) { + removeDebugButtons(); + } else { + connectDebugButtons(); + ALWAYS_SHOW_AUTH_SERVER = true; + ALWAYS_SHOW_SYNC_SERVER = true; + } profilePreference.setOnPreferenceClickListener(this); + manageAccountPreference.setOnPreferenceClickListener(this); removeAccountPreference.setOnPreferenceClickListener(this); needsPasswordPreference.setOnPreferenceClickListener(this); @@ -188,19 +209,13 @@ public class FxAccountStatusFragment deviceNamePreference.setOnPreferenceChangeListener(this); syncServerPreference = ensureFindPreference("sync_server"); + morePreference = ensureFindPreference("more"); + morePreference.setOnPreferenceClickListener(this); syncNowPreference = ensureFindPreference("sync_now"); syncNowPreference.setEnabled(true); syncNowPreference.setOnPreferenceClickListener(this); - if (!FxAccountUtils.LOG_PERSONAL_INFORMATION) { - removeDebugButtons(); - } else { - connectDebugButtons(); - } - - updateAdditionalPreferences(); - ensureFindPreference("linktos").setOnPreferenceClickListener(this); ensureFindPreference("linkprivacy").setOnPreferenceClickListener(this); } @@ -217,6 +232,11 @@ public class FxAccountStatusFragment @Override public boolean onPreferenceClick(Preference preference) { if (preference == profilePreference) { + ActivityUtils.openURLInFennec(getActivity().getApplicationContext(), "about:accounts?action=avatar"); + return true; + } + + if (preference == manageAccountPreference) { ActivityUtils.openURLInFennec(getActivity().getApplicationContext(), "about:accounts?action=manage"); return true; } @@ -267,6 +287,11 @@ public class FxAccountStatusFragment return true; } + if (preference == morePreference) { + getActivity().openOptionsMenu(); + return true; + } + if (preference == syncNowPreference) { if (fxAccount != null) { fxAccount.requestImmediateSync(null, null); @@ -304,22 +329,6 @@ public class FxAccountStatusFragment * single error preference to show; if null, hide all error preferences */ protected void showOnlyOneErrorPreference(Preference errorPreferenceToShow) { - final PreferenceScreen statusScreen = (PreferenceScreen) ensureFindPreference("status_screen"); - final boolean showShowErrorState = errorPreferenceToShow != null; - final boolean currentlyShowingErrorState = null != findPreference(errorStatesCategory.getKey()); - - if (currentlyShowingErrorState != showShowErrorState) { - if (showShowErrorState) { - statusScreen.addPreference(errorStatesCategory); - } else { - statusScreen.removePreference(errorStatesCategory); - } - } - - if (!showShowErrorState) { - return; - } - final Preference[] errorPreferences = new Preference[] { this.needsPasswordPreference, this.needsUpgradePreference, @@ -328,35 +337,39 @@ public class FxAccountStatusFragment this.needsFinishMigratingPreference, }; for (Preference errorPreference : errorPreferences) { - final boolean currentlyShown = null != errorStatesCategory.findPreference(errorPreference.getKey()); + final boolean currentlyShown = null != findPreference(errorPreference.getKey()); final boolean shouldBeShown = errorPreference == errorPreferenceToShow; if (currentlyShown == shouldBeShown) { continue; } if (shouldBeShown) { - errorStatesCategory.addPreference(errorPreference); + syncCategory.addPreference(errorPreference); } else { - errorStatesCategory.removePreference(errorPreference); + syncCategory.removePreference(errorPreference); } } } protected void showNeedsPassword() { + syncCategory.setTitle(R.string.fxaccount_status_sync); showOnlyOneErrorPreference(needsPasswordPreference); setCheckboxesEnabled(false); } protected void showNeedsUpgrade() { + syncCategory.setTitle(R.string.fxaccount_status_sync); showOnlyOneErrorPreference(needsUpgradePreference); setCheckboxesEnabled(false); } protected void showNeedsVerification() { + syncCategory.setTitle(R.string.fxaccount_status_sync); showOnlyOneErrorPreference(needsVerificationPreference); setCheckboxesEnabled(false); } protected void showNeedsMasterSyncAutomaticallyEnabled() { + syncCategory.setTitle(R.string.fxaccount_status_sync); needsMasterSyncAutomaticallyEnabledPreference.setTitle(AppConstants.Versions.preLollipop ? R.string.fxaccount_status_needs_master_sync_automatically_enabled : R.string.fxaccount_status_needs_master_sync_automatically_enabled_v21); @@ -365,17 +378,19 @@ public class FxAccountStatusFragment } protected void showNeedsFinishMigrating() { + syncCategory.setTitle(R.string.fxaccount_status_sync); showOnlyOneErrorPreference(needsFinishMigratingPreference); setCheckboxesEnabled(false); } protected void showConnected() { + syncCategory.setTitle(R.string.fxaccount_status_sync_enabled); showOnlyOneErrorPreference(null); setCheckboxesEnabled(true); } - private class InnerSyncStatusDelegate implements SyncStatusListener { - /* package-private */ final Runnable refreshRunnable = new Runnable() { + protected class InnerSyncStatusDelegate implements SyncStatusListener { + protected final Runnable refreshRunnable = new Runnable() { @Override public void run() { refresh(); @@ -504,7 +519,8 @@ public class FxAccountStatusFragment profileAvatarTarget = new PicassoPreferenceIconTarget(getResources(), profilePreference, cornerRadius); updateProfileInformation(); - updateAdditionalPreferences(); + updateAuthServerPreference(); + updateSyncServerPreference(); try { // There are error states determined by Android, not the login state @@ -632,52 +648,31 @@ public class FxAccountStatusFragment handler.postDelayed(lastSyncedTimeUpdateRunnable, LAST_SYNCED_TIME_UPDATE_INTERVAL_IN_MILLISECONDS); } - private void updateAdditionalPreferences() { - // Ensure we have fxAccount; it's set in refresh(). - if (fxAccount == null) { - return; - } - - // In debug mode, everything is shown. Otherwise, we show those that have been customized. + protected void updateAuthServerPreference() { final String authServer = fxAccount.getAccountServerURI(); - final String syncServer = fxAccount.getTokenServerURI(); - final boolean inDebugMode = FxAccountUtils.LOG_PERSONAL_INFORMATION; - final boolean authServerCustomized = !FxAccountConstants.DEFAULT_AUTH_SERVER_ENDPOINT.equals(authServer); - final boolean syncServerCustomized = !FxAccountConstants.DEFAULT_TOKEN_SERVER_ENDPOINT.equals(syncServer); - - final boolean shouldBeShown = inDebugMode || authServerCustomized || syncServerCustomized; - - final boolean additionalSettingsCategoryCurrentlyShown = null != findPreference(additionalSettingsCategory.getKey()); - if (shouldBeShown != additionalSettingsCategoryCurrentlyShown) { - final PreferenceScreen statusScreen = (PreferenceScreen) ensureFindPreference("status_screen"); + final boolean shouldBeShown = ALWAYS_SHOW_AUTH_SERVER || !FxAccountConstants.DEFAULT_AUTH_SERVER_ENDPOINT.equals(authServer); + final boolean currentlyShown = null != findPreference(authServerPreference.getKey()); + if (currentlyShown != shouldBeShown) { if (shouldBeShown) { - statusScreen.addPreference(additionalSettingsCategory); + accountCategory.addPreference(authServerPreference); } else { - statusScreen.removePreference(additionalSettingsCategory); - return; - } - } - - final boolean showAuthServerPref = authServerCustomized || inDebugMode; - final boolean authServerPrefCurrentlyShown = null != findPreference(authServerPreference.getKey()); - if (authServerPrefCurrentlyShown != showAuthServerPref) { - if (showAuthServerPref) { - additionalSettingsCategory.addPreference(authServerPreference); - } else { - additionalSettingsCategory.removePreference(authServerPreference); + accountCategory.removePreference(authServerPreference); } } // Always set the summary, because on first run, the preference is visible, // and the above block will be skipped if there is a custom value. authServerPreference.setSummary(authServer); + } - final boolean showSyncServerPref = syncServerCustomized || inDebugMode; - final boolean syncServerPrefCurrentlyShown = null != findPreference(syncServerPreference.getKey()); - if (syncServerPrefCurrentlyShown != showSyncServerPref) { - if (showSyncServerPref) { - additionalSettingsCategory.addPreference(syncServerPreference); + protected void updateSyncServerPreference() { + final String syncServer = fxAccount.getTokenServerURI(); + final boolean shouldBeShown = ALWAYS_SHOW_SYNC_SERVER || !FxAccountConstants.DEFAULT_TOKEN_SERVER_ENDPOINT.equals(syncServer); + final boolean currentlyShown = null != findPreference(syncServerPreference.getKey()); + if (currentlyShown != shouldBeShown) { + if (shouldBeShown) { + syncCategory.addPreference(syncServerPreference); } else { - additionalSettingsCategory.removePreference(syncServerPreference); + syncCategory.removePreference(syncServerPreference); } } // Always set the summary, because on first run, the preference is visible, diff --git a/mobile/android/services/src/main/res/layout/fxaccount_status_error_preference.xml b/mobile/android/services/src/main/res/layout/fxaccount_status_error_preference.xml index f9e977df8b01..4a507cddd0c3 100644 --- a/mobile/android/services/src/main/res/layout/fxaccount_status_error_preference.xml +++ b/mobile/android/services/src/main/res/layout/fxaccount_status_error_preference.xml @@ -5,7 +5,7 @@ android:background="@color/fxaccount_error_preference_backgroundcolor" android:gravity="center_vertical" android:minHeight="?android:attr/listPreferredItemHeight" - android:paddingRight="?android:attr/scrollbarSize"> + android:paddingRight="?android:attr/scrollbarSize" > - + android:key="signed_in_as_category" + android:title="@string/fxaccount_status_signed_in_as" > + + + + + - - - - - - - - - - - - - - - - - - - + android:title="@string/fxaccount_status_sync_now" + android:summary="" /> + + + + + + + + - + + + @@ -122,7 +125,6 @@ android:persistent="false" android:title="@string/fxaccount_status_linkprivacy" /> - diff --git a/mobile/android/services/strings.xml.in b/mobile/android/services/strings.xml.in index c2898a9b0517..8d6f70a03e66 100644 --- a/mobile/android/services/strings.xml.in +++ b/mobile/android/services/strings.xml.in @@ -29,6 +29,8 @@ &fxaccount_getting_started_get_started; &syncBrand.shortName.label; +&fxaccount_status_signed_in_as; +&fxaccount_status_manage_account; &fxaccount_status_auth_server; &fxaccount_status_sync_now; &fxaccount_status_syncing2; @@ -37,21 +39,21 @@ &fxaccount_status_device_name; &fxaccount_status_sync_server; &fxaccount_status_sync; +&fxaccount_status_sync_enabled; &fxaccount_status_needs_verification2; &fxaccount_status_needs_credentials; &fxaccount_status_needs_upgrade; &fxaccount_status_needs_master_sync_automatically_enabled; &fxaccount_status_needs_master_sync_automatically_enabled_v21; &fxaccount_status_needs_finish_migrating; -&fxaccount_status_choose_what; &fxaccount_status_bookmarks; &fxaccount_status_history; &fxaccount_status_passwords2; &fxaccount_status_tabs; -&fxaccount_status_additional_settings; &fxaccount_status_legal; &fxaccount_status_linktos2; &fxaccount_status_linkprivacy2; +&fxaccount_status_more; &fxaccount_remove_account; &fxaccount_account_type_label;