1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 14:47:29 +00:00

auto-cookie-detection

This commit is contained in:
Austin Huang 2020-08-01 12:41:00 -04:00
parent f4ca89e2d9
commit 582b651d79
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
9 changed files with 36 additions and 6 deletions

View File

@ -261,7 +261,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
private RecyclerLazyLoader feedLazyLoader, discoverLazyLoader;
private DiscoverAdapter discoverAdapter;
public SimpleExoPlayer currentFeedPlayer; // hack for remix drawer layout
final boolean isLoggedIn = !Utils.isEmpty(Utils.settingsHelper.getString(Constants.COOKIE));
public final boolean isLoggedIn = !Utils.isEmpty(Utils.settingsHelper.getString(Constants.COOKIE));
public MainHelper(@NonNull final Main main) {
stopCurrentExecutor();
@ -624,6 +624,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
}
main.mainBinding.appBarLayout.setExpanded(true, true);
main.mainBinding.privatePage.setVisibility(View.GONE);
main.mainBinding.privatePage2.setTextSize(28);
main.mainBinding.mainProfileImage.setImageBitmap(null);
main.mainBinding.mainHashtagImage.setImageBitmap(null);
main.mainBinding.mainLocationImage.setImageBitmap(null);
@ -928,7 +929,6 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
if (!profileModel.isReallyPrivate()) {
main.mainBinding.mainFollowing.setClickable(true);
main.mainBinding.mainFollowers.setClickable(true);
main.mainBinding.privatePage.setVisibility(View.GONE);
if (isLoggedIn) {
final View.OnClickListener followClickListener = v -> main.startActivity(new Intent(main, FollowViewer.class)

View File

@ -1,6 +1,7 @@
package awais.instagrabber.activities;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
@ -31,10 +32,19 @@ public final class Login extends BaseLanguageActivity implements View.OnClickLis
@Override
public void onPageFinished(final WebView view, final String url) {
webViewUrl = url;
final String mainCookie = Utils.getCookie(url);
if (!mainCookie.contains("; ds_user_id=")) ready = true;
else if (mainCookie.contains("; ds_user_id=") && ready) {
Utils.setupCookies(mainCookie);
settingsHelper.putString(Constants.COOKIE, mainCookie);
Toast.makeText(getApplicationContext(), R.string.login_success_loading_cookies, Toast.LENGTH_SHORT).show();
finish();
}
}
};
private final WebChromeClient webChromeClient = new WebChromeClient();
private String webViewUrl, defaultUserAgent;
private boolean ready = false;
private ActivityLoginBinding loginBinding;
@Override
@ -62,7 +72,9 @@ public final class Login extends BaseLanguageActivity implements View.OnClickLis
Utils.setupCookies(mainCookie);
settingsHelper.putString(Constants.COOKIE, mainCookie);
Toast.makeText(this, R.string.login_success_loading_cookies, Toast.LENGTH_SHORT).show();
finish();
Intent intent = new Intent(getApplicationContext(), Main.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
}
}

View File

@ -230,8 +230,13 @@ public final class Main extends BaseLanguageActivity {
mainBinding.mainLocationImage.setEnabled(false);
final boolean isQueryNull = userQuery == null;
if (isQueryNull) allItems.clear();
if (BuildConfig.DEBUG && isQueryNull) userQuery = "@austinhuang.me";
if (isQueryNull) {
allItems.clear();
mainBinding.privatePage1.setImageResource(R.drawable.ic_info);
mainBinding.privatePage2.setTextSize(20);
mainBinding.privatePage2.setText(mainHelper.isLoggedIn ? R.string.no_acc_logged_in : R.string.no_acc);
mainBinding.privatePage.setVisibility(View.VISIBLE);
}
if (!mainBinding.swipeRefreshLayout.isRefreshing() && userQuery != null) mainHelper.onRefresh();
mainHelper.onIntent(getIntent());
@ -327,7 +332,7 @@ public final class Main extends BaseLanguageActivity {
searchView.setQueryHint(getResources().getString(R.string.action_search));
searchView.setSuggestionsAdapter(suggestionAdapter);
searchView.setOnSearchClickListener(v -> {
searchView.setQuery((cookieModel != null && userQuery.equals("@"+cookieModel.getUsername())) ? "" : userQuery, false);
searchView.setQuery((cookieModel != null && userQuery != null && userQuery.equals("@"+cookieModel.getUsername())) ? "" : 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);

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:alpha="0.8"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M11,7h2v2h-2zM11,11h2v6h-2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 811 B

View File

@ -68,6 +68,8 @@
<string name="votef_story_poll">Vote successful!</string>
<string name="voted_story_poll">You have already voted!</string>
<string name="priv_acc">This Account is Private</string>
<string name="no_acc">You can log in via Settings on the bottom-right corner. Or, you can view public accounts without login!</string>
<string name="no_acc_logged_in">You can swipe left/right for explore/feed, or search something below!</string>
<string name="empty_acc">This Account has No Posts</string>
<string name="empty_list">No Such Posts!</string>
<string name="curr_version">Current version: v%s</string>