|
|
|
@ -169,22 +169,37 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @classname: NotesListActivity
|
|
|
|
|
* @methodname setAppInfoFromRawRes
|
|
|
|
|
* @description:从设备的资源文件中获取内容,并且保存在WorkingNote中(标记,这个不是,但可以类似去找修改笔记中的字符显示)
|
|
|
|
|
* @date: 2024/1/12 9:58
|
|
|
|
|
* @author: Xia Yanbo
|
|
|
|
|
*/
|
|
|
|
|
private void setAppInfoFromRawRes() {
|
|
|
|
|
// 获取默认的SharedPreferences对象,用于存储和获取应用的一些常用配置信息
|
|
|
|
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
|
|
|
|
if (!sp.getBoolean(PREFERENCE_ADD_INTRODUCTION, false)) {
|
|
|
|
|
// 创建一个StringBuilder对象,用于构建从资源文件中读取的内容
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
InputStream in = null;
|
|
|
|
|
InputStream in = null;// 声明一个InputStream对象,用于读取资源文件
|
|
|
|
|
try {
|
|
|
|
|
//打开资源,作为读取的对象
|
|
|
|
|
in = getResources().openRawResource(R.raw.introduction);
|
|
|
|
|
if (in != null) {
|
|
|
|
|
// 创建一个InputStreamReader对象,将InputStream转换为字符流
|
|
|
|
|
InputStreamReader isr = new InputStreamReader(in);
|
|
|
|
|
// 创建一个BufferedReader对象,用于按行读取字符流的内容
|
|
|
|
|
BufferedReader br = new BufferedReader(isr);
|
|
|
|
|
// 创建一个字符数组,用于临时存储从资源文件中读取的字符数据,每个块大小为1024字节
|
|
|
|
|
char [] buf = new char[1024];
|
|
|
|
|
int len = 0;
|
|
|
|
|
int len = 0; // 声明一个整型变量,用于存储每次从资源文件中读取的字符数量
|
|
|
|
|
// 循环读取字符数据,直到没有数据可读
|
|
|
|
|
while ((len = br.read(buf)) > 0) {
|
|
|
|
|
// 将读取到的字符数据追加到StringBuilder对象中
|
|
|
|
|
sb.append(buf, 0, len);
|
|
|
|
|
}
|
|
|
|
|
//读取失败在日志中输出错误信息
|
|
|
|
|
} else {
|
|
|
|
|
Log.e(TAG, "Read introduction file error");
|
|
|
|
|
return;
|
|
|
|
@ -193,6 +208,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return;
|
|
|
|
|
} finally {
|
|
|
|
|
// 最后,关闭InputStream对象,释放资源
|
|
|
|
|
if(in != null) {
|
|
|
|
|
try {
|
|
|
|
|
in.close();
|
|
|
|
@ -202,14 +218,17 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建一个工作笔记对象,并设置一些属性值
|
|
|
|
|
WorkingNote note = WorkingNote.createEmptyNote(this, Notes.ID_ROOT_FOLDER,
|
|
|
|
|
AppWidgetManager.INVALID_APPWIDGET_ID, Notes.TYPE_WIDGET_INVALIDE,
|
|
|
|
|
ResourceParser.RED);
|
|
|
|
|
// 将从资源文件中读取的内容设置到工作笔记的文本属性中
|
|
|
|
|
note.setWorkingText(sb.toString());
|
|
|
|
|
// 如果成功保存工作笔记,则将一个布尔值添加到SharedPreferences中,键为PREFERENCE_ADD_INTRODUCTION,值为true,并提交更改
|
|
|
|
|
if (note.saveNote()) {
|
|
|
|
|
sp.edit().putBoolean(PREFERENCE_ADD_INTRODUCTION, true).commit();
|
|
|
|
|
} else {
|
|
|
|
|
// 如果保存失败,则在日志中输出错误信息,并结束方法执行
|
|
|
|
|
Log.e(TAG, "Save introduction note error");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -432,7 +451,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
String str1 = "520";
|
|
|
|
|
String str1 = "444";
|
|
|
|
|
String [] PROJECTION = new String [] { //定义一个新的PROJECTION数组,只换掉SNIPPET
|
|
|
|
|
NoteColumns.ID,
|
|
|
|
|
NoteColumns.ALERTED_DATE,
|
|
|
|
@ -848,16 +867,18 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
}
|
|
|
|
|
else if(item.getItemId()==R.id.menu_secret)
|
|
|
|
|
{//进入私密模式
|
|
|
|
|
secret_mode = 1;
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
|
|
|
|
|
dialog.setTitle("重要提醒");
|
|
|
|
|
dialog.setMessage("您确认进入私密模式吗?");
|
|
|
|
|
dialog.setCancelable(false);
|
|
|
|
|
dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
startAsyncNotesListQuery();
|
|
|
|
|
Toast.makeText(NotesListActivity.this,"您已进入私密模式",Toast.LENGTH_SHORT).show();
|
|
|
|
|
secret_mode = 1;
|
|
|
|
|
startAsyncNotesListQuery();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
|
@ -866,11 +887,11 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
});
|
|
|
|
|
dialog.show();
|
|
|
|
|
startAsyncNotesListQuery();
|
|
|
|
|
Toast.makeText(this,"您已进入私密模式",Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(item.getItemId()==R.id.menu_quit_secret)
|
|
|
|
|
{ //退出私密模式
|
|
|
|
|
secret_mode = 0;
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
|
|
|
|
|
dialog.setTitle("重要提醒");
|
|
|
|
|
dialog.setMessage("您确认退出私密模式吗?");
|
|
|
|
@ -878,8 +899,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
startAsyncNotesListQuery();
|
|
|
|
|
secret_mode = 0;
|
|
|
|
|
Toast.makeText(NotesListActivity.this,"您已退出私密模式",Toast.LENGTH_SHORT).show();
|
|
|
|
|
startAsyncNotesListQuery();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
|
|