Compare commits

..

No commits in common. 'main' and 'master' have entirely different histories.
main ... master

@ -0,0 +1,49 @@
// 版权声明
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.
// 以下是代码部分
// 调用ContentResolver的applyBatch方法传入Authority和操作列表
// Notes.AUTHORITY是内容提供者的Authority
// operationList是包含要执行的操作的列表
// 如果操作结果为空、长度为0或第一个结果为空则返回null否则返回带有ID的笔记URI
return (results == null || results.length == 0 || results[0] == null) ? null
: ContentUris.withAppendedId(Notes.CONTENTNOTEURI, noteId);
// 捕获远程异常
catch (RemoteException e) {
// 记录远程异常错误日志
// TAG是日志的标签e.toString()是异常的字符串表示e.getMessage()是异常的消息
Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
// 返回null表示操作失败
return null;
}
// 捕获操作应用异常
catch (OperationApplicationException e) {
// 记录操作应用异常错误日志
// TAG是日志的标签e.toString()是异常的字符串表示e.getMessage()是异常的消息
Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
// 返回null表示操作失败
return null;
}
// 如果没有操作要应用则返回null
return null;

@ -0,0 +1,425 @@
/*
* 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.
*//*
* MiCodewww.micode.net
*/
/*
* Apache2.0
* 使
*
*/
/*
*
*
*
*/
package net.micode.notes.model;
// 导入AppWidgetManager类用于管理AppWidget
import android.appwidget.AppWidgetManager;
// 导入ContentUris类用于操作内容URI
import android.content.ContentUris;
// 导入Context类用于获取应用程序环境
import android.content.Context;
// 导入Cursor类用于数据库查询结果
import android.database.Cursor;
// 导入TextUtils类用于字符串操作
import android.text.TextUtils;
// 导入Log类用于日志记录
import android.util.Log;
// 导入Notes类用于操作笔记数据
import net.micode.notes.data.Notes;
// 导入Notes.CallNote类用于操作电话笔记数据
import net.micode.notes.data.Notes.CallNote;
// 导入Notes.DataColumns类用于操作笔记数据列
import net.micode.notes.data.Notes.DataColumns;
// 导入Notes.DataConstants类用于操作笔记数据常量
import net.micode.notes.data.Notes.DataConstants;
// 导入Notes.NoteColumns类用于操作笔记列
import net.micode.notes.data.Notes.NoteColumns;
// 导入Notes.TextNote类用于操作文本笔记数据
import net.micode.notes.data.Notes.TextNote;
// 导入ResourceParser.NoteBgResources类用于获取笔记背景资源
import net.micode.notes.tool.ResourceParser.NoteBgResources;
// 定义WorkingNote类用于操作工作笔记
public class WorkingNote {
// 工作笔记的Note对象
private Note mNote;
// 工作笔记的ID
private long mNoteId;
// 工作笔记的内容
private String mContent;
// 工作笔记的模式
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;
}
// 现有笔记构造函数
private WorkingNote(Context context, long noteId, long folderId) {
mContext = context;
mNoteId = noteId;
mFolderId = folderId;
mIsDeleted = false;
mNote = new Note();
loadNote();
}
// 加载笔记
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();
}
// 加载笔记数据
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);
}
}
// 创建空笔记
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;
}
// 加载笔记
public static WorkingNote load(Context context, long id) {
return new WorkingNote(context, id, 0);
}
// 保存笔记
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);
/**
*
*/
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE
&& mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onWidgetChanged();
}
return true;
} else {
return false;
}
}
// 检查笔记是否存在于数据库中
public boolean existInDatabase() {
return mNoteId > 0;
}
// 检查笔记是否值得保存
private boolean isWorthSaving() {
if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
|| (existInDatabase() && !mNote.isLocalModified())) {
return false;
} else {
return true;
}
}
// 设置设置状态更改监听器
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
mNoteSettingStatusListener = l;
}
// 设置提醒日期
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);
}
}
// 标记删除
public void markDeleted(boolean mark) {
mIsDeleted = mark;
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE && mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onWidgetChanged();
}
}
// 设置背景颜色ID
public void setBgColorId(int id) {
if (id != mBgColorId) {
mBgColorId = id;
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onBackgroundColorChanged();
}
mNote.setNoteValue(NoteColumns.BG_COLOR_ID, String.valueOf(id));
}
}
// 设置检查列表模式
public void setCheckListMode(int mode) {
if (mMode != mode) {
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onCheckListModeChanged(mMode, mode);
}
mMode = mode;
mNote.setTextData(TextNote.MODE, String.valueOf(mMode));
}
}
// 设置小部件类型
public void setWidgetType(int type) {
if (type != mWidgetType) {
mWidgetType = type;
mNote.setNoteValue(NoteColumns.WIDGET_TYPE, String.valueOf(mWidgetType));
}
}
// 设置小部件ID
public void setWidgetId(int id) {
if (id != mWidgetId) {
mWidgetId = id;
mNote.setNoteValue(NoteColumns.WIDGET_ID, String.valueOf(mWidgetId));
}
}
// 设置工作文本
public void setWorkingText(String text) {
if (!TextUtils.equals(mContent, text)) {
mContent = text;
mNote.setTextData(DataColumns.CONTENT, mContent);
}
}
// 转换为电话笔记
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;
}
// 获取背景颜色资源ID
public int getBgColorResId() {
return NoteBgResources.getNoteBgResource(mBgColorId);
}
// 获取背景颜色ID
public int getBgColorId() {
return mBgColorId;
}
// 获取标题背景资源ID
public int getTitleBgResId() {
return NoteBgResources.getNoteTitleBgResource(mBgColorId);
}
// 获取检查列表模式
public int getCheckListMode() {
return mMode;
}
// 获取笔记ID
public long getNoteId() {
return mNoteId;
}
// 获取文件夹ID
public long getFolderId() {
return mFolderId;
}
// 获取小部件ID
public int getWidgetId() {
return mWidgetId;
}
// 获取小部件类型
public int getWidgetType() {
return mWidgetType;
}
// 定义设置状态更改监听器接口
public interface NoteSettingChangedListener {
/**
*
*/
void onBackgroundColorChanged();
/**
*
*/
void onClockAlertChanged(long date, boolean set);
/**
*
*/
void onWidgetChanged();
/**
*
* @param oldMode
* @param newMode
*/
void onCheckListModeChanged(int oldMode, int newMode);
}
}

@ -0,0 +1,146 @@
/*
* 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.
*/
/*
* MiCodewww.micode.net
*
* Apache2.0
* 使
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
*
*
*
*/
package net.micode.notes.widget; // 定义包名表示这个类属于net.micode.notes.widget包
import android.app.PendingIntent; // 导入PendingIntent类用于创建延迟执行的操作
import android.appwidget.AppWidgetManager; // 导入AppWidgetManager类用于管理App Widget
import android.appwidget.AppWidgetProvider; // 导入AppWidgetProvider类提供App Widget的基本功能
import android.content.ContentValues; // 导入ContentValues类用于存储键值对数据
import android.content.Context; // 导入Context类提供对应用环境的访问
import android.content.Intent; // 导入Intent类用于启动活动或服务
import android.database.Cursor; // 导入Cursor类用于遍历查询结果
import android.util.Log; // 导入Log类用于日志记录
import android.widget.RemoteViews; // 导入RemoteViews类用于在App Widget中显示视图
import net.micode.notes.R; // 导入R类包含应用的所有资源ID
import net.micode.notes.data.Notes; // 导入Notes类包含笔记数据的相关操作
import net.micode.notes.data.Notes.NoteColumns; // 导入NoteColumns类包含笔记数据的列定义
import net.micode.notes.tool.ResourceParser; // 导入ResourceParser类用于解析资源
import net.micode.notes.ui.NoteEditActivity; // 导入NoteEditActivity类用于编辑笔记
import net.micode.notes.ui.NotesListActivity; // 导入NotesListActivity类用于显示笔记列表
public abstract class NoteWidgetProvider extends AppWidgetProvider { // 定义NoteWidgetProvider类继承自AppWidgetProvider
public static final String [] PROJECTION = new String [] { // 定义一个字符串数组,用于查询笔记数据
NoteColumns.ID, // 笔记ID
NoteColumns.BG_COLOR_ID, // 背景颜色ID
NoteColumns.SNIPPET // 笔记摘要
};
public static final int COLUMN_ID = 0; // 定义常量表示ID列的索引
public static final int COLUMN_BG_COLOR_ID = 1; // 定义常量表示背景颜色ID列的索引
public static final int COLUMN_SNIPPET = 2; // 定义常量,表示摘要列的索引
private static final String TAG = "NoteWidgetProvider"; // 定义日志标签
@Override
public void onDeleted(Context context, int[] appWidgetIds) { // 重写onDeleted方法当App Widget被删除时调用
ContentValues values = new ContentValues(); // 创建ContentValues对象用于存储更新数据
values.put(NoteColumns.WIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); // 设置Widget ID为无效值
for (int i = 0; i < appWidgetIds.length; i++) { // 遍历所有被删除的App Widget ID
context.getContentResolver().update(Notes.CONTENT_NOTE_URI, // 更新笔记数据
values, // 更新数据
NoteColumns.WIDGET_ID + "=?", // 更新条件
new String[] { String.valueOf(appWidgetIds[i])}); // 更新条件参数
}
}
private Cursor getNoteWidgetInfo(Context context, int widgetId) { // 定义方法获取指定Widget的笔记信息
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); // 排序条件
}
protected void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // 定义方法更新App Widget
update(context, appWidgetManager, appWidgetIds, false); // 调用重载方法,默认不启用隐私模式
}
private void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds,
boolean privacyMode) { // 定义方法更新App Widget支持隐私模式
for (int i = 0; i < appWidgetIds.length; i++) { // 遍历所有App Widget ID
if (appWidgetIds[i] != AppWidgetManager.INVALID_APPWIDGET_ID) { // 检查Widget ID是否有效
int bgId = ResourceParser.getDefaultBgId(context); // 获取默认背景颜色ID
String snippet = ""; // 初始化笔记摘要
Intent intent = new Intent(context, NoteEditActivity.class); // 创建Intent用于启动NoteEditActivity
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); // 设置Intent标志确保只启动一个实例
intent.putExtra(Notes.INTENT_EXTRA_WIDGET_ID, appWidgetIds[i]); // 添加Widget ID到Intent
intent.putExtra(Notes.INTENT_EXTRA_WIDGET_TYPE, getWidgetType()); // 添加Widget类型到Intent
Cursor c = getNoteWidgetInfo(context, appWidgetIds[i]); // 获取指定Widget的笔记信息
if (c != null && c.moveToFirst()) { // 检查Cursor是否有效并移动到第一行
if (c.getCount() > 1) { // 检查是否有多个笔记
Log.e(TAG, "Multiple message with same widget id:" + appWidgetIds[i]); // 记录错误日志
c.close(); // 关闭Cursor
return; // 返回
}
snippet = c.getString(COLUMN_SNIPPET); // 获取笔记摘要
bgId = c.getInt(COLUMN_BG_COLOR_ID); // 获取背景颜色ID
intent.putExtra(Intent.EXTRA_UID, c.getLong(COLUMN_ID)); // 添加笔记ID到Intent
intent.setAction(Intent.ACTION_VIEW); // 设置Intent动作
} else {
snippet = context.getResources().getString(R.string.widget_havenot_content); // 获取默认摘要
intent.setAction(Intent.ACTION_INSERT_OR_EDIT); // 设置Intent动作
}
if (c != null) { // 检查Cursor是否有效
c.close(); // 关闭Cursor
}
RemoteViews rv = new RemoteViews(context.getPackageName(), getLayoutId()); // 创建RemoteViews对象
rv.setImageViewResource(R.id.widget_bg_image, getBgResourceId(bgId)); // 设置背景图片资源
intent.putExtra(Notes.INTENT_EXTRA_BACKGROUND_ID, bgId); // 添加背景颜色ID到Intent
/**
* 宿ActivityPendingIntent
*/
PendingIntent pendingIntent = null; // 初始化PendingIntent
if (privacyMode) { // 检查是否启用隐私模式
rv.setTextViewText(R.id.widget_text, // 设置文本视图文本
context.getString(R.string.widget_under_visit_mode)); // 获取隐私模式文本
pendingIntent = PendingIntent.getActivity(context, appWidgetIds[i], new Intent( // 创建PendingIntent
context, NotesListActivity.class), PendingIntent.FLAG_UPDATE_CURRENT); // 启动NotesListActivity
} else {
rv.setTextViewText(R.id.widget_text, snippet); // 设置文本视图文本为笔记摘要
pendingIntent = PendingIntent.getActivity(context, appWidgetIds[i], intent, // 创建PendingIntent
PendingIntent.FLAG_UPDATE_CURRENT); // 启动NoteEditActivity
}
rv.setOnClickPendingIntent(R.id.widget_text, pendingIntent); // 设置点击事件
appWidgetManager.updateAppWidget(appWidgetIds[i], rv); // 更新App Widget
}
}
}
protected abstract int getBgResourceId(int bgId); // 定义抽象方法获取背景资源ID
protected abstract int getLayoutId(); // 定义抽象方法获取布局资源ID
protected abstract int getWidgetType(); // 定义抽象方法获取Widget类型
}

@ -0,0 +1,64 @@
/*
* 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.
*/
/*
* MiCodewww.micode.net
*/
/*
* Apache2.0
* 使
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
*
*
*
*/
package net.micode.notes.widget; // 定义包名表示这个类属于net.micode.notes.widget包
import android.appwidget.AppWidgetManager; // 导入AppWidgetManager类用于管理App Widget
import android.content.Context; // 导入Context类提供对应用环境的访问
import net.micode.notes.R; // 导入R类包含应用的所有资源ID
import net.micode.notes.data.Notes; // 导入Notes类用于处理笔记数据
import net.micode.notes.tool.ResourceParser; // 导入ResourceParser类用于解析资源
public class NoteWidgetProvider_2x extends NoteWidgetProvider { // 定义NoteWidgetProvider_2x类继承自NoteWidgetProvider
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// 重写onUpdate方法当App Widget需要更新时调用
super.update(context, appWidgetManager, appWidgetIds); // 调用父类的update方法进行更新
}
@Override
protected int getLayoutId() {
// 重写getLayoutId方法返回布局资源的ID
return R.layout.widget_2x; // 返回widget_2x布局资源的ID
}
@Override
protected int getBgResourceId(int bgId) {
// 重写getBgResourceId方法根据传入的背景ID返回对应的背景资源ID
return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId); // 使用ResourceParser获取2x尺寸的背景资源
}
@Override
protected int getWidgetType() {
// 重写getWidgetType方法返回Widget的类型
return Notes.TYPE_WIDGET_2X; // 返回Notes.TYPE_WIDGET_2X表示这是一个2x尺寸的Widget
}
}

@ -0,0 +1,60 @@
/*
* 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.
*/
/*
* MiCodewww.micode.net
*
* Apache2.0
* 使
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
*
*
*
*/
package net.micode.notes.widget; // 定义包名表示这个类属于net.micode.notes.widget包
import android.appwidget.AppWidgetManager; // 导入AppWidgetManager类用于管理App Widget
import android.content.Context; // 导入Context类提供对应用环境的访问
import net.micode.notes.R; // 导入R类包含应用的所有资源ID
import net.micode.notes.data.Notes; // 导入Notes类可能包含笔记相关的数据和方法
import net.micode.notes.tool.ResourceParser; // 导入ResourceParser类用于解析资源
public class NoteWidgetProvider_4x extends NoteWidgetProvider { // 定义NoteWidgetProvider_4x类继承自NoteWidgetProvider
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // 重写onUpdate方法用于更新App Widget
super.update(context, appWidgetManager, appWidgetIds); // 调用父类的update方法进行实际的更新操作
}
protected int getLayoutId() { // 定义getLayoutId方法用于获取布局资源的ID
return R.layout.widget_4x; // 返回4x尺寸Widget的布局资源ID
}
@Override
protected int getBgResourceId(int bgId) { // 重写getBgResourceId方法根据传入的背景ID返回对应的背景资源ID
return ResourceParser.WidgetBgResources.getWidget4xBgResource(bgId); // 调用ResourceParser的getWidget4xBgResource方法获取4x尺寸Widget的背景资源ID
}
@Override
protected int getWidgetType() { // 重写getWidgetType方法返回Widget的类型
return Notes.TYPE_WIDGET_4X; // 返回4x尺寸Widget的类型
}
}

@ -1,2 +0,0 @@
# WXYMZX1
Loading…
Cancel
Save