diff --git a/Notes-master/.idea/misc.xml b/Notes-master/.idea/misc.xml index 208e2c3..72f7ca7 100644 --- a/Notes-master/.idea/misc.xml +++ b/Notes-master/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/Notes-master/.idea/vcs.xml b/Notes-master/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Notes-master/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Notes-master/res/menu/note_edit.xml b/Notes-master/res/menu/note_edit.xml index 35cacd1..cb92988 100644 --- a/Notes-master/res/menu/note_edit.xml +++ b/Notes-master/res/menu/note_edit.xml @@ -49,4 +49,7 @@ + \ No newline at end of file diff --git a/Notes-master/res/values-zh-rCN/strings.xml b/Notes-master/res/values-zh-rCN/strings.xml index 09f75ed..fc2dce1 100644 --- a/Notes-master/res/values-zh-rCN/strings.xml +++ b/Notes-master/res/values-zh-rCN/strings.xml @@ -58,6 +58,7 @@ 查看文件夹 刪除文件夹 修改文件夹名称 + 添加图片 文件夹 %1$s 已存在,请重新命名 分享 发送到桌面 diff --git a/Notes-master/res/values/strings.xml b/Notes-master/res/values/strings.xml index 55df868..00521ef 100644 --- a/Notes-master/res/values/strings.xml +++ b/Notes-master/res/values/strings.xml @@ -69,6 +69,7 @@ Delete reminder Select folder Parent folder + add Image Note added to home Confirm to delete folder and its notes? Delete selected notes diff --git a/Notes-master/src/net/micode/notes/ui/NoteEditActivity.java b/Notes-master/src/net/micode/notes/ui/NoteEditActivity.java index 96a9ff8..de98982 100644 --- a/Notes-master/src/net/micode/notes/ui/NoteEditActivity.java +++ b/Notes-master/src/net/micode/notes/ui/NoteEditActivity.java @@ -71,7 +71,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; - +//笔记编辑功能 public class NoteEditActivity extends Activity implements OnClickListener, NoteSettingChangedListener, OnTextViewChangeListener { private class HeadViewHolder { @@ -83,7 +83,7 @@ public class NoteEditActivity extends Activity implements OnClickListener, public ImageView ibSetBgColor; } - + //便签背景选择按钮 private static final Map sBgSelectorBtnsMap = new HashMap(); static { sBgSelectorBtnsMap.put(R.id.iv_bg_yellow, ResourceParser.YELLOW); @@ -150,10 +150,11 @@ public class NoteEditActivity extends Activity implements OnClickListener, private Pattern mPattern; @Override + //创建时进行初始化操作 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + //将布局样式进行添加 this.setContentView(R.layout.note_edit); - if (savedInstanceState == null && !initActivityState(getIntent())) { finish(); return; @@ -162,8 +163,7 @@ public class NoteEditActivity extends Activity implements OnClickListener, } /** - * Current activity may be killed when the memory is low. Once it is killed, for another time - * user load this activity, we should restore the former state + * 当前Activity可能因内存不足被杀死,再次加载时应恢复之前的状态 */ @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { @@ -178,11 +178,10 @@ public class NoteEditActivity extends Activity implements OnClickListener, Log.d(TAG, "Restoring from killed activity"); } } - + //初始化活动状态函数 private boolean initActivityState(Intent intent) { /** - * If the user specified the {@link Intent#ACTION_VIEW} but not provided with id, - * then jump to the NotesListActivity + * 如果用户指定查看笔记但未提供ID,跳转到笔记列表页 */ mWorkingNote = null; if (TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())) { @@ -190,7 +189,7 @@ public class NoteEditActivity extends Activity implements OnClickListener, mUserQuery = ""; /** - * Starting from the searched result + * 如果是从搜索结果启动 */ if (intent.hasExtra(SearchManager.EXTRA_DATA_KEY)) { noteId = Long.parseLong(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY)); @@ -211,11 +210,12 @@ public class NoteEditActivity extends Activity implements OnClickListener, return false; } } + //设置软键盘 getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); } else if(TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) { - // New note + // 新建笔记 long folderId = intent.getLongExtra(Notes.INTENT_EXTRA_FOLDER_ID, 0); int widgetId = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); @@ -224,7 +224,7 @@ public class NoteEditActivity extends Activity implements OnClickListener, int bgResId = intent.getIntExtra(Notes.INTENT_EXTRA_BACKGROUND_ID, ResourceParser.getDefaultBgId(this)); - // Parse call-record note + // 解析通话记录笔记 String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); long callDate = intent.getLongExtra(Notes.INTENT_EXTRA_CALL_DATE, 0); if (callDate != 0 && phoneNumber != null) { @@ -263,11 +263,12 @@ public class NoteEditActivity extends Activity implements OnClickListener, } @Override + //Activity恢复时调用,初始化笔记界面 protected void onResume() { super.onResume(); initNoteScreen(); } - + //设置文本样式、背景等 private void initNoteScreen() { mNoteEditor.setTextAppearance(this, TextAppearanceResources .getTexAppearanceResource(mFontSizeId)); @@ -289,12 +290,11 @@ public class NoteEditActivity extends Activity implements OnClickListener, | DateUtils.FORMAT_SHOW_YEAR)); /** - * TODO: Add the menu for setting alert. Currently disable it because the DateTimePicker - * is not ready + * TODO: 添加设置提醒的菜单,目前因日期选择器未准备好而禁用 */ showAlertHeader(); } - + //显示提醒头部信息,根据是否有提醒的设置显示相应内容 private void showAlertHeader() { if (mWorkingNote.hasClockAlert()) { long time = System.currentTimeMillis(); @@ -313,19 +313,17 @@ public class NoteEditActivity extends Activity implements OnClickListener, } @Override + //重新初始化活动状态 protected void onNewIntent(Intent intent) { super.onNewIntent(intent); initActivityState(intent); } @Override + //用于保存笔记id protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - /** - * For new note without note id, we should firstly save it to - * generate a id. If the editing note is not worth saving, there - * is no id which is equivalent to create new note - */ + //若未保存笔记,则先保存笔记id if (!mWorkingNote.existInDatabase()) { saveNote(); } @@ -334,6 +332,7 @@ public class NoteEditActivity extends Activity implements OnClickListener, } @Override + //添加触摸事件,处理背景颜色和字体大小选项的显示和隐藏 public boolean dispatchTouchEvent(MotionEvent ev) { if (mNoteBgColorSelector.getVisibility() == View.VISIBLE && !inRangeOfView(mNoteBgColorSelector, ev)) { @@ -374,6 +373,7 @@ public class NoteEditActivity extends Activity implements OnClickListener, mNoteEditor = (EditText) findViewById(R.id.note_edit_view); mNoteEditorPanel = findViewById(R.id.sv_note_edit); mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector); + //为控件添加事件监听器,点击时触发当前类的onClick方法 for (int id : sBgSelectorBtnsMap.keySet()) { ImageView iv = (ImageView) findViewById(id); iv.setOnClickListener(this); @@ -387,9 +387,9 @@ public class NoteEditActivity extends Activity implements OnClickListener, mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); mFontSizeId = mSharedPrefs.getInt(PREFERENCE_FONT_SIZE, ResourceParser.BG_DEFAULT_FONT_SIZE); /** - * HACKME: Fix bug of store the resource id in shared preference. - * The id may larger than the length of resources, in this case, - * return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE} + * HACKME: 修复在 SharedPreferences 中存储资源 id 可能出现的问题。 + * * 存储的 id 可能会大于资源数组的长度,在这种情况下, + * * 返回 {@link ResourceParser#BG_DEFAULT_FONT_SIZE} */ if(mFontSizeId >= TextAppearanceResources.getResourcesSize()) { mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE; @@ -398,21 +398,28 @@ public class NoteEditActivity extends Activity implements OnClickListener, } @Override + //当Activity暂停时调用此方法 protected void onPause() { + //调用父类的onPause方法 super.onPause(); + //保存笔记 if(saveNote()) { + //记录日志信息 Log.d(TAG, "Note data was saved with length:" + mWorkingNote.getContent().length()); } + //清除设置状态 clearSettingState(); } - + //更新部件的方法 private void updateWidget() { Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE); + //判断部件的类型,并为intent的目标类设置一定的效果 if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_2X) { intent.setClass(this, NoteWidgetProvider_2x.class); } else if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_4X) { intent.setClass(this, NoteWidgetProvider_4x.class); } else { + //记录错误日志信息 Log.e(TAG, "Unspported widget type"); return; }