mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-11-04 08:43:52 +01:00 
			
		
		
		
	Move SharedPreferences injection into NearbyMapFragment
This commit is contained in:
		
							parent
							
								
									89d0f8da8f
								
							
						
					
					
						commit
						9a1a004a25
					
				
					 2 changed files with 12 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -23,15 +23,16 @@ class DirectUpload {
 | 
			
		|||
    private String desc;
 | 
			
		||||
    private ContributionController controller;
 | 
			
		||||
    private Fragment fragment;
 | 
			
		||||
    private SharedPreferences prefs;
 | 
			
		||||
 | 
			
		||||
    @Inject @Named("prefs") SharedPreferences prefs;
 | 
			
		||||
    @Inject @Named("default_preferences") SharedPreferences defaultPrefs;
 | 
			
		||||
 | 
			
		||||
    DirectUpload(String title, String desc, Fragment fragment, ContributionController controller) {
 | 
			
		||||
 | 
			
		||||
    DirectUpload(String title, String desc, Fragment fragment, ContributionController controller, SharedPreferences prefs) {
 | 
			
		||||
        this.title = title;
 | 
			
		||||
        this.desc = desc;
 | 
			
		||||
        this.fragment = fragment;
 | 
			
		||||
        this.controller = controller;
 | 
			
		||||
        this.prefs = prefs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void storeSharedPrefs() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
package fr.free.nrw.commons.nearby;
 | 
			
		||||
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
import android.content.SharedPreferences;
 | 
			
		||||
import android.content.pm.PackageManager;
 | 
			
		||||
import android.graphics.Color;
 | 
			
		||||
import android.net.Uri;
 | 
			
		||||
| 
						 | 
				
			
			@ -39,6 +40,9 @@ import java.lang.reflect.Type;
 | 
			
		|||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import javax.inject.Inject;
 | 
			
		||||
import javax.inject.Named;
 | 
			
		||||
 | 
			
		||||
import dagger.android.support.DaggerFragment;
 | 
			
		||||
import fr.free.nrw.commons.R;
 | 
			
		||||
import fr.free.nrw.commons.contributions.ContributionController;
 | 
			
		||||
| 
						 | 
				
			
			@ -86,6 +90,8 @@ public class NearbyMapFragment extends DaggerFragment {
 | 
			
		|||
    private Place place;
 | 
			
		||||
    private Marker selected;
 | 
			
		||||
 | 
			
		||||
    @Inject @Named("prefs") SharedPreferences prefs;
 | 
			
		||||
 | 
			
		||||
    public NearbyMapFragment() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -403,7 +409,7 @@ public class NearbyMapFragment extends DaggerFragment {
 | 
			
		|||
        fabCamera.setOnClickListener(view -> {
 | 
			
		||||
            Timber.d("Camera button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
 | 
			
		||||
            controller = new ContributionController(this);
 | 
			
		||||
            DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller);
 | 
			
		||||
            DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller, prefs);
 | 
			
		||||
            directUpload.storeSharedPrefs();
 | 
			
		||||
            directUpload.initiateCameraUpload();
 | 
			
		||||
        });
 | 
			
		||||
| 
						 | 
				
			
			@ -411,7 +417,7 @@ public class NearbyMapFragment extends DaggerFragment {
 | 
			
		|||
        fabGallery.setOnClickListener(view -> {
 | 
			
		||||
            Timber.d("Gallery button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
 | 
			
		||||
            controller = new ContributionController(this);
 | 
			
		||||
            DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller);
 | 
			
		||||
            DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller, prefs);
 | 
			
		||||
            directUpload.storeSharedPrefs();
 | 
			
		||||
            directUpload.initiateGalleryUpload();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue