mirror of
https://github.com/KokaKiwi/BarInsta
synced 2026-03-04 11:31:35 +00:00
v16.6: yes
This commit is contained in:
parent
9626b9fa54
commit
06d2614680
40 changed files with 385 additions and 248 deletions
|
|
@ -4,6 +4,7 @@ import android.content.Intent;
|
|||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
|
@ -84,6 +85,9 @@ import static awais.instagrabber.utils.Constants.AUTOLOAD_POSTS;
|
|||
import static awais.instagrabber.utils.Constants.BOTTOM_TOOLBAR;
|
||||
import static awais.instagrabber.utils.Utils.logCollector;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
private static AsyncTask<?, ?, ?> currentlyExecuting;
|
||||
private AsyncTask<Void, Void, FeedStoryModel[]> prevStoriesFetcher;
|
||||
|
|
@ -278,12 +282,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
|
||||
setupExplore();
|
||||
|
||||
final boolean showFeed = Utils.settingsHelper.getBoolean(Constants.SHOW_FEED);
|
||||
if (showFeed) setupFeed();
|
||||
else {
|
||||
iconFeed.setAlpha(0.4f);
|
||||
main.mainBinding.drawerLayout.removeView(main.mainBinding.feedLayout);
|
||||
}
|
||||
setupFeed();
|
||||
|
||||
final TypedValue resolvedAttr = new TypedValue();
|
||||
main.getTheme().resolveAttribute(android.R.attr.textColorPrimary, resolvedAttr, true);
|
||||
|
|
@ -333,18 +332,16 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
if (drawerOpening && alpha > 100)
|
||||
ImageViewCompat.setImageTintList(iconDiscover, colorStateList.withAlpha(currentIconAlpha));
|
||||
|
||||
if (showFeed) ImageViewCompat.setImageTintList(iconFeed, colorStateList.withAlpha(otherIconAlpha));
|
||||
ImageViewCompat.setImageTintList(iconFeed, colorStateList.withAlpha(otherIconAlpha));
|
||||
} else {
|
||||
// this changes toolbar title
|
||||
main.mainBinding.toolbar.toolbar.setTitle(slideOffset >= 0.466 ? titleDiscover : main.userQuery);
|
||||
|
||||
if (showFeed) {
|
||||
imageTintList = ImageViewCompat.getImageTintList(iconFeed);
|
||||
alpha = imageTintList != null ? (imageTintList.getDefaultColor() & 0xFF_000000) >> 24 : 0;
|
||||
imageTintList = ImageViewCompat.getImageTintList(iconFeed);
|
||||
alpha = imageTintList != null ? (imageTintList.getDefaultColor() & 0xFF_000000) >> 24 : 0;
|
||||
|
||||
if (drawerOpening && alpha > 100)
|
||||
ImageViewCompat.setImageTintList(iconFeed, colorStateList.withAlpha(currentIconAlpha));
|
||||
}
|
||||
if (drawerOpening && alpha > 100)
|
||||
ImageViewCompat.setImageTintList(iconFeed, colorStateList.withAlpha(currentIconAlpha));
|
||||
|
||||
ImageViewCompat.setImageTintList(iconDiscover, colorStateList.withAlpha(otherIconAlpha));
|
||||
}
|
||||
|
|
@ -620,7 +617,6 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
main.mainBinding.appBarLayout.setExpanded(true, true);
|
||||
main.mainBinding.privatePage.setVisibility(View.GONE);
|
||||
main.mainBinding.mainProfileImage.setImageBitmap(null);
|
||||
main.mainBinding.mainProfileImage.setImageDrawable(null);
|
||||
main.mainBinding.mainUrl.setText(null);
|
||||
main.mainBinding.mainFullName.setText(null);
|
||||
main.mainBinding.mainPostCount.setText(null);
|
||||
|
|
@ -686,19 +682,8 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
}
|
||||
|
||||
main.mainBinding.mainProfileImage.setEnabled(false);
|
||||
Glide.with(main).load(profileModel.getSdProfilePic()).listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable final GlideException e, final Object model, final Target<Drawable> target, final boolean isFirstResource) {
|
||||
main.mainBinding.mainProfileImage.setEnabled(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(final Drawable resource, final Object model, final Target<Drawable> target, final DataSource dataSource, final boolean isFirstResource) {
|
||||
main.mainBinding.mainProfileImage.setEnabled(true);
|
||||
return false;
|
||||
}
|
||||
}).into(main.mainBinding.mainProfileImage);
|
||||
new MyTask().execute();
|
||||
main.mainBinding.mainProfileImage.setEnabled(true);
|
||||
|
||||
final long followersCount = profileModel.getFollowersCount();
|
||||
final long followingCount = profileModel.getFollowingCount();
|
||||
|
|
@ -877,4 +862,22 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
}
|
||||
return returnvalue;
|
||||
}
|
||||
|
||||
class MyTask extends AsyncTask<Void, Bitmap, Void> {
|
||||
private Bitmap mIcon_val;
|
||||
|
||||
protected Void doInBackground(Void... voids) {
|
||||
try {
|
||||
mIcon_val = BitmapFactory.decodeStream((InputStream) new URL(main.profileModel.getSdProfilePic()).getContent());
|
||||
} catch (Throwable ex) {
|
||||
Log.e("austin_debug", "bitmap: " + ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
main.mainBinding.mainProfileImage.setImageBitmap(mIcon_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
|
|
@ -43,6 +44,8 @@ import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
|||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
@ -65,6 +68,8 @@ import awais.instagrabber.models.enums.MediaItemType;
|
|||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
public final class PostViewer extends BaseLanguageActivity {
|
||||
private ActivityViewerBinding viewerBinding;
|
||||
private String url, prevUsername, commentsEndCursor;
|
||||
|
|
@ -151,7 +156,10 @@ public final class PostViewer extends BaseLanguageActivity {
|
|||
viewerBinding.bottomPanel.btnMute.setImageResource(intVol == 0f ? R.drawable.vol : R.drawable.mute);
|
||||
Utils.sessionVolumeFull = intVol == 1f;
|
||||
}
|
||||
|
||||
} else if (v == viewerBinding.btnLike) {
|
||||
new Like().execute();
|
||||
} else if (v == viewerBinding.btnBookmark) {
|
||||
new Bookmark().execute();
|
||||
} else {
|
||||
final Object tag = v.getTag();
|
||||
if (tag instanceof ViewerPostModel) {
|
||||
|
|
@ -203,6 +211,14 @@ public final class PostViewer extends BaseLanguageActivity {
|
|||
viewerBinding.topPanel.ivProfilePic.setOnClickListener(onClickListener);
|
||||
|
||||
viewerBinding.ivToggleFullScreen.setOnClickListener(onClickListener);
|
||||
if (Utils.isEmpty(settingsHelper.getString(Constants.COOKIE))) {
|
||||
viewerBinding.btnLike.setVisibility(View.GONE);
|
||||
viewerBinding.btnBookmark.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
viewerBinding.btnLike.setOnClickListener(onClickListener);
|
||||
viewerBinding.btnBookmark.setOnClickListener(onClickListener);
|
||||
}
|
||||
viewerBinding.btnDownload.setOnClickListener(downloadClickListener);
|
||||
|
||||
profileDialogAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,
|
||||
|
|
@ -345,6 +361,8 @@ public final class PostViewer extends BaseLanguageActivity {
|
|||
postModel.setPostId(viewerPostModel.getPostId());
|
||||
postModel.setTimestamp(viewerPostModel.getTimestamp());
|
||||
postModel.setPostCaption(viewerPostModel.getPostCaption());
|
||||
postModel.setLike(viewerPostModel.getLike());
|
||||
postModel.setBookmark(viewerPostModel.getBookmark());
|
||||
}
|
||||
|
||||
setupPostInfoBar(viewerPostModel.getUsername(), viewerPostModel.getItemType());
|
||||
|
|
@ -555,6 +573,28 @@ public final class PostViewer extends BaseLanguageActivity {
|
|||
postModel.setPostId(viewerPostModel.getPostId());
|
||||
postModel.setTimestamp(viewerPostModel.getTimestamp());
|
||||
postModel.setPostCaption(viewerPostModel.getPostCaption());
|
||||
postModel.setLike(viewerPostModel.getLike());
|
||||
postModel.setBookmark(viewerPostModel.getBookmark());
|
||||
if (viewerPostModel.getLike() == true) {
|
||||
viewerBinding.btnLike.setText(R.string.unlike);
|
||||
viewerBinding.btnLike.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
|
||||
R.color.btn_pink_background, null)));
|
||||
}
|
||||
else {
|
||||
viewerBinding.btnLike.setText(R.string.like);
|
||||
viewerBinding.btnLike.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
|
||||
R.color.btn_lightpink_background, null)));
|
||||
}
|
||||
if (viewerPostModel.getBookmark() == true) {
|
||||
viewerBinding.btnBookmark.setText(R.string.unbookmark);
|
||||
viewerBinding.btnBookmark.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
|
||||
R.color.btn_orange_background, null)));
|
||||
}
|
||||
else {
|
||||
viewerBinding.btnBookmark.setText(R.string.bookmark);
|
||||
viewerBinding.btnBookmark.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
|
||||
R.color.btn_lightorange_background, null)));
|
||||
}
|
||||
}
|
||||
|
||||
viewerBinding.bottomPanel.tvPostDate.setText(viewerPostModel.getPostDate());
|
||||
|
|
@ -639,4 +679,77 @@ public final class PostViewer extends BaseLanguageActivity {
|
|||
newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||
decorView.setSystemUiVisibility(newUiOptions);
|
||||
}
|
||||
|
||||
/*
|
||||
Recommended for PERSONAL use only
|
||||
Don't ever think about running a like farm with this
|
||||
*/
|
||||
|
||||
class Like extends AsyncTask<Void, Void, Void> {
|
||||
boolean ok = false;
|
||||
|
||||
protected Void doInBackground(Void... voids) {
|
||||
final String url = "https://www.instagram.com/web/likes/"+postModel.getPostId()+"/"+
|
||||
(postModel.getLike() == true ? "unlike/" : "like/");
|
||||
try {
|
||||
final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
|
||||
urlConnection.setRequestMethod("POST");
|
||||
urlConnection.setUseCaches(false);
|
||||
urlConnection.setRequestProperty("User-Agent", Constants.USER_AGENT);
|
||||
urlConnection.setRequestProperty("x-csrftoken",
|
||||
settingsHelper.getString(Constants.COOKIE).split("csrftoken=")[1].split(";")[0]);
|
||||
urlConnection.connect();
|
||||
if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
||||
ok = true;
|
||||
}
|
||||
else Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT);
|
||||
} catch (Throwable ex) {
|
||||
Log.e("austin_debug", "like: " + ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
if (ok == true) {
|
||||
viewerPostModel.setLike(postModel.getLike() == true ? false : true);
|
||||
postModel.setLike(postModel.getLike() == true ? false : true);
|
||||
refreshPost();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Bookmark extends AsyncTask<Void, Void, Void> {
|
||||
boolean ok = false;
|
||||
|
||||
protected Void doInBackground(Void... voids) {
|
||||
final String url = "https://www.instagram.com/web/save/"+postModel.getPostId()+"/"+
|
||||
(postModel.getBookmark() == true ? "unsave/" : "save/");
|
||||
try {
|
||||
final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
|
||||
urlConnection.setRequestMethod("POST");
|
||||
urlConnection.setUseCaches(false);
|
||||
urlConnection.setRequestProperty("User-Agent", Constants.USER_AGENT);
|
||||
urlConnection.setRequestProperty("x-csrftoken",
|
||||
settingsHelper.getString(Constants.COOKIE).split("csrftoken=")[1].split(";")[0]);
|
||||
urlConnection.connect();
|
||||
if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
||||
ok = true;
|
||||
}
|
||||
else Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT);
|
||||
} catch (Throwable ex) {
|
||||
Log.e("austin_debug", "bookmark: " + ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
if (ok == true) {
|
||||
viewerPostModel.setBookmark(postModel.getBookmark() == true ? false : true);
|
||||
postModel.setBookmark(postModel.getBookmark() == true ? false : true);
|
||||
refreshPost();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -126,21 +126,24 @@ public final class StoryViewer extends BaseLanguageActivity {
|
|||
&& intent.hasExtra(Constants.FEED)) {
|
||||
final FeedStoryModel[] storyFeed = (FeedStoryModel[]) intent.getSerializableExtra(Constants.FEED);
|
||||
final int index = intent.getIntExtra(Constants.FEED_ORDER, 1738);
|
||||
final FeedStoryModel feedStoryModel = isRightSwipe ?
|
||||
(storyFeed.length == 0 ? null : storyFeed[index-1]) :
|
||||
(storyFeed.length == index+1 ? null : storyFeed[index+1]);
|
||||
final StoryModel[] nextStoryModels = feedStoryModel.getStoryModels();
|
||||
if ((isRightSwipe == true && index == 0) || (isRightSwipe == false && index == storyFeed.length - 1))
|
||||
Toast.makeText(getApplicationContext(), R.string.no_more_stories, Toast.LENGTH_SHORT).show();
|
||||
else {
|
||||
final FeedStoryModel feedStoryModel = isRightSwipe ?
|
||||
(index == 0 ? null : storyFeed[index - 1]) :
|
||||
(storyFeed.length == index + 1 ? null : storyFeed[index + 1]);
|
||||
final StoryModel[] nextStoryModels = feedStoryModel.getStoryModels();
|
||||
|
||||
if (feedStoryModel != null) {
|
||||
final Intent newIntent = new Intent(getApplicationContext(), StoryViewer.class)
|
||||
.putExtra(Constants.EXTRAS_STORIES, nextStoryModels)
|
||||
.putExtra(Constants.EXTRAS_USERNAME, feedStoryModel.getProfileModel().getUsername())
|
||||
.putExtra(Constants.FEED, storyFeed)
|
||||
.putExtra(Constants.FEED_ORDER, isRightSwipe ? (index-1) : (index+1));
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(newIntent);
|
||||
if (feedStoryModel != null) {
|
||||
final Intent newIntent = new Intent(getApplicationContext(), StoryViewer.class)
|
||||
.putExtra(Constants.EXTRAS_STORIES, nextStoryModels)
|
||||
.putExtra(Constants.EXTRAS_USERNAME, feedStoryModel.getProfileModel().getUsername())
|
||||
.putExtra(Constants.FEED, storyFeed)
|
||||
.putExtra(Constants.FEED_ORDER, isRightSwipe ? (index - 1) : (index + 1));
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(newIntent);
|
||||
}
|
||||
}
|
||||
else Toast.makeText(getApplicationContext(), R.string.no_more_stories, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else {
|
||||
if (isRightSwipe) {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public final class DiscoverFetcher extends AsyncTask<Void, Void, DiscoverItemMod
|
|||
final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
|
||||
|
||||
urlConnection.setUseCaches(false);
|
||||
urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Linux; Android 8.1.0; motorola one Build/OPKS28.63-18-3; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36 Instagram 72.0.0.21.98 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 132081645)");
|
||||
urlConnection.setRequestProperty("User-Agent", Constants.USER_AGENT);
|
||||
|
||||
if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
||||
final JSONObject discoverResponse = new JSONObject(Utils.readFromConnection(urlConnection));
|
||||
|
|
|
|||
|
|
@ -129,7 +129,9 @@ public final class FeedFetcher extends AsyncTask<Void, Void, FeedModel[]> {
|
|||
feedItem.getString(Constants.EXTRAS_SHORTCODE),
|
||||
captionText,
|
||||
commentsCount,
|
||||
feedItem.optLong("taken_at_timestamp", -1));
|
||||
feedItem.optLong("taken_at_timestamp", -1),
|
||||
feedItem.getBoolean("viewer_has_liked"),
|
||||
feedItem.getBoolean("viewer_has_saved"));
|
||||
|
||||
final boolean isSlider = "GraphSidecar".equals(mediaType) && feedItem.has("edge_sidecar_to_children");
|
||||
|
||||
|
|
@ -150,7 +152,7 @@ public final class FeedFetcher extends AsyncTask<Void, Void, FeedModel[]> {
|
|||
node.getString(Constants.EXTRAS_ID),
|
||||
isChildVideo ? node.getString("video_url") : Utils.getHighQualityImage(node),
|
||||
null, null, null,
|
||||
node.optLong("video_view_count", -1), -1);
|
||||
node.optLong("video_view_count", -1), -1, false, false);
|
||||
|
||||
sliderItems[j].setSliderDisplayUrl(node.getString("display_url"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public final class PostFetcher extends AsyncTask<Void, Void, ViewerPostModel[]>
|
|||
Utils.isEmpty(postCaption) ? null : postCaption,
|
||||
username,
|
||||
isVideo && media.has("video_view_count") ? media.getLong("video_view_count") : -1,
|
||||
timestamp);
|
||||
timestamp, media.getBoolean("viewer_has_liked"), media.getBoolean("viewer_has_saved"));
|
||||
|
||||
postModel.setCommentsCount(commentsCount);
|
||||
postModel.setCommentsEndCursor(endCursor);
|
||||
|
|
@ -112,7 +112,7 @@ public final class PostFetcher extends AsyncTask<Void, Void, ViewerPostModel[]>
|
|||
postCaption,
|
||||
username,
|
||||
isChildVideo && node.has("video_view_count") ? node.getLong("video_view_count") : -1,
|
||||
timestamp);
|
||||
timestamp, media.getBoolean("viewer_has_liked"), media.getBoolean("viewer_has_saved"));
|
||||
postModels[i].setSliderDisplayUrl(node.getString("display_url"));
|
||||
|
||||
Utils.checkExistence(downloadDir, customDir, username, true, i, postModels[i]);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,8 @@ public final class PostsFetcher extends AsyncTask<Void, Void, PostModel[]> {
|
|||
mediaNode.getString("display_url"), mediaNode.getString("thumbnail_src"),
|
||||
mediaNode.getString(Constants.EXTRAS_SHORTCODE),
|
||||
captions.length() > 0 ? captions.getJSONObject(0).getJSONObject("node").getString("text") : null,
|
||||
mediaNode.getLong("taken_at_timestamp"));
|
||||
mediaNode.getLong("taken_at_timestamp"), mediaNode.optBoolean("viewer_has_liked"),
|
||||
mediaNode.optBoolean("viewer_has_saved"));
|
||||
|
||||
Utils.checkExistence(downloadDir, customDir, username, isSlider, -1, models[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,19 +30,24 @@ public final class AboutDialog extends BottomSheetDialogFragment {
|
|||
final LinearLayoutCompat infoContainer = contentView.findViewById(R.id.infoContainer);
|
||||
|
||||
final View btnTelegram = infoContainer.getChildAt(1);
|
||||
final View btnProject = infoContainer.getChildAt(2);
|
||||
final View btnMatrix = infoContainer.getChildAt(2);
|
||||
final View btnProject = infoContainer.getChildAt(3);
|
||||
final View.OnClickListener onClickListener = v -> {
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
if (v == btnTelegram) {
|
||||
intent.setData(Uri.parse("https://t.me/grabber_app"));
|
||||
if (!Utils.isEmpty(Utils.telegramPackage))
|
||||
intent.setPackage(Utils.telegramPackage);
|
||||
}
|
||||
else if (v == btnMatrix) {
|
||||
intent.setData(Uri.parse("https://matrix.to/#/#instagrabber:matrix.org"));
|
||||
} else
|
||||
intent.setData(Uri.parse("https://github.com/austinhuang0131/instagrabber/"));
|
||||
startActivity(intent);
|
||||
};
|
||||
btnProject.setOnClickListener(onClickListener);
|
||||
btnTelegram.setOnClickListener(onClickListener);
|
||||
btnMatrix.setOnClickListener(onClickListener);
|
||||
|
||||
final String description = getString(R.string.description);
|
||||
if (!Utils.isEmpty(description)) {
|
||||
|
|
@ -60,32 +65,15 @@ public final class AboutDialog extends BottomSheetDialogFragment {
|
|||
c = descriptionText.charAt(i);
|
||||
if (c == ']') {
|
||||
descriptionText.delete(i, i + 1);
|
||||
descriptionText.setSpan(new RelativeSizeSpan(0.5f), smallTextStart, i, 0);
|
||||
descriptionText.setSpan(new RelativeSizeSpan(0.6f), smallTextStart, i, 0);
|
||||
}
|
||||
++i;
|
||||
} while (c != ']' || i == descriptionText.length() - 1);
|
||||
} else if (c == '{') {
|
||||
final int smallerTextStart = i;
|
||||
descriptionText.delete(i, i + 1);
|
||||
i = smallerTextStart;
|
||||
|
||||
do {
|
||||
c = descriptionText.charAt(i);
|
||||
if (c == '}') {
|
||||
descriptionText.delete(i, i + 1);
|
||||
descriptionText.setSpan(new RelativeSizeSpan(0.35f), smallerTextStart, i, 0);
|
||||
}
|
||||
++i;
|
||||
lastIndex = i;
|
||||
} while (c != '}' || i == descriptionText.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
lastIndex = Utils.indexOfChar(descriptionText, '@', lastIndex);
|
||||
descriptionText.setSpan(new URLSpan("https://t.me/awais404"), lastIndex, lastIndex + 9, 0);
|
||||
|
||||
lastIndex = Utils.indexOfChar(descriptionText, ':', lastIndex + 9) + 2;
|
||||
descriptionText.setSpan(new URLSpan("mailto:chapter50000@hotmail.com"), lastIndex, lastIndex + 24, 0);
|
||||
lastIndex = Utils.indexOfChar(descriptionText, '@', lastIndex) - 12;
|
||||
descriptionText.setSpan(new URLSpan("mailto:instagrabber@austinhuang.me"), lastIndex, lastIndex + 27, 0);
|
||||
|
||||
final TextView textView = (TextView) infoContainer.getChildAt(0);
|
||||
textView.setMovementMethod(new LinkMovementMethod());
|
||||
|
|
|
|||
|
|
@ -17,13 +17,16 @@ import android.widget.Toast;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatCheckBox;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.activities.Login;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.DirectoryChooser;
|
||||
import awais.instagrabber.utils.LocaleUtils;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
|
|
@ -45,7 +48,8 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
|
|||
CompoundButton.OnCheckedChangeListener {
|
||||
private Activity activity;
|
||||
private FragmentManager fragmentManager;
|
||||
private View btnSaveTo, btnImportExport, btnLogin, btnTimeSettings, btnReport;
|
||||
private View btnSaveTo, btnImportExport, btnLogin, btnLogout, btnTimeSettings, btnReport;
|
||||
private AppCompatTextView settingTitle;
|
||||
private Spinner spAppTheme, spLanguage;
|
||||
private boolean somethingChanged = false;
|
||||
private int currentTheme, currentLanguage, selectedLanguage;
|
||||
|
|
@ -81,7 +85,10 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
|
|||
|
||||
final View contentView = View.inflate(activity, R.layout.dialog_main_settings, null);
|
||||
|
||||
settingTitle = contentView.findViewById(R.id.settingTitle);
|
||||
settingTitle.setText("Settings (v"+BuildConfig.VERSION_NAME+")");
|
||||
btnLogin = contentView.findViewById(R.id.btnLogin);
|
||||
btnLogout = contentView.findViewById(R.id.btnLogout);
|
||||
btnSaveTo = contentView.findViewById(R.id.btnSaveTo);
|
||||
btnImportExport = contentView.findViewById(R.id.importExport);
|
||||
btnTimeSettings = contentView.findViewById(R.id.btnTimeSettings);
|
||||
|
|
@ -90,11 +97,14 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
|
|||
Utils.setTooltipText(btnImportExport, R.string.import_export);
|
||||
|
||||
btnLogin.setOnClickListener(this);
|
||||
btnLogout.setOnClickListener(this);
|
||||
btnReport.setOnClickListener(this);
|
||||
btnSaveTo.setOnClickListener(this);
|
||||
btnImportExport.setOnClickListener(this);
|
||||
btnTimeSettings.setOnClickListener(this);
|
||||
|
||||
if (Utils.isEmpty(settingsHelper.getString(Constants.COOKIE))) btnLogout.setEnabled(false);
|
||||
|
||||
spAppTheme = contentView.findViewById(R.id.spAppTheme);
|
||||
currentTheme = settingsHelper.getInteger(APP_THEME);
|
||||
spAppTheme.setSelection(currentTheme);
|
||||
|
|
@ -106,7 +116,6 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
|
|||
spLanguage.setOnItemSelectedListener(this);
|
||||
|
||||
final AppCompatCheckBox cbSaveTo = contentView.findViewById(R.id.cbSaveTo);
|
||||
final AppCompatCheckBox cbShowFeed = contentView.findViewById(R.id.cbShowFeed);
|
||||
final AppCompatCheckBox cbMuteVideos = contentView.findViewById(R.id.cbMuteVideos);
|
||||
final AppCompatCheckBox cbBottomToolbar = contentView.findViewById(R.id.cbBottomToolbar);
|
||||
final AppCompatCheckBox cbAutoloadPosts = contentView.findViewById(R.id.cbAutoloadPosts);
|
||||
|
|
@ -118,12 +127,10 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
|
|||
cbBottomToolbar.setChecked(settingsHelper.getBoolean(BOTTOM_TOOLBAR));
|
||||
cbAutoplayVideos.setChecked(settingsHelper.getBoolean(AUTOPLAY_VIDEOS));
|
||||
|
||||
cbShowFeed.setChecked(settingsHelper.getBoolean(SHOW_FEED));
|
||||
cbAutoloadPosts.setChecked(settingsHelper.getBoolean(AUTOLOAD_POSTS));
|
||||
cbDownloadUsername.setChecked(settingsHelper.getBoolean(DOWNLOAD_USER_FOLDER));
|
||||
|
||||
setupListener(cbSaveTo);
|
||||
setupListener(cbShowFeed);
|
||||
setupListener(cbMuteVideos);
|
||||
setupListener(cbBottomToolbar);
|
||||
setupListener(cbAutoloadPosts);
|
||||
|
|
@ -163,7 +170,11 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
|
|||
if (v == btnLogin) {
|
||||
startActivity(new Intent(v.getContext(), Login.class));
|
||||
somethingChanged = true;
|
||||
|
||||
} else if (v == btnLogout) {
|
||||
Utils.setupCookies("LOGOUT");
|
||||
settingsHelper.putString(Constants.COOKIE, null);
|
||||
this.dismiss();
|
||||
activity.recreate();
|
||||
} else if (v == btnImportExport) {
|
||||
if (ContextCompat.checkSelfPermission(activity, Utils.PERMS[0]) == PackageManager.PERMISSION_DENIED)
|
||||
requestPermissions(Utils.PERMS, 6007);
|
||||
|
|
@ -192,7 +203,6 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
|
|||
else if (id == R.id.cbAutoplayVideos) settingsHelper.putBoolean(AUTOPLAY_VIDEOS, checked);
|
||||
else if (id == R.id.cbMuteVideos) settingsHelper.putBoolean(MUTED_VIDEOS, checked);
|
||||
else if (id == R.id.cbAutoloadPosts) settingsHelper.putBoolean(AUTOLOAD_POSTS, checked);
|
||||
else if (id == R.id.cbShowFeed) settingsHelper.putBoolean(SHOW_FEED, checked);
|
||||
else if (id == R.id.cbSaveTo) {
|
||||
settingsHelper.putBoolean(FOLDER_SAVE_TO, checked);
|
||||
btnSaveTo.setEnabled(checked);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@ public final class MultiDirectDialog extends BaseLanguageActivity {
|
|||
final ArrayList<PostModel> models = new ArrayList<>(postModels.length - 1);
|
||||
for (final ViewerPostModel postModel : postModels)
|
||||
models.add(new PostModel(postModel.getItemType(), postModel.getPostId(), postModel.getDisplayUrl(),
|
||||
postModel.getSliderDisplayUrl(), postModel.getShortCode(), postModel.getPostCaption(), postModel.getTimestamp()));
|
||||
postModel.getSliderDisplayUrl(), postModel.getShortCode(), postModel.getPostCaption(), postModel.getTimestamp(),
|
||||
postModel.getLike(), postModel.getBookmark()));
|
||||
|
||||
postsAdapter = new PostsAdapter(models, v -> {
|
||||
final Object tag = v.getTag();
|
||||
|
|
|
|||
|
|
@ -18,6 +18,21 @@ public abstract class BasePostModel implements Serializable {
|
|||
protected boolean isDownloaded;
|
||||
protected long timestamp;
|
||||
protected int position;
|
||||
boolean liked, bookmarked;
|
||||
|
||||
public boolean getLike() {
|
||||
return liked;
|
||||
}
|
||||
public boolean getBookmark() {
|
||||
return bookmarked;
|
||||
}
|
||||
|
||||
public boolean setLike(final boolean like) {
|
||||
liked = like; this.liked = liked; return liked;
|
||||
}
|
||||
public boolean setBookmark(final boolean bookmark) {
|
||||
bookmarked = bookmark; this.bookmarked = bookmarked; return bookmarked;
|
||||
}
|
||||
|
||||
public MediaItemType getItemType() {
|
||||
return itemType;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ public final class FeedModel extends PostModel {
|
|||
|
||||
public FeedModel(final ProfileModel profileModel, final MediaItemType itemType, final long viewCount, final String postId,
|
||||
final String displayUrl, final String thumbnailUrl, final String shortCode, final String postCaption,
|
||||
final long commentsCount, final long timestamp) {
|
||||
super(itemType, postId, displayUrl, thumbnailUrl, shortCode, postCaption, timestamp);
|
||||
final long commentsCount, final long timestamp, boolean liked, boolean bookmarked) {
|
||||
super(itemType, postId, displayUrl, thumbnailUrl, shortCode, postCaption, timestamp, liked, bookmarked);
|
||||
this.profileModel = profileModel;
|
||||
this.commentsCount = commentsCount;
|
||||
this.viewCount = viewCount;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class PostModel extends BasePostModel {
|
|||
}
|
||||
|
||||
public PostModel(final MediaItemType itemType, final String postId, final String displayUrl, final String thumbnailUrl,
|
||||
final String shortCode, final CharSequence postCaption, long timestamp) {
|
||||
final String shortCode, final CharSequence postCaption, long timestamp, boolean liked, boolean bookmarked) {
|
||||
this.itemType = itemType;
|
||||
this.postId = postId;
|
||||
this.displayUrl = displayUrl;
|
||||
|
|
@ -21,6 +21,8 @@ public class PostModel extends BasePostModel {
|
|||
this.shortCode = shortCode;
|
||||
this.postCaption = postCaption;
|
||||
this.timestamp = timestamp;
|
||||
this.liked = liked;
|
||||
this.bookmarked = bookmarked;
|
||||
}
|
||||
|
||||
public String getThumbnailUrl() {
|
||||
|
|
@ -31,6 +33,20 @@ public class PostModel extends BasePostModel {
|
|||
return endCursor;
|
||||
}
|
||||
|
||||
public boolean getLike() {
|
||||
return liked;
|
||||
}
|
||||
public boolean getBookmark() {
|
||||
return bookmarked;
|
||||
}
|
||||
|
||||
public boolean setLike() {
|
||||
liked = liked == true ? false : true; this.liked = liked; return liked;
|
||||
}
|
||||
public boolean setBookmark() {
|
||||
bookmarked = bookmarked == true ? false : true; this.bookmarked = bookmarked; return bookmarked;
|
||||
}
|
||||
|
||||
public boolean hasNextPage() {
|
||||
return endCursor != null && hasNextPage;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ public final class ViewerPostModel extends BasePostModel {
|
|||
private boolean isCurrentSlide = false;
|
||||
|
||||
public ViewerPostModel(final MediaItemType itemType, final String postId, final String displayUrl, final String shortCode,
|
||||
final String postCaption, final String username, final long videoViews, final long timestamp) {
|
||||
final String postCaption, final String username, final long videoViews, final long timestamp,
|
||||
boolean liked, boolean bookmarked) {
|
||||
this.itemType = itemType;
|
||||
this.postId = postId;
|
||||
this.displayUrl = displayUrl;
|
||||
|
|
@ -19,6 +20,22 @@ public final class ViewerPostModel extends BasePostModel {
|
|||
this.shortCode = shortCode;
|
||||
this.videoViews = videoViews;
|
||||
this.timestamp = timestamp;
|
||||
this.liked = liked;
|
||||
this.bookmarked = bookmarked;
|
||||
}
|
||||
|
||||
public boolean getLike() {
|
||||
return liked;
|
||||
}
|
||||
public boolean getBookmark() {
|
||||
return bookmarked;
|
||||
}
|
||||
|
||||
public boolean setLike() {
|
||||
liked = liked == true ? false : true; this.liked = liked; return liked;
|
||||
}
|
||||
public boolean setBookmark() {
|
||||
bookmarked = bookmarked == true ? false : true; this.bookmarked = bookmarked; return bookmarked;
|
||||
}
|
||||
|
||||
public long getCommentsCount() {
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
package awais.instagrabber.utils;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
|
||||
public final class ChangelogFetcher extends AsyncTask<Void, Void, String> {
|
||||
private final FetchListener<CharSequence> fetchListener;
|
||||
|
||||
public ChangelogFetcher(final FetchListener<CharSequence> fetchListener) {
|
||||
this.fetchListener = fetchListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(final Void... voids) {
|
||||
String result = null;
|
||||
final String changelogUrl = "https://gitlab.com/AwaisKing/instagrabber/-/raw/master/CHANGELOG";
|
||||
|
||||
try {
|
||||
final HttpURLConnection conn = (HttpURLConnection) new URL(changelogUrl).openConnection();
|
||||
conn.setUseCaches(false);
|
||||
conn.connect();
|
||||
|
||||
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
||||
result = Utils.readFromConnection(conn);
|
||||
}
|
||||
|
||||
conn.disconnect();
|
||||
} catch (final Exception e) {
|
||||
if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
if (fetchListener != null) fetchListener.doBefore();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final String result) {
|
||||
if (fetchListener != null) fetchListener.onResult(result);
|
||||
}
|
||||
}
|
||||
|
|
@ -237,7 +237,6 @@ public final class ExportImportUtils {
|
|||
json.put(Constants.MUTED_VIDEOS, settingsHelper.getBoolean(Constants.MUTED_VIDEOS));
|
||||
json.put(Constants.BOTTOM_TOOLBAR, settingsHelper.getBoolean(Constants.BOTTOM_TOOLBAR));
|
||||
json.put(Constants.AUTOPLAY_VIDEOS, settingsHelper.getBoolean(Constants.AUTOPLAY_VIDEOS));
|
||||
json.put(Constants.SHOW_FEED, settingsHelper.getBoolean(Constants.SHOW_FEED));
|
||||
json.put(Constants.AUTOLOAD_POSTS, settingsHelper.getBoolean(Constants.AUTOLOAD_POSTS));
|
||||
json.put(Constants.FOLDER_SAVE_TO, settingsHelper.getBoolean(Constants.FOLDER_SAVE_TO));
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ 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;
|
||||
|
|
@ -39,60 +40,8 @@ public final class FlavorTown {
|
|||
|
||||
public static void changelogCheck(@NonNull final Context context) {
|
||||
if (settingsHelper.getInteger(Constants.PREV_INSTALL_VERSION) < BuildConfig.VERSION_CODE) {
|
||||
new ChangelogFetcher(new FetchListener<CharSequence>() {
|
||||
private AlertDialog alertDialog;
|
||||
private TextView textView;
|
||||
|
||||
@Override
|
||||
public void doBefore() {
|
||||
final ViewGroup rootView = (ViewGroup) View.inflate(context, R.layout.layout_changelog_textview, null);
|
||||
textView = (TextView) rootView.getChildAt(0);
|
||||
textView.setMovementMethod(new LinkMovementMethod());
|
||||
alertDialog = new AlertDialog.Builder(context).setTitle(R.string.title_changelog).setView(rootView).create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResult(final CharSequence result) {
|
||||
if (alertDialog != null && textView != null && !Utils.isEmpty(result)) {
|
||||
final Resources resources = context.getResources();
|
||||
|
||||
final SpannableStringBuilder stringBuilder = new SpannableStringBuilder(
|
||||
resources.getString(R.string.curr_version, BuildConfig.VERSION_NAME))
|
||||
.append('\n');
|
||||
|
||||
stringBuilder.setSpan(new RelativeSizeSpan(1.3f), 0, stringBuilder.length() - 1, 0);
|
||||
|
||||
final int resLen = result.length();
|
||||
int versionTimes = 0;
|
||||
|
||||
for (int i = 0; i < resLen; ++i) {
|
||||
final char c = result.charAt(i);
|
||||
|
||||
if (c == 'v' && i > 0) {
|
||||
final char c1 = result.charAt(i - 1);
|
||||
if (c1 == '\r' || c1 == '\n') {
|
||||
if (++versionTimes == 4) break;
|
||||
}
|
||||
}
|
||||
|
||||
stringBuilder.append(c);
|
||||
}
|
||||
|
||||
final String strReadMore = resources.getString(R.string.read_more);
|
||||
stringBuilder.append('\n').append(strReadMore);
|
||||
|
||||
final int sbLen = stringBuilder.length();
|
||||
stringBuilder.setSpan(new URLSpan("https://gitlab.com/AwaisKing/instagrabber/-/blob/master/CHANGELOG"),
|
||||
sbLen - strReadMore.length(), sbLen, 0);
|
||||
|
||||
textView.setText(stringBuilder, TextView.BufferType.SPANNABLE);
|
||||
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
settingsHelper.putInteger(Constants.PREV_INSTALL_VERSION, BuildConfig.VERSION_CODE);
|
||||
}
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
Toast.makeText(context, R.string.updated, Toast.LENGTH_SHORT).show();
|
||||
settingsHelper.putInteger(Constants.PREV_INSTALL_VERSION, BuildConfig.VERSION_CODE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,6 @@ import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO;
|
|||
import static awais.instagrabber.utils.Constants.MUTED_VIDEOS;
|
||||
import static awais.instagrabber.utils.Constants.PREV_INSTALL_VERSION;
|
||||
import static awais.instagrabber.utils.Constants.PROFILE_FETCH_MODE;
|
||||
import static awais.instagrabber.utils.Constants.SHOW_FEED;
|
||||
import static awais.instagrabber.utils.Constants.SHOW_QUICK_ACCESS_DIALOG;
|
||||
|
||||
public final class SettingsHelper {
|
||||
|
|
@ -107,7 +106,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, SHOW_FEED, CUSTOM_DATE_TIME_FORMAT_ENABLED})
|
||||
AUTOLOAD_POSTS, CUSTOM_DATE_TIME_FORMAT_ENABLED})
|
||||
public @interface BooleanSettings {}
|
||||
|
||||
@StringDef({APP_THEME, APP_LANGUAGE, PROFILE_FETCH_MODE, PREV_INSTALL_VERSION})
|
||||
|
|
|
|||
|
|
@ -117,7 +117,11 @@ public final class Utils {
|
|||
public static SimpleDateFormat datetimeParser;
|
||||
|
||||
public static void setupCookies(final String cookieRaw) {
|
||||
if (cookieRaw != null && !isEmpty(cookieRaw)) {
|
||||
if (cookieRaw == "LOGOUT") {
|
||||
final CookieStore cookieStore = NET_COOKIE_MANAGER.getCookieStore();
|
||||
cookieStore.removeAll();
|
||||
}
|
||||
else if (cookieRaw != null && !isEmpty(cookieRaw)) {
|
||||
final CookieStore cookieStore = NET_COOKIE_MANAGER.getCookieStore();
|
||||
try {
|
||||
final URI uri1 = new URI("https://instagram.com");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue