-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
Add an option to invalidate the quest cache #706
Conversation
Currently there is no confirmation dialog if the user clicks on the button (maybe even accidentally). Do you think that this should be added? |
It can be bothersome to reload all of it if you have a slow or no connection at the moment. If it's not too much work it may be a good idea :) |
Oh no, I think there has been a misunderstanding. The user should never have the option to delete all quests. Just the cache should be invalidated. More information in the comments below. |
Oops... |
{ | ||
SQLiteDatabase db = dbHelper.getReadableDatabase(); | ||
db.execSQL("DELETE FROM " + getTableName()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this, by the way, also deletes to-be-uploaded quests, reverted quests, ... everything.
app/src/main/res/xml/preferences.xml
Outdated
android:key="quests.deletion" | ||
android:title="@string/pref_title_quests_deletion" | ||
android:summary="@string/pref_title_quests_deletion_summary" | ||
android:widgetLayout="@layout/widget_image_delete" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I misuse the widget layout in some cases only to signal that something is a subpage or that something leads out of this app (into a browser). It should not be used to generally display an icon.
So I will close this for the first time |
So the option in the settings should be called "Invalidate Quest Cache" and what it should do is to clear the downloaded tiles table only. To clarify for the user, a message like the following should be shown: The quest cache is invalidated automatically after one week and immediately when a quest you solved turns out to be already answered by someone else." Optionally, the dialog could also ask whether to clear the cache just here (in the tile the user is looking at) or everywhere because I think for most users, the former is what they actually want to do. |
I'm sorry, this is maybe a dumb question, but how do I get the current shown tile (to be more precise: the Point I have to pass as an argument to |
It needs to be calculated from a LatLon: SlippyMapMath.enclosingTile(current position as lat lon, ApplicationConstants.QUEST_TILE_ZOOM) Now, getting that LatLon is the hard(er) part. Hint: MapFragment saves the current LatLon into SharedPreferences on onPause(). But this is all optional, you don't need to do it. |
Oh great thank you! I think this will help me a lot! |
"Shown tile" the "shown" is unnecessary IMHO. |
Not sure if the subtitle of the Invalidate Quest Cache is necessary. I do not want to put more text than necessary there. Opinions? Also, could you split the text into paragraphs, like I did in my comment? Finally, I wouldn't introduce the term "tile" to the user here, is is not introduced to the user anywhere and basically is just a technical detail. |
I have no idea how to change the order of the buttons... |
@@ -70,6 +70,12 @@ public int remove(Point tile) | |||
DownloadedTilesTable.Columns.Y + " = ?", whereArgs); | |||
} | |||
|
|||
public void removeAll() | |||
{ | |||
SQLiteDatabase db = dbHelper.getReadableDatabase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getWritableDatabase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -559,7 +560,7 @@ private void saveMapState() | |||
{ | |||
if(controller == null) return; | |||
|
|||
SharedPreferences.Editor editor = getActivity().getPreferences(Activity.MODE_PRIVATE).edit(); | |||
SharedPreferences.Editor editor = getActivity().getSharedPreferences(PREF_NAME, Activity.MODE_PRIVATE).edit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok,... that's the caveat. Hmm, it's a but ugly that other activities access the preferences of the map this way. But I don't have an idea right now to have a cleaner interface there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmh... me too...
@@ -57,6 +96,21 @@ public void onStart() | |||
getActivity().setTitle(R.string.action_settings); | |||
} | |||
|
|||
private Point getShownTile() | |||
{ | |||
SharedPreferences preferences = getActivity().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to have the static const here fully qualified, i.e. MapFragment.PREF_NAME etc. because this is the SettingsFragment, everything is settings and prefernces here. It is necessary to know the context of any such preference/settings.
LngLat pos = new LngLat( | ||
Double.longBitsToDouble(preferences.getLong(PREF_LON,0)), | ||
Double.longBitsToDouble(preferences.getLong(PREF_LAT,0)) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You create a LngLat here, and then convert the LngLat to a LatLon. Why not simply create a LatLon in the first place? (The default implementation of that interface is OsmLatLon)
} else | ||
{ | ||
Toast.makeText(getContext(), R.string.invalidation_error, Toast.LENGTH_SHORT).show(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave out the success and error messages. This will only confuse the users. Instead, just check if getShownTile() is null before building the dialog and only add that answer option ("Only this tile") if the current shown tile can be determined.
Or, optionally, if possible, show that option but disable it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if the invalidation succeeded, there should really be no success message?
Or, "Invalidate the cache?" - "Only here" - "Everywhere" |
The location of the positive - negative - cancel buttons is predefined by the Android system. Do not attempt to change it. |
Yeah
…On 24 November 2017 17:03:09 CET, ENT8R ***@***.***> wrote:
ENT8R commented on this pull request.
> @@ -47,6 +62,30 @@
getFragmentActivity().setCurrentFragment(new
QuestSelectionFragment());
return true;
});
+
+ Preference questsInvalidation =
getPreferenceScreen().findPreference("quests.invalidation");
+ questsInvalidation.setOnPreferenceClickListener(preference ->
+ {
+ new AlertDialogBuilder(getContext())
+ .setMessage(R.string.invalidation_dialog_message)
+ .setPositiveButton(R.string.invalidate_shown_tile, (dialog,
which) -> {
+ if (getShownTile() != null)
+ {
+ downloadedTilesDao.remove(getShownTile());
+ Toast.makeText(getContext(), R.string.invalidation_success,
Toast.LENGTH_SHORT).show();
+ } else
+ {
+ Toast.makeText(getContext(), R.string.invalidation_error,
Toast.LENGTH_SHORT).show();
+ }
But if the invalidation succeeded, there should really be **no**
success message?
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#706 (comment)
--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
|
Oh, that's a bug then!
…On 24 November 2017 17:17:53 CET, ENT8R ***@***.***> wrote:
ENT8R commented on this pull request.
> @@ -70,6 +70,12 @@ public int remove(Point tile)
DownloadedTilesTable.Columns.Y + " = ?", whereArgs);
}
+ public void removeAll()
+ {
+ SQLiteDatabase db = dbHelper.getReadableDatabase();
But you are doing the same here:
https://github.com/westnordost/StreetComplete/blob/fb3f6ccddf64e35ecb1576a7cb13471474d775f5/app/src/main/java/de/westnordost/streetcomplete/data/visiblequests/VisibleQuestTypeDao.java#L99
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#706 (comment)
--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
|
Should I fix it too? |
👍
…On 24 November 2017 17:45:01 CET, ENT8R ***@***.***> wrote:
This is how it looks now:
<img
src="https://user-images.githubusercontent.com/25306497/33218763-f57fe376-d13e-11e7-9966-48d8990733d5.png"
width="250px"> <img
src="https://user-images.githubusercontent.com/25306497/33218764-f5a2eab0-d13e-11e7-8cfe-1f744972692e.png"
width="250px">
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#706 (comment)
--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
|
Okay, but what does "Here" mean? I thought one selection clears the "map/tile cache" (maybe call it "map cache" to avoid the term "tile") and when choosing "everywhere" it invalidates the quest cache and the map cache. |
Mmhh... The intention behind this is that the user can redownload the quests in a specific tile (or even on the whole map), if he thinks that some of the quests are outdated, after clicking on one of the two buttons. The app knows where it downloaded quests already and where not. This information is stored in a database ( It's not intented for clearing the map cache... |
Ah so "here" makes sense. "In this area" would maybe be a bit more explicit/specific, but I admit that it may be too long. |
Hmm, yeah, actually... I think, @rugk ist right. You know, I have had to explain the mechanism with quest cache invalidation to various people what seemed to me a dozen times already. I had hoped that the implementation of such a "flush cache" button would bring this thing to a close (also using the confirmation message box to shortly explain the mechanism) but it seems the separation of "clear cache here" and "clear cache everywhere" is overengineered, in, that it actually adds to the confusion: Finally, I think it is not too necessary to have the user have such a finegrained control over where to clear the cache because after one week only, all his freshly downloaded quests will be invalidated anyway. Not deleted, just invalidated. All in all, my conclusion is to remove that "clear cache only here" option again. There is too little gain for the added complexity and confusion. Sorry about my idée fixe, first letting you implement this and then deciding otherwise. To accommodate, I can offer to remove these parts myself so you do not have to do that. |
No problem! I will do this tomorrow 😀 |
This is removed now |
.setPositiveButton(R.string.invalidate_confirmation, (dialog, which) -> { | ||
downloadedTilesDao.removeAll(); | ||
}) | ||
.setNegativeButton(android.R.string.cancel, (dialog, which) -> {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(dialog, which) -> {}
can be null
, by the way.
Looks good! Note that I will merge this into v4, as it contains both new strings and, well, is a new feature. (I will be not available the whole December to fix possible bugs, so I am very cautious right now). |
That's fine! |
This github resolve conflict editor does not seem to work. |
Awesome! You guys rock a lot! I really appreciate the app and all the effort you are putting into it! |
:-)
Am 8. Februar 2018 01:21:49 MEZ schrieb Pieter Vander Vennet <notifications@github.com>:
…Awesome! You guys rock a lot!
I really appreciate the app and all the effort you are putting into it!
--
You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub:
#706 (comment)
--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
|
This PR adds an option in the settings to easily delete all saved quests without needing to wipe the whole data of the app. This PR fixes #300