Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you configure "later" delay? #6

Open
rmohan80 opened this issue Apr 24, 2016 · 4 comments
Open

How do you configure "later" delay? #6

rmohan80 opened this issue Apr 24, 2016 · 4 comments
Labels

Comments

@rmohan80
Copy link
Contributor

Is tit the same as when you initially fire the rating?

@ocram ocram added the question label Apr 27, 2016
@ocram
Copy link
Contributor

ocram commented Apr 27, 2016

Thanks for your question!

Right now, it cannot be configured, yet. But this could be improved, of course :)

The current solution is implemented here.

Doesn't the default behaviour work for you?

@rmohan80
Copy link
Contributor Author

I'm sorry, but I don't understand the implementation completely. The "later" button again reminds user depending on the first launch preference, but will remind only after 24 hours whatever be the preference, is it?

Maybe this could be a Readme update?

@ocram
Copy link
Contributor

ocram commented Apr 30, 2016

You're right, the current implementation doesn't make any sense! Thank you :)

What about the following improvements?

Alternative 1

Replace ...

private void buttonLaterClick(SharedPreferences.Editor editor, DialogInterface dialog, long firstLaunchTime) {
    setFirstLaunchTime(editor, firstLaunchTime + DateUtils.DAY_IN_MILLIS);
    closeDialog(dialog);
}

... with ...

private void buttonLaterClick(SharedPreferences.Editor editor) {
    long daysToWait = 1;
    long manipulatedFirstLaunchTime = System.currentTimeMillis() - (mDaysBeforePrompt - daysToWait) * DateUtils.DAY_IN_MILLIS;
    setFirstLaunchTime(editor, manipulatedFirstLaunchTime);
}

Alternative 2

Replace ...

private void buttonLaterClick(SharedPreferences.Editor editor, DialogInterface dialog, long firstLaunchTime) {
    setFirstLaunchTime(editor, firstLaunchTime + DateUtils.DAY_IN_MILLIS);
    closeDialog(dialog);
}

...

if (System.currentTimeMillis() >= (firstLaunchTime + (mDaysBeforePrompt * DateUtils.DAY_IN_MILLIS))) {

... with ...

private void buttonLaterClick(SharedPreferences.Editor editor) {
    if (editor != null) {
        long daysToWait = 1;
        long oldDelay = prefs.getLong("delay", 0);
        editor.putLong("delay", oldDelay + daysToWait * DateUtils.DAY_IN_MILLIS);
        savePreferences(editor);
    }
}

...

long dontShowBefore = firstLaunchTime + (mDaysBeforePrompt * DateUtils.DAY_IN_MILLIS) + prefs.getLong("delay", 0);
if (System.currentTimeMillis() >= dontShowBefore) {

... using a new delay preference?

The first approach is shorter but the second approach is cleaner because it does not manipulate the date of the first launch retrospectively.

@rmohan80
Copy link
Contributor Author

I would prefer 2nd approach as it is more self-explanatory from a code readability perspective and as you mention it is cleaner.

I would also think a Readme update with a few lines explaining this would be good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants