mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Add a boolean pref to disable EventLogging based tracking
This commit is contained in:
parent
72b351b21a
commit
06a0fb9028
3 changed files with 19 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ import java.net.URI;
|
|||
|
||||
import android.accounts.*;
|
||||
import android.app.Application;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
|
|
@ -98,6 +99,10 @@ public class CommonsApplication extends Application {
|
|||
// LET US WIN THE AWARD FOR DUMBEST CHECKED EXCEPTION EVER!
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// Enable / disable tracking based on user preference. Defaults to true
|
||||
SharedPreferences settings = getSharedPreferences(Prefs.GLOBAL_PREFS, MODE_PRIVATE);
|
||||
EventLog.enabled = settings.getBoolean(Prefs.TRACKING_ENABLED, EventLog.enabled);
|
||||
}
|
||||
|
||||
public MWApi getApi() {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ import java.io.IOException;
|
|||
import java.net.*;
|
||||
|
||||
public class EventLog {
|
||||
|
||||
// Set to false in CommonsApplication if the user has disabled tracking
|
||||
public static boolean enabled = false;
|
||||
|
||||
private static class LogTask extends AsyncTask<LogBuilder, Void, Boolean> {
|
||||
|
||||
@Override
|
||||
|
|
@ -87,6 +91,9 @@ public class EventLog {
|
|||
}
|
||||
|
||||
public void log() {
|
||||
if(!enabled) {
|
||||
return; // User has disabled tracking
|
||||
}
|
||||
LogTask logTask = new LogTask();
|
||||
Utils.executeAsyncTask(logTask, this);
|
||||
}
|
||||
|
|
|
|||
7
commons/src/main/java/org/wikimedia/commons/Prefs.java
Normal file
7
commons/src/main/java/org/wikimedia/commons/Prefs.java
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package org.wikimedia.commons;
|
||||
|
||||
public class Prefs {
|
||||
public static String GLOBAL_PREFS = "org.wikimedia.commons.preferences";
|
||||
|
||||
public static String TRACKING_ENABLED = "eventLogging";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue