Remove setLong from old preferences

pull/189/head
Alex Baker 12 years ago
parent cec9ac0500
commit 0b276c4b65

@ -225,14 +225,4 @@ public class Preferences {
Context context = ContextManager.getContext(); Context context = ContextManager.getContext();
return getPrefs(context).getLong(key, defValue); return getPrefs(context).getLong(key, defValue);
} }
/**
* Sets long preference
*/
public static void setLong(String key, long value) {
Context context = ContextManager.getContext();
Editor editor = getPrefs(context).edit();
editor.putLong(key, value);
editor.commit();
}
} }

@ -7,13 +7,13 @@ package com.todoroo.astrid.backup;
import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.backup.BackupService.BackupDirectorySetting; import com.todoroo.astrid.backup.BackupService.BackupDirectorySetting;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.test.DatabaseTestCase; import com.todoroo.astrid.test.DatabaseTestCase;
import org.tasks.R; import org.tasks.R;
import org.tasks.preferences.Preferences;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -29,6 +29,7 @@ public class BackupServiceTests extends DatabaseTestCase {
File temporaryDirectory = null; File temporaryDirectory = null;
@Autowired private TaskDao taskDao; @Autowired private TaskDao taskDao;
@Autowired private Preferences preferences;
BackupDirectorySetting setting = new BackupDirectorySetting() { BackupDirectorySetting setting = new BackupDirectorySetting() {
public File getBackupDirectory() { public File getBackupDirectory() {
@ -65,11 +66,11 @@ public class BackupServiceTests extends DatabaseTestCase {
} }
private boolean getBackupSetting() { private boolean getBackupSetting() {
return Preferences.getBoolean(R.string.backup_BPr_auto_key, true); return preferences.getBoolean(R.string.backup_BPr_auto_key, true);
} }
private void setBackupSetting(boolean setting) { private void setBackupSetting(boolean setting) {
Preferences.setBoolean(R.string.backup_BPr_auto_key, setting); preferences.setBoolean(R.string.backup_BPr_auto_key, setting);
} }
/** Test backup works */ /** Test backup works */
@ -79,7 +80,7 @@ public class BackupServiceTests extends DatabaseTestCase {
boolean backupSetting = getBackupSetting(); boolean backupSetting = getBackupSetting();
try { try {
setBackupSetting(true); setBackupSetting(true);
Preferences.setLong(BackupPreferences.PREF_BACKUP_LAST_DATE, 0); preferences.setLong(BackupPreferences.PREF_BACKUP_LAST_DATE, 0);
// create a backup // create a backup
BackupService service = new BackupService(); BackupService service = new BackupService();
@ -94,8 +95,8 @@ public class BackupServiceTests extends DatabaseTestCase {
assertTrue(files[0].getName().matches(BackupService.BACKUP_FILE_NAME_REGEX)); assertTrue(files[0].getName().matches(BackupService.BACKUP_FILE_NAME_REGEX));
// assert summary updated // assert summary updated
assertTrue(Preferences.getLong(BackupPreferences.PREF_BACKUP_LAST_DATE, 0) > 0); assertTrue(preferences.getLong(BackupPreferences.PREF_BACKUP_LAST_DATE, 0) > 0);
assertNull(Preferences.getStringValue(BackupPreferences.PREF_BACKUP_LAST_ERROR)); assertNull(preferences.getStringValue(BackupPreferences.PREF_BACKUP_LAST_ERROR));
} finally { } finally {
setBackupSetting(backupSetting); setBackupSetting(backupSetting);
} }
@ -108,7 +109,7 @@ public class BackupServiceTests extends DatabaseTestCase {
boolean backupSetting = getBackupSetting(); boolean backupSetting = getBackupSetting();
try { try {
setBackupSetting(false); setBackupSetting(false);
Preferences.setLong(BackupPreferences.PREF_BACKUP_LAST_DATE, 0); preferences.setLong(BackupPreferences.PREF_BACKUP_LAST_DATE, 0);
// create a backup // create a backup
BackupService service = new BackupService(); BackupService service = new BackupService();
@ -127,7 +128,7 @@ public class BackupServiceTests extends DatabaseTestCase {
assertEquals(0, files.length); assertEquals(0, files.length);
// assert summary not updated // assert summary not updated
assertEquals(0, Preferences.getLong(BackupPreferences.PREF_BACKUP_LAST_DATE, 0)); assertEquals(0, preferences.getLong(BackupPreferences.PREF_BACKUP_LAST_DATE, 0));
} finally { } finally {
setBackupSetting(backupSetting); setBackupSetting(backupSetting);
} }

@ -48,7 +48,6 @@ import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Field; import com.todoroo.andlib.sql.Field;
import com.todoroo.andlib.sql.Join; import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.SortSelectionActivity.OnSortSelectedListener; import com.todoroo.astrid.activity.SortSelectionActivity.OnSortSelectedListener;
import com.todoroo.astrid.adapter.TaskAdapter; import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.adapter.TaskAdapter.OnCompletedTaskListener; import com.todoroo.astrid.adapter.TaskAdapter.OnCompletedTaskListener;
@ -86,6 +85,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.InjectingListFragment; import org.tasks.injection.InjectingListFragment;
import org.tasks.preferences.Preferences;
import java.util.List; import java.util.List;
import java.util.Timer; import java.util.Timer;
@ -145,6 +145,7 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
@Inject TaskDeleter taskDeleter; @Inject TaskDeleter taskDeleter;
@Inject TaskDuplicator taskDuplicator; @Inject TaskDuplicator taskDuplicator;
@Inject @ForActivity Context context; @Inject @ForActivity Context context;
@Inject Preferences preferences;
protected Resources resources; protected Resources resources;
protected TaskAdapter taskAdapter = null; protected TaskAdapter taskAdapter = null;
@ -276,7 +277,7 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
// We have a menu item to show in action bar. // We have a menu item to show in action bar.
resources = getResources(); resources = getResources();
setHasOptionsMenu(true); setHasOptionsMenu(true);
syncActionHelper = new SyncActionHelper(syncService, getActivity(), this); syncActionHelper = new SyncActionHelper(syncService, getActivity(), preferences, this);
setUpUiComponents(); setUpUiComponents();
initializeData(); initializeData();
setupQuickAddBar(); setupQuickAddBar();
@ -292,9 +293,9 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
getListView().setItemsCanFocus(false); getListView().setItemsCanFocus(false);
} }
if (Preferences.getInt(AstridPreferences.P_UPGRADE_FROM, -1) > -1) { if (preferences.getInt(AstridPreferences.P_UPGRADE_FROM, -1) > -1) {
upgradeService.showChangeLog(getActivity(), upgradeService.showChangeLog(getActivity(),
Preferences.getInt(AstridPreferences.P_UPGRADE_FROM, -1)); preferences.getInt(AstridPreferences.P_UPGRADE_FROM, -1));
} }
getListView().setOnItemClickListener(new OnItemClickListener() { getListView().setOnItemClickListener(new OnItemClickListener() {
@ -357,7 +358,7 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
if (!TextUtils.isEmpty(filterId)) { if (!TextUtils.isEmpty(filterId)) {
taskListMetadata = taskListMetadataDao.fetchByTagId(filterId, TaskListMetadata.PROPERTIES); taskListMetadata = taskListMetadataDao.fetchByTagId(filterId, TaskListMetadata.PROPERTIES);
if (taskListMetadata == null) { if (taskListMetadata == null) {
String defaultOrder = Preferences.getStringValue(prefId); String defaultOrder = preferences.getStringValue(prefId);
if (TextUtils.isEmpty(defaultOrder)) { if (TextUtils.isEmpty(defaultOrder)) {
defaultOrder = "[]"; //$NON-NLS-1$ defaultOrder = "[]"; //$NON-NLS-1$
} }
@ -694,7 +695,7 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
TasksWidget.updateWidgets(getActivity()); TasksWidget.updateWidgets(getActivity());
return; return;
} else if (resultCode == SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE) { } else if (resultCode == SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE) {
Preferences.setLong(SyncActionHelper.PREF_LAST_AUTO_SYNC, 0); // Forces autosync to occur after login preferences.setLong(SyncActionHelper.PREF_LAST_AUTO_SYNC, 0); // Forces autosync to occur after login
} }
} }
@ -736,8 +737,7 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
syncActionHelper.request(); syncActionHelper.request();
} }
public static int getTaskRowResource() { public static int getTaskRowResource(int rowStyle) {
int rowStyle = Preferences.getIntegerFromString(R.string.p_taskRowStyle_v2, 0);
switch(rowStyle) { switch(rowStyle) {
case 1: case 1:
return R.layout.task_adapter_row_simple; return R.layout.task_adapter_row_simple;
@ -751,7 +751,7 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
protected TaskAdapter createTaskAdapter(TodorooCursor<Task> cursor) { protected TaskAdapter createTaskAdapter(TodorooCursor<Task> cursor) {
return new TaskAdapter(taskService, this, getTaskRowResource(), return new TaskAdapter(taskService, this, getTaskRowResource(preferences.getIntegerFromString(R.string.p_taskRowStyle_v2, 0)),
cursor, sqlQueryTemplate, cursor, sqlQueryTemplate,
new OnCompletedTaskListener() { new OnCompletedTaskListener() {
@Override @Override
@ -788,7 +788,7 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
} }
public Property<?>[] taskProperties() { public Property<?>[] taskProperties() {
if (Preferences.getIntegerFromString(R.string.p_taskRowStyle_v2, 0) == 2) { if (preferences.getIntegerFromString(R.string.p_taskRowStyle_v2, 0) == 2) {
return TaskAdapter.BASIC_PROPERTIES; return TaskAdapter.BASIC_PROPERTIES;
} }
return TaskAdapter.PROPERTIES; return TaskAdapter.PROPERTIES;

@ -21,7 +21,6 @@ import com.todoroo.andlib.sql.Order;
import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria; import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
@ -33,6 +32,7 @@ import com.todoroo.astrid.utility.AstridPreferences;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.Injector; import org.tasks.injection.Injector;
import org.tasks.preferences.Preferences;
import org.xmlpull.v1.XmlSerializer; import org.xmlpull.v1.XmlSerializer;
import java.io.File; import java.io.File;
@ -70,6 +70,7 @@ public class TasksXmlExporter {
@Inject TagDataService tagDataService; @Inject TagDataService tagDataService;
@Inject MetadataService metadataService; @Inject MetadataService metadataService;
@Inject TaskService taskService; @Inject TaskService taskService;
@Inject Preferences preferences;
// 3 is started on Version 4.6.10 // 3 is started on Version 4.6.10
private static final int FORMAT = 3; private static final int FORMAT = 3;
@ -129,8 +130,8 @@ public class TasksXmlExporter {
doTasksExport(output); doTasksExport(output);
} }
Preferences.setLong(BackupPreferences.PREF_BACKUP_LAST_DATE, DateUtilities.now()); preferences.setLong(BackupPreferences.PREF_BACKUP_LAST_DATE, DateUtilities.now());
Preferences.setString(BackupPreferences.PREF_BACKUP_LAST_ERROR, null); preferences.setString(BackupPreferences.PREF_BACKUP_LAST_ERROR, null);
if (exportType == ExportType.EXPORT_TYPE_MANUAL) { if (exportType == ExportType.EXPORT_TYPE_MANUAL) {
onFinishExport(output); onFinishExport(output);

@ -20,7 +20,6 @@ import android.widget.ArrayAdapter;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.SyncAction; import com.todoroo.astrid.api.SyncAction;
@ -32,6 +31,7 @@ import com.todoroo.astrid.sync.SyncV2Provider;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.tasks.R; import org.tasks.R;
import org.tasks.preferences.Preferences;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
@ -58,19 +58,19 @@ public class SyncActionHelper {
public final SyncResultCallback syncResultCallback; public final SyncResultCallback syncResultCallback;
private final Activity activity;
private final Fragment fragment;
protected SyncActionReceiver syncActionReceiver = new SyncActionReceiver(); protected SyncActionReceiver syncActionReceiver = new SyncActionReceiver();
private final SyncV2Service syncService; private final SyncV2Service syncService;
private final Activity activity;
private final Preferences preferences;
private final Fragment fragment;
// --- boilerplate // --- boilerplate
public SyncActionHelper(SyncV2Service syncService, final Activity activity, Fragment fragment) { public SyncActionHelper(SyncV2Service syncService, final Activity activity, Preferences preferences, Fragment fragment) {
this.syncService = syncService; this.syncService = syncService;
this.activity = activity; this.activity = activity;
this.preferences = preferences;
this.fragment = fragment; this.fragment = fragment;
syncResultCallback = new ProgressBarSyncResultCallback(activity, fragment, syncResultCallback = new ProgressBarSyncResultCallback(activity, fragment,
R.id.progressBar, new Runnable() { R.id.progressBar, new Runnable() {
@ -86,7 +86,7 @@ public class SyncActionHelper {
// --- automatic sync logic // --- automatic sync logic
public void initiateAutomaticSync() { public void initiateAutomaticSync() {
long tasksPushedAt = Preferences.getLong(PREF_LAST_AUTO_SYNC, 0); long tasksPushedAt = preferences.getLong(PREF_LAST_AUTO_SYNC, 0);
if (DateUtilities.now() - tasksPushedAt > TaskListFragment.AUTOSYNC_INTERVAL) { if (DateUtilities.now() - tasksPushedAt > TaskListFragment.AUTOSYNC_INTERVAL) {
performSyncServiceV2Sync(); performSyncServiceV2Sync();
} }
@ -139,7 +139,7 @@ public class SyncActionHelper {
protected void performSyncServiceV2Sync() { protected void performSyncServiceV2Sync() {
boolean syncOccurred = syncService.synchronizeActiveTasks(false, syncResultCallback); boolean syncOccurred = syncService.synchronizeActiveTasks(false, syncResultCallback);
if (syncOccurred) { if (syncOccurred) {
Preferences.setLong(PREF_LAST_AUTO_SYNC, DateUtilities.now()); preferences.setLong(PREF_LAST_AUTO_SYNC, DateUtilities.now());
} }
} }

@ -188,7 +188,7 @@ public class AstridOrderedListFragmentHelper<LIST> implements OrderedListFragmen
public TaskAdapter createTaskAdapter(TodorooCursor<Task> cursor, public TaskAdapter createTaskAdapter(TodorooCursor<Task> cursor,
AtomicReference<String> sqlQueryTemplate) { AtomicReference<String> sqlQueryTemplate) {
taskAdapter = new DraggableTaskAdapter(fragment, TaskListFragment.getTaskRowResource(), taskAdapter = new DraggableTaskAdapter(fragment, TaskListFragment.getTaskRowResource(Preferences.getIntegerFromString(R.string.p_taskRowStyle_v2, 0)),
cursor, sqlQueryTemplate); cursor, sqlQueryTemplate);
getTouchListView().setItemHightNormal(taskAdapter.computeFullRowHeight()); getTouchListView().setItemHightNormal(taskAdapter.computeFullRowHeight());

@ -202,7 +202,7 @@ public class OrderedMetadataListFragmentHelper<LIST> implements OrderedListFragm
public TaskAdapter createTaskAdapter(TodorooCursor<Task> cursor, public TaskAdapter createTaskAdapter(TodorooCursor<Task> cursor,
AtomicReference<String> sqlQueryTemplate) { AtomicReference<String> sqlQueryTemplate) {
taskAdapter = new DraggableTaskAdapter(fragment, TaskListFragment.getTaskRowResource(), taskAdapter = new DraggableTaskAdapter(fragment, TaskListFragment.getTaskRowResource(Preferences.getIntegerFromString(R.string.p_taskRowStyle_v2, 0)),
cursor, sqlQueryTemplate); cursor, sqlQueryTemplate);
taskAdapter.addOnCompletedTaskListener(new OnCompletedTaskListener() { taskAdapter.addOnCompletedTaskListener(new OnCompletedTaskListener() {

@ -14,7 +14,6 @@ import android.os.Bundle;
import android.widget.RemoteViews; import android.widget.RemoteViews;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.TaskEditActivity; import com.todoroo.astrid.activity.TaskEditActivity;
import com.todoroo.astrid.activity.TaskEditFragment; import com.todoroo.astrid.activity.TaskEditFragment;
import com.todoroo.astrid.activity.TaskListActivity; import com.todoroo.astrid.activity.TaskListActivity;
@ -34,6 +33,7 @@ import com.todoroo.astrid.widget.WidgetConfigActivity;
import com.todoroo.astrid.widget.WidgetUpdateService; import com.todoroo.astrid.widget.WidgetUpdateService;
import org.tasks.R; import org.tasks.R;
import org.tasks.preferences.Preferences;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -71,10 +71,12 @@ public class WidgetHelper {
} }
private final TagDataService tagDataService; private final TagDataService tagDataService;
private final Preferences preferences;
@Inject @Inject
public WidgetHelper(TagDataService tagDataService) { public WidgetHelper(TagDataService tagDataService, Preferences preferences) {
this.tagDataService = tagDataService; this.tagDataService = tagDataService;
this.preferences = preferences;
} }
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@ -110,10 +112,10 @@ public class WidgetHelper {
public PendingIntent getListIntent(Context context, Filter filter, int widgetId) { public PendingIntent getListIntent(Context context, Filter filter, int widgetId) {
Intent listIntent = new Intent(context, TaskListActivity.class); Intent listIntent = new Intent(context, TaskListActivity.class);
String customIntent = Preferences.getStringValue(WidgetConfigActivity.PREF_CUSTOM_INTENT String customIntent = preferences.getStringValue(WidgetConfigActivity.PREF_CUSTOM_INTENT
+ widgetId); + widgetId);
if (customIntent != null) { if (customIntent != null) {
String serializedExtras = Preferences.getStringValue(WidgetConfigActivity.PREF_CUSTOM_EXTRAS String serializedExtras = preferences.getStringValue(WidgetConfigActivity.PREF_CUSTOM_EXTRAS
+ widgetId); + widgetId);
Bundle extras = AndroidUtilities.bundleFromSerializedString(serializedExtras); Bundle extras = AndroidUtilities.bundleFromSerializedString(serializedExtras);
listIntent.putExtras(extras); listIntent.putExtras(extras);
@ -182,49 +184,49 @@ public class WidgetHelper {
// base our filter off the inbox filter, replace stuff if we have it // base our filter off the inbox filter, replace stuff if we have it
Filter filter = CoreFilterExposer.buildInboxFilter(context.getResources()); Filter filter = CoreFilterExposer.buildInboxFilter(context.getResources());
String sql = Preferences.getStringValue(WidgetConfigActivity.PREF_SQL + widgetId); String sql = preferences.getStringValue(WidgetConfigActivity.PREF_SQL + widgetId);
if (sql != null) { if (sql != null) {
filter.setSqlQuery(sql); filter.setSqlQuery(sql);
} }
String title = Preferences.getStringValue(WidgetConfigActivity.PREF_TITLE + widgetId); String title = preferences.getStringValue(WidgetConfigActivity.PREF_TITLE + widgetId);
if (title != null) { if (title != null) {
filter.title = title; filter.title = title;
} }
String contentValues = Preferences.getStringValue(WidgetConfigActivity.PREF_VALUES + widgetId); String contentValues = preferences.getStringValue(WidgetConfigActivity.PREF_VALUES + widgetId);
if (contentValues != null) { if (contentValues != null) {
filter.valuesForNewTasks = AndroidUtilities.contentValuesFromSerializedString(contentValues); filter.valuesForNewTasks = AndroidUtilities.contentValuesFromSerializedString(contentValues);
} }
String customComponent = Preferences.getStringValue(WidgetConfigActivity.PREF_CUSTOM_INTENT String customComponent = preferences.getStringValue(WidgetConfigActivity.PREF_CUSTOM_INTENT
+ widgetId); + widgetId);
if (customComponent != null) { if (customComponent != null) {
ComponentName component = ComponentName.unflattenFromString(customComponent); ComponentName component = ComponentName.unflattenFromString(customComponent);
filter = new FilterWithCustomIntent(filter.title, filter.title, filter.getSqlQuery(), filter.valuesForNewTasks); filter = new FilterWithCustomIntent(filter.title, filter.title, filter.getSqlQuery(), filter.valuesForNewTasks);
((FilterWithCustomIntent) filter).customTaskList = component; ((FilterWithCustomIntent) filter).customTaskList = component;
String serializedExtras = Preferences.getStringValue(WidgetConfigActivity.PREF_CUSTOM_EXTRAS String serializedExtras = preferences.getStringValue(WidgetConfigActivity.PREF_CUSTOM_EXTRAS
+ widgetId); + widgetId);
((FilterWithCustomIntent) filter).customExtras = AndroidUtilities.bundleFromSerializedString(serializedExtras); ((FilterWithCustomIntent) filter).customExtras = AndroidUtilities.bundleFromSerializedString(serializedExtras);
} }
// Validate tagData // Validate tagData
long id = Preferences.getLong(WidgetConfigActivity.PREF_TAG_ID + widgetId, 0); long id = preferences.getLong(WidgetConfigActivity.PREF_TAG_ID + widgetId, 0);
TagData tagData; TagData tagData;
if (id > 0) { if (id > 0) {
tagData = tagDataService.fetchById(id, TagData.ID, TagData.NAME, TagData.TASK_COUNT, TagData.UUID, TagData.PICTURE, TagData.USER_ID, TagData.MEMBER_COUNT); tagData = tagDataService.fetchById(id, TagData.ID, TagData.NAME, TagData.TASK_COUNT, TagData.UUID, TagData.PICTURE, TagData.USER_ID, TagData.MEMBER_COUNT);
if (tagData != null && !tagData.getName().equals(filter.title)) { // Tag has been renamed; rebuild filter if (tagData != null && !tagData.getName().equals(filter.title)) { // Tag has been renamed; rebuild filter
filter = TagFilterExposer.filterFromTagData(context, tagData); filter = TagFilterExposer.filterFromTagData(context, tagData);
Preferences.setString(WidgetConfigActivity.PREF_SQL + widgetId, filter.getSqlQuery()); preferences.setString(WidgetConfigActivity.PREF_SQL + widgetId, filter.getSqlQuery());
Preferences.setString(WidgetConfigActivity.PREF_TITLE + widgetId, filter.title); preferences.setString(WidgetConfigActivity.PREF_TITLE + widgetId, filter.title);
ContentValues newTaskValues = filter.valuesForNewTasks; ContentValues newTaskValues = filter.valuesForNewTasks;
String contentValuesString = null; String contentValuesString = null;
if (newTaskValues != null) { if (newTaskValues != null) {
contentValuesString = AndroidUtilities.contentValuesToSerializedString(newTaskValues); contentValuesString = AndroidUtilities.contentValuesToSerializedString(newTaskValues);
} }
Preferences.setString(WidgetConfigActivity.PREF_VALUES + widgetId, contentValuesString); preferences.setString(WidgetConfigActivity.PREF_VALUES + widgetId, contentValuesString);
if (filter != null) { if (filter != null) {
String flattenedExtras = AndroidUtilities.bundleToSerializedString(((FilterWithCustomIntent) filter).customExtras); String flattenedExtras = AndroidUtilities.bundleToSerializedString(((FilterWithCustomIntent) filter).customExtras);
if (flattenedExtras != null) { if (flattenedExtras != null) {
Preferences.setString(WidgetConfigActivity.PREF_CUSTOM_EXTRAS + widgetId, preferences.setString(WidgetConfigActivity.PREF_CUSTOM_EXTRAS + widgetId,
flattenedExtras); flattenedExtras);
} }
} }
@ -232,7 +234,7 @@ public class WidgetHelper {
} else { } else {
tagData = tagDataService.getTagByName(filter.title, TagData.ID); tagData = tagDataService.getTagByName(filter.title, TagData.ID);
if (tagData != null) { if (tagData != null) {
Preferences.setLong(WidgetConfigActivity.PREF_TAG_ID + widgetId, tagData.getId()); preferences.setLong(WidgetConfigActivity.PREF_TAG_ID + widgetId, tagData.getId());
} }
} }

Loading…
Cancel
Save