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

Commit aa04429b authored by Ethan Chen's avatar Ethan Chen Committed by Steve Kondik
Browse files

Show owner info creation if no owner is set for UserTile

Change-Id: I43575946023676a1b75b67e1ae1996a0a3a35b88
parent b44325be
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Profile;
import android.util.Log;
@@ -31,6 +32,7 @@ import com.android.systemui.statusbar.phone.QuickSettingsController;
public class UserTile extends QuickSettingsTile {

    private static final String TAG = "UserTile";
    private static final String INTENT_EXTRA_NEW_LOCAL_PROFILE = "newLocalProfile";
    private Drawable userAvatar;
    private AsyncTask<Void, Void, Pair<String, Drawable>> mUserInfoTask;

@@ -43,16 +45,26 @@ public class UserTile extends QuickSettingsTile {
                mQsc.mBar.collapseAllPanels(true);
                final UserManager um =
                        (UserManager) mContext.getSystemService(Context.USER_SERVICE);
                if (um.getUsers(true).size() > 1) {
                int numUsers = um.getUsers(true).size();
                if (numUsers <= 1) {
                    final Cursor cursor = mContext.getContentResolver().query(
                            Profile.CONTENT_URI, null, null, null, null);
                    if (cursor.moveToNext() && !cursor.isNull(0)) {
                        Intent intent = new Intent(Intent.ACTION_VIEW, ContactsContract.Profile.CONTENT_URI);
                        startSettingsActivity(intent);
                    } else {
                        Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
                        intent.putExtra(INTENT_EXTRA_NEW_LOCAL_PROFILE, true);
                        startSettingsActivity(intent);
                    }
                    cursor.close();
                } else {
                    try {
                        WindowManagerGlobal.getWindowManagerService().lockNow(
                                null);
                    } catch (RemoteException e) {
                        Log.e(TAG, "Couldn't show user switcher", e);
                    }
                } else {
                    Intent intent = new Intent(Intent.ACTION_VIEW, ContactsContract.Profile.CONTENT_URI);
                    startSettingsActivity(intent);
                }
            }
        };