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

Commit 82ca9a1c authored by Mykola Podolian's avatar Mykola Podolian Committed by Android (Google) Code Review
Browse files

Merge "Updated bubble setting design according to b/284170911." into main

parents e6e41fb1 c43f10f3
Loading
Loading
Loading
Loading

res/drawable/ic_bubble_all.xml

deleted100644 → 0
+0 −25
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2020 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.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:pathData="M16,11c1.66,0 2.99,-1.34 2.99,-3S17.66,5 16,5c-1.66,0 -3,1.34 -3,3s1.34,3 3,3zM8,11c1.66,0 2.99,-1.34 2.99,-3S9.66,5 8,5C6.34,5 5,6.34 5,8s1.34,3 3,3zM8,13c-2.33,0 -7,1.17 -7,3.5L1,19h14v-2.5c0,-2.33 -4.67,-3.5 -7,-3.5zM16,13c-0.29,0 -0.62,0.02 -0.97,0.05 1.16,0.84 1.97,1.97 1.97,3.45L17,19h6v-2.5c0,-2.33 -4.67,-3.5 -7,-3.5z"
        android:fillColor="#000000"/>
</vector>

res/drawable/ic_bubble_none.xml

deleted100644 → 0
+0 −25
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2020 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.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:pathData="M12,2C6.5,2 2,6.5 2,12s4.5,10 10,10 10,-4.5 10,-10S17.5,2 12,2zM4,12c0,-4.4 3.6,-8 8,-8 1.8,0 3.5,0.6 4.9,1.7L5.7,16.9C4.6,15.5 4,13.8 4,12zM12,20c-1.8,0 -3.5,-0.6 -4.9,-1.7L18.3,7.1C19.4,8.5 20,10.2 20,12c0,4.4 -3.6,8 -8,8z"
        android:fillColor="#000000"/>
</vector>
+0 −25
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2020 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.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:pathData="M15,8c0,-1.42 -0.5,-2.73 -1.33,-3.76 0.42,-0.14 0.86,-0.24 1.33,-0.24 2.21,0 4,1.79 4,4s-1.79,4 -4,4c-0.43,0 -0.84,-0.09 -1.23,-0.21 -0.03,-0.01 -0.06,-0.02 -0.1,-0.03C14.5,10.73 15,9.42 15,8zM16.66,13.13C18.03,14.06 19,15.32 19,17v3h4v-3c0,-2.18 -3.58,-3.47 -6.34,-3.87zM9,6c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2m0,9c-2.7,0 -5.8,1.29 -6,2.01L3,18h12v-1c-0.2,-0.71 -3.3,-2 -6,-2M9,4c2.21,0 4,1.79 4,4s-1.79,4 -4,4 -4,-1.79 -4,-4 1.79,-4 4,-4zM9,13c2.67,0 8,1.34 8,4v3L1,20v-3c0,-2.66 5.33,-4 8,-4z"
        android:fillColor="#000000"/>
</vector>
+33 −91
Original line number Diff line number Diff line
@@ -15,13 +15,12 @@
  ~ limitations under the License.
  -->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:padding="@dimen/notification_importance_toggle_marginTop"
    android:orientation="vertical">
    android:orientation="vertical"
    android:padding="@dimen/notification_importance_toggle_marginTop">

    <!-- If bubbles is managed by the admin this is used to inform the user. -->
    <TextView
@@ -30,102 +29,45 @@
        android:layout_height="wrap_content"
        android:padding="@dimen/notification_importance_button_padding"
        android:textAppearance="@style/TextAppearance.Small"
        android:visibility="gone"
        />
        android:visibility="gone" />

    <com.android.settings.notification.NotificationButtonRelativeLayout
        android:id="@+id/bubble_all"
    <RadioGroup
        android:id="@+id/radio_group"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/notification_importance_button_padding"
        android:clickable="true"
        android:focusable="true">
        <ImageView
            android:id="@+id/bubble_all_icon"
            android:src="@drawable/ic_bubble_all"
            android:background="@android:color/transparent"
            android:layout_centerVertical="true"
        android:checkedButton="@+id/redact_sensitive">

        <RadioButton
            android:id="@+id/bubble_all"
            style="@style/SudRadioButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="false"
            android:focusable="false"/>
        <TextView
            android:id="@+id/bubble_all_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:ellipsize="end"
            android:maxLines="3"
            android:clickable="false"
            android:focusable="false"
            android:layout_toEndOf="@id/bubble_all_icon"
            android:layout_marginStart="@dimen/notification_importance_drawable_padding"
            android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected"
            android:text="@string/bubble_app_setting_all"/>
    </com.android.settings.notification.NotificationButtonRelativeLayout>
            android:layout_marginVertical="0dp"
            android:fontFamily="@*android:string/config_headlineFontFamily"
            android:minHeight="56dp"
            android:text="@string/bubble_app_setting_all"
            android:textColor="?android:attr/textColorSecondary" />

    <com.android.settings.notification.NotificationButtonRelativeLayout
        <RadioButton
            android:id="@+id/bubble_selected"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/notification_importance_button_padding"
        android:layout_marginTop="@dimen/notification_importance_button_separation"
        android:clickable="true"
        android:focusable="true">
        <ImageView
            android:id="@+id/bubble_selected_icon"
            android:src="@drawable/ic_bubble_selected"
            android:background="@android:color/transparent"
            android:layout_centerVertical="true"
            style="@style/SudRadioButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="false"
            android:focusable="false"/>
        <TextView
            android:id="@+id/bubble_selected_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:ellipsize="end"
            android:maxLines="3"
            android:clickable="false"
            android:focusable="false"
            android:layout_toEndOf="@id/bubble_selected_icon"
            android:layout_marginStart="@dimen/notification_importance_drawable_padding"
            android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected"
            android:text="@string/bubble_app_setting_selected"/>
    </com.android.settings.notification.NotificationButtonRelativeLayout>
            android:layout_marginVertical="0dp"
            android:fontFamily="@*android:string/config_headlineFontFamily"
            android:minHeight="56dp"
            android:text="@string/bubble_app_setting_selected"
            android:textColor="?android:attr/textColorSecondary" />

    <com.android.settings.notification.NotificationButtonRelativeLayout
        <RadioButton
            android:id="@+id/bubble_none"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/notification_importance_button_padding"
        android:layout_marginTop="@dimen/notification_importance_button_separation"
        android:clickable="true"
        android:focusable="true">
        <ImageView
            android:id="@+id/bubble_none_icon"
            android:src="@drawable/ic_bubble_none"
            android:background="@android:color/transparent"
            android:layout_centerVertical="true"
            style="@style/SudRadioButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="false"
            android:focusable="false"/>
        <TextView
            android:id="@+id/bubble_none_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:ellipsize="end"
            android:maxLines="3"
            android:clickable="false"
            android:focusable="false"
            android:layout_toEndOf="@id/bubble_none_icon"
            android:layout_marginStart="@dimen/notification_importance_drawable_padding"
            android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected"
            android:text="@string/bubble_app_setting_none"/>
    </com.android.settings.notification.NotificationButtonRelativeLayout>

            android:layout_marginVertical="0dp"
            android:fontFamily="@*android:string/config_headlineFontFamily"
            android:minHeight="56dp"
            android:text="@string/bubble_app_setting_none"
            android:textColor="?android:attr/textColorSecondary" />
    </RadioGroup>
</LinearLayout>
+32 −80
Original line number Diff line number Diff line
@@ -21,34 +21,27 @@ import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE;
import static android.app.NotificationManager.BUBBLE_PREFERENCE_SELECTED;

import android.content.Context;
import android.content.res.ColorStateList;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import androidx.annotation.NonNull;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;

import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedPreferenceHelper;

/**
 * A tri-state preference allowing a user to specify what gets to bubble.
 */
public class BubblePreference extends Preference implements View.OnClickListener {
public class BubblePreference extends Preference implements RadioGroup.OnCheckedChangeListener {
    RestrictedPreferenceHelper mHelper;

    private int mSelectedPreference;

    private Context mContext;

    private ButtonViewHolder mBubbleAllButton;
    private ButtonViewHolder mBubbleSelectedButton;
    private ButtonViewHolder mBubbleNoneButton;

    private boolean mSelectedVisible;

    public BubblePreference(Context context) {
@@ -68,12 +61,12 @@ public class BubblePreference extends Preference implements View.OnClickListener
        super(context, attrs, defStyleAttr, defStyleRes);
        mHelper = new RestrictedPreferenceHelper(context, this, attrs);
        mHelper.useAdminDisabledSummary(true);
        mContext = context;
        setLayoutResource(R.layout.bubble_preference);
    }

    public void setSelectedPreference(int preference) {
        mSelectedPreference = preference;
        notifyChanged();
    }

    public int getSelectedPreference() {
@@ -92,9 +85,8 @@ public class BubblePreference extends Preference implements View.OnClickListener
    }

    @Override
    public void onBindViewHolder(final PreferenceViewHolder holder) {
    public void onBindViewHolder(@NonNull final PreferenceViewHolder holder) {
        super.onBindViewHolder(holder);

        final boolean disabledByAdmin = mHelper.isDisabledByAdmin();
        View summary = holder.findViewById(android.R.id.summary);
        if (disabledByAdmin) {
@@ -105,74 +97,34 @@ public class BubblePreference extends Preference implements View.OnClickListener
        }
        holder.itemView.setClickable(false);

        View bubbleAll = holder.findViewById(R.id.bubble_all);
        ImageView bubbleAllImage = (ImageView) holder.findViewById(R.id.bubble_all_icon);
        TextView bubbleAllText = (TextView) holder.findViewById(R.id.bubble_all_label);
        mBubbleAllButton = new ButtonViewHolder(bubbleAll, bubbleAllImage, bubbleAllText,
                BUBBLE_PREFERENCE_ALL);
        mBubbleAllButton.setSelected(mContext, mSelectedPreference == BUBBLE_PREFERENCE_ALL);
        bubbleAll.setTag(BUBBLE_PREFERENCE_ALL);
        bubbleAll.setOnClickListener(this);
        bubbleAll.setVisibility(disabledByAdmin ? View.GONE : View.VISIBLE);

        View bubbleSelected = holder.findViewById(R.id.bubble_selected);
        ImageView bubbleSelectedImage = (ImageView) holder.findViewById(R.id.bubble_selected_icon);
        TextView bubbleSelectedText = (TextView) holder.findViewById(R.id.bubble_selected_label);
        mBubbleSelectedButton = new ButtonViewHolder(bubbleSelected, bubbleSelectedImage,
                bubbleSelectedText, BUBBLE_PREFERENCE_SELECTED);
        mBubbleSelectedButton.setSelected(mContext,
                mSelectedPreference == BUBBLE_PREFERENCE_SELECTED);
        bubbleSelected.setTag(BUBBLE_PREFERENCE_SELECTED);
        bubbleSelected.setOnClickListener(this);
        bubbleSelected.setVisibility((!mSelectedVisible || disabledByAdmin)
                ? View.GONE : View.VISIBLE);

        View bubbleNone = holder.findViewById(R.id.bubble_none);
        ImageView bubbleNoneImage = (ImageView) holder.findViewById(R.id.bubble_none_icon);
        TextView bubbleNoneText = (TextView) holder.findViewById(R.id.bubble_none_label);
        mBubbleNoneButton = new ButtonViewHolder(bubbleNone, bubbleNoneImage, bubbleNoneText,
                BUBBLE_PREFERENCE_NONE);
        mBubbleNoneButton.setSelected(mContext, mSelectedPreference == BUBBLE_PREFERENCE_NONE);
        bubbleNone.setTag(BUBBLE_PREFERENCE_NONE);
        bubbleNone.setOnClickListener(this);
        bubbleNone.setVisibility(disabledByAdmin ? View.GONE : View.VISIBLE);
    }
        RadioButton bubbleAllButton = (RadioButton) holder.findViewById(R.id.bubble_all);
        bubbleAllButton.setChecked(mSelectedPreference == BUBBLE_PREFERENCE_ALL);
        bubbleAllButton.setTag(BUBBLE_PREFERENCE_ALL);
        bubbleAllButton.setVisibility(disabledByAdmin ? View.GONE : View.VISIBLE);

    @Override
    public void onClick(View v) {
        final int selected = (int) v.getTag();
        callChangeListener(selected);
        RadioButton bubbleSelectedButton = (RadioButton) holder.findViewById(R.id.bubble_selected);
        bubbleSelectedButton.setChecked(mSelectedPreference == BUBBLE_PREFERENCE_SELECTED);
        bubbleSelectedButton.setTag(BUBBLE_PREFERENCE_SELECTED);
        int selectedButtonVisibility =
                (!mSelectedVisible || disabledByAdmin) ? View.GONE : View.VISIBLE;
        bubbleSelectedButton.setVisibility(selectedButtonVisibility);

        mBubbleAllButton.setSelected(mContext, selected == BUBBLE_PREFERENCE_ALL);
        mBubbleSelectedButton.setSelected(mContext, selected == BUBBLE_PREFERENCE_SELECTED);
        mBubbleNoneButton.setSelected(mContext, selected == BUBBLE_PREFERENCE_NONE);
    }
        RadioButton bubbleNoneButton = (RadioButton) holder.findViewById(R.id.bubble_none);
        bubbleNoneButton.setChecked(mSelectedPreference == BUBBLE_PREFERENCE_NONE);
        bubbleNoneButton.setTag(BUBBLE_PREFERENCE_NONE);
        bubbleNoneButton.setVisibility(disabledByAdmin ? View.GONE : View.VISIBLE);

    private class ButtonViewHolder {
        private View mView;
        private ImageView mImageView;
        private TextView mTextView;
        private int mId;

        ButtonViewHolder(View v, ImageView iv, TextView tv, int identifier) {
            mView = v;
            mImageView = iv;
            mTextView = tv;
            mId = identifier;
        RadioGroup bublesRadioGroup = (RadioGroup) holder.findViewById(R.id.radio_group);
        bublesRadioGroup.setOnCheckedChangeListener(this);
    }

        void setSelected(Context context, boolean selected) {
            mView.setBackground(mContext.getDrawable(selected
                ? R.drawable.notification_importance_button_background_selected
                : R.drawable.notification_importance_button_background_unselected));
            mView.setSelected(selected);

            int colorResId = selected
                    ? R.attr.notification_importance_button_foreground_color_selected
                    : R.attr.notification_importance_button_foreground_color_unselected;
            ColorStateList stateList = Utils.getColorAttr(context, colorResId);
            mImageView.setImageTintList(stateList);
            mTextView.setTextColor(stateList);
    @Override
    public void onCheckedChanged(@NonNull RadioGroup group, int checkedId) {
        View v = group.findViewById(checkedId);
        if (v == null || v.getTag() == null) {
            return;
        }
        int selectedTag = (int) v.getTag();
        callChangeListener(selectedTag);
    }
}