This commit is contained in:
veliymolfar 2020-01-17 15:45:01 +02:00
parent 1e28fa3c20
commit 8e3b9f7e1d
4 changed files with 8 additions and 22 deletions

View file

@ -29,7 +29,6 @@ import net.osmand.plus.activities.LocalIndexHelper;
import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.LocalIndexInfo;
import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dialogs.RateUsBottomSheetDialog.RateUsState;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask; import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask;
import net.osmand.plus.helpers.AvoidSpecificRoads; 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_UPDATE_CARD.set(true);
app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_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; initSettings = true;
} }

View file

@ -3215,8 +3215,8 @@ public class OsmandSettings {
public final OsmandPreference<Long> LAST_CHECKED_UPDATES = public final OsmandPreference<Long> LAST_CHECKED_UPDATES =
new LongPreference("last_checked_updates", 0).makeGlobal(); new LongPreference("last_checked_updates", 0).makeGlobal();
public final OsmandPreference<Integer> NUMBER_OF_APP_STARTS_AFTER_DISLIKE = public final OsmandPreference<Integer> NUMBER_OF_APP_STARTS_ON_DISLIKE_MOMENT =
new IntPreference("number_of_app_starts_after_dislike", 0).makeGlobal().cache(); new IntPreference("number_of_app_starts_on_dislike_moment", 0).makeGlobal().cache();
public final OsmandPreference<RateUsBottomSheetDialog.RateUsState> RATE_US_STATE = public final OsmandPreference<RateUsBottomSheetDialog.RateUsState> RATE_US_STATE =
new EnumIntPreference<>("rate_us_state", new EnumIntPreference<>("rate_us_state",

View file

@ -46,7 +46,7 @@ public class DislikeOsmAndBottomSheetDialogFragment extends MenuBottomSheetDialo
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
if (app != null) { if (app != null) {
app.getSettings().RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITHOUT_MESSAGE); 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()); app.getSettings().LAST_DISPLAY_TIME.set(System.currentTimeMillis());
} }
} }
@ -63,7 +63,7 @@ public class DislikeOsmAndBottomSheetDialogFragment extends MenuBottomSheetDialo
OsmandSettings settings = app.getSettings(); OsmandSettings settings = app.getSettings();
String email = getString(R.string.support_email); String email = getString(R.string.support_email);
settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITH_MESSAGE); 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()); settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis());
Intent sendEmail = new Intent(Intent.ACTION_SENDTO); Intent sendEmail = new Intent(Intent.ACTION_SENDTO);
sendEmail.setDataAndType(Uri.parse("mailto:" + email), "text/plain"); sendEmail.setDataAndType(Uri.parse("mailto:" + email), "text/plain");

View file

@ -17,7 +17,6 @@ import net.osmand.plus.R;
import net.osmand.plus.Version; import net.osmand.plus.Version;
import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.base.BottomSheetDialogFragment;
import java.util.Calendar;
public class RateUsBottomSheetDialog extends BottomSheetDialogFragment { public class RateUsBottomSheetDialog extends BottomSheetDialogFragment {
private RateUsBottomSheetDialog.FragmentState state = RateUsBottomSheetDialog.FragmentState.INITIAL_STATE; private RateUsBottomSheetDialog.FragmentState state = RateUsBottomSheetDialog.FragmentState.INITIAL_STATE;
@ -56,13 +55,11 @@ public class RateUsBottomSheetDialog extends BottomSheetDialogFragment {
case IGNORED: case IGNORED:
case DISLIKED_WITH_MESSAGE: case DISLIKED_WITH_MESSAGE:
case DISLIKED_WITHOUT_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(); long lastDisplayTimeInMillis = settings.LAST_DISPLAY_TIME.get();
Calendar modifiedTime = Calendar.getInstance(); long currentTime = System.currentTimeMillis();
modifiedTime.add(Calendar.DAY_OF_YEAR, -60); return currentTime - lastDisplayTimeInMillis > 5_184_000_000L
Calendar lastDisplayTime = Calendar.getInstance(); && numberOfStarts - startsOnDislikeMoment > 50;
lastDisplayTime.setTimeInMillis(lastDisplayTimeInMillis);
return modifiedTime.after(lastDisplayTime) && startsAfterDislike > 50;
} }
return false; return false;
} }
@ -102,8 +99,6 @@ public class RateUsBottomSheetDialog extends BottomSheetDialogFragment {
case USER_DISLIKES_APP: case USER_DISLIKES_APP:
String email = getString(R.string.support_email); String email = getString(R.string.support_email);
settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITH_MESSAGE); 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); Intent sendEmail = new Intent(Intent.ACTION_SENDTO);
sendEmail.setType("text/plain"); sendEmail.setType("text/plain");
sendEmail.setData(Uri.parse("mailto:" + email)); 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); settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITHOUT_MESSAGE);
break; break;
} }
settings.NUMBER_OF_APP_STARTS_AFTER_DISLIKE.set(0);
settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis());
dismiss(); dismiss();
} }
} }