Skip to content

Commit

Permalink
Merged
Browse files Browse the repository at this point in the history
  • Loading branch information
budowski committed Aug 18, 2024
2 parents 8bfacc4 + 2abc5ba commit 01ba7dc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,20 @@ public static String formatIdDate(Context context, Timestamp postDate, BetterJSO
// Only show month/year for observations that you don't own + obscured/private
INaturalistApp app = (INaturalistApp) context.getApplicationContext();
String currentUser = app.currentUserLogin();
String obsUser = null;

if (observation != null) {
if (observation.getJSONObject("user") != null &&
observation.getJSONObject("user").has("login")) {
obsUser = observation.getJSONObject("user").optString("login");
} else {
obsUser = observation.getString("user_login");
}
}
boolean obsByUser = observation != null &&
currentUser != null &&
observation.getJSONObject("user") != null &&
observation.getJSONObject("user").optString("login", "").equals(currentUser);
obsUser != null &&
obsUser.equals(currentUser);
boolean isPrivateOrObscured = false;

if (observation != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public class INaturalistApp extends MultiDexApplication implements OnMapsSdkInit
private long mAppStartTime;

private boolean mCalledStartForeground = false;
private String mInstallationID = null;

public boolean hasCalledStartForeground() {
return mCalledStartForeground;
Expand Down Expand Up @@ -157,6 +158,10 @@ public void setShownOnboarding(boolean value) {
mOnboardingShownBefore = true;
}

public String getInstallationID() {
return mInstallationID;
}

@Override
public void onMapsSdkInitialized(@NonNull MapsInitializer.Renderer renderer) {
switch (renderer) {
Expand Down Expand Up @@ -328,6 +333,14 @@ public void run() {
setShownOnboarding(true);
}

String installationID = pref.getString("installation_id", null);
if (installationID == null) {
installationID = UUID.randomUUID().toString();
pref.edit().putString("installation_id", installationID).apply();
}

mInstallationID = installationID;

// Clear out any old cached photos
Intent serviceIntent = new Intent(INaturalistService.ACTION_CLEAR_OLD_PHOTOS_CACHE, null, this, INaturalistService.class);
INaturalistService.callService(this, serviceIntent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5864,6 +5864,7 @@ private JSONArray request(String url, String method, ArrayList<Pair<String, Stri
.build();
Request.Builder requestBuilder = new Request.Builder()
.addHeader("User-Agent", getUserAgent(mApp))
.addHeader("X-Installation-ID", mApp.getInstallationID())
.url(url);

mRetryAfterDate = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,8 @@ private void refreshFavorites() {
mRemoveFavorite.setVisibility(View.GONE);
}

mFavoritesAdapter = new FavoritesAdapter(getActivity(), mFavorites, new BetterJSONObject(mObsJson));
mFavoritesAdapter = new FavoritesAdapter(getActivity(), mFavorites,
mObsJson != null ? new BetterJSONObject(mObsJson) : new BetterJSONObject(mObservation.toJSONObject()));
mFavoritesList.setAdapter(mFavoritesAdapter);

mRemoveFavorite.setOnClickListener(new OnClickListener() {
Expand Down

0 comments on commit 01ba7dc

Please sign in to comment.