diff --git a/NotePad/AndroidManifest.xml b/NotePad/AndroidManifest.xml index 5131bce..f68b41b 100644 --- a/NotePad/AndroidManifest.xml +++ b/NotePad/AndroidManifest.xml @@ -49,6 +49,7 @@ diff --git a/NotePad/res/drawable/header_bg_brown.xml b/NotePad/res/drawable/header_bg_brown.xml new file mode 100644 index 0000000..303abb2 --- /dev/null +++ b/NotePad/res/drawable/header_bg_brown.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/NotePad/res/drawable/note_item_bg_blue.xml b/NotePad/res/drawable/note_item_bg_blue.xml new file mode 100644 index 0000000..c5fb359 --- /dev/null +++ b/NotePad/res/drawable/note_item_bg_blue.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + diff --git a/NotePad/res/drawable/note_item_bg_green.xml b/NotePad/res/drawable/note_item_bg_green.xml new file mode 100644 index 0000000..175c958 --- /dev/null +++ b/NotePad/res/drawable/note_item_bg_green.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + diff --git a/NotePad/res/drawable/note_item_bg_grey.xml b/NotePad/res/drawable/note_item_bg_grey.xml new file mode 100644 index 0000000..33d5f25 --- /dev/null +++ b/NotePad/res/drawable/note_item_bg_grey.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + diff --git a/NotePad/res/drawable/note_item_bg_pink.xml b/NotePad/res/drawable/note_item_bg_pink.xml new file mode 100644 index 0000000..5330abc --- /dev/null +++ b/NotePad/res/drawable/note_item_bg_pink.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + diff --git a/NotePad/res/drawable/note_item_bg_yellow.xml b/NotePad/res/drawable/note_item_bg_yellow.xml new file mode 100644 index 0000000..fbe4a36 --- /dev/null +++ b/NotePad/res/drawable/note_item_bg_yellow.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + diff --git a/NotePad/res/drawable/notes_background.jpg b/NotePad/res/drawable/notes_background.jpg new file mode 100644 index 0000000..2614eaa Binary files /dev/null and b/NotePad/res/drawable/notes_background.jpg differ diff --git a/NotePad/res/drawable/notes_btn_changecolors.png b/NotePad/res/drawable/notes_btn_changecolors.png new file mode 100644 index 0000000..6f6c45c Binary files /dev/null and b/NotePad/res/drawable/notes_btn_changecolors.png differ diff --git a/NotePad/res/drawable/transparent72.png b/NotePad/res/drawable/transparent72.png new file mode 100644 index 0000000..65343ba Binary files /dev/null and b/NotePad/res/drawable/transparent72.png differ diff --git a/NotePad/res/drawable/zhengwen_xuanyanse.png b/NotePad/res/drawable/zhengwen_xuanyanse.png new file mode 100644 index 0000000..33ceb63 Binary files /dev/null and b/NotePad/res/drawable/zhengwen_xuanyanse.png differ diff --git a/NotePad/res/layout/note_editor.xml b/NotePad/res/layout/note_editor.xml index 8bd8c15..11fa66e 100644 --- a/NotePad/res/layout/note_editor.xml +++ b/NotePad/res/layout/note_editor.xml @@ -16,15 +16,63 @@ * limitations under the License. --> - \ No newline at end of file + android:layout_height="match_parent"> + + + + + + + + + + + + + + diff --git a/NotePad/res/layout/noteslist.xml b/NotePad/res/layout/noteslist.xml index ba1a38c..4fb0c57 100644 --- a/NotePad/res/layout/noteslist.xml +++ b/NotePad/res/layout/noteslist.xml @@ -17,22 +17,9 @@ - - - + + > - + #faffd1 + #eef3c1 + #cdd0a4 + + #CCCCCC + #EFEFEF + #848484 + #2D2D2D + + #825f3f + #5b371d + + #ddf2ff + #ddf2ff + #acd6f1 + + #ffeded + #ffeded + #d1c2c2 + + #eafecf + #cfe08a + #b3c665 + diff --git a/NotePad/res/values/strings.xml b/NotePad/res/values/strings.xml index b5fe4e9..78880f1 100644 --- a/NotePad/res/values/strings.xml +++ b/NotePad/res/values/strings.xml @@ -68,6 +68,8 @@ Share + Color + Empty note No application available for sharing. diff --git a/NotePad/res/values/styles.xml b/NotePad/res/values/styles.xml new file mode 100644 index 0000000..fc6ae30 --- /dev/null +++ b/NotePad/res/values/styles.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/NotePad/src/org/openintents/notepad/NoteEditor.java b/NotePad/src/org/openintents/notepad/NoteEditor.java index 37122b0..76e7860 100644 --- a/NotePad/src/org/openintents/notepad/NoteEditor.java +++ b/NotePad/src/org/openintents/notepad/NoteEditor.java @@ -88,8 +88,12 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; +import android.view.View; +import android.view.View.OnClickListener; import android.view.Window; import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; @@ -114,6 +118,7 @@ public class NoteEditor extends Activity implements ThemeDialogListener { Notes.SELECTION_START, // 5 Notes.SELECTION_END, // 6 Notes.SCROLL_POSITION, // 7 + Notes.COLOR, // 7 }; /** The index of the note column */ private static final int COLUMN_INDEX_ID = 0; @@ -124,6 +129,7 @@ public class NoteEditor extends Activity implements ThemeDialogListener { private static final int COLUMN_INDEX_SELECTION_START = 5; private static final int COLUMN_INDEX_SELECTION_END = 6; private static final int COLUMN_INDEX_SCROLL_POSITION = 7; + private static final int COLUMN_INDEX_COLOR = 8; // This is our state data that is stored when freezing. private static final String BUNDLE_ORIGINAL_CONTENT = "original_content"; @@ -151,6 +157,7 @@ public class NoteEditor extends Activity implements ThemeDialogListener { private static final int MENU_SETTINGS = Menu.FIRST + 9; private static final int MENU_SEND = Menu.FIRST + 10; private static final int MENU_WORD_COUNT = Menu.FIRST + 11; + private static final int MENU_COLOR = Menu.FIRST + 12; // private static final int REQUEST_CODE_ENCRYPT = 1; private static final int REQUEST_CODE_DECRYPT = 2; @@ -196,6 +203,8 @@ public class NoteEditor extends Activity implements ThemeDialogListener { private long mEncrypted; private String mDecryptedText; + private int mColor = -1; + /** * static string for hack. Only used for configuration changes. */ @@ -203,6 +212,13 @@ public class NoteEditor extends Activity implements ThemeDialogListener { private static int sSelectionStart = 0; private static int sSelectionStop = 0; + private static final int BLUE = 1; + private static final int GREEN = 2; + private static final int GREY = 3; + private static final int PINK = 4; + private static final int YELLOW = 5; + + private String mFileContent; // private String mTags; @@ -223,6 +239,7 @@ public class NoteEditor extends Activity implements ThemeDialogListener { private boolean hasNoteColumn = true; private boolean hasTagsColumn = true; private boolean hasEncryptionColumn = true; + private boolean hasColorColumn = true; private boolean hasThemeColumn = true; private boolean hasSelection_startColumn = true; private boolean hasSelection_endColumn = true; @@ -534,7 +551,10 @@ protected void onCreate(Bundle savedInstanceState) { if (!columnNames.contains(Notes.THEME)) { hasThemeColumn = false; } - if (!columnNames.contains(Notes.SELECTION_START)) { + if(!columnNames.contains(Notes.COLOR)){ + hasColorColumn = false; + } + if(!columnNames.contains(Notes.SELECTION_START)){ hasSelection_startColumn = false; } if (!columnNames.contains(Notes.SELECTION_END)) { @@ -799,6 +819,7 @@ private void getNoteFromContentProvider() { mTheme = mCursor.getString(COLUMN_INDEX_THEME); mSelectionStart = mCursor.getInt(COLUMN_INDEX_SELECTION_START); mSelectionStop = mCursor.getInt(COLUMN_INDEX_SELECTION_END); + mColor = mCursor.getInt(COLUMN_INDEX_COLOR); } if (mEncrypted == 0) { @@ -1008,11 +1029,13 @@ protected void onPause() { if (hasThemeColumn) { values.put(Notes.THEME, mTheme); } - if (hasSelection_startColumn) { - values.put(Notes.SELECTION_START, - mText.getSelectionStart()); + if(hasColorColumn){ + values.put(Notes.COLOR, mColor); + } + if(hasSelection_startColumn){ + values.put(Notes.SELECTION_START, mText.getSelectionStart()); } - if (hasSelection_endColumn) { + if(hasSelection_endColumn){ values.put(Notes.SELECTION_END, mText.getSelectionEnd()); } @@ -1032,6 +1055,9 @@ protected void onPause() { if (hasThemeColumn) { values.put(Notes.THEME, mTheme); } + if(hasColorColumn){ + values.put(Notes.COLOR, mColor); + } getContentResolver().update(mUri, values, null, null); @@ -1219,6 +1245,12 @@ public boolean onCreateOptionsMenu(Menu menu) { WrapActionBar.showIfRoom(item); } + item = menu.add(4, MENU_COLOR, 0, R.string.menu_color); + item.setIcon( R.drawable.notes_btn_changecolors ); + if(mActionBarAvailable){ + WrapActionBar.showIfRoom(item); + } + menu.add(5, MENU_WORD_COUNT, 0, R.string.menu_word_count); /* @@ -1368,6 +1400,9 @@ public boolean onOptionsItemSelected(MenuItem item) { case MENU_SEND: shareNote(); return true; + case MENU_COLOR: + setColor(); + return true; case MENU_WORD_COUNT: showWordCount(); break; @@ -1383,12 +1418,88 @@ public boolean onOptionsItemSelected(MenuItem item) { return super.onOptionsItemSelected(item); } + private void setColor() { + LinearLayout color = (LinearLayout) findViewById(R.id.editor_color); + ImageView color_yellow = (ImageView) findViewById(R.id.editor_color_yellow); + ImageView color_pink = (ImageView) findViewById(R.id.editor_color_pink); + ImageView color_blue = (ImageView) findViewById(R.id.editor_color_blue); + ImageView color_green = (ImageView) findViewById(R.id.editor_color_green); + ImageView color_gray = (ImageView) findViewById(R.id.editor_color_gray); + + color_yellow.setOnClickListener(colorListener); + color_pink.setOnClickListener(colorListener); + color_blue.setOnClickListener(colorListener); + color_green.setOnClickListener(colorListener); + color_gray.setOnClickListener(colorListener); + + color.setVisibility(View.VISIBLE); + } + + OnClickListener colorListener = new OnClickListener() { + @Override + public void onClick(View v) { + // TODO Auto-generated method stub + switch (v.getId()) { + case R.id.editor_color_yellow: + setNoteColor(YELLOW); + break; + case R.id.editor_color_pink: + setNoteColor(PINK); + break; + case R.id.editor_color_blue: + setNoteColor(BLUE); + break; + case R.id.editor_color_green: + setNoteColor(GREEN); + break; + case R.id.editor_color_gray: + setNoteColor(GREY); + break; + default: + break; + } + } + }; + private void shareNote() { String content = mText.getText().toString(); String title = ExtractTitle.extractTitle(content); SendNote.sendNote(this, title, content); } + protected void setNoteColor(int color) { + int id = (int)R.color.lightYellow; + Resources res = getResources(); + LinearLayout c = (LinearLayout) findViewById(R.id.editor_color); + c.setVisibility(View.GONE); + + switch (color) { + case BLUE: + id = (int)R.color.lightBabyBlue; + break; + case GREEN: + id = (int)R.color.lightGreen; + break; + case PINK: + id = (int)R.color.lightPink; + break; + case GREY: + id = (int)R.color.lightGray; + break; + default: + break; + } + + mText.setBackgroundDrawable(res.getDrawable(id)); + + if (color == mColor) + return; + mColor = color; + ContentValues values = new ContentValues(); + values.put(Notes.COLOR, mColor); + getContentResolver().update(mUri, values, null, null); + } + private void deleteNoteWithConfirm() { showDialog(DIALOG_DELETE); } @@ -1885,6 +1996,7 @@ private boolean setRemoteStyle(String styleName, int size) { } else { // remove background mText.setBackgroundResource(0); + setNoteColor(mColor); } } catch (NameNotFoundException e) { Log.e(TAG, "Package not found for Theme background.", e); @@ -2115,4 +2227,4 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { } } } -} \ No newline at end of file +} diff --git a/NotePad/src/org/openintents/notepad/NotePad.java b/NotePad/src/org/openintents/notepad/NotePad.java index 46942fd..37df749 100644 --- a/NotePad/src/org/openintents/notepad/NotePad.java +++ b/NotePad/src/org/openintents/notepad/NotePad.java @@ -156,6 +156,16 @@ private Notes() { */ public static final String SCROLL_POSITION = "scroll_position"; + /** + * A color id + *

+ * Type: INTEGER + *

+ * + * @since 1.3.2 + */ + public static final String COLOR = "color"; + /** * Support sort orders. The "sort order" in the preferences is an index * into this array. diff --git a/NotePad/src/org/openintents/notepad/NotePadProvider.java b/NotePad/src/org/openintents/notepad/NotePadProvider.java index 662d8b4..686cd11 100644 --- a/NotePad/src/org/openintents/notepad/NotePadProvider.java +++ b/NotePad/src/org/openintents/notepad/NotePadProvider.java @@ -54,9 +54,10 @@ public class NotePadProvider extends ContentProvider { *
  • Version 2 (1.0.0 - 1.0.2): title, note, created_date, modified_date
  • *
  • Version 3 (1.1.0 - 1.2.3): tags, encrypted, theme
  • *
  • Version 4 (1.2.3 - ): selection_start, selection_end
  • + *
  • Version 5 (1.3 - ): color
  • * */ - private static final int DATABASE_VERSION = 4; + private static final int DATABASE_VERSION = 5; private static final String NOTES_TABLE_NAME = "notes"; private static HashMap sNotesProjectionMap; @@ -90,7 +91,10 @@ public void onCreate(SQLiteDatabase db) { + Notes.THEME + " TEXT," // Version 4: + Notes.SELECTION_START + " INTEGER," + Notes.SELECTION_END - + " INTEGER," + Notes.SCROLL_POSITION + " REAL" + ");"); + + " INTEGER," + Notes.SCROLL_POSITION + " REAL," + // Version 5: + + Notes.COLOR+ " INTEGER);" + ); } @Override @@ -139,6 +143,15 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } case 4: + try { + db.execSQL("ALTER TABLE " + NOTES_TABLE_NAME + " ADD COLUMN " + + Notes.COLOR + " INTEGER;"); + } catch (SQLException e) { + Log.e(TAG, "Error executing SQL: ", e); + } + // fall through for further upgrades. + + case 5: // add more columns here break; @@ -266,6 +279,10 @@ public Uri insert(Uri uri, ContentValues initialValues) { values.put(Notes.SCROLL_POSITION, 0.0); } + if(values.containsKey(Notes.COLOR) == false) { + values.put(Notes.COLOR, -1); + } + SQLiteDatabase db = mOpenHelper.getWritableDatabase(); long rowId = db.insert(NOTES_TABLE_NAME, Notes.NOTE, values); if (rowId > 0) { @@ -369,5 +386,6 @@ public int update(Uri uri, ContentValues values, String where, sNotesProjectionMap.put(Notes.SELECTION_START, Notes.SELECTION_START); sNotesProjectionMap.put(Notes.SELECTION_END, Notes.SELECTION_END); sNotesProjectionMap.put(Notes.SCROLL_POSITION, Notes.SCROLL_POSITION); + sNotesProjectionMap.put(Notes.COLOR, Notes.COLOR); } } diff --git a/NotePad/src/org/openintents/notepad/noteslist/NotesListCursor.java b/NotePad/src/org/openintents/notepad/noteslist/NotesListCursor.java index 62dd9f5..af4f0e8 100644 --- a/NotePad/src/org/openintents/notepad/noteslist/NotesListCursor.java +++ b/NotePad/src/org/openintents/notepad/noteslist/NotesListCursor.java @@ -33,9 +33,11 @@ public class NotesListCursor extends OpenMatrixCursor { protected static final String[] PROJECTION_DB = new String[] { Notes._ID, // 0 Notes.TITLE, // 1 Notes.TAGS, // 2 - Notes.ENCRYPTED // 3 + Notes.ENCRYPTED, // 3 + Notes.COLOR // 4 }; + /** * This cursors' columns */ @@ -44,7 +46,8 @@ public class NotesListCursor extends OpenMatrixCursor { Notes.TAGS, // 2 Notes.ENCRYPTED, // 3 TITLE_DECRYPTED, // 4 - TAGS_DECRYPTED // 5 + TAGS_DECRYPTED, // 5 + Notes.COLOR // 6 }; public static final int COLUMN_INDEX_ID = 0; @@ -55,6 +58,7 @@ public class NotesListCursor extends OpenMatrixCursor { /** Contains the encrypted title if it has not been decrypted yet */ public static final int COLUMN_INDEX_TITLE_ENCRYPTED = 4; public static final int COLUMN_INDEX_TAGS_ENCRYPTED = 5; + public static final int COLUMN_INDEX_COLOR = 4; static boolean mLoggedIn = false; @@ -188,6 +192,7 @@ private void runQuery(CharSequence constraint, String tag) { String title = mDbCursor.getString(COLUMN_INDEX_TITLE); String tags = mDbCursor.getString(COLUMN_INDEX_TAGS); long encrypted = mDbCursor.getLong(COLUMN_INDEX_ENCRYPTED); + int color = mDbCursor.getInt(COLUMN_INDEX_COLOR); String titleEncrypted = ""; String tagsEncrypted = ""; @@ -305,7 +310,7 @@ private void runQuery(CharSequence constraint, String tag) { } Object[] row = new Object[] { id, title, tags, encrypted, - titleEncrypted, tagsEncrypted }; + titleEncrypted, tagsEncrypted, color}; addRow(row); } } diff --git a/NotePad/src/org/openintents/notepad/noteslist/NotesListCursorAdapter.java b/NotePad/src/org/openintents/notepad/noteslist/NotesListCursorAdapter.java index 3558c51..72fff81 100644 --- a/NotePad/src/org/openintents/notepad/noteslist/NotesListCursorAdapter.java +++ b/NotePad/src/org/openintents/notepad/noteslist/NotesListCursorAdapter.java @@ -37,6 +37,7 @@ public void bindView(View view, Context context, Cursor cursor) { .getString(NotesListCursor.COLUMN_INDEX_TITLE_ENCRYPTED); String tagsEncrypted = cursor .getString(NotesListCursor.COLUMN_INDEX_TAGS_ENCRYPTED); + int color = cursor.getInt(NotesListCursor.COLUMN_INDEX_COLOR + 2); nliv.setEncrypted(encrypted); @@ -44,6 +45,7 @@ public void bindView(View view, Context context, Cursor cursor) { nliv.setTags(tags); nliv.mTitleEncrypted = titleEncrypted; nliv.mTagsEncrypted = tagsEncrypted; + nliv.setColor(color); /* * if (encrypted == 0) { // Not encrypted: nliv.setTitle(title); diff --git a/NotePad/src/org/openintents/notepad/noteslist/NotesListItemView.java b/NotePad/src/org/openintents/notepad/noteslist/NotesListItemView.java index 628f5bf..ae3e496 100644 --- a/NotePad/src/org/openintents/notepad/noteslist/NotesListItemView.java +++ b/NotePad/src/org/openintents/notepad/noteslist/NotesListItemView.java @@ -4,6 +4,8 @@ import org.openintents.notepad.R; import android.content.Context; +import android.content.res.Resources; +import android.graphics.drawable.Drawable; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; @@ -25,6 +27,12 @@ public class NotesListItemView extends LinearLayout { protected String mTitleEncrypted; protected String mTagsEncrypted; + private static final int BLUE = 1; + private static final int GREEN = 2; + private static final int GREY = 3; + private static final int PINK = 4; + private static final int YELLOW = 5; + public NotesListItemView(Context context) { super(context); mContext = context; @@ -76,4 +84,27 @@ public void setEncrypted(long encrypted) { mStatus.setImageBitmap(null); } } + + public void setColor(int color) { + Resources res = this.getResources(); + Drawable d = res.getDrawable(R.drawable.note_item_bg_yellow); + switch(color) { + case BLUE: + d = res.getDrawable(R.drawable.note_item_bg_blue); + break; + case GREY: + d = res.getDrawable(R.drawable.note_item_bg_grey); + break; + case GREEN: + d = res.getDrawable(R.drawable.note_item_bg_green); + break; + case PINK: + d = res.getDrawable(R.drawable.note_item_bg_pink); + break; + default: + break; + } + + mTitle.setBackgroundDrawable(d); + } }