diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 8ecaca958b..095a819a2a 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -29,7 +29,6 @@ import net.osmand.plus.activities.LocalIndexHelper; import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.base.MapViewTrackingUtilities; -import net.osmand.plus.dialogs.RateUsBottomSheetDialog.RateUsState; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask; import net.osmand.plus.helpers.AvoidSpecificRoads; @@ -213,12 +212,6 @@ public class AppInitializer implements IProgress { } app.getSettings().SHOW_TRAVEL_UPDATE_CARD.set(true); app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.set(true); - - RateUsState rateUsState = app.getSettings().RATE_US_STATE.get(); - if (rateUsState != RateUsState.INITIAL_STATE && rateUsState != RateUsState.LIKED) { - int startsAfterDismiss = app.getSettings().NUMBER_OF_APP_STARTS_AFTER_DISLIKE.get(); - app.getSettings().NUMBER_OF_APP_STARTS_AFTER_DISLIKE.set(startsAfterDismiss + 1); - } initSettings = true; } diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index e29ca9da5a..d494eb3c4a 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -3215,8 +3215,8 @@ public class OsmandSettings { public final OsmandPreference LAST_CHECKED_UPDATES = new LongPreference("last_checked_updates", 0).makeGlobal(); - public final OsmandPreference NUMBER_OF_APP_STARTS_AFTER_DISLIKE = - new IntPreference("number_of_app_starts_after_dislike", 0).makeGlobal().cache(); + public final OsmandPreference NUMBER_OF_APP_STARTS_ON_DISLIKE_MOMENT = + new IntPreference("number_of_app_starts_on_dislike_moment", 0).makeGlobal().cache(); public final OsmandPreference RATE_US_STATE = new EnumIntPreference<>("rate_us_state", diff --git a/OsmAnd/src/net/osmand/plus/dialogs/DislikeOsmAndBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/DislikeOsmAndBottomSheetDialogFragment.java index 57ca2fdd8a..c1708b4a85 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/DislikeOsmAndBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/DislikeOsmAndBottomSheetDialogFragment.java @@ -46,7 +46,7 @@ public class DislikeOsmAndBottomSheetDialogFragment extends MenuBottomSheetDialo OsmandApplication app = getMyApplication(); if (app != null) { app.getSettings().RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITHOUT_MESSAGE); - app.getSettings().NUMBER_OF_APP_STARTS_AFTER_DISLIKE.set(0); + app.getSettings().NUMBER_OF_APP_STARTS_ON_DISLIKE_MOMENT.set(app.getAppInitializer().getNumberOfStarts()); app.getSettings().LAST_DISPLAY_TIME.set(System.currentTimeMillis()); } } @@ -63,7 +63,7 @@ public class DislikeOsmAndBottomSheetDialogFragment extends MenuBottomSheetDialo OsmandSettings settings = app.getSettings(); String email = getString(R.string.support_email); settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITH_MESSAGE); - settings.NUMBER_OF_APP_STARTS_AFTER_DISLIKE.set(0); + settings.NUMBER_OF_APP_STARTS_ON_DISLIKE_MOMENT.set(app.getAppInitializer().getNumberOfStarts()); settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis()); Intent sendEmail = new Intent(Intent.ACTION_SENDTO); sendEmail.setDataAndType(Uri.parse("mailto:" + email), "text/plain"); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialog.java b/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialog.java index eeb5b72bdf..424ba9c6ba 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialog.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialog.java @@ -17,7 +17,6 @@ import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.base.BottomSheetDialogFragment; -import java.util.Calendar; public class RateUsBottomSheetDialog extends BottomSheetDialogFragment { private RateUsBottomSheetDialog.FragmentState state = RateUsBottomSheetDialog.FragmentState.INITIAL_STATE; @@ -56,13 +55,11 @@ public class RateUsBottomSheetDialog extends BottomSheetDialogFragment { case IGNORED: case DISLIKED_WITH_MESSAGE: case DISLIKED_WITHOUT_MESSAGE: - int startsAfterDislike = settings.NUMBER_OF_APP_STARTS_AFTER_DISLIKE.get(); + int startsOnDislikeMoment = settings.NUMBER_OF_APP_STARTS_ON_DISLIKE_MOMENT.get(); long lastDisplayTimeInMillis = settings.LAST_DISPLAY_TIME.get(); - Calendar modifiedTime = Calendar.getInstance(); - modifiedTime.add(Calendar.DAY_OF_YEAR, -60); - Calendar lastDisplayTime = Calendar.getInstance(); - lastDisplayTime.setTimeInMillis(lastDisplayTimeInMillis); - return modifiedTime.after(lastDisplayTime) && startsAfterDislike > 50; + long currentTime = System.currentTimeMillis(); + return currentTime - lastDisplayTimeInMillis > 5_184_000_000L + && numberOfStarts - startsOnDislikeMoment > 50; } return false; } @@ -102,8 +99,6 @@ public class RateUsBottomSheetDialog extends BottomSheetDialogFragment { case USER_DISLIKES_APP: String email = getString(R.string.support_email); settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITH_MESSAGE); - settings.NUMBER_OF_APP_STARTS_AFTER_DISLIKE.set(0); - settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis()); Intent sendEmail = new Intent(Intent.ACTION_SENDTO); sendEmail.setType("text/plain"); sendEmail.setData(Uri.parse("mailto:" + email)); @@ -148,8 +143,6 @@ public class RateUsBottomSheetDialog extends BottomSheetDialogFragment { settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITHOUT_MESSAGE); break; } - settings.NUMBER_OF_APP_STARTS_AFTER_DISLIKE.set(0); - settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis()); dismiss(); } }