补全了一部分注释

pull/9/head
eazzy 11 months ago
parent 6169c3f260
commit 7c8e9087a6

@ -67,9 +67,6 @@ import java.util.regex.Pattern;
*/
public class NoteEditActivity extends Activity implements OnClickListener,
NoteSettingChangedListener, OnTextViewChangeListener {
/**
*
*/
private class HeadViewHolder {
public TextView tvModified;
@ -259,7 +256,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
initNoteScreen();
}
/**
* @method initNoteScreen
* @description
* @date: 12/24/2023 6:24 PM
* @author: YangYizhe
*/
private void initNoteScreen() {
mNoteEditor.setTextAppearance(this, TextAppearanceResources
.getTexAppearanceResource(mFontSizeId));
@ -286,7 +288,17 @@ public class NoteEditActivity extends Activity implements OnClickListener,
*/
showAlertHeader();
}
/**
* @method showAlertHeader
* @description
* 便
*
*
*
*
* @date: 12/24/2023 6:24 PM
* @author: YangYizhe
*/
private void showAlertHeader() {
if (mWorkingNote.hasClockAlert()) {
long time = System.currentTimeMillis();
@ -398,6 +410,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
clearSettingState();
}
/**
* @method updateWidget
* @description
* @date: 12/24/2023 6:21 PM
* @author: YangYizhe
*/
private void updateWidget() {
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_2X) {
@ -454,7 +472,13 @@ public class NoteEditActivity extends Activity implements OnClickListener,
saveNote();
super.onBackPressed();
}
/**
* @method clearSettingState
* @description ,
* @date: 12/24/2023 6:22 PM
* @author: YangYizhe
* @return boolean
*/
private boolean clearSettingState() {
if (mNoteBgColorSelector.getVisibility() == View.VISIBLE) {
mNoteBgColorSelector.setVisibility(View.GONE);
@ -465,6 +489,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
return false;
}
/**
* @method onBackgroundColorChanged
* @description
* @date: 12/24/2023 6:23 PM
* @author: YangYizhe
*/
public void onBackgroundColorChanged() {
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.VISIBLE);
@ -496,6 +526,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return true;
}
@Override
/**
* @method onOptionsItemSelected
* @description
* @date: 12/24/2023 6:21 PM
* @author: YangYizhe
* @param [item]
* @return boolean
*/
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.menu_new_note) {
@ -626,9 +664,20 @@ public class NoteEditActivity extends Activity implements OnClickListener,
showToast(R.string.error_note_empty_for_clock);
}
}
/**
* updateWidget
*/
public void onWidgetChanged() {
updateWidget();
}
/**
* @method onEditTextDelete
* @description
* @date: 12/24/2023 6:19 PM
* @author: YangYizhe
* @param index
* @param text
*/
public void onEditTextDelete(int index, String text) {
int childCount = mEditTextList.getChildCount();
if (childCount == 1) {
@ -654,6 +703,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
edit.requestFocus();
edit.setSelection(length);
}
/**
* @method onEditTextEnter
* @description
* @date: 12/24/2023 6:19 PM
* @author: YangYizhe
* @param index
* @param text
*/
public void onEditTextEnter(int index, String text) {
/**
* Should not happen, check for debug
@ -672,6 +729,13 @@ public class NoteEditActivity extends Activity implements OnClickListener,
.setIndex(i);
}
}
/**
* @method switchToListMode
* @description
* @date: 12/24/2023 6:19 PM
* @author: YangYizhe
* @param text
*/
private void switchToListMode(String text) {
mEditTextList.removeAllViews();
String[] items = text.split("\n");
@ -688,6 +752,15 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mNoteEditor.setVisibility(View.GONE);
mEditTextList.setVisibility(View.VISIBLE);
}
/**
* @method getHighlightQueryResult
* @description
* @date: 12/24/2023 6:18 PM
* @author: YangYizhe
* @param fullText
* @param userQuery
* @return Spannable
*/
private Spannable getHighlightQueryResult(String fullText, String userQuery) {
SpannableString spannable = new SpannableString(fullText == null ? "" : fullText);
if (!TextUtils.isEmpty(userQuery)) {
@ -704,6 +777,15 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
return spannable;
}
/**
* @method getListItem
* @description
* @date: 12/24/2023 6:17 PM
* @author: YangYizhe
* @param item
* @param index
* @return
*/
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);
@ -734,6 +816,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
edit.setText(getHighlightQueryResult(item, mUserQuery));
return view;
}
/**
* @method onTextChange
* @description
* @date: 12/24/2023 6:17 PM
* @author: YangYizhe
* @param index
* @param hasText
*/
public void onTextChange(int index, boolean hasText) {
if (index >= mEditTextList.getChildCount()) {
Log.e(TAG, "Wrong index, should not happen");
@ -745,52 +835,64 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.GONE);
}
}
/**
* @method onCheckListModeChanged
* @description
* @date: 12/24/2023 6:17 PM
* @author: YangYizhe
* @param oldMode
* @param newMode
*/
public void onCheckListModeChanged(int oldMode, int newMode) {
if (newMode == TextNote.MODE_CHECK_LIST) {
switchToListMode(mNoteEditor.getText().toString());
//检查模式切换到列表模式
} else {
if (!getWorkingText()) {
mWorkingNote.setWorkingText(mWorkingNote.getContent().replace(TAG_UNCHECKED + " ",
""));
}
//若是获取到文本就改变其检查标记
mNoteEditor.setText(getHighlightQueryResult(mWorkingNote.getContent(), mUserQuery));
mEditTextList.setVisibility(View.GONE);
mNoteEditor.setVisibility(View.VISIBLE);
//修改文本编辑器的内容和可见性
}
}
/**
* @method getWorkingText
* @description
* @date: 12/24/2023 6:12 PM
* @author: YangYizhe
* @return
*/
private boolean getWorkingText() {
boolean hasChecked = false;
//初始化check标记
boolean hasChecked = false;//初始化check标记
if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
// 若模式为CHECK_LIST
/**
* CHECK_LIST
*
*
*/
StringBuilder sb = new StringBuilder();
//创建可变字符串
for (int i = 0; i < mEditTextList.getChildCount(); i++) {
View view = mEditTextList.getChildAt(i);
//遍历所有子编辑框的视图
NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
if (!TextUtils.isEmpty(edit.getText())) {
//若文本不为空
/**
*
*
* true
*/
if (((CheckBox) view.findViewById(R.id.cb_edit_item)).isChecked()) {
//该选项框已打钩
sb.append(TAG_CHECKED).append(" ").append(edit.getText()).append("\n");
hasChecked = true;
//扩展字符串为已打钩并把标记置true
} else {
sb.append(TAG_UNCHECKED).append(" ").append(edit.getText()).append("\n");
//扩展字符串添加未打钩
sb.append(TAG_UNCHECKED).append(" ").append(edit.getText()).append("\n");
}
}
}
mWorkingNote.setWorkingText(sb.toString());
//利用编辑好的字符串设置运行便签的内容
} else {
mWorkingNote.setWorkingText(sb.toString());//利用编辑好的字符串设置运行便签的内容
} else {// 若不是该模式直接用编辑器中的内容设置运行中标签的内容
mWorkingNote.setWorkingText(mNoteEditor.getText().toString());
// 若不是该模式直接用编辑器中的内容设置运行中标签的内容
}
return hasChecked;
}
@ -800,8 +902,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
* 便,退
* @date: 12/21/2023 8:14 AM
* @author: YangYizhe
* @param
* @return
*/
private boolean saveNote() {
getWorkingText();
@ -826,8 +926,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
* send to home
* @date: 12/21/2023 8:15 AM
* @author: YangYizhe
* @param
* @return
*/
private void sendToDesktop() {
/**
@ -863,6 +961,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
showToast(R.string.error_note_empty_for_send_to_desktop);
}
}
/**
* @method makeShortcutIconTitle
* @description
* @date: 12/24/2023 6:11 PM
* @author: YangYizhe
* @param content
* @return
*/
private String makeShortcutIconTitle(String content) {
content = content.replace(TAG_CHECKED, "");
content = content.replace(TAG_UNCHECKED, "");

@ -46,19 +46,12 @@ import java.util.Map;
* @Version: 1.0
*/
public class NoteEditText extends EditText {
//常量标识
private static final String TAG = "NoteEditText";
//声明整型变量,文本索引
private int mIndex;
//声明整型变量
private int mSelectionStartBeforeDelete;
//声明字符串常量,标志电话、网址、邮件
private static final String SCHEME_TEL = "tel:" ;
private static final String SCHEME_HTTP = "http:" ;
private static final String SCHEME_EMAIL = "mailto:" ;
//设置映射,将文本内容(电话、网址、邮件)做链接处理
private static final Map<String, Integer> sSchemaActionResMap = new HashMap<String, Integer>();
static {
sSchemaActionResMap.put(SCHEME_TEL, R.string.note_link_tel);
@ -103,7 +96,9 @@ public class NoteEditText extends EditText {
mIndex = 0;
}
//设置索引号
/**
*
*/
public void setIndex(int index) {
mIndex = index;
}
@ -129,15 +124,15 @@ public class NoteEditText extends EditText {
// TODO Auto-generated constructor stub
}
@Override
/**
* @method onTouchEvent
* @description
* @date: 12/21/2023 12:41 AM
* @date: 12/24/2023 6:07 PM
* @author: YangYizhe
* @param
* @return
* @param [event]
* @return boolean
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
@ -240,15 +235,15 @@ public class NoteEditText extends EditText {
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
@Override
/**
* @method onCreateContextMenu
* @description
* @date: 12/21/2023 12:39 AM
* @description
* @date: 12/24/2023 6:08 PM
* @author: YangYizhe
* @param
* @return
* @param [menu]
* @return void
*/
@Override
protected void onCreateContextMenu(ContextMenu menu) {
if (getText() instanceof Spanned) {
int selStart = getSelectionStart();

@ -25,7 +25,14 @@ import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.tool.DataUtils;
/**
* @Package: net.micode.notes.ui
* @ClassName: NoteItemData
* @Description:
* @Author: YangYizhe
* @CreateDate: 12/24/2023 6:00 PM
* @Version: 1.0
*/
public class NoteItemData {
static final String [] PROJECTION = new String [] {
NoteColumns.ID,
@ -75,7 +82,16 @@ public class NoteItemData {
private boolean mIsOnlyOneItem;
private boolean mIsOneNoteFollowingFolder;
private boolean mIsMultiNotesFollowingFolder;
/**
* @method NoteItemData
* @description
*
*
* @date: 12/24/2023 6:00 PM
* @author: YangYizhe
* @param context
* @param cursor
*/
public NoteItemData(Context context, Cursor cursor) {
mId = cursor.getLong(ID_COLUMN);
mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN);
@ -108,7 +124,13 @@ public class NoteItemData {
}
checkPostion(cursor);
}
/**
* @method checkPostion
* @description
* @date: 12/24/2023 6:00 PM
* @author: YangYizhe
* @param cursor
*/
private void checkPostion(Cursor cursor) {
mIsLastItem = cursor.isLast() ? true : false;
mIsFirstItem = cursor.isFirst() ? true : false;
@ -133,59 +155,87 @@ public class NoteItemData {
}
}
}
/**
*
*/
public boolean isOneFollowingFolder() {
return mIsOneNoteFollowingFolder;
}
/**
*
*/
public boolean isMultiFollowingFolder() {
return mIsMultiNotesFollowingFolder;
}
/**
*
*/
public boolean isLast() {
return mIsLastItem;
}
/**
*
*/
public String getCallName() {
return mName;
}
/**
*
*/
public boolean isFirst() {
return mIsFirstItem;
}
/**
*
*/
public boolean isSingle() {
return mIsOnlyOneItem;
}
/**
* ID
*/
public long getId() {
return mId;
}
/**
*
*/
public long getAlertDate() {
return mAlertDate;
}
/**
*
*/
public long getCreatedDate() {
return mCreatedDate;
}
/**
*
*/
public boolean hasAttachment() {
return mHasAttachment;
}
/**
*
*/
public long getModifiedDate() {
return mModifiedDate;
}
/**
* ID
*/
public int getBgColorId() {
return mBgColorId;
}
/**
* ID
*/
public long getParentId() {
return mParentId;
}
/**
*
*/
public int getNotesCount() {
return mNotesCount;
}

Loading…
Cancel
Save