Merge "Redesign individual conversation page" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
43d9013aaa
@@ -68,7 +68,7 @@ public class BubblePreferenceController extends NotificationPreferenceController
|
||||
if (isDefaultChannel()) {
|
||||
return true;
|
||||
} else {
|
||||
return mAppRow != null && mAppRow.allowBubbles;
|
||||
return mAppRow != null;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@@ -18,15 +18,8 @@ package com.android.settings.notification.app;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.notification.NotificationBackend;
|
||||
@@ -60,7 +53,7 @@ public class ConversationListSettings extends DashboardFragment {
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
mControllers = new ArrayList<>();
|
||||
mControllers.add(new ImportantConversationsPreferenceController(context, mBackend));
|
||||
mControllers.add(new PriorityConversationsPreferenceController(context, mBackend));
|
||||
mControllers.add(new AllConversationsPreferenceController(context, mBackend));
|
||||
return new ArrayList<>(mControllers);
|
||||
}
|
||||
|
@@ -79,18 +79,13 @@ public class ConversationNotificationSettings extends NotificationSettings {
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
mControllers = new ArrayList<>();
|
||||
mControllers.add(new ConversationHeaderPreferenceController(context, this));
|
||||
mControllers.add(new ConversationImportantPreferenceController(
|
||||
mControllers.add(new ConversationPriorityPreferenceController(
|
||||
context, mBackend, mDependentFieldListener));
|
||||
mControllers.add(new DefaultImportancePreferenceController(
|
||||
context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new AddToHomeScreenPreferenceController(context, mBackend));
|
||||
mControllers.add(new HighImportancePreferenceController(
|
||||
context, mDependentFieldListener, mBackend));
|
||||
mControllers.add(new SoundPreferenceController(context, this,
|
||||
mDependentFieldListener, mBackend));
|
||||
mControllers.add(new VibrationPreferenceController(context, mBackend));
|
||||
mControllers.add(new AppLinkPreferenceController(context));
|
||||
mControllers.add(new DescriptionPreferenceController(context));
|
||||
mControllers.add(new VisibilityPreferenceController(context, new LockPatternUtils(context),
|
||||
mBackend));
|
||||
mControllers.add(new LightsPreferenceController(context, mBackend));
|
||||
|
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.notification.app;
|
||||
|
||||
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
|
||||
import static android.app.NotificationManager.IMPORTANCE_LOW;
|
||||
import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.transition.AutoTransition;
|
||||
import android.transition.TransitionManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Pair;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.R;
|
||||
|
||||
public class ConversationPriorityPreference extends Preference {
|
||||
|
||||
private boolean mIsConfigurable = true;
|
||||
private int mImportance;
|
||||
private int mOriginalImportance;
|
||||
private boolean mPriorityConversation;
|
||||
private View mSilenceButton;
|
||||
private View mAlertButton;
|
||||
private View mPriorityButton;
|
||||
private Context mContext;
|
||||
Drawable selectedBackground;
|
||||
Drawable unselectedBackground;
|
||||
private static final int BUTTON_ANIM_TIME_MS = 100;
|
||||
|
||||
public ConversationPriorityPreference(Context context, AttributeSet attrs,
|
||||
int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public ConversationPriorityPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public ConversationPriorityPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public ConversationPriorityPreference(Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
|
||||
private void init(Context context) {
|
||||
mContext = context;
|
||||
selectedBackground = mContext.getDrawable(R.drawable.button_border_selected);
|
||||
unselectedBackground = mContext.getDrawable(R.drawable.button_border_unselected);
|
||||
setLayoutResource(R.layout.notif_priority_conversation_preference);
|
||||
}
|
||||
|
||||
public void setImportance(int importance) {
|
||||
mImportance = importance;
|
||||
}
|
||||
|
||||
public void setConfigurable(boolean configurable) {
|
||||
mIsConfigurable = configurable;
|
||||
}
|
||||
|
||||
public void setPriorityConversation(boolean priorityConversation) {
|
||||
mPriorityConversation = priorityConversation;
|
||||
}
|
||||
|
||||
public void setOriginalImportance(int importance) {
|
||||
mOriginalImportance = importance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
holder.itemView.setClickable(false);
|
||||
|
||||
mSilenceButton = holder.findViewById(R.id.silence);
|
||||
mAlertButton = holder.findViewById(R.id.alert);
|
||||
mPriorityButton = holder.findViewById(R.id.priority_group);
|
||||
|
||||
if (!mIsConfigurable) {
|
||||
mSilenceButton.setEnabled(false);
|
||||
mAlertButton.setEnabled(false);
|
||||
mPriorityButton.setEnabled(false);
|
||||
}
|
||||
|
||||
updateToggles((ViewGroup) holder.itemView, mImportance, mPriorityConversation,
|
||||
false);
|
||||
|
||||
mSilenceButton.setOnClickListener(v -> {
|
||||
callChangeListener(new Pair(IMPORTANCE_LOW, false));
|
||||
updateToggles((ViewGroup) holder.itemView, IMPORTANCE_LOW, false, true);
|
||||
});
|
||||
mAlertButton.setOnClickListener(v -> {
|
||||
int newImportance = Math.max(mOriginalImportance, IMPORTANCE_DEFAULT);
|
||||
callChangeListener(new Pair(newImportance, false));
|
||||
updateToggles((ViewGroup) holder.itemView, newImportance, false, true);
|
||||
});
|
||||
mPriorityButton.setOnClickListener(v -> {
|
||||
int newImportance = Math.max(mOriginalImportance, IMPORTANCE_DEFAULT);
|
||||
callChangeListener(new Pair(newImportance, true));
|
||||
updateToggles((ViewGroup) holder.itemView, newImportance, true, true);
|
||||
});
|
||||
}
|
||||
|
||||
private ColorStateList getAccentTint() {
|
||||
return Utils.getColorAccent(getContext());
|
||||
}
|
||||
|
||||
private ColorStateList getRegularTint() {
|
||||
return Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary);
|
||||
}
|
||||
|
||||
void updateToggles(ViewGroup parent, int importance, boolean isPriority,
|
||||
boolean fromUser) {
|
||||
if (fromUser) {
|
||||
AutoTransition transition = new AutoTransition();
|
||||
transition.setDuration(BUTTON_ANIM_TIME_MS);
|
||||
TransitionManager.beginDelayedTransition(parent, transition);
|
||||
}
|
||||
|
||||
ColorStateList colorAccent = getAccentTint();
|
||||
ColorStateList colorNormal = getRegularTint();
|
||||
ImageView silenceIcon = parent.findViewById(R.id.silence_icon);
|
||||
TextView silenceLabel = parent.findViewById(R.id.silence_label);
|
||||
TextView silenceSummary = parent.findViewById(R.id.silence_summary);
|
||||
ImageView alertIcon = parent.findViewById(R.id.alert_icon);
|
||||
TextView alertLabel = parent.findViewById(R.id.alert_label);
|
||||
TextView alertSummary = parent.findViewById(R.id.alert_summary);
|
||||
ImageView priorityIcon = parent.findViewById(R.id.priority_icon);
|
||||
TextView priorityLabel = parent.findViewById(R.id.priority_label);
|
||||
TextView prioritySummary = parent.findViewById(R.id.priority_summary);
|
||||
|
||||
if (importance <= IMPORTANCE_LOW && importance > IMPORTANCE_UNSPECIFIED) {
|
||||
alertSummary.setVisibility(GONE);
|
||||
alertIcon.setImageTintList(colorNormal);
|
||||
alertLabel.setTextColor(colorNormal);
|
||||
|
||||
prioritySummary.setVisibility(GONE);
|
||||
priorityIcon.setImageTintList(colorNormal);
|
||||
priorityLabel.setTextColor(colorNormal);
|
||||
|
||||
silenceIcon.setImageTintList(colorAccent);
|
||||
silenceLabel.setTextColor(colorAccent);
|
||||
silenceSummary.setVisibility(VISIBLE);
|
||||
|
||||
mAlertButton.setBackground(unselectedBackground);
|
||||
mPriorityButton.setBackground(unselectedBackground);
|
||||
mSilenceButton.setBackground(selectedBackground);
|
||||
// a11y service won't always read the newly appearing text in the right order if the
|
||||
// selection happens too soon (readback happens on a different thread as layout). post
|
||||
// the selection to make that conflict less likely
|
||||
parent.post(() -> mSilenceButton.setSelected(true));
|
||||
} else {
|
||||
if (isPriority) {
|
||||
alertSummary.setVisibility(GONE);
|
||||
alertIcon.setImageTintList(colorNormal);
|
||||
alertLabel.setTextColor(colorNormal);
|
||||
|
||||
prioritySummary.setVisibility(VISIBLE);
|
||||
priorityIcon.setImageTintList(colorAccent);
|
||||
priorityLabel.setTextColor(colorAccent);
|
||||
|
||||
silenceIcon.setImageTintList(colorNormal);
|
||||
silenceLabel.setTextColor(colorNormal);
|
||||
silenceSummary.setVisibility(GONE);
|
||||
|
||||
mAlertButton.setBackground(unselectedBackground);
|
||||
mPriorityButton.setBackground(selectedBackground);
|
||||
mSilenceButton.setBackground(unselectedBackground);
|
||||
parent.post(() -> mPriorityButton.setSelected(true));
|
||||
} else {
|
||||
alertSummary.setVisibility(VISIBLE);
|
||||
alertIcon.setImageTintList(colorAccent);
|
||||
alertLabel.setTextColor(colorAccent);
|
||||
|
||||
prioritySummary.setVisibility(GONE);
|
||||
priorityIcon.setImageTintList(colorNormal);
|
||||
priorityLabel.setTextColor(colorNormal);
|
||||
|
||||
silenceIcon.setImageTintList(colorNormal);
|
||||
silenceLabel.setTextColor(colorNormal);
|
||||
silenceSummary.setVisibility(GONE);
|
||||
|
||||
mAlertButton.setBackground(selectedBackground);
|
||||
mPriorityButton.setBackground(unselectedBackground);
|
||||
mSilenceButton.setBackground(unselectedBackground);
|
||||
parent.post(() -> mAlertButton.setSelected(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -16,25 +16,22 @@
|
||||
|
||||
package com.android.settings.notification.app;
|
||||
|
||||
import static android.provider.Settings.Secure.BUBBLE_IMPORTANT_CONVERSATIONS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.notification.NotificationBackend;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
|
||||
public class ConversationImportantPreferenceController extends NotificationPreferenceController
|
||||
public class ConversationPriorityPreferenceController extends NotificationPreferenceController
|
||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String TAG = "ConvoImpPC";
|
||||
private static final String KEY = "important";
|
||||
private static final String TAG = "ConvoPriorityPC";
|
||||
private static final String KEY = "priority";
|
||||
private final NotificationSettings.DependentFieldListener mDependentFieldListener;
|
||||
|
||||
public ConversationImportantPreferenceController(Context context,
|
||||
public ConversationPriorityPreferenceController(Context context,
|
||||
NotificationBackend backend, NotificationSettings.DependentFieldListener listener) {
|
||||
super(context, backend);
|
||||
mDependentFieldListener = listener;
|
||||
@@ -58,10 +55,12 @@ public class ConversationImportantPreferenceController extends NotificationPrefe
|
||||
|
||||
public void updateState(Preference preference) {
|
||||
if (mAppRow != null) {
|
||||
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
|
||||
pref.setDisabledByAdmin(mAdmin);
|
||||
pref.setChecked(mChannel.isImportantConversation());
|
||||
pref.setEnabled(!pref.isDisabledByAdmin());
|
||||
preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());
|
||||
ConversationPriorityPreference pref = (ConversationPriorityPreference) preference;
|
||||
pref.setConfigurable(!mChannel.isImportanceLockedByOEM());
|
||||
pref.setImportance(mChannel.getImportance());
|
||||
pref.setOriginalImportance(mChannel.getOriginalImportance());
|
||||
pref.setPriorityConversation(mChannel.isImportantConversation());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,19 +69,21 @@ public class ConversationImportantPreferenceController extends NotificationPrefe
|
||||
if (mChannel == null) {
|
||||
return false;
|
||||
}
|
||||
final boolean value = (Boolean) newValue;
|
||||
mChannel.setImportantConversation(value);
|
||||
if (value && bubbleImportantConversations()) {
|
||||
boolean wasPriorityConversation = mChannel.isImportantConversation();
|
||||
|
||||
final Pair<Integer, Boolean> value = (Pair) newValue;
|
||||
mChannel.setImportance(value.first);
|
||||
mChannel.setImportantConversation(value.second);
|
||||
|
||||
if (value.second) {
|
||||
mChannel.setAllowBubbles(true);
|
||||
} else if (wasPriorityConversation) {
|
||||
mChannel.setAllowBubbles(false);
|
||||
}
|
||||
|
||||
mDependentFieldListener.onFieldValueChanged();
|
||||
saveChannel();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean bubbleImportantConversations() {
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
BUBBLE_IMPORTANT_CONVERSATIONS, 1) == 1;
|
||||
}
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.notification.app;
|
||||
|
||||
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
|
||||
import static android.app.NotificationManager.IMPORTANCE_LOW;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.notification.NotificationBackend;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
|
||||
public class DefaultImportancePreferenceController extends NotificationPreferenceController
|
||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String KEY = "alerting";
|
||||
private NotificationSettings.DependentFieldListener mDependentFieldListener;
|
||||
|
||||
public DefaultImportancePreferenceController(Context context,
|
||||
NotificationSettings.DependentFieldListener dependentFieldListener,
|
||||
NotificationBackend backend) {
|
||||
super(context, backend);
|
||||
mDependentFieldListener = dependentFieldListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
if (!super.isAvailable()) {
|
||||
return false;
|
||||
}
|
||||
if (mChannel == null) {
|
||||
return false;
|
||||
}
|
||||
if (isDefaultChannel()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (mAppRow != null && mChannel != null) {
|
||||
preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());
|
||||
|
||||
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
|
||||
pref.setChecked(mChannel.getImportance() >= IMPORTANCE_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (mChannel != null) {
|
||||
final boolean checked = (boolean) newValue;
|
||||
|
||||
mChannel.setImportance(checked ? IMPORTANCE_DEFAULT : IMPORTANCE_LOW);
|
||||
mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
|
||||
saveChannel();
|
||||
mDependentFieldListener.onFieldValueChanged();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -28,14 +28,14 @@ import com.android.settings.notification.NotificationBackend;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ImportantConversationsPreferenceController extends
|
||||
public class PriorityConversationsPreferenceController extends
|
||||
ConversationListPreferenceController {
|
||||
|
||||
private static final String KEY = "important_conversations";
|
||||
private static final String LIST_KEY = "important_conversations_list";
|
||||
private List<ConversationChannelWrapper> mConversations;
|
||||
|
||||
public ImportantConversationsPreferenceController(Context context,
|
||||
public PriorityConversationsPreferenceController(Context context,
|
||||
NotificationBackend backend) {
|
||||
super(context, backend);
|
||||
}
|
Reference in New Issue
Block a user