From f7e5914df82f35af31053aaf6c3879988b3881bc Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Tue, 14 Jul 2020 20:35:41 -0400 Subject: [PATCH] v16.6-a6 this time the proper version --- README.md | 2 +- .../activities/DirectMessagesUserInbox.java | 45 +++++++------- .../instagrabber/activities/StoryViewer.java | 13 ++++ .../adapters/DirectMessagesAdapter.java | 17 ++++-- .../adapters/MessageItemsAdapter.java | 59 ++++++++++--------- .../direct_messages/DirectItemModel.java | 12 +++- .../instagrabber/utils/UpdateChecker.java | 2 +- .../java/awais/instagrabber/utils/Utils.java | 20 +++++-- app/src/main/res/values/strings.xml | 1 + 9 files changed, 109 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index e62b3c4f..ce65e475 100755 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This app is originally made by [@AwaisKing](https://github.com/AwaisKing) who po Download [here](https://github.com/austinhuang0131/instagrabber/releases). Under each release is an `app-release.apk`. Just install that. Unfortunately, * I have to sign it with my own key, which means you have to uninstall the old app and log in again. Sorry. -* I don't plan on getting a Google Play Dev account yet, so that means Google Play will shout at you for installing "malware". Just ignore it. If you're skeptical (which is not necessarily a bad thing), just inspect the source code and build the app yourself. +* ~~I don't plan on getting a Google Play Dev account yet, so that means Google Play will shout at you for installing "malware". Just ignore it.~~ (Does not seem to happen anymore after I sent the app to Google.) If you're skeptical (which is not necessarily a bad thing), just inspect the source code and build the app yourself. ### How to log in diff --git a/app/src/main/java/awais/instagrabber/activities/DirectMessagesUserInbox.java b/app/src/main/java/awais/instagrabber/activities/DirectMessagesUserInbox.java index 6625727d..fba5d12a 100755 --- a/app/src/main/java/awais/instagrabber/activities/DirectMessagesUserInbox.java +++ b/app/src/main/java/awais/instagrabber/activities/DirectMessagesUserInbox.java @@ -30,6 +30,7 @@ import awais.instagrabber.models.ProfileModel; import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.direct_messages.DirectItemModel; import awais.instagrabber.models.direct_messages.DirectItemModel.DirectItemMediaModel; +import awais.instagrabber.models.direct_messages.DirectItemModel.DirectItemRavenMediaModel; import awais.instagrabber.models.direct_messages.InboxThreadModel; import awais.instagrabber.models.enums.DirectItemType; import awais.instagrabber.models.enums.DownloadMethod; @@ -104,46 +105,50 @@ public final class DirectMessagesUserInbox extends AppCompatActivity { Object tag = v.getTag(); if (tag instanceof DirectItemModel) { directItemModel = (DirectItemModel) tag; - final String username = getUser(directItemModel.getUserId()).getUsername(); final DirectItemType itemType = directItemModel.getItemType(); switch (itemType) { + case MEDIA_SHARE: + startActivity(new Intent(this, PostViewer.class) + .putExtra(Constants.EXTRAS_POST, new PostModel(directItemModel.getMediaModel().getCode()))); + break; case LINK: Intent linkIntent = new Intent(Intent.ACTION_VIEW); linkIntent.setData(Uri.parse(directItemModel.getLinkModel().getLinkContext().getLinkUrl())); startActivity(linkIntent); break; - case MEDIA_SHARE: - startActivity(new Intent(this, PostViewer.class) - .putExtra(Constants.EXTRAS_POST, new PostModel(directItemModel.getMediaModel().getCode()))); + case TEXT: + case REEL_SHARE: + Utils.copyText(v.getContext(), directItemModel.getText()); + Toast.makeText(v.getContext(), R.string.clipboard_copied, Toast.LENGTH_SHORT).show(); break; + case RAVEN_MEDIA: case MEDIA: - Utils.dmDownload(this, username, DownloadMethod.DOWNLOAD_DIRECT, Collections.singletonList(directItemModel.getMediaModel())); + Utils.dmDownload(this, getUser(directItemModel.getUserId()).getUsername(), DownloadMethod.DOWNLOAD_DIRECT, + Collections.singletonList(itemType == DirectItemType.MEDIA ? directItemModel.getMediaModel() : directItemModel.getRavenMediaModel().getMedia())); Toast.makeText(v.getContext(), R.string.downloader_downloading_media, Toast.LENGTH_SHORT).show(); break; - case REEL_SHARE: case STORY_SHARE: + StoryModel sm = new StoryModel( + directItemModel.getReelShare().getReelId(), + directItemModel.getReelShare().getMedia().getVideoUrl(), + directItemModel.getReelShare().getMedia().getMediaType(), + directItemModel.getTimestamp() + ); + sm.setVideoUrl(directItemModel.getReelShare().getMedia().getVideoUrl()); + StoryModel[] sms = {sm}; if (directItemModel.getReelShare() != null) startActivity(new Intent(this, StoryViewer.class) - .putExtra(Constants.EXTRAS_USERNAME, directItemModel.getReelShare().getReelOwnerName()) - /*.putExtra(Constants.EXTRAS_STORIES, new StoryModel( - directItemModel.getReelShare().getReelId(), - directItemModel.getReelShare().getMedia() - ))*/ + .putExtra(Constants.EXTRAS_USERNAME, directItemModel.getReelShare().getReelOwnerName()) + .putExtra(Constants.EXTRAS_STORIES, sms) ); break; - case TEXT: - Utils.copyText(v.getContext(), directItemModel.getText()); - Toast.makeText(v.getContext(), R.string.clipboard_copied, Toast.LENGTH_SHORT).show(); - break; + default: + Log.d("austin_debug", "unsupported type "+itemType); } - - /* - startActivity(new Intent(this, PostViewer.class) - .putExtra(Constants.EXTRAS_POST, new PostModel(tag.toString()))); - */ } }, (view, text, isHashtag) -> { + searchUsername(text); }); dmsBinding.rvDirectMessages.setAdapter( diff --git a/app/src/main/java/awais/instagrabber/activities/StoryViewer.java b/app/src/main/java/awais/instagrabber/activities/StoryViewer.java index 01cf541e..6128dd16 100755 --- a/app/src/main/java/awais/instagrabber/activities/StoryViewer.java +++ b/app/src/main/java/awais/instagrabber/activities/StoryViewer.java @@ -104,6 +104,9 @@ public final class StoryViewer extends BaseLanguageActivity { if (hasUsername) { storyViewerBinding.toolbar.toolbar.setTitle(username); + storyViewerBinding.toolbar.toolbar.setOnClickListener(v -> { + searchUsername(username); + }); if (hasHighlight) storyViewerBinding.toolbar.toolbar.setSubtitle(getString(R.string.title_highlight, highlight)); else storyViewerBinding.toolbar.toolbar.setSubtitle(R.string.title_user_story); } @@ -344,6 +347,16 @@ public final class StoryViewer extends BaseLanguageActivity { else setupImage(); } + private void searchUsername(final String text) { + if (Main.scanHack != null) { + Main.scanHack.onResult(text); + setResult(6969); + Intent intent = new Intent(getApplicationContext(), Main.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + } + } + private void releasePlayer() { if (player != null) { try { player.stop(true); } catch (Exception ignored) { } diff --git a/app/src/main/java/awais/instagrabber/adapters/DirectMessagesAdapter.java b/app/src/main/java/awais/instagrabber/adapters/DirectMessagesAdapter.java index 0c8717ab..e5c9a168 100755 --- a/app/src/main/java/awais/instagrabber/adapters/DirectMessagesAdapter.java +++ b/app/src/main/java/awais/instagrabber/adapters/DirectMessagesAdapter.java @@ -6,6 +6,7 @@ import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; +import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; @@ -85,8 +86,8 @@ public final class DirectMessagesAdapter extends RecyclerView.Adapter"+context.getString(R.string.dms_inbox_media_shared_from, modelUser.getUsername())+"", 63)); holder.tvMessage.setVisibility(View.VISIBLE); } } @@ -220,31 +221,34 @@ public final class MessageItemsAdapter extends RecyclerView.Adapter { @NonNull @Override protected Boolean doInBackground(final Void... voids) { - final String UPDATE_BASE_URL = "https://gitlab.com/AwaisKing/instagrabber/-/releases/v"; + final String UPDATE_BASE_URL = "https://github.com/austinhuang0131/instagrabber/releases/tag/v"; final String versionName = BuildConfig.VERSION_NAME; final int index = versionName.indexOf('.'); diff --git a/app/src/main/java/awais/instagrabber/utils/Utils.java b/app/src/main/java/awais/instagrabber/utils/Utils.java index bc1c57b3..35b90b84 100755 --- a/app/src/main/java/awais/instagrabber/utils/Utils.java +++ b/app/src/main/java/awais/instagrabber/utils/Utils.java @@ -349,6 +349,16 @@ public final class Utils { return thumbnail; } + public static String getVideoUrl(@NonNull final JSONObject mediaObj) throws Exception { + String thumbnail = null; + + final JSONArray imageVersions = mediaObj.optJSONArray("video_versions"); + if (imageVersions != null) + thumbnail = Utils.getItemThumbnail(imageVersions); + + return thumbnail; + } + @Nullable public static MediaItemType getMediaItemType(final int mediaType) { if (mediaType == 1) return MediaItemType.MEDIA_TYPE_IMAGE; @@ -387,6 +397,7 @@ public final class Utils { mediaObj.optLong("pk"), id, getThumbnailUrl(mediaObj, mediaType), + mediaType == MediaItemType.MEDIA_TYPE_VIDEO ? getVideoUrl(mediaObj) : null, user, mediaObj.optString("code")); } @@ -521,7 +532,7 @@ public final class Utils { linkModel = new DirectItemLinkModel(linkObj.getString("text"), linkObj.getString("client_context"), - linkObj.getString("mutation_token"), + linkObj.optString("mutation_token"), itemLinkContext); } break; @@ -570,7 +581,7 @@ public final class Utils { } ravenMediaModel = new DirectItemRavenMediaModel( - visualMedia.getLong(viewType == RavenMediaViewType.PERMANENT ? "url_expire_at_secs" : "replay_expiring_at_us"), + visualMedia.optLong(viewType == RavenMediaViewType.PERMANENT ? "url_expire_at_secs" : "replay_expiring_at_us"), visualMedia.optInt("playback_duration_secs"), visualMedia.getInt("seen_count"), seenUserIds, @@ -618,7 +629,6 @@ public final class Utils { case ACTION_LOG: if (inThreadView && itemObject.optInt("hide_in_thread", 0) != 0) - // prevents empty viewholders when in thread view mode continue; final JSONObject actionLog = itemObject.getJSONObject("action_log"); String desc = actionLog.getString("description"); @@ -910,7 +920,7 @@ public final class Utils { if (main == null) { new DownloadAsync(context, - selectedItem.getThumbUrl(), + selectedItem.getMediaType() == MediaItemType.MEDIA_TYPE_VIDEO ? selectedItem.getVideoUrl() : selectedItem.getThumbUrl(), getDownloadSaveFileDm(finalDir, selectedItem, ""), null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); @@ -929,7 +939,7 @@ public final class Utils { @NonNull private static File getDownloadSaveFileDm(final File finalDir, @NonNull final DirectItemMediaModel model, final String sliderPrefix) { - final String displayUrl = model.getThumbUrl(); + final String displayUrl = model.getMediaType() == MediaItemType.MEDIA_TYPE_VIDEO ? model.getVideoUrl() : model.getThumbUrl(); return new File(finalDir, model.getId() + sliderPrefix + getExtensionFromModel(displayUrl, model)); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 76977ce0..547a56bc 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -114,6 +114,7 @@ You Shared a link Shared a media + Shared a timed message Replied to a story Reacted on a story Mentioned in a story