mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
@Injected shared preferences where needed
This commit is contained in:
parent
1b840502a9
commit
9aa021695b
20 changed files with 137 additions and 100 deletions
|
|
@ -3,7 +3,6 @@ package fr.free.nrw.commons;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.stetho.Stetho;
|
||||
|
|
@ -16,6 +15,7 @@ import org.acra.annotation.ReportsCrashes;
|
|||
import java.io.File;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import dagger.android.AndroidInjector;
|
||||
import dagger.android.DaggerApplication;
|
||||
|
|
@ -27,7 +27,6 @@ import fr.free.nrw.commons.di.CommonsApplicationComponent;
|
|||
import fr.free.nrw.commons.di.CommonsApplicationModule;
|
||||
import fr.free.nrw.commons.di.DaggerCommonsApplicationComponent;
|
||||
import fr.free.nrw.commons.modifications.ModifierSequence;
|
||||
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||
import fr.free.nrw.commons.utils.FileUtils;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
|
@ -44,9 +43,11 @@ import timber.log.Timber;
|
|||
)
|
||||
public class CommonsApplication extends DaggerApplication {
|
||||
|
||||
@Inject MediaWikiApi mediaWikiApi;
|
||||
@Inject SessionManager sessionManager;
|
||||
@Inject DBOpenHelper dbOpenHelper;
|
||||
@Inject @Named("default_preferences") SharedPreferences defaultPrefs;
|
||||
@Inject @Named("application_preferences") SharedPreferences applicationPrefs;
|
||||
@Inject @Named("prefs") SharedPreferences otherPrefs;
|
||||
|
||||
public static final Object[] EVENT_UPLOAD_ATTEMPT = {"MobileAppUploadAttempts", 5334329L};
|
||||
public static final Object[] EVENT_LOGIN_ATTEMPT = {"MobileAppLoginAttempts", 5257721L};
|
||||
|
|
@ -117,12 +118,10 @@ public class CommonsApplication extends DaggerApplication {
|
|||
.subscribe(() -> {
|
||||
Timber.d("All accounts have been removed");
|
||||
//TODO: fix preference manager
|
||||
PreferenceManager.getDefaultSharedPreferences(CommonsApplication.this).edit().clear().commit();
|
||||
SharedPreferences preferences = context
|
||||
.getSharedPreferences("fr.free.nrw.commons", MODE_PRIVATE);
|
||||
preferences.edit().clear().commit();
|
||||
context.getSharedPreferences("prefs", Context.MODE_PRIVATE).edit().clear().commit();
|
||||
preferences.edit().putBoolean("firstrun", false).apply();
|
||||
defaultPrefs.edit().clear().commit();
|
||||
applicationPrefs.edit().clear().commit();
|
||||
applicationPrefs.edit().putBoolean("firstrun", false).apply();
|
||||
otherPrefs.edit().clear().commit();
|
||||
updateAllDatabases();
|
||||
|
||||
logoutListener.onLogoutComplete();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import dagger.android.AndroidInjection;
|
||||
import fr.free.nrw.commons.BuildConfig;
|
||||
|
|
@ -37,8 +38,8 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
|||
@Inject MediaWikiApi mwApi;
|
||||
@Inject AccountUtil accountUtil;
|
||||
@Inject SessionManager sessionManager;
|
||||
|
||||
private SharedPreferences prefs = null;
|
||||
@Inject @Named("application_preferences") SharedPreferences prefs = null;
|
||||
@Inject @Named("default_preferences") SharedPreferences defaultPrefs;
|
||||
|
||||
private Button loginButton;
|
||||
private EditText usernameEdit;
|
||||
|
|
@ -60,8 +61,6 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
|||
passwordEdit = (EditText) findViewById(R.id.loginPassword);
|
||||
twoFactorEdit = (EditText) findViewById(R.id.loginTwoFactor);
|
||||
|
||||
prefs = getSharedPreferences("fr.free.nrw.commons", MODE_PRIVATE);
|
||||
|
||||
usernameEdit.addTextChangedListener(textWatcher);
|
||||
passwordEdit.addTextChangedListener(textWatcher);
|
||||
twoFactorEdit.addTextChangedListener(textWatcher);
|
||||
|
|
@ -145,7 +144,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
|||
canonicializeUsername(usernameEdit.getText().toString()),
|
||||
passwordEdit.getText().toString(),
|
||||
twoFactorEdit.getText().toString(),
|
||||
accountUtil, this, mwApi
|
||||
accountUtil, mwApi, defaultPrefs
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package fr.free.nrw.commons.auth;
|
|||
|
||||
import android.accounts.AccountAuthenticatorResponse;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
||||
|
|
@ -26,19 +26,19 @@ class LoginTask extends AsyncTask<String, String, String> {
|
|||
private String password;
|
||||
private String twoFactorCode = "";
|
||||
private AccountUtil accountUtil;
|
||||
private Context context;
|
||||
private MediaWikiApi mwApi;
|
||||
private SharedPreferences prefs;
|
||||
|
||||
public LoginTask(LoginActivity loginActivity, String username, String password,
|
||||
String twoFactorCode, AccountUtil accountUtil,
|
||||
Context context, MediaWikiApi mwApi) {
|
||||
MediaWikiApi mwApi, SharedPreferences prefs) {
|
||||
this.loginActivity = loginActivity;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.twoFactorCode = twoFactorCode;
|
||||
this.accountUtil = accountUtil;
|
||||
this.context = context;
|
||||
this.mwApi = mwApi;
|
||||
this.prefs = prefs;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -71,7 +71,7 @@ class LoginTask extends AsyncTask<String, String, String> {
|
|||
super.onPostExecute(result);
|
||||
Timber.d("Login done!");
|
||||
|
||||
EventLog.schema(CommonsApplication.EVENT_LOGIN_ATTEMPT, context, mwApi)
|
||||
EventLog.schema(CommonsApplication.EVENT_LOGIN_ATTEMPT, mwApi, prefs)
|
||||
.param("username", username)
|
||||
.param("result", result)
|
||||
.log();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package fr.free.nrw.commons.category;
|
|||
import android.content.ContentProviderClient;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
|
@ -30,6 +29,7 @@ import java.util.List;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
|
@ -66,6 +66,7 @@ public class CategorizationFragment extends DaggerFragment {
|
|||
TextView categoriesSkip;
|
||||
|
||||
@Inject MediaWikiApi mwApi;
|
||||
@Inject @Named("default_preferences") SharedPreferences prefs;
|
||||
|
||||
private RVRendererAdapter<CategoryItem> categoriesAdapter;
|
||||
private OnCategoriesSaveHandler onCategoriesSaveHandler;
|
||||
|
|
@ -250,8 +251,7 @@ public class CategorizationFragment extends DaggerFragment {
|
|||
|
||||
private Observable<CategoryItem> titleCategories() {
|
||||
//Retrieve the title that was saved when user tapped submit icon
|
||||
SharedPreferences titleDesc = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
String title = titleDesc.getString("Title", "");
|
||||
String title = prefs.getString("Title", "");
|
||||
|
||||
return mwApi
|
||||
.searchTitles(title, SEARCH_CATS_LIMIT)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import android.database.Cursor;
|
|||
import android.database.DataSetObserver;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
|
|
@ -24,6 +23,7 @@ import android.widget.AdapterView;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import fr.free.nrw.commons.HandlerService;
|
||||
|
|
@ -45,7 +45,9 @@ import static fr.free.nrw.commons.contributions.Contribution.STATE_FAILED;
|
|||
import static fr.free.nrw.commons.contributions.Contribution.Table.ALL_FIELDS;
|
||||
import static fr.free.nrw.commons.contributions.ContributionsContentProvider.AUTHORITY;
|
||||
import static fr.free.nrw.commons.contributions.ContributionsContentProvider.BASE_URI;
|
||||
import static fr.free.nrw.commons.settings.Prefs.UPLOADS_SHOWING;public class ContributionsActivity
|
||||
import static fr.free.nrw.commons.settings.Prefs.UPLOADS_SHOWING;
|
||||
|
||||
public class ContributionsActivity
|
||||
extends AuthenticatedActivity
|
||||
implements LoaderManager.LoaderCallbacks<Cursor>,
|
||||
AdapterView.OnItemClickListener,
|
||||
|
|
@ -55,6 +57,7 @@ import static fr.free.nrw.commons.settings.Prefs.UPLOADS_SHOWING;public class
|
|||
|
||||
@Inject MediaWikiApi mediaWikiApi;
|
||||
@Inject SessionManager sessionManager;
|
||||
@Inject @Named("default_preferences") SharedPreferences prefs;
|
||||
|
||||
private Cursor allContributions;
|
||||
private ContributionsListFragment contributionsList;
|
||||
|
|
@ -108,12 +111,8 @@ import static fr.free.nrw.commons.settings.Prefs.UPLOADS_SHOWING;public class
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean isSettingsChanged =
|
||||
sharedPreferences.getBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED, false);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED, false);
|
||||
editor.apply();
|
||||
boolean isSettingsChanged = prefs.getBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED, false);
|
||||
prefs.edit().putBoolean(Prefs.IS_CONTRIBUTION_COUNT_CHANGED, false).apply();
|
||||
if (isSettingsChanged) {
|
||||
refreshSource();
|
||||
}
|
||||
|
|
@ -235,8 +234,7 @@ import static fr.free.nrw.commons.settings.Prefs.UPLOADS_SHOWING;public class
|
|||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
int uploads = sharedPref.getInt(UPLOADS_SHOWING, 100);
|
||||
int uploads = prefs.getInt(UPLOADS_SHOWING, 100);
|
||||
return new CursorLoader(this, BASE_URI,
|
||||
ALL_FIELDS, CONTRIBUTION_SELECTION, null,
|
||||
CONTRIBUTION_SORT + "LIMIT " + uploads);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ import android.widget.GridView;
|
|||
import android.widget.ListAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import dagger.android.support.DaggerFragment;
|
||||
|
|
@ -28,7 +31,6 @@ import timber.log.Timber;
|
|||
|
||||
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
import static android.view.View.GONE;
|
||||
|
||||
|
|
@ -37,6 +39,7 @@ public class ContributionsListFragment extends DaggerFragment {
|
|||
@BindView(R.id.contributionsList) GridView contributionsList;
|
||||
@BindView(R.id.waitingMessage) TextView waitingMessage;
|
||||
@BindView(R.id.emptyMessage) TextView emptyMessage;
|
||||
@Inject @Named("prefs") SharedPreferences prefs;
|
||||
private ContributionController controller;
|
||||
|
||||
@Override
|
||||
|
|
@ -51,7 +54,6 @@ public class ContributionsListFragment extends DaggerFragment {
|
|||
}
|
||||
|
||||
//TODO: Should this be in onResume?
|
||||
SharedPreferences prefs = getActivity().getSharedPreferences("prefs", MODE_PRIVATE);
|
||||
String lastModified = prefs.getString("lastSyncTimestamp", "");
|
||||
Timber.d("Last Sync Timestamp: %s", lastModified);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.util.Locale;
|
|||
import java.util.TimeZone;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
|
|
@ -28,11 +29,11 @@ import fr.free.nrw.commons.mwapi.LogEventResult;
|
|||
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
import static fr.free.nrw.commons.contributions.Contribution.STATE_COMPLETED;
|
||||
import static fr.free.nrw.commons.contributions.Contribution.Table.COLUMN_FILENAME;
|
||||
import static fr.free.nrw.commons.contributions.ContributionsContentProvider.BASE_URI;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||
|
||||
private static final String[] existsQuery = {COLUMN_FILENAME};
|
||||
|
|
@ -42,6 +43,7 @@ public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter {
|
|||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@Inject MediaWikiApi mwApi;
|
||||
@Inject @Named("prefs") SharedPreferences prefs;
|
||||
|
||||
public ContributionsSyncAdapter(Context context, boolean autoInitialize) {
|
||||
super(context, autoInitialize);
|
||||
|
|
@ -79,7 +81,6 @@ public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter {
|
|||
((CommonsApplication) getContext().getApplicationContext()).injector().inject(this);
|
||||
// This code is fraught with possibilities of race conditions, but lalalalala I can't hear you!
|
||||
String user = account.name;
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("prefs", MODE_PRIVATE);
|
||||
String lastModified = prefs.getString("lastSyncTimestamp", "");
|
||||
Date curTime = new Date();
|
||||
LogEventResult result;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package fr.free.nrw.commons.di;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.util.LruCache;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
|
|
@ -15,6 +18,9 @@ import fr.free.nrw.commons.data.DBOpenHelper;
|
|||
import fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApi;
|
||||
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||
import fr.free.nrw.commons.nearby.NearbyPlaces;
|
||||
import fr.free.nrw.commons.upload.UploadController;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
@Module
|
||||
@SuppressWarnings({"WeakerAccess", "unused"})
|
||||
|
|
@ -30,6 +36,29 @@ public class CommonsApplicationModule {
|
|||
return new AccountUtil(application);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Named("application_preferences")
|
||||
public SharedPreferences providesApplicationSharedPreferences() {
|
||||
return application.getSharedPreferences("fr.free.nrw.commons", MODE_PRIVATE);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Named("default_preferences")
|
||||
public SharedPreferences providesDefaultSharedPreferences() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(application);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Named("prefs")
|
||||
public SharedPreferences providesOtherSharedPreferences() {
|
||||
return application.getSharedPreferences("prefs", MODE_PRIVATE);
|
||||
}
|
||||
|
||||
@Provides
|
||||
public UploadController providesUploadController(SessionManager sessionManager, @Named("default_preferences") SharedPreferences sharedPreferences) {
|
||||
return new UploadController(sessionManager, application, sharedPreferences);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public SessionManager providesSessionManager(MediaWikiApi mediaWikiApi) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package fr.free.nrw.commons.media;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.DataSetObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
|
@ -25,6 +26,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import dagger.android.support.DaggerFragment;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
|
|
@ -46,6 +48,7 @@ public class MediaDetailPagerFragment extends DaggerFragment implements ViewPage
|
|||
|
||||
@Inject MediaWikiApi mwApi;
|
||||
@Inject SessionManager sessionManager;
|
||||
@Inject @Named("default_preferences") SharedPreferences prefs;
|
||||
|
||||
private ViewPager pager;
|
||||
private Boolean editable;
|
||||
|
|
@ -109,7 +112,7 @@ public class MediaDetailPagerFragment extends DaggerFragment implements ViewPage
|
|||
case R.id.menu_share_current_image:
|
||||
// Share - this is just logs it, intent set in onCreateOptionsMenu, around line 252
|
||||
CommonsApplication app = (CommonsApplication) getActivity().getApplication();
|
||||
EventLog.schema(EVENT_SHARE_ATTEMPT, getContext().getApplicationContext(), mwApi)
|
||||
EventLog.schema(EVENT_SHARE_ATTEMPT, mwApi, prefs)
|
||||
.param("username", sessionManager.getCurrentAccount().name)
|
||||
.param("filename", m.getFilename())
|
||||
.log();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package fr.free.nrw.commons.mwapi;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
|
||||
import fr.free.nrw.commons.Utils;
|
||||
|
|
@ -16,14 +16,14 @@ public class EventLog {
|
|||
}
|
||||
}
|
||||
|
||||
private static LogBuilder schema(String schema, long revision, Context context, MediaWikiApi mwApi) {
|
||||
return new LogBuilder(schema, revision, context, mwApi);
|
||||
private static LogBuilder schema(String schema, long revision, MediaWikiApi mwApi, SharedPreferences prefs) {
|
||||
return new LogBuilder(schema, revision, mwApi, prefs);
|
||||
}
|
||||
|
||||
public static LogBuilder schema(Object[] scid, Context context, MediaWikiApi mwApi) {
|
||||
public static LogBuilder schema(Object[] scid, MediaWikiApi mwApi, SharedPreferences prefs) {
|
||||
if (scid.length != 2) {
|
||||
throw new IllegalArgumentException("Needs an object array with schema as first param and revision as second");
|
||||
}
|
||||
return schema((String) scid[0], (Long) scid[1], context, mwApi);
|
||||
return schema((String) scid[0], (Long) scid[1], mwApi, prefs);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
package fr.free.nrw.commons.mwapi;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
|
@ -13,23 +11,22 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
|
||||
import fr.free.nrw.commons.BuildConfig;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.settings.Prefs;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class LogBuilder {
|
||||
private final Context context;
|
||||
private final MediaWikiApi mwApi;
|
||||
private final JSONObject data;
|
||||
private final long rev;
|
||||
private final String schema;
|
||||
private final SharedPreferences prefs;
|
||||
|
||||
LogBuilder(String schema, long revision, Context context, MediaWikiApi mwApi) {
|
||||
LogBuilder(String schema, long revision, MediaWikiApi mwApi, SharedPreferences prefs) {
|
||||
this.prefs = prefs;
|
||||
this.data = new JSONObject();
|
||||
this.schema = schema;
|
||||
this.rev = revision;
|
||||
this.context = context;
|
||||
this.mwApi = mwApi;
|
||||
}
|
||||
|
||||
|
|
@ -62,8 +59,7 @@ public class LogBuilder {
|
|||
// Use *only* for tracking the user preference change for EventLogging
|
||||
// Attempting to use anywhere else will cause kitten explosions
|
||||
public void log(boolean force) {
|
||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (!settings.getBoolean(Prefs.TRACKING_ENABLED, true) && !force) {
|
||||
if (!prefs.getBoolean(Prefs.TRACKING_ENABLED, true) && !force) {
|
||||
return; // User has disabled tracking
|
||||
}
|
||||
LogTask logTask = new LogTask(mwApi);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package fr.free.nrw.commons.nearby;
|
|||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.LocationManager;
|
||||
import android.net.Uri;
|
||||
|
|
@ -28,6 +29,7 @@ import com.google.gson.GsonBuilder;
|
|||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
|
@ -43,6 +45,7 @@ public class NearbyActivity extends NavigationBaseActivity {
|
|||
@BindView(R.id.progressBar)
|
||||
ProgressBar progressBar;
|
||||
@Inject NearbyPlaces nearbyPlaces;
|
||||
@Inject @Named("default_preferences") SharedPreferences prefs;
|
||||
|
||||
private boolean isMapViewActive = false;
|
||||
private static final int LOCATION_REQUEST = 1;
|
||||
|
|
@ -93,7 +96,7 @@ public class NearbyActivity extends NavigationBaseActivity {
|
|||
locationManager = new LocationServiceManager(this);
|
||||
locationManager.registerLocationManager();
|
||||
curLatLang = locationManager.getLatestLocation();
|
||||
nearbyAsyncTask = new NearbyAsyncTask(this, new NearbyController(nearbyPlaces));
|
||||
nearbyAsyncTask = new NearbyAsyncTask(this, new NearbyController(nearbyPlaces, prefs));
|
||||
nearbyAsyncTask.execute();
|
||||
}
|
||||
|
||||
|
|
@ -232,7 +235,7 @@ public class NearbyActivity extends NavigationBaseActivity {
|
|||
}
|
||||
|
||||
private void refreshView() {
|
||||
nearbyAsyncTask = new NearbyAsyncTask(this, new NearbyController(nearbyPlaces));
|
||||
nearbyAsyncTask = new NearbyAsyncTask(this, new NearbyController(nearbyPlaces, prefs));
|
||||
nearbyAsyncTask.execute();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package fr.free.nrw.commons.nearby;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.graphics.drawable.VectorDrawableCompat;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.IconFactory;
|
||||
|
|
@ -27,9 +26,11 @@ import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
|
|||
public class NearbyController {
|
||||
private static final int MAX_RESULTS = 1000;
|
||||
private final NearbyPlaces nearbyPlaces;
|
||||
private final SharedPreferences prefs;
|
||||
|
||||
public NearbyController(NearbyPlaces nearbyPlaces) {
|
||||
public NearbyController(NearbyPlaces nearbyPlaces, SharedPreferences prefs) {
|
||||
this.nearbyPlaces = nearbyPlaces;
|
||||
this.prefs = prefs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -43,7 +44,6 @@ public class NearbyController {
|
|||
if (curLatLng == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
List<Place> places = prefs.getBoolean("useWikidata", true)
|
||||
? nearbyPlaces.getFromWikidataQuery(curLatLng, Locale.getDefault().getLanguage())
|
||||
: nearbyPlaces.getFromWikiNeedsPictures();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import android.preference.CheckBoxPreference;
|
|||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import dagger.android.AndroidInjection;
|
||||
import fr.free.nrw.commons.R;
|
||||
|
|
@ -16,6 +18,8 @@ import fr.free.nrw.commons.Utils;
|
|||
|
||||
public class SettingsFragment extends PreferenceFragment {
|
||||
|
||||
@Inject @Named("default_preferences") SharedPreferences prefs;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
AndroidInjection.inject(this);
|
||||
|
|
@ -46,14 +50,12 @@ public class SettingsFragment extends PreferenceFragment {
|
|||
});
|
||||
|
||||
final EditTextPreference uploadLimit = (EditTextPreference) findPreference("uploads");
|
||||
final SharedPreferences sharedPref = PreferenceManager
|
||||
.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||
int uploads = sharedPref.getInt(Prefs.UPLOADS_SHOWING, 100);
|
||||
int uploads = prefs.getInt(Prefs.UPLOADS_SHOWING, 100);
|
||||
uploadLimit.setText(uploads + "");
|
||||
uploadLimit.setSummary(uploads + "");
|
||||
uploadLimit.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
int value = Integer.parseInt(newValue.toString());
|
||||
final SharedPreferences.Editor editor = sharedPref.edit();
|
||||
final SharedPreferences.Editor editor = prefs.edit();
|
||||
if (value > 500) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.maximum_limit)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import android.location.LocationListener;
|
|||
import android.location.LocationManager;
|
||||
import android.media.ExifInterface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
|
@ -26,6 +25,7 @@ import timber.log.Timber;
|
|||
public class GPSExtractor {
|
||||
|
||||
private final Context context;
|
||||
private SharedPreferences prefs;
|
||||
private ExifInterface exif;
|
||||
private double decLatitude;
|
||||
private double decLongitude;
|
||||
|
|
@ -41,8 +41,9 @@ public class GPSExtractor {
|
|||
* @param context the context
|
||||
*/
|
||||
@RequiresApi(24)
|
||||
public GPSExtractor(@NonNull FileDescriptor fileDescriptor, Context context) {
|
||||
public GPSExtractor(@NonNull FileDescriptor fileDescriptor, Context context, SharedPreferences prefs) {
|
||||
this.context = context;
|
||||
this.prefs = prefs;
|
||||
try {
|
||||
exif = new ExifInterface(fileDescriptor);
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
|
|
@ -55,7 +56,8 @@ public class GPSExtractor {
|
|||
* @param path file path of the image
|
||||
* @param context the context
|
||||
*/
|
||||
public GPSExtractor(@NonNull String path, Context context) {
|
||||
public GPSExtractor(@NonNull String path, Context context, SharedPreferences prefs) {
|
||||
this.prefs = prefs;
|
||||
try {
|
||||
exif = new ExifInterface(path);
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
|
|
@ -69,9 +71,7 @@ public class GPSExtractor {
|
|||
* @return true if enabled, false if disabled
|
||||
*/
|
||||
private boolean gpsPreferenceEnabled() {
|
||||
SharedPreferences sharedPref
|
||||
= PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean gpsPref = sharedPref.getBoolean("allowGps", false);
|
||||
boolean gpsPref = prefs.getBoolean("allowGps", false);
|
||||
Timber.d("Gps pref set to: %b", gpsPref);
|
||||
return gpsPref;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.content.ContentProviderClient;
|
|||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.DataSetObserver;
|
||||
import android.net.Uri;
|
||||
|
|
@ -25,6 +26,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
|
|
@ -53,6 +55,8 @@ public class MultipleShareActivity extends AuthenticatedActivity
|
|||
|
||||
@Inject MediaWikiApi mwApi;
|
||||
@Inject SessionManager sessionManager;
|
||||
@Inject UploadController uploadController;
|
||||
@Inject @Named("default_preferences") SharedPreferences prefs;
|
||||
|
||||
private ArrayList<Contribution> photosList = null;
|
||||
|
||||
|
|
@ -60,8 +64,6 @@ public class MultipleShareActivity extends AuthenticatedActivity
|
|||
private MediaDetailPagerFragment mediaDetails;
|
||||
private CategorizationFragment categorizationFragment;
|
||||
|
||||
private UploadController uploadController;
|
||||
|
||||
@Override
|
||||
public Media getMediaAtPosition(int i) {
|
||||
return photosList.get(i);
|
||||
|
|
@ -179,7 +181,7 @@ public class MultipleShareActivity extends AuthenticatedActivity
|
|||
// FIXME: Make sure that the content provider is up
|
||||
// This is the wrong place for it, but bleh - better than not having it turned on by default for people who don't go throughl ogin
|
||||
ContentResolver.setSyncAutomatically(sessionManager.getCurrentAccount(), ModificationsContentProvider.AUTHORITY, true); // Enable sync by default!
|
||||
EventLog.schema(CommonsApplication.EVENT_CATEGORIZATION_ATTEMPT, getApplicationContext(), mwApi)
|
||||
EventLog.schema(CommonsApplication.EVENT_CATEGORIZATION_ATTEMPT, mwApi, prefs)
|
||||
.param("username", sessionManager.getCurrentAccount().name)
|
||||
.param("categories-count", categories.size())
|
||||
.param("files-count", photosList.size())
|
||||
|
|
@ -204,7 +206,6 @@ public class MultipleShareActivity extends AuthenticatedActivity
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
uploadController = new UploadController(sessionManager, this);
|
||||
|
||||
setContentView(R.layout.activity_multiple_uploads);
|
||||
ButterKnife.bind(this);
|
||||
|
|
@ -289,7 +290,7 @@ public class MultipleShareActivity extends AuthenticatedActivity
|
|||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
if (categorizationFragment != null && categorizationFragment.isVisible()) {
|
||||
EventLog.schema(CommonsApplication.EVENT_CATEGORIZATION_ATTEMPT, getApplicationContext(), mwApi)
|
||||
EventLog.schema(CommonsApplication.EVENT_CATEGORIZATION_ATTEMPT, mwApi, prefs)
|
||||
.param("username", sessionManager.getCurrentAccount().name)
|
||||
.param("categories-count", categorizationFragment.getCurrentSelectedCount())
|
||||
.param("files-count", photosList.size())
|
||||
|
|
@ -297,7 +298,7 @@ public class MultipleShareActivity extends AuthenticatedActivity
|
|||
.param("result", "cancelled")
|
||||
.log();
|
||||
} else {
|
||||
EventLog.schema(CommonsApplication.EVENT_UPLOAD_ATTEMPT, getApplicationContext(), mwApi)
|
||||
EventLog.schema(CommonsApplication.EVENT_UPLOAD_ATTEMPT, mwApi, prefs)
|
||||
.param("username", sessionManager.getCurrentAccount().name)
|
||||
.param("source", getIntent().getStringExtra(UploadService.EXTRA_SOURCE))
|
||||
.param("multiple", true)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package fr.free.nrw.commons.upload;
|
|||
import android.Manifest;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
|
@ -34,6 +35,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
|
|
@ -73,6 +75,8 @@ public class ShareActivity
|
|||
@Inject MediaWikiApi mwApi;
|
||||
@Inject CacheController cacheController;
|
||||
@Inject SessionManager sessionManager;
|
||||
@Inject UploadController uploadController;
|
||||
@Inject @Named("default_preferences") SharedPreferences prefs;
|
||||
|
||||
private String source;
|
||||
private String mimeType;
|
||||
|
|
@ -81,8 +85,6 @@ public class ShareActivity
|
|||
private Contribution contribution;
|
||||
private SimpleDraweeView backgroundImageView;
|
||||
|
||||
private UploadController uploadController;
|
||||
|
||||
private boolean cacheFound;
|
||||
|
||||
private GPSExtractor imageObj;
|
||||
|
|
@ -172,7 +174,7 @@ public class ShareActivity
|
|||
// This is the wrong place for it, but bleh - better than not having it turned on by default for people who don't go throughl ogin
|
||||
ContentResolver.setSyncAutomatically(sessionManager.getCurrentAccount(), ModificationsContentProvider.AUTHORITY, true); // Enable sync by default!
|
||||
|
||||
EventLog.schema(CommonsApplication.EVENT_CATEGORIZATION_ATTEMPT, getApplicationContext(), mwApi)
|
||||
EventLog.schema(CommonsApplication.EVENT_CATEGORIZATION_ATTEMPT, mwApi, prefs)
|
||||
.param("username", sessionManager.getCurrentAccount().name)
|
||||
.param("categories-count", categories.size())
|
||||
.param("files-count", 1)
|
||||
|
|
@ -194,7 +196,7 @@ public class ShareActivity
|
|||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
if(categorizationFragment != null && categorizationFragment.isVisible()) {
|
||||
EventLog.schema(CommonsApplication.EVENT_CATEGORIZATION_ATTEMPT, getApplicationContext(), mwApi)
|
||||
EventLog.schema(CommonsApplication.EVENT_CATEGORIZATION_ATTEMPT, mwApi, prefs)
|
||||
.param("username", sessionManager.getCurrentAccount().name)
|
||||
.param("categories-count", categorizationFragment.getCurrentSelectedCount())
|
||||
.param("files-count", 1)
|
||||
|
|
@ -202,7 +204,7 @@ public class ShareActivity
|
|||
.param("result", "cancelled")
|
||||
.log();
|
||||
} else {
|
||||
EventLog.schema(CommonsApplication.EVENT_UPLOAD_ATTEMPT, getApplicationContext(), mwApi)
|
||||
EventLog.schema(CommonsApplication.EVENT_UPLOAD_ATTEMPT, mwApi, prefs)
|
||||
.param("username", sessionManager.getCurrentAccount().name)
|
||||
.param("source", getIntent().getStringExtra(UploadService.EXTRA_SOURCE))
|
||||
.param("multiple", true)
|
||||
|
|
@ -226,7 +228,7 @@ public class ShareActivity
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
uploadController = new UploadController(sessionManager, this);
|
||||
|
||||
setContentView(R.layout.activity_share);
|
||||
ButterKnife.bind(this);
|
||||
initBack();
|
||||
|
|
@ -451,12 +453,12 @@ public class ShareActivity
|
|||
= getContentResolver().openFileDescriptor(mediaUri, "r");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
if (descriptor != null) {
|
||||
imageObj = new GPSExtractor(descriptor.getFileDescriptor(), this);
|
||||
imageObj = new GPSExtractor(descriptor.getFileDescriptor(), this, prefs);
|
||||
}
|
||||
} else {
|
||||
String filePath = getPathOfMediaOrCopy();
|
||||
if (filePath != null) {
|
||||
imageObj = new GPSExtractor(filePath, this);
|
||||
imageObj = new GPSExtractor(filePath, this, prefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ import android.widget.TextView;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
|
@ -50,7 +53,8 @@ public class SingleUploadFragment extends DaggerFragment {
|
|||
@BindView(R.id.share_license_summary) TextView licenseSummaryView;
|
||||
@BindView(R.id.licenseSpinner) Spinner licenseSpinner;
|
||||
|
||||
private SharedPreferences prefs;
|
||||
@Inject @Named("default_preferences") SharedPreferences prefs;
|
||||
|
||||
private String license;
|
||||
private OnUploadActionInitiated uploadActionInitiatedHandler;
|
||||
private TitleTextWatcher textWatcher = new TitleTextWatcher();
|
||||
|
|
@ -73,11 +77,10 @@ public class SingleUploadFragment extends DaggerFragment {
|
|||
String desc = descEdit.getText().toString();
|
||||
|
||||
//Save the title/desc in short-lived cache so next time this fragment is loaded, we can access these
|
||||
SharedPreferences titleDesc = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
SharedPreferences.Editor editor = titleDesc.edit();
|
||||
editor.putString("Title", title);
|
||||
editor.putString("Desc", desc);
|
||||
editor.apply();
|
||||
prefs.edit()
|
||||
.putString("Title", title)
|
||||
.putString("Desc", desc)
|
||||
.apply();
|
||||
|
||||
uploadActionInitiatedHandler.uploadActionInitiated(title, desc);
|
||||
return true;
|
||||
|
|
@ -91,7 +94,6 @@ public class SingleUploadFragment extends DaggerFragment {
|
|||
View rootView = inflater.inflate(R.layout.fragment_single_upload, container, false);
|
||||
ButterKnife.bind(this, rootView);
|
||||
|
||||
|
||||
ArrayList<String> licenseItems = new ArrayList<>();
|
||||
licenseItems.add(getString(R.string.license_name_cc0));
|
||||
licenseItems.add(getString(R.string.license_name_cc_by));
|
||||
|
|
@ -99,7 +101,6 @@ public class SingleUploadFragment extends DaggerFragment {
|
|||
licenseItems.add(getString(R.string.license_name_cc_by_four));
|
||||
licenseItems.add(getString(R.string.license_name_cc_by_sa_four));
|
||||
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
license = prefs.getString(Prefs.DEFAULT_LICENSE, Prefs.Licenses.CC_BY_SA_3);
|
||||
|
||||
// check if this is the first time we have uploaded
|
||||
|
|
@ -172,9 +173,9 @@ public class SingleUploadFragment extends DaggerFragment {
|
|||
}
|
||||
|
||||
setLicenseSummary(license);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putString(Prefs.DEFAULT_LICENSE, license);
|
||||
editor.commit();
|
||||
prefs.edit()
|
||||
.putString(Prefs.DEFAULT_LICENSE, license)
|
||||
.commit();
|
||||
}
|
||||
|
||||
@OnTouch(R.id.share_license_summary)
|
||||
|
|
@ -193,9 +194,8 @@ public class SingleUploadFragment extends DaggerFragment {
|
|||
@OnClick(R.id.titleDescButton)
|
||||
void setTitleDescButton() {
|
||||
//Retrieve last title and desc entered
|
||||
SharedPreferences titleDesc = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
String title = titleDesc.getString("Title", "");
|
||||
String desc = titleDesc.getString("Desc", "");
|
||||
String title = prefs.getString("Title", "");
|
||||
String desc = prefs.getString("Desc", "");
|
||||
Timber.d("Title: %s, Desc: %s", title, desc);
|
||||
|
||||
titleEdit.setText(title);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import android.database.Cursor;
|
|||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.IBinder;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
|
||||
|
|
@ -31,14 +30,16 @@ public class UploadController {
|
|||
private UploadService uploadService;
|
||||
private SessionManager sessionManager;
|
||||
private Context context;
|
||||
private SharedPreferences prefs;
|
||||
|
||||
public interface ContributionUploadProgress {
|
||||
void onUploadStarted(Contribution contribution);
|
||||
}
|
||||
|
||||
public UploadController(SessionManager sessionManager, Context context) {
|
||||
public UploadController(SessionManager sessionManager, Context context, SharedPreferences sharedPreferences) {
|
||||
this.sessionManager = sessionManager;
|
||||
this.context = context;
|
||||
this.prefs = sharedPreferences;
|
||||
}
|
||||
|
||||
private boolean isUploadServiceConnected;
|
||||
|
|
@ -85,8 +86,6 @@ public class UploadController {
|
|||
}
|
||||
|
||||
public void startUpload(final Contribution contribution, final ContributionUploadProgress onComplete) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
|
||||
|
||||
//Set creator, desc, and license
|
||||
if(TextUtils.isEmpty(contribution.getCreator())) {
|
||||
contribution.setCreator(sessionManager.getCurrentAccount().name);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import android.content.ContentProviderClient;
|
|||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
|
@ -23,6 +24,7 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.HandlerService;
|
||||
|
|
@ -50,6 +52,7 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
|
||||
@Inject MediaWikiApi mwApi;
|
||||
@Inject SessionManager sessionManager;
|
||||
@Inject @Named("default_preferences") SharedPreferences prefs;
|
||||
|
||||
private NotificationManager notificationManager;
|
||||
private ContentProviderClient contributionsProviderClient;
|
||||
|
|
@ -247,7 +250,7 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
String resultStatus = uploadResult.getResultStatus();
|
||||
if (!resultStatus.equals("Success")) {
|
||||
showFailedNotification(contribution);
|
||||
EventLog.schema(CommonsApplication.EVENT_UPLOAD_ATTEMPT, getApplicationContext(), mwApi)
|
||||
EventLog.schema(CommonsApplication.EVENT_UPLOAD_ATTEMPT, mwApi, prefs)
|
||||
.param("username", sessionManager.getCurrentAccount().name)
|
||||
.param("source", contribution.getSource())
|
||||
.param("multiple", contribution.getMultiple())
|
||||
|
|
@ -261,7 +264,7 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
contribution.setDateUploaded(uploadResult.getDateUploaded());
|
||||
contribution.save();
|
||||
|
||||
EventLog.schema(CommonsApplication.EVENT_UPLOAD_ATTEMPT, getApplicationContext(), mwApi)
|
||||
EventLog.schema(CommonsApplication.EVENT_UPLOAD_ATTEMPT, mwApi, prefs)
|
||||
.param("username", sessionManager.getCurrentAccount().name)
|
||||
.param("source", contribution.getSource()) //FIXME
|
||||
.param("filename", contribution.getFilename())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue