Loading res/values/strings.xml +3 −3 Original line number Diff line number Diff line Loading @@ -7816,8 +7816,8 @@ <string name="notification_settings_work_profile">Notification access is not available for apps in the work profile.</string> <!-- Title for setting tile leading to saved autofill passwords, autofill, and account settings [CHAR LIMIT=40]--> <string name="account_dashboard_title">Passwords and accounts</string> <!-- Summary for account settings tiles when there is no accounts on device [CHAR LIMIT=NONE]--> <string name="account_dashboard_default_summary">No accounts added</string> <!-- Summary for setting tile leading to saved autofill passwords, autofill, and account settings [CHAR LIMIT=NONE]--> <string name="account_dashboard_default_summary">Saved passwords, autofill, synced accounts</string> <!-- Title for setting tile leading to setting UI which allows user set default app to handle actions such as open web page, making phone calls, default SMS apps [CHAR LIMIT=40]--> <string name="app_default_dashboard_title">Default apps</string> src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java +1 −32 Original line number Diff line number Diff line Loading @@ -17,19 +17,11 @@ package com.android.settings.accounts; import android.content.Context; import android.icu.text.ListFormatter; import android.os.UserHandle; import android.text.BidiFormatter; import android.text.TextUtils; import android.util.FeatureFlagUtils; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; import com.android.settings.core.FeatureFlags; import com.android.settingslib.accounts.AuthenticatorHelper; import java.util.ArrayList; import java.util.List; public class TopLevelAccountEntryPreferenceController extends BasePreferenceController { public TopLevelAccountEntryPreferenceController(Context context, String preferenceKey) { Loading @@ -47,29 +39,6 @@ public class TopLevelAccountEntryPreferenceController extends BasePreferenceCont if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)) { return null; } final AuthenticatorHelper authHelper = new AuthenticatorHelper(mContext, UserHandle.of(UserHandle.myUserId()), null /* OnAccountsUpdateListener */); final String[] types = authHelper.getEnabledAccountTypes(); final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); final List<CharSequence> summaries = new ArrayList<>(); if (types == null || types.length == 0) { summaries.add(mContext.getString(R.string.account_dashboard_default_summary)); } else { // Show up to 3 account types, ignore any null value int accountToAdd = Math.min(3, types.length); for (int i = 0; i < types.length && accountToAdd > 0; i++) { final CharSequence label = authHelper.getLabelForType(mContext, types[i]); if (TextUtils.isEmpty(label)) { continue; } summaries.add(bidiFormatter.unicodeWrap(label)); accountToAdd--; } } return ListFormatter.getInstance().format(summaries); return mContext.getString(R.string.account_dashboard_default_summary); } } tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java +0 −31 Original line number Diff line number Diff line Loading @@ -23,63 +23,32 @@ import android.util.FeatureFlagUtils; import com.android.settings.R; import com.android.settings.core.FeatureFlags; import com.android.settings.testutils.shadow.ShadowAuthenticationHelper; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; @RunWith(RobolectricTestRunner.class) @Config(shadows = {ShadowAuthenticationHelper.class}) public class TopLevelAccountEntryPreferenceControllerTest { private TopLevelAccountEntryPreferenceController mController; private Context mContext; private String[] LABELS; private String[] TYPES; @Before public void setUp() { mContext = RuntimeEnvironment.application; mController = new TopLevelAccountEntryPreferenceController(mContext, "test_key"); LABELS = ShadowAuthenticationHelper.getLabels(); TYPES = ShadowAuthenticationHelper.getTypes(); FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, false); } @After public void tearDown() { ShadowAuthenticationHelper.reset(); } @Test public void updateSummary_hasAccount_shouldDisplayUpTo3AccountTypes() { assertThat(mController.getSummary()) .isEqualTo(LABELS[0] + ", " + LABELS[1] + ", and " + LABELS[2]); } @Test public void updateSummary_noAccount_shouldDisplayDefaultSummary() { ShadowAuthenticationHelper.setEnabledAccount(null); assertThat(mController.getSummary()).isEqualTo( mContext.getText(R.string.account_dashboard_default_summary)); } @Test public void updateSummary_noAccountTypeLabel_shouldNotDisplayNullEntry() { final String[] enabledAccounts = {TYPES[0], "unlabeled_account_type", TYPES[1]}; ShadowAuthenticationHelper.setEnabledAccount(enabledAccounts); // should only show the 2 accounts with labels assertThat(mController.getSummary()).isEqualTo(LABELS[0] + " and " + LABELS[1]); } @Test public void getSummary_silkyHomeEnabled_shouldBeNull() { FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, true); Loading Loading
res/values/strings.xml +3 −3 Original line number Diff line number Diff line Loading @@ -7816,8 +7816,8 @@ <string name="notification_settings_work_profile">Notification access is not available for apps in the work profile.</string> <!-- Title for setting tile leading to saved autofill passwords, autofill, and account settings [CHAR LIMIT=40]--> <string name="account_dashboard_title">Passwords and accounts</string> <!-- Summary for account settings tiles when there is no accounts on device [CHAR LIMIT=NONE]--> <string name="account_dashboard_default_summary">No accounts added</string> <!-- Summary for setting tile leading to saved autofill passwords, autofill, and account settings [CHAR LIMIT=NONE]--> <string name="account_dashboard_default_summary">Saved passwords, autofill, synced accounts</string> <!-- Title for setting tile leading to setting UI which allows user set default app to handle actions such as open web page, making phone calls, default SMS apps [CHAR LIMIT=40]--> <string name="app_default_dashboard_title">Default apps</string>
src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java +1 −32 Original line number Diff line number Diff line Loading @@ -17,19 +17,11 @@ package com.android.settings.accounts; import android.content.Context; import android.icu.text.ListFormatter; import android.os.UserHandle; import android.text.BidiFormatter; import android.text.TextUtils; import android.util.FeatureFlagUtils; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; import com.android.settings.core.FeatureFlags; import com.android.settingslib.accounts.AuthenticatorHelper; import java.util.ArrayList; import java.util.List; public class TopLevelAccountEntryPreferenceController extends BasePreferenceController { public TopLevelAccountEntryPreferenceController(Context context, String preferenceKey) { Loading @@ -47,29 +39,6 @@ public class TopLevelAccountEntryPreferenceController extends BasePreferenceCont if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)) { return null; } final AuthenticatorHelper authHelper = new AuthenticatorHelper(mContext, UserHandle.of(UserHandle.myUserId()), null /* OnAccountsUpdateListener */); final String[] types = authHelper.getEnabledAccountTypes(); final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); final List<CharSequence> summaries = new ArrayList<>(); if (types == null || types.length == 0) { summaries.add(mContext.getString(R.string.account_dashboard_default_summary)); } else { // Show up to 3 account types, ignore any null value int accountToAdd = Math.min(3, types.length); for (int i = 0; i < types.length && accountToAdd > 0; i++) { final CharSequence label = authHelper.getLabelForType(mContext, types[i]); if (TextUtils.isEmpty(label)) { continue; } summaries.add(bidiFormatter.unicodeWrap(label)); accountToAdd--; } } return ListFormatter.getInstance().format(summaries); return mContext.getString(R.string.account_dashboard_default_summary); } }
tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java +0 −31 Original line number Diff line number Diff line Loading @@ -23,63 +23,32 @@ import android.util.FeatureFlagUtils; import com.android.settings.R; import com.android.settings.core.FeatureFlags; import com.android.settings.testutils.shadow.ShadowAuthenticationHelper; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; @RunWith(RobolectricTestRunner.class) @Config(shadows = {ShadowAuthenticationHelper.class}) public class TopLevelAccountEntryPreferenceControllerTest { private TopLevelAccountEntryPreferenceController mController; private Context mContext; private String[] LABELS; private String[] TYPES; @Before public void setUp() { mContext = RuntimeEnvironment.application; mController = new TopLevelAccountEntryPreferenceController(mContext, "test_key"); LABELS = ShadowAuthenticationHelper.getLabels(); TYPES = ShadowAuthenticationHelper.getTypes(); FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, false); } @After public void tearDown() { ShadowAuthenticationHelper.reset(); } @Test public void updateSummary_hasAccount_shouldDisplayUpTo3AccountTypes() { assertThat(mController.getSummary()) .isEqualTo(LABELS[0] + ", " + LABELS[1] + ", and " + LABELS[2]); } @Test public void updateSummary_noAccount_shouldDisplayDefaultSummary() { ShadowAuthenticationHelper.setEnabledAccount(null); assertThat(mController.getSummary()).isEqualTo( mContext.getText(R.string.account_dashboard_default_summary)); } @Test public void updateSummary_noAccountTypeLabel_shouldNotDisplayNullEntry() { final String[] enabledAccounts = {TYPES[0], "unlabeled_account_type", TYPES[1]}; ShadowAuthenticationHelper.setEnabledAccount(enabledAccounts); // should only show the 2 accounts with labels assertThat(mController.getSummary()).isEqualTo(LABELS[0] + " and " + LABELS[1]); } @Test public void getSummary_silkyHomeEnabled_shouldBeNull() { FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, true); Loading