Users served in the past 24hrs
closes #6 (closed)
Merge request reports
Activity
added 10 commits
-
6b288d37...7cac3c5b - 2 commits from branch
tpo/anti-censorship/pluggable-transports:master
- c6936875 - Moved creation of shared preferences to GlobalApplication
- a6ce892d - Added checkServedDate method
- 78ef0ce6 - Launched checkServedDate on another thread and fixed date parsing exception
- 18a2285e - Updated user_served in MyPersistentService
- 154331c5 - Fetched the count in the MainFragment and logged it
- c24291af - Added text view to show the user how many clients he has served
- 4b8579aa - Extracted string resouce from user served text view
- ab9b4f1d - Refactored .xml MainFragment code
Toggle commit list-
6b288d37...7cac3c5b - 2 commits from branch
308 320 309 321 if (STATE == DataChannel.State.OPEN) { 310 322 updateNotification("Connection Established. Serving one client."); 323 updateServedCount(); @cohosh It's working fine for me... it only updates if the connection is established (i.e when DataChannel is Open) can you restart your Snowbox? can you confirm that you are looking at the log of the correct client?
Additionally, can you please confirm that you are checking out the right branch? this is a trivial suggestion but worth looking out I guess.
Ah alright I'm seeing the notification and that the code path is being executed (I was looking for it in the logs). I'm not seeing the UI update though. Even if I switch to settings and back, or toggle the services off and on the users served stays the same. The only way I got it to update was by killing the app and restarting it.
Is there a good way to address this here, or should we do it in the changes for #11 (closed) ?
@cohosh made the patch. Please try again.
5 5 <string name="not_channel_desc">This Channel should not be muted. The Android system will consider Snowflake not import and will kill the service if it\'s muted.</string> 6 6 <string name="initial_run_boolean">initial_run</string> 7 7 <string name="not_channel_name">Snowflake Service</string> 8 <string name="users_served">users_served</string> 9 <string name="served_date">date</string> The resource compiler looks for all the "strings.xml" files, we can create a separate file. I'll do that if you want me to. And let me know how to segregate the strings and files. Another approach is to comment on this same file separating/diving the file into sections.
Edited by HashikDLet's make them completely separate files at least. In general I don't like the idea of storing these values in the application's "preferences" since they are stored usage data and don't have anything to do with preferences. It seems like we should be storing this using the app's internal storage. Can we also store the count of users served directly as an int and not a string?
Sorry, I am a little confused. SharedPrefernces are widely used for storing data in Android.
Apart from that, there is SQLite to store data but it's used in cases where we have to search through a bunch of data.
For our use case, SharedPreferences are perfect since we are having just key-value pairs, not a repeated set of data. Many apps actually use it to store session data as-well like cookies (but mostly in encrypted form)
Can we also store the count of users served directly as an int and not a string?
We are, hence the call "getInt" and "putInt" on shared preference handling users_served.
Does this answer what you were asking? or am I talking about different things? I am not sure what you meant by the app's internal storage tho, we can call these shared preferences the internal storage for the application.
Edited by HashikDSharedPrefernces are widely used for storing data in Android. For our use case, SharedPreferences are perfect since we are having just key-value pairs, not a repeated set of data. Many apps actually use it to store session data as-well like cookies (but mostly in encrypted form)
Okay that's fine, I'll defer to your judgement here. But we should still split out these files to avoid confusion. IMO we should have one file for string constants, and one file for stored data.
We are, hence the call "getInt" and "putInt" on shared preference handling users_served.
We're still storing them as strings in the xml file:
<string name="users_served">users_served</string>
, and handling them as strings before the call togetInt
:sp.getInt(getString(R.string.users_served), 0) + 1)
If this is how things are usually done, that's fine. But it surprises me that we'd have to store this value as a string at all.
Ah okay! Now I got what you are saying. Anything is fine, Android OS will compile these String resources and put it on to the main memory into a lookup table. So, there is no performance benefit to either. So, we can create constants.
But, Android official documentation did it our way, and personally I got used to it and many devs do it too.
changed this line in version 5 of the diff
added 1 commit
- 689949d2 - Updating the count of users served even when the app is in foreground
added 1 commit
- dafed99d - Moved and renamed String.xml SharedPreference keys
Alright let's merge this. Thanks @HashikD!