Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
06818622fb | 1 year ago |
|
|
e2e7bb397b | 1 year ago |
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 - 2011, The MiCode Open Source Community (www.micode.net)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package net.micode.notes.tool;
|
||||
|
||||
// GTaskStringUtils类用于定义与GTask相关的JSON字符串常量
|
||||
public class GTaskStringUtils {
|
||||
// JSON中表示操作ID的键
|
||||
public final static String GTASK_JSON_ACTION_ID = "action_id";
|
||||
// JSON中表示操作列表的键
|
||||
public final static String GTASK_JSON_ACTION_LIST = "action_list";
|
||||
// JSON中表示操作类型的键
|
||||
public final static String GTASK_JSON_ACTION_TYPE = "action_type";
|
||||
// JSON中创建操作的类型值
|
||||
public final static String GTASK_JSON_ACTION_TYPE_CREATE = "create";
|
||||
// JSON中获取所有操作的类型值
|
||||
public final static String GTASK_JSON_ACTION_TYPE_GETALL = "get_all";
|
||||
// JSON中移动操作的类型值
|
||||
public final static String GTASK_JSON_ACTION_TYPE_MOVE = "move";
|
||||
// JSON中更新操作的类型值
|
||||
public final static String GTASK_JSON_ACTION_TYPE_UPDATE = "update";
|
||||
// JSON中表示创建者ID的键
|
||||
public final static String GTASK_JSON_CREATOR_ID = "creator_id";
|
||||
// JSON中表示子实体的键
|
||||
public final static String GTASK_JSON_CHILD_ENTITY = "child_entity";
|
||||
// JSON中表示客户端版本的键
|
||||
public final static String GTASK_JSON_CLIENT_VERSION = "client_version";
|
||||
// JSON中表示完成状态的键
|
||||
public final static String GTASK_JSON_COMPLETED = "completed";
|
||||
// JSON中表示当前列表ID的键
|
||||
public final static String GTASK_JSON_CURRENT_LIST_ID = "current_list_id";
|
||||
// JSON中表示默认列表ID的键
|
||||
public final static String GTASK_JSON_DEFAULT_LIST_ID = "default_list_id";
|
||||
// JSON中表示已删除状态的键
|
||||
public final static String GTASK_JSON_DELETED = "deleted";
|
||||
// JSON中表示目标列表的键
|
||||
public final static String GTASK_JSON_DEST_LIST = "dest_list";
|
||||
// JSON中表示目标父级的键
|
||||
public final static String GTASK_JSON_DEST_PARENT = "dest_parent";
|
||||
// JSON中表示目标父级类型的键
|
||||
public final static String GTASK_JSON_DEST_PARENT_TYPE = "dest_parent_type";
|
||||
// JSON中表示实体差异的键
|
||||
public final static String GTASK_JSON_ENTITY_DELTA = "entity_delta";
|
||||
// JSON中表示实体类型的键
|
||||
public final static String GTASK_JSON_ENTITY_TYPE = "entity_type";
|
||||
// JSON中表示获取已删除项的键
|
||||
public final static String GTASK_JSON_GET_DELETED = "get_deleted";
|
||||
// JSON中表示ID的键
|
||||
public final static String GTASK_JSON_ID = "id";
|
||||
// JSON中表示索引的键
|
||||
public final static String GTASK_JSON_INDEX = "index";
|
||||
// JSON中表示最后修改时间的键
|
||||
public final static String GTASK_JSON_LAST_MODIFIED = "last_modified";
|
||||
// JSON中表示最新同步点的键
|
||||
public final static String GTASK_JSON_LATEST_SYNC_POINT = "latest_sync_point";
|
||||
// JSON中表示列表ID的键
|
||||
public final static String GTASK_JSON_LIST_ID = "list_id";
|
||||
// JSON中表示列表的键
|
||||
public final static String GTASK_JSON_LISTS = "lists";
|
||||
// JSON中表示名称的键
|
||||
public final static String GTASK_JSON_NAME = "name";
|
||||
// JSON中表示新ID的键
|
||||
public final static String GTASK_JSON_NEW_ID = "new_id";
|
||||
// JSON中表示笔记的键
|
||||
public final static String GTASK_JSON_NOTES = "notes";
|
||||
// JSON中表示父级ID的键
|
||||
public final static String GTASK_JSON_PARENT_ID = "parent_id";
|
||||
// JSON中表示前一个兄弟ID的键
|
||||
public final static String GTASK_JSON_PRIOR_SIBLING_ID = "prior_sibling_id";
|
||||
// JSON中表示结果的键
|
||||
public final static String GTASK_JSON_RESULTS = "results";
|
||||
// JSON中表示源列表的键
|
||||
public final static String GTASK_JSON_SOURCE_LIST = "source_list";
|
||||
// JSON中表示任务的键
|
||||
public final static String GTASK_JSON_TASKS = "tasks";
|
||||
// JSON中表示类型的键
|
||||
public final static String GTASK_JSON_TYPE = "type";
|
||||
// JSON中表示组类型的类型值
|
||||
public final static String GTASK_JSON_TYPE_GROUP = "GROUP";
|
||||
// JSON中表示任务类型的类型值
|
||||
public final static String GTASK_JSON_TYPE_TASK = "TASK";
|
||||
// JSON中表示用户的键
|
||||
public final static String GTASK_JSON_USER = "user";
|
||||
// MIUI文件夹的前缀
|
||||
public final static String MIUI_FOLDER_PREFFIX = "[MIUI_Notes]";
|
||||
// 默认文件夹名称
|
||||
public final static String FOLDER_DEFAULT = "Default";
|
||||
// 通话笔记文件夹名称
|
||||
public final static String FOLDER_CALL_NOTE = "Call_Note";
|
||||
// 元数据文件夹名称
|
||||
public final static String FOLDER_META = "METADATA";
|
||||
// 元数据中GTask ID的头部名称
|
||||
public final static String META_HEAD_GTASK_ID = "meta_gid";
|
||||
// 元数据中笔记的头部名称
|
||||
public final static String META_HEAD_NOTE = "meta_note";
|
||||
// 元数据中数据的头部名称
|
||||
public final static String META_HEAD_DATA = "meta_data";
|
||||
// 元数据笔记的名称(不允许更新和删除)
|
||||
public final static String META_NOTE_NAME = "[META INFO] DON'T UPDATE AND DELETE";
|
||||
}
|
||||
@ -0,0 +1,272 @@
|
||||
【java】
|
||||
/*
|
||||
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package net.micode.notes.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.AsyncQueryHandler;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.ActionMode;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.Display;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MenuItem.OnMenuItemClickListener;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnCreateContextMenuListener;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.AdapterView.OnItemLongClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import net.micode.notes.R;
|
||||
import net.micode.notes.data.Notes;
|
||||
import net.micode.notes.data.Notes.NoteColumns;
|
||||
import net.micode.notes.gtask.remote.GTaskSyncService;
|
||||
import net.micode.notes.model.WorkingNote;
|
||||
import net.micode.notes.tool.BackupUtils;
|
||||
import net.micode.notes.tool.DataUtils;
|
||||
import net.micode.notes.tool.ResourceParser;
|
||||
import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute;
|
||||
import net.micode.notes.widget.NoteWidgetProvider_2x;
|
||||
import net.micode.notes.widget.NoteWidgetProvider_4x;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener {
|
||||
// 常量定义
|
||||
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
|
||||
private static final int FOLDER_LIST_QUERY_TOKEN = 1;
|
||||
private static final int MENU_FOLDER_DELETE = 0;
|
||||
private static final int MENU_FOLDER_VIEW = 1;
|
||||
private static final int MENU_FOLDER_CHANGE_NAME = 2;
|
||||
private static final String PREFERENCE_ADD_INTRODUCTION = "net.micode.notes.introduction";
|
||||
|
||||
// 枚举类定义列表编辑状态
|
||||
private enum ListEditState {
|
||||
NOTE_LIST, SUB_FOLDER, CALL_RECORD_FOLDER
|
||||
};
|
||||
|
||||
// 成员变量定义
|
||||
private ListEditState mState;
|
||||
private BackgroundQueryHandler mBackgroundQueryHandler;
|
||||
private NotesListAdapter mNotesListAdapter;
|
||||
private ListView mNotesListView;
|
||||
private Button mAddNewNote;
|
||||
private boolean mDispatch;
|
||||
private int mOriginY;
|
||||
private int mDispatchY;
|
||||
private TextView mTitleBar;
|
||||
private long mCurrentFolderId;
|
||||
private ContentResolver mContentResolver;
|
||||
private ModeCallback mModeCallBack;
|
||||
private static final String TAG = "NotesListActivity";
|
||||
public static final int NOTES_LISTVIEW_SCROLL_RATE = 30;
|
||||
private NoteItemData mFocusNoteDataItem;
|
||||
private static final String NORMAL_SELECTION = NoteColumns.PARENT_ID + "=?";
|
||||
private static final String ROOT_FOLDER_SELECTION = "(" + NoteColumns.TYPE + "<>"
|
||||
+ Notes.TYPE_SYSTEM + " AND " + NoteColumns.PARENT_ID + "=?)" + " OR ("
|
||||
+ NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER + " AND "
|
||||
+ NoteColumns.NOTES_COUNT + ">0)";
|
||||
private final static int REQUEST_CODE_OPEN_NODE = 102;
|
||||
private final static int REQUEST_CODE_NEW_NODE = 103;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.note_list);
|
||||
initResources();
|
||||
// 插入应用介绍
|
||||
setAppInfoFromRawRes();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == RESULT_OK && (requestCode == REQUEST_CODE_OPEN_NODE || requestCode == REQUEST_CODE_NEW_NODE)) {
|
||||
mNotesListAdapter.changeCursor(null);
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAppInfoFromRawRes() {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if (!sp.getBoolean(PREFERENCE_ADD_INTRODUCTION, false)) {
|
||||
// 从资源文件中读取介绍信息并保存为笔记
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
startAsyncNotesListQuery();
|
||||
}
|
||||
|
||||
private void initResources() {
|
||||
// 初始化资源
|
||||
}
|
||||
|
||||
// 回调接口实现
|
||||
private class ModeCallback implements ListView.MultiChoiceModeListener, OnMenuItemClickListener {
|
||||
// 实现ListView的多选模式监听器接口
|
||||
}
|
||||
|
||||
private class NewNoteOnTouchListener implements OnTouchListener {
|
||||
// 实现新笔记按钮的触摸监听器接口
|
||||
}
|
||||
|
||||
private void startAsyncNotesListQuery() {
|
||||
// 异步查询笔记列表
|
||||
}
|
||||
|
||||
private final class BackgroundQueryHandler extends AsyncQueryHandler {
|
||||
// 异步查询处理器
|
||||
}
|
||||
|
||||
private void showFolderListMenu(Cursor cursor) {
|
||||
// 显示文件夹列表菜单
|
||||
}
|
||||
|
||||
private void createNewNote() {
|
||||
// 创建新笔记
|
||||
}
|
||||
|
||||
private void batchDelete() {
|
||||
// 批量删除笔记
|
||||
}
|
||||
|
||||
private void deleteFolder(long folderId) {
|
||||
// 删除文件夹
|
||||
}
|
||||
|
||||
private void openNode(NoteItemData data) {
|
||||
// 打开笔记节点
|
||||
}
|
||||
|
||||
private void openFolder(NoteItemData data) {
|
||||
// 打开文件夹
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// 按钮点击事件处理
|
||||
}
|
||||
|
||||
private void showSoftInput() {
|
||||
// 显示软键盘
|
||||
}
|
||||
|
||||
private void hideSoftInput(View view) {
|
||||
// 隐藏软键盘
|
||||
}
|
||||
|
||||
private void showCreateOrModifyFolderDialog(final boolean create) {
|
||||
// 显示创建或修改文件夹对话框
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// 后退按钮事件处理
|
||||
}
|
||||
|
||||
private void updateWidget(int appWidgetId, int appWidgetType) {
|
||||
// 更新小部件
|
||||
}
|
||||
|
||||
private final OnCreateContextMenuListener mFolderOnCreateContextMenuListener = new OnCreateContextMenuListener() {
|
||||
// 实现创建上下文菜单监听器接口
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onContextMenuClosed(Menu menu) {
|
||||
// 上下文菜单关闭事件处理
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
// 上下文菜单项点击事件处理
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
// 准备选项菜单
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// 选项菜单项点击事件处理
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSearchRequested() {
|
||||
// 搜索请求事件处理
|
||||
}
|
||||
|
||||
private void exportNoteToText() {
|
||||
// 导出笔记到文本文件
|
||||
}
|
||||
|
||||
private boolean isSyncMode() {
|
||||
// 判断是否处于同步模式
|
||||
}
|
||||
|
||||
private void startPreferenceActivity() {
|
||||
// 启动设置活动
|
||||
}
|
||||
|
||||
private class OnListItemClickListener implements OnItemClickListener {
|
||||
// 实现列表项点击监听器接口
|
||||
}
|
||||
|
||||
private void startQueryDestinationFolders() {
|
||||
// 开始查询目标文件夹
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// 列表项长按事件处理
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue