~tomdroid-dev/tomdroid/sync-ui

« back to all changes in this revision

Viewing changes to src/org/tomdroid/NoteManager.java

  • Committer: Rodja Trappe
  • Date: 2010-10-03 11:32:14 UTC
  • mfrom: (204.1.8 freshen-ui)
  • Revision ID: mail@rodja.net-20101003113214-3lt1ighuedvdmoaw
Merged with Matt Stevenson's freshen-ui branch which introduces last change dates in the note list and inserts the tomdroid logo in the actionbar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
package org.tomdroid;
24
24
 
25
25
import org.tomdroid.ui.Tomdroid;
 
26
import org.tomdroid.util.NoteListCursorAdapter;
 
27
import org.tomdroid.util.Preferences;
26
28
 
27
29
import android.app.Activity;
28
30
import android.content.ContentResolver;
29
31
import android.content.ContentValues;
30
32
import android.database.Cursor;
31
33
import android.net.Uri;
 
34
import android.preference.ListPreference;
32
35
import android.util.Log;
33
36
import android.widget.ListAdapter;
34
37
import android.widget.SimpleCursorAdapter;
36
39
public class NoteManager {
37
40
        
38
41
        public static final String[] FULL_PROJECTION = { Note.ID, Note.TITLE, Note.FILE, Note.NOTE_CONTENT, Note.MODIFIED_DATE };
39
 
        public static final String[] LIST_PROJECTION = { Note.ID, Note.TITLE };
 
42
        public static final String[] LIST_PROJECTION = { Note.ID, Note.TITLE, Note.MODIFIED_DATE };
40
43
        public static final String[] TITLE_PROJECTION = { Note.TITLE };
41
44
        public static final String[] GUID_PROJECTION = { Note.ID, Note.GUID };
42
45
        public static final String[] ID_PROJECTION = { Note.ID };
132
135
                // get a cursor representing all notes from the NoteProvider
133
136
                Uri notes = Tomdroid.CONTENT_URI;
134
137
                String where = null;
 
138
                String orderBy;
135
139
                if (!includeNotebookTemplates) {
136
140
                        where = Note.TAGS + " NOT LIKE '%" + "system:template" + "%'";
137
141
                }
138
 
                return activity.managedQuery(notes, LIST_PROJECTION, where, null, null);                
 
142
                orderBy = Note.MODIFIED_DATE + " DESC";
 
143
                return activity.managedQuery(notes, LIST_PROJECTION, where, null, orderBy);             
139
144
        }
140
145
        
141
146
 
142
147
        public static ListAdapter getListAdapter(Activity activity) {
 
148
 
143
149
                Cursor notesCursor = getAllNotes(activity, false);
144
150
                
145
151
                // set up an adapter binding the TITLE field of the cursor to the list item
146
 
                String[] from = new String[] { Note.TITLE };
147
 
                int[] to = new int[] { R.id.note_title };
148
 
                return new SimpleCursorAdapter(activity, R.layout.main_list_item, notesCursor, from, to);
 
152
                String[] from = new String[] { Note.TITLE, Note.MODIFIED_DATE };
 
153
                int[] to = new int[] { R.id.note_title, R.id.note_date };
 
154
                return new NoteListCursorAdapter(activity, R.layout.main_list_item, notesCursor, from, to);
149
155
        }
150
156
 
151
157
        // gets the titles of the notes present in the db, used in ViewNote.buildLinkifyPattern()