Adding 'created by' detail to producteev tasks, fix for not fully logging out, don't read null's from database

pull/14/head
Tim Su 16 years ago
parent f9eb247ef6
commit de43051ee1

@ -338,7 +338,12 @@ public abstract class AbstractModel implements Parcelable {
public synchronized void save(Property<?> property, ContentValues newStore, Object value) {
this.store = newStore;
property.accept(this, value);
// we don't allow null values, as they indicate unset properties
// when the database was written
if(value != null)
property.accept(this, value);
}
public Void visitDouble(Property<Double> property, Object value) {

@ -7,6 +7,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.api.AstridApiConstants;
@ -64,6 +65,9 @@ public class ProducteevDetailExposer extends BroadcastReceiver implements Detail
long responsibleId = -1;
if(metadata.containsNonNullValue(ProducteevTask.RESPONSIBLE_ID))
responsibleId = metadata.getValue(ProducteevTask.RESPONSIBLE_ID);
long creatorId = -1;
if(metadata.containsNonNullValue(ProducteevTask.CREATOR_ID))
responsibleId = metadata.getValue(ProducteevTask.CREATOR_ID);
// display dashboard if not "no sync" or "default"
StoreObject ownerDashboard = null;
@ -86,14 +90,21 @@ public class ProducteevDetailExposer extends BroadcastReceiver implements Detail
// display responsible user if not current one
if(responsibleId > 0 && ownerDashboard != null && responsibleId !=
Preferences.getLong(ProducteevUtilities.PREF_USER_ID, 0L)) {
String users = ";" + ownerDashboard.getValue(ProducteevDashboard.USERS); //$NON-NLS-1$
int index = users.indexOf(";" + responsibleId + ","); //$NON-NLS-1$ //$NON-NLS-2$
if(index > -1) {
String user = users.substring(users.indexOf(',', index) + 1,
users.indexOf(';', index + 1));
String user = getUserFromDashboard(ownerDashboard, responsibleId);
if(user != null)
builder.append("<img src='silk_user_gray'/> ").append(user).append(TaskAdapter.DETAIL_SEPARATOR); //$NON-NLS-1$
}
}
// display creator user if not the current one
if(creatorId > 0 && ownerDashboard != null && creatorId !=
Preferences.getLong(ProducteevUtilities.PREF_USER_ID, 0L)) {
String user = getUserFromDashboard(ownerDashboard, responsibleId);
if(user != null)
builder.append("<img src='silk_user_gray'/> ").append( //$NON-NLS-1$
context.getString(R.string.producteev_PDE_task_from, user)).
append(TaskAdapter.DETAIL_SEPARATOR);
}
} else {
TodorooCursor<Metadata> notesCursor = ProducteevDataService.getInstance().getTaskNotesCursor(id);
try {
@ -112,6 +123,16 @@ public class ProducteevDetailExposer extends BroadcastReceiver implements Detail
return result.substring(0, result.length() - TaskAdapter.DETAIL_SEPARATOR.length());
}
/** Try and find user in the dashboard. return null if un-findable */
private String getUserFromDashboard(StoreObject dashboard, long userId) {
String users = ";" + dashboard.getValue(ProducteevDashboard.USERS); //$NON-NLS-1$
int index = users.indexOf(";" + userId + ","); //$NON-NLS-1$ //$NON-NLS-2$
if(index > -1)
return users.substring(users.indexOf(',', index) + 1,
users.indexOf(';', index + 1));
return null;
}
@Override
public String getPluginIdentifier() {
return ProducteevUtilities.IDENTIFIER;

@ -85,6 +85,7 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
preferences.setToken(null);
Preferences.setString(R.string.producteev_PPr_email, null);
Preferences.setString(R.string.producteev_PPr_password, null);
Preferences.setString(ProducteevUtilities.PREF_SERVER_LAST_SYNC, null);
preferences.clearLastSyncDate();
dataService = ProducteevDataService.getInstance();

@ -15,6 +15,9 @@
<!-- Producteev dashboard filter title (%s => dashboardname) -->
<string name="producteev_FEx_responsible_title">Assigned To \'%s\'</string>
<!-- detail for showing tasks created by someone else (%s => person name) -->
<string name="producteev_PDE_task_from">from %s</string>
<!-- ==================================================== Preferences == -->

Loading…
Cancel
Save