This commit is contained in:
ziji Wu 2019-10-10 19:59:41 +08:00
parent f97578591f
commit a0ce16049b
2 changed files with 59 additions and 31 deletions

View File

@ -6,7 +6,7 @@
</shared> </shared>
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="c8515555-ebbc-49d5-889b-0c59bd6c3b6d" name="默认更改列表" comment=""> <list default="true" id="c8515555-ebbc-49d5-889b-0c59bd6c3b6d" name="默认更改列表" comment="comment">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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" /> <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> </list>
@ -42,11 +42,11 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/ui/NotesListActivity.java"> <entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/ui/NotesListActivity.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="244"> <state relative-caret-position="335">
<caret line="1021" lean-forward="true" selection-start-line="1021" selection-end-line="1021" /> <caret line="1115" column="9" lean-forward="true" selection-start-line="1115" selection-start-column="9" selection-end-line="1115" selection-end-column="9" />
<folding> <folding>
<element signature="e#10700#10767#0" expanded="true" /> <element signature="e#10700#10767#0" expanded="true" />
<element signature="e#11187#11211#0" expanded="true" /> <element signature="e#11187#11211#0" expanded="true" />
@ -66,7 +66,7 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/src/main/res/values-zh-rCN/strings.xml"> <entry file="file://$PROJECT_DIR$/app/src/main/res/values-zh-rCN/strings.xml">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="149"> <state relative-caret-position="149">
@ -97,7 +97,7 @@
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Notes.java"> <entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Notes.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="158"> <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" /> <caret line="23" column="28" selection-start-line="23" selection-start-column="28" selection-end-line="23" selection-end-column="28" />
<folding> <folding>
<element signature="e#0#9163#0" expanded="true" /> <element signature="e#0#9163#0" expanded="true" />
<element signature="class#TextNote#0;class#Notes#0" /> <element signature="class#TextNote#0;class#Notes#0" />
@ -816,7 +816,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1570673666384</updated> <updated>1570673666384</updated>
</task> </task>
<option name="localTasksCounter" value="25" /> <task id="LOCAL-00025" summary="comment">
<created>1570707769289</created>
<option name="number" value="00025" />
<option name="presentableId" value="LOCAL-00025" />
<option name="project" value="LOCAL" />
<updated>1570707769289</updated>
</task>
<option name="localTasksCounter" value="26" />
<servers /> <servers />
</component> </component>
<component name="TodoView"> <component name="TodoView">
@ -894,12 +901,12 @@
<MESSAGE value="correct some error using sonarlint" /> <MESSAGE value="correct some error using sonarlint" />
<MESSAGE value="none" /> <MESSAGE value="none" />
<MESSAGE value="ziji wu comment" /> <MESSAGE value="ziji wu comment" />
<MESSAGE value="comment" />
<MESSAGE value="introduction" /> <MESSAGE value="introduction" />
<MESSAGE value="noteslistadapter" /> <MESSAGE value="noteslistadapter" />
<MESSAGE value="noteslistadapter &amp;&amp; noteslistactivity" /> <MESSAGE value="noteslistadapter &amp;&amp; noteslistactivity" />
<MESSAGE value="noteslistactivity" /> <MESSAGE value="noteslistactivity" />
<option name="LAST_COMMIT_MESSAGE" value="noteslistactivity" /> <MESSAGE value="comment" />
<option name="LAST_COMMIT_MESSAGE" value="comment" />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/res/drawable-hdpi/menu_delete.png"> <entry file="file://$PROJECT_DIR$/res/drawable-hdpi/menu_delete.png">
@ -1202,18 +1209,6 @@
<provider editor-type-id="text-editor" /> <provider editor-type-id="text-editor" />
<provider selected="true" editor-type-id="android-designer2" /> <provider selected="true" editor-type-id="android-designer2" />
</entry> </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="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"> <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" /> <provider selected="true" editor-type-id="images" />
</entry> </entry>
@ -1233,10 +1228,29 @@
</provider> </provider>
<provider editor-type-id="android-designer2" /> <provider editor-type-id="android-designer2" />
</entry> </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>
<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="158">
<caret line="23" column="28" selection-start-line="23" selection-start-column="28" selection-end-line="23" selection-end-column="28" />
<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/ui/NotesListActivity.java"> <entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/ui/NotesListActivity.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="244"> <state relative-caret-position="335">
<caret line="1021" lean-forward="true" selection-start-line="1021" selection-end-line="1021" /> <caret line="1115" column="9" lean-forward="true" selection-start-line="1115" selection-start-column="9" selection-end-line="1115" selection-end-column="9" />
<folding> <folding>
<element signature="e#10700#10767#0" expanded="true" /> <element signature="e#10700#10767#0" expanded="true" />
<element signature="e#11187#11211#0" expanded="true" /> <element signature="e#11187#11211#0" expanded="true" />
@ -1255,13 +1269,6 @@
</state> </state>
</provider> </provider>
</entry> </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>
<component name="masterDetails"> <component name="masterDetails">
<states> <states>

View File

@ -1026,6 +1026,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
if (view instanceof NotesListItem) { if (view instanceof NotesListItem) {
NoteItemData item = ((NotesListItem) view).getItemData(); NoteItemData item = ((NotesListItem) view).getItemData();
if (mNotesListAdapter.isInChoiceMode()) { if (mNotesListAdapter.isInChoiceMode()) {
//如果为便签类型
if (item.getType() == Notes.TYPE_NOTE) { if (item.getType() == Notes.TYPE_NOTE) {
position = position - mNotesListView.getHeaderViewsCount(); position = position - mNotesListView.getHeaderViewsCount();
mModeCallBack.onItemCheckedStateChanged(null, position, id, mModeCallBack.onItemCheckedStateChanged(null, position, id,
@ -1034,18 +1035,26 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
return; return;
} }
//对状态进行选择
switch (mState) { switch (mState) {
//如果为列表状态
case NOTE_LIST: case NOTE_LIST:
//判断是否为文件夹
if (item.getType() == Notes.TYPE_FOLDER if (item.getType() == Notes.TYPE_FOLDER
|| item.getType() == Notes.TYPE_SYSTEM) { || item.getType() == Notes.TYPE_SYSTEM) {
//打开文件夹
openFolder(item); openFolder(item);
} else if (item.getType() == Notes.TYPE_NOTE) { } else if (item.getType() == Notes.TYPE_NOTE) {
//如果是便签打开便签
openNode(item); openNode(item);
} else { } else {
//异常处理将错误类型记入日志
Log.e(TAG, "Wrong note type in NOTE_LIST"); Log.e(TAG, "Wrong note type in NOTE_LIST");
} }
break; break;
//如果为子文件夹状态不执行操作
case SUB_FOLDER: case SUB_FOLDER:
//如果为通话记录类型
case CALL_RECORD_FOLDER: case CALL_RECORD_FOLDER:
if (item.getType() == Notes.TYPE_NOTE) { if (item.getType() == Notes.TYPE_NOTE) {
openNode(item); openNode(item);
@ -1062,10 +1071,13 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
} }
private void startQueryDestinationFolders() { private void startQueryDestinationFolders() {
//定义用于在数据库中查询的语句对typeparent_idID进行判断选择
String selection = NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>? AND " + NoteColumns.ID + "<>?"; String selection = NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>? AND " + NoteColumns.ID + "<>?";
selection = (mState == ListEditState.NOTE_LIST) ? selection: selection = (mState == ListEditState.NOTE_LIST) ? selection:
"(" + selection + ") OR (" + NoteColumns.ID + "=" + Notes.ID_ROOT_FOLDER + ")"; "(" + selection + ") OR (" + NoteColumns.ID + "=" + Notes.ID_ROOT_FOLDER + ")";
//后台查询句柄
//结果以最近修改时间排序
mBackgroundQueryHandler.startQuery(FOLDER_LIST_QUERY_TOKEN, mBackgroundQueryHandler.startQuery(FOLDER_LIST_QUERY_TOKEN,
null, null,
Notes.CONTENT_NOTE_URI, Notes.CONTENT_NOTE_URI,
@ -1079,17 +1091,26 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
NoteColumns.MODIFIED_DATE + " DESC"); NoteColumns.MODIFIED_DATE + " DESC");
} }
/*
* 该方法实现了长按的操作
* @ view 窗口类
* @ id
* */
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
//判断窗体是否为列表状态
if (view instanceof NotesListItem) { if (view instanceof NotesListItem) {
//设置焦点便签
mFocusNoteDataItem = ((NotesListItem) view).getItemData(); mFocusNoteDataItem = ((NotesListItem) view).getItemData();
if (mFocusNoteDataItem.getType() == Notes.TYPE_NOTE && !mNotesListAdapter.isInChoiceMode()) { if (mFocusNoteDataItem.getType() == Notes.TYPE_NOTE && !mNotesListAdapter.isInChoiceMode()) {
if (mNotesListView.startActionMode(mModeCallBack) != null) { if (mNotesListView.startActionMode(mModeCallBack) != null) {
mModeCallBack.onItemCheckedStateChanged(null, position, id, true); mModeCallBack.onItemCheckedStateChanged(null, position, id, true);
mNotesListView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); mNotesListView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
} else { } else {
//便签活动状态设置失败记入日志
Log.e(TAG, "startActionMode fails"); Log.e(TAG, "startActionMode fails");
} }
} else if (mFocusNoteDataItem.getType() == Notes.TYPE_FOLDER) { } else if (mFocusNoteDataItem.getType() == Notes.TYPE_FOLDER) {//如果为文件夹状态
//设置窗体内容为文件夹内容
mNotesListView.setOnCreateContextMenuListener(mFolderOnCreateContextMenuListener); mNotesListView.setOnCreateContextMenuListener(mFolderOnCreateContextMenuListener);
} }
} }