Browse Source

fix id-load logic & location suggestions

renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
6393bbc02b
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 4
      app/src/main/java/awais/instagrabber/adapters/SuggestionsAdapter.java
  2. 2
      app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java
  3. 2
      app/src/main/java/awais/instagrabber/fragments/LocationFragment.java
  4. 3
      app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java
  5. 1
      app/src/main/java/awais/instagrabber/utils/CookieUtils.java
  6. 2
      app/src/main/java/awais/instagrabber/utils/NavigationExtensions.java
  7. BIN
      app/src/main/res/drawable/ic_location.png
  8. 2
      app/src/main/res/values/strings.xml

4
app/src/main/java/awais/instagrabber/adapters/SuggestionsAdapter.java

@ -10,6 +10,7 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.cursoradapter.widget.CursorAdapter;
import awais.instagrabber.R;
import awais.instagrabber.databinding.ItemSuggestionBinding;
import awais.instagrabber.models.enums.SuggestionType;
@ -38,7 +39,7 @@ public final class SuggestionsAdapter extends CursorAdapter {
// 0, 1 , 2 , 3 , 4 , 5
final String fullName = cursor.getString(2);
String username = cursor.getString(1);
final String picUrl = cursor.getString(4);
String picUrl = cursor.getString(4);
final boolean verified = cursor.getString(5).charAt(0) == 't';
final String type = cursor.getString(3);
@ -61,6 +62,7 @@ public final class SuggestionsAdapter extends CursorAdapter {
break;
case TYPE_LOCATION:
query = fullName;
picUrl = "res:/" + R.drawable.ic_location;
break;
default:
return; // will never come here

2
app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java

@ -233,7 +233,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
if (postModels == null || postModels.size() == 0) return;
if (postModels.get(0) == null) return;
final String postId = postModels.get(0).getPostId();
final boolean isId = postId != null;
final boolean isId = postId != null && isLoggedIn;
final String[] idsOrShortCodes = new String[postModels.size()];
for (int i = 0; i < postModels.size(); i++) {
idsOrShortCodes[i] = isId ? postModels.get(i).getPostId()

2
app/src/main/java/awais/instagrabber/fragments/LocationFragment.java

@ -236,7 +236,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
if (postModels == null || postModels.size() == 0) return;
if (postModels.get(0) == null) return;
final String postId = postModels.get(0).getPostId();
final boolean isId = postId != null;
final boolean isId = postId != null && isLoggedIn;
final String[] idsOrShortCodes = new String[postModels.size()];
for (int i = 0; i < postModels.size(); i++) {
idsOrShortCodes[i] = isId ? postModels.get(i).getPostId()

3
app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java

@ -168,8 +168,7 @@ public class SettingsPreferencesFragment extends BasePreferencesFragment {
if (context == null) return null;
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
preference.setKey(Constants.DOWNLOAD_USER_FOLDER);
preference.setTitle("Download to username folder");
preference.setSummary(R.string.download_user_folder);
preference.setTitle(R.string.download_user_folder);
preference.setIconSpaceReserved(false);
return preference;
}

1
app/src/main/java/awais/instagrabber/utils/CookieUtils.java

@ -69,6 +69,7 @@ public final class CookieUtils {
@Nullable
private static String getCookieValue(final String cookies, final String name) {
if (cookies == null) return null;
final Pattern pattern = Pattern.compile(name + "=(.+?);");
final Matcher matcher = pattern.matcher(cookies);
if (matcher.find()) {

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

@ -66,7 +66,7 @@ public class NavigationExtensions {
// throw new RuntimeException("null cannot be cast to non-null NavHostFragment");
}
final NavHostFragment selectedFragment = (NavHostFragment) fragment;
if (!firstFragmentTag.equals(newlySelectedItemTag)) {
if (firstFragmentTag != null && !firstFragmentTag.equals(newlySelectedItemTag)) {
FragmentTransaction fragmentTransaction = fragmentManager
.beginTransaction()
.setCustomAnimations(

BIN
app/src/main/res/drawable/ic_location.png

After

Width: 132  |  Height: 132  |  Size: 3.8 KiB

2
app/src/main/res/values/strings.xml

@ -34,7 +34,7 @@
<string name="title_changelog">Changelog</string>
<string name="bottom_toolbar">Show toolbar at bottom</string>
<string name="update_check">Check for updates at startup</string>
<string name="download_user_folder">Download posts to username folder in Downloads</string>
<string name="download_user_folder">Download posts to username folders</string>
<string name="autoload_posts">Auto-load all posts from user</string>
<string name="mark_as_seen_setting">Mark stories as seen after viewing</string>
<string name="mark_as_seen_setting_summary">Story author will know you viewed it</string>

Loading…
Cancel
Save