diff --git a/doc/~$软件泛读、标注和维护报告文档.docx b/doc/~$软件泛读、标注和维护报告文档.docx
deleted file mode 100644
index ce41eec..0000000
Binary files a/doc/~$软件泛读、标注和维护报告文档.docx and /dev/null differ
diff --git a/doc/开源软件泛读、标注和维护报告文档.docx b/doc/开源软件泛读、标注和维护报告文档.docx
index a71cab9..38e94cf 100644
Binary files a/doc/开源软件泛读、标注和维护报告文档.docx and b/doc/开源软件泛读、标注和维护报告文档.docx differ
diff --git a/doc/开源软件的质量分析报告文档.docx b/doc/开源软件的质量分析报告文档.docx
index 543a593..65cd465 100644
Binary files a/doc/开源软件的质量分析报告文档.docx and b/doc/开源软件的质量分析报告文档.docx differ
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 81ecf81..479954a 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -30,6 +30,9 @@
+
+
+
mHistory = new Vector(MAX_REVOKE_TIMES);
+ private boolean mIsRvoke;
+
/*--- 以上是此类中的数据区,以下是方法区 ---*/
/**
@@ -441,6 +457,13 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
return true;
}
+ private String textFilter(String oriText){
+ String newText = oriText;
+ newText = newText.replace("\n", "");
+ newText = newText.replace(" ", "");
+ return newText;
+ }
+
private void initResources() {
/**
* @method: initResources
@@ -460,6 +483,28 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color);
mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this);
mNoteEditor = (EditText) findViewById(R.id.note_edit_view);
+ mNoteEditor.addTextChangedListener(new TextWatcher() {
+ int currentLength = 0;
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after)
+ {
+ mNoteHeaderHolder.tvTextNum.setVisibility(View.VISIBLE);
+ mNoteHeaderHolder.tvTextNum.setText("长度" + String.valueOf(currentLength));
+ }
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ currentLength = textFilter(mNoteEditor.getText().toString()).length();
+ }
+ @Override
+ public void afterTextChanged(Editable s) {//储存文本更改的编辑
+ if(!mIsRvoke) {
+ saveHistory();
+ }else {
+ mIsRvoke = false;
+ }
+ mNoteHeaderHolder.tvTextNum.setText("长度" + String.valueOf(currentLength));
+ }
+ });
mNoteEditorPanel = findViewById(R.id.sv_note_edit);
mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector);
for (int id : sBgSelectorBtnsMap.keySet()) {
@@ -483,6 +528,7 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE;
}
mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list);
+
}
@Override
@@ -655,6 +701,10 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
} else if (itemId == R.id.menu_top) {
mWorkingNote.reverseTopState();
showTopHeader();
+ } else if (itemId == R.id.menu_revoke) {
+ doRevoke();
+ } else if (itemId == R.id.menu_screenshot) {
+ doScreenshot();
}
return true;
}
@@ -1050,4 +1100,86 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
private void showToast(int resId, int duration) {
Toast.makeText(this, resId, duration).show();
}
+
+ /**
+ * @method saveHistory
+ * @description 将每次编辑的内容保存在栈中
+ * @date: 2024-01-08 8:56
+ * @author: 郑鲲鹏
+ * @return void
+ */
+ private void saveHistory() {
+ SpannableString text = new SpannableString(mNoteEditor.getText());
+ if (mHistory.size() >= MAX_REVOKE_TIMES) {
+ mHistory.removeElementAt(0);
+ mHistory.add(text);
+ }
+ else {
+ mHistory.add(text);
+ }
+ }
+
+ /**
+ * @method doRevoke
+ * @description 该方法实现撤回的操作
+ * @date: 2024-01-08 15:56
+ * @author: 郑鲲鹏
+ * @return void
+ */
+ private void doRevoke() {
+ AlertDialog.Builder dialog = new AlertDialog.Builder(this);
+ dialog.setTitle(R.string.tips_of_revoke);
+ dialog.setCancelable(true);
+ dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ }
+ });
+ mIsRvoke = true;
+ if(mHistory.size() <= 1){
+ dialog.setMessage(R.string.cannot_revoke_anything);
+ dialog.show();
+ }
+ else {
+ mNoteEditor.setText((CharSequence)mHistory.elementAt(mHistory.size() - 2));
+ mHistory.removeElementAt(mHistory.size() - 1);
+ }
+ }
+
+ /**
+ * @method doScreenshot
+ * @description 该方法实现截取除了导航栏之外的屏幕的功能
+ * @date: 2024-01-17 17:20
+ * @author: 郑鲲鹏
+ * @return
+ */
+ private void doScreenshot() {
+ // 调用 getWindow().getDecorView().getRootView() 获取屏幕的根视图
+ // 使用 getDrawingCache() 获取视图的缓存位图
+ // 2024-01-17 23:22
+ View view = getWindow().getDecorView();
+ view.setDrawingCacheEnabled(true);
+ view.buildDrawingCache();
+ Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
+ view.setDrawingCacheEnabled(false);
+ // 保存Bitmap对象至文件中
+ // 2024-01-17 23:21
+ if (bitmap != null) {
+ try {
+ String sdCardPath = Environment.getExternalStorageDirectory().getPath();
+ String filePath = sdCardPath + File.separator + "screenshot.png";
+ File file = new File(filePath);
+ FileOutputStream fos = new FileOutputStream(file);
+ bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
+ fos.flush();
+ fos.close();
+ // showToast(R.string.success_screenshot_saved);
+ Toast.makeText(this, "Successfully saved the screenshot to" + filePath, Toast.LENGTH_LONG).show();
+ } catch (Exception e) {
+ Log.e(TAG, "Take a screenshot error");
+ showToast(R.string.error_screenshot_saved);
+ }
+ }
+ }
+
} //NOTE: 这一整个文件就是这一个类 @zhoukexing 2023/12/17 23:41
diff --git a/src/main/res/layout/note_edit.xml b/src/main/res/layout/note_edit.xml
index 0480e30..68dc2b7 100644
--- a/src/main/res/layout/note_edit.xml
+++ b/src/main/res/layout/note_edit.xml
@@ -71,6 +71,7 @@
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="8dip"
+ android:textAppearance="@style/TextAppearanceSecondaryItem" />
/>
+
+
+
+
\ No newline at end of file
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 05be5b6..b6d8a86 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -68,6 +68,10 @@
Share
Send to home
Remind me
+ Revoke text
+ Tip
+ You cannot revoke anything
+ Screenshot
Delete reminder
Select folder
Parent folder
@@ -87,6 +91,8 @@
The note is not exist
Sorry, can not set clock on empty note
Sorry, can not send and empty note to home
+ "Successfully saved the screenshot
+ Failed to save screenshot
Export successful
Export fail
Export text file (%1$s) to SD (%2$s) directory