mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 13:23:58 +01:00
Move storeSharedPrefs to fragment that is already injected
This commit is contained in:
parent
40495d91ab
commit
083564c906
3 changed files with 13 additions and 10 deletions
|
|
@ -31,7 +31,7 @@ public interface CommonsApplicationComponent extends AndroidInjector<CommonsAppl
|
||||||
|
|
||||||
void inject(MediaWikiImageView mediaWikiImageView);
|
void inject(MediaWikiImageView mediaWikiImageView);
|
||||||
|
|
||||||
void inject(DirectUpload directUpload);
|
//void inject(DirectUpload directUpload);
|
||||||
|
|
||||||
@Component.Builder
|
@Component.Builder
|
||||||
@SuppressWarnings({"WeakerAccess", "unused"})
|
@SuppressWarnings({"WeakerAccess", "unused"})
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ public class DirectUpload {
|
||||||
private Fragment fragment;
|
private Fragment fragment;
|
||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
|
|
||||||
@Inject @Named("direct_nearby_upload_prefs") SharedPreferences directPrefs;
|
|
||||||
|
|
||||||
DirectUpload(String title, String desc, Fragment fragment, ContributionController controller, SharedPreferences prefs) {
|
DirectUpload(String title, String desc, Fragment fragment, ContributionController controller, SharedPreferences prefs) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
|
@ -35,13 +35,7 @@ public class DirectUpload {
|
||||||
this.prefs = prefs;
|
this.prefs = prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void storeSharedPrefs() {
|
|
||||||
SharedPreferences.Editor editor = directPrefs.edit();
|
|
||||||
|
|
||||||
editor.putString("Title", title);
|
|
||||||
editor.putString("Desc", desc);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
void initiateCameraUpload() {
|
void initiateCameraUpload() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
private Marker selected;
|
private Marker selected;
|
||||||
|
|
||||||
@Inject @Named("prefs") SharedPreferences prefs;
|
@Inject @Named("prefs") SharedPreferences prefs;
|
||||||
|
@Inject @Named("direct_nearby_upload_prefs") SharedPreferences directPrefs;
|
||||||
|
|
||||||
public NearbyMapFragment() {
|
public NearbyMapFragment() {
|
||||||
}
|
}
|
||||||
|
|
@ -407,7 +408,7 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
Timber.d("Camera button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
|
Timber.d("Camera button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
|
||||||
controller = new ContributionController(this);
|
controller = new ContributionController(this);
|
||||||
DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller, prefs);
|
DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller, prefs);
|
||||||
directUpload.storeSharedPrefs();
|
storeSharedPrefs();
|
||||||
directUpload.initiateCameraUpload();
|
directUpload.initiateCameraUpload();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -415,11 +416,19 @@ public class NearbyMapFragment extends DaggerFragment {
|
||||||
Timber.d("Gallery button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
|
Timber.d("Gallery button tapped. Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
|
||||||
controller = new ContributionController(this);
|
controller = new ContributionController(this);
|
||||||
DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller, prefs);
|
DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller, prefs);
|
||||||
directUpload.storeSharedPrefs();
|
storeSharedPrefs();
|
||||||
directUpload.initiateGalleryUpload();
|
directUpload.initiateGalleryUpload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void storeSharedPrefs() {
|
||||||
|
SharedPreferences.Editor editor = directPrefs.edit();
|
||||||
|
|
||||||
|
editor.putString("Title", title);
|
||||||
|
editor.putString("Desc", desc);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
Timber.d("onRequestPermissionsResult: req code = " + " perm = " + permissions + " grant =" + grantResults);
|
Timber.d("onRequestPermissionsResult: req code = " + " perm = " + permissions + " grant =" + grantResults);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue