mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 05:43:55 +01:00
Consolidate shared prefs to a single store (#2613)
* Consolidate shared prefs to a single store * Fix achievements activity * Fix store usage
This commit is contained in:
parent
51f58b7118
commit
7cb87f3cab
41 changed files with 207 additions and 279 deletions
|
|
@ -27,14 +27,12 @@ import com.google.gson.Gson;
|
|||
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.contributions.MainActivity;
|
||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||
import fr.free.nrw.commons.kvstore.BasicKvStore;
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
import fr.free.nrw.commons.location.LocationServiceManager;
|
||||
import fr.free.nrw.commons.location.LocationUpdateListener;
|
||||
|
|
@ -76,9 +74,6 @@ public class NearbyFragment extends CommonsDaggerSupportFragment
|
|||
NearbyController nearbyController;
|
||||
@Inject
|
||||
WikidataEditListener wikidataEditListener;
|
||||
@Inject
|
||||
@Named("application_preferences")
|
||||
BasicKvStore applicationKvStore;
|
||||
@Inject Gson gson;
|
||||
|
||||
public NearbyMapFragment nearbyMapFragment;
|
||||
|
|
|
|||
|
|
@ -15,15 +15,12 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.contributions.ContributionController;
|
||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||
import fr.free.nrw.commons.kvstore.BasicKvStore;
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
|
@ -39,8 +36,6 @@ public class NearbyListFragment extends CommonsDaggerSupportFragment {
|
|||
private RecyclerView recyclerView;
|
||||
|
||||
@Inject ContributionController controller;
|
||||
@Inject @Named("direct_nearby_upload_prefs") JsonKvStore directKvStore;
|
||||
@Inject @Named("default_preferences") BasicKvStore defaultKvStore;
|
||||
@Inject Gson gson;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -8,13 +8,6 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
@ -29,6 +22,8 @@ import android.widget.ProgressBar;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
|
|
@ -53,6 +48,11 @@ import java.util.List;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
|
||||
import dagger.android.support.DaggerFragment;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.R;
|
||||
|
|
@ -60,7 +60,6 @@ import fr.free.nrw.commons.Utils;
|
|||
import fr.free.nrw.commons.auth.LoginActivity;
|
||||
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
|
||||
import fr.free.nrw.commons.contributions.ContributionController;
|
||||
import fr.free.nrw.commons.kvstore.BasicKvStore;
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||
import fr.free.nrw.commons.utils.LocationUtils;
|
||||
import fr.free.nrw.commons.utils.UiUtils;
|
||||
|
|
@ -129,10 +128,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
private Bundle bundleForUpdates;// Carry information from activity about changed nearby places and current location
|
||||
private boolean searchedAroundCurrentLocation = true;
|
||||
|
||||
@Inject @Named("application_preferences") BasicKvStore applicationKvStore;
|
||||
@Inject @Named("defaultKvStore") BasicKvStore prefs;
|
||||
@Inject @Named("direct_nearby_upload_prefs") JsonKvStore directKvStore;
|
||||
@Inject @Named("default_preferences") BasicKvStore defaultKvStore;
|
||||
@Inject @Named("default_preferences") JsonKvStore applicationKvStore;
|
||||
@Inject BookmarkLocationsDao bookmarkLocationDao;
|
||||
@Inject ContributionController controller;
|
||||
@Inject Gson gson;
|
||||
|
|
@ -512,7 +508,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
*/
|
||||
private void setupMapView(Bundle savedInstanceState) {
|
||||
Timber.d("setupMapView called");
|
||||
boolean isDarkTheme = defaultKvStore.getBoolean("theme", false);
|
||||
boolean isDarkTheme = applicationKvStore.getBoolean("theme", false);
|
||||
MapboxMapOptions options = new MapboxMapOptions()
|
||||
.compassGravity(Gravity.BOTTOM | Gravity.LEFT)
|
||||
.compassMargins(new int[]{12, 0, 0, 24})
|
||||
|
|
@ -900,7 +896,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
|
||||
void storeSharedPrefs() {
|
||||
Timber.d("Store place object %s", place.toString());
|
||||
directKvStore.putJson(PLACE_OBJECT, place);
|
||||
applicationKvStore.putJson(PLACE_OBJECT, place);
|
||||
}
|
||||
|
||||
private void openWebView(Uri link) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import fr.free.nrw.commons.auth.LoginActivity;
|
|||
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
|
||||
import fr.free.nrw.commons.contributions.ContributionController;
|
||||
import fr.free.nrw.commons.di.ApplicationlessInjection;
|
||||
import fr.free.nrw.commons.kvstore.BasicKvStore;
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
|
@ -69,10 +68,9 @@ public class PlaceRenderer extends Renderer<Place> {
|
|||
private OnBookmarkClick onBookmarkClick;
|
||||
|
||||
@Inject BookmarkLocationsDao bookmarkLocationDao;
|
||||
@Inject @Named("application_preferences") BasicKvStore applicationKvStore;
|
||||
@Inject @Named("defaultKvStore") BasicKvStore prefs;
|
||||
@Inject @Named("direct_nearby_upload_prefs") JsonKvStore directKvStore;
|
||||
@Inject @Named("default_preferences") BasicKvStore defaultKvStore;
|
||||
@Inject
|
||||
@Named("default_preferences")
|
||||
JsonKvStore applicationKvStore;
|
||||
|
||||
public PlaceRenderer(){
|
||||
openedItems = new ArrayList<>();
|
||||
|
|
@ -138,7 +136,7 @@ public class PlaceRenderer extends Renderer<Place> {
|
|||
.setPositiveButton(R.string.login, (dialog, which) -> {
|
||||
startActivityWithFlags( getContext(), LoginActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
||||
Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
prefs.putBoolean("login_skipped", false);
|
||||
applicationKvStore.putBoolean("login_skipped", false);
|
||||
fragment.getActivity().finish();
|
||||
})
|
||||
.show();
|
||||
|
|
@ -158,7 +156,7 @@ public class PlaceRenderer extends Renderer<Place> {
|
|||
.setPositiveButton(R.string.login, (dialog, which) -> {
|
||||
startActivityWithFlags( getContext(), LoginActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
||||
Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
prefs.putBoolean("login_skipped", false);
|
||||
applicationKvStore.putBoolean("login_skipped", false);
|
||||
fragment.getActivity().finish();
|
||||
})
|
||||
.show();
|
||||
|
|
@ -177,7 +175,7 @@ public class PlaceRenderer extends Renderer<Place> {
|
|||
.setPositiveButton(R.string.login, (dialog, which) -> {
|
||||
startActivityWithFlags( getContext(), LoginActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
||||
Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
prefs.putBoolean("login_skipped", false);
|
||||
applicationKvStore.putBoolean("login_skipped", false);
|
||||
fragment.getActivity().finish();
|
||||
})
|
||||
.show();
|
||||
|
|
@ -197,7 +195,7 @@ public class PlaceRenderer extends Renderer<Place> {
|
|||
|
||||
private void storeSharedPrefs() {
|
||||
Timber.d("Store place object %s", place.toString());
|
||||
directKvStore.putJson(PLACE_OBJECT, place);
|
||||
applicationKvStore.putJson(PLACE_OBJECT, place);
|
||||
}
|
||||
|
||||
private void closeLayout(LinearLayout buttonLayout){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue