comment
This commit is contained in:
parent
4231e1220e
commit
f97578591f
|
@ -7,19 +7,7 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c8515555-ebbc-49d5-889b-0c59bd6c3b6d" name="默认更改列表" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.bin" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.lock" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/5.4.1/fileHashes/fileHashes.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/fileHashes/fileHashes.bin" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/5.4.1/fileHashes/fileHashes.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/fileHashes/fileHashes.lock" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/sonarlint/issuestore/2/8/283f16cc23da56ca65616082bc810304d3511d0a" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/sonarlint/issuestore/2/8/283f16cc23da56ca65616082bc810304d3511d0a" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/sonarlint/issuestore/3/e/3e688be40dc69cfd1062f41d0fc27fe261a26710" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/sonarlint/issuestore/3/e/3e688be40dc69cfd1062f41d0fc27fe261a26710" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/sonarlint/issuestore/5/7/577f30d26378ec8a2bd2e4a43f3c79b3f04c402c" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/sonarlint/issuestore/5/7/577f30d26378ec8a2bd2e4a43f3c79b3f04c402c" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/sonarlint/issuestore/6/a/6a65e747031f27aef20597b4181148a9fbf963d5" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/sonarlint/issuestore/6/a/6a65e747031f27aef20597b4181148a9fbf963d5" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/sonarlint/issuestore/8/7/876016634c6642b35109680ccac740dc8271b236" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/sonarlint/issuestore/8/7/876016634c6642b35109680ccac740dc8271b236" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/sonarlint/issuestore/a/d/ad72331a1bed265bb9c0fe838faa74dbf69fce32" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/sonarlint/issuestore/a/d/ad72331a1bed265bb9c0fe838faa74dbf69fce32" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/build/generated/source/buildConfig/debug/net/micode/notes/BuildConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/build/generated/source/buildConfig/debug/net/micode/notes/BuildConfig.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/src/main/java/net/micode/notes/ui/NotesListActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/net/micode/notes/ui/NotesListActivity.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
|
@ -54,24 +42,35 @@
|
|||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/ui/NotesListActivity.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="328">
|
||||
<caret line="319" column="67" selection-start-line="319" selection-start-column="67" selection-end-line="319" selection-end-column="67" />
|
||||
<state relative-caret-position="244">
|
||||
<caret line="1021" lean-forward="true" selection-start-line="1021" selection-end-line="1021" />
|
||||
<folding>
|
||||
<element signature="e#10700#10767#0" expanded="true" />
|
||||
<element signature="e#11187#11211#0" expanded="true" />
|
||||
<element signature="e#12282#12318#0" expanded="true" />
|
||||
<element signature="e#23149#23181#0" expanded="true" />
|
||||
<element signature="e#24580#24623#0" expanded="true" />
|
||||
<element signature="e#24827#24870#0" expanded="true" />
|
||||
<element signature="e#25005#25176#0" expanded="true" />
|
||||
<element signature="e#25175#25176#0" expanded="true" />
|
||||
<element signature="e#25359#26888#0" expanded="true" />
|
||||
<element signature="e#26887#26888#0" expanded="true" />
|
||||
<element signature="e#29304#29828#0" expanded="true" />
|
||||
<element signature="e#29827#29828#0" expanded="true" />
|
||||
<element signature="e#32663#32692#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/res/values-zh-rCN/strings.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="166">
|
||||
<caret line="48" column="29" selection-start-line="48" selection-start-column="29" selection-end-line="48" selection-end-column="29" />
|
||||
<state relative-caret-position="149">
|
||||
<caret line="40" column="18" selection-start-line="40" selection-start-column="18" selection-end-line="40" selection-end-column="18" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -97,8 +96,8 @@
|
|||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Notes.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2888">
|
||||
<caret line="171" column="15" lean-forward="true" selection-start-line="171" selection-start-column="15" selection-end-line="171" selection-end-column="15" />
|
||||
<state relative-caret-position="158">
|
||||
<caret line="45" column="31" selection-start-line="45" selection-start-column="31" selection-end-line="45" selection-end-column="31" />
|
||||
<folding>
|
||||
<element signature="e#0#9163#0" expanded="true" />
|
||||
<element signature="class#TextNote#0;class#Notes#0" />
|
||||
|
@ -108,15 +107,6 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="140">
|
||||
<caret line="30" column="13" selection-start-line="30" selection-start-column="13" selection-end-line="30" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/model/Note.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
|
@ -134,15 +124,6 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/model/WorkingNote.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="6060">
|
||||
<caret line="354" column="15" selection-start-line="354" selection-start-column="15" selection-end-line="354" selection-end-column="15" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
|
@ -828,7 +809,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1570527902675</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="24" />
|
||||
<task id="LOCAL-00024" summary="noteslistactivity">
|
||||
<created>1570673666384</created>
|
||||
<option name="number" value="00024" />
|
||||
<option name="presentableId" value="LOCAL-00024" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1570673666384</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="25" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TodoView">
|
||||
|
@ -845,7 +833,7 @@
|
|||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info id="Captures" order="0" sideWeight="0.5019305" side_tool="true" weight="0.16957104" />
|
||||
<window_info active="true" content_ui="combo" id="Project" order="1" sideWeight="0.48771265" visible="true" weight="0.15281501" />
|
||||
<window_info content_ui="combo" id="Project" order="1" sideWeight="0.48771265" visible="true" weight="0.15281501" />
|
||||
<window_info id="设计器" order="2" />
|
||||
<window_info id="Resources Explorer" order="3" weight="0.3297587" />
|
||||
<window_info id="Structure" order="4" sideWeight="0.51132077" side_tool="true" weight="0.15281501" />
|
||||
|
@ -863,14 +851,14 @@
|
|||
<window_info anchor="bottom" id="Terminal" order="7" weight="0.3297587" />
|
||||
<window_info anchor="bottom" id="Event Log" order="8" side_tool="true" weight="0.3294271" />
|
||||
<window_info anchor="bottom" id="Version Control" order="9" weight="0.3297587" />
|
||||
<window_info anchor="bottom" id="Build" order="10" visible="true" weight="0.29088473" />
|
||||
<window_info active="true" anchor="bottom" id="Build" order="10" visible="true" weight="0.29088473" />
|
||||
<window_info anchor="bottom" id="Messages" order="11" weight="0.3297587" />
|
||||
<window_info anchor="right" id="Gradle" order="0" weight="0.3297587" />
|
||||
<window_info anchor="right" id="Device File Explorer" order="1" side_tool="true" weight="0.3297587" />
|
||||
<window_info anchor="right" id="Theme Preview" order="2" />
|
||||
<window_info anchor="right" id="Capture Analysis" order="3" />
|
||||
<window_info anchor="right" id="Palette	" order="4" />
|
||||
<window_info anchor="right" id="Preview" order="5" weight="0.3294271" />
|
||||
<window_info anchor="right" id="Preview" order="5" weight="0.32908848" />
|
||||
<window_info anchor="right" id="Assistant" order="6" weight="0.3297587" />
|
||||
</layout>
|
||||
</component>
|
||||
|
@ -914,31 +902,6 @@
|
|||
<option name="LAST_COMMIT_MESSAGE" value="noteslistactivity" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/app/build/generated/not_namespaced_r_class_sources/debug/r/net/micode/notes/R.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="280">
|
||||
<caret line="14" column="11" lean-forward="true" selection-start-line="14" selection-start-column="11" selection-end-line="14" selection-end-column="11" />
|
||||
<folding>
|
||||
<element signature="e#0#16964#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/res/drawable-hdpi/clock.png">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/res/drawable-hdpi/list_blue_middle.9.png">
|
||||
<provider selected="true" editor-type-id="ninepatcheditor" />
|
||||
<provider editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/res/drawable-hdpi/list_green_up.9.png">
|
||||
<provider selected="true" editor-type-id="ninepatcheditor" />
|
||||
<provider editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/res/drawable-hdpi/list_white_single.9.png">
|
||||
<provider selected="true" editor-type-id="ninepatcheditor" />
|
||||
<provider editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/res/drawable-hdpi/menu_delete.png">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
|
@ -1221,18 +1184,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Notes.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2888">
|
||||
<caret line="171" column="15" lean-forward="true" selection-start-line="171" selection-start-column="15" selection-end-line="171" selection-end-column="15" />
|
||||
<folding>
|
||||
<element signature="e#0#9163#0" expanded="true" />
|
||||
<element signature="class#TextNote#0;class#Notes#0" />
|
||||
<element signature="class#CallNote#0;class#Notes#0" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-145">
|
||||
|
@ -1247,24 +1198,70 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/res/values-zh-rCN/strings.xml">
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/res/layout/dialog_edit_text.xml">
|
||||
<provider editor-type-id="text-editor" />
|
||||
<provider selected="true" editor-type-id="android-designer2" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Notes.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="166">
|
||||
<caret line="48" column="29" selection-start-line="48" selection-start-column="29" selection-end-line="48" selection-end-column="29" />
|
||||
<state relative-caret-position="158">
|
||||
<caret line="45" column="31" selection-start-line="45" selection-start-column="31" selection-end-line="45" selection-end-column="31" />
|
||||
<folding>
|
||||
<element signature="e#0#9163#0" expanded="true" />
|
||||
<element signature="class#TextNote#0;class#Notes#0" />
|
||||
<element signature="class#CallNote#0;class#Notes#0" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://D:/Android_SDK/SDK/platforms/android-28/data/res/drawable-hdpi/ic_dialog_alert.png">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/res/menu/sub_folder.xml">
|
||||
<provider editor-type-id="text-editor" />
|
||||
<provider selected="true" editor-type-id="android-designer2" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/res/menu/call_record_folder.xml">
|
||||
<provider editor-type-id="text-editor" />
|
||||
<provider selected="true" editor-type-id="android-designer2" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/res/menu/note_list.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="150">
|
||||
<caret line="28" column="20" selection-start-line="28" selection-start-column="20" selection-end-line="28" selection-end-column="20" />
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="android-designer2" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/ui/NotesListActivity.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="328">
|
||||
<caret line="319" column="67" selection-start-line="319" selection-start-column="67" selection-end-line="319" selection-end-column="67" />
|
||||
<state relative-caret-position="244">
|
||||
<caret line="1021" lean-forward="true" selection-start-line="1021" selection-end-line="1021" />
|
||||
<folding>
|
||||
<element signature="e#10700#10767#0" expanded="true" />
|
||||
<element signature="e#11187#11211#0" expanded="true" />
|
||||
<element signature="e#12282#12318#0" expanded="true" />
|
||||
<element signature="e#23149#23181#0" expanded="true" />
|
||||
<element signature="e#24580#24623#0" expanded="true" />
|
||||
<element signature="e#24827#24870#0" expanded="true" />
|
||||
<element signature="e#25005#25176#0" expanded="true" />
|
||||
<element signature="e#25175#25176#0" expanded="true" />
|
||||
<element signature="e#25359#26888#0" expanded="true" />
|
||||
<element signature="e#26887#26888#0" expanded="true" />
|
||||
<element signature="e#29304#29828#0" expanded="true" />
|
||||
<element signature="e#29827#29828#0" expanded="true" />
|
||||
<element signature="e#32663#32692#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/src/main/res/values-zh-rCN/strings.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="149">
|
||||
<caret line="40" column="18" selection-start-line="40" selection-start-column="18" selection-end-line="40" selection-end-column="18" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
|
|
|
@ -317,7 +317,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
item.setTitle(R.string.menu_deselect_all);
|
||||
} else {
|
||||
item.setChecked(false);
|
||||
item.setTitle(R.string.menu_select_all);//设置标题,
|
||||
item.setTitle(R.string.menu_select_all);//设置标题,字符来自R文件
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -346,17 +346,20 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
boolean checked) {
|
||||
mNotesListAdapter.setCheckedItem(position, checked);
|
||||
updateMenu();
|
||||
}
|
||||
}//在选中项目更改后更新
|
||||
|
||||
//对菜单点击进行响应
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (mNotesListAdapter.getSelectedCount() == 0) {
|
||||
Toast.makeText(NotesListActivity.this, getString(R.string.menu_select_none),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
Toast.LENGTH_SHORT).show();//显示没有选中,操作无效
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (item.getItemId()) {
|
||||
//对项目进行操作
|
||||
case R.id.delete:
|
||||
//删除
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
|
||||
builder.setTitle(getString(R.string.alert_title_delete));
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert);
|
||||
|
@ -373,20 +376,28 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
builder.show();
|
||||
break;
|
||||
case R.id.move:
|
||||
//移动
|
||||
startQueryDestinationFolders();
|
||||
break;
|
||||
default:
|
||||
//返回false,操作失败
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 该类实现点击新建便签按钮,新建便签的实现方法
|
||||
* */
|
||||
private class NewNoteOnTouchListener implements OnTouchListener {
|
||||
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
//获取事件列表中的操作
|
||||
switch (event.getAction()) {
|
||||
//按下按钮的情况
|
||||
case MotionEvent.ACTION_DOWN: {
|
||||
//显示默认窗体
|
||||
Display display = getWindowManager().getDefaultDisplay();
|
||||
int screenHeight = display.getHeight();
|
||||
int newNoteViewHeight = mAddNewNote.getHeight();
|
||||
|
@ -463,14 +474,19 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
|
||||
@Override
|
||||
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
|
||||
//对token进行选择,执行不同操作
|
||||
switch (token) {
|
||||
//文件夹下列表查询
|
||||
case FOLDER_NOTE_LIST_QUERY_TOKEN:
|
||||
mNotesListAdapter.changeCursor(cursor);
|
||||
break;
|
||||
//文件列表查询
|
||||
case FOLDER_LIST_QUERY_TOKEN:
|
||||
//存在文件夹
|
||||
if (cursor != null && cursor.getCount() > 0) {
|
||||
showFolderListMenu(cursor);
|
||||
} else {
|
||||
//记入错误日志,无文件夹
|
||||
Log.e(TAG, "Query folder failed");
|
||||
}
|
||||
break;
|
||||
|
@ -480,8 +496,14 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 该方法实现了展示文件夹列表的功能
|
||||
* @ cursor 游标,获取文件夹信息
|
||||
* */
|
||||
private void showFolderListMenu(Cursor cursor) {
|
||||
//新建窗体
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
|
||||
//设置标题
|
||||
builder.setTitle(R.string.menu_title_select_folder);
|
||||
final FoldersListAdapter adapter = new FoldersListAdapter(this, cursor);
|
||||
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||
|
@ -498,12 +520,18 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
mModeCallBack.finishActionMode();
|
||||
}
|
||||
});
|
||||
//展示窗体
|
||||
builder.show();
|
||||
}
|
||||
|
||||
/*
|
||||
* 该方法实现了创建空的新便签功能
|
||||
* */
|
||||
private void createNewNote() {
|
||||
Intent intent = new Intent(this, NoteEditActivity.class);
|
||||
//设置便签状态,插入或者编辑
|
||||
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
|
||||
//插入便签信息
|
||||
intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mCurrentFolderId);
|
||||
this.startActivityForResult(intent, REQUEST_CODE_NEW_NODE);
|
||||
}
|
||||
|
@ -545,8 +573,13 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
}.execute();
|
||||
}
|
||||
|
||||
/*
|
||||
* 该方法实现了删除文件夹得功能
|
||||
* @ folderId 要删除文件夹得id
|
||||
* */
|
||||
private void deleteFolder(long folderId) {
|
||||
if (folderId == Notes.ID_ROOT_FOLDER) {
|
||||
//删除父文件夹时报错
|
||||
Log.e(TAG, "Wrong folder id, should not happen " + folderId);
|
||||
return;
|
||||
}
|
||||
|
@ -556,10 +589,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
HashSet<AppWidgetAttribute> widgets = DataUtils.getFolderNoteWidget(mContentResolver,
|
||||
folderId);
|
||||
if (!isSyncMode()) {
|
||||
// if not synced, delete folder directly
|
||||
// 如果没有同步,直接删除
|
||||
DataUtils.batchDeleteNotes(mContentResolver, ids);
|
||||
} else {
|
||||
// in sync mode, we'll move the deleted folder into the trash folder
|
||||
// 如果同步,丢入垃圾箱
|
||||
DataUtils.batchMoveToFolder(mContentResolver, ids, Notes.ID_TRASH_FOLER);
|
||||
}
|
||||
if (widgets != null) {
|
||||
|
@ -579,25 +612,35 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
this.startActivityForResult(intent, REQUEST_CODE_OPEN_NODE);
|
||||
}
|
||||
|
||||
/*
|
||||
* 该方法实现了打开文件夹的功能
|
||||
* */
|
||||
private void openFolder(NoteItemData data) {
|
||||
//获取当前文件夹id
|
||||
mCurrentFolderId = data.getId();
|
||||
startAsyncNotesListQuery();
|
||||
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
|
||||
//状态设为
|
||||
mState = ListEditState.CALL_RECORD_FOLDER;
|
||||
mAddNewNote.setVisibility(View.GONE);
|
||||
} else {
|
||||
mState = ListEditState.SUB_FOLDER;
|
||||
}
|
||||
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
|
||||
//设置文本内容为“通话便签”
|
||||
mTitleBar.setText(R.string.call_record_folder_name);
|
||||
} else {
|
||||
mTitleBar.setText(data.getSnippet());
|
||||
}
|
||||
//将内容展示出来
|
||||
mTitleBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
//界面视图下点击操作
|
||||
public void onClick(View v) {
|
||||
//对点击的id进行区分
|
||||
switch (v.getId()) {
|
||||
//如果按下“新建便签”按钮,新建便签
|
||||
case R.id.btn_new_note:
|
||||
createNewNote();
|
||||
break;
|
||||
|
@ -607,42 +650,59 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
}
|
||||
|
||||
private void showSoftInput() {
|
||||
//获取输入法服务
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
//如果输入法存在
|
||||
if (inputMethodManager != null) {
|
||||
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//隐藏输入键盘
|
||||
private void hideSoftInput(View view) {
|
||||
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* 该方法实现了新建或者修改文件夹的方法
|
||||
* @ create 判断是否为新建文件夹
|
||||
* false - 修改文件夹
|
||||
* true - 新建文件夹
|
||||
* */
|
||||
private void showCreateOrModifyFolderDialog(final boolean create) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
//声明视图,使用样式为dialog_edit_text
|
||||
View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
|
||||
final EditText etName = (EditText) view.findViewById(R.id.et_foler_name);
|
||||
//显示键盘
|
||||
showSoftInput();
|
||||
if (!create) {
|
||||
if (mFocusNoteDataItem != null) {
|
||||
etName.setText(mFocusNoteDataItem.getSnippet());
|
||||
//显示内容“修改文件夹名称”
|
||||
builder.setTitle(getString(R.string.menu_folder_change_name));
|
||||
} else {
|
||||
//错误信息写入日志
|
||||
Log.e(TAG, "The long click data item is null");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
etName.setText("");
|
||||
//显示内容,“新建文件夹”
|
||||
builder.setTitle(this.getString(R.string.menu_create_folder));
|
||||
}
|
||||
|
||||
//设置ok按钮
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
//设置“取消”按钮
|
||||
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
hideSoftInput(etName);
|
||||
}
|
||||
});
|
||||
|
||||
//展示窗体,显示界面
|
||||
final Dialog dialog = builder.setView(view).show();
|
||||
final Button positive = (Button)dialog.findViewById(android.R.id.button1);
|
||||
positive.setOnClickListener(new OnClickListener() {
|
||||
|
@ -680,7 +740,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
positive.setEnabled(false);
|
||||
}
|
||||
/**
|
||||
* When the name edit text is null, disable the positive button
|
||||
* 当未输入名称时,ok键为灰色
|
||||
*/
|
||||
etName.addTextChangedListener(new TextWatcher() {
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
@ -689,9 +749,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
//如果输入内容为空
|
||||
if (TextUtils.isEmpty(etName.getText())) {
|
||||
//ok键无效,置为灰色
|
||||
positive.setEnabled(false);
|
||||
} else {
|
||||
//否则,ok键有效
|
||||
positive.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -705,13 +768,17 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
//对当前状态进行选择
|
||||
switch (mState) {
|
||||
//位于子文件夹下
|
||||
case SUB_FOLDER:
|
||||
mCurrentFolderId = Notes.ID_ROOT_FOLDER;
|
||||
//状态置为列表状态
|
||||
mState = ListEditState.NOTE_LIST;
|
||||
startAsyncNotesListQuery();
|
||||
mTitleBar.setVisibility(View.GONE);
|
||||
break;
|
||||
//位于通话记录文件夹下
|
||||
case CALL_RECORD_FOLDER:
|
||||
mCurrentFolderId = Notes.ID_ROOT_FOLDER;
|
||||
mState = ListEditState.NOTE_LIST;
|
||||
|
@ -719,6 +786,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
mTitleBar.setVisibility(View.GONE);
|
||||
startAsyncNotesListQuery();
|
||||
break;
|
||||
//位于便签列表下
|
||||
case NOTE_LIST:
|
||||
super.onBackPressed();
|
||||
break;
|
||||
|
@ -727,6 +795,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
}
|
||||
}
|
||||
|
||||
//更新widget的方法,根据appWidgetId设置widget形式
|
||||
private void updateWidget(int appWidgetId, int appWidgetType) {
|
||||
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
||||
if (appWidgetType == Notes.TYPE_WIDGET_2X) {
|
||||
|
@ -742,14 +811,17 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
appWidgetId
|
||||
});
|
||||
|
||||
//将intent的内容广播
|
||||
sendBroadcast(intent);
|
||||
setResult(RESULT_OK, intent);
|
||||
}
|
||||
|
||||
private final OnCreateContextMenuListener mFolderOnCreateContextMenuListener = new OnCreateContextMenuListener() {
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
//如果当前便签数据项不为空
|
||||
if (mFocusNoteDataItem != null) {
|
||||
menu.setHeaderTitle(mFocusNoteDataItem.getSnippet());
|
||||
//设置菜单内容
|
||||
menu.add(0, MENU_FOLDER_VIEW, 0, R.string.menu_folder_view);
|
||||
menu.add(0, MENU_FOLDER_DELETE, 0, R.string.menu_folder_delete);
|
||||
menu.add(0, MENU_FOLDER_CHANGE_NAME, 0, R.string.menu_folder_change_name);
|
||||
|
@ -759,26 +831,37 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
|
||||
@Override
|
||||
public void onContextMenuClosed(Menu menu) {
|
||||
//如果当前处于便签列表形式
|
||||
if (mNotesListView != null) {
|
||||
//显示菜单栏
|
||||
mNotesListView.setOnCreateContextMenuListener(null);
|
||||
}
|
||||
//调用父类的构造函数
|
||||
super.onContextMenuClosed(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
if (mFocusNoteDataItem == null) {
|
||||
//长按数据项为空,报错并记入日志
|
||||
Log.e(TAG, "The long click data item is null");
|
||||
return false;
|
||||
}
|
||||
//对item的id进行判断
|
||||
switch (item.getItemId()) {
|
||||
//如果是文件夹,打开文件夹
|
||||
case MENU_FOLDER_VIEW:
|
||||
openFolder(mFocusNoteDataItem);
|
||||
break;
|
||||
//如果是删除文件夹
|
||||
case MENU_FOLDER_DELETE:
|
||||
//声明警示窗口
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
//设置标题
|
||||
builder.setTitle(getString(R.string.alert_title_delete));
|
||||
//设置警告图标
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert);
|
||||
//设置内容,确认是否删除
|
||||
builder.setMessage(getString(R.string.alert_message_delete_folder));
|
||||
builder.setPositiveButton(android.R.string.ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
@ -786,16 +869,18 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
deleteFolder(mFocusNoteDataItem.getId());
|
||||
}
|
||||
});
|
||||
//取消则不执行任何操作
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
builder.show();
|
||||
break;
|
||||
//如果是修改文件夹名称
|
||||
case MENU_FOLDER_CHANGE_NAME:
|
||||
showCreateOrModifyFolderDialog(false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//操作成功,返回true
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -804,38 +889,56 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
menu.clear();
|
||||
if (mState == ListEditState.NOTE_LIST) {
|
||||
getMenuInflater().inflate(R.menu.note_list, menu);
|
||||
// set sync or sync_cancel
|
||||
// 设置是否同步
|
||||
menu.findItem(R.id.menu_sync).setTitle(
|
||||
GTaskSyncService.isSyncing() ? R.string.menu_sync_cancel : R.string.menu_sync);
|
||||
} else if (mState == ListEditState.SUB_FOLDER) {
|
||||
} else if (mState == ListEditState.SUB_FOLDER) {//如果位于子文件夹下
|
||||
//菜单采用子文件夹下的形式,只有添加便签选项
|
||||
getMenuInflater().inflate(R.menu.sub_folder, menu);
|
||||
} else if (mState == ListEditState.CALL_RECORD_FOLDER) {
|
||||
} else if (mState == ListEditState.CALL_RECORD_FOLDER) {//如果位于通话记录文件夹下
|
||||
//菜单仅仅提供搜索功能
|
||||
getMenuInflater().inflate(R.menu.call_record_folder, menu);
|
||||
} else {
|
||||
//状态不合法,记入日志
|
||||
Log.e(TAG, "Wrong state:" + mState);
|
||||
}
|
||||
//
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* 该方法实现了对菜单功能的实现
|
||||
* @ item 选中的菜单项
|
||||
* */
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
//对选中的菜单项进行判断
|
||||
switch (item.getItemId()) {
|
||||
//如果按下的是新建文件夹按钮
|
||||
case R.id.menu_new_folder: {
|
||||
//新建文件夹,true - 新建模式
|
||||
showCreateOrModifyFolderDialog(true);
|
||||
break;
|
||||
}
|
||||
//如果按下的是导出文本按钮
|
||||
case R.id.menu_export_text: {
|
||||
//导出文本
|
||||
exportNoteToText();
|
||||
break;
|
||||
}
|
||||
//如果按下的是同步按钮
|
||||
case R.id.menu_sync: {
|
||||
//判断当前是否为同步模式
|
||||
if (isSyncMode()) {
|
||||
//处于同步模式,且确认后直接同步
|
||||
if (TextUtils.equals(item.getTitle(), getString(R.string.menu_sync))) {
|
||||
GTaskSyncService.startSync(this);
|
||||
} else {
|
||||
//处于同步模式,取消同步
|
||||
GTaskSyncService.cancelSync(this);
|
||||
}
|
||||
} else {
|
||||
//不处于同步模式,
|
||||
startPreferenceActivity();
|
||||
}
|
||||
break;
|
||||
|
@ -905,11 +1008,13 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|||
}.execute();
|
||||
}
|
||||
|
||||
//判断是否位于同步模式的私有方法
|
||||
private boolean isSyncMode() {
|
||||
return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
|
||||
}
|
||||
|
||||
private void startPreferenceActivity() {
|
||||
//新建activity,如果有父activity,用父activity,否则新建
|
||||
Activity from = getParent() != null ? getParent() : this;
|
||||
Intent intent = new Intent(from, NotesPreferenceActivity.class);
|
||||
from.startActivityIfNeeded(intent, -1);
|
||||
|
|
Loading…
Reference in New Issue