Remove setting to disable geofences

pull/384/head
Alex Baker 9 years ago
parent 0638233cc0
commit 6364269406

@ -44,7 +44,7 @@ public class GeofenceApi {
}
public void register(final List<Geofence> geofences) {
if (geofences.isEmpty() || !preferences.geofencesEnabled() || !permissionChecker.canAccessLocation()) {
if (geofences.isEmpty() || !permissionChecker.canAccessLocation()) {
return;
}

@ -77,6 +77,7 @@ import org.tasks.location.GeofenceService;
import org.tasks.location.PlacePicker;
import org.tasks.notifications.NotificationManager;
import org.tasks.preferences.ActivityPreferences;
import org.tasks.preferences.DeviceInfo;
import org.tasks.preferences.PermissionRequestor;
import org.tasks.ui.DeadlineControlSet;
import org.tasks.ui.MenuColorizer;
@ -167,6 +168,7 @@ public final class TaskEditFragment extends InjectingFragment implements EditNot
@Inject GeofenceService geofenceService;
@Inject DialogBuilder dialogBuilder;
@Inject PermissionRequestor permissionRequestor;
@Inject DeviceInfo deviceInfo;
// --- UI components
@ -311,7 +313,7 @@ public final class TaskEditFragment extends InjectingFragment implements EditNot
controlSetMap.put(getString(R.string.TEA_ctrl_notes_pref),
notesControlSet);
reminderControlSet = new ReminderControlSet(alarmService, geofenceService, this, preferences, permissionRequestor);
reminderControlSet = new ReminderControlSet(alarmService, geofenceService, this, permissionRequestor, deviceInfo);
controls.add(reminderControlSet);
controlSetMap.put(getString(R.string.TEA_ctrl_reminders_pref), reminderControlSet);

@ -57,8 +57,7 @@ public class ReminderPreferences extends InjectingPreferenceActivity {
R.string.p_rmd_quietEnd);
resetGeofencesOnChange(
R.string.p_geofence_radius,
R.string.p_geofence_responsiveness,
R.string.p_geofence_reminders_enabled);
R.string.p_geofence_responsiveness);
fieldMissedCalls = (CheckBoxPreference) findPreference(getString(R.string.p_field_missed_calls));
fieldMissedCalls.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

@ -6,7 +6,6 @@
package com.todoroo.astrid.ui;
import android.content.Intent;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@ -30,8 +29,8 @@ import org.tasks.activities.DateAndTimePickerActivity;
import org.tasks.location.Geofence;
import org.tasks.location.GeofenceService;
import org.tasks.location.PlacePicker;
import org.tasks.preferences.DeviceInfo;
import org.tasks.preferences.PermissionRequestor;
import org.tasks.preferences.Preferences;
import org.tasks.ui.HiddenTopArrayAdapter;
import java.util.ArrayList;
@ -66,21 +65,21 @@ public class ReminderControlSet extends TaskEditControlSetBase implements Adapte
private AlarmService alarmService;
private GeofenceService geofenceService;
private TaskEditFragment taskEditFragment;
private Preferences preferences;
private PermissionRequestor permissionRequestor;
private DeviceInfo deviceInfo;
private List<String> spinnerOptions = new ArrayList<>();
private ArrayAdapter<String> remindAdapter;
public ReminderControlSet(AlarmService alarmService, GeofenceService geofenceService,
TaskEditFragment taskEditFragment, Preferences preferences,
PermissionRequestor permissionRequestor) {
TaskEditFragment taskEditFragment, PermissionRequestor permissionRequestor,
DeviceInfo deviceInfo) {
super(taskEditFragment.getActivity(), R.layout.control_set_reminders);
this.alarmService = alarmService;
this.geofenceService = geofenceService;
this.taskEditFragment = taskEditFragment;
this.preferences = preferences;
this.permissionRequestor = permissionRequestor;
this.deviceInfo = deviceInfo;
}
public int getValue() {
@ -132,10 +131,6 @@ public class ReminderControlSet extends TaskEditControlSetBase implements Adapte
}
});
alertItem.setTag(geofence);
if (!preferences.geofencesEnabled()) {
TextView alarmString = (TextView) alertItem.findViewById(R.id.alarm_string);
alarmString.setPaintFlags(alarmString.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
}
private View addAlarmRow(String text, Long timestamp, final OnClickListener onRemove) {
@ -175,7 +170,7 @@ public class ReminderControlSet extends TaskEditControlSetBase implements Adapte
if (randomControlSet == null) {
spinnerOptions.add(taskEditFragment.getString(R.string.randomly));
}
if (preferences.geofencesEnabled()) {
if (deviceInfo.supportsLocationServices()) {
spinnerOptions.add(taskEditFragment.getString(R.string.pick_a_location));
}
spinnerOptions.add(taskEditFragment.getString(R.string.pick_a_date_and_time));

@ -24,8 +24,8 @@ public class ActivityPreferences extends Preferences {
private final Activity activity;
@Inject
public ActivityPreferences(Activity activity, DeviceInfo deviceInfo, PermissionChecker permissionChecker) {
super(activity, deviceInfo, permissionChecker);
public ActivityPreferences(Activity activity, PermissionChecker permissionChecker) {
super(activity, permissionChecker);
this.activity = activity;
}

@ -38,15 +38,13 @@ public class Preferences {
private static final String PREF_SORT_SORT = "sort_sort"; //$NON-NLS-1$
protected final Context context;
private final DeviceInfo deviceInfo;
private final PermissionChecker permissionChecker;
private final SharedPreferences prefs;
private final SharedPreferences publicPrefs;
@Inject
public Preferences(@ForApplication Context context, DeviceInfo deviceInfo, PermissionChecker permissionChecker) {
public Preferences(@ForApplication Context context, PermissionChecker permissionChecker) {
this.context = context;
this.deviceInfo = deviceInfo;
this.permissionChecker = permissionChecker;
prefs = PreferenceManager.getDefaultSharedPreferences(context);
publicPrefs = context.getSharedPreferences(AstridApiConstants.PUBLIC_PREFS, Context.MODE_WORLD_READABLE);
@ -104,10 +102,6 @@ public class Preferences {
return atLeastMarshmallow() && getBoolean(R.string.p_doze_notifications, false);
}
public boolean geofencesEnabled() {
return deviceInfo.supportsLocationServices() && getBoolean(R.string.p_geofence_reminders_enabled, true);
}
public void clear() {
prefs
.edit()

@ -237,7 +237,6 @@
<string name="p_rmd_notif_actions_enabled">p_rmd_notif_actions_enabled</string>
<string name="p_geofence_radius">geolocation_radius</string>
<string name="p_geofence_responsiveness">geofence_responsiveness</string>
<string name="p_geofence_reminders_enabled">geofence_reminders_enabled</string>
<string name="p_show_hidden_tasks">show_hidden_tasks</string>
<string name="p_show_completed_tasks">show_completed_tasks</string>
<string name="p_reverse_sort">reverse_sort</string>

@ -105,21 +105,16 @@
<PreferenceCategory
android:key="@string/geolocation_reminders"
android:title="@string/geolocation_reminders">
<CheckBoxPreference
android:defaultValue="true"
android:dependency="@string/p_rmd_enabled"
android:key="@string/p_geofence_reminders_enabled"
android:title="@string/enabled" />
<com.todoroo.astrid.ui.MultilineListPreference
android:defaultValue="250"
android:dependency="@string/p_geofence_reminders_enabled"
android:dependency="@string/p_rmd_enabled"
android:entries="@array/geofence_radius_values"
android:entryValues="@array/geofence_radius_values"
android:key="@string/p_geofence_radius"
android:title="@string/geofence_radius_title" />
<com.todoroo.astrid.ui.MultilineListPreference
android:defaultValue="60"
android:dependency="@string/p_geofence_reminders_enabled"
android:dependency="@string/p_rmd_enabled"
android:entries="@array/geofence_responsiveness"
android:entryValues="@array/geofence_responsiveness_values"
android:key="@string/p_geofence_responsiveness"

Loading…
Cancel
Save