From 9dc3af4ee8d96378426c9895acac3fcd66658732 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sun, 30 May 2021 18:03:28 -0400 Subject: [PATCH 1/8] ignore .fdroid.yml --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b220be23..a2ae4420 100755 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,5 @@ app/release /sentry.properties /app/fdroid/ /app/github/ -/repo \ No newline at end of file +/repo +/.fdroid.yml From 37b4817bd7b0dde2f23cc974892994da17bc990a Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sun, 30 May 2021 18:06:40 -0400 Subject: [PATCH 2/8] Rename .java to .kt --- .../responses/notification/{Notification.java => Notification.kt} | 0 .../{NotificationCounts.java => NotificationCounts.kt} | 0 .../notification/{NotificationImage.java => NotificationImage.kt} | 0 .../{CollectionsListResponse.java => CollectionsListResponse.kt} | 0 .../responses/saved/{SavedCollection.java => SavedCollection.kt} | 0 .../responses/search/{SearchResponse.java => SearchResponse.kt} | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename app/src/main/java/awais/instagrabber/repositories/responses/notification/{Notification.java => Notification.kt} (100%) rename app/src/main/java/awais/instagrabber/repositories/responses/notification/{NotificationCounts.java => NotificationCounts.kt} (100%) rename app/src/main/java/awais/instagrabber/repositories/responses/notification/{NotificationImage.java => NotificationImage.kt} (100%) rename app/src/main/java/awais/instagrabber/repositories/responses/saved/{CollectionsListResponse.java => CollectionsListResponse.kt} (100%) rename app/src/main/java/awais/instagrabber/repositories/responses/saved/{SavedCollection.java => SavedCollection.kt} (100%) rename app/src/main/java/awais/instagrabber/repositories/responses/search/{SearchResponse.java => SearchResponse.kt} (100%) diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/notification/Notification.java b/app/src/main/java/awais/instagrabber/repositories/responses/notification/Notification.kt similarity index 100% rename from app/src/main/java/awais/instagrabber/repositories/responses/notification/Notification.java rename to app/src/main/java/awais/instagrabber/repositories/responses/notification/Notification.kt diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationCounts.java b/app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationCounts.kt similarity index 100% rename from app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationCounts.java rename to app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationCounts.kt diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationImage.java b/app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationImage.kt similarity index 100% rename from app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationImage.java rename to app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationImage.kt diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/saved/CollectionsListResponse.java b/app/src/main/java/awais/instagrabber/repositories/responses/saved/CollectionsListResponse.kt similarity index 100% rename from app/src/main/java/awais/instagrabber/repositories/responses/saved/CollectionsListResponse.java rename to app/src/main/java/awais/instagrabber/repositories/responses/saved/CollectionsListResponse.kt diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/saved/SavedCollection.java b/app/src/main/java/awais/instagrabber/repositories/responses/saved/SavedCollection.kt similarity index 100% rename from app/src/main/java/awais/instagrabber/repositories/responses/saved/SavedCollection.java rename to app/src/main/java/awais/instagrabber/repositories/responses/saved/SavedCollection.kt diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/search/SearchResponse.java b/app/src/main/java/awais/instagrabber/repositories/responses/search/SearchResponse.kt similarity index 100% rename from app/src/main/java/awais/instagrabber/repositories/responses/search/SearchResponse.java rename to app/src/main/java/awais/instagrabber/repositories/responses/search/SearchResponse.kt From 972f71c4806e391322d8c58fe6e05a664206d39a Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sun, 30 May 2021 19:07:58 -0400 Subject: [PATCH 3/8] convert some to kotlin --- .../adapters/SavedCollectionsAdapter.java | 9 ++- .../viewholder/TopicClusterViewHolder.java | 10 +-- .../fragments/CollectionPostsFragment.java | 14 ++--- .../fragments/SavedCollectionsFragment.java | 4 +- .../responses/notification/Notification.kt | 36 +++-------- .../notification/NotificationCounts.kt | 62 +++---------------- .../notification/NotificationImage.kt | 20 +----- .../saved/CollectionsListResponse.kt | 60 ++++-------------- .../responses/saved/SavedCollection.kt | 62 +++---------------- .../responses/search/SearchResponse.kt | 54 +++------------- 10 files changed, 67 insertions(+), 264 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/adapters/SavedCollectionsAdapter.java b/app/src/main/java/awais/instagrabber/adapters/SavedCollectionsAdapter.java index 8d9ff290..0d6e361a 100644 --- a/app/src/main/java/awais/instagrabber/adapters/SavedCollectionsAdapter.java +++ b/app/src/main/java/awais/instagrabber/adapters/SavedCollectionsAdapter.java @@ -11,20 +11,19 @@ import androidx.recyclerview.widget.ListAdapter; import awais.instagrabber.adapters.viewholder.TopicClusterViewHolder; import awais.instagrabber.databinding.ItemDiscoverTopicBinding; import awais.instagrabber.repositories.responses.saved.SavedCollection; -import awais.instagrabber.utils.ResponseBodyUtils; public class SavedCollectionsAdapter extends ListAdapter { private static final DiffUtil.ItemCallback DIFF_CALLBACK = new DiffUtil.ItemCallback() { @Override public boolean areItemsTheSame(@NonNull final SavedCollection oldItem, @NonNull final SavedCollection newItem) { - return oldItem.getId().equals(newItem.getId()); + return oldItem.getCollectionId().equals(newItem.getCollectionId()); } @Override public boolean areContentsTheSame(@NonNull final SavedCollection oldItem, @NonNull final SavedCollection newItem) { - if (oldItem.getCoverMedias() != null && newItem.getCoverMedias() != null - && oldItem.getCoverMedias().size() == newItem.getCoverMedias().size()) { - return oldItem.getCoverMedias().get(0).getId().equals(newItem.getCoverMedias().get(0).getId()); + if (oldItem.getCoverMediaList() != null && newItem.getCoverMediaList() != null + && oldItem.getCoverMediaList().size() == newItem.getCoverMediaList().size()) { + return oldItem.getCoverMediaList().get(0).getId().equals(newItem.getCoverMediaList().get(0).getId()); } else if (oldItem.getCoverMedia() != null && newItem.getCoverMedia() != null) { return oldItem.getCoverMedia().getId().equals(newItem.getCoverMedia().getId()); diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/TopicClusterViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/TopicClusterViewHolder.java index 45027d14..809e09b1 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/TopicClusterViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/TopicClusterViewHolder.java @@ -128,11 +128,11 @@ public class TopicClusterViewHolder extends RecyclerView.ViewHolder { backgroundColor.get() )); } - // binding.title.setTransitionName("title-" + topicCluster.getId()); - binding.cover.setTransitionName("cover-" + topicCluster.getId()); - final String thumbUrl = ResponseBodyUtils.getThumbUrl(topicCluster.getCoverMedias() == null + // binding.title.setTransitionName("title-" + topicCluster.getCollectionId()); + binding.cover.setTransitionName("cover-" + topicCluster.getCollectionId()); + final String thumbUrl = ResponseBodyUtils.getThumbUrl(topicCluster.getCoverMediaList() == null ? topicCluster.getCoverMedia() - : topicCluster.getCoverMedias().get(0)); + : topicCluster.getCoverMediaList().get(0)); if (thumbUrl == null) { binding.cover.setImageURI((String) null); } else { @@ -174,6 +174,6 @@ public class TopicClusterViewHolder extends RecyclerView.ViewHolder { }, CallerThreadExecutor.getInstance()); binding.cover.setImageRequest(imageRequest); } - binding.title.setText(topicCluster.getTitle()); + binding.title.setText(topicCluster.getCollectionName()); } } diff --git a/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java b/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java index 1ca49c15..ce12e26e 100644 --- a/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java @@ -297,7 +297,7 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay .setTitle(R.string.delete_collection) .setMessage(R.string.delete_collection_note) .setPositiveButton(R.string.confirm, (d, w) -> collectionService.deleteCollection( - savedCollection.getId(), + savedCollection.getCollectionId(), new ServiceCallback() { @Override public void onSuccess(final String result) { @@ -325,7 +325,7 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay .setTitle(R.string.edit_collection) .setView(input) .setPositiveButton(R.string.confirm, (d, w) -> collectionService.editCollectionName( - savedCollection.getId(), + savedCollection.getCollectionId(), input.getText().toString(), new ServiceCallback() { @Override @@ -408,9 +408,9 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay if (savedCollection == null) { return; } - binding.cover.setTransitionName("collection-" + savedCollection.getId()); + binding.cover.setTransitionName("collection-" + savedCollection.getCollectionId()); fragmentActivity.setToolbar(binding.toolbar); - binding.collapsingToolbarLayout.setTitle(savedCollection.getTitle()); + binding.collapsingToolbarLayout.setTitle(savedCollection.getCollectionName()); final int collapsedTitleTextColor = ColorUtils.setAlphaComponent(titleColor, 0xFF); final int expandedTitleTextColor = ColorUtils.setAlphaComponent(titleColor, 0x99); binding.collapsingToolbarLayout.setExpandedTitleColor(expandedTitleTextColor); @@ -442,9 +442,9 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay } private void setupCover() { - final String coverUrl = ResponseBodyUtils.getImageUrl(savedCollection.getCoverMedias() == null + final String coverUrl = ResponseBodyUtils.getImageUrl(savedCollection.getCoverMediaList() == null ? savedCollection.getCoverMedia() - : savedCollection.getCoverMedias().get(0)); + : savedCollection.getCoverMediaList().get(0)); final DraweeController controller = Fresco .newDraweeControllerBuilder() .setOldController(binding.cover.getController()) @@ -471,7 +471,7 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay private void setupPosts() { binding.posts.setViewModelStoreOwner(this) .setLifeCycleOwner(this) - .setPostFetchService(new SavedPostFetchService(0, PostItemType.COLLECTION, true, savedCollection.getId())) + .setPostFetchService(new SavedPostFetchService(0, PostItemType.COLLECTION, true, savedCollection.getCollectionId())) .setLayoutPreferences(layoutPreferences) .addFetchStatusChangeListener(fetching -> updateSwipeRefreshState()) .setFeedItemCallback(feedItemCallback) diff --git a/app/src/main/java/awais/instagrabber/fragments/SavedCollectionsFragment.java b/app/src/main/java/awais/instagrabber/fragments/SavedCollectionsFragment.java index 880aae27..35382476 100644 --- a/app/src/main/java/awais/instagrabber/fragments/SavedCollectionsFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/SavedCollectionsFragment.java @@ -145,12 +145,12 @@ public class SavedCollectionsFragment extends Fragment implements SwipeRefreshLa final SavedCollectionsAdapter adapter = new SavedCollectionsAdapter((topicCluster, root, cover, title, titleColor, backgroundColor) -> { final NavController navController = NavHostFragment.findNavController(this); if (isSaving) { - setNavControllerResult(navController, topicCluster.getId()); + setNavControllerResult(navController, topicCluster.getCollectionId()); navController.navigateUp(); } else { try { final FragmentNavigator.Extras.Builder builder = new FragmentNavigator.Extras.Builder() - .addSharedElement(cover, "collection-" + topicCluster.getId()); + .addSharedElement(cover, "collection-" + topicCluster.getCollectionId()); final SavedCollectionsFragmentDirections.ActionSavedCollectionsFragmentToCollectionPostsFragment action = SavedCollectionsFragmentDirections .actionSavedCollectionsFragmentToCollectionPostsFragment(topicCluster, titleColor, backgroundColor); navController.navigate(action, builder.build()); diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/notification/Notification.kt b/app/src/main/java/awais/instagrabber/repositories/responses/notification/Notification.kt index 6da18866..0cd35777 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/notification/Notification.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/notification/Notification.kt @@ -1,29 +1,11 @@ -package awais.instagrabber.repositories.responses.notification; +package awais.instagrabber.repositories.responses.notification -import awais.instagrabber.models.enums.NotificationType; +import awais.instagrabber.models.enums.NotificationType +import awais.instagrabber.models.enums.NotificationType.Companion.valueOfType -public class Notification { - private final NotificationArgs args; - private final int storyType; - private final String pk; - - public Notification(final NotificationArgs args, - final int storyType, - final String pk) { - this.args = args; - this.storyType = storyType; - this.pk = pk; - } - - public NotificationArgs getArgs() { - return args; - } - - public NotificationType getType() { - return NotificationType.valueOfType(storyType); - } - - public String getPk() { - return pk; - } -} +class Notification(val args: NotificationArgs, + private val storyType: Int, + val pk: String) { + val type: NotificationType? + get() = valueOfType(storyType) +} \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationCounts.kt b/app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationCounts.kt index dfad97e0..d989dc0c 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationCounts.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationCounts.kt @@ -1,55 +1,9 @@ -package awais.instagrabber.repositories.responses.notification; +package awais.instagrabber.repositories.responses.notification -public class NotificationCounts { - private final int commentLikes; - private final int usertags; - private final int likes; - private final int comments; - private final int relationships; - private final int photosOfYou; - private final int requests; - - public NotificationCounts(final int commentLikes, - final int usertags, - final int likes, - final int comments, - final int relationships, - final int photosOfYou, - final int requests) { - this.commentLikes = commentLikes; - this.usertags = usertags; - this.likes = likes; - this.comments = comments; - this.relationships = relationships; - this.photosOfYou = photosOfYou; - this.requests = requests; - } - - public int getRelationshipsCount() { - return relationships; - } - - public int getUserTagsCount() { - return usertags; - } - - public int getCommentsCount() { - return comments; - } - - public int getCommentLikesCount() { - return commentLikes; - } - - public int getLikesCount() { - return likes; - } - - public int getPOYCount() { - return photosOfYou; - } - - public int getRequestsCount() { - return requests; - } -} +class NotificationCounts(val commentLikesCount: Int, + val userTagsCount: Int, + val likesCount: Int, + val commentsCount: Int, + val relationshipsCount: Int, + val pOYCount: Int, + val requestsCount: Int) \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationImage.kt b/app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationImage.kt index e3d31bc9..48210182 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationImage.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/notification/NotificationImage.kt @@ -1,19 +1,3 @@ -package awais.instagrabber.repositories.responses.notification; +package awais.instagrabber.repositories.responses.notification -public class NotificationImage { - private final String id; - private final String image; - - public NotificationImage(final String id, final String image) { - this.id = id; - this.image = image; - } - - public String getId() { - return id; - } - - public String getImage() { - return image; - } -} +class NotificationImage(val id: String, val image: String) \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/saved/CollectionsListResponse.kt b/app/src/main/java/awais/instagrabber/repositories/responses/saved/CollectionsListResponse.kt index 3c91dacf..b81e8c50 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/saved/CollectionsListResponse.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/saved/CollectionsListResponse.kt @@ -1,50 +1,12 @@ -package awais.instagrabber.repositories.responses.saved; +package awais.instagrabber.repositories.responses.saved -import java.util.List; - -public class CollectionsListResponse { - private final boolean moreAvailable; - private final String nextMaxId; - private final String maxId; - private final String status; -// private final int numResults; - private final List items; - - public CollectionsListResponse(final boolean moreAvailable, - final String nextMaxId, - final String maxId, - final String status, -// final int numResults, - final List items) { - this.moreAvailable = moreAvailable; - this.nextMaxId = nextMaxId; - this.maxId = maxId; - this.status = status; -// this.numResults = numResults; - this.items = items; - } - - public boolean isMoreAvailable() { - return moreAvailable; - } - - public String getNextMaxId() { - return nextMaxId; - } - - public String getMaxId() { - return maxId; - } - - public String getStatus() { - return status; - } - -// public int getNumResults() { -// return numResults; -// } - - public List getItems() { - return items; - } -} +class CollectionsListResponse // this.numResults = numResults; +(val isMoreAvailable: Boolean, + val nextMaxId: String, + val maxId: String, + val status: String, // final int numResults, + // public int getNumResults() { + // return numResults; + // } + // private final int numResults; + val items: List) \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/saved/SavedCollection.kt b/app/src/main/java/awais/instagrabber/repositories/responses/saved/SavedCollection.kt index 2bedfb77..02732c94 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/saved/SavedCollection.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/saved/SavedCollection.kt @@ -1,54 +1,12 @@ -package awais.instagrabber.repositories.responses.saved; +package awais.instagrabber.repositories.responses.saved -import java.io.Serializable; -import java.util.List; +import awais.instagrabber.repositories.responses.Media +import java.io.Serializable -import awais.instagrabber.repositories.responses.Media; - -public class SavedCollection implements Serializable { - private final String collectionId; - private final String collectionName; - private final String collectionType; - private final int collectionMediacount; - private final Media coverMedia; - private final List coverMediaList; - - public SavedCollection(final String collectionId, - final String collectionName, - final String collectionType, - final int collectionMediacount, - final Media coverMedia, - final List coverMediaList) { - this.collectionId = collectionId; - this.collectionName = collectionName; - this.collectionType = collectionType; - this.collectionMediacount = collectionMediacount; - this.coverMedia = coverMedia; - this.coverMediaList = coverMediaList; - } - - public String getId() { - return collectionId; - } - - public String getTitle() { - return collectionName; - } - - public String getType() { - return collectionType; - } - - public int getMediaCount() { - return collectionMediacount; - } - - // check the list first, then the single - // i have no idea what condition is required - - public Media getCoverMedia() { return coverMedia; } - - public List getCoverMedias() { - return coverMediaList; - } -} +class SavedCollection(val collectionId: String, + val collectionName: String, + val collectionType: String, + val collectionMediaCount: Int, + // coverMedia or coverMediaList: only one is defined + val coverMedia: Media, + val coverMediaList: List) : Serializable \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/responses/search/SearchResponse.kt b/app/src/main/java/awais/instagrabber/repositories/responses/search/SearchResponse.kt index d3f0e143..25f148ca 100644 --- a/app/src/main/java/awais/instagrabber/repositories/responses/search/SearchResponse.kt +++ b/app/src/main/java/awais/instagrabber/repositories/responses/search/SearchResponse.kt @@ -1,46 +1,10 @@ -package awais.instagrabber.repositories.responses.search; +package awais.instagrabber.repositories.responses.search -import java.util.List; - -public class SearchResponse { - // app - private final List list; - // browser - private final List users; - private final List places; - private final List hashtags; - // universal - private final String status; - - public SearchResponse(final List list, - final List users, - final List places, - final List hashtags, - final String status) { - this.list = list; - this.users = users; - this.places = places; - this.hashtags = hashtags; - this.status = status; - } - - public List getList() { - return list; - } - - public List getUsers() { - return users; - } - - public List getPlaces() { - return places; - } - - public List getHashtags() { - return hashtags; - } - - public String getStatus() { - return status; - } -} +class SearchResponse(// app + val list: List, + // browser + val users: List, + val places: List, + val hashtags: List, + // universal + val status: String) \ No newline at end of file From 241c9437c51316ec823c0e4dd1ba8e61f5aa8a74 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sun, 30 May 2021 19:23:09 -0400 Subject: [PATCH 4/8] close #1360, close #1361 --- .../fragments/CollectionPostsFragment.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java b/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java index ce12e26e..1480f6e3 100644 --- a/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/CollectionPostsFragment.java @@ -84,6 +84,7 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay private int downloadChildPosition = -1; private CollectionService collectionService; private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_SAVED_POSTS_LAYOUT); + private MenuItem deleteMenu, editMenu; private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) { @Override @@ -281,8 +282,13 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay @Override public void onCreateOptionsMenu(@NonNull final Menu menu, @NonNull final MenuInflater inflater) { - // delaying to make toolbar resume animation smooth, otherwise lags - binding.getRoot().postDelayed(() -> inflater.inflate(R.menu.collection_posts_menu, menu), 500); + inflater.inflate(R.menu.collection_posts_menu, menu); + deleteMenu = menu.findItem(R.id.delete); + if (deleteMenu != null) + deleteMenu.setVisible(savedCollection.getCollectionType().equals("MEDIA")); + editMenu = menu.findItem(R.id.edit); + if (editMenu != null) + editMenu.setVisible(savedCollection.getCollectionType().equals("MEDIA")); } @Override @@ -493,7 +499,7 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay private void showPostsLayoutPreferences() { final PostsLayoutPreferencesDialogFragment fragment = new PostsLayoutPreferencesDialogFragment( - Constants.PREF_TOPIC_POSTS_LAYOUT, + Constants.PREF_SAVED_POSTS_LAYOUT, preferences -> { layoutPreferences = preferences; new Handler().postDelayed(() -> binding.posts.setLayoutPreferences(preferences), 200); From 267096ff3924830e5780b84fb5005423fe7b78ae Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sun, 30 May 2021 20:02:18 -0400 Subject: [PATCH 5/8] move private post warning to share dialog i don't know if this works on android 10+ but eh --- .../awais/instagrabber/fragments/PostViewV2Fragment.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java b/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java index 71e2a43c..3d642502 100644 --- a/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java @@ -763,8 +763,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme if (isPrivate) { final Context context = getContext(); if (context == null) return; - // is this necessary? - Toast.makeText(context, R.string.share_private_post, Toast.LENGTH_LONG).show(); +// Toast.makeText(context, R.string.share_private_post, Toast.LENGTH_LONG).show(); } if (viewModel.isLoggedIn()) { final Context context = getContext(); @@ -807,6 +806,8 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme private void shareLink(@NonNull final Media media, final boolean isPrivate) { final Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); + sharingIntent.putExtra(android.content.Intent.EXTRA_TITLE, + getString(isPrivate ? R.string.share_private_post : R.string.share_public_post)); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://instagram.com/p/" + media.getCode()); startActivity(Intent.createChooser( sharingIntent, From a037b68f2759ef1430943860a7946e749986d707 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sun, 30 May 2021 20:47:44 -0400 Subject: [PATCH 6/8] oops --- app/src/main/java/awais/instagrabber/models/Comment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/awais/instagrabber/models/Comment.kt b/app/src/main/java/awais/instagrabber/models/Comment.kt index 20c03f76..4d85e338 100644 --- a/app/src/main/java/awais/instagrabber/models/Comment.kt +++ b/app/src/main/java/awais/instagrabber/models/Comment.kt @@ -21,7 +21,7 @@ class Comment( return hasLikedComment } - fun setLiked(liked: Boolean) { + fun setLiked(hasLikedComment: Boolean) { commentLikeCount = if (hasLikedComment) commentLikeCount + 1 else commentLikeCount - 1 this.hasLikedComment = hasLikedComment } From 7cf659c4f5c00a7790b5937282d4b424e5ff08ef Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sun, 30 May 2021 20:51:54 -0400 Subject: [PATCH 7/8] Rename .java to .kt --- .../models/enums/{DirectItemType.java => DirectItemType.kt} | 0 .../enums/{RavenMediaViewMode.java => RavenMediaViewMode.kt} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename app/src/main/java/awais/instagrabber/models/enums/{DirectItemType.java => DirectItemType.kt} (100%) rename app/src/main/java/awais/instagrabber/models/enums/{RavenMediaViewMode.java => RavenMediaViewMode.kt} (100%) diff --git a/app/src/main/java/awais/instagrabber/models/enums/DirectItemType.java b/app/src/main/java/awais/instagrabber/models/enums/DirectItemType.kt similarity index 100% rename from app/src/main/java/awais/instagrabber/models/enums/DirectItemType.java rename to app/src/main/java/awais/instagrabber/models/enums/DirectItemType.kt diff --git a/app/src/main/java/awais/instagrabber/models/enums/RavenMediaViewMode.java b/app/src/main/java/awais/instagrabber/models/enums/RavenMediaViewMode.kt similarity index 100% rename from app/src/main/java/awais/instagrabber/models/enums/RavenMediaViewMode.java rename to app/src/main/java/awais/instagrabber/models/enums/RavenMediaViewMode.kt From d532d28ac3ca47eebcaa5e6c77d976650fea289c Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sun, 30 May 2021 20:51:54 -0400 Subject: [PATCH 8/8] convert some to kotlin --- .../adapters/DirectItemsAdapter.java | 2 +- .../instagrabber/managers/ThreadManager.kt | 3 +- .../models/enums/DirectItemType.kt | 100 +++++++----------- .../models/enums/RavenMediaViewMode.kt | 6 +- .../models/enums/SuggestionType.kt | 5 - 5 files changed, 44 insertions(+), 72 deletions(-) delete mode 100755 app/src/main/java/awais/instagrabber/models/enums/SuggestionType.kt diff --git a/app/src/main/java/awais/instagrabber/adapters/DirectItemsAdapter.java b/app/src/main/java/awais/instagrabber/adapters/DirectItemsAdapter.java index 444d4aa1..40624082 100644 --- a/app/src/main/java/awais/instagrabber/adapters/DirectItemsAdapter.java +++ b/app/src/main/java/awais/instagrabber/adapters/DirectItemsAdapter.java @@ -139,7 +139,7 @@ public final class DirectItemsAdapter extends RecyclerView.Adapter map = new HashMap<>(); + companion object { + private val map: MutableMap = mutableMapOf() - static { - for (DirectItemType type : DirectItemType.values()) { - map.put(type.id, type); + @JvmStatic + fun getId(id: Int): DirectItemType? { + return map[id] } - } - DirectItemType(final int id) { - this.id = id; - } - - public int getId() { - return id; - } - - public static DirectItemType valueOf(final int id) { - if (!map.containsKey(id)) return DirectItemType.UNKNOWN; - return map.get(id); - } - - public String getName() { - switch (this) { - case TEXT: - return "text"; - case LIKE: - return "like"; - case LINK: - return "link"; - case MEDIA: - return "media"; - case RAVEN_MEDIA: - return "raven_media"; - case PROFILE: - return "profile"; - case VIDEO_CALL_EVENT: - return "video_call_event"; - case ANIMATED_MEDIA: - return "animated_media"; - case VOICE_MEDIA: - return "voice_media"; - case MEDIA_SHARE: - return "media_share"; - case REEL_SHARE: - return "reel_share"; - case ACTION_LOG: - return "action_log"; - case PLACEHOLDER: - return "placeholder"; - case STORY_SHARE: - return "story_share"; - case CLIP: - return "clip"; - case FELIX_SHARE: - return "felix_share"; - case LOCATION: - return "location"; + @JvmStatic + fun getName(directItemType: DirectItemType): String? { + when (directItemType) { + TEXT -> return "text" + LIKE -> return "like" + LINK -> return "link" + MEDIA -> return "media" + RAVEN_MEDIA -> return "raven_media" + PROFILE -> return "profile" + VIDEO_CALL_EVENT -> return "video_call_event" + ANIMATED_MEDIA -> return "animated_media" + VOICE_MEDIA -> return "voice_media" + MEDIA_SHARE -> return "media_share" + REEL_SHARE -> return "reel_share" + ACTION_LOG -> return "action_log" + PLACEHOLDER -> return "placeholder" + STORY_SHARE -> return "story_share" + CLIP -> return "clip" + FELIX_SHARE -> return "felix_share" + LOCATION -> return "location" + } + return null + } + + init { + for (type in DirectItemType.values()) { + map[type.id] = type + } } - return null; } } \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/models/enums/RavenMediaViewMode.kt b/app/src/main/java/awais/instagrabber/models/enums/RavenMediaViewMode.kt index 75f8ca76..2707d2f0 100644 --- a/app/src/main/java/awais/instagrabber/models/enums/RavenMediaViewMode.kt +++ b/app/src/main/java/awais/instagrabber/models/enums/RavenMediaViewMode.kt @@ -1,8 +1,8 @@ -package awais.instagrabber.models.enums; +package awais.instagrabber.models.enums -import com.google.gson.annotations.SerializedName; +import com.google.gson.annotations.SerializedName -public enum RavenMediaViewMode { +enum class RavenMediaViewMode { @SerializedName("permanent") PERMANENT, @SerializedName("replayable") diff --git a/app/src/main/java/awais/instagrabber/models/enums/SuggestionType.kt b/app/src/main/java/awais/instagrabber/models/enums/SuggestionType.kt deleted file mode 100755 index e24f542c..00000000 --- a/app/src/main/java/awais/instagrabber/models/enums/SuggestionType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package awais.instagrabber.models.enums - -enum class SuggestionType { - TYPE_USER, TYPE_HASHTAG, TYPE_LOCATION -} \ No newline at end of file