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:
committed by
Michael Bestas
parent
2fa1f81707
commit
4246987beb
@@ -17,44 +17,19 @@ package com.android.messaging.datamodel.data;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.android.messaging.R;
|
||||
import com.android.messaging.datamodel.data.ConversationListItemData.ConversationListViewColumns;
|
||||
import com.android.messaging.util.Assert;
|
||||
import com.android.messaging.util.RingtoneUtil;
|
||||
|
||||
public class PeopleOptionsItemData {
|
||||
public static final String[] PROJECTION = {
|
||||
ConversationListViewColumns.NOTIFICATION_ENABLED,
|
||||
ConversationListViewColumns.NOTIFICATION_SOUND_URI,
|
||||
ConversationListViewColumns.NOTIFICATION_VIBRATION,
|
||||
};
|
||||
|
||||
// Column index for query projection.
|
||||
private static final int INDEX_NOTIFICATION_ENABLED = 0;
|
||||
private static final int INDEX_NOTIFICATION_SOUND_URI = 1;
|
||||
private static final int INDEX_NOTIFICATION_VIBRATION = 2;
|
||||
|
||||
// Identification for each setting that's surfaced to the UI layer.
|
||||
public static final int SETTING_NOTIFICATION_ENABLED = 0;
|
||||
public static final int SETTING_NOTIFICATION_SOUND_URI = 1;
|
||||
public static final int SETTING_NOTIFICATION_VIBRATION = 2;
|
||||
public static final int SETTING_BLOCKED = 3;
|
||||
public static final int SETTINGS_COUNT = 4;
|
||||
|
||||
// Type of UI switch to show for the toggle button.
|
||||
public static final int TOGGLE_TYPE_CHECKBOX = 0;
|
||||
public static final int TOGGLE_TYPE_SWITCH = 1;
|
||||
public static final int SETTING_NOTIFICATION = 0;
|
||||
public static final int SETTING_BLOCKED = 1;
|
||||
public static final int SETTINGS_COUNT = 2;
|
||||
|
||||
private String mTitle;
|
||||
private String mSubtitle;
|
||||
private Uri mRingtoneUri;
|
||||
private boolean mCheckable;
|
||||
private boolean mChecked;
|
||||
private boolean mEnabled;
|
||||
private int mItemId;
|
||||
private ParticipantData mOtherParticipant;
|
||||
|
||||
@@ -71,41 +46,12 @@ public class PeopleOptionsItemData {
|
||||
*/
|
||||
public void bind(
|
||||
final Cursor cursor, final ParticipantData otherParticipant, final int settingType) {
|
||||
mSubtitle = null;
|
||||
mRingtoneUri = null;
|
||||
mCheckable = true;
|
||||
mEnabled = true;
|
||||
mItemId = settingType;
|
||||
mOtherParticipant = otherParticipant;
|
||||
|
||||
final boolean notificationEnabled = cursor.getInt(INDEX_NOTIFICATION_ENABLED) == 1;
|
||||
switch (settingType) {
|
||||
case SETTING_NOTIFICATION_ENABLED:
|
||||
case SETTING_NOTIFICATION:
|
||||
mTitle = mContext.getString(R.string.notifications_enabled_conversation_pref_title);
|
||||
mChecked = notificationEnabled;
|
||||
break;
|
||||
|
||||
case SETTING_NOTIFICATION_SOUND_URI:
|
||||
mTitle = mContext.getString(R.string.notification_sound_pref_title);
|
||||
final String ringtoneString = cursor.getString(INDEX_NOTIFICATION_SOUND_URI);
|
||||
Uri ringtoneUri = RingtoneUtil.getNotificationRingtoneUri(ringtoneString);
|
||||
|
||||
mSubtitle = mContext.getString(R.string.silent_ringtone);
|
||||
if (ringtoneUri != null) {
|
||||
final Ringtone ringtone = RingtoneManager.getRingtone(mContext, ringtoneUri);
|
||||
if (ringtone != null) {
|
||||
mSubtitle = ringtone.getTitle(mContext);
|
||||
}
|
||||
}
|
||||
mCheckable = false;
|
||||
mRingtoneUri = ringtoneUri;
|
||||
mEnabled = notificationEnabled;
|
||||
break;
|
||||
|
||||
case SETTING_NOTIFICATION_VIBRATION:
|
||||
mTitle = mContext.getString(R.string.notification_vibrate_pref_title);
|
||||
mChecked = cursor.getInt(INDEX_NOTIFICATION_VIBRATION) == 1;
|
||||
mEnabled = notificationEnabled;
|
||||
break;
|
||||
|
||||
case SETTING_BLOCKED:
|
||||
@@ -113,7 +59,6 @@ public class PeopleOptionsItemData {
|
||||
final int resourceId = otherParticipant.isBlocked() ?
|
||||
R.string.unblock_contact_title : R.string.block_contact_title;
|
||||
mTitle = mContext.getString(resourceId, otherParticipant.getDisplayDestination());
|
||||
mCheckable = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -125,30 +70,10 @@ public class PeopleOptionsItemData {
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
public String getSubtitle() {
|
||||
return mSubtitle;
|
||||
}
|
||||
|
||||
public boolean getCheckable() {
|
||||
return mCheckable;
|
||||
}
|
||||
|
||||
public boolean getChecked() {
|
||||
return mChecked;
|
||||
}
|
||||
|
||||
public boolean getEnabled() {
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return mItemId;
|
||||
}
|
||||
|
||||
public Uri getRingtoneUri() {
|
||||
return mRingtoneUri;
|
||||
}
|
||||
|
||||
public ParticipantData getOtherParticipant() {
|
||||
return mOtherParticipant;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user