pull/13/head
prmw2qx5j 2 years ago
commit 5a9b11dbf1

@ -13,7 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Description便sqldatanotedata
* SqlDataSqlNote
*/
package net.micode.notes.gtask.data;
import android.appwidget.AppWidgetManager;
@ -37,12 +40,21 @@ import org.json.JSONObject;
import java.util.ArrayList;
/*
*
*
*/
public class SqlNote {
private static final String TAG = SqlNote.class.getSimpleName();
/*
* TAG
* getSimpleName ()
*/
private static final int INVALID_ID = -99999;
// 集合了interface NoteColumns中所有SF常量17个
public static final String[] PROJECTION_NOTE = new String[] {
NoteColumns.ID, NoteColumns.ALERTED_DATE, NoteColumns.BG_COLOR_ID,
NoteColumns.CREATED_DATE, NoteColumns.HAS_ATTACHMENT, NoteColumns.MODIFIED_DATE,
@ -51,7 +63,7 @@ public class SqlNote {
NoteColumns.LOCAL_MODIFIED, NoteColumns.ORIGIN_PARENT_ID, NoteColumns.GTASK_ID,
NoteColumns.VERSION
};
//以下设置17个列的编号
public static final int ID_COLUMN = 0;
public static final int ALERTED_DATE_COLUMN = 1;
@ -85,7 +97,7 @@ public class SqlNote {
public static final int GTASK_ID_COLUMN = 15;
public static final int VERSION_COLUMN = 16;
//以下定义了17个内部的变量其中12个可以由content中获得5个需要初始化为0或者new
private Context mContext;
private ContentResolver mContentResolver;
@ -121,7 +133,12 @@ public class SqlNote {
private ContentValues mDiffNoteValues;
private ArrayList<SqlData> mDataList;
/*
*
* mIsCreate
*/
//构造函数只有context对所有的变量进行初始化
public SqlNote(Context context) {
mContext = context;
mContentResolver = context.getContentResolver();
@ -129,9 +146,9 @@ public class SqlNote {
mId = INVALID_ID;
mAlertDate = 0;
mBgColorId = ResourceParser.getDefaultBgId(context);
mCreatedDate = System.currentTimeMillis();
mCreatedDate = System.currentTimeMillis();//调用系统函数获得创建时间
mHasAttachment = 0;
mModifiedDate = System.currentTimeMillis();
mModifiedDate = System.currentTimeMillis();//最后一次修改时间初始化为创建时间
mParentId = 0;
mSnippet = "";
mType = Notes.TYPE_NOTE;
@ -142,6 +159,12 @@ public class SqlNote {
mDiffNoteValues = new ContentValues();
mDataList = new ArrayList<SqlData>();
}
/*
*
* mIsCreate
*/
//构造函数有context和一个数据库的cursor多数变量通过cursor指向的一条记录直接进行初始化
public SqlNote(Context context, Cursor c) {
mContext = context;
@ -153,7 +176,10 @@ public class SqlNote {
loadDataContent();
mDiffNoteValues = new ContentValues();
}
/*
*
* mIsCreate
*/
public SqlNote(Context context, long id) {
mContext = context;
mContentResolver = context.getContentResolver();
@ -173,9 +199,10 @@ public class SqlNote {
new String[] {
String.valueOf(id)
}, null);
if (c != null) {
if (c != null) {//通过id获得对应的ContentResolver中的cursor
c.moveToNext();
loadFromCursor(c);
loadFromCursor(c);//然后加载数据进行初始化,这样函数
//SqlNote(Context context, long id)与SqlNote(Context context, long id)的实现方式基本相同
} else {
Log.w(TAG, "loadFromCursor: cursor = null");
}
@ -184,8 +211,11 @@ public class SqlNote {
c.close();
}
}
/*
*
*/
private void loadFromCursor(Cursor c) {
//直接从一条记录中的获得以下变量的初始值
mId = c.getLong(ID_COLUMN);
mAlertDate = c.getLong(ALERTED_DATE_COLUMN);
mBgColorId = c.getInt(BG_COLOR_ID_COLUMN);
@ -199,7 +229,9 @@ public class SqlNote {
mWidgetType = c.getInt(WIDGET_TYPE_COLUMN);
mVersion = c.getLong(VERSION_COLUMN);
}
/*
* content
* */
private void loadDataContent() {
Cursor c = null;
mDataList.clear();
@ -225,7 +257,8 @@ public class SqlNote {
c.close();
}
}
/*
* content*/
public boolean setContent(JSONObject js) {
try {
JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE);
@ -359,6 +392,8 @@ public class SqlNote {
return true;
}
/*
* contentnote*/
public JSONObject getContent() {
try {
JSONObject js = new JSONObject();
@ -406,40 +441,49 @@ public class SqlNote {
}
return null;
}
/*
* idid*/
public void setParentId(long id) {
mParentId = id;
mDiffNoteValues.put(NoteColumns.PARENT_ID, id);
}
/*
* idGtaskid*/
public void setGtaskId(String gid) {
mDiffNoteValues.put(NoteColumns.GTASK_ID, gid);
}
/*
* idid*/
public void setSyncId(long syncId) {
mDiffNoteValues.put(NoteColumns.SYNC_ID, syncId);
}
/*
* */
public void resetLocalModified() {
mDiffNoteValues.put(NoteColumns.LOCAL_MODIFIED, 0);
}
/*
* id*/
public long getId() {
return mId;
}
/*
* idid*/
public long getParentId() {
return mParentId;
}
/*
* 便*/
public String getSnippet() {
return mSnippet;
}
/*
* 便*/
public boolean isNoteType() {
return mType == Notes.TYPE_NOTE;
}
/*
* commit*/
public void commit(boolean validateVersion) {
if (mIsCreate) {
if (mId == INVALID_ID && mDiffNoteValues.containsKey(NoteColumns.ID)) {

@ -35,22 +35,22 @@ import org.json.JSONObject;
public class Task extends Node {
private static final String TAG = Task.class.getSimpleName();
private boolean mCompleted;
private boolean mCompleted;//是否完成
private String mNotes;
private JSONObject mMetaInfo;
private JSONObject mMetaInfo;//将在实例中存储数据的类型
private Task mPriorSibling;
private TaskList mParent;
private TaskList mParent;//所在的任务列表的指针
public Task() {
super();
mCompleted = false;
mNotes = null;
mPriorSibling = null;
mParent = null;
mPriorSibling = null;//TaskList中当前Task前面的Task的指针
mParent = null;//当前Task所在的TaskList
mMetaInfo = null;
}

@ -31,11 +31,11 @@ import java.util.ArrayList;
public class TaskList extends Node {
private static final String TAG = TaskList.class.getSimpleName();
private static final String TAG = TaskList.class.getSimpleName();//tag标记
private int mIndex;
private int mIndex;//当前TaskList的指针
private ArrayList<Task> mChildren;
private ArrayList<Task> mChildren;//类中主要的保存数据的单元用来实现一个以Task为元素的ArrayList
public TaskList() {
super();
@ -43,6 +43,7 @@ public class TaskList extends Node {
mIndex = 1;
}
//生成并返回一个包含了一定数据的JSONObject实体
public JSONObject getCreateAction(int actionId) {
JSONObject js = new JSONObject();
@ -74,6 +75,8 @@ public class TaskList extends Node {
return js;
}
//生成并返回一个包含了一定数据的JSONObject实体
public JSONObject getUpdateAction(int actionId) {
JSONObject js = new JSONObject();
@ -216,6 +219,8 @@ public class TaskList extends Node {
return SYNC_ACTION_ERROR;
}
//功能获得TaskList的大小即mChildren的大小
public int getChildTaskCount() {
return mChildren.size();
}
@ -233,7 +238,7 @@ public class TaskList extends Node {
}
return ret;
}
//功能:在当前任务表的指定位置添加新的任务
public boolean addChildTask(Task task, int index) {
if (index < 0 || index > mChildren.size()) {
Log.e(TAG, "add child task: invalid index");
@ -260,6 +265,7 @@ public class TaskList extends Node {
return true;
}
// 功能删除TaskList中的一个Task
public boolean removeChildTask(Task task) {
boolean ret = false;
int index = mChildren.indexOf(task);
@ -281,6 +287,7 @@ public class TaskList extends Node {
return ret;
}
//功能将当前TaskList中含有的某个Task移到index位置
public boolean moveChildTask(Task task, int index) {
if (index < 0 || index >= mChildren.size()) {
@ -298,7 +305,10 @@ public class TaskList extends Node {
return true;
return (removeChildTask(task) && addChildTask(task, index));
}
//利用已实现好的功能完成当下功能;
// 功能按gid寻找Task
public Task findChildTaskByGid(String gid) {
for (int i = 0; i < mChildren.size(); i++) {
Task t = mChildren.get(i);
@ -308,11 +318,13 @@ public class TaskList extends Node {
}
return null;
}
//功能返回指定Task的index
public int getChildTaskIndex(Task task) {
return mChildren.indexOf(task);
}
//功能返回指定index的Task
public Task getChildTaskByIndex(int index) {
if (index < 0 || index >= mChildren.size()) {
Log.e(TAG, "getTaskByIndex: invalid index");
@ -321,6 +333,8 @@ public class TaskList extends Node {
return mChildren.get(index);
}
//功能返回指定index的Task
public Task getChilTaskByGid(String gid) {
for (Task task : mChildren) {
if (task.getGid().equals(gid))

@ -14,14 +14,24 @@
* limitations under the License.
*/
// 支持小米便签运行过程中的运行异常处理
package net.micode.notes.gtask.exception;
public class ActionFailureException extends RuntimeException {
private static final long serialVersionUID = 4425249765923293627L;
/*
* serialVersionUIDjava
* serialVersionUID
*/
public ActionFailureException() {
super();
}
/*
* JAVA使superthis.
* new
*/
public ActionFailureException(String paramString) {
super(paramString);

@ -13,11 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Description便
*/
package net.micode.notes.gtask.exception;
public class NetworkFailureException extends Exception {
private static final long serialVersionUID = 2107610287180234136L;
// serialVersionUID作用是序列化时保持版本的兼容性即在版本升级时反序列化仍保持对象的唯一性。
/*
* JAVA使superthis.
* new
*/
public NetworkFailureException() {
super();

@ -28,6 +28,13 @@ import net.micode.notes.R;
import net.micode.notes.ui.NotesListActivity;
import net.micode.notes.ui.NotesPreferenceActivity;
/*GTask
*
* private void showNotification(int tickerId, String content)
* protected Integer doInBackground(Void... unused) 线
* protected void onProgressUpdate(String... progress) 使 线
* protected void onPostExecute(Integer result) Handler UI使doInBackground UI
*/
public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
@ -57,7 +64,7 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
mTaskManager.cancelSync();
}
public void publishProgess(String message) {
public void publishProgess(String message) {// 发布进度单位系统将会调用onProgressUpdate()方法更新这些值
publishProgress(new String[] {
message
});
@ -66,30 +73,29 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
private void showNotification(int tickerId, String content) {
Notification notification = new Notification(R.drawable.notification, mContext
.getString(tickerId), System.currentTimeMillis());
notification.defaults = Notification.DEFAULT_LIGHTS;
notification.defaults = Notification.DEFAULT_LIGHTS;// 调用系统自带灯光
notification.flags = Notification.FLAG_AUTO_CANCEL;
PendingIntent pendingIntent;
if (tickerId != R.string.ticker_success) {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
NotesPreferenceActivity.class), 0);
NotesPreferenceActivity.class), 0);//如果同步不成功那么从系统取得一个用于启动一个NotesPreferenceActivity的PendingIntent对象
} else {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
NotesListActivity.class), 0);
NotesListActivity.class), 0);//如果同步成功那么从系统取得一个用于启动一个NotesListActivity的PendingIntent对象
}
notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
pendingIntent);
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
// notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
// pendingIntent);
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);//通过NotificationManager对象的notify方法来执行一个notification的消息
}
@Override
// @Override
protected Integer doInBackground(Void... unused) {
publishProgess(mContext.getString(R.string.sync_progress_login, NotesPreferenceActivity
.getSyncAccountName(mContext)));
return mTaskManager.sync(mContext, this);
return mTaskManager.sync(mContext, this); //进行后台同步具体操作
}
@Override
// @Override
protected void onProgressUpdate(String... progress) {
showNotification(R.string.ticker_syncing, progress[0]);
if (mContext instanceof GTaskSyncService) {
@ -97,8 +103,8 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
}
}
@Override
protected void onPostExecute(Integer result) {
//@Override
protected void onPostExecute(Integer result) {//用于在执行完后台任务后更新UI,显示结果
if (result == GTaskManager.STATE_SUCCESS) {
showNotification(R.string.ticker_success, mContext.getString(
R.string.success_sync_account, mTaskManager.getSyncAccount()));

@ -60,7 +60,10 @@ import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
/*
* GTASKGTASK
* 使accountManager JSONObject HttpParams authToken Gid
*/
public class GTaskClient {
private static final String TAG = GTaskClient.class.getSimpleName();
@ -102,6 +105,10 @@ public class GTaskClient {
mUpdateArray = null;
}
/*
* 使 getInstance()
* mInstance
*/
public static synchronized GTaskClient getInstance() {
if (mInstance == null) {
mInstance = new GTaskClient();

@ -87,9 +87,9 @@ public class GTaskManager {
private HashMap<Long, String> mNidToGid;
private GTaskManager() {
mSyncing = false;
mCancelled = false;
private GTaskManager() { //对象初始化函数
mSyncing = false; //正在同步,flase代表未执行
mCancelled = false; //全局标识flase代表可以执行
mGTaskListHashMap = new HashMap<String, TaskList>();
mGTaskHashMap = new HashMap<String, Node>();
mMetaHashMap = new HashMap<String, MetaData>();
@ -113,7 +113,7 @@ public class GTaskManager {
public int sync(Context context, GTaskASyncTask asyncTask) {
if (mSyncing) {
Log.d(TAG, "Sync is in progress");
Log.d(TAG, "Sync is in progress");//创建日志文件调试信息debug
return STATE_SYNC_IN_PROGRESS;
}
mContext = context;
@ -128,7 +128,7 @@ public class GTaskManager {
mNidToGid.clear();
try {
GTaskClient client = GTaskClient.getInstance();
GTaskClient client = GTaskClient.getInstance();//getInstance即为创建一个实例,client--客户机
client.resetUpdateArray();
// login google task
@ -140,7 +140,7 @@ public class GTaskManager {
// get the task list from google
asyncTask.publishProgess(mContext.getString(R.string.sync_progress_init_list));
initGTaskList();
initGTaskList(); //获取Google上的JSONtasklist转为本地TaskList
// do content sync work
asyncTask.publishProgess(mContext.getString(R.string.sync_progress_syncing));
@ -168,12 +168,17 @@ public class GTaskManager {
return mCancelled ? STATE_SYNC_CANCELLED : STATE_SUCCESS;
}
/*
*GtaskListGoogleJSONtasklistTaskList
*mMetaListmGTaskListHashMapmGTaskHashMap
*/
private void initGTaskList() throws NetworkFailureException {
if (mCancelled)
return;
GTaskClient client = GTaskClient.getInstance();
try {
JSONArray jsTaskLists = client.getTaskLists();
JSONArray jsTaskLists = client.getTaskLists(); //getInstance即为创建一个实例client应指远端客户机
// init meta list first
mMetaList = null;
@ -247,6 +252,8 @@ public class GTaskManager {
}
}
//功能:本地内容同步操作
private void syncContent() throws NetworkFailureException {
int syncType;
Cursor c = null;

@ -42,6 +42,8 @@ public class GTaskSyncService extends Service {
private static String mSyncProgress = "";
////开始一个同步的工作
private void startSync() {
if (mSyncTask == null) {
mSyncTask = new GTaskASyncTask(this, new GTaskASyncTask.OnCompleteListener() {
@ -65,13 +67,14 @@ public class GTaskSyncService extends Service {
@Override
public void onCreate() {
mSyncTask = null;
}
}///初始化一个service
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Bundle bundle = intent.getExtras();
if (bundle != null && bundle.containsKey(ACTION_STRING_NAME)) {
switch (bundle.getInt(ACTION_STRING_NAME, ACTION_INVALID)) {
//两种情况,开始同步或者取消同步
case ACTION_START_SYNC:
startSync();
break;
@ -81,7 +84,7 @@ public class GTaskSyncService extends Service {
default:
break;
}
return START_STICKY;
return START_STICKY;//等待新的intent来是这个service继续运行
}
return super.onStartCommand(intent, flags, startId);
}

@ -47,6 +47,7 @@ import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -85,8 +86,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
public ImageView ibSetBgColor;
}
//使用Map实现数据存储
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);
@ -97,6 +100,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);
@ -107,6 +111,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);
@ -116,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);
@ -220,7 +226,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
// intent.getAction()
// 大多用于broadcast发送广播时给机制intent设置一个action就是一个字符串
@ -287,6 +293,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
super.onResume();
initNoteScreen(); //调用方法初始化笔记屏幕
}
//初始化笔记界面的方法
private void initNoteScreen() {
//设置笔记编辑器的文字样式
@ -341,8 +348,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
//没有提醒时,隐藏提醒日期和图标
mNoteHeaderHolder.tvAlertDate.setVisibility(View.GONE);
mNoteHeaderHolder.ivAlertIcon.setVisibility(View.GONE);
};
}
;
}
//当活动通过意图重新初始化时调用
@Override
protected void onNewIntent(Intent intent) {
@ -390,7 +399,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
//判断触摸事件是否在给定的视图的范围内的方法
private boolean inRangeOfView(View view, MotionEvent ev) {
int []location = new int[2];
int[] location = new int[2];
//获取视图在屏幕上的位置
view.getLocationOnScreen(location);
int x = location[0];
@ -400,8 +409,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;
}
@ -429,7 +438,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
for (int id : sFontSizeBtnsMap.keySet()) {
View view = findViewById(id);
view.setOnClickListener(this);
};
}
;
//获取共享偏好设置,用于恢复特定的笔记属性,如字体的大小
mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
mFontSizeId = mSharedPrefs.getInt(PREFERENCE_FONT_SIZE, ResourceParser.BG_DEFAULT_FONT_SIZE);
@ -439,7 +449,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
* return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE}
*/
//如果字体大小ID超出资源数组大小设置为默认字体大小
if(mFontSizeId >= TextAppearanceResources.getResourcesSize()) {
if (mFontSizeId >= TextAppearanceResources.getResourcesSize()) {
mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE;
}
//初始化笔记编辑列表视图
@ -451,7 +461,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
protected void onPause() {
super.onPause();
//尝试保存笔记,如果成功则记录保存的长度
if(saveNote()) {
if (saveNote()) {
Log.d(TAG, "Note data was saved with length:" + mWorkingNote.getContent().length());
}
//清除设置状态
@ -473,14 +483,15 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return;
}
//添加小部件ID到intent中
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] {
mWorkingNote.getWidgetId()
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[]{
mWorkingNote.getWidgetId()
});
//发送广播以通知小部件更新
sendBroadcast(intent);
//设置结果为OK
setResult(RESULT_OK, intent);
}
//处理点击事件
public void onClick(View v) {
int id = v.getId();
@ -488,8 +499,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
if (id == R.id.btn_set_bg_color) {
mNoteBgColorSelector.setVisibility(View.VISIBLE);
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
- View.VISIBLE);
//更改背景颜色或字体大小的逻辑
-View.VISIBLE);
//更改背景颜色或字体大小的逻辑
} else if (sBgSelectorBtnsMap.containsKey(id)) {
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.GONE);
@ -515,7 +526,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
@Override
public void onBackPressed() {
//清除设置状态,如果已经处理则返回
if(clearSettingState()) {
if (clearSettingState()) {
return;
}
//保存笔记然后正常处理返回事件
@ -620,7 +631,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
d.setOnDateTimeSetListener(new OnDateTimeSetListener() {
public void OnDateTimeSet(AlertDialog dialog, long date) {
//当用户设置了日期时间后,将这个时间保存为提醒的时间
mWorkingNote.setAlertDate(date , true);
mWorkingNote.setAlertDate(date, true);
}
});
//显示日期时间选择对话框
@ -707,7 +718,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE));
//显示提醒的头部信息
showAlertHeader();
if(!set) {
if (!set) {
//如果set为false取消任何现有的闹钟
alarmManager.cancel(pendingIntent);
} else {
@ -745,7 +756,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mEditTextList.removeViewAt(index);//移除指定索引处的编辑框视图
NoteEditText edit = null;
if(index == 0) { //如果删除的是第一个编辑框
if (index == 0) { //如果删除的是第一个编辑框
edit = (NoteEditText) mEditTextList.getChildAt(0).findViewById(
R.id.et_edit_text);
} else {//否则,获取欠一个编辑框
@ -764,7 +775,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
/**
* Should not happen, check for debug
*/
if(index > mEditTextList.getChildCount()) {
if (index > mEditTextList.getChildCount()) {
Log.e(TAG, "Index out of mEditTextList boundrary, should not happen");
}
//创建新的列表项视图,然后将其添加到列表中的指定位置
@ -786,7 +797,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
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++;
}
@ -862,7 +873,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
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);
@ -1000,4 +1011,19 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private void showToast(int resId, int duration) {
Toast.makeText(this, resId, duration).show();
}
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");
Intent loadImage = new Intent(Intent.ACTION_GET_CONTENT);
loadImage.addCategory(Intent.CATEGORY_OPENABLE);
loadImage.setType("image/*");
startActivityForResult(loadImage, PHOTO_REQUESt);
}
});
}

@ -0,0 +1,29 @@
package net.micode.notes.ui;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowInsets;
import net.micode.notes.R;
public class SplashActivity extends AppCompatActivity {
Handler mHandler=new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); //加载启动界面
setContentView(R.layout.activity_splash); //加载启动
// 当计时结束时,跳转至 NotesListActivity
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent();
intent.setClass(SplashActivity.this, LoginActivity.class);
startActivity(intent);
finish(); //销毁欢迎页面
}
}, 2000); // 2 秒后跳转}

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="旧密码:"/>
<EditText
android:id="@+id/old_password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="新密码:"/>
<EditText
android:id="@+id/new_password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认密码:"/>
<EditText
android:id="@+id/ack_password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/Acknowledged"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输入密码:"/>
<EditText
android:id="@+id/thepassword"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/Dt_Acknowledged"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height='wrap_content'
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码:"/>
<EditText
android:id="@+id/lgn_password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="新设置密码:"/>
<EditText
android:id="@+id/password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认密码:" />
<EditText
android:id="@+id/password_ack"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/acknowledge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="0099cc"
tools:context=".ui.SplashActivity">
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->
<TextView android:id="@+id/fullscreen_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#33b5e5"
android:keepScreenOn="true"
android:textStyle="bold"
android:textSize="50sp"
android:gravity="center"
android:text="@string/dummy_content" />
<!-- This FrameLayout insets its children based on system windows using
android:fitsSystemWindows. -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:id = "@+id/fullscreen_content_controls"
style = "?metaButtonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:background="@color/black_overlay"
android:orientation="horizontal"
tools:ignore="UselessParent">
<Button android:id="@+id/dummy_button"
style= "?metaButtonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text = "@string/dummy_button" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/splash"
android:gravity="top"
android:keepScreenOn="true"
android:text="@string/dummy_content"
android:textSize="50sp"
android:textStyle="bold"
/>
</FrameLayout>
</FrameLayout>

@ -237,6 +237,16 @@
</FrameLayout>
</LinearLayout>
<ImageButton
android:id = "@+id/add_img_btn"
android:layout_width="45dp"
android:layout_height="match_parent"
android:src="@android:drawable/ic_menu_gallery"/>
<LinearLayout
android:id="@+id/font_size_selector"
android:layout_width="fill_parent"

@ -0,0 +1,6 @@
<resources>
<declare-styleable name="FullscreenAttrs">
<attr name="fullscreenBackgroundColor" format="color" />
<attr name="fullscreenTextColor" format="color" />
</declare-styleable>
</resources>

@ -15,6 +15,16 @@
limitations under the License.
-->
<!--<resources>-->
<!-- <color name="user_query_highlight">#335b5b5b</color>-->
<!--</resources>-->
<resources>
<color name="user_query_highlight">#335b5b5b</color>
</resources>
<color name="light_blue_600">#FFO39BE5</color>
<color name="light_blue_900">#FF01579B</color>
<color name="liqht_blue_A200">#FF40C4FF</color>
<color name="liqht_blue_A400">#FFOOBOFF</color>
<color name="black_overlay">#66000000</color>
</resources>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Newnote" parent="Theme.AppCompat.Light"/>
<style name="Theme.Newnote.Fullscreen" parent="Theme.Newnote">
<item name="android:actionBarStyle">@style/Widget.Theme.Newnote.ActionBar.Fullscreen</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">@null</item>
</style>
<style name="ThemeOverlay.Newnote.FullscreenContainer" parent="">
<item name="fullscreenBackgroundColor">@color/light_blue_600</item>
<item name="fullscreenTextColor">@color/light_blue_A200</item>
</style>
</resources>

@ -0,0 +1,6 @@
<resources>
<style name="ThemeOverlay.Newnote.FullscreenContainer" parent="">
<item name="fullscreenBackgroundColor">@color/light_blue_900</item>
<item name="fullscreenTextColor">@color/light_blue_A400</item>
</style>
</resources>
Loading…
Cancel
Save