Signed-off-by: qijingxi <2904615854@qq.com>
main
qijingxi 7 months ago
parent 5c2c3cf910
commit d1b81592d3

@ -31,8 +31,8 @@ import java.util.HashMap;
* @Package: net.micode.notes.data * @Package: net.micode.notes.data
* @ClassName: Contact * @ClassName: Contact
* @Description: * @Description:
* @Author: * @Author:
* @Date: 2023-12-16 17:57 * @Date: 2024-12-20 19:42
*/ */
public class Contact { public class Contact {
private static HashMap<String, String> sContactCache; private static HashMap<String, String> sContactCache;
@ -44,11 +44,11 @@ public class Contact {
+ "(SELECT raw_contact_id " + "(SELECT raw_contact_id "
+ " FROM phone_lookup" + " FROM phone_lookup"
+ " WHERE min_match = '+')"; + " WHERE min_match = '+')";
/** /**
* @method getContact * @method getContact
* @description * @description
* @date: 2023-12-16 19:24 * @date: 2024-12-20 20:02
* @author: * @author:
* @return string * @return string
*/ */
public static String getContact(Context context, String phoneNumber) { public static String getContact(Context context, String phoneNumber) {
@ -57,7 +57,7 @@ public class Contact {
} }
// 查找HashMap中是否有phoneNumber的信息 // 查找HashMap中是否有phoneNumber的信息
// 2023-12-16 19:43 // 2024-12-20 20:04
if(sContactCache.containsKey(phoneNumber)) { if(sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber); return sContactCache.get(phoneNumber);
} }
@ -66,7 +66,7 @@ public class Contact {
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber)); PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
// 查找数据库中phoneNumber的信息 // 查找数据库中phoneNumber的信息
// 2023-12-16 19:43 // 2024-12-20 20:06
Cursor cursor = context.getContentResolver().query( Cursor cursor = context.getContentResolver().query(
Data.CONTENT_URI, Data.CONTENT_URI,
new String [] { Phone.DISPLAY_NAME }, new String [] { Phone.DISPLAY_NAME },
@ -75,7 +75,7 @@ public class Contact {
null); null);
// 检查是否查询到联系人找到则将相关信息加入HashMap中未找到则处理异常 // 检查是否查询到联系人找到则将相关信息加入HashMap中未找到则处理异常
// 2023-12-16 19:41 // 2024-12-20 20:07
if (cursor != null && cursor.moveToFirst()) { if (cursor != null && cursor.moveToFirst()) {
try { try {
String name = cursor.getString(0); String name = cursor.getString(0);

@ -14,6 +14,18 @@
* limitations under the License. * limitations under the License.
*/ */
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: Notes
* @Description: Intent
URI访使
* @Author:
* @Date: 2024-12-21 19:42
*/
package net.micode.notes.data; package net.micode.notes.data;
import android.net.Uri; import android.net.Uri;
@ -46,6 +58,13 @@ public class Notes {
public static final int TYPE_WIDGET_2X = 0; public static final int TYPE_WIDGET_2X = 0;
public static final int TYPE_WIDGET_4X = 1; public static final int TYPE_WIDGET_4X = 1;
/**
* @method DataConstants
* @description MIME
* @date: 2024-12-21 20:02
* @author:
*/
public static class DataConstants { public static class DataConstants {
public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; public static final String NOTE = TextNote.CONTENT_ITEM_TYPE;
public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE; public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE;
@ -61,6 +80,16 @@ public class Notes {
*/ */
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data"); public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
/**
* @method NoteColumns
* @description ID ID
ID ID ID
IDGTask ID
* @date: 2024-12-21 20:04
* @author:
*/
public interface NoteColumns { public interface NoteColumns {
/** /**
* The unique ID for a row * The unique ID for a row
@ -173,6 +202,15 @@ public class Notes {
public static final String TOP = "top"; public static final String TOP = "top";
} }
/**
* @method DataColumns
* @description IDMIME
ID
* @date: 2024-12-21 20:05
* @author:
*/
public interface DataColumns { public interface DataColumns {
/** /**
* The unique ID for a row * The unique ID for a row
@ -247,6 +285,14 @@ public class Notes {
public static final String DATA5 = "data5"; public static final String DATA5 = "data5";
} }
/**
* @method TextNote
* @description DataColumns MIME
MIME URI
* @date: 2024-12-21 20:07
* @author:
*/
public static final class TextNote implements DataColumns { public static final class TextNote implements DataColumns {
/** /**
* Mode to indicate the text in check list mode or not * Mode to indicate the text in check list mode or not
@ -263,6 +309,13 @@ public class Notes {
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note"); public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");
} }
/**
* @method CallNote
* @description DataColumns MIME
MIME URI
* @date: 2024-12-21 20:10
* @author:
*/
public static final class CallNote implements DataColumns { public static final class CallNote implements DataColumns {
/** /**
* Call date for this record * Call date for this record

@ -14,6 +14,18 @@
* limitations under the License. * limitations under the License.
*/ */
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: NotesDatabaseHelper
* @Description: SQLiteOpenHelper
SQL
便
* @Author:
* @Date: 2024-12-21 22:10
*/
package net.micode.notes.data; package net.micode.notes.data;
import android.content.ContentValues; import android.content.ContentValues;
@ -207,10 +219,25 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" + " WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" +
" END"; " END";
/**
* @method NotesDatabaseHelper
* @description NotesDatabaseHelper
* @date: 2024-12-21 22:10
* @author:
*/
public NotesDatabaseHelper(Context context) { public NotesDatabaseHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION); super(context, DB_NAME, null, DB_VERSION);
} }
/**
* @method createNoteTable
* @description SQL reCreateNoteTableTriggers
* @date: 2024-12-21 22:13
* @author:
*/
public void createNoteTable(SQLiteDatabase db) { public void createNoteTable(SQLiteDatabase db) {
db.execSQL(CREATE_NOTE_TABLE_SQL); db.execSQL(CREATE_NOTE_TABLE_SQL);
reCreateNoteTableTriggers(db); reCreateNoteTableTriggers(db);
@ -218,6 +245,14 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
Log.d(TAG, "note table has been created"); Log.d(TAG, "note table has been created");
} }
/**
* @method reCreateNoteTableTriggers
* @description
* @date: 2024-12-21 22:15
* @author:
*/
private void reCreateNoteTableTriggers(SQLiteDatabase db) { private void reCreateNoteTableTriggers(SQLiteDatabase db) {
db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_update"); db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_update");
db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_update"); db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_update");
@ -236,6 +271,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL(FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER); db.execSQL(FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER);
} }
/**
* @method createSystemFolder
* @description 使 ContentValues ID
* @date: 2024-12-21 22:20
* @author:
*/
private void createSystemFolder(SQLiteDatabase db) { private void createSystemFolder(SQLiteDatabase db) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
@ -271,6 +313,12 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.insert(TABLE.NOTE, null, values); db.insert(TABLE.NOTE, null, values);
} }
/**
* @method createDataTable
* @description SQL reCreateDataTableTriggers
* @date: 2024-12-21 22:23
* @author:
*/
public void createDataTable(SQLiteDatabase db) { public void createDataTable(SQLiteDatabase db) {
db.execSQL(CREATE_DATA_TABLE_SQL); db.execSQL(CREATE_DATA_TABLE_SQL);
reCreateDataTableTriggers(db); reCreateDataTableTriggers(db);
@ -278,6 +326,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
Log.d(TAG, "data table has been created"); Log.d(TAG, "data table has been created");
} }
/**
* @method reCreateDataTableTriggers
* @description
* @date: 2024-12-21 22:25
* @author:
*/
private void reCreateDataTableTriggers(SQLiteDatabase db) { private void reCreateDataTableTriggers(SQLiteDatabase db) {
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_insert"); db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_insert");
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_update"); db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_update");
@ -288,6 +343,12 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER); db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER);
} }
/**
* @method getInstance
* @description NotesDatabaseHelper
* @date: 2024-12-21 22:30
* @author:
*/
static synchronized NotesDatabaseHelper getInstance(Context context) { static synchronized NotesDatabaseHelper getInstance(Context context) {
if (mInstance == null) { if (mInstance == null) {
mInstance = new NotesDatabaseHelper(context); mInstance = new NotesDatabaseHelper(context);
@ -295,12 +356,27 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
return mInstance; return mInstance;
} }
/**
* @method onCreate
* @description createNoteTable createDataTable
* @date: 2024-12-21 22:40
* @author:
*/
@Override @Override
public void onCreate(SQLiteDatabase db) { public void onCreate(SQLiteDatabase db) {
createNoteTable(db); createNoteTable(db);
createDataTable(db); createDataTable(db);
} }
/**
* @method onUpgrade
* @description
upgradeToV2upgradeToV3
* @date: 2024-12-21 22:47
* @author:
*/
@Override @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
boolean reCreateTriggers = false; boolean reCreateTriggers = false;
@ -339,6 +415,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
} }
} }
/**
* @method upgradeToV2
* @description 2
* @date: 2024-12-21 22:51
* @author:
*/
private void upgradeToV2(SQLiteDatabase db) { private void upgradeToV2(SQLiteDatabase db) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE.NOTE); db.execSQL("DROP TABLE IF EXISTS " + TABLE.NOTE);
db.execSQL("DROP TABLE IF EXISTS " + TABLE.DATA); db.execSQL("DROP TABLE IF EXISTS " + TABLE.DATA);
@ -346,6 +429,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
createDataTable(db); createDataTable(db);
} }
/**
* @method upgradeToV3
* @description 3使 gtask_id
* @date: 2024-12-21 22:55
* @author:
*/
private void upgradeToV3(SQLiteDatabase db) { private void upgradeToV3(SQLiteDatabase db) {
// drop unused triggers // drop unused triggers
db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_insert"); db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_insert");
@ -361,11 +451,25 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.insert(TABLE.NOTE, null, values); db.insert(TABLE.NOTE, null, values);
} }
/**
* @method upgradeToV4
* @description 4 version
* @date: 2024-12-21 22:57
* @author:
*/
private void upgradeToV4(SQLiteDatabase db) { private void upgradeToV4(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ " INTEGER NOT NULL DEFAULT 0"); + " INTEGER NOT NULL DEFAULT 0");
} }
/**
* @method upgradeToV5
* @description 5 top
* @date: 2024-12-21 23:00
* @author:
*/
private void upgradeToV5(SQLiteDatabase db) { private void upgradeToV5(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.TOP db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.TOP
+ " INTEGER NOT NULL DEFAULT 0"); + " INTEGER NOT NULL DEFAULT 0");

@ -14,6 +14,18 @@
* limitations under the License. * limitations under the License.
*/ */
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: NotesProvider
* @Description: ContentProvider访 URI
ContentProvider onCreatequeryinsertdeleteupdate
便访
* @Author:
* @Date: 2024-12-21 23:10
*/
package net.micode.notes.data; package net.micode.notes.data;
@ -34,6 +46,13 @@ import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.NoteColumns; import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.NotesDatabaseHelper.TABLE; import net.micode.notes.data.NotesDatabaseHelper.TABLE;
/**
* @method NotesProvider
* @description
* @date: 2024-12-21 23:12
* @author:
*/
public class NotesProvider extends ContentProvider { public class NotesProvider extends ContentProvider {
private static final UriMatcher mMatcher; private static final UriMatcher mMatcher;
@ -80,12 +99,27 @@ public class NotesProvider extends ContentProvider {
+ " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER + " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER
+ " AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE; + " AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE;
/**
* @method onCreate
* @description ContentProvider NotesDatabaseHelper.getInstance
mHelper true
* @date: 2024-12-21 23:13
* @author:
*/
@Override @Override
public boolean onCreate() { public boolean onCreate() {
mHelper = NotesDatabaseHelper.getInstance(getContext()); mHelper = NotesDatabaseHelper.getInstance(getContext());
return true; return true;
} }
/**
* @method query
* @description URI
* @date: 2024-12-21 23:15
* @author:
*/
@Override @Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) { String sortOrder) {
@ -147,7 +181,12 @@ public class NotesProvider extends ContentProvider {
} }
return c; return c;
} }
/**
* @method insert
* @description URI
* @date: 2024-12-21 23:17
* @author:
*/
@Override @Override
public Uri insert(Uri uri, ContentValues values) { public Uri insert(Uri uri, ContentValues values) {
SQLiteDatabase db = mHelper.getWritableDatabase(); SQLiteDatabase db = mHelper.getWritableDatabase();
@ -182,6 +221,12 @@ public class NotesProvider extends ContentProvider {
return ContentUris.withAppendedId(uri, insertedId); return ContentUris.withAppendedId(uri, insertedId);
} }
/**
* @method delete
* @description URI
* @date: 2024-12-21 23:20
* @author:
*/
@Override @Override
public int delete(Uri uri, String selection, String[] selectionArgs) { public int delete(Uri uri, String selection, String[] selectionArgs) {
int count = 0; int count = 0;
@ -227,7 +272,12 @@ public class NotesProvider extends ContentProvider {
} }
return count; return count;
} }
/**
* @method update
* @description URI
* @date: 2024-12-21 23:22
* @author:
*/
@Override @Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
int count = 0; int count = 0;
@ -267,11 +317,23 @@ public class NotesProvider extends ContentProvider {
} }
return count; return count;
} }
/**
* @method parseSelection
* @description
* @date: 2024-12-21 23:25
* @author:
*/
private String parseSelection(String selection) { private String parseSelection(String selection) {
return (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""); return (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : "");
} }
/**
* @method increaseNoteVersion
* @description ID
* @date: 2024-12-21 23:27
* @author:
*/
private void increaseNoteVersion(long id, String selection, String[] selectionArgs) { private void increaseNoteVersion(long id, String selection, String[] selectionArgs) {
StringBuilder sql = new StringBuilder(120); StringBuilder sql = new StringBuilder(120);
sql.append("UPDATE "); sql.append("UPDATE ");
@ -297,6 +359,13 @@ public class NotesProvider extends ContentProvider {
mHelper.getWritableDatabase().execSQL(sql.toString()); mHelper.getWritableDatabase().execSQL(sql.toString());
} }
/**
* @method getType
* @description MIME null
* @date: 2024-12-21 23:30
* @author:
*/
@Override @Override
public String getType(Uri uri) { public String getType(Uri uri) {
// TODO Auto-generated method stub // TODO Auto-generated method stub

Loading…
Cancel
Save