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.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;
}

View file

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

View file

@ -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");

View file

@ -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();
}
}