代码注释

Signed-off-by: 王润泽 <3254719436@qq.com>
pull/8/head
王润泽 2 years ago
parent ee9e7d0bb3
commit 8f4fa66623

@ -1,3 +0,0 @@
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Android API 33, extension level 3 Platform" project-jdk-type="Android SDK" />
</project>

@ -59,7 +59,12 @@ import java.util.List;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater; import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream; import java.util.zip.InflaterInputStream;
/**
* @classname: GTaskClient
* @description:GTASKGTASK
* @date: 2024/1/4 11:21
* @author: wangrunze
*/
public class GTaskClient { public class GTaskClient {
private static final String TAG = GTaskClient.class.getSimpleName(); private static final String TAG = GTaskClient.class.getSimpleName();
@ -101,17 +106,32 @@ public class GTaskClient {
mAccount = null; mAccount = null;
mUpdateArray = null; mUpdateArray = null;
} }
/**
* @classname: GTaskClient
* @methodname: getInstance
* @description:
* @date: 2024/1/4 11:22
* @author: wangrunze
*/
public static synchronized GTaskClient getInstance() { public static synchronized GTaskClient getInstance() {
if (mInstance == null) { if (mInstance == null) {
mInstance = new GTaskClient(); mInstance = new GTaskClient();
} }
return mInstance; return mInstance;
} }
/**
* @classname: GTaskClient
* @methodname: login
* @description:
* @date: 2024/1/4 11:22
* @author: wangrunze
* @param:Activity activity
* @return:true/false
*/
public boolean login(Activity activity) { public boolean login(Activity activity) {
// we suppose that the cookie would expire after 5 minutes // we suppose that the cookie would expire after 5 minutes
// then we need to re-login // then we need to re-login
//判断距离最后一次登录操作是否超过5分钟
final long interval = 1000 * 60 * 5; final long interval = 1000 * 60 * 5;
if (mLastLoginTime + interval < System.currentTimeMillis()) { if (mLastLoginTime + interval < System.currentTimeMillis()) {
mLoggedin = false; mLoggedin = false;
@ -126,6 +146,7 @@ public class GTaskClient {
if (mLoggedin) { if (mLoggedin) {
Log.d(TAG, "already logged in"); Log.d(TAG, "already logged in");
//如果没超过时间,则不需要重新登录
return true; return true;
} }
@ -135,7 +156,7 @@ public class GTaskClient {
Log.e(TAG, "login google account failed"); Log.e(TAG, "login google account failed");
return false; return false;
} }
//使用用户自己的域名登录
// login with custom domain if necessary // login with custom domain if necessary
if (!(mAccount.name.toLowerCase().endsWith("gmail.com") || mAccount.name.toLowerCase() if (!(mAccount.name.toLowerCase().endsWith("gmail.com") || mAccount.name.toLowerCase()
.endsWith("googlemail.com"))) { .endsWith("googlemail.com"))) {
@ -151,6 +172,7 @@ public class GTaskClient {
} }
} }
//如果用户账户无法登录则使用谷歌官方的URI进行登录
// try to login with google official url // try to login with google official url
if (!mLoggedin) { if (!mLoggedin) {
mGetUrl = GTASK_GET_URL; mGetUrl = GTASK_GET_URL;
@ -163,7 +185,16 @@ public class GTaskClient {
mLoggedin = true; mLoggedin = true;
return true; return true;
} }
/**
* @classname: GTaskClient
* @methodname: loginGoogleAccount
* @description:使
* @date: 2024/1/4 11:24
* @author: wangrunze
* @param:Activity activity
* @param:boolean invalidateToken
* @return:
*/
private String loginGoogleAccount(Activity activity, boolean invalidateToken) { private String loginGoogleAccount(Activity activity, boolean invalidateToken) {
String authToken; String authToken;
AccountManager accountManager = AccountManager.get(activity); AccountManager accountManager = AccountManager.get(activity);
@ -188,7 +219,7 @@ public class GTaskClient {
Log.e(TAG, "unable to get an account with the same name in the settings"); Log.e(TAG, "unable to get an account with the same name in the settings");
return null; return null;
} }
//获取选中账号的令牌
// get the token now // get the token now
AccountManagerFuture<Bundle> accountManagerFuture = accountManager.getAuthToken(account, AccountManagerFuture<Bundle> accountManagerFuture = accountManager.getAuthToken(account,
"goanna_mobile", null, activity, null, null); "goanna_mobile", null, activity, null, null);
@ -206,7 +237,16 @@ public class GTaskClient {
return authToken; return authToken;
} }
/**
* @classname: GTaskClient
* @methodname: tryToLoginGtask
* @description:GTask
* @date: 2024/1/4 11:25
* @author: wangrunze
* @param:Activity activity
* @param:String authToken
* @return:true/false
*/
private boolean tryToLoginGtask(Activity activity, String authToken) { private boolean tryToLoginGtask(Activity activity, String authToken) {
if (!loginGtask(authToken)) { if (!loginGtask(authToken)) {
// maybe the auth token is out of date, now let's invalidate the // maybe the auth token is out of date, now let's invalidate the
@ -224,7 +264,14 @@ public class GTaskClient {
} }
return true; return true;
} }
/**
* @classname: GTaskClient
* @methodname: loginGtask
* @description:GTask
* @date: 2024/1/4 11:26
* @author: wangrunze
* @param:String authToken
*/
private boolean loginGtask(String authToken) { private boolean loginGtask(String authToken) {
int timeoutConnection = 10000; int timeoutConnection = 10000;
int timeoutSocket = 15000; int timeoutSocket = 15000;
@ -238,11 +285,11 @@ public class GTaskClient {
// login gtask // login gtask
try { try {
String loginUrl = mGetUrl + "?auth=" + authToken; String loginUrl = mGetUrl + "?auth=" + authToken;//设置登录的url
HttpGet httpGet = new HttpGet(loginUrl); HttpGet httpGet = new HttpGet(loginUrl);//通过登录的uri实例化网页上资源的查找
HttpResponse response = null; HttpResponse response = null;
response = mHttpClient.execute(httpGet); response = mHttpClient.execute(httpGet);
//获取CookieStore里存放的cookie
// get the cookie now // get the cookie now
List<Cookie> cookies = mHttpClient.getCookieStore().getCookies(); List<Cookie> cookies = mHttpClient.getCookieStore().getCookies();
boolean hasAuthCookie = false; boolean hasAuthCookie = false;
@ -254,7 +301,7 @@ public class GTaskClient {
if (!hasAuthCookie) { if (!hasAuthCookie) {
Log.w(TAG, "it seems that there is no auth cookie"); Log.w(TAG, "it seems that there is no auth cookie");
} }
//获取client的内容
// get the client version // get the client version
String resString = getResponseContent(response.getEntity()); String resString = getResponseContent(response.getEntity());
String jsBegin = "_setup("; String jsBegin = "_setup(";
@ -283,14 +330,29 @@ public class GTaskClient {
private int getActionId() { private int getActionId() {
return mActionId++; return mActionId++;
} }
/**
* @classname: GTaskClient
* @methodname: createHttpPost
* @description:
* @date: 2024/1/4 11:28
* @author: wangrunze
* @return:httpPost
*/
private HttpPost createHttpPost() { private HttpPost createHttpPost() {
HttpPost httpPost = new HttpPost(mPostUrl); HttpPost httpPost = new HttpPost(mPostUrl);
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8"); httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
httpPost.setHeader("AT", "1"); httpPost.setHeader("AT", "1");
return httpPost; return httpPost;
} }
/**
* @classname: GTaskClient
* @methodname: getResponseContent
* @description:
* @date: 2024/1/4 11:29
* @author: wangrunze
* @param:HttpEntity entity
* @return:
*/
private String getResponseContent(HttpEntity entity) throws IOException { private String getResponseContent(HttpEntity entity) throws IOException {
String contentEncoding = null; String contentEncoding = null;
if (entity.getContentEncoding() != null) { if (entity.getContentEncoding() != null) {
@ -322,7 +384,15 @@ public class GTaskClient {
input.close(); input.close();
} }
} }
/**
* @classname: GTaskClient
* @methodname: postRequest
* @description: JSON
* @date: 2024/1/4 11:30
* @author: wangrunze
* @param:JSONObject js
* @return:JSONObject
*/
private JSONObject postRequest(JSONObject js) throws NetworkFailureException { private JSONObject postRequest(JSONObject js) throws NetworkFailureException {
if (!mLoggedin) { if (!mLoggedin) {
Log.e(TAG, "please login first"); Log.e(TAG, "please login first");
@ -359,7 +429,14 @@ public class GTaskClient {
throw new ActionFailureException("error occurs when posting request"); throw new ActionFailureException("error occurs when posting request");
} }
} }
/**
* @classname: GTaskClient
* @methodname: createTask
* @description:
* @date: 2024/1/4 11:31
* @author: wangrunze
* @param:Task task
*/
public void createTask(Task task) throws NetworkFailureException { public void createTask(Task task) throws NetworkFailureException {
commitUpdate(); commitUpdate();
try { try {
@ -385,7 +462,14 @@ public class GTaskClient {
throw new ActionFailureException("create task: handing jsonobject failed"); throw new ActionFailureException("create task: handing jsonobject failed");
} }
} }
/**
* @classname: GTaskClient
* @methodname: createTaskList
* @description:
* @date: 2024/1/4 11:31
* @author: wangrunze
* @param:TaskList tasklist
*/
public void createTaskList(TaskList tasklist) throws NetworkFailureException { public void createTaskList(TaskList tasklist) throws NetworkFailureException {
commitUpdate(); commitUpdate();
try { try {
@ -411,7 +495,13 @@ public class GTaskClient {
throw new ActionFailureException("create tasklist: handing jsonobject failed"); throw new ActionFailureException("create tasklist: handing jsonobject failed");
} }
} }
/**
* @classname: GTaskClient
* @methodname: commitUpdate
* @description:
* @date: 2024/1/4 11:32
* @author: wangrunze
*/
public void commitUpdate() throws NetworkFailureException { public void commitUpdate() throws NetworkFailureException {
if (mUpdateArray != null) { if (mUpdateArray != null) {
try { try {
@ -432,7 +522,14 @@ public class GTaskClient {
} }
} }
} }
/**
* @classname: GTaskClient
* @methodname: addUpdateNode
* @description:
* @date: 2024/1/4 11:32
* @author: wangrunze
* @param:Node node
*/
public void addUpdateNode(Node node) throws NetworkFailureException { public void addUpdateNode(Node node) throws NetworkFailureException {
if (node != null) { if (node != null) {
// too many update items may result in an error // too many update items may result in an error
@ -446,7 +543,16 @@ public class GTaskClient {
mUpdateArray.put(node.getUpdateAction(getActionId())); mUpdateArray.put(node.getUpdateAction(getActionId()));
} }
} }
/**
* @classname: GTaskClient
* @methodname: moveTask
* @description:task
* @date: 2024/1/4 11:32
* @author: wangrunze
* @param:Task task
* @param:TaskList preParent
* @param:TaskList curParent
*/
public void moveTask(Task task, TaskList preParent, TaskList curParent) public void moveTask(Task task, TaskList preParent, TaskList curParent)
throws NetworkFailureException { throws NetworkFailureException {
commitUpdate(); commitUpdate();
@ -485,7 +591,14 @@ public class GTaskClient {
throw new ActionFailureException("move task: handing jsonobject failed"); throw new ActionFailureException("move task: handing jsonobject failed");
} }
} }
/**
* @classname: GTaskClient
* @methodname: deleteNode
* @description:
* @date: 2024/1/4 11:33
* @author: wangrunze
* @param:Node node
*/
public void deleteNode(Node node) throws NetworkFailureException { public void deleteNode(Node node) throws NetworkFailureException {
commitUpdate(); commitUpdate();
try { try {
@ -508,7 +621,13 @@ public class GTaskClient {
throw new ActionFailureException("delete node: handing jsonobject failed"); throw new ActionFailureException("delete node: handing jsonobject failed");
} }
} }
/**
* @classname: GTaskClient
* @methodname: getTaskLists
* @description:
* @date: 2024/1/4 11:34
* @author: wangrunze
*/
public JSONArray getTaskLists() throws NetworkFailureException { public JSONArray getTaskLists() throws NetworkFailureException {
if (!mLoggedin) { if (!mLoggedin) {
Log.e(TAG, "please login first"); Log.e(TAG, "please login first");
@ -546,7 +665,14 @@ public class GTaskClient {
throw new ActionFailureException("get task lists: handing jasonobject failed"); throw new ActionFailureException("get task lists: handing jasonobject failed");
} }
} }
/**
* @classname: GTaskClient
* @methodname: getTaskList
* @description:
* @date: 2024/1/4 11:34
* @author: wangrunze
* @param:String listGid
*/
public JSONArray getTaskList(String listGid) throws NetworkFailureException { public JSONArray getTaskList(String listGid) throws NetworkFailureException {
commitUpdate(); commitUpdate();
try { try {

@ -47,7 +47,12 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
/**
* @classname: GTaskManager
* @description:gtask
* @date: 2024/1/4 11:36
* @author: wangrunze
*/
public class GTaskManager { public class GTaskManager {
private static final String TAG = GTaskManager.class.getSimpleName(); private static final String TAG = GTaskManager.class.getSimpleName();
@ -87,7 +92,7 @@ public class GTaskManager {
private HashMap<Long, String> mNidToGid; private HashMap<Long, String> mNidToGid;
private GTaskManager() { private GTaskManager() {//对象初始化函数
mSyncing = false; mSyncing = false;
mCancelled = false; mCancelled = false;
mGTaskListHashMap = new HashMap<String, TaskList>(); mGTaskListHashMap = new HashMap<String, TaskList>();
@ -98,19 +103,41 @@ public class GTaskManager {
mGidToNid = new HashMap<String, Long>(); mGidToNid = new HashMap<String, Long>();
mNidToGid = new HashMap<Long, String>(); mNidToGid = new HashMap<Long, String>();
} }
/**
* @classname: GTaskManager
* @methodname: getInstance
* @description:
* @date: 2024/1/4 11:37
* @author: wangrunze
*/
public static synchronized GTaskManager getInstance() { public static synchronized GTaskManager getInstance() {
if (mInstance == null) { if (mInstance == null) {
mInstance = new GTaskManager(); mInstance = new GTaskManager();
} }
return mInstance; return mInstance;
} }
/**
* @classname: GTaskManager
* @methodname: setActivityContext
* @description:线
* @date: 2024/1/4 11:38
* @author: wangrunze
* @param:Activity activity
*/
public synchronized void setActivityContext(Activity activity) { public synchronized void setActivityContext(Activity activity) {
// used for getting authtoken // used for getting authtoken
mActivity = activity; mActivity = activity;
} }
/**
* @classname: GTaskManager
* @methodname: sync
* @description:
* @date: 2024/1/4 11:38
* @author: wangrunze
* @param:Context context
* @param:GTaskASyncTask asyncTask
*/
public int sync(Context context, GTaskASyncTask asyncTask) { public int sync(Context context, GTaskASyncTask asyncTask) {
if (mSyncing) { if (mSyncing) {
Log.d(TAG, "Sync is in progress"); Log.d(TAG, "Sync is in progress");
@ -128,14 +155,14 @@ public class GTaskManager {
mNidToGid.clear(); mNidToGid.clear();
try { try {
GTaskClient client = GTaskClient.getInstance(); GTaskClient client = GTaskClient.getInstance();//getInstance即为创建一个实例
client.resetUpdateArray(); client.resetUpdateArray();
// login google task // login google task
if (!mCancelled) { if (!mCancelled) {
if (!client.login(mActivity)) { if (!client.login(mActivity)) {
throw new NetworkFailureException("login google task failed"); throw new NetworkFailureException("login google task failed");
} }//获取Google上的JSONtasklist转为本地TaskList
} }
// get the task list from google // get the task list from google
@ -167,7 +194,13 @@ public class GTaskManager {
return mCancelled ? STATE_SYNC_CANCELLED : STATE_SUCCESS; return mCancelled ? STATE_SYNC_CANCELLED : STATE_SUCCESS;
} }
/**
* @classname: GTaskManager
* @methodname: initGTaskList
* @description:GtaskList
* @date: 2024/1/4 11:41
* @author: wangrunze
*/
private void initGTaskList() throws NetworkFailureException { private void initGTaskList() throws NetworkFailureException {
if (mCancelled) if (mCancelled)
return; return;
@ -246,7 +279,13 @@ public class GTaskManager {
throw new ActionFailureException("initGTaskList: handing JSONObject failed"); throw new ActionFailureException("initGTaskList: handing JSONObject failed");
} }
} }
/**
* @classname: GTaskManager
* @methodname: syncContent
* @description:
* @date: 2024/1/4 11:41
* @author: wangrunze
*/
private void syncContent() throws NetworkFailureException { private void syncContent() throws NetworkFailureException {
int syncType; int syncType;
Cursor c = null; Cursor c = null;
@ -350,7 +389,13 @@ public class GTaskManager {
} }
} }
/**
* @classname: GTaskManager
* @methodname: syncFolder
* @description:
* @date: 2024/1/4 11:42
* @author: wangrunze
*/
private void syncFolder() throws NetworkFailureException { private void syncFolder() throws NetworkFailureException {
Cursor c = null; Cursor c = null;
String gid; String gid;
@ -475,7 +520,16 @@ public class GTaskManager {
if (!mCancelled) if (!mCancelled)
GTaskClient.getInstance().commitUpdate(); GTaskClient.getInstance().commitUpdate();
} }
/**
* @classname: GTaskManager
* @methodname: doContentSync
* @description:syncType
* @date: 2024/1/4 11:43
* @author: wangrunze
* @param:int syncType
* @param:Node node
* @param: Cursor c
*/
private void doContentSync(int syncType, Node node, Cursor c) throws NetworkFailureException { private void doContentSync(int syncType, Node node, Cursor c) throws NetworkFailureException {
if (mCancelled) { if (mCancelled) {
return; return;
@ -521,7 +575,14 @@ public class GTaskManager {
throw new ActionFailureException("unkown sync action type"); throw new ActionFailureException("unkown sync action type");
} }
} }
/**
* @classname: GTaskManager
* @methodname: addLocalNode
* @description:Node
* @date: 2024/1/4 11:43
* @author: wangrunze
* @param:Node node
*/
private void addLocalNode(Node node) throws NetworkFailureException { private void addLocalNode(Node node) throws NetworkFailureException {
if (mCancelled) { if (mCancelled) {
return; return;
@ -595,7 +656,15 @@ public class GTaskManager {
// update meta // update meta
updateRemoteMeta(node.getGid(), sqlNote); updateRemoteMeta(node.getGid(), sqlNote);
} }
/**
* @classname: GTaskManager
* @methodname: updateLocalNode
* @description:node
* @date: 2024/1/4 11:44
* @author: wangrunze
* @param:Node node
* @param:Cursor cCursor c
*/
private void updateLocalNode(Node node, Cursor c) throws NetworkFailureException { private void updateLocalNode(Node node, Cursor c) throws NetworkFailureException {
if (mCancelled) { if (mCancelled) {
return; return;
@ -618,7 +687,15 @@ public class GTaskManager {
// update meta info // update meta info
updateRemoteMeta(node.getGid(), sqlNote); updateRemoteMeta(node.getGid(), sqlNote);
} }
/**
* @classname: GTaskManager
* @methodname: addRemoteNode
* @description:Node
* @date: 2024/1/4 11:44
* @author: wangrunze
* @param:Node node
* @param:Cursor c
*/
private void addRemoteNode(Node node, Cursor c) throws NetworkFailureException { private void addRemoteNode(Node node, Cursor c) throws NetworkFailureException {
if (mCancelled) { if (mCancelled) {
return; return;
@ -691,7 +768,15 @@ public class GTaskManager {
mGidToNid.put(n.getGid(), sqlNote.getId()); mGidToNid.put(n.getGid(), sqlNote.getId());
mNidToGid.put(sqlNote.getId(), n.getGid()); mNidToGid.put(sqlNote.getId(), n.getGid());
} }
/**
* @classname: GTaskManager
* @methodname: updateRemoteNode
* @description:Node
* @date: 2024/1/4 11:45
* @author: wangrunze
* @param:Node node
* @param:Cursor c
*/
private void updateRemoteNode(Node node, Cursor c) throws NetworkFailureException { private void updateRemoteNode(Node node, Cursor c) throws NetworkFailureException {
if (mCancelled) { if (mCancelled) {
return; return;
@ -729,7 +814,15 @@ public class GTaskManager {
sqlNote.resetLocalModified(); sqlNote.resetLocalModified();
sqlNote.commit(true); sqlNote.commit(true);
} }
/**
* @classname: GTaskManager
* @methodname: updateRemoteMeta
* @description:meta
* @date: 2024/1/4 11:45
* @author: wangrunze
* @param:String gid
* @param:SqlNote sqlNote
*/
private void updateRemoteMeta(String gid, SqlNote sqlNote) throws NetworkFailureException { private void updateRemoteMeta(String gid, SqlNote sqlNote) throws NetworkFailureException {
if (sqlNote != null && sqlNote.isNoteType()) { if (sqlNote != null && sqlNote.isNoteType()) {
MetaData metaData = mMetaHashMap.get(gid); MetaData metaData = mMetaHashMap.get(gid);
@ -745,7 +838,13 @@ public class GTaskManager {
} }
} }
} }
/**
* @classname: GTaskManager
* @methodname: refreshLocalSyncId
* @description:
* @date: 2024/1/4 11:46
* @author: wangrunze
*/
private void refreshLocalSyncId() throws NetworkFailureException { private void refreshLocalSyncId() throws NetworkFailureException {
if (mCancelled) { if (mCancelled) {
return; return;
@ -789,11 +888,23 @@ public class GTaskManager {
} }
} }
} }
/**
* @classname: GTaskManager
* @methodname: getSyncAccount
* @description:
* @date: 2024/1/4 11:47
* @author: wangrunze
*/
public String getSyncAccount() { public String getSyncAccount() {
return GTaskClient.getInstance().getSyncAccount().name; return GTaskClient.getInstance().getSyncAccount().name;
} }
/**
* @classname: GTaskManager
* @methodname: cancelSync
* @description:
* @date: 2024/1/4 11:48
* @author: wangrunze
*/
public void cancelSync() { public void cancelSync() {
mCancelled = true; mCancelled = true;
} }

@ -22,7 +22,12 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
/**
* @classname: GTaskSyncService
* @description:
* @date: 2024/1/4 11:50
* @author: wangrunze
*/
public class GTaskSyncService extends Service { public class GTaskSyncService extends Service {
public final static String ACTION_STRING_NAME = "sync_action_type"; public final static String ACTION_STRING_NAME = "sync_action_type";
@ -41,7 +46,13 @@ public class GTaskSyncService extends Service {
private static GTaskASyncTask mSyncTask = null; private static GTaskASyncTask mSyncTask = null;
private static String mSyncProgress = ""; private static String mSyncProgress = "";
/**
* @classname: GTaskSyncService
* @methodname: startSync
* @description:
* @date: 2024/1/4 11:52
* @author: wangrunze
*/
private void startSync() { private void startSync() {
if (mSyncTask == null) { if (mSyncTask == null) {
mSyncTask = new GTaskASyncTask(this, new GTaskASyncTask.OnCompleteListener() { mSyncTask = new GTaskASyncTask(this, new GTaskASyncTask.OnCompleteListener() {
@ -55,18 +66,36 @@ public class GTaskSyncService extends Service {
mSyncTask.execute(); mSyncTask.execute();
} }
} }
/**
* @classname: GTaskSyncService
* @methodname: cancelSync
* @description:
* @date: 2024/1/4 11:53
* @author: wangrunze
*/
private void cancelSync() { private void cancelSync() {
if (mSyncTask != null) { if (mSyncTask != null) {
mSyncTask.cancelSync(); mSyncTask.cancelSync();
} }
} }
/**
* @classname: GTaskSyncService
* @methodname: onCreate
* @description:service
* @date: 2024/1/4 11:53
* @author: wangrunze
*/
@Override @Override
public void onCreate() { public void onCreate() {
mSyncTask = null; mSyncTask = null;
} }
/**
* @classname: GTaskSyncService
* @methodname: onStartCommand
* @description:service
* @date: 2024/1/4 11:54
* @author: wangrunze
*/
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
Bundle bundle = intent.getExtras(); Bundle bundle = intent.getExtras();
@ -85,7 +114,13 @@ public class GTaskSyncService extends Service {
} }
return super.onStartCommand(intent, flags, startId); return super.onStartCommand(intent, flags, startId);
} }
/**
* @classname: GTaskSyncService
* @methodname: onLowMemory
* @description:
* @date: 2024/1/4 11:54
* @author: wangrunze
*/
@Override @Override
public void onLowMemory() { public void onLowMemory() {
if (mSyncTask != null) { if (mSyncTask != null) {
@ -96,7 +131,14 @@ public class GTaskSyncService extends Service {
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
return null; return null;
} }
/**
* @classname: GTaskSyncService
* @methodname: sendBroadcast
* @description:广
* @date: 2024/1/4 11:55
* @author: wangrunze
* @param:String msg
*/
public void sendBroadcast(String msg) { public void sendBroadcast(String msg) {
mSyncProgress = msg; mSyncProgress = msg;
Intent intent = new Intent(GTASK_SERVICE_BROADCAST_NAME); Intent intent = new Intent(GTASK_SERVICE_BROADCAST_NAME);
@ -105,13 +147,28 @@ public class GTaskSyncService extends Service {
sendBroadcast(intent); sendBroadcast(intent);
} }
/**
* @classname: GTaskSyncService
* @methodname: startSync
* @description:service
* @date: 2024/1/4 11:56
* @author: wangrunze
* @param:Activity activity
*/
public static void startSync(Activity activity) { public static void startSync(Activity activity) {
GTaskManager.getInstance().setActivityContext(activity); GTaskManager.getInstance().setActivityContext(activity);
Intent intent = new Intent(activity, GTaskSyncService.class); Intent intent = new Intent(activity, GTaskSyncService.class);
intent.putExtra(GTaskSyncService.ACTION_STRING_NAME, GTaskSyncService.ACTION_START_SYNC); intent.putExtra(GTaskSyncService.ACTION_STRING_NAME, GTaskSyncService.ACTION_START_SYNC);
activity.startService(intent); activity.startService(intent);
} }
/**
* @classname: GTaskSyncService
* @methodname: cancelSync
* @description:service
* @date: 2024/1/4 11:56
* @author: wangrunze
* @param:Context context
*/
public static void cancelSync(Context context) { public static void cancelSync(Context context) {
Intent intent = new Intent(context, GTaskSyncService.class); Intent intent = new Intent(context, GTaskSyncService.class);
intent.putExtra(GTaskSyncService.ACTION_STRING_NAME, GTaskSyncService.ACTION_CANCEL_SYNC); intent.putExtra(GTaskSyncService.ACTION_STRING_NAME, GTaskSyncService.ACTION_CANCEL_SYNC);

@ -14,200 +14,199 @@
* limitations under the License. * limitations under the License.
*/ */
package net.micode.notes.ui; package net.micode.notes.ui;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnDismissListener;
import android.content.Intent; import android.content.Intent;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.media.RingtoneManager; import android.media.RingtoneManager;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.provider.Settings; import android.provider.Settings;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import net.micode.notes.R; import net.micode.notes.R;
import net.micode.notes.data.Notes; import net.micode.notes.data.Notes;
import net.micode.notes.tool.DataUtils; import net.micode.notes.tool.DataUtils;
import java.io.IOException; import java.io.IOException;
/** /**
* @classname: AlarmAlertActivity * @classname: AlarmAlertActivity
* @description: * @description:
* @date: 2023/12/28 11:18 * @date: 2023/12/28 11:18
* @author: wangrunze * @author: wangrunze
*/ */
public class AlarmAlertActivity extends Activity implements OnClickListener, OnDismissListener { public class AlarmAlertActivity extends Activity implements OnClickListener, OnDismissListener {
private long mNoteId;//文本在数据库存储中的ID号 private long mNoteId;//文本在数据库存储中的ID号
private String mSnippet;//闹钟提示时出现的文本片段 private String mSnippet;//闹钟提示时出现的文本片段
private static final int SNIPPET_PREW_MAX_LEN = 60; private static final int SNIPPET_PREW_MAX_LEN = 60;
MediaPlayer mPlayer; MediaPlayer mPlayer;
//Bundle类型的数据与Map类型的数据相似都是以key-value的形式存储数据的 //Bundle类型的数据与Map类型的数据相似都是以key-value的形式存储数据的
//onsaveInstanceState方法是用来保存Activity的状态的,能从onCreate的参数savedInsanceState中获得状态数据 //onsaveInstanceState方法是用来保存Activity的状态的,能从onCreate的参数savedInsanceState中获得状态数据
/** /**
* @classname: AlarmAlertActivity * @classname: AlarmAlertActivity
* @methodname onCreate * @methodname onCreate
* @description: * @description:
* @date: 2023/12/28 11:27 * @date: 2023/12/28 11:27
* @author: wangrunze * @author: wangrunze
* @param: Bundle savedInstanceState * @param: Bundle savedInstanceState
*/ */
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);//界面显示——无标题 requestWindowFeature(Window.FEATURE_NO_TITLE);//界面显示——无标题
final Window win = getWindow(); final Window win = getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
if (!isScreenOn()) { if (!isScreenOn()) {
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON//保持窗体点亮 win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON//保持窗体点亮
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON//将窗体点亮 | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON//将窗体点亮
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON//允许窗体点亮时锁屏 | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON//允许窗体点亮时锁屏
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);//在手机锁屏后如果到了闹钟提示时间,点亮屏幕 | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);//在手机锁屏后如果到了闹钟提示时间,点亮屏幕
} }
Intent intent = getIntent(); Intent intent = getIntent();
try { try {
mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1)); mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1));
mSnippet = DataUtils.getSnippetById(this.getContentResolver(), mNoteId);//根据ID从数据库中获取标签的内容 mSnippet = DataUtils.getSnippetById(this.getContentResolver(), mNoteId);//根据ID从数据库中获取标签的内容
mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ? mSnippet.substring(0, mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ? mSnippet.substring(0,
SNIPPET_PREW_MAX_LEN) + getResources().getString(R.string.notelist_string_info)//判断标签片段是否达到符合长度 SNIPPET_PREW_MAX_LEN) + getResources().getString(R.string.notelist_string_info)//判断标签片段是否达到符合长度
: mSnippet; : mSnippet;
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
return; return;
} }
mPlayer = new MediaPlayer(); mPlayer = new MediaPlayer();
if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) { if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) {
showActionDialog();//弹出对话框 showActionDialog();//弹出对话框
playAlarmSound();//闹钟提示音激发 playAlarmSound();//闹钟提示音激发
} else { } else {
finish(); finish();
} }
} }
/** /**
* @classname: AlarmAlertActivity * @classname: AlarmAlertActivity
* @methodname isScreenOn * @methodname isScreenOn
* @description: * @description:
* @date: 2023/12/28 11:28 * @date: 2023/12/28 11:28
* @author: wangrunze * @author: wangrunze
* @return: pm.isScreenOn() * @return: pm.isScreenOn()
*/ */
private boolean isScreenOn() { private boolean isScreenOn() {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
return pm.isScreenOn(); return pm.isScreenOn();
} }
/** /**
* @classname: AlarmAlertActivity * @classname: AlarmAlertActivity
* @methodname playAlarmSound * @methodname playAlarmSound
* @description: * @description:
* @date: 2023/12/28 11:29 * @date: 2023/12/28 11:29
* @author: wangrunze * @author: wangrunze
*/ */
private void playAlarmSound() { private void playAlarmSound() {
Uri url = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM); Uri url = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM);
int silentModeStreams = Settings.System.getInt(getContentResolver(), int silentModeStreams = Settings.System.getInt(getContentResolver(),
Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); //调用系统的铃声管理URI得到闹钟提示音 Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); //调用系统的铃声管理URI得到闹钟提示音
if ((silentModeStreams & (1 << AudioManager.STREAM_ALARM)) != 0) { if ((silentModeStreams & (1 << AudioManager.STREAM_ALARM)) != 0) {
mPlayer.setAudioStreamType(silentModeStreams); mPlayer.setAudioStreamType(silentModeStreams);
} else { } else {
mPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); mPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
} }
try { try {
mPlayer.setDataSource(this, url);//无返回值,设置多媒体数据来源 mPlayer.setDataSource(this, url);//无返回值,设置多媒体数据来源
mPlayer.prepare();//准备同步 mPlayer.prepare();//准备同步
mPlayer.setLooping(true);//设置是否循环播放 mPlayer.setLooping(true);//设置是否循环播放
mPlayer.start();//开始播放 mPlayer.start();//开始播放
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace();//抛出异常, 还将显示出更深的调用信息 e.printStackTrace();//抛出异常, 还将显示出更深的调用信息
} catch (SecurityException e) { } catch (SecurityException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
/** /**
* @classname: AlarmAlertActivity * @classname: AlarmAlertActivity
* @methodname showActionDialog * @methodname showActionDialog
* @description: * @description:
* @date: 2023/12/28 11:30 * @date: 2023/12/28 11:30
* @author: wangrunze * @author: wangrunze
*/ */
private void showActionDialog() { private void showActionDialog() {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);//用到AlertDialog.Builder中的create()新建了一个AlertDialog AlertDialog.Builder dialog = new AlertDialog.Builder(this);//用到AlertDialog.Builder中的create()新建了一个AlertDialog
dialog.setTitle(R.string.app_name);//为对话框设置标题 dialog.setTitle(R.string.app_name);//为对话框设置标题
dialog.setMessage(mSnippet);//为对话框设置内容 dialog.setMessage(mSnippet);//为对话框设置内容
dialog.setPositiveButton(R.string.notealert_ok, this);//给对话框添加"Yes"按钮 dialog.setPositiveButton(R.string.notealert_ok, this);//给对话框添加"Yes"按钮
if (isScreenOn()) { if (isScreenOn()) {
dialog.setNegativeButton(R.string.notealert_enter, this);//给对话框添加"no"按钮 dialog.setNegativeButton(R.string.notealert_enter, this);//给对话框添加"no"按钮
} }
dialog.show().setOnDismissListener(this); dialog.show().setOnDismissListener(this);
} }
//DialogInterface dialog为对话框which为选择按钮,功能为选择各种操作 //DialogInterface dialog为对话框which为选择按钮,功能为选择各种操作
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which) { switch (which) {
case DialogInterface.BUTTON_NEGATIVE://这是取消操作 case DialogInterface.BUTTON_NEGATIVE://这是取消操作
Intent intent = new Intent(this, NoteEditActivity.class);//实现两个类间的数据传输 Intent intent = new Intent(this, NoteEditActivity.class);//实现两个类间的数据传输
intent.setAction(Intent.ACTION_VIEW);//设置动作属性 intent.setAction(Intent.ACTION_VIEW);//设置动作属性
intent.putExtra(Intent.EXTRA_UID, mNoteId); intent.putExtra(Intent.EXTRA_UID, mNoteId);
startActivity(intent); startActivity(intent);
break; break;
default: default:
break; break;
} }
} }
/** /**
* @classname: AlarmAlertActivity * @classname: AlarmAlertActivity
* @methodname onDismiss * @methodname onDismiss
* @description: * @description:
* @date: 2023/12/28 11:30 * @date: 2023/12/28 11:30
* @author: wangrunze * @author: wangrunze
* @param:DialogInterface dialog * @param:DialogInterface dialog
*/ */
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
stopAlarmSound(); stopAlarmSound();
finish(); finish();
} }
/** /**
* @classname: AlarmAlertActivity * @classname: AlarmAlertActivity
* @methodname: stopAlarmSound * @methodname: stopAlarmSound
* @description: * @description:
* @date: 2023/12/28 11:31 * @date: 2023/12/28 11:31
* @author: wangrunze * @author: wangrunze
*/ */
private void stopAlarmSound() { private void stopAlarmSound() {
if (mPlayer != null) { if (mPlayer != null) {
mPlayer.stop(); mPlayer.stop();
mPlayer.release(); mPlayer.release();
mPlayer = null; mPlayer = null;
} }
} }
} }

@ -27,20 +27,34 @@ import android.database.Cursor;
import net.micode.notes.data.Notes; import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.NoteColumns; import net.micode.notes.data.Notes.NoteColumns;
/**
* @classname: AlarmInitReceiver
* @description:
* @date: 2023/12/29 11:17
* @author: wangrunze
*/
public class AlarmInitReceiver extends BroadcastReceiver { public class AlarmInitReceiver extends BroadcastReceiver {
private static final String [] PROJECTION = new String [] { private static final String [] PROJECTION = new String [] {
NoteColumns.ID, NoteColumns.ID,
NoteColumns.ALERTED_DATE NoteColumns.ALERTED_DATE
}; };
//对数据库的操作调用标签ID和闹钟时间
private static final int COLUMN_ID = 0; private static final int COLUMN_ID = 0;
private static final int COLUMN_ALERTED_DATE = 1; private static final int COLUMN_ALERTED_DATE = 1;
/**
* @classname: AlarmInitReceiver
* @methodname: onReceive
* @description:
* @date: 2023/12/29 11:23
* @author: wangrunze
* @param:Context context
* @param:Intent intent
*/
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
long currentDate = System.currentTimeMillis(); long currentDate = System.currentTimeMillis();//System.currentTimeMillis()产生一个当前的毫秒,这个毫秒其实就是自1970年1月1日0时起的毫秒数
Cursor c = context.getContentResolver().query(Notes.CONTENT_NOTE_URI, Cursor c = context.getContentResolver().query(Notes.CONTENT_NOTE_URI,
PROJECTION, PROJECTION,
NoteColumns.ALERTED_DATE + ">? AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE, NoteColumns.ALERTED_DATE + ">? AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE,

@ -19,8 +19,23 @@ package net.micode.notes.ui;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
/**
* @classname: AlarmReceiver
* @description:alarm
* @date: 2023/12/29 11:28
* @author: wangrunze
*/
public class AlarmReceiver extends BroadcastReceiver { public class AlarmReceiver extends BroadcastReceiver {
/**
* @classname: AlarmReceiver
* @methodname: onReceive
* @description:AlarmAlertActivity
* @date: 2023/12/29 11:29
* @author: wangrunze
* @param:Context context
* @param:Intent intent
*/
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
intent.setClass(context, AlarmAlertActivity.class); intent.setClass(context, AlarmAlertActivity.class);

@ -28,6 +28,12 @@ import android.view.View;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.NumberPicker; import android.widget.NumberPicker;
/**
* @classname: DateTimePicker
* @description:
* @date: 2023/12/29 11:40
* @author: wangrunze
*/
public class DateTimePicker extends FrameLayout { public class DateTimePicker extends FrameLayout {
private static final boolean DEFAULT_ENABLE_STATE = true; private static final boolean DEFAULT_ENABLE_STATE = true;
@ -65,6 +71,16 @@ public class DateTimePicker extends FrameLayout {
private OnDateTimeChangedListener mOnDateTimeChangedListener; private OnDateTimeChangedListener mOnDateTimeChangedListener;
private NumberPicker.OnValueChangeListener mOnDateChangedListener = new NumberPicker.OnValueChangeListener() { private NumberPicker.OnValueChangeListener mOnDateChangedListener = new NumberPicker.OnValueChangeListener() {
/**
* @classname: DateTimePicker
* @methodname: onValueChange
* @description:
* @date: 2023/12/29 11:41
* @author: wangrunze
* @param:NumberPicker picker
* @param:int oldVal
* @param: int newVal
*/
@Override @Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) { public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
mDate.add(Calendar.DAY_OF_YEAR, newVal - oldVal); mDate.add(Calendar.DAY_OF_YEAR, newVal - oldVal);
@ -74,6 +90,16 @@ public class DateTimePicker extends FrameLayout {
}; };
private NumberPicker.OnValueChangeListener mOnHourChangedListener = new NumberPicker.OnValueChangeListener() { private NumberPicker.OnValueChangeListener mOnHourChangedListener = new NumberPicker.OnValueChangeListener() {
/**
* @classname: DateTimePicker
* @methodname: onValueChange
* @description:Hour
* @date: 2023/12/29 11:42
* @author: wangrunze
* @param:NumberPicker picker
* @param:int oldVal
* @param:int newVal
*/
@Override @Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) { public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
boolean isDateChanged = false; boolean isDateChanged = false;
@ -116,6 +142,16 @@ public class DateTimePicker extends FrameLayout {
}; };
private NumberPicker.OnValueChangeListener mOnMinuteChangedListener = new NumberPicker.OnValueChangeListener() { private NumberPicker.OnValueChangeListener mOnMinuteChangedListener = new NumberPicker.OnValueChangeListener() {
/**
* @classname: DateTimePicker
* @methodname: onValueChange
* @description:
* @date: 2023/12/29 11:43
* @author: wangrunze
* @param:NumberPicker picker
* @param:int oldVal
* @param:int newVal
*/
@Override @Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) { public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
int minValue = mMinuteSpinner.getMinValue(); int minValue = mMinuteSpinner.getMinValue();
@ -146,6 +182,16 @@ public class DateTimePicker extends FrameLayout {
private NumberPicker.OnValueChangeListener mOnAmPmChangedListener = new NumberPicker.OnValueChangeListener() { private NumberPicker.OnValueChangeListener mOnAmPmChangedListener = new NumberPicker.OnValueChangeListener() {
@Override @Override
/**
* @classname: DateTimePicker
* @methodname: onValueChange
* @description: AMPM
* @date: 2023/12/29 11:43
* @author: wangrunze
* @param:NumberPicker picker
* @param:int oldVal
* @param: int newVal
*/
public void onValueChange(NumberPicker picker, int oldVal, int newVal) { public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
mIsAm = !mIsAm; mIsAm = !mIsAm;
if (mIsAm) { if (mIsAm) {
@ -157,12 +203,20 @@ public class DateTimePicker extends FrameLayout {
onDateTimeChanged(); onDateTimeChanged();
} }
}; };
public interface OnDateTimeChangedListener { public interface OnDateTimeChangedListener {
void onDateTimeChanged(DateTimePicker view, int year, int month, void onDateTimeChanged(DateTimePicker view, int year, int month,
int dayOfMonth, int hourOfDay, int minute); int dayOfMonth, int hourOfDay, int minute);
} }
/**
* @classname: DateTimePicker
* @methodname: DateTimePicker
* @description:
* @date: 2023/12/29 11:45
* @author: wangrunze
* @param:Context context
*/
public DateTimePicker(Context context) { public DateTimePicker(Context context) {
this(context, System.currentTimeMillis()); this(context, System.currentTimeMillis());
} }
@ -171,6 +225,16 @@ public class DateTimePicker extends FrameLayout {
this(context, date, DateFormat.is24HourFormat(context)); this(context, date, DateFormat.is24HourFormat(context));
} }
/**
* @classname: DateTimePicker
* @methodname: DateTimePicker
* @description:
* @date: 2023/12/29 11:47
* @author: wangrunze
* @param:Context context
* @param:long date
* @param:boolean is24HourView
*/
public DateTimePicker(Context context, long date, boolean is24HourView) { public DateTimePicker(Context context, long date, boolean is24HourView) {
super(context); super(context);
mDate = Calendar.getInstance(); mDate = Calendar.getInstance();
@ -214,6 +278,14 @@ public class DateTimePicker extends FrameLayout {
mInitialising = false; mInitialising = false;
} }
/**
* @classname: DateTimePicker
* @methodname: setEnabled
* @description:
* @date: 2023/12/29 11:49
* @author: wangrunze
* @param:boolean enabled
*/
@Override @Override
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
if (mIsEnabled == enabled) { if (mIsEnabled == enabled) {
@ -246,6 +318,14 @@ public class DateTimePicker extends FrameLayout {
* *
* @param date The current date in millis * @param date The current date in millis
*/ */
/**
* @classname: DateTimePicker
* @methodname: setCurrentDate
* @description:
* @date: 2023/12/29 11:51
* @author: wangrunze
* @param:long date
*/
public void setCurrentDate(long date) { public void setCurrentDate(long date) {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(date); cal.setTimeInMillis(date);
@ -262,6 +342,14 @@ public class DateTimePicker extends FrameLayout {
* @param hourOfDay The current hourOfDay * @param hourOfDay The current hourOfDay
* @param minute The current minute * @param minute The current minute
*/ */
/**
* @classname: DateTimePicker
* @methodname: setCurrentDate
* @description:
* @date: 2023/12/29 11:51
* @author: wangrunze
* @param:long date
*/
public void setCurrentDate(int year, int month, public void setCurrentDate(int year, int month,
int dayOfMonth, int hourOfDay, int minute) { int dayOfMonth, int hourOfDay, int minute) {
setCurrentYear(year); setCurrentYear(year);
@ -285,6 +373,14 @@ public class DateTimePicker extends FrameLayout {
* *
* @param year The current year * @param year The current year
*/ */
/**
* @classname: DateTimePicker
* @methodname: setCurrentYear
* @description:Set current year
* @date: 2024/1/7 9:53
* @author: wangrunze
* @param:year
*/
public void setCurrentYear(int year) { public void setCurrentYear(int year) {
if (!mInitialising && year == getCurrentYear()) { if (!mInitialising && year == getCurrentYear()) {
return; return;
@ -293,12 +389,19 @@ public class DateTimePicker extends FrameLayout {
updateDateControl(); updateDateControl();
onDateTimeChanged(); onDateTimeChanged();
} }
/** /**
* Get current month in the year * Get current month in the year
* *
* @return The current month in the year * @return The current month in the year
*/ */
/**
* @classname: DateTimePicker
* @methodname: getCurrentMonth
* @description:Get current month in the year
* @date: 2024/1/7 9:54
* @author: wangrunze
* @return:current month
*/
public int getCurrentMonth() { public int getCurrentMonth() {
return mDate.get(Calendar.MONTH); return mDate.get(Calendar.MONTH);
} }
@ -308,6 +411,14 @@ public class DateTimePicker extends FrameLayout {
* *
* @param month The month in the year * @param month The month in the year
*/ */
/**
* @classname: DateTimePicker
* @methodname: setCurrentMonth
* @description:Set current month in the year
* @date: 2024/1/7 9:56
* @author: wangrunze
* @param:current month
*/
public void setCurrentMonth(int month) { public void setCurrentMonth(int month) {
if (!mInitialising && month == getCurrentMonth()) { if (!mInitialising && month == getCurrentMonth()) {
return; return;
@ -322,6 +433,14 @@ public class DateTimePicker extends FrameLayout {
* *
* @return The day of the month * @return The day of the month
*/ */
/**
* @classname: DateTimePicker
* @methodname: getCurrentDay
* @description:Get current day of the month
* @date: 2024/1/7 9:57
* @author: wangrunze
* @return:current day
*/
public int getCurrentDay() { public int getCurrentDay() {
return mDate.get(Calendar.DAY_OF_MONTH); return mDate.get(Calendar.DAY_OF_MONTH);
} }
@ -331,6 +450,14 @@ public class DateTimePicker extends FrameLayout {
* *
* @param dayOfMonth The day of the month * @param dayOfMonth The day of the month
*/ */
/**
* @classname: DateTimePicker
* @methodname: setCurrentDay
* @description:Set current day of the month
* @date: 2024/1/7 9:57
* @author: wangrunze
* @param:The day of the month
*/
public void setCurrentDay(int dayOfMonth) { public void setCurrentDay(int dayOfMonth) {
if (!mInitialising && dayOfMonth == getCurrentDay()) { if (!mInitialising && dayOfMonth == getCurrentDay()) {
return; return;
@ -344,10 +471,26 @@ public class DateTimePicker extends FrameLayout {
* Get current hour in 24 hour mode, in the range (0~23) * Get current hour in 24 hour mode, in the range (0~23)
* @return The current hour in 24 hour mode * @return The current hour in 24 hour mode
*/ */
/**
* @classname: DateTimePicker
* @methodname: getCurrentHourOfDay
* @description:Get current hour in 24 hour mode
* @date: 2024/1/7 9:58
* @author: wangrunze
* @return:The current hour in 24 hour mode
*/
public int getCurrentHourOfDay() { public int getCurrentHourOfDay() {
return mDate.get(Calendar.HOUR_OF_DAY); return mDate.get(Calendar.HOUR_OF_DAY);
} }
/**
* @classname: DateTimePicker
* @methodname: getCurrentHour
* @description:Get current hour
* @date: 2024/1/7 9:58
* @author: wangrunze
* @return:The current hour
*/
private int getCurrentHour() { private int getCurrentHour() {
if (mIs24HourView){ if (mIs24HourView){
return getCurrentHourOfDay(); return getCurrentHourOfDay();
@ -366,6 +509,14 @@ public class DateTimePicker extends FrameLayout {
* *
* @param hourOfDay * @param hourOfDay
*/ */
/**
* @classname: DateTimePicker
* @methodname: setCurrentHour
* @description:Set current hour in 24 hour mode
* @date: 2024/1/7 9:59
* @author: wangrunze
* @param:hourOfDay
*/
public void setCurrentHour(int hourOfDay) { public void setCurrentHour(int hourOfDay) {
if (!mInitialising && hourOfDay == getCurrentHourOfDay()) { if (!mInitialising && hourOfDay == getCurrentHourOfDay()) {
return; return;
@ -394,6 +545,14 @@ public class DateTimePicker extends FrameLayout {
* *
* @return The Current Minute * @return The Current Minute
*/ */
/**
* @classname: DateTimePicker
* @methodname: getCurrentMinute
* @description: Get currentMinute
* @date: 2024/1/7 9:59
* @author: wangrunze
* @return:The Current Minute
*/
public int getCurrentMinute() { public int getCurrentMinute() {
return mDate.get(Calendar.MINUTE); return mDate.get(Calendar.MINUTE);
} }
@ -401,6 +560,14 @@ public class DateTimePicker extends FrameLayout {
/** /**
* Set current minute * Set current minute
*/ */
/**
* @classname: DateTimePicker
* @methodname: setCurrentMinute
* @description:Set current minute
* @date: 2024/1/7 9:59
* @author: wangrunze
* @param:int minute
*/
public void setCurrentMinute(int minute) { public void setCurrentMinute(int minute) {
if (!mInitialising && minute == getCurrentMinute()) { if (!mInitialising && minute == getCurrentMinute()) {
return; return;
@ -413,6 +580,14 @@ public class DateTimePicker extends FrameLayout {
/** /**
* @return true if this is in 24 hour view else false. * @return true if this is in 24 hour view else false.
*/ */
/**
* @classname: DateTimePicker
* @methodname: is24HourView
* @description:24Hour
* @date: 2024/1/7 10:00
* @author: wangrunze
* @return:true if this is in 24 hour view else false.
*/
public boolean is24HourView () { public boolean is24HourView () {
return mIs24HourView; return mIs24HourView;
} }
@ -422,6 +597,14 @@ public class DateTimePicker extends FrameLayout {
* *
* @param is24HourView True for 24 hour mode. False for AM/PM mode. * @param is24HourView True for 24 hour mode. False for AM/PM mode.
*/ */
/**
* @classname: DateTimePicker
* @methodname: set24HourView
* @description:Set whether in 24 hour or AM/PM mode
* @date: 2024/1/7 10:01
* @author: wangrunze
* @param:is24HourView True for 24 hour mode
*/
public void set24HourView(boolean is24HourView) { public void set24HourView(boolean is24HourView) {
if (mIs24HourView == is24HourView) { if (mIs24HourView == is24HourView) {
return; return;
@ -434,6 +617,13 @@ public class DateTimePicker extends FrameLayout {
updateAmPmControl(); updateAmPmControl();
} }
/**
* @classname: DateTimePicker
* @methodname: updateDateControl
* @description:
* @date: 2023/12/29 11:53
* @author: wangrunze
*/
private void updateDateControl() { private void updateDateControl() {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(mDate.getTimeInMillis()); cal.setTimeInMillis(mDate.getTimeInMillis());
@ -448,6 +638,13 @@ public class DateTimePicker extends FrameLayout {
mDateSpinner.invalidate(); mDateSpinner.invalidate();
} }
/**
* @classname: DateTimePicker
* @methodname: updateDateControl
* @description:ampm
* @date: 2023/12/29 11:53
* @author: wangrunze
*/
private void updateAmPmControl() { private void updateAmPmControl() {
if (mIs24HourView) { if (mIs24HourView) {
mAmPmSpinner.setVisibility(View.GONE); mAmPmSpinner.setVisibility(View.GONE);
@ -458,6 +655,13 @@ public class DateTimePicker extends FrameLayout {
} }
} }
/**
* @classname: DateTimePicker
* @methodname: updateDateControl
* @description:
* @date: 2023/12/29 11:53
* @author: wangrunze
*/
private void updateHourControl() { private void updateHourControl() {
if (mIs24HourView) { if (mIs24HourView) {
mHourSpinner.setMinValue(HOUR_SPINNER_MIN_VAL_24_HOUR_VIEW); mHourSpinner.setMinValue(HOUR_SPINNER_MIN_VAL_24_HOUR_VIEW);
@ -476,6 +680,13 @@ public class DateTimePicker extends FrameLayout {
mOnDateTimeChangedListener = callback; mOnDateTimeChangedListener = callback;
} }
/**
* @classname: DateTimePicker
* @methodname: onDateTimeChanged
* @description:
* @date: 2023/12/29 11:54
* @author: wangrunze
*/
private void onDateTimeChanged() { private void onDateTimeChanged() {
if (mOnDateTimeChangedListener != null) { if (mOnDateTimeChangedListener != null) {
mOnDateTimeChangedListener.onDateTimeChanged(this, getCurrentYear(), mOnDateTimeChangedListener.onDateTimeChanged(this, getCurrentYear(),

@ -29,17 +29,31 @@ import android.content.DialogInterface.OnClickListener;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.text.format.DateUtils; import android.text.format.DateUtils;
/**
* @classname: DateTimePickerDialog
* @description:
* @date: 2024/1/4 10:19
* @author: wangrunze
*/
public class DateTimePickerDialog extends AlertDialog implements OnClickListener { public class DateTimePickerDialog extends AlertDialog implements OnClickListener {
private Calendar mDate = Calendar.getInstance(); private Calendar mDate = Calendar.getInstance();
private boolean mIs24HourView; private boolean mIs24HourView;
private OnDateTimeSetListener mOnDateTimeSetListener; private OnDateTimeSetListener mOnDateTimeSetListener;
private DateTimePicker mDateTimePicker; private DateTimePicker mDateTimePicker;//DateTimePicker控件控件一般用于让用户可以从日期列表中选择单个值。
public interface OnDateTimeSetListener { public interface OnDateTimeSetListener {
void OnDateTimeSet(AlertDialog dialog, long date); void OnDateTimeSet(AlertDialog dialog, long date);
} }
/**
* @classname: DateTimePickerDialog
* @methodname: DateTimePickerDialog
* @description:
* @date: 2024/1/4 10:26
* @author: wangrunze
* @param:Context context
* @param:long date
*/
public DateTimePickerDialog(Context context, long date) { public DateTimePickerDialog(Context context, long date) {
super(context); super(context);
mDateTimePicker = new DateTimePicker(context); mDateTimePicker = new DateTimePicker(context);
@ -64,14 +78,35 @@ public class DateTimePickerDialog extends AlertDialog implements OnClickListener
updateTitle(mDate.getTimeInMillis()); updateTitle(mDate.getTimeInMillis());
} }
/**
* @classname: DateTimePickerDialog
* @methodname: set24HourView
* @description:24
* @date: 2024/1/4 10:34
* @author: wangrunze
*/
public void set24HourView(boolean is24HourView) { public void set24HourView(boolean is24HourView) {
mIs24HourView = is24HourView; mIs24HourView = is24HourView;
} }
/**
* @classname: DateTimePickerDialog
* @methodname: setOnDateTimeSetListener
* @description:
* @date: 2024/1/4 10:43
* @author: wangrunze
* @param:OnDateTimeSetListener callBack
*/
public void setOnDateTimeSetListener(OnDateTimeSetListener callBack) { public void setOnDateTimeSetListener(OnDateTimeSetListener callBack) {
mOnDateTimeSetListener = callBack; mOnDateTimeSetListener = callBack;
} }
/**
* @classname: DateTimePickerDialog
* @methodname: updateTitle
* @description:
* @date: 2024/1/4 10:55
* @author: wangrunze
* @param:long date
*/
private void updateTitle(long date) { private void updateTitle(long date) {
int flag = int flag =
DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_YEAR |
@ -80,7 +115,15 @@ public class DateTimePickerDialog extends AlertDialog implements OnClickListener
flag |= mIs24HourView ? DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_24HOUR; flag |= mIs24HourView ? DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_24HOUR;
setTitle(DateUtils.formatDateTime(this.getContext(), date, flag)); setTitle(DateUtils.formatDateTime(this.getContext(), date, flag));
} }
/**
* @classname: DateTimePickerDialog
* @methodname: onClick
* @description:
* @date: 2024/1/4 10:58
* @author: wangrunze
* @param:DialogInterface arg0
* @param:int arg1
*/
public void onClick(DialogInterface arg0, int arg1) { public void onClick(DialogInterface arg0, int arg1) {
if (mOnDateTimeSetListener != null) { if (mOnDateTimeSetListener != null) {
mOnDateTimeSetListener.OnDateTimeSet(this, mDate.getTimeInMillis()); mOnDateTimeSetListener.OnDateTimeSet(this, mDate.getTimeInMillis());

@ -26,12 +26,26 @@ import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener; import android.widget.PopupMenu.OnMenuItemClickListener;
import net.micode.notes.R; import net.micode.notes.R;
/**
* @classname: DropdownMenu
* @description:
* @date: 2024/1/4 11:00
* @author: wangrunze
*/
public class DropdownMenu { public class DropdownMenu {
private Button mButton; private Button mButton;
private PopupMenu mPopupMenu; private PopupMenu mPopupMenu;
private Menu mMenu; private Menu mMenu;
/**
* @classname: DropdownMenu
* @methodname: DropdownMenu
* @description:
* @date: 2024/1/4 11:02
* @author: wangrunze
* @param:Context context
* @param:Button button
* @param:int menuId
*/
public DropdownMenu(Context context, Button button, int menuId) { public DropdownMenu(Context context, Button button, int menuId) {
mButton = button; mButton = button;
mButton.setBackgroundResource(R.drawable.dropdown_icon); mButton.setBackgroundResource(R.drawable.dropdown_icon);
@ -44,17 +58,38 @@ public class DropdownMenu {
} }
}); });
} }
/**
* @classname: DropdownMenu
* @methodname: setOnDropdownMenuItemClickListener
* @description:
* @date: 2024/1/4 11:03
* @author: wangrunze
* @param:OnMenuItemClickListener listener
*/
public void setOnDropdownMenuItemClickListener(OnMenuItemClickListener listener) { public void setOnDropdownMenuItemClickListener(OnMenuItemClickListener listener) {
if (mPopupMenu != null) { if (mPopupMenu != null) {
mPopupMenu.setOnMenuItemClickListener(listener); mPopupMenu.setOnMenuItemClickListener(listener);
} }
} }
/**
* @classname: DropdownMenu
* @methodname: findItem
* @description:
* @date: 2024/1/4 11:04
* @author: wangrunze
* @param:int id
*/
public MenuItem findItem(int id) { public MenuItem findItem(int id) {
return mMenu.findItem(id); return mMenu.findItem(id);
} }
/**
* @classname: DropdownMenu
* @methodname: setTitle
* @description:
* @date: 2024/1/4 11:05
* @author: wangrunze
* @param:CharSequence title
*/
public void setTitle(CharSequence title) { public void setTitle(CharSequence title) {
mButton.setText(title); mButton.setText(title);
} }

@ -28,26 +28,57 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes; import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.NoteColumns; import net.micode.notes.data.Notes.NoteColumns;
/**
* @classname: FoldersListAdapter
* @description:便
* @date: 2024/1/4 11:07
* @author: wangrunze
*/
public class FoldersListAdapter extends CursorAdapter { public class FoldersListAdapter extends CursorAdapter {
public static final String [] PROJECTION = { public static final String [] PROJECTION = {
NoteColumns.ID, NoteColumns.ID,
NoteColumns.SNIPPET NoteColumns.SNIPPET
}; };//调用数据库中便签的ID和片段
public static final int ID_COLUMN = 0; public static final int ID_COLUMN = 0;
public static final int NAME_COLUMN = 1; public static final int NAME_COLUMN = 1;
/**
* @classname: FoldersListAdapter
* @methodname: FoldersListAdapter
* @description:
* @date: 2024/1/4 11:08
* @author: wangrunze
* @param:Context context
* @param: Cursor c
*/
public FoldersListAdapter(Context context, Cursor c) { public FoldersListAdapter(Context context, Cursor c) {
super(context, c); super(context, c);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
/**
* @classname: FoldersListAdapter
* @methodname: newView
* @description:
* @date: 2024/1/4 11:09
* @author: wangrunze
* @param:Context context
* @param:Cursor cursor
* @param:ViewGroup parent
*/
@Override @Override
public View newView(Context context, Cursor cursor, ViewGroup parent) { public View newView(Context context, Cursor cursor, ViewGroup parent) {
return new FolderListItem(context); return new FolderListItem(context);
} }
/**
* @classname: FoldersListAdapter
* @methodname: bindView
* @description:
* @date: 2024/1/4 11:10
* @author: wangrunze
* @param:View view
* @param:Context context
* @param:Cursor cursor
*/
@Override @Override
public void bindView(View view, Context context, Cursor cursor) { public void bindView(View view, Context context, Cursor cursor) {
if (view instanceof FolderListItem) { if (view instanceof FolderListItem) {
@ -56,22 +87,49 @@ public class FoldersListAdapter extends CursorAdapter {
((FolderListItem) view).bind(folderName); ((FolderListItem) view).bind(folderName);
} }
} }
/**
* @classname: FoldersListAdapter
* @methodname: getFolderName
* @description:
* @date: 2024/1/4 11:10
* @author: wangrunze
* @param:Context context
* @param:int position
*/
public String getFolderName(Context context, int position) { public String getFolderName(Context context, int position) {
Cursor cursor = (Cursor) getItem(position); Cursor cursor = (Cursor) getItem(position);
return (cursor.getLong(ID_COLUMN) == Notes.ID_ROOT_FOLDER) ? context return (cursor.getLong(ID_COLUMN) == Notes.ID_ROOT_FOLDER) ? context
.getString(R.string.menu_move_parent_folder) : cursor.getString(NAME_COLUMN); .getString(R.string.menu_move_parent_folder) : cursor.getString(NAME_COLUMN);
} }
/**
* @classname: FoldersListAdapter
* @description:
* @date: 2024/1/4 11:11
* @author: wangrunze
*/
private class FolderListItem extends LinearLayout { private class FolderListItem extends LinearLayout {
private TextView mName; private TextView mName;
/**
* @classname: FolderListItem
* @methodname: FolderListItem
* @description:
* @date: 2024/1/4 11:12
* @author: wangrunze
* @param:Context context
*/
public FolderListItem(Context context) { public FolderListItem(Context context) {
super(context); super(context);
inflate(context, R.layout.folder_list_item, this); inflate(context, R.layout.folder_list_item, this);
mName = (TextView) findViewById(R.id.tv_folder_name); mName = (TextView) findViewById(R.id.tv_folder_name);
} }
/**
* @classname: FolderListItem
* @methodname: bind
* @description:
* @date: 2024/1/4 11:13
* @author: wangrunze
* @param:String name
*/
public void bind(String name) { public void bind(String name) {
mName.setText(name); mName.setText(name);
} }

@ -31,7 +31,12 @@ import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.tool.ResourceParser; import net.micode.notes.tool.ResourceParser;
import net.micode.notes.ui.NoteEditActivity; import net.micode.notes.ui.NoteEditActivity;
import net.micode.notes.ui.NotesListActivity; import net.micode.notes.ui.NotesListActivity;
/**
* @classname: NoteWidgetProvider
* @description:
* @date: 2024/1/7 10:22
* @author: wangrunze
*/
public abstract class NoteWidgetProvider extends AppWidgetProvider { public abstract class NoteWidgetProvider extends AppWidgetProvider {
public static final String [] PROJECTION = new String [] { public static final String [] PROJECTION = new String [] {
NoteColumns.ID, NoteColumns.ID,
@ -45,6 +50,15 @@ public abstract class NoteWidgetProvider extends AppWidgetProvider {
private static final String TAG = "NoteWidgetProvider"; private static final String TAG = "NoteWidgetProvider";
/**
* @classname: NoteWidgetProvider
* @methodname: onDeleted
* @description:
* @date: 2024/1/7 10:23
* @author: wangrunze
* @param:Context context
* @param:int[] appWidgetIds
*/
@Override @Override
public void onDeleted(Context context, int[] appWidgetIds) { public void onDeleted(Context context, int[] appWidgetIds) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
@ -56,7 +70,15 @@ public abstract class NoteWidgetProvider extends AppWidgetProvider {
new String[] { String.valueOf(appWidgetIds[i])}); new String[] { String.valueOf(appWidgetIds[i])});
} }
} }
/**
* @classname: NoteWidgetProvider
* @methodname: getNoteWidgetInfo
* @description:
* @date: 2024/1/7 10:23
* @author: wangrunze
* @param:Context context
* @param:int widgetId
*/
private Cursor getNoteWidgetInfo(Context context, int widgetId) { private Cursor getNoteWidgetInfo(Context context, int widgetId) {
return context.getContentResolver().query(Notes.CONTENT_NOTE_URI, return context.getContentResolver().query(Notes.CONTENT_NOTE_URI,
PROJECTION, PROJECTION,
@ -64,11 +86,30 @@ public abstract class NoteWidgetProvider extends AppWidgetProvider {
new String[] { String.valueOf(widgetId), String.valueOf(Notes.ID_TRASH_FOLER) }, new String[] { String.valueOf(widgetId), String.valueOf(Notes.ID_TRASH_FOLER) },
null); null);
} }
/**
* @classname: NoteWidgetProvider
* @methodname: update
* @description:
* @date: 2024/1/7 10:24
* @author: wangrunze
* @param:Context context
* @param:AppWidgetManager appWidgetManager
* @param:int[] appWidgetIds
*/
protected void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { protected void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
update(context, appWidgetManager, appWidgetIds, false); update(context, appWidgetManager, appWidgetIds, false);
} }
/**
* @classname: NoteWidgetProvider
* @methodname: update
* @description:
* @date: 2024/1/7 10:24
* @author: wangrunze
* @param:Context context
* @param:AppWidgetManager appWidgetManager
* @param:int[] appWidgetIds
* @param:boolean privacyMode
*/
private void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds, private void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds,
boolean privacyMode) { boolean privacyMode) {
for (int i = 0; i < appWidgetIds.length; i++) { for (int i = 0; i < appWidgetIds.length; i++) {

@ -23,24 +23,61 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes; import net.micode.notes.data.Notes;
import net.micode.notes.tool.ResourceParser; import net.micode.notes.tool.ResourceParser;
/**
* @classname: NoteWidgetProvider_2x
* @description:2*2
* @date: 2024/1/7 10:27
* @author: wangrunze
*/
public class NoteWidgetProvider_2x extends NoteWidgetProvider { public class NoteWidgetProvider_2x extends NoteWidgetProvider {
@Override @Override
/**
* @classname: NoteWidgetProvider_2x
* @methodname: onUpdate
* @description:
* @date: 2024/1/7 10:29
* @author: wangrunze
* @param:Context context
* @param:AppWidgetManager appWidgetManager
* @param:int[] appWidgetIds
*/
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.update(context, appWidgetManager, appWidgetIds); super.update(context, appWidgetManager, appWidgetIds);
} }
@Override @Override
/**
* @classname: NoteWidgetProvider_2x
* @methodname: getLayoutId
* @description:ID
* @date: 2024/1/7 10:30
* @author: wangrunze
*/
protected int getLayoutId() { protected int getLayoutId() {
return R.layout.widget_2x; return R.layout.widget_2x;
} }
@Override @Override
/**
* @classname: NoteWidgetProvider_2x
* @methodname: getBgResourceId
* @description:2ID
* @date: 2024/1/7 10:31
* @author: wangrunze
* @param:int bgId
*/
protected int getBgResourceId(int bgId) { protected int getBgResourceId(int bgId) {
return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId); return ResourceParser.WidgetBgResources.getWidget2xBgResource(bgId);
} }
@Override @Override
/**
* @classname: NoteWidgetProvider_2x
* @methodname: getWidgetType
* @description:
* @date: 2024/1/7 10:31
* @author: wangrunze
*/
protected int getWidgetType() { protected int getWidgetType() {
return Notes.TYPE_WIDGET_2X; return Notes.TYPE_WIDGET_2X;
} }

@ -23,23 +23,59 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes; import net.micode.notes.data.Notes;
import net.micode.notes.tool.ResourceParser; import net.micode.notes.tool.ResourceParser;
/**
* @classname: NoteWidgetProvider_4x
* @description:4*1
* @date: 2024/1/7 10:32
* @author: wangrunze
*/
public class NoteWidgetProvider_4x extends NoteWidgetProvider { public class NoteWidgetProvider_4x extends NoteWidgetProvider {
@Override @Override
/**
* @classname: NoteWidgetProvider_4x
* @methodname: onUpdate
* @description:
* @date: 2024/1/7 10:32
* @author: wangrunze
* @param:Context context
* @param:AppWidgetManager appWidgetManager
* @param: int[] appWidgetIds
*/
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.update(context, appWidgetManager, appWidgetIds); super.update(context, appWidgetManager, appWidgetIds);
} }
/**
* @classname: NoteWidgetProvider_4x
* @methodname: getLayoutId
* @description:ID
* @date: 2024/1/7 10:33
* @author: wangrunze
*/
protected int getLayoutId() { protected int getLayoutId() {
return R.layout.widget_4x; return R.layout.widget_4x;
} }
@Override @Override
/**
* @classname: NoteWidgetProvider_4x
* @methodname: getBgResourceId
* @description:4ID
* @date: 2024/1/7 10:33
* @author: wangrunze
* @param:int bgId
*/
protected int getBgResourceId(int bgId) { protected int getBgResourceId(int bgId) {
return ResourceParser.WidgetBgResources.getWidget4xBgResource(bgId); return ResourceParser.WidgetBgResources.getWidget4xBgResource(bgId);
} }
@Override @Override
/**
* @classname: NoteWidgetProvider_4x
* @methodname: getWidgetType
* @description:
* @date: 2024/1/7 10:34
* @author: wangrunze
*/
protected int getWidgetType() { protected int getWidgetType() {
return Notes.TYPE_WIDGET_4X; return Notes.TYPE_WIDGET_4X;
} }

Loading…
Cancel
Save