Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1025)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/SyncPreference.java

Issue 2032043002: Surface sync error icon if sync is off may be unintentional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/preferences/SignInPreference.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 package org.chromium.chrome.browser.preferences; 4 package org.chromium.chrome.browser.preferences;
5 5
6 import android.accounts.Account; 6 import android.accounts.Account;
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.res.Resources; 8 import android.content.res.Resources;
9 import android.graphics.PorterDuff; 9 import android.graphics.PorterDuff;
10 import android.graphics.drawable.Drawable; 10 import android.graphics.drawable.Drawable;
(...skipping 17 matching lines...) Expand all
28 super(context, attrs); 28 super(context, attrs);
29 updateSyncSummaryAndIcon(); 29 updateSyncSummaryAndIcon();
30 } 30 }
31 31
32 /** 32 /**
33 * Updates the summary and icon for this preference to reflect the current s tate of syncing. 33 * Updates the summary and icon for this preference to reflect the current s tate of syncing.
34 */ 34 */
35 public void updateSyncSummaryAndIcon() { 35 public void updateSyncSummaryAndIcon() {
36 setSummary(getSyncStatusSummary(getContext())); 36 setSummary(getSyncStatusSummary(getContext()));
37 37
38 if (ProfileSyncService.get().getAuthError() == GoogleServiceAuthError.St ate.NONE) { 38 if (SyncPreference.showSyncErrorIcon(getContext())) {
39 setIcon(ApiCompatibilityUtils.getDrawable(
40 getContext().getResources(), R.drawable.sync_error));
41 } else {
39 // Sets preference icon and tints it to blue. 42 // Sets preference icon and tints it to blue.
40 Drawable icon = ApiCompatibilityUtils.getDrawable( 43 Drawable icon = ApiCompatibilityUtils.getDrawable(
41 getContext().getResources(), R.drawable.permission_backgroun d_sync); 44 getContext().getResources(), R.drawable.permission_backgroun d_sync);
42 icon.setColorFilter(ApiCompatibilityUtils.getColor( 45 icon.setColorFilter(ApiCompatibilityUtils.getColor(
43 getContext().getResources(), R.color.lig ht_active_color), 46 getContext().getResources(), R.color.lig ht_active_color),
44 PorterDuff.Mode.SRC_IN); 47 PorterDuff.Mode.SRC_IN);
45 setIcon(icon); 48 setIcon(icon);
46 } else {
47 setIcon(ApiCompatibilityUtils.getDrawable(
48 getContext().getResources(), R.drawable.sync_error));
49 } 49 }
50 } 50 }
51 51
52 /**
53 * Checks if sync error icon should be shown. Show sync error icon if sync i s off because
54 * of error, passphrase required or disabled in Android.
55 */
56 public static boolean showSyncErrorIcon(Context context) {
57 if (!AndroidSyncSettings.isMasterSyncEnabled(context)) {
58 return true;
59 }
60
61 ProfileSyncService profileSyncService = ProfileSyncService.get();
62 if (profileSyncService != null) {
63 if (profileSyncService.hasUnrecoverableError()) {
64 return true;
65 }
66
67 if (profileSyncService.getAuthError() != GoogleServiceAuthError.Stat e.NONE) {
68 return true;
69 }
70
71 if (profileSyncService.isSyncActive()
72 && profileSyncService.isPassphraseRequiredForDecryption()) {
73 return true;
74 }
75 }
76
77 return false;
78 }
79
52 private static String getSyncStatusSummary(Context context) { 80 private static String getSyncStatusSummary(Context context) {
53 if (!ChromeSigninController.get(context).isSignedIn()) return ""; 81 if (!ChromeSigninController.get(context).isSignedIn()) return "";
54 82
55 ProfileSyncService profileSyncService = ProfileSyncService.get(); 83 ProfileSyncService profileSyncService = ProfileSyncService.get();
56 Resources res = context.getResources(); 84 Resources res = context.getResources();
57 85
58 if (ChildAccountService.isChildAccount()) { 86 if (ChildAccountService.isChildAccount()) {
59 return res.getString(R.string.kids_account); 87 return res.getString(R.string.kids_account);
60 } 88 }
61 89
(...skipping 24 matching lines...) Expand all
86 } 114 }
87 115
88 Account account = ChromeSigninController.get(context).getSignedInUse r(); 116 Account account = ChromeSigninController.get(context).getSignedInUse r();
89 return String.format( 117 return String.format(
90 context.getString(R.string.account_management_sync_summary), account.name); 118 context.getString(R.string.account_management_sync_summary), account.name);
91 } 119 }
92 120
93 return context.getString(R.string.sync_is_disabled); 121 return context.getString(R.string.sync_is_disabled);
94 } 122 }
95 } 123 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/preferences/SignInPreference.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698