auto-cookie-detection
This commit is contained in:
parent
f4ca89e2d9
commit
582b651d79
@ -261,7 +261,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||||||
private RecyclerLazyLoader feedLazyLoader, discoverLazyLoader;
|
private RecyclerLazyLoader feedLazyLoader, discoverLazyLoader;
|
||||||
private DiscoverAdapter discoverAdapter;
|
private DiscoverAdapter discoverAdapter;
|
||||||
public SimpleExoPlayer currentFeedPlayer; // hack for remix drawer layout
|
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) {
|
public MainHelper(@NonNull final Main main) {
|
||||||
stopCurrentExecutor();
|
stopCurrentExecutor();
|
||||||
@ -624,6 +624,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||||||
}
|
}
|
||||||
main.mainBinding.appBarLayout.setExpanded(true, true);
|
main.mainBinding.appBarLayout.setExpanded(true, true);
|
||||||
main.mainBinding.privatePage.setVisibility(View.GONE);
|
main.mainBinding.privatePage.setVisibility(View.GONE);
|
||||||
|
main.mainBinding.privatePage2.setTextSize(28);
|
||||||
main.mainBinding.mainProfileImage.setImageBitmap(null);
|
main.mainBinding.mainProfileImage.setImageBitmap(null);
|
||||||
main.mainBinding.mainHashtagImage.setImageBitmap(null);
|
main.mainBinding.mainHashtagImage.setImageBitmap(null);
|
||||||
main.mainBinding.mainLocationImage.setImageBitmap(null);
|
main.mainBinding.mainLocationImage.setImageBitmap(null);
|
||||||
@ -928,7 +929,6 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
|||||||
if (!profileModel.isReallyPrivate()) {
|
if (!profileModel.isReallyPrivate()) {
|
||||||
main.mainBinding.mainFollowing.setClickable(true);
|
main.mainBinding.mainFollowing.setClickable(true);
|
||||||
main.mainBinding.mainFollowers.setClickable(true);
|
main.mainBinding.mainFollowers.setClickable(true);
|
||||||
main.mainBinding.privatePage.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
final View.OnClickListener followClickListener = v -> main.startActivity(new Intent(main, FollowViewer.class)
|
final View.OnClickListener followClickListener = v -> main.startActivity(new Intent(main, FollowViewer.class)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package awais.instagrabber.activities;
|
package awais.instagrabber.activities;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -31,10 +32,19 @@ public final class Login extends BaseLanguageActivity implements View.OnClickLis
|
|||||||
@Override
|
@Override
|
||||||
public void onPageFinished(final WebView view, final String url) {
|
public void onPageFinished(final WebView view, final String url) {
|
||||||
webViewUrl = 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 final WebChromeClient webChromeClient = new WebChromeClient();
|
||||||
private String webViewUrl, defaultUserAgent;
|
private String webViewUrl, defaultUserAgent;
|
||||||
|
private boolean ready = false;
|
||||||
private ActivityLoginBinding loginBinding;
|
private ActivityLoginBinding loginBinding;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -62,7 +72,9 @@ public final class Login extends BaseLanguageActivity implements View.OnClickLis
|
|||||||
Utils.setupCookies(mainCookie);
|
Utils.setupCookies(mainCookie);
|
||||||
settingsHelper.putString(Constants.COOKIE, mainCookie);
|
settingsHelper.putString(Constants.COOKIE, mainCookie);
|
||||||
Toast.makeText(this, R.string.login_success_loading_cookies, Toast.LENGTH_SHORT).show();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,8 +230,13 @@ public final class Main extends BaseLanguageActivity {
|
|||||||
mainBinding.mainLocationImage.setEnabled(false);
|
mainBinding.mainLocationImage.setEnabled(false);
|
||||||
|
|
||||||
final boolean isQueryNull = userQuery == null;
|
final boolean isQueryNull = userQuery == null;
|
||||||
if (isQueryNull) allItems.clear();
|
if (isQueryNull) {
|
||||||
if (BuildConfig.DEBUG && isQueryNull) userQuery = "@austinhuang.me";
|
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();
|
if (!mainBinding.swipeRefreshLayout.isRefreshing() && userQuery != null) mainHelper.onRefresh();
|
||||||
|
|
||||||
mainHelper.onIntent(getIntent());
|
mainHelper.onIntent(getIntent());
|
||||||
@ -327,7 +332,7 @@ public final class Main extends BaseLanguageActivity {
|
|||||||
searchView.setQueryHint(getResources().getString(R.string.action_search));
|
searchView.setQueryHint(getResources().getString(R.string.action_search));
|
||||||
searchView.setSuggestionsAdapter(suggestionAdapter);
|
searchView.setSuggestionsAdapter(suggestionAdapter);
|
||||||
searchView.setOnSearchClickListener(v -> {
|
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_about).setVisible(false);
|
||||||
menu.findItem(R.id.action_settings).setVisible(false);
|
menu.findItem(R.id.action_settings).setVisible(false);
|
||||||
menu.findItem(R.id.action_dms).setVisible(false);
|
menu.findItem(R.id.action_dms).setVisible(false);
|
||||||
|
11
app/src/main/res/drawable-anydpi/ic_info.xml
Normal file
11
app/src/main/res/drawable-anydpi/ic_info.xml
Normal 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>
|
BIN
app/src/main/res/drawable-hdpi/ic_info.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_info.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 451 B |
BIN
app/src/main/res/drawable-mdpi/ic_info.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_info.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 253 B |
BIN
app/src/main/res/drawable-xhdpi/ic_info.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_info.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 597 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_info.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_info.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 811 B |
@ -68,6 +68,8 @@
|
|||||||
<string name="votef_story_poll">Vote successful!</string>
|
<string name="votef_story_poll">Vote successful!</string>
|
||||||
<string name="voted_story_poll">You have already voted!</string>
|
<string name="voted_story_poll">You have already voted!</string>
|
||||||
<string name="priv_acc">This Account is Private</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_acc">This Account has No Posts</string>
|
||||||
<string name="empty_list">No Such Posts!</string>
|
<string name="empty_list">No Such Posts!</string>
|
||||||
<string name="curr_version">Current version: v%s</string>
|
<string name="curr_version">Current version: v%s</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user