Threema 3 rokov pred
rodič
commit
8f0515c910

+ 2 - 2
app/build.gradle

@@ -13,7 +13,7 @@ if (getGradle().getStartParameter().getTaskRequests().toString().contains("Hms")
 }
 
 // version codes
-def app_version = "5.0.1"
+def app_version = "5.0.2"
 def beta_suffix = "" // with leading dash
 
 /**
@@ -92,7 +92,7 @@ android {
         vectorDrawables.useSupportLibrary = true
         applicationId "ch.threema.app"
         testApplicationId 'ch.threema.app.test'
-        versionCode 777
+        versionCode 779
         versionName "${app_version}${beta_suffix}"
         resValue "string", "app_name", "Threema"
         // package name used for sync adapter - needs to match mime types below

+ 4 - 5
app/src/main/java/ch/threema/app/preference/ThreemaPreferenceFragment.kt

@@ -84,11 +84,11 @@ abstract class ThreemaPreferenceFragment : PreferenceFragmentCompat() {
     /**
      * Get the preference with the given key. Returns null if there is no such preference.
      */
-    protected fun <T : Preference> getPrefOrNull(string: String): T? {
+    protected fun <T : Preference> getPrefOrNull(key: String): T? {
         return try {
-            getPref(string)
+            getPref(key)
         } catch (e: Exception) {
-            logger.error("Preference not found", e)
+            logger.warn("Preference '$key' not found")
             null
         }
     }
@@ -172,8 +172,7 @@ abstract class ThreemaPreferenceFragment : PreferenceFragmentCompat() {
     }
 
     private fun preferenceNotFound(pref: String): Nothing {
-        logger.error("No preference '$pref' found")
-        throw IllegalArgumentException("Exception")
+        throw IllegalArgumentException("No preference '$pref' found")
     }
 
 }

+ 8 - 1
app/src/main/java/ch/threema/app/services/NotificationServiceImpl.java

@@ -434,6 +434,13 @@ public class NotificationServiceImpl implements NotificationService {
 
 	@Override
 	public void addGroupCallNotification(@NonNull GroupModel group, @NonNull ContactModel contactModel) {
+		// Treat the visibility of a group call notification the same as a group message that contains a mention.
+		MessageReceiver<?> messageReceiver = groupService.createReceiver(group);
+		DNDUtil dndUtil = DNDUtil.getInstance();
+		if (dndUtil.isMutedChat(messageReceiver) || dndUtil.isMutedWork()) {
+			return;
+		}
+
 		NotificationCompat.Action joinAction = new NotificationCompat.Action(
 			R.drawable.ic_group_call,
 			context.getString(R.string.voip_gc_join_call),
@@ -928,10 +935,10 @@ public class NotificationServiceImpl implements NotificationService {
 			}
 
 			if (newestGroup.getMessageReceiver() instanceof GroupMessageReceiver) {
-				builder.addAction(getMarkAsReadAction(markReadPendingIntent));
 				if (unreadMessagesCount == 1) {
 					builder.addAction(getThumbsUpAction(ackPendingIntent));
 				}
+				showMarkAsReadAction = true;
 			} else if (newestGroup.getMessageReceiver() instanceof ContactMessageReceiver) {
 
 				if (conversationNotification.getMessageType().equals(MessageType.VOIP_STATUS))  {

+ 36 - 12
app/src/main/java/ch/threema/app/utils/DNDUtil.java

@@ -58,8 +58,8 @@ import ch.threema.storage.models.ContactModel;
 
 public class DNDUtil {
 	private static final Logger logger = LoggingUtil.getThreemaLogger("DNDUtil");
-	private DeadlineListService mutedChatsListService;
-	private DeadlineListService mentionOnlyChatsListService;
+	private final DeadlineListService mutedChatsListService;
+	private final DeadlineListService mentionOnlyChatsListService;
 	private final IdentityStore identityStore;
 	private final Context context;
 
@@ -98,6 +98,34 @@ public class DNDUtil {
 		return false;
 	}
 
+	/**
+	 * Returns true if the chat for the provided MessageReceiver is set to mention only at this time.
+	 * @param messageReceiver MessageReceiver to check for DND status
+	 * @return true if the chat is muted
+	 */
+	public boolean isMentionOnlyChat(@Nullable MessageReceiver<?> messageReceiver) {
+		if (messageReceiver instanceof  GroupMessageReceiver) {
+			String uniqueId = messageReceiver.getUniqueIdString();
+			return mentionOnlyChatsListService != null && mentionOnlyChatsListService.has(uniqueId);
+		}
+		return false;
+	}
+
+	/**
+	 * Returns true if the chat for the provided MessageReceiver is muted at this time. This does
+	 * NOT check for work hours (use {@link #isMutedWork()} for this) or mention-only chats (use
+	 * {@link #isMentionOnlyChat(MessageReceiver)} to check this).
+	 * @param messageReceiver MessageReceiver to check for DND status
+	 * @return true if the chat is muted
+	 */
+	public boolean isMutedChat(@Nullable MessageReceiver<?> messageReceiver) {
+		if (messageReceiver != null) {
+			String uniqueId = messageReceiver.getUniqueIdString();
+			return mutedChatsListService != null && mutedChatsListService.has(uniqueId);
+		}
+		return false;
+	}
+
 	/**
 	 * Returns true if the chat for the provided MessageReceiver is permanently or temporarily muted AT THIS TIME and
 	 * no intrusive notification should be shown for an incoming message
@@ -114,20 +142,16 @@ public class DNDUtil {
 	public boolean isMutedPrivate(MessageReceiver messageReceiver, CharSequence rawMessageText) {
 		String uniqueId = messageReceiver.getUniqueIdString();
 
-		if (this.mutedChatsListService != null &&
-				this.mutedChatsListService.has(uniqueId)) {
+		if (isMutedChat(messageReceiver)) {
 			// user has set DND option on this chat
 			logger.info("Chat is muted");
 			return true;
 		}
-		if (messageReceiver instanceof GroupMessageReceiver) {
-			if (this.mentionOnlyChatsListService != null &&
-					this.mentionOnlyChatsListService.has(uniqueId)) {
-				// user has "DND except when mentioned" option enabled on this chat
-				logger.info("Chat is mention only");
-				// user is not mentioned => mute
-				return !isUserMentioned(rawMessageText);
-			}
+		if (isMentionOnlyChat(messageReceiver)) {
+			// user has "DND except when mentioned" option enabled on this chat
+			logger.info("Chat is mention only");
+			// user is not mentioned => mute
+			return !isUserMentioned(rawMessageText);
 		}
 		return false;
 	}

+ 4 - 2
app/src/main/java/ch/threema/app/voip/activities/GroupCallActivity.kt

@@ -281,8 +281,10 @@ class GroupCallActivity : ThreemaActivity(), GenericAlertDialog.DialogClickListe
 			}
 		})
 
-		intent?.getBooleanExtra(EXTRA_MICROPHONE_ACTIVE, true)?.let {
-			viewModel.microphoneActiveDefault = it
+		if (intent?.hasExtra(EXTRA_MICROPHONE_ACTIVE) == true) {
+			intent?.getBooleanExtra(EXTRA_MICROPHONE_ACTIVE, true)?.let {
+				viewModel.microphoneActiveDefault = it
+			}
 			intent?.removeExtra(EXTRA_MICROPHONE_ACTIVE)
 		}
 	}

+ 4 - 2
app/src/main/java/ch/threema/app/voip/viewmodel/GroupCallViewModel.kt

@@ -74,7 +74,7 @@ class GroupCallViewModel(application: Application) : AndroidViewModel(applicatio
 
 	private lateinit var audioManager: CallAudioManager
 
-	var microphoneActiveDefault = true
+	var microphoneActiveDefault: Boolean? = null
 
 	private val audioDevices = MutableLiveData<Set<AudioDevice>>(setOf())
 	fun getAudioDevices(): LiveData<Set<AudioDevice>> = audioDevices
@@ -323,7 +323,9 @@ class GroupCallViewModel(application: Application) : AndroidViewModel(applicatio
 
 	@UiThread
 	private fun initMicrophoneState() {
-		muteMicrophone(!microphoneActiveDefault)
+		val enableMicrophone = microphoneActiveDefault ?: callController.microphoneActive
+		muteMicrophone(!enableMicrophone)
+		microphoneActiveDefault = null
 	}
 
 	@UiThread

+ 8 - 0
app/src/main/java/ch/threema/app/workers/WorkSyncWorker.kt

@@ -249,6 +249,14 @@ class WorkSyncWorker(private val context: Context, workerParameters: WorkerParam
                 if (preset != null) {
                     editor.putBoolean(context.getString(R.string.preferences__voip_enable), !preset)
                 }
+                preset = AppRestrictionUtil.getBooleanRestriction(context.getString(R.string.restriction__disable_video_calls))
+                if (preset != null) {
+                    editor.putBoolean(context.getString(R.string.preferences__voip_video_enable), !preset)
+                }
+                preset = AppRestrictionUtil.getBooleanRestriction(context.getString(R.string.restriction__disable_group_calls))
+                if (preset != null) {
+                    editor.putBoolean(context.getString(R.string.preferences__group_calls_enable), !preset)
+                }
                 preset = AppRestrictionUtil.getBooleanRestriction(context.getString(R.string.restriction__hide_inactive_ids))
                 if (preset != null) {
                     editor.putBoolean(context.getString(R.string.preferences__show_inactive_contacts), !preset)