mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-12-23 05:16:58 +00:00
v16.6-a3: Invite/kick actions now visible, preparations on message actions
This commit is contained in:
parent
d523a1e22c
commit
f85d438066
@ -4,6 +4,7 @@ import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@ -18,17 +19,25 @@ import java.util.List;
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.adapters.MessageItemsAdapter;
|
||||
import awais.instagrabber.asyncs.direct_messages.UserInboxFetcher;
|
||||
import awais.instagrabber.asyncs.UsernameFetcher;
|
||||
import awais.instagrabber.customviews.helpers.RecyclerLazyLoader;
|
||||
import awais.instagrabber.databinding.ActivityDmsBinding;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.models.PostModel;
|
||||
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.InboxThreadModel;
|
||||
import awais.instagrabber.models.enums.DirectItemType;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.models.enums.UserInboxDirection;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
|
||||
public final class DirectMessagesUserInbox extends AppCompatActivity {
|
||||
private DirectItemModel directItemModel;
|
||||
private final ProfileModel myProfileHolder = new ProfileModel(false, false, null, null, null, null, null, null, null, 0, 0, 0);
|
||||
private final ArrayList<ProfileModel> users = new ArrayList<>();
|
||||
private final ArrayList<DirectItemModel> directItemModels = new ArrayList<>();
|
||||
private final FetchListener<InboxThreadModel> fetchListener = new FetchListener<InboxThreadModel>() {
|
||||
@ -90,12 +99,58 @@ public final class DirectMessagesUserInbox extends AppCompatActivity {
|
||||
|
||||
dmsBinding.rvDirectMessages.setAdapter(messageItemsAdapter = new MessageItemsAdapter(directItemModels, users, v -> {
|
||||
// todo do something with clicked message
|
||||
Log.d("AWAISKING_APP", "--> " + v.getTag());
|
||||
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 STORY_SHARE:
|
||||
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()
|
||||
))
|
||||
);
|
||||
break;*/
|
||||
case TEXT:
|
||||
searchUsername(username);
|
||||
}
|
||||
|
||||
/*
|
||||
startActivity(new Intent(this, PostViewer.class)
|
||||
.putExtra(Constants.EXTRAS_POST, new PostModel(tag.toString())));
|
||||
*/
|
||||
}
|
||||
}, (view, text, isHashtag) -> {
|
||||
// todo mention click stuff
|
||||
|
||||
}));
|
||||
|
||||
new UserInboxFetcher(threadModel.getThreadId(), UserInboxDirection.OLDER, null, fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ProfileModel getUser(final long userId) {
|
||||
if (users != null) {
|
||||
for (final ProfileModel user : users)
|
||||
if (Long.toString(userId).equals(user.getId())) return user;
|
||||
return myProfileHolder;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,16 @@
|
||||
package awais.instagrabber.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.text.Spanned;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -20,6 +23,7 @@ import com.bumptech.glide.RequestManager;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.activities.Main;
|
||||
import awais.instagrabber.adapters.viewholder.directmessages.TextMessageViewHolder;
|
||||
import awais.instagrabber.interfaces.MentionClickListener;
|
||||
import awais.instagrabber.models.ProfileModel;
|
||||
@ -30,6 +34,7 @@ import awais.instagrabber.models.enums.DirectItemType;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.models.enums.RavenExpiringMediaType;
|
||||
import awais.instagrabber.models.enums.RavenMediaViewType;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
|
||||
import static awais.instagrabber.models.direct_messages.DirectItemModel.DirectItemLinkContext;
|
||||
@ -163,6 +168,10 @@ public final class MessageItemsAdapter extends RecyclerView.Adapter<TextMessageV
|
||||
else holder.tvMessage.setText(text);
|
||||
|
||||
holder.tvMessage.setVisibility(View.VISIBLE);
|
||||
holder.tvMessage.setOnClickListener(v -> {
|
||||
Utils.copyText(v.getContext(), holder.tvMessage.getText());
|
||||
Toast.makeText(v.getContext(), R.string.clipboard_copied, Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
break;
|
||||
|
||||
case LINK: {
|
||||
@ -351,7 +360,14 @@ public final class MessageItemsAdapter extends RecyclerView.Adapter<TextMessageV
|
||||
case VIDEO_CALL_EVENT: {
|
||||
// todo add call event info
|
||||
holder.tvMessage.setVisibility(View.VISIBLE);
|
||||
holder.itemView.setBackgroundColor(0xFF_1F90E6); // blue bitch
|
||||
holder.itemView.setBackgroundColor(0xFF_1F90E6);
|
||||
}
|
||||
break;
|
||||
|
||||
case ACTION_LOG: {
|
||||
text = directItemModel.getActionLogModel().getDescription();
|
||||
holder.tvMessage.setText(HtmlCompat.fromHtml("<small>"+text+"</small>", 63));
|
||||
holder.tvMessage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public final class AboutDialog extends BottomSheetDialogFragment {
|
||||
if (!Utils.isEmpty(Utils.telegramPackage))
|
||||
intent.setPackage(Utils.telegramPackage);
|
||||
} else
|
||||
intent.setData(Uri.parse("https://gitlab.com/AwaisKing/instagrabber/"));
|
||||
intent.setData(Uri.parse("https://github.com/austinhuang0131/instagrabber/"));
|
||||
startActivity(intent);
|
||||
};
|
||||
btnProject.setOnClickListener(onClickListener);
|
||||
|
@ -291,6 +291,7 @@ public final class DirectItemModel implements Serializable, Comparable<DirectIte
|
||||
public final static class DirectItemReelShareModel implements Serializable {
|
||||
private final boolean isReelPersisted;
|
||||
private final long reelOwnerId;
|
||||
private final String reelOwnerName;
|
||||
private final String text;
|
||||
private final String type;
|
||||
private final String reelType;
|
||||
@ -298,10 +299,12 @@ public final class DirectItemModel implements Serializable, Comparable<DirectIte
|
||||
private final String reelId;
|
||||
private final DirectItemMediaModel media;
|
||||
|
||||
public DirectItemReelShareModel(final boolean isReelPersisted, final long reelOwnerId, final String text, final String type,
|
||||
final String reelType, final String reelName, final String reelId, final DirectItemMediaModel media) {
|
||||
public DirectItemReelShareModel(final boolean isReelPersisted, final long reelOwnerId, final String reelOwnerName,
|
||||
final String text, final String type, final String reelType, final String reelName,
|
||||
final String reelId, final DirectItemMediaModel media) {
|
||||
this.isReelPersisted = isReelPersisted;
|
||||
this.reelOwnerId = reelOwnerId;
|
||||
this.reelOwnerName = reelOwnerName;
|
||||
this.text = text;
|
||||
this.type = type;
|
||||
this.reelType = reelType;
|
||||
@ -318,6 +321,8 @@ public final class DirectItemModel implements Serializable, Comparable<DirectIte
|
||||
return reelOwnerId;
|
||||
}
|
||||
|
||||
public String getReelOwnerName() { return reelOwnerName; }
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
@ -346,17 +351,18 @@ public final class DirectItemModel implements Serializable, Comparable<DirectIte
|
||||
public final static class DirectItemMediaModel implements Serializable {
|
||||
private final MediaItemType mediaType;
|
||||
private final long expiringAt, pk;
|
||||
private final String id, thumbUrl;
|
||||
private final String id, thumbUrl, code;
|
||||
private final ProfileModel user;
|
||||
|
||||
public DirectItemMediaModel(final MediaItemType mediaType, final long expiringAt, final long pk, final String id,
|
||||
final String thumbUrl, final ProfileModel user) {
|
||||
final String thumbUrl, final ProfileModel user, final String code) {
|
||||
this.mediaType = mediaType;
|
||||
this.expiringAt = expiringAt;
|
||||
this.pk = pk;
|
||||
this.id = id;
|
||||
this.thumbUrl = thumbUrl;
|
||||
this.user = user;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public MediaItemType getMediaType() {
|
||||
@ -375,6 +381,10 @@ public final class DirectItemModel implements Serializable, Comparable<DirectIte
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public ProfileModel getUser() {
|
||||
return user;
|
||||
}
|
||||
|
@ -384,7 +384,8 @@ public final class Utils {
|
||||
mediaObj.optLong("pk"),
|
||||
id,
|
||||
getThumbnailUrl(mediaObj, mediaType),
|
||||
user);
|
||||
user,
|
||||
mediaObj.optString("code"));
|
||||
}
|
||||
return mediaModel;
|
||||
}
|
||||
@ -527,6 +528,7 @@ public final class Utils {
|
||||
reelShareModel = new DirectItemReelShareModel(
|
||||
reelShare.optBoolean("is_reel_persisted"),
|
||||
reelShare.getLong("reel_owner_id"),
|
||||
reelShare.getJSONObject("media").getJSONObject("user").getString("username"),
|
||||
reelShare.getString("text"),
|
||||
reelShare.getString("type"),
|
||||
reelShare.getString("reel_type"),
|
||||
@ -616,9 +618,15 @@ public final class Utils {
|
||||
// prevents empty viewholders when in thread view mode
|
||||
continue;
|
||||
final JSONObject actionLog = itemObject.getJSONObject("action_log");
|
||||
actionLogModel = new DirectItemActionLogModel(actionLog.getString("description")
|
||||
// todo add bold , text_attributes objects [find out how tf to implement them]
|
||||
);
|
||||
String desc = actionLog.getString("description");
|
||||
JSONArray bold = actionLog.getJSONArray("bold");
|
||||
for (int q=0; q < bold.length(); ++q) {
|
||||
JSONObject boldItem = bold.getJSONObject(q);
|
||||
desc = desc.substring(0, boldItem.getInt("start") + q*7) + "<b>"
|
||||
+ desc.substring(boldItem.getInt("start") + q*7, boldItem.getInt("end") + q*7)
|
||||
+ "</b>" + desc.substring(boldItem.getInt("end") + q*7, desc.length());
|
||||
}
|
||||
actionLogModel = new DirectItemActionLogModel(desc);
|
||||
break;
|
||||
|
||||
case MEDIA_SHARE:
|
||||
@ -642,6 +650,7 @@ public final class Utils {
|
||||
reelShareModel = new DirectItemReelShareModel(
|
||||
storyShare.optBoolean("is_reel_persisted"),
|
||||
storyShare.getJSONObject("media").getJSONObject("user").getLong("pk"),
|
||||
storyShare.getJSONObject("media").getJSONObject("user").getString("username"),
|
||||
storyShare.getString("text"),
|
||||
storyShare.getString("story_share_type"),
|
||||
storyShare.getString("reel_type"),
|
||||
|
Loading…
Reference in New Issue
Block a user