张林浩标注 #2

Merged
mwxbgi697 merged 1 commits from zhanglinhao_branch into master 2 years ago

@ -24,35 +24,49 @@ import android.telephony.PhoneNumberUtils;
import android.util.Log;
import java.util.HashMap;
/**
* @ProjectName: Contact.java
* @Package: net.micode.notes.data
* @ClassName: Contact
* @Description:
* @Author: ZHANGLINHAO
* @CreateDate: 2023/12/22 20:15
*/
public class Contact {
private static HashMap<String, String> sContactCache; //用散列表缓存联系人
private static final String TAG = "Contact"; //标识设为”Contact“
private static HashMap<String, String> sContactCache;
private static final String TAG = "Contact";
private static final String CALLER_ID_SELECTION = "PHONE_NUMBERS_EQUAL(" + Phone.NUHashMapMBER
+ ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'"
+ " AND " + Data.RAW_CONTACT_ID + " IN "
private static final String CALLER_ID_SELECTION = "PHONE_NUMBERS_EQUAL(" + Phone.NUMBER
+ ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'"
+ " AND " + Data.RAW_CONTACT_ID + " IN "
+ "(SELECT raw_contact_id "
+ " FROM phone_lookup"
+ " WHERE min_match = '+')"; //电话号码数据中查找与给定号码相匹配的联系人信息
+ " WHERE min_match = '+')";
/**
* @method: getContact
* @description:
* @date: 2023/12/22 20:15
* @author: ZHANGLINHAO
* @param:
* @return:
*/
public static String getContact(Context context, String phoneNumber) {
if(sContactCache == null) {
sContactCache = new HashMap<String, String>();
} //若缓存区为空,创建新的散列表
}
if(sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber);
} //查找并返回一个电话号码在联系人缓存中对应的值
}
String selection = CALLER_ID_SELECTION.replace("+",
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber)); //将传入的电话号码转换为一个可用于最小匹配的调用者ID格式
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
Cursor cursor = context.getContentResolver().query(
Data.CONTENT_URI,
new String [] { Phone.DISPLAY_NAME },
selection,
new String[] { phoneNumber },
null);//从联系人数据库中查询与phoneNumber匹配的联系人的显示名称。查询结果将被存储在返回的Cursor对象中可以遍历这个Cursor来获取每个匹配联系人的显示名称。
null);
if (cursor != null && cursor.moveToFirst()) {
try {
@ -67,7 +81,7 @@ public class Contact {
}
} else {
Log.d(TAG, "No contact matched with number:" + phoneNumber);
return null;//从Android设备的联系人数据库中检索与特定电话号码匹配的联系人名称
return null;
}
}
}

@ -33,7 +33,14 @@ import net.micode.notes.data.Notes.TextNote;
import java.util.ArrayList;
/**
* @ProjectName: Note.java
* @Package: net.micode.notes.model
* @ClassName: Note
* @Description: 便
* @Author: ZHANGLINHAO
* @CreateDate: 2023/12/22:10
*/
public class Note {
private ContentValues mNoteDiffValues;//创建一个记录小米便签值的表
private NoteData mNoteData;

@ -0,0 +1,487 @@
/*
* 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.model;
import android.appwidget.AppWidgetManager;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.text.TextUtils;
import android.util.Log;
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.CallNote;
import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.DataConstants;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.Notes.TextNote;
import net.micode.notes.tool.ResourceParser.NoteBgResources;
/**
* @ProjectName: WorkingNote.java
* @Package: net.micode.notes.model
* @ClassName: WorkingNote
* @Description: 便
* @Author: ZHANGLINHAO
* @CreateDate: 2023/12/22 20:17
*/
public class WorkingNote {
// Note for the working note
private Note mNote;
// Note Id
private long mNoteId;
// Note content
private String mContent;
// Note mode
private int mMode;
private long mAlertDate;
private long mModifiedDate;
private int mBgColorId;
private int mWidgetId;
private int mWidgetType;
private long mFolderId;
private Context mContext;
private static final String TAG = "WorkingNote";
private boolean mIsDeleted;
private NoteSettingChangedListener mNoteSettingStatusListener;
public static final String[] DATA_PROJECTION = new String[] {
DataColumns.ID,
DataColumns.CONTENT,
DataColumns.MIME_TYPE,
DataColumns.DATA1,
DataColumns.DATA2,
DataColumns.DATA3,
DataColumns.DATA4,
};
public static final String[] NOTE_PROJECTION = new String[] {
NoteColumns.PARENT_ID,
NoteColumns.ALERTED_DATE,
NoteColumns.BG_COLOR_ID,
NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE,
NoteColumns.MODIFIED_DATE
};
private static final int DATA_ID_COLUMN = 0;
private static final int DATA_CONTENT_COLUMN = 1;
private static final int DATA_MIME_TYPE_COLUMN = 2;
private static final int DATA_MODE_COLUMN = 3;
private static final int NOTE_PARENT_ID_COLUMN = 0;
private static final int NOTE_ALERTED_DATE_COLUMN = 1;
private static final int NOTE_BG_COLOR_ID_COLUMN = 2;
private static final int NOTE_WIDGET_ID_COLUMN = 3;
private static final int NOTE_WIDGET_TYPE_COLUMN = 4;
private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
// 新便签的构造
private WorkingNote(Context context, long folderId) {
mContext = context;
mAlertDate = 0;
mModifiedDate = System.currentTimeMillis();
mFolderId = folderId;
mNote = new Note();
mNoteId = 0;
mIsDeleted = false;
mMode = 0;
mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
}
// Existing note construct
private WorkingNote(Context context, long noteId, long folderId) {
mContext = context;
mNoteId = noteId;
mFolderId = folderId;
mIsDeleted = false;
mNote = new Note();
loadNote();
}
/**
* @method: loadNote
* @description:便
* @date: 2023/12/24 20:19
* @author: ZHANGLINHAO
* @param:
* @return:
*/
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);
mBgColorId = cursor.getInt(NOTE_BG_COLOR_ID_COLUMN);
mWidgetId = cursor.getInt(NOTE_WIDGET_ID_COLUMN);
mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN);
mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN);
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);
}
loadNoteData();
}
/**
* @method: loadNoteData
* @description:便
* @date: 2023/12/22 20:29
* @author: ZHANGLINHAO
* @param:
* @return:
*/
private void loadNoteData() {
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
DataColumns.NOTE_ID + "=?", new String[] {
String.valueOf(mNoteId)
}, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
String type = cursor.getString(DATA_MIME_TYPE_COLUMN);
if (DataConstants.NOTE.equals(type)) {
mContent = cursor.getString(DATA_CONTENT_COLUMN);
mMode = cursor.getInt(DATA_MODE_COLUMN);
mNote.setTextDataId(cursor.getLong(DATA_ID_COLUMN));
} else if (DataConstants.CALL_NOTE.equals(type)) {
mNote.setCallDataId(cursor.getLong(DATA_ID_COLUMN));
} else {
Log.d(TAG, "Wrong note type with type:" + type);
}
} while (cursor.moveToNext());
}
cursor.close();
} else {
Log.e(TAG, "No data with id:" + mNoteId);
throw new IllegalArgumentException("Unable to find note's data with id " + mNoteId);
}
}
/**
* @method: createEmptyNote
* @description:便
* @date: 2023/12/24 20:30
* @author: ZHANGLINHAO
* @param: IDIDID
* @return: note
*/
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);
return note;
}
/**
* @method: load
* @description:便
* @date: 2023/12/22 20:44
* @author: ZHANGLINHAO
* @param: ID
* @return: 便
*/
public static WorkingNote load(Context context, long id) {
return new WorkingNote(context, id, 0);
}
/**
* @method: saveNote
* @description:便
* @date: 2023/12/24 20:45
* @author: ZHANGLINHAO
* @param:
* @return: true/false
*/
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;
}
}
mNote.syncNote(mContext, mNoteId);
/**
* Update widget content if there exist any widget of this note
*/
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE
&& mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onWidgetChanged();
}
return true;
} else {
return false;
}
}
/**
* @method: existInDatabase
* @description:
* @date: 2023/12/22 20:46
* @author: ZHANGLINHAO
* @param:
* @return: 1/0
*/
public boolean existInDatabase() {
return mNoteId > 0;
}
/**
* @method: isWorthSaving
* @description:
* @date: 2023/12/22 20:47
* @author: ZHANGLINHAO
* @param:
* @return: 1/0
*/
private boolean isWorthSaving() {
if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
|| (existInDatabase() && !mNote.isLocalModified())) {
return false;
} else {
return true;
}
}
/**
* @method: setOnSettingStatusChangedListener
* @description:
* @date: 2023/12/22/20:50
* @author: ZHANGLINHAO
* @param:
* @return:
*/
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
mNoteSettingStatusListener = l;
}
/**
* @method: setAlertDate
* @description:
* @date: 2023/12/22 21:03
* @author: ZHANGLINHAO
* @param:
* @return:
*/
public void setAlertDate(long date, boolean set) {
if (date != mAlertDate) {
mAlertDate = date;
mNote.setNoteValue(NoteColumns.ALERTED_DATE, String.valueOf(mAlertDate));
}
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onClockAlertChanged(date, set);
}
}
/**
* @method: markDeleted
* @description:
* @date: 2023/12/22 21:04
* @author: ZHANGLINHAO
* @param:
* @return:
*/
public void markDeleted(boolean mark) {
mIsDeleted = mark;
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE && mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onWidgetChanged();
}
}
/**
* @method: setBgColorId
* @description:ID
* @date: 2023/12/22 21:06
* @author: ZHANGLINHAO
* @param: ID
* @return:
*/
public void setBgColorId(int id) {
if (id != mBgColorId) {
mBgColorId = id;
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onBackgroundColorChanged();
}
mNote.setNoteValue(NoteColumns.BG_COLOR_ID, String.valueOf(id));
}
}
/**
* @method: setCheckListMode
* @description:
* @date: 2023/12/22 21:07
* @author: ZHANGLINHAO
* @param:
* @return:
*/
public void setCheckListMode(int mode) {
if (mMode != mode) {
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onCheckListModeChanged(mMode, mode);
}
mMode = mode;
mNote.setTextData(TextNote.MODE, String.valueOf(mMode));
}
}
/**
* @method: setWidgetType
* @description:
* @date: 2023/12/24 21:07
* @author: ZHANGLINHAO
* @param:
* @return:
*/
public void setWidgetType(int type) {
if (type != mWidgetType) {
mWidgetType = type;
mNote.setNoteValue(NoteColumns.WIDGET_TYPE, String.valueOf(mWidgetType));
}
}
/**
* @method: setWidgetId
* @description:ID
* @date: 2023/12/24 21:08
* @author: ZHANGLINHAO
* @param: ID
* @return:
*/
public void setWidgetId(int id) {
if (id != mWidgetId) {
mWidgetId = id;
mNote.setNoteValue(NoteColumns.WIDGET_ID, String.valueOf(mWidgetId));
}
}
/**
* @method: setWorkingText
* @description:
* @date: 2023/12/24 21:08
* @author: ZHANGLINHAO
* @param:
* @return:
*/
public void setWorkingText(String text) {
if (!TextUtils.equals(mContent, text)) {
mContent = text;
mNote.setTextData(DataColumns.CONTENT, mContent);
}
}
/**
* @method: convertToCallNote
* @description:
* @date: 2023/12/24 21:09
* @author: ZHANGLINHAO
* @param:
* @return:
*/
public void convertToCallNote(String phoneNumber, long callDate) {
mNote.setCallData(CallNote.CALL_DATE, String.valueOf(callDate));
mNote.setCallData(CallNote.PHONE_NUMBER, phoneNumber);
mNote.setNoteValue(NoteColumns.PARENT_ID, String.valueOf(Notes.ID_CALL_RECORD_FOLDER));
}
public boolean hasClockAlert() {
return (mAlertDate > 0 ? true : false);
}
public String getContent() {
return mContent;
}
public long getAlertDate() {
return mAlertDate;
}
public long getModifiedDate() {
return mModifiedDate;
}
public int getBgColorResId() {
return NoteBgResources.getNoteBgResource(mBgColorId);
}
public int getBgColorId() {
return mBgColorId;
}
public int getTitleBgResId() {
return NoteBgResources.getNoteTitleBgResource(mBgColorId);
}
public int getCheckListMode() {
return mMode;
}
public long getNoteId() {
return mNoteId;
}
public long getFolderId() {
return mFolderId;
}
public int getWidgetId() {
return mWidgetId;
}
public int getWidgetType() {
return mWidgetType;
}
public interface NoteSettingChangedListener {
/**
* Called when the background color of current note has just changed
*/
void onBackgroundColorChanged();
/**
* Called when user set clock
*/
void onClockAlertChanged(long date, boolean set);
/**
* Call when user create note from widget
*/
void onWidgetChanged();
/**
* Call when switch between check list mode and normal mode
* @param oldMode is previous mode before change
* @param newMode is new mode
*/
void onCheckListModeChanged(int oldMode, int newMode);
}
}

File diff suppressed because it is too large Load Diff

@ -31,8 +31,15 @@ import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.tool.ResourceParser;
import net.micode.notes.ui.NoteEditActivity;
import net.micode.notes.ui.NotesListActivity;
public abstract class NoteWidgetProvider extends AppWidgetProvider { //添加小米便签到安卓系统小部件
/**
* @ProjectName: NoteWidgetProvider.java
* @Package: net.micode.notes.widget
* @ClassName: NoteWidgetProvider
* @Description: 便
* @Author: ZHANGLINHAO
* @CreateDate: 2023/12/22 19:30
*/
public abstract class NoteWidgetProvider extends AppWidgetProvider {
public static final String [] PROJECTION = new String [] {
NoteColumns.ID,
NoteColumns.BG_COLOR_ID,
@ -44,35 +51,66 @@ public abstract class NoteWidgetProvider extends AppWidgetProvider { //添加小
public static final int COLUMN_SNIPPET = 2;
private static final String TAG = "NoteWidgetProvider";
@Override //子类对父类的允许访问的方法的实现过程进行重新编写, 返回值和形参都不能改变。
public void onDeleted(Context context, int[] appWidgetIds) { //onDeleted在用户从桌面上删除小部件时被调用
/**
* @method: onDeleted
* @description:onDeleted
* @date: 2023/12/22 19:36
* @author: ZHANGLINHAO
* @param: , ID
* @return:
*/
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
ContentValues values = new ContentValues();
values.put(NoteColumns.WIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
/**在小部件被删除时更新数据库将所有相关联的小部件ID标记为无效*/
for (int i = 0; i < appWidgetIds.length; i++) {
context.getContentResolver().update(Notes.CONTENT_NOTE_URI,
values,
NoteColumns.WIDGET_ID + "=?",
new String[] { String.valueOf(appWidgetIds[i])});
}
} //在小部件被删除时更新数据库将所有相关联的小部件ID标记为无效
}
/**
* @method: getNoteWidgetInfo
* @description:便
* @date: 2023/12/22 19:43
* @author: ZHANGLINHAO
* @param: , ID
* @return: context.getContentResolver().query
*/
private Cursor getNoteWidgetInfo(Context context, int widgetId) {
return context.getContentResolver().query(Notes.CONTENT_NOTE_URI,
PROJECTION,
NoteColumns.WIDGET_ID + "=? AND " + NoteColumns.PARENT_ID + "<>?",
new String[] { String.valueOf(widgetId), String.valueOf(Notes.ID_TRASH_FOLER) },
null);
} // 获取小米便签小部件的信息
}
/**
* @method: update
* @description:便
* @date: 2023/12/22 19:44
* @author: ZHANGLINHAO
* @param: , , ID
* @return:
*/
protected void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
update(context, appWidgetManager, appWidgetIds, false);
} //更新小米便签小部件信息
}
/**
* @method: update
* @description:
* @date: 2023/12/22 19:46
* @author: ZHANGLINHAO
* @param: , , ID
* @return:
*/
private void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds,
boolean privacyMode) {
for (int i = 0; i < appWidgetIds.length; i++) {//遍历所有的小部件ID然后更新每个小部件的视图和行为
if (appWidgetIds[i] != AppWidgetManager.INVALID_APPWIDGET_ID) { //判断是否无效小部件
/**遍历所有的小部件ID然后更新每个小部件的视图和行为*/
for (int i = 0; i < appWidgetIds.length; i++) {
/**判断是否无效小部件*/
if (appWidgetIds[i] != AppWidgetManager.INVALID_APPWIDGET_ID) {
int bgId = ResourceParser.getDefaultBgId(context);
String snippet = "";
Intent intent = new Intent(context, NoteEditActivity.class);
@ -81,24 +119,25 @@ public abstract class NoteWidgetProvider extends AppWidgetProvider { //添加小
intent.putExtra(Notes.INTENT_EXTRA_WIDGET_TYPE, getWidgetType());
Cursor c = getNoteWidgetInfo(context, appWidgetIds[i]);
/**检测点击信息*/
if (c != null && c.moveToFirst()) {
if (c.getCount() > 1) {
Log.e(TAG, "Multiple message with same widget id:" + appWidgetIds[i]);
c.close();
return;
} //将新数据放到数据表中
}
snippet = c.getString(COLUMN_SNIPPET);
bgId = c.getInt(COLUMN_BG_COLOR_ID);
intent.putExtra(Intent.EXTRA_UID, c.getLong(COLUMN_ID));
intent.setAction(Intent.ACTION_VIEW);
} else {
snippet = context.getResources().getString(R.string.widget_havenot_content);
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);//点击事件。没有检测到关联的小部件,点击创建
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
}
if (c != null) {
c.close();
} //关闭游标
}
RemoteViews rv = new RemoteViews(context.getPackageName(), getLayoutId());
rv.setImageViewResource(R.id.widget_bg_image, getBgResourceId(bgId));
@ -107,19 +146,20 @@ public abstract class NoteWidgetProvider extends AppWidgetProvider { //添加小
* intent
*/
PendingIntent pendingIntent = null;// 新建点击程序
/**按状态更新小部件视图*/
if (privacyMode) {
rv.setTextViewText(R.id.widget_text,
context.getString(R.string.widget_under_visit_mode));
pendingIntent = PendingIntent.getActivity(context, appWidgetIds[i], new Intent(
context, NotesListActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);// 提示处于访客模式创建新的intent变量记录活动
context, NotesListActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
} else {
rv.setTextViewText(R.id.widget_text, snippet);
pendingIntent = PendingIntent.getActivity(context, appWidgetIds[i], intent,
PendingIntent.FLAG_UPDATE_CURRENT);//直接使用已有intent记录活动
PendingIntent.FLAG_UPDATE_CURRENT);
}
rv.setOnClickPendingIntent(R.id.widget_text, pendingIntent); //为小部件文本视图设置点击程序
appWidgetManager.updateAppWidget(appWidgetIds[i], rv); // 更新小部件视图
rv.setOnClickPendingIntent(R.id.widget_text, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
}
}
}

@ -23,25 +23,32 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.tool.ResourceParser;
public class NoteWidgetProvider_2x extends NoteWidgetProvider {//扩展
/**
* @ProjectName: NoteWidgetProvider_2x.java
* @Package: net.micode.notes.widget
* @ClassName: NoteWidgetProvider_2x
* @Description: 2
* @Author: ZHANGLINHAO
* @CreateDate: 2023/12/22 19:49
*/
public class NoteWidgetProvider_2x extends NoteWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.update(context, appWidgetManager, appWidgetIds);//重写二倍大小小部件的更新函数
super.update(context, appWidgetManager, appWidgetIds);
}
@Override
protected int getLayoutId() {
return R.layout.widget_2x;
}//重写两倍大小小部件的布局文件的资源ID
}
@Override
protected int getBgResourceId(int bgId) {
return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId);//重写两倍大小小部件的背景资源的ID
return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId);
}
@Override
protected int getWidgetType() {
return Notes.TYPE_WIDGET_2X;
}//重写两倍大小小部件的小部件类型
}
}

@ -23,24 +23,31 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.tool.ResourceParser;
public class NoteWidgetProvider_4x extends NoteWidgetProvider {//扩展
/**
* @ProjectName: NoteWidgetProvider_4x.java
* @Package: net.micode.notes.widget
* @ClassName: NoteWidgetProvider_4x
* @Description: 4
* @Author: ZHANGLINHAO
* @CreateDate: 2023/12/24 19:50
*/
public class NoteWidgetProvider_4x extends NoteWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.update(context, appWidgetManager, appWidgetIds);//重写四倍大小小部件的更新函数
super.update(context, appWidgetManager, appWidgetIds);
}
protected int getLayoutId() {
return R.layout.widget_4x;
}//重写四倍大小小部件的布局文件的资源ID
}
@Override
protected int getBgResourceId(int bgId) {
return ResourceParser.WidgetBgResources.getWidget4xBgResource(bgId);//重写四倍大小小部件的背景资源的ID
return ResourceParser.WidgetBgResources.getWidget4xBgResource(bgId);
}
@Override
protected int getWidgetType() {
return Notes.TYPE_WIDGET_4X;
}//重写四倍大小小部件的小部件类型
}
}

Loading…
Cancel
Save