Backed out changeset 0408636c7ea9 (bug 1398283)

This commit is contained in:
Sebastian Hengst 2017-09-19 20:07:03 +02:00
Родитель a9a1e6e30b
Коммит 734fdf1202
5 изменённых файлов: 148 добавлений и 149 удалений

Просмотреть файл

@ -51,24 +51,25 @@
<!ENTITY fxaccount_getting_started_get_started 'Get started'>
<!ENTITY fxaccount_getting_started_old_firefox 'Using an older version of &syncBrand.shortName.label;?'>
<!ENTITY fxaccount_status_signed_in_as 'Signed in as'>
<!ENTITY fxaccount_status_manage_account 'Manage account'>
<!ENTITY fxaccount_status_auth_server 'Account server'>
<!ENTITY fxaccount_status_sync_now 'Sync now'>
<!ENTITY fxaccount_status_syncing2 'Syncing…'>
<!ENTITY fxaccount_status_device_name 'Device name'>
<!ENTITY fxaccount_status_sync_server 'Sync server'>
<!ENTITY fxaccount_status_sync '&syncBrand.shortName.label;'>
<!ENTITY fxaccount_status_sync_enabled '&syncBrand.shortName.label;: enabled'>
<!ENTITY fxaccount_status_needs_verification2 'Your account needs to be verified. Tap to resend verification email.'>
<!ENTITY fxaccount_status_needs_credentials 'Cannot connect. Tap to sign in.'>
<!ENTITY fxaccount_status_needs_upgrade 'You need to upgrade &brandShortName; to sign in.'>
<!ENTITY fxaccount_status_needs_master_sync_automatically_enabled '&syncBrand.shortName.label; is set up, but not syncing automatically. Toggle “Auto-sync data” in Android Settings &gt; Data Usage.'>
<!ENTITY fxaccount_status_needs_master_sync_automatically_enabled_v21 '&syncBrand.shortName.label; is set up, but not syncing automatically. Toggle “Auto-sync data” in the menu of Android Settings &gt; Accounts.'>
<!ENTITY fxaccount_status_needs_finish_migrating 'Tap to sign in to your new Firefox Account.'>
<!ENTITY fxaccount_status_choose_what 'Choose what to sync'>
<!ENTITY fxaccount_status_bookmarks 'Bookmarks'>
<!ENTITY fxaccount_status_history 'History'>
<!ENTITY fxaccount_status_passwords2 'Logins'>
<!ENTITY fxaccount_status_tabs 'Open tabs'>
<!ENTITY fxaccount_status_additional_settings 'Additional Settings'>
<!ENTITY fxaccount_status_legal 'Legal' >
<!-- Localization note: when tapped, the following two strings link to
external web pages. Compare fxaccount_policy_{linktos,linkprivacy}:
@ -76,6 +77,7 @@
the two uses differently. -->
<!ENTITY fxaccount_status_linktos2 'Terms of service'>
<!ENTITY fxaccount_status_linkprivacy2 'Privacy notice'>
<!ENTITY fxaccount_status_more 'More&ellipsis;'>
<!ENTITY fxaccount_remove_account 'Disconnect&ellipsis;'>
<!ENTITY fxaccount_remove_account_dialog_title2 'Disconnect from Sync?'>

Просмотреть файл

@ -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,

Просмотреть файл

@ -28,10 +28,8 @@
android:layout_height="wrap_content"
android:layout_marginBottom="6dip"
android:layout_marginLeft="15dip"
android:layout_marginStart="15dip"
android:layout_marginRight="15dip"
android:layout_marginEnd="6dip"
android:layout_marginTop="0dp"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_weight="1" >
<TextView

Просмотреть файл

@ -4,8 +4,28 @@
android:key="status_screen">
<PreferenceCategory
android:key="error_state">
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="" />
<Preference
android:editable="false"
android:key="manage_account"
android:persistent="false"
android:title="@string/fxaccount_status_manage_account" />
<Preference
android:editable="false"
android:key="auth_server"
android:persistent="false"
android:title="@string/fxaccount_status_auth_server" />
</PreferenceCategory>
<PreferenceCategory
android:key="sync_category"
android:title="@string/fxaccount_status_sync" >
<Preference
android:editable="false"
android:icon="@drawable/fxaccount_sync_error"
@ -41,14 +61,6 @@
android:layout="@layout/fxaccount_status_error_preference"
android:persistent="false"
android:title="@string/fxaccount_status_needs_finish_migrating" />
</PreferenceCategory>
<Preference
android:editable="false"
android:key="profile"
android:icon="@drawable/sync_avatar_default"
android:persistent="false"
android:title="" />
<Preference
android:editable="false"
@ -58,26 +70,22 @@
android:title="@string/fxaccount_status_sync_now"
android:summary="" />
<PreferenceCategory
android:title="@string/fxaccount_status_choose_what">
<SwitchPreference
<CheckBoxPreference
android:key="bookmarks"
android:persistent="false"
android:title="@string/fxaccount_status_bookmarks" />
<SwitchPreference
<CheckBoxPreference
android:key="history"
android:persistent="false"
android:title="@string/fxaccount_status_history" />
<SwitchPreference
<CheckBoxPreference
android:key="tabs"
android:persistent="false"
android:title="@string/fxaccount_status_tabs" />
<SwitchPreference
<CheckBoxPreference
android:key="passwords"
android:persistent="false"
android:title="@string/fxaccount_status_passwords" />
</PreferenceCategory>
<EditTextPreference
android:singleLine="true"
@ -85,29 +93,24 @@
android:persistent="false"
android:title="@string/fxaccount_status_device_name" />
<Preference
android:editable="false"
android:key="sync_server"
android:persistent="false"
android:title="@string/fxaccount_status_sync_server" />
<org.mozilla.gecko.fxa.activities.CustomColorPreference
android:editable="false"
android:key="remove_account"
android:persistent="false"
gecko:titleColor="@color/rejection_red"
android:title="@string/fxaccount_remove_account" />
<PreferenceCategory
android:key="additional_settings"
android:title="@string/fxaccount_status_additional_settings">
<Preference
android:editable="false"
android:key="auth_server"
android:key="more"
android:persistent="false"
android:title="@string/fxaccount_status_auth_server" />
<Preference
android:editable="false"
android:key="sync_server"
android:persistent="false"
android:title="@string/fxaccount_status_sync_server" />
android:title="@string/fxaccount_status_more" />
</PreferenceCategory>
<PreferenceCategory
android:key="legal_category"
android:title="@string/fxaccount_status_legal" >
@ -122,7 +125,6 @@
android:persistent="false"
android:title="@string/fxaccount_status_linkprivacy" />
</PreferenceCategory>
<PreferenceCategory
android:key="debug_category" >
<Preference android:key="debug_refresh" />

Просмотреть файл

@ -29,6 +29,8 @@
<string name="fxaccount_getting_started_get_started">&fxaccount_getting_started_get_started;</string>
<string name="fxaccount_status_activity_label">&syncBrand.shortName.label;</string>
<string name="fxaccount_status_signed_in_as">&fxaccount_status_signed_in_as;</string>
<string name="fxaccount_status_manage_account">&fxaccount_status_manage_account;</string>
<string name="fxaccount_status_auth_server">&fxaccount_status_auth_server;</string>
<string name="fxaccount_status_sync_now">&fxaccount_status_sync_now;</string>
<string name="fxaccount_status_syncing">&fxaccount_status_syncing2;</string>
@ -37,21 +39,21 @@
<string name="fxaccount_status_device_name">&fxaccount_status_device_name;</string>
<string name="fxaccount_status_sync_server">&fxaccount_status_sync_server;</string>
<string name="fxaccount_status_sync">&fxaccount_status_sync;</string>
<string name="fxaccount_status_sync_enabled">&fxaccount_status_sync_enabled;</string>
<string name="fxaccount_status_needs_verification">&fxaccount_status_needs_verification2;</string>
<string name="fxaccount_status_needs_credentials">&fxaccount_status_needs_credentials;</string>
<string name="fxaccount_status_needs_upgrade">&fxaccount_status_needs_upgrade;</string>
<string name="fxaccount_status_needs_master_sync_automatically_enabled">&fxaccount_status_needs_master_sync_automatically_enabled;</string>
<string name="fxaccount_status_needs_master_sync_automatically_enabled_v21">&fxaccount_status_needs_master_sync_automatically_enabled_v21;</string>
<string name="fxaccount_status_needs_finish_migrating">&fxaccount_status_needs_finish_migrating;</string>
<string name="fxaccount_status_choose_what">&fxaccount_status_choose_what;</string>
<string name="fxaccount_status_bookmarks">&fxaccount_status_bookmarks;</string>
<string name="fxaccount_status_history">&fxaccount_status_history;</string>
<string name="fxaccount_status_passwords">&fxaccount_status_passwords2;</string>
<string name="fxaccount_status_tabs">&fxaccount_status_tabs;</string>
<string name="fxaccount_status_additional_settings">&fxaccount_status_additional_settings;</string>
<string name="fxaccount_status_legal">&fxaccount_status_legal;</string>
<string name="fxaccount_status_linktos">&fxaccount_status_linktos2;</string>
<string name="fxaccount_status_linkprivacy">&fxaccount_status_linkprivacy2;</string>
<string name="fxaccount_status_more">&fxaccount_status_more;</string>
<string name="fxaccount_remove_account">&fxaccount_remove_account;</string>
<string name="fxaccount_label">&fxaccount_account_type_label;</string>