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

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

@ -60,9 +60,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
NoteColumns.LOCAL_MODIFIED + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.PASSWORD + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.TAG_PASSWORD + " TEXT NOT NULL DEFAULT ''" +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
")";//数据库中需要存储的项目的名称,就相当于创建一个表格的表头的内容。
private static final String CREATE_DATA_TABLE_SQL =
@ -327,16 +325,6 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
oldVersion++;
}
if(oldVersion == 4){
upgradeToV5(db);
oldVersion++;
}
if(oldVersion == 5){
upgradeToV6(db);
oldVersion++;
}
if (reCreateTriggers) {
reCreateNoteTableTriggers(db);
reCreateDataTableTriggers(db);
@ -374,14 +362,4 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ " INTEGER NOT NULL DEFAULT 0");
}//更新到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
private String mContent;
// Note mode
private String mPassword = "";
private String mTag = "";
//note password,initial = 0
private int mMode;
private long mAlertDate;
@ -83,9 +80,7 @@ public class WorkingNote {
NoteColumns.BG_COLOR_ID,
NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE,
NoteColumns.MODIFIED_DATE,
NoteColumns.PASSWORD,
NoteColumns.TAG_PASSWORD
NoteColumns.MODIFIED_DATE
};
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_PASSWORD_COLUMN = 6;
private static final int NOTE_TAG_PASSWORD_COLUMN = 7;
// New note construct
public WorkingNote(Context context, long folderId) {
mContext = context;
@ -152,8 +143,6 @@ public class WorkingNote {
mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN);
mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN);
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
mPassword = cursor.getString(NOTE_PASSWORD_COLUMN);
mTag = cursor.getString(NOTE_TAG_PASSWORD_COLUMN);
}
cursor.close();
// 若不存在,报错
@ -429,16 +418,4 @@ public class WorkingNote {
*/
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;
import android.Manifest;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.PendingIntent;
import android.app.SearchManager;
import android.appwidget.AppWidgetManager;
@ -50,11 +50,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
import android.view.inputmethod.InputMethodManager;
=======
import android.widget.Button;
>>>>>>> 8c352e6399667edb8fde9a423fcc254e47cee228:src/main/java/ui/NoteEditActivity.java
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
@ -100,7 +96,9 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
public ImageView ibSetBgColor;
}
//使用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>();
static {
sBgSelectorBtnsMap.put(R.id.iv_bg_yellow, ResourceParser.YELLOW);
@ -309,8 +307,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
}
private void initNoteScreen() {
//对便签的初始化操作
//对界面的初始化操作
mNoteEditor.setTextAppearance(this, TextAppearanceResources
.getTexAppearanceResource(mFontSizeId));
//设置外观
@ -583,60 +580,14 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
//根据菜单的id来编剧相关项目
<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
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();
case R.id.action_insert_image:
//绑定按钮的点击响应获取危险权限这里的100是申请码可以自己定义整数即可
ActivityCompat.requestPermissions(NoteEditActivity.this, mPermissionList, 100);
//用于获取焦点,否则插入图片时没有响应
mNoteEditor.getFocusable();
mNoteEditor.insertImage(realPathFromUri, realPathFromUri + "\" style=\"max-width:100%");
break;
=======
>>>>>>> 8c352e6399667edb8fde9a423fcc254e47cee228:src/main/java/ui/NoteEditActivity.java
case R.id.menu_new_note:
//创建一个新的便签
createNewNote();
@ -1255,4 +1206,5 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
// mNoteEditor.focusEditor();
// }
// });
}

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

@ -936,7 +936,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (view instanceof NotesListItem) {
final NoteItemData item = ((NotesListItem) view).getItemData();
NoteItemData item = ((NotesListItem) view).getItemData();
if (mNotesListAdapter.isInChoiceMode()) {
if (item.getType() == Notes.TYPE_NOTE) {
position = position - mNotesListView.getHeaderViewsCount();
@ -952,46 +952,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
|| item.getType() == Notes.TYPE_SYSTEM) {
openFolder(item);
} else if (item.getType() == Notes.TYPE_NOTE) {
final AlertDialog.Builder check_password = new AlertDialog.Builder(NotesListActivity.this);
//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 {
Log.e(TAG, "Wrong note type in NOTE_LIST");
}

@ -38,7 +38,6 @@ public class NotesListItem extends LinearLayout {
private TextView mCallName; //
private NoteItemData mItemData; //标签数据
private CheckBox mCheckBox; //打钩框
private ImageView mLocker;//锁图片
/*初始化基本信息*/
public NotesListItem(Context context) {
@ -50,7 +49,6 @@ public class NotesListItem extends LinearLayout {
mTime = (TextView) findViewById(R.id.tv_time);
mCallName = (TextView) findViewById(R.id.tv_name);
mCheckBox = (CheckBox) findViewById(android.R.id.checkbox);
mLocker = (ImageView) findViewById(R.id.iv_locker);
}
///根据data的属性对各个控件的属性的控制主要是可见性Visibility内容setText格式setTextAppearance
public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) {
@ -60,8 +58,8 @@ public class NotesListItem extends LinearLayout {
} else {
mCheckBox.setVisibility(View.GONE);
}
mItemData = data;
mItemData = data;
///设置控件属性一共三种情况由data的id和父id是否与保存到文件夹的id一致来决定
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
mCallName.setVisibility(View.GONE);
@ -84,7 +82,6 @@ public class NotesListItem extends LinearLayout {
} else {
mAlert.setVisibility(View.GONE);
}
} else {
mCallName.setVisibility(View.GONE);
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里编辑的日期中获取
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_gravity="right|center_vertical"
android:layout_marginRight="8dip" />
<ImageButton
<<<<<<< HEAD
android:id="@+id/image_button"
=======
android:id="@+id/btn_set_bg_color"
>>>>>>> 8c352e6399667edb8fde9a423fcc254e47cee228
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
@ -108,11 +103,11 @@
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_gravity="left|top"
android:layout_weight="1"
android:fadingEdgeLength="0dip"
android:scrollbars="none"
android:overScrollMode="never"
android:scrollbars="none">
android:layout_gravity="left|top"
android:fadingEdgeLength="0dip">
<LinearLayout
android:layout_width="fill_parent"
@ -132,12 +127,11 @@
<LinearLayout
android:id="@+id/note_edit_list"
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="-10dip"
android:orientation="vertical"
android:layout_marginLeft="-10dip"
android:visibility="gone" />
</LinearLayout>
</ScrollView>

@ -69,12 +69,6 @@
android:clickable="false"
android:visibility="gone" />
</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
android:id="@+id/iv_alert_icon"

@ -20,12 +20,6 @@
<item
android:id="@+id/action_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
android:id="@+id/menu_new_note"
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_under_visit_mode">Privacy modecan not see note content</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="delete_remind_time_message">Delete reminder successfully</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_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="alert_set_password">Set your password and tag</string>;
<!-- Error information -->
<string name="error_sdcard_unmounted">SD card busy, not available now</string>
<string name="error_sdcard_export">Export failed, please check SD card</string>

Loading…
Cancel
Save