|
|
|
@ -18,6 +18,7 @@ package net.micode.notes.ui;
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.AlarmManager;
|
|
|
|
import android.app.AlarmManager;
|
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.app.AlertDialog;
|
|
|
|
|
|
|
|
import android.app.Dialog;
|
|
|
|
import android.app.PendingIntent;
|
|
|
|
import android.app.PendingIntent;
|
|
|
|
import android.app.SearchManager;
|
|
|
|
import android.app.SearchManager;
|
|
|
|
import android.appwidget.AppWidgetManager;
|
|
|
|
import android.appwidget.AppWidgetManager;
|
|
|
|
@ -45,6 +46,7 @@ import android.view.MotionEvent;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View.OnClickListener;
|
|
|
|
import android.view.View.OnClickListener;
|
|
|
|
import android.view.WindowManager;
|
|
|
|
import android.view.WindowManager;
|
|
|
|
|
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
|
import android.widget.CheckBox;
|
|
|
|
import android.widget.CheckBox;
|
|
|
|
import android.widget.CompoundButton;
|
|
|
|
import android.widget.CompoundButton;
|
|
|
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
|
|
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
|
|
|
@ -294,7 +296,8 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void initNoteScreen() {
|
|
|
|
private void initNoteScreen() {
|
|
|
|
//对界面的初始化操作
|
|
|
|
|
|
|
|
|
|
|
|
//对便签的初始化操作
|
|
|
|
mNoteEditor.setTextAppearance(this, TextAppearanceResources
|
|
|
|
mNoteEditor.setTextAppearance(this, TextAppearanceResources
|
|
|
|
.getTexAppearanceResource(mFontSizeId));
|
|
|
|
.getTexAppearanceResource(mFontSizeId));
|
|
|
|
//设置外观
|
|
|
|
//设置外观
|
|
|
|
@ -550,6 +553,56 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
//根据菜单的id来编剧相关项目
|
|
|
|
//根据菜单的id来编剧相关项目
|
|
|
|
|
|
|
|
case R.id.locker:
|
|
|
|
|
|
|
|
//为便签上锁
|
|
|
|
|
|
|
|
final AlertDialog.Builder create_password = new AlertDialog.Builder(this);
|
|
|
|
|
|
|
|
//创建关于上锁操作的对话框
|
|
|
|
|
|
|
|
final View view = LayoutInflater.from(this).inflate(R.layout.buttom,null);
|
|
|
|
|
|
|
|
//???
|
|
|
|
|
|
|
|
final EditText etName = (EditText)view.findViewById(R.id.password);
|
|
|
|
|
|
|
|
final EditText etTag = (EditText)view.findViewById(R.id.tag);
|
|
|
|
|
|
|
|
//???
|
|
|
|
|
|
|
|
etName.setText("");
|
|
|
|
|
|
|
|
etName.setHint(" Please input your password");
|
|
|
|
|
|
|
|
etTag.setText("");
|
|
|
|
|
|
|
|
etTag.setHint(" Please input your tag");
|
|
|
|
|
|
|
|
create_password.setTitle(getString(R.string.alert_set_password));
|
|
|
|
|
|
|
|
//设置标题为Set your password
|
|
|
|
|
|
|
|
create_password.setNegativeButton("OK", new DialogInterface.OnClickListener() {//设置监听,获取输入的字符串
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
|
|
|
String password = etName.getText().toString();
|
|
|
|
|
|
|
|
String tag = etTag.getText().toString();
|
|
|
|
|
|
|
|
//获取输入的字符串
|
|
|
|
|
|
|
|
mWorkingNote.setPassword(password,tag);
|
|
|
|
|
|
|
|
//设置密码
|
|
|
|
|
|
|
|
Toast.makeText(NoteEditActivity.this,"Password created successfully",Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
//设置密码成功的消息弹窗
|
|
|
|
|
|
|
|
InputMethodManager inputMethodManager = (InputMethodManager)
|
|
|
|
|
|
|
|
getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
|
|
|
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
|
|
|
|
|
|
|
|
//关闭软键盘
|
|
|
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
|
|
|
//关闭dialog
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
create_password.setPositiveButton("Cancel", new DialogInterface.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
|
|
|
//关闭软键盘
|
|
|
|
|
|
|
|
Toast.makeText(NoteEditActivity.this,"Canceling...",Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
InputMethodManager inputMethodManager = (InputMethodManager)
|
|
|
|
|
|
|
|
getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
|
|
|
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
final Dialog dialog = create_password.setView(view).show();//error
|
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R.id.unlocker:
|
|
|
|
|
|
|
|
mWorkingNote.setPassword("","");
|
|
|
|
|
|
|
|
Toast.makeText(NoteEditActivity.this,"Password unlocked successfully",Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
|
break;
|
|
|
|
case R.id.menu_new_note:
|
|
|
|
case R.id.menu_new_note:
|
|
|
|
//创建一个新的便签
|
|
|
|
//创建一个新的便签
|
|
|
|
createNewNote();
|
|
|
|
createNewNote();
|
|
|
|
|