lyt 1 year ago
parent 352d482c6e
commit 470a9c66cf

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="C:\Users\86139\.android\avd\Pixel_2.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2024-01-04T02:28:43.057211200Z" />
</component>
</project>

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
@ -6,11 +7,4 @@
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="VisualizationToolProject">
<option name="state">
<ProjectState>
<option name="scale" value="0.07379862700228833" />
</ProjectState>
</option>
</component>
</project>

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RenderSettings">
<option name="showDecorations" value="true" />
</component>
</project>

@ -1,4 +1,4 @@
#Thu Jan 11 23:59:53 CST 2024
#Sun Jan 07 22:29:33 CST 2024
net.micode.notes.app-main-6\:/color/primary_text_dark.xml=E\:\\Notes-master1\\app\\build\\intermediates\\merged_res\\debug\\color_primary_text_dark.xml.flat
net.micode.notes.app-main-6\:/color/secondary_text_dark.xml=E\:\\Notes-master1\\app\\build\\intermediates\\merged_res\\debug\\color_secondary_text_dark.xml.flat
net.micode.notes.app-main-6\:/drawable-hdpi/bg_btn_set_color.png=E\:\\Notes-master1\\app\\build\\intermediates\\merged_res\\debug\\drawable-hdpi_bg_btn_set_color.png.flat

@ -1,4 +1,4 @@
#Thu Jan 11 23:59:53 CST 2024
#Sun Jan 07 22:29:33 CST 2024
net.micode.notes.app-main-5\:/color/primary_text_dark.xml=E\:\\Notes-master1\\app\\build\\intermediates\\packaged_res\\debug\\color\\primary_text_dark.xml
net.micode.notes.app-main-5\:/color/secondary_text_dark.xml=E\:\\Notes-master1\\app\\build\\intermediates\\packaged_res\\debug\\color\\secondary_text_dark.xml
net.micode.notes.app-main-5\:/drawable-hdpi/bg_btn_set_color.png=E\:\\Notes-master1\\app\\build\\intermediates\\packaged_res\\debug\\drawable-hdpi-v4\\bg_btn_set_color.png

@ -1,4 +1,4 @@
#Fri Jan 12 00:11:46 CST 2024
#Fri Jan 12 11:50:33 CST 2024
base.0=E\:\\Notes-master1\\app\\build\\intermediates\\dex\\debug\\mergeDexDebug\\classes.dex
path.0=classes.dex
renamed.0=classes.dex

@ -82,7 +82,6 @@ drawable widget_4x_yellow
id account_dialog_subtitle
id account_dialog_title
id action_select_all
id add_img_btn
id amPm
id btn_new_note
id btn_set_bg_color

@ -67,6 +67,10 @@
"merged": "C:\\Users\\86139\\.gradle\\daemon\\8.0\\net.micode.notes.app-merged_res-4:\\drawable-hdpi_list_white_up.9.png.flat",
"source": "C:\\Users\\86139\\.gradle\\daemon\\8.0\\net.micode.notes.app-main-6:\\drawable-hdpi\\list_white_up.9.png"
},
{
"merged": "net.micode.notes.app-merged_res-4:/layout_note_edit.xml.flat",
"source": "net.micode.notes.app-main-6:/layout/note_edit.xml"
},
{
"merged": "C:\\Users\\86139\\.gradle\\daemon\\8.0\\net.micode.notes.app-merged_res-4:\\drawable-hdpi_edit_green.9.png.flat",
"source": "C:\\Users\\86139\\.gradle\\daemon\\8.0\\net.micode.notes.app-main-6:\\drawable-hdpi\\edit_green.9.png"
@ -103,10 +107,6 @@
"merged": "C:\\Users\\86139\\.gradle\\daemon\\8.0\\net.micode.notes.app-merged_res-4:\\drawable-hdpi_list_blue_single.9.png.flat",
"source": "C:\\Users\\86139\\.gradle\\daemon\\8.0\\net.micode.notes.app-main-6:\\drawable-hdpi\\list_blue_single.9.png"
},
{
"merged": "net.micode.notes.app-merged_res-4:/layout_note_list.xml.flat",
"source": "net.micode.notes.app-main-6:/layout/note_list.xml"
},
{
"merged": "C:\\Users\\86139\\.gradle\\daemon\\8.0\\net.micode.notes.app-merged_res-4:\\menu_note_edit.xml.flat",
"source": "C:\\Users\\86139\\.gradle\\daemon\\8.0\\net.micode.notes.app-main-6:\\menu\\note_edit.xml"

@ -69,8 +69,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/bg_btn_set_color" />
</LinearLayout>
<LinearLayout
@ -407,13 +405,4 @@
android:src="@drawable/selected" />
</FrameLayout>
</LinearLayout>
<ImageButton
android:id="@+id/add_img_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginTop="600dp"
android:layout_marginBottom="7dp"
android:src="@android:drawable/ic_menu_gallery" />
</FrameLayout>

@ -17,7 +17,6 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!--android:background="@drawable/list_background" -->
@ -56,11 +55,4 @@
android:layout_gravity="bottom"
android:background="@drawable/new_note"
android:focusable="false" />
<Button
android:id="@+id/add_img_btn"
android:layout_width="match_parent"
android:layout_height="135dp"
android:layout_gravity="bottom"
android:focusable="false"
tools:ignore="DuplicateIds" />
</FrameLayout>

@ -80,75 +80,74 @@ int drawable widget_4x_yellow 0x7f040044
int id account_dialog_subtitle 0x7f050000
int id account_dialog_title 0x7f050001
int id action_select_all 0x7f050002
int id add_img_btn 0x7f050003
int id amPm 0x7f050004
int id btn_new_note 0x7f050005
int id btn_set_bg_color 0x7f050006
int id cb_edit_item 0x7f050007
int id date 0x7f050008
int id delete 0x7f050009
int id et_edit_text 0x7f05000a
int id et_foler_name 0x7f05000b
int id font_size_selector 0x7f05000c
int id hour 0x7f05000d
int id iv_alert_icon 0x7f05000e
int id iv_bg_blue 0x7f05000f
int id iv_bg_blue_select 0x7f050010
int id iv_bg_green 0x7f050011
int id iv_bg_green_select 0x7f050012
int id iv_bg_red 0x7f050013
int id iv_bg_red_select 0x7f050014
int id iv_bg_white 0x7f050015
int id iv_bg_white_select 0x7f050016
int id iv_bg_yellow 0x7f050017
int id iv_bg_yellow_select 0x7f050018
int id iv_large_select 0x7f050019
int id iv_medium_select 0x7f05001a
int id iv_small_select 0x7f05001b
int id iv_super_select 0x7f05001c
int id ll_font_large 0x7f05001d
int id ll_font_normal 0x7f05001e
int id ll_font_small 0x7f05001f
int id ll_font_super 0x7f050020
int id menu_alert 0x7f050021
int id menu_delete 0x7f050022
int id menu_delete_remind 0x7f050023
int id menu_export_text 0x7f050024
int id menu_font_size 0x7f050025
int id menu_grass 0x7f050026
int id menu_lanyangyang 0x7f050027
int id menu_list_mode 0x7f050028
int id menu_new_folder 0x7f050029
int id menu_new_note 0x7f05002a
int id menu_playground1 0x7f05002b
int id menu_search 0x7f05002c
int id menu_send_to_desktop 0x7f05002d
int id menu_setting 0x7f05002e
int id menu_share 0x7f05002f
int id menu_sync 0x7f050030
int id minute 0x7f050031
int id move 0x7f050032
int id navigation_bar 0x7f050033
int id note_bg_color_selector 0x7f050034
int id note_edit_list 0x7f050035
int id note_edit_view 0x7f050036
int id note_item 0x7f050037
int id note_title 0x7f050038
int id notes_list 0x7f050039
int id prefenerece_sync_status_textview 0x7f05003a
int id preference_sync_button 0x7f05003b
int id selection_menu 0x7f05003c
int id sv_note_edit 0x7f05003d
int id text_num 0x7f05003e
int id tv_alert_date 0x7f05003f
int id tv_folder_name 0x7f050040
int id tv_modified_date 0x7f050041
int id tv_name 0x7f050042
int id tv_time 0x7f050043
int id tv_title 0x7f050044
int id tv_title_bar 0x7f050045
int id widget_bg_image 0x7f050046
int id widget_text 0x7f050047
int id amPm 0x7f050003
int id btn_new_note 0x7f050004
int id btn_set_bg_color 0x7f050005
int id cb_edit_item 0x7f050006
int id date 0x7f050007
int id delete 0x7f050008
int id et_edit_text 0x7f050009
int id et_foler_name 0x7f05000a
int id font_size_selector 0x7f05000b
int id hour 0x7f05000c
int id iv_alert_icon 0x7f05000d
int id iv_bg_blue 0x7f05000e
int id iv_bg_blue_select 0x7f05000f
int id iv_bg_green 0x7f050010
int id iv_bg_green_select 0x7f050011
int id iv_bg_red 0x7f050012
int id iv_bg_red_select 0x7f050013
int id iv_bg_white 0x7f050014
int id iv_bg_white_select 0x7f050015
int id iv_bg_yellow 0x7f050016
int id iv_bg_yellow_select 0x7f050017
int id iv_large_select 0x7f050018
int id iv_medium_select 0x7f050019
int id iv_small_select 0x7f05001a
int id iv_super_select 0x7f05001b
int id ll_font_large 0x7f05001c
int id ll_font_normal 0x7f05001d
int id ll_font_small 0x7f05001e
int id ll_font_super 0x7f05001f
int id menu_alert 0x7f050020
int id menu_delete 0x7f050021
int id menu_delete_remind 0x7f050022
int id menu_export_text 0x7f050023
int id menu_font_size 0x7f050024
int id menu_grass 0x7f050025
int id menu_lanyangyang 0x7f050026
int id menu_list_mode 0x7f050027
int id menu_new_folder 0x7f050028
int id menu_new_note 0x7f050029
int id menu_playground1 0x7f05002a
int id menu_search 0x7f05002b
int id menu_send_to_desktop 0x7f05002c
int id menu_setting 0x7f05002d
int id menu_share 0x7f05002e
int id menu_sync 0x7f05002f
int id minute 0x7f050030
int id move 0x7f050031
int id navigation_bar 0x7f050032
int id note_bg_color_selector 0x7f050033
int id note_edit_list 0x7f050034
int id note_edit_view 0x7f050035
int id note_item 0x7f050036
int id note_title 0x7f050037
int id notes_list 0x7f050038
int id prefenerece_sync_status_textview 0x7f050039
int id preference_sync_button 0x7f05003a
int id selection_menu 0x7f05003b
int id sv_note_edit 0x7f05003c
int id text_num 0x7f05003d
int id tv_alert_date 0x7f05003e
int id tv_folder_name 0x7f05003f
int id tv_modified_date 0x7f050040
int id tv_name 0x7f050041
int id tv_time 0x7f050042
int id tv_title 0x7f050043
int id tv_title_bar 0x7f050044
int id widget_bg_image 0x7f050045
int id widget_text 0x7f050046
int layout account_dialog_title 0x7f060000
int layout add_account_text 0x7f060001
int layout datetime_picker 0x7f060002

@ -57,6 +57,9 @@ net.micode.notes:string/format_datetime_mdhm = 0x7f0a0019
net.micode.notes:string/preferences_account_summary = 0x7f0a0047
net.micode.notes:string/format_date_ymd = 0x7f0a0018
net.micode.notes:string/file_name_txt_format = 0x7f0a0015
net.micode.notes:id/note_edit_list = 0x7f050034
net.micode.notes:drawable/new_note = 0x7f040031
net.micode.notes:string/folder_exist = 0x7f0a0017
net.micode.notes:string/menu_select_none = 0x7f0a0036
net.micode.notes:string/failed_sdcard_export = 0x7f0a0014
net.micode.notes:string/ticker_cancel = 0x7f0a0063
@ -69,7 +72,7 @@ net.micode.notes:drawable/widget_4x_green = 0x7f040041
net.micode.notes:string/error_sdcard_export = 0x7f0a000f
net.micode.notes:string/notealert_ok = 0x7f0a0044
net.micode.notes:string/menu_move_parent_folder = 0x7f0a0030
net.micode.notes:id/tv_title = 0x7f050044
net.micode.notes:id/tv_title = 0x7f050043
net.micode.notes:string/error_note_empty_for_clock = 0x7f0a000c
net.micode.notes:string/delete_remind_time_message = 0x7f0a000b
net.micode.notes:style/TextAppearanceNormal = 0x7f0b0006
@ -90,7 +93,7 @@ net.micode.notes:menu/sub_folder = 0x7f070006
net.micode.notes:menu/note_list = 0x7f070003
net.micode.notes:string/ticker_syncing = 0x7f0a0066
net.micode.notes:drawable/menu_move = 0x7f040030
net.micode.notes:id/menu_search = 0x7f05002c
net.micode.notes:id/menu_search = 0x7f05002b
net.micode.notes:string/datetime_dialog_ok = 0x7f0a000a
net.micode.notes:raw/introduction = 0x7f090000
net.micode.notes:menu/call_record_folder = 0x7f070001
@ -107,102 +110,98 @@ net.micode.notes:string/alert_message_delete_notes = 0x7f0a0002
net.micode.notes:drawable/widget_2x_blue = 0x7f04003b
net.micode.notes:layout/folder_list_item = 0x7f060004
net.micode.notes:string/sync_progress_init_list = 0x7f0a0060
net.micode.notes:id/btn_new_note = 0x7f050005
net.micode.notes:id/btn_new_note = 0x7f050004
net.micode.notes:layout/add_account_text = 0x7f060001
net.micode.notes:id/widget_text = 0x7f050047
net.micode.notes:id/widget_bg_image = 0x7f050046
net.micode.notes:id/widget_text = 0x7f050046
net.micode.notes:id/widget_bg_image = 0x7f050045
net.micode.notes:string/menu_folder_delete = 0x7f0a0025
net.micode.notes:id/tv_name = 0x7f050042
net.micode.notes:id/tv_alert_date = 0x7f05003f
net.micode.notes:id/tv_name = 0x7f050041
net.micode.notes:id/tv_alert_date = 0x7f05003e
net.micode.notes:color/primary_text_dark = 0x7f020000
net.micode.notes:id/tv_time = 0x7f050043
net.micode.notes:id/selection_menu = 0x7f05003c
net.micode.notes:id/preference_sync_button = 0x7f05003b
net.micode.notes:id/tv_time = 0x7f050042
net.micode.notes:id/selection_menu = 0x7f05003b
net.micode.notes:id/preference_sync_button = 0x7f05003a
net.micode.notes:string/error_sync_network = 0x7f0a0013
net.micode.notes:id/notes_list = 0x7f050039
net.micode.notes:id/notes_list = 0x7f050038
net.micode.notes:drawable/playground1 = 0x7f040036
net.micode.notes:id/note_title = 0x7f050038
net.micode.notes:id/note_bg_color_selector = 0x7f050034
net.micode.notes:id/navigation_bar = 0x7f050033
net.micode.notes:id/move = 0x7f050032
net.micode.notes:id/menu_sync = 0x7f050030
net.micode.notes:id/note_title = 0x7f050037
net.micode.notes:id/note_bg_color_selector = 0x7f050033
net.micode.notes:id/navigation_bar = 0x7f050032
net.micode.notes:id/move = 0x7f050031
net.micode.notes:id/menu_sync = 0x7f05002f
net.micode.notes:string/menu_move = 0x7f0a002f
net.micode.notes:id/date = 0x7f050008
net.micode.notes:id/note_item = 0x7f050037
net.micode.notes:id/menu_setting = 0x7f05002e
net.micode.notes:id/menu_send_to_desktop = 0x7f05002d
net.micode.notes:id/menu_share = 0x7f05002f
net.micode.notes:id/menu_playground1 = 0x7f05002b
net.micode.notes:id/date = 0x7f050007
net.micode.notes:id/note_item = 0x7f050036
net.micode.notes:id/menu_setting = 0x7f05002d
net.micode.notes:id/menu_send_to_desktop = 0x7f05002c
net.micode.notes:id/menu_share = 0x7f05002e
net.micode.notes:id/menu_playground1 = 0x7f05002a
net.micode.notes:style/HighlightTextAppearancePrimary = 0x7f0b0000
net.micode.notes:drawable/font_size_selector_bg = 0x7f040012
net.micode.notes:id/menu_lanyangyang = 0x7f050027
net.micode.notes:id/note_edit_view = 0x7f050036
net.micode.notes:id/menu_list_mode = 0x7f050028
net.micode.notes:id/menu_lanyangyang = 0x7f050026
net.micode.notes:id/note_edit_view = 0x7f050035
net.micode.notes:id/menu_list_mode = 0x7f050027
net.micode.notes:string/menu_lanyangyang = 0x7f0a002d
net.micode.notes:id/account_dialog_title = 0x7f050001
net.micode.notes:id/tv_folder_name = 0x7f050040
net.micode.notes:id/menu_grass = 0x7f050026
net.micode.notes:id/tv_folder_name = 0x7f05003f
net.micode.notes:id/menu_grass = 0x7f050025
net.micode.notes:string/preferences_dialog_select_account_title = 0x7f0a0050
net.micode.notes:id/menu_font_size = 0x7f050025
net.micode.notes:id/menu_font_size = 0x7f050024
net.micode.notes:string/preferences_button_sync_cancel = 0x7f0a004b
net.micode.notes:id/menu_alert = 0x7f050021
net.micode.notes:id/menu_alert = 0x7f050020
net.micode.notes:string/menu_grass = 0x7f0a002c
net.micode.notes:id/ll_font_small = 0x7f05001f
net.micode.notes:id/ll_font_small = 0x7f05001e
net.micode.notes:string/error_note_not_exist = 0x7f0a000e
net.micode.notes:string/error_note_empty_for_send_to_desktop = 0x7f0a000d
net.micode.notes:id/minute = 0x7f050031
net.micode.notes:id/ll_font_normal = 0x7f05001e
net.micode.notes:id/ll_font_large = 0x7f05001d
net.micode.notes:id/minute = 0x7f050030
net.micode.notes:id/ll_font_normal = 0x7f05001d
net.micode.notes:id/ll_font_large = 0x7f05001c
net.micode.notes:string/preferences_button_sync_immediately = 0x7f0a004c
net.micode.notes:string/menu_playground1 = 0x7f0a0032
net.micode.notes:id/iv_super_select = 0x7f05001c
net.micode.notes:id/iv_super_select = 0x7f05001b
net.micode.notes:string/ticker_success = 0x7f0a0065
net.micode.notes:id/iv_medium_select = 0x7f05001a
net.micode.notes:id/iv_large_select = 0x7f050019
net.micode.notes:id/iv_bg_yellow_select = 0x7f050018
net.micode.notes:id/iv_medium_select = 0x7f050019
net.micode.notes:id/iv_large_select = 0x7f050018
net.micode.notes:id/iv_bg_yellow_select = 0x7f050017
net.micode.notes:drawable/bg_btn_set_color = 0x7f040000
net.micode.notes:id/iv_bg_yellow = 0x7f050017
net.micode.notes:id/iv_bg_yellow = 0x7f050016
net.micode.notes:layout/account_dialog_title = 0x7f060000
net.micode.notes:string/notelist_menu_new = 0x7f0a0045
net.micode.notes:drawable/menu_delete = 0x7f04002f
net.micode.notes:id/iv_bg_red_select = 0x7f050014
net.micode.notes:id/iv_bg_red = 0x7f050013
net.micode.notes:id/menu_new_note = 0x7f05002a
net.micode.notes:id/iv_bg_green_select = 0x7f050012
net.micode.notes:id/iv_bg_red_select = 0x7f050013
net.micode.notes:id/iv_bg_red = 0x7f050012
net.micode.notes:menu/note_edit = 0x7f070002
net.micode.notes:drawable/list_white_down = 0x7f040027
net.micode.notes:drawable/list_white_up = 0x7f04002a
net.micode.notes:id/iv_bg_green = 0x7f050011
net.micode.notes:id/iv_bg_green = 0x7f050010
net.micode.notes:drawable/delete = 0x7f040004
net.micode.notes:id/iv_bg_blue = 0x7f05000f
net.micode.notes:id/iv_bg_blue = 0x7f05000e
net.micode.notes:drawable/list_green_single = 0x7f040021
net.micode.notes:id/iv_alert_icon = 0x7f05000e
net.micode.notes:id/iv_alert_icon = 0x7f05000d
net.micode.notes:drawable/list_yellow_single = 0x7f04002d
net.micode.notes:id/cb_edit_item = 0x7f050007
net.micode.notes:id/cb_edit_item = 0x7f050006
net.micode.notes:drawable/font_super = 0x7f040014
net.micode.notes:drawable/edit_title_blue = 0x7f040009
net.micode.notes:color/user_query_highlight = 0x7f020002
net.micode.notes:id/font_size_selector = 0x7f05000c
net.micode.notes:id/font_size_selector = 0x7f05000b
net.micode.notes:string/preferences_toast_cannot_change_account = 0x7f0a0057
net.micode.notes:id/et_edit_text = 0x7f05000a
net.micode.notes:id/et_edit_text = 0x7f050009
net.micode.notes:drawable/widget_2x_yellow = 0x7f04003f
net.micode.notes:id/amPm = 0x7f050004
net.micode.notes:id/amPm = 0x7f050003
net.micode.notes:id/account_dialog_subtitle = 0x7f050000
net.micode.notes:drawable/clock = 0x7f040003
net.micode.notes:drawable/font_small = 0x7f040013
net.micode.notes:id/btn_set_bg_color = 0x7f050006
net.micode.notes:id/btn_set_bg_color = 0x7f050005
net.micode.notes:array/menu_share_ways = 0x7f010001
net.micode.notes:style/NoteTheme = 0x7f0b0003
net.micode.notes:drawable/notification = 0x7f040035
net.micode.notes:id/iv_bg_blue_select = 0x7f050010
net.micode.notes:id/iv_bg_blue_select = 0x7f05000f
net.micode.notes:string/menu_title_select_folder = 0x7f0a003d
net.micode.notes:string/hint_foler_name = 0x7f0a001d
net.micode.notes:drawable/list_red_down = 0x7f040023
net.micode.notes:id/menu_delete = 0x7f050022
net.micode.notes:id/menu_delete = 0x7f050021
net.micode.notes:drawable/lanyangyang = 0x7f040017
net.micode.notes:drawable/widget_4x_blue = 0x7f040040
net.micode.notes:menu/note_list_dropdown = 0x7f070004
net.micode.notes:id/add_img_btn = 0x7f050003
net.micode.notes:drawable/edit_title_white = 0x7f04000c
net.micode.notes:string/menu_delete = 0x7f0a0021
net.micode.notes:drawable/list_footer_bg = 0x7f04001e
@ -227,44 +226,44 @@ net.micode.notes:drawable/edit_title_green = 0x7f04000a
net.micode.notes:drawable/new_note_normal = 0x7f040032
net.micode.notes:drawable/edit_white = 0x7f04000e
net.micode.notes:drawable/widget_2x_green = 0x7f04003c
net.micode.notes:id/iv_bg_white = 0x7f050015
net.micode.notes:id/iv_bg_white = 0x7f050014
net.micode.notes:drawable/bg_color_btn_mask = 0x7f040001
net.micode.notes:drawable/list_yellow_up = 0x7f04002e
net.micode.notes:drawable/list_white_single = 0x7f040029
net.micode.notes:menu/note_list_dropdown = 0x7f070004
net.micode.notes:drawable/edit_title_red = 0x7f04000b
net.micode.notes:id/tv_title_bar = 0x7f050045
net.micode.notes:id/tv_title_bar = 0x7f050044
net.micode.notes:drawable/list_red_up = 0x7f040026
net.micode.notes:id/delete = 0x7f050009
net.micode.notes:id/delete = 0x7f050008
net.micode.notes:layout/note_edit_list_item = 0x7f060006
net.micode.notes:string/call_record_folder_name = 0x7f0a0008
net.micode.notes:drawable/list_green_up = 0x7f040022
net.micode.notes:id/prefenerece_sync_status_textview = 0x7f05003a
net.micode.notes:id/et_foler_name = 0x7f05000b
net.micode.notes:string/folder_exist = 0x7f0a0017
net.micode.notes:id/note_edit_list = 0x7f050035
net.micode.notes:drawable/new_note = 0x7f040031
net.micode.notes:id/menu_delete_remind = 0x7f050023
net.micode.notes:id/prefenerece_sync_status_textview = 0x7f050039
net.micode.notes:id/et_foler_name = 0x7f05000a
net.micode.notes:id/menu_delete_remind = 0x7f050022
net.micode.notes:drawable/note_edit_color_selector_panel = 0x7f040034
net.micode.notes:id/menu_export_text = 0x7f050024
net.micode.notes:id/hour = 0x7f05000d
net.micode.notes:id/menu_export_text = 0x7f050023
net.micode.notes:id/hour = 0x7f05000c
net.micode.notes:string/menu_folder_view = 0x7f0a0026
net.micode.notes:drawable/dropdown_icon = 0x7f040005
net.micode.notes:string/notelist_string_info = 0x7f0a0046
net.micode.notes:drawable/list_blue_single = 0x7f04001b
net.micode.notes:drawable/list_white_middle = 0x7f040028
net.micode.notes:drawable/call_record = 0x7f040002
net.micode.notes:id/text_num = 0x7f05003e
net.micode.notes:id/text_num = 0x7f05003d
net.micode.notes:dimen/text_font_size_normal = 0x7f030002
net.micode.notes:layout/dialog_edit_text = 0x7f060003
net.micode.notes:color/secondary_text_dark = 0x7f020001
net.micode.notes:drawable/list_folder = 0x7f04001d
net.micode.notes:id/iv_bg_green_select = 0x7f050011
net.micode.notes:id/menu_new_note = 0x7f050029
net.micode.notes:drawable/list_green_middle = 0x7f040020
net.micode.notes:string/sync_progress_syncing = 0x7f0a0062
net.micode.notes:drawable/font_normal = 0x7f040011
net.micode.notes:drawable/list_blue_up = 0x7f04001c
net.micode.notes:id/iv_small_select = 0x7f05001b
net.micode.notes:id/iv_small_select = 0x7f05001a
net.micode.notes:drawable/list_blue_down = 0x7f040019
net.micode.notes:id/ll_font_super = 0x7f050020
net.micode.notes:id/ll_font_super = 0x7f05001f
net.micode.notes:dimen/text_font_size_large = 0x7f030000
net.micode.notes:drawable/edit_yellow = 0x7f04000f
net.micode.notes:drawable/list_yellow_down = 0x7f04002b
@ -276,12 +275,12 @@ net.micode.notes:drawable/list_yellow_middle = 0x7f04002c
net.micode.notes:drawable/list_blue_middle = 0x7f04001a
net.micode.notes:dimen/text_font_size_medium = 0x7f030001
net.micode.notes:drawable/new_note_pressed = 0x7f040033
net.micode.notes:id/menu_new_folder = 0x7f050029
net.micode.notes:id/sv_note_edit = 0x7f05003d
net.micode.notes:id/menu_new_folder = 0x7f050028
net.micode.notes:id/sv_note_edit = 0x7f05003c
net.micode.notes:drawable/edit_green = 0x7f040007
net.micode.notes:id/action_select_all = 0x7f050002
net.micode.notes:id/tv_modified_date = 0x7f050041
net.micode.notes:id/iv_bg_white_select = 0x7f050016
net.micode.notes:id/tv_modified_date = 0x7f050040
net.micode.notes:id/iv_bg_white_select = 0x7f050015
net.micode.notes:drawable/edit_title_yellow = 0x7f04000d
net.micode.notes:layout/note_list_footer = 0x7f06000a
net.micode.notes:string/menu_font_super = 0x7f0a002b

@ -44,7 +44,7 @@ public class WorkingNote {//`WorkingNote` 类用于管理笔记数据,包含
// Note Id
private long mNoteId;//笔记的 ID
// Note content
public String mContent;//笔记的内容
private String mContent;//笔记的内容
// Note mode
private int mMode;//笔记的模式

@ -92,6 +92,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>();
static {
sBgSelectorBtnsMap.put(R.id.iv_bg_yellow, ResourceParser.YELLOW); // 黄色背景按钮
sBgSelectorBtnsMap.put(R.id.iv_bg_red, ResourceParser.RED); // 红色背景按钮
@ -101,6 +102,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
private static final Map<Integer, Integer> sBgSelectorSelectionMap = new HashMap<Integer, Integer>();
static {
sBgSelectorSelectionMap.put(ResourceParser.YELLOW, R.id.iv_bg_yellow_select); // 选择的黄色背景按钮
sBgSelectorSelectionMap.put(ResourceParser.RED, R.id.iv_bg_red_select); // 选择的红色背景按钮
@ -110,6 +112,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
private static final Map<Integer, Integer> sFontSizeBtnsMap = new HashMap<Integer, Integer>();
static {
sFontSizeBtnsMap.put(R.id.ll_font_large, ResourceParser.TEXT_LARGE); // 大号字体按钮
sFontSizeBtnsMap.put(R.id.ll_font_small, ResourceParser.TEXT_SMALL); // 小号字体按钮
@ -118,6 +121,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
private static final Map<Integer, Integer> sFontSelectorSelectionMap = new HashMap<Integer, Integer>();
static {
sFontSelectorSelectionMap.put(ResourceParser.TEXT_LARGE, R.id.iv_large_select); // 选择的大号字体按钮
sFontSelectorSelectionMap.put(ResourceParser.TEXT_SMALL, R.id.iv_small_select); // 选择的小号字体按钮
@ -157,6 +161,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private Pattern mPattern; // 模式
private EditText editText; // 编辑框
private TextView textView; // 文本视图
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -169,7 +174,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
initResources();
count();
}
private void count(){
private void count() {
mNoteEditor.addTextChangedListener(new TextWatcher() {
int currentLength = 0;
@ -186,6 +192,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
});
}
/**
* 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
@ -239,7 +246,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
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())) {
} 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,
@ -280,11 +287,11 @@ public class NoteEditActivity extends Activity implements OnClickListener,
| WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
} else {
Log.e(TAG, "Intent not specified action, should not support");
finish();
finish();// 初始化状态失败结束当前Activity
return false;
}
mWorkingNote.setOnSettingStatusChangedListener(this);
return true;
return true;// 输出日志信息表示正在从被销毁的Activity中进行恢复
}
@Override
@ -293,21 +300,25 @@ public class NoteEditActivity extends Activity implements OnClickListener,
initNoteScreen();
}
private void initNoteScreen() {
private void initNoteScreen() { // 设置文本样式为指定字体大小
mNoteEditor.setTextAppearance(this, TextAppearanceResources
.getTexAppearanceResource(mFontSizeId));
// 根据笔记的模式切换到对应的列表模式或文本模式
if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
switchToListMode(mWorkingNote.getContent());
} else {
} 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
@ -323,18 +334,19 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private void showAlertHeader() {
if (mWorkingNote.hasClockAlert()) {
long time = System.currentTimeMillis();
if (time > mWorkingNote.getAlertDate()) {
if (time > mWorkingNote.getAlertDate()) { // 如果提醒时间已过期,则显示"提醒已过期"文本
mNoteHeaderHolder.tvAlertDate.setText(R.string.note_alert_expired);
} else {
} else {// 显示相对时间,例如"2分钟前"
mNoteHeaderHolder.tvAlertDate.setText(DateUtils.getRelativeTimeSpanString(
mWorkingNote.getAlertDate(), time, DateUtils.MINUTE_IN_MILLIS));
}
}// 显示提醒时间文本和提醒图标
mNoteHeaderHolder.tvAlertDate.setVisibility(View.VISIBLE);
mNoteHeaderHolder.ivAlertIcon.setVisibility(View.VISIBLE);
} else {
} else { // 隐藏提醒时间文本和提醒图标
mNoteHeaderHolder.tvAlertDate.setVisibility(View.GONE);
mNoteHeaderHolder.ivAlertIcon.setVisibility(View.GONE);
};
}
;
}
@Override
@ -359,23 +371,23 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
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;
}
}// 调用父类的dispatchTouchEvent方法处理触摸事件
return super.dispatchTouchEvent(ev);
}
private boolean inRangeOfView(View view, MotionEvent ev) {
int []location = new int[2];
int[] location = new int[2];
view.getLocationOnScreen(location);
int x = location[0];
int y = location[1];
@ -383,8 +395,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|| ev.getX() > (x + view.getWidth())
|| ev.getY() < y
|| ev.getY() > (y + view.getHeight())) {
return false;
}
return false;
}
return true;
}
@ -394,10 +406,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
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);
// 初始化编辑器和文本计数器
mNoteHeaderHolder.editText = (EditText) findViewById(R.id.note_edit_view);
mNoteHeaderHolder.textView = (TextView) findViewById(R.id.text_num);
// 初始化背景颜色选择器按钮和点击事件
mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color);
mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this);
mNoteEditor = (EditText) findViewById(R.id.note_edit_view);
@ -407,12 +419,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
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);
};
}
;
// 初始化SharedPreferences和字体大小
mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
mFontSizeId = mSharedPrefs.getInt(PREFERENCE_FONT_SIZE, ResourceParser.BG_DEFAULT_FONT_SIZE);
/**
@ -420,36 +434,42 @@ public class NoteEditActivity extends Activity implements OnClickListener,
* The id may larger than the length of resources, in this case,
* return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE}
*/
if(mFontSizeId >= TextAppearanceResources.getResourcesSize()) {
if (mFontSizeId >= TextAppearanceResources.getResourcesSize()) {
mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE;
}
// 初始化编辑器列表
mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list);
}
@Override
protected void onPause() {
super.onPause();
if(saveNote()) {
if (saveNote()) {
Log.d(TAG, "Note data was saved with length:" + mWorkingNote.getContent().length());
}
clearSettingState();
}
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");
Log.e(TAG, "Unsupported widget type");
return;
}
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] {
mWorkingNote.getWidgetId()
// 将当前笔记的小部件ID作为额外参数传递给意图
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[]{
mWorkingNote.getWidgetId()
});
// 发送广播,通知小部件进行更新
sendBroadcast(intent);
setResult(RESULT_OK, intent);
}
@ -457,14 +477,16 @@ public class NoteEditActivity extends Activity implements OnClickListener,
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(View.VISIBLE);
} else if (sBgSelectorBtnsMap.containsKey(id)) {
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.GONE);
// 隐藏当前笔记的背景颜色选中状态并设置新的背景颜色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();
@ -473,16 +495,16 @@ public class NoteEditActivity extends Activity implements OnClickListener,
getWorkingText();
switchToListMode(mWorkingNote.getContent());
} else {
mNoteEditor.setTextAppearance(this,
TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
mNoteEditor.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
}
mFontSizeSelector.setVisibility(View.GONE);
}
}
@Override
public void onBackPressed() {
if(clearSettingState()) {
if (clearSettingState()) {
return;
}
@ -491,10 +513,13 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
private boolean clearSettingState() {
// 如果背景颜色选择器可见,则隐藏它
if (mNoteBgColorSelector.getVisibility() == View.VISIBLE) {
mNoteBgColorSelector.setVisibility(View.GONE);
return true;
} else if (mFontSizeSelector.getVisibility() == View.VISIBLE) {
}
// 如果字体大小选择器可见,则隐藏它
else if (mFontSizeSelector.getVisibility() == View.VISIBLE) {
mFontSizeSelector.setVisibility(View.GONE);
return true;
}
@ -502,29 +527,35 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
public void onBackgroundColorChanged() {
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.VISIBLE);
// 显示当前笔记的背景颜色选中状态,并更新编辑器和标题栏的背景资源
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(View.VISIBLE);
mNoteEditorPanel.setBackgroundResource(mWorkingNote.getBgColorResId());
mHeadViewPanel.setBackgroundResource(mWorkingNote.getTitleBgResId());
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// 如果Activity即将关闭则返回true
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);
}
// 根据笔记的模式,设置列表模式菜单项的标题
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 {
@ -533,6 +564,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
/**
@ -589,7 +621,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis());
d.setOnDateTimeSetListener(new OnDateTimeSetListener() {
public void OnDateTimeSet(AlertDialog dialog, long date) {
mWorkingNote.setAlertDate(date , true);
mWorkingNote.setAlertDate(date, true);
}
});
d.show();
@ -626,6 +658,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
private void deleteCurrentNote() {
// 如果当前笔记存在于数据库中
if (mWorkingNote.existInDatabase()) {
HashSet<Long> ids = new HashSet<Long>();
long id = mWorkingNote.getNoteId();
@ -634,28 +667,30 @@ public class NoteEditActivity extends Activity implements OnClickListener,
} 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;
}
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();
}
@ -665,45 +700,45 @@ public class NoteEditActivity extends Activity implements OnClickListener,
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE));
showAlertHeader();
if(!set) {
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
*/
// 如果没有笔记ID则提示用户输入内容
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);
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);
edit = (NoteEditText) mEditTextList.getChildAt(index - 1).findViewById(R.id.et_edit_text);
}
int length = edit.length();
edit.append(text);
@ -712,13 +747,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
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");
// 调试时不应该发生的情况,检查索引是否超出范围
if (index > mEditTextList.getChildCount()) {
Log.e(TAG, "Index out of mEditTextList boundary, should not happen");
}
// 在指定索引处添加编辑文本
View view = getListItem(text, index);
mEditTextList.addView(view, index);
NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
@ -731,18 +765,23 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
private void switchToListMode(String text) {
// 清空编辑文本列表
mEditTextList.removeAllViews();
// 将文本按换行符分割为多个条目
String[] items = text.split("\n");
int index = 0;
for (String item : items) {
if(!TextUtils.isEmpty(item)) {
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);
}
@ -754,6 +793,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
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(),
@ -765,12 +805,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
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 {
@ -780,10 +822,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
});
if (item.startsWith(TAG_CHECKED)) {
// 如果条目以"[x] "开头,则设置复选框为选中状态,并添加删除线样式
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();
@ -795,12 +839,13 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return view;
}
public void onTextChange(int index, boolean hasText) {
if (index >= mEditTextList.getChildCount()) {
Log.e(TAG, "Wrong index, should not happen");
return;
}
if(hasText) {
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);
@ -823,6 +868,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
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++) {
@ -830,47 +876,44 @@ public class NoteEditActivity extends Activity implements OnClickListener,
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()) {
// 如果编辑文本的复选框被选中,则添加"[x] "前缀
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
*/
// 设置结果为RESULT_OK用于标识创建/编辑状态
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);
@ -885,17 +928,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
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
*/
// 如果没有笔记ID则提示用户输入内容
Log.e(TAG, "Send to desktop error");
showToast(R.string.error_note_empty_for_send_to_desktop);
}
}
private String makeShortcutIconTitle(String content) {
// 去除文本中的"[x] "和"[ ] "前缀,作为快捷方式的标题
content = content.replace(TAG_CHECKED, "");
content = content.replace(TAG_UNCHECKED, "");
return content.length() > SHORTCUT_ICON_TITLE_MAX_LEN ? content.substring(0,
@ -909,6 +949,4 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private void showToast(int resId, int duration) {
Toast.makeText(this, resId, duration).show();
}
}

@ -16,12 +16,9 @@
package net.micode.notes.ui;
import static net.micode.notes.R.id.*;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.SearchManager;
import android.appwidget.AppWidgetManager;
import android.content.AsyncQueryHandler;
import android.content.ContentResolver;
@ -31,21 +28,12 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.ImageSpan;
import android.util.Log;
import android.view.ActionMode;
import android.view.ContextMenu;
@ -61,21 +49,18 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnCreateContextMenuListener;
import android.view.View.OnTouchListener;
import android.view.WindowManager;
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.ImageButton;
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.R.id;
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.gtask.remote.GTaskSyncService;
@ -88,7 +73,6 @@ import net.micode.notes.widget.NoteWidgetProvider_2x;
import net.micode.notes.widget.NoteWidgetProvider_4x;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -97,7 +81,7 @@ import java.util.HashSet;
public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener {
/* 首页背景切换*/
private int mode = -1;
private WorkingNote mWorkingNote;
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
private static final int FOLDER_LIST_QUERY_TOKEN = 1;
@ -112,7 +96,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
private enum ListEditState {
NOTE_LIST, SUB_FOLDER, CALL_RECORD_FOLDER
}
};
private ListEditState mState;
@ -153,76 +137,19 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
private final static int REQUEST_CODE_OPEN_NODE = 102;
private final static int REQUEST_CODE_NEW_NODE = 103;
private final int PHOTO_REQUEST = 1;//请求码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.note_edit);
setContentView(R.layout.note_list);
getWindow().setBackgroundDrawableResource(R.drawable.lanyangyang);
initResources();
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");
//ACTION_GET_CONTENT: 允许用户选择特殊种类的数据,并返回(特殊种类的数据:照一张相片或录一段音)
Intent loadImage = new Intent(Intent.ACTION_GET_CONTENT);
//Category属性用于指定当前动作Action被执行的环境.
//CATEGORY_OPENABLE; 用来指示一个ACTION_GET_CONTENT的intent
loadImage.addCategory(Intent.CATEGORY_OPENABLE);
loadImage.setType("image/*");
startActivityForResult(loadImage, PHOTO_REQUEST);
}
});
/**
* Insert an introduction when user firstly use this application
*/
setAppInfoFromRawRes();
}
//路径字符串格式 转换为 图片image格式
private void convertToImage() {
NoteEditText noteEditText = (NoteEditText) findViewById(note_edit_view); //获取当前的edit
Editable editable = noteEditText.getText();//1.获取text
String noteText = editable.toString(); //2.将note内容转换为字符串
int length = editable.length(); //内容的长度
//3.截取img片段 [local]+uri+[local]提取uri
for(int i = 0; i < length; i++) {
for(int j = i; j < length; j++) {
String img_fragment = noteText.substring(i, j+1); //img_fragment关于图片路径的片段
if(img_fragment.length() > 15 && img_fragment.endsWith("[/local]") && img_fragment.startsWith("[local]")){
int limit = 7; //[local]为7个字符
//[local][/local]共15个字符剩下的为真正的path长度
int len = img_fragment.length()-15;
//从[local]之后的len个字符就是path
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(this, bitmap);
//4.创建一个SpannableString对象以便插入用ImageSpan对象封装的图像
String ss = "[local]" + path + "[/local]";
SpannableString spannableString = new SpannableString(ss);
//5.将指定的标记对象附加到文本的开始...结束范围
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); //6.删掉图片路径的文字
edit_text.insert(i, spannableString); //7.在路径的起始位置插入图片
}
}
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
@ -232,110 +159,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
} else {
super.onActivityResult(requestCode, resultCode, data);
}
ContentResolver resolver = getContentResolver();
switch (requestCode) {
case PHOTO_REQUEST:
Intent intent = new Intent(this, NoteEditActivity.class);
Uri originalUri = intent.getData(); //1.获得图片的真实路径
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){
//3.根据Bitmap对象创建ImageSpan对象
Log.d(TAG, "onActivityResult: bitmap is not null");
ImageSpan imageSpan = new ImageSpan(this, bitmap);
String path = getPath(this,originalUri);
//4.使用[local][/local]将path括起来用于之后方便识别图片路径在note中的位置
String img_fragment= "[local]" + path + "[/local]";
//创建一个SpannableString对象以便插入用ImageSpan对象封装的图像
SpannableString spannableString = new SpannableString(img_fragment);
spannableString.setSpan(imageSpan, 0, img_fragment.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
//5.将选择的图片追加到EditText中光标所在位置
NoteEditText e = (NoteEditText) findViewById(note_edit_view);
int index = e.getSelectionStart(); //获取光标所在位置
Log.d(TAG, "Index是: " + index);
Editable edit_text = e.getEditableText();
edit_text.insert(index, spannableString); //将图片插入到光标所在位置
mWorkingNote.mContent = e.getText().toString();
//6.把改动提交到数据库中,两个数据库表都要改的
ContentResolver contentResolver = getContentResolver();
ContentValues contentValues = new ContentValues();
final long id = mWorkingNote.getNoteId();
contentValues.put("snippet",mWorkingNote.mContent);
contentResolver.update(Uri.parse("content://micode_notes/note"), contentValues,"_id=?",new String[]{""+id});
ContentValues contentValues1 = new ContentValues();
contentValues1.put("content",mWorkingNote.mContent);
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(this, "获取图片失败", Toast.LENGTH_SHORT).show();
}
break;
default:
break;
}
}
//获取数据列_获取此 Uri 的数据列的值。这对MediaStore Uris 和其他基于文件的 ContentProvider。
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;
}
//获取文件的real path
public String getPath(final Context context, final Uri uri) {
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// DocumentProvider
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;
}
private void setAppInfoFromRawRes() {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
@ -389,25 +213,24 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
startAsyncNotesListQuery();
}
private void initResources() {
mContentResolver = this.getContentResolver();
mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver());
mCurrentFolderId = Notes.ID_ROOT_FOLDER;
mNotesListView = (ListView) findViewById(notes_list);
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(btn_new_note);
mAddNewNote = (Button) findViewById(R.id.btn_new_note);
mAddNewNote.setOnClickListener(this);
mAddNewNote.setOnTouchListener(new NewNoteOnTouchListener());
mDispatch = false;
mDispatchY = 0;
mOriginY = 0;
mTitleBar = (TextView) findViewById(tv_title_bar);
mTitleBar = (TextView) findViewById(R.id.tv_title_bar);
mState = ListEditState.NOTE_LIST;
mModeCallBack = new ModeCallback();
@ -420,8 +243,8 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
getMenuInflater().inflate(R.menu.note_list_options, menu);
menu.findItem(delete).setOnMenuItemClickListener(this);
mMoveMenu = menu.findItem(move);
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);
@ -438,7 +261,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
R.layout.note_list_dropdown_menu, null);
mode.setCustomView(customView);
mDropDownMenu = new DropdownMenu(NotesListActivity.this,
(Button) customView.findViewById(selection_menu),
(Button) customView.findViewById(R.id.selection_menu),
R.menu.note_list_dropdown);
mDropDownMenu.setOnDropdownMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){
public boolean onMenuItemClick(MenuItem item) {
@ -456,7 +279,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
// Update dropdown menu
String format = getResources().getString(R.string.menu_select_title, selectedCount);
mDropDownMenu.setTitle(format);
MenuItem item = mDropDownMenu.findItem(action_select_all);
MenuItem item = mDropDownMenu.findItem(R.id.action_select_all);
if (item != null) {
if (mNotesListAdapter.isAllSelected()) {
item.setChecked(true);
@ -503,7 +326,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
int itemId = item.getItemId();
if (itemId == delete) {
if (itemId == 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);
@ -518,7 +341,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.show();
} else if (itemId == move) {
} else if (itemId == R.id.move) {
startQueryDestinationFolders();
} else {
return false;
@ -751,7 +574,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
public void onClick(View v) {
if (v.getId() == btn_new_note) {
if (v.getId() == R.id.btn_new_note) {
createNewNote();
}
}
@ -780,7 +603,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
private void showCreateOrModifyFolderDialog(final boolean create) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this); // 创建一个AlertDialog.Builder对象
View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null); // 从XML布局文件中加载视图
final EditText etName = (EditText) view.findViewById(et_foler_name); // 获取布局文件中的EditText控件
final EditText etName = (EditText) view.findViewById(R.id.et_foler_name); // 获取布局文件中的EditText控件
showSoftInput(); // 显示软键盘
if (!create) { // 判断是否为修改文件夹名称
if (mFocusNoteDataItem != null) {
@ -964,7 +787,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
if (mState == ListEditState.NOTE_LIST) {
getMenuInflater().inflate(R.menu.note_list, menu);
// set sync or sync_cancel
menu.findItem(menu_sync).setTitle(
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);
@ -974,11 +797,11 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
Log.e(TAG, "Wrong state:" + mState);
}
if (mode == -1) {
menu.findItem(menu_lanyangyang).setVisible(false);
menu.findItem(R.id.menu_lanyangyang).setVisible(false);
} else if (mode == 0) {
menu.findItem(menu_grass).setVisible(false);
menu.findItem(R.id.menu_grass).setVisible(false);
} else if (mode == 1) {
menu.findItem(menu_playground1).setVisible(false);
menu.findItem(R.id.menu_playground1).setVisible(false);
}
return true;
}
@ -986,11 +809,11 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == menu_new_folder) {
if (itemId == R.id.menu_new_folder) {
showCreateOrModifyFolderDialog(true);
} else if (itemId == menu_export_text) {
} else if (itemId == R.id.menu_export_text) {
exportNoteToText();
} else if (itemId == menu_sync) {
} else if (itemId == R.id.menu_sync) {
if (isSyncMode()) {
if (TextUtils.equals(item.getTitle(), getString(R.string.menu_sync))) {
GTaskSyncService.startSync(this);
@ -1000,19 +823,19 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
} else {
startPreferenceActivity();
}
} else if (itemId == menu_setting) {
} else if (itemId == R.id.menu_setting) {
startPreferenceActivity();
} else if (itemId == menu_new_note) {
} else if (itemId == R.id.menu_new_note) {
createNewNote();
} else if (itemId == menu_search) {
} else if (itemId == R.id.menu_search) {
onSearchRequested();
} else if (itemId == menu_lanyangyang) {
} else if (itemId == R.id.menu_lanyangyang) {
mode = -1;
getWindow().setBackgroundDrawableResource(R.drawable.lanyangyang);
} else if (itemId == menu_grass) {
} else if (itemId == R.id.menu_grass) {
mode = 0;
getWindow().setBackgroundDrawableResource(R.drawable.grass);
} else if (itemId == menu_playground1) {
} else if (itemId == R.id.menu_playground1) {
mode = 1;
getWindow().setBackgroundDrawableResource(R.drawable.playground1);
}
@ -1152,10 +975,4 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
return false;
}
//是否为媒体文件
public boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
}

@ -33,100 +33,155 @@ import net.micode.notes.ui.NoteEditActivity;
import net.micode.notes.ui.NotesListActivity;
public abstract class NoteWidgetProvider extends AppWidgetProvider {
public static final String [] PROJECTION = new String [] {
NoteColumns.ID,
NoteColumns.BG_COLOR_ID,
NoteColumns.SNIPPET
public static final String[] PROJECTION = new String[] {
NoteColumns.ID, // 在查询结果中表示笔记的ID
NoteColumns.BG_COLOR_ID, // 在查询结果中表示笔记的背景颜色的ID
NoteColumns.SNIPPET // 在查询结果中表示笔记的摘要
};
public static final int COLUMN_ID = 0;
public static final int COLUMN_BG_COLOR_ID = 1;
public static final int COLUMN_SNIPPET = 2;
public static final int COLUMN_ID = 0; // 笔记ID在PROJECTION数组中的索引
public static final int COLUMN_BG_COLOR_ID = 1; // 背景颜色ID在PROJECTION数组中的索引
public static final int COLUMN_SNIPPET = 2; // 笔记摘要在PROJECTION数组中的索引
private static final String TAG = "NoteWidgetProvider";
private static final String TAG = "NoteWidgetProvider"; // 用于日志的标签用于在日志中标识来自NoteWidgetProvider的信息
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
// 定义一个 ContentValues 对象用于存储需要更新的数据
ContentValues values = new ContentValues();
// 将无效的小部件 IDAppWidgetManager.INVALID_APPWIDGET_ID存入 values
values.put(NoteColumns.WIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
// 遍历 appWidgetIds 数组中的所有小部件 ID
for (int i = 0; i < appWidgetIds.length; i++) {
context.getContentResolver().update(Notes.CONTENT_NOTE_URI,
values,
NoteColumns.WIDGET_ID + "=?",
new String[] { String.valueOf(appWidgetIds[i])});
/**
* ContentResolver update()
* Notes.CONTENT_NOTE_URI
* NoteColumns.WIDGET_ID = appWidgetIds[i]
* values
*/
context.getContentResolver().update(
Notes.CONTENT_NOTE_URI, // 更新的数据位于此 URI 地址下
values, // 需要更新的数据
NoteColumns.WIDGET_ID + "=?", // 更新条件NoteColumns.WIDGET_ID = appWidgetIds[i]
new String[] { String.valueOf(appWidgetIds[i])} // 更新条件的参数值
);
}
}
private Cursor getNoteWidgetInfo(Context context, int widgetId) {
return context.getContentResolver().query(Notes.CONTENT_NOTE_URI,
PROJECTION,
NoteColumns.WIDGET_ID + "=? AND " + NoteColumns.PARENT_ID + "<>?",
new String[] { String.valueOf(widgetId), String.valueOf(Notes.ID_TRASH_FOLER) },
null);
/**
* 使 ContentResolver query() Notes.CONTENT_NOTE_URI
* PROJECTION
* NoteColumns.WIDGET_ID = widgetId NoteColumns.PARENT_ID <> Notes.ID_TRASH_FOLER
* widgetId Notes.ID_TRASH_FOLER
* null
*/
return context.getContentResolver().query(
Notes.CONTENT_NOTE_URI, // 查询的数据位于此 URI 地址下
PROJECTION, // 查询的列为 PROJECTION 数组所指定的列
NoteColumns.WIDGET_ID + "=? AND " + NoteColumns.PARENT_ID + "<>?", // 查询条件
new String[]{String.valueOf(widgetId), String.valueOf(Notes.ID_TRASH_FOLER)}, // 查询参数
null // 排序参数
);
}
protected void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
/**
* update() false
*
*/
update(context, appWidgetManager, appWidgetIds, false);
}
private void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds,
boolean privacyMode) {
boolean privacyMode) {
// 遍历 appWidgetIds 数组
for (int i = 0; i < appWidgetIds.length; i++) {
// 如果 appWidgetIds[i] 不等于无效的 appWidgetId
if (appWidgetIds[i] != AppWidgetManager.INVALID_APPWIDGET_ID) {
// 获取默认背景 id
int bgId = ResourceParser.getDefaultBgId(context);
// 默认片段为空字符串
String snippet = "";
// 创建一个 Intent 对象,并指定其目标为 NoteEditActivity 类
Intent intent = new Intent(context, NoteEditActivity.class);
// 设置 Intent 的标志为 Intent.FLAG_ACTIVITY_SINGLE_TOP
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// 将 appWidgetIds[i] 作为额外的 widgetId 传递给 Intent
intent.putExtra(Notes.INTENT_EXTRA_WIDGET_ID, appWidgetIds[i]);
// 将 widgetType 传递给 Intent
intent.putExtra(Notes.INTENT_EXTRA_WIDGET_TYPE, getWidgetType());
// 调用 getNoteWidgetInfo() 方法查询与当前 widgetId 关联的便签数据
Cursor c = getNoteWidgetInfo(context, appWidgetIds[i]);
// 判断查询结果是否为 null 且是否有数据
if (c != null && c.moveToFirst()) {
// 如果查询结果数量大于 1则输出错误日志并关闭 Cursor 并返回
if (c.getCount() > 1) {
Log.e(TAG, "Multiple message with same widget id:" + appWidgetIds[i]);
c.close();
return;
}
// 获取片段内容
snippet = c.getString(COLUMN_SNIPPET);
// 获取背景颜色 id
bgId = c.getInt(COLUMN_BG_COLOR_ID);
// 将便签的 ID 传递给 Intent
intent.putExtra(Intent.EXTRA_UID, c.getLong(COLUMN_ID));
// 设置 Action 为 ACTION_VIEW
intent.setAction(Intent.ACTION_VIEW);
} else {
// 如果查询结果为空,则设置片段内容为默认的提示语
snippet = context.getResources().getString(R.string.widget_havenot_content);
// 设置 Action 为 ACTION_INSERT_OR_EDIT
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
}
// 关闭 Cursor
if (c != null) {
c.close();
}
// 创建 RemoteViews 对象,并设置其布局资源 ID
RemoteViews rv = new RemoteViews(context.getPackageName(), getLayoutId());
// 设置 RemoteViews 中的 ImageView 的资源 ID
rv.setImageViewResource(R.id.widget_bg_image, getBgResourceId(bgId));
// 将背景颜色 id 作为额外的参数传递给 Intent
intent.putExtra(Notes.INTENT_EXTRA_BACKGROUND_ID, bgId);
/**
* Generate the pending intent to start host for the widget
* widget 宿 PendingIntent
*/
PendingIntent pendingIntent = null;
// 如果处于隐私模式下
if (privacyMode) {
// 设置 RemoteViews 中的 TextView 的文本为隐私模式提示语
rv.setTextViewText(R.id.widget_text,
context.getString(R.string.widget_under_visit_mode));
// 创建用于启动 NotesListActivity 的 PendingIntent
pendingIntent = PendingIntent.getActivity(context, appWidgetIds[i], new Intent(
context, NotesListActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
} else {
// 如果不处于隐私模式下,则设置 RemoteViews 中的 TextView 的文本为片段内容
rv.setTextViewText(R.id.widget_text, snippet);
// 创建用于启动 NoteEditActivity 的 PendingIntent
pendingIntent = PendingIntent.getActivity(context, appWidgetIds[i], intent,
PendingIntent.FLAG_UPDATE_CURRENT);
}
// 设置 RemoteViews 中的 TextView 的点击事件为 pendingIntent
rv.setOnClickPendingIntent(R.id.widget_text, pendingIntent);
// 更新 appWidgetManager 中对应 appWidgetId 的 widget
appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
}
}
}
protected abstract int getBgResourceId(int bgId);
protected abstract int getBgResourceId(int bgId);//根据给定的背景 ID 返回对应的背景资源 ID
protected abstract int getLayoutId();
protected abstract int getLayoutId();//返回当前小部件的布局资源 ID。
protected abstract int getWidgetType();
protected abstract int getWidgetType();//返回当前小部件的类型。
}

@ -26,21 +26,25 @@ import net.micode.notes.tool.ResourceParser;
public class NoteWidgetProvider_2x extends NoteWidgetProvider {
@Override
//重写了父类的onUpdate()方法并且在方法中调用了父类的update()方法。
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.update(context, appWidgetManager, appWidgetIds);
}
@Override
//重写getLayoutId()方法它返回R.layout.widget_2x指定了当前小部件所使用的布局资源ID。
protected int getLayoutId() {
return R.layout.widget_2x;
}
@Override
//重写getBgResourceId()方法它接收一个背景ID参数然后调用ResourceParser.WidgetBgResources.getWidget2xBgResource()方法来返回对应背景ID的资源ID。
protected int getBgResourceId(int bgId) {
return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId);
}
@Override
//重写的getWidgetType()方法它返回Notes.TYPE_WIDGET_2X指定了当前小部件的类型。
protected int getWidgetType() {
return Notes.TYPE_WIDGET_2X;
}

@ -26,20 +26,23 @@ import net.micode.notes.tool.ResourceParser;
public class NoteWidgetProvider_4x extends NoteWidgetProvider {
@Override
//重写父类NoteWidgetProvider中的onUpdate方法使用了super关键字调用了父类的update方法。
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.update(context, appWidgetManager, appWidgetIds);
}
//非重写的getLayoutId方法返回了R.layout.widget_4x指定了当前小部件所使用的布局资源ID。
protected int getLayoutId() {
return R.layout.widget_4x;
}
@Override
//重写了父类NoteWidgetProvider中的getBgResourceId方法根据bgId调用了ResourceParser.WidgetBgResources.getWidget4xBgResource方法返回对应背景ID的资源ID。
protected int getBgResourceId(int bgId) {
return ResourceParser.WidgetBgResources.getWidget4xBgResource(bgId);
}
@Override
//重写父类NoteWidgetProvider中的getWidgetType方法返回了Notes.TYPE_WIDGET_4X指定了当前小部件的类型。
protected int getWidgetType() {
return Notes.TYPE_WIDGET_4X;
}

@ -69,8 +69,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/bg_btn_set_color" />
</LinearLayout>
<LinearLayout
@ -407,13 +405,4 @@
android:src="@drawable/selected" />
</FrameLayout>
</LinearLayout>
<ImageButton
android:id="@+id/add_img_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginTop="600dp"
android:layout_marginBottom="7dp"
android:src="@android:drawable/ic_menu_gallery" />
</FrameLayout>

@ -17,7 +17,6 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!--android:background="@drawable/list_background" -->
@ -56,11 +55,4 @@
android:layout_gravity="bottom"
android:background="@drawable/new_note"
android:focusable="false" />
<Button
android:id="@+id/add_img_btn"
android:layout_width="match_parent"
android:layout_height="135dp"
android:layout_gravity="bottom"
android:focusable="false"
tools:ignore="DuplicateIds" />
</FrameLayout>

Loading…
Cancel
Save