Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 541743ce authored by Wenyi Wang's avatar Wenyi Wang
Browse files

Better name for local account (1/2)

Bug 29882162

Change-Id: I046b81f62dec109c3502f84ee19eae008217ae98
parent 4d27a239
Loading
Loading
Loading
Loading
+13 −16
Original line number Diff line number Diff line
@@ -137,28 +137,25 @@ public class EditorUiUtils {
    public static Pair<String,String> getAccountInfo(Context context, String accountName,
            AccountType accountType) {
        CharSequence accountTypeDisplayLabel = accountType.getDisplayLabel(context);
        if (TextUtils.isEmpty(accountTypeDisplayLabel)) {
        if (TextUtils.isEmpty(accountTypeDisplayLabel)
                || TextUtils.equals(
                        context.getString(R.string.account_phone), accountTypeDisplayLabel)) {
            accountTypeDisplayLabel = context.getString(R.string.account_phone);
        } else if (GoogleAccountType.ACCOUNT_TYPE.equals(accountType.accountType)
                && accountType.dataSet == null){
            accountTypeDisplayLabel = context.getString(R.string.google_account_type_format,
                    accountTypeDisplayLabel);
        } else {
            accountTypeDisplayLabel = context.getString(R.string.account_type_format,
                    accountTypeDisplayLabel);
        }

        if (TextUtils.isEmpty(accountName)) {
            return new Pair<>(
                    /* accountName =*/ null,
                    context.getString(R.string.account_type_format, accountTypeDisplayLabel));
            return new Pair<>(/* accountName */ null, accountTypeDisplayLabel.toString());
        }

        final String accountNameDisplayLabel =
                context.getString(R.string.from_account_format, accountName);

        if (GoogleAccountType.ACCOUNT_TYPE.equals(accountType.accountType)
                && accountType.dataSet == null) {
            return new Pair<>(
                    accountNameDisplayLabel,
                    context.getString(R.string.google_account_type_format, accountTypeDisplayLabel));
        }
        return new Pair<>(
                accountNameDisplayLabel,
                context.getString(R.string.account_type_format, accountTypeDisplayLabel));
        return new Pair<>(context.getString(R.string.from_account_format, accountName),
                accountTypeDisplayLabel.toString());
    }

    /**
+10 −8
Original line number Diff line number Diff line
@@ -119,10 +119,7 @@ public class EditorUiUtilsTest extends AndroidTestCase {
        assertNotNull(pair);
        assertEquals(getContext().getString(R.string.from_account_format, ACCOUNT_NAME),
                pair.first); // somebody@lunkedin.com
        assertEquals(
                getContext().getString(R.string.account_type_format,
                        getContext().getString(R.string.account_phone)),
                pair.second); // "Phone-only, unsynced contact"
        assertEquals(getContext().getString(R.string.account_phone), pair.second); // Device
    }

    public void testGetAccountInfo_NoAccountName_DisplayLabel() {
@@ -133,6 +130,14 @@ public class EditorUiUtilsTest extends AndroidTestCase {
        assertNull(pair.first);
        assertEquals(getContext().getString(R.string.account_type_format, DISPLAY_LABEL),
                pair.second); // LunkedIn contact

        final Pair pairDevice = EditorUiUtils.getAccountInfo(
                getContext(),
                /* accountName =*/ null,
                new MockAccountType(getContext().getString(R.string.account_phone)));
        assertNotNull(pairDevice);
        assertNull(pairDevice.first);
        assertEquals(getContext().getString(R.string.account_phone), pairDevice.second); // Device
    }

    public void testGetAccountInfo_NoAccountName_NoDisplayLabel() {
@@ -141,10 +146,7 @@ public class EditorUiUtilsTest extends AndroidTestCase {

        assertNotNull(pair);
        assertNull(pair.first);
        assertEquals(
                getContext().getString(R.string.account_type_format,
                        getContext().getString(R.string.account_phone)),
                pair.second); // "Phone-only, unsynced contact"
        assertEquals(getContext().getString(R.string.account_phone), pair.second); // Device
    }

    public void testGetRingtongStrFromUri_lessThanOrEqualsToM() {