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

Commit 0448ce17 authored by Tingting Wang's avatar Tingting Wang Committed by Android (Google) Code Review
Browse files

Merge "Read metadataSyncEnabled flag from N sdk." into ub-contactsdialer-b-dev

parents b7158bbe fc216948
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line 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 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";
    public static final String CONTACT_METADATA_AUTHORITY = "com.android.contacts.metadata";


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


import com.android.contacts.common.R;
import com.android.contacts.common.R;
import com.android.contacts.common.activity.LicenseActivity;
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.AccountTypeManager;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.model.account.GoogleAccountType;


import java.util.List;
import java.util.List;


@@ -84,10 +86,20 @@ public class DisplayOptionsPreferenceFragment extends PreferenceFragment {
            getPreferenceScreen().removePreference(findPreference("accounts"));
            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
        // 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"));
            getPreferenceScreen().removePreference(findPreference("contactMetadata"));
        }
        }
    }


    @Override
    @Override
    public Context getContext() {
    public Context getContext() {