From 6393bbc02b1aa57af751cc06b2488034677d291d Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sat, 26 Sep 2020 21:02:31 -0400 Subject: [PATCH] fix id-load logic & location suggestions --- .../adapters/SuggestionsAdapter.java | 4 +++- .../instagrabber/fragments/HashTagFragment.java | 2 +- .../instagrabber/fragments/LocationFragment.java | 2 +- .../settings/SettingsPreferencesFragment.java | 3 +-- .../awais/instagrabber/utils/CookieUtils.java | 1 + .../instagrabber/utils/NavigationExtensions.java | 2 +- app/src/main/res/drawable/ic_location.png | Bin 0 -> 3869 bytes app/src/main/res/values/strings.xml | 2 +- 8 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/drawable/ic_location.png diff --git a/app/src/main/java/awais/instagrabber/adapters/SuggestionsAdapter.java b/app/src/main/java/awais/instagrabber/adapters/SuggestionsAdapter.java index 19412e37..154e83f2 100755 --- a/app/src/main/java/awais/instagrabber/adapters/SuggestionsAdapter.java +++ b/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 diff --git a/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java b/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java index 89941cfe..9eab384e 100644 --- a/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java +++ b/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() diff --git a/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java b/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java index e7190977..c8837682 100644 --- a/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java +++ b/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() diff --git a/app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java b/app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java index d2b2ef87..fda589f5 100644 --- a/app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java +++ b/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; } diff --git a/app/src/main/java/awais/instagrabber/utils/CookieUtils.java b/app/src/main/java/awais/instagrabber/utils/CookieUtils.java index a9421372..918dcf38 100644 --- a/app/src/main/java/awais/instagrabber/utils/CookieUtils.java +++ b/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()) { diff --git a/app/src/main/java/awais/instagrabber/utils/NavigationExtensions.java b/app/src/main/java/awais/instagrabber/utils/NavigationExtensions.java index 9af64d87..4343a103 100644 --- a/app/src/main/java/awais/instagrabber/utils/NavigationExtensions.java +++ b/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( diff --git a/app/src/main/res/drawable/ic_location.png b/app/src/main/res/drawable/ic_location.png new file mode 100644 index 0000000000000000000000000000000000000000..5d4d03e18f4318ee4908d4afb0d66ab400c55c24 GIT binary patch literal 3869 zcmV+&5908NP)004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00002 zVoOIv0RM-N%)bBt4me3fK~#9!?VWpYR96|mPeLf8j-A?3pgOjUHDgPrY9|)ypq=SZ zYpZRYwpI$Gt=9MgMVLx;v}*c@Ps~7((ORX7M5Yw2Z9}j~Uqc+gH8F|X-JDIsZrD6s zk^tQ#Bw_E*KXUeRclRdQO}-lvXTSX?lfC!sIp6)>udCF|LeZ8*)uo44`^xLLHtcGu z@%sYdU_2NPg#EsznucBVTYcq+R#%s9S)_{8{~wgj-&=BIUE}UxyGEl45vGkO9dyw{ zj2Jz1(Lt0p!h{&RD%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001 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f84c980a..426d57a6 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -34,7 +34,7 @@ Changelog Show toolbar at bottom Check for updates at startup - Download posts to username folder in Downloads + Download posts to username folders Auto-load all posts from user Mark stories as seen after viewing Story author will know you viewed it