diff --git a/doc/实践资源-开源软件维护方案及成果模板.docx.orig b/doc/实践资源-开源软件维护方案及成果模板.docx.orig
new file mode 100644
index 0000000..0b7e6ea
Binary files /dev/null and b/doc/实践资源-开源软件维护方案及成果模板.docx.orig differ
diff --git a/src/app/src/main/AndroidManifest.xml b/src/app/src/main/AndroidManifest.xml
index 28995fa..6a067c9 100644
--- a/src/app/src/main/AndroidManifest.xml
+++ b/src/app/src/main/AndroidManifest.xml
@@ -20,11 +20,17 @@
android:versionCode="1"
android:versionName="0.1" >
+<<<<<<< HEAD
+=======
+
+
+>>>>>>> origin/Branch_liujie
+<<<<<<< HEAD
@@ -34,6 +40,12 @@
+=======
+
+
+
+
+>>>>>>> origin/Branch_liujie
>>>>>> origin/Branch_liujie
android:windowSoftInputMode="adjustPan" >
@@ -57,7 +74,11 @@
android:name=".ui.NoteEditActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTop"
+<<<<<<< HEAD
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
+=======
+ android:theme="@style/NoteTheme" >
+>>>>>>> origin/Branch_liujie
diff --git a/src/app/src/main/AndroidManifest.xml.orig b/src/app/src/main/AndroidManifest.xml.orig
new file mode 100644
index 0000000..6a067c9
--- /dev/null
+++ b/src/app/src/main/AndroidManifest.xml.orig
@@ -0,0 +1,174 @@
+
+
+
+
+
+
+<<<<<<< HEAD
+=======
+
+
+>>>>>>> origin/Branch_liujie
+
+
+
+
+
+<<<<<<< HEAD
+
+
+
+
+
+
+
+
+
+=======
+
+
+
+
+>>>>>>> origin/Branch_liujie
+
+
+ >>>>>> origin/Branch_liujie
+ android:windowSoftInputMode="adjustPan" >
+
+
+
+
+
+
+
+
+=======
+ android:theme="@style/NoteTheme" >
+>>>>>>> origin/Branch_liujie
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/assets/font/SIMFANG.TTF b/src/app/src/main/assets/font/SIMFANG.TTF
new file mode 100644
index 0000000..68334e2
Binary files /dev/null and b/src/app/src/main/assets/font/SIMFANG.TTF differ
diff --git a/src/app/src/main/assets/font/SIMKAI.TTF b/src/app/src/main/assets/font/SIMKAI.TTF
new file mode 100644
index 0000000..d7c3b90
Binary files /dev/null and b/src/app/src/main/assets/font/SIMKAI.TTF differ
diff --git a/src/app/src/main/assets/font/SIMLI.TTF b/src/app/src/main/assets/font/SIMLI.TTF
new file mode 100644
index 0000000..67a3d4a
Binary files /dev/null and b/src/app/src/main/assets/font/SIMLI.TTF differ
diff --git a/src/app/src/main/java/net/micode/notes/data/Notes.java b/src/app/src/main/java/net/micode/notes/data/Notes.java
index 5901336..b72cc45 100644
--- a/src/app/src/main/java/net/micode/notes/data/Notes.java
+++ b/src/app/src/main/java/net/micode/notes/data/Notes.java
@@ -166,7 +166,12 @@ public class Notes {
*/
public static final String VERSION = "version";
+<<<<<<< HEAD
public static final String TOP = "top";
+=======
+
+ String PASSWORD = "";
+>>>>>>> origin/Branch_liujie
}
public interface DataColumns {
diff --git a/src/app/src/main/java/net/micode/notes/data/Notes.java.orig b/src/app/src/main/java/net/micode/notes/data/Notes.java.orig
new file mode 100644
index 0000000..b72cc45
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/data/Notes.java.orig
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.data;
+
+import android.net.Uri;
+public class Notes {
+ public static final String AUTHORITY = "micode_notes";
+ public static final String TAG = "Notes";
+ public static final int TYPE_NOTE = 0;
+ public static final int TYPE_FOLDER = 1;
+ public static final int TYPE_SYSTEM = 2;
+
+ /**
+ * Following IDs are system folders' identifiers
+ * {@link Notes#ID_ROOT_FOLDER } is default folder
+ * {@link Notes#ID_TEMPARAY_FOLDER } is for notes belonging no folder
+ * {@link Notes#ID_CALL_RECORD_FOLDER} is to store call records
+ */
+ public static final int ID_ROOT_FOLDER = 0;
+ public static final int ID_TEMPARAY_FOLDER = -1;
+ public static final int ID_CALL_RECORD_FOLDER = -2;
+ public static final int ID_TRASH_FOLER = -3;
+
+ public static final String INTENT_EXTRA_ALERT_DATE = "net.micode.notes.alert_date";
+ public static final String INTENT_EXTRA_BACKGROUND_ID = "net.micode.notes.background_color_id";
+ public static final String INTENT_EXTRA_WIDGET_ID = "net.micode.notes.widget_id";
+ public static final String INTENT_EXTRA_WIDGET_TYPE = "net.micode.notes.widget_type";
+ public static final String INTENT_EXTRA_FOLDER_ID = "net.micode.notes.folder_id";
+ public static final String INTENT_EXTRA_CALL_DATE = "net.micode.notes.call_date";
+
+ public static final int TYPE_WIDGET_INVALIDE = -1;
+ public static final int TYPE_WIDGET_2X = 0;
+ public static final int TYPE_WIDGET_4X = 1;
+
+ public static class DataConstants {
+ public static final String NOTE = TextNote.CONTENT_ITEM_TYPE;
+ public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE;
+ }
+
+ /**
+ * Uri to query all notes and folders
+ */
+ public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note");
+
+ /**
+ * Uri to query data
+ */
+ public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
+
+ public interface NoteColumns {
+ /**
+ * The unique ID for a row
+ *
Type: INTEGER (long)
+ */
+ public static final String ID = "_id";
+
+ /**
+ * The parent's id for note or folder
+ *
Type: INTEGER (long)
+ */
+ public static final String PARENT_ID = "parent_id";
+
+ /**
+ * Created data for note or folder
+ *
Type: INTEGER (long)
+ */
+ public static final String CREATED_DATE = "created_date";
+
+ /**
+ * Latest modified date
+ *
Type: INTEGER (long)
+ */
+ public static final String MODIFIED_DATE = "modified_date";
+
+
+ /**
+ * Alert date
+ *
Type: INTEGER (long)
+ */
+ public static final String ALERTED_DATE = "alert_date";
+
+ /**
+ * Folder's name or text content of note
+ *
Type: TEXT
+ */
+ public static final String SNIPPET = "snippet";
+
+ /**
+ * Note's widget id
+ *
Type: INTEGER (long)
+ */
+ public static final String WIDGET_ID = "widget_id";
+
+ /**
+ * Note's widget type
+ *
Type: INTEGER (long)
+ */
+ public static final String WIDGET_TYPE = "widget_type";
+
+ /**
+ * Note's background color's id
+ *
Type: INTEGER (long)
+ */
+ public static final String BG_COLOR_ID = "bg_color_id";
+
+ /**
+ * For text note, it doesn't has attachment, for multi-media
+ * note, it has at least one attachment
+ *
Type: INTEGER
+ */
+ public static final String HAS_ATTACHMENT = "has_attachment";
+
+ /**
+ * Folder's count of notes
+ *
Type: INTEGER (long)
+ */
+ public static final String NOTES_COUNT = "notes_count";
+
+ /**
+ * The file type: folder or note
+ *
Type: INTEGER
+ */
+ public static final String TYPE = "type";
+
+ /**
+ * The last sync id
+ *
Type: INTEGER (long)
+ */
+ public static final String SYNC_ID = "sync_id";
+
+ /**
+ * Sign to indicate local modified or not
+ *
Type: INTEGER
+ */
+ public static final String LOCAL_MODIFIED = "local_modified";
+
+ /**
+ * Original parent id before moving into temporary folder
+ *
Type : INTEGER
+ */
+ public static final String ORIGIN_PARENT_ID = "origin_parent_id";
+
+ /**
+ * The gtask id
+ *
Type : TEXT
+ */
+ public static final String GTASK_ID = "gtask_id";
+
+ /**
+ * The version code
+ *
Type : INTEGER (long)
+ */
+ public static final String VERSION = "version";
+
+<<<<<<< HEAD
+ public static final String TOP = "top";
+=======
+
+ String PASSWORD = "";
+>>>>>>> origin/Branch_liujie
+ }
+
+ public interface DataColumns {
+ /**
+ * The unique ID for a row
+ *
Type: INTEGER (long)
+ */
+ public static final String ID = "_id";
+
+ /**
+ * The MIME type of the item represented by this row.
+ *
Type: Text
+ */
+ public static final String MIME_TYPE = "mime_type";
+
+ /**
+ * The reference id to note that this data belongs to
+ *
Type: INTEGER (long)
+ */
+ public static final String NOTE_ID = "note_id";
+
+ /**
+ * Created data for note or folder
+ *
Type: INTEGER (long)
+ */
+ public static final String CREATED_DATE = "created_date";
+
+ /**
+ * Latest modified date
+ *
Type: INTEGER (long)
+ */
+ public static final String MODIFIED_DATE = "modified_date";
+
+ /**
+ * Data's content
+ *
Type: TEXT
+ */
+ public static final String CONTENT = "content";
+
+
+ /**
+ * Generic data column, the meaning is {@link #MIMETYPE} specific, used for
+ * integer data type
+ *
Type: INTEGER
+ */
+ public static final String DATA1 = "data1";
+
+ /**
+ * Generic data column, the meaning is {@link #MIMETYPE} specific, used for
+ * integer data type
+ *
Type: INTEGER
+ */
+ public static final String DATA2 = "data2";
+
+ /**
+ * Generic data column, the meaning is {@link #MIMETYPE} specific, used for
+ * TEXT data type
+ *
Type: TEXT
+ */
+ public static final String DATA3 = "data3";
+
+ /**
+ * Generic data column, the meaning is {@link #MIMETYPE} specific, used for
+ * TEXT data type
+ *
Type: TEXT
+ */
+ public static final String DATA4 = "data4";
+
+ /**
+ * Generic data column, the meaning is {@link #MIMETYPE} specific, used for
+ * TEXT data type
+ *
Type: TEXT
+ */
+ public static final String DATA5 = "data5";
+ }
+
+ public static final class TextNote implements DataColumns {
+ /**
+ * Mode to indicate the text in check list mode or not
+ *
Type: Integer 1:check list mode 0: normal mode
+ */
+ public static final String MODE = DATA1;
+
+ public static final int MODE_CHECK_LIST = 1;
+
+ public static final String CONTENT_TYPE = "vnd.android.cursor.dir/text_note";
+
+ public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/text_note";
+
+ public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");
+ }
+
+ public static final class CallNote implements DataColumns {
+ /**
+ * Call date for this record
+ *
Type: INTEGER (long)
+ */
+ public static final String CALL_DATE = DATA1;
+
+ /**
+ * Phone number for this record
+ *
Type: TEXT
+ */
+ public static final String PHONE_NUMBER = DATA3;
+
+ public static final String CONTENT_TYPE = "vnd.android.cursor.dir/call_note";
+
+ public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/call_note";
+
+ public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note");
+ }
+}
diff --git a/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java b/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java
index d4d4732..a263b9d 100644
--- a/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java
+++ b/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java
@@ -59,11 +59,19 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
NoteColumns.SYNC_ID + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.LOCAL_MODIFIED + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
+<<<<<<< HEAD
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT 1," +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.TOP + " INTEGER NOT NULL DEFAULT 0" +
")";
+=======
+ NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
+ NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
+ ")";
+
+
+>>>>>>> origin/Branch_liujie
private static final String CREATE_DATA_TABLE_SQL =
"CREATE TABLE " + TABLE.DATA + "(" +
DataColumns.ID + " INTEGER PRIMARY KEY," +
@@ -323,10 +331,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
oldVersion++;
}
+<<<<<<< HEAD
if (oldVersion == 4) {
upgradeToV5(db);
oldVersion++;
}
+=======
+>>>>>>> origin/Branch_liujie
if (reCreateTriggers) {
reCreateNoteTableTriggers(db);
@@ -339,6 +350,11 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
}
}
+<<<<<<< HEAD
+=======
+
+
+>>>>>>> origin/Branch_liujie
private void upgradeToV2(SQLiteDatabase db) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE.NOTE);
db.execSQL("DROP TABLE IF EXISTS " + TABLE.DATA);
@@ -365,10 +381,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ " INTEGER NOT NULL DEFAULT 0");
}
+<<<<<<< HEAD
private void upgradeToV5(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.TOP
+ " INTEGER NOT NULL DEFAULT 0");
}
+=======
+>>>>>>> origin/Branch_liujie
}
diff --git a/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java.orig b/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java.orig
new file mode 100644
index 0000000..a263b9d
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java.orig
@@ -0,0 +1,393 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.data;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+import android.util.Log;
+
+import net.micode.notes.data.Notes.DataColumns;
+import net.micode.notes.data.Notes.DataConstants;
+import net.micode.notes.data.Notes.NoteColumns;
+
+
+public class NotesDatabaseHelper extends SQLiteOpenHelper {
+ private static final String DB_NAME = "note.db";
+
+ private static final int DB_VERSION = 4;
+
+ public interface TABLE {
+ public static final String NOTE = "note";
+
+ public static final String DATA = "data";
+ }
+
+ private static final String TAG = "NotesDatabaseHelper";
+
+ private static NotesDatabaseHelper mInstance;
+
+ private static final String CREATE_NOTE_TABLE_SQL =
+ "CREATE TABLE " + TABLE.NOTE + "(" +
+ NoteColumns.ID + " INTEGER PRIMARY KEY," +
+ NoteColumns.PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.ALERTED_DATE + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.BG_COLOR_ID + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.CREATED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
+ NoteColumns.HAS_ATTACHMENT + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.MODIFIED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
+ NoteColumns.NOTES_COUNT + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.SNIPPET + " TEXT NOT NULL DEFAULT ''," +
+ NoteColumns.TYPE + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.WIDGET_ID + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.WIDGET_TYPE + " INTEGER NOT NULL DEFAULT -1," +
+ NoteColumns.SYNC_ID + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.LOCAL_MODIFIED + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
+<<<<<<< HEAD
+ NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT 1," +
+ NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.TOP + " INTEGER NOT NULL DEFAULT 0" +
+ ")";
+
+=======
+ NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
+ NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
+ ")";
+
+
+>>>>>>> origin/Branch_liujie
+ private static final String CREATE_DATA_TABLE_SQL =
+ "CREATE TABLE " + TABLE.DATA + "(" +
+ DataColumns.ID + " INTEGER PRIMARY KEY," +
+ DataColumns.MIME_TYPE + " TEXT NOT NULL," +
+ DataColumns.NOTE_ID + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.CREATED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
+ NoteColumns.MODIFIED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
+ DataColumns.CONTENT + " TEXT NOT NULL DEFAULT ''," +
+ DataColumns.DATA1 + " INTEGER," +
+ DataColumns.DATA2 + " INTEGER," +
+ DataColumns.DATA3 + " TEXT NOT NULL DEFAULT ''," +
+ DataColumns.DATA4 + " TEXT NOT NULL DEFAULT ''," +
+ DataColumns.DATA5 + " TEXT NOT NULL DEFAULT ''" +
+ ")";
+
+ private static final String CREATE_DATA_NOTE_ID_INDEX_SQL =
+ "CREATE INDEX IF NOT EXISTS note_id_index ON " +
+ TABLE.DATA + "(" + DataColumns.NOTE_ID + ");";
+
+ /**
+ * Increase folder's note count when move note to the folder
+ */
+ private static final String NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =
+ "CREATE TRIGGER increase_folder_count_on_update "+
+ " AFTER UPDATE OF " + NoteColumns.PARENT_ID + " ON " + TABLE.NOTE +
+ " BEGIN " +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + " + 1" +
+ " WHERE " + NoteColumns.ID + "=new." + NoteColumns.PARENT_ID + ";" +
+ " END";
+
+ /**
+ * Decrease folder's note count when move note from folder
+ */
+ private static final String NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =
+ "CREATE TRIGGER decrease_folder_count_on_update " +
+ " AFTER UPDATE OF " + NoteColumns.PARENT_ID + " ON " + TABLE.NOTE +
+ " BEGIN " +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + "-1" +
+ " WHERE " + NoteColumns.ID + "=old." + NoteColumns.PARENT_ID +
+ " AND " + NoteColumns.NOTES_COUNT + ">0" + ";" +
+ " END";
+
+ /**
+ * Increase folder's note count when insert new note to the folder
+ */
+ private static final String NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER =
+ "CREATE TRIGGER increase_folder_count_on_insert " +
+ " AFTER INSERT ON " + TABLE.NOTE +
+ " BEGIN " +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + " + 1" +
+ " WHERE " + NoteColumns.ID + "=new." + NoteColumns.PARENT_ID + ";" +
+ " END";
+
+ /**
+ * Decrease folder's note count when delete note from the folder
+ */
+ private static final String NOTE_DECREASE_FOLDER_COUNT_ON_DELETE_TRIGGER =
+ "CREATE TRIGGER decrease_folder_count_on_delete " +
+ " AFTER DELETE ON " + TABLE.NOTE +
+ " BEGIN " +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + "-1" +
+ " WHERE " + NoteColumns.ID + "=old." + NoteColumns.PARENT_ID +
+ " AND " + NoteColumns.NOTES_COUNT + ">0;" +
+ " END";
+
+ /**
+ * Update note's content when insert data with type {@link DataConstants#NOTE}
+ */
+ private static final String DATA_UPDATE_NOTE_CONTENT_ON_INSERT_TRIGGER =
+ "CREATE TRIGGER update_note_content_on_insert " +
+ " AFTER INSERT ON " + TABLE.DATA +
+ " WHEN new." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
+ " BEGIN" +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.SNIPPET + "=new." + DataColumns.CONTENT +
+ " WHERE " + NoteColumns.ID + "=new." + DataColumns.NOTE_ID + ";" +
+ " END";
+
+ /**
+ * Update note's content when data with {@link DataConstants#NOTE} type has changed
+ */
+ private static final String DATA_UPDATE_NOTE_CONTENT_ON_UPDATE_TRIGGER =
+ "CREATE TRIGGER update_note_content_on_update " +
+ " AFTER UPDATE ON " + TABLE.DATA +
+ " WHEN old." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
+ " BEGIN" +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.SNIPPET + "=new." + DataColumns.CONTENT +
+ " WHERE " + NoteColumns.ID + "=new." + DataColumns.NOTE_ID + ";" +
+ " END";
+
+ /**
+ * Update note's content when data with {@link DataConstants#NOTE} type has deleted
+ */
+ private static final String DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER =
+ "CREATE TRIGGER update_note_content_on_delete " +
+ " AFTER delete ON " + TABLE.DATA +
+ " WHEN old." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
+ " BEGIN" +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.SNIPPET + "=''" +
+ " WHERE " + NoteColumns.ID + "=old." + DataColumns.NOTE_ID + ";" +
+ " END";
+
+ /**
+ * Delete datas belong to note which has been deleted
+ */
+ private static final String NOTE_DELETE_DATA_ON_DELETE_TRIGGER =
+ "CREATE TRIGGER delete_data_on_delete " +
+ " AFTER DELETE ON " + TABLE.NOTE +
+ " BEGIN" +
+ " DELETE FROM " + TABLE.DATA +
+ " WHERE " + DataColumns.NOTE_ID + "=old." + NoteColumns.ID + ";" +
+ " END";
+
+ /**
+ * Delete notes belong to folder which has been deleted
+ */
+ private static final String FOLDER_DELETE_NOTES_ON_DELETE_TRIGGER =
+ "CREATE TRIGGER folder_delete_notes_on_delete " +
+ " AFTER DELETE ON " + TABLE.NOTE +
+ " BEGIN" +
+ " DELETE FROM " + TABLE.NOTE +
+ " WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" +
+ " END";
+
+ /**
+ * Move notes belong to folder which has been moved to trash folder
+ */
+ private static final String FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER =
+ "CREATE TRIGGER folder_move_notes_on_trash " +
+ " AFTER UPDATE ON " + TABLE.NOTE +
+ " WHEN new." + NoteColumns.PARENT_ID + "=" + Notes.ID_TRASH_FOLER +
+ " BEGIN" +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.PARENT_ID + "=" + Notes.ID_TRASH_FOLER +
+ " WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" +
+ " END";
+
+ public NotesDatabaseHelper(Context context) {
+ super(context, DB_NAME, null, DB_VERSION);
+ }
+
+ public void createNoteTable(SQLiteDatabase db) {
+ db.execSQL(CREATE_NOTE_TABLE_SQL);
+ reCreateNoteTableTriggers(db);
+ createSystemFolder(db);
+ Log.d(TAG, "note table has been created");
+ }
+
+ private void reCreateNoteTableTriggers(SQLiteDatabase db) {
+ db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_update");
+ db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_update");
+ db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_delete");
+ db.execSQL("DROP TRIGGER IF EXISTS delete_data_on_delete");
+ db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_insert");
+ db.execSQL("DROP TRIGGER IF EXISTS folder_delete_notes_on_delete");
+ db.execSQL("DROP TRIGGER IF EXISTS folder_move_notes_on_trash");
+
+ db.execSQL(NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER);
+ db.execSQL(NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER);
+ db.execSQL(NOTE_DECREASE_FOLDER_COUNT_ON_DELETE_TRIGGER);
+ db.execSQL(NOTE_DELETE_DATA_ON_DELETE_TRIGGER);
+ db.execSQL(NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER);
+ db.execSQL(FOLDER_DELETE_NOTES_ON_DELETE_TRIGGER);
+ db.execSQL(FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER);
+ }
+
+ private void createSystemFolder(SQLiteDatabase db) {
+ ContentValues values = new ContentValues();
+
+ /**
+ * call record foler for call notes
+ */
+ values.put(NoteColumns.ID, Notes.ID_CALL_RECORD_FOLDER);
+ values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
+ db.insert(TABLE.NOTE, null, values);
+
+ /**
+ * root folder which is default folder
+ */
+ values.clear();
+ values.put(NoteColumns.ID, Notes.ID_ROOT_FOLDER);
+ values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
+ db.insert(TABLE.NOTE, null, values);
+
+ /**
+ * temporary folder which is used for moving note
+ */
+ values.clear();
+ values.put(NoteColumns.ID, Notes.ID_TEMPARAY_FOLDER);
+ values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
+ db.insert(TABLE.NOTE, null, values);
+
+ /**
+ * create trash folder
+ */
+ values.clear();
+ values.put(NoteColumns.ID, Notes.ID_TRASH_FOLER);
+ values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
+ db.insert(TABLE.NOTE, null, values);
+ }
+
+ public void createDataTable(SQLiteDatabase db) {
+ db.execSQL(CREATE_DATA_TABLE_SQL);
+ reCreateDataTableTriggers(db);
+ db.execSQL(CREATE_DATA_NOTE_ID_INDEX_SQL);
+ Log.d(TAG, "data table has been created");
+ }
+
+ private void reCreateDataTableTriggers(SQLiteDatabase db) {
+ db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_insert");
+ db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_update");
+ db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_delete");
+
+ db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_INSERT_TRIGGER);
+ db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_UPDATE_TRIGGER);
+ db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER);
+ }
+
+ static synchronized NotesDatabaseHelper getInstance(Context context) {
+ if (mInstance == null) {
+ mInstance = new NotesDatabaseHelper(context);
+ }
+ return mInstance;
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ createNoteTable(db);
+ createDataTable(db);
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ boolean reCreateTriggers = false;
+ boolean skipV2 = false;
+
+ if (oldVersion == 1) {
+ upgradeToV2(db);
+ skipV2 = true; // this upgrade including the upgrade from v2 to v3
+ oldVersion++;
+ }
+
+ if (oldVersion == 2 && !skipV2) {
+ upgradeToV3(db);
+ reCreateTriggers = true;
+ oldVersion++;
+ }
+
+ if (oldVersion == 3) {
+ upgradeToV4(db);
+ oldVersion++;
+ }
+
+<<<<<<< HEAD
+ if (oldVersion == 4) {
+ upgradeToV5(db);
+ oldVersion++;
+ }
+=======
+>>>>>>> origin/Branch_liujie
+
+ if (reCreateTriggers) {
+ reCreateNoteTableTriggers(db);
+ reCreateDataTableTriggers(db);
+ }
+
+ if (oldVersion != newVersion) {
+ throw new IllegalStateException("Upgrade notes database to version " + newVersion
+ + "fails");
+ }
+ }
+
+<<<<<<< HEAD
+=======
+
+
+>>>>>>> origin/Branch_liujie
+ private void upgradeToV2(SQLiteDatabase db) {
+ db.execSQL("DROP TABLE IF EXISTS " + TABLE.NOTE);
+ db.execSQL("DROP TABLE IF EXISTS " + TABLE.DATA);
+ createNoteTable(db);
+ createDataTable(db);
+ }
+
+ private void upgradeToV3(SQLiteDatabase db) {
+ // drop unused triggers
+ db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_insert");
+ db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_delete");
+ db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_update");
+ // add a column for gtask id
+ db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.GTASK_ID
+ + " TEXT NOT NULL DEFAULT ''");
+ // add a trash system folder
+ ContentValues values = new ContentValues();
+ values.put(NoteColumns.ID, Notes.ID_TRASH_FOLER);
+ values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
+ db.insert(TABLE.NOTE, null, values);
+ }
+
+ private void upgradeToV4(SQLiteDatabase db) {
+ db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ + " INTEGER NOT NULL DEFAULT 0");
+ }
+<<<<<<< HEAD
+
+ private void upgradeToV5(SQLiteDatabase db) {
+ db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.TOP
+ + " INTEGER NOT NULL DEFAULT 0");
+ }
+
+=======
+>>>>>>> origin/Branch_liujie
+}
diff --git a/src/app/src/main/java/net/micode/notes/data/NotesProvider.java b/src/app/src/main/java/net/micode/notes/data/NotesProvider.java
index 1cc63c6..be12757 100644
--- a/src/app/src/main/java/net/micode/notes/data/NotesProvider.java
+++ b/src/app/src/main/java/net/micode/notes/data/NotesProvider.java
@@ -33,18 +33,25 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.NotesDatabaseHelper.TABLE;
+<<<<<<< HEAD
import net.micode.notes.gtask.data.SqlNote;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Iterator;
+=======
+>>>>>>> origin/Branch_liujie
public class NotesProvider extends ContentProvider {
private static final UriMatcher mMatcher;
+<<<<<<< HEAD
private static NotesDatabaseHelper mHelper;
+=======
+ private NotesDatabaseHelper mHelper;
+>>>>>>> origin/Branch_liujie
private static final String TAG = "NotesProvider";
@@ -308,6 +315,7 @@ public class NotesProvider extends ContentProvider {
return null;
}
+<<<<<<< HEAD
@@ -451,4 +459,6 @@ public class NotesProvider extends ContentProvider {
db.execSQL(sql,bindArgs);
}
}
+=======
+>>>>>>> origin/Branch_liujie
}
diff --git a/src/app/src/main/java/net/micode/notes/data/NotesProvider.java.orig b/src/app/src/main/java/net/micode/notes/data/NotesProvider.java.orig
new file mode 100644
index 0000000..be12757
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/data/NotesProvider.java.orig
@@ -0,0 +1,464 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.data;
+
+
+import android.app.SearchManager;
+import android.content.ContentProvider;
+import android.content.ContentUris;
+import android.content.ContentValues;
+import android.content.Intent;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.net.Uri;
+import android.text.TextUtils;
+import android.util.Log;
+
+import net.micode.notes.R;
+import net.micode.notes.data.Notes.DataColumns;
+import net.micode.notes.data.Notes.NoteColumns;
+import net.micode.notes.data.NotesDatabaseHelper.TABLE;
+<<<<<<< HEAD
+import net.micode.notes.gtask.data.SqlNote;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+=======
+>>>>>>> origin/Branch_liujie
+
+
+public class NotesProvider extends ContentProvider {
+ private static final UriMatcher mMatcher;
+
+<<<<<<< HEAD
+ private static NotesDatabaseHelper mHelper;
+=======
+ private NotesDatabaseHelper mHelper;
+>>>>>>> origin/Branch_liujie
+
+ private static final String TAG = "NotesProvider";
+
+ private static final int URI_NOTE = 1;
+ private static final int URI_NOTE_ITEM = 2;
+ private static final int URI_DATA = 3;
+ private static final int URI_DATA_ITEM = 4;
+
+ private static final int URI_SEARCH = 5;
+ private static final int URI_SEARCH_SUGGEST = 6;
+
+ static {
+ mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+ mMatcher.addURI(Notes.AUTHORITY, "note", URI_NOTE);
+ mMatcher.addURI(Notes.AUTHORITY, "note/#", URI_NOTE_ITEM);
+ mMatcher.addURI(Notes.AUTHORITY, "data", URI_DATA);
+ mMatcher.addURI(Notes.AUTHORITY, "data/#", URI_DATA_ITEM);
+ mMatcher.addURI(Notes.AUTHORITY, "search", URI_SEARCH);
+ mMatcher.addURI(Notes.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, URI_SEARCH_SUGGEST);
+ mMatcher.addURI(Notes.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", URI_SEARCH_SUGGEST);
+ }
+
+ /**
+ * x'0A' represents the '\n' character in sqlite. For title and content in the search result,
+ * we will trim '\n' and white space in order to show more information.
+ */
+ private static final String NOTES_SEARCH_PROJECTION = NoteColumns.ID + ","
+ + NoteColumns.ID + " AS " + SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA + ","
+ + "TRIM(REPLACE(" + NoteColumns.SNIPPET + ", x'0A','')) AS " + SearchManager.SUGGEST_COLUMN_TEXT_1 + ","
+ + "TRIM(REPLACE(" + NoteColumns.SNIPPET + ", x'0A','')) AS " + SearchManager.SUGGEST_COLUMN_TEXT_2 + ","
+ + R.drawable.search_result + " AS " + SearchManager.SUGGEST_COLUMN_ICON_1 + ","
+ + "'" + Intent.ACTION_VIEW + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_ACTION + ","
+ + "'" + Notes.TextNote.CONTENT_TYPE + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA;
+
+ private static String NOTES_SNIPPET_SEARCH_QUERY = "SELECT " + NOTES_SEARCH_PROJECTION
+ + " FROM " + TABLE.NOTE
+ + " WHERE " + NoteColumns.SNIPPET + " LIKE ?"
+ + " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER
+ + " AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE;
+
+ @Override
+ public boolean onCreate() {
+ mHelper = NotesDatabaseHelper.getInstance(getContext());
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
+ String sortOrder) {
+ Cursor c = null;
+ SQLiteDatabase db = mHelper.getReadableDatabase();
+ String id = null;
+ switch (mMatcher.match(uri)) {
+ case URI_NOTE:
+ c = db.query(TABLE.NOTE, projection, selection, selectionArgs, null, null,
+ sortOrder);
+ break;
+ case URI_NOTE_ITEM:
+ id = uri.getPathSegments().get(1);
+ c = db.query(TABLE.NOTE, projection, NoteColumns.ID + "=" + id
+ + parseSelection(selection), selectionArgs, null, null, sortOrder);
+ break;
+ case URI_DATA:
+ c = db.query(TABLE.DATA, projection, selection, selectionArgs, null, null,
+ sortOrder);
+ break;
+ case URI_DATA_ITEM:
+ id = uri.getPathSegments().get(1);
+ c = db.query(TABLE.DATA, projection, DataColumns.ID + "=" + id
+ + parseSelection(selection), selectionArgs, null, null, sortOrder);
+ break;
+ case URI_SEARCH:
+ case URI_SEARCH_SUGGEST:
+ if (sortOrder != null || projection != null) {
+ throw new IllegalArgumentException(
+ "do not specify sortOrder, selection, selectionArgs, or projection" + "with this query");
+ }
+
+ String searchString = null;
+ if (mMatcher.match(uri) == URI_SEARCH_SUGGEST) {
+ if (uri.getPathSegments().size() > 1) {
+ searchString = uri.getPathSegments().get(1);
+ }
+ } else {
+ searchString = uri.getQueryParameter("pattern");
+ }
+
+ if (TextUtils.isEmpty(searchString)) {
+ return null;
+ }
+
+ try {
+ searchString = String.format("%%%s%%", searchString);
+ c = db.rawQuery(NOTES_SNIPPET_SEARCH_QUERY,
+ new String[] { searchString });
+ } catch (IllegalStateException ex) {
+ Log.e(TAG, "got exception: " + ex.toString());
+ }
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown URI " + uri);
+ }
+ if (c != null) {
+ c.setNotificationUri(getContext().getContentResolver(), uri);
+ }
+ return c;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ SQLiteDatabase db = mHelper.getWritableDatabase();
+ long dataId = 0, noteId = 0, insertedId = 0;
+ switch (mMatcher.match(uri)) {
+ case URI_NOTE:
+ insertedId = noteId = db.insert(TABLE.NOTE, null, values);
+ break;
+ case URI_DATA:
+ if (values.containsKey(DataColumns.NOTE_ID)) {
+ noteId = values.getAsLong(DataColumns.NOTE_ID);
+ } else {
+ Log.d(TAG, "Wrong data format without note id:" + values.toString());
+ }
+ insertedId = dataId = db.insert(TABLE.DATA, null, values);
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown URI " + uri);
+ }
+ // Notify the note uri
+ if (noteId > 0) {
+ getContext().getContentResolver().notifyChange(
+ ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), null);
+ }
+
+ // Notify the data uri
+ if (dataId > 0) {
+ getContext().getContentResolver().notifyChange(
+ ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId), null);
+ }
+
+ return ContentUris.withAppendedId(uri, insertedId);
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ int count = 0;
+ String id = null;
+ SQLiteDatabase db = mHelper.getWritableDatabase();
+ boolean deleteData = false;
+ switch (mMatcher.match(uri)) {
+ case URI_NOTE:
+ selection = "(" + selection + ") AND " + NoteColumns.ID + ">0 ";
+ count = db.delete(TABLE.NOTE, selection, selectionArgs);
+ break;
+ case URI_NOTE_ITEM:
+ id = uri.getPathSegments().get(1);
+ /**
+ * ID that smaller than 0 is system folder which is not allowed to
+ * trash
+ */
+ long noteId = Long.valueOf(id);
+ if (noteId <= 0) {
+ break;
+ }
+ count = db.delete(TABLE.NOTE,
+ NoteColumns.ID + "=" + id + parseSelection(selection), selectionArgs);
+ break;
+ case URI_DATA:
+ count = db.delete(TABLE.DATA, selection, selectionArgs);
+ deleteData = true;
+ break;
+ case URI_DATA_ITEM:
+ id = uri.getPathSegments().get(1);
+ count = db.delete(TABLE.DATA,
+ DataColumns.ID + "=" + id + parseSelection(selection), selectionArgs);
+ deleteData = true;
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown URI " + uri);
+ }
+ if (count > 0) {
+ if (deleteData) {
+ getContext().getContentResolver().notifyChange(Notes.CONTENT_NOTE_URI, null);
+ }
+ getContext().getContentResolver().notifyChange(uri, null);
+ }
+ return count;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ int count = 0;
+ String id = null;
+ SQLiteDatabase db = mHelper.getWritableDatabase();
+ boolean updateData = false;
+ switch (mMatcher.match(uri)) {
+ case URI_NOTE:
+ increaseNoteVersion(-1, selection, selectionArgs);
+ count = db.update(TABLE.NOTE, values, selection, selectionArgs);
+ break;
+ case URI_NOTE_ITEM:
+ id = uri.getPathSegments().get(1);
+ increaseNoteVersion(Long.valueOf(id), selection, selectionArgs);
+ count = db.update(TABLE.NOTE, values, NoteColumns.ID + "=" + id
+ + parseSelection(selection), selectionArgs);
+ break;
+ case URI_DATA:
+ count = db.update(TABLE.DATA, values, selection, selectionArgs);
+ updateData = true;
+ break;
+ case URI_DATA_ITEM:
+ id = uri.getPathSegments().get(1);
+ count = db.update(TABLE.DATA, values, DataColumns.ID + "=" + id
+ + parseSelection(selection), selectionArgs);
+ updateData = true;
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown URI " + uri);
+ }
+
+ if (count > 0) {
+ if (updateData) {
+ getContext().getContentResolver().notifyChange(Notes.CONTENT_NOTE_URI, null);
+ }
+ getContext().getContentResolver().notifyChange(uri, null);
+ }
+ return count;
+ }
+
+ private String parseSelection(String selection) {
+ return (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : "");
+ }
+
+ private void increaseNoteVersion(long id, String selection, String[] selectionArgs) {
+ StringBuilder sql = new StringBuilder(120);
+ sql.append("UPDATE ");
+ sql.append(TABLE.NOTE);
+ sql.append(" SET ");
+ sql.append(NoteColumns.VERSION);
+ sql.append("=" + NoteColumns.VERSION + "+1 ");
+
+ if (id > 0 || !TextUtils.isEmpty(selection)) {
+ sql.append(" WHERE ");
+ }
+ if (id > 0) {
+ sql.append(NoteColumns.ID + "=" + String.valueOf(id));
+ }
+ if (!TextUtils.isEmpty(selection)) {
+ String selectString = id > 0 ? parseSelection(selection) : selection;
+ for (String args : selectionArgs) {
+ selectString = selectString.replaceFirst("\\?", args);
+ }
+ sql.append(selectString);
+ }
+
+ mHelper.getWritableDatabase().execSQL(sql.toString());
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+<<<<<<< HEAD
+
+
+
+ public static JSONObject uploadnote()throws JSONException {
+ JSONObject js = new JSONObject();
+ SQLiteDatabase db;
+ db = mHelper.getReadableDatabase();
+ Cursor cursor = null;
+ cursor = db.query(NotesDatabaseHelper.TABLE.NOTE,
+ null, null, null, null, null, null);
+ //判断游标是否为空
+ if (cursor.moveToFirst()) {
+ for (int index = 1; index <= cursor.getCount(); index++) {
+ JSONObject note = new JSONObject();
+ note.put(NoteColumns.PARENT_ID,cursor.getString(1));
+ note.put(NoteColumns.ALERTED_DATE,cursor.getString(2));
+ note.put(NoteColumns.BG_COLOR_ID,cursor.getString(3));
+ note.put(NoteColumns.CREATED_DATE,cursor.getString(4));
+ note.put(NoteColumns.HAS_ATTACHMENT,cursor.getString(5));
+ note.put(NoteColumns.MODIFIED_DATE,cursor.getString(6));
+ note.put(NoteColumns.NOTES_COUNT,cursor.getString(7));
+ note.put(NoteColumns.SNIPPET,cursor.getString(8));
+ note.put(NoteColumns.TYPE,cursor.getString(9));
+ note.put(NoteColumns.WIDGET_ID,cursor.getString(10));
+ note.put(NoteColumns.WIDGET_TYPE,cursor.getString(11));
+ note.put(NoteColumns.SYNC_ID,cursor.getString(12));
+ note.put(NoteColumns.LOCAL_MODIFIED,cursor.getString(13));
+ note.put(NoteColumns.ORIGIN_PARENT_ID,cursor.getString(14));
+ note.put(NoteColumns.GTASK_ID,cursor.getString(15));
+ note.put(NoteColumns.VERSION,cursor.getString(16));
+ note.put(NoteColumns.TOP,cursor.getString(17));
+ js.put(cursor.getString(0),note);
+ if(!cursor.isLast()){
+ cursor.moveToNext();
+ }
+ }
+ }
+ System.out.println(js);
+ return js;
+ }
+ public static JSONObject uploaddata()throws JSONException {
+ JSONObject js = new JSONObject();
+ SQLiteDatabase db;
+ db = mHelper.getReadableDatabase();
+ Cursor cursor = null;
+ cursor = db.query(NotesDatabaseHelper.TABLE.DATA,
+ null, null, null, null, null, null);
+ //判断游标是否为空
+ if (cursor.moveToFirst()) {
+ for (int index = 1; index <= cursor.getCount(); index++) {
+
+ JSONObject data = new JSONObject();
+ data.put(DataColumns.MIME_TYPE,cursor.getString(1));
+ data.put(DataColumns.NOTE_ID,cursor.getString(2));
+ data.put(DataColumns.CREATED_DATE,cursor.getString(3));
+ data.put(DataColumns.MODIFIED_DATE,cursor.getString(4));
+ data.put(DataColumns.CONTENT,cursor.getString(5));
+ data.put(DataColumns.DATA1,cursor.getString(6));
+ data.put(DataColumns.DATA2,cursor.getString(7));
+ data.put(DataColumns.DATA3,cursor.getString(8));
+ data.put(DataColumns.DATA4,cursor.getString(9));
+ data.put(DataColumns.DATA5,cursor.getString(10));
+ js.put(cursor.getString(0),data);
+ if(!cursor.isLast()){
+ cursor.moveToNext();
+ }
+ }
+ }
+ System.out.println(js);
+ return js;
+ }
+
+ public static void syncTABLE(JSONObject JSONInfo) throws JSONException {
+ SQLiteDatabase db;
+ db = mHelper.getReadableDatabase();
+ String sql;
+ JSONObject NOTE = null;
+ JSONObject DATA = null;
+ try {
+ NOTE = (JSONObject) JSONInfo.get("NOTE");
+ DATA = (JSONObject) JSONInfo.get("DATA");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ sql = "DELETE FROM" + " " + TABLE.NOTE;
+ db.execSQL(sql);
+
+ assert NOTE != null;
+ Iterator NOTEKeys = NOTE.keys();
+ while (NOTEKeys.hasNext()){
+ String NOTEKey = NOTEKeys.next();
+ JSONObject NOTEInfo = (JSONObject) NOTE.get(NOTEKey);
+ sql = "INSERT INTO note(_id,parent_id,alert_date,bg_color_id,created_date,has_attachment,modified_date," +
+ "notes_count,snippet,type,widget_id,widget_type,sync_id,local_modified,origin_parent_id,gtask_id," +
+ "version,top,star,passcode) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ Object bindArgs[] = new Object[] {
+ NOTEKey,
+ NOTEInfo.getString("parent_id"),
+ NOTEInfo.getString("alert_date"),
+ NOTEInfo.getString("bg_color_id"),
+ NOTEInfo.getString("created_date"),
+ NOTEInfo.getString("has_attachment"),
+ NOTEInfo.getString("modified_date"),
+ "0",//NOTEInfo.getString("notes_count")
+ "0",
+ NOTEInfo.getString("snippet"),
+ NOTEInfo.getString("type"),
+ NOTEInfo.getString("widget_id"),
+ NOTEInfo.getString("widget_type"),
+ NOTEInfo.getString("sync_id"),
+ NOTEInfo.getString("local_modified"),
+ NOTEInfo.getString("origin_parent_id"),
+ NOTEInfo.getString("gtask_id"),
+ NOTEInfo.getString("version"),
+ NOTEInfo.getString("top"),
+ NOTEInfo.getString("star"),
+ NOTEInfo.getString("passcode")
+ };
+ db.execSQL(sql,bindArgs);
+ }
+
+ assert DATA != null;
+ Iterator DATAKeys = DATA.keys();
+ while (DATAKeys.hasNext()){
+ String DATAKey = DATAKeys.next();
+ JSONObject DATAInfo = (JSONObject) DATA.get(DATAKey);
+ sql = "INSERT INTO data(_id,mime_type,note_id,created_date,modified_date,content,data3,data4,data5)" +
+ "values (?,?,?,?,?,?,?,?,?)";
+ Object bindArgs[] = new Object[] {
+ DATAKey,
+ DATAInfo.getString("mime_type"),
+ DATAInfo.getString("note_id"),
+ DATAInfo.getString("created_date"),
+ DATAInfo.getString("modified_date"),
+ DATAInfo.getString("content"),
+ DATAInfo.getString("data3"),
+ DATAInfo.getString("data4"),
+ DATAInfo.getString("data5")
+ };
+ db.execSQL(sql,bindArgs);
+ }
+ }
+=======
+>>>>>>> origin/Branch_liujie
+}
diff --git a/src/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java b/src/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java
index 1dd6ad8..8682598 100644
--- a/src/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java
+++ b/src/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java
@@ -49,7 +49,11 @@ public class SqlNote {
NoteColumns.NOTES_COUNT, NoteColumns.PARENT_ID, NoteColumns.SNIPPET, NoteColumns.TYPE,
NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE, NoteColumns.SYNC_ID,
NoteColumns.LOCAL_MODIFIED, NoteColumns.ORIGIN_PARENT_ID, NoteColumns.GTASK_ID,
+<<<<<<< HEAD
NoteColumns.VERSION,NoteColumns.TOP,
+=======
+ NoteColumns.VERSION
+>>>>>>> origin/Branch_liujie
};
public static final int ID_COLUMN = 0;
@@ -86,8 +90,11 @@ public class SqlNote {
public static final int VERSION_COLUMN = 16;
+<<<<<<< HEAD
public static final int Top_COLUMN = 17;
+=======
+>>>>>>> origin/Branch_liujie
private Context mContext;
private ContentResolver mContentResolver;
@@ -120,8 +127,11 @@ public class SqlNote {
private long mVersion;
+<<<<<<< HEAD
private String mTop;
+=======
+>>>>>>> origin/Branch_liujie
private ContentValues mDiffNoteValues;
private ArrayList mDataList;
@@ -143,7 +153,10 @@ public class SqlNote {
mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
mOriginParent = 0;
mVersion = 0;
+<<<<<<< HEAD
mTop = getmTop();
+=======
+>>>>>>> origin/Branch_liujie
mDiffNoteValues = new ContentValues();
mDataList = new ArrayList();
}
@@ -157,7 +170,10 @@ public class SqlNote {
if (mType == Notes.TYPE_NOTE)
loadDataContent();
mDiffNoteValues = new ContentValues();
+<<<<<<< HEAD
mTop = getmTop();
+=======
+>>>>>>> origin/Branch_liujie
}
public SqlNote(Context context, long id) {
@@ -169,6 +185,7 @@ public class SqlNote {
if (mType == Notes.TYPE_NOTE)
loadDataContent();
mDiffNoteValues = new ContentValues();
+<<<<<<< HEAD
mTop = getmTop();
}
@@ -177,6 +194,11 @@ public class SqlNote {
return mTop;
}
+=======
+
+ }
+
+>>>>>>> origin/Branch_liujie
private void loadFromCursor(long id) {
Cursor c = null;
try {
@@ -209,7 +231,10 @@ public class SqlNote {
mWidgetId = c.getInt(WIDGET_ID_COLUMN);
mWidgetType = c.getInt(WIDGET_TYPE_COLUMN);
mVersion = c.getLong(VERSION_COLUMN);
+<<<<<<< HEAD
mTop = c.getString(Top_COLUMN);
+=======
+>>>>>>> origin/Branch_liujie
}
private void loadDataContent() {
diff --git a/src/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java.orig b/src/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java.orig
new file mode 100644
index 0000000..8682598
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java.orig
@@ -0,0 +1,542 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.gtask.data;
+
+import android.appwidget.AppWidgetManager;
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+import android.util.Log;
+
+import net.micode.notes.data.Notes;
+import net.micode.notes.data.Notes.DataColumns;
+import net.micode.notes.data.Notes.NoteColumns;
+import net.micode.notes.gtask.exception.ActionFailureException;
+import net.micode.notes.tool.GTaskStringUtils;
+import net.micode.notes.tool.ResourceParser;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+
+
+public class SqlNote {
+ private static final String TAG = SqlNote.class.getSimpleName();
+
+ private static final int INVALID_ID = -99999;
+
+ public static final String[] PROJECTION_NOTE = new String[] {
+ NoteColumns.ID, NoteColumns.ALERTED_DATE, NoteColumns.BG_COLOR_ID,
+ NoteColumns.CREATED_DATE, NoteColumns.HAS_ATTACHMENT, NoteColumns.MODIFIED_DATE,
+ NoteColumns.NOTES_COUNT, NoteColumns.PARENT_ID, NoteColumns.SNIPPET, NoteColumns.TYPE,
+ NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE, NoteColumns.SYNC_ID,
+ NoteColumns.LOCAL_MODIFIED, NoteColumns.ORIGIN_PARENT_ID, NoteColumns.GTASK_ID,
+<<<<<<< HEAD
+ NoteColumns.VERSION,NoteColumns.TOP,
+=======
+ NoteColumns.VERSION
+>>>>>>> origin/Branch_liujie
+ };
+
+ public static final int ID_COLUMN = 0;
+
+ public static final int ALERTED_DATE_COLUMN = 1;
+
+ public static final int BG_COLOR_ID_COLUMN = 2;
+
+ public static final int CREATED_DATE_COLUMN = 3;
+
+ public static final int HAS_ATTACHMENT_COLUMN = 4;
+
+ public static final int MODIFIED_DATE_COLUMN = 5;
+
+ public static final int NOTES_COUNT_COLUMN = 6;
+
+ public static final int PARENT_ID_COLUMN = 7;
+
+ public static final int SNIPPET_COLUMN = 8;
+
+ public static final int TYPE_COLUMN = 9;
+
+ public static final int WIDGET_ID_COLUMN = 10;
+
+ public static final int WIDGET_TYPE_COLUMN = 11;
+
+ public static final int SYNC_ID_COLUMN = 12;
+
+ public static final int LOCAL_MODIFIED_COLUMN = 13;
+
+ public static final int ORIGIN_PARENT_ID_COLUMN = 14;
+
+ public static final int GTASK_ID_COLUMN = 15;
+
+ public static final int VERSION_COLUMN = 16;
+
+<<<<<<< HEAD
+ public static final int Top_COLUMN = 17;
+
+=======
+>>>>>>> origin/Branch_liujie
+ private Context mContext;
+
+ private ContentResolver mContentResolver;
+
+ private boolean mIsCreate;
+
+ private long mId;
+
+ private long mAlertDate;
+
+ private int mBgColorId;
+
+ private long mCreatedDate;
+
+ private int mHasAttachment;
+
+ private long mModifiedDate;
+
+ private long mParentId;
+
+ private String mSnippet;
+
+ private int mType;
+
+ private int mWidgetId;
+
+ private int mWidgetType;
+
+ private long mOriginParent;
+
+ private long mVersion;
+
+<<<<<<< HEAD
+ private String mTop;
+
+=======
+>>>>>>> origin/Branch_liujie
+ private ContentValues mDiffNoteValues;
+
+ private ArrayList mDataList;
+
+ public SqlNote(Context context) {
+ mContext = context;
+ mContentResolver = context.getContentResolver();
+ mIsCreate = true;
+ mId = INVALID_ID;
+ mAlertDate = 0;
+ mBgColorId = ResourceParser.getDefaultBgId(context);
+ mCreatedDate = System.currentTimeMillis();
+ mHasAttachment = 0;
+ mModifiedDate = System.currentTimeMillis();
+ mParentId = 0;
+ mSnippet = "";
+ mType = Notes.TYPE_NOTE;
+ mWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
+ mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
+ mOriginParent = 0;
+ mVersion = 0;
+<<<<<<< HEAD
+ mTop = getmTop();
+=======
+>>>>>>> origin/Branch_liujie
+ mDiffNoteValues = new ContentValues();
+ mDataList = new ArrayList();
+ }
+
+ public SqlNote(Context context, Cursor c) {
+ mContext = context;
+ mContentResolver = context.getContentResolver();
+ mIsCreate = false;
+ loadFromCursor(c);
+ mDataList = new ArrayList();
+ if (mType == Notes.TYPE_NOTE)
+ loadDataContent();
+ mDiffNoteValues = new ContentValues();
+<<<<<<< HEAD
+ mTop = getmTop();
+=======
+>>>>>>> origin/Branch_liujie
+ }
+
+ public SqlNote(Context context, long id) {
+ mContext = context;
+ mContentResolver = context.getContentResolver();
+ mIsCreate = false;
+ loadFromCursor(id);
+ mDataList = new ArrayList();
+ if (mType == Notes.TYPE_NOTE)
+ loadDataContent();
+ mDiffNoteValues = new ContentValues();
+<<<<<<< HEAD
+ mTop = getmTop();
+
+ }
+
+ public String getmTop(){
+ return mTop;
+ }
+
+=======
+
+ }
+
+>>>>>>> origin/Branch_liujie
+ private void loadFromCursor(long id) {
+ Cursor c = null;
+ try {
+ c = mContentResolver.query(Notes.CONTENT_NOTE_URI, PROJECTION_NOTE, "(_id=?)",
+ new String[] {
+ String.valueOf(id)
+ }, null);
+ if (c != null) {
+ c.moveToNext();
+ loadFromCursor(c);
+ } else {
+ Log.w(TAG, "loadFromCursor: cursor = null");
+ }
+ } finally {
+ if (c != null)
+ c.close();
+ }
+ }
+
+ private void loadFromCursor(Cursor c) {
+ mId = c.getLong(ID_COLUMN);
+ mAlertDate = c.getLong(ALERTED_DATE_COLUMN);
+ mBgColorId = c.getInt(BG_COLOR_ID_COLUMN);
+ mCreatedDate = c.getLong(CREATED_DATE_COLUMN);
+ mHasAttachment = c.getInt(HAS_ATTACHMENT_COLUMN);
+ mModifiedDate = c.getLong(MODIFIED_DATE_COLUMN);
+ mParentId = c.getLong(PARENT_ID_COLUMN);
+ mSnippet = c.getString(SNIPPET_COLUMN);
+ mType = c.getInt(TYPE_COLUMN);
+ mWidgetId = c.getInt(WIDGET_ID_COLUMN);
+ mWidgetType = c.getInt(WIDGET_TYPE_COLUMN);
+ mVersion = c.getLong(VERSION_COLUMN);
+<<<<<<< HEAD
+ mTop = c.getString(Top_COLUMN);
+=======
+>>>>>>> origin/Branch_liujie
+ }
+
+ private void loadDataContent() {
+ Cursor c = null;
+ mDataList.clear();
+ try {
+ c = mContentResolver.query(Notes.CONTENT_DATA_URI, SqlData.PROJECTION_DATA,
+ "(note_id=?)", new String[] {
+ String.valueOf(mId)
+ }, null);
+ if (c != null) {
+ if (c.getCount() == 0) {
+ Log.w(TAG, "it seems that the note has not data");
+ return;
+ }
+ while (c.moveToNext()) {
+ SqlData data = new SqlData(mContext, c);
+ mDataList.add(data);
+ }
+ } else {
+ Log.w(TAG, "loadDataContent: cursor = null");
+ }
+ } finally {
+ if (c != null)
+ c.close();
+ }
+ }
+
+ public boolean setContent(JSONObject js) {
+ try {
+ JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE);
+ if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_SYSTEM) {
+ Log.w(TAG, "cannot set system folder");
+ } else if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_FOLDER) {
+ // for folder we can only update the snnipet and type
+ String snippet = note.has(NoteColumns.SNIPPET) ? note
+ .getString(NoteColumns.SNIPPET) : "";
+ if (mIsCreate || !mSnippet.equals(snippet)) {
+ mDiffNoteValues.put(NoteColumns.SNIPPET, snippet);
+ }
+ mSnippet = snippet;
+
+ int type = note.has(NoteColumns.TYPE) ? note.getInt(NoteColumns.TYPE)
+ : Notes.TYPE_NOTE;
+ if (mIsCreate || mType != type) {
+ mDiffNoteValues.put(NoteColumns.TYPE, type);
+ }
+ mType = type;
+ } else if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_NOTE) {
+ JSONArray dataArray = js.getJSONArray(GTaskStringUtils.META_HEAD_DATA);
+ long id = note.has(NoteColumns.ID) ? note.getLong(NoteColumns.ID) : INVALID_ID;
+ if (mIsCreate || mId != id) {
+ mDiffNoteValues.put(NoteColumns.ID, id);
+ }
+ mId = id;
+
+ long alertDate = note.has(NoteColumns.ALERTED_DATE) ? note
+ .getLong(NoteColumns.ALERTED_DATE) : 0;
+ if (mIsCreate || mAlertDate != alertDate) {
+ mDiffNoteValues.put(NoteColumns.ALERTED_DATE, alertDate);
+ }
+ mAlertDate = alertDate;
+
+ int bgColorId = note.has(NoteColumns.BG_COLOR_ID) ? note
+ .getInt(NoteColumns.BG_COLOR_ID) : ResourceParser.getDefaultBgId(mContext);
+ if (mIsCreate || mBgColorId != bgColorId) {
+ mDiffNoteValues.put(NoteColumns.BG_COLOR_ID, bgColorId);
+ }
+ mBgColorId = bgColorId;
+
+ long createDate = note.has(NoteColumns.CREATED_DATE) ? note
+ .getLong(NoteColumns.CREATED_DATE) : System.currentTimeMillis();
+ if (mIsCreate || mCreatedDate != createDate) {
+ mDiffNoteValues.put(NoteColumns.CREATED_DATE, createDate);
+ }
+ mCreatedDate = createDate;
+
+ int hasAttachment = note.has(NoteColumns.HAS_ATTACHMENT) ? note
+ .getInt(NoteColumns.HAS_ATTACHMENT) : 0;
+ if (mIsCreate || mHasAttachment != hasAttachment) {
+ mDiffNoteValues.put(NoteColumns.HAS_ATTACHMENT, hasAttachment);
+ }
+ mHasAttachment = hasAttachment;
+
+ long modifiedDate = note.has(NoteColumns.MODIFIED_DATE) ? note
+ .getLong(NoteColumns.MODIFIED_DATE) : System.currentTimeMillis();
+ if (mIsCreate || mModifiedDate != modifiedDate) {
+ mDiffNoteValues.put(NoteColumns.MODIFIED_DATE, modifiedDate);
+ }
+ mModifiedDate = modifiedDate;
+
+ long parentId = note.has(NoteColumns.PARENT_ID) ? note
+ .getLong(NoteColumns.PARENT_ID) : 0;
+ if (mIsCreate || mParentId != parentId) {
+ mDiffNoteValues.put(NoteColumns.PARENT_ID, parentId);
+ }
+ mParentId = parentId;
+
+ String snippet = note.has(NoteColumns.SNIPPET) ? note
+ .getString(NoteColumns.SNIPPET) : "";
+ if (mIsCreate || !mSnippet.equals(snippet)) {
+ mDiffNoteValues.put(NoteColumns.SNIPPET, snippet);
+ }
+ mSnippet = snippet;
+
+ int type = note.has(NoteColumns.TYPE) ? note.getInt(NoteColumns.TYPE)
+ : Notes.TYPE_NOTE;
+ if (mIsCreate || mType != type) {
+ mDiffNoteValues.put(NoteColumns.TYPE, type);
+ }
+ mType = type;
+
+ int widgetId = note.has(NoteColumns.WIDGET_ID) ? note.getInt(NoteColumns.WIDGET_ID)
+ : AppWidgetManager.INVALID_APPWIDGET_ID;
+ if (mIsCreate || mWidgetId != widgetId) {
+ mDiffNoteValues.put(NoteColumns.WIDGET_ID, widgetId);
+ }
+ mWidgetId = widgetId;
+
+ int widgetType = note.has(NoteColumns.WIDGET_TYPE) ? note
+ .getInt(NoteColumns.WIDGET_TYPE) : Notes.TYPE_WIDGET_INVALIDE;
+ if (mIsCreate || mWidgetType != widgetType) {
+ mDiffNoteValues.put(NoteColumns.WIDGET_TYPE, widgetType);
+ }
+ mWidgetType = widgetType;
+
+ long originParent = note.has(NoteColumns.ORIGIN_PARENT_ID) ? note
+ .getLong(NoteColumns.ORIGIN_PARENT_ID) : 0;
+ if (mIsCreate || mOriginParent != originParent) {
+ mDiffNoteValues.put(NoteColumns.ORIGIN_PARENT_ID, originParent);
+ }
+ mOriginParent = originParent;
+
+ for (int i = 0; i < dataArray.length(); i++) {
+ JSONObject data = dataArray.getJSONObject(i);
+ SqlData sqlData = null;
+ if (data.has(DataColumns.ID)) {
+ long dataId = data.getLong(DataColumns.ID);
+ for (SqlData temp : mDataList) {
+ if (dataId == temp.getId()) {
+ sqlData = temp;
+ }
+ }
+ }
+
+ if (sqlData == null) {
+ sqlData = new SqlData(mContext);
+ mDataList.add(sqlData);
+ }
+
+ sqlData.setContent(data);
+ }
+ }
+ } catch (JSONException e) {
+ Log.e(TAG, e.toString());
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ public JSONObject getContent() {
+ try {
+ JSONObject js = new JSONObject();
+
+ if (mIsCreate) {
+ Log.e(TAG, "it seems that we haven't created this in database yet");
+ return null;
+ }
+
+ JSONObject note = new JSONObject();
+ if (mType == Notes.TYPE_NOTE) {
+ note.put(NoteColumns.ID, mId);
+ note.put(NoteColumns.ALERTED_DATE, mAlertDate);
+ note.put(NoteColumns.BG_COLOR_ID, mBgColorId);
+ note.put(NoteColumns.CREATED_DATE, mCreatedDate);
+ note.put(NoteColumns.HAS_ATTACHMENT, mHasAttachment);
+ note.put(NoteColumns.MODIFIED_DATE, mModifiedDate);
+ note.put(NoteColumns.PARENT_ID, mParentId);
+ note.put(NoteColumns.SNIPPET, mSnippet);
+ note.put(NoteColumns.TYPE, mType);
+ note.put(NoteColumns.WIDGET_ID, mWidgetId);
+ note.put(NoteColumns.WIDGET_TYPE, mWidgetType);
+ note.put(NoteColumns.ORIGIN_PARENT_ID, mOriginParent);
+ js.put(GTaskStringUtils.META_HEAD_NOTE, note);
+
+ JSONArray dataArray = new JSONArray();
+ for (SqlData sqlData : mDataList) {
+ JSONObject data = sqlData.getContent();
+ if (data != null) {
+ dataArray.put(data);
+ }
+ }
+ js.put(GTaskStringUtils.META_HEAD_DATA, dataArray);
+ } else if (mType == Notes.TYPE_FOLDER || mType == Notes.TYPE_SYSTEM) {
+ note.put(NoteColumns.ID, mId);
+ note.put(NoteColumns.TYPE, mType);
+ note.put(NoteColumns.SNIPPET, mSnippet);
+ js.put(GTaskStringUtils.META_HEAD_NOTE, note);
+ }
+
+ return js;
+ } catch (JSONException e) {
+ Log.e(TAG, e.toString());
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public void setParentId(long id) {
+ mParentId = id;
+ mDiffNoteValues.put(NoteColumns.PARENT_ID, id);
+ }
+
+ public void setGtaskId(String gid) {
+ mDiffNoteValues.put(NoteColumns.GTASK_ID, gid);
+ }
+
+ public void setSyncId(long syncId) {
+ mDiffNoteValues.put(NoteColumns.SYNC_ID, syncId);
+ }
+
+ public void resetLocalModified() {
+ mDiffNoteValues.put(NoteColumns.LOCAL_MODIFIED, 0);
+ }
+
+ public long getId() {
+ return mId;
+ }
+
+ public long getParentId() {
+ return mParentId;
+ }
+
+ public String getSnippet() {
+ return mSnippet;
+ }
+
+ public boolean isNoteType() {
+ return mType == Notes.TYPE_NOTE;
+ }
+
+ public void commit(boolean validateVersion) {
+ if (mIsCreate) {
+ if (mId == INVALID_ID && mDiffNoteValues.containsKey(NoteColumns.ID)) {
+ mDiffNoteValues.remove(NoteColumns.ID);
+ }
+
+ Uri uri = mContentResolver.insert(Notes.CONTENT_NOTE_URI, mDiffNoteValues);
+ try {
+ mId = Long.valueOf(uri.getPathSegments().get(1));
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "Get note id error :" + e.toString());
+ throw new ActionFailureException("create note failed");
+ }
+ if (mId == 0) {
+ throw new IllegalStateException("Create thread id failed");
+ }
+
+ if (mType == Notes.TYPE_NOTE) {
+ for (SqlData sqlData : mDataList) {
+ sqlData.commit(mId, false, -1);
+ }
+ }
+ } else {
+ if (mId <= 0 && mId != Notes.ID_ROOT_FOLDER && mId != Notes.ID_CALL_RECORD_FOLDER) {
+ Log.e(TAG, "No such note");
+ throw new IllegalStateException("Try to update note with invalid id");
+ }
+ if (mDiffNoteValues.size() > 0) {
+ mVersion ++;
+ int result = 0;
+ if (!validateVersion) {
+ result = mContentResolver.update(Notes.CONTENT_NOTE_URI, mDiffNoteValues, "("
+ + NoteColumns.ID + "=?)", new String[] {
+ String.valueOf(mId)
+ });
+ } else {
+ result = mContentResolver.update(Notes.CONTENT_NOTE_URI, mDiffNoteValues, "("
+ + NoteColumns.ID + "=?) AND (" + NoteColumns.VERSION + "<=?)",
+ new String[] {
+ String.valueOf(mId), String.valueOf(mVersion)
+ });
+ }
+ if (result == 0) {
+ Log.w(TAG, "there is no update. maybe user updates note when syncing");
+ }
+ }
+
+ if (mType == Notes.TYPE_NOTE) {
+ for (SqlData sqlData : mDataList) {
+ sqlData.commit(mId, validateVersion, mVersion);
+ }
+ }
+ }
+
+ // refresh local info
+ loadFromCursor(mId);
+ if (mType == Notes.TYPE_NOTE)
+ loadDataContent();
+
+ mDiffNoteValues.clear();
+ mIsCreate = false;
+ }
+}
diff --git a/src/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java b/src/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java
index 3f3c358..a3671c6 100644
--- a/src/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java
+++ b/src/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java
@@ -77,8 +77,14 @@ public class GTaskASyncTask extends AsyncTask {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
NotesListActivity.class), 0);
}
+<<<<<<< HEAD
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
+=======
+ /** notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
+ pendingIntent);
+ mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);**/
+>>>>>>> origin/Branch_liujie
}
@Override
diff --git a/src/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java.orig b/src/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java.orig
new file mode 100644
index 0000000..a3671c6
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java.orig
@@ -0,0 +1,128 @@
+
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.gtask.remote;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.os.AsyncTask;
+
+import net.micode.notes.R;
+import net.micode.notes.ui.NotesListActivity;
+import net.micode.notes.ui.NotesPreferenceActivity;
+
+
+public class GTaskASyncTask extends AsyncTask {
+
+ private static int GTASK_SYNC_NOTIFICATION_ID = 5234235;
+
+ public interface OnCompleteListener {
+ void onComplete();
+ }
+
+ private Context mContext;
+
+ private NotificationManager mNotifiManager;
+
+ private GTaskManager mTaskManager;
+
+ private OnCompleteListener mOnCompleteListener;
+
+ public GTaskASyncTask(Context context, OnCompleteListener listener) {
+ mContext = context;
+ mOnCompleteListener = listener;
+ mNotifiManager = (NotificationManager) mContext
+ .getSystemService(Context.NOTIFICATION_SERVICE);
+ mTaskManager = GTaskManager.getInstance();
+ }
+
+ public void cancelSync() {
+ mTaskManager.cancelSync();
+ }
+
+ public void publishProgess(String message) {
+ publishProgress(new String[] {
+ message
+ });
+ }
+
+ private void showNotification(int tickerId, String content) {
+ Notification notification = new Notification(R.drawable.notification, mContext
+ .getString(tickerId), System.currentTimeMillis());
+ notification.defaults = Notification.DEFAULT_LIGHTS;
+ notification.flags = Notification.FLAG_AUTO_CANCEL;
+ PendingIntent pendingIntent;
+ if (tickerId != R.string.ticker_success) {
+ pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
+ NotesPreferenceActivity.class), 0);
+
+ } else {
+ pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
+ NotesListActivity.class), 0);
+ }
+<<<<<<< HEAD
+
+ mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
+=======
+ /** notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
+ pendingIntent);
+ mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);**/
+>>>>>>> origin/Branch_liujie
+ }
+
+ @Override
+ protected Integer doInBackground(Void... unused) {
+ publishProgess(mContext.getString(R.string.sync_progress_login, NotesPreferenceActivity
+ .getSyncAccountName(mContext)));
+ return mTaskManager.sync(mContext, this);
+ }
+
+ @Override
+ protected void onProgressUpdate(String... progress) {
+ showNotification(R.string.ticker_syncing, progress[0]);
+ if (mContext instanceof GTaskSyncService) {
+ ((GTaskSyncService) mContext).sendBroadcast(progress[0]);
+ }
+ }
+
+ @Override
+ protected void onPostExecute(Integer result) {
+ if (result == GTaskManager.STATE_SUCCESS) {
+ showNotification(R.string.ticker_success, mContext.getString(
+ R.string.success_sync_account, mTaskManager.getSyncAccount()));
+ NotesPreferenceActivity.setLastSyncTime(mContext, System.currentTimeMillis());
+ } else if (result == GTaskManager.STATE_NETWORK_ERROR) {
+ showNotification(R.string.ticker_fail, mContext.getString(R.string.error_sync_network));
+ } else if (result == GTaskManager.STATE_INTERNAL_ERROR) {
+ showNotification(R.string.ticker_fail, mContext.getString(R.string.error_sync_internal));
+ } else if (result == GTaskManager.STATE_SYNC_CANCELLED) {
+ showNotification(R.string.ticker_cancel, mContext
+ .getString(R.string.error_sync_cancelled));
+ }
+ if (mOnCompleteListener != null) {
+ new Thread(new Runnable() {
+
+ public void run() {
+ mOnCompleteListener.onComplete();
+ }
+ }).start();
+ }
+ }
+}
diff --git a/src/app/src/main/java/net/micode/notes/model/Note.java b/src/app/src/main/java/net/micode/notes/model/Note.java
index 0ccf19f..629829f 100644
--- a/src/app/src/main/java/net/micode/notes/model/Note.java
+++ b/src/app/src/main/java/net/micode/notes/model/Note.java
@@ -47,7 +47,10 @@ public class Note {
long createdTime = System.currentTimeMillis();
values.put(NoteColumns.CREATED_DATE, createdTime);
values.put(NoteColumns.MODIFIED_DATE, createdTime);
+<<<<<<< HEAD
//values.put(NoteColumns.TOP,"1");
+=======
+>>>>>>> origin/Branch_liujie
values.put(NoteColumns.TYPE, Notes.TYPE_NOTE);
values.put(NoteColumns.LOCAL_MODIFIED, 1);
values.put(NoteColumns.PARENT_ID, folderId);
@@ -77,10 +80,13 @@ public class Note {
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
+<<<<<<< HEAD
public void setTopValue(String key, String value) {
mNoteDiffValues.put(key, value);
}
+=======
+>>>>>>> origin/Branch_liujie
public void setTextData(String key, String value) {
mNoteData.setTextData(key, value);
}
@@ -140,8 +146,11 @@ public class Note {
private ContentValues mTextDataValues;
+<<<<<<< HEAD
private ContentValues mTopValues;
+=======
+>>>>>>> origin/Branch_liujie
private long mCallDataId;
private ContentValues mCallDataValues;
@@ -151,7 +160,10 @@ public class Note {
public NoteData() {
mTextDataValues = new ContentValues();
mCallDataValues = new ContentValues();
+<<<<<<< HEAD
mTopValues = new ContentValues();
+=======
+>>>>>>> origin/Branch_liujie
mTextDataId = 0;
mCallDataId = 0;
}
diff --git a/src/app/src/main/java/net/micode/notes/model/Note.java.orig b/src/app/src/main/java/net/micode/notes/model/Note.java.orig
new file mode 100644
index 0000000..629829f
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/model/Note.java.orig
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.model;
+import android.content.ContentProviderOperation;
+import android.content.ContentProviderResult;
+import android.content.ContentUris;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.OperationApplicationException;
+import android.net.Uri;
+import android.os.RemoteException;
+import android.util.Log;
+
+import net.micode.notes.data.Notes;
+import net.micode.notes.data.Notes.CallNote;
+import net.micode.notes.data.Notes.DataColumns;
+import net.micode.notes.data.Notes.NoteColumns;
+import net.micode.notes.data.Notes.TextNote;
+
+import java.util.ArrayList;
+
+
+public class Note {
+ private ContentValues mNoteDiffValues;
+ private NoteData mNoteData;
+ private static final String TAG = "Note";
+ /**
+ * Create a new note id for adding a new note to databases
+ */
+ public static synchronized long getNewNoteId(Context context, long folderId) {
+ // Create a new note in the database
+ ContentValues values = new ContentValues();
+ long createdTime = System.currentTimeMillis();
+ values.put(NoteColumns.CREATED_DATE, createdTime);
+ values.put(NoteColumns.MODIFIED_DATE, createdTime);
+<<<<<<< HEAD
+ //values.put(NoteColumns.TOP,"1");
+=======
+>>>>>>> origin/Branch_liujie
+ values.put(NoteColumns.TYPE, Notes.TYPE_NOTE);
+ values.put(NoteColumns.LOCAL_MODIFIED, 1);
+ values.put(NoteColumns.PARENT_ID, folderId);
+ Uri uri = context.getContentResolver().insert(Notes.CONTENT_NOTE_URI, values);
+
+ long noteId = 0;
+ try {
+ noteId = Long.valueOf(uri.getPathSegments().get(1));
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "Get note id error :" + e.toString());
+ noteId = 0;
+ }
+ if (noteId == -1) {
+ throw new IllegalStateException("Wrong note id:" + noteId);
+ }
+ return noteId;
+ }
+
+ public Note() {
+ mNoteDiffValues = new ContentValues();
+ mNoteData = new NoteData();
+ }
+
+ public void setNoteValue(String key, String value) {
+ mNoteDiffValues.put(key, value);
+ mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
+ mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
+ }
+
+<<<<<<< HEAD
+ public void setTopValue(String key, String value) {
+ mNoteDiffValues.put(key, value);
+ }
+
+=======
+>>>>>>> origin/Branch_liujie
+ public void setTextData(String key, String value) {
+ mNoteData.setTextData(key, value);
+ }
+
+ public void setTextDataId(long id) {
+ mNoteData.setTextDataId(id);
+ }
+
+ public long getTextDataId() {
+ return mNoteData.mTextDataId;
+ }
+
+ public void setCallDataId(long id) {
+ mNoteData.setCallDataId(id);
+ }
+
+ public void setCallData(String key, String value) {
+ mNoteData.setCallData(key, value);
+ }
+
+ public boolean isLocalModified() {
+ return mNoteDiffValues.size() > 0 || mNoteData.isLocalModified();
+ }
+
+ public boolean syncNote(Context context, long noteId) {
+ if (noteId <= 0) {
+ throw new IllegalArgumentException("Wrong note id:" + noteId);
+ }
+
+ if (!isLocalModified()) {
+ return true;
+ }
+
+ /**
+ * In theory, once data changed, the note should be updated on {@link NoteColumns#LOCAL_MODIFIED} and
+ * {@link NoteColumns#MODIFIED_DATE}. For data safety, though update note fails, we also update the
+ * note data info
+ */
+ if (context.getContentResolver().update(
+ ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), mNoteDiffValues, null,
+ null) == 0) {
+ Log.e(TAG, "Update note error, should not happen");
+ // Do not return, fall through
+ }
+ mNoteDiffValues.clear();
+
+ if (mNoteData.isLocalModified()
+ && (mNoteData.pushIntoContentResolver(context, noteId) == null)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ private class NoteData {
+ private long mTextDataId;
+
+ private ContentValues mTextDataValues;
+
+<<<<<<< HEAD
+ private ContentValues mTopValues;
+
+=======
+>>>>>>> origin/Branch_liujie
+ private long mCallDataId;
+
+ private ContentValues mCallDataValues;
+
+ private static final String TAG = "NoteData";
+
+ public NoteData() {
+ mTextDataValues = new ContentValues();
+ mCallDataValues = new ContentValues();
+<<<<<<< HEAD
+ mTopValues = new ContentValues();
+=======
+>>>>>>> origin/Branch_liujie
+ mTextDataId = 0;
+ mCallDataId = 0;
+ }
+
+ boolean isLocalModified() {
+ return mTextDataValues.size() > 0 || mCallDataValues.size() > 0;
+ }
+
+ void setTextDataId(long id) {
+ if(id <= 0) {
+ throw new IllegalArgumentException("Text data id should larger than 0");
+ }
+ mTextDataId = id;
+ }
+
+ void setCallDataId(long id) {
+ if (id <= 0) {
+ throw new IllegalArgumentException("Call data id should larger than 0");
+ }
+ mCallDataId = id;
+ }
+
+ void setCallData(String key, String value) {
+ mCallDataValues.put(key, value);
+ mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
+ mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
+ }
+
+ void setTextData(String key, String value) {
+ mTextDataValues.put(key, value);
+ mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
+ mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
+ }
+
+ Uri pushIntoContentResolver(Context context, long noteId) {
+ /**
+ * Check for safety
+ */
+ if (noteId <= 0) {
+ throw new IllegalArgumentException("Wrong note id:" + noteId);
+ }
+
+ ArrayList operationList = new ArrayList();
+ ContentProviderOperation.Builder builder = null;
+
+ if(mTextDataValues.size() > 0) {
+ mTextDataValues.put(DataColumns.NOTE_ID, noteId);
+ if (mTextDataId == 0) {
+ mTextDataValues.put(DataColumns.MIME_TYPE, TextNote.CONTENT_ITEM_TYPE);
+ Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI,
+ mTextDataValues);
+ try {
+ setTextDataId(Long.valueOf(uri.getPathSegments().get(1)));
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "Insert new text data fail with noteId" + noteId);
+ mTextDataValues.clear();
+ return null;
+ }
+ } else {
+ builder = ContentProviderOperation.newUpdate(ContentUris.withAppendedId(
+ Notes.CONTENT_DATA_URI, mTextDataId));
+ builder.withValues(mTextDataValues);
+ operationList.add(builder.build());
+ }
+ mTextDataValues.clear();
+ }
+
+ if(mCallDataValues.size() > 0) {
+ mCallDataValues.put(DataColumns.NOTE_ID, noteId);
+ if (mCallDataId == 0) {
+ mCallDataValues.put(DataColumns.MIME_TYPE, CallNote.CONTENT_ITEM_TYPE);
+ Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI,
+ mCallDataValues);
+ try {
+ setCallDataId(Long.valueOf(uri.getPathSegments().get(1)));
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "Insert new call data fail with noteId" + noteId);
+ mCallDataValues.clear();
+ return null;
+ }
+ } else {
+ builder = ContentProviderOperation.newUpdate(ContentUris.withAppendedId(
+ Notes.CONTENT_DATA_URI, mCallDataId));
+ builder.withValues(mCallDataValues);
+ operationList.add(builder.build());
+ }
+ mCallDataValues.clear();
+ }
+
+ if (operationList.size() > 0) {
+ try {
+ ContentProviderResult[] results = context.getContentResolver().applyBatch(
+ Notes.AUTHORITY, operationList);
+ return (results == null || results.length == 0 || results[0] == null) ? null
+ : ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId);
+ } catch (RemoteException e) {
+ Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
+ return null;
+ } catch (OperationApplicationException e) {
+ Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
+ return null;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/src/app/src/main/java/net/micode/notes/model/WorkingNote.java b/src/app/src/main/java/net/micode/notes/model/WorkingNote.java
index cb16126..4faa06c 100644
--- a/src/app/src/main/java/net/micode/notes/model/WorkingNote.java
+++ b/src/app/src/main/java/net/micode/notes/model/WorkingNote.java
@@ -29,7 +29,10 @@ import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.DataConstants;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.Notes.TextNote;
+<<<<<<< HEAD
import net.micode.notes.data.NotesProvider;
+=======
+>>>>>>> origin/Branch_liujie
import net.micode.notes.tool.ResourceParser.NoteBgResources;
@@ -61,6 +64,7 @@ public class WorkingNote {
private boolean mIsDeleted;
+<<<<<<< HEAD
/**记录已置顶便签*/
private String mTop = "0";
@@ -69,6 +73,8 @@ public class WorkingNote {
private int mClass;
+=======
+>>>>>>> origin/Branch_liujie
private NoteSettingChangedListener mNoteSettingStatusListener;
public static final String[] DATA_PROJECTION = new String[] {
@@ -87,8 +93,12 @@ public class WorkingNote {
NoteColumns.BG_COLOR_ID,
NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE,
+<<<<<<< HEAD
NoteColumns.MODIFIED_DATE,
NoteColumns.TOP,
+=======
+ NoteColumns.MODIFIED_DATE
+>>>>>>> origin/Branch_liujie
};
private static final int DATA_ID_COLUMN = 0;
@@ -111,7 +121,10 @@ public class WorkingNote {
private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
+<<<<<<< HEAD
private static final int NOTE_TOP_COLUMN = 6;
+=======
+>>>>>>> origin/Branch_liujie
// New note construct
private WorkingNote(Context context, long folderId) {
@@ -124,7 +137,10 @@ public class WorkingNote {
mIsDeleted = false;
mMode = 0;
mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
+<<<<<<< HEAD
mTop = String.valueOf(getTopId());
+=======
+>>>>>>> origin/Branch_liujie
}
// Existing note construct
@@ -150,7 +166,10 @@ public class WorkingNote {
mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN);
mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN);
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
+<<<<<<< HEAD
mTop = cursor.getString(NOTE_TOP_COLUMN);
+=======
+>>>>>>> origin/Branch_liujie
}
cursor.close();
} else {
@@ -243,6 +262,7 @@ public class WorkingNote {
mNoteSettingStatusListener = l;
}
+<<<<<<< HEAD
public void setTop(String Top){
if (!mTop.equals(Top)) {
mTop = Top;
@@ -253,6 +273,8 @@ public class WorkingNote {
}
}
+=======
+>>>>>>> origin/Branch_liujie
public void setAlertDate(long date, boolean set) {
if (date != mAlertDate) {
mAlertDate = date;
@@ -312,10 +334,13 @@ public class WorkingNote {
}
}
+<<<<<<< HEAD
public void setmContent(String text){
mContent = text;
}
+=======
+>>>>>>> origin/Branch_liujie
public void convertToCallNote(String phoneNumber, long callDate) {
mNote.setCallData(CallNote.CALL_DATE, String.valueOf(callDate));
mNote.setCallData(CallNote.PHONE_NUMBER, phoneNumber);
@@ -326,6 +351,7 @@ public class WorkingNote {
return (mAlertDate > 0 ? true : false);
}
+<<<<<<< HEAD
public int getTopId() {
if (mTop.equals("1")) {
return 1;
@@ -334,6 +360,8 @@ public class WorkingNote {
}
}
+=======
+>>>>>>> origin/Branch_liujie
public String getContent() {
return mContent;
}
@@ -385,12 +413,15 @@ public class WorkingNote {
void onBackgroundColorChanged();
/**
+<<<<<<< HEAD
* Called when user set top
*/
void onTopChanged(String Top);
/**
+=======
+>>>>>>> origin/Branch_liujie
* Called when user set clock
*/
void onClockAlertChanged(long date, boolean set);
@@ -407,4 +438,21 @@ public class WorkingNote {
*/
void onCheckListModeChanged(int oldMode, int newMode);
}
+<<<<<<< HEAD
+=======
+ /* 设置便签的访问密码
+ * @param password 新的访问密码
+ */
+ public void setPassword(String password){
+ //将该类的mPassword属性设置为新的访问密码
+ String mPassword = password;
+ //将修改后的便签密码写入到便签数据库中
+ mNote.setNoteValue(NoteColumns.PASSWORD,mPassword);
+ }
+
+ public String getmPassword(){
+ String mPassword="1234";
+ return mPassword;
+ }
+>>>>>>> origin/Branch_liujie
}
diff --git a/src/app/src/main/java/net/micode/notes/model/WorkingNote.java.orig b/src/app/src/main/java/net/micode/notes/model/WorkingNote.java.orig
new file mode 100644
index 0000000..4faa06c
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/model/WorkingNote.java.orig
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.model;
+
+import android.appwidget.AppWidgetManager;
+import android.content.ContentUris;
+import android.content.Context;
+import android.database.Cursor;
+import android.text.TextUtils;
+import android.util.Log;
+
+import net.micode.notes.data.Notes;
+import net.micode.notes.data.Notes.CallNote;
+import net.micode.notes.data.Notes.DataColumns;
+import net.micode.notes.data.Notes.DataConstants;
+import net.micode.notes.data.Notes.NoteColumns;
+import net.micode.notes.data.Notes.TextNote;
+<<<<<<< HEAD
+import net.micode.notes.data.NotesProvider;
+=======
+>>>>>>> origin/Branch_liujie
+import net.micode.notes.tool.ResourceParser.NoteBgResources;
+
+
+public class WorkingNote {
+ // Note for the working note
+ private Note mNote;
+ // Note Id
+ private long mNoteId;
+ // Note content
+ private String mContent;
+ // Note mode
+ private int mMode;
+
+ private long mAlertDate;
+
+ private long mModifiedDate;
+
+ private int mBgColorId;
+
+ private int mWidgetId;
+
+ private int mWidgetType;
+
+ private long mFolderId;
+
+ private Context mContext;
+
+ private static final String TAG = "WorkingNote";
+
+ private boolean mIsDeleted;
+
+<<<<<<< HEAD
+
+ /**记录已置顶便签*/
+ private String mTop = "0";
+
+ /**记录便签所属类别*/
+ private int mClass;
+
+
+=======
+>>>>>>> origin/Branch_liujie
+ private NoteSettingChangedListener mNoteSettingStatusListener;
+
+ public static final String[] DATA_PROJECTION = new String[] {
+ DataColumns.ID,
+ DataColumns.CONTENT,
+ DataColumns.MIME_TYPE,
+ DataColumns.DATA1,
+ DataColumns.DATA2,
+ DataColumns.DATA3,
+ DataColumns.DATA4,
+ };
+
+ public static final String[] NOTE_PROJECTION = new String[] {
+ NoteColumns.PARENT_ID,
+ NoteColumns.ALERTED_DATE,
+ NoteColumns.BG_COLOR_ID,
+ NoteColumns.WIDGET_ID,
+ NoteColumns.WIDGET_TYPE,
+<<<<<<< HEAD
+ NoteColumns.MODIFIED_DATE,
+ NoteColumns.TOP,
+=======
+ NoteColumns.MODIFIED_DATE
+>>>>>>> origin/Branch_liujie
+ };
+
+ private static final int DATA_ID_COLUMN = 0;
+
+ private static final int DATA_CONTENT_COLUMN = 1;
+
+ private static final int DATA_MIME_TYPE_COLUMN = 2;
+
+ private static final int DATA_MODE_COLUMN = 3;
+
+ private static final int NOTE_PARENT_ID_COLUMN = 0;
+
+ private static final int NOTE_ALERTED_DATE_COLUMN = 1;
+
+ private static final int NOTE_BG_COLOR_ID_COLUMN = 2;
+
+ private static final int NOTE_WIDGET_ID_COLUMN = 3;
+
+ private static final int NOTE_WIDGET_TYPE_COLUMN = 4;
+
+ private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
+
+<<<<<<< HEAD
+ private static final int NOTE_TOP_COLUMN = 6;
+=======
+>>>>>>> origin/Branch_liujie
+
+ // New note construct
+ private WorkingNote(Context context, long folderId) {
+ mContext = context;
+ mAlertDate = 0;
+ mModifiedDate = System.currentTimeMillis();
+ mFolderId = folderId;
+ mNote = new Note();
+ mNoteId = 0;
+ mIsDeleted = false;
+ mMode = 0;
+ mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
+<<<<<<< HEAD
+ mTop = String.valueOf(getTopId());
+=======
+>>>>>>> origin/Branch_liujie
+ }
+
+ // Existing note construct
+ private WorkingNote(Context context, long noteId, long folderId) {
+ mContext = context;
+ mNoteId = noteId;
+ mFolderId = folderId;
+ mIsDeleted = false;
+ mNote = new Note();
+ loadNote();
+ }
+
+ private void loadNote() {
+ Cursor cursor = mContext.getContentResolver().query(
+ ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mNoteId), NOTE_PROJECTION, null,
+ null, null);
+
+ if (cursor != null) {
+ if (cursor.moveToFirst()) {
+ mFolderId = cursor.getLong(NOTE_PARENT_ID_COLUMN);
+ mBgColorId = cursor.getInt(NOTE_BG_COLOR_ID_COLUMN);
+ mWidgetId = cursor.getInt(NOTE_WIDGET_ID_COLUMN);
+ mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN);
+ mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN);
+ mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
+<<<<<<< HEAD
+ mTop = cursor.getString(NOTE_TOP_COLUMN);
+=======
+>>>>>>> origin/Branch_liujie
+ }
+ cursor.close();
+ } else {
+ Log.e(TAG, "No note with id:" + mNoteId);
+ throw new IllegalArgumentException("Unable to find note with id " + mNoteId);
+ }
+ loadNoteData();
+ }
+
+ private void loadNoteData() {
+ Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
+ DataColumns.NOTE_ID + "=?", new String[] {
+ String.valueOf(mNoteId)
+ }, null);
+
+ if (cursor != null) {
+ if (cursor.moveToFirst()) {
+ do {
+ String type = cursor.getString(DATA_MIME_TYPE_COLUMN);
+ if (DataConstants.NOTE.equals(type)) {
+ mContent = cursor.getString(DATA_CONTENT_COLUMN);
+ mMode = cursor.getInt(DATA_MODE_COLUMN);
+ mNote.setTextDataId(cursor.getLong(DATA_ID_COLUMN));
+ } else if (DataConstants.CALL_NOTE.equals(type)) {
+ mNote.setCallDataId(cursor.getLong(DATA_ID_COLUMN));
+ } else {
+ Log.d(TAG, "Wrong note type with type:" + type);
+ }
+ } while (cursor.moveToNext());
+ }
+ cursor.close();
+ } else {
+ Log.e(TAG, "No data with id:" + mNoteId);
+ throw new IllegalArgumentException("Unable to find note's data with id " + mNoteId);
+ }
+ }
+
+ public static WorkingNote createEmptyNote(Context context, long folderId, int widgetId,
+ int widgetType, int defaultBgColorId) {
+ WorkingNote note = new WorkingNote(context, folderId);
+ note.setBgColorId(defaultBgColorId);
+ note.setWidgetId(widgetId);
+ note.setWidgetType(widgetType);
+ return note;
+ }
+
+ public static WorkingNote load(Context context, long id) {
+ return new WorkingNote(context, id, 0);
+ }
+
+ public synchronized boolean saveNote() {
+ if (isWorthSaving()) {
+ if (!existInDatabase()) {
+ if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
+ Log.e(TAG, "Create new note fail with id:" + mNoteId);
+ return false;
+ }
+ }
+
+ mNote.syncNote(mContext, mNoteId);
+
+ /**
+ * Update widget content if there exist any widget of this note
+ */
+ if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
+ && mWidgetType != Notes.TYPE_WIDGET_INVALIDE
+ && mNoteSettingStatusListener != null) {
+ mNoteSettingStatusListener.onWidgetChanged();
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean existInDatabase() {
+ return mNoteId > 0;
+ }
+
+ private boolean isWorthSaving() {
+ if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
+ || (existInDatabase() && !mNote.isLocalModified())) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
+ mNoteSettingStatusListener = l;
+ }
+
+<<<<<<< HEAD
+ public void setTop(String Top){
+ if (!mTop.equals(Top)) {
+ mTop = Top;
+ mNote.setTopValue(NoteColumns.TOP,mTop);
+ }
+ if (mNoteSettingStatusListener != null) {
+ mNoteSettingStatusListener.onTopChanged(Top);
+ }
+ }
+
+=======
+>>>>>>> origin/Branch_liujie
+ public void setAlertDate(long date, boolean set) {
+ if (date != mAlertDate) {
+ mAlertDate = date;
+ mNote.setNoteValue(NoteColumns.ALERTED_DATE, String.valueOf(mAlertDate));
+ }
+ if (mNoteSettingStatusListener != null) {
+ mNoteSettingStatusListener.onClockAlertChanged(date, set);
+ }
+ }
+
+ public void markDeleted(boolean mark) {
+ mIsDeleted = mark;
+ if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
+ && mWidgetType != Notes.TYPE_WIDGET_INVALIDE && mNoteSettingStatusListener != null) {
+ mNoteSettingStatusListener.onWidgetChanged();
+ }
+ }
+
+ public void setBgColorId(int id) {
+ if (id != mBgColorId) {
+ mBgColorId = id;
+ if (mNoteSettingStatusListener != null) {
+ mNoteSettingStatusListener.onBackgroundColorChanged();
+ }
+ mNote.setNoteValue(NoteColumns.BG_COLOR_ID, String.valueOf(id));
+ }
+ }
+
+ public void setCheckListMode(int mode) {
+ if (mMode != mode) {
+ if (mNoteSettingStatusListener != null) {
+ mNoteSettingStatusListener.onCheckListModeChanged(mMode, mode);
+ }
+ mMode = mode;
+ mNote.setTextData(TextNote.MODE, String.valueOf(mMode));
+ }
+ }
+
+ public void setWidgetType(int type) {
+ if (type != mWidgetType) {
+ mWidgetType = type;
+ mNote.setNoteValue(NoteColumns.WIDGET_TYPE, String.valueOf(mWidgetType));
+ }
+ }
+
+ public void setWidgetId(int id) {
+ if (id != mWidgetId) {
+ mWidgetId = id;
+ mNote.setNoteValue(NoteColumns.WIDGET_ID, String.valueOf(mWidgetId));
+ }
+ }
+
+ public void setWorkingText(String text) {
+ if (!TextUtils.equals(mContent, text)) {
+ mContent = text;
+ mNote.setTextData(DataColumns.CONTENT, mContent);
+ }
+ }
+
+<<<<<<< HEAD
+ public void setmContent(String text){
+ mContent = text;
+ }
+
+=======
+>>>>>>> origin/Branch_liujie
+ public void convertToCallNote(String phoneNumber, long callDate) {
+ mNote.setCallData(CallNote.CALL_DATE, String.valueOf(callDate));
+ mNote.setCallData(CallNote.PHONE_NUMBER, phoneNumber);
+ mNote.setNoteValue(NoteColumns.PARENT_ID, String.valueOf(Notes.ID_CALL_RECORD_FOLDER));
+ }
+
+ public boolean hasClockAlert() {
+ return (mAlertDate > 0 ? true : false);
+ }
+
+<<<<<<< HEAD
+ public int getTopId() {
+ if (mTop.equals("1")) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+=======
+>>>>>>> origin/Branch_liujie
+ public String getContent() {
+ return mContent;
+ }
+
+ public long getAlertDate() {
+ return mAlertDate;
+ }
+
+ public long getModifiedDate() {
+ return mModifiedDate;
+ }
+
+ public int getBgColorResId() {
+ return NoteBgResources.getNoteBgResource(mBgColorId);
+ }
+
+ public int getBgColorId() {
+ return mBgColorId;
+ }
+
+ public int getTitleBgResId() {
+ return NoteBgResources.getNoteTitleBgResource(mBgColorId);
+ }
+
+ public int getCheckListMode() {
+ return mMode;
+ }
+
+ public long getNoteId() {
+ return mNoteId;
+ }
+
+ public long getFolderId() {
+ return mFolderId;
+ }
+
+ public int getWidgetId() {
+ return mWidgetId;
+ }
+
+ public int getWidgetType() {
+ return mWidgetType;
+ }
+
+ public interface NoteSettingChangedListener {
+ /**
+ * Called when the background color of current note has just changed
+ */
+ void onBackgroundColorChanged();
+
+ /**
+<<<<<<< HEAD
+ * Called when user set top
+ */
+ void onTopChanged(String Top);
+
+
+ /**
+=======
+>>>>>>> origin/Branch_liujie
+ * Called when user set clock
+ */
+ void onClockAlertChanged(long date, boolean set);
+
+ /**
+ * Call when user create note from widget
+ */
+ void onWidgetChanged();
+
+ /**
+ * Call when switch between check list mode and normal mode
+ * @param oldMode is previous mode before change
+ * @param newMode is new mode
+ */
+ void onCheckListModeChanged(int oldMode, int newMode);
+ }
+<<<<<<< HEAD
+=======
+ /* 设置便签的访问密码
+ * @param password 新的访问密码
+ */
+ public void setPassword(String password){
+ //将该类的mPassword属性设置为新的访问密码
+ String mPassword = password;
+ //将修改后的便签密码写入到便签数据库中
+ mNote.setNoteValue(NoteColumns.PASSWORD,mPassword);
+ }
+
+ public String getmPassword(){
+ String mPassword="1234";
+ return mPassword;
+ }
+>>>>>>> origin/Branch_liujie
+}
diff --git a/src/app/src/main/java/net/micode/notes/tool/DataUtils.java b/src/app/src/main/java/net/micode/notes/tool/DataUtils.java
index 0487afa..ef7ad70 100644
--- a/src/app/src/main/java/net/micode/notes/tool/DataUtils.java
+++ b/src/app/src/main/java/net/micode/notes/tool/DataUtils.java
@@ -16,7 +16,10 @@
package net.micode.notes.tool;
+<<<<<<< HEAD
import android.app.Activity;
+=======
+>>>>>>> origin/Branch_liujie
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
import android.content.ContentResolver;
@@ -26,6 +29,7 @@ import android.content.OperationApplicationException;
import android.database.Cursor;
import android.os.RemoteException;
import android.util.Log;
+<<<<<<< HEAD
import android.database.sqlite.SQLiteDatabase;
import android.widget.Toast;
@@ -38,11 +42,20 @@ import net.micode.notes.data.NotesProvider;
import net.micode.notes.gtask.data.SqlNote;
import net.micode.notes.model.Note;
import net.micode.notes.ui.NoteEditActivity;
+=======
+
+import net.micode.notes.data.Notes;
+import net.micode.notes.data.Notes.CallNote;
+import net.micode.notes.data.Notes.NoteColumns;
+>>>>>>> origin/Branch_liujie
import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute;
import java.util.ArrayList;
import java.util.HashSet;
+<<<<<<< HEAD
import java.util.TreeSet;
+=======
+>>>>>>> origin/Branch_liujie
public class DataUtils {
diff --git a/src/app/src/main/java/net/micode/notes/tool/DataUtils.java.orig b/src/app/src/main/java/net/micode/notes/tool/DataUtils.java.orig
new file mode 100644
index 0000000..ef7ad70
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/tool/DataUtils.java.orig
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.tool;
+
+<<<<<<< HEAD
+import android.app.Activity;
+=======
+>>>>>>> origin/Branch_liujie
+import android.content.ContentProviderOperation;
+import android.content.ContentProviderResult;
+import android.content.ContentResolver;
+import android.content.ContentUris;
+import android.content.ContentValues;
+import android.content.OperationApplicationException;
+import android.database.Cursor;
+import android.os.RemoteException;
+import android.util.Log;
+<<<<<<< HEAD
+import android.database.sqlite.SQLiteDatabase;
+import android.widget.Toast;
+
+import net.micode.notes.R;
+import net.micode.notes.data.Notes;
+import net.micode.notes.data.Notes.CallNote;
+import net.micode.notes.data.Notes.NoteColumns;
+import net.micode.notes.data.NotesDatabaseHelper;
+import net.micode.notes.data.NotesProvider;
+import net.micode.notes.gtask.data.SqlNote;
+import net.micode.notes.model.Note;
+import net.micode.notes.ui.NoteEditActivity;
+=======
+
+import net.micode.notes.data.Notes;
+import net.micode.notes.data.Notes.CallNote;
+import net.micode.notes.data.Notes.NoteColumns;
+>>>>>>> origin/Branch_liujie
+import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+<<<<<<< HEAD
+import java.util.TreeSet;
+=======
+>>>>>>> origin/Branch_liujie
+
+
+public class DataUtils {
+ public static final String TAG = "DataUtils";
+ public static boolean batchDeleteNotes(ContentResolver resolver, HashSet ids) {
+ if (ids == null) {
+ Log.d(TAG, "the ids is null");
+ return true;
+ }
+ if (ids.size() == 0) {
+ Log.d(TAG, "no id is in the hashset");
+ return true;
+ }
+
+ ArrayList operationList = new ArrayList();
+ for (long id : ids) {
+ if(id == Notes.ID_ROOT_FOLDER) {
+ Log.e(TAG, "Don't delete system folder root");
+ continue;
+ }
+ ContentProviderOperation.Builder builder = ContentProviderOperation
+ .newDelete(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id));
+ operationList.add(builder.build());
+ }
+ try {
+ ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList);
+ if (results == null || results.length == 0 || results[0] == null) {
+ Log.d(TAG, "delete notes failed, ids:" + ids.toString());
+ return false;
+ }
+ return true;
+ } catch (RemoteException e) {
+ Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
+ } catch (OperationApplicationException e) {
+ Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
+ }
+ return false;
+ }
+
+ public static void moveNoteToFoler(ContentResolver resolver, long id, long srcFolderId, long desFolderId) {
+ ContentValues values = new ContentValues();
+ values.put(NoteColumns.PARENT_ID, desFolderId);
+ values.put(NoteColumns.ORIGIN_PARENT_ID, srcFolderId);
+ values.put(NoteColumns.LOCAL_MODIFIED, 1);
+ resolver.update(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id), values, null, null);
+ }
+
+ public static boolean batchMoveToFolder(ContentResolver resolver, HashSet ids,
+ long folderId) {
+ if (ids == null) {
+ Log.d(TAG, "the ids is null");
+ return true;
+ }
+
+ ArrayList operationList = new ArrayList();
+ for (long id : ids) {
+ ContentProviderOperation.Builder builder = ContentProviderOperation
+ .newUpdate(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id));
+ builder.withValue(NoteColumns.PARENT_ID, folderId);
+ builder.withValue(NoteColumns.LOCAL_MODIFIED, 1);
+ operationList.add(builder.build());
+ }
+
+ try {
+ ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList);
+ if (results == null || results.length == 0 || results[0] == null) {
+ Log.d(TAG, "delete notes failed, ids:" + ids.toString());
+ return false;
+ }
+ return true;
+ } catch (RemoteException e) {
+ Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
+ } catch (OperationApplicationException e) {
+ Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
+ }
+ return false;
+ }
+
+ /**
+ * Get the all folder count except system folders {@link Notes#TYPE_SYSTEM}}
+ */
+ public static int getUserFolderCount(ContentResolver resolver) {
+ Cursor cursor =resolver.query(Notes.CONTENT_NOTE_URI,
+ new String[] { "COUNT(*)" },
+ NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>?",
+ new String[] { String.valueOf(Notes.TYPE_FOLDER), String.valueOf(Notes.ID_TRASH_FOLER)},
+ null);
+
+ int count = 0;
+ if(cursor != null) {
+ if(cursor.moveToFirst()) {
+ try {
+ count = cursor.getInt(0);
+ } catch (IndexOutOfBoundsException e) {
+ Log.e(TAG, "get folder count failed:" + e.toString());
+ } finally {
+ cursor.close();
+ }
+ }
+ }
+ return count;
+ }
+
+ public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteId, int type) {
+ Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),
+ null,
+ NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER,
+ new String [] {String.valueOf(type)},
+ null);
+
+ boolean exist = false;
+ if (cursor != null) {
+ if (cursor.getCount() > 0) {
+ exist = true;
+ }
+ cursor.close();
+ }
+ return exist;
+ }
+
+ public static boolean existInNoteDatabase(ContentResolver resolver, long noteId) {
+ Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),
+ null, null, null, null);
+
+ boolean exist = false;
+ if (cursor != null) {
+ if (cursor.getCount() > 0) {
+ exist = true;
+ }
+ cursor.close();
+ }
+ return exist;
+ }
+
+ public static boolean existInDataDatabase(ContentResolver resolver, long dataId) {
+ Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId),
+ null, null, null, null);
+
+ boolean exist = false;
+ if (cursor != null) {
+ if (cursor.getCount() > 0) {
+ exist = true;
+ }
+ cursor.close();
+ }
+ return exist;
+ }
+
+ public static boolean checkVisibleFolderName(ContentResolver resolver, String name) {
+ Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI, null,
+ NoteColumns.TYPE + "=" + Notes.TYPE_FOLDER +
+ " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER +
+ " AND " + NoteColumns.SNIPPET + "=?",
+ new String[] { name }, null);
+ boolean exist = false;
+ if(cursor != null) {
+ if(cursor.getCount() > 0) {
+ exist = true;
+ }
+ cursor.close();
+ }
+ return exist;
+ }
+
+ public static HashSet getFolderNoteWidget(ContentResolver resolver, long folderId) {
+ Cursor c = resolver.query(Notes.CONTENT_NOTE_URI,
+ new String[] { NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE },
+ NoteColumns.PARENT_ID + "=?",
+ new String[] { String.valueOf(folderId) },
+ null);
+
+ HashSet set = null;
+ if (c != null) {
+ if (c.moveToFirst()) {
+ set = new HashSet();
+ do {
+ try {
+ AppWidgetAttribute widget = new AppWidgetAttribute();
+ widget.widgetId = c.getInt(0);
+ widget.widgetType = c.getInt(1);
+ set.add(widget);
+ } catch (IndexOutOfBoundsException e) {
+ Log.e(TAG, e.toString());
+ }
+ } while (c.moveToNext());
+ }
+ c.close();
+ }
+ return set;
+ }
+
+ public static String getCallNumberByNoteId(ContentResolver resolver, long noteId) {
+ Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI,
+ new String [] { CallNote.PHONE_NUMBER },
+ CallNote.NOTE_ID + "=? AND " + CallNote.MIME_TYPE + "=?",
+ new String [] { String.valueOf(noteId), CallNote.CONTENT_ITEM_TYPE },
+ null);
+
+ if (cursor != null && cursor.moveToFirst()) {
+ try {
+ return cursor.getString(0);
+ } catch (IndexOutOfBoundsException e) {
+ Log.e(TAG, "Get call number fails " + e.toString());
+ } finally {
+ cursor.close();
+ }
+ }
+ return "";
+ }
+
+ public static long getNoteIdByPhoneNumberAndCallDate(ContentResolver resolver, String phoneNumber, long callDate) {
+ Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI,
+ new String [] { CallNote.NOTE_ID },
+ CallNote.CALL_DATE + "=? AND " + CallNote.MIME_TYPE + "=? AND PHONE_NUMBERS_EQUAL("
+ + CallNote.PHONE_NUMBER + ",?)",
+ new String [] { String.valueOf(callDate), CallNote.CONTENT_ITEM_TYPE, phoneNumber },
+ null);
+
+ if (cursor != null) {
+ if (cursor.moveToFirst()) {
+ try {
+ return cursor.getLong(0);
+ } catch (IndexOutOfBoundsException e) {
+ Log.e(TAG, "Get call note id fails " + e.toString());
+ }
+ }
+ cursor.close();
+ }
+ return 0;
+ }
+
+ public static String getSnippetById(ContentResolver resolver, long noteId) {
+ Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI,
+ new String [] { NoteColumns.SNIPPET },
+ NoteColumns.ID + "=?",
+ new String [] { String.valueOf(noteId)},
+ null);
+
+ if (cursor != null) {
+ String snippet = "";
+ if (cursor.moveToFirst()) {
+ snippet = cursor.getString(0);
+ }
+ cursor.close();
+ return snippet;
+ }
+ throw new IllegalArgumentException("Note is not found with id: " + noteId);
+ }
+
+ public static String getFormattedSnippet(String snippet) {
+ if (snippet != null) {
+ snippet = snippet.trim();
+ int index = snippet.indexOf('\n');
+ if (index != -1) {
+ snippet = snippet.substring(0, index);
+ }
+ }
+ return snippet;
+ }
+}
diff --git a/src/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java b/src/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java
index 3e6173b..eff5e69 100644
--- a/src/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java
+++ b/src/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java
@@ -1,4 +1,7 @@
+<<<<<<< HEAD
+=======
+>>>>>>> origin/Branch_liujie
/*
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
*
diff --git a/src/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java.orig b/src/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java.orig
new file mode 100644
index 0000000..eff5e69
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java.orig
@@ -0,0 +1,162 @@
+<<<<<<< HEAD
+
+=======
+>>>>>>> origin/Branch_liujie
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.ui;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.content.DialogInterface.OnDismissListener;
+import android.content.Intent;
+import android.media.AudioManager;
+import android.media.MediaPlayer;
+import android.media.RingtoneManager;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.PowerManager;
+import android.provider.Settings;
+import android.view.Window;
+import android.view.WindowManager;
+
+import net.micode.notes.R;
+import net.micode.notes.data.Notes;
+import net.micode.notes.tool.DataUtils;
+
+import java.io.IOException;
+
+
+public class AlarmAlertActivity extends Activity implements OnClickListener, OnDismissListener {
+ private long mNoteId;
+ private String mSnippet;
+ private static final int SNIPPET_PREW_MAX_LEN = 60;
+ MediaPlayer mPlayer;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+
+ final Window win = getWindow();
+ win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
+
+ if (!isScreenOn()) {
+ win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
+ }
+
+ Intent intent = getIntent();
+
+ try {
+ mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1));
+ mSnippet = DataUtils.getSnippetById(this.getContentResolver(), mNoteId);
+ mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ? mSnippet.substring(0,
+ SNIPPET_PREW_MAX_LEN) + getResources().getString(R.string.notelist_string_info)
+ : mSnippet;
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ return;
+ }
+
+ mPlayer = new MediaPlayer();
+ if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) {
+ showActionDialog();
+ playAlarmSound();
+ } else {
+ finish();
+ }
+ }
+
+ private boolean isScreenOn() {
+ PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ return pm.isScreenOn();
+ }
+
+ private void playAlarmSound() {
+ Uri url = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM);
+
+ int silentModeStreams = Settings.System.getInt(getContentResolver(),
+ Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
+
+ if ((silentModeStreams & (1 << AudioManager.STREAM_ALARM)) != 0) {
+ mPlayer.setAudioStreamType(silentModeStreams);
+ } else {
+ mPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
+ }
+ try {
+ mPlayer.setDataSource(this, url);
+ mPlayer.prepare();
+ mPlayer.setLooping(true);
+ mPlayer.start();
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalStateException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private void showActionDialog() {
+ AlertDialog.Builder dialog = new AlertDialog.Builder(this);
+ dialog.setTitle(R.string.app_name);
+ dialog.setMessage(mSnippet);
+ dialog.setPositiveButton(R.string.notealert_ok, this);
+ if (isScreenOn()) {
+ dialog.setNegativeButton(R.string.notealert_enter, this);
+ }
+ dialog.show().setOnDismissListener(this);
+ }
+
+ public void onClick(DialogInterface dialog, int which) {
+ switch (which) {
+ case DialogInterface.BUTTON_NEGATIVE:
+ Intent intent = new Intent(this, NoteEditActivity.class);
+ intent.setAction(Intent.ACTION_VIEW);
+ intent.putExtra(Intent.EXTRA_UID, mNoteId);
+ startActivity(intent);
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void onDismiss(DialogInterface dialog) {
+ stopAlarmSound();
+ finish();
+ }
+
+ private void stopAlarmSound() {
+ if (mPlayer != null) {
+ mPlayer.stop();
+ mPlayer.release();
+ mPlayer = null;
+ }
+ }
+}
diff --git a/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java b/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
index 14ee596..14447b8 100644
--- a/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
+++ b/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
@@ -16,6 +16,7 @@
package net.micode.notes.ui;
+<<<<<<< HEAD
import android.Manifest;
import android.app.Activity;
import android.content.ContentResolver;
@@ -43,6 +44,13 @@ import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.app.AlarmManager;
import android.app.AlertDialog;
+=======
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.app.AlarmManager;
+import android.app.AlertDialog;
+import android.app.Dialog;
+>>>>>>> origin/Branch_liujie
import android.app.PendingIntent;
import android.app.SearchManager;
import android.appwidget.AppWidgetManager;
@@ -52,6 +60,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Paint;
+<<<<<<< HEAD
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.telecom.Call;
@@ -63,6 +72,16 @@ import android.text.TextWatcher;
import android.text.format.DateUtils;
import android.text.style.BackgroundColorSpan;
import android.text.style.ImageSpan;
+=======
+import android.os.Build;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.TextUtils;
+import android.text.format.DateUtils;
+import android.text.style.BackgroundColorSpan;
+>>>>>>> origin/Branch_liujie
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -71,12 +90,19 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
+<<<<<<< HEAD
import android.widget.Button;
+=======
+import android.view.inputmethod.InputMethodManager;
+>>>>>>> origin/Branch_liujie
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
+<<<<<<< HEAD
import android.widget.ImageButton;
+=======
+>>>>>>> origin/Branch_liujie
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -92,6 +118,7 @@ import net.micode.notes.tool.ResourceParser;
import net.micode.notes.tool.ResourceParser.TextAppearanceResources;
import net.micode.notes.ui.DateTimePickerDialog.OnDateTimeSetListener;
import net.micode.notes.ui.NoteEditText.OnTextViewChangeListener;
+<<<<<<< HEAD
import net.micode.notes.ui.translate_demo.RespondBean;
import net.micode.notes.widget.NoteWidgetProvider_2x;
import net.micode.notes.widget.NoteWidgetProvider_4x;
@@ -102,10 +129,18 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
+=======
+import net.micode.notes.widget.NoteWidgetProvider_2x;
+import net.micode.notes.widget.NoteWidgetProvider_4x;
+
+import java.util.HashMap;
+import java.util.HashSet;
+>>>>>>> origin/Branch_liujie
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+<<<<<<< HEAD
import net.micode.notes.ui.translate_demo.MD5Utils;
import net.micode.notes.ui.translate_demo.BaiduTranslateService;
@@ -122,13 +157,21 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class NoteEditActivity<关闭> extends AppCompatActivity implements OnClickListener,
NoteSettingChangedListener, OnTextViewChangeListener {
+=======
+
+public class NoteEditActivity extends Activity implements OnClickListener,
+ NoteSettingChangedListener, OnTextViewChangeListener {
+>>>>>>> origin/Branch_liujie
private class HeadViewHolder {
public TextView tvModified;
public ImageView ivAlertIcon;
+<<<<<<< HEAD
public TextView tvToptext;
+=======
+>>>>>>> origin/Branch_liujie
public TextView tvAlertDate;
public ImageView ibSetBgColor;
@@ -187,8 +230,11 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
private SharedPreferences mSharedPrefs;
private int mFontSizeId;
+<<<<<<< HEAD
+=======
+>>>>>>> origin/Branch_liujie
private static final String PREFERENCE_FONT_SIZE = "pref_font_size";
private static final int SHORTCUT_ICON_TITLE_MAX_LEN = 10;
@@ -196,6 +242,7 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
public static final String TAG_CHECKED = String.valueOf('\u221A');
public static final String TAG_UNCHECKED = String.valueOf('\u25A1');
+<<<<<<< HEAD
public static final int TAKE_PHOTO = 1;
public static final int CHOOSE_PHOTO = 2;
private final int PHOTO_SUCCESS = 3;
@@ -212,6 +259,8 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
+=======
+>>>>>>> origin/Branch_liujie
private LinearLayout mEditTextList;
private String mUserQuery;
@@ -227,6 +276,7 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
return;
}
initResources();
+<<<<<<< HEAD
final ImageButton add_img_btn = (ImageButton) findViewById(R.id.add_img_btn);
@@ -247,6 +297,10 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
+=======
+ }
+
+>>>>>>> origin/Branch_liujie
/**
* Current activity may be killed when the memory is low. Once it is killed, for another time
* user load this activity, we should restore the former state
@@ -379,8 +433,47 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
* is not ready
*/
showAlertHeader();
+<<<<<<< HEAD
convertToImage();
showTopHeader();
+=======
+ //密码验证
+ final String mPassword = mWorkingNote.getmPassword();//读取数据库中的密码
+ if (mPassword!=null) {
+ //创建dialog,插入edittext,用户输入密码并做出检验。
+ final AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
+ //编辑Text
+ final EditText etName = (EditText) view.findViewById(R.id.et_foler_name);
+ etName.setText("");
+ etName.setHint("请输入密码");
+ builder.setTitle("密码");
+ builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ //获取输入的字符串
+ String password = etName.getText().toString();
+ Log.d("mPassword: ", mPassword);
+ Log.d("password: ", password);
+ //判断密码正确性
+ if (!password.equals(mPassword)) {
+ Log.d("密码不正确,正确密码是:",mPassword);
+ dialog.dismiss();
+ onBackPressed();
+ }
+ }
+ });
+ builder.setNegativeButton("cancel", new DialogInterface.OnClickListener(){
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ onBackPressed();
+ }
+ });
+ final Dialog dialog = builder.setView(view).show();
+ dialog.show();
+ }
+>>>>>>> origin/Branch_liujie
}
private void showAlertHeader() {
@@ -397,6 +490,7 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
} else {
mNoteHeaderHolder.tvAlertDate.setVisibility(View.GONE);
mNoteHeaderHolder.ivAlertIcon.setVisibility(View.GONE);
+<<<<<<< HEAD
}
}
@@ -407,6 +501,9 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
} else{
mNoteHeaderHolder.tvToptext.setVisibility(View.GONE);
}
+=======
+ };
+>>>>>>> origin/Branch_liujie
}
@Override
@@ -455,8 +552,13 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
|| ev.getX() > (x + view.getWidth())
|| ev.getY() < y
|| ev.getY() > (y + view.getHeight())) {
+<<<<<<< HEAD
return false;
}
+=======
+ return false;
+ }
+>>>>>>> origin/Branch_liujie
return true;
}
@@ -466,7 +568,10 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
mNoteHeaderHolder.tvModified = (TextView) findViewById(R.id.tv_modified_date);
mNoteHeaderHolder.ivAlertIcon = (ImageView) findViewById(R.id.iv_alert_icon);
mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date);
+<<<<<<< HEAD
mNoteHeaderHolder.tvToptext = (TextView) findViewById(R.id.tv_set_top);
+=======
+>>>>>>> origin/Branch_liujie
mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color);
mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this);
mNoteEditor = (EditText) findViewById(R.id.note_edit_view);
@@ -486,18 +591,26 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
mFontSizeId = mSharedPrefs.getInt(PREFERENCE_FONT_SIZE, ResourceParser.BG_DEFAULT_FONT_SIZE);
/**
* HACKME: Fix bug of store the resource id in shared preference.
+<<<<<<< HEAD
* * The id may larger than the length of resources, in this case,
* * return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE}
+=======
+ * The id may larger than the length of resources, in this case,
+ * return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE}
+>>>>>>> origin/Branch_liujie
*/
if(mFontSizeId >= TextAppearanceResources.getResourcesSize()) {
mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE;
}
mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list);
+<<<<<<< HEAD
speech_sum();
local_sel();
translate();
+=======
+>>>>>>> origin/Branch_liujie
}
@Override
@@ -507,11 +620,16 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
Log.d(TAG, "Note data was saved with length:" + mWorkingNote.getContent().length());
}
clearSettingState();
+<<<<<<< HEAD
}
+=======
+ }
+
+>>>>>>> origin/Branch_liujie
private void updateWidget() {
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_2X) {
@@ -524,7 +642,11 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
}
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] {
+<<<<<<< HEAD
mWorkingNote.getWidgetId()
+=======
+ mWorkingNote.getWidgetId()
+>>>>>>> origin/Branch_liujie
});
sendBroadcast(intent);
@@ -536,7 +658,11 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
if (id == R.id.btn_set_bg_color) {
mNoteBgColorSelector.setVisibility(View.VISIBLE);
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
+<<<<<<< HEAD
View.VISIBLE);
+=======
+ - View.VISIBLE);
+>>>>>>> origin/Branch_liujie
} else if (sBgSelectorBtnsMap.containsKey(id)) {
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.GONE);
@@ -556,6 +682,49 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
}
mFontSizeSelector.setVisibility(View.GONE);
}
+<<<<<<< HEAD
+=======
+ //添加设置密码的点击
+ if (id==R.id.m_locker){
+ final AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ final View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text,null);
+ //编辑Text
+ final EditText etName = (EditText)view.findViewById(R.id.et_foler_name);
+ etName.setText("");
+ etName.setHint("请输入密码");
+ builder.setTitle("为便签设置新密码");
+ builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
+ @TargetApi(Build.VERSION_CODES.CUPCAKE)
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ //获取输入的字符串
+ String password = etName.getText().toString();
+ //设置密码
+ mWorkingNote.setPassword(password);
+ //设置密码成功提示
+ Toast.makeText(NoteEditActivity.this, "密码设置成功", Toast.LENGTH_SHORT).show();
+ //关闭软键盘
+ InputMethodManager inputMethodManager = (InputMethodManager)
+ getSystemService(Context.INPUT_METHOD_SERVICE);
+ inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
+ //关闭dialog
+ dialog.dismiss();
+ }
+ });
+ builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
+ @TargetApi(Build.VERSION_CODES.CUPCAKE)
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ //关闭软键盘
+ InputMethodManager inputMethodManager = (InputMethodManager)
+ getSystemService(Context.INPUT_METHOD_SERVICE);
+ inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
+ }
+ });
+ final Dialog dialog = builder.setView(view).show();
+ dialog.show();
+ }
+>>>>>>> origin/Branch_liujie
}
@Override
@@ -598,11 +767,14 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
} else {
getMenuInflater().inflate(R.menu.note_edit, menu);
}
+<<<<<<< HEAD
if (mWorkingNote.getTopId() == 1 ) {
menu.findItem(R.id.menu_set_top).setVisible(false);
} else if(mWorkingNote.getTopId() == 0){
menu.findItem(R.id.menu_cancel_top).setVisible(false);
}
+=======
+>>>>>>> origin/Branch_liujie
if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
menu.findItem(R.id.menu_list_mode).setTitle(R.string.menu_normal_mode);
} else {
@@ -622,11 +794,28 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
case R.id.menu_new_note:
createNewNote();
break;
+<<<<<<< HEAD
case R.id.menu_set_top:
mWorkingNote.setTop((mWorkingNote.getTopId())==1 ? "0" : "1");
break;
case R.id.menu_cancel_top:
mWorkingNote.setTop((mWorkingNote.getTopId())==0 ? "1" : "0");
+=======
+ case R.id.menu_count_word://数字统计
+ AlertDialog.Builder builder1 = new AlertDialog.Builder(this);//对话框对象
+ builder1.setIcon(android.R.drawable.ic_dialog_alert);//对话框图标
+ TextView content=(TextView)findViewById(R.id.note_edit_view);
+ int c =content.length();
+ builder1.setMessage("字数统计为:"+ c);
+ builder1.setPositiveButton(android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ finish();
+ }
+ });//确定按钮
+ builder1.setNegativeButton(android.R.string.cancel, null);//取消按钮
+ builder1.show();//对话框启动
+>>>>>>> origin/Branch_liujie
break;
case R.id.menu_delete:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
@@ -664,9 +853,12 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
case R.id.menu_delete_remind:
mWorkingNote.setAlertDate(0, false);
break;
+<<<<<<< HEAD
case R.id.menu_font_select:
showSingleAlertDiglog();
break;
+=======
+>>>>>>> origin/Branch_liujie
default:
break;
}
@@ -732,6 +924,7 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
}
+<<<<<<< HEAD
public void onTopChanged(String Top){
/**
* User could set clock to an unsaved note, so before setting the
@@ -752,6 +945,8 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
}
+=======
+>>>>>>> origin/Branch_liujie
public void onClockAlertChanged(long date, boolean set) {
/**
* User could set clock to an unsaved note, so before setting the
@@ -1010,6 +1205,7 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
private void showToast(int resId, int duration) {
Toast.makeText(this, resId, duration).show();
}
+<<<<<<< HEAD
@@ -1615,3 +1811,6 @@ public class NoteEditActivity<关闭> extends AppCompatActivity implements OnCli
}
+=======
+}
+>>>>>>> origin/Branch_liujie
diff --git a/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java.orig b/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java.orig
new file mode 100644
index 0000000..14447b8
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java.orig
@@ -0,0 +1,1816 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.ui;
+
+<<<<<<< HEAD
+import android.Manifest;
+import android.app.Activity;
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.pm.PackageManager;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Typeface;
+import android.location.Address;
+import android.location.Geocoder;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.net.Uri;
+import android.os.Build;
+import android.provider.DocumentsContract;
+import android.provider.MediaStore;
+import android.speech.tts.TextToSpeech;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.RequiresApi;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
+import android.support.v7.app.AppCompatActivity;
+import android.app.AlarmManager;
+import android.app.AlertDialog;
+=======
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.app.AlarmManager;
+import android.app.AlertDialog;
+import android.app.Dialog;
+>>>>>>> origin/Branch_liujie
+import android.app.PendingIntent;
+import android.app.SearchManager;
+import android.appwidget.AppWidgetManager;
+import android.content.ContentUris;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.graphics.Paint;
+<<<<<<< HEAD
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.telecom.Call;
+import android.text.Editable;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.text.format.DateUtils;
+import android.text.style.BackgroundColorSpan;
+import android.text.style.ImageSpan;
+=======
+import android.os.Build;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.TextUtils;
+import android.text.format.DateUtils;
+import android.text.style.BackgroundColorSpan;
+>>>>>>> origin/Branch_liujie
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.WindowManager;
+<<<<<<< HEAD
+import android.widget.Button;
+=======
+import android.view.inputmethod.InputMethodManager;
+>>>>>>> origin/Branch_liujie
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.EditText;
+<<<<<<< HEAD
+import android.widget.ImageButton;
+=======
+>>>>>>> origin/Branch_liujie
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import net.micode.notes.R;
+import net.micode.notes.data.Notes;
+import net.micode.notes.data.Notes.TextNote;
+import net.micode.notes.model.WorkingNote;
+import net.micode.notes.model.WorkingNote.NoteSettingChangedListener;
+import net.micode.notes.tool.DataUtils;
+import net.micode.notes.tool.ResourceParser;
+import net.micode.notes.tool.ResourceParser.TextAppearanceResources;
+import net.micode.notes.ui.DateTimePickerDialog.OnDateTimeSetListener;
+import net.micode.notes.ui.NoteEditText.OnTextViewChangeListener;
+<<<<<<< HEAD
+import net.micode.notes.ui.translate_demo.RespondBean;
+import net.micode.notes.widget.NoteWidgetProvider_2x;
+import net.micode.notes.widget.NoteWidgetProvider_4x;
+
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+=======
+import net.micode.notes.widget.NoteWidgetProvider_2x;
+import net.micode.notes.widget.NoteWidgetProvider_4x;
+
+import java.util.HashMap;
+import java.util.HashSet;
+>>>>>>> origin/Branch_liujie
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+<<<<<<< HEAD
+import net.micode.notes.ui.translate_demo.MD5Utils;
+import net.micode.notes.ui.translate_demo.BaiduTranslateService;
+
+import retrofit2.Callback;
+import retrofit2.Response;
+import retrofit2.Retrofit;
+
+import retrofit2.converter.gson.GsonConverterFactory;
+
+
+
+
+
+public class NoteEditActivity<关闭> extends AppCompatActivity implements OnClickListener,
+ NoteSettingChangedListener, OnTextViewChangeListener {
+
+=======
+
+public class NoteEditActivity extends Activity implements OnClickListener,
+ NoteSettingChangedListener, OnTextViewChangeListener {
+>>>>>>> origin/Branch_liujie
+ private class HeadViewHolder {
+ public TextView tvModified;
+
+ public ImageView ivAlertIcon;
+
+<<<<<<< HEAD
+ public TextView tvToptext;
+
+=======
+>>>>>>> origin/Branch_liujie
+ public TextView tvAlertDate;
+
+ public ImageView ibSetBgColor;
+ }
+
+ private static final Map sBgSelectorBtnsMap = new HashMap();
+ static {
+ sBgSelectorBtnsMap.put(R.id.iv_bg_yellow, ResourceParser.YELLOW);
+ sBgSelectorBtnsMap.put(R.id.iv_bg_red, ResourceParser.RED);
+ sBgSelectorBtnsMap.put(R.id.iv_bg_blue, ResourceParser.BLUE);
+ sBgSelectorBtnsMap.put(R.id.iv_bg_green, ResourceParser.GREEN);
+ sBgSelectorBtnsMap.put(R.id.iv_bg_white, ResourceParser.WHITE);
+ }
+
+ private static final Map sBgSelectorSelectionMap = new HashMap();
+ static {
+ sBgSelectorSelectionMap.put(ResourceParser.YELLOW, R.id.iv_bg_yellow_select);
+ sBgSelectorSelectionMap.put(ResourceParser.RED, R.id.iv_bg_red_select);
+ sBgSelectorSelectionMap.put(ResourceParser.BLUE, R.id.iv_bg_blue_select);
+ sBgSelectorSelectionMap.put(ResourceParser.GREEN, R.id.iv_bg_green_select);
+ sBgSelectorSelectionMap.put(ResourceParser.WHITE, R.id.iv_bg_white_select);
+ }
+
+ private static final Map sFontSizeBtnsMap = new HashMap();
+ static {
+ sFontSizeBtnsMap.put(R.id.ll_font_large, ResourceParser.TEXT_LARGE);
+ sFontSizeBtnsMap.put(R.id.ll_font_small, ResourceParser.TEXT_SMALL);
+ sFontSizeBtnsMap.put(R.id.ll_font_normal, ResourceParser.TEXT_MEDIUM);
+ sFontSizeBtnsMap.put(R.id.ll_font_super, ResourceParser.TEXT_SUPER);
+ }
+
+ private static final Map sFontSelectorSelectionMap = new HashMap();
+ static {
+ sFontSelectorSelectionMap.put(ResourceParser.TEXT_LARGE, R.id.iv_large_select);
+ sFontSelectorSelectionMap.put(ResourceParser.TEXT_SMALL, R.id.iv_small_select);
+ sFontSelectorSelectionMap.put(ResourceParser.TEXT_MEDIUM, R.id.iv_medium_select);
+ sFontSelectorSelectionMap.put(ResourceParser.TEXT_SUPER, R.id.iv_super_select);
+ }
+
+ private static final String TAG = "NoteEditActivity";
+
+ private HeadViewHolder mNoteHeaderHolder;
+
+ private View mHeadViewPanel;
+
+ private View mNoteBgColorSelector;
+
+ private View mFontSizeSelector;
+
+ private EditText mNoteEditor;
+
+ private View mNoteEditorPanel;
+
+ private WorkingNote mWorkingNote;
+
+ private SharedPreferences mSharedPrefs;
+ private int mFontSizeId;
+
+<<<<<<< HEAD
+
+
+=======
+>>>>>>> origin/Branch_liujie
+ private static final String PREFERENCE_FONT_SIZE = "pref_font_size";
+
+ private static final int SHORTCUT_ICON_TITLE_MAX_LEN = 10;
+
+ public static final String TAG_CHECKED = String.valueOf('\u221A');
+ public static final String TAG_UNCHECKED = String.valueOf('\u25A1');
+
+<<<<<<< HEAD
+ public static final int TAKE_PHOTO = 1;
+ public static final int CHOOSE_PHOTO = 2;
+ private final int PHOTO_SUCCESS = 3;
+ private final int CAMERA_SUCCESS = 4;
+// TextToSpeech tts;
+ TextView num_word;
+ TextView location;
+ public static final int LOCATION_CODE = 301;
+ private LocationManager locationManager;
+ private String locationProvider = null;
+ private final int PHOTO_REQUEST = 1;
+ private AlertDialog alertDialog2;
+ private CharSequence restore_translate = null;
+
+
+
+=======
+>>>>>>> origin/Branch_liujie
+ private LinearLayout mEditTextList;
+
+ private String mUserQuery;
+ private Pattern mPattern;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ this.setContentView(R.layout.note_edit);
+
+ if (savedInstanceState == null && !initActivityState(getIntent())) {
+ finish();
+ return;
+ }
+ initResources();
+<<<<<<< HEAD
+
+
+ final ImageButton add_img_btn = (ImageButton) findViewById(R.id.add_img_btn);
+ add_img_btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Log.d(TAG, "onClick: click add image button");
+ Intent loadImage = new Intent(Intent.ACTION_GET_CONTENT);
+ loadImage.addCategory(Intent.CATEGORY_OPENABLE);
+ loadImage.setType("image/*");
+ startActivityForResult(loadImage, PHOTO_REQUEST);
+ }
+ });
+
+ }
+
+
+
+
+
+=======
+ }
+
+>>>>>>> origin/Branch_liujie
+ /**
+ * Current activity may be killed when the memory is low. Once it is killed, for another time
+ * user load this activity, we should restore the former state
+ */
+ @Override
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ if (savedInstanceState != null && savedInstanceState.containsKey(Intent.EXTRA_UID)) {
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.putExtra(Intent.EXTRA_UID, savedInstanceState.getLong(Intent.EXTRA_UID));
+ if (!initActivityState(intent)) {
+ finish();
+ return;
+ }
+ Log.d(TAG, "Restoring from killed activity");
+ }
+ }
+
+ private boolean initActivityState(Intent intent) {
+ /**
+ * If the user specified the {@link Intent#ACTION_VIEW} but not provided with id,
+ * then jump to the NotesListActivity
+ */
+ mWorkingNote = null;
+ if (TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())) {
+ long noteId = intent.getLongExtra(Intent.EXTRA_UID, 0);
+ mUserQuery = "";
+
+ /**
+ * Starting from the searched result
+ */
+ if (intent.hasExtra(SearchManager.EXTRA_DATA_KEY)) {
+ noteId = Long.parseLong(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
+ mUserQuery = intent.getStringExtra(SearchManager.USER_QUERY);
+ }
+
+ if (!DataUtils.visibleInNoteDatabase(getContentResolver(), noteId, Notes.TYPE_NOTE)) {
+ Intent jump = new Intent(this, NotesListActivity.class);
+ startActivity(jump);
+ showToast(R.string.error_note_not_exist);
+ finish();
+ return false;
+ } else {
+ mWorkingNote = WorkingNote.load(this, noteId);
+ if (mWorkingNote == null) {
+ Log.e(TAG, "load note failed with note id" + noteId);
+ finish();
+ return false;
+ }
+ }
+ getWindow().setSoftInputMode(
+ WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
+ | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
+ } else if(TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) {
+ // New note
+ long folderId = intent.getLongExtra(Notes.INTENT_EXTRA_FOLDER_ID, 0);
+ int widgetId = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_ID,
+ AppWidgetManager.INVALID_APPWIDGET_ID);
+ int widgetType = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_TYPE,
+ Notes.TYPE_WIDGET_INVALIDE);
+ int bgResId = intent.getIntExtra(Notes.INTENT_EXTRA_BACKGROUND_ID,
+ ResourceParser.getDefaultBgId(this));
+
+ // Parse call-record note
+ String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
+ long callDate = intent.getLongExtra(Notes.INTENT_EXTRA_CALL_DATE, 0);
+ if (callDate != 0 && phoneNumber != null) {
+ if (TextUtils.isEmpty(phoneNumber)) {
+ Log.w(TAG, "The call record number is null");
+ }
+ long noteId = 0;
+ if ((noteId = DataUtils.getNoteIdByPhoneNumberAndCallDate(getContentResolver(),
+ phoneNumber, callDate)) > 0) {
+ mWorkingNote = WorkingNote.load(this, noteId);
+ if (mWorkingNote == null) {
+ Log.e(TAG, "load call note failed with note id" + noteId);
+ finish();
+ return false;
+ }
+ } else {
+ mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId,
+ widgetType, bgResId);
+ mWorkingNote.convertToCallNote(phoneNumber, callDate);
+ }
+ } else {
+ mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType,
+ bgResId);
+ }
+
+ getWindow().setSoftInputMode(
+ WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
+ | WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
+ } else {
+ Log.e(TAG, "Intent not specified action, should not support");
+ finish();
+ return false;
+ }
+ mWorkingNote.setOnSettingStatusChangedListener(this);
+ return true;
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ initNoteScreen();
+ }
+
+ private void initNoteScreen() {
+ mNoteEditor.setTextAppearance(this, TextAppearanceResources
+ .getTexAppearanceResource(mFontSizeId));
+ if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
+ switchToListMode(mWorkingNote.getContent());
+ } else {
+ mNoteEditor.setText(getHighlightQueryResult(mWorkingNote.getContent(), mUserQuery));
+ mNoteEditor.setSelection(mNoteEditor.getText().length());
+ }
+ for (Integer id : sBgSelectorSelectionMap.keySet()) {
+ findViewById(sBgSelectorSelectionMap.get(id)).setVisibility(View.GONE);
+ }
+ mHeadViewPanel.setBackgroundResource(mWorkingNote.getTitleBgResId());
+ mNoteEditorPanel.setBackgroundResource(mWorkingNote.getBgColorResId());
+
+ mNoteHeaderHolder.tvModified.setText(DateUtils.formatDateTime(this,
+ mWorkingNote.getModifiedDate(), DateUtils.FORMAT_SHOW_DATE
+ | DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME
+ | DateUtils.FORMAT_SHOW_YEAR));
+
+ /**
+ * TODO: Add the menu for setting alert. Currently disable it because the DateTimePicker
+ * is not ready
+ */
+ showAlertHeader();
+<<<<<<< HEAD
+ convertToImage();
+ showTopHeader();
+=======
+ //密码验证
+ final String mPassword = mWorkingNote.getmPassword();//读取数据库中的密码
+ if (mPassword!=null) {
+ //创建dialog,插入edittext,用户输入密码并做出检验。
+ final AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
+ //编辑Text
+ final EditText etName = (EditText) view.findViewById(R.id.et_foler_name);
+ etName.setText("");
+ etName.setHint("请输入密码");
+ builder.setTitle("密码");
+ builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ //获取输入的字符串
+ String password = etName.getText().toString();
+ Log.d("mPassword: ", mPassword);
+ Log.d("password: ", password);
+ //判断密码正确性
+ if (!password.equals(mPassword)) {
+ Log.d("密码不正确,正确密码是:",mPassword);
+ dialog.dismiss();
+ onBackPressed();
+ }
+ }
+ });
+ builder.setNegativeButton("cancel", new DialogInterface.OnClickListener(){
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ onBackPressed();
+ }
+ });
+ final Dialog dialog = builder.setView(view).show();
+ dialog.show();
+ }
+>>>>>>> origin/Branch_liujie
+ }
+
+ private void showAlertHeader() {
+ if (mWorkingNote.hasClockAlert()) {
+ long time = System.currentTimeMillis();
+ if (time > mWorkingNote.getAlertDate()) {
+ mNoteHeaderHolder.tvAlertDate.setText(R.string.note_alert_expired);
+ } else {
+ mNoteHeaderHolder.tvAlertDate.setText(DateUtils.getRelativeTimeSpanString(
+ mWorkingNote.getAlertDate(), time, DateUtils.MINUTE_IN_MILLIS));
+ }
+ mNoteHeaderHolder.tvAlertDate.setVisibility(View.VISIBLE);
+ mNoteHeaderHolder.ivAlertIcon.setVisibility(View.VISIBLE);
+ } else {
+ mNoteHeaderHolder.tvAlertDate.setVisibility(View.GONE);
+ mNoteHeaderHolder.ivAlertIcon.setVisibility(View.GONE);
+<<<<<<< HEAD
+ }
+ }
+
+ private void showTopHeader(){
+ mNoteHeaderHolder.tvToptext.setText(R.string.menu_set_top);
+ if(mWorkingNote.getTopId()==1){
+ mNoteHeaderHolder.tvToptext.setVisibility(View.VISIBLE);
+ } else{
+ mNoteHeaderHolder.tvToptext.setVisibility(View.GONE);
+ }
+=======
+ };
+>>>>>>> origin/Branch_liujie
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ initActivityState(intent);
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ /**
+ * For new note without note id, we should firstly save it to
+ * generate a id. If the editing note is not worth saving, there
+ * is no id which is equivalent to create new note
+ */
+ if (!mWorkingNote.existInDatabase()) {
+ saveNote();
+ }
+ outState.putLong(Intent.EXTRA_UID, mWorkingNote.getNoteId());
+ Log.d(TAG, "Save working note id: " + mWorkingNote.getNoteId() + " onSaveInstanceState");
+ }
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent ev) {
+ if (mNoteBgColorSelector.getVisibility() == View.VISIBLE
+ && !inRangeOfView(mNoteBgColorSelector, ev)) {
+ mNoteBgColorSelector.setVisibility(View.GONE);
+ return true;
+ }
+
+ if (mFontSizeSelector.getVisibility() == View.VISIBLE
+ && !inRangeOfView(mFontSizeSelector, ev)) {
+ mFontSizeSelector.setVisibility(View.GONE);
+ return true;
+ }
+ return super.dispatchTouchEvent(ev);
+ }
+
+ private boolean inRangeOfView(View view, MotionEvent ev) {
+ int []location = new int[2];
+ view.getLocationOnScreen(location);
+ int x = location[0];
+ int y = location[1];
+ if (ev.getX() < x
+ || ev.getX() > (x + view.getWidth())
+ || ev.getY() < y
+ || ev.getY() > (y + view.getHeight())) {
+<<<<<<< HEAD
+ return false;
+ }
+=======
+ return false;
+ }
+>>>>>>> origin/Branch_liujie
+ return true;
+ }
+
+ private void initResources() {
+ mHeadViewPanel = findViewById(R.id.note_title);
+ mNoteHeaderHolder = new HeadViewHolder();
+ mNoteHeaderHolder.tvModified = (TextView) findViewById(R.id.tv_modified_date);
+ mNoteHeaderHolder.ivAlertIcon = (ImageView) findViewById(R.id.iv_alert_icon);
+ mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date);
+<<<<<<< HEAD
+ mNoteHeaderHolder.tvToptext = (TextView) findViewById(R.id.tv_set_top);
+=======
+>>>>>>> origin/Branch_liujie
+ mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color);
+ mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this);
+ mNoteEditor = (EditText) findViewById(R.id.note_edit_view);
+ mNoteEditorPanel = findViewById(R.id.sv_note_edit);
+ mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector);
+ for (int id : sBgSelectorBtnsMap.keySet()) {
+ ImageView iv = (ImageView) findViewById(id);
+ iv.setOnClickListener(this);
+ }
+
+ mFontSizeSelector = findViewById(R.id.font_size_selector);
+ for (int id : sFontSizeBtnsMap.keySet()) {
+ View view = findViewById(id);
+ view.setOnClickListener(this);
+ };
+ mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ mFontSizeId = mSharedPrefs.getInt(PREFERENCE_FONT_SIZE, ResourceParser.BG_DEFAULT_FONT_SIZE);
+ /**
+ * HACKME: Fix bug of store the resource id in shared preference.
+<<<<<<< HEAD
+ * * The id may larger than the length of resources, in this case,
+ * * return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE}
+=======
+ * The id may larger than the length of resources, in this case,
+ * return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE}
+>>>>>>> origin/Branch_liujie
+ */
+ if(mFontSizeId >= TextAppearanceResources.getResourcesSize()) {
+ mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE;
+ }
+ mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list);
+<<<<<<< HEAD
+
+
+ speech_sum();
+ local_sel();
+ translate();
+=======
+>>>>>>> origin/Branch_liujie
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ if(saveNote()) {
+ Log.d(TAG, "Note data was saved with length:" + mWorkingNote.getContent().length());
+ }
+ clearSettingState();
+<<<<<<< HEAD
+
+ }
+
+
+
+=======
+ }
+
+>>>>>>> origin/Branch_liujie
+ private void updateWidget() {
+ Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
+ if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_2X) {
+ intent.setClass(this, NoteWidgetProvider_2x.class);
+ } else if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_4X) {
+ intent.setClass(this, NoteWidgetProvider_4x.class);
+ } else {
+ Log.e(TAG, "Unspported widget type");
+ return;
+ }
+
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] {
+<<<<<<< HEAD
+ mWorkingNote.getWidgetId()
+=======
+ mWorkingNote.getWidgetId()
+>>>>>>> origin/Branch_liujie
+ });
+
+ sendBroadcast(intent);
+ setResult(RESULT_OK, intent);
+ }
+
+ public void onClick(View v) {
+ int id = v.getId();
+ if (id == R.id.btn_set_bg_color) {
+ mNoteBgColorSelector.setVisibility(View.VISIBLE);
+ findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
+<<<<<<< HEAD
+ View.VISIBLE);
+=======
+ - View.VISIBLE);
+>>>>>>> origin/Branch_liujie
+ } else if (sBgSelectorBtnsMap.containsKey(id)) {
+ findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
+ View.GONE);
+ mWorkingNote.setBgColorId(sBgSelectorBtnsMap.get(id));
+ mNoteBgColorSelector.setVisibility(View.GONE);
+ } else if (sFontSizeBtnsMap.containsKey(id)) {
+ findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.GONE);
+ mFontSizeId = sFontSizeBtnsMap.get(id);
+ mSharedPrefs.edit().putInt(PREFERENCE_FONT_SIZE, mFontSizeId).commit();
+ findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE);
+ if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
+ getWorkingText();
+ switchToListMode(mWorkingNote.getContent());
+ } else {
+ mNoteEditor.setTextAppearance(this,
+ TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
+ }
+ mFontSizeSelector.setVisibility(View.GONE);
+ }
+<<<<<<< HEAD
+=======
+ //添加设置密码的点击
+ if (id==R.id.m_locker){
+ final AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ final View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text,null);
+ //编辑Text
+ final EditText etName = (EditText)view.findViewById(R.id.et_foler_name);
+ etName.setText("");
+ etName.setHint("请输入密码");
+ builder.setTitle("为便签设置新密码");
+ builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
+ @TargetApi(Build.VERSION_CODES.CUPCAKE)
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ //获取输入的字符串
+ String password = etName.getText().toString();
+ //设置密码
+ mWorkingNote.setPassword(password);
+ //设置密码成功提示
+ Toast.makeText(NoteEditActivity.this, "密码设置成功", Toast.LENGTH_SHORT).show();
+ //关闭软键盘
+ InputMethodManager inputMethodManager = (InputMethodManager)
+ getSystemService(Context.INPUT_METHOD_SERVICE);
+ inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
+ //关闭dialog
+ dialog.dismiss();
+ }
+ });
+ builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
+ @TargetApi(Build.VERSION_CODES.CUPCAKE)
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ //关闭软键盘
+ InputMethodManager inputMethodManager = (InputMethodManager)
+ getSystemService(Context.INPUT_METHOD_SERVICE);
+ inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
+ }
+ });
+ final Dialog dialog = builder.setView(view).show();
+ dialog.show();
+ }
+>>>>>>> origin/Branch_liujie
+ }
+
+ @Override
+ public void onBackPressed() {
+ if(clearSettingState()) {
+ return;
+ }
+
+ saveNote();
+ super.onBackPressed();
+ }
+
+ private boolean clearSettingState() {
+ if (mNoteBgColorSelector.getVisibility() == View.VISIBLE) {
+ mNoteBgColorSelector.setVisibility(View.GONE);
+ return true;
+ } else if (mFontSizeSelector.getVisibility() == View.VISIBLE) {
+ mFontSizeSelector.setVisibility(View.GONE);
+ return true;
+ }
+ return false;
+ }
+
+ public void onBackgroundColorChanged() {
+ findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
+ View.VISIBLE);
+ mNoteEditorPanel.setBackgroundResource(mWorkingNote.getBgColorResId());
+ mHeadViewPanel.setBackgroundResource(mWorkingNote.getTitleBgResId());
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ if (isFinishing()) {
+ return true;
+ }
+ clearSettingState();
+ menu.clear();
+ if (mWorkingNote.getFolderId() == Notes.ID_CALL_RECORD_FOLDER) {
+ getMenuInflater().inflate(R.menu.call_note_edit, menu);
+ } else {
+ getMenuInflater().inflate(R.menu.note_edit, menu);
+ }
+<<<<<<< HEAD
+ if (mWorkingNote.getTopId() == 1 ) {
+ menu.findItem(R.id.menu_set_top).setVisible(false);
+ } else if(mWorkingNote.getTopId() == 0){
+ menu.findItem(R.id.menu_cancel_top).setVisible(false);
+ }
+=======
+>>>>>>> origin/Branch_liujie
+ if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
+ menu.findItem(R.id.menu_list_mode).setTitle(R.string.menu_normal_mode);
+ } else {
+ menu.findItem(R.id.menu_list_mode).setTitle(R.string.menu_list_mode);
+ }
+ if (mWorkingNote.hasClockAlert()) {
+ menu.findItem(R.id.menu_alert).setVisible(false);
+ } else {
+ menu.findItem(R.id.menu_delete_remind).setVisible(false);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.menu_new_note:
+ createNewNote();
+ break;
+<<<<<<< HEAD
+ case R.id.menu_set_top:
+ mWorkingNote.setTop((mWorkingNote.getTopId())==1 ? "0" : "1");
+ break;
+ case R.id.menu_cancel_top:
+ mWorkingNote.setTop((mWorkingNote.getTopId())==0 ? "1" : "0");
+=======
+ case R.id.menu_count_word://数字统计
+ AlertDialog.Builder builder1 = new AlertDialog.Builder(this);//对话框对象
+ builder1.setIcon(android.R.drawable.ic_dialog_alert);//对话框图标
+ TextView content=(TextView)findViewById(R.id.note_edit_view);
+ int c =content.length();
+ builder1.setMessage("字数统计为:"+ c);
+ builder1.setPositiveButton(android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ finish();
+ }
+ });//确定按钮
+ builder1.setNegativeButton(android.R.string.cancel, null);//取消按钮
+ builder1.show();//对话框启动
+>>>>>>> origin/Branch_liujie
+ break;
+ case R.id.menu_delete:
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(getString(R.string.alert_title_delete));
+ builder.setIcon(android.R.drawable.ic_dialog_alert);
+ builder.setMessage(getString(R.string.alert_message_delete_note));
+ builder.setPositiveButton(android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ deleteCurrentNote();
+ finish();
+ }
+ });
+ builder.setNegativeButton(android.R.string.cancel, null);
+ builder.show();
+ break;
+ case R.id.menu_font_size:
+ mFontSizeSelector.setVisibility(View.VISIBLE);
+ findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE);
+ break;
+ case R.id.menu_list_mode:
+ mWorkingNote.setCheckListMode(mWorkingNote.getCheckListMode() == 0 ?
+ TextNote.MODE_CHECK_LIST : 0);
+ break;
+ case R.id.menu_share:
+ getWorkingText();
+ sendTo(this, mWorkingNote.getContent());
+ break;
+ case R.id.menu_send_to_desktop:
+ sendToDesktop();
+ break;
+ case R.id.menu_alert:
+ setReminder();
+ break;
+ case R.id.menu_delete_remind:
+ mWorkingNote.setAlertDate(0, false);
+ break;
+<<<<<<< HEAD
+ case R.id.menu_font_select:
+ showSingleAlertDiglog();
+ break;
+=======
+>>>>>>> origin/Branch_liujie
+ default:
+ break;
+ }
+ return true;
+ }
+
+ private void setReminder() {
+ DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis());
+ d.setOnDateTimeSetListener(new OnDateTimeSetListener() {
+ public void OnDateTimeSet(AlertDialog dialog, long date) {
+ mWorkingNote.setAlertDate(date , true);
+ }
+ });
+ d.show();
+ }
+
+ /**
+ * Share note to apps that support {@link Intent#ACTION_SEND} action
+ * and {@text/plain} type
+ */
+ private void sendTo(Context context, String info) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.putExtra(Intent.EXTRA_TEXT, info);
+ intent.setType("text/plain");
+ context.startActivity(intent);
+ }
+
+ private void createNewNote() {
+ // Firstly, save current editing notes
+ saveNote();
+
+ // For safety, start a new NoteEditActivity
+ finish();
+ Intent intent = new Intent(this, NoteEditActivity.class);
+ intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
+ intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mWorkingNote.getFolderId());
+ startActivity(intent);
+ }
+
+ private void deleteCurrentNote() {
+ if (mWorkingNote.existInDatabase()) {
+ HashSet ids = new HashSet();
+ long id = mWorkingNote.getNoteId();
+ if (id != Notes.ID_ROOT_FOLDER) {
+ ids.add(id);
+ } else {
+ Log.d(TAG, "Wrong note id, should not happen");
+ }
+ if (!isSyncMode()) {
+ if (!DataUtils.batchDeleteNotes(getContentResolver(), ids)) {
+ Log.e(TAG, "Delete Note error");
+ }
+ } else {
+ if (!DataUtils.batchMoveToFolder(getContentResolver(), ids, Notes.ID_TRASH_FOLER)) {
+ Log.e(TAG, "Move notes to trash folder error, should not happens");
+ }
+ }
+ }
+ mWorkingNote.markDeleted(true);
+ }
+
+ private boolean isSyncMode() {
+ return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
+ }
+
+<<<<<<< HEAD
+ public void onTopChanged(String Top){
+ /**
+ * User could set clock to an unsaved note, so before setting the
+ * alert clock, we should save the note first
+ */
+ saveNote();
+ if (mWorkingNote.getNoteId() > 0) {
+ showTopHeader();
+ } else {
+ /**
+ * There is the condition that user has input nothing (the note is
+ * not worthy saving), we have no note id, remind the user that he
+ * should input something
+ */
+ Log.e(TAG, "Top setting error");
+ showToast(R.string.error_note_empty_for_top);
+ }
+ }
+
+
+=======
+>>>>>>> origin/Branch_liujie
+ public void onClockAlertChanged(long date, boolean set) {
+ /**
+ * User could set clock to an unsaved note, so before setting the
+ * alert clock, we should save the note first
+ */
+ if (!mWorkingNote.existInDatabase()) {
+ saveNote();
+ }
+ if (mWorkingNote.getNoteId() > 0) {
+ Intent intent = new Intent(this, AlarmReceiver.class);
+ intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId()));
+ PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
+ AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE));
+ showAlertHeader();
+ if(!set) {
+ alarmManager.cancel(pendingIntent);
+ } else {
+ alarmManager.set(AlarmManager.RTC_WAKEUP, date, pendingIntent);
+ }
+ } else {
+ /**
+ * There is the condition that user has input nothing (the note is
+ * not worthy saving), we have no note id, remind the user that he
+ * should input something
+ */
+ Log.e(TAG, "Clock alert setting error");
+ showToast(R.string.error_note_empty_for_clock);
+ }
+ }
+
+ public void onWidgetChanged() {
+ updateWidget();
+ }
+
+ public void onEditTextDelete(int index, String text) {
+ int childCount = mEditTextList.getChildCount();
+ if (childCount == 1) {
+ return;
+ }
+
+ for (int i = index + 1; i < childCount; i++) {
+ ((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
+ .setIndex(i - 1);
+ }
+
+ mEditTextList.removeViewAt(index);
+ NoteEditText edit = null;
+ if(index == 0) {
+ edit = (NoteEditText) mEditTextList.getChildAt(0).findViewById(
+ R.id.et_edit_text);
+ } else {
+ edit = (NoteEditText) mEditTextList.getChildAt(index - 1).findViewById(
+ R.id.et_edit_text);
+ }
+ int length = edit.length();
+ edit.append(text);
+ edit.requestFocus();
+ edit.setSelection(length);
+ }
+
+ public void onEditTextEnter(int index, String text) {
+ /**
+ * Should not happen, check for debug
+ */
+ if(index > mEditTextList.getChildCount()) {
+ Log.e(TAG, "Index out of mEditTextList boundrary, should not happen");
+ }
+
+ View view = getListItem(text, index);
+ mEditTextList.addView(view, index);
+ NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
+ edit.requestFocus();
+ edit.setSelection(0);
+ for (int i = index + 1; i < mEditTextList.getChildCount(); i++) {
+ ((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
+ .setIndex(i);
+ }
+ }
+
+ private void switchToListMode(String text) {
+ mEditTextList.removeAllViews();
+ String[] items = text.split("\n");
+ int index = 0;
+ for (String item : items) {
+ if(!TextUtils.isEmpty(item)) {
+ mEditTextList.addView(getListItem(item, index));
+ index++;
+ }
+ }
+ mEditTextList.addView(getListItem("", index));
+ mEditTextList.getChildAt(index).findViewById(R.id.et_edit_text).requestFocus();
+
+ mNoteEditor.setVisibility(View.GONE);
+ mEditTextList.setVisibility(View.VISIBLE);
+ }
+
+ private Spannable getHighlightQueryResult(String fullText, String userQuery) {
+ SpannableString spannable = new SpannableString(fullText == null ? "" : fullText);
+ if (!TextUtils.isEmpty(userQuery)) {
+ mPattern = Pattern.compile(userQuery);
+ Matcher m = mPattern.matcher(fullText);
+ int start = 0;
+ while (m.find(start)) {
+ spannable.setSpan(
+ new BackgroundColorSpan(this.getResources().getColor(
+ R.color.user_query_highlight)), m.start(), m.end(),
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
+ start = m.end();
+ }
+ }
+ return spannable;
+ }
+
+ private View getListItem(String item, int index) {
+ View view = LayoutInflater.from(this).inflate(R.layout.note_edit_list_item, null);
+ final NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
+ edit.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
+ CheckBox cb = ((CheckBox) view.findViewById(R.id.cb_edit_item));
+ cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (isChecked) {
+ edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
+ } else {
+ edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
+ }
+ }
+ });
+
+ if (item.startsWith(TAG_CHECKED)) {
+ cb.setChecked(true);
+ edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
+ item = item.substring(TAG_CHECKED.length(), item.length()).trim();
+ } else if (item.startsWith(TAG_UNCHECKED)) {
+ cb.setChecked(false);
+ edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
+ item = item.substring(TAG_UNCHECKED.length(), item.length()).trim();
+ }
+
+ edit.setOnTextViewChangeListener(this);
+ edit.setIndex(index);
+ edit.setText(getHighlightQueryResult(item, mUserQuery));
+ return view;
+ }
+
+ public void onTextChange(int index, boolean hasText) {
+ if (index >= mEditTextList.getChildCount()) {
+ Log.e(TAG, "Wrong index, should not happen");
+ return;
+ }
+ if(hasText) {
+ mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.VISIBLE);
+ } else {
+ mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.GONE);
+ }
+ }
+
+ public void onCheckListModeChanged(int oldMode, int newMode) {
+ if (newMode == TextNote.MODE_CHECK_LIST) {
+ switchToListMode(mNoteEditor.getText().toString());
+ } else {
+ if (!getWorkingText()) {
+ mWorkingNote.setWorkingText(mWorkingNote.getContent().replace(TAG_UNCHECKED + " ",
+ ""));
+ }
+ mNoteEditor.setText(getHighlightQueryResult(mWorkingNote.getContent(), mUserQuery));
+ mEditTextList.setVisibility(View.GONE);
+ mNoteEditor.setVisibility(View.VISIBLE);
+ }
+ }
+
+ private boolean getWorkingText() {
+ boolean hasChecked = false;
+ if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < mEditTextList.getChildCount(); i++) {
+ View view = mEditTextList.getChildAt(i);
+ NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
+ if (!TextUtils.isEmpty(edit.getText())) {
+ if (((CheckBox) view.findViewById(R.id.cb_edit_item)).isChecked()) {
+ sb.append(TAG_CHECKED).append(" ").append(edit.getText()).append("\n");
+ hasChecked = true;
+ } else {
+ sb.append(TAG_UNCHECKED).append(" ").append(edit.getText()).append("\n");
+ }
+ }
+ }
+ mWorkingNote.setWorkingText(sb.toString());
+ } else {
+ mWorkingNote.setWorkingText(mNoteEditor.getText().toString());
+ }
+ return hasChecked;
+ }
+
+ private boolean saveNote() {
+ getWorkingText();
+ boolean saved = mWorkingNote.saveNote();
+ if (saved) {
+ /**
+ * There are two modes from List view to edit view, open one note,
+ * create/edit a node. Opening node requires to the original
+ * position in the list when back from edit view, while creating a
+ * new node requires to the top of the list. This code
+ * {@link #RESULT_OK} is used to identify the create/edit state
+ */
+ setResult(RESULT_OK);
+ }
+ return saved;
+ }
+
+ private void sendToDesktop() {
+ /**
+ * Before send message to home, we should make sure that current
+ * editing note is exists in databases. So, for new note, firstly
+ * save it
+ */
+ if (!mWorkingNote.existInDatabase()) {
+ saveNote();
+ }
+
+ if (mWorkingNote.getNoteId() > 0) {
+ Intent sender = new Intent();
+ Intent shortcutIntent = new Intent(this, NoteEditActivity.class);
+ shortcutIntent.setAction(Intent.ACTION_VIEW);
+ shortcutIntent.putExtra(Intent.EXTRA_UID, mWorkingNote.getNoteId());
+ sender.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
+ sender.putExtra(Intent.EXTRA_SHORTCUT_NAME,
+ makeShortcutIconTitle(mWorkingNote.getContent()));
+ sender.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
+ Intent.ShortcutIconResource.fromContext(this, R.drawable.icon_app));
+ sender.putExtra("duplicate", true);
+ sender.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
+ showToast(R.string.info_note_enter_desktop);
+ sendBroadcast(sender);
+ } else {
+ /**
+ * There is the condition that user has input nothing (the note is
+ * not worthy saving), we have no note id, remind the user that he
+ * should input something
+ */
+ Log.e(TAG, "Send to desktop error");
+ showToast(R.string.error_note_empty_for_send_to_desktop);
+ }
+ }
+
+ private String makeShortcutIconTitle(String content) {
+ content = content.replace(TAG_CHECKED, "");
+ content = content.replace(TAG_UNCHECKED, "");
+ return content.length() > SHORTCUT_ICON_TITLE_MAX_LEN ? content.substring(0,
+ SHORTCUT_ICON_TITLE_MAX_LEN) : content;
+ }
+
+ private void showToast(int resId) {
+ showToast(resId, Toast.LENGTH_SHORT);
+ }
+
+ private void showToast(int resId, int duration) {
+ Toast.makeText(this, resId, duration).show();
+ }
+<<<<<<< HEAD
+
+
+
+
+
+ private String getLocation(){
+ //1.获取位置管理器
+ String city = null;
+ locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
+
+ //2.获取位置提供器,GPS或是NetWork
+ List providers = locationManager.getProviders(true);
+
+ if (providers.contains(LocationManager.GPS_PROVIDER)) {
+ //如果是GPS
+ locationProvider = LocationManager.GPS_PROVIDER;
+ Log.v("TAG", "定位方式GPS");
+ } else if (providers.contains(LocationManager.NETWORK_PROVIDER)) {
+ //如果是Network
+ locationProvider = LocationManager.NETWORK_PROVIDER;
+ Log.v("TAG", "定位方式Network");
+ }else {
+ Toast.makeText(this, "没有可用的位置提供器", Toast.LENGTH_SHORT).show();
+ return null;
+ }
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ //获取权限(如果没有开启权限,会弹出对话框,询问是否开启权限)
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED ||
+ ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED) {
+ //请求权限
+ ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION,
+ Manifest.permission.ACCESS_COARSE_LOCATION}, LOCATION_CODE);
+ } else {
+ //3.获取上次的位置,一般第一次运行,此值为null
+ Location location = locationManager.getLastKnownLocation(locationProvider);
+ if (location!=null){
+ Toast.makeText(this, location.getLongitude() + " " +
+ location.getLatitude() + "",Toast.LENGTH_SHORT).show();
+ Log.v("TAG", "获取上次的位置-经纬度:"+location.getLongitude()+" "+location.getLatitude());
+ city=getAddress(location);
+
+ }else{
+ //监视地理位置变化,第二个和第三个参数分别为更新的最短时间minTime和最短距离minDistace
+ locationManager.requestLocationUpdates(locationProvider, 3000, 1,locationListener);
+ }
+ }
+ } else {
+ Location location = locationManager.getLastKnownLocation(locationProvider);
+ if (location!=null){
+ Toast.makeText(this, location.getLongitude() + " " +
+ location.getLatitude() + "", Toast.LENGTH_SHORT).show();
+ Log.v("TAG", "获取上次的位置-经纬度:"+location.getLongitude()+" "+location.getLatitude());
+ city=getAddress(location);
+
+ }else{
+ //监视地理位置变化,第二个和第三个参数分别为更新的最短时间minTime和最短距离minDistace
+ locationManager.requestLocationUpdates(locationProvider, 3000, 1,locationListener);
+ }
+ }
+ return city;
+ }
+
+ public LocationListener locationListener = new LocationListener() {
+ // Provider的状态在可用、暂时不可用和无服务三个状态直接切换时触发此函数
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+ // Provider被enable时触发此函数,比如GPS被打开
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+ // Provider被disable时触发此函数,比如GPS被关闭
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+ //当坐标改变时触发此函数,如果Provider传进相同的坐标,它就不会被触发
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location != null) {
+ //如果位置发生变化,重新显示地理位置经纬度
+ Toast.makeText(NoteEditActivity.this, location.getLongitude() + " " +
+ location.getLatitude() + "", Toast.LENGTH_SHORT).show();
+ Log.v("TAG", "监视地理位置变化-经纬度:"+location.getLongitude()+" "+location.getLatitude());
+ }
+ }
+ };
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ switch (requestCode) {
+ case LOCATION_CODE:
+ if(grantResults.length > 0 && grantResults[0] == getPackageManager().PERMISSION_GRANTED
+ && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
+ Toast.makeText(this, "申请权限", Toast.LENGTH_LONG).show();
+ try {
+ List providers = locationManager.getProviders(true);
+ if (providers.contains(LocationManager.NETWORK_PROVIDER)) {
+ //如果是Network
+ locationProvider = LocationManager.NETWORK_PROVIDER;
+
+ }else if (providers.contains(LocationManager.GPS_PROVIDER)) {
+ //如果是GPS
+ locationProvider = LocationManager.GPS_PROVIDER;
+ }
+ Location location = locationManager.getLastKnownLocation(locationProvider);
+ if (location!=null){
+ Toast.makeText(this, location.getLongitude() + " " +
+ location.getLatitude() + "", Toast.LENGTH_SHORT).show();
+ Log.v("TAG", "获取上次的位置-经纬度:"+location.getLongitude()+" "+location.getLatitude());
+ }else{
+ // 监视地理位置变化,第二个和第三个参数分别为更新的最短时间minTime和最短距离minDistace
+ locationManager.requestLocationUpdates(locationProvider, 0, 0,locationListener);
+ }
+
+ }catch (SecurityException e){
+ e.printStackTrace();
+ }
+ } else {
+ Toast.makeText(this, "缺少权限", Toast.LENGTH_LONG).show();
+ finish();
+ }
+ break;
+ }
+ }
+
+ //获取地址信息:城市、街道等信息
+ private String getAddress(Location location) {
+ List result = null;
+ String city = null;
+ try {
+ if (location != null) {
+ Geocoder gc = new Geocoder(this, Locale.getDefault());
+ result = gc.getFromLocation(location.getLatitude(),
+ location.getLongitude(), 1);
+ city = result.get(0).getAddressLine(0).toString();
+ Toast.makeText(this, "获取地址信息:"+city, Toast.LENGTH_LONG).show();
+ Log.v("TAG", "获取地址信息:"+city);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ Log.e(TAG, city);
+ return city;
+ }
+
+
+
+
+
+
+ private void local_sel(){
+ final Button get_local = findViewById(R.id.location);
+ get_local.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(final View v) {
+ Button local1 = new Button(NoteEditActivity.this);
+ final Button local2 = new Button(NoteEditActivity.this);
+ local1.setText("获取地理信息");
+ local2.setText("清除地理信息");
+ LinearLayout linear = new LinearLayout(NoteEditActivity.this);
+ linear.setOrientation(LinearLayout.VERTICAL);
+ linear.addView(local1);
+ linear.addView(local2);
+ AlertDialog.Builder builder = new AlertDialog.Builder(NoteEditActivity.this);
+ builder.setView(linear);
+ builder.setTitle("请选择功能");
+ AlertDialog choose_local = builder.create();
+ choose_local.show();
+ local1.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Toast.makeText(NoteEditActivity.this, "获取地理信息", Toast.LENGTH_SHORT).show();
+ String city = null;
+ city = getLocation();
+
+ if(city == null) {
+ get_local.setText("点击获得地理信息");
+ } else{
+ get_local.setText(city);
+ }
+ }
+ });
+ local2.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Toast.makeText(NoteEditActivity.this, "清除地理信息", Toast.LENGTH_SHORT).show();
+ get_local.setText("点击获得地理信息");
+ }
+ });
+
+ }
+
+// builder.setTitle("choose");
+// AlertDialog choose_local = builder.create();
+// choose_local.show();
+
+ });
+ }
+
+ public void speech_sum(){
+ EditText editable = findViewById(R.id.note_edit_view);
+ //Toast.makeText(NoteEditActivity.this, editable.getText().toString(), Toast.LENGTH_SHORT).show();
+ final Button speak = findViewById(R.id.iatBtn);
+ final int[] tmp = new int[1];
+ final TextToSpeech[] tts = new TextToSpeech[1];
+ tts[0] = new TextToSpeech(NoteEditActivity.this, new TextToSpeech.OnInitListener() {
+ @Override
+ public void onInit(int status) {
+ tts[0].setLanguage(Locale.US);
+ }
+ });
+ editable.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ tmp[0] = cutOfimage(operateText(s.toString())).length();
+ TextView number_word = findViewById(R.id.num_word);
+ number_word.setText("字符数:"+ tmp[0]);
+ final String temp = cutOfimage(s.toString());
+ speak.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ tts[0].speak(temp.toString(),TextToSpeech.QUEUE_FLUSH,null);
+ }
+ });
+ }
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+ });
+ }
+
+ public String operateText(String str){
+ String dest = "";
+ Pattern p = Pattern.compile("\\s*|t|r|n");
+ Matcher m = p.matcher(str);
+ dest = m.replaceAll("");
+ return dest;
+ }
+
+ public String cutOfimage(String str){
+ String dest = str;
+ int index1 = dest.indexOf("[local]");
+ int index2 = dest.indexOf("[/local]");
+ while(index1 != -1 && index2 != -1){
+ dest = dest.substring(0,index1) + dest.substring(index2+8);
+ index1 = dest.indexOf("[local]");
+ index2 = dest.indexOf("[/local]");
+ }
+ return dest;
+ }
+
+
+
+ private void convertToImage() {
+ NoteEditText noteEditText = (NoteEditText) findViewById(R.id.note_edit_view);
+ Editable editable = noteEditText.getText();
+ String noteText = editable.toString();
+ int length = editable.length();
+ for(int i = 0; i < length; i++) {
+ for(int j = i; j < length; j++) {
+ String img_fragment = noteText.substring(i, j+1);
+ if(img_fragment.length() > 15 && img_fragment.endsWith("[/local]") && img_fragment.startsWith("[local]")){
+ int limit = 7;
+ int len = img_fragment.length()-15;
+ String path = img_fragment.substring(limit,limit+len);
+ Bitmap bitmap = null;
+ Log.d(TAG, "图片的路径是:"+path);
+ try {
+ bitmap = BitmapFactory.decodeFile(path);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if(bitmap!=null){
+ Log.d(TAG, "图片不为null");
+ ImageSpan imageSpan = new ImageSpan(NoteEditActivity.this, bitmap);
+ String ss = "[local]" + path + "[/local]";
+ SpannableString spannableString = new SpannableString(ss);
+ spannableString.setSpan(imageSpan, 0, ss.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ Log.d(TAG, "Create spannable string success!");
+ Editable edit_text = noteEditText.getEditableText();
+ edit_text.delete(i,i+len+15);
+ edit_text.insert(i, spannableString);
+ }
+ }
+ }
+ }
+ }
+
+
+
+ @RequiresApi(api = Build.VERSION_CODES.KITKAT)
+ protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
+ super.onActivityResult(requestCode, resultCode, intent);
+ ContentResolver resolver = getContentResolver();
+ switch (requestCode) {
+ case PHOTO_REQUEST:
+ Uri originalUri = intent.getData();
+ Bitmap bitmap = null;
+ try {
+ bitmap = BitmapFactory.decodeStream(resolver.openInputStream(originalUri));//2.解码图片
+ } catch (FileNotFoundException e) {
+ Log.d(TAG, "onActivityResult: get file_exception");
+ e.printStackTrace();
+ }
+
+ if(bitmap != null){
+ Log.d(TAG, "onActivityResult: bitmap is not null");
+ ImageSpan imageSpan = new ImageSpan(NoteEditActivity.this, bitmap);
+ String path = getPath(this,originalUri);
+ String img_fragment= "[local]" + path + "[/local]";
+ SpannableString spannableString = new SpannableString(img_fragment);
+ spannableString.setSpan(imageSpan, 0, img_fragment.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ NoteEditText e = (NoteEditText) findViewById(R.id.note_edit_view);
+ int index = e.getSelectionStart();
+ Log.d(TAG, "Index是: " + index);
+ Editable edit_text = e.getEditableText();
+ edit_text.insert(index, spannableString);
+ mWorkingNote.setmContent(e.getText().toString());
+ ContentResolver contentResolver = getContentResolver();
+ ContentValues contentValues = new ContentValues();
+ final long id = mWorkingNote.getNoteId();
+ contentValues.put("snippet",mWorkingNote.getContent());
+ contentResolver.update(Uri.parse("content://micode_notes/note"), contentValues,"_id=?",new String[]{""+id});
+ ContentValues contentValues1 = new ContentValues();
+ contentValues1.put("content",mWorkingNote.getContent());
+ contentResolver.update(Uri.parse("content://micode_notes/data"), contentValues1,"mime_type=? and note_id=?", new String[]{"vnd.android.cursor.item/text_note",""+id});
+
+ }else{
+ Toast.makeText(NoteEditActivity.this, "获取图片失败", Toast.LENGTH_SHORT).show();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+
+ @RequiresApi(api = Build.VERSION_CODES.KITKAT)
+ public String getPath(final Context context, final Uri uri) {
+
+ final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
+ if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
+ if (isMediaDocument(uri)) {
+ final String docId = DocumentsContract.getDocumentId(uri);
+ final String[] split = docId.split(":");
+ final String type = split[0];
+
+ Uri contentUri = null;
+ if ("image".equals(type)) {
+ contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
+ }
+
+ final String selection = "_id=?";
+ final String[] selectionArgs = new String[]{split[1]};
+
+ return getDataColumn(context, contentUri, selection, selectionArgs);
+ }
+ }
+ // Media
+ else if ("content".equalsIgnoreCase(uri.getScheme())) {
+ return getDataColumn(context, uri, null, null);
+ }
+ // File
+ else if ("file".equalsIgnoreCase(uri.getScheme())) {
+ return uri.getPath();
+ }
+ return null;
+ }
+
+ public String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
+
+ Cursor cursor = null;
+ final String column = "_data";
+ final String[] projection = {column};
+
+ try {
+ cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
+ if (cursor != null && cursor.moveToFirst()) {
+ final int column_index = cursor.getColumnIndexOrThrow(column);
+ return cursor.getString(column_index);
+ }
+ } finally {
+ if (cursor != null)
+ cursor.close();
+ }
+ return null;
+ }
+
+ public boolean isMediaDocument(Uri uri) {
+ return "com.android.providers.media.documents".equals(uri.getAuthority());
+ }
+
+
+ public void showSingleAlertDiglog(){
+ final String[] items = {"默认-普通","默认-非衬线","默认-衬线","默认-等宽","仿宋","黑体","楷体","姚体","隶书","行楷","新魏","中宋"};
+ AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
+ alertBuilder.setTitle("选择字体");
+ alertBuilder.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ switch (i) {
+ case 0:
+ mNoteEditor.setTypeface(Typeface.DEFAULT);
+ break;
+ case 1:
+ mNoteEditor.setTypeface(Typeface.SANS_SERIF);
+ break;
+ case 2:
+ mNoteEditor.setTypeface(Typeface.SERIF);
+ break;
+ case 3:
+ mNoteEditor.setTypeface(Typeface.MONOSPACE);
+ break;
+ case 4:
+ Typeface typeface0 = Typeface.createFromAsset(getAssets(), "font/simfang.ttf");
+ mNoteEditor.setTypeface(typeface0);
+ break;
+ case 5:
+ Typeface typeface1 = Typeface.createFromAsset(getAssets(), "font/simhei.ttf");
+ mNoteEditor.setTypeface(typeface1);
+ break;
+ case 6:
+ Typeface typeface2 = Typeface.createFromAsset(getAssets(), "font/simkai.ttf");
+ mNoteEditor.setTypeface(typeface2);
+ break;
+ case 7:
+ Typeface typeface3 = Typeface.createFromAsset(getAssets(), "font/FZYTK.TTF");
+ mNoteEditor.setTypeface(typeface3);
+ break;
+ case 8:
+ Typeface typeface4 = Typeface.createFromAsset(getAssets(), "font/STLITI.TTF");
+ mNoteEditor.setTypeface(typeface4);
+ break;
+ case 9:
+ Typeface typeface5 = Typeface.createFromAsset(getAssets(), "font/STXINGKA.TTF");
+ mNoteEditor.setTypeface(typeface5);
+ break;
+ case 10:
+ Typeface typeface6 = Typeface.createFromAsset(getAssets(), "font/STXINWEI.TTF");
+ mNoteEditor.setTypeface(typeface6);
+ break;
+ case 11:
+ Typeface typeface7 = Typeface.createFromAsset(getAssets(), "font/STZHONGS.TTF");
+ mNoteEditor.setTypeface(typeface7);
+ break;
+ }
+ Toast.makeText(NoteEditActivity.this, items[i], Toast.LENGTH_SHORT).show();
+ }
+ });
+ alertBuilder.setPositiveButton("确定",new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ alertDialog2.dismiss();
+
+ }
+
+ });
+ alertBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ alertDialog2.dismiss();
+ }
+
+ });
+ alertDialog2 = alertBuilder.create();
+ alertDialog2.show();
+ }
+
+ public void translate(){
+ final EditText editable = findViewById(R.id.note_edit_view);
+ final Button get_local = findViewById(R.id.translate);
+ get_local.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(final View v) {
+ Button trans1 = new Button(NoteEditActivity.this);
+ Button trans2 = new Button(NoteEditActivity.this);
+ Button trans3 = new Button(NoteEditActivity.this);
+ trans1.setText("中文翻译为英文");
+ trans2.setText("英文翻译为中文");
+ trans3.setText("还原");
+ LinearLayout linear = new LinearLayout(NoteEditActivity.this);
+ linear.setOrientation(LinearLayout.VERTICAL);
+ linear.addView(trans1);
+ linear.addView(trans2);
+ linear.addView(trans3);
+ AlertDialog.Builder builder = new AlertDialog.Builder(NoteEditActivity.this);
+ builder.setView(linear);
+ builder.setTitle("请选择翻译模式");
+ AlertDialog choose_trans = builder.create();
+ choose_trans.show();
+ trans1.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ restore_translate = editable.getText();
+ translate_z2u();
+ Toast.makeText(NoteEditActivity.this, "中文翻译为英文", Toast.LENGTH_SHORT).show();
+ }
+ });
+ trans2.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ restore_translate = editable.getText();
+ translate_u2z();
+ Toast.makeText(NoteEditActivity.this, "英文翻译为中文", Toast.LENGTH_SHORT).show();
+ }
+ });
+ trans3.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if(restore_translate == null || restore_translate.toString().equals(editable.getText().toString())){
+ Toast.makeText(NoteEditActivity.this, "无可还原内容", Toast.LENGTH_SHORT).show();
+ }else {
+ editable.setText(restore_translate);
+ Toast.makeText(NoteEditActivity.this, "已还原", Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+ }
+ });
+ }
+
+
+ public void translate_z2u() {
+ final EditText editable = findViewById(R.id.note_edit_view);
+ String word = editable.getText().toString();
+ word = word.replaceAll("\\n","//");
+ String from = "auto";
+ String to = "en";
+ String appid = "20221021001406789";
+ String salt = (int) (Math.random() * 100 + 1) + "";
+ String key = "eWky8SSKgL99Dh4rHMog";
+ String secretKey = appid + word + salt + key;
+ String sign = MD5Utils.getMD5Code(secretKey);
+ Log.d(TAG, "secretKey:" + secretKey);
+ Log.d(TAG, "sign: " + sign);
+ Retrofit retrofitBaidu = new Retrofit.Builder()
+ .baseUrl("https://fanyi-api.baidu.com/api/trans/vip/")
+ .addConverterFactory(GsonConverterFactory.create())
+ .build();
+ BaiduTranslateService baiduTranslateService =retrofitBaidu.create(BaiduTranslateService.class);
+ retrofit2.Call call = baiduTranslateService.translate(word, from, to, appid, salt, sign);
+ call.enqueue(new Callback() {
+ @Override
+ public void onResponse(retrofit2.Call call, Response response) {
+ Log.d(TAG, "onResponse: 请求成功");
+ RespondBean respondBean = response.body();
+ String result = respondBean.getTrans_result().get(0).getDst();
+ editable.setText(result);
+ Log.d(TAG, "中译英结果" + result);
+ }
+ @Override
+ public void onFailure(retrofit2.Call call, Throwable t) {
+ Log.d(TAG, "onResponse: 请求失败 " + t);
+ }
+ });
+ }
+
+ public void translate_u2z() {
+ final EditText editable = findViewById(R.id.note_edit_view);
+ String word = editable.getText().toString();
+ word = word.replaceAll("\\n","//");
+ Log.d(TAG, word);
+ String from = "auto";
+ String to = "zh";
+ String appid = "20221021001406789";
+ String salt = (int) (Math.random() * 100 + 1) + "";
+ String key = "eWky8SSKgL99Dh4rHMog";
+ String secretKey = appid + word + salt + key;
+ String sign = MD5Utils.getMD5Code(secretKey);
+ Log.d(TAG, "secretKey:" + secretKey);
+ Log.d(TAG, "sign: " + sign);
+ Retrofit retrofitBaidu = new Retrofit.Builder()
+ .baseUrl("https://fanyi-api.baidu.com/api/trans/vip/")
+ .addConverterFactory(GsonConverterFactory.create())
+ .build();
+ BaiduTranslateService baiduTranslateService =retrofitBaidu.create(BaiduTranslateService.class);
+ retrofit2.Call call = baiduTranslateService.translate(word, from, to, appid, salt, sign);
+ call.enqueue(new Callback() {
+ @Override
+ public void onResponse(retrofit2.Call call, Response response) {
+ Log.d(TAG, "onResponse: 请求成功");
+ RespondBean respondBean = response.body();
+ String result = respondBean.getTrans_result().get(0).getDst();
+ editable.setText(result);
+ Log.d(TAG, "中译英结果" + result);
+ }
+ @Override
+ public void onFailure(retrofit2.Call call, Throwable t) {
+ Log.d(TAG, "onResponse: 请求失败 " + t);
+ }
+ });
+ }
+
+
+
+
+}
+
+
+=======
+}
+>>>>>>> origin/Branch_liujie
diff --git a/src/app/src/main/java/net/micode/notes/ui/NoteEditText.java b/src/app/src/main/java/net/micode/notes/ui/NoteEditText.java
index 24278b5..0ad029e 100644
--- a/src/app/src/main/java/net/micode/notes/ui/NoteEditText.java
+++ b/src/app/src/main/java/net/micode/notes/ui/NoteEditText.java
@@ -37,7 +37,11 @@ import net.micode.notes.R;
import java.util.HashMap;
import java.util.Map;
+<<<<<<< HEAD
public class NoteEditText extends android.support.v7.widget.AppCompatEditText {
+=======
+public class NoteEditText extends EditText {
+>>>>>>> origin/Branch_liujie
private static final String TAG = "NoteEditText";
private int mIndex;
private int mSelectionStartBeforeDelete;
diff --git a/src/app/src/main/java/net/micode/notes/ui/NoteEditText.java.orig b/src/app/src/main/java/net/micode/notes/ui/NoteEditText.java.orig
new file mode 100644
index 0000000..0ad029e
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/ui/NoteEditText.java.orig
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.ui;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.text.Layout;
+import android.text.Selection;
+import android.text.Spanned;
+import android.text.TextUtils;
+import android.text.style.URLSpan;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.ContextMenu;
+import android.view.KeyEvent;
+import android.view.MenuItem;
+import android.view.MenuItem.OnMenuItemClickListener;
+import android.view.MotionEvent;
+import android.widget.EditText;
+
+import net.micode.notes.R;
+
+import java.util.HashMap;
+import java.util.Map;
+
+<<<<<<< HEAD
+public class NoteEditText extends android.support.v7.widget.AppCompatEditText {
+=======
+public class NoteEditText extends EditText {
+>>>>>>> origin/Branch_liujie
+ private static final String TAG = "NoteEditText";
+ private int mIndex;
+ private int mSelectionStartBeforeDelete;
+
+ private static final String SCHEME_TEL = "tel:" ;
+ private static final String SCHEME_HTTP = "http:" ;
+ private static final String SCHEME_EMAIL = "mailto:" ;
+
+ private static final Map sSchemaActionResMap = new HashMap();
+ static {
+ sSchemaActionResMap.put(SCHEME_TEL, R.string.note_link_tel);
+ sSchemaActionResMap.put(SCHEME_HTTP, R.string.note_link_web);
+ sSchemaActionResMap.put(SCHEME_EMAIL, R.string.note_link_email);
+ }
+
+ /**
+ * Call by the {@link NoteEditActivity} to delete or add edit text
+ */
+ public interface OnTextViewChangeListener {
+ /**
+ * Delete current edit text when {@link KeyEvent#KEYCODE_DEL} happens
+ * and the text is null
+ */
+ void onEditTextDelete(int index, String text);
+
+ /**
+ * Add edit text after current edit text when {@link KeyEvent#KEYCODE_ENTER}
+ * happen
+ */
+ void onEditTextEnter(int index, String text);
+
+ /**
+ * Hide or show item option when text change
+ */
+ void onTextChange(int index, boolean hasText);
+ }
+
+ private OnTextViewChangeListener mOnTextViewChangeListener;
+
+ public NoteEditText(Context context) {
+ super(context, null);
+ mIndex = 0;
+ }
+
+ public void setIndex(int index) {
+ mIndex = index;
+ }
+
+ public void setOnTextViewChangeListener(OnTextViewChangeListener listener) {
+ mOnTextViewChangeListener = listener;
+ }
+
+ public NoteEditText(Context context, AttributeSet attrs) {
+ super(context, attrs, android.R.attr.editTextStyle);
+ }
+
+ public NoteEditText(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+
+ int x = (int) event.getX();
+ int y = (int) event.getY();
+ x -= getTotalPaddingLeft();
+ y -= getTotalPaddingTop();
+ x += getScrollX();
+ y += getScrollY();
+
+ Layout layout = getLayout();
+ int line = layout.getLineForVertical(y);
+ int off = layout.getOffsetForHorizontal(line, x);
+ Selection.setSelection(getText(), off);
+ break;
+ }
+
+ return super.onTouchEvent(event);
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_ENTER:
+ if (mOnTextViewChangeListener != null) {
+ return false;
+ }
+ break;
+ case KeyEvent.KEYCODE_DEL:
+ mSelectionStartBeforeDelete = getSelectionStart();
+ break;
+ default:
+ break;
+ }
+ return super.onKeyDown(keyCode, event);
+ }
+
+ @Override
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
+ switch(keyCode) {
+ case KeyEvent.KEYCODE_DEL:
+ if (mOnTextViewChangeListener != null) {
+ if (0 == mSelectionStartBeforeDelete && mIndex != 0) {
+ mOnTextViewChangeListener.onEditTextDelete(mIndex, getText().toString());
+ return true;
+ }
+ } else {
+ Log.d(TAG, "OnTextViewChangeListener was not seted");
+ }
+ break;
+ case KeyEvent.KEYCODE_ENTER:
+ if (mOnTextViewChangeListener != null) {
+ int selectionStart = getSelectionStart();
+ String text = getText().subSequence(selectionStart, length()).toString();
+ setText(getText().subSequence(0, selectionStart));
+ mOnTextViewChangeListener.onEditTextEnter(mIndex + 1, text);
+ } else {
+ Log.d(TAG, "OnTextViewChangeListener was not seted");
+ }
+ break;
+ default:
+ break;
+ }
+ return super.onKeyUp(keyCode, event);
+ }
+
+ @Override
+ protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
+ if (mOnTextViewChangeListener != null) {
+ if (!focused && TextUtils.isEmpty(getText())) {
+ mOnTextViewChangeListener.onTextChange(mIndex, false);
+ } else {
+ mOnTextViewChangeListener.onTextChange(mIndex, true);
+ }
+ }
+ super.onFocusChanged(focused, direction, previouslyFocusedRect);
+ }
+
+ @Override
+ protected void onCreateContextMenu(ContextMenu menu) {
+ if (getText() instanceof Spanned) {
+ int selStart = getSelectionStart();
+ int selEnd = getSelectionEnd();
+
+ int min = Math.min(selStart, selEnd);
+ int max = Math.max(selStart, selEnd);
+
+ final URLSpan[] urls = ((Spanned) getText()).getSpans(min, max, URLSpan.class);
+ if (urls.length == 1) {
+ int defaultResId = 0;
+ for(String schema: sSchemaActionResMap.keySet()) {
+ if(urls[0].getURL().indexOf(schema) >= 0) {
+ defaultResId = sSchemaActionResMap.get(schema);
+ break;
+ }
+ }
+
+ if (defaultResId == 0) {
+ defaultResId = R.string.note_link_other;
+ }
+
+ menu.add(0, 0, 0, defaultResId).setOnMenuItemClickListener(
+ new OnMenuItemClickListener() {
+ public boolean onMenuItemClick(MenuItem item) {
+ // goto a new intent
+ urls[0].onClick(NoteEditText.this);
+ return true;
+ }
+ });
+ }
+ }
+ super.onCreateContextMenu(menu);
+ }
+}
diff --git a/src/app/src/main/java/net/micode/notes/ui/NoteItemData.java b/src/app/src/main/java/net/micode/notes/ui/NoteItemData.java
index 1966e95..9eb8bd6 100644
--- a/src/app/src/main/java/net/micode/notes/ui/NoteItemData.java
+++ b/src/app/src/main/java/net/micode/notes/ui/NoteItemData.java
@@ -40,7 +40,10 @@ public class NoteItemData {
NoteColumns.TYPE,
NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE,
+<<<<<<< HEAD
NoteColumns.TOP,
+=======
+>>>>>>> origin/Branch_liujie
};
private static final int ID_COLUMN = 0;
@@ -55,7 +58,10 @@ public class NoteItemData {
private static final int TYPE_COLUMN = 9;
private static final int WIDGET_ID_COLUMN = 10;
private static final int WIDGET_TYPE_COLUMN = 11;
+<<<<<<< HEAD
private static final int TOP_ID_COLUMN = 12;
+=======
+>>>>>>> origin/Branch_liujie
private long mId;
private long mAlertDate;
@@ -71,7 +77,10 @@ public class NoteItemData {
private int mWidgetType;
private String mName;
private String mPhoneNumber;
+<<<<<<< HEAD
private String mTop;
+=======
+>>>>>>> origin/Branch_liujie
private boolean mIsLastItem;
private boolean mIsFirstItem;
@@ -94,7 +103,10 @@ public class NoteItemData {
mType = cursor.getInt(TYPE_COLUMN);
mWidgetId = cursor.getInt(WIDGET_ID_COLUMN);
mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);
+<<<<<<< HEAD
mTop = cursor.getString(TOP_ID_COLUMN);
+=======
+>>>>>>> origin/Branch_liujie
mPhoneNumber = "";
if (mParentId == Notes.ID_CALL_RECORD_FOLDER) {
@@ -138,6 +150,7 @@ public class NoteItemData {
}
}
+<<<<<<< HEAD
public boolean isTOP() {
if(mTop.equals("1")) {
return true;
@@ -146,6 +159,8 @@ public class NoteItemData {
}
}
+=======
+>>>>>>> origin/Branch_liujie
public boolean isOneFollowingFolder() {
return mIsOneNoteFollowingFolder;
}
diff --git a/src/app/src/main/java/net/micode/notes/ui/NoteItemData.java.orig b/src/app/src/main/java/net/micode/notes/ui/NoteItemData.java.orig
new file mode 100644
index 0000000..9eb8bd6
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/ui/NoteItemData.java.orig
@@ -0,0 +1,251 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.ui;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.text.TextUtils;
+
+import net.micode.notes.data.Contact;
+import net.micode.notes.data.Notes;
+import net.micode.notes.data.Notes.NoteColumns;
+import net.micode.notes.tool.DataUtils;
+
+
+public class NoteItemData {
+ static final String [] PROJECTION = new String [] {
+ NoteColumns.ID,
+ NoteColumns.ALERTED_DATE,
+ NoteColumns.BG_COLOR_ID,
+ NoteColumns.CREATED_DATE,
+ NoteColumns.HAS_ATTACHMENT,
+ NoteColumns.MODIFIED_DATE,
+ NoteColumns.NOTES_COUNT,
+ NoteColumns.PARENT_ID,
+ NoteColumns.SNIPPET,
+ NoteColumns.TYPE,
+ NoteColumns.WIDGET_ID,
+ NoteColumns.WIDGET_TYPE,
+<<<<<<< HEAD
+ NoteColumns.TOP,
+=======
+>>>>>>> origin/Branch_liujie
+ };
+
+ private static final int ID_COLUMN = 0;
+ private static final int ALERTED_DATE_COLUMN = 1;
+ private static final int BG_COLOR_ID_COLUMN = 2;
+ private static final int CREATED_DATE_COLUMN = 3;
+ private static final int HAS_ATTACHMENT_COLUMN = 4;
+ private static final int MODIFIED_DATE_COLUMN = 5;
+ private static final int NOTES_COUNT_COLUMN = 6;
+ private static final int PARENT_ID_COLUMN = 7;
+ private static final int SNIPPET_COLUMN = 8;
+ private static final int TYPE_COLUMN = 9;
+ private static final int WIDGET_ID_COLUMN = 10;
+ private static final int WIDGET_TYPE_COLUMN = 11;
+<<<<<<< HEAD
+ private static final int TOP_ID_COLUMN = 12;
+=======
+>>>>>>> origin/Branch_liujie
+
+ private long mId;
+ private long mAlertDate;
+ private int mBgColorId;
+ private long mCreatedDate;
+ private boolean mHasAttachment;
+ private long mModifiedDate;
+ private int mNotesCount;
+ private long mParentId;
+ private String mSnippet;
+ private int mType;
+ private int mWidgetId;
+ private int mWidgetType;
+ private String mName;
+ private String mPhoneNumber;
+<<<<<<< HEAD
+ private String mTop;
+=======
+>>>>>>> origin/Branch_liujie
+
+ private boolean mIsLastItem;
+ private boolean mIsFirstItem;
+ private boolean mIsOnlyOneItem;
+ private boolean mIsOneNoteFollowingFolder;
+ private boolean mIsMultiNotesFollowingFolder;
+
+ public NoteItemData(Context context, Cursor cursor) {
+ mId = cursor.getLong(ID_COLUMN);
+ mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN);
+ mBgColorId = cursor.getInt(BG_COLOR_ID_COLUMN);
+ mCreatedDate = cursor.getLong(CREATED_DATE_COLUMN);
+ mHasAttachment = (cursor.getInt(HAS_ATTACHMENT_COLUMN) > 0) ? true : false;
+ mModifiedDate = cursor.getLong(MODIFIED_DATE_COLUMN);
+ mNotesCount = cursor.getInt(NOTES_COUNT_COLUMN);
+ mParentId = cursor.getLong(PARENT_ID_COLUMN);
+ mSnippet = cursor.getString(SNIPPET_COLUMN);
+ mSnippet = mSnippet.replace(NoteEditActivity.TAG_CHECKED, "").replace(
+ NoteEditActivity.TAG_UNCHECKED, "");
+ mType = cursor.getInt(TYPE_COLUMN);
+ mWidgetId = cursor.getInt(WIDGET_ID_COLUMN);
+ mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);
+<<<<<<< HEAD
+ mTop = cursor.getString(TOP_ID_COLUMN);
+=======
+>>>>>>> origin/Branch_liujie
+
+ mPhoneNumber = "";
+ if (mParentId == Notes.ID_CALL_RECORD_FOLDER) {
+ mPhoneNumber = DataUtils.getCallNumberByNoteId(context.getContentResolver(), mId);
+ if (!TextUtils.isEmpty(mPhoneNumber)) {
+ mName = Contact.getContact(context, mPhoneNumber);
+ if (mName == null) {
+ mName = mPhoneNumber;
+ }
+ }
+ }
+
+ if (mName == null) {
+ mName = "";
+ }
+ checkPostion(cursor);
+ }
+
+ private void checkPostion(Cursor cursor) {
+ mIsLastItem = cursor.isLast() ? true : false;
+ mIsFirstItem = cursor.isFirst() ? true : false;
+ mIsOnlyOneItem = (cursor.getCount() == 1);
+ mIsMultiNotesFollowingFolder = false;
+ mIsOneNoteFollowingFolder = false;
+
+ if (mType == Notes.TYPE_NOTE && !mIsFirstItem) {
+ int position = cursor.getPosition();
+ if (cursor.moveToPrevious()) {
+ if (cursor.getInt(TYPE_COLUMN) == Notes.TYPE_FOLDER
+ || cursor.getInt(TYPE_COLUMN) == Notes.TYPE_SYSTEM) {
+ if (cursor.getCount() > (position + 1)) {
+ mIsMultiNotesFollowingFolder = true;
+ } else {
+ mIsOneNoteFollowingFolder = true;
+ }
+ }
+ if (!cursor.moveToNext()) {
+ throw new IllegalStateException("cursor move to previous but can't move back");
+ }
+ }
+ }
+ }
+
+<<<<<<< HEAD
+ public boolean isTOP() {
+ if(mTop.equals("1")) {
+ return true;
+ }else {
+ return false;
+ }
+ }
+
+=======
+>>>>>>> origin/Branch_liujie
+ public boolean isOneFollowingFolder() {
+ return mIsOneNoteFollowingFolder;
+ }
+
+ public boolean isMultiFollowingFolder() {
+ return mIsMultiNotesFollowingFolder;
+ }
+
+ public boolean isLast() {
+ return mIsLastItem;
+ }
+
+ public String getCallName() {
+ return mName;
+ }
+
+ public boolean isFirst() {
+ return mIsFirstItem;
+ }
+
+ public boolean isSingle() {
+ return mIsOnlyOneItem;
+ }
+
+ public long getId() {
+ return mId;
+ }
+
+ public long getAlertDate() {
+ return mAlertDate;
+ }
+
+ public long getCreatedDate() {
+ return mCreatedDate;
+ }
+
+ public boolean hasAttachment() {
+ return mHasAttachment;
+ }
+
+ public long getModifiedDate() {
+ return mModifiedDate;
+ }
+
+ public int getBgColorId() {
+ return mBgColorId;
+ }
+
+ public long getParentId() {
+ return mParentId;
+ }
+
+ public int getNotesCount() {
+ return mNotesCount;
+ }
+
+ public long getFolderId () {
+ return mParentId;
+ }
+
+ public int getType() {
+ return mType;
+ }
+
+ public int getWidgetType() {
+ return mWidgetType;
+ }
+
+ public int getWidgetId() {
+ return mWidgetId;
+ }
+
+ public String getSnippet() {
+ return mSnippet;
+ }
+
+ public boolean hasAlert() {
+ return (mAlertDate > 0);
+ }
+
+ public boolean isCallRecord() {
+ return (mParentId == Notes.ID_CALL_RECORD_FOLDER && !TextUtils.isEmpty(mPhoneNumber));
+ }
+
+ public static int getNoteType(Cursor cursor) {
+ return cursor.getInt(TYPE_COLUMN);
+ }
+}
diff --git a/src/app/src/main/java/net/micode/notes/ui/NotesListActivity.java b/src/app/src/main/java/net/micode/notes/ui/NotesListActivity.java
index 27c60e2..2f4edaf 100644
--- a/src/app/src/main/java/net/micode/notes/ui/NotesListActivity.java
+++ b/src/app/src/main/java/net/micode/notes/ui/NotesListActivity.java
@@ -17,7 +17,10 @@
package net.micode.notes.ui;
import android.app.Activity;
+<<<<<<< HEAD
import android.support.v7.app.AppCompatActivity;
+=======
+>>>>>>> origin/Branch_liujie
import android.app.AlertDialog;
import android.app.Dialog;
import android.appwidget.AppWidgetManager;
@@ -79,7 +82,13 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
+<<<<<<< HEAD
public class NotesListActivity extends AppCompatActivity implements OnClickListener, OnItemLongClickListener {
+=======
+public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener {
+ public static int secret_mode = 0;
+
+>>>>>>> origin/Branch_liujie
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
private static final int FOLDER_LIST_QUERY_TOKEN = 1;
@@ -136,14 +145,20 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
private final static int REQUEST_CODE_OPEN_NODE = 102;
private final static int REQUEST_CODE_NEW_NODE = 103;
+<<<<<<< HEAD
static Activity NoteListActivity;
+=======
+>>>>>>> origin/Branch_liujie
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.note_list);
+<<<<<<< HEAD
NoteListActivity = this;
+=======
+>>>>>>> origin/Branch_liujie
initResources();
/**
@@ -416,10 +431,42 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
private void startAsyncNotesListQuery() {
String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION
: NORMAL_SELECTION;
+<<<<<<< HEAD
mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] {
String.valueOf(mCurrentFolderId)
}, NoteColumns.TOP+ " DESC,"+ NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
+=======
+ if(secret_mode == 0) {
+ mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
+ Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[]{
+ String.valueOf(mCurrentFolderId)
+ }, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
+ }
+ else{
+ String str1 = "5201314";
+ String [] PROJECTION = new String [] { //定义一个新的PROJECTION数组,只换掉SNIPPET
+ NoteColumns.ID,
+ NoteColumns.ALERTED_DATE,
+ NoteColumns.BG_COLOR_ID,
+ NoteColumns.CREATED_DATE,
+ NoteColumns.HAS_ATTACHMENT,
+ NoteColumns.MODIFIED_DATE,
+ NoteColumns.NOTES_COUNT,
+ NoteColumns.PARENT_ID,
+// NoteColumns.SNIPPET,
+ str1,
+ NoteColumns.TYPE,
+ NoteColumns.WIDGET_ID,
+ NoteColumns.WIDGET_TYPE,
+ };
+ mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
+ Notes.CONTENT_NOTE_URI, PROJECTION, selection, new String[]{
+ String.valueOf(mCurrentFolderId)
+ }, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
+
+ }
+>>>>>>> origin/Branch_liujie
}
private final class BackgroundQueryHandler extends AsyncQueryHandler {
@@ -768,6 +815,10 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.clear();
+<<<<<<< HEAD
+=======
+
+>>>>>>> origin/Branch_liujie
if (mState == ListEditState.NOTE_LIST) {
getMenuInflater().inflate(R.menu.note_list, menu);
// set sync or sync_cancel
@@ -790,6 +841,51 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
showCreateOrModifyFolderDialog(true);
break;
}
+<<<<<<< HEAD
+=======
+ case R.id.menu_secret: { //进入私密模式
+ secret_mode = 1;
+ AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
+ dialog.setTitle("重要提醒");
+ dialog.setMessage("您确认进入私密模式吗?");
+ dialog.setCancelable(false);
+ dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ startAsyncNotesListQuery();
+ Toast.makeText(NotesListActivity.this,"您已进入私密模式",Toast.LENGTH_SHORT).show();
+ }
+ });
+ dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which){}
+ });
+ dialog.show();
+ startAsyncNotesListQuery();
+ Toast.makeText(this,"您已进入私密模式",Toast.LENGTH_SHORT).show();
+ break;
+ }
+ case R.id.menu_quit_secret:{ //退出私密模式
+ secret_mode = 0;
+ AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
+ dialog.setTitle("重要提醒");
+ dialog.setMessage("您确认退出私密模式吗?");
+ dialog.setCancelable(false);
+ dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ startAsyncNotesListQuery();
+ Toast.makeText(NotesListActivity.this,"您已退出私密模式",Toast.LENGTH_SHORT).show();
+ }
+ });
+ dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which){}
+ });
+ dialog.show();
+ break;
+ }
+>>>>>>> origin/Branch_liujie
case R.id.menu_export_text: {
exportNoteToText();
break;
diff --git a/src/app/src/main/java/net/micode/notes/ui/NotesListActivity.java.orig b/src/app/src/main/java/net/micode/notes/ui/NotesListActivity.java.orig
new file mode 100644
index 0000000..2f4edaf
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/ui/NotesListActivity.java.orig
@@ -0,0 +1,1055 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.ui;
+
+import android.app.Activity;
+<<<<<<< HEAD
+import android.support.v7.app.AppCompatActivity;
+=======
+>>>>>>> origin/Branch_liujie
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.appwidget.AppWidgetManager;
+import android.content.AsyncQueryHandler;
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.database.Cursor;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.util.Log;
+import android.view.ActionMode;
+import android.view.ContextMenu;
+import android.view.ContextMenu.ContextMenuInfo;
+import android.view.Display;
+import android.view.HapticFeedbackConstants;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MenuItem.OnMenuItemClickListener;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnCreateContextMenuListener;
+import android.view.View.OnTouchListener;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.AdapterView.OnItemLongClickListener;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.PopupMenu;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import net.micode.notes.R;
+import net.micode.notes.data.Notes;
+import net.micode.notes.data.Notes.NoteColumns;
+import net.micode.notes.gtask.remote.GTaskSyncService;
+import net.micode.notes.model.WorkingNote;
+import net.micode.notes.tool.BackupUtils;
+import net.micode.notes.tool.DataUtils;
+import net.micode.notes.tool.ResourceParser;
+import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute;
+import net.micode.notes.widget.NoteWidgetProvider_2x;
+import net.micode.notes.widget.NoteWidgetProvider_4x;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashSet;
+
+<<<<<<< HEAD
+public class NotesListActivity extends AppCompatActivity implements OnClickListener, OnItemLongClickListener {
+=======
+public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener {
+ public static int secret_mode = 0;
+
+>>>>>>> origin/Branch_liujie
+ private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
+
+ private static final int FOLDER_LIST_QUERY_TOKEN = 1;
+
+ private static final int MENU_FOLDER_DELETE = 0;
+
+ private static final int MENU_FOLDER_VIEW = 1;
+
+ private static final int MENU_FOLDER_CHANGE_NAME = 2;
+
+ private static final String PREFERENCE_ADD_INTRODUCTION = "net.micode.notes.introduction";
+
+ private enum ListEditState {
+ NOTE_LIST, SUB_FOLDER, CALL_RECORD_FOLDER
+ };
+
+ private ListEditState mState;
+
+ private BackgroundQueryHandler mBackgroundQueryHandler;
+
+ private NotesListAdapter mNotesListAdapter;
+
+ private ListView mNotesListView;
+
+ private Button mAddNewNote;
+
+ private boolean mDispatch;
+
+ private int mOriginY;
+
+ private int mDispatchY;
+
+ private TextView mTitleBar;
+
+ private long mCurrentFolderId;
+
+ private ContentResolver mContentResolver;
+
+ private ModeCallback mModeCallBack;
+
+ private static final String TAG = "NotesListActivity";
+
+ public static final int NOTES_LISTVIEW_SCROLL_RATE = 30;
+
+ private NoteItemData mFocusNoteDataItem;
+
+ private static final String NORMAL_SELECTION = NoteColumns.PARENT_ID + "=?";
+
+ private static final String ROOT_FOLDER_SELECTION = "(" + NoteColumns.TYPE + "<>"
+ + Notes.TYPE_SYSTEM + " AND " + NoteColumns.PARENT_ID + "=?)" + " OR ("
+ + NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER + " AND "
+ + NoteColumns.NOTES_COUNT + ">0)";
+
+ private final static int REQUEST_CODE_OPEN_NODE = 102;
+ private final static int REQUEST_CODE_NEW_NODE = 103;
+
+<<<<<<< HEAD
+ static Activity NoteListActivity;
+
+=======
+>>>>>>> origin/Branch_liujie
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.note_list);
+<<<<<<< HEAD
+ NoteListActivity = this;
+
+=======
+>>>>>>> origin/Branch_liujie
+ initResources();
+
+ /**
+ * Insert an introduction when user firstly use this application
+ */
+ setAppInfoFromRawRes();
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (resultCode == RESULT_OK
+ && (requestCode == REQUEST_CODE_OPEN_NODE || requestCode == REQUEST_CODE_NEW_NODE)) {
+ mNotesListAdapter.changeCursor(null);
+ } else {
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+ }
+
+ private void setAppInfoFromRawRes() {
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
+ if (!sp.getBoolean(PREFERENCE_ADD_INTRODUCTION, false)) {
+ StringBuilder sb = new StringBuilder();
+ InputStream in = null;
+ try {
+ in = getResources().openRawResource(R.raw.introduction);
+ if (in != null) {
+ InputStreamReader isr = new InputStreamReader(in);
+ BufferedReader br = new BufferedReader(isr);
+ char [] buf = new char[1024];
+ int len = 0;
+ while ((len = br.read(buf)) > 0) {
+ sb.append(buf, 0, len);
+ }
+ } else {
+ Log.e(TAG, "Read introduction file error");
+ return;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ return;
+ } finally {
+ if(in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ WorkingNote note = WorkingNote.createEmptyNote(this, Notes.ID_ROOT_FOLDER,
+ AppWidgetManager.INVALID_APPWIDGET_ID, Notes.TYPE_WIDGET_INVALIDE,
+ ResourceParser.RED);
+ note.setWorkingText(sb.toString());
+ if (note.saveNote()) {
+ sp.edit().putBoolean(PREFERENCE_ADD_INTRODUCTION, true).commit();
+ } else {
+ Log.e(TAG, "Save introduction note error");
+ return;
+ }
+ }
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ startAsyncNotesListQuery();
+ }
+
+ private void initResources() {
+ mContentResolver = this.getContentResolver();
+ mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver());
+ mCurrentFolderId = Notes.ID_ROOT_FOLDER;
+ mNotesListView = (ListView) findViewById(R.id.notes_list);
+ mNotesListView.addFooterView(LayoutInflater.from(this).inflate(R.layout.note_list_footer, null),
+ null, false);
+ mNotesListView.setOnItemClickListener(new OnListItemClickListener());
+ mNotesListView.setOnItemLongClickListener(this);
+ mNotesListAdapter = new NotesListAdapter(this);
+ mNotesListView.setAdapter(mNotesListAdapter);
+ mAddNewNote = (Button) findViewById(R.id.btn_new_note);
+ mAddNewNote.setOnClickListener(this);
+ mAddNewNote.setOnTouchListener(new NewNoteOnTouchListener());
+ mDispatch = false;
+ mDispatchY = 0;
+ mOriginY = 0;
+ mTitleBar = (TextView) findViewById(R.id.tv_title_bar);
+ mState = ListEditState.NOTE_LIST;
+ mModeCallBack = new ModeCallback();
+ }
+
+ private class ModeCallback implements ListView.MultiChoiceModeListener, OnMenuItemClickListener {
+ private DropdownMenu mDropDownMenu;
+ private ActionMode mActionMode;
+ private MenuItem mMoveMenu;
+
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ getMenuInflater().inflate(R.menu.note_list_options, menu);
+ menu.findItem(R.id.delete).setOnMenuItemClickListener(this);
+ mMoveMenu = menu.findItem(R.id.move);
+ if (mFocusNoteDataItem.getParentId() == Notes.ID_CALL_RECORD_FOLDER
+ || DataUtils.getUserFolderCount(mContentResolver) == 0) {
+ mMoveMenu.setVisible(false);
+ } else {
+ mMoveMenu.setVisible(true);
+ mMoveMenu.setOnMenuItemClickListener(this);
+ }
+ mActionMode = mode;
+ mNotesListAdapter.setChoiceMode(true);
+ mNotesListView.setLongClickable(false);
+ mAddNewNote.setVisibility(View.GONE);
+
+ View customView = LayoutInflater.from(NotesListActivity.this).inflate(
+ R.layout.note_list_dropdown_menu, null);
+ mode.setCustomView(customView);
+ mDropDownMenu = new DropdownMenu(NotesListActivity.this,
+ (Button) customView.findViewById(R.id.selection_menu),
+ R.menu.note_list_dropdown);
+ mDropDownMenu.setOnDropdownMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){
+ public boolean onMenuItemClick(MenuItem item) {
+ mNotesListAdapter.selectAll(!mNotesListAdapter.isAllSelected());
+ updateMenu();
+ return true;
+ }
+
+ });
+ return true;
+ }
+
+ private void updateMenu() {
+ int selectedCount = mNotesListAdapter.getSelectedCount();
+ // Update dropdown menu
+ String format = getResources().getString(R.string.menu_select_title, selectedCount);
+ mDropDownMenu.setTitle(format);
+ MenuItem item = mDropDownMenu.findItem(R.id.action_select_all);
+ if (item != null) {
+ if (mNotesListAdapter.isAllSelected()) {
+ item.setChecked(true);
+ item.setTitle(R.string.menu_deselect_all);
+ } else {
+ item.setChecked(false);
+ item.setTitle(R.string.menu_select_all);
+ }
+ }
+ }
+
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void onDestroyActionMode(ActionMode mode) {
+ mNotesListAdapter.setChoiceMode(false);
+ mNotesListView.setLongClickable(true);
+ mAddNewNote.setVisibility(View.VISIBLE);
+ }
+
+ public void finishActionMode() {
+ mActionMode.finish();
+ }
+
+ public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
+ boolean checked) {
+ mNotesListAdapter.setCheckedItem(position, checked);
+ updateMenu();
+ }
+
+ public boolean onMenuItemClick(MenuItem item) {
+ if (mNotesListAdapter.getSelectedCount() == 0) {
+ Toast.makeText(NotesListActivity.this, getString(R.string.menu_select_none),
+ Toast.LENGTH_SHORT).show();
+ return true;
+ }
+
+ switch (item.getItemId()) {
+ case R.id.delete:
+ AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
+ builder.setTitle(getString(R.string.alert_title_delete));
+ builder.setIcon(android.R.drawable.ic_dialog_alert);
+ builder.setMessage(getString(R.string.alert_message_delete_notes,
+ mNotesListAdapter.getSelectedCount()));
+ builder.setPositiveButton(android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int which) {
+ batchDelete();
+ }
+ });
+ builder.setNegativeButton(android.R.string.cancel, null);
+ builder.show();
+ break;
+ case R.id.move:
+ startQueryDestinationFolders();
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+ }
+
+ private class NewNoteOnTouchListener implements OnTouchListener {
+
+ public boolean onTouch(View v, MotionEvent event) {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN: {
+ Display display = getWindowManager().getDefaultDisplay();
+ int screenHeight = display.getHeight();
+ int newNoteViewHeight = mAddNewNote.getHeight();
+ int start = screenHeight - newNoteViewHeight;
+ int eventY = start + (int) event.getY();
+ /**
+ * Minus TitleBar's height
+ */
+ if (mState == ListEditState.SUB_FOLDER) {
+ eventY -= mTitleBar.getHeight();
+ start -= mTitleBar.getHeight();
+ }
+ /**
+ * HACKME:When click the transparent part of "New Note" button, dispatch
+ * the event to the list view behind this button. The transparent part of
+ * "New Note" button could be expressed by formula y=-0.12x+94(Unit:pixel)
+ * and the line top of the button. The coordinate based on left of the "New
+ * Note" button. The 94 represents maximum height of the transparent part.
+ * Notice that, if the background of the button changes, the formula should
+ * also change. This is very bad, just for the UI designer's strong requirement.
+ */
+ if (event.getY() < (event.getX() * (-0.12) + 94)) {
+ View view = mNotesListView.getChildAt(mNotesListView.getChildCount() - 1
+ - mNotesListView.getFooterViewsCount());
+ if (view != null && view.getBottom() > start
+ && (view.getTop() < (start + 94))) {
+ mOriginY = (int) event.getY();
+ mDispatchY = eventY;
+ event.setLocation(event.getX(), mDispatchY);
+ mDispatch = true;
+ return mNotesListView.dispatchTouchEvent(event);
+ }
+ }
+ break;
+ }
+ case MotionEvent.ACTION_MOVE: {
+ if (mDispatch) {
+ mDispatchY += (int) event.getY() - mOriginY;
+ event.setLocation(event.getX(), mDispatchY);
+ return mNotesListView.dispatchTouchEvent(event);
+ }
+ break;
+ }
+ default: {
+ if (mDispatch) {
+ event.setLocation(event.getX(), mDispatchY);
+ mDispatch = false;
+ return mNotesListView.dispatchTouchEvent(event);
+ }
+ break;
+ }
+ }
+ return false;
+ }
+
+ };
+
+ private void startAsyncNotesListQuery() {
+ String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION
+ : NORMAL_SELECTION;
+<<<<<<< HEAD
+ mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
+ Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] {
+ String.valueOf(mCurrentFolderId)
+ }, NoteColumns.TOP+ " DESC,"+ NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
+=======
+ if(secret_mode == 0) {
+ mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
+ Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[]{
+ String.valueOf(mCurrentFolderId)
+ }, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
+ }
+ else{
+ String str1 = "5201314";
+ String [] PROJECTION = new String [] { //定义一个新的PROJECTION数组,只换掉SNIPPET
+ NoteColumns.ID,
+ NoteColumns.ALERTED_DATE,
+ NoteColumns.BG_COLOR_ID,
+ NoteColumns.CREATED_DATE,
+ NoteColumns.HAS_ATTACHMENT,
+ NoteColumns.MODIFIED_DATE,
+ NoteColumns.NOTES_COUNT,
+ NoteColumns.PARENT_ID,
+// NoteColumns.SNIPPET,
+ str1,
+ NoteColumns.TYPE,
+ NoteColumns.WIDGET_ID,
+ NoteColumns.WIDGET_TYPE,
+ };
+ mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
+ Notes.CONTENT_NOTE_URI, PROJECTION, selection, new String[]{
+ String.valueOf(mCurrentFolderId)
+ }, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
+
+ }
+>>>>>>> origin/Branch_liujie
+ }
+
+ private final class BackgroundQueryHandler extends AsyncQueryHandler {
+ public BackgroundQueryHandler(ContentResolver contentResolver) {
+ super(contentResolver);
+ }
+
+ @Override
+ protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
+ switch (token) {
+ case FOLDER_NOTE_LIST_QUERY_TOKEN:
+ mNotesListAdapter.changeCursor(cursor);
+ break;
+ case FOLDER_LIST_QUERY_TOKEN:
+ if (cursor != null && cursor.getCount() > 0) {
+ showFolderListMenu(cursor);
+ } else {
+ Log.e(TAG, "Query folder failed");
+ }
+ break;
+ default:
+ return;
+ }
+ }
+ }
+
+ private void showFolderListMenu(Cursor cursor) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
+ builder.setTitle(R.string.menu_title_select_folder);
+ final FoldersListAdapter adapter = new FoldersListAdapter(this, cursor);
+ builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
+
+ public void onClick(DialogInterface dialog, int which) {
+ DataUtils.batchMoveToFolder(mContentResolver,
+ mNotesListAdapter.getSelectedItemIds(), adapter.getItemId(which));
+ Toast.makeText(
+ NotesListActivity.this,
+ getString(R.string.format_move_notes_to_folder,
+ mNotesListAdapter.getSelectedCount(),
+ adapter.getFolderName(NotesListActivity.this, which)),
+ Toast.LENGTH_SHORT).show();
+ mModeCallBack.finishActionMode();
+ }
+ });
+ builder.show();
+ }
+
+ private void createNewNote() {
+ Intent intent = new Intent(this, NoteEditActivity.class);
+ intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
+ intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mCurrentFolderId);
+ this.startActivityForResult(intent, REQUEST_CODE_NEW_NODE);
+ }
+
+ private void batchDelete() {
+ new AsyncTask>() {
+ protected HashSet doInBackground(Void... unused) {
+ HashSet widgets = mNotesListAdapter.getSelectedWidget();
+ if (!isSyncMode()) {
+ // if not synced, delete notes directly
+ if (DataUtils.batchDeleteNotes(mContentResolver, mNotesListAdapter
+ .getSelectedItemIds())) {
+ } else {
+ Log.e(TAG, "Delete notes error, should not happens");
+ }
+ } else {
+ // in sync mode, we'll move the deleted note into the trash
+ // folder
+ if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter
+ .getSelectedItemIds(), Notes.ID_TRASH_FOLER)) {
+ Log.e(TAG, "Move notes to trash folder error, should not happens");
+ }
+ }
+ return widgets;
+ }
+
+ @Override
+ protected void onPostExecute(HashSet widgets) {
+ if (widgets != null) {
+ for (AppWidgetAttribute widget : widgets) {
+ if (widget.widgetId != AppWidgetManager.INVALID_APPWIDGET_ID
+ && widget.widgetType != Notes.TYPE_WIDGET_INVALIDE) {
+ updateWidget(widget.widgetId, widget.widgetType);
+ }
+ }
+ }
+ mModeCallBack.finishActionMode();
+ }
+ }.execute();
+ }
+
+ private void deleteFolder(long folderId) {
+ if (folderId == Notes.ID_ROOT_FOLDER) {
+ Log.e(TAG, "Wrong folder id, should not happen " + folderId);
+ return;
+ }
+
+ HashSet ids = new HashSet();
+ ids.add(folderId);
+ HashSet widgets = DataUtils.getFolderNoteWidget(mContentResolver,
+ folderId);
+ if (!isSyncMode()) {
+ // if not synced, delete folder directly
+ DataUtils.batchDeleteNotes(mContentResolver, ids);
+ } else {
+ // in sync mode, we'll move the deleted folder into the trash folder
+ DataUtils.batchMoveToFolder(mContentResolver, ids, Notes.ID_TRASH_FOLER);
+ }
+ if (widgets != null) {
+ for (AppWidgetAttribute widget : widgets) {
+ if (widget.widgetId != AppWidgetManager.INVALID_APPWIDGET_ID
+ && widget.widgetType != Notes.TYPE_WIDGET_INVALIDE) {
+ updateWidget(widget.widgetId, widget.widgetType);
+ }
+ }
+ }
+ }
+
+ private void openNode(NoteItemData data) {
+ Intent intent = new Intent(this, NoteEditActivity.class);
+ intent.setAction(Intent.ACTION_VIEW);
+ intent.putExtra(Intent.EXTRA_UID, data.getId());
+ this.startActivityForResult(intent, REQUEST_CODE_OPEN_NODE);
+ }
+
+ private void openFolder(NoteItemData data) {
+ mCurrentFolderId = data.getId();
+ startAsyncNotesListQuery();
+ if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
+ mState = ListEditState.CALL_RECORD_FOLDER;
+ mAddNewNote.setVisibility(View.GONE);
+ } else {
+ mState = ListEditState.SUB_FOLDER;
+ }
+ if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
+ mTitleBar.setText(R.string.call_record_folder_name);
+ } else {
+ mTitleBar.setText(data.getSnippet());
+ }
+ mTitleBar.setVisibility(View.VISIBLE);
+ }
+
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.btn_new_note:
+ createNewNote();
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void showSoftInput() {
+ InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (inputMethodManager != null) {
+ inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+ }
+ }
+
+ private void hideSoftInput(View view) {
+ InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
+ }
+
+ private void showCreateOrModifyFolderDialog(final boolean create) {
+ final AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
+ final EditText etName = (EditText) view.findViewById(R.id.et_foler_name);
+ showSoftInput();
+ if (!create) {
+ if (mFocusNoteDataItem != null) {
+ etName.setText(mFocusNoteDataItem.getSnippet());
+ builder.setTitle(getString(R.string.menu_folder_change_name));
+ } else {
+ Log.e(TAG, "The long click data item is null");
+ return;
+ }
+ } else {
+ etName.setText("");
+ builder.setTitle(this.getString(R.string.menu_create_folder));
+ }
+
+ builder.setPositiveButton(android.R.string.ok, null);
+ builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ hideSoftInput(etName);
+ }
+ });
+
+ final Dialog dialog = builder.setView(view).show();
+ final Button positive = (Button)dialog.findViewById(android.R.id.button1);
+ positive.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ hideSoftInput(etName);
+ String name = etName.getText().toString();
+ if (DataUtils.checkVisibleFolderName(mContentResolver, name)) {
+ Toast.makeText(NotesListActivity.this, getString(R.string.folder_exist, name),
+ Toast.LENGTH_LONG).show();
+ etName.setSelection(0, etName.length());
+ return;
+ }
+ if (!create) {
+ if (!TextUtils.isEmpty(name)) {
+ ContentValues values = new ContentValues();
+ values.put(NoteColumns.SNIPPET, name);
+ values.put(NoteColumns.TYPE, Notes.TYPE_FOLDER);
+ values.put(NoteColumns.LOCAL_MODIFIED, 1);
+ mContentResolver.update(Notes.CONTENT_NOTE_URI, values, NoteColumns.ID
+ + "=?", new String[] {
+ String.valueOf(mFocusNoteDataItem.getId())
+ });
+ }
+ } else if (!TextUtils.isEmpty(name)) {
+ ContentValues values = new ContentValues();
+ values.put(NoteColumns.SNIPPET, name);
+ values.put(NoteColumns.TYPE, Notes.TYPE_FOLDER);
+ mContentResolver.insert(Notes.CONTENT_NOTE_URI, values);
+ }
+ dialog.dismiss();
+ }
+ });
+
+ if (TextUtils.isEmpty(etName.getText())) {
+ positive.setEnabled(false);
+ }
+ /**
+ * When the name edit text is null, disable the positive button
+ */
+ etName.addTextChangedListener(new TextWatcher() {
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ if (TextUtils.isEmpty(etName.getText())) {
+ positive.setEnabled(false);
+ } else {
+ positive.setEnabled(true);
+ }
+ }
+
+ public void afterTextChanged(Editable s) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ }
+
+ @Override
+ public void onBackPressed() {
+ switch (mState) {
+ case SUB_FOLDER:
+ mCurrentFolderId = Notes.ID_ROOT_FOLDER;
+ mState = ListEditState.NOTE_LIST;
+ startAsyncNotesListQuery();
+ mTitleBar.setVisibility(View.GONE);
+ break;
+ case CALL_RECORD_FOLDER:
+ mCurrentFolderId = Notes.ID_ROOT_FOLDER;
+ mState = ListEditState.NOTE_LIST;
+ mAddNewNote.setVisibility(View.VISIBLE);
+ mTitleBar.setVisibility(View.GONE);
+ startAsyncNotesListQuery();
+ break;
+ case NOTE_LIST:
+ super.onBackPressed();
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void updateWidget(int appWidgetId, int appWidgetType) {
+ Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
+ if (appWidgetType == Notes.TYPE_WIDGET_2X) {
+ intent.setClass(this, NoteWidgetProvider_2x.class);
+ } else if (appWidgetType == Notes.TYPE_WIDGET_4X) {
+ intent.setClass(this, NoteWidgetProvider_4x.class);
+ } else {
+ Log.e(TAG, "Unspported widget type");
+ return;
+ }
+
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] {
+ appWidgetId
+ });
+
+ sendBroadcast(intent);
+ setResult(RESULT_OK, intent);
+ }
+
+ private final OnCreateContextMenuListener mFolderOnCreateContextMenuListener = new OnCreateContextMenuListener() {
+ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
+ if (mFocusNoteDataItem != null) {
+ menu.setHeaderTitle(mFocusNoteDataItem.getSnippet());
+ menu.add(0, MENU_FOLDER_VIEW, 0, R.string.menu_folder_view);
+ menu.add(0, MENU_FOLDER_DELETE, 0, R.string.menu_folder_delete);
+ menu.add(0, MENU_FOLDER_CHANGE_NAME, 0, R.string.menu_folder_change_name);
+ }
+ }
+ };
+
+ @Override
+ public void onContextMenuClosed(Menu menu) {
+ if (mNotesListView != null) {
+ mNotesListView.setOnCreateContextMenuListener(null);
+ }
+ super.onContextMenuClosed(menu);
+ }
+
+ @Override
+ public boolean onContextItemSelected(MenuItem item) {
+ if (mFocusNoteDataItem == null) {
+ Log.e(TAG, "The long click data item is null");
+ return false;
+ }
+ switch (item.getItemId()) {
+ case MENU_FOLDER_VIEW:
+ openFolder(mFocusNoteDataItem);
+ break;
+ case MENU_FOLDER_DELETE:
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(getString(R.string.alert_title_delete));
+ builder.setIcon(android.R.drawable.ic_dialog_alert);
+ builder.setMessage(getString(R.string.alert_message_delete_folder));
+ builder.setPositiveButton(android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ deleteFolder(mFocusNoteDataItem.getId());
+ }
+ });
+ builder.setNegativeButton(android.R.string.cancel, null);
+ builder.show();
+ break;
+ case MENU_FOLDER_CHANGE_NAME:
+ showCreateOrModifyFolderDialog(false);
+ break;
+ default:
+ break;
+ }
+
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ menu.clear();
+<<<<<<< HEAD
+=======
+
+>>>>>>> origin/Branch_liujie
+ if (mState == ListEditState.NOTE_LIST) {
+ getMenuInflater().inflate(R.menu.note_list, menu);
+ // set sync or sync_cancel
+ menu.findItem(R.id.menu_sync).setTitle(
+ GTaskSyncService.isSyncing() ? R.string.menu_sync_cancel : R.string.menu_sync);
+ } else if (mState == ListEditState.SUB_FOLDER) {
+ getMenuInflater().inflate(R.menu.sub_folder, menu);
+ } else if (mState == ListEditState.CALL_RECORD_FOLDER) {
+ getMenuInflater().inflate(R.menu.call_record_folder, menu);
+ } else {
+ Log.e(TAG, "Wrong state:" + mState);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.menu_new_folder: {
+ showCreateOrModifyFolderDialog(true);
+ break;
+ }
+<<<<<<< HEAD
+=======
+ case R.id.menu_secret: { //进入私密模式
+ secret_mode = 1;
+ AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
+ dialog.setTitle("重要提醒");
+ dialog.setMessage("您确认进入私密模式吗?");
+ dialog.setCancelable(false);
+ dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ startAsyncNotesListQuery();
+ Toast.makeText(NotesListActivity.this,"您已进入私密模式",Toast.LENGTH_SHORT).show();
+ }
+ });
+ dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which){}
+ });
+ dialog.show();
+ startAsyncNotesListQuery();
+ Toast.makeText(this,"您已进入私密模式",Toast.LENGTH_SHORT).show();
+ break;
+ }
+ case R.id.menu_quit_secret:{ //退出私密模式
+ secret_mode = 0;
+ AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
+ dialog.setTitle("重要提醒");
+ dialog.setMessage("您确认退出私密模式吗?");
+ dialog.setCancelable(false);
+ dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ startAsyncNotesListQuery();
+ Toast.makeText(NotesListActivity.this,"您已退出私密模式",Toast.LENGTH_SHORT).show();
+ }
+ });
+ dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which){}
+ });
+ dialog.show();
+ break;
+ }
+>>>>>>> origin/Branch_liujie
+ case R.id.menu_export_text: {
+ exportNoteToText();
+ break;
+ }
+ case R.id.menu_sync: {
+ if (isSyncMode()) {
+ if (TextUtils.equals(item.getTitle(), getString(R.string.menu_sync))) {
+ GTaskSyncService.startSync(this);
+ } else {
+ GTaskSyncService.cancelSync(this);
+ }
+ } else {
+ startPreferenceActivity();
+ }
+ break;
+ }
+ case R.id.menu_setting: {
+ startPreferenceActivity();
+ break;
+ }
+ case R.id.menu_new_note: {
+ createNewNote();
+ break;
+ }
+ case R.id.menu_search:
+ onSearchRequested();
+ break;
+ default:
+ break;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onSearchRequested() {
+ startSearch(null, false, null /* appData */, false);
+ return true;
+ }
+
+ private void exportNoteToText() {
+ final BackupUtils backup = BackupUtils.getInstance(NotesListActivity.this);
+ new AsyncTask() {
+
+ @Override
+ protected Integer doInBackground(Void... unused) {
+ return backup.exportToText();
+ }
+
+ @Override
+ protected void onPostExecute(Integer result) {
+ if (result == BackupUtils.STATE_SD_CARD_UNMOUONTED) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
+ builder.setTitle(NotesListActivity.this
+ .getString(R.string.failed_sdcard_export));
+ builder.setMessage(NotesListActivity.this
+ .getString(R.string.error_sdcard_unmounted));
+ builder.setPositiveButton(android.R.string.ok, null);
+ builder.show();
+ } else if (result == BackupUtils.STATE_SUCCESS) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
+ builder.setTitle(NotesListActivity.this
+ .getString(R.string.success_sdcard_export));
+ builder.setMessage(NotesListActivity.this.getString(
+ R.string.format_exported_file_location, backup
+ .getExportedTextFileName(), backup.getExportedTextFileDir()));
+ builder.setPositiveButton(android.R.string.ok, null);
+ builder.show();
+ } else if (result == BackupUtils.STATE_SYSTEM_ERROR) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
+ builder.setTitle(NotesListActivity.this
+ .getString(R.string.failed_sdcard_export));
+ builder.setMessage(NotesListActivity.this
+ .getString(R.string.error_sdcard_export));
+ builder.setPositiveButton(android.R.string.ok, null);
+ builder.show();
+ }
+ }
+
+ }.execute();
+ }
+
+ private boolean isSyncMode() {
+ return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
+ }
+
+ private void startPreferenceActivity() {
+ Activity from = getParent() != null ? getParent() : this;
+ Intent intent = new Intent(from, NotesPreferenceActivity.class);
+ from.startActivityIfNeeded(intent, -1);
+ }
+
+ private class OnListItemClickListener implements OnItemClickListener {
+
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ if (view instanceof NotesListItem) {
+ NoteItemData item = ((NotesListItem) view).getItemData();
+ if (mNotesListAdapter.isInChoiceMode()) {
+ if (item.getType() == Notes.TYPE_NOTE) {
+ position = position - mNotesListView.getHeaderViewsCount();
+ mModeCallBack.onItemCheckedStateChanged(null, position, id,
+ !mNotesListAdapter.isSelectedItem(position));
+ }
+ return;
+ }
+
+ switch (mState) {
+ case NOTE_LIST:
+ if (item.getType() == Notes.TYPE_FOLDER
+ || item.getType() == Notes.TYPE_SYSTEM) {
+ openFolder(item);
+ } else if (item.getType() == Notes.TYPE_NOTE) {
+ openNode(item);
+ } else {
+ Log.e(TAG, "Wrong note type in NOTE_LIST");
+ }
+ break;
+ case SUB_FOLDER:
+ case CALL_RECORD_FOLDER:
+ if (item.getType() == Notes.TYPE_NOTE) {
+ openNode(item);
+ } else {
+ Log.e(TAG, "Wrong note type in SUB_FOLDER");
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ }
+
+ private void startQueryDestinationFolders() {
+ String selection = NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>? AND " + NoteColumns.ID + "<>?";
+ selection = (mState == ListEditState.NOTE_LIST) ? selection:
+ "(" + selection + ") OR (" + NoteColumns.ID + "=" + Notes.ID_ROOT_FOLDER + ")";
+
+ mBackgroundQueryHandler.startQuery(FOLDER_LIST_QUERY_TOKEN,
+ null,
+ Notes.CONTENT_NOTE_URI,
+ FoldersListAdapter.PROJECTION,
+ selection,
+ new String[] {
+ String.valueOf(Notes.TYPE_FOLDER),
+ String.valueOf(Notes.ID_TRASH_FOLER),
+ String.valueOf(mCurrentFolderId)
+ },
+ NoteColumns.MODIFIED_DATE + " DESC");
+ }
+
+ public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) {
+ if (view instanceof NotesListItem) {
+ mFocusNoteDataItem = ((NotesListItem) view).getItemData();
+ if (mFocusNoteDataItem.getType() == Notes.TYPE_NOTE && !mNotesListAdapter.isInChoiceMode()) {
+ if (mNotesListView.startActionMode(mModeCallBack) != null) {
+ mModeCallBack.onItemCheckedStateChanged(null, position, id, true);
+ mNotesListView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
+ } else {
+ Log.e(TAG, "startActionMode fails");
+ }
+ } else if (mFocusNoteDataItem.getType() == Notes.TYPE_FOLDER) {
+ mNotesListView.setOnCreateContextMenuListener(mFolderOnCreateContextMenuListener);
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/app/src/main/java/net/micode/notes/ui/NotesListItem.java b/src/app/src/main/java/net/micode/notes/ui/NotesListItem.java
index 2746619..c48825f 100644
--- a/src/app/src/main/java/net/micode/notes/ui/NotesListItem.java
+++ b/src/app/src/main/java/net/micode/notes/ui/NotesListItem.java
@@ -37,7 +37,10 @@ public class NotesListItem extends LinearLayout {
private TextView mCallName;
private NoteItemData mItemData;
private CheckBox mCheckBox;
+<<<<<<< HEAD
private ImageView mTop;
+=======
+>>>>>>> origin/Branch_liujie
public NotesListItem(Context context) {
super(context);
@@ -47,7 +50,10 @@ public class NotesListItem extends LinearLayout {
mTime = (TextView) findViewById(R.id.tv_time);
mCallName = (TextView) findViewById(R.id.tv_name);
mCheckBox = (CheckBox) findViewById(android.R.id.checkbox);
+<<<<<<< HEAD
mTop = (ImageView) findViewById(R.id.iv_top_icon);
+=======
+>>>>>>> origin/Branch_liujie
}
public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) {
@@ -95,20 +101,26 @@ public class NotesListItem extends LinearLayout {
mAlert.setVisibility(View.GONE);
}
}
+<<<<<<< HEAD
if(data.isTOP()){
mTop.setImageResource(R.drawable.menu_top);
mTop.setVisibility(View.VISIBLE);
} else{
mTop.setVisibility((View.GONE));
}
+=======
+>>>>>>> origin/Branch_liujie
}
mTime.setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate()));
setBackground(data);
}
+<<<<<<< HEAD
+=======
+>>>>>>> origin/Branch_liujie
private void setBackground(NoteItemData data) {
int id = data.getBgColorId();
if (data.getType() == Notes.TYPE_NOTE) {
diff --git a/src/app/src/main/java/net/micode/notes/ui/NotesListItem.java.orig b/src/app/src/main/java/net/micode/notes/ui/NotesListItem.java.orig
new file mode 100644
index 0000000..c48825f
--- /dev/null
+++ b/src/app/src/main/java/net/micode/notes/ui/NotesListItem.java.orig
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.micode.notes.ui;
+
+import android.content.Context;
+import android.text.format.DateUtils;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import net.micode.notes.R;
+import net.micode.notes.data.Notes;
+import net.micode.notes.tool.DataUtils;
+import net.micode.notes.tool.ResourceParser.NoteItemBgResources;
+
+
+public class NotesListItem extends LinearLayout {
+ private ImageView mAlert;
+ private TextView mTitle;
+ private TextView mTime;
+ private TextView mCallName;
+ private NoteItemData mItemData;
+ private CheckBox mCheckBox;
+<<<<<<< HEAD
+ private ImageView mTop;
+=======
+>>>>>>> origin/Branch_liujie
+
+ public NotesListItem(Context context) {
+ super(context);
+ inflate(context, R.layout.note_item, this);
+ mAlert = (ImageView) findViewById(R.id.iv_alert_icon);
+ mTitle = (TextView) findViewById(R.id.tv_title);
+ mTime = (TextView) findViewById(R.id.tv_time);
+ mCallName = (TextView) findViewById(R.id.tv_name);
+ mCheckBox = (CheckBox) findViewById(android.R.id.checkbox);
+<<<<<<< HEAD
+ mTop = (ImageView) findViewById(R.id.iv_top_icon);
+=======
+>>>>>>> origin/Branch_liujie
+ }
+
+ public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) {
+ if (choiceMode && data.getType() == Notes.TYPE_NOTE) {
+ mCheckBox.setVisibility(View.VISIBLE);
+ mCheckBox.setChecked(checked);
+ } else {
+ mCheckBox.setVisibility(View.GONE);
+ }
+
+ mItemData = data;
+ if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
+ mCallName.setVisibility(View.GONE);
+ mAlert.setVisibility(View.VISIBLE);
+ mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem);
+ mTitle.setText(context.getString(R.string.call_record_folder_name)
+ + context.getString(R.string.format_folder_files_count, data.getNotesCount()));
+ mAlert.setImageResource(R.drawable.call_record);
+ } else if (data.getParentId() == Notes.ID_CALL_RECORD_FOLDER) {
+ mCallName.setVisibility(View.VISIBLE);
+ mCallName.setText(data.getCallName());
+ mTitle.setTextAppearance(context,R.style.TextAppearanceSecondaryItem);
+ mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet()));
+ if (data.hasAlert()) {
+ mAlert.setImageResource(R.drawable.clock);
+ mAlert.setVisibility(View.VISIBLE);
+ } else {
+ mAlert.setVisibility(View.GONE);
+ }
+ } else {
+ mCallName.setVisibility(View.GONE);
+ mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem);
+
+ if (data.getType() == Notes.TYPE_FOLDER) {
+ mTitle.setText(data.getSnippet()
+ + context.getString(R.string.format_folder_files_count,
+ data.getNotesCount()));
+ mAlert.setVisibility(View.GONE);
+ } else {
+ mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet()));
+ if (data.hasAlert()) {
+ mAlert.setImageResource(R.drawable.clock);
+ mAlert.setVisibility(View.VISIBLE);
+ } else {
+ mAlert.setVisibility(View.GONE);
+ }
+ }
+<<<<<<< HEAD
+ if(data.isTOP()){
+ mTop.setImageResource(R.drawable.menu_top);
+ mTop.setVisibility(View.VISIBLE);
+ } else{
+ mTop.setVisibility((View.GONE));
+ }
+=======
+>>>>>>> origin/Branch_liujie
+ }
+ mTime.setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate()));
+
+ setBackground(data);
+ }
+
+<<<<<<< HEAD
+
+
+=======
+>>>>>>> origin/Branch_liujie
+ private void setBackground(NoteItemData data) {
+ int id = data.getBgColorId();
+ if (data.getType() == Notes.TYPE_NOTE) {
+ if (data.isSingle() || data.isOneFollowingFolder()) {
+ setBackgroundResource(NoteItemBgResources.getNoteBgSingleRes(id));
+ } else if (data.isLast()) {
+ setBackgroundResource(NoteItemBgResources.getNoteBgLastRes(id));
+ } else if (data.isFirst() || data.isMultiFollowingFolder()) {
+ setBackgroundResource(NoteItemBgResources.getNoteBgFirstRes(id));
+ } else {
+ setBackgroundResource(NoteItemBgResources.getNoteBgNormalRes(id));
+ }
+ } else {
+ setBackgroundResource(NoteItemBgResources.getFolderBgRes());
+ }
+ }
+
+ public NoteItemData getItemData() {
+ return mItemData;
+ }
+}
diff --git a/src/app/src/main/res/color/primary_text_dark.xml b/src/app/src/main/res/color/primary_text_dark.xml
index ceef389..d488e27 100644
--- a/src/app/src/main/res/color/primary_text_dark.xml
+++ b/src/app/src/main/res/color/primary_text_dark.xml
@@ -19,4 +19,8 @@
+<<<<<<< HEAD
+=======
+
+>>>>>>> origin/Branch_liujie
diff --git a/src/app/src/main/res/color/primary_text_dark.xml.orig b/src/app/src/main/res/color/primary_text_dark.xml.orig
new file mode 100644
index 0000000..d488e27
--- /dev/null
+++ b/src/app/src/main/res/color/primary_text_dark.xml.orig
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+<<<<<<< HEAD
+
+=======
+
+>>>>>>> origin/Branch_liujie
diff --git a/src/app/src/main/res/color/secondary_text_dark.xml b/src/app/src/main/res/color/secondary_text_dark.xml
index f0de0f5..4ac31f3 100644
--- a/src/app/src/main/res/color/secondary_text_dark.xml
+++ b/src/app/src/main/res/color/secondary_text_dark.xml
@@ -17,6 +17,10 @@
+<<<<<<< HEAD
+=======
+
+>>>>>>> origin/Branch_liujie
diff --git a/src/app/src/main/res/color/secondary_text_dark.xml.orig b/src/app/src/main/res/color/secondary_text_dark.xml.orig
new file mode 100644
index 0000000..4ac31f3
--- /dev/null
+++ b/src/app/src/main/res/color/secondary_text_dark.xml.orig
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+<<<<<<< HEAD
+
+
+
+=======
+
+>>>>>>> origin/Branch_liujie
diff --git a/src/app/src/main/res/layout/account_dialog_title.xml b/src/app/src/main/res/layout/account_dialog_title.xml
index 5f2ebce..a4c09fc 100644
--- a/src/app/src/main/res/layout/account_dialog_title.xml
+++ b/src/app/src/main/res/layout/account_dialog_title.xml
@@ -15,15 +15,24 @@
limitations under the License.
-->
+<<<<<<< HEAD
+=======
+
+>>>>>>> origin/Branch_liujie
+=======
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:gravity="center"
+ android:layout_marginTop="-2.7dip"
+ android:layout_marginBottom="-2.7dip"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"/>
+>>>>>>> origin/Branch_liujie
+=======
+ android:gravity="center"/>
+>>>>>>> origin/Branch_liujie
\ No newline at end of file
diff --git a/src/app/src/main/res/layout/account_dialog_title.xml.orig b/src/app/src/main/res/layout/account_dialog_title.xml.orig
new file mode 100644
index 0000000..a4c09fc
--- /dev/null
+++ b/src/app/src/main/res/layout/account_dialog_title.xml.orig
@@ -0,0 +1,65 @@
+
+
+
+
+<<<<<<< HEAD
+
+=======
+
+>>>>>>> origin/Branch_liujie
+
+
+=======
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:gravity="center"
+ android:layout_marginTop="-2.7dip"
+ android:layout_marginBottom="-2.7dip"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"/>
+>>>>>>> origin/Branch_liujie
+
+
+=======
+ android:gravity="center"/>
+>>>>>>> origin/Branch_liujie
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/layout/note_edit.xml b/src/app/src/main/res/layout/note_edit.xml
index 76d8aae..ea5fea6 100644
--- a/src/app/src/main/res/layout/note_edit.xml
+++ b/src/app/src/main/res/layout/note_edit.xml
@@ -15,7 +15,11 @@
limitations under the License.
-->
+<<<<<<< HEAD
>>>>>> origin/Branch_liujie
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/list_background"
@@ -26,6 +30,7 @@
android:layout_height="fill_parent"
android:orientation="vertical">
+<<<<<<< HEAD
+=======
+>>>>>>> origin/Branch_liujie
+<<<<<<< HEAD
@@ -64,6 +72,8 @@
+=======
+>>>>>>> origin/Branch_liujie
+<<<<<<< HEAD
+=======
+
+>>>>>>> origin/Branch_liujie
+=======
+ android:layout_height="fill_parent">
+>>>>>>> origin/Branch_liujie
+<<<<<<< HEAD
+=======
+>>>>>>> origin/Branch_liujie
>>>>>> origin/Branch_liujie
android:layout_height="43dip"
android:layout_width="wrap_content"
android:background="@drawable/bg_color_btn_mask"
diff --git a/src/app/src/main/res/layout/note_edit.xml.orig b/src/app/src/main/res/layout/note_edit.xml.orig
new file mode 100644
index 0000000..ea5fea6
--- /dev/null
+++ b/src/app/src/main/res/layout/note_edit.xml.orig
@@ -0,0 +1,487 @@
+
+
+
+
+<<<<<<< HEAD
+>>>>>> origin/Branch_liujie
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@drawable/list_background"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+
+
+<<<<<<< HEAD
+
+
+
+=======
+>>>>>>> origin/Branch_liujie
+
+
+<<<<<<< HEAD
+
+
+
+
+
+
+
+
+
+
+
+=======
+>>>>>>> origin/Branch_liujie
+
+
+
+
+
+
+<<<<<<< HEAD
+
+
+
+
+=======
+
+>>>>>>> origin/Branch_liujie
+
+
+
+
+
+
+
+
+
+=======
+ android:layout_height="fill_parent">
+>>>>>>> origin/Branch_liujie
+
+
+
+
+
+
+
+<<<<<<< HEAD
+
+
+
+
+=======
+>>>>>>> origin/Branch_liujie
+
+
+
+
+ >>>>>> origin/Branch_liujie
+ android:layout_height="43dip"
+ android:layout_width="wrap_content"
+ android:background="@drawable/bg_color_btn_mask"
+ android:layout_gravity="top|right" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/res/layout/note_item.xml b/src/app/src/main/res/layout/note_item.xml
index 10d6eae..cdd0819 100644
--- a/src/app/src/main/res/layout/note_item.xml
+++ b/src/app/src/main/res/layout/note_item.xml
@@ -75,6 +75,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"/>
+<<<<<<< HEAD
+=======
+>>>>>>> origin/Branch_liujie
diff --git a/src/app/src/main/res/layout/note_item.xml.orig b/src/app/src/main/res/layout/note_item.xml.orig
new file mode 100644
index 0000000..cdd0819
--- /dev/null
+++ b/src/app/src/main/res/layout/note_item.xml.orig
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<<<<<<< HEAD
+
+
+
+=======
+>>>>>>> origin/Branch_liujie
+
diff --git a/src/app/src/main/res/layout/note_list.xml b/src/app/src/main/res/layout/note_list.xml
index 321381a..0c318a1 100644
--- a/src/app/src/main/res/layout/note_list.xml
+++ b/src/app/src/main/res/layout/note_list.xml
@@ -39,6 +39,7 @@
+=======
+ android:layout_width="fill_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1"
+ android:cacheColorHint="@null"
+ android:listSelector="@android:color/transparent"
+ android:divider="@null"
+ android:fadingEdge="@null" />
+>>>>>>> origin/Branch_liujie
+=======
+ android:background="@drawable/new_note"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:focusable="false"
+ android:layout_gravity="bottom" />
+>>>>>>> origin/Branch_liujie
diff --git a/src/app/src/main/res/layout/note_list.xml.orig b/src/app/src/main/res/layout/note_list.xml.orig
new file mode 100644
index 0000000..0c318a1
--- /dev/null
+++ b/src/app/src/main/res/layout/note_list.xml.orig
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+=======
+ android:layout_width="fill_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1"
+ android:cacheColorHint="@null"
+ android:listSelector="@android:color/transparent"
+ android:divider="@null"
+ android:fadingEdge="@null" />
+>>>>>>> origin/Branch_liujie
+
+
+
+=======
+ android:background="@drawable/new_note"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:focusable="false"
+ android:layout_gravity="bottom" />
+>>>>>>> origin/Branch_liujie
+
diff --git a/src/app/src/main/res/menu/call_note_edit.xml b/src/app/src/main/res/menu/call_note_edit.xml
index e314fbd..afd2740 100644
--- a/src/app/src/main/res/menu/call_note_edit.xml
+++ b/src/app/src/main/res/menu/call_note_edit.xml
@@ -45,8 +45,11 @@
+<<<<<<< HEAD
+=======
+>>>>>>> origin/Branch_liujie
diff --git a/src/app/src/main/res/menu/call_note_edit.xml.orig b/src/app/src/main/res/menu/call_note_edit.xml.orig
new file mode 100644
index 0000000..afd2740
--- /dev/null
+++ b/src/app/src/main/res/menu/call_note_edit.xml.orig
@@ -0,0 +1,55 @@
+
+
+
+
+
diff --git a/src/app/src/main/res/menu/note_edit.xml b/src/app/src/main/res/menu/note_edit.xml
index 514d3f7..1ba0127 100644
--- a/src/app/src/main/res/menu/note_edit.xml
+++ b/src/app/src/main/res/menu/note_edit.xml
@@ -23,6 +23,7 @@
android:title="@string/notelist_menu_new"/>
@@ -31,11 +32,17 @@
android:title="@string/menu_cancel_top"/>
>>>>>> origin/Branch_liujie
android:id="@+id/menu_delete"
android:title="@string/menu_delete"/>
>>>>>> origin/Branch_liujie
android:title="@string/menu_font_size"/>
+=======
+ android:id="@+id/menu_count_word"
+ android:title="@string/menu_count_word" />
+
+
+
+
+
+>>>>>>> origin/Branch_liujie
\ No newline at end of file
diff --git a/src/app/src/main/res/menu/note_edit.xml.orig b/src/app/src/main/res/menu/note_edit.xml.orig
new file mode 100644
index 0000000..1ba0127
--- /dev/null
+++ b/src/app/src/main/res/menu/note_edit.xml.orig
@@ -0,0 +1,85 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/menu/note_list.xml b/src/app/src/main/res/menu/note_list.xml
index 42ea736..5246fba 100644
--- a/src/app/src/main/res/menu/note_list.xml
+++ b/src/app/src/main/res/menu/note_list.xml
@@ -36,4 +36,17 @@
+<<<<<<< HEAD
+=======
+
+
+
+
+
+
+>>>>>>> origin/Branch_liujie
diff --git a/src/app/src/main/res/menu/note_list.xml.orig b/src/app/src/main/res/menu/note_list.xml.orig
new file mode 100644
index 0000000..5246fba
--- /dev/null
+++ b/src/app/src/main/res/menu/note_list.xml.orig
@@ -0,0 +1,52 @@
+
+
+
+
+
diff --git a/src/app/src/main/res/menu/note_list_options.xml b/src/app/src/main/res/menu/note_list_options.xml
index 25788f8..92633d0 100644
--- a/src/app/src/main/res/menu/note_list_options.xml
+++ b/src/app/src/main/res/menu/note_list_options.xml
@@ -16,12 +16,20 @@
-->
\ No newline at end of file
diff --git a/src/app/src/main/res/menu/sub_folder.xml.orig b/src/app/src/main/res/menu/sub_folder.xml.orig
new file mode 100644
index 0000000..d0134a0
--- /dev/null
+++ b/src/app/src/main/res/menu/sub_folder.xml.orig
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+=======
+ android:id="@+id/menu_secret"
+ android:title="@string/menu_secret"/>
+
+
+>>>>>>> origin/Branch_liujie
+
\ No newline at end of file
diff --git a/src/app/src/main/res/values-ko-rKR/arrays.xml b/src/app/src/main/res/values-ko-rKR/arrays.xml
new file mode 100644
index 0000000..a092386
--- /dev/null
+++ b/src/app/src/main/res/values-ko-rKR/arrays.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+ 短信
+ 邮件
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/values-ko-rKR/strings.xml b/src/app/src/main/res/values-ko-rKR/strings.xml
new file mode 100644
index 0000000..4f95a76
--- /dev/null
+++ b/src/app/src/main/res/values-ko-rKR/strings.xml
@@ -0,0 +1,140 @@
+
+
+
+
+
+ 메일
+ 단어 수를 계산합니다
+ 암호를 설정하세요
+ 비밀번호 삭제
+ 개인 정보 보호 모드
+ 비공개 모드를 종료합니다
+ 메일 2x2
+ 메일 4x4
+ 연합되는 주를 창조하기 위하여 찾아내는 연합되는 주 없음, 누르기.
+ 기밀 형태는, 주 내용을 볼 수 없다
+ ...
+ 새 메모
+ 미리 알림 성공적으로 삭제
+ 알람 생성
+ 기간이 만료됨
+ yyyyMMdd
+ MMMd kk:mm
+ 알겠어요
+ 보기
+ 호출 전화
+ 전자 우편 보내기
+ 웹 페이지 찾아보기
+ 지도 열기
+
+ /MIUI/notes/
+ notes_%s.txt
+
+ (%d)
+ 새 폴더 만들기
+ 텍스트 내보내기
+ 동기화
+ 동기화 해제
+ 설정
+ 검색
+ 삭제
+ 편지함으로 이동
+ %d 항목 선택됨
+ 선택된 항목이 없습니다. 작업이 올바르지 않습니다
+ 모두 선택
+ 모두 선택 해제
+ 텍스트 크기
+ 작은
+ 가운데
+ 큰
+ 초대
+ 상세한 명부 본에 들어간다
+ 목록 모드 끝내기
+ 폴더 보기
+ 폴더 삭제
+ 폴더 이름 바꾸기
+ 폴더%1 s이 (가) 이미 존재합니다. 이름을 바꾸십시오.
+ 나누기
+ 데스크톱으로 보내기
+ 깨우쳐 주다
+ 알람 삭제
+ 편지함 선택
+ 상위 디렉토리r
+ 데스크톱에 추가됨
+ 폴더 및 그 아래에 있는 메모를 삭제하시겠습니까?
+ 삭제
+ 선택한%d 노트를 삭제하시겠습니까?
+ 이 메모 지우시겠습니까?
+ 선택한%1달러 d 노트북은%2달러 s 폴더에 옮겨졌습니다
+
+ SD 카드가 사용되어 운영되지 않고 있습니다
+ 텍스트를 내보낼 때 오류가 발생했습니다. SD 카드를 확인하십시오.
+ 확인할 노트가 없습니다
+ 빈 노트북에 알람을 설정할 수 없습니다
+ 데스크톱에 빈 메모 보낼 수 없음
+ 내보내기 성공
+ 내보내기 실패
+ 텍스트 파일 (%1$s)을 SD 카드에서 출력했습니다 (%2$s) 디렉터리로
+
+ 동기화 메모 …
+ 동기화 성공
+ 동기화 실패
+ 동기화 해제
+ %1$s 동기화 성공
+ 동기화에 실패했습니다. 네트워크와 계정 설정을 확인하십시오.
+ 동기화 실패, 내부 오류 발생
+ 동기화 해제
+ 로그인%1$s …
+ 서버 메모 목록 가져오는 중 …
+ 로컬 메모 동기화 중 …
+
+ 설정
+ 동기화 계정
+ google task와 나란히 메모
+ 지난 번에%1$s 동기화
+ yyyy-MM-dd hh:mm:ss
+ 계좌 번호 추가
+ 계좌 번호를 바꾸다
+ 계정 삭제
+ 취소
+ 지금 동기화
+ 동기화 해제
+ 커런트 계정%1$s
+ 동기식 계정 변경시 과거 계정 동기식 정보가 지워지므로 재전환시 데이터가 중복될 수 있습니다.
+ 동기화 메모
+ 이 계정의 구글 작업 내용과 동기화하기 위해 구글 계정을 선택하십시오
+ 동기화하는 중 계정 정보를 수정할 수 없습니다.
+ 계정이%1$s로 설정되었습니다.
+ 새 메모 배경 색상 임의적으로
+
+ 삭제
+ 통화 메모
+ 이름을 입력하십시오.
+
+ 메모 찾는 중
+ 메모 찾기
+ 메모의 글
+ 메모
+ 설정
+ 취소
+
+ %1$s result for \"%2$s\"
+
+ %1$s 가닥입니다“%2$s” 검색 결과에 부합하는
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/values-zh-rCN/strings.xml b/src/app/src/main/res/values-zh-rCN/strings.xml
index 658f3d3..c31245b 100644
--- a/src/app/src/main/res/values-zh-rCN/strings.xml
+++ b/src/app/src/main/res/values-zh-rCN/strings.xml
@@ -18,14 +18,25 @@
便签
+<<<<<<< HEAD
+=======
+ 统计字数
+ 设定密码
+ 删除密码
+ 私密模式
+ 退出私密模式
+>>>>>>> origin/Branch_liujie
便签2x2便签4x4没有关联内容,点击新建便签。访客模式下,便签内容不可见...新建便签
+<<<<<<< HEAD
置顶签取消置顶
+=======
+>>>>>>> origin/Branch_liujie
成功删除提醒创建提醒已过期
@@ -65,8 +76,11 @@
发送到桌面提醒我删除提醒
+<<<<<<< HEAD
设置字体删设置密码
+=======
+>>>>>>> origin/Branch_liujie
选择文件夹上一级文件夹已添加到桌面
@@ -79,7 +93,10 @@
SD卡被占用,不能操作导出文本时发生错误,请检查SD卡要查看的便签不存在
+<<<<<<< HEAD
不能置顶空便签
+=======
+>>>>>>> origin/Branch_liujie
不能为空便签设置闹钟提醒不能将空便签发送到桌面导出成功
@@ -124,7 +141,10 @@
便签设置取消
+<<<<<<< HEAD
关键
+=======
+>>>>>>> origin/Branch_liujie
%1$s 条符合“%2$s”的搜索结果
diff --git a/src/app/src/main/res/values-zh-rCN/strings.xml.orig b/src/app/src/main/res/values-zh-rCN/strings.xml.orig
new file mode 100644
index 0000000..c31245b
--- /dev/null
+++ b/src/app/src/main/res/values-zh-rCN/strings.xml.orig
@@ -0,0 +1,152 @@
+
+
+
+
+
+ 便签
+<<<<<<< HEAD
+=======
+ 统计字数
+ 设定密码
+ 删除密码
+ 私密模式
+ 退出私密模式
+>>>>>>> origin/Branch_liujie
+ 便签2x2
+ 便签4x4
+ 没有关联内容,点击新建便签。
+ 访客模式下,便签内容不可见
+ ...
+ 新建便签
+<<<<<<< HEAD
+ 置顶签
+ 取消置顶
+=======
+>>>>>>> origin/Branch_liujie
+ 成功删除提醒
+ 创建提醒
+ 已过期
+ yyyyMMdd
+ MM月dd日 kk:mm
+ 知道了
+ 查看
+ 呼叫电话
+ 发送邮件
+ 浏览网页
+ 打开地图
+
+ 新建文件夹
+ 导出文本
+ 同步
+ 取消同步
+ 设置
+ 搜索
+ 删除
+ 移动到文件夹
+ 选中了 %d 项
+ 没有选中项,操作无效
+ 全选
+ 取消全选
+ 文字大小
+ 小
+ 正常
+ 大
+ 超大
+ 进入清单模式
+ 退出清单模式
+ 查看文件夹
+ 刪除文件夹
+ 修改文件夹名称
+ 文件夹 %1$s 已存在,请重新命名
+ 分享
+ 发送到桌面
+ 提醒我
+ 删除提醒
+<<<<<<< HEAD
+ 设置字体
+ 删设置密码
+=======
+>>>>>>> origin/Branch_liujie
+ 选择文件夹
+ 上一级文件夹
+ 已添加到桌面
+ 删除
+ 确认要删除所选的 %d 条便签吗?
+ 确认要删除该条便签吗?
+ 确认删除文件夹及所包含的便签吗?
+ 已将所选 %1$d 条便签移到 %2$s 文件夹
+
+ SD卡被占用,不能操作
+ 导出文本时发生错误,请检查SD卡
+ 要查看的便签不存在
+<<<<<<< HEAD
+ 不能置顶空便签
+=======
+>>>>>>> origin/Branch_liujie
+ 不能为空便签设置闹钟提醒
+ 不能将空便签发送到桌面
+ 导出成功
+ 导出失败
+ 已将文本文件(%1$s)输出至SD卡(%2$s)目录
+
+ 同步便签...
+ 同步成功
+ 同步失败
+ 同步已取消
+ 与%1$s同步成功
+ 同步失败,请检查网络和帐号设置
+ 同步失败,发生内部错误
+ 同步已取消
+ 登录%1$s...
+ 正在获取服务器便签列表...
+ 正在同步本地便签...
+
+ 设置
+ 同步账号
+ 与google task同步便签记录
+ 上次同步于 %1$s
+ 添加账号
+ 更换账号
+ 删除账号
+ 取消
+ 立即同步
+ 取消同步
+ 当前帐号 %1$s
+ 如更换同步帐号,过去的帐号同步信息将被清空,再次切换的同时可能会造成数据重复
+ 同步便签
+ 请选择google帐号,便签将与该帐号的google task内容同步。
+ 正在同步中,不能修改同步帐号
+ 同步帐号已设置为%1$s
+ 新建便签背景颜色随机
+ 删除
+ 通话便签
+ 请输入名称
+ 正在搜索便签
+ 搜索便签
+ 便签中的文字
+ 便签
+ 设置
+ 取消
+<<<<<<< HEAD
+ 关键
+=======
+>>>>>>> origin/Branch_liujie
+
+ %1$s 条符合“%2$s”的搜索结果
+
+
+
diff --git a/src/app/src/main/res/values-zh-rTW/strings.xml b/src/app/src/main/res/values-zh-rTW/strings.xml
index 88425c2..201adf4 100644
--- a/src/app/src/main/res/values-zh-rTW/strings.xml
+++ b/src/app/src/main/res/values-zh-rTW/strings.xml
@@ -18,14 +18,25 @@
便簽
+<<<<<<< HEAD
+=======
+ 統計字數
+ 設定密碼
+ 刪除密碼
+ 私密模式
+ 退出私密模式
+>>>>>>> origin/Branch_liujie
便簽2x2便簽4x4沒有關聯內容,點擊新建便簽。訪客模式下,便籤內容不可見...新建便簽
+<<<<<<< HEAD
置顶取消置顶
+=======
+>>>>>>> origin/Branch_liujie
成功刪除提醒創建提醒已過期
@@ -66,8 +77,11 @@
發送到桌面提醒我刪除提醒
+<<<<<<< HEAD
设置字体设置密码
+=======
+>>>>>>> origin/Branch_liujie
選擇文件夾上一級文件夾已添加到桌面
@@ -78,7 +92,10 @@
SD卡被佔用,不能操作導出TXT時發生錯誤,請檢查SD卡要查看的便籤不存在
+<<<<<<< HEAD
不能置顶空便籤
+=======
+>>>>>>> origin/Branch_liujie
不能爲空便籤設置鬧鐘提醒不能將空便籤發送到桌面導出成功
@@ -125,7 +142,10 @@
便籤設置取消
+<<<<<<< HEAD
关键
+=======
+>>>>>>> origin/Branch_liujie
%1$s 條符合”%2$s“的搜尋結果
diff --git a/src/app/src/main/res/values-zh-rTW/strings.xml.orig b/src/app/src/main/res/values-zh-rTW/strings.xml.orig
new file mode 100644
index 0000000..201adf4
--- /dev/null
+++ b/src/app/src/main/res/values-zh-rTW/strings.xml.orig
@@ -0,0 +1,153 @@
+
+
+
+
+
+ 便簽
+<<<<<<< HEAD
+=======
+ 統計字數
+ 設定密碼
+ 刪除密碼
+ 私密模式
+ 退出私密模式
+>>>>>>> origin/Branch_liujie
+ 便簽2x2
+ 便簽4x4
+ 沒有關聯內容,點擊新建便簽。
+ 訪客模式下,便籤內容不可見
+ ...
+ 新建便簽
+<<<<<<< HEAD
+ 置顶
+ 取消置顶
+=======
+>>>>>>> origin/Branch_liujie
+ 成功刪除提醒
+ 創建提醒
+ 已過期
+ yyyyMMdd
+ MM月dd日 kk:mm
+ 知道了
+ 查看
+ 呼叫電話
+ 發送郵件
+ 浏覽網頁
+ 打開地圖
+ 已將所選 %1$d 便籤移到 %2$s 文件夾
+
+ 新建文件夾
+ 導出文本
+ 同步
+ 取消同步
+ 設置
+ 搜尋
+ 刪除
+ 移動到文件夾
+ 選中了 %d 項
+ 沒有選中項,操作無效
+ 全選
+ 取消全選
+ 文字大小
+ 小
+ 正常
+ 大
+ 超大
+ 進入清單模式
+ 退出清單模式
+ 查看文件夾
+ 刪除文件夾
+ 修改文件夾名稱
+ 文件夾 %1$s 已存在,請重新命名
+ 分享
+ 發送到桌面
+ 提醒我
+ 刪除提醒
+<<<<<<< HEAD
+ 设置字体
+ 设置密码
+=======
+>>>>>>> origin/Branch_liujie
+ 選擇文件夾
+ 上一級文件夾
+ 已添加到桌面
+ 刪除
+ 确认要刪除所選的 %d 條便籤嗎?
+ 确认要删除該條便籤嗎?
+ 確認刪除檔夾及所包含的便簽嗎?
+ SD卡被佔用,不能操作
+ 導出TXT時發生錯誤,請檢查SD卡
+ 要查看的便籤不存在
+<<<<<<< HEAD
+ 不能置顶空便籤
+=======
+>>>>>>> origin/Branch_liujie
+ 不能爲空便籤設置鬧鐘提醒
+ 不能將空便籤發送到桌面
+ 導出成功
+ 導出失敗
+ 已將文本文件(%1$s)導出至SD(%2$s)目錄
+
+ 同步便簽...
+ 同步成功
+ 同步失敗
+ 同步已取消
+ 與%1$s同步成功
+ 同步失敗,請檢查網絡和帳號設置
+ 同步失敗,發生內部錯誤
+ 同步已取消
+ 登陸%1$s...
+ 正在獲取服務器便籤列表...
+ 正在同步本地便籤...
+
+ 設置
+ 同步賬號
+ 与google task同步便簽記錄
+ 上次同步于 %1$s
+ 添加賬號
+ 更換賬號
+ 刪除賬號
+ 取消
+ 立即同步
+ 取消同步
+ 當前帳號 %1$s
+ 如更換同步帳號,過去的帳號同步信息將被清空,再次切換的同時可能會造成數據重復
+ 同步便簽
+ 請選擇google帳號,便簽將與該帳號的google task內容同步。
+ 正在同步中,不能修改同步帳號
+ 同步帳號已設置為%1$s
+ 新建便籤背景顏色隨機
+
+ 刪除
+ 通話便籤
+ 請輸入名稱
+
+ 正在搜索便籤
+ 搜索便籤
+ 便籤中的文字
+ 便籤
+ 設置
+ 取消
+<<<<<<< HEAD
+ 关键
+=======
+>>>>>>> origin/Branch_liujie
+
+ %1$s 條符合”%2$s“的搜尋結果
+
+
+
diff --git a/src/app/src/main/res/values/ids.xml b/src/app/src/main/res/values/ids.xml
new file mode 100644
index 0000000..c878215
--- /dev/null
+++ b/src/app/src/main/res/values/ids.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/values/strings.xml b/src/app/src/main/res/values/strings.xml
index 7e3f052..5190b38 100644
--- a/src/app/src/main/res/values/strings.xml
+++ b/src/app/src/main/res/values/strings.xml
@@ -18,14 +18,25 @@
Notes
+<<<<<<< HEAD
+=======
+ Count word
+ Set passcode
+ Delete passcode
+ secret model
+ quit secret model
+>>>>>>> origin/Branch_liujie
Notes 2x2Notes 4x4No associated note found, click to create associated note.Privacy mode,can not see note content...Add note
+<<<<<<< HEAD
Set topCancel top
+=======
+>>>>>>> origin/Branch_liujie
Delete reminder successfullySet reminderExpired
@@ -69,8 +80,11 @@
Send to homeRemind meDelete reminder
+<<<<<<< HEAD
Set fontSet password
+=======
+>>>>>>> origin/Branch_liujie
Select folderParent folderNote added to home
@@ -83,7 +97,10 @@
SD card busy, not available nowExport failed, please check SD cardThe note is not exist
+<<<<<<< HEAD
Sorry, can not set top on empty note
+=======
+>>>>>>> origin/Branch_liujie
Sorry, can not set clock on empty noteSorry, can not send and empty note to homeExport successful
@@ -131,7 +148,10 @@
Notessetcancel
+<<<<<<< HEAD
key
+=======
+>>>>>>> origin/Branch_liujie
%1$s result for \"%2$s\"
diff --git a/src/app/src/main/res/values/strings.xml.orig b/src/app/src/main/res/values/strings.xml.orig
new file mode 100644
index 0000000..5190b38
--- /dev/null
+++ b/src/app/src/main/res/values/strings.xml.orig
@@ -0,0 +1,161 @@
+
+
+
+
+
+ Notes
+<<<<<<< HEAD
+=======
+ Count word
+ Set passcode
+ Delete passcode
+ secret model
+ quit secret model
+>>>>>>> origin/Branch_liujie
+ Notes 2x2
+ Notes 4x4
+ No associated note found, click to create associated note.
+ Privacy mode,can not see note content
+ ...
+ Add note
+<<<<<<< HEAD
+ Set top
+ Cancel top
+=======
+>>>>>>> origin/Branch_liujie
+ Delete reminder successfully
+ Set reminder
+ Expired
+ yyyyMMdd
+ MMMd kk:mm
+ Got it
+ Take a look
+ Call
+ Send email
+ Browse web
+ Open map
+
+ /MIUI/notes/
+ notes_%s.txt
+
+ (%d)
+ New Folder
+ Export text
+ Sync
+ Cancel syncing
+ Settings
+ Search
+ Delete
+ Move to folder
+ %d selected
+ Nothing selected, the operation is invalid
+ Select all
+ Deselect all
+ Font size
+ Small
+ Medium
+ Large
+ Super
+ Enter check list
+ Leave check list
+ View folder
+ Delete folder
+ Change folder name
+ The folder %1$s exist, please rename
+ Share
+ Send to home
+ Remind me
+ Delete reminder
+<<<<<<< HEAD
+ Set font
+ Set password
+=======
+>>>>>>> origin/Branch_liujie
+ Select folder
+ Parent folder
+ Note added to home
+ Confirm to delete folder and its notes?
+ Delete selected notes
+ Confirm to delete the selected %d notes?
+ Confirm to delete this note?
+ Have moved selected %1$d notes to %2$s folder
+
+ SD card busy, not available now
+ Export failed, please check SD card
+ The note is not exist
+<<<<<<< HEAD
+ Sorry, can not set top on empty note
+=======
+>>>>>>> origin/Branch_liujie
+ Sorry, can not set clock on empty note
+ Sorry, can not send and empty note to home
+ Export successful
+ Export fail
+ Export text file (%1$s) to SD (%2$s) directory
+
+ Syncing notes...
+ Sync is successful
+ Sync is failed
+ Sync is canceled
+ Sync is successful with account %1$s
+ Sync failed, please check network and account settings
+ Sync failed, internal error occurs
+ Sync is canceled
+ Logging into %1$s...
+ Getting remote note list...
+ Synchronize local notes with Google Task...
+
+ Settings
+ Sync account
+ Sync notes with google task
+ Last sync time %1$s
+ yyyy-MM-dd hh:mm:ss
+ Add account
+ Change sync account
+ Remove sync account
+ Cancel
+ Sync immediately
+ Cancel syncing
+ Current account %1$s
+ All sync related information will be deleted, which may result in duplicated items sometime
+ Sync notes
+ Please select a google account. Local notes will be synced with google task.
+ Cannot change the account because sync is in progress
+ %1$s has been set as the sync account
+ New note background color random
+
+ Delete
+ Call notes
+ Input name
+
+ Searching Notes
+ Search notes
+ Text in your notes
+ Notes
+ set
+ cancel
+<<<<<<< HEAD
+ key
+=======
+>>>>>>> origin/Branch_liujie
+
+ %1$s result for \"%2$s\"
+
+ %1$s results for \"%2$s\"
+
+
+
diff --git a/src/app/src/main/res/values/styles.xml b/src/app/src/main/res/values/styles.xml
index d750e65..2640981 100644
--- a/src/app/src/main/res/values/styles.xml
+++ b/src/app/src/main/res/values/styles.xml
@@ -63,7 +63,12 @@
\ No newline at end of file
diff --git a/src/app/src/main/res/values/styles.xml.orig b/src/app/src/main/res/values/styles.xml.orig
new file mode 100644
index 0000000..2640981
--- /dev/null
+++ b/src/app/src/main/res/values/styles.xml.orig
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file