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

Commit fc216948 authored by Tingting Wang's avatar Tingting Wang
Browse files

Read metadataSyncEnabled flag from N sdk.

Only show Lychee sync account setting when metadataSyncEnabled flag
in N SDK is true and there's at least one focus google account.

BUG 26771407

Change-Id: I6844ef0e2abd43c3d94b3d049af8ec46df3bc593
parent 4a459181
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public final class ContactsPreferences implements OnSharedPreferenceChangeListen

    public static final boolean PREF_DISPLAY_ONLY_PHONES_DEFAULT = false;

    public static final String DO_NOT_SYNC_CONTACT_METADATA_MSG = "Do not sync contact metadata.";
    public static final String DO_NOT_SYNC_CONTACT_METADATA_MSG = "Do not sync metadata";

    public static final String CONTACT_METADATA_AUTHORITY = "com.android.contacts.metadata";

+14 −2
Original line number Diff line number Diff line
@@ -29,8 +29,10 @@ import android.preference.PreferenceScreen;

import com.android.contacts.common.R;
import com.android.contacts.common.activity.LicenseActivity;
import com.android.contacts.common.compat.MetadataSyncEnabledCompat;
import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.model.account.GoogleAccountType;

import java.util.List;

@@ -84,10 +86,20 @@ public class DisplayOptionsPreferenceFragment extends PreferenceFragment {
            getPreferenceScreen().removePreference(findPreference("accounts"));
        }

        // STOPSHIP Show this option when 1) metadata sync is enabled
        // Show Contact metadata sync option when 1) metadata sync is enabled
        // and 2) there is at least one focus google account
        boolean hasFocusGoogleAccount = false;
        for (AccountWithDataSet account : accounts) {
            if (GoogleAccountType.ACCOUNT_TYPE.equals(account.type) && account.dataSet == null) {
                hasFocusGoogleAccount = true;
                break;
            }
        }
        if (!hasFocusGoogleAccount
                || !MetadataSyncEnabledCompat.isMetadataSyncEnabled(getContext())) {
            getPreferenceScreen().removePreference(findPreference("contactMetadata"));
        }
    }

    @Override
    public Context getContext() {