Browse Source

fix #39, url opener, and login; rmbr write changelog later

legacy
Austin Huang 4 years ago
parent
commit
f10fe0840b
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 4
      app/build.gradle
  2. 3
      app/src/main/java/awais/instagrabber/MainHelper.java
  3. 1
      app/src/main/java/awais/instagrabber/dialogs/SettingsDialog.java
  4. 1
      app/src/main/java/awais/instagrabber/models/enums/IntentModelType.java
  5. 2
      app/src/main/java/awais/instagrabber/utils/Constants.java
  6. 2
      app/src/main/java/awais/instagrabber/utils/FlavorTown.java
  7. 41
      app/src/main/java/awais/instagrabber/utils/UpdateChecker.java
  8. 13
      app/src/main/java/awais/instagrabber/utils/Utils.java

4
app/build.gradle

@ -9,8 +9,8 @@ android {
minSdkVersion 16
targetSdkVersion 29
versionCode 42
versionName '17.6'
versionCode 43
versionName '17.7'
multiDexEnabled true

3
app/src/main/java/awais/instagrabber/MainHelper.java

@ -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();
}
}

1
app/src/main/java/awais/instagrabber/dialogs/SettingsDialog.java

@ -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, "");

1
app/src/main/java/awais/instagrabber/models/enums/IntentModelType.java

@ -5,4 +5,5 @@ public enum IntentModelType {
USERNAME,
POST,
HASHTAG,
LOCATION
}

2
app/src/main/java/awais/instagrabber/utils/Constants.java

@ -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 / [email protected]";
public static final String A_USER_AGENT = "https://InstaGrabber.AustinHuang.me / mailto:[email protected]";
// 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," +

2
app/src/main/java/awais/instagrabber/utils/FlavorTown.java

@ -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
}

41
app/src/main/java/awais/instagrabber/utils/UpdateChecker.java

@ -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 = "v" + (verMajor + 1) + ".0";
version = "";
// 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 (responseCode == HttpURLConnection.HTTP_MOVED_TEMP) {
version = conn.getHeaderField("Location").split("/v")[1];
return Float.parseFloat(version) > Float.parseFloat(BuildConfig.VERSION_NAME);
}
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
conn.disconnect();
return true;
}
}
}
} 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);
}
}

13
app/src/main/java/awais/instagrabber/utils/Utils.java

@ -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…
Cancel
Save