Messaging: Implement per conversation channels. Update API level to 28.
* Get rid of in-app settings for notifications, replaced by channels features * Remove all the notification plumbing and dead code Test: m, manual Signed-off-by: Luca Stefani <luca.stefani.ge1@gmail.com> Signed-off-by: Joey <joey@lineageos.org> Signed-off-by: Danny Baumann <dannybaumann@web.de> Signed-off-by: Arne Coucheron <arco68@gmail.com> Signed-off-by: Lyubo <lyubodzhamov@gmail.com> Change-Id: Idb39ca32751d40b3376934775d2119dd6cc7e297
This commit is contained in:
@@ -18,12 +18,12 @@ package com.android.messaging.ui.conversationsettings;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Fragment;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.media.RingtoneManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.provider.Settings;
|
||||
@@ -49,6 +49,7 @@ import com.android.messaging.ui.CompositeAdapter;
|
||||
import com.android.messaging.ui.PersonItemView;
|
||||
import com.android.messaging.ui.UIIntents;
|
||||
import com.android.messaging.ui.conversation.ConversationActivity;
|
||||
import com.android.messaging.util.NotificationsUtil;
|
||||
import com.android.messaging.util.Assert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -62,11 +63,10 @@ public class PeopleAndOptionsFragment extends Fragment
|
||||
private ListView mListView;
|
||||
private OptionsListAdapter mOptionsListAdapter;
|
||||
private PeopleListAdapter mPeopleListAdapter;
|
||||
private List<ParticipantData> mOtherParticipants;
|
||||
private final Binding<PeopleAndOptionsData> mBinding =
|
||||
BindingBase.createBinding(this);
|
||||
|
||||
private static final int REQUEST_CODE_RINGTONE_PICKER = 1000;
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -89,17 +89,6 @@ public class PeopleAndOptionsFragment extends Fragment
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE_RINGTONE_PICKER) {
|
||||
final Parcelable pick = data.getParcelableExtra(
|
||||
RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||
final String pickedUri = pick == null ? "" : pick.toString();
|
||||
mBinding.getData().setConversationNotificationSound(mBinding, pickedUri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
@@ -125,30 +114,31 @@ public class PeopleAndOptionsFragment extends Fragment
|
||||
final List<ParticipantData> participants) {
|
||||
mBinding.ensureBound(data);
|
||||
mPeopleListAdapter.updateParticipants(participants);
|
||||
mOtherParticipants = participants;
|
||||
final ParticipantData otherParticipant = participants.size() == 1 ?
|
||||
participants.get(0) : null;
|
||||
mOptionsListAdapter.setOtherParticipant(otherParticipant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOptionsItemViewClicked(final PeopleOptionsItemData item,
|
||||
final boolean isChecked) {
|
||||
public void onOptionsItemViewClicked(final PeopleOptionsItemData item) {
|
||||
switch (item.getItemId()) {
|
||||
case PeopleOptionsItemData.SETTING_NOTIFICATION_ENABLED:
|
||||
mBinding.getData().enableConversationNotifications(mBinding, isChecked);
|
||||
break;
|
||||
|
||||
case PeopleOptionsItemData.SETTING_NOTIFICATION_SOUND_URI:
|
||||
final Intent ringtonePickerIntent = UIIntents.get().getRingtonePickerIntent(
|
||||
getString(R.string.notification_sound_pref_title),
|
||||
item.getRingtoneUri(), Settings.System.DEFAULT_NOTIFICATION_URI,
|
||||
RingtoneManager.TYPE_NOTIFICATION);
|
||||
startActivityForResult(ringtonePickerIntent, REQUEST_CODE_RINGTONE_PICKER);
|
||||
break;
|
||||
|
||||
case PeopleOptionsItemData.SETTING_NOTIFICATION_VIBRATION:
|
||||
mBinding.getData().enableConversationNotificationVibration(mBinding,
|
||||
isChecked);
|
||||
case PeopleOptionsItemData.SETTING_NOTIFICATION:
|
||||
ArrayList<String> participantsNames = new ArrayList<String>();
|
||||
for (ParticipantData participant : mOtherParticipants) {
|
||||
participantsNames.add(participant.getDisplayName(true));
|
||||
}
|
||||
NotificationsUtil.createNotificationChannelGroup(getActivity(),
|
||||
NotificationsUtil.CONVERSATION_GROUP_NAME,
|
||||
R.string.notification_channel_messages_title);
|
||||
NotificationsUtil.createNotificationChannel(getActivity(),
|
||||
mBinding.getData().getConversationId(),
|
||||
String.join(", ", participantsNames),
|
||||
NotificationManager.IMPORTANCE_DEFAULT,
|
||||
NotificationsUtil.CONVERSATION_GROUP_NAME);
|
||||
Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getContext().getPackageName());
|
||||
startActivity(intent);
|
||||
break;
|
||||
|
||||
case PeopleOptionsItemData.SETTING_BLOCKED:
|
||||
|
||||
@@ -38,7 +38,7 @@ public class PeopleOptionsItemView extends LinearLayout {
|
||||
* Implemented by the host of this view that handles options click event.
|
||||
*/
|
||||
public interface HostInterface {
|
||||
void onOptionsItemViewClicked(PeopleOptionsItemData item, boolean isChecked);
|
||||
void onOptionsItemViewClicked(PeopleOptionsItemData item);
|
||||
}
|
||||
|
||||
private TextView mTitle;
|
||||
@@ -55,12 +55,10 @@ public class PeopleOptionsItemView extends LinearLayout {
|
||||
@Override
|
||||
protected void onFinishInflate () {
|
||||
mTitle = (TextView) findViewById(R.id.title);
|
||||
mSubtitle = (TextView) findViewById(R.id.subtitle);
|
||||
mSwitch = (SwitchCompat) findViewById(R.id.switch_button);
|
||||
setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
mHostInterface.onOptionsItemViewClicked(mData, !mData.getChecked());
|
||||
mHostInterface.onOptionsItemViewClicked(mData);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -72,28 +70,5 @@ public class PeopleOptionsItemView extends LinearLayout {
|
||||
mHostInterface = hostInterface;
|
||||
|
||||
mTitle.setText(mData.getTitle());
|
||||
final String subtitle = mData.getSubtitle();
|
||||
if (TextUtils.isEmpty(subtitle)) {
|
||||
mSubtitle.setVisibility(GONE);
|
||||
} else {
|
||||
mSubtitle.setVisibility(VISIBLE);
|
||||
mSubtitle.setText(subtitle);
|
||||
}
|
||||
|
||||
if (mData.getCheckable()) {
|
||||
mSwitch.setVisibility(VISIBLE);
|
||||
mSwitch.setChecked(mData.getChecked());
|
||||
} else {
|
||||
mSwitch.setVisibility(GONE);
|
||||
}
|
||||
|
||||
final boolean enabled = mData.getEnabled();
|
||||
if (enabled != isEnabled()) {
|
||||
mTitle.setEnabled(enabled);
|
||||
mSubtitle.setEnabled(enabled);
|
||||
mSwitch.setEnabled(enabled);
|
||||
setAlpha(enabled ? 1.0f : 0.5f);
|
||||
setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user