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

Commit 93e80fe9 authored by Oli Lan's avatar Oli Lan Committed by Android (Google) Code Review
Browse files

Merge changes from topic "avatarpicker1"

* changes:
  Offer colored default avatars if no preselected images are provided.
  Support taking or choosing a photo in avatar picker.
  Add avatar picker that shows a predefined set of images.
parents 77f35083 4f3a0b8f
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.util;

import android.annotation.ColorInt;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -72,9 +73,30 @@ public class UserIcons {
            // Return colored icon instead
            colorResId = USER_ICON_COLORS[userId % USER_ICON_COLORS.length];
        }
        return getDefaultUserIconInColor(resources, resources.getColor(colorResId, null));
    }

    /**
     * Returns a default user icon in a particular color.
     *
     * @param resources resources object to fetch the user icon
     * @param color the color used for the icon
     */
    public static Drawable getDefaultUserIconInColor(Resources resources, @ColorInt int color) {
        Drawable icon = resources.getDrawable(R.drawable.ic_account_circle, null).mutate();
        icon.setColorFilter(resources.getColor(colorResId, null), Mode.SRC_IN);
        icon.setColorFilter(color, Mode.SRC_IN);
        icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
        return icon;
    }

    /**
     * Returns an array containing colors to be used for default user icons.
     */
    public static int[] getUserIconColors(Resources resources) {
        int[] result = new int[USER_ICON_COLORS.length];
        for (int i = 0; i < result.length; i++) {
            result[i] = resources.getColor(USER_ICON_COLORS[i], null);
        }
        return result;
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ android_library {
        "SettingsLibSettingsTransition",
        "SettingsLibActivityEmbedding",
        "SettingsLibButtonPreference",
        "setupdesign",
    ],

    // ANDROIDMK TRANSLATION ERROR: unsupported assignment to LOCAL_SHARED_JAVA_LIBRARIES
+6 −0
Original line number Diff line number Diff line
@@ -18,4 +18,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.settingslib">

    <application>
        <activity
            android:name="com.android.settingslib.users.AvatarPickerActivity"
            android:theme="@style/SudThemeGlifV2.DayNight"/>
    </application>

</manifest>
+30 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2022 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="oval">
            <stroke
                android:width="2dp"
                android:color="?android:attr/colorPrimary"/>
        </shape>
    </item>
    <item
        android:left="@dimen/avatar_picker_icon_inset"
        android:right="@dimen/avatar_picker_icon_inset"
        android:top="@dimen/avatar_picker_icon_inset"
        android:bottom="@dimen/avatar_picker_icon_inset"
        android:drawable="@drawable/ic_avatar_choose_photo"/>
</layer-list>
+25 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2022 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
  -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true">
        <shape android:shape="oval">
            <stroke
                android:color="?android:attr/colorPrimary"
                android:width="@dimen/avatar_picker_padding"/>
        </shape>
    </item>
</selector>
 No newline at end of file
Loading