Delete tags, deprecated DELETION_DATE

pull/189/head
Alex Baker 12 years ago
parent dc275202eb
commit cf4fe55ea7

@ -9,7 +9,6 @@ package com.todoroo.astrid.data;
import android.content.ContentValues; import android.content.ContentValues;
import com.todoroo.andlib.data.Property; import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Property.IntegerProperty;
import com.todoroo.andlib.data.Property.LongProperty; import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty; import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.andlib.data.Table; import com.todoroo.andlib.data.Table;
@ -43,6 +42,7 @@ public final class TagData extends RemoteModel {
TABLE, "name"); TABLE, "name");
/** Unixtime Project was deleted. 0 means not deleted */ /** Unixtime Project was deleted. 0 means not deleted */
@Deprecated
public static final LongProperty DELETION_DATE = new LongProperty( public static final LongProperty DELETION_DATE = new LongProperty(
TABLE, "deleted", Property.PROP_FLAG_DATE); TABLE, "deleted", Property.PROP_FLAG_DATE);
@ -106,12 +106,6 @@ public final class TagData extends RemoteModel {
// --- data access methods // --- data access methods
/** Checks whether task is deleted. Will return false if DELETION_DATE not read */
public boolean isDeleted() {
// assume false if we didn't load deletion date
return containsValue(DELETION_DATE) && getValue(DELETION_DATE) > 0;
}
public String getName() { public String getName() {
return getValue(NAME); return getValue(NAME);
} }
@ -139,8 +133,4 @@ public final class TagData extends RemoteModel {
public void setUUID(String uuid) { public void setUUID(String uuid) {
setValue(UUID, uuid); setValue(UUID, uuid);
} }
public void setDeletionDate(Long deletionDate) {
setValue(DELETION_DATE, deletionDate);
}
} }

@ -59,8 +59,6 @@ public class TagViewFragment extends TaskListFragment {
private boolean dataLoaded = false; private boolean dataLoaded = false;
protected boolean justDeleted = false;
// --- UI initialization // --- UI initialization
@Override @Override
@ -168,32 +166,12 @@ public class TagViewFragment extends TaskListFragment {
} }
} }
@Override
public void onResume() {
if (justDeleted) {
parentOnResume();
// tag was deleted locally in settings
// go back to active tasks
AstridActivity activity = ((AstridActivity) getActivity());
FilterListFragment fl = activity.getFilterListFragment();
if (fl != null) {
fl.clear(); // Should auto refresh
activity.switchToActiveTasks();
}
return;
}
super.onResume();
}
protected void reloadTagData() { protected void reloadTagData() {
tagData = tagDataService.fetchById(tagData.getId(), TagData.PROPERTIES); // refetch tagData = tagDataService.fetchById(tagData.getId(), TagData.PROPERTIES); // refetch
if (tagData == null) { if (tagData == null) {
// This can happen if a tag has been deleted as part of a sync // This can happen if a tag has been deleted as part of a sync
taskListMetadata = null; taskListMetadata = null;
return; return;
} else if (tagData.isDeleted()) {
justDeleted = true;
return;
} }
initializeTaskListMetadata(); initializeTaskListMetadata();
filter = TagFilterExposer.filterFromTagData(getActivity(), tagData); filter = TagFilterExposer.filterFromTagData(getActivity(), tagData);

@ -91,7 +91,6 @@ public class NameMaps {
TAG_PROPERTIES_EXCLUDED = new HashSet<>(); TAG_PROPERTIES_EXCLUDED = new HashSet<>();
putTagPropertyToServerName(TagData.NAME, "name", true); putTagPropertyToServerName(TagData.NAME, "name", true);
putTagPropertyToServerName(TagData.DELETION_DATE, "deleted_at", true);
putTagPropertyToServerName(TagData.UUID, "uuid", false); putTagPropertyToServerName(TagData.UUID, "uuid", false);
} }

@ -330,10 +330,6 @@ public class AstridActivity extends InjectingActionBarActivity
} }
} }
public void switchToActiveTasks() {
onFilterItemClicked(CoreFilterExposer.buildInboxFilter(getResources()));
}
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_RESTART_ACTIVITY) { if (resultCode == RESULT_RESTART_ACTIVITY) {

@ -486,15 +486,6 @@ public class TaskListFragment extends InjectingListFragment implements OnSortSel
quickAddBar.destroyRecognizerApi(); quickAddBar.destroyRecognizerApi();
} }
/**
* Crazy hack so that tag view fragment won't automatically initiate an autosync after a tag
* is deleted. TagViewFragment has to call onResume, but we don't want it to call
* the normal tasklist onResume.
*/
protected void parentOnResume() {
super.onResume();
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();

@ -82,7 +82,7 @@ public class SubtasksTagListFragment extends TagViewFragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (lastVisibleIndex >= 0 && !justDeleted) { if (lastVisibleIndex >= 0) {
getListView().setSelection(lastVisibleIndex); getListView().setSelection(lastVisibleIndex);
} }
} }

@ -12,7 +12,6 @@ import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.TagDataDao; import com.todoroo.astrid.dao.TagDataDao;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.service.TagDataService;
import org.tasks.R; import org.tasks.R;
@ -21,7 +20,6 @@ import javax.inject.Inject;
public class DeleteTagActivity extends TagActivity { public class DeleteTagActivity extends TagActivity {
@Inject TagDataDao tagDataDao; @Inject TagDataDao tagDataDao;
@Inject TagDataService tagDataService;
@Inject MetadataDao metadataDao; @Inject MetadataDao metadataDao;
@Override @Override
@ -32,11 +30,10 @@ public class DeleteTagActivity extends TagActivity {
@Override @Override
protected Intent ok() { protected Intent ok() {
int deleted = deleteTagMetadata(uuid); int deleted = deleteTagMetadata(uuid);
TagData tagData = tagDataDao.fetch(uuid, TagData.ID, TagData.UUID, TagData.DELETION_DATE); TagData tagData = tagDataDao.fetch(uuid, TagData.ID, TagData.UUID);
Intent tagDeleted = new Intent(AstridApiConstants.BROADCAST_EVENT_TAG_DELETED); Intent tagDeleted = new Intent(AstridApiConstants.BROADCAST_EVENT_TAG_DELETED);
if (tagData != null) { if (tagData != null) {
tagData.setDeletionDate(DateUtilities.now()); tagDataDao.delete(tagData.getId());
tagDataService.save(tagData);
tagDeleted.putExtra(TagViewFragment.EXTRA_TAG_UUID, tagData.getUuid()); tagDeleted.putExtra(TagViewFragment.EXTRA_TAG_UUID, tagData.getUuid());
} }
Toast.makeText(this, getString(R.string.TEA_tags_deleted, tag, deleted), Toast.LENGTH_SHORT).show(); Toast.makeText(this, getString(R.string.TEA_tags_deleted, tag, deleted), Toast.LENGTH_SHORT).show();

Loading…
Cancel
Save