diff --git a/astrid/plugin-src/com/todoroo/astrid/files/FileMetadata.java b/astrid/plugin-src/com/todoroo/astrid/files/FileMetadata.java index 945feb35a..9e5ed4567 100644 --- a/astrid/plugin-src/com/todoroo/astrid/files/FileMetadata.java +++ b/astrid/plugin-src/com/todoroo/astrid/files/FileMetadata.java @@ -1,7 +1,9 @@ package com.todoroo.astrid.files; +import com.todoroo.andlib.data.Property.IntegerProperty; import com.todoroo.andlib.data.Property.LongProperty; import com.todoroo.andlib.data.Property.StringProperty; +import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.data.Metadata; public class FileMetadata { @@ -16,16 +18,19 @@ public class FileMetadata { public static final StringProperty FILE_PATH = new StringProperty(Metadata.TABLE, Metadata.VALUE1.name); - public static final LongProperty FILE_TYPE = new LongProperty(Metadata.TABLE, + public static final IntegerProperty FILE_TYPE = new IntegerProperty(Metadata.TABLE, Metadata.VALUE2.name); + public static final LongProperty ATTACH_DATE = new LongProperty(Metadata.TABLE, + Metadata.VALUE3.name); - public static Metadata createNewFileMetadata(long taskId, String filePath, long fileType) { + public static Metadata createNewFileMetadata(long taskId, String filePath, int fileType) { Metadata metadata = new Metadata(); metadata.setValue(Metadata.KEY, METADATA_KEY); metadata.setValue(Metadata.TASK, taskId); metadata.setValue(FILE_PATH, filePath); metadata.setValue(FILE_TYPE, fileType); + metadata.setValue(ATTACH_DATE, DateUtilities.now()); return metadata; } diff --git a/astrid/plugin-src/com/todoroo/astrid/files/FilesControlSet.java b/astrid/plugin-src/com/todoroo/astrid/files/FilesControlSet.java index 0a34cd70d..313113835 100644 --- a/astrid/plugin-src/com/todoroo/astrid/files/FilesControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/files/FilesControlSet.java @@ -1,6 +1,5 @@ package com.todoroo.astrid.files; -import java.io.File; import java.util.ArrayList; import java.util.Date; @@ -30,7 +29,7 @@ public class FilesControlSet extends PopupControlSet { @Autowired private MetadataService metadataService; - private final ArrayList files = new ArrayList(); + private final ArrayList files = new ArrayList(); private final LinearLayout fileList; public FilesControlSet(Activity activity, int viewLayout, int displayViewLayout, int title) { @@ -44,16 +43,16 @@ public class FilesControlSet extends PopupControlSet { @Override protected void refreshDisplayView() { fileList.removeAllViews(); - for (final File f : files) { + for (final Metadata m : files) { TextView textView = new TextView(activity); - String name = parseName(f.getName()); + String name = parseName(m); textView.setText(name); textView.setTextAppearance(activity, R.style.TextAppearance_EditRowDisplay); - if (name.contains("audio")) { //$NON-NLS-1$ + if (m.getValue(FileMetadata.FILE_TYPE) == FileMetadata.FILE_TYPE_AUDIO) { textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - RecognizerApi.play(f.getAbsolutePath()); + RecognizerApi.play(m.getValue(FileMetadata.FILE_PATH)); } }); } @@ -72,11 +71,10 @@ public class FilesControlSet extends PopupControlSet { .where(MetadataCriteria.byTaskAndwithKey(model.getId(), FileMetadata.METADATA_KEY))); try { files.clear(); - Metadata metadata = new Metadata(); for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { + Metadata metadata = new Metadata(); metadata.readFromCursor(cursor); - File file = new File(metadata.getValue(FileMetadata.FILE_PATH)); - files.add(file); + files.add(metadata); } } finally { cursor.close(); @@ -105,11 +103,25 @@ public class FilesControlSet extends PopupControlSet { return null; } - private String parseName(String filename) { - String[] components = filename.split("_"); - long date = Long.parseLong(components[1]); - String dateString = DateUtilities.getDateString(activity, new Date(date)); - return components[2] + " " + dateString; + @SuppressWarnings("nls") + private String parseName(Metadata metadata) { + int prefix = 0; + switch(metadata.getValue(FileMetadata.FILE_TYPE)) { + case FileMetadata.FILE_TYPE_AUDIO: + prefix = R.string.files_type_audio; + break; + case FileMetadata.FILE_TYPE_PDF: + prefix = R.string.files_type_pdf; + break; + } + + String prefixStr = ""; + if (prefix > 0) { + prefixStr = activity.getString(prefix) + " "; + } + + long date = metadata.getValue(FileMetadata.ATTACH_DATE); + return prefixStr + DateUtilities.getDateString(activity, new Date(date)); } } diff --git a/astrid/res/values/strings-premium.xml b/astrid/res/values/strings-premium.xml new file mode 100644 index 000000000..faecec0d5 --- /dev/null +++ b/astrid/res/values/strings-premium.xml @@ -0,0 +1,8 @@ + + + + + Audio + PDF + +