mirror of
https://github.com/KokaKiwi/BarInsta
synced 2026-03-04 11:31:35 +00:00
v16.7
This commit is contained in:
parent
cdbc0173c4
commit
394ffe19b7
46 changed files with 467 additions and 374 deletions
|
|
@ -26,7 +26,6 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
|
|
@ -34,15 +33,14 @@ import androidx.core.widget.ImageViewCompat;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.engine.GlideException;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
|
||||
import awais.instagrabber.activities.FollowViewer;
|
||||
|
|
@ -85,9 +83,6 @@ 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;
|
||||
|
|
@ -148,6 +143,12 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
model.setPageCursor(false, null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
main.mainBinding.swipeRefreshLayout.setRefreshing(false);
|
||||
main.mainBinding.privatePage1.setImageResource(R.drawable.ic_cancel);
|
||||
main.mainBinding.privatePage2.setText(R.string.empty_acc);
|
||||
main.mainBinding.privatePage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
};
|
||||
private final FetchListener<FeedModel[]> feedFetchListener = new FetchListener<FeedModel[]>() {
|
||||
|
|
@ -403,7 +404,6 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
}
|
||||
if (color == -1 || color == 0) color = resources.getBoolean(R.bool.isNight) ? 0xff212121 : 0xfff5f5f5;
|
||||
main.mainBinding.profileInfo.setBackgroundColor(color);
|
||||
main.mainBinding.profileInfo.setClickable(true);
|
||||
if (!isBottomToolbar) main.mainBinding.toolbar.toolbar.setBackgroundColor(color);
|
||||
|
||||
main.mainBinding.appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
||||
|
|
@ -628,6 +628,9 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
main.mainBinding.mainBiography.setMentionClickListener(null);
|
||||
main.mainBinding.mainUrl.setVisibility(View.GONE);
|
||||
main.mainBinding.isVerified.setVisibility(View.GONE);
|
||||
main.mainBinding.btnFollow.setVisibility(View.GONE);
|
||||
main.mainBinding.btnRestrict.setVisibility(View.GONE);
|
||||
main.mainBinding.btnBlock.setVisibility(View.GONE);
|
||||
|
||||
main.mainBinding.mainPosts.setNestedScrollingEnabled(false);
|
||||
main.mainBinding.highlightsList.setVisibility(View.GONE);
|
||||
|
|
@ -666,7 +669,8 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
main.mainBinding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE);
|
||||
final String profileId = profileModel.getId();
|
||||
|
||||
final boolean isLoggedIn = !Utils.isEmpty(Utils.settingsHelper.getString(Constants.COOKIE));
|
||||
final String cookie = Utils.settingsHelper.getString(Constants.COOKIE);
|
||||
final boolean isLoggedIn = !Utils.isEmpty(cookie);
|
||||
if (isLoggedIn) {
|
||||
new StoryStatusFetcher(profileId, result -> {
|
||||
main.storyModels = result;
|
||||
|
|
@ -679,6 +683,51 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
main.highlightsAdapter.setData(result);
|
||||
}
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
||||
final String myId = Utils.getUserIdFromCookie(Utils.settingsHelper.getString(Constants.COOKIE));
|
||||
if (!profileId.equals(myId)) {
|
||||
main.mainBinding.btnFollow.setVisibility(View.VISIBLE);
|
||||
main.mainBinding.btnFollow.setOnClickListener(profileActionListener);
|
||||
if (profileModel.getFollowing() == true) {
|
||||
main.mainBinding.btnFollow.setText(R.string.unfollow);
|
||||
main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
|
||||
R.color.btn_purple_background, null)));
|
||||
}
|
||||
else if (profileModel.getRequested() == true) {
|
||||
main.mainBinding.btnFollow.setText(R.string.cancel);
|
||||
main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
|
||||
R.color.btn_purple_background, null)));
|
||||
}
|
||||
else {
|
||||
main.mainBinding.btnFollow.setText(R.string.follow);
|
||||
main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
|
||||
R.color.btn_pink_background, null)));
|
||||
}
|
||||
main.mainBinding.btnRestrict.setVisibility(View.VISIBLE);
|
||||
main.mainBinding.btnRestrict.setOnClickListener(profileActionListener);
|
||||
if (profileModel.getRestricted() == true) {
|
||||
main.mainBinding.btnRestrict.setText(R.string.unrestrict);
|
||||
main.mainBinding.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
|
||||
R.color.btn_blue_background, null)));
|
||||
}
|
||||
else {
|
||||
main.mainBinding.btnRestrict.setText(R.string.restrict);
|
||||
main.mainBinding.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
|
||||
R.color.btn_orange_background, null)));
|
||||
}
|
||||
main.mainBinding.btnBlock.setVisibility(View.VISIBLE);
|
||||
main.mainBinding.btnBlock.setOnClickListener(profileActionListener);
|
||||
if (profileModel.getBlocked() == true) {
|
||||
main.mainBinding.btnBlock.setText(R.string.unblock);
|
||||
main.mainBinding.btnBlock.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
|
||||
R.color.btn_green_background, null)));
|
||||
}
|
||||
else {
|
||||
main.mainBinding.btnBlock.setText(R.string.block);
|
||||
main.mainBinding.btnBlock.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
|
||||
R.color.btn_red_background, null)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main.mainBinding.mainProfileImage.setEnabled(false);
|
||||
|
|
@ -735,8 +784,8 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
main.mainBinding.mainBiography.setEnabled(true);
|
||||
|
||||
if (!profileModel.isPrivate()) {
|
||||
main.mainBinding.swipeRefreshLayout.setRefreshing(true);
|
||||
main.mainBinding.mainPosts.setVisibility(View.VISIBLE);
|
||||
main.mainBinding.mainFollowing.setClickable(true);
|
||||
main.mainBinding.mainFollowers.setClickable(true);
|
||||
main.mainBinding.privatePage.setVisibility(View.GONE);
|
||||
|
||||
if (isLoggedIn) {
|
||||
|
|
@ -749,10 +798,25 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
main.mainBinding.mainFollowing.setOnClickListener(followingCount > 0 ? followClickListener : null);
|
||||
}
|
||||
|
||||
currentlyExecuting = new PostsFetcher(profileId, postsFetchListener).setUsername(profileModel.getUsername())
|
||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
if (profileModel.getPostCount() == 0) {
|
||||
main.mainBinding.swipeRefreshLayout.setRefreshing(false);
|
||||
main.mainBinding.privatePage1.setImageResource(R.drawable.ic_cancel);
|
||||
main.mainBinding.privatePage2.setText(R.string.empty_acc);
|
||||
main.mainBinding.privatePage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
main.mainBinding.swipeRefreshLayout.setRefreshing(true);
|
||||
main.mainBinding.mainPosts.setVisibility(View.VISIBLE);
|
||||
currentlyExecuting = new PostsFetcher(profileId, postsFetchListener).setUsername(profileModel.getUsername())
|
||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
} else {
|
||||
main.mainBinding.mainFollowers.setClickable(false);
|
||||
main.mainBinding.mainFollowing.setClickable(false);
|
||||
main.mainBinding.swipeRefreshLayout.setRefreshing(false);
|
||||
// error
|
||||
main.mainBinding.privatePage1.setImageResource(R.drawable.lock);
|
||||
main.mainBinding.privatePage2.setText(R.string.priv_acc);
|
||||
main.mainBinding.privatePage.setVisibility(View.VISIBLE);
|
||||
main.mainBinding.mainPosts.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
@ -880,4 +944,75 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||
main.mainBinding.mainProfileImage.setImageBitmap(mIcon_val);
|
||||
}
|
||||
}
|
||||
|
||||
private final View.OnClickListener profileActionListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
if (v == main.mainBinding.btnFollow) {
|
||||
new ProfileAction().execute("follow");
|
||||
} else if (v == main.mainBinding.btnRestrict) {
|
||||
new ProfileAction().execute("restrict");
|
||||
} else if (v == main.mainBinding.btnBlock) {
|
||||
new ProfileAction().execute("block");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class ProfileAction extends AsyncTask<String, Void, Void> {
|
||||
boolean ok = false;
|
||||
String action;
|
||||
|
||||
// arg: follow / restrict / block
|
||||
|
||||
// restrict https://www.instagram.com/web/restrict_action/(un)restrict/
|
||||
// requires form data "target_user_id: <id>"
|
||||
|
||||
protected Void doInBackground(String... rawAction) {
|
||||
action = rawAction[0];
|
||||
final String url = "https://www.instagram.com/web/"+
|
||||
(action == "restrict" ? "restrict_action" : ("friendships/"+main.profileModel.getId()))+"/"+
|
||||
(action == "follow" ?
|
||||
((main.profileModel.getFollowing() == true ||
|
||||
(main.profileModel.getFollowing() == false && main.profileModel.getRequested() == true))
|
||||
? "unfollow/" : "follow/") :
|
||||
(action == "restrict" ?
|
||||
(main.profileModel.getRestricted() == true ? "unrestrict/" : "restrict/") :
|
||||
(main.profileModel.getBlocked() == true ? "unblock/" : "block/")));
|
||||
final String urlParameters = "target_user_id="+main.profileModel.getId();
|
||||
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",
|
||||
Utils.settingsHelper.getString(Constants.COOKIE).split("csrftoken=")[1].split(";")[0]);
|
||||
if (action == "restrict") {
|
||||
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();
|
||||
}
|
||||
else urlConnection.connect();
|
||||
if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
||||
ok = true;
|
||||
}
|
||||
else Toast.makeText(main, R.string.downloader_unknown_error, Toast.LENGTH_SHORT);
|
||||
urlConnection.disconnect();
|
||||
} catch (Throwable ex) {
|
||||
Log.e("austin_debug", action+": " + ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
if (ok == true) {
|
||||
onRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,8 @@ import awais.instagrabber.utils.Utils;
|
|||
|
||||
public final class DirectMessagesUserInbox extends AppCompatActivity {
|
||||
private DirectItemModel directItemModel;
|
||||
private final ProfileModel myProfileHolder = new ProfileModel(false, false, null, null, null, null, null, null, null, 0, 0, 0);
|
||||
private final ProfileModel myProfileHolder =
|
||||
new ProfileModel(false, false, null, null, null, null, null, null, null, 0, 0, 0, false, false, false, false);
|
||||
private final ArrayList<ProfileModel> users = new ArrayList<>();
|
||||
private final ArrayList<DirectItemModel> directItemModels = new ArrayList<>();
|
||||
private final FetchListener<InboxThreadModel> fetchListener = new FetchListener<InboxThreadModel>() {
|
||||
|
|
@ -160,12 +161,10 @@ public final class DirectMessagesUserInbox extends AppCompatActivity {
|
|||
|
||||
@Nullable
|
||||
private ProfileModel getUser(final long userId) {
|
||||
if (users != null) {
|
||||
for (final ProfileModel user : users)
|
||||
if (Long.toString(userId).equals(user.getId())) return user;
|
||||
return myProfileHolder;
|
||||
for (final ProfileModel user : users) {
|
||||
if (Long.toString(userId).equals(user.getId())) return user;
|
||||
}
|
||||
return null;
|
||||
return myProfileHolder;
|
||||
}
|
||||
|
||||
private void searchUsername(final String text) {
|
||||
|
|
|
|||
|
|
@ -72,28 +72,13 @@ public final class FollowViewer extends BaseLanguageActivity implements SwipeRef
|
|||
followBinding.toolbar.toolbar.setTitle(name);
|
||||
|
||||
resources = getResources();
|
||||
final ArrayAdapter<Object> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new String[]{
|
||||
resources.getString(R.string.open_profile), resources.getString(R.string.followers_open_in_insta)});
|
||||
final AlertDialog alertDialog = new AlertDialog.Builder(this).setAdapter(adapter, (dialog, which) -> {
|
||||
if (model != null) {
|
||||
if (which == 0) {
|
||||
if (Main.scanHack != null) {
|
||||
Main.scanHack.onResult(model.getUsername());
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
final Intent actIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://instagram.com/" + model.getUsername()));
|
||||
if (Utils.isInstagramInstalled) actIntent.setPackage("com.instagram.android");
|
||||
startActivity(actIntent);
|
||||
}
|
||||
}
|
||||
}).setTitle(R.string.what_to_do_dialog).create();
|
||||
|
||||
clickListener = v -> {
|
||||
final Object tag = v.getTag();
|
||||
if (tag instanceof FollowModel) {
|
||||
model = (FollowModel) tag;
|
||||
if (!alertDialog.isShowing()) alertDialog.show();
|
||||
Main.scanHack.onResult(model.getUsername());
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -318,11 +303,11 @@ public final class FollowViewer extends BaseLanguageActivity implements SwipeRef
|
|||
final ArrayList<ExpandableGroup> groups = new ArrayList<>(1);
|
||||
|
||||
if (isCompare) {
|
||||
if (followingModels.size() > 0)
|
||||
if (followingModels != null && followingModels.size() > 0)
|
||||
groups.add(new ExpandableGroup(resources.getString(R.string.followers_not_following, name), followingModels));
|
||||
if (followersModels.size() > 0)
|
||||
if (followersModels != null && followersModels.size() > 0)
|
||||
groups.add(new ExpandableGroup(resources.getString(R.string.followers_not_follower, namePost), followersModels));
|
||||
if (allFollowing.size() > 0)
|
||||
if (allFollowing != null && allFollowing.size() > 0)
|
||||
groups.add(new ExpandableGroup(resources.getString(R.string.followers_both_following), allFollowing));
|
||||
} else {
|
||||
final ExpandableGroup group = new ExpandableGroup(type, followModels);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ import awais.instagrabber.models.enums.SuggestionType;
|
|||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.DataBox;
|
||||
import awais.instagrabber.utils.FlavorTown;
|
||||
import awais.instagrabber.utils.MyApps;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
|
@ -293,7 +292,7 @@ public final class Main extends BaseLanguageActivity {
|
|||
downloadAction = menu.findItem(R.id.action_download).setOnMenuItemClickListener(clickListener);
|
||||
|
||||
if (!Utils.isEmpty(Utils.settingsHelper.getString(Constants.COOKIE))) {
|
||||
settingsAction.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
//settingsAction.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
dmsAction.setVisible(true).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
}
|
||||
|
||||
|
|
@ -305,7 +304,28 @@ public final class Main extends BaseLanguageActivity {
|
|||
|
||||
searchView.setQueryHint(getResources().getString(R.string.action_search));
|
||||
searchView.setSuggestionsAdapter(suggestionAdapter);
|
||||
searchView.setOnSearchClickListener(v -> searchView.setQuery(userQuery, false));
|
||||
searchView.setOnSearchClickListener(v -> {
|
||||
searchView.setQuery(userQuery, false);
|
||||
menu.findItem(R.id.action_about).setVisible(false);
|
||||
menu.findItem(R.id.action_settings).setVisible(false);
|
||||
menu.findItem(R.id.action_dms).setVisible(false);
|
||||
menu.findItem(R.id.action_quickaccess).setVisible(false);
|
||||
});
|
||||
searchAction.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
menu.findItem(R.id.action_about).setVisible(true);
|
||||
menu.findItem(R.id.action_settings).setVisible(true);
|
||||
menu.findItem(R.id.action_dms).setVisible(true);
|
||||
menu.findItem(R.id.action_quickaccess).setVisible(true);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
private boolean searchUser, searchHash;
|
||||
private AsyncTask<?, ?, ?> prevSuggestionAsync;
|
||||
|
|
@ -351,6 +371,8 @@ public final class Main extends BaseLanguageActivity {
|
|||
@Override
|
||||
public boolean onQueryTextSubmit(final String query) {
|
||||
cancelSuggestionsAsync();
|
||||
menu.findItem(R.id.action_about).setVisible(true);
|
||||
menu.findItem(R.id.action_settings).setVisible(true);
|
||||
|
||||
closeAnyOpenDrawer();
|
||||
addToStack();
|
||||
|
|
@ -412,11 +434,6 @@ public final class Main extends BaseLanguageActivity {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MyApps.showAlertDialog(this, (parent, view, position, id) -> {
|
||||
if (id == -1 && position == -1 && parent == null) super.onBackPressed();
|
||||
else MyApps.openAppStore(this, position);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -157,9 +157,9 @@ public final class PostViewer extends BaseLanguageActivity {
|
|||
Utils.sessionVolumeFull = intVol == 1f;
|
||||
}
|
||||
} else if (v == viewerBinding.btnLike) {
|
||||
new Like().execute();
|
||||
new PostAction().execute("likes");
|
||||
} else if (v == viewerBinding.btnBookmark) {
|
||||
new Bookmark().execute();
|
||||
new PostAction().execute("save");
|
||||
} else {
|
||||
final Object tag = v.getTag();
|
||||
if (tag instanceof ViewerPostModel) {
|
||||
|
|
@ -252,8 +252,8 @@ public final class PostViewer extends BaseLanguageActivity {
|
|||
isMainSwipe = false;
|
||||
}
|
||||
|
||||
final BasePostModel[] basePostModels = mediaAdapter != null ? mediaAdapter.getPostModels() : null;
|
||||
final int slides = basePostModels != null ? basePostModels.length : 0;
|
||||
final BasePostModel[] basePostModels = mediaAdapter.getPostModels();
|
||||
final int slides = basePostModels.length;
|
||||
|
||||
int position = postModel.getPosition();
|
||||
|
||||
|
|
@ -685,12 +685,15 @@ public final class PostViewer extends BaseLanguageActivity {
|
|||
Don't ever think about running a like farm with this
|
||||
*/
|
||||
|
||||
class Like extends AsyncTask<Void, Void, Void> {
|
||||
class PostAction extends AsyncTask<String, Void, Void> {
|
||||
boolean ok = false;
|
||||
String action;
|
||||
|
||||
protected Void doInBackground(Void... voids) {
|
||||
final String url = "https://www.instagram.com/web/likes/"+postModel.getPostId()+"/"+
|
||||
(postModel.getLike() == true ? "unlike/" : "like/");
|
||||
protected Void doInBackground(String... rawAction) {
|
||||
action = rawAction[0];
|
||||
final String url = "https://www.instagram.com/web/"+action+"/"+postModel.getPostId()+"/"+ (action == "save" ?
|
||||
(postModel.getBookmark() == true ? "unsave/" : "save/") :
|
||||
(postModel.getLike() == true ? "unlike/" : "like/"));
|
||||
try {
|
||||
final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
|
||||
urlConnection.setRequestMethod("POST");
|
||||
|
|
@ -703,49 +706,21 @@ public final class PostViewer extends BaseLanguageActivity {
|
|||
ok = true;
|
||||
}
|
||||
else Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT);
|
||||
urlConnection.disconnect();
|
||||
} catch (Throwable ex) {
|
||||
Log.e("austin_debug", "like: " + ex);
|
||||
Log.e("austin_debug", action+": " + ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
if (ok == true) {
|
||||
if (ok == true && action == "likes") {
|
||||
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) {
|
||||
else if (ok == true && action == "save") {
|
||||
viewerPostModel.setBookmark(postModel.getBookmark() == true ? false : true);
|
||||
postModel.setBookmark(postModel.getBookmark() == true ? false : true);
|
||||
refreshPost();
|
||||
|
|
|
|||
|
|
@ -132,9 +132,8 @@ public final class StoryViewer extends BaseLanguageActivity {
|
|||
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 StoryModel[] nextStoryModels = feedStoryModel.getStoryModels();
|
||||
final Intent newIntent = new Intent(getApplicationContext(), StoryViewer.class)
|
||||
.putExtra(Constants.EXTRAS_STORIES, nextStoryModels)
|
||||
.putExtra(Constants.EXTRAS_USERNAME, feedStoryModel.getProfileModel().getUsername())
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public final class DirectMessagesAdapter extends RecyclerView.Adapter<DirectMess
|
|||
}
|
||||
else if (itemType == DirectItemType.RAVEN_MEDIA) {
|
||||
messageText = context.getString(R.string.direct_messages_sent_media);
|
||||
} else messageText = null;
|
||||
} else messageText = "<i>Unsupported message</i>";
|
||||
|
||||
holder.tvMessage.setText(HtmlCompat.fromHtml(messageText.toString(), 63));
|
||||
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ public final class FeedAdapter extends RecyclerView.Adapter<FeedItemViewHolder>
|
|||
|
||||
if (!captionEmpty && Utils.hasMentions(postCaption)) {
|
||||
postCaption = Utils.getMentionText(postCaption);
|
||||
feedModel.setPostCaption(postCaption);
|
||||
//feedModel.setPostCaption(postCaption);
|
||||
viewHolder.viewerCaption.setText(postCaption, TextView.BufferType.SPANNABLE);
|
||||
viewHolder.viewerCaption.setMentionClickListener(mentionClickListener);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ import static awais.instagrabber.models.direct_messages.DirectItemModel.RavenExp
|
|||
|
||||
public final class MessageItemsAdapter extends RecyclerView.Adapter<TextMessageViewHolder> {
|
||||
private static final int MESSAGE_INCOMING = 69, MESSAGE_OUTGOING = 420;
|
||||
private final ProfileModel myProfileHolder = new ProfileModel(false, false, null, null, null, null, null, null, null, 0, 0, 0);
|
||||
private final ProfileModel myProfileHolder =
|
||||
new ProfileModel(false, false, null, null, null, null, null, null, null, 0, 0, 0, false, false, false, false);
|
||||
private final ArrayList<DirectItemModel> directItemModels;
|
||||
private final ArrayList<ProfileModel> users;
|
||||
private final View.OnClickListener onClickListener;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ 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;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, CommentModel[]>
|
|||
owner.getString(Constants.EXTRAS_USERNAME),
|
||||
null, null, null,
|
||||
owner.getString("profile_pic_url"),
|
||||
null, 0, 0, 0);
|
||||
null, 0, 0, 0, false, false, false, false);
|
||||
|
||||
final JSONObject likedBy = childComment.optJSONObject("edge_liked_by");
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, CommentModel[]>
|
|||
owner.getString(Constants.EXTRAS_USERNAME),
|
||||
null, null, null,
|
||||
owner.getString("profile_pic_url"),
|
||||
null, 0, 0, 0);
|
||||
null, 0, 0, 0, false, false, false, false);
|
||||
|
||||
final JSONObject likedBy = comment.optJSONObject("edge_liked_by");
|
||||
final String commentId = comment.getString(Constants.EXTRAS_ID);
|
||||
|
|
@ -231,7 +231,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, CommentModel[]>
|
|||
tempJsonObject.getString(Constants.EXTRAS_USERNAME),
|
||||
null, null, null,
|
||||
tempJsonObject.getString("profile_pic_url"),
|
||||
null, 0, 0, 0);
|
||||
null, 0, 0, 0, false, false, false, false);
|
||||
|
||||
tempJsonObject = childComment.optJSONObject("edge_liked_by");
|
||||
childCommentModels[j] = new CommentModel(childComment.getString(Constants.EXTRAS_ID),
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public final class FeedFetcher extends AsyncTask<Void, Void, FeedModel[]> {
|
|||
owner.optString("full_name"),
|
||||
null, null,
|
||||
owner.getString("profile_pic_url"),
|
||||
null, 0, 0, 0);
|
||||
null, 0, 0, 0, false, false, false, false);
|
||||
}
|
||||
|
||||
JSONObject tempJsonObject = feedItem.optJSONObject("edge_media_preview_comment");
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public final class FeedStoriesFetcher extends AsyncTask<Void, Void, FeedStoryMod
|
|||
user.getString("username"),
|
||||
null, null, null,
|
||||
user.getString("profile_pic_url"),
|
||||
null, 0, 0, 0);
|
||||
null, 0, 0, 0, false, false, false, false);
|
||||
|
||||
final String id = node.getString("id");
|
||||
feedStoryIDs[i] = id;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,11 @@ public final class ProfileFetcher extends AsyncTask<Void, Void, ProfileModel> {
|
|||
user.getString("profile_pic_url_hd"),
|
||||
timelineMedia.getLong("count"),
|
||||
user.getJSONObject("edge_followed_by").getLong("count"),
|
||||
user.getJSONObject("edge_follow").getLong("count"));
|
||||
user.getJSONObject("edge_follow").getLong("count"),
|
||||
user.getBoolean("followed_by_viewer"),
|
||||
user.getBoolean("restricted_by_viewer"),
|
||||
user.getBoolean("blocked_by_viewer"),
|
||||
user.getBoolean("requested_by_viewer"));
|
||||
}
|
||||
|
||||
conn.disconnect();
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ 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+")");
|
||||
settingTitle.setText(getString(R.string.action_setting, BuildConfig.VERSION_NAME));
|
||||
btnLogin = contentView.findViewById(R.id.btnLogin);
|
||||
btnLogout = contentView.findViewById(R.id.btnLogout);
|
||||
btnSaveTo = contentView.findViewById(R.id.btnSaveTo);
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ public abstract class BasePostModel implements Serializable {
|
|||
}
|
||||
|
||||
public boolean setLike(final boolean like) {
|
||||
liked = like; this.liked = liked; return liked;
|
||||
liked = like; return liked;
|
||||
}
|
||||
public boolean setBookmark(final boolean bookmark) {
|
||||
bookmarked = bookmark; this.bookmarked = bookmarked; return bookmarked;
|
||||
bookmarked = bookmark; return bookmarked;
|
||||
}
|
||||
|
||||
public MediaItemType getItemType() {
|
||||
|
|
|
|||
|
|
@ -33,20 +33,6 @@ 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,14 @@ package awais.instagrabber.models;
|
|||
import java.io.Serializable;
|
||||
|
||||
public final class ProfileModel implements Serializable {
|
||||
private final boolean isPrivate, isVerified;
|
||||
private final boolean isPrivate, isVerified, following, restricted, blocked, requested;
|
||||
private final long postCount, followersCount, followingCount;
|
||||
private final String id, username, name, biography, url, sdProfilePic, hdProfilePic;
|
||||
|
||||
public ProfileModel(final boolean isPrivate, final boolean isVerified, final String id, final String username,
|
||||
final String name, final String biography, final String url, final String sdProfilePic, final String hdProfilePic,
|
||||
final long postCount, final long followersCount, final long followingCount) {
|
||||
final long postCount, final long followersCount, final long followingCount, final boolean following,
|
||||
final boolean restricted, final boolean blocked, final boolean requested) {
|
||||
this.isPrivate = isPrivate;
|
||||
this.isVerified = isVerified;
|
||||
this.id = id;
|
||||
|
|
@ -22,6 +23,10 @@ public final class ProfileModel implements Serializable {
|
|||
this.postCount = postCount;
|
||||
this.followersCount = followersCount;
|
||||
this.followingCount = followingCount;
|
||||
this.following = following;
|
||||
this.restricted = restricted;
|
||||
this.blocked = blocked;
|
||||
this.requested = requested;
|
||||
}
|
||||
|
||||
public boolean isPrivate() {
|
||||
|
|
@ -60,16 +65,23 @@ public final class ProfileModel implements Serializable {
|
|||
return hdProfilePic;
|
||||
}
|
||||
|
||||
public long getPostCount() {
|
||||
return postCount;
|
||||
}
|
||||
public long getPostCount() { return postCount; }
|
||||
|
||||
public long getFollowersCount() {
|
||||
return followersCount;
|
||||
}
|
||||
public long getFollowersCount() { return followersCount; }
|
||||
|
||||
public long getFollowingCount() {
|
||||
return followingCount;
|
||||
}
|
||||
|
||||
public boolean getFollowing() { return following; }
|
||||
|
||||
public boolean getRestricted() { return restricted; }
|
||||
|
||||
public boolean getBlocked() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
public boolean getRequested() {
|
||||
return requested;
|
||||
}
|
||||
}
|
||||
|
|
@ -24,20 +24,6 @@ public final class ViewerPostModel extends BasePostModel {
|
|||
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() {
|
||||
return commentsCount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,138 +0,0 @@
|
|||
package awais.instagrabber.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Process;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
|
||||
public final class MyApps {
|
||||
public final static Icons[] iconsList = Icons.values();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public enum Icons {
|
||||
MEDIASCAN("awais.media.scanner", "mediaScanner", R.drawable.zzz_ms),
|
||||
ADDME("awais.addme", "AddMe", R.drawable.zzz_adm),
|
||||
LINKEDWORDS("awais.backworddictionary", "Linked Words", R.drawable.zzz_lw),
|
||||
QUODB("awais.quodb", "QuoDB", R.drawable.zzz_qdb),
|
||||
REVERSIFY("awais.reversify", "Reversify", R.drawable.zzz_rev),
|
||||
REVERSIFY_LITE("awais.reversify.lite", "Reversify Lite", R.drawable.zzz_revl),
|
||||
TESV("awais.skyrimconsole", "Skyrim Cheats", R.drawable.zzz_tesv);
|
||||
private final int icon;
|
||||
private final String name, pkg;
|
||||
|
||||
Icons(final String pkg, final String name, final int icon) {
|
||||
this.name = name;
|
||||
this.pkg = pkg;
|
||||
this.icon = icon;
|
||||
}
|
||||
}
|
||||
|
||||
public static void openAppStore(@NonNull final Context context, final int position) {
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + MyApps.iconsList[position].pkg)));
|
||||
}
|
||||
|
||||
public static void showAlertDialog(final Context context, final AdapterView.OnItemClickListener clickListener) {
|
||||
final DialogInterface.OnCancelListener cancelListener = d -> {
|
||||
if (clickListener != null) clickListener.onItemClick(null, null, -1, -1);
|
||||
else Process.killProcess(Process.myPid());
|
||||
};
|
||||
if (new Random().nextDouble() < 0.420D) {
|
||||
cancelListener.onCancel(null);
|
||||
return;
|
||||
}
|
||||
final GridView gridView = new GridView(context);
|
||||
gridView.setAdapter(new ImageAdapter(context));
|
||||
gridView.setNumColumns(3);
|
||||
gridView.setOnItemClickListener(clickListener);
|
||||
final AlertDialog dialog = new AlertDialog.Builder(context).setView(gridView).setTitle("Support my apps tho").create();
|
||||
dialog.setOnCancelListener(cancelListener);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static class ImageAdapter extends BaseAdapter {
|
||||
private final Context context;
|
||||
private final int size;
|
||||
|
||||
public ImageAdapter(final Context context) {
|
||||
this.context = context;
|
||||
this.size = (int) (80 * Resources.getSystem().getDisplayMetrics().density);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return iconsList.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(final int position) {
|
||||
return iconsList[position];
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(final int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public View getView(final int position, View convertView, final ViewGroup parent) {
|
||||
final ViewHolder holder;
|
||||
if (convertView == null) {
|
||||
final LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
final AppCompatImageView imageView = new AppCompatImageView(context);
|
||||
final AppCompatTextView textView = new AppCompatTextView(context);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
textView.setTextAlignment(View.TEXT_ALIGNMENT_GRAVITY);
|
||||
textView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
imageView.setAdjustViewBounds(true);
|
||||
linearLayout.addView(imageView, LinearLayout.LayoutParams.MATCH_PARENT, size);
|
||||
linearLayout.addView(textView);
|
||||
final int padding = size >> 2;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
linearLayout.setPaddingRelative(padding, padding, padding, padding);
|
||||
else linearLayout.setPadding(padding, padding, padding, padding);
|
||||
convertView = linearLayout;
|
||||
convertView.setTag(holder = new ViewHolder(textView, imageView));
|
||||
} else
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
|
||||
final Object item = getItem(position);
|
||||
if (item instanceof Icons) {
|
||||
final Icons icons = (Icons) item;
|
||||
holder.title.setText(icons.name);
|
||||
holder.icon.setImageResource(icons.icon);
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private final static class ViewHolder {
|
||||
private final TextView title;
|
||||
private final ImageView icon;
|
||||
|
||||
private ViewHolder(final TextView title, final ImageView icon) {
|
||||
this.title = title;
|
||||
this.icon = icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ public final class SettingsHelper {
|
|||
themeCode = sharedPreferences.getInt(APP_THEME, themeCode);
|
||||
if (themeCode == 1) themeCode = AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
|
||||
else if (themeCode == 3) themeCode = AppCompatDelegate.MODE_NIGHT_NO;
|
||||
else if (themeCode != 2) themeCode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
|
||||
else if (themeCode == 0) themeCode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
|
||||
}
|
||||
|
||||
if (themeCode == AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM && Build.VERSION.SDK_INT < 29)
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ public final class Utils {
|
|||
userObj.getString("full_name"),
|
||||
null, null,
|
||||
userObj.getString("profile_pic_url"),
|
||||
null, 0, 0, 0);
|
||||
null, 0, 0, 0, false, false, false, false);
|
||||
}
|
||||
|
||||
final MediaItemType mediaType = getMediaItemType(mediaObj.optInt("media_type", -1));
|
||||
|
|
@ -465,7 +465,7 @@ public final class Utils {
|
|||
userObject.getString("full_name"),
|
||||
null, null,
|
||||
userObject.getString("profile_pic_url"),
|
||||
null, 0, 0, 0);
|
||||
null, 0, 0, 0, false, false, false, false);
|
||||
}
|
||||
|
||||
final JSONArray items = data.getJSONArray("items");
|
||||
|
|
@ -614,7 +614,7 @@ public final class Utils {
|
|||
profile.getString("full_name"),
|
||||
null, null,
|
||||
profile.getString("profile_pic_url"),
|
||||
null, 0, 0, 0);
|
||||
null, 0, 0, 0, false, false, false, false);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue