Ver Fonte

Fix #402

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic há 5 anos atrás
pai
commit
8cbc0c7bc9

+ 1 - 1
app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt

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

+ 12 - 4
app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java

@@ -130,6 +130,7 @@ public class NotificationWorker extends Worker {
 
     private String credentials;
     private boolean muteCall = false;
+    private boolean importantConversation = false;
 
     public NotificationWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
         super(context, workerParams);
@@ -145,6 +146,12 @@ public class NotificationWorker extends Worker {
             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(),
                 intent.getExtras().getString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN())))
                 .blockingSubscribe(new Observer<RoomOverall>() {
@@ -450,7 +457,8 @@ public class NotificationWorker extends Worker {
         NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
         notificationManager.notify(notificationId, notification);
 
-        if (!muteCall) {
+
+        if (!notification.category.equals(Notification.CATEGORY_CALL) || !muteCall) {
             String ringtonePreferencesString;
             Uri soundUri;
 
@@ -469,8 +477,8 @@ public class NotificationWorker extends Worker {
                 }
             }
 
-            if (soundUri != null & !ApplicationWideCurrentRoomHolder.getInstance().isInCall() &&
-                    DoNotDisturbUtils.INSTANCE.shouldPlaySound()) {
+            if (soundUri != null && !ApplicationWideCurrentRoomHolder.getInstance().isInCall() &&
+                    (DoNotDisturbUtils.INSTANCE.shouldPlaySound() || importantConversation)) {
                 AudioAttributes.Builder audioAttributesBuilder = new AudioAttributes.Builder().setContentType
                         (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);
 
                 if (vibrator != null) {

+ 9 - 0
app/src/main/res/layout/notification_settings_item.xml

@@ -32,6 +32,15 @@
         apc:mpc_title="@string/nc_notification_settings"
         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
             android:id="@+id/conversation_info_message_notifications"
             android:layout_width="match_parent"

+ 3 - 0
app/src/main/res/values/strings.xml

@@ -201,6 +201,9 @@
     <string name="nc_notify_me_never">Never notify</string>
     <string name="nc_mute_calls">Mute calls</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 -->
     <string name="nc_failed_to_perform_operation">Sorry, something went wrong!</string>