Truncate notes longer than 200 chars from details.

pull/14/head
Tim Su 13 years ago
parent ffaa628e61
commit 7d256e6c3d

@ -1,5 +1,7 @@
package com.todoroo.andlib.sql;
import com.todoroo.andlib.data.Property.StringProperty;
@ -40,4 +42,8 @@ public final class Functions {
return new Field("COUNT(1)");
}
public static Field length(StringProperty field) {
return new Field("LENGTH(" + field.toString() + ")");
}
}

@ -28,6 +28,8 @@ import com.todoroo.astrid.data.Task;
*/
public class NotesDetailExposer extends BroadcastReceiver {
private static final int NOTE_MAX = 200;
@Override
public void onReceive(Context context, Intent intent) {
// get tags associated with this task
@ -59,8 +61,14 @@ public class NotesDetailExposer extends BroadcastReceiver {
StringBuilder notesBuilder = new StringBuilder();
String notes = task.getValue(Task.NOTES);
if(!TextUtils.isEmpty(notes))
if(!TextUtils.isEmpty(notes)) {
if(notes.length() > NOTE_MAX) {
int lastSpace = notes.lastIndexOf(' ', NOTE_MAX);
notes = notes.substring(0, Math.max(lastSpace, NOTE_MAX - 20));
notesBuilder.append("...");
}
notesBuilder.append(notes);
}
TodorooCursor<Metadata> cursor = PluginServices.getMetadataService().query(
Query.select(Metadata.PROPERTIES).where(

@ -20,6 +20,7 @@ import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Functions;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
@ -122,8 +123,11 @@ public final class UpgradeService {
if(from < V3_1_0)
new Astrid2To3UpgradeHelper().upgrade3To3_1(context, from);
if (from <= V3_8_3_1)
if(from < V3_8_3_1)
new TagCaseMigrator().performTagCaseMigration(context);
if(from < V3_8_4)
taskService.clearDetails(Functions.length(Task.NOTES).gt(170));
} finally {
DialogUtilities.dismissDialog((Activity)context, dialog);
}

Loading…
Cancel
Save