Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2019-09-02 13:47:24 +02:00
parent 7d838bd72b
commit 8cbc0c7bc9
4 changed files with 25 additions and 5 deletions

View File

@ -422,7 +422,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args) {
} }
private fun fetchRoomInfo() { private fun fetchRoomInfo() {
ncApi!!.getRoom(credentials, ApiUtils.getRoom(conversationUser!!.baseUrl, conversationToken)) ncApi.getRoom(credentials, ApiUtils.getRoom(conversationUser!!.baseUrl, conversationToken))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<RoomOverall> { .subscribe(object : Observer<RoomOverall> {

View File

@ -130,6 +130,7 @@ public class NotificationWorker extends Worker {
private String credentials; private String credentials;
private boolean muteCall = false; private boolean muteCall = false;
private boolean importantConversation = false;
public NotificationWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { public NotificationWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams); super(context, workerParams);
@ -145,6 +146,12 @@ public class NotificationWorker extends Worker {
muteCall = Boolean.parseBoolean(arbitraryStorageEntity.getValue()); muteCall = Boolean.parseBoolean(arbitraryStorageEntity.getValue());
} }
if ((arbitraryStorageEntity = arbitraryStorageUtils.getStorageSetting(userEntity.getId(),
"important_conversation", intent.getExtras().getString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN()))) != null) {
importantConversation = Boolean.parseBoolean(arbitraryStorageEntity.getValue());
}
ncApi.getRoom(credentials, ApiUtils.getRoom(userEntity.getBaseUrl(), ncApi.getRoom(credentials, ApiUtils.getRoom(userEntity.getBaseUrl(),
intent.getExtras().getString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN()))) intent.getExtras().getString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN())))
.blockingSubscribe(new Observer<RoomOverall>() { .blockingSubscribe(new Observer<RoomOverall>() {
@ -450,7 +457,8 @@ public class NotificationWorker extends Worker {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(notificationId, notification); notificationManager.notify(notificationId, notification);
if (!muteCall) {
if (!notification.category.equals(Notification.CATEGORY_CALL) || !muteCall) {
String ringtonePreferencesString; String ringtonePreferencesString;
Uri soundUri; Uri soundUri;
@ -469,8 +477,8 @@ public class NotificationWorker extends Worker {
} }
} }
if (soundUri != null & !ApplicationWideCurrentRoomHolder.getInstance().isInCall() && if (soundUri != null && !ApplicationWideCurrentRoomHolder.getInstance().isInCall() &&
DoNotDisturbUtils.INSTANCE.shouldPlaySound()) { (DoNotDisturbUtils.INSTANCE.shouldPlaySound() || importantConversation)) {
AudioAttributes.Builder audioAttributesBuilder = new AudioAttributes.Builder().setContentType AudioAttributes.Builder audioAttributesBuilder = new AudioAttributes.Builder().setContentType
(AudioAttributes.CONTENT_TYPE_SONIFICATION); (AudioAttributes.CONTENT_TYPE_SONIFICATION);
@ -495,7 +503,7 @@ public class NotificationWorker extends Worker {
} }
if (DoNotDisturbUtils.INSTANCE.shouldVibrate(appPreferences.getShouldVibrateSetting())) { if (DoNotDisturbUtils.INSTANCE.shouldVibrate(appPreferences.getShouldVibrateSetting()) || importantConversation) {
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
if (vibrator != null) { if (vibrator != null) {

View File

@ -32,6 +32,15 @@
apc:mpc_title="@string/nc_notification_settings" apc:mpc_title="@string/nc_notification_settings"
apc:mpc_title_color="@color/colorPrimary"> apc:mpc_title_color="@color/colorPrimary">
<com.yarolegovich.mp.MaterialSwitchPreference
android:id="@+id/conversation_info_priority_conversation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
apc:mp_default_value="false"
apc:mp_key="important_conversation"
apc:mp_title="@string/nc_important_conversation"
apc:mp_summary="@string/nc_important_conversation_desc"/>
<com.yarolegovich.mp.MaterialChoicePreference <com.yarolegovich.mp.MaterialChoicePreference
android:id="@+id/conversation_info_message_notifications" android:id="@+id/conversation_info_message_notifications"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -201,6 +201,9 @@
<string name="nc_notify_me_never">Never notify</string> <string name="nc_notify_me_never">Never notify</string>
<string name="nc_mute_calls">Mute calls</string> <string name="nc_mute_calls">Mute calls</string>
<string name="nc_mute_calls_desc">Incoming calls will be silenced</string> <string name="nc_mute_calls_desc">Incoming calls will be silenced</string>
<string name="nc_important_conversation">Important conversation</string>
<string name="nc_important_conversation_desc">Notifications in this conversation will override
Do-Not-Disturb settings</string>
<!-- Bottom sheet menu --> <!-- Bottom sheet menu -->
<string name="nc_failed_to_perform_operation">Sorry, something went wrong!</string> <string name="nc_failed_to_perform_operation">Sorry, something went wrong!</string>