mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 13:53:54 +01:00
Use wrapper for interacting with shared preferences (#2288)
* Use wrapper for accessing shared preferences across the app * Use Json kv store for storing place object * Fix tests * Fix test failure * Fix UI tests
This commit is contained in:
parent
1b7b909107
commit
d4fa9cfa45
61 changed files with 908 additions and 585 deletions
|
|
@ -21,12 +21,14 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.contributions.MainActivity;
|
||||
import fr.free.nrw.commons.kvstore.BasicKvStore;
|
||||
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||
import fr.free.nrw.commons.theme.NavigationBaseActivity;
|
||||
import fr.free.nrw.commons.utils.NetworkUtils;
|
||||
|
|
@ -48,8 +50,8 @@ public class NotificationActivity extends NavigationBaseActivity {
|
|||
@BindView(R.id.container) RelativeLayout relativeLayout;
|
||||
|
||||
@Inject NotificationController controller;
|
||||
@Inject
|
||||
MediaWikiApi mediaWikiApi;
|
||||
@Inject MediaWikiApi mediaWikiApi;
|
||||
@Inject @Named("last_read_notification_date") BasicKvStore kvStore;
|
||||
|
||||
private static final String TAG_NOTIFICATION_WORKER_FRAGMENT = "NotificationWorkerFragment";
|
||||
private NotificationWorkerFragment mNotificationWorkerFragment;
|
||||
|
|
@ -89,7 +91,7 @@ public class NotificationActivity extends NavigationBaseActivity {
|
|||
|
||||
// Store when add notification is called last
|
||||
long currentDate = new Date(System.currentTimeMillis()).getTime();
|
||||
getSharedPreferences("prefs", MODE_PRIVATE).edit().putLong("last_read_notification_date", currentDate).apply();
|
||||
kvStore.putLong("last_read_notification_date", currentDate);
|
||||
Timber.d("Set last notification read date to current date:"+ currentDate);
|
||||
|
||||
if(mNotificationWorkerFragment == null){
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class UnreadNotificationsCheckAsync extends AsyncTask<Void, Void, Notific
|
|||
}
|
||||
|
||||
Date lastNotificationCheckDate = new Date(context.get()
|
||||
.getSharedPreferences("prefs",0)
|
||||
.getSharedPreferences("defaultKvStore",0)
|
||||
.getLong("last_read_notification_date", 0));
|
||||
Timber.d("You may have unread notifications since"+lastNotificationCheckDate);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue