Compare commits

...

4 Commits
master ... syh

Author SHA1 Message Date
19960030627 477fb3c62b 提交了个人的代码注释
2 years ago
19960030627 374a2d33a3 补偿Workingnote类的注释
2 years ago
19960030627 4ba7e00fc1 Merge remote-tracking branch 'origin/master' into syh
2 years ago
19960030627 6a3195b72a 补偿note类和contact类的注释
2 years ago

@ -25,9 +25,20 @@ import android.util.Log;
import java.util.HashMap;
/**
* change
*/
public class Contact {
/**
*
*/
private static HashMap<String, String> sContactCache;
private static final String TAG = "Contact";
/**
* CALLER_ID_SELECTION
*/
private static final String CALLER_ID_SELECTION = "PHONE_NUMBERS_EQUAL(" + Phone.NUMBER
+ ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'"
@ -36,6 +47,13 @@ public class Contact {
+ " FROM phone_lookup"
+ " WHERE min_match = '+')";
/**
*
* @param context
* @param phoneNumber
* @return
*/
public static String getContact(Context context, String phoneNumber) {
if (sContactCache == null) {
sContactCache = new HashMap<String, String>();
@ -47,6 +65,7 @@ public class Contact {
String selection = CALLER_ID_SELECTION.replace("+",
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
Cursor cursor = context.getContentResolver().query(
Data.CONTENT_URI,
new String[]{Phone.DISPLAY_NAME},

@ -36,6 +36,9 @@ import java.util.ArrayList;
public class Note {
/**
*private ContentValues mNoteDiffValues;
*/
private ContentValues mNoteDiffValues;
private NoteData mNoteData;
private static final String TAG = "Note";
@ -52,7 +55,14 @@ public class Note {
values.put(NoteColumns.TYPE, Notes.TYPE_NOTE);
values.put(NoteColumns.LOCAL_MODIFIED, 1);
values.put(NoteColumns.PARENT_ID, folderId);
/**
*
*/
Uri uri = context.getContentResolver().insert(Notes.CONTENT_NOTE_URI, values);
/**
* ContentResolver()ContentProvider
*
*/
long noteId = 0;
try {
@ -61,6 +71,9 @@ public class Note {
Log.e(TAG, "Get note id error :" + e.toString());
noteId = 0;
}
/**
* try-catch
*/
if (noteId == -1) {
throw new IllegalStateException("Wrong note id:" + noteId);
}
@ -72,36 +85,81 @@ public class Note {
mNoteData = new NoteData();
}
/**
* 便便便
* @param key
* @param value
*/
public void setNoteValue(String key, String value) {
mNoteDiffValues.put(key, value);
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
/**
*
* @param key
* @param value
*/
public void setTextData(String key, String value) {
mNoteData.setTextData(key, value);
}
/**
*
* @param id
*/
public void setTextDataId(long id) {
mNoteData.setTextDataId(id);
}
/**
* ID
* @return
*/
public long getTextDataId() {
return mNoteData.mTextDataId;
}
/**
* ID
* @param id
*/
public void setCallDataId(long id) {
mNoteData.setCallDataId(id);
}
/**
* ID
* @param key
* @param value
*/
public void setCallData(String key, String value) {
mNoteData.setCallData(key, value);
}
/**
* ID
* @return
*/
public boolean isLocalModified() {
return mNoteDiffValues.size() > 0 || mNoteData.isLocalModified();
}
/**
*
* @param context
* @param noteId
* @return
*/
public boolean syncNote(Context context, long noteId) {
if (noteId <= 0) {
throw new IllegalArgumentException("Wrong note id:" + noteId);
@ -132,14 +190,27 @@ public class Note {
return true;
}
/**
*
*/
private class NoteData {
/**
* 便
*/
private long mTextDataId;
private ContentValues mTextDataValues;
/**
*
*/
private long mCallDataId;
private ContentValues mCallDataValues;
/**
*
*/
private static final String TAG = "NoteData";
@ -150,6 +221,11 @@ public class Note {
mCallDataId = 0;
}
/**
*
* @return
*/
boolean isLocalModified() {
return mTextDataValues.size() > 0 || mCallDataValues.size() > 0;
}
@ -180,6 +256,13 @@ public class Note {
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
/**
* Uri
* @param context
* @param noteId
* @return
*/
Uri pushIntoContentResolver(Context context, long noteId) {
/**
* Check for safety
@ -187,9 +270,15 @@ public class Note {
if (noteId <= 0) {
throw new IllegalArgumentException("Wrong note id:" + noteId);
}
/**
*
*/
ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>();
ContentProviderOperation.Builder builder = null;
/**
*
*/
if (mTextDataValues.size() > 0) {
mTextDataValues.put(DataColumns.NOTE_ID, noteId);
@ -212,6 +301,9 @@ public class Note {
}
mTextDataValues.clear();
}
/**
* DataColums
*/
if (mCallDataValues.size() > 0) {
mCallDataValues.put(DataColumns.NOTE_ID, noteId);
@ -234,6 +326,9 @@ public class Note {
}
mCallDataValues.clear();
}
/**
* DataColumns
*/
if (operationList.size() > 0) {
try {
@ -249,6 +344,9 @@ public class Note {
return null;
}
}
/**
*
*/
return null;
}
}

@ -61,7 +61,7 @@ public class WorkingNote {
private boolean mIsDeleted;
private NoteSettingChangedListener mNoteSettingStatusListener;
// 声明 DATA_PROJECTION字符串数组
public static final String[] DATA_PROJECTION = new String[]{
DataColumns.ID,
DataColumns.CONTENT,
@ -71,7 +71,9 @@ public class WorkingNote {
DataColumns.DATA3,
DataColumns.DATA4,
};
/**
* // 声明 NOTE_PROJECTION字符串数组
*/
public static final String[] NOTE_PROJECTION = new String[]{
NoteColumns.PARENT_ID,
NoteColumns.ALERTED_DATE,
@ -124,11 +126,17 @@ public class WorkingNote {
loadNote();
}
/**
* Note
* query
*/
private void loadNote() {
Cursor cursor = mContext.getContentResolver().query(
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mNoteId), NOTE_PROJECTION, null,
null, null);
/**
*
*/
if (cursor != null) {
if (cursor.moveToFirst()) {
mFolderId = cursor.getLong(NOTE_PARENT_ID_COLUMN);
@ -139,6 +147,9 @@ public class WorkingNote {
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
}
cursor.close();
/**
*
*/
} else {
Log.e(TAG, "No note with id:" + mNoteId);
throw new IllegalArgumentException("Unable to find note with id " + mNoteId);
@ -146,6 +157,10 @@ public class WorkingNote {
loadNoteData();
}
/**
* Notedata
*/
private void loadNoteData() {
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
DataColumns.NOTE_ID + "=?", new String[]{
@ -153,7 +168,13 @@ public class WorkingNote {
}, null);
if (cursor != null) {
/**
*
*/
if (cursor.moveToFirst()) {
/**
*
*/
do {
String type = cursor.getString(DATA_MIME_TYPE_COLUMN);
if (DataConstants.NOTE.equals(type)) {
@ -166,6 +187,9 @@ public class WorkingNote {
Log.d(TAG, "Wrong note type with type:" + type);
}
} while (cursor.moveToNext());
/**
*
*/
}
cursor.close();
} else {
@ -174,9 +198,22 @@ public class WorkingNote {
}
}
/**
* Note
* contextidwidget
* @param context
* @param folderId
* @param widgetId
* @param widgetType
* @param defaultBgColorId
* @return
*/
public static WorkingNote createEmptyNote(Context context, long folderId, int widgetId,
int widgetType, int defaultBgColorId) {
WorkingNote note = new WorkingNote(context, folderId);
/**
*
*/
note.setBgColorId(defaultBgColorId);
note.setWidgetId(widgetId);
note.setWidgetType(widgetType);
@ -186,10 +223,19 @@ public class WorkingNote {
public static WorkingNote load(Context context, long id) {
return new WorkingNote(context, id, 0);
}
/**
* note
*/
public synchronized boolean saveNote() {
if (isWorthSaving()) {
/**
*
*/
if (!existInDatabase()) {
/**
*
*/
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
Log.e(TAG, "Create new note fail with id:" + mNoteId);
return false;
@ -211,12 +257,23 @@ public class WorkingNote {
return false;
}
}
/**
*
*/
public boolean existInDatabase() {
return mNoteId > 0;
}
/**
*
* @return
*/
private boolean isWorthSaving() {
/**
*
*/
if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
|| (existInDatabase() && !mNote.isLocalModified())) {
return false;
@ -225,10 +282,22 @@ public class WorkingNote {
}
}
/**
* mNoteSettingStatusListener
* @param l
*/
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
mNoteSettingStatusListener = l;
}
/**
* AlertDate
* mAlertDatedatamAlertDateNoteValue
* @param date
* @param set
*/
public void setAlertDate(long date, boolean set) {
if (date != mAlertDate) {
mAlertDate = date;
@ -239,7 +308,15 @@ public class WorkingNote {
}
}
/**
*
* @param mark
*/
public void markDeleted(boolean mark) {
/**
*
*/
mIsDeleted = mark;
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE && mNoteSettingStatusListener != null) {
@ -247,6 +324,11 @@ public class WorkingNote {
}
}
/**
*
* @param id
*/
public void setBgColorId(int id) {
if (id != mBgColorId) {
mBgColorId = id;
@ -257,6 +339,10 @@ public class WorkingNote {
}
}
/**
*
* @param mode
*/
public void setCheckListMode(int mode) {
if (mMode != mode) {
if (mNoteSettingStatusListener != null) {
@ -267,6 +353,12 @@ public class WorkingNote {
}
}
/**
* // 设定WidgetType
* // 参数type
* @param type
*/
public void setWidgetType(int type) {
if (type != mWidgetType) {
mWidgetType = type;
@ -274,6 +366,10 @@ public class WorkingNote {
}
}
/**
* widgetid
* @param id
*/
public void setWidgetId(int id) {
if (id != mWidgetId) {
mWidgetId = id;
@ -281,12 +377,20 @@ public class WorkingNote {
}
}
/**
* NotesetNoteValueWidgetId
* @param text
*/
public void setWorkingText(String text) {
if (!TextUtils.equals(mContent, text)) {
mContent = text;
mNote.setTextData(DataColumns.CONTENT, mContent);
}
}
/**
* NotesetTextDataWorkingText
*/
public void convertToCallNote(String phoneNumber, long callDate) {
mNote.setCallData(CallNote.CALL_DATE, String.valueOf(callDate));
@ -294,54 +398,115 @@ public class WorkingNote {
mNote.setNoteValue(NoteColumns.PARENT_ID, String.valueOf(Notes.ID_CALL_RECORD_FOLDER));
}
/**
*
* @return
*/
public boolean hasClockAlert() {
return (mAlertDate > 0 ? true : false);
}
/**
* Content
* @return
*/
public String getContent() {
return mContent;
}
/**
* AlertDate
* @return
*/
public long getAlertDate() {
return mAlertDate;
}
/**
* ModifiedDate
* @return
*/
public long getModifiedDate() {
return mModifiedDate;
}
/**
* id
* @return
*/
public int getBgColorResId() {
return NoteBgResources.getNoteBgResource(mBgColorId);
}
/**
* id
* @return
*/
public int getBgColorId() {
return mBgColorId;
}
/**
* id
* @return
*/
public int getTitleBgResId() {
return NoteBgResources.getNoteTitleBgResource(mBgColorId);
}
/**
* CheckListMode
* @return
*/
public int getCheckListMode() {
return mMode;
}
/**
* 便id
* @return
*/
public long getNoteId() {
return mNoteId;
}
/**
* id
* @return
*/
public long getFolderId() {
return mFolderId;
}
/**
* id
* @return
*/
public int getWidgetId() {
return mWidgetId;
}
/**
* WidgetId
* @return
*/
public int getWidgetType() {
return mWidgetType;
}
/**
* WidgetType
*/
public interface NoteSettingChangedListener {
/**
* Called when the background color of current note has just changed

Binary file not shown.

Binary file not shown.

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading…
Cancel
Save