diff --git a/res/values/strings.xml b/res/values/strings.xml
index f86cc56cb28..3e211b44d49 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6652,6 +6652,8 @@
Permissions, default apps
Accounts
+
+ No accounts added
Default apps
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index 65a5ff09e6f..0a4c343b2bc 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -91,17 +91,20 @@ public class AccountDashboardFragment extends DashboardFragment {
final BidiFormatter bidiFormatter = BidiFormatter.getInstance();
CharSequence summary = null;
+ if (types == null || types.length == 0) {
+ summary = mContext.getString(R.string.account_dashboard_default_summary);
+ } else {
+ // Show up to 3 account types
+ final int size = Math.min(3, types.length);
- // Show up to 3 account types
- final int size = Math.min(3, types.length);
-
- for (int i = 0; i < size; i++) {
- final CharSequence label = authHelper.getLabelForType(mContext, types[i]);
- if (summary == null) {
- summary = bidiFormatter.unicodeWrap(label);
- } else {
- summary = mContext.getString(R.string.join_many_items_middle, summary,
- bidiFormatter.unicodeWrap(label));
+ for (int i = 0; i < size; i++) {
+ final CharSequence label = authHelper.getLabelForType(mContext, types[i]);
+ if (summary == null) {
+ summary = bidiFormatter.unicodeWrap(label);
+ } else {
+ summary = mContext.getString(R.string.join_many_items_middle, summary,
+ bidiFormatter.unicodeWrap(label));
+ }
}
}
mSummaryLoader.setSummary(this, summary);
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index a8fab139485..fcb8aef0b47 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -249,11 +249,14 @@ public class UserSettings extends SettingsPreferenceFragment
mAddUser.useAdminDisabledSummary(false);
// Determine if add user/profile button should be visible
if (mUserCaps.mCanAddUser && Utils.isDeviceProvisioned(getActivity())) {
+ mAddUser.setVisible(true);
mAddUser.setOnPreferenceClickListener(this);
// change label to only mention user, if restricted profiles are not supported
if (!mUserCaps.mCanAddRestrictedProfile) {
mAddUser.setTitle(R.string.user_add_user_menu);
}
+ } else {
+ mAddUser.setVisible(false);
}
final IntentFilter filter = new IntentFilter(Intent.ACTION_USER_REMOVED);
filter.addAction(Intent.ACTION_USER_INFO_CHANGED);
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
index aeffd20d005..9371019fd60 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
@@ -27,11 +27,13 @@ import android.os.UserHandle;
import android.provider.SearchIndexableResource;
import android.text.TextUtils;
+import com.android.settings.R;
import com.android.settings.TestConfig;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settingslib.accounts.AuthenticatorHelper;
import com.android.settingslib.drawer.CategoryKey;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -41,6 +43,7 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
+import org.robolectric.annotation.Resetter;
import org.robolectric.shadows.ShadowApplication;
import java.util.List;
@@ -57,6 +60,11 @@ public class AccountDashboardFragmentTest {
mFragment = new AccountDashboardFragment();
}
+ @After
+ public void tearDown() {
+ ShadowAuthenticationHelper.reset();
+ }
+
@Test
public void testCategory_isAccount() {
assertThat(mFragment.getCategoryKey()).isEqualTo(CategoryKey.CATEGORY_ACCOUNT);
@@ -66,7 +74,8 @@ public class AccountDashboardFragmentTest {
@Config(shadows = {
ShadowAuthenticationHelper.class
})
- public void updateSummary_shouldDisplayUpTo3AccountTypes() {
+ public void updateSummary_hasAccount_shouldDisplayUpTo3AccountTypes() {
+ ShadowAuthenticationHelper.setHasAccount(true);
final SummaryLoader loader = mock(SummaryLoader.class);
final Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
@@ -77,6 +86,23 @@ public class AccountDashboardFragmentTest {
verify(loader).setSummary(provider, LABELS[0] + ", " + LABELS[1] + ", " + LABELS[2]);
}
+ @Test
+ @Config(shadows = {
+ ShadowAuthenticationHelper.class
+ })
+ public void updateSummary_noAccount_shouldDisplayDefaultSummary() {
+ ShadowAuthenticationHelper.setHasAccount(false);
+ final SummaryLoader loader = mock(SummaryLoader.class);
+ final Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
+
+ final SummaryLoader.SummaryProvider provider = mFragment.SUMMARY_PROVIDER_FACTORY
+ .createSummaryProvider(activity, loader);
+ provider.setListening(true);
+
+ verify(loader).setSummary(provider,
+ activity.getString(R.string.account_dashboard_default_summary));
+ }
+
@Test
public void testSearchIndexProvider_shouldIndexResource() {
final List indexRes =
@@ -94,15 +120,24 @@ public class AccountDashboardFragmentTest {
static final String[] TYPES = new String[] {"type1", "type2", "type3", "type4"};
static final String[] LABELS = new String[] {"LABEL1", "LABEL2",
"LABEL3", "LABEL4"};
+ private static boolean sHasAccount = true;
public void __constructor__(Context context, UserHandle userHandle,
AuthenticatorHelper.OnAccountsUpdateListener listener) {
+ }
+ public static void setHasAccount(boolean hasAccount) {
+ sHasAccount = hasAccount;
+ }
+
+ @Resetter
+ public static void reset() {
+ sHasAccount = true;
}
@Implementation
public String[] getEnabledAccountTypes() {
- return TYPES;
+ return sHasAccount ? TYPES : null;
}
@Implementation