|
|
|
@ -72,8 +72,12 @@ import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
NoteSettingChangedListener, OnTextViewChangeListener {
|
|
|
|
|
public class NoteEditActivity extends Activity //NOTE: extends--单继承,但可多重继承 @zhoukexing 2023/12/17 23:29
|
|
|
|
|
implements OnClickListener, NoteSettingChangedListener, OnTextViewChangeListener { //NOTE: implements--实现接口 @zhoukexing 2023/12/17 23:24
|
|
|
|
|
/** NOTE:
|
|
|
|
|
*
|
|
|
|
|
* @zhoukexing 2023/12/17 23:39
|
|
|
|
|
*/
|
|
|
|
|
private class HeadViewHolder {
|
|
|
|
|
public TextView tvModified;
|
|
|
|
|
|
|
|
|
@ -149,8 +153,21 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
private String mUserQuery;
|
|
|
|
|
private Pattern mPattern;
|
|
|
|
|
|
|
|
|
|
/*--- 以上是此类中的数据区,以下是方法区 ---*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @zkx 2023/12/18 复写了Activity类中的onCreate函数,当用户点击创建时,会进入这个函数
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
/**
|
|
|
|
|
* @method: onCreate
|
|
|
|
|
* @description: 描述一下方法的作用
|
|
|
|
|
* @date: 2023/12/18 23:22
|
|
|
|
|
* @author: zhoukexing
|
|
|
|
|
* @param: [savedInstanceState]
|
|
|
|
|
* @return: void
|
|
|
|
|
*/
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
this.setContentView(R.layout.note_edit);
|
|
|
|
|
|
|
|
|
@ -180,6 +197,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean initActivityState(Intent intent) {
|
|
|
|
|
/**
|
|
|
|
|
* @method: initActivityState
|
|
|
|
|
* @description: 根据intent(Key-Value)内容,初始化一个便签编辑活动
|
|
|
|
|
* @date: 2023/12/18 23:31
|
|
|
|
|
* @author: zhoukexing
|
|
|
|
|
* @param: [intent]
|
|
|
|
|
* @return: boolean 为真则初始化成功,为假则失败。失败原因:不存在、(call)load失败、intent内容错误
|
|
|
|
|
*/
|
|
|
|
|
/**
|
|
|
|
|
* If the user specified the {@link Intent#ACTION_VIEW} but not provided with id,
|
|
|
|
|
* then jump to the NotesListActivity
|
|
|
|
@ -295,15 +320,32 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
showAlertHeader();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Method showAlertHeader
|
|
|
|
|
* @Date 2023/12/13 11:32
|
|
|
|
|
* @Author lenovo
|
|
|
|
|
* @Return void
|
|
|
|
|
* @Description 在便签页面的上方栏显示提醒信息
|
|
|
|
|
*/
|
|
|
|
|
private void showAlertHeader() {
|
|
|
|
|
if (mWorkingNote.hasClockAlert()) {
|
|
|
|
|
long time = System.currentTimeMillis();
|
|
|
|
|
if (time > mWorkingNote.getAlertDate()) {
|
|
|
|
|
// 闹钟时间大于当前时间, 显示 "Expired", 闹钟失效
|
|
|
|
|
mNoteHeaderHolder.tvAlertDate.setText(R.string.note_alert_expired);
|
|
|
|
|
} else {
|
|
|
|
|
// 显示正常闹钟信息
|
|
|
|
|
mNoteHeaderHolder.tvAlertDate.setText(DateUtils.getRelativeTimeSpanString(
|
|
|
|
|
mWorkingNote.getAlertDate(), time, DateUtils.MINUTE_IN_MILLIS));
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* setVisibility()
|
|
|
|
|
* 用于设置空间的可见性
|
|
|
|
|
* VISIBLE 可见
|
|
|
|
|
* INVISIBLE 不可见,但是占用一个位置
|
|
|
|
|
* GNONE 不可见且不占用位置
|
|
|
|
|
* lenovo 2023/12/13 11:28
|
|
|
|
|
*/
|
|
|
|
|
mNoteHeaderHolder.tvAlertDate.setVisibility(View.VISIBLE);
|
|
|
|
|
mNoteHeaderHolder.ivAlertIcon.setVisibility(View.VISIBLE);
|
|
|
|
|
} else {
|
|
|
|
@ -364,6 +406,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initResources() {
|
|
|
|
|
/**
|
|
|
|
|
* @method: initResources
|
|
|
|
|
* @description: 初始化资源。被onCreate唯一调用
|
|
|
|
|
* @date: 2023/12/18 23:36
|
|
|
|
|
* @author: zhoukexing
|
|
|
|
|
* @param: []
|
|
|
|
|
* @return: void
|
|
|
|
|
*/
|
|
|
|
|
mHeadViewPanel = findViewById(R.id.note_title);
|
|
|
|
|
mNoteHeaderHolder = new HeadViewHolder();
|
|
|
|
|
mNoteHeaderHolder.tvModified = (TextView) findViewById(R.id.tv_modified_date);
|
|
|
|
@ -430,7 +480,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
if (id == R.id.btn_set_bg_color) {
|
|
|
|
|
mNoteBgColorSelector.setVisibility(View.VISIBLE);
|
|
|
|
|
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
|
|
|
|
|
- View.VISIBLE);
|
|
|
|
|
View.VISIBLE);
|
|
|
|
|
} else if (sBgSelectorBtnsMap.containsKey(id)) {
|
|
|
|
|
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
|
|
|
|
|
View.GONE);
|
|
|
|
@ -543,8 +593,16 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Method setReminder
|
|
|
|
|
* @Date 2023/12/13 12:52
|
|
|
|
|
* @Author lenovo
|
|
|
|
|
* @Return void
|
|
|
|
|
* @Description 显示时间选择器,默认时间为当前时间
|
|
|
|
|
*/
|
|
|
|
|
private void setReminder() {
|
|
|
|
|
DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis());
|
|
|
|
|
// 设置时间选择器的监听事件,当选中 date 之后调用 setAlertDate 设置提醒时间
|
|
|
|
|
d.setOnDateTimeSetListener(new OnDateTimeSetListener() {
|
|
|
|
|
public void OnDateTimeSet(AlertDialog dialog, long date) {
|
|
|
|
|
mWorkingNote.setAlertDate(date , true);
|
|
|
|
@ -570,7 +628,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
|
|
|
|
|
// For safety, start a new NoteEditActivity
|
|
|
|
|
finish();
|
|
|
|
|
Intent intent = new Intent(this, NoteEditActivity.class);
|
|
|
|
|
Intent intent = new Intent(this, NoteEditActivity.class); //Q: 在类的内部,还没有实现完全时,启动这个类自己?@zkx 2023/12/17
|
|
|
|
|
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
|
|
|
|
|
intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mWorkingNote.getFolderId());
|
|
|
|
|
startActivity(intent);
|
|
|
|
@ -602,6 +660,15 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Method onClockAlertChanged
|
|
|
|
|
* @Date 2023/12/13 9:52
|
|
|
|
|
* @param date
|
|
|
|
|
* @param set 0 取消 1 设置
|
|
|
|
|
* @Author lenovo
|
|
|
|
|
* @Return void
|
|
|
|
|
* @Description 设置提醒的监听事件
|
|
|
|
|
*/
|
|
|
|
|
public void onClockAlertChanged(long date, boolean set) {
|
|
|
|
|
/**
|
|
|
|
|
* User could set clock to an unsaved note, so before setting the
|
|
|
|
@ -617,8 +684,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE));
|
|
|
|
|
showAlertHeader();
|
|
|
|
|
if(!set) {
|
|
|
|
|
// 取消监听事件
|
|
|
|
|
alarmManager.cancel(pendingIntent);
|
|
|
|
|
} else {
|
|
|
|
|
// 设置监听事件,到时间启动提醒
|
|
|
|
|
alarmManager.set(AlarmManager.RTC_WAKEUP, date, pendingIntent);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@ -860,4 +929,4 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
private void showToast(int resId, int duration) {
|
|
|
|
|
Toast.makeText(this, resId, duration).show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} //NOTE: 这一整个文件就是这一个类 @zhoukexing 2023/12/17 23:41
|
|
|
|
|