|
|
|
@ -19,6 +19,8 @@ import android.text.SpannableString;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.text.format.DateUtils;
|
|
|
|
|
import android.text.style.BackgroundColorSpan;
|
|
|
|
|
import android.text.Editable;// 引入textwatcher和Editable
|
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
import android.view.Menu;
|
|
|
|
@ -67,12 +69,6 @@ import java.util.regex.Pattern;
|
|
|
|
|
*/
|
|
|
|
|
public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
NoteSettingChangedListener, OnTextViewChangeListener {
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
========
|
|
|
|
|
/**
|
|
|
|
|
* 类属性的定义
|
|
|
|
|
*/
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
private class HeadViewHolder {
|
|
|
|
|
public TextView tvModified;
|
|
|
|
|
|
|
|
|
@ -81,6 +77,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
public TextView tvAlertDate;
|
|
|
|
|
|
|
|
|
|
public ImageView ibSetBgColor;
|
|
|
|
|
|
|
|
|
|
public TextView textNum;
|
|
|
|
|
}
|
|
|
|
|
private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>();
|
|
|
|
|
static {
|
|
|
|
@ -138,6 +136,70 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
|
|
|
|
|
private String mUserQuery;
|
|
|
|
|
private Pattern mPattern;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @method Textchange
|
|
|
|
|
* @description 对原始文本进行处理,去除图片字符、换行符和空格字符
|
|
|
|
|
* @date: 1/3/2024 8:48 AM
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
* @param oriText
|
|
|
|
|
* @return 处理后的文本
|
|
|
|
|
*/
|
|
|
|
|
private String Textchange(String oriText){
|
|
|
|
|
StringBuffer stringBuffer = new StringBuffer(oriText);
|
|
|
|
|
int Flag1 = -1;
|
|
|
|
|
int Flag2 = -1;
|
|
|
|
|
do {//不计入表示图片的字符
|
|
|
|
|
Flag1 = stringBuffer.indexOf("<img");
|
|
|
|
|
Flag2 = stringBuffer.indexOf(">");
|
|
|
|
|
if (Flag1 != -1 && Flag2 != -1) {
|
|
|
|
|
stringBuffer = stringBuffer.replace(Flag1, Flag2+1, "");
|
|
|
|
|
}
|
|
|
|
|
} while (Flag1 != -1 && Flag2 != -1);
|
|
|
|
|
|
|
|
|
|
do {//不计入换行字符
|
|
|
|
|
Flag1 = stringBuffer.indexOf("\n");
|
|
|
|
|
|
|
|
|
|
if (Flag1 != -1){
|
|
|
|
|
stringBuffer = stringBuffer.replace(Flag1, Flag1+1, "");
|
|
|
|
|
}
|
|
|
|
|
} while (Flag1 != -1);
|
|
|
|
|
do {//不计入空格字符
|
|
|
|
|
Flag1 = stringBuffer.indexOf(" ");
|
|
|
|
|
|
|
|
|
|
if (Flag1 != -1) {
|
|
|
|
|
stringBuffer = stringBuffer.replace(Flag1, Flag1+1, "");
|
|
|
|
|
}
|
|
|
|
|
} while (Flag1 != -1);
|
|
|
|
|
return stringBuffer.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @method count
|
|
|
|
|
* @description 监听编辑框文本变化并更新字符数
|
|
|
|
|
* @date: 1/3/2024 9:09 AM
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
*/
|
|
|
|
|
private void count() {
|
|
|
|
|
mNoteEditor.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
int currentLength = 0;
|
|
|
|
|
@Override
|
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
|
mNoteHeaderHolder.textNum.setText("字数:" + currentLength);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
|
currentLength = Textchange(mNoteEditor.getText().toString()).length();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
|
mNoteHeaderHolder.textNum.setText("字数:" + currentLength);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*在 Activity 创建时进行一些初始化工作,包括设置布局、初始化状态和资源等操作
|
|
|
|
|
*/
|
|
|
|
@ -150,6 +212,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
initResources();
|
|
|
|
|
count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -294,7 +357,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
*/
|
|
|
|
|
showAlertHeader();
|
|
|
|
|
}
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
/**
|
|
|
|
|
* @method showAlertHeader
|
|
|
|
|
* @description
|
|
|
|
@ -306,9 +368,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* @date: 12/24/2023 6:24 PM
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
*/
|
|
|
|
|
========
|
|
|
|
|
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
private void showAlertHeader() {
|
|
|
|
|
if (mWorkingNote.hasClockAlert()) {
|
|
|
|
|
long time = System.currentTimeMillis();
|
|
|
|
@ -385,6 +444,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
mNoteHeaderHolder.ivAlertIcon = (ImageView) findViewById(R.id.iv_alert_icon);
|
|
|
|
|
mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date);
|
|
|
|
|
mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color);
|
|
|
|
|
mNoteHeaderHolder.textNum = (TextView) findViewById(R.id.text_num);
|
|
|
|
|
mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this);
|
|
|
|
|
mNoteEditor = (EditText) findViewById(R.id.note_edit_view);
|
|
|
|
|
mNoteEditorPanel = findViewById(R.id.sv_note_edit);
|
|
|
|
@ -420,15 +480,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
}
|
|
|
|
|
clearSettingState();
|
|
|
|
|
}
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
/**
|
|
|
|
|
* @method updateWidget
|
|
|
|
|
* @description 更新小部件的操作
|
|
|
|
|
* @date: 12/24/2023 6:21 PM
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
*/
|
|
|
|
|
========
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
private void updateWidget() {
|
|
|
|
|
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
|
|
|
|
if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_2X) {
|
|
|
|
@ -551,8 +608,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
int itemId = item.getItemId();
|
|
|
|
|
if (itemId == R.id.menu_new_note) {
|
|
|
|
|
createNewNote();
|
|
|
|
|
}
|
|
|
|
|
else if (itemId == R.id.menu_delete) {
|
|
|
|
|
} else if (itemId == R.id.menu_delete) {
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
|
builder.setTitle(getString(R.string.alert_title_delete));
|
|
|
|
|
builder.setIcon(android.R.drawable.ic_dialog_alert);
|
|
|
|
@ -677,7 +733,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
showToast(R.string.error_note_empty_for_clock);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
/**
|
|
|
|
|
* 当小部件发生改变时调用updateWidget
|
|
|
|
|
*/
|
|
|
|
@ -692,11 +747,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* @param index 文本框索引
|
|
|
|
|
* @param text 文本框中的文本内容
|
|
|
|
|
*/
|
|
|
|
|
========
|
|
|
|
|
public void onWidgetChanged() {
|
|
|
|
|
updateWidget();
|
|
|
|
|
}
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
public void onEditTextDelete(int index, String text) {
|
|
|
|
|
int childCount = mEditTextList.getChildCount();
|
|
|
|
|
if (childCount == 1) {
|
|
|
|
@ -722,7 +772,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
edit.requestFocus();
|
|
|
|
|
edit.setSelection(length);
|
|
|
|
|
}
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
/**
|
|
|
|
|
* @method onEditTextEnter
|
|
|
|
|
* @description 编辑文本框中按下回车键的操作
|
|
|
|
@ -731,8 +780,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* @param index 文本框索引
|
|
|
|
|
* @param text 文本框中的文本内容
|
|
|
|
|
*/
|
|
|
|
|
========
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
public void onEditTextEnter(int index, String text) {
|
|
|
|
|
/**
|
|
|
|
|
* Should not happen, check for debug
|
|
|
|
@ -751,7 +798,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
.setIndex(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
/**
|
|
|
|
|
* @method switchToListMode
|
|
|
|
|
* @description 切换到列表模式
|
|
|
|
@ -759,8 +805,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
* @param text 列表文本
|
|
|
|
|
*/
|
|
|
|
|
========
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
private void switchToListMode(String text) {
|
|
|
|
|
mEditTextList.removeAllViews();
|
|
|
|
|
String[] items = text.split("\n");
|
|
|
|
@ -777,7 +821,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
mNoteEditor.setVisibility(View.GONE);
|
|
|
|
|
mEditTextList.setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
/**
|
|
|
|
|
* @method getHighlightQueryResult
|
|
|
|
|
* @description 获取高亮查询结果
|
|
|
|
@ -787,8 +830,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* @param userQuery 用户查询关键词
|
|
|
|
|
* @return 带有高亮效果的 Spannable 对象
|
|
|
|
|
*/
|
|
|
|
|
========
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
private Spannable getHighlightQueryResult(String fullText, String userQuery) {
|
|
|
|
|
SpannableString spannable = new SpannableString(fullText == null ? "" : fullText);
|
|
|
|
|
if (!TextUtils.isEmpty(userQuery)) {
|
|
|
|
@ -805,7 +846,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
}
|
|
|
|
|
return spannable;
|
|
|
|
|
}
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
/**
|
|
|
|
|
* @method getListItem
|
|
|
|
|
* @description 获取列表项视图
|
|
|
|
@ -815,8 +855,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* @param index 列表项索引
|
|
|
|
|
* @return 列表项视图
|
|
|
|
|
*/
|
|
|
|
|
========
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
private View getListItem(String item, int index) {
|
|
|
|
|
View view = LayoutInflater.from(this).inflate(R.layout.note_edit_list_item, null);
|
|
|
|
|
final NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
|
|
|
|
@ -847,7 +885,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
edit.setText(getHighlightQueryResult(item, mUserQuery));
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
/**
|
|
|
|
|
* @method onTextChange
|
|
|
|
|
* @description 当文本内容发生变化时的处理方法
|
|
|
|
@ -856,8 +893,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* @param index 文本索引
|
|
|
|
|
* @param hasText 是否有文本内容
|
|
|
|
|
*/
|
|
|
|
|
========
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
public void onTextChange(int index, boolean hasText) {
|
|
|
|
|
if (index >= mEditTextList.getChildCount()) {
|
|
|
|
|
Log.e(TAG, "Wrong index, should not happen");
|
|
|
|
@ -869,7 +904,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
/**
|
|
|
|
|
* @method onCheckListModeChanged
|
|
|
|
|
* @description 当检查列表模式发生变化时的处理方法
|
|
|
|
@ -878,9 +912,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* @param oldMode 旧的模式
|
|
|
|
|
* @param newMode 新的模式
|
|
|
|
|
*/
|
|
|
|
|
========
|
|
|
|
|
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
public void onCheckListModeChanged(int oldMode, int newMode) {
|
|
|
|
|
if (newMode == TextNote.MODE_CHECK_LIST) {
|
|
|
|
|
switchToListMode(mNoteEditor.getText().toString());
|
|
|
|
@ -894,7 +925,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
mNoteEditor.setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
/**
|
|
|
|
|
* @method getWorkingText
|
|
|
|
|
* @description 获取正在编辑的文本内容
|
|
|
|
@ -902,8 +932,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
* @return 是否存在已打钩的选项
|
|
|
|
|
*/
|
|
|
|
|
========
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
private boolean getWorkingText() {
|
|
|
|
|
boolean hasChecked = false;//初始化check标记
|
|
|
|
|
if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
|
|
|
|
@ -943,11 +971,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* 保存便签,退出时候会自动调本函数
|
|
|
|
|
* @date: 12/21/2023 8:14 AM
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
========
|
|
|
|
|
* @param
|
|
|
|
|
* @return
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
*/
|
|
|
|
|
private boolean saveNote() {
|
|
|
|
|
getWorkingText();
|
|
|
|
@ -972,11 +995,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* send to home功能,发到桌面上
|
|
|
|
|
* @date: 12/21/2023 8:15 AM
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
========
|
|
|
|
|
* @param
|
|
|
|
|
* @return
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
*/
|
|
|
|
|
private void sendToDesktop() {
|
|
|
|
|
/**
|
|
|
|
@ -1012,7 +1030,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
showToast(R.string.error_note_empty_for_send_to_desktop);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
<<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
/**
|
|
|
|
|
* @method makeShortcutIconTitle
|
|
|
|
|
* @description 生成快捷方式图标标题
|
|
|
|
@ -1021,8 +1038,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* @param content 内容
|
|
|
|
|
* @return 生成的快捷方式图标标题
|
|
|
|
|
*/
|
|
|
|
|
========
|
|
|
|
|
>>>>>>>> b654a61 (code):src/Notes/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
|
|
|
|
|
private String makeShortcutIconTitle(String content) {
|
|
|
|
|
content = content.replace(TAG_CHECKED, "");
|
|
|
|
|
content = content.replace(TAG_UNCHECKED, "");
|
|
|
|
|