• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Simple Notepad Application for Android OS


Commit MetaInfo

Revision3af251b42254ce15847e6eaaea34e24dff1ce632 (tree)
Zeit2012-08-11 21:58:13
AutorMasahiko, SAWAI <say@user...>
CommiterMasahiko, SAWAI

Log Message

NoteDB に新しいテーブルを追加するための準備

Ändern Zusammenfassung

Diff

--- a/notepad-common/src/org/routine_work/notepad/provider/NoteDBConstants.java
+++ b/notepad-common/src/org/routine_work/notepad/provider/NoteDBConstants.java
@@ -34,27 +34,32 @@ interface NoteDBConstants
3434
3535 String DATABASE_NAME = "NoteDB";
3636 int DATABASE_VERSION = 5;
37- String TABLE_NAME = "Notes";
38- // CREATE SQL
39- String CREATE_TABLE_SQL = "CREATE TABLE " + TABLE_NAME + "("
40- + " " + NoteColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT"
41- + ", " + NoteColumns.TITLE + " TEXT"
42- + ", " + NoteColumns.CONTENT + " TEXT"
43- + ", " + NoteColumns.TITLE_LOCKED + " BOOLEAN NOT NULL"
44- + ", " + NoteColumns.CONTENT_LOCKED + " BOOLEAN NOT NULL"
45- + ", " + NoteColumns.DATE_ADDED + " INTEGER NOT NULL"
46- + ", " + NoteColumns.DATE_MODIFIED + " INTEGER NOT NULL"
47- + ");";
48- // DROP SQL
49- String DROP_TABLE_SQL = "DROP TABLE " + TABLE_NAME + ";";
50- String CREATE_TITLE_INDEX_SQL = "CREATE INDEX " + NoteColumns.TITLE + "_index "
51- + "ON " + TABLE_NAME + "(" + NoteColumns.TITLE + ");";
52- String CREATE_CONTENT_INDEX_SQL = "CREATE INDEX " + NoteColumns.CONTENT + "_index "
53- + "ON " + TABLE_NAME + "(" + NoteColumns.CONTENT + ");";
54- String CREATE_DATE_ADDED_INDEX_SQL = "CREATE INDEX " + NoteColumns.DATE_ADDED + "_index "
55- + "ON " + TABLE_NAME + "(" + NoteColumns.DATE_ADDED + ");";
56- String CREATE_DATE_MODIFIED_INDEX_SQL = "CREATE INDEX " + NoteColumns.DATE_MODIFIED + "_index "
57- + "ON " + TABLE_NAME + "(" + NoteColumns.DATE_MODIFIED + ");";
58- String REINDEX_SQL = "REINDEX;";
59- String VACCUM_SQL = "VACUUM;";
37+
38+ interface Notes
39+ {
40+
41+ String TABLE_NAME = "Notes";
42+ // CREATE SQL
43+ String CREATE_TABLE_SQL = "CREATE TABLE " + TABLE_NAME + "("
44+ + " " + NoteColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT"
45+ + ", " + NoteColumns.TITLE + " TEXT"
46+ + ", " + NoteColumns.CONTENT + " TEXT"
47+ + ", " + NoteColumns.TITLE_LOCKED + " BOOLEAN NOT NULL"
48+ + ", " + NoteColumns.CONTENT_LOCKED + " BOOLEAN NOT NULL"
49+ + ", " + NoteColumns.DATE_ADDED + " INTEGER NOT NULL"
50+ + ", " + NoteColumns.DATE_MODIFIED + " INTEGER NOT NULL"
51+ + ");";
52+ // DROP SQL
53+ String DROP_TABLE_SQL = "DROP TABLE " + TABLE_NAME + ";";
54+ String CREATE_TITLE_INDEX_SQL = "CREATE INDEX " + NoteColumns.TITLE + "_index "
55+ + "ON " + TABLE_NAME + "(" + NoteColumns.TITLE + ");";
56+ String CREATE_CONTENT_INDEX_SQL = "CREATE INDEX " + NoteColumns.CONTENT + "_index "
57+ + "ON " + TABLE_NAME + "(" + NoteColumns.CONTENT + ");";
58+ String CREATE_DATE_ADDED_INDEX_SQL = "CREATE INDEX " + NoteColumns.DATE_ADDED + "_index "
59+ + "ON " + TABLE_NAME + "(" + NoteColumns.DATE_ADDED + ");";
60+ String CREATE_DATE_MODIFIED_INDEX_SQL = "CREATE INDEX " + NoteColumns.DATE_MODIFIED + "_index "
61+ + "ON " + TABLE_NAME + "(" + NoteColumns.DATE_MODIFIED + ");";
62+ String REINDEX_SQL = "REINDEX;";
63+ String VACCUM_SQL = "VACUUM;";
64+ }
6065 }
--- a/notepad-common/src/org/routine_work/notepad/provider/NoteDBHelper.java
+++ b/notepad-common/src/org/routine_work/notepad/provider/NoteDBHelper.java
@@ -62,16 +62,16 @@ class NoteDBHelper extends SQLiteOpenHelper
6262 public void onCreate(SQLiteDatabase db)
6363 {
6464 Log.w(LOG_TAG, "Create database.");
65- Log.w(LOG_TAG, "CREATE_TABLE_SQL => " + CREATE_TABLE_SQL);
66- db.execSQL(CREATE_TABLE_SQL);
67- Log.w(LOG_TAG, "CREATE_TITLE_INDEX_SQL => " + CREATE_TITLE_INDEX_SQL);
68- db.execSQL(CREATE_TITLE_INDEX_SQL);
69- Log.w(LOG_TAG, "CREATE_CONTENT_INDEX_SQL => " + CREATE_CONTENT_INDEX_SQL);
70- db.execSQL(CREATE_CONTENT_INDEX_SQL);
71- Log.w(LOG_TAG, "CREATE_DATE_ADDED_INDEX_SQL => " + CREATE_DATE_ADDED_INDEX_SQL);
72- db.execSQL(CREATE_DATE_ADDED_INDEX_SQL);
73- Log.w(LOG_TAG, "CREATE_DATE_MODIFIED_INDEX_SQL => " + CREATE_DATE_MODIFIED_INDEX_SQL);
74- db.execSQL(CREATE_DATE_MODIFIED_INDEX_SQL);
65+ Log.w(LOG_TAG, "Notes.CREATE_TABLE_SQL => " + Notes.CREATE_TABLE_SQL);
66+ db.execSQL(Notes.CREATE_TABLE_SQL);
67+ Log.w(LOG_TAG, "Notes.CREATE_TITLE_INDEX_SQL => " + Notes.CREATE_TITLE_INDEX_SQL);
68+ db.execSQL(Notes.CREATE_TITLE_INDEX_SQL);
69+ Log.w(LOG_TAG, "Notes.CREATE_CONTENT_INDEX_SQL => " + Notes.CREATE_CONTENT_INDEX_SQL);
70+ db.execSQL(Notes.CREATE_CONTENT_INDEX_SQL);
71+ Log.w(LOG_TAG, "Notes.CREATE_DATE_ADDED_INDEX_SQL => " + Notes.CREATE_DATE_ADDED_INDEX_SQL);
72+ db.execSQL(Notes.CREATE_DATE_ADDED_INDEX_SQL);
73+ Log.w(LOG_TAG, "Notes.CREATE_DATE_MODIFIED_INDEX_SQL => " + Notes.CREATE_DATE_MODIFIED_INDEX_SQL);
74+ db.execSQL(Notes.CREATE_DATE_MODIFIED_INDEX_SQL);
7575 }
7676
7777 @Override
@@ -87,7 +87,7 @@ class NoteDBHelper extends SQLiteOpenHelper
8787 backupV4To(db, backupDir);
8888 }
8989 // upgrade table
90- db.execSQL(DROP_TABLE_SQL);
90+ db.execSQL(Notes.DROP_TABLE_SQL);
9191
9292 // restore data
9393 onCreate(db);
@@ -97,12 +97,12 @@ class NoteDBHelper extends SQLiteOpenHelper
9797
9898 public void reindex(SQLiteDatabase db)
9999 {
100- db.execSQL(REINDEX_SQL);
100+ db.execSQL(Notes.REINDEX_SQL);
101101 }
102102
103103 public void vacuum(SQLiteDatabase db)
104104 {
105- db.execSQL(VACCUM_SQL);
105+ db.execSQL(Notes.VACCUM_SQL);
106106 }
107107
108108 public void backupV4To(SQLiteDatabase db, File backupDirectory)
@@ -110,7 +110,7 @@ class NoteDBHelper extends SQLiteOpenHelper
110110 Log.v(LOG_TAG, "Hello");
111111 Log.v(LOG_TAG, "backupDirectory => " + backupDirectory);
112112
113- Cursor cursor = db.query(TABLE_NAME, null, null, null, null, null, null);
113+ Cursor cursor = db.query(Notes.TABLE_NAME, null, null, null, null, null, null);
114114 if (cursor != null && cursor.moveToFirst())
115115 {
116116 int idIndex = cursor.getColumnIndex(NoteColumns._ID);
@@ -173,7 +173,7 @@ class NoteDBHelper extends SQLiteOpenHelper
173173 values.put(NoteColumns.CONTENT_LOCKED, note.contentLocked);
174174 values.put(NoteColumns.DATE_ADDED, note.added);
175175 values.put(NoteColumns.DATE_MODIFIED, note.modified);
176- db.insert(TABLE_NAME, null, values);
176+ db.insert(Notes.TABLE_NAME, null, values);
177177 }
178178 catch (FileNotFoundException ex)
179179 {
--- a/notepad-common/src/org/routine_work/notepad/provider/NoteProvider.java
+++ b/notepad-common/src/org/routine_work/notepad/provider/NoteProvider.java
@@ -45,10 +45,10 @@ public class NoteProvider extends ContentProvider
4545
4646 private static final String LOG_TAG = "simple-notepad";
4747 // URI
48- private static final int ITEM_ALL = 1;
49- private static final int ITEM_BY_ID = 2;
50- private static final int SUGGEST_SEARCH_ALL = 3;
51- private static final int SUGGEST_SEARCH_BY_WORD = 4;
48+ private static final int NOTES_ITEM_ALL = 1;
49+ private static final int NOTES_ITEM_BY_ID = 2;
50+ private static final int NOTES_SUGGEST_SEARCH_ALL = 3;
51+ private static final int NOTES_SUGGEST_SEARCH_BY_WORD = 4;
5252 private static final UriMatcher URI_MATCHER;
5353 private static final Map<String, String> SUGGESTION_PROJECTION_MAP;
5454 // DB
@@ -57,10 +57,10 @@ public class NoteProvider extends ContentProvider
5757 static
5858 {
5959 URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
60- URI_MATCHER.addURI(NoteStore.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, SUGGEST_SEARCH_ALL);
61- URI_MATCHER.addURI(NoteStore.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", SUGGEST_SEARCH_BY_WORD);
62- URI_MATCHER.addURI(NoteStore.AUTHORITY, "notes", ITEM_ALL);
63- URI_MATCHER.addURI(NoteStore.AUTHORITY, "notes/#", ITEM_BY_ID);
60+ URI_MATCHER.addURI(NoteStore.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, NOTES_SUGGEST_SEARCH_ALL);
61+ URI_MATCHER.addURI(NoteStore.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", NOTES_SUGGEST_SEARCH_BY_WORD);
62+ URI_MATCHER.addURI(NoteStore.AUTHORITY, "notes", NOTES_ITEM_ALL);
63+ URI_MATCHER.addURI(NoteStore.AUTHORITY, "notes/#", NOTES_ITEM_BY_ID);
6464
6565 SUGGESTION_PROJECTION_MAP = new HashMap<String, String>();
6666 SUGGESTION_PROJECTION_MAP.put(SearchManager.SUGGEST_COLUMN_TEXT_1,
@@ -91,35 +91,35 @@ public class NoteProvider extends ContentProvider
9191 Log.d(LOG_TAG, "query uri => " + uri);
9292
9393 SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
94- qb.setTables(TABLE_NAME);
94+ qb.setTables(Notes.TABLE_NAME);
9595
9696 int match = URI_MATCHER.match(uri);
9797 switch (match)
9898 {
99- case SUGGEST_SEARCH_ALL:
100- case SUGGEST_SEARCH_BY_WORD:
99+ case NOTES_SUGGEST_SEARCH_ALL:
100+ case NOTES_SUGGEST_SEARCH_BY_WORD:
101101 qb.setProjectionMap(SUGGESTION_PROJECTION_MAP);
102102 break;
103103 }
104104
105105 switch (match)
106106 {
107- case SUGGEST_SEARCH_BY_WORD:
107+ case NOTES_SUGGEST_SEARCH_BY_WORD:
108108 Log.d(LOG_TAG, "*SEARCH_BY_WORD");
109109 String queryWord = uri.getLastPathSegment().trim();
110110 Log.d(LOG_TAG, "queryWord => " + queryWord);
111111 setUpQueryByWord(qb, queryWord);
112112 break;
113- case SUGGEST_SEARCH_ALL:
113+ case NOTES_SUGGEST_SEARCH_ALL:
114114 break;
115- case ITEM_ALL:
115+ case NOTES_ITEM_ALL:
116116 uri.getQueryParameter("q");
117117 Log.d(LOG_TAG, "*SEARCH_BY_WORD");
118118 String q = uri.getQueryParameter("q");
119119 Log.d(LOG_TAG, "queryWord => " + q);
120120 setUpQueryByWord(qb, q);
121121 break;
122- case ITEM_BY_ID:
122+ case NOTES_ITEM_BY_ID:
123123 qb.appendWhere(NoteColumns._ID + "=" + uri.getPathSegments().get(1));
124124 break;
125125 default:
@@ -143,7 +143,7 @@ public class NoteProvider extends ContentProvider
143143 Log.v(LOG_TAG, "Hello");
144144 Uri newUri = null;
145145
146- long rowID = noteDB.insert(TABLE_NAME, null, initialValues);
146+ long rowID = noteDB.insert(Notes.TABLE_NAME, null, initialValues);
147147 Log.d(LOG_TAG, "rowID => " + rowID);
148148
149149 if (rowID > 0)
@@ -169,10 +169,10 @@ public class NoteProvider extends ContentProvider
169169
170170 switch (URI_MATCHER.match(uri))
171171 {
172- case ITEM_ALL:
173- count = noteDB.delete(TABLE_NAME, where, whereArgs);
172+ case NOTES_ITEM_ALL:
173+ count = noteDB.delete(Notes.TABLE_NAME, where, whereArgs);
174174 break;
175- case ITEM_BY_ID:
175+ case NOTES_ITEM_BY_ID:
176176 String itemId = uri.getPathSegments().get(1);
177177 StringBuilder whereClause = new StringBuilder();
178178 whereClause.append(NoteStore.NoteColumns._ID);
@@ -185,7 +185,7 @@ public class NoteProvider extends ContentProvider
185185 whereClause.append(")");
186186 }
187187
188- count = noteDB.delete(TABLE_NAME, whereClause.toString(),
188+ count = noteDB.delete(Notes.TABLE_NAME, whereClause.toString(),
189189 whereArgs);
190190 break;
191191
@@ -207,11 +207,11 @@ public class NoteProvider extends ContentProvider
207207
208208 switch (URI_MATCHER.match(uri))
209209 {
210- case ITEM_ALL:
211- count = noteDB.update(TABLE_NAME, values, where, whereArgs);
210+ case NOTES_ITEM_ALL:
211+ count = noteDB.update(Notes.TABLE_NAME, values, where, whereArgs);
212212 break;
213213
214- case ITEM_BY_ID:
214+ case NOTES_ITEM_BY_ID:
215215 String segment = uri.getPathSegments().get(1);
216216
217217 StringBuilder whereClause = new StringBuilder();
@@ -225,7 +225,7 @@ public class NoteProvider extends ContentProvider
225225 whereClause.append(where);
226226 whereClause.append(")");
227227 }
228- count = noteDB.update(TABLE_NAME, values,
228+ count = noteDB.update(Notes.TABLE_NAME, values,
229229 whereClause.toString(), whereArgs);
230230 break;
231231
@@ -247,11 +247,11 @@ public class NoteProvider extends ContentProvider
247247
248248 switch (URI_MATCHER.match(uri))
249249 {
250- case SUGGEST_SEARCH_ALL:
251- case ITEM_ALL:
250+ case NOTES_SUGGEST_SEARCH_ALL:
251+ case NOTES_ITEM_ALL:
252252 type = NoteStore.NOTE_LIST_CONTENT_TYPE;
253253 break;
254- case ITEM_BY_ID:
254+ case NOTES_ITEM_BY_ID:
255255 type = NoteStore.NOTE_ITEM_CONTENT_TYPE;
256256 break;
257257 default:
@@ -277,7 +277,7 @@ public class NoteProvider extends ContentProvider
277277 }
278278 catch (NumberFormatException e)
279279 {
280- Log.e(LOG_TAG, "limit parameter is illegal value : limitText => " + limit);
280+ Log.e(LOG_TAG, "limit parameter is illegal value : limitText => " + limit, e);
281281 limit = null;
282282 }
283283 }
--- a/notepad-common/src/org/routine_work/notepad/provider/NoteStore.java
+++ b/notepad-common/src/org/routine_work/notepad/provider/NoteStore.java
@@ -30,7 +30,6 @@ import android.database.Cursor;
3030 import android.database.sqlite.SQLiteDatabase;
3131 import android.net.Uri;
3232 import android.provider.BaseColumns;
33-import android.text.TextUtils;
3433 import org.routine_work.utils.Log;
3534
3635 /**
--- a/notepad-common/src/org/routine_work/notepad/provider/RecentQueryTextSuggestionProvider.java
+++ b/notepad-common/src/org/routine_work/notepad/provider/RecentQueryTextSuggestionProvider.java
@@ -32,6 +32,7 @@ import android.content.SearchRecentSuggestionsProvider;
3232 */
3333 public class RecentQueryTextSuggestionProvider extends SearchRecentSuggestionsProvider
3434 {
35+
3536 public static final String AUTHORITY = "org.routine_work.notepad.recent_query_text_suggestion_provider";
3637
3738 public RecentQueryTextSuggestionProvider()