fix #39, url opener, and login; rmbr write changelog later
This commit is contained in:
parent
2d4f600c39
commit
f10fe0840b
@ -9,8 +9,8 @@ android {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
|
||||
versionCode 42
|
||||
versionName '17.6'
|
||||
versionCode 43
|
||||
versionName '17.7'
|
||||
|
||||
multiDexEnabled true
|
||||
|
||||
|
@ -626,7 +626,8 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
.putExtra(Constants.EXTRAS_POST, new PostModel(modelText, false)), 9629);
|
||||
} else {
|
||||
main.addToStack();
|
||||
main.userQuery = modelType == IntentModelType.HASHTAG ? '#' + modelText : ("@"+modelText);
|
||||
main.userQuery = modelType == IntentModelType.HASHTAG ? ('#' + modelText) :
|
||||
(modelType == IntentModelType.LOCATION ? modelText : ('@'+modelText));
|
||||
onRefresh();
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,6 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
|
||||
if (v == btnLogin) {
|
||||
startActivity(new Intent(v.getContext(), Login.class));
|
||||
somethingChanged = true;
|
||||
this.dismiss();
|
||||
} else if (v == btnLogout) {
|
||||
Utils.setupCookies("LOGOUT");
|
||||
settingsHelper.putString(Constants.COOKIE, "");
|
||||
|
@ -5,4 +5,5 @@ public enum IntentModelType {
|
||||
USERNAME,
|
||||
POST,
|
||||
HASHTAG,
|
||||
LOCATION
|
||||
}
|
@ -51,7 +51,7 @@ public final class Constants {
|
||||
"Instagram 152.0.0.25.117 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 234847224)";
|
||||
public static final String I_USER_AGENT =
|
||||
"Instagram 152.0.0.25.117 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 234847224)";
|
||||
public static final String A_USER_AGENT = "InstaGrabber.AustinHuang.me / InstaGrabber@AustinHuang.me";
|
||||
public static final String A_USER_AGENT = "https://InstaGrabber.AustinHuang.me / mailto:InstaGrabber@AustinHuang.me";
|
||||
// see https://github.com/dilame/instagram-private-api/blob/master/src/core/constants.ts
|
||||
public static final String SUPPORTED_CAPABILITIES = "[ { \"name\": \"SUPPORTED_SDK_VERSIONS\", \"value\":" +
|
||||
" \"13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0," +
|
||||
|
@ -36,7 +36,7 @@ public final class FlavorTown {
|
||||
.setNegativeButton(R.string.action_github, (dialog, which) -> {
|
||||
try {
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW).setData(
|
||||
Uri.parse("https://github.com/austinhuang0131/instagrabber/releases/tag/" + version)));
|
||||
Uri.parse("https://github.com/austinhuang0131/instagrabber/releases/latest")));
|
||||
} catch (final ActivityNotFoundException e) {
|
||||
// do nothing
|
||||
}
|
||||
|
@ -22,44 +22,23 @@ public final class UpdateChecker extends AsyncTask<Void, Void, Boolean> {
|
||||
@NonNull
|
||||
@Override
|
||||
protected Boolean doInBackground(final Void... voids) {
|
||||
final String UPDATE_BASE_URL = "https://github.com/austinhuang0131/instagrabber/releases/tag/";
|
||||
final String versionName = BuildConfig.VERSION_NAME;
|
||||
final int index = versionName.indexOf('.');
|
||||
|
||||
try {
|
||||
final int verMajor = Integer.parseInt(versionName.substring(0, index));
|
||||
version = "";
|
||||
|
||||
version = "v" + (verMajor + 1) + ".0";
|
||||
|
||||
// check major version first
|
||||
HttpURLConnection conn = (HttpURLConnection) new URL(UPDATE_BASE_URL + version).openConnection();
|
||||
HttpURLConnection conn =
|
||||
(HttpURLConnection) new URL("https://github.com/austinhuang0131/instagrabber/releases/latest").openConnection();
|
||||
conn.setUseCaches(false);
|
||||
conn.setRequestMethod("HEAD");
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
conn.setRequestProperty("User-Agent", Constants.A_USER_AGENT);
|
||||
conn.connect();
|
||||
|
||||
final int responseCode = conn.getResponseCode();
|
||||
conn.disconnect();
|
||||
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) return true;
|
||||
else {
|
||||
final String substring = versionName.substring(index + 1);
|
||||
final int verMinor = Integer.parseInt(substring) + 1;
|
||||
|
||||
for (int i = verMinor; i < 10; ++i) {
|
||||
version = "v" + verMajor + '.' + i;
|
||||
conn.disconnect();
|
||||
|
||||
conn = (HttpURLConnection) new URL(UPDATE_BASE_URL + version).openConnection();
|
||||
conn.setUseCaches(false);
|
||||
conn.setRequestMethod("HEAD");
|
||||
conn.connect();
|
||||
|
||||
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
||||
conn.disconnect();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (responseCode == HttpURLConnection.HTTP_MOVED_TEMP) {
|
||||
version = conn.getHeaderField("Location").split("/v")[1];
|
||||
return Float.parseFloat(version) > Float.parseFloat(BuildConfig.VERSION_NAME);
|
||||
}
|
||||
|
||||
conn.disconnect();
|
||||
} catch (final Exception e) {
|
||||
if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e);
|
||||
}
|
||||
@ -70,6 +49,6 @@ public final class UpdateChecker extends AsyncTask<Void, Void, Boolean> {
|
||||
@Override
|
||||
protected void onPostExecute(final Boolean result) {
|
||||
if (result != null && result && fetchListener != null)
|
||||
fetchListener.onResult(version);
|
||||
fetchListener.onResult("v"+version);
|
||||
}
|
||||
}
|
@ -175,12 +175,18 @@ public final class Utils {
|
||||
clipString = clipString.substring((isHttps ? 22 : 21) + wwwDel);
|
||||
|
||||
final char firstChar = clipString.charAt(0);
|
||||
if ((firstChar == 'p' || firstChar == 'P') && clipString.charAt(1) == '/') {
|
||||
clipString = clipString.substring(2);
|
||||
if (clipString.startsWith("p/") || clipString.startsWith("reel/")) {
|
||||
clipString = clipString.substring(clipString.startsWith("p/") ? 2 : 5);
|
||||
type = IntentModelType.POST;
|
||||
} else if (clipString.startsWith("explore/tags/")) {
|
||||
clipString = clipString.substring(13);
|
||||
type = IntentModelType.HASHTAG;
|
||||
} else if (clipString.startsWith("explore/locations/")) {
|
||||
clipString = clipString.substring(18);
|
||||
type = IntentModelType.LOCATION;
|
||||
} else if (clipString.startsWith("_u/")) { // usually exists in embeds
|
||||
clipString = clipString.substring(3);
|
||||
type = IntentModelType.USERNAME;
|
||||
}
|
||||
|
||||
clipString = cleanString(clipString);
|
||||
@ -195,7 +201,8 @@ public final class Utils {
|
||||
if (clipString.charAt(clipLen) == '/')
|
||||
clipString = clipString.substring(0, clipLen);
|
||||
|
||||
return new IntentModel(type, clipString);
|
||||
if (!clipString.contains("/")) return new IntentModel(type, clipString);
|
||||
else return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
Loading…
Reference in New Issue
Block a user