mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Add a settings screen, with a preference to disable tracking
This commit is contained in:
parent
3ba54daf4f
commit
1b89d96943
7 changed files with 42 additions and 6 deletions
|
|
@ -73,6 +73,10 @@
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".SettingsActivity"
|
||||||
|
android:label="@string/title_activity_settings"
|
||||||
|
/>
|
||||||
<service android:name="UploadService" >
|
<service android:name="UploadService" >
|
||||||
</service>
|
</service>
|
||||||
<service
|
<service
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,10 @@
|
||||||
android:showAsAction="always|withText"
|
android:showAsAction="always|withText"
|
||||||
android:icon="@android:drawable/ic_menu_gallery"
|
android:icon="@android:drawable/ic_menu_gallery"
|
||||||
/>
|
/>
|
||||||
|
<item android:id="@+id/menu_settings"
|
||||||
|
android:title="@string/menu_settings"
|
||||||
|
android:showAsAction="never"
|
||||||
|
android:icon="@android:drawable/ic_menu_preferences"
|
||||||
|
/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
||||||
|
|
@ -72,4 +72,7 @@
|
||||||
<string name="categories_not_found">No categories matching %1$s found</string>
|
<string name="categories_not_found">No categories matching %1$s found</string>
|
||||||
<string name="categories_skip_explanation">Add categories to make your images more discoverable on Wikimedia Commons.\n\nStart typing to add categories.\nTap this message (or hit back) to skip this step.</string>
|
<string name="categories_skip_explanation">Add categories to make your images more discoverable on Wikimedia Commons.\n\nStart typing to add categories.\nTap this message (or hit back) to skip this step.</string>
|
||||||
<string name="categories_activity_title">Categories</string>
|
<string name="categories_activity_title">Categories</string>
|
||||||
|
<string name="preference_tracking">Usage reports</string>
|
||||||
|
<string name="preference_tracking_summary">Send usage reports to Wikimedia to help us improve the app</string>
|
||||||
|
<string name="title_activity_settings">Settings</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -100,9 +100,8 @@ public class CommonsApplication extends Application {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable / disable tracking based on user preference. Defaults to true
|
// Initialize EventLogging
|
||||||
SharedPreferences settings = getSharedPreferences(Prefs.GLOBAL_PREFS, MODE_PRIVATE);
|
EventLog.setApp(this);
|
||||||
EventLog.enabled = settings.getBoolean(Prefs.TRACKING_ENABLED, EventLog.enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MWApi getApi() {
|
public MWApi getApi() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package org.wikimedia.commons;
|
package org.wikimedia.commons;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.util.*;
|
import android.util.*;
|
||||||
import in.yuvi.http.fluent.Http;
|
import in.yuvi.http.fluent.Http;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
|
|
@ -10,8 +13,7 @@ import java.net.*;
|
||||||
|
|
||||||
public class EventLog {
|
public class EventLog {
|
||||||
|
|
||||||
// Set to false in CommonsApplication if the user has disabled tracking
|
private static CommonsApplication app;
|
||||||
public static boolean enabled = true;
|
|
||||||
|
|
||||||
private static class LogTask extends AsyncTask<LogBuilder, Void, Boolean> {
|
private static class LogTask extends AsyncTask<LogBuilder, Void, Boolean> {
|
||||||
|
|
||||||
|
|
@ -52,6 +54,10 @@ public class EventLog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setApp(CommonsApplication app) {
|
||||||
|
EventLog.app = app;
|
||||||
|
}
|
||||||
|
|
||||||
public static class LogBuilder {
|
public static class LogBuilder {
|
||||||
private JSONObject data;
|
private JSONObject data;
|
||||||
private long rev;
|
private long rev;
|
||||||
|
|
@ -91,7 +97,8 @@ public class EventLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log() {
|
public void log() {
|
||||||
if(!enabled) {
|
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(app);
|
||||||
|
if(!settings.getBoolean(Prefs.TRACKING_ENABLED, true)) {
|
||||||
return; // User has disabled tracking
|
return; // User has disabled tracking
|
||||||
}
|
}
|
||||||
LogTask logTask = new LogTask();
|
LogTask logTask = new LogTask();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.wikimedia.commons;
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import com.actionbarsherlock.app.SherlockPreferenceActivity;
|
||||||
|
|
||||||
|
public class SettingsActivity extends SherlockPreferenceActivity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -217,6 +217,10 @@ public class ContributionsListFragment extends SherlockFragment {
|
||||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, lastGeneratedCaptureURI);
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, lastGeneratedCaptureURI);
|
||||||
startActivityForResult(takePictureIntent, SELECT_FROM_CAMERA);
|
startActivityForResult(takePictureIntent, SELECT_FROM_CAMERA);
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.menu_settings:
|
||||||
|
Intent settingsIntent = new Intent(getActivity(), SettingsActivity.class);
|
||||||
|
startActivity(settingsIntent);
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue