From 841c3bdbda6482d0e7cf668c304f602fe775f966 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Tue, 25 May 2021 01:58:37 +0900 Subject: [PATCH] Convert to kotlin --- .../instagrabber/managers/ThreadManager.java | 10 +- .../directmessages/DirectItemClip.kt | 33 +- .../directmessages/DirectItemFelixShare.kt | 33 +- .../directmessages/DirectItemReelShare.kt | 98 +---- .../DirectItemReelShareReactionInfo.kt | 40 +- .../directmessages/DirectItemStoryShare.kt | 89 +--- .../directmessages/DirectItemVisualMedia.kt | 102 +---- .../responses/directmessages/DirectThread.kt | 413 ++---------------- .../DirectThreadDetailsChangeResponse.kt | 23 +- .../directmessages/DirectThreadDirectStory.kt | 41 +- ...DirectThreadParticipantRequestsResponse.kt | 82 +--- .../directmessages/RankedRecipient.kt | 59 +-- .../RankedRecipientsResponse.kt | 58 +-- .../RavenExpiringMediaActionSummary.kt | 92 ++-- .../instagrabber/services/DMSyncService.java | 2 +- .../awais/instagrabber/utils/DMUtils.java | 3 +- .../viewmodels/DirectSettingsViewModel.java | 2 +- .../webservices/DiscoverService.java | 4 +- 18 files changed, 193 insertions(+), 991 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/managers/ThreadManager.java b/app/src/main/java/awais/instagrabber/managers/ThreadManager.java index b479b427..df3b9ff8 100644 --- a/app/src/main/java/awais/instagrabber/managers/ThreadManager.java +++ b/app/src/main/java/awais/instagrabber/managers/ThreadManager.java @@ -195,7 +195,7 @@ public final class ThreadManager { .orElse(null); if (thread != null) { cursor = thread.getOldestCursor(); - hasOlder = thread.hasOlder(); + hasOlder = thread.getHasOlder(); } return thread; })); @@ -229,7 +229,7 @@ public final class ThreadManager { })); pending = distinctUntilChanged(map(thread, t -> { if (t == null) return true; - return t.isPending(); + return t.getPending(); })); adminUserIds = distinctUntilChanged(map(thread, t -> { if (t == null) return Collections.emptyList(); @@ -249,15 +249,15 @@ public final class ThreadManager { })); isMuted = distinctUntilChanged(map(thread, t -> { if (t == null) return false; - return t.isMuted(); + return t.getMuted(); })); isApprovalRequiredToJoin = distinctUntilChanged(map(thread, t -> { if (t == null) return false; - return t.isApprovalRequiredForNewMembers(); + return t.getApprovalRequiredForNewMembers(); })); isMentionsMuted = distinctUntilChanged(map(thread, t -> { if (t == null) return false; - return t.isMentionsMuted(); + return t.getMentionsMuted(); })); pendingRequestsCount = distinctUntilChanged(map(pendingRequests, p -> { if (p == null) return 0; diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemClip.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemClip.kt index 0568220d..a1419699 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemClip.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemClip.kt @@ -1,31 +1,6 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import awais.instagrabber.repositories.responses.Media +import java.io.Serializable -import awais.instagrabber.repositories.responses.Media; - -public class DirectItemClip implements Serializable { - private final Media clip; - - public DirectItemClip(final Media clip) { - this.clip = clip; - } - - public Media getClip() { - return clip; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemClip that = (DirectItemClip) o; - return Objects.equals(clip, that.clip); - } - - @Override - public int hashCode() { - return Objects.hash(clip); - } -} +data class DirectItemClip(val clip: Media? = null) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemFelixShare.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemFelixShare.kt index f230027c..83029a15 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemFelixShare.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemFelixShare.kt @@ -1,31 +1,6 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import awais.instagrabber.repositories.responses.Media +import java.io.Serializable -import awais.instagrabber.repositories.responses.Media; - -public class DirectItemFelixShare implements Serializable { - private final Media video; - - public DirectItemFelixShare(final Media video) { - this.video = video; - } - - public Media getVideo() { - return video; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemFelixShare that = (DirectItemFelixShare) o; - return Objects.equals(video, that.video); - } - - @Override - public int hashCode() { - return Objects.hash(video); - } -} +data class DirectItemFelixShare(val video: Media? = null) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemReelShare.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemReelShare.kt index 1e434dc4..4bba98b1 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemReelShare.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemReelShare.kt @@ -1,87 +1,15 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import awais.instagrabber.repositories.responses.Media +import java.io.Serializable -import awais.instagrabber.repositories.responses.Media; - -public class DirectItemReelShare implements Serializable { - private final String text; - private final String type; - private final long reelOwnerId; - private final long mentionedUserId; - private final boolean isReelPersisted; - private final String reelType; - private final Media media; - private final DirectItemReelShareReactionInfo reactionInfo; - - public DirectItemReelShare(final String text, - final String type, - final long reelOwnerId, - final long mentionedUserId, - final boolean isReelPersisted, - final String reelType, - final Media media, - final DirectItemReelShareReactionInfo reactionInfo) { - this.text = text; - this.type = type; - this.reelOwnerId = reelOwnerId; - this.mentionedUserId = mentionedUserId; - this.isReelPersisted = isReelPersisted; - this.reelType = reelType; - this.media = media; - this.reactionInfo = reactionInfo; - } - - public String getText() { - return text; - } - - public String getType() { - return type; - } - - public long getReelOwnerId() { - return reelOwnerId; - } - - public boolean isReelPersisted() { - return isReelPersisted; - } - - public String getReelType() { - return reelType; - } - - public Media getMedia() { - return media; - } - - public DirectItemReelShareReactionInfo getReactionInfo() { - return reactionInfo; - } - - public long getMentionedUserId() { - return mentionedUserId; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemReelShare that = (DirectItemReelShare) o; - return reelOwnerId == that.reelOwnerId && - mentionedUserId == that.mentionedUserId && - isReelPersisted == that.isReelPersisted && - Objects.equals(text, that.text) && - Objects.equals(type, that.type) && - Objects.equals(reelType, that.reelType) && - Objects.equals(media, that.media) && - Objects.equals(reactionInfo, that.reactionInfo); - } - - @Override - public int hashCode() { - return Objects.hash(text, type, reelOwnerId, mentionedUserId, isReelPersisted, reelType, media, reactionInfo); - } -} +data class DirectItemReelShare( + val text: String? = null, + val type: String? = null, + val reelOwnerId: Long = 0, + val mentionedUserId: Long = 0, + val isReelPersisted: Boolean = false, + val reelType: String? = null, + val media: Media? = null, + val reactionInfo: DirectItemReelShareReactionInfo? = null, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemReelShareReactionInfo.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemReelShareReactionInfo.kt index e515ca2e..8d0aed9c 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemReelShareReactionInfo.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemReelShareReactionInfo.kt @@ -1,36 +1,8 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import java.io.Serializable -public class DirectItemReelShareReactionInfo implements Serializable { - private final String emoji; - private final String intensity; - - public DirectItemReelShareReactionInfo(final String emoji, final String intensity) { - this.emoji = emoji; - this.intensity = intensity; - } - - public String getEmoji() { - return emoji; - } - - public String getIntensity() { - return intensity; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemReelShareReactionInfo that = (DirectItemReelShareReactionInfo) o; - return Objects.equals(emoji, that.emoji) && - Objects.equals(intensity, that.intensity); - } - - @Override - public int hashCode() { - return Objects.hash(emoji, intensity); - } -} +data class DirectItemReelShareReactionInfo( + val emoji: String? = null, + val intensity: String? = null, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemStoryShare.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemStoryShare.kt index 0e618b85..c5e669bb 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemStoryShare.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemStoryShare.kt @@ -1,79 +1,14 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import awais.instagrabber.repositories.responses.Media +import java.io.Serializable -import awais.instagrabber.repositories.responses.Media; - -public class DirectItemStoryShare implements Serializable { - private final String reelId; - private final String reelType; - private final String text; - private final boolean isReelPersisted; - private final Media media; - private final String title; - private final String message; - - public DirectItemStoryShare(final String reelId, - final String reelType, - final String text, - final boolean isReelPersisted, - final Media media, - final String title, - final String message) { - this.reelId = reelId; - this.reelType = reelType; - this.text = text; - this.isReelPersisted = isReelPersisted; - this.media = media; - this.title = title; - this.message = message; - } - - public String getReelId() { - return reelId; - } - - public String getReelType() { - return reelType; - } - - public String getText() { - return text; - } - - public boolean isReelPersisted() { - return isReelPersisted; - } - - public Media getMedia() { - return media; - } - - public String getTitle() { - return title; - } - - public String getMessage() { - return message; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemStoryShare that = (DirectItemStoryShare) o; - return isReelPersisted == that.isReelPersisted && - Objects.equals(reelId, that.reelId) && - Objects.equals(reelType, that.reelType) && - Objects.equals(text, that.text) && - Objects.equals(media, that.media) && - Objects.equals(title, that.title) && - Objects.equals(message, that.message); - } - - @Override - public int hashCode() { - return Objects.hash(reelId, reelType, text, isReelPersisted, media, title, message); - } -} +data class DirectItemStoryShare( + val reelId: String? = null, + val reelType: String? = null, + val text: String? = null, + val isReelPersisted: Boolean = false, + val media: Media? = null, + val title: String? = null, + val message: String? = null, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemVisualMedia.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemVisualMedia.kt index 2e6bf7e7..5534e1bf 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemVisualMedia.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectItemVisualMedia.kt @@ -1,90 +1,16 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.List; -import java.util.Objects; +import awais.instagrabber.models.enums.RavenMediaViewMode +import awais.instagrabber.repositories.responses.Media +import java.io.Serializable -import awais.instagrabber.models.enums.RavenMediaViewMode; -import awais.instagrabber.repositories.responses.Media; - -public class DirectItemVisualMedia implements Serializable { - private final long urlExpireAtSecs; - private final int playbackDurationSecs; - private final List seenUserIds; - private final RavenMediaViewMode viewMode; - private final int seenCount; - private final long replayExpiringAtUs; - private final RavenExpiringMediaActionSummary expiringMediaActionSummary; - private final Media media; - - public DirectItemVisualMedia(final long urlExpireAtSecs, - final int playbackDurationSecs, - final List seenUserIds, - final RavenMediaViewMode viewMode, - final int seenCount, - final long replayExpiringAtUs, - final RavenExpiringMediaActionSummary expiringMediaActionSummary, - final Media media) { - this.urlExpireAtSecs = urlExpireAtSecs; - this.playbackDurationSecs = playbackDurationSecs; - this.seenUserIds = seenUserIds; - this.viewMode = viewMode; - this.seenCount = seenCount; - this.replayExpiringAtUs = replayExpiringAtUs; - this.expiringMediaActionSummary = expiringMediaActionSummary; - this.media = media; - } - - public long getUrlExpireAtSecs() { - return urlExpireAtSecs; - } - - public int getPlaybackDurationSecs() { - return playbackDurationSecs; - } - - public List getSeenUserIds() { - return seenUserIds; - } - - public RavenMediaViewMode getViewMode() { - return viewMode; - } - - public int getSeenCount() { - return seenCount; - } - - public long getReplayExpiringAtUs() { - return replayExpiringAtUs; - } - - public RavenExpiringMediaActionSummary getExpiringMediaActionSummary() { - return expiringMediaActionSummary; - } - - public Media getMedia() { - return media; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectItemVisualMedia media1 = (DirectItemVisualMedia) o; - return urlExpireAtSecs == media1.urlExpireAtSecs && - playbackDurationSecs == media1.playbackDurationSecs && - seenCount == media1.seenCount && - replayExpiringAtUs == media1.replayExpiringAtUs && - Objects.equals(seenUserIds, media1.seenUserIds) && - viewMode == media1.viewMode && - Objects.equals(expiringMediaActionSummary, media1.expiringMediaActionSummary) && - Objects.equals(media, media1.media); - } - - @Override - public int hashCode() { - return Objects - .hash(urlExpireAtSecs, playbackDurationSecs, seenUserIds, viewMode, seenCount, replayExpiringAtUs, expiringMediaActionSummary, media); - } -} +data class DirectItemVisualMedia( + val urlExpireAtSecs: Long = 0, + val playbackDurationSecs: Int = 0, + val seenUserIds: List? = null, + val viewMode: RavenMediaViewMode? = null, + val seenCount: Int = 0, + val replayExpiringAtUs: Long = 0, + val expiringMediaActionSummary: RavenExpiringMediaActionSummary? = null, + val media: Media? = null, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThread.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThread.kt index 1f6ffd66..65094c70 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThread.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThread.kt @@ -1,372 +1,49 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; +import awais.instagrabber.repositories.responses.User +import java.io.Serializable -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import java.util.Objects; +data class DirectThread( + val threadId: String? = null, + val threadV2Id: String? = null, + var users: List? = null, + var leftUsers: List? = null, + var adminUserIds: List? = null, + var items: List? = null, + val lastActivityAt: Long = 0, + var muted: Boolean = false, + val isPin: Boolean = false, + val named: Boolean = false, + val canonical: Boolean = false, + var pending: Boolean = false, + val archived: Boolean = false, + val valuedRequest: Boolean = false, + val threadType: String? = null, + val viewerId: Long = 0, + val threadTitle: String? = null, + val pendingScore: String? = null, + val folder: Long = 0, + val vcMuted: Boolean = false, + val isGroup: Boolean = false, + var mentionsMuted: Boolean = false, + val inviter: User? = null, + val hasOlder: Boolean = false, + val hasNewer: Boolean = false, + var lastSeenAt: Map? = null, + val newestCursor: String? = null, + val oldestCursor: String? = null, + val isSpam: Boolean = false, + val lastPermanentItem: DirectItem? = null, + val directStory: DirectThreadDirectStory? = null, + var approvalRequiredForNewMembers: Boolean = false, + var inputMode: Int = 0, + val threadContextItems: List? = null +) : Serializable, Cloneable { + var isTemp = false -import awais.instagrabber.repositories.responses.User; + val firstDirectItem: DirectItem? + get() = items?.firstNotNullOfOrNull { it } -public class DirectThread implements Serializable, Cloneable { - private final String threadId; - private final String threadV2Id; - private List users; - private List leftUsers; - private List adminUserIds; - private List items; - private final long lastActivityAt; - private boolean muted; - private final boolean isPin; - private final boolean named; - private final boolean canonical; - private boolean pending; - private final boolean archived; - private final boolean valuedRequest; - private final String threadType; - private final long viewerId; - private final String threadTitle; - private final String pendingScore; - private final long folder; - private final boolean vcMuted; - private final boolean isGroup; - private boolean mentionsMuted; - private final User inviter; - private final boolean hasOlder; - private final boolean hasNewer; - private Map lastSeenAt; - private final String newestCursor; - private final String oldestCursor; - private final boolean isSpam; - private final DirectItem lastPermanentItem; - private final DirectThreadDirectStory directStory; - private boolean approvalRequiredForNewMembers; - private int inputMode; - private final List threadContextItems; - private boolean isTemp; - - public DirectThread(final String threadId, - final String threadV2Id, - final List users, - final List leftUsers, - final List adminUserIds, - final List items, - final long lastActivityAt, - final boolean muted, - final boolean isPin, - final boolean named, - final boolean canonical, - final boolean pending, - final boolean archived, - final boolean valuedRequest, - final String threadType, - final long viewerId, - final String threadTitle, - final String pendingScore, - final long folder, - final boolean vcMuted, - final boolean isGroup, - final boolean mentionsMuted, - final User inviter, - final boolean hasOlder, - final boolean hasNewer, - final Map lastSeenAt, - final String newestCursor, - final String oldestCursor, - final boolean isSpam, - final DirectItem lastPermanentItem, - final DirectThreadDirectStory directStory, - final boolean approvalRequiredForNewMembers, - final int inputMode, - final List threadContextItems) { - this.threadId = threadId; - this.threadV2Id = threadV2Id; - this.users = users; - this.leftUsers = leftUsers; - this.adminUserIds = adminUserIds; - this.items = items; - this.lastActivityAt = lastActivityAt; - this.muted = muted; - this.isPin = isPin; - this.named = named; - this.canonical = canonical; - this.pending = pending; - this.archived = archived; - this.valuedRequest = valuedRequest; - this.threadType = threadType; - this.viewerId = viewerId; - this.threadTitle = threadTitle; - this.pendingScore = pendingScore; - this.folder = folder; - this.vcMuted = vcMuted; - this.isGroup = isGroup; - this.mentionsMuted = mentionsMuted; - this.inviter = inviter; - this.hasOlder = hasOlder; - this.hasNewer = hasNewer; - this.lastSeenAt = lastSeenAt; - this.newestCursor = newestCursor; - this.oldestCursor = oldestCursor; - this.isSpam = isSpam; - this.lastPermanentItem = lastPermanentItem; - this.directStory = directStory; - this.approvalRequiredForNewMembers = approvalRequiredForNewMembers; - this.inputMode = inputMode; - this.threadContextItems = threadContextItems; - } - - public String getThreadId() { - return threadId; - } - - public String getThreadV2Id() { - return threadV2Id; - } - - public List getUsers() { - return users; - } - - public void setUsers(final List users) { - this.users = users; - } - - public List getLeftUsers() { - return leftUsers; - } - - public void setLeftUsers(final List leftUsers) { - this.leftUsers = leftUsers; - } - - public List getAdminUserIds() { - return adminUserIds; - } - - public void setAdminUserIds(final List adminUserIds) { - this.adminUserIds = adminUserIds; - } - - public List getItems() { - return items; - } - - public void setItems(final List items) { - this.items = items; - } - - public long getLastActivityAt() { - return lastActivityAt; - } - - public boolean isMuted() { - return muted; - } - - public void setMuted(final boolean muted) { - this.muted = muted; - } - - public boolean isPin() { - return isPin; - } - - public boolean isNamed() { - return named; - } - - public boolean isCanonical() { - return canonical; - } - - public boolean isPending() { - return pending; - } - - public void setPending(final boolean pending) { - this.pending = pending; - } - - public boolean isArchived() { - return archived; - } - - public boolean isValuedRequest() { - return valuedRequest; - } - - public String getThreadType() { - return threadType; - } - - public long getViewerId() { - return viewerId; - } - - public String getThreadTitle() { - return threadTitle; - } - - public String getPendingScore() { - return pendingScore; - } - - public long getFolder() { - return folder; - } - - public boolean isVcMuted() { - return vcMuted; - } - - public boolean isGroup() { - return isGroup; - } - - public boolean isMentionsMuted() { - return mentionsMuted; - } - - public void setMentionsMuted(final boolean mentionsMuted) { - this.mentionsMuted = mentionsMuted; - } - - public User getInviter() { - return inviter; - } - - public boolean hasOlder() { - return hasOlder; - } - - public boolean hasNewer() { - return hasNewer; - } - - public Map getLastSeenAt() { - return lastSeenAt; - } - - public void setLastSeenAt(final Map lastSeenAt) { - this.lastSeenAt = lastSeenAt; - } - - public String getNewestCursor() { - return newestCursor; - } - - public String getOldestCursor() { - return oldestCursor; - } - - public boolean isSpam() { - return isSpam; - } - - public DirectItem getLastPermanentItem() { - return lastPermanentItem; - } - - public DirectThreadDirectStory getDirectStory() { - return directStory; - } - - public boolean isApprovalRequiredForNewMembers() { - return approvalRequiredForNewMembers; - } - - public void setApprovalRequiredForNewMembers(final boolean approvalRequiredForNewMembers) { - this.approvalRequiredForNewMembers = approvalRequiredForNewMembers; - } - - public int getInputMode() { - return inputMode; - } - - public void setInputMode(final int inputMode) { - this.inputMode = inputMode; - } - - public List getThreadContextItems() { - return threadContextItems; - } - - public boolean isTemp() { - return isTemp; - } - - public void setTemp(final boolean isTemp) { - this.isTemp = isTemp; - } - - @Nullable - public DirectItem getFirstDirectItem() { - DirectItem firstItem = null; - if (!items.isEmpty()) { - int position = 0; - while (firstItem == null && position < items.size()) { - firstItem = items.get(position); - position++; - } - } - return firstItem; - } - - @NonNull - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectThread that = (DirectThread) o; - return lastActivityAt == that.lastActivityAt && - muted == that.muted && - isPin == that.isPin && - named == that.named && - canonical == that.canonical && - pending == that.pending && - archived == that.archived && - valuedRequest == that.valuedRequest && - viewerId == that.viewerId && - folder == that.folder && - vcMuted == that.vcMuted && - isGroup == that.isGroup && - mentionsMuted == that.mentionsMuted && - hasOlder == that.hasOlder && - hasNewer == that.hasNewer && - isSpam == that.isSpam && - approvalRequiredForNewMembers == that.approvalRequiredForNewMembers && - inputMode == that.inputMode && - Objects.equals(threadId, that.threadId) && - Objects.equals(threadV2Id, that.threadV2Id) && - Objects.equals(users, that.users) && - Objects.equals(leftUsers, that.leftUsers) && - Objects.equals(adminUserIds, that.adminUserIds) && - Objects.equals(items, that.items) && - Objects.equals(threadType, that.threadType) && - Objects.equals(threadTitle, that.threadTitle) && - Objects.equals(pendingScore, that.pendingScore) && - Objects.equals(inviter, that.inviter) && - Objects.equals(lastSeenAt, that.lastSeenAt) && - Objects.equals(newestCursor, that.newestCursor) && - Objects.equals(oldestCursor, that.oldestCursor) && - Objects.equals(lastPermanentItem, that.lastPermanentItem) && - Objects.equals(directStory, that.directStory) && - Objects.equals(threadContextItems, that.threadContextItems); - } - - @Override - public int hashCode() { - return Objects - .hash(threadId, threadV2Id, users, leftUsers, adminUserIds, items, lastActivityAt, muted, isPin, named, canonical, pending, archived, - valuedRequest, threadType, viewerId, threadTitle, pendingScore, folder, vcMuted, isGroup, mentionsMuted, inviter, hasOlder, - hasNewer, lastSeenAt, newestCursor, oldestCursor, isSpam, lastPermanentItem, directStory, approvalRequiredForNewMembers, - inputMode, threadContextItems); - } -} + @Throws(CloneNotSupportedException::class) + public override fun clone(): Any = super.clone() +} \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadDetailsChangeResponse.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadDetailsChangeResponse.kt index 416fc284..9bc25fde 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadDetailsChangeResponse.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadDetailsChangeResponse.kt @@ -1,19 +1,6 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -public class DirectThreadDetailsChangeResponse { - private final DirectThread thread; - private final String status; - - public DirectThreadDetailsChangeResponse(final DirectThread thread, final String status) { - this.thread = thread; - this.status = status; - } - - public DirectThread getThread() { - return thread; - } - - public String getStatus() { - return status; - } -} +data class DirectThreadDetailsChangeResponse( + val thread: DirectThread? = null, + val status: String? = null +) \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadDirectStory.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadDirectStory.kt index 8f1db622..47d0bd0d 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadDirectStory.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadDirectStory.kt @@ -1,37 +1,8 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.List; -import java.util.Objects; +import java.io.Serializable -public class DirectThreadDirectStory implements Serializable { - private final List items; - private final int unseenCount; - - public DirectThreadDirectStory(final List items, final int unseenCount) { - this.items = items; - this.unseenCount = unseenCount; - } - - public List getItems() { - return items; - } - - public int getUnseenCount() { - return unseenCount; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DirectThreadDirectStory that = (DirectThreadDirectStory) o; - return unseenCount == that.unseenCount && - Objects.equals(items, that.items); - } - - @Override - public int hashCode() { - return Objects.hash(items, unseenCount); - } -} +data class DirectThreadDirectStory( + val items: List? = null, + val unseenCount: Int = 0, +) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadParticipantRequestsResponse.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadParticipantRequestsResponse.kt index d02bae90..0afac9d7 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadParticipantRequestsResponse.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectThreadParticipantRequestsResponse.kt @@ -1,70 +1,16 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import androidx.annotation.NonNull; +import awais.instagrabber.repositories.responses.User +import java.io.Serializable -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import awais.instagrabber.repositories.responses.User; - -public class DirectThreadParticipantRequestsResponse implements Serializable, Cloneable { - private List users; - private final Map requesterUsernames; - private final String cursor; - private final int totalThreadParticipants; - private int totalParticipantRequests; - private final String status; - - public DirectThreadParticipantRequestsResponse(final List users, - final Map requesterUsernames, - final String cursor, - final int totalThreadParticipants, - final int totalParticipantRequests, - final String status) { - this.users = users; - this.requesterUsernames = requesterUsernames; - this.cursor = cursor; - this.totalThreadParticipants = totalThreadParticipants; - this.totalParticipantRequests = totalParticipantRequests; - this.status = status; - } - - public List getUsers() { - return users; - } - - public void setUsers(final List users) { - this.users = users; - } - - public Map getRequesterUsernames() { - return requesterUsernames; - } - - public String getCursor() { - return cursor; - } - - public int getTotalThreadParticipants() { - return totalThreadParticipants; - } - - public int getTotalParticipantRequests() { - return totalParticipantRequests; - } - - public void setTotalParticipantRequests(final int totalParticipantRequests) { - this.totalParticipantRequests = totalParticipantRequests; - } - - public String getStatus() { - return status; - } - - @NonNull - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } -} +data class DirectThreadParticipantRequestsResponse( + var users: List? = null, + val requesterUsernames: Map? = null, + val cursor: String? = null, + val totalThreadParticipants: Int = 0, + var totalParticipantRequests: Int = 0, + val status: String? = null, +) : Serializable, Cloneable { + @Throws(CloneNotSupportedException::class) + public override fun clone(): Any = super.clone() +} \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/RankedRecipient.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/RankedRecipient.kt index cd36639f..a01ba31a 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/RankedRecipient.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/RankedRecipient.kt @@ -1,46 +1,21 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.io.Serializable; -import java.util.Objects; +import awais.instagrabber.repositories.responses.User +import java.io.Serializable -import awais.instagrabber.repositories.responses.User; +data class RankedRecipient( + val user: User? = null, + val thread: DirectThread? = null, +) : Serializable { + companion object { + @JvmStatic + fun of(user: User): RankedRecipient { + return RankedRecipient(user = user) + } -public class RankedRecipient implements Serializable { - private final User user; - private final DirectThread thread; - - public RankedRecipient(final User user, final DirectThread thread) { - this.user = user; - this.thread = thread; + @JvmStatic + fun of(thread: DirectThread): RankedRecipient { + return RankedRecipient(thread = thread) + } } - - public User getUser() { - return user; - } - - public DirectThread getThread() { - return thread; - } - - public static RankedRecipient of(final User user) { - return new RankedRecipient(user, null); - } - - public static RankedRecipient of(final DirectThread thread) { - return new RankedRecipient(null, thread); - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final RankedRecipient that = (RankedRecipient) o; - return Objects.equals(user, that.user) && - Objects.equals(thread, that.thread); - } - - @Override - public int hashCode() { - return Objects.hash(user, thread); - } -} +} \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/RankedRecipientsResponse.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/RankedRecipientsResponse.kt index 2c0b2885..c65d8bc3 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/RankedRecipientsResponse.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/RankedRecipientsResponse.kt @@ -1,50 +1,10 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import java.util.List; - -public class RankedRecipientsResponse { - private final List rankedRecipients; - private final long expires; - private final boolean filtered; - private final String requestId; - private final String rankToken; - private final String status; - - public RankedRecipientsResponse(final List rankedRecipients, - final long expires, - final boolean filtered, - final String requestId, - final String rankToken, - final String status) { - this.rankedRecipients = rankedRecipients; - this.expires = expires; - this.filtered = filtered; - this.requestId = requestId; - this.rankToken = rankToken; - this.status = status; - } - - public List getRankedRecipients() { - return rankedRecipients; - } - - public long getExpires() { - return expires; - } - - public boolean isFiltered() { - return filtered; - } - - public String getRequestId() { - return requestId; - } - - public String getRankToken() { - return rankToken; - } - - public String getStatus() { - return status; - } -} +data class RankedRecipientsResponse( + val rankedRecipients: List? = null, + val expires: Long = 0, + val filtered: Boolean = false, + val requestId: String? = null, + val rankToken: String? = null, + val status: String? = null, +) \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/RavenExpiringMediaActionSummary.kt b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/RavenExpiringMediaActionSummary.kt index da60b4bf..c5c332d6 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/RavenExpiringMediaActionSummary.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/directmessages/RavenExpiringMediaActionSummary.kt @@ -1,69 +1,43 @@ -package awais.instagrabber.repositories.responses.directmessages; +package awais.instagrabber.repositories.responses.directmessages -import com.google.gson.annotations.SerializedName; +import com.google.gson.annotations.SerializedName +import java.io.Serializable -import java.io.Serializable; -import java.util.Objects; +data class RavenExpiringMediaActionSummary( + val timestamp: Long = 0, + val count: Int = 0, + val type: ActionType? = null, +) : Serializable -public final class RavenExpiringMediaActionSummary implements Serializable { - private final ActionType type; - private final long timestamp; - private final int count; +// thanks to http://github.com/warifp/InstagramAutoPostImageUrl/blob/master/vendor/mgp25/instagram-php/src/Response/Model/ActionBadge.php +enum class ActionType { + @SerializedName("raven_delivered") + DELIVERED, - public RavenExpiringMediaActionSummary(final long timestamp, final int count, final ActionType type) { - this.timestamp = timestamp; - this.count = count; - this.type = type; - } + @SerializedName("raven_sent") + SENT, - public long getTimestamp() { - return timestamp; - } + @SerializedName("raven_opened") + OPENED, - public int getCount() { - return count; - } + @SerializedName("raven_screenshot") + SCREENSHOT, - public ActionType getType() { - return type; - } + @SerializedName("raven_replayed") + REPLAYED, - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final RavenExpiringMediaActionSummary that = (RavenExpiringMediaActionSummary) o; - return timestamp == that.timestamp && - count == that.count && - type == that.type; - } + @SerializedName("raven_cannot_deliver") + CANNOT_DELIVER, - @Override - public int hashCode() { - return Objects.hash(type, timestamp, count); - } + @SerializedName("raven_sending") + SENDING, - // thanks to http://github.com/warifp/InstagramAutoPostImageUrl/blob/master/vendor/mgp25/instagram-php/src/Response/Model/ActionBadge.php - public enum ActionType { - @SerializedName("raven_delivered") - DELIVERED, - @SerializedName("raven_sent") - SENT, - @SerializedName("raven_opened") - OPENED, - @SerializedName("raven_screenshot") - SCREENSHOT, - @SerializedName("raven_replayed") - REPLAYED, - @SerializedName("raven_cannot_deliver") - CANNOT_DELIVER, - @SerializedName("raven_sending") - SENDING, - @SerializedName("raven_blocked") - BLOCKED, - @SerializedName("raven_unknown") - UNKNOWN, - @SerializedName("raven_suggested") - SUGGESTED, - } -} + @SerializedName("raven_blocked") + BLOCKED, + + @SerializedName("raven_unknown") + UNKNOWN, + + @SerializedName("raven_suggested") + SUGGESTED, +} \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/services/DMSyncService.java b/app/src/main/java/awais/instagrabber/services/DMSyncService.java index 63ae752a..a5df0cd5 100644 --- a/app/src/main/java/awais/instagrabber/services/DMSyncService.java +++ b/app/src/main/java/awais/instagrabber/services/DMSyncService.java @@ -91,7 +91,7 @@ public class DMSyncService extends LifecycleService { return; } for (final DirectThread thread : threads) { - if (thread.isMuted()) continue; + if (thread.getMuted()) continue; final boolean read = DMUtils.isRead(thread); if (read) continue; final List unreadMessages = getUnreadMessages(thread); diff --git a/app/src/main/java/awais/instagrabber/utils/DMUtils.java b/app/src/main/java/awais/instagrabber/utils/DMUtils.java index 44cab81b..f315c906 100644 --- a/app/src/main/java/awais/instagrabber/utils/DMUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/DMUtils.java @@ -15,6 +15,7 @@ import awais.instagrabber.models.enums.DirectItemType; import awais.instagrabber.models.enums.MediaItemType; import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.User; +import awais.instagrabber.repositories.responses.directmessages.ActionType; import awais.instagrabber.repositories.responses.directmessages.DirectItem; import awais.instagrabber.repositories.responses.directmessages.DirectItemAnimatedMedia; import awais.instagrabber.repositories.responses.directmessages.DirectItemReelShare; @@ -267,7 +268,7 @@ public final class DMUtils { final DirectItemVisualMedia visualMedia = item.getVisualMedia(); final RavenExpiringMediaActionSummary summary = visualMedia.getExpiringMediaActionSummary(); if (summary != null) { - final RavenExpiringMediaActionSummary.ActionType expiringMediaType = summary.getType(); + final ActionType expiringMediaType = summary.getType(); int textRes = 0; switch (expiringMediaType) { case DELIVERED: diff --git a/app/src/main/java/awais/instagrabber/viewmodels/DirectSettingsViewModel.java b/app/src/main/java/awais/instagrabber/viewmodels/DirectSettingsViewModel.java index bd918d7f..6f292bc2 100644 --- a/app/src/main/java/awais/instagrabber/viewmodels/DirectSettingsViewModel.java +++ b/app/src/main/java/awais/instagrabber/viewmodels/DirectSettingsViewModel.java @@ -80,7 +80,7 @@ public class DirectSettingsViewModel extends AndroidViewModel { // final List adminUserIds = thread.getAdminUserIds(); // this.adminUserIds.postValue(adminUserIds); // viewerIsAdmin = adminUserIds.contains(viewerId); - // muted.postValue(thread.isMuted()); + // muted.postValue(thread.getMuted()); // mentionsMuted.postValue(thread.isMentionsMuted()); // approvalRequiredToJoin.postValue(thread.isApprovalRequiredForNewMembers()); // isPending.postValue(thread.isPending()); diff --git a/app/src/main/java/awais/instagrabber/webservices/DiscoverService.java b/app/src/main/java/awais/instagrabber/webservices/DiscoverService.java index 880ae526..6f00df93 100644 --- a/app/src/main/java/awais/instagrabber/webservices/DiscoverService.java +++ b/app/src/main/java/awais/instagrabber/webservices/DiscoverService.java @@ -107,7 +107,7 @@ public class DiscoverService extends BaseService { // } // final String type = clusterJson.optString("type"); // final boolean canMute = clusterJson.optBoolean("can_mute"); - // final boolean isMuted = clusterJson.optBoolean("is_muted"); + // final boolean getMuted = clusterJson.optBoolean("is_muted"); // final JSONObject coverMediaJson = clusterJson.optJSONObject("cover_media"); // final int rankedPosition = clusterJson.optInt("ranked_position"); // final FeedModel feedModel = parseClusterCover(coverMediaJson); @@ -116,7 +116,7 @@ public class DiscoverService extends BaseService { // title, // type, // canMute, - // isMuted, + // getMuted, // rankedPosition, // feedModel // );