diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index 73c61c7d0..f5f8f2a9a 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -4,6 +4,8 @@ * @author Mario Danic * @author Marcel Hibbe * @author Andy Scherzinger + * @author Tim Krüger + * Copyright (C) 2021 Tim Krüger * Copyright (C) 2021 Andy Scherzinger * Copyright (C) 2021 Marcel Hibbe * Copyright (C) 2017-2019 Mario Danic @@ -229,7 +231,6 @@ class ChatController(args: Bundle) : val voiceOnly: Boolean var isFirstMessagesProcessing = true var isLeavingForConversation: Boolean = false - var isLinkPreviewAllowed: Boolean = false var wasDetached: Boolean = false var emojiPopup: EmojiPopup? = null @@ -1363,8 +1364,6 @@ class ChatController(args: Bundle) : ApplicationWideCurrentRoomHolder.getInstance().isInCall = false ApplicationWideCurrentRoomHolder.getInstance().userInRoom = conversationUser - isLinkPreviewAllowed = appPreferences?.areLinkPreviewsAllowed ?: false - val smileyButton = binding.messageInputView.findViewById(R.id.smileyButton) emojiPopup = binding.messageInputView.inputEditText?.let { @@ -1908,7 +1907,6 @@ class ChatController(args: Bundle) : val chatMessage = chatMessageList[i] chatMessage.isOneToOneConversation = currentConversation?.type == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL - chatMessage.isLinkPreviewAllowed = isLinkPreviewAllowed chatMessage.activeUser = conversationUser } @@ -1937,7 +1935,6 @@ class ChatController(args: Bundle) : chatMessage = chatMessageList[i] chatMessage.activeUser = conversationUser - chatMessage.isLinkPreviewAllowed = isLinkPreviewAllowed val shouldScroll = !isThereANewNotice && @@ -2377,7 +2374,6 @@ class ChatController(args: Bundle) : messageTemp.isOneToOneConversation = currentConversation?.type == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL - messageTemp.isLinkPreviewAllowed = isLinkPreviewAllowed messageTemp.activeUser = conversationUser adapter?.update(messageTemp) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java index f7ce60575..a0035bdce 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java @@ -3,6 +3,9 @@ * * @author Andy Scherzinger * @author Mario Danic + * @author Tim Krüger + * Copyright (C) 2021 Tim Krüger + * Copyright (C) 2021 Andy Scherzinger * Copyright (C) 2017 Mario Danic (mario@lovelyhq.com) * * This program is free software: you can redistribute it and/or modify @@ -173,8 +176,6 @@ public class SettingsController extends BaseController { MaterialSwitchPreference incognitoKeyboardSwitchPreference; @BindView(R.id.settings_screen_security) MaterialSwitchPreference screenSecuritySwitchPreference; - @BindView(R.id.settings_link_previews) - MaterialSwitchPreference linkPreviewsSwitchPreference; @BindView(R.id.settings_screen_lock) MaterialSwitchPreference screenLockSwitchPreference; @BindView(R.id.settings_screen_lock_timeout) @@ -463,7 +464,6 @@ public class SettingsController extends BaseController { readPrivacyPreference.setVisibility(View.GONE); } - ((Checkable) linkPreviewsSwitchPreference.findViewById(R.id.mp_checkable)).setChecked(appPreferences.getAreLinkPreviewsAllowed()); ((Checkable) phoneBookIntegrationPreference.findViewById(R.id.mp_checkable)).setChecked(appPreferences.isPhoneBookIntegrationEnabled()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { diff --git a/app/src/main/java/com/nextcloud/talk/dagger/modules/DatabaseModule.java b/app/src/main/java/com/nextcloud/talk/dagger/modules/DatabaseModule.java index f4a308c9b..c30b36a34 100644 --- a/app/src/main/java/com/nextcloud/talk/dagger/modules/DatabaseModule.java +++ b/app/src/main/java/com/nextcloud/talk/dagger/modules/DatabaseModule.java @@ -59,6 +59,8 @@ public class DatabaseModule { @Provides @Singleton public AppPreferences providePreferences(@NonNull final Context poContext) { - return StoreBox.create(poContext, AppPreferences.class); + AppPreferences p = StoreBox.create(poContext, AppPreferences.class); + p.removeLinkPreviews(); + return p; } } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java index b05d03b8b..e3da928ae 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java @@ -31,7 +31,6 @@ import com.nextcloud.talk.application.NextcloudTalkApplication; import com.nextcloud.talk.models.database.UserEntity; import com.nextcloud.talk.models.json.converters.EnumSystemMessageTypeConverter; import com.nextcloud.talk.utils.ApiUtils; -import com.nextcloud.talk.utils.TextMatchers; import com.stfalcon.chatkit.commons.models.IUser; import com.stfalcon.chatkit.commons.models.MessageContentType; @@ -60,8 +59,6 @@ public class ChatMessage implements MessageContentType, MessageContentType.Image @JsonIgnore public Map selectedIndividualHashMap; @JsonIgnore - public boolean isLinkPreviewAllowed; - @JsonIgnore public boolean isDeleted; @JsonField(name = "id") public int jsonMessageId; @@ -157,7 +154,7 @@ public class ChatMessage implements MessageContentType, MessageContentType.Image } } - if (!messageTypesToIgnore.contains(getMessageType()) && isLinkPreviewAllowed) { + if (!messageTypesToIgnore.contains(getMessageType())) { return getMessage().trim(); } @@ -330,10 +327,6 @@ public class ChatMessage implements MessageContentType, MessageContentType.Image return this.activeUser; } - public boolean isLinkPreviewAllowed() { - return this.isLinkPreviewAllowed; - } - public boolean isDeleted() { return this.isDeleted; } @@ -402,10 +395,6 @@ public class ChatMessage implements MessageContentType, MessageContentType.Image this.activeUser = activeUser; } - public void setLinkPreviewAllowed(boolean isLinkPreviewAllowed) { - this.isLinkPreviewAllowed = isLinkPreviewAllowed; - } - public void setDeleted(boolean isDeleted) { this.isDeleted = isDeleted; } @@ -493,9 +482,6 @@ public class ChatMessage implements MessageContentType, MessageContentType.Image if (this$selectedIndividualHashMap == null ? other$selectedIndividualHashMap != null : !this$selectedIndividualHashMap.equals(other$selectedIndividualHashMap)) { return false; } - if (this.isLinkPreviewAllowed() != other.isLinkPreviewAllowed()) { - return false; - } if (this.isDeleted() != other.isDeleted()) { return false; } @@ -572,7 +558,6 @@ public class ChatMessage implements MessageContentType, MessageContentType.Image result = result * PRIME + ($activeUser == null ? 43 : $activeUser.hashCode()); final Object $selectedIndividualHashMap = this.getSelectedIndividualHashMap(); result = result * PRIME + ($selectedIndividualHashMap == null ? 43 : $selectedIndividualHashMap.hashCode()); - result = result * PRIME + (this.isLinkPreviewAllowed() ? 79 : 97); result = result * PRIME + (this.isDeleted() ? 79 : 97); result = result * PRIME + this.getJsonMessageId(); final Object $token = this.getToken(); @@ -602,7 +587,7 @@ public class ChatMessage implements MessageContentType, MessageContentType.Image } public String toString() { - return "ChatMessage(isGrouped=" + this.isGrouped() + ", isOneToOneConversation=" + this.isOneToOneConversation() + ", activeUser=" + this.getActiveUser() + ", selectedIndividualHashMap=" + this.getSelectedIndividualHashMap() + ", isLinkPreviewAllowed=" + this.isLinkPreviewAllowed() + ", isDeleted=" + this.isDeleted() + ", jsonMessageId=" + this.getJsonMessageId() + ", token=" + this.getToken() + ", actorType=" + this.getActorType() + ", actorId=" + this.getActorId() + ", actorDisplayName=" + this.getActorDisplayName() + ", timestamp=" + this.getTimestamp() + ", message=" + this.getMessage() + ", messageParameters=" + this.getMessageParameters() + ", systemMessageType=" + this.getSystemMessageType() + ", replyable=" + this.isReplyable() + ", parentMessage=" + this.getParentMessage() + ", readStatus=" + this.getReadStatus() + ", messageTypesToIgnore=" + this.getMessageTypesToIgnore() + ")"; + return "ChatMessage(isGrouped=" + this.isGrouped() + ", isOneToOneConversation=" + this.isOneToOneConversation() + ", activeUser=" + this.getActiveUser() + ", selectedIndividualHashMap=" + this.getSelectedIndividualHashMap() + ", isDeleted=" + this.isDeleted() + ", jsonMessageId=" + this.getJsonMessageId() + ", token=" + this.getToken() + ", actorType=" + this.getActorType() + ", actorId=" + this.getActorId() + ", actorDisplayName=" + this.getActorDisplayName() + ", timestamp=" + this.getTimestamp() + ", message=" + this.getMessage() + ", messageParameters=" + this.getMessageParameters() + ", systemMessageType=" + this.getSystemMessageType() + ", replyable=" + this.isReplyable() + ", parentMessage=" + this.getParentMessage() + ", readStatus=" + this.getReadStatus() + ", messageTypesToIgnore=" + this.getMessageTypesToIgnore() + ")"; } public boolean isVoiceMessage(){ diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java index bb0e053e5..321fc233a 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java @@ -2,6 +2,8 @@ * Nextcloud Talk application * * @author Mario Danic + * @author Tim Krüger + * Copyright (C) 2021 Tim Krüger * Copyright (C) 2017 Mario Danic * * This program is free software: you can redistribute it and/or modify @@ -241,10 +243,6 @@ public interface AppPreferences { @KeyByString("incognito_keyboard") @RemoveMethod void removeIncognitoKeyboard(); - - @KeyByString("link_previews") - @DefaultValue(R.bool.value_true) - boolean getAreLinkPreviewsAllowed(); @KeyByString("phone_book_integration") @DefaultValue(R.bool.value_false) @@ -253,9 +251,7 @@ public interface AppPreferences { @KeyByString("phone_book_integration") void setPhoneBookIntegration(boolean value); - @KeyByString("link_previews") - void setLinkPreviewsAllowed(boolean value); - + // TODO: Remove in 13.0.0 @KeyByString("link_previews") @RemoveMethod void removeLinkPreviews(); diff --git a/app/src/main/res/layout/controller_settings.xml b/app/src/main/res/layout/controller_settings.xml index 4dddab404..a7cacf340 100644 --- a/app/src/main/res/layout/controller_settings.xml +++ b/app/src/main/res/layout/controller_settings.xml @@ -3,6 +3,8 @@ ~ ~ @author Mario Danic ~ @author Andy Scherzinger + ~ @author Tim Krüger + ~ Copyright (C) 2021 Tim Krüger ~ Copyright (C) 2021 Andy Scherzinger ~ Copyright (C) 2017 Mario Danic ~ @@ -235,15 +237,6 @@ apc:mp_summary="@string/nc_settings_incognito_keyboard_desc" apc:mp_title="@string/nc_settings_incognito_keyboard_title" /> - - Incognito keyboard Instructs keyboard to disable personalized learning (without guarantees) incognito_keyboard - Show link previews - Allows previews of content from received links for supported services - link_previews read_privacy Tap to unlock Locked diff --git a/scripts/analysis/lint-results.txt b/scripts/analysis/lint-results.txt index 8e9192559..7ca98a429 100644 --- a/scripts/analysis/lint-results.txt +++ b/scripts/analysis/lint-results.txt @@ -1,2 +1,2 @@ DO NOT TOUCH; GENERATED BY DRONE - Lint Report: 3 errors and 272 warnings + Lint Report: 3 errors and 270 warnings