diff --git a/android/src/com/mapswithme/maps/SplashActivity.java b/android/src/com/mapswithme/maps/SplashActivity.java index 6ab4e5209f..e4b01f6ef3 100644 --- a/android/src/com/mapswithme/maps/SplashActivity.java +++ b/android/src/com/mapswithme/maps/SplashActivity.java @@ -390,7 +390,7 @@ public class SplashActivity extends AppCompatActivity boolean showNews = NewsFragment.showOn(this, this); if (!showNews) { - if (ViralFragment.shouldDisplay()) + if (ViralFragment.shouldDisplay(getApplicationContext())) { UiUtils.hide(mIvLogo, mAppName); ViralFragment dialog = new ViralFragment(); diff --git a/android/src/com/mapswithme/maps/background/NotificationService.java b/android/src/com/mapswithme/maps/background/NotificationService.java index c82d59902d..e685b4cfb4 100644 --- a/android/src/com/mapswithme/maps/background/NotificationService.java +++ b/android/src/com/mapswithme/maps/background/NotificationService.java @@ -52,15 +52,16 @@ public class NotificationService extends JobIntentService return false; } - final long lastEventTimestamp = prefs().getLong(LAST_AUTH_NOTIFICATION_TIMESTAMP, 0); + final long lastEventTimestamp = prefs(getApplicationContext()) + .getLong(LAST_AUTH_NOTIFICATION_TIMESTAMP, 0); if (System.currentTimeMillis() - lastEventTimestamp > MIN_AUTH_EVENT_DELTA_MILLIS) { LOGGER.d(TAG, "Authentication notification will be sent."); - prefs().edit() - .putLong(LAST_AUTH_NOTIFICATION_TIMESTAMP, System.currentTimeMillis()) - .apply(); + prefs(getApplicationContext()).edit() + .putLong(LAST_AUTH_NOTIFICATION_TIMESTAMP, System.currentTimeMillis()) + .apply(); Notifier notifier = Notifier.from(getApplication()); notifier.notifyAuthentication(); diff --git a/android/src/com/mapswithme/maps/editor/EditorHostFragment.java b/android/src/com/mapswithme/maps/editor/EditorHostFragment.java index 4ed198595e..52644149e5 100644 --- a/android/src/com/mapswithme/maps/editor/EditorHostFragment.java +++ b/android/src/com/mapswithme/maps/editor/EditorHostFragment.java @@ -291,7 +291,7 @@ public class EditorHostFragment extends BaseMwmToolbarFragment return; // Save object edits - if (!MwmApplication.prefs().contains(NOOB_ALERT_SHOWN)) + if (!MwmApplication.prefs(requireContext()).contains(NOOB_ALERT_SHOWN)) { showNoobDialog(); } @@ -385,7 +385,7 @@ public class EditorHostFragment extends BaseMwmToolbarFragment @Override public void onClick(DialogInterface dlg, int which) { - MwmApplication.prefs().edit() + MwmApplication.prefs(requireContext()).edit() .putBoolean(NOOB_ALERT_SHOWN, true) .apply(); saveNote(); diff --git a/android/src/com/mapswithme/maps/editor/ViralFragment.java b/android/src/com/mapswithme/maps/editor/ViralFragment.java index 97a1b352f5..87ada6337a 100644 --- a/android/src/com/mapswithme/maps/editor/ViralFragment.java +++ b/android/src/com/mapswithme/maps/editor/ViralFragment.java @@ -1,8 +1,11 @@ package com.mapswithme.maps.editor; import android.annotation.SuppressLint; +import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; + +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; @@ -30,9 +33,9 @@ public class ViralFragment extends BaseMwmDialogFragment @Nullable private Runnable mDismissListener; - public static boolean shouldDisplay() + public static boolean shouldDisplay(@NonNull Context context) { - return !MwmApplication.prefs().contains(EXTRA_CONGRATS_SHOWN) && + return !MwmApplication.prefs(context).contains(EXTRA_CONGRATS_SHOWN) && Editor.nativeGetStats()[0] == 2 && ConnectionState.isConnected(); } @@ -47,7 +50,7 @@ public class ViralFragment extends BaseMwmDialogFragment @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - MwmApplication.prefs().edit().putBoolean(EXTRA_CONGRATS_SHOWN, true).apply(); + MwmApplication.prefs(requireContext()).edit().putBoolean(EXTRA_CONGRATS_SHOWN, true).apply(); @SuppressLint("InflateParams") final View root = inflater.inflate(R.layout.fragment_editor_viral, null); diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 313f024eef..820013b680 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -399,7 +399,7 @@ public class PlacePageView extends NestedScrollViewClickFixed public PlacePageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs); - mIsLatLonDms = MwmApplication.prefs().getBoolean(PREF_USE_DMS, false); + mIsLatLonDms = MwmApplication.prefs(context).getBoolean(PREF_USE_DMS, false); mGalleryAdapter = new com.mapswithme.maps.widget.placepage.GalleryAdapter(context); init(attrs, defStyleAttr); } @@ -1858,7 +1858,7 @@ public class PlacePageView extends NestedScrollViewClickFixed break; case R.id.ll__place_latlon: mIsLatLonDms = !mIsLatLonDms; - MwmApplication.prefs().edit().putBoolean(PREF_USE_DMS, mIsLatLonDms).apply(); + MwmApplication.prefs(getContext()).edit().putBoolean(PREF_USE_DMS, mIsLatLonDms).apply(); if (mMapObject == null) { LOGGER.e(TAG, "A LatLon cannot be refreshed, mMapObject is null");