diff --git a/color/primary_text_dark.xml b/color/primary_text_dark.xml
new file mode 100644
index 0000000..7c85459
--- /dev/null
+++ b/color/primary_text_dark.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/color/secondary_text_dark.xml b/color/secondary_text_dark.xml
new file mode 100644
index 0000000..c1c2384
--- /dev/null
+++ b/color/secondary_text_dark.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/drawable-hdpi/bg_btn_set_color.png b/drawable-hdpi/bg_btn_set_color.png
new file mode 100644
index 0000000..5eb5d44
Binary files /dev/null and b/drawable-hdpi/bg_btn_set_color.png differ
diff --git a/drawable-hdpi/bg_color_btn_mask.png b/drawable-hdpi/bg_color_btn_mask.png
new file mode 100644
index 0000000..100db77
Binary files /dev/null and b/drawable-hdpi/bg_color_btn_mask.png differ
diff --git a/drawable-hdpi/call_record.png b/drawable-hdpi/call_record.png
new file mode 100644
index 0000000..fb88ca4
Binary files /dev/null and b/drawable-hdpi/call_record.png differ
diff --git a/drawable-hdpi/clock.png b/drawable-hdpi/clock.png
new file mode 100644
index 0000000..5f2ae9a
Binary files /dev/null and b/drawable-hdpi/clock.png differ
diff --git a/drawable-hdpi/delete.png b/drawable-hdpi/delete.png
new file mode 100644
index 0000000..643de3e
Binary files /dev/null and b/drawable-hdpi/delete.png differ
diff --git a/drawable-hdpi/dropdown_icon.9.png b/drawable-hdpi/dropdown_icon.9.png
new file mode 100644
index 0000000..5525025
Binary files /dev/null and b/drawable-hdpi/dropdown_icon.9.png differ
diff --git a/drawable-hdpi/edit_blue.9.png b/drawable-hdpi/edit_blue.9.png
new file mode 100644
index 0000000..55a1856
Binary files /dev/null and b/drawable-hdpi/edit_blue.9.png differ
diff --git a/drawable-hdpi/edit_green.9.png b/drawable-hdpi/edit_green.9.png
new file mode 100644
index 0000000..2cb2d60
Binary files /dev/null and b/drawable-hdpi/edit_green.9.png differ
diff --git a/drawable-hdpi/edit_red.9.png b/drawable-hdpi/edit_red.9.png
new file mode 100644
index 0000000..bae944a
Binary files /dev/null and b/drawable-hdpi/edit_red.9.png differ
diff --git a/drawable-hdpi/edit_title_blue.9.png b/drawable-hdpi/edit_title_blue.9.png
new file mode 100644
index 0000000..96e6092
Binary files /dev/null and b/drawable-hdpi/edit_title_blue.9.png differ
diff --git a/drawable-hdpi/edit_title_green.9.png b/drawable-hdpi/edit_title_green.9.png
new file mode 100644
index 0000000..08d8644
Binary files /dev/null and b/drawable-hdpi/edit_title_green.9.png differ
diff --git a/drawable-hdpi/edit_title_red.9.png b/drawable-hdpi/edit_title_red.9.png
new file mode 100644
index 0000000..9c430e5
Binary files /dev/null and b/drawable-hdpi/edit_title_red.9.png differ
diff --git a/drawable-hdpi/edit_title_white.9.png b/drawable-hdpi/edit_title_white.9.png
new file mode 100644
index 0000000..19e8d95
Binary files /dev/null and b/drawable-hdpi/edit_title_white.9.png differ
diff --git a/drawable-hdpi/edit_title_yellow.9.png b/drawable-hdpi/edit_title_yellow.9.png
new file mode 100644
index 0000000..bf8f580
Binary files /dev/null and b/drawable-hdpi/edit_title_yellow.9.png differ
diff --git a/drawable-hdpi/edit_white.9.png b/drawable-hdpi/edit_white.9.png
new file mode 100644
index 0000000..918f7a6
Binary files /dev/null and b/drawable-hdpi/edit_white.9.png differ
diff --git a/drawable-hdpi/edit_yellow.9.png b/drawable-hdpi/edit_yellow.9.png
new file mode 100644
index 0000000..10cb642
Binary files /dev/null and b/drawable-hdpi/edit_yellow.9.png differ
diff --git a/drawable-hdpi/font_large.png b/drawable-hdpi/font_large.png
new file mode 100644
index 0000000..78cf2e6
Binary files /dev/null and b/drawable-hdpi/font_large.png differ
diff --git a/drawable-hdpi/font_normal.png b/drawable-hdpi/font_normal.png
new file mode 100644
index 0000000..9de7ced
Binary files /dev/null and b/drawable-hdpi/font_normal.png differ
diff --git a/drawable-hdpi/font_size_selector_bg.9.png b/drawable-hdpi/font_size_selector_bg.9.png
new file mode 100644
index 0000000..be8e64c
Binary files /dev/null and b/drawable-hdpi/font_size_selector_bg.9.png differ
diff --git a/drawable-hdpi/font_small.png b/drawable-hdpi/font_small.png
new file mode 100644
index 0000000..d3ff104
Binary files /dev/null and b/drawable-hdpi/font_small.png differ
diff --git a/drawable-hdpi/font_super.png b/drawable-hdpi/font_super.png
new file mode 100644
index 0000000..85b13a1
Binary files /dev/null and b/drawable-hdpi/font_super.png differ
diff --git a/drawable-hdpi/icon_app.png b/drawable-hdpi/icon_app.png
new file mode 100644
index 0000000..418aadc
Binary files /dev/null and b/drawable-hdpi/icon_app.png differ
diff --git a/drawable-hdpi/list_background.png b/drawable-hdpi/list_background.png
new file mode 100644
index 0000000..087e1f9
Binary files /dev/null and b/drawable-hdpi/list_background.png differ
diff --git a/drawable-hdpi/list_blue_down.9.png b/drawable-hdpi/list_blue_down.9.png
new file mode 100644
index 0000000..b88eebf
Binary files /dev/null and b/drawable-hdpi/list_blue_down.9.png differ
diff --git a/drawable-hdpi/list_blue_middle.9.png b/drawable-hdpi/list_blue_middle.9.png
new file mode 100644
index 0000000..96b1c8b
Binary files /dev/null and b/drawable-hdpi/list_blue_middle.9.png differ
diff --git a/drawable-hdpi/list_blue_single.9.png b/drawable-hdpi/list_blue_single.9.png
new file mode 100644
index 0000000..d7e7206
Binary files /dev/null and b/drawable-hdpi/list_blue_single.9.png differ
diff --git a/drawable-hdpi/list_blue_up.9.png b/drawable-hdpi/list_blue_up.9.png
new file mode 100644
index 0000000..632e88c
Binary files /dev/null and b/drawable-hdpi/list_blue_up.9.png differ
diff --git a/drawable-hdpi/list_folder.9.png b/drawable-hdpi/list_folder.9.png
new file mode 100644
index 0000000..829f61b
Binary files /dev/null and b/drawable-hdpi/list_folder.9.png differ
diff --git a/drawable-hdpi/list_footer_bg.9.png b/drawable-hdpi/list_footer_bg.9.png
new file mode 100644
index 0000000..5325c25
Binary files /dev/null and b/drawable-hdpi/list_footer_bg.9.png differ
diff --git a/drawable-hdpi/list_green_down.9.png b/drawable-hdpi/list_green_down.9.png
new file mode 100644
index 0000000..64a39d9
Binary files /dev/null and b/drawable-hdpi/list_green_down.9.png differ
diff --git a/drawable-hdpi/list_green_middle.9.png b/drawable-hdpi/list_green_middle.9.png
new file mode 100644
index 0000000..897325a
Binary files /dev/null and b/drawable-hdpi/list_green_middle.9.png differ
diff --git a/drawable-hdpi/list_green_single.9.png b/drawable-hdpi/list_green_single.9.png
new file mode 100644
index 0000000..c83405f
Binary files /dev/null and b/drawable-hdpi/list_green_single.9.png differ
diff --git a/drawable-hdpi/list_green_up.9.png b/drawable-hdpi/list_green_up.9.png
new file mode 100644
index 0000000..141f9e1
Binary files /dev/null and b/drawable-hdpi/list_green_up.9.png differ
diff --git a/drawable-hdpi/list_red_down.9.png b/drawable-hdpi/list_red_down.9.png
new file mode 100644
index 0000000..4224309
Binary files /dev/null and b/drawable-hdpi/list_red_down.9.png differ
diff --git a/drawable-hdpi/list_red_middle.9.png b/drawable-hdpi/list_red_middle.9.png
new file mode 100644
index 0000000..9988f17
Binary files /dev/null and b/drawable-hdpi/list_red_middle.9.png differ
diff --git a/drawable-hdpi/list_red_single.9.png b/drawable-hdpi/list_red_single.9.png
new file mode 100644
index 0000000..587c348
Binary files /dev/null and b/drawable-hdpi/list_red_single.9.png differ
diff --git a/drawable-hdpi/list_red_up.9.png b/drawable-hdpi/list_red_up.9.png
new file mode 100644
index 0000000..46b4757
Binary files /dev/null and b/drawable-hdpi/list_red_up.9.png differ
diff --git a/drawable-hdpi/list_white_down.9.png b/drawable-hdpi/list_white_down.9.png
new file mode 100644
index 0000000..29f9d8c
Binary files /dev/null and b/drawable-hdpi/list_white_down.9.png differ
diff --git a/drawable-hdpi/list_white_middle.9.png b/drawable-hdpi/list_white_middle.9.png
new file mode 100644
index 0000000..77a4ab4
Binary files /dev/null and b/drawable-hdpi/list_white_middle.9.png differ
diff --git a/drawable-hdpi/list_white_single.9.png b/drawable-hdpi/list_white_single.9.png
new file mode 100644
index 0000000..3e79189
Binary files /dev/null and b/drawable-hdpi/list_white_single.9.png differ
diff --git a/drawable-hdpi/list_white_up.9.png b/drawable-hdpi/list_white_up.9.png
new file mode 100644
index 0000000..e23cd5c
Binary files /dev/null and b/drawable-hdpi/list_white_up.9.png differ
diff --git a/drawable-hdpi/list_yellow_down.9.png b/drawable-hdpi/list_yellow_down.9.png
new file mode 100644
index 0000000..31cfc1e
Binary files /dev/null and b/drawable-hdpi/list_yellow_down.9.png differ
diff --git a/drawable-hdpi/list_yellow_middle.9.png b/drawable-hdpi/list_yellow_middle.9.png
new file mode 100644
index 0000000..b6549b2
Binary files /dev/null and b/drawable-hdpi/list_yellow_middle.9.png differ
diff --git a/drawable-hdpi/list_yellow_single.9.png b/drawable-hdpi/list_yellow_single.9.png
new file mode 100644
index 0000000..3faf507
Binary files /dev/null and b/drawable-hdpi/list_yellow_single.9.png differ
diff --git a/drawable-hdpi/list_yellow_up.9.png b/drawable-hdpi/list_yellow_up.9.png
new file mode 100644
index 0000000..4ae791c
Binary files /dev/null and b/drawable-hdpi/list_yellow_up.9.png differ
diff --git a/drawable-hdpi/menu_delete.png b/drawable-hdpi/menu_delete.png
new file mode 100644
index 0000000..ccdfc4b
Binary files /dev/null and b/drawable-hdpi/menu_delete.png differ
diff --git a/drawable-hdpi/menu_move.png b/drawable-hdpi/menu_move.png
new file mode 100644
index 0000000..1140b71
Binary files /dev/null and b/drawable-hdpi/menu_move.png differ
diff --git a/drawable-hdpi/new_note_normal.png b/drawable-hdpi/new_note_normal.png
new file mode 100644
index 0000000..e24e0d1
Binary files /dev/null and b/drawable-hdpi/new_note_normal.png differ
diff --git a/drawable-hdpi/new_note_pressed.png b/drawable-hdpi/new_note_pressed.png
new file mode 100644
index 0000000..c748936
Binary files /dev/null and b/drawable-hdpi/new_note_pressed.png differ
diff --git a/drawable-hdpi/note_edit_color_selector_panel.png b/drawable-hdpi/note_edit_color_selector_panel.png
new file mode 100644
index 0000000..fc49552
Binary files /dev/null and b/drawable-hdpi/note_edit_color_selector_panel.png differ
diff --git a/drawable-hdpi/notification.png b/drawable-hdpi/notification.png
new file mode 100644
index 0000000..b13ab4a
Binary files /dev/null and b/drawable-hdpi/notification.png differ
diff --git a/drawable-hdpi/search_result.png b/drawable-hdpi/search_result.png
new file mode 100644
index 0000000..ff2befd
Binary files /dev/null and b/drawable-hdpi/search_result.png differ
diff --git a/drawable-hdpi/selected.png b/drawable-hdpi/selected.png
new file mode 100644
index 0000000..b889bef
Binary files /dev/null and b/drawable-hdpi/selected.png differ
diff --git a/drawable-hdpi/title_alert.png b/drawable-hdpi/title_alert.png
new file mode 100644
index 0000000..544ee9c
Binary files /dev/null and b/drawable-hdpi/title_alert.png differ
diff --git a/drawable-hdpi/title_bar_bg.9.png b/drawable-hdpi/title_bar_bg.9.png
new file mode 100644
index 0000000..eb6bff0
Binary files /dev/null and b/drawable-hdpi/title_bar_bg.9.png differ
diff --git a/drawable-hdpi/widget_2x_blue.png b/drawable-hdpi/widget_2x_blue.png
new file mode 100644
index 0000000..a1707f4
Binary files /dev/null and b/drawable-hdpi/widget_2x_blue.png differ
diff --git a/drawable-hdpi/widget_2x_green.png b/drawable-hdpi/widget_2x_green.png
new file mode 100644
index 0000000..f86886c
Binary files /dev/null and b/drawable-hdpi/widget_2x_green.png differ
diff --git a/drawable-hdpi/widget_2x_red.png b/drawable-hdpi/widget_2x_red.png
new file mode 100644
index 0000000..0e66c29
Binary files /dev/null and b/drawable-hdpi/widget_2x_red.png differ
diff --git a/drawable-hdpi/widget_2x_white.png b/drawable-hdpi/widget_2x_white.png
new file mode 100644
index 0000000..5f0619a
Binary files /dev/null and b/drawable-hdpi/widget_2x_white.png differ
diff --git a/drawable-hdpi/widget_2x_yellow.png b/drawable-hdpi/widget_2x_yellow.png
new file mode 100644
index 0000000..12d1c2b
Binary files /dev/null and b/drawable-hdpi/widget_2x_yellow.png differ
diff --git a/drawable-hdpi/widget_4x_blue.png b/drawable-hdpi/widget_4x_blue.png
new file mode 100644
index 0000000..9183738
Binary files /dev/null and b/drawable-hdpi/widget_4x_blue.png differ
diff --git a/drawable-hdpi/widget_4x_green.png b/drawable-hdpi/widget_4x_green.png
new file mode 100644
index 0000000..fa8b452
Binary files /dev/null and b/drawable-hdpi/widget_4x_green.png differ
diff --git a/drawable-hdpi/widget_4x_red.png b/drawable-hdpi/widget_4x_red.png
new file mode 100644
index 0000000..62de074
Binary files /dev/null and b/drawable-hdpi/widget_4x_red.png differ
diff --git a/drawable-hdpi/widget_4x_white.png b/drawable-hdpi/widget_4x_white.png
new file mode 100644
index 0000000..a37d67c
Binary files /dev/null and b/drawable-hdpi/widget_4x_white.png differ
diff --git a/drawable-hdpi/widget_4x_yellow.png b/drawable-hdpi/widget_4x_yellow.png
new file mode 100644
index 0000000..d7c5fa4
Binary files /dev/null and b/drawable-hdpi/widget_4x_yellow.png differ
diff --git a/drawable/new_note.xml b/drawable/new_note.xml
new file mode 100644
index 0000000..2154ebc
--- /dev/null
+++ b/drawable/new_note.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
diff --git a/layout/account_dialog_title.xml b/layout/account_dialog_title.xml
new file mode 100644
index 0000000..7717112
--- /dev/null
+++ b/layout/account_dialog_title.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/layout/add_account_text.xml b/layout/add_account_text.xml
new file mode 100644
index 0000000..c799178
--- /dev/null
+++ b/layout/add_account_text.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/layout/datetime_picker.xml b/layout/datetime_picker.xml
new file mode 100644
index 0000000..f10d592
--- /dev/null
+++ b/layout/datetime_picker.xml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/layout/dialog_edit_text.xml b/layout/dialog_edit_text.xml
new file mode 100644
index 0000000..361b39a
--- /dev/null
+++ b/layout/dialog_edit_text.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/layout/folder_list_item.xml b/layout/folder_list_item.xml
new file mode 100644
index 0000000..77e8148
--- /dev/null
+++ b/layout/folder_list_item.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/layout/note_edit.xml b/layout/note_edit.xml
new file mode 100644
index 0000000..10b2aa7
--- /dev/null
+++ b/layout/note_edit.xml
@@ -0,0 +1,400 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/layout/note_edit_list_item.xml b/layout/note_edit_list_item.xml
new file mode 100644
index 0000000..a885f9c
--- /dev/null
+++ b/layout/note_edit_list_item.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/layout/note_item.xml b/layout/note_item.xml
new file mode 100644
index 0000000..d541f6a
--- /dev/null
+++ b/layout/note_item.xml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/layout/note_list.xml b/layout/note_list.xml
new file mode 100644
index 0000000..6b25d38
--- /dev/null
+++ b/layout/note_list.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/layout/note_list_dropdown_menu.xml b/layout/note_list_dropdown_menu.xml
new file mode 100644
index 0000000..3fa271d
--- /dev/null
+++ b/layout/note_list_dropdown_menu.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/layout/note_list_footer.xml b/layout/note_list_footer.xml
new file mode 100644
index 0000000..5ca7b22
--- /dev/null
+++ b/layout/note_list_footer.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/layout/settings_header.xml b/layout/settings_header.xml
new file mode 100644
index 0000000..5eb8c50
--- /dev/null
+++ b/layout/settings_header.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/layout/widget_2x.xml b/layout/widget_2x.xml
new file mode 100644
index 0000000..55970ce
--- /dev/null
+++ b/layout/widget_2x.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
diff --git a/layout/widget_4x.xml b/layout/widget_4x.xml
new file mode 100644
index 0000000..dc9bb51
--- /dev/null
+++ b/layout/widget_4x.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/menu/call_note_edit.xml b/menu/call_note_edit.xml
new file mode 100644
index 0000000..02c0528
--- /dev/null
+++ b/menu/call_note_edit.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
diff --git a/menu/call_record_folder.xml b/menu/call_record_folder.xml
new file mode 100644
index 0000000..c664346
--- /dev/null
+++ b/menu/call_record_folder.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
diff --git a/menu/note_edit.xml b/menu/note_edit.xml
new file mode 100644
index 0000000..35cacd1
--- /dev/null
+++ b/menu/note_edit.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/menu/note_list.xml b/menu/note_list.xml
new file mode 100644
index 0000000..42ea736
--- /dev/null
+++ b/menu/note_list.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
diff --git a/menu/note_list_dropdown.xml b/menu/note_list_dropdown.xml
new file mode 100644
index 0000000..7cbaadc
--- /dev/null
+++ b/menu/note_list_dropdown.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/menu/note_list_options.xml b/menu/note_list_options.xml
new file mode 100644
index 0000000..daac008
--- /dev/null
+++ b/menu/note_list_options.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/menu/sub_folder.xml b/menu/sub_folder.xml
new file mode 100644
index 0000000..b00de26
--- /dev/null
+++ b/menu/sub_folder.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/tool/DataUtils.java b/tool/DataUtils.java
new file mode 100644
index 0000000..2a14982
--- /dev/null
+++ b/tool/DataUtils.java
@@ -0,0 +1,295 @@
+/*
+ * 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;
+
+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;
+
+import net.micode.notes.data.Notes;
+import net.micode.notes.data.Notes.CallNote;
+import net.micode.notes.data.Notes.NoteColumns;
+import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+
+
+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;
+ }
+}