/*
* 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();
/**
* Insert an introduction when user firstly use this application
*/
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)) {
StringBuilder sb = new StringBuilder();
InputStream in = null;
try {
in = getResources().openRawResource(R.raw.introduction);
if (in != null) {
InputStreamReader isr = new InputStreamReader(in);
BufferedReader br = new BufferedReader(isr);
char [] buf = new char[1024];
int len = 0;
while ((len = br.read(buf)) > 0) {
sb.append(buf, 0, len);
}
} else {
Log.e(TAG, "Read introduction file error");
return;
}
} catch (IOException e) {
e.printStackTrace();
return;
} finally {
if(in != null) {
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
WorkingNote note = WorkingNote.createEmptyNote(this, Notes.ID_ROOT_FOLDER,
AppWidgetManager.INVALID_APPWIDGET_ID, Notes.TYPE_WIDGET_INVALIDE,
ResourceParser.RED);
note.setWorkingText(sb.toString());
if (note.saveNote()) {
sp.edit().putBoolean(PREFERENCE_ADD_INTRODUCTION, true).commit();
} else {
Log.e(TAG, "Save introduction note error");
return;
}
}
}
@Override
protected void onStart() {
super.onStart();
startAsyncNotesListQuery();
}
private void initResources() {
mContentResolver = this.getContentResolver();
mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver());
mCurrentFolderId = Notes.ID_ROOT_FOLDER;
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(R.id.btn_new_note);
mAdd
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Android 小米系统之便签源码.zip项目安卓应用源码下载Android 小米系统之便签源码.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
资源推荐
资源详情
资源评论
收起资源包目录
Android 小米系统之便签源码.zip项目安卓应用源码下载 (148个子文件)
.gitignore 122B
introduction 472B
introduction 26B
NotesListActivity.java 38KB
NoteEditActivity.java 34KB
GTaskManager.java 29KB
GTaskClient.java 21KB
SqlNote.java 18KB
DateTimePicker.java 16KB
NotesPreferenceActivity.java 15KB
NotesDatabaseHelper.java 14KB
BackupUtils.java 13KB
NotesProvider.java 12KB
Task.java 12KB
WorkingNote.java 11KB
TaskList.java 11KB
DataUtils.java 11KB
Note.java 9KB
Notes.java 9KB
NoteEditText.java 7KB
SqlData.java 7KB
NoteItemData.java 7KB
ResourceParser.java 6KB
NoteWidgetProvider.java 6KB
NotesListAdapter.java 6KB
AlarmAlertActivity.java 5KB
NotesListItem.java 5KB
GTaskASyncTask.java 4KB
GTaskSyncService.java 4KB
GTaskStringUtils.java 4KB
DateTimePickerDialog.java 3KB
FoldersListAdapter.java 3KB
Contact.java 3KB
MetaData.java 2KB
Node.java 2KB
AlarmInitReceiver.java 2KB
DropdownMenu.java 2KB
NoteWidgetProvider_2x.java 1KB
NoteWidgetProvider_4x.java 1KB
ActionFailureException.java 1KB
NetworkFailureException.java 1KB
AlarmReceiver.java 1KB
NOTICE 10KB
list_background.png 554KB
1-1209221JF90-L.png 292KB
new_note_pressed.png 88KB
new_note_normal.png 87KB
note_edit_color_selector_panel.png 7KB
icon_app.png 7KB
edit_title_yellow.9.png 6KB
title_bar_bg.9.png 6KB
edit_title_green.9.png 5KB
list_folder.9.png 5KB
edit_title_blue.9.png 5KB
edit_title_red.9.png 5KB
selected.png 5KB
list_green_single.9.png 5KB
list_yellow_single.9.png 5KB
list_blue_single.9.png 5KB
list_red_single.9.png 4KB
list_white_single.9.png 4KB
list_green_down.9.png 4KB
list_yellow_down.9.png 4KB
list_blue_down.9.png 4KB
list_red_down.9.png 4KB
list_white_down.9.png 4KB
widget_4x_red.png 4KB
widget_4x_yellow.png 4KB
widget_4x_green.png 4KB
widget_4x_blue.png 4KB
widget_4x_white.png 4KB
font_size_selector_bg.9.png 4KB
clock.png 4KB
edit_title_white.9.png 4KB
title_alert.png 4KB
edit_yellow.9.png 4KB
bg_btn_set_color.png 4KB
edit_green.9.png 3KB
call_record.png 3KB
edit_blue.9.png 3KB
delete.png 3KB
edit_red.9.png 3KB
edit_white.9.png 3KB
menu_delete.png 3KB
list_green_up.9.png 3KB
list_yellow_up.9.png 3KB
list_blue_up.9.png 3KB
menu_move.png 3KB
list_red_up.9.png 3KB
list_white_up.9.png 3KB
font_super.png 3KB
list_green_middle.9.png 3KB
font_large.png 3KB
list_yellow_middle.9.png 3KB
notification.png 3KB
list_blue_middle.9.png 3KB
font_small.png 3KB
font_normal.png 3KB
list_red_middle.9.png 3KB
list_white_middle.9.png 3KB
共 148 条
- 1
- 2
资源评论
yxkfw
- 粉丝: 82
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功