pull/1/head
1172104155@qq.com 3 years ago
parent e64b753472
commit 7fd9f6eefa

@ -16,6 +16,7 @@
package net.micode.notes.data; package net.micode.notes.data;
import android.content.ContentUris;
import android.net.Uri; import android.net.Uri;
// Notes 类中定义了很多常量这些常量大多是int型和string型 // Notes 类中定义了很多常量这些常量大多是int型和string型
public class Notes { public class Notes {
@ -192,12 +193,6 @@ AUTHORITY + "/data");//定义查找数据的指针。
* <P> Type : INTEGER (long) </P> * <P> Type : INTEGER (long) </P>
*/ */
public static final String VERSION = "version"; public static final String VERSION = "version";
/**
*passwored
*
*/
public static final String PASSWORD = "set_password";//设置密码的什么东西啊?
public static final String TAG_PASSWORD = "set_tag";
}//这些常量主要是定义便签的属性的。 }//这些常量主要是定义便签的属性的。
// 定义DataColumns的常量,用于后面创建数据库的表头 // 定义DataColumns的常量,用于后面创建数据库的表头

@ -60,9 +60,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
NoteColumns.LOCAL_MODIFIED + " INTEGER NOT NULL DEFAULT 0," + NoteColumns.LOCAL_MODIFIED + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," + NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," + NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0," + NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
NoteColumns.PASSWORD + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.TAG_PASSWORD + " TEXT NOT NULL DEFAULT ''" +
")";//数据库中需要存储的项目的名称,就相当于创建一个表格的表头的内容。 ")";//数据库中需要存储的项目的名称,就相当于创建一个表格的表头的内容。
private static final String CREATE_DATA_TABLE_SQL = private static final String CREATE_DATA_TABLE_SQL =
@ -327,16 +325,6 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
oldVersion++; oldVersion++;
} }
if(oldVersion == 4){
upgradeToV5(db);
oldVersion++;
}
if(oldVersion == 5){
upgradeToV6(db);
oldVersion++;
}
if (reCreateTriggers) { if (reCreateTriggers) {
reCreateNoteTableTriggers(db); reCreateNoteTableTriggers(db);
reCreateDataTableTriggers(db); reCreateDataTableTriggers(db);
@ -374,14 +362,4 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ " INTEGER NOT NULL DEFAULT 0"); + " INTEGER NOT NULL DEFAULT 0");
}//更新到V4版本,但是不知道V2、V3、V4是什么意思 }//更新到V4版本,但是不知道V2、V3、V4是什么意思
private void upgradeToV5(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.PASSWORD
+ " INTEGER NOT NULL DEFAULT 0");
}
private void upgradeToV6(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.TAG_PASSWORD
+ " INTEGER NOT NULL DEFAULT 0");
}
} }

@ -40,9 +40,6 @@ public class WorkingNote {
// Note content // Note content
private String mContent; private String mContent;
// Note mode // Note mode
private String mPassword = "";
private String mTag = "";
//note password,initial = 0
private int mMode; private int mMode;
private long mAlertDate; private long mAlertDate;
@ -83,9 +80,7 @@ public class WorkingNote {
NoteColumns.BG_COLOR_ID, NoteColumns.BG_COLOR_ID,
NoteColumns.WIDGET_ID, NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE, NoteColumns.WIDGET_TYPE,
NoteColumns.MODIFIED_DATE, NoteColumns.MODIFIED_DATE
NoteColumns.PASSWORD,
NoteColumns.TAG_PASSWORD
}; };
private static final int DATA_ID_COLUMN = 0; private static final int DATA_ID_COLUMN = 0;
@ -108,10 +103,6 @@ public class WorkingNote {
private static final int NOTE_MODIFIED_DATE_COLUMN = 5; private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
private static final int NOTE_PASSWORD_COLUMN = 6;
private static final int NOTE_TAG_PASSWORD_COLUMN = 7;
// New note construct // New note construct
public WorkingNote(Context context, long folderId) { public WorkingNote(Context context, long folderId) {
mContext = context; mContext = context;
@ -152,8 +143,6 @@ public class WorkingNote {
mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN); mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN);
mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN); mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN);
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN); mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
mPassword = cursor.getString(NOTE_PASSWORD_COLUMN);
mTag = cursor.getString(NOTE_TAG_PASSWORD_COLUMN);
} }
cursor.close(); cursor.close();
// 若不存在,报错 // 若不存在,报错
@ -429,16 +418,4 @@ public class WorkingNote {
*/ */
void onCheckListModeChanged(int oldMode, int newMode); void onCheckListModeChanged(int oldMode, int newMode);
} }
/**便
*
* @param password 访
*/
public void setPassword(String password,String tag){
mPassword = password;
mTag = tag;
mNote.setNoteValue(NoteColumns.PASSWORD,String.valueOf(mPassword));
mNote.setNoteValue(NoteColumns.TAG_PASSWORD,String.valueOf(mTag));
}
} }

@ -17,10 +17,10 @@
package net.micode.notes.ui; package net.micode.notes.ui;
import android.Manifest; import android.Manifest;
import android.speech.tts.TextToSpeech.OnInitListener; import android.speech.tts.TextToSpeech.OnInitListener;
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;
@ -50,11 +50,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;
<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
import android.view.inputmethod.InputMethodManager;
=======
import android.widget.Button; import android.widget.Button;
>>>>>>> 8c352e6399667edb8fde9a423fcc254e47cee228:src/main/java/ui/NoteEditActivity.java
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;
@ -100,7 +96,9 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
public ImageView ibSetBgColor; public ImageView ibSetBgColor;
} }
//使用Map实现数据存储 //使用Map实现数据存储
final String[] mPermissionList = new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE};
private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>(); private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>();
static { static {
sBgSelectorBtnsMap.put(R.id.iv_bg_yellow, ResourceParser.YELLOW); sBgSelectorBtnsMap.put(R.id.iv_bg_yellow, ResourceParser.YELLOW);
@ -309,8 +307,7 @@ 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));
//设置外观 //设置外观
@ -583,60 +580,14 @@ 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来编剧相关项目
<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java case R.id.action_insert_image:
case R.id.locker: //绑定按钮的点击响应获取危险权限这里的100是申请码可以自己定义整数即可
//为便签上锁 ActivityCompat.requestPermissions(NoteEditActivity.this, mPermissionList, 100);
final AlertDialog.Builder create_password = new AlertDialog.Builder(this); //用于获取焦点,否则插入图片时没有响应
//创建关于上锁操作的对话框 mNoteEditor.getFocusable();
final View view = LayoutInflater.from(this).inflate(R.layout.buttom,null); mNoteEditor.insertImage(realPathFromUri, realPathFromUri + "\" style=\"max-width:100%");
//???
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; break;
=======
>>>>>>> 8c352e6399667edb8fde9a423fcc254e47cee228:src/main/java/ui/NoteEditActivity.java
case R.id.menu_new_note: case R.id.menu_new_note:
//创建一个新的便签 //创建一个新的便签
createNewNote(); createNewNote();
@ -1255,4 +1206,5 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
// mNoteEditor.focusEditor(); // mNoteEditor.focusEditor();
// } // }
// }); // });
} }

@ -40,8 +40,6 @@ public class NoteItemData {
NoteColumns.TYPE, NoteColumns.TYPE,
NoteColumns.WIDGET_ID, NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE, NoteColumns.WIDGET_TYPE,
NoteColumns.PASSWORD,
NoteColumns.TAG_PASSWORD
}; };
//常量标记和数据就不一一标记了,意义翻译基本就知道 //常量标记和数据就不一一标记了,意义翻译基本就知道
private static final int ID_COLUMN = 0; private static final int ID_COLUMN = 0;
@ -56,8 +54,6 @@ public class NoteItemData {
private static final int TYPE_COLUMN = 9; private static final int TYPE_COLUMN = 9;
private static final int WIDGET_ID_COLUMN = 10; private static final int WIDGET_ID_COLUMN = 10;
private static final int WIDGET_TYPE_COLUMN = 11; private static final int WIDGET_TYPE_COLUMN = 11;
private static final int PASSWORD_COLUMN = 12;
private static final int TAG_PASSWORD_COLUMN = 13;
private long mId; private long mId;
private long mAlertDate; private long mAlertDate;
@ -71,8 +67,6 @@ public class NoteItemData {
private int mType; private int mType;
private int mWidgetId; private int mWidgetId;
private int mWidgetType; private int mWidgetType;
private String mPassword;
private String mTAG;
private String mName; private String mName;
private String mPhoneNumber; private String mPhoneNumber;
@ -98,8 +92,6 @@ public class NoteItemData {
mType = cursor.getInt(TYPE_COLUMN); mType = cursor.getInt(TYPE_COLUMN);
mWidgetId = cursor.getInt(WIDGET_ID_COLUMN); mWidgetId = cursor.getInt(WIDGET_ID_COLUMN);
mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN); mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);
mPassword = cursor.getString(PASSWORD_COLUMN);
mTAG = cursor.getString(TAG_PASSWORD_COLUMN);
//初始化电话号码的信息 //初始化电话号码的信息
mPhoneNumber = ""; mPhoneNumber = "";
@ -128,7 +120,7 @@ public class NoteItemData {
mIsMultiNotesFollowingFolder = false; mIsMultiNotesFollowingFolder = false;
mIsOneNoteFollowingFolder = false; mIsOneNoteFollowingFolder = false;
//主要是设置上述2个标记 //主要是设置上诉2标记
if (mType == Notes.TYPE_NOTE && !mIsFirstItem) {//若是note格式并且不是第一个元素 if (mType == Notes.TYPE_NOTE && !mIsFirstItem) {//若是note格式并且不是第一个元素
int position = cursor.getPosition(); int position = cursor.getPosition();
if (cursor.moveToPrevious()) {//获取光标位置后看上一行 if (cursor.moveToPrevious()) {//获取光标位置后看上一行
@ -227,8 +219,6 @@ public class NoteItemData {
return (mAlertDate > 0); return (mAlertDate > 0);
} }
public String getPassword() { return mPassword;}
//若数据父id为保存至文件夹模式的id且满足电话号码单元不为空则isCallRecord为true //若数据父id为保存至文件夹模式的id且满足电话号码单元不为空则isCallRecord为true
public boolean isCallRecord() { public boolean isCallRecord() {
return (mParentId == Notes.ID_CALL_RECORD_FOLDER && !TextUtils.isEmpty(mPhoneNumber)); return (mParentId == Notes.ID_CALL_RECORD_FOLDER && !TextUtils.isEmpty(mPhoneNumber));
@ -237,8 +227,4 @@ public class NoteItemData {
public static int getNoteType(Cursor cursor) { public static int getNoteType(Cursor cursor) {
return cursor.getInt(TYPE_COLUMN); return cursor.getInt(TYPE_COLUMN);
} }
public boolean hasPassword() { return mPassword.equals("") ;}
public String getmTAG() {return mTAG;}
} }

@ -160,8 +160,8 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
@Override @Override
// 返回一些子模块完成的数据交给主Activity处理 // 返回一些子模块完成的数据交给主Activity处理
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// 结果值 和 要求值 符合要求 // 结果值 和 要求值 符合要求
if (resultCode == RESULT_OK if (resultCode == RESULT_OK
&& (requestCode == REQUEST_CODE_OPEN_NODE || requestCode == REQUEST_CODE_NEW_NODE)) { && (requestCode == REQUEST_CODE_OPEN_NODE || requestCode == REQUEST_CODE_NEW_NODE)) {
mNotesListAdapter.changeCursor(null); mNotesListAdapter.changeCursor(null);
} else { } else {
@ -171,15 +171,15 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
} }
private void setAppInfoFromRawRes() { private void setAppInfoFromRawRes() {
// Android平台给我们提供了一个SharedPreferences类它是一个轻量级的存储类特别适合用于保存软件配置参数。 // Android平台给我们提供了一个SharedPreferences类它是一个轻量级的存储类特别适合用于保存软件配置参数。
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
if (!sp.getBoolean(PREFERENCE_ADD_INTRODUCTION, false)) { if (!sp.getBoolean(PREFERENCE_ADD_INTRODUCTION, false)) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
InputStream in = null; InputStream in = null;
try { try {
// 把资源文件放到应用程序的/raw/raw下那么就可以在应用中使用getResources获取资源后, // 把资源文件放到应用程序的/raw/raw下那么就可以在应用中使用getResources获取资源后,
// 以openRawResource方法不带后缀的资源文件名打开这个文件。 // 以openRawResource方法不带后缀的资源文件名打开这个文件。
in = getResources().openRawResource(R.raw.introduction); in = getResources().openRawResource(R.raw.introduction);
if (in != null) { if (in != null) {
InputStreamReader isr = new InputStreamReader(in); InputStreamReader isr = new InputStreamReader(in);
BufferedReader br = new BufferedReader(isr); BufferedReader br = new BufferedReader(isr);
@ -205,14 +205,14 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
} }
} }
} }
// 创建空的WorkingNote // 创建空的WorkingNote
WorkingNote note = WorkingNote.createEmptyNote(this, Notes.ID_ROOT_FOLDER, WorkingNote note = WorkingNote.createEmptyNote(this, Notes.ID_ROOT_FOLDER,
AppWidgetManager.INVALID_APPWIDGET_ID, Notes.TYPE_WIDGET_INVALIDE, AppWidgetManager.INVALID_APPWIDGET_ID, Notes.TYPE_WIDGET_INVALIDE,
ResourceParser.RED); ResourceParser.RED);
note.setWorkingText(sb.toString()); note.setWorkingText(sb.toString());
if (note.saveNote()) { if (note.saveNote()) {
// 更新保存note的信息 // 更新保存note的信息
sp.edit().putBoolean(PREFERENCE_ADD_INTRODUCTION, true).commit(); sp.edit().putBoolean(PREFERENCE_ADD_INTRODUCTION, true).commit();
} else { } else {
Log.e(TAG, "Save introduction note error"); Log.e(TAG, "Save introduction note error");
@ -232,7 +232,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
mContentResolver = this.getContentResolver(); // 获取应用程序的数据,得到类似数据表的东西 mContentResolver = this.getContentResolver(); // 获取应用程序的数据,得到类似数据表的东西
mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver()); mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver());
mCurrentFolderId = Notes.ID_ROOT_FOLDER; mCurrentFolderId = Notes.ID_ROOT_FOLDER;
// findViewById 是安卓编程的定位函数,主要是引用.R文件里的引用名 // findViewById 是安卓编程的定位函数,主要是引用.R文件里的引用名
mNotesListView = (ListView) findViewById(R.id.notes_list); // 绑定XML中的ListView作为Item的容器 mNotesListView = (ListView) findViewById(R.id.notes_list); // 绑定XML中的ListView作为Item的容器
mNotesListView.addFooterView(LayoutInflater.from(this).inflate(R.layout.note_list_footer, null), mNotesListView.addFooterView(LayoutInflater.from(this).inflate(R.layout.note_list_footer, null),
@ -330,7 +330,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
} }
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
boolean checked) { boolean checked) {
mNotesListAdapter.setCheckedItem(position, checked); mNotesListAdapter.setCheckedItem(position, checked);
updateMenu(); updateMenu();
} }
@ -348,14 +348,14 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
builder.setTitle(getString(R.string.alert_title_delete)); builder.setTitle(getString(R.string.alert_title_delete));
builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setMessage(getString(R.string.alert_message_delete_notes, builder.setMessage(getString(R.string.alert_message_delete_notes,
mNotesListAdapter.getSelectedCount())); mNotesListAdapter.getSelectedCount()));
builder.setPositiveButton(android.R.string.ok, builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog,
int which) { int which) {
batchDelete(); batchDelete();
} }
}); });
builder.setNegativeButton(android.R.string.cancel, null); builder.setNegativeButton(android.R.string.cancel, null);
builder.show(); builder.show();
break; break;
@ -436,7 +436,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
: NORMAL_SELECTION; : NORMAL_SELECTION;
mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null, mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] { Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] {
String.valueOf(mCurrentFolderId) String.valueOf(mCurrentFolderId)
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC"); }, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
} }
@ -647,7 +647,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
values.put(NoteColumns.LOCAL_MODIFIED, 1); values.put(NoteColumns.LOCAL_MODIFIED, 1);
mContentResolver.update(Notes.CONTENT_NOTE_URI, values, NoteColumns.ID mContentResolver.update(Notes.CONTENT_NOTE_URI, values, NoteColumns.ID
+ "=?", new String[] { + "=?", new String[] {
String.valueOf(mFocusNoteDataItem.getId()) String.valueOf(mFocusNoteDataItem.getId())
}); });
} }
} else if (!TextUtils.isEmpty(name)) { } else if (!TextUtils.isEmpty(name)) {
@ -693,25 +693,25 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
*/ */
@Override @Override
public void onBackPressed() { switch (mState) { public void onBackPressed() { switch (mState) {
case SUB_FOLDER: case SUB_FOLDER:
mCurrentFolderId = Notes.ID_ROOT_FOLDER; mCurrentFolderId = Notes.ID_ROOT_FOLDER;
mState = ListEditState.NOTE_LIST; mState = ListEditState.NOTE_LIST;
startAsyncNotesListQuery(); startAsyncNotesListQuery();
mTitleBar.setVisibility(View.GONE); mTitleBar.setVisibility(View.GONE);
break; break;
case CALL_RECORD_FOLDER: case CALL_RECORD_FOLDER:
mCurrentFolderId = Notes.ID_ROOT_FOLDER; mCurrentFolderId = Notes.ID_ROOT_FOLDER;
mState = ListEditState.NOTE_LIST; mState = ListEditState.NOTE_LIST;
mAddNewNote.setVisibility(View.VISIBLE); mAddNewNote.setVisibility(View.VISIBLE);
mTitleBar.setVisibility(View.GONE); mTitleBar.setVisibility(View.GONE);
startAsyncNotesListQuery(); startAsyncNotesListQuery();
break; break;
case NOTE_LIST: case NOTE_LIST:
super.onBackPressed(); super.onBackPressed();
break; break;
default: default:
break; break;
} }
} }
/** /**
@ -731,7 +731,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
} }
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] { intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] {
appWidgetId appWidgetId
}); });
sendBroadcast(intent); sendBroadcast(intent);
@ -936,7 +936,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (view instanceof NotesListItem) { if (view instanceof NotesListItem) {
final NoteItemData item = ((NotesListItem) view).getItemData(); NoteItemData item = ((NotesListItem) view).getItemData();
if (mNotesListAdapter.isInChoiceMode()) { if (mNotesListAdapter.isInChoiceMode()) {
if (item.getType() == Notes.TYPE_NOTE) { if (item.getType() == Notes.TYPE_NOTE) {
position = position - mNotesListView.getHeaderViewsCount(); position = position - mNotesListView.getHeaderViewsCount();
@ -952,46 +952,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
|| item.getType() == Notes.TYPE_SYSTEM) { || item.getType() == Notes.TYPE_SYSTEM) {
openFolder(item); openFolder(item);
} else if (item.getType() == Notes.TYPE_NOTE) { } else if (item.getType() == Notes.TYPE_NOTE) {
final AlertDialog.Builder check_password = new AlertDialog.Builder(NotesListActivity.this); openNode(item);
//this is what???
final View view_check = LayoutInflater.from(NotesListActivity.this).inflate(R.layout.dialog_edit_text,null);
final EditText etName = (EditText)view_check.findViewById(R.id.et_foler_name);
if (item.hasPassword()){
openNode(item);
}
else{
etName.setText("");
etName.setHint(" Input the right password");
check_password.setTitle("Check your password");
check_password.setPositiveButton("Cancel", new DialogInterface.OnClickListener() {//设置Cancel按钮
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(NotesListActivity.this,"Canceling...",Toast.LENGTH_SHORT).show();
InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
}
});
check_password.setNegativeButton("OK", new DialogInterface.OnClickListener() {//设置OK按钮
@Override
public void onClick(DialogInterface dialog, int which) {
String password = etName.getText().toString();
if (password.equals(item.getPassword())){
Toast.makeText(NotesListActivity.this,"Oh!!!You are right!",Toast.LENGTH_SHORT).show();
InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
dialog.dismiss();
openNode(item);
}
else {
Toast.makeText(NotesListActivity.this,"You are wrong...",Toast.LENGTH_SHORT).show();
}
}
});
final Dialog dialog = check_password.setView(view_check).show();//view is wrong
dialog.show();
}
} else { } else {
Log.e(TAG, "Wrong note type in NOTE_LIST"); Log.e(TAG, "Wrong note type in NOTE_LIST");
} }
@ -1018,7 +979,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
private void startQueryDestinationFolders() { private void startQueryDestinationFolders() {
String selection = NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>? AND " + NoteColumns.ID + "<>?"; String selection = NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>? AND " + NoteColumns.ID + "<>?";
selection = (mState == ListEditState.NOTE_LIST) ? selection: selection = (mState == ListEditState.NOTE_LIST) ? selection:
"(" + selection + ") OR (" + NoteColumns.ID + "=" + Notes.ID_ROOT_FOLDER + ")"; "(" + selection + ") OR (" + NoteColumns.ID + "=" + Notes.ID_ROOT_FOLDER + ")";
mBackgroundQueryHandler.startQuery(FOLDER_LIST_QUERY_TOKEN, mBackgroundQueryHandler.startQuery(FOLDER_LIST_QUERY_TOKEN,
null, null,

@ -38,7 +38,6 @@ public class NotesListItem extends LinearLayout {
private TextView mCallName; // private TextView mCallName; //
private NoteItemData mItemData; //标签数据 private NoteItemData mItemData; //标签数据
private CheckBox mCheckBox; //打钩框 private CheckBox mCheckBox; //打钩框
private ImageView mLocker;//锁图片
/*初始化基本信息*/ /*初始化基本信息*/
public NotesListItem(Context context) { public NotesListItem(Context context) {
@ -50,7 +49,6 @@ public class NotesListItem extends LinearLayout {
mTime = (TextView) findViewById(R.id.tv_time); mTime = (TextView) findViewById(R.id.tv_time);
mCallName = (TextView) findViewById(R.id.tv_name); mCallName = (TextView) findViewById(R.id.tv_name);
mCheckBox = (CheckBox) findViewById(android.R.id.checkbox); mCheckBox = (CheckBox) findViewById(android.R.id.checkbox);
mLocker = (ImageView) findViewById(R.id.iv_locker);
} }
///根据data的属性对各个控件的属性的控制主要是可见性Visibility内容setText格式setTextAppearance ///根据data的属性对各个控件的属性的控制主要是可见性Visibility内容setText格式setTextAppearance
public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) { public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) {
@ -60,8 +58,8 @@ public class NotesListItem extends LinearLayout {
} else { } else {
mCheckBox.setVisibility(View.GONE); mCheckBox.setVisibility(View.GONE);
} }
mItemData = data;
mItemData = data;
///设置控件属性一共三种情况由data的id和父id是否与保存到文件夹的id一致来决定 ///设置控件属性一共三种情况由data的id和父id是否与保存到文件夹的id一致来决定
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) { if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
mCallName.setVisibility(View.GONE); mCallName.setVisibility(View.GONE);
@ -84,7 +82,6 @@ public class NotesListItem extends LinearLayout {
} else { } else {
mAlert.setVisibility(View.GONE); mAlert.setVisibility(View.GONE);
} }
} else { } else {
mCallName.setVisibility(View.GONE); mCallName.setVisibility(View.GONE);
mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem); mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem);
@ -104,16 +101,6 @@ public class NotesListItem extends LinearLayout {
} }
} }
} }
mLocker.setImageResource(R.drawable.title_locker);
if (data.hasPassword()){
mLocker.setVisibility(GONE);
}
else {
mLocker.setVisibility(VISIBLE);
String text = " 不给你看哟~" + " (tag:" + data.getmTAG() + ")";
mTitle.setText(text);
}
///设置内容获取相关时间从data里编辑的日期中获取 ///设置内容获取相关时间从data里编辑的日期中获取
mTime. setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate())); mTime. setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate()));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 958 B

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
<EditText
android:id="@+id/tag"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
</LinearLayout>

@ -72,13 +72,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical" android:layout_gravity="right|center_vertical"
android:layout_marginRight="8dip" /> android:layout_marginRight="8dip" />
<ImageButton <ImageButton
<<<<<<< HEAD
android:id="@+id/image_button"
=======
android:id="@+id/btn_set_bg_color" android:id="@+id/btn_set_bg_color"
>>>>>>> 8c352e6399667edb8fde9a423fcc254e47cee228
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center" android:layout_gravity="center"
@ -108,11 +103,11 @@
<ScrollView <ScrollView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="0dip" android:layout_height="0dip"
android:layout_gravity="left|top"
android:layout_weight="1" android:layout_weight="1"
android:fadingEdgeLength="0dip" android:scrollbars="none"
android:overScrollMode="never" android:overScrollMode="never"
android:scrollbars="none"> android:layout_gravity="left|top"
android:fadingEdgeLength="0dip">
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -132,12 +127,11 @@
<LinearLayout <LinearLayout
android:id="@+id/note_edit_list" android:id="@+id/note_edit_list"
android:layout_width="wrap_content" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="-10dip"
android:orientation="vertical" android:orientation="vertical"
android:layout_marginLeft="-10dip"
android:visibility="gone" /> android:visibility="gone" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

@ -69,12 +69,6 @@
android:clickable="false" android:clickable="false"
android:visibility="gone" /> android:visibility="gone" />
</LinearLayout> </LinearLayout>
<ImageView
android:id="@+id/iv_locker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@drawable/title_locker" />
<ImageView <ImageView
android:id="@+id/iv_alert_icon" android:id="@+id/iv_alert_icon"

@ -20,12 +20,6 @@
<item <item
android:id="@+id/action_insert_image" android:id="@+id/action_insert_image"
android:title="insert image"/> android:title="insert image"/>
<item
android:id="@+id/locker"
android:title="@string/note_lock"/>
<item
android:id="@+id/unlocker"
android:title="@string/note_unlock"/>
<item <item
android:id="@+id/menu_new_note" android:id="@+id/menu_new_note"
android:title="@string/notelist_menu_new"/> android:title="@string/notelist_menu_new"/>

@ -24,8 +24,6 @@
<string name="widget_havenot_content">No associated note found, click to create associated note.</string> <string name="widget_havenot_content">No associated note found, click to create associated note.</string>
<string name="widget_under_visit_mode">Privacy modecan not see note content</string> <string name="widget_under_visit_mode">Privacy modecan not see note content</string>
<string name="notelist_string_info">...</string> <string name="notelist_string_info">...</string>
<string name="note_lock">Lock</string>
<string name="note_unlock">Unlock</string>
<string name="notelist_menu_new">Add note</string> <string name="notelist_menu_new">Add note</string>
<string name="delete_remind_time_message">Delete reminder successfully</string> <string name="delete_remind_time_message">Delete reminder successfully</string>
<string name="set_remind_time_message">Set reminder</string> <string name="set_remind_time_message">Set reminder</string>
@ -79,8 +77,6 @@
<string name="alert_message_delete_notes">Confirm to delete the selected %d notes?</string> <string name="alert_message_delete_notes">Confirm to delete the selected %d notes?</string>
<string name="alert_message_delete_note">Confirm to delete this note?</string> <string name="alert_message_delete_note">Confirm to delete this note?</string>
<string name="format_move_notes_to_folder">Have moved selected %1$d notes to %2$s folder</string> <string name="format_move_notes_to_folder">Have moved selected %1$d notes to %2$s folder</string>
<string name="alert_set_password">Set your password and tag</string>;
<!-- Error information --> <!-- Error information -->
<string name="error_sdcard_unmounted">SD card busy, not available now</string> <string name="error_sdcard_unmounted">SD card busy, not available now</string>
<string name="error_sdcard_export">Export failed, please check SD card</string> <string name="error_sdcard_export">Export failed, please check SD card</string>

Loading…
Cancel
Save