mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 06:37:30 +00:00
optimize imports, add DM settings (init), add notification setting
This commit is contained in:
parent
ca0d89fdb6
commit
4a439f74eb
@ -33,7 +33,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
@ -9,10 +9,10 @@ import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.util.Log;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -259,7 +259,7 @@ public final class CommentsViewer extends BaseLanguageActivity implements SwipeR
|
||||
(commentModel == null ? "" : commentModel.getId());
|
||||
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
urlConnection.setRequestProperty("Content-Length", "" +
|
||||
Integer.toString(urlParameters.getBytes().length));
|
||||
urlParameters.getBytes().length);
|
||||
urlConnection.setDoOutput(true);
|
||||
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
|
||||
wr.writeBytes(urlParameters);
|
||||
|
@ -1,10 +1,12 @@
|
||||
package awais.instagrabber.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.navigation.NavController;
|
||||
@ -20,6 +22,7 @@ import awais.instagrabber.fragments.directmessages.DirectMessageThreadFragmentAr
|
||||
public class DirectMessagesActivity extends BaseLanguageActivity implements NavController.OnDestinationChangedListener {
|
||||
|
||||
private TextView toolbarTitle;
|
||||
private AppCompatImageView infoButton;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -33,6 +36,8 @@ public class DirectMessagesActivity extends BaseLanguageActivity implements NavC
|
||||
final Toolbar toolbar = binding.toolbar;
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
infoButton = binding.dmInfo;
|
||||
|
||||
final NavController navController = Navigation.findNavController(this, R.id.direct_messages_nav_host_fragment);
|
||||
navController.addOnDestinationChangedListener(this);
|
||||
final AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build();
|
||||
@ -46,6 +51,7 @@ public class DirectMessagesActivity extends BaseLanguageActivity implements NavC
|
||||
switch (destination.getId()) {
|
||||
case R.id.directMessagesInboxFragment:
|
||||
setToolbarTitle(R.string.action_dms);
|
||||
infoButton.setVisibility(View.GONE);
|
||||
return;
|
||||
case R.id.directMessagesThreadFragment:
|
||||
if (arguments == null) {
|
||||
@ -53,6 +59,14 @@ public class DirectMessagesActivity extends BaseLanguageActivity implements NavC
|
||||
}
|
||||
final String title = DirectMessageThreadFragmentArgs.fromBundle(arguments).getTitle();
|
||||
setToolbarTitle(title);
|
||||
infoButton.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
case R.id.directMessagesSettingsFragment:
|
||||
if (arguments == null) {
|
||||
return;
|
||||
}
|
||||
setToolbarTitle(R.string.action_settings);
|
||||
infoButton.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,14 @@ package awais.instagrabber.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package awais.instagrabber.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -71,6 +71,7 @@ import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
public final class Main extends BaseLanguageActivity {
|
||||
private static final int INITIAL_DELAY_MILLIS = 200;
|
||||
private static final int DELAY_MILLIS = 60000;
|
||||
public static FetchListener<String> scanHack;
|
||||
public static ItemGetter itemGetter;
|
||||
// -------- items --------
|
||||
@ -263,9 +264,7 @@ public final class Main extends BaseLanguageActivity {
|
||||
runnable = () -> {
|
||||
final GetActivityAsyncTask activityAsyncTask = new GetActivityAsyncTask(uid, cookie, result -> {
|
||||
if (result == null) {
|
||||
if (!Utils.isEmpty(cookie)) {
|
||||
Toast.makeText(Main.this, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
Toast.makeText(Main.this, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (notificationManager == null) {
|
||||
@ -304,8 +303,8 @@ public final class Main extends BaseLanguageActivity {
|
||||
notificationManager.cancel(1800000000);
|
||||
notificationManager.notify(1800000000, notification);
|
||||
});
|
||||
activityAsyncTask.execute();
|
||||
handler.postDelayed(runnable, 60000);
|
||||
if (!Utils.isEmpty(cookie) && Utils.settingsHelper.getBoolean(Constants.CHECK_ACTIVITY)) activityAsyncTask.execute();
|
||||
handler.postDelayed(runnable, DELAY_MILLIS);
|
||||
};
|
||||
handler.postDelayed(runnable, INITIAL_DELAY_MILLIS);
|
||||
}
|
||||
|
@ -9,8 +9,6 @@ import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Toast;
|
||||
@ -28,10 +26,9 @@ import awais.instagrabber.asyncs.NotificationsFetcher;
|
||||
import awais.instagrabber.databinding.ActivityNotificationBinding;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.interfaces.MentionClickListener;
|
||||
import awais.instagrabber.models.enums.NotificationType;
|
||||
import awais.instagrabber.models.NotificationModel;
|
||||
import awais.instagrabber.models.PostModel;
|
||||
import awais.instagrabber.models.ProfileModel;
|
||||
import awais.instagrabber.models.enums.NotificationType;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
|
||||
|
@ -44,6 +44,8 @@ import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
@ -51,8 +53,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.adapters.PostsMediaAdapter;
|
||||
import awais.instagrabber.asyncs.PostFetcher;
|
||||
@ -244,7 +244,7 @@ public final class PostViewer extends BaseLanguageActivity {
|
||||
}
|
||||
|
||||
setupPostInfoBar("@"+viewerPostModel.getUsername(), viewerPostModel.getItemType(),
|
||||
viewerPostModel.getLocation() == null ? null : viewerPostModel.getLocation());
|
||||
viewerPostModel.getLocation());
|
||||
|
||||
postCaption = postModel.getPostCaption();
|
||||
viewerCaptionParent.setVisibility(View.VISIBLE);
|
||||
|
@ -16,15 +16,10 @@ import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -32,8 +27,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.core.widget.ImageViewCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
@ -54,12 +47,10 @@ import awais.instagrabber.asyncs.LocationFetcher;
|
||||
import awais.instagrabber.asyncs.PostsFetcher;
|
||||
import awais.instagrabber.asyncs.ProfileFetcher;
|
||||
import awais.instagrabber.asyncs.i.iStoryStatusFetcher;
|
||||
import awais.instagrabber.customviews.MouseDrawer;
|
||||
import awais.instagrabber.customviews.RamboTextView;
|
||||
import awais.instagrabber.customviews.helpers.GridAutofitLayoutManager;
|
||||
import awais.instagrabber.customviews.helpers.GridSpacingItemDecoration;
|
||||
import awais.instagrabber.customviews.helpers.RecyclerLazyLoader;
|
||||
import awais.instagrabber.customviews.helpers.VideoAwareRecyclerScroller;
|
||||
import awais.instagrabber.databinding.ActivityProfileBinding;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.interfaces.MentionClickListener;
|
||||
@ -78,7 +69,6 @@ import awais.instagrabber.utils.Utils;
|
||||
import awaisomereport.LogCollector;
|
||||
|
||||
import static awais.instagrabber.utils.Constants.AUTOLOAD_POSTS;
|
||||
import static awais.instagrabber.utils.Constants.BOTTOM_TOOLBAR;
|
||||
import static awais.instagrabber.utils.Utils.logCollector;
|
||||
|
||||
public final class ProfileViewer extends BaseLanguageActivity implements SwipeRefreshLayout.OnRefreshListener {
|
||||
|
@ -10,7 +10,6 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.Menu;
|
||||
@ -18,7 +17,6 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -41,17 +39,16 @@ import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.adapters.StoriesAdapter;
|
||||
@ -62,12 +59,12 @@ import awais.instagrabber.customviews.helpers.SwipeGestureListener;
|
||||
import awais.instagrabber.databinding.ActivityStoryViewerBinding;
|
||||
import awais.instagrabber.interfaces.SwipeEvent;
|
||||
import awais.instagrabber.models.FeedStoryModel;
|
||||
import awais.instagrabber.models.stickers.PollModel;
|
||||
import awais.instagrabber.models.stickers.QuestionModel;
|
||||
import awais.instagrabber.models.stickers.QuizModel;
|
||||
import awais.instagrabber.models.PostModel;
|
||||
import awais.instagrabber.models.StoryModel;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.models.stickers.PollModel;
|
||||
import awais.instagrabber.models.stickers.QuestionModel;
|
||||
import awais.instagrabber.models.stickers.QuizModel;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awaisomereport.LogCollector;
|
||||
@ -285,7 +282,7 @@ public final class StoryViewer extends BaseLanguageActivity {
|
||||
quiz = (QuizModel) quiz;
|
||||
String[] choices = new String[quiz.getChoices().length];
|
||||
for (int q = 0; q < choices.length; ++q) {
|
||||
choices[q] = (quiz.getMyChoice() == q ? "√ " :"") + quiz.getChoices()[q]+ " (" + String.valueOf(quiz.getCounts()[q]) + ")";
|
||||
choices[q] = (quiz.getMyChoice() == q ? "√ " :"") + quiz.getChoices()[q]+ " (" + quiz.getCounts()[q] + ")";
|
||||
}
|
||||
new AlertDialog.Builder(this).setTitle(quiz.getMyChoice() > -1 ? getString(R.string.story_quizzed) : quiz.getQuestion())
|
||||
.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, choices), (d,w) -> {
|
||||
@ -700,8 +697,8 @@ final String url = "https://i.instagram.com/api/v1/media/"+currentStory.getStory
|
||||
String urlParameters = "reelMediaId="+currentStory.getStoryMediaId().split("_")[0]
|
||||
+"&reelMediaOwnerId="+currentStory.getUserId()
|
||||
+"&reelId="+currentStory.getUserId()
|
||||
+"&reelMediaTakenAt="+String.valueOf(currentStory.getTimestamp())
|
||||
+"&viewSeenAt="+String.valueOf(currentStory.getTimestamp());
|
||||
+"&reelMediaTakenAt="+ currentStory.getTimestamp()
|
||||
+"&viewSeenAt="+ currentStory.getTimestamp();
|
||||
final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
|
||||
urlConnection.setRequestMethod("POST");
|
||||
urlConnection.setUseCaches(false);
|
||||
@ -738,7 +735,7 @@ final String url = "https://i.instagram.com/api/v1/media/"+currentStory.getStory
|
||||
+"\",\"recipient_users\":\"["+currentStory.getUserId() // <- string of array of number (not joking)
|
||||
+"]\"}");
|
||||
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
urlConnection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
|
||||
urlConnection.setRequestProperty("Content-Length", "" + urlParameters.getBytes().length);
|
||||
urlConnection.setDoOutput(true);
|
||||
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
|
||||
wr.writeBytes(urlParameters);
|
||||
|
@ -0,0 +1,55 @@
|
||||
package awais.instagrabber.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.adapters.viewholder.FollowsViewHolder;
|
||||
import awais.instagrabber.models.ProfileModel;
|
||||
|
||||
public final class DirectMessageMembersAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private final ProfileModel[] profileModels;
|
||||
private final View.OnClickListener onClickListener;
|
||||
private final LayoutInflater layoutInflater;
|
||||
|
||||
public DirectMessageMembersAdapter(final ProfileModel[] profileModels, final Context context, final View.OnClickListener onClickListener) {
|
||||
this.profileModels = profileModels;
|
||||
this.layoutInflater = LayoutInflater.from(context);
|
||||
this.onClickListener = onClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull final ViewGroup parent, final int viewType) {
|
||||
final View view = layoutInflater.inflate(R.layout.item_follow, parent, false);
|
||||
return new FollowsViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) {
|
||||
final ProfileModel model = profileModels[position];
|
||||
|
||||
final FollowsViewHolder followHolder = (FollowsViewHolder) holder;
|
||||
if (model != null) {
|
||||
followHolder.itemView.setTag(model);
|
||||
followHolder.itemView.setOnClickListener(onClickListener);
|
||||
|
||||
followHolder.tvUsername.setText(model.getUsername());
|
||||
followHolder.tvFullName.setText(model.getName());
|
||||
|
||||
Glide.with(layoutInflater.getContext()).load(model.getSdProfilePic()).into(followHolder.profileImage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return profileModels.length;
|
||||
}
|
||||
}
|
@ -5,13 +5,10 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -35,11 +32,11 @@ import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
||||
import com.google.android.exoplayer2.ui.PlayerView;
|
||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.activities.CommentsViewer;
|
||||
|
@ -1,28 +1,22 @@
|
||||
package awais.instagrabber.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
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;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.adapters.viewholder.NotificationViewHolder;
|
||||
import awais.instagrabber.interfaces.MentionClickListener;
|
||||
import awais.instagrabber.models.enums.NotificationType;
|
||||
import awais.instagrabber.models.NotificationModel;
|
||||
import awais.instagrabber.utils.LocaleUtils;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.models.enums.NotificationType;
|
||||
|
||||
public final class NotificationsAdapter extends RecyclerView.Adapter<NotificationViewHolder> {
|
||||
private final View.OnClickListener onClickListener;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package awais.instagrabber.adapters;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -17,18 +16,12 @@ import com.bumptech.glide.load.engine.GlideException;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.adapters.viewholder.PostViewHolder;
|
||||
import awais.instagrabber.models.PostModel;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awaisomereport.LogCollector;
|
||||
|
||||
import static awais.instagrabber.utils.Utils.logCollector;
|
||||
|
||||
public final class PostsAdapter extends RecyclerView.Adapter<PostViewHolder> {
|
||||
private final ArrayList<PostModel> postModels;
|
||||
|
@ -2,7 +2,6 @@ package awais.instagrabber.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -9,7 +9,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.adapters.CommentsAdapter;
|
||||
import awais.instagrabber.customviews.RamboTextView;
|
||||
import awais.instagrabber.interfaces.MentionClickListener;
|
||||
import awais.instagrabber.models.NotificationModel;
|
||||
|
@ -7,7 +7,6 @@ import androidx.core.text.HtmlCompat;
|
||||
|
||||
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
||||
import awais.instagrabber.databinding.LayoutDmTextBinding;
|
||||
import awais.instagrabber.models.ProfileModel;
|
||||
import awais.instagrabber.models.direct_messages.DirectItemModel;
|
||||
|
||||
import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_COMPACT;
|
||||
|
@ -7,7 +7,6 @@ import androidx.core.text.HtmlCompat;
|
||||
|
||||
import awais.instagrabber.databinding.LayoutDmBaseBinding;
|
||||
import awais.instagrabber.databinding.LayoutDmTextBinding;
|
||||
import awais.instagrabber.models.ProfileModel;
|
||||
import awais.instagrabber.models.direct_messages.DirectItemModel;
|
||||
|
||||
import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_COMPACT;
|
||||
|
@ -14,10 +14,10 @@ import java.util.ArrayList;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.models.FeedModel;
|
||||
import awais.instagrabber.models.ProfileModel;
|
||||
import awais.instagrabber.models.ViewerPostModel;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awaisomereport.LogCollector;
|
||||
|
@ -13,8 +13,8 @@ import java.net.URL;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.models.ViewerPostModel;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awaisomereport.LogCollector;
|
||||
|
@ -13,8 +13,8 @@ import java.net.URL;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.models.PostModel;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awaisomereport.LogCollector;
|
||||
|
@ -2,7 +2,6 @@ package awais.instagrabber.asyncs;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Jsoup;
|
||||
|
@ -47,7 +47,7 @@ public final class DirectMessageInboxThreadFetcher extends AsyncTask<Void, Void,
|
||||
InboxThreadModel result = null;
|
||||
final Map<String, String> queryParamsMap = new HashMap<>();
|
||||
queryParamsMap.put("visual_message_return_type", "unseen");
|
||||
queryParamsMap.put("direction", direction.getValue());
|
||||
if (direction != null) queryParamsMap.put("direction", direction.getValue());
|
||||
if (!Utils.isEmpty(endCursor)) {
|
||||
queryParamsMap.put("cursor", endCursor);
|
||||
}
|
||||
|
@ -11,11 +11,11 @@ import java.net.URL;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.models.StoryModel;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.models.stickers.PollModel;
|
||||
import awais.instagrabber.models.stickers.QuestionModel;
|
||||
import awais.instagrabber.models.stickers.QuizModel;
|
||||
import awais.instagrabber.models.StoryModel;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awaisomereport.LogCollector;
|
||||
@ -149,7 +149,7 @@ public final class iStoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[
|
||||
if (locations != null) {
|
||||
for (int h = 0; h < locations.length(); ++h) {
|
||||
mentions[h + (hashtags == null ? 0 : hashtags.length()) + (atmarks == null ? 0 : atmarks.length())] =
|
||||
String.valueOf(locations.getJSONObject(h).getJSONObject("location").getLong("pk"))
|
||||
locations.getJSONObject(h).getJSONObject("location").getLong("pk")
|
||||
+"/ ("+locations.getJSONObject(h).getJSONObject("location").getString("short_name")+")";
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package awais.instagrabber.asyncs.i;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -6,7 +6,6 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -39,6 +39,7 @@ import static awais.instagrabber.utils.Constants.APP_THEME;
|
||||
import static awais.instagrabber.utils.Constants.AUTOLOAD_POSTS;
|
||||
import static awais.instagrabber.utils.Constants.AUTOPLAY_VIDEOS;
|
||||
import static awais.instagrabber.utils.Constants.BOTTOM_TOOLBAR;
|
||||
import static awais.instagrabber.utils.Constants.CHECK_ACTIVITY;
|
||||
import static awais.instagrabber.utils.Constants.COOKIE;
|
||||
import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER;
|
||||
import static awais.instagrabber.utils.Constants.FOLDER_PATH;
|
||||
@ -132,6 +133,7 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
|
||||
final AppCompatCheckBox cbAutoplayVideos = contentView.findViewById(R.id.cbAutoplayVideos);
|
||||
final AppCompatCheckBox cbDownloadUsername = contentView.findViewById(R.id.cbDownloadUsername);
|
||||
final AppCompatCheckBox cbMarkAsSeen = contentView.findViewById(R.id.cbMarkAsSeen);
|
||||
final AppCompatCheckBox cbActivity = contentView.findViewById(R.id.cbActivity);
|
||||
final AppCompatCheckBox cbInstadp = contentView.findViewById(R.id.cbInstadp);
|
||||
final AppCompatCheckBox cbStoriesig = contentView.findViewById(R.id.cbStoriesig);
|
||||
final AppCompatCheckBox cbAmoledTheme = contentView.findViewById(R.id.cbAmoledTheme);
|
||||
@ -144,6 +146,7 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
|
||||
cbInstadp.setChecked(settingsHelper.getBoolean(INSTADP));
|
||||
cbStoriesig.setChecked(settingsHelper.getBoolean(STORIESIG));
|
||||
cbAmoledTheme.setChecked(settingsHelper.getBoolean(AMOLED_THEME));
|
||||
cbActivity.setChecked(settingsHelper.getBoolean(CHECK_ACTIVITY));
|
||||
cbAutoloadPosts.setChecked(settingsHelper.getBoolean(AUTOLOAD_POSTS));
|
||||
cbDownloadUsername.setChecked(settingsHelper.getBoolean(DOWNLOAD_USER_FOLDER));
|
||||
|
||||
@ -157,6 +160,7 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
|
||||
setupListener(cbInstadp);
|
||||
setupListener(cbStoriesig);
|
||||
setupListener(cbAmoledTheme);
|
||||
setupListener(cbActivity);
|
||||
|
||||
btnSaveTo.setEnabled(cbSaveTo.isChecked());
|
||||
|
||||
@ -228,6 +232,7 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
|
||||
else if (id == R.id.cbInstadp) settingsHelper.putBoolean(INSTADP, checked);
|
||||
else if (id == R.id.cbStoriesig) settingsHelper.putBoolean(STORIESIG, checked);
|
||||
else if (id == R.id.cbAmoledTheme) settingsHelper.putBoolean(AMOLED_THEME, checked);
|
||||
else if (id == R.id.cbActivity) settingsHelper.putBoolean(CHECK_ACTIVITY, checked);
|
||||
else if (id == R.id.cbSaveTo) {
|
||||
settingsHelper.putBoolean(FOLDER_SAVE_TO, checked);
|
||||
btnSaveTo.setEnabled(checked);
|
||||
|
@ -21,9 +21,9 @@ import awais.instagrabber.customviews.helpers.GridSpacingItemDecoration;
|
||||
import awais.instagrabber.models.BasePostModel;
|
||||
import awais.instagrabber.models.PostModel;
|
||||
import awais.instagrabber.models.ViewerPostModel;
|
||||
import awais.instagrabber.models.enums.DownloadMethod;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.models.enums.DownloadMethod;
|
||||
|
||||
public final class MultiDirectDialog extends BaseLanguageActivity {
|
||||
public final ArrayList<BasePostModel> selectedItems = new ArrayList<>();
|
||||
|
@ -46,6 +46,7 @@ public class DirectMessageInboxFragment extends Fragment implements SwipeRefresh
|
||||
private String endCursor;
|
||||
private AsyncTask<Void, Void, InboxModel> currentlyRunning;
|
||||
private InboxThreadModelListViewModel listViewModel;
|
||||
public static boolean afterLeave = false;
|
||||
|
||||
private final FetchListener<InboxModel> fetchListener = new FetchListener<InboxModel>() {
|
||||
@Override
|
||||
@ -115,6 +116,15 @@ public class DirectMessageInboxFragment extends Fragment implements SwipeRefresh
|
||||
currentlyRunning = new InboxFetcher(null, fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (afterLeave) {
|
||||
onRefresh();
|
||||
afterLeave = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> {
|
||||
if (!Utils.isEmpty(endCursor))
|
||||
|
@ -0,0 +1,209 @@
|
||||
package awais.instagrabber.fragments.directmessages;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.activities.ProfileViewer;
|
||||
import awais.instagrabber.adapters.DirectMessageMembersAdapter;
|
||||
import awais.instagrabber.asyncs.direct_messages.DirectMessageInboxThreadFetcher;
|
||||
import awais.instagrabber.databinding.FragmentDirectMessagesSettingsBinding;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.models.ProfileModel;
|
||||
import awais.instagrabber.models.direct_messages.InboxThreadModel;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
|
||||
public class DirectMessageSettingsFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
|
||||
private static final String TAG = "DirectMessagesSettingsFrag";
|
||||
|
||||
private FragmentActivity fragmentActivity;
|
||||
private RecyclerView userList;
|
||||
private EditText titleText;
|
||||
private AppCompatImageView titleSend;
|
||||
private AppCompatButton btnLeave;
|
||||
private LinearLayoutManager layoutManager;
|
||||
private String threadId, threadTitle;
|
||||
private final String cookie = Utils.settingsHelper.getString(Constants.COOKIE);
|
||||
private AsyncTask<Void, Void, InboxThreadModel> currentlyRunning;
|
||||
private DirectMessageMembersAdapter memberAdapter;
|
||||
private View.OnClickListener clickListener;
|
||||
|
||||
private final FetchListener<InboxThreadModel> fetchListener = new FetchListener<InboxThreadModel>() {
|
||||
@Override
|
||||
public void doBefore() {}
|
||||
|
||||
@Override
|
||||
public void onResult(final InboxThreadModel threadModel) {
|
||||
memberAdapter = new DirectMessageMembersAdapter(threadModel.getUsers(), requireContext(), clickListener);
|
||||
userList.setAdapter(memberAdapter);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
fragmentActivity = requireActivity();
|
||||
|
||||
clickListener = v -> {
|
||||
final Object tag = v.getTag();
|
||||
if (tag instanceof ProfileModel) {
|
||||
// TODO: kick dialog
|
||||
ProfileModel model = (ProfileModel) tag;
|
||||
startActivity(
|
||||
new Intent(requireContext(), ProfileViewer.class)
|
||||
.putExtra(Constants.EXTRAS_USERNAME, model.getUsername())
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater,
|
||||
final ViewGroup container,
|
||||
final Bundle savedInstanceState) {
|
||||
final FragmentDirectMessagesSettingsBinding binding = FragmentDirectMessagesSettingsBinding.inflate(inflater, container, false);
|
||||
final LinearLayout root = binding.getRoot();
|
||||
layoutManager = new LinearLayoutManager(requireContext());
|
||||
|
||||
threadId = DirectMessageSettingsFragmentArgs.fromBundle(getArguments()).getThreadId();
|
||||
threadTitle = DirectMessageSettingsFragmentArgs.fromBundle(getArguments()).getTitle();
|
||||
binding.swipeRefreshLayout.setEnabled(false);
|
||||
|
||||
userList = binding.userList;
|
||||
userList.setHasFixedSize(true);
|
||||
userList.setLayoutManager(layoutManager);
|
||||
|
||||
titleText = binding.titleText;
|
||||
titleText.setText(threadTitle);
|
||||
|
||||
titleSend = binding.titleSend;
|
||||
titleSend.setOnClickListener(v -> {
|
||||
new ChangeSettings().execute("update_title");
|
||||
});
|
||||
|
||||
titleText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
titleSend.setVisibility(s.toString().equals(threadTitle) ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
btnLeave = binding.btnLeave;
|
||||
btnLeave.setOnClickListener(v -> {
|
||||
new AlertDialog.Builder(requireContext()).setTitle(R.string.dms_action_leave_question)
|
||||
.setPositiveButton(R.string.yes, (x,y) -> {
|
||||
new ChangeSettings().execute("leave");
|
||||
})
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.show();
|
||||
});
|
||||
|
||||
currentlyRunning = new DirectMessageInboxThreadFetcher(threadId, null, null, fetchListener).execute();
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
stopCurrentExecutor();
|
||||
currentlyRunning = new DirectMessageInboxThreadFetcher(threadId, null, null, fetchListener).execute();
|
||||
}
|
||||
|
||||
private void stopCurrentExecutor() {
|
||||
if (currentlyRunning != null) {
|
||||
try {
|
||||
currentlyRunning.cancel(true);
|
||||
} catch (final Exception e) {
|
||||
if (BuildConfig.DEBUG) Log.e(TAG, "", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ChangeSettings extends AsyncTask<String, Void, Void> {
|
||||
String action;
|
||||
boolean ok = false;
|
||||
|
||||
protected Void doInBackground(String... rawAction) {
|
||||
action = rawAction[0];
|
||||
final String url = "https://i.instagram.com/api/v1/direct_v2/threads/"+threadId+"/"+action+"/";
|
||||
try {
|
||||
String urlParameters = "_csrftoken=" + cookie.split("csrftoken=")[1].split(";")[0]
|
||||
+"&_uuid=" + Utils.settingsHelper.getString(Constants.DEVICE_UUID);
|
||||
if (action.equals("update_title"))
|
||||
urlParameters += "&title=" + URLEncoder.encode(titleText.getText().toString(), "UTF-8")
|
||||
.replaceAll("\\+", "%20").replaceAll("%21", "!").replaceAll("%27", "'")
|
||||
.replaceAll("%28", "(").replaceAll("%29", ")").replaceAll("%7E", "~");
|
||||
final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
|
||||
urlConnection.setRequestMethod("POST");
|
||||
urlConnection.setUseCaches(false);
|
||||
urlConnection.setRequestProperty("User-Agent", Constants.I_USER_AGENT);
|
||||
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
urlConnection.setRequestProperty("Content-Length", Integer.toString(urlParameters.getBytes().length));
|
||||
urlConnection.setDoOutput(true);
|
||||
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
|
||||
wr.writeBytes(urlParameters);
|
||||
wr.flush();
|
||||
wr.close();
|
||||
urlConnection.connect();
|
||||
if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
||||
ok = true;
|
||||
}
|
||||
urlConnection.disconnect();
|
||||
} catch (Throwable ex) {
|
||||
Log.e("austin_debug", "unsend: " + ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
if (ok) {
|
||||
Toast.makeText(requireContext(), R.string.dms_action_success, Toast.LENGTH_SHORT).show();
|
||||
if (action.equals("update_title")) {
|
||||
threadTitle = titleText.getText().toString();
|
||||
titleSend.setVisibility(View.GONE);
|
||||
titleText.clearFocus();
|
||||
}
|
||||
else if (action.equals("leave")) {
|
||||
DirectMessageInboxFragment.afterLeave = true;
|
||||
NavHostFragment.findNavController(DirectMessageSettingsFragment.this).popBackStack(R.id.directMessagesInboxFragment, false);
|
||||
}
|
||||
}
|
||||
else Toast.makeText(requireContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
@ -20,11 +20,15 @@ import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.NavDirections;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
@ -32,8 +36,6 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -44,7 +46,6 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.activities.PostViewer;
|
||||
@ -75,7 +76,7 @@ public class DirectMessageThreadFragment extends Fragment {
|
||||
private static final int PICK_IMAGE = 100;
|
||||
|
||||
private FragmentActivity fragmentActivity;
|
||||
private String threadId;
|
||||
private String threadId, threadTitle;
|
||||
private String cursor;
|
||||
private final String cookie = Utils.settingsHelper.getString(Constants.COOKIE);
|
||||
private final String myId = Utils.getUserIdFromCookie(cookie);
|
||||
@ -83,6 +84,7 @@ public class DirectMessageThreadFragment extends Fragment {
|
||||
private DirectItemModelListViewModel listViewModel;
|
||||
private DirectItemModel directItemModel;
|
||||
private RecyclerView messageList;
|
||||
private AppCompatImageView dmInfo;
|
||||
private boolean hasSentSomething, hasDeletedSomething;
|
||||
private boolean hasOlder = true;
|
||||
|
||||
@ -131,12 +133,6 @@ public class DirectMessageThreadFragment extends Fragment {
|
||||
leftUsers.clear();
|
||||
leftUsers.addAll(Arrays.asList(result.getLeftUsers()));
|
||||
|
||||
// thread title is already comma separated username, so no need to set by ourselves
|
||||
// String[] users = new String[result.getUsers().length];
|
||||
// for (int i = 0; i < users.length; ++i) {
|
||||
// users[i] = result.getUsers()[i].getUsername();
|
||||
// }
|
||||
|
||||
List<DirectItemModel> list = listViewModel.getList().getValue();
|
||||
final List<DirectItemModel> newList = Arrays.asList(result.getItems());
|
||||
list = list != null ? new LinkedList<>(list) : new LinkedList<>();
|
||||
@ -170,11 +166,18 @@ public class DirectMessageThreadFragment extends Fragment {
|
||||
final ViewGroup container,
|
||||
final Bundle savedInstanceState) {
|
||||
binding = FragmentDirectMessagesThreadBinding.inflate(inflater, container, false);
|
||||
CoordinatorLayout containerTwo = (CoordinatorLayout) container.getParent();
|
||||
dmInfo = containerTwo.findViewById(R.id.dmInfo);
|
||||
final LinearLayout root = binding.getRoot();
|
||||
listViewModel = new ViewModelProvider(fragmentActivity).get(DirectItemModelListViewModel.class);
|
||||
if (getArguments() == null) {
|
||||
return root;
|
||||
}
|
||||
threadId = DirectMessageThreadFragmentArgs.fromBundle(getArguments()).getThreadId();
|
||||
if (!DirectMessageThreadFragmentArgs.fromBundle(getArguments()).getThreadId().equals(threadId)) {
|
||||
listViewModel.empty();
|
||||
threadId = DirectMessageThreadFragmentArgs.fromBundle(getArguments()).getThreadId();
|
||||
}
|
||||
threadTitle = DirectMessageThreadFragmentArgs.fromBundle(getArguments()).getTitle();
|
||||
binding.swipeRefreshLayout.setEnabled(false);
|
||||
messageList = binding.messageList;
|
||||
messageList.setHasFixedSize(true);
|
||||
@ -190,6 +193,11 @@ public class DirectMessageThreadFragment extends Fragment {
|
||||
}
|
||||
new DirectMessageInboxThreadFetcher(threadId, UserInboxDirection.OLDER, cursor, fetchListener).execute(); // serial because we don't want messages to be randomly ordered
|
||||
}));
|
||||
dmInfo.setOnClickListener(v -> {
|
||||
final NavDirections action =
|
||||
DirectMessageThreadFragmentDirections.actionDMThreadFragmentToDMSettingsFragment(threadId, threadTitle);
|
||||
NavHostFragment.findNavController(DirectMessageThreadFragment.this).navigate(action);
|
||||
});
|
||||
|
||||
final DialogInterface.OnClickListener onDialogListener = (dialogInterface, which) -> {
|
||||
if (which == 0) {
|
||||
@ -306,9 +314,10 @@ public class DirectMessageThreadFragment extends Fragment {
|
||||
final MentionClickListener mentionClickListener = (view, text, isHashtag) -> searchUsername(text);
|
||||
final DirectMessageItemsAdapter adapter = new DirectMessageItemsAdapter(users, leftUsers, onClickListener, mentionClickListener);
|
||||
messageList.setAdapter(adapter);
|
||||
listViewModel = new ViewModelProvider(fragmentActivity).get(DirectItemModelListViewModel.class);
|
||||
listViewModel.getList().observe(fragmentActivity, adapter::submitList);
|
||||
new DirectMessageInboxThreadFetcher(threadId, UserInboxDirection.OLDER, null, fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
if (listViewModel.isEmpty()) {
|
||||
new DirectMessageInboxThreadFetcher(threadId, UserInboxDirection.OLDER, null, fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
@ -420,13 +429,25 @@ public class DirectMessageThreadFragment extends Fragment {
|
||||
|
||||
public static class DirectItemModelListViewModel extends ViewModel {
|
||||
private MutableLiveData<List<DirectItemModel>> list;
|
||||
private boolean isEmpty;
|
||||
|
||||
public MutableLiveData<List<DirectItemModel>> getList() {
|
||||
if (list == null) {
|
||||
list = new MutableLiveData<>();
|
||||
isEmpty = true;
|
||||
}
|
||||
else isEmpty = false;
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
public void empty() {
|
||||
list = null;
|
||||
isEmpty = true;
|
||||
}
|
||||
}
|
||||
|
||||
class Unsend extends AsyncTask<Void, Void, Void> {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package awais.instagrabber.models;
|
||||
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
|
||||
public final class FeedModel extends PostModel {
|
||||
private final ProfileModel profileModel;
|
||||
private final long commentsCount, viewCount;
|
||||
|
@ -4,8 +4,8 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.models.enums.NotificationType;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
|
||||
public final class NotificationModel {
|
||||
private final String id, username, profilePicUrl, shortcode, previewUrl;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package awais.instagrabber.models;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
|
||||
public final class ViewerPostModel extends BasePostModel {
|
||||
|
@ -23,6 +23,7 @@ public final class Constants {
|
||||
public static final String INSTADP = "instadp";
|
||||
public static final String STORIESIG = "storiesig";
|
||||
public static final String AMOLED_THEME = "amoled_theme";
|
||||
public static final String CHECK_ACTIVITY = "check_activity";
|
||||
// never Export
|
||||
public static final String COOKIE = "cookie";
|
||||
public static final String SHOW_QUICK_ACCESS_DIALOG = "show_quick_dlg";
|
||||
|
@ -6,22 +6,13 @@ import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
|
@ -14,6 +14,7 @@ import static awais.instagrabber.utils.Constants.APP_THEME;
|
||||
import static awais.instagrabber.utils.Constants.AUTOLOAD_POSTS;
|
||||
import static awais.instagrabber.utils.Constants.AUTOPLAY_VIDEOS;
|
||||
import static awais.instagrabber.utils.Constants.BOTTOM_TOOLBAR;
|
||||
import static awais.instagrabber.utils.Constants.CHECK_ACTIVITY;
|
||||
import static awais.instagrabber.utils.Constants.COOKIE;
|
||||
import static awais.instagrabber.utils.Constants.CUSTOM_DATE_TIME_FORMAT;
|
||||
import static awais.instagrabber.utils.Constants.CUSTOM_DATE_TIME_FORMAT_ENABLED;
|
||||
@ -110,7 +111,7 @@ public final class SettingsHelper {
|
||||
public @interface StringSettings {}
|
||||
|
||||
@StringDef({DOWNLOAD_USER_FOLDER, BOTTOM_TOOLBAR, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS,
|
||||
AUTOLOAD_POSTS, CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, INSTADP, STORIESIG, AMOLED_THEME})
|
||||
AUTOLOAD_POSTS, CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, INSTADP, STORIESIG, AMOLED_THEME, CHECK_ACTIVITY})
|
||||
public @interface BooleanSettings {}
|
||||
|
||||
@StringDef({APP_THEME, APP_LANGUAGE, PREV_INSTALL_VERSION})
|
||||
|
10
app/src/main/res/drawable-anydpi/ic_submit.xml
Normal file
10
app/src/main/res/drawable-anydpi/ic_submit.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
|
||||
</vector>
|
BIN
app/src/main/res/drawable-hdpi/ic_submit.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_submit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 186 B |
BIN
app/src/main/res/drawable-mdpi/ic_submit.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_submit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 139 B |
BIN
app/src/main/res/drawable-xhdpi/ic_submit.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_submit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 323 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_submit.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_submit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 337 B |
@ -44,10 +44,26 @@
|
||||
<TextView
|
||||
android:id="@+id/toolbar_title"
|
||||
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/app_name" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/dmInfo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingLeft="4dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingBottom="4dp"
|
||||
app:srcCompat="@drawable/ic_info" />
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -320,6 +320,31 @@
|
||||
android:textSize="16sp" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckBox
|
||||
android:id="@+id/cbActivity"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:contentDescription="@string/activity_setting" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="5dp"
|
||||
android:text="@string/activity_setting"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="16sp" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/titleText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="bottom"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLength="2200"
|
||||
android:maxLines="10"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:paddingRight="4dp"
|
||||
android:scrollHorizontally="false" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/titleSend"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingLeft="4dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:visibility="gone"
|
||||
app:srcCompat="@drawable/ic_submit" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btnLeave"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:text="@string/dms_action_leave"
|
||||
android:textColor="@color/btn_red_text_color"
|
||||
android:textSize="18sp"
|
||||
app:backgroundTint="@color/btn_red_background" />
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/userList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</LinearLayout>
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -10,16 +10,16 @@
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/ivProfilePic"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginStart="88dp"
|
||||
android:layout_marginLeft="88dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginStart="66dp"
|
||||
android:layout_marginLeft="66dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:selectableItemBackground"
|
||||
|
@ -22,5 +22,19 @@
|
||||
<argument
|
||||
android:name="title"
|
||||
app:argType="string" />
|
||||
<action
|
||||
android:id="@+id/action_dMThreadFragment_to_dMSettingsFragment"
|
||||
app:destination="@id/directMessagesSettingsFragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/directMessagesSettingsFragment"
|
||||
android:name="awais.instagrabber.fragments.directmessages.DirectMessageSettingsFragment"
|
||||
android:label="DirectMessagesSettingsFragment">
|
||||
<argument
|
||||
android:name="threadId"
|
||||
app:argType="string" />
|
||||
<argument
|
||||
android:name="title"
|
||||
app:argType="string" />
|
||||
</fragment>
|
||||
</navigation>
|
@ -37,6 +37,7 @@
|
||||
<string name="download_user_folder">Download posts to username folder in Downloads</string>
|
||||
<string name="autoload_posts">Auto-load all posts from user</string>
|
||||
<string name="mark_as_seen_setting">Mark stories as seen after viewing\n(Story author will know you viewed it)</string>
|
||||
<string name="activity_setting">Enable activity notifications</string>
|
||||
<string name="error_loading_profile">Error loading profile!\nTry logging in and search again.</string>
|
||||
<string name="error_creating_folders">Error creating Download folder(s).</string>
|
||||
<string name="show_feed">Show user feed (Works only when user is logged in)</string>
|
||||
@ -169,6 +170,9 @@
|
||||
<string name="dms_inbox_raven_media_suggested">Suggested</string>
|
||||
<string name="dms_inbox_raven_media_screenshot">Screenshotted</string>
|
||||
<string name="dms_inbox_raven_media_cant_deliver">Cannot delivered</string>
|
||||
<string name="dms_action_success">Great success!</string>
|
||||
<string name="dms_action_leave">Leave</string>
|
||||
<string name="dms_action_leave_question">Leave this chat?</string>
|
||||
<string name="direct_download">Download directly</string>
|
||||
<string name="direct_download_desc">Downloads posts directly to the phone!</string>
|
||||
<string name="direct_download_loading">Fetching post(s)</string>
|
||||
|
Loading…
Reference in New Issue
Block a user