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:
@@ -264,16 +264,6 @@ public abstract class UIIntents {
|
||||
*/
|
||||
public abstract Intent getViewUrlIntent(final String url);
|
||||
|
||||
/**
|
||||
* Get an intent to launch the ringtone picker
|
||||
* @param title the title to show in the ringtone picker
|
||||
* @param existingUri the currently set uri
|
||||
* @param defaultUri the default uri if none is currently set
|
||||
* @param toneType type of ringtone to pick, maybe any of RingtoneManager.TYPE_*
|
||||
*/
|
||||
public abstract Intent getRingtonePickerIntent(final String title, final Uri existingUri,
|
||||
final Uri defaultUri, final int toneType);
|
||||
|
||||
/**
|
||||
* Get an intent to launch the wireless alert viewer.
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.ContactsContract.Contacts;
|
||||
@@ -450,16 +449,6 @@ public class UIIntentsImpl extends UIIntents {
|
||||
return resultPendingIntent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getRingtonePickerIntent(final String title, final Uri existingUri,
|
||||
final Uri defaultUri, final int toneType) {
|
||||
return new Intent(RingtoneManager.ACTION_RINGTONE_PICKER)
|
||||
.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, toneType)
|
||||
.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, title)
|
||||
.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, existingUri)
|
||||
.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, defaultUri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PendingIntent getPendingIntentForLowStorageNotifications(final Context context) {
|
||||
final TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context);
|
||||
|
||||
@@ -18,18 +18,12 @@ package com.android.messaging.ui.appsettings;
|
||||
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.RingtonePreference;
|
||||
import android.preference.SwitchPreference;
|
||||
import android.preference.TwoStatePreference;
|
||||
import android.provider.Settings;
|
||||
import androidx.core.app.NavUtils;
|
||||
import android.text.TextUtils;
|
||||
@@ -85,14 +79,10 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public static class ApplicationSettingsFragment extends PreferenceFragment implements
|
||||
OnSharedPreferenceChangeListener {
|
||||
public static class ApplicationSettingsFragment extends PreferenceFragment {
|
||||
|
||||
private String mNotificationsEnabledPreferenceKey;
|
||||
private TwoStatePreference mNotificationsEnabledPreference;
|
||||
private String mRingtonePreferenceKey;
|
||||
private RingtonePreference mRingtonePreference;
|
||||
private Preference mVibratePreference;
|
||||
private String mNotificationsPreferenceKey;
|
||||
private Preference mNotificationsPreference;
|
||||
private String mSmsDisabledPrefKey;
|
||||
private Preference mSmsDisabledPreference;
|
||||
private String mSmsEnabledPrefKey;
|
||||
@@ -112,14 +102,9 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity {
|
||||
getPreferenceManager().setSharedPreferencesName(BuglePrefs.SHARED_PREFERENCES_NAME);
|
||||
addPreferencesFromResource(R.xml.preferences_application);
|
||||
|
||||
mNotificationsEnabledPreferenceKey =
|
||||
getString(R.string.notifications_enabled_pref_key);
|
||||
mNotificationsEnabledPreference = (TwoStatePreference) findPreference(
|
||||
mNotificationsEnabledPreferenceKey);
|
||||
mRingtonePreferenceKey = getString(R.string.notification_sound_pref_key);
|
||||
mRingtonePreference = (RingtonePreference) findPreference(mRingtonePreferenceKey);
|
||||
mVibratePreference = findPreference(
|
||||
getString(R.string.notification_vibration_pref_key));
|
||||
mNotificationsPreferenceKey =
|
||||
getString(R.string.notifications_pref_key);
|
||||
mNotificationsPreference = findPreference(mNotificationsPreferenceKey);
|
||||
mSmsDisabledPrefKey = getString(R.string.sms_disabled_pref_key);
|
||||
mSmsDisabledPreference = findPreference(mSmsDisabledPrefKey);
|
||||
mSmsEnabledPrefKey = getString(R.string.sms_enabled_pref_key);
|
||||
@@ -130,9 +115,6 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity {
|
||||
(SwitchPreference) findPreference(mSwipeRightToDeleteConversationkey);
|
||||
mIsSmsPreferenceClicked = false;
|
||||
|
||||
final SharedPreferences prefs = getPreferenceScreen().getSharedPreferences();
|
||||
updateSoundSummary(prefs);
|
||||
|
||||
if (!DebugUtils.isDebugEnabled()) {
|
||||
final Preference debugCategory = findPreference(getString(
|
||||
R.string.debug_pref_key));
|
||||
@@ -154,8 +136,13 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick (PreferenceScreen preferenceScreen,
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
|
||||
Preference preference) {
|
||||
if (preference.getKey() == mNotificationsPreferenceKey) {
|
||||
Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getContext().getPackageName());
|
||||
startActivity(intent);
|
||||
}
|
||||
if (preference.getKey() == mSmsDisabledPrefKey ||
|
||||
preference.getKey() == mSmsEnabledPrefKey) {
|
||||
mIsSmsPreferenceClicked = true;
|
||||
@@ -163,35 +150,6 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity {
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
|
||||
private void updateSoundSummary(final SharedPreferences sharedPreferences) {
|
||||
// The silent ringtone just returns an empty string
|
||||
String ringtoneName = mRingtonePreference.getContext().getString(
|
||||
R.string.silent_ringtone);
|
||||
|
||||
String ringtoneString = sharedPreferences.getString(mRingtonePreferenceKey, null);
|
||||
|
||||
// Bootstrap the default setting in the preferences so that we have a valid selection
|
||||
// in the dialog the first time that the user opens it.
|
||||
if (ringtoneString == null) {
|
||||
ringtoneString = Settings.System.DEFAULT_NOTIFICATION_URI.toString();
|
||||
final SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(mRingtonePreferenceKey, ringtoneString);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(ringtoneString)) {
|
||||
final Uri ringtoneUri = Uri.parse(ringtoneString);
|
||||
final Ringtone tone = RingtoneManager.getRingtone(mRingtonePreference.getContext(),
|
||||
ringtoneUri);
|
||||
|
||||
if (tone != null) {
|
||||
ringtoneName = tone.getTitle(mRingtonePreference.getContext());
|
||||
}
|
||||
}
|
||||
|
||||
mRingtonePreference.setSummary(ringtoneName);
|
||||
}
|
||||
|
||||
private void updateSmsEnabledPreferences() {
|
||||
if (!OsUtil.isAtLeastKLP()) {
|
||||
getPreferenceScreen().removePreference(mSmsDisabledPreference);
|
||||
@@ -222,48 +180,14 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity {
|
||||
getPreferenceScreen().removePreference(mSmsEnabledPreference);
|
||||
mSmsDisabledPreference.setSummary(defaultSmsAppLabel);
|
||||
}
|
||||
updateNotificationsPreferences();
|
||||
}
|
||||
mIsSmsPreferenceClicked = false;
|
||||
}
|
||||
|
||||
private void updateNotificationsPreferences() {
|
||||
final boolean canNotify = !OsUtil.isAtLeastKLP()
|
||||
|| PhoneUtils.getDefault().isDefaultSmsApp();
|
||||
mNotificationsEnabledPreference.setEnabled(canNotify);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
// We do this on start rather than on resume because the sound picker is in a
|
||||
// separate activity.
|
||||
getPreferenceScreen().getSharedPreferences()
|
||||
.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateSmsEnabledPreferences();
|
||||
updateNotificationsPreferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences,
|
||||
final String key) {
|
||||
if (key.equals(mNotificationsEnabledPreferenceKey)) {
|
||||
updateNotificationsPreferences();
|
||||
} else if (key.equals(mRingtonePreferenceKey)) {
|
||||
updateSoundSummary(sharedPreferences);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
getPreferenceScreen().getSharedPreferences()
|
||||
.unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.view.View;
|
||||
import com.android.messaging.R;
|
||||
import com.android.messaging.datamodel.action.DeleteConversationAction;
|
||||
import com.android.messaging.datamodel.action.UpdateConversationArchiveStatusAction;
|
||||
import com.android.messaging.datamodel.action.UpdateConversationOptionsAction;
|
||||
import com.android.messaging.datamodel.action.UpdateDestinationBlockedAction;
|
||||
import com.android.messaging.datamodel.data.ConversationListData;
|
||||
import com.android.messaging.datamodel.data.ConversationListItemData;
|
||||
@@ -190,23 +189,6 @@ public abstract class AbstractConversationListActivity extends BugleActionBarAc
|
||||
exitMultiSelectState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionBarNotification(final Iterable<SelectedConversation> conversations,
|
||||
final boolean isNotificationOn) {
|
||||
for (final SelectedConversation conversation : conversations) {
|
||||
UpdateConversationOptionsAction.enableConversationNotifications(
|
||||
conversation.conversationId, isNotificationOn);
|
||||
}
|
||||
|
||||
final int textId = isNotificationOn ?
|
||||
R.string.notification_on_toast_message : R.string.notification_off_toast_message;
|
||||
final String message = getResources().getString(textId, 1);
|
||||
UiUtils.showSnackBar(this, findViewById(android.R.id.list), message,
|
||||
null /* undoRunnable */,
|
||||
SnackBar.Action.SNACK_BAR_UNDO, mConversationListFragment.getSnackBarInteractions());
|
||||
exitMultiSelectState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionBarAddContact(final SelectedConversation conversation) {
|
||||
final Uri avatarUri;
|
||||
|
||||
@@ -127,7 +127,6 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
|
||||
private TextView mTimestampTextView;
|
||||
private ContactIconView mContactIconView;
|
||||
private ImageView mContactCheckmarkView;
|
||||
private ImageView mNotificationBellView;
|
||||
private ImageView mFailedStatusIconView;
|
||||
private ImageView mCrossSwipeArchiveLeftImageView;
|
||||
private ImageView mCrossSwipeArchiveRightImageView;
|
||||
@@ -153,7 +152,6 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
|
||||
mTimestampTextView = (TextView) findViewById(R.id.conversation_timestamp);
|
||||
mContactIconView = (ContactIconView) findViewById(R.id.conversation_icon);
|
||||
mContactCheckmarkView = (ImageView) findViewById(R.id.conversation_checkmark);
|
||||
mNotificationBellView = (ImageView) findViewById(R.id.conversation_notification_bell);
|
||||
mFailedStatusIconView = (ImageView) findViewById(R.id.conversation_failed_status_icon);
|
||||
mCrossSwipeArchiveLeftImageView = (ImageView) findViewById(R.id.crossSwipeArchiveIconLeft);
|
||||
mCrossSwipeArchiveRightImageView =
|
||||
@@ -503,9 +501,6 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
|
||||
mAudioAttachmentView.setOnLongClickListener(this);
|
||||
mAudioAttachmentView.setVisibility(audioPreviewVisiblity);
|
||||
|
||||
final int notificationBellVisiblity = mData.getNotificationEnabled() ? GONE : VISIBLE;
|
||||
mNotificationBellView.setVisibility(notificationBellVisiblity);
|
||||
|
||||
if (PrefsUtils.isSwipeRightToDeleteEnabled()) {
|
||||
mCrossSwipeArchiveLeftImageView.setImageDrawable(getResources()
|
||||
.getDrawable(R.drawable.ic_delete_small_dark));
|
||||
|
||||
@@ -37,8 +37,6 @@ public class MultiSelectActionModeCallback implements Callback {
|
||||
void onActionBarDelete(Collection<SelectedConversation> conversations);
|
||||
void onActionBarArchive(Iterable<SelectedConversation> conversations,
|
||||
boolean isToArchive);
|
||||
void onActionBarNotification(Iterable<SelectedConversation> conversations,
|
||||
boolean isNotificationOn);
|
||||
void onActionBarAddContact(final SelectedConversation conversation);
|
||||
void onActionBarBlock(final SelectedConversation conversation);
|
||||
void onActionBarHome();
|
||||
@@ -52,7 +50,6 @@ public class MultiSelectActionModeCallback implements Callback {
|
||||
public final CharSequence participantLookupKey;
|
||||
public final boolean isGroup;
|
||||
public final boolean isArchived;
|
||||
public final boolean notificationEnabled;
|
||||
public SelectedConversation(ConversationListItemData data) {
|
||||
conversationId = data.getConversationId();
|
||||
timestamp = data.getTimestamp();
|
||||
@@ -61,7 +58,6 @@ public class MultiSelectActionModeCallback implements Callback {
|
||||
participantLookupKey = data.getParticipantLookupKey();
|
||||
isGroup = data.getIsGroup();
|
||||
isArchived = data.getIsArchived();
|
||||
notificationEnabled = data.getNotificationEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +68,6 @@ public class MultiSelectActionModeCallback implements Callback {
|
||||
private MenuItem mUnarchiveMenuItem;
|
||||
private MenuItem mAddContactMenuItem;
|
||||
private MenuItem mBlockMenuItem;
|
||||
private MenuItem mNotificationOnMenuItem;
|
||||
private MenuItem mNotificationOffMenuItem;
|
||||
private boolean mHasInflated;
|
||||
|
||||
public MultiSelectActionModeCallback(final Listener listener) {
|
||||
@@ -89,8 +83,6 @@ public class MultiSelectActionModeCallback implements Callback {
|
||||
mUnarchiveMenuItem = menu.findItem(R.id.action_unarchive);
|
||||
mAddContactMenuItem = menu.findItem(R.id.action_add_contact);
|
||||
mBlockMenuItem = menu.findItem(R.id.action_block);
|
||||
mNotificationOffMenuItem = menu.findItem(R.id.action_notification_off);
|
||||
mNotificationOnMenuItem = menu.findItem(R.id.action_notification_on);
|
||||
mHasInflated = true;
|
||||
updateActionIconsVisiblity();
|
||||
return true;
|
||||
@@ -113,12 +105,6 @@ public class MultiSelectActionModeCallback implements Callback {
|
||||
case R.id.action_unarchive:
|
||||
mListener.onActionBarArchive(mSelectedConversations.values(), false);
|
||||
return true;
|
||||
case R.id.action_notification_off:
|
||||
mListener.onActionBarNotification(mSelectedConversations.values(), false);
|
||||
return true;
|
||||
case R.id.action_notification_on:
|
||||
mListener.onActionBarNotification(mSelectedConversations.values(), true);
|
||||
return true;
|
||||
case R.id.action_add_contact:
|
||||
Assert.isTrue(mSelectedConversations.size() == 1);
|
||||
mListener.onActionBarAddContact(mSelectedConversations.valueAt(0));
|
||||
@@ -186,16 +172,8 @@ public class MultiSelectActionModeCallback implements Callback {
|
||||
|
||||
boolean hasCurrentlyArchived = false;
|
||||
boolean hasCurrentlyUnarchived = false;
|
||||
boolean hasCurrentlyOnNotification = false;
|
||||
boolean hasCurrentlyOffNotification = false;
|
||||
final Iterable<SelectedConversation> conversations = mSelectedConversations.values();
|
||||
for (final SelectedConversation conversation : conversations) {
|
||||
if (conversation.notificationEnabled) {
|
||||
hasCurrentlyOnNotification = true;
|
||||
} else {
|
||||
hasCurrentlyOffNotification = true;
|
||||
}
|
||||
|
||||
if (conversation.isArchived) {
|
||||
hasCurrentlyArchived = true;
|
||||
} else {
|
||||
@@ -203,15 +181,10 @@ public class MultiSelectActionModeCallback implements Callback {
|
||||
}
|
||||
|
||||
// If we found at least one of each example we don't need to keep looping.
|
||||
if (hasCurrentlyOffNotification && hasCurrentlyOnNotification &&
|
||||
hasCurrentlyArchived && hasCurrentlyUnarchived) {
|
||||
if (hasCurrentlyArchived && hasCurrentlyUnarchived) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If we have notification off conversations we show on button, if we have notification on
|
||||
// conversation we show off button. We can show both if we have a mixture.
|
||||
mNotificationOffMenuItem.setVisible(hasCurrentlyOnNotification);
|
||||
mNotificationOnMenuItem.setVisible(hasCurrentlyOffNotification);
|
||||
|
||||
mArchiveMenuItem.setVisible(hasCurrentlyUnarchived);
|
||||
mUnarchiveMenuItem.setVisible(hasCurrentlyArchived);
|
||||
|
||||
@@ -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