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

Commit 49ecfa15 authored by taiki tsutsumi's avatar taiki tsutsumi Committed by android-build-merger
Browse files

Merge "Fixed Bidi layout issue of MyInfo in Settings"

am: cddb4a29

Change-Id: If5ecf7f9da0a4560fbec7cc51bc717617d9d74bd
parents d0f348f0 cddb4a29
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.res.Configuration;
import android.database.Cursor;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.provider.ContactsContract.DisplayNameSources;
import android.provider.ContactsContract.ProviderStatus;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
@@ -202,17 +203,19 @@ public final class ContactsPreferenceActivity extends PreferenceActivity
        boolean hasProfile = false;
        String displayName = null;
        long contactId = -1;
        int displayNameSource = DisplayNameSources.UNDEFINED;
        if (cursor != null && cursor.moveToFirst()) {
            hasProfile = cursor.getInt(ProfileQuery.CONTACT_IS_USER_PROFILE) == 1;
            displayName = cursor.getString(ProfileQuery.CONTACT_DISPLAY_NAME);
            contactId = cursor.getLong(ProfileQuery.CONTACT_ID);
            displayNameSource = cursor.getInt(ProfileQuery.DISPLAY_NAME_SOURCE);
        }
        if (hasProfile && TextUtils.isEmpty(displayName)) {
            displayName = getString(R.string.missing_name);
        }
        final DisplayOptionsPreferenceFragment fragment = (DisplayOptionsPreferenceFragment)
                getFragmentManager().findFragmentByTag(TAG_DISPLAY_OPTIONS);
        fragment.updateMyInfoPreference(hasProfile, displayName, contactId);
        fragment.updateMyInfoPreference(hasProfile, displayName, contactId, displayNameSource);
    }

    @Override
+13 −2
Original line number Diff line number Diff line
@@ -33,11 +33,14 @@ import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.provider.BlockedNumberContract;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.DisplayNameSources;
import android.provider.ContactsContract.Profile;
import android.support.design.widget.Snackbar;
import android.support.v4.content.LocalBroadcastManager;
import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
import android.text.BidiFormatter;
import android.text.TextDirectionHeuristics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -111,17 +114,20 @@ public class DisplayOptionsPreferenceFragment extends PreferenceFragment
                Contacts._ID,                           // 0
                Contacts.DISPLAY_NAME_PRIMARY,          // 1
                Contacts.IS_USER_PROFILE,               // 2
                Contacts.DISPLAY_NAME_SOURCE,           // 3
        };

        private static final String[] PROFILE_PROJECTION_ALTERNATIVE = new String[] {
                Contacts._ID,                           // 0
                Contacts.DISPLAY_NAME_ALTERNATIVE,      // 1
                Contacts.IS_USER_PROFILE,               // 2
                Contacts.DISPLAY_NAME_SOURCE,           // 3
        };

        public static final int CONTACT_ID               = 0;
        public static final int CONTACT_DISPLAY_NAME     = 1;
        public static final int CONTACT_IS_USER_PROFILE  = 2;
        public static final int DISPLAY_NAME_SOURCE      = 3;
    }

    private String mNewLocalProfileExtra;
@@ -255,8 +261,13 @@ public class DisplayOptionsPreferenceFragment extends PreferenceFragment
        mRootView = null;
    }

    public void updateMyInfoPreference(boolean hasProfile, String displayName, long contactId) {
        final CharSequence summary = hasProfile ? displayName : getString(R.string.set_up_profile);
    public void updateMyInfoPreference(boolean hasProfile, String displayName, long contactId,
            int displayNameSource) {
        final CharSequence summary = !hasProfile ?
                getString(R.string.set_up_profile) :
                displayNameSource == DisplayNameSources.PHONE ?
                BidiFormatter.getInstance().unicodeWrap(displayName, TextDirectionHeuristics.LTR) :
                displayName;
        mMyInfoPreference.setSummary(summary);
        mHasProfile = hasProfile;
        mProfileContactId = contactId;