mirror of
https://github.com/KokaKiwi/BarInsta
synced 2026-03-05 12:01:35 +00:00
Merge branch 'master' into dm-notifications-enhancements
This commit is contained in:
commit
8f926baee5
58 changed files with 1548 additions and 552 deletions
|
|
@ -12,13 +12,11 @@ import com.facebook.imagepipeline.core.ImagePipelineConfig;
|
|||
import java.net.CookieHandler;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.LocaleUtils;
|
||||
import awais.instagrabber.utils.SettingsHelper;
|
||||
import awais.instagrabber.utils.TextUtils;
|
||||
import awais.instagrabber.utils.UserAgentUtils;
|
||||
import awaisomereport.CrashReporter;
|
||||
import awaisomereport.LogCollector;
|
||||
|
||||
|
|
@ -87,15 +85,5 @@ public final class InstaGrabberApplication extends Application {
|
|||
if (TextUtils.isEmpty(settingsHelper.getString(Constants.DEVICE_UUID))) {
|
||||
settingsHelper.putString(Constants.DEVICE_UUID, UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
if (settingsHelper.getInteger(Constants.BROWSER_UA_CODE) == -1) {
|
||||
int randomNum = ThreadLocalRandom.current().nextInt(0, UserAgentUtils.browsers.length);
|
||||
settingsHelper.putInteger(Constants.BROWSER_UA_CODE, randomNum);
|
||||
}
|
||||
|
||||
if (settingsHelper.getInteger(Constants.APP_UA_CODE) == -1) {
|
||||
int randomNum = ThreadLocalRandom.current().nextInt(0, UserAgentUtils.devices.length);
|
||||
settingsHelper.putInteger(Constants.APP_UA_CODE, randomNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -83,6 +83,10 @@ public class FeedGridItemViewHolder extends RecyclerView.ViewHolder {
|
|||
final Media child = sliderItems.get(0);
|
||||
if (child != null) {
|
||||
thumbnailUrl = ResponseBodyUtils.getThumbUrl(child);
|
||||
if (layoutPreferences.getType() == STAGGERED_GRID) {
|
||||
final float childAspectRatio = (float) child.getOriginalWidth() / child.getOriginalHeight();
|
||||
binding.postImage.setAspectRatio(childAspectRatio);
|
||||
}
|
||||
}
|
||||
}
|
||||
typeIconRes = R.drawable.ic_checkbox_multiple_blank_stroke;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package awais.instagrabber.adapters.viewholder.directmessages;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.View;
|
||||
|
||||
|
|
@ -126,13 +127,14 @@ public final class DirectInboxItemViewHolder extends RecyclerView.ViewHolder {
|
|||
|
||||
private void setSubtitle(@NonNull final DirectThread thread) {
|
||||
// If there is an unopened raven media, give it highest priority
|
||||
final Resources resources = itemView.getResources();
|
||||
final DirectThreadDirectStory directStory = thread.getDirectStory();
|
||||
final long viewerId = thread.getViewerId();
|
||||
if (directStory != null && !directStory.getItems().isEmpty()) {
|
||||
final DirectItem item = directStory.getItems().get(0);
|
||||
final MediaItemType mediaType = item.getVisualMedia().getMedia().getMediaType();
|
||||
final String username = getUsername(thread.getUsers(), item.getUserId(), viewerId);
|
||||
final String subtitle = getMediaSpecificSubtitle(username, mediaType);
|
||||
final String username = getUsername(thread.getUsers(), item.getUserId(), viewerId, resources);
|
||||
final String subtitle = getMediaSpecificSubtitle(username, resources, mediaType);
|
||||
binding.subtitle.setText(subtitle);
|
||||
return;
|
||||
}
|
||||
|
|
@ -141,10 +143,10 @@ public final class DirectInboxItemViewHolder extends RecyclerView.ViewHolder {
|
|||
final long senderId = item.getUserId();
|
||||
final DirectItemType itemType = item.getItemType();
|
||||
String subtitle = null;
|
||||
final String username = getUsername(thread.getUsers(), senderId, viewerId);
|
||||
final String username = getUsername(thread.getUsers(), senderId, viewerId, resources);
|
||||
String message = "";
|
||||
if (itemType == null) {
|
||||
message = "Unsupported message";
|
||||
message = resources.getString(R.string.dms_inbox_raven_message_unknown);
|
||||
} else {
|
||||
switch (itemType) {
|
||||
case TEXT:
|
||||
|
|
@ -160,20 +162,20 @@ public final class DirectInboxItemViewHolder extends RecyclerView.ViewHolder {
|
|||
message = item.getPlaceholder().getMessage();
|
||||
break;
|
||||
case MEDIA_SHARE:
|
||||
subtitle = String.format("%s shared a post", username != null ? username : "");
|
||||
subtitle = resources.getString(R.string.dms_inbox_shared_post, username != null ? username : "", item.getMediaShare().getUser().getUsername());
|
||||
break;
|
||||
case ANIMATED_MEDIA:
|
||||
subtitle = String.format("%s shared a gif", username != null ? username : "");
|
||||
subtitle = resources.getString(R.string.dms_inbox_shared_gif, username != null ? username : "");
|
||||
break;
|
||||
case PROFILE:
|
||||
subtitle = String.format("%s shared a profile: @%s", username != null ? username : "", item.getProfile().getUsername());
|
||||
subtitle = resources.getString(R.string.dms_inbox_shared_profile, username != null ? username : "", item.getProfile().getUsername());
|
||||
break;
|
||||
case LOCATION:
|
||||
subtitle = String.format("%s shared a location: %s", username != null ? username : "", item.getLocation().getName());
|
||||
subtitle = resources.getString(R.string.dms_inbox_shared_location, username != null ? username : "", item.getLocation().getName());
|
||||
break;
|
||||
case MEDIA: {
|
||||
final MediaItemType mediaType = item.getMedia().getMediaType();
|
||||
subtitle = getMediaSpecificSubtitle(username, mediaType);
|
||||
subtitle = getMediaSpecificSubtitle(username, resources, mediaType);
|
||||
break;
|
||||
}
|
||||
case STORY_SHARE: {
|
||||
|
|
@ -181,17 +183,16 @@ public final class DirectInboxItemViewHolder extends RecyclerView.ViewHolder {
|
|||
if (reelType == null) {
|
||||
subtitle = item.getStoryShare().getTitle();
|
||||
} else {
|
||||
String format = "%s shared a story by @%s";
|
||||
if (reelType.equals("highlight_reel")) {
|
||||
format = "%s shared a story highlight by @%s";
|
||||
}
|
||||
subtitle = String.format(format, username != null ? username : "",
|
||||
final int format = reelType.equals("highlight_reel")
|
||||
? R.string.dms_inbox_shared_highlight
|
||||
: R.string.dms_inbox_shared_story;
|
||||
subtitle = resources.getString(format, username != null ? username : "",
|
||||
item.getStoryShare().getMedia().getUser().getUsername());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VOICE_MEDIA:
|
||||
subtitle = String.format("%s sent a voice message", username != null ? username : "");
|
||||
subtitle = resources.getString(R.string.dms_inbox_shared_voice, username != null ? username : "");
|
||||
break;
|
||||
case ACTION_LOG:
|
||||
subtitle = item.getActionLog().getDescription();
|
||||
|
|
@ -200,15 +201,15 @@ public final class DirectInboxItemViewHolder extends RecyclerView.ViewHolder {
|
|||
subtitle = item.getVideoCallEvent().getDescription();
|
||||
break;
|
||||
case CLIP:
|
||||
subtitle = String.format("%s shared a clip by @%s", username != null ? username : "",
|
||||
item.getClip().getClip().getUser().getUsername());
|
||||
subtitle = resources.getString(R.string.dms_inbox_shared_clip, username != null ? username : "",
|
||||
item.getClip().getClip().getUser().getUsername());
|
||||
break;
|
||||
case FELIX_SHARE:
|
||||
subtitle = String.format("%s shared an IGTV video by @%s", username != null ? username : "",
|
||||
item.getFelixShare().getVideo().getUser().getUsername());
|
||||
subtitle = resources.getString(R.string.dms_inbox_shared_igtv, username != null ? username : "",
|
||||
item.getFelixShare().getVideo().getUser().getUsername());
|
||||
break;
|
||||
case RAVEN_MEDIA:
|
||||
subtitle = getRavenMediaSubtitle(item, username);
|
||||
subtitle = getRavenMediaSubtitle(item, resources, username);
|
||||
break;
|
||||
case REEL_SHARE:
|
||||
final DirectItemReelShare reelShare = item.getReelShare();
|
||||
|
|
@ -220,27 +221,27 @@ public final class DirectInboxItemViewHolder extends RecyclerView.ViewHolder {
|
|||
switch (reelType) {
|
||||
case "reply":
|
||||
if (viewerId == item.getUserId()) {
|
||||
subtitle = String.format("You replied to their story: %s", reelShare.getText());
|
||||
subtitle = resources.getString(R.string.dms_inbox_replied_story_outgoing, reelShare.getText());
|
||||
} else {
|
||||
subtitle = String.format("%s replied to your story: %s", username != null ? username : "", reelShare.getText());
|
||||
subtitle = resources.getString(R.string.dms_inbox_replied_story_incoming, username != null ? username : "", reelShare.getText());
|
||||
}
|
||||
break;
|
||||
case "mention":
|
||||
if (viewerId == item.getUserId()) {
|
||||
// You mentioned the other person
|
||||
final long mentionedUserId = item.getReelShare().getMentionedUserId();
|
||||
final String otherUsername = getUsername(thread.getUsers(), mentionedUserId, viewerId);
|
||||
subtitle = String.format("You mentioned @%s in your story", otherUsername);
|
||||
final String otherUsername = getUsername(thread.getUsers(), mentionedUserId, viewerId, resources);
|
||||
subtitle = resources.getString(R.string.dms_inbox_mentioned_story_outgoing, otherUsername);
|
||||
} else {
|
||||
// They mentioned you
|
||||
subtitle = String.format("%s mentioned you in their story", username != null ? username : "");
|
||||
subtitle = resources.getString(R.string.dms_inbox_mentioned_story_incoming, username != null ? username : "");
|
||||
}
|
||||
break;
|
||||
case "reaction":
|
||||
if (viewerId == item.getUserId()) {
|
||||
subtitle = String.format("You reacted to their story: %s", reelShare.getText());
|
||||
subtitle = resources.getString(R.string.dms_inbox_reacted_story_outgoing, reelShare.getText());
|
||||
} else {
|
||||
subtitle = String.format("%s reacted to your story: %s", username != null ? username : "", reelShare.getText());
|
||||
subtitle = resources.getString(R.string.dms_inbox_reacted_story_incoming, username != null ? username : "", reelShare.getText());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
@ -249,7 +250,7 @@ public final class DirectInboxItemViewHolder extends RecyclerView.ViewHolder {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
message = "Unsupported message";
|
||||
message = resources.getString(R.string.dms_inbox_raven_message_unknown);
|
||||
}
|
||||
}
|
||||
if (subtitle == null) {
|
||||
|
|
@ -263,10 +264,10 @@ public final class DirectInboxItemViewHolder extends RecyclerView.ViewHolder {
|
|||
binding.subtitle.setText(subtitle != null ? subtitle : "");
|
||||
}
|
||||
|
||||
private String getMediaSpecificSubtitle(final String username, final MediaItemType mediaType) {
|
||||
final String userSharedAnImage = String.format("%s shared an image", username != null ? username : "");
|
||||
final String userSharedAVideo = String.format("%s shared a video", username != null ? username : "");
|
||||
final String userSentAMessage = String.format("%s sent a message", username != null ? username : "");
|
||||
private String getMediaSpecificSubtitle(final String username, final Resources resources, final MediaItemType mediaType) {
|
||||
final String userSharedAnImage = resources.getString(R.string.dms_inbox_shared_image, username != null ? username : "");
|
||||
final String userSharedAVideo = resources.getString(R.string.dms_inbox_shared_video, username != null ? username : "");
|
||||
final String userSentAMessage = resources.getString(R.string.dms_inbox_shared_message, username != null ? username : "");
|
||||
String subtitle;
|
||||
switch (mediaType) {
|
||||
case MEDIA_TYPE_IMAGE:
|
||||
|
|
@ -283,6 +284,7 @@ public final class DirectInboxItemViewHolder extends RecyclerView.ViewHolder {
|
|||
}
|
||||
|
||||
private String getRavenMediaSubtitle(final DirectItem item,
|
||||
final Resources resources,
|
||||
final String username) {
|
||||
String subtitle = "↗ ";
|
||||
final DirectItemVisualMedia visualMedia = item.getVisualMedia();
|
||||
|
|
@ -325,15 +327,16 @@ public final class DirectInboxItemViewHolder extends RecyclerView.ViewHolder {
|
|||
return subtitle;
|
||||
}
|
||||
final MediaItemType mediaType = visualMedia.getMedia().getMediaType();
|
||||
subtitle = getMediaSpecificSubtitle(username, mediaType);
|
||||
subtitle = getMediaSpecificSubtitle(username, resources, mediaType);
|
||||
return subtitle;
|
||||
}
|
||||
|
||||
private String getUsername(final List<User> users,
|
||||
final long userId,
|
||||
final long viewerId) {
|
||||
final long viewerId,
|
||||
final Resources resources) {
|
||||
if (userId == viewerId) {
|
||||
return "You";
|
||||
return resources.getString(R.string.you);
|
||||
}
|
||||
final Optional<User> senderOptional = users.stream()
|
||||
.filter(Objects::nonNull)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.facebook.drawee.drawable.ScalingUtils;
|
|||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
||||
import com.facebook.drawee.generic.RoundingParams;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.adapters.DirectItemsAdapter.DirectItemCallback;
|
||||
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
||||
import awais.instagrabber.databinding.LayoutDmRavenMediaBinding;
|
||||
|
|
@ -118,28 +119,28 @@ public class DirectItemRavenMediaViewHolder extends DirectItemViewHolder {
|
|||
if (viewMode != RavenMediaViewMode.PERMANENT) {
|
||||
final MediaItemType mediaType = media.getMediaType();
|
||||
final boolean expired = media.getPk() == null;
|
||||
final String info;
|
||||
final int info;
|
||||
switch (mediaType) {
|
||||
case MEDIA_TYPE_IMAGE:
|
||||
if (expired) {
|
||||
info = "Image has expired";
|
||||
info = R.string.raven_image_expired;
|
||||
break;
|
||||
}
|
||||
info = "Image will expire when seen";
|
||||
info = R.string.raven_image_info;
|
||||
break;
|
||||
case MEDIA_TYPE_VIDEO:
|
||||
if (expired) {
|
||||
info = "Video has expired";
|
||||
info = R.string.raven_video_expired;
|
||||
break;
|
||||
}
|
||||
info = "Video will expire when seen";
|
||||
info = R.string.raven_video_info;
|
||||
break;
|
||||
default:
|
||||
if (expired) {
|
||||
info = "Message has expired";
|
||||
info = R.string.raven_msg_expired;
|
||||
break;
|
||||
}
|
||||
info = "Message will expire when seen";
|
||||
info = R.string.raven_msg_info;
|
||||
break;
|
||||
}
|
||||
binding.expiryInfo.setVisibility(View.VISIBLE);
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public class DirectItemReelShareViewHolder extends DirectItemViewHolder {
|
|||
private void setReply(final MessageDirection messageDirection,
|
||||
final DirectItemReelShare reelShare,
|
||||
final boolean isSelf) {
|
||||
final String info = isSelf ? "You replied to their story" : "They replied to your story";
|
||||
final int info = isSelf ? R.string.replied_story_outgoing : R.string.replied_story_incoming;
|
||||
binding.shareInfo.setText(info);
|
||||
binding.reaction.setVisibility(View.GONE);
|
||||
final String text = reelShare.getText();
|
||||
|
|
@ -122,7 +122,7 @@ public class DirectItemReelShareViewHolder extends DirectItemViewHolder {
|
|||
final DirectItemReelShare reelShare,
|
||||
final boolean isSelf,
|
||||
final boolean expired) {
|
||||
final String info = isSelf ? "You reacted to their story" : "They reacted to your story";
|
||||
final int info = isSelf ? R.string.reacted_story_outgoing : R.string.reacted_story_incoming;
|
||||
binding.shareInfo.setText(info);
|
||||
binding.message.setVisibility(View.GONE);
|
||||
final String text = reelShare.getText();
|
||||
|
|
@ -139,7 +139,7 @@ public class DirectItemReelShareViewHolder extends DirectItemViewHolder {
|
|||
}
|
||||
|
||||
private void setMention(final boolean isSelf) {
|
||||
final String info = isSelf ? "You mentioned them in your story" : "Mentioned you in their story";
|
||||
final int info = isSelf ? R.string.mentioned_story_outgoing : R.string.mentioned_story_incoming;
|
||||
binding.shareInfo.setText(info);
|
||||
binding.message.setVisibility(View.GONE);
|
||||
binding.reaction.setVisibility(View.GONE);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package awais.instagrabber.adapters.viewholder.directmessages;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
|
@ -11,6 +12,7 @@ import com.facebook.drawee.drawable.ScalingUtils;
|
|||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
||||
import com.facebook.drawee.generic.RoundingParams;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.adapters.DirectItemsAdapter.DirectItemCallback;
|
||||
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
||||
import awais.instagrabber.databinding.LayoutDmStoryShareBinding;
|
||||
|
|
@ -41,17 +43,18 @@ public class DirectItemStoryShareViewHolder extends DirectItemViewHolder {
|
|||
|
||||
@Override
|
||||
public void bindItem(final DirectItem item, final MessageDirection messageDirection) {
|
||||
String format = "@%s's story";
|
||||
final Resources resources = itemView.getResources();
|
||||
int format = R.string.story_share;
|
||||
final String reelType = item.getStoryShare().getReelType();
|
||||
if (reelType == null || item.getStoryShare().getMedia() == null) {
|
||||
setExpiredStoryInfo(item);
|
||||
return;
|
||||
}
|
||||
if (reelType.equals("highlight_reel")) {
|
||||
format = "@%s's story highlight";
|
||||
format = R.string.story_share_highlight;
|
||||
}
|
||||
final User user = item.getStoryShare().getMedia().getUser();
|
||||
final String info = String.format(format, user != null ? user.getUsername() : "");
|
||||
final String info = resources.getString(format, user != null ? user.getUsername() : "");
|
||||
binding.shareInfo.setText(info);
|
||||
binding.text.setVisibility(View.GONE);
|
||||
binding.ivMediaPreview.setController(null);
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple
|
|||
final List<User> users) {
|
||||
final DirectItem replied = item.getRepliedToMessage();
|
||||
final DirectItemType itemType = replied.getItemType();
|
||||
final Resources resources = itemView.getResources();
|
||||
String text = null;
|
||||
String url = null;
|
||||
switch (itemType) {
|
||||
|
|
@ -246,7 +247,7 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple
|
|||
url = ResponseBodyUtils.getThumbUrl(replied.getVisualMedia().getMedia().getImageVersions2());
|
||||
break;
|
||||
case VOICE_MEDIA:
|
||||
text = "Voice message";
|
||||
text = resources.getString(R.string.voice_message);
|
||||
break;
|
||||
case MEDIA_SHARE:
|
||||
Media mediaShare = replied.getMediaShare();
|
||||
|
|
@ -285,7 +286,7 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple
|
|||
return;
|
||||
}
|
||||
setReplyGravity(messageDirection);
|
||||
final String info = setReplyInfo(item, replied, users);
|
||||
final String info = setReplyInfo(item, replied, users, resources);
|
||||
binding.replyInfo.setVisibility(View.VISIBLE);
|
||||
binding.replyInfo.setText(info);
|
||||
binding.quoteLine.setVisibility(View.VISIBLE);
|
||||
|
|
@ -298,7 +299,6 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple
|
|||
}
|
||||
binding.replyImage.setVisibility(View.GONE);
|
||||
final Drawable background = binding.replyText.getBackground().mutate();
|
||||
final Resources resources = itemView.getResources();
|
||||
background.setTint(replied.getUserId() != currentUser.getPk()
|
||||
? resources.getColor(R.color.grey_600)
|
||||
: resources.getColor(R.color.deep_purple_400));
|
||||
|
|
@ -309,30 +309,33 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple
|
|||
|
||||
private String setReplyInfo(final DirectItem item,
|
||||
final DirectItem replied,
|
||||
final List<User> users) {
|
||||
final List<User> users,
|
||||
final Resources resources) {
|
||||
final long repliedToUserId = replied.getUserId();
|
||||
if (repliedToUserId == item.getUserId() && item.getUserId() == currentUser.getPk()) {
|
||||
// User replied to own message
|
||||
return "You replied to yourself";
|
||||
return resources.getString(R.string.replied_to_yourself);
|
||||
}
|
||||
if (repliedToUserId == item.getUserId()) {
|
||||
// opposite user replied to their own message
|
||||
return "Replied to themself";
|
||||
return resources.getString(R.string.replied_to_themself);
|
||||
}
|
||||
final User user = getUser(repliedToUserId, users);
|
||||
final String repliedToUsername = user != null ? user.getUsername() : "";
|
||||
if (item.getUserId() == currentUser.getPk()) {
|
||||
return !thread.isGroup() ? "You replied" : String.format("You replied to %s", repliedToUsername);
|
||||
return thread.isGroup()
|
||||
? resources.getString(R.string.replied_you_group, repliedToUsername)
|
||||
: resources.getString(R.string.replied_you);
|
||||
}
|
||||
if (repliedToUserId == currentUser.getPk()) {
|
||||
return "Replied to you";
|
||||
return resources.getString(R.string.replied_to_you);
|
||||
}
|
||||
return String.format("Replied to %s", repliedToUsername);
|
||||
return resources.getString(R.string.replied_group, repliedToUsername);
|
||||
}
|
||||
|
||||
private void setForwardInfo(final MessageDirection direction) {
|
||||
binding.replyInfo.setVisibility(View.VISIBLE);
|
||||
binding.replyInfo.setText(direction == MessageDirection.OUTGOING ? "You forwarded a message" : "Forwarded a message");
|
||||
binding.replyInfo.setText(direction == MessageDirection.OUTGOING ? R.string.forward_outgoing : R.string.forward_incoming);
|
||||
}
|
||||
|
||||
private void setReplyGravity(final MessageDirection messageDirection) {
|
||||
|
|
|
|||
|
|
@ -115,19 +115,27 @@ public abstract class FeedItemViewHolder extends RecyclerView.ViewHolder {
|
|||
|
||||
private void setupLocation(@NonNull final Media media) {
|
||||
final Location location = media.getLocation();
|
||||
final String locationName = location.getName();
|
||||
if (TextUtils.isEmpty(locationName)) {
|
||||
if (location == null) {
|
||||
topBinding.location.setVisibility(View.GONE);
|
||||
topBinding.title.setLayoutParams(new RelativeLayout.LayoutParams(
|
||||
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT
|
||||
));
|
||||
} else {
|
||||
topBinding.location.setVisibility(View.VISIBLE);
|
||||
topBinding.location.setText(locationName);
|
||||
topBinding.title.setLayoutParams(new RelativeLayout.LayoutParams(
|
||||
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
topBinding.location.setOnClickListener(v -> feedItemCallback.onLocationClick(media));
|
||||
}
|
||||
else {
|
||||
final String locationName = location.getName();
|
||||
if (TextUtils.isEmpty(locationName)) {
|
||||
topBinding.location.setVisibility(View.GONE);
|
||||
topBinding.title.setLayoutParams(new RelativeLayout.LayoutParams(
|
||||
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT
|
||||
));
|
||||
} else {
|
||||
topBinding.location.setVisibility(View.VISIBLE);
|
||||
topBinding.location.setText(locationName);
|
||||
topBinding.title.setLayoutParams(new RelativeLayout.LayoutParams(
|
||||
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
topBinding.location.setOnClickListener(v -> feedItemCallback.onLocationClick(media));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,17 +94,12 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||
commentsViewModel.getList().postValue(list);
|
||||
}
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
stopCurrentExecutor();
|
||||
stopCurrentExecutor(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
try {
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
stopCurrentExecutor();
|
||||
}
|
||||
catch(Throwable e) {}
|
||||
stopCurrentExecutor(t);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -227,7 +222,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||
endCursor = null;
|
||||
lazyLoader.resetState();
|
||||
commentsViewModel.getList().postValue(Collections.emptyList());
|
||||
stopCurrentExecutor();
|
||||
stopCurrentExecutor(null);
|
||||
currentlyRunning = new CommentsFetcher(shortCode, "", fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +271,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||
endCursor = null;
|
||||
});
|
||||
binding.rvComments.addOnScrollListener(lazyLoader);
|
||||
stopCurrentExecutor();
|
||||
stopCurrentExecutor(null);
|
||||
onRefresh();
|
||||
}
|
||||
|
||||
|
|
@ -462,7 +457,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||
NavHostFragment.findNavController(this).navigate(action);
|
||||
}
|
||||
|
||||
private void stopCurrentExecutor() {
|
||||
private void stopCurrentExecutor(final Throwable t) {
|
||||
if (currentlyRunning != null) {
|
||||
try {
|
||||
currentlyRunning.cancel(true);
|
||||
|
|
@ -470,6 +465,13 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||
if (BuildConfig.DEBUG) Log.e(TAG, "", e);
|
||||
}
|
||||
}
|
||||
if (t != null) {
|
||||
try {
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
catch(Throwable e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
|||
|
|
@ -348,16 +348,17 @@ public final class FollowViewerFragment extends Fragment implements SwipeRefresh
|
|||
loading = false;
|
||||
final ArrayList<ExpandableGroup> groups = new ArrayList<>(1);
|
||||
|
||||
if (isCompare) {
|
||||
if (isCompare && followingModels != null && followersModels != null && allFollowing != null) {
|
||||
if (followingModels != null && followingModels.size() > 0)
|
||||
groups.add(new ExpandableGroup(resources.getString(R.string.followers_not_following, username), followingModels));
|
||||
if (followersModels != null && followersModels.size() > 0)
|
||||
groups.add(new ExpandableGroup(resources.getString(R.string.followers_not_follower, namePost), followersModels));
|
||||
if (allFollowing != null && allFollowing.size() > 0)
|
||||
groups.add(new ExpandableGroup(resources.getString(R.string.followers_both_following), allFollowing));
|
||||
} else {
|
||||
} else if (followModels != null) {
|
||||
groups.add(new ExpandableGroup(type, followModels));
|
||||
}
|
||||
else return;
|
||||
adapter = new FollowAdapter(clickListener, groups);
|
||||
adapter.toggleGroup(0);
|
||||
binding.rvFollow.setAdapter(adapter);
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||
private boolean hasStories = false;
|
||||
private boolean opening = false;
|
||||
private String hashtag;
|
||||
private HashtagModel hashtagModel;
|
||||
private HashtagModel hashtagModel = null;
|
||||
private ActionMode actionMode;
|
||||
private StoriesService storiesService;
|
||||
private AsyncTask<?, ?, ?> currentlyExecuting;
|
||||
|
|
@ -373,22 +373,12 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||
public void onResult(final HashtagModel result) {
|
||||
hashtagModel = result;
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (hashtagModel == null) {
|
||||
Toast.makeText(context, R.string.error_loading_hashtag, Toast.LENGTH_SHORT).show();
|
||||
binding.swipeRefreshLayout.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
setTitle();
|
||||
setHashtagDetails();
|
||||
setupPosts();
|
||||
fetchStories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
setHashtagDetails();
|
||||
}
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
|
@ -406,6 +396,17 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||
}
|
||||
|
||||
private void setHashtagDetails() {
|
||||
if (hashtagModel == null) {
|
||||
try {
|
||||
Toast.makeText(getContext(), R.string.error_loading_hashtag, Toast.LENGTH_SHORT).show();
|
||||
binding.swipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
return;
|
||||
}
|
||||
setTitle();
|
||||
setupPosts();
|
||||
fetchStories();
|
||||
if (isLoggedIn) {
|
||||
hashtagDetailsBinding.btnFollowTag.setVisibility(View.VISIBLE);
|
||||
hashtagDetailsBinding.btnFollowTag.setText(hashtagModel.getFollowing() ? R.string.unfollow : R.string.follow);
|
||||
|
|
|
|||
|
|
@ -87,12 +87,20 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
|
|||
private final ServiceCallback<ArchiveFetchResponse> cb = new ServiceCallback<ArchiveFetchResponse>() {
|
||||
@Override
|
||||
public void onSuccess(final ArchiveFetchResponse result) {
|
||||
endCursor = result.getNextCursor();
|
||||
final List<HighlightModel> models = archivesViewModel.getList().getValue();
|
||||
final List<HighlightModel> modelsCopy = models == null ? new ArrayList<>() : new ArrayList<>(models);
|
||||
modelsCopy.addAll(result.getResult());
|
||||
archivesViewModel.getList().postValue(modelsCopy);
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
if (result == null) {
|
||||
try {
|
||||
final Context context = getContext();
|
||||
Toast.makeText(context, R.string.empty_list, Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
else {
|
||||
endCursor = result.getNextCursor();
|
||||
final List<HighlightModel> models = archivesViewModel.getList().getValue();
|
||||
final List<HighlightModel> modelsCopy = models == null ? new ArrayList<>() : new ArrayList<>(models);
|
||||
modelsCopy.addAll(result.getResult());
|
||||
archivesViewModel.getList().postValue(modelsCopy);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -490,15 +490,21 @@ public class StoryViewerFragment extends Fragment {
|
|||
@Override
|
||||
public void onSuccess(final StoryStickerResponse result) {
|
||||
sticking = false;
|
||||
poll.setMyChoice(w);
|
||||
Toast.makeText(context, R.string.votef_story_poll, Toast.LENGTH_SHORT).show();
|
||||
try {
|
||||
poll.setMyChoice(w);
|
||||
Toast.makeText(context, R.string.votef_story_poll, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable t) {
|
||||
sticking = false;
|
||||
Log.e(TAG, "Error responding", t);
|
||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
try {
|
||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -525,14 +531,20 @@ public class StoryViewerFragment extends Fragment {
|
|||
@Override
|
||||
public void onSuccess(final StoryStickerResponse result) {
|
||||
sticking = false;
|
||||
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
|
||||
try {
|
||||
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable t) {
|
||||
sticking = false;
|
||||
Log.e(TAG, "Error responding", t);
|
||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
try {
|
||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
|
@ -565,15 +577,21 @@ public class StoryViewerFragment extends Fragment {
|
|||
@Override
|
||||
public void onSuccess(final StoryStickerResponse result) {
|
||||
sticking = false;
|
||||
quiz.setMyChoice(w);
|
||||
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
try {
|
||||
quiz.setMyChoice(w);
|
||||
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable t) {
|
||||
sticking = false;
|
||||
Log.e(TAG, "Error responding", t);
|
||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
try {
|
||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -631,15 +649,21 @@ public class StoryViewerFragment extends Fragment {
|
|||
@Override
|
||||
public void onSuccess(final StoryStickerResponse result) {
|
||||
sticking = false;
|
||||
slider.setMyChoice(sliderValue);
|
||||
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
|
||||
try {
|
||||
slider.setMyChoice(sliderValue);
|
||||
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable t) {
|
||||
sticking = false;
|
||||
Log.e(TAG, "Error responding", t);
|
||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
try {
|
||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
|
|
|||
|
|
@ -113,9 +113,6 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
|||
private static final int STORAGE_PERM_REQUEST_CODE = 8020;
|
||||
private static final int AUDIO_RECORD_PERM_REQUEST_CODE = 1000;
|
||||
private static final int CAMERA_REQUEST_CODE = 200;
|
||||
private static final String UPDATING_TITLE = "Updating...";
|
||||
private static final String MESSAGE_LABEL = "Message";
|
||||
private static final String HOLD_TO_RECORD_AUDIO_LABEL = "Press and hold to record audio";
|
||||
private static final String TRANSLATION_Y = "translationY";
|
||||
|
||||
private DirectItemsAdapter itemsAdapter;
|
||||
|
|
@ -596,7 +593,7 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
|||
}
|
||||
break;
|
||||
case LOADING:
|
||||
setTitle(UPDATING_TITLE);
|
||||
setTitle(getString(R.string.dms_thread_updating));
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
@ -932,7 +929,7 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
|||
if (inputMode != null && inputMode == 1) return;
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
tooltip.setText(HOLD_TO_RECORD_AUDIO_LABEL);
|
||||
tooltip.setText(R.string.dms_thread_audio_hint);
|
||||
setMicToSendIcon();
|
||||
binding.recordView.setMinMillis(1000);
|
||||
binding.recordView.setOnRecordListener(new RecordView.OnRecordListener() {
|
||||
|
|
@ -981,7 +978,7 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
|||
}
|
||||
});
|
||||
binding.recordView.setOnBasketAnimationEndListener(() -> {
|
||||
binding.input.setHint(MESSAGE_LABEL);
|
||||
binding.input.setHint(R.string.dms_thread_message_hint);
|
||||
binding.gallery.setVisibility(View.VISIBLE);
|
||||
binding.camera.setVisibility(View.VISIBLE);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import javax.security.cert.CertificateException;
|
||||
import javax.security.cert.X509Certificate;
|
||||
|
|
@ -103,10 +103,18 @@ public final class FlavorTown {
|
|||
|
||||
public static void changelogCheck(@NonNull final Context context) {
|
||||
if (settingsHelper.getInteger(Constants.PREV_INSTALL_VERSION) < BuildConfig.VERSION_CODE) {
|
||||
final int appUaCode = settingsHelper.getInteger(Constants.APP_UA_CODE);
|
||||
int appUaCode = settingsHelper.getInteger(Constants.APP_UA_CODE);
|
||||
int browserUaCode = settingsHelper.getInteger(Constants.BROWSER_UA_CODE);
|
||||
if (browserUaCode == -1) {
|
||||
browserUaCode = ThreadLocalRandom.current().nextInt(0, UserAgentUtils.browsers.length);
|
||||
settingsHelper.putInteger(Constants.BROWSER_UA_CODE, browserUaCode);
|
||||
}
|
||||
if (appUaCode == -1) {
|
||||
appUaCode = ThreadLocalRandom.current().nextInt(0, UserAgentUtils.devices.length);
|
||||
settingsHelper.putInteger(Constants.APP_UA_CODE, appUaCode);
|
||||
}
|
||||
final String appUa = UserAgentUtils.generateAppUA(appUaCode, LocaleUtils.getCurrentLocale().getLanguage());
|
||||
settingsHelper.putString(Constants.APP_UA, appUa);
|
||||
final int browserUaCode = settingsHelper.getInteger(Constants.BROWSER_UA_CODE);
|
||||
final String browserUa = UserAgentUtils.generateBrowserUA(browserUaCode);
|
||||
settingsHelper.putString(Constants.BROWSER_UA, browserUa);
|
||||
Toast.makeText(context, R.string.updated, Toast.LENGTH_SHORT).show();
|
||||
|
|
|
|||
|
|
@ -57,26 +57,30 @@ public final class LocaleUtils {
|
|||
if (TextUtils.isEmpty(appLanguageSettings)) return null;
|
||||
|
||||
final int appLanguageIndex = Integer.parseInt(appLanguageSettings);
|
||||
if (appLanguageIndex == 1) return "en";
|
||||
if (appLanguageIndex == 2) return "fr";
|
||||
if (appLanguageIndex == 3) return "es";
|
||||
if (appLanguageIndex == 4) return "zh_CN";
|
||||
if (appLanguageIndex == 5) return "in";
|
||||
if (appLanguageIndex == 6) return "it";
|
||||
if (appLanguageIndex == 7) return "de";
|
||||
if (appLanguageIndex == 8) return "pl";
|
||||
if (appLanguageIndex == 9) return "tr";
|
||||
if (appLanguageIndex == 10) return "pt";
|
||||
if (appLanguageIndex == 11) return "fa";
|
||||
if (appLanguageIndex == 12) return "mk";
|
||||
if (appLanguageIndex == 13) return "vi";
|
||||
if (appLanguageIndex == 14) return "zh_TW";
|
||||
if (appLanguageIndex == 15) return "ca";
|
||||
if (appLanguageIndex == 16) return "ru";
|
||||
if (appLanguageIndex == 17) return "hi";
|
||||
if (appLanguageIndex == 18) return "nl";
|
||||
if (appLanguageIndex == 19) return "sk";
|
||||
if (appLanguageIndex == 20) return "ja";
|
||||
switch (appLanguageIndex) {
|
||||
case 1: return "en";
|
||||
case 2: return "fr";
|
||||
case 3: return "es";
|
||||
case 4: return "zh_CN";
|
||||
case 5: return "in";
|
||||
case 6: return "it";
|
||||
case 7: return "de";
|
||||
case 8: return "pl";
|
||||
case 9: return "tr";
|
||||
case 10: return "pt";
|
||||
case 11: return "fa";
|
||||
case 12: return "mk";
|
||||
case 13: return "vi";
|
||||
case 14: return "zh_TW";
|
||||
case 15: return "ca";
|
||||
case 16: return "ru";
|
||||
case 17: return "hi";
|
||||
case 18: return "nl";
|
||||
case 19: return "sk";
|
||||
case 20: return "ja";
|
||||
case 21: return "el";
|
||||
case 22: return "eu";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ public class UserAgentUtils {
|
|||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15"
|
||||
};
|
||||
// use APKpure, assume x86
|
||||
private static final String igVersion = "169.3.0.30.135";
|
||||
private static final String igVersionCode = "264009054";
|
||||
private static final String igVersion = "175.1.0.25.119";
|
||||
private static final String igVersionCode = "273907115";
|
||||
// only pick the ones that has width 1440 for maximum download quality
|
||||
public static final String[] devices = {
|
||||
// https://github.com/dilame/instagram-private-api/blob/master/src/samples/devices.json
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ public class DirectMessagesService extends BaseService {
|
|||
public Call<DirectInboxResponse> fetchPendingInbox(final String cursor, final long seqId) {
|
||||
final ImmutableMap.Builder<String, Object> queryMapBuilder = ImmutableMap.<String, Object>builder()
|
||||
.put("visual_message_return_type", "unseen")
|
||||
.put("thread_message_limit", 10)
|
||||
.put("thread_message_limit", 20)
|
||||
.put("persistentBadging", true)
|
||||
.put("limit", 10);
|
||||
if (!TextUtils.isEmpty(cursor)) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import awais.instagrabber.models.FeedStoryModel;
|
||||
|
|
@ -276,7 +275,6 @@ public class StoriesService extends BaseService {
|
|||
form.put("include_suggested_highlights", "false");
|
||||
form.put("is_in_archive_home", "true");
|
||||
form.put("include_cover", "1");
|
||||
form.put("timezone_offset", String.valueOf((float) TimeZone.getDefault().getRawOffset() / 1000));
|
||||
if (!TextUtils.isEmpty(maxId)) {
|
||||
form.put("max_id", maxId); // NOT TESTED
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue