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

Commit 6a956f37 authored by kaiyiz's avatar kaiyiz Committed by Gerrit - the friendly Code Review server
Browse files

Settings: Jump to contacts when set photo of user.

Camera and Gallery2 can't read and write files in settings, because
they don't have the permission.

The photo of user will be updated as the profile is changed in
contacts. Since contacts can implement the same function, it will
jump to contacts when set photo of user. And update owner name when
profile is changed.

Change-Id: I8ae00e0281fb73e36c15b2dc8625f43bb0cd9aa9
CRs-Fixed: 785671
parent e4d3822e
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -57,18 +57,11 @@ public class ProfileUpdateReceiver extends BroadcastReceiver {
    }

    static void copyProfileName(Context context) {
        SharedPreferences prefs = context.getSharedPreferences("profile", Context.MODE_PRIVATE);
        if (prefs.contains(KEY_PROFILE_NAME_COPIED_ONCE)) {
            return;
        }

        int userId = UserHandle.myUserId();
        UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
        String profileName = Utils.getMeProfileName(context, false /* partial name */);
        if (profileName != null && profileName.length() > 0) {
            um.setUserName(userId, profileName);
            // Flag that we've written the profile one time at least. No need to do it in the future.
            prefs.edit().putBoolean(KEY_PROFILE_NAME_COPIED_ONCE, true).commit();
        }
    }
}
+5 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.os.UserManager;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceGroup;
import android.provider.ContactsContract;
import android.provider.Settings;
import android.provider.Settings.Secure;
import android.util.Log;
@@ -884,7 +885,10 @@ public class UserSettings extends SettingsPreferenceFragment
            if (mUserManager.isLinkedUser()) {
                onManageUserClicked(UserHandle.myUserId(), false);
            } else {
                showDialog(DIALOG_USER_PROFILE_EDITOR);
                Intent intent = ContactsContract.QuickContact.composeQuickContactsIntent(
                        getActivity(), getView(), ContactsContract.Profile.CONTENT_URI,
                        ContactsContract.QuickContact.MODE_LARGE, null);
                getActivity().startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
            }
        } else if (pref instanceof UserPreference) {
            int userId = ((UserPreference) pref).getUserId();