Compare commits

...

2 Commits

Author SHA1 Message Date
Joker21a e524c032d9 无注释 功能完全版
2 years ago
Joker21a d33aed2988 1.7
2 years ago

@ -36,12 +36,12 @@
android:icon="@drawable/icon_app"
android:label="@string/app_name" >
<activity
android:name=".ui.NotesListActivity"
android:name=".ui.LoginView"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/NoteTheme"
android:uiOptions="splitActionBarWhenNarrow"
android:theme="@style/NoteTheme"
android:windowSoftInputMode="adjustPan" >
<intent-filter>
@ -50,6 +50,36 @@
</intent-filter>
</activity>
<activity
android:name=".ui.LoginActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
android:uiOptions="splitActionBarWhenNarrow"
android:theme="@style/NoteTheme"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name=".ui.ChangeLoginPasswordActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
android:uiOptions="splitActionBarWhenNarrow"
android:theme="@style/NoteTheme"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name=".ui.NotesListActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
android:uiOptions="splitActionBarWhenNarrow"
android:theme="@style/NoteTheme"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name=".ui.NoteEditActivity"
android:configChanges="keyboardHidden|orientation|screenSize"

@ -41,6 +41,7 @@ public class Notes {
public static final String INTENT_EXTRA_WIDGET_TYPE = "net.micode.notes.widget_type";
public static final String INTENT_EXTRA_FOLDER_ID = "net.micode.notes.folder_id";
public static final String INTENT_EXTRA_CALL_DATE = "net.micode.notes.call_date";
public static final String INTENT_EXTRA_TEMPLE_TEXT="net.micode.notes.temple_text";
public static final int TYPE_WIDGET_INVALIDE = -1;
public static final int TYPE_WIDGET_2X = 0;
@ -165,6 +166,8 @@ public class Notes {
* <P> Type : INTEGER (long) </P>
*/
public static final String VERSION = "version";
public static final String PASSWORD= "password";
}
public interface DataColumns {

@ -30,7 +30,7 @@ import net.micode.notes.data.Notes.NoteColumns;
public class NotesDatabaseHelper extends SQLiteOpenHelper {
private static final String DB_NAME = "note.db";
private static final int DB_VERSION = 4;
private static final int DB_VERSION = 5;
public interface TABLE {
public static final String NOTE = "note";
@ -60,7 +60,8 @@ 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.VERSION + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.PASSWORD + " TEXT DEFAULT NULL " +
")";
private static final String CREATE_DATA_TABLE_SQL =
@ -321,6 +322,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
upgradeToV4(db);
oldVersion++;
}
if(oldVersion == 4){
upgradeToV5(db);
oldVersion++;
}
if (reCreateTriggers) {
reCreateNoteTableTriggers(db);
@ -359,4 +364,9 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ " INTEGER NOT NULL DEFAULT 0");
}
private void upgradeToV5(SQLiteDatabase db){
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.PASSWORD
+ " TEXT DEFAULT NULL ");
}
}

@ -77,8 +77,8 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
NotesListActivity.class), 0);
}
notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
pendingIntent);
// notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
// pendingIntent);
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
}

@ -50,8 +50,9 @@ import net.micode.notes.tool.ResourceParser.NoteBgResources;
*/
public class WorkingNote {
// Note for the working note
//这个在Note里面定义了Note类的基本类型
private Note mNote;
private String mPassword;
private Note mNote;//这个在Note里面定义了Note类的基本类型
// Note Id
private long mNoteId;
// Note content
@ -60,31 +61,25 @@ public class WorkingNote {
private int mMode;
private long mAlertDate;
//最后的修改日期
private long mModifiedDate;
//定义的颜色的ID
private long mModifiedDate;//最后的修改日期
private int mBgColorId;
private int mBgColorId;//定义的颜色的ID
//定义了一个int类型用来定位到哪一个小组件被使用
private int mWidgetId;
private int mWidgetId;//定义了一个int类型用来定位到哪一个小组件被使用
//定义了一个int类型用来区分使用了什么类型的小组件
private int mWidgetType;
private int mWidgetType;//定义了一个int类型用来区分使用了什么类型的小组件
//用来定位便签放在哪个文件夹
private long mFolderId;
private long mFolderId;//用来定位便签放在哪个文件夹
private Context mContext;
//定义为静态变量,保证不能再被更改。防止数据出现异常
private static final String TAG = "WorkingNote";
public boolean PRIVATE_MODE = false;
private static final String TAG = "WorkingNote"; //定义为静态变量,保证不能再被更改。防止数据出现异常
private boolean mIsDeleted; //定义一个布尔变量,用来保存是否要被删除。通过查看用法,发现在后面保存|修改的时候要进行判断。
//定义一个布尔变量,用来保存是否要被删除。通过查看用法,发现在后面保存|修改的时候要进行判断。
private boolean mIsDeleted;
//定义了一个接口具体是在NoteEditActivities中实现实现对于便签是否修改的监听
private NoteSettingChangedListener mNoteSettingStatusListener;
private NoteSettingChangedListener mNoteSettingStatusListener;//定义了一个接口具体是在NoteEditActivities中实现实现对于便签是否修改的监听
/**
* DataColumnDataColumn
* DataColumn便
@ -94,8 +89,7 @@ public class WorkingNote {
* 访访
*/
public static final String[] DATA_PROJECTION = new String[] {
//在Note里面定义一个接口类型
DataColumns.ID,
DataColumns.ID,//在Note里面定义一个接口类型
DataColumns.CONTENT,
DataColumns.MIME_TYPE,
DataColumns.DATA1,
@ -135,18 +129,12 @@ public class WorkingNote {
private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
/**
* @method: WorkingNote
* @description: Note
* @date: 2024/1/6 11:28
* @author:
* @param: [android.content.Context, long]:[context, folderId]
* @return:
*/
private WorkingNote(Context context, long folderId) {
// New note construct
//初始化一个新的操作的Note
private WorkingNote(Context context, long folderId) {
mContext = context;
mAlertDate = 0;//这里为什么是0还存疑
mModifiedDate = System.currentTimeMillis();//获取系统时间,保存给最后修改时间
@ -203,38 +191,23 @@ public class WorkingNote {
}
loadNoteData();
}
/**
* @method: loadNoteData
* @description: selection,MIME
* @date: 2024/1/6 11:29
* @author:
* @param: []:[]
* @return: void
*/
//基本同上一个函数。值得注意的是这里对数据进行了筛选通过selection,还对MIME进行了判断后加载
private void loadNoteData() {
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
DataColumns.NOTE_ID + "=?", new String[] {
String.valueOf(mNoteId)
}, null);
if (cursor != null) {
// 检查是否有数据
if (cursor.moveToFirst()) {
do {
// 获取类型
String type = cursor.getString(DATA_MIME_TYPE_COLUMN);
if (DataConstants.NOTE.equals(type)) {
// 获取内容
mContent = cursor.getString(DATA_CONTENT_COLUMN);
// 获取模式
mMode = cursor.getInt(DATA_MODE_COLUMN);
// 获取ID
mNote.setTextDataId(cursor.getLong(DATA_ID_COLUMN));
} else if (DataConstants.CALL_NOTE.equals(type)) {
// 设置通话ID
mNote.setCallDataId(cursor.getLong(DATA_ID_COLUMN));
} else {
Log.d(TAG, "Wrong note type with type:" + type);
@ -247,49 +220,23 @@ public class WorkingNote {
throw new IllegalArgumentException("Unable to find note's data with id " + mNoteId);
}
}
/**
* @method: createEmptyNote
* @description:
* @date: 2024/1/2 10:21
* @author:
* @param: [android.content.Context, long, int, int, int]:[context, folderId, widgetId, widgetType, defaultBgColorId]
* @return: net.micode.notes.model.WorkingNote
*/
public static WorkingNote createEmptyNote(Context context, long folderId, int widgetId,
//简单的初始化函数,一会看一下用法
public static WorkingNote createEmptyNote(Context context, long folderId, int widgetId,
int widgetType, int defaultBgColorId) {
// 创建一个新的WorkingNote实例
WorkingNote note = new WorkingNote(context, folderId);
// 设置笔记的背景颜色
note.setBgColorId(defaultBgColorId);
// 设置笔记的widgetId
note.setWidgetId(widgetId);
// 设置笔记的widgetType
note.setWidgetType(widgetType);
// 返回新的WorkingNote实例
return note;
}
public static WorkingNote load(Context context, long id) {
return new WorkingNote(context, id, 0);
}
/**
* @method: saveNote
* @description:
* @date: 2024/1/2 10:23
* @author:
* @param: []:[]
* @return: boolean
*/
public synchronized boolean saveNote() {
// 如果笔记 worth saving
//这里涉及了多线程的操作。
public synchronized boolean saveNote() {
if (isWorthSaving()) {
// 如果笔记不存在数据库中
if (!existInDatabase()) {
// 获取新笔记id
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
Log.e(TAG, "Create new note fail with id:" + mNoteId);
return false;
@ -322,18 +269,7 @@ public synchronized boolean saveNote() {
return mNoteId > 0;
}
/**
* @method: isWorthSaving
* @description:
* @date: 2024/1/2 10:24
* @author:
* @param: []:[]
* @return: boolean
*/
private boolean isWorthSaving() {
if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
|| (existInDatabase() && !mNote.isLocalModified())) {
return false;
@ -341,19 +277,8 @@ public synchronized boolean saveNote() {
return true;
}
}
/**
* @method: setOnSettingStatusChangedListener
* @description:
* @date: 2024/1/2 10:24
* @author:
* @param: [net.micode.notes.model.WorkingNote.NoteSettingChangedListener]:[l]
* @return: void
*/
//这个变量设置是用来记录状态设定是否有发生过更改。
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
mNoteSettingStatusListener = l;
}
@ -384,18 +309,8 @@ public synchronized boolean saveNote() {
mNote.setNoteValue(NoteColumns.BG_COLOR_ID, String.valueOf(id));
}
}
/**
* @method: setCheckListMode
* @description: EditActivities使list
* @date: 2024/1/6 11:30
* @author:
* @param: [int]:[mode]
* @return: void
*/
//在EditActivities中使用用来设定在list时的状态
public void setCheckListMode(int mode) {
if (mMode != mode) {
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onCheckListModeChanged(mMode, mode);
@ -439,6 +354,10 @@ public synchronized boolean saveNote() {
mNote.setCallData(CallNote.PHONE_NUMBER, phoneNumber);
mNote.setNoteValue(NoteColumns.PARENT_ID, String.valueOf(Notes.ID_CALL_RECORD_FOLDER));
}
public void setPassword(String password){
// mPassword=password;
mNote.setNoteValue(NoteColumns.PASSWORD,password);
}
public boolean hasClockAlert() {
return (mAlertDate > 0 ? true : false);
@ -487,6 +406,8 @@ public synchronized boolean saveNote() {
public int getWidgetType() {
return mWidgetType;
}
public String getPassword() { return mPassword; }
//声明了一个接口具体都在EditActivies中进行实现。主要是一个监听listener来设置各个量的改变
public interface NoteSettingChangedListener {
/**

@ -30,6 +30,8 @@ public class ResourceParser {
public static final int GREEN = 3;
public static final int RED = 4;
public static final int DUCK = 5;
public static final int BG_DEFAULT_COLOR = YELLOW;
public static final int TEXT_SMALL = 0;
@ -45,7 +47,10 @@ public class ResourceParser {
R.drawable.edit_blue,
R.drawable.edit_white,
R.drawable.edit_green,
R.drawable.edit_red
R.drawable.edit_red,
R.drawable.note_bg_photo_wangyi
};
private final static int [] BG_EDIT_TITLE_RESOURCES = new int [] {
@ -53,7 +58,9 @@ public class ResourceParser {
R.drawable.edit_title_blue,
R.drawable.edit_title_white,
R.drawable.edit_title_green,
R.drawable.edit_title_red
R.drawable.edit_title_red,
R.drawable.note_bg_photo_wangyi
};
public static int getNoteBgResource(int id) {
@ -80,7 +87,8 @@ public class ResourceParser {
R.drawable.list_blue_up,
R.drawable.list_white_up,
R.drawable.list_green_up,
R.drawable.list_red_up
R.drawable.list_red_up,
R.drawable.note_bg_photo_wangyi
};
private final static int [] BG_NORMAL_RESOURCES = new int [] {
@ -88,7 +96,8 @@ public class ResourceParser {
R.drawable.list_blue_middle,
R.drawable.list_white_middle,
R.drawable.list_green_middle,
R.drawable.list_red_middle
R.drawable.list_red_middle,
R.drawable.note_bg_photo_wangyi
};
private final static int [] BG_LAST_RESOURCES = new int [] {
@ -97,6 +106,7 @@ public class ResourceParser {
R.drawable.list_white_down,
R.drawable.list_green_down,
R.drawable.list_red_down,
R.drawable.note_bg_photo_wangyi
};
private final static int [] BG_SINGLE_RESOURCES = new int [] {
@ -104,7 +114,8 @@ public class ResourceParser {
R.drawable.list_blue_single,
R.drawable.list_white_single,
R.drawable.list_green_single,
R.drawable.list_red_single
R.drawable.list_red_single,
R.drawable.note_bg_photo_wangyi
};
public static int getNoteBgFirstRes(int id) {

@ -0,0 +1,127 @@
package net.micode.notes.ui;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.app.SearchManager;
import android.appwidget.AppWidgetManager;
import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Paint;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.style.BackgroundColorSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.TextNote;
import net.micode.notes.model.WorkingNote;
import net.micode.notes.model.WorkingNote.NoteSettingChangedListener;
import net.micode.notes.tool.DataUtils;
import net.micode.notes.tool.ResourceParser;
import net.micode.notes.tool.ResourceParser.TextAppearanceResources;
import net.micode.notes.ui.DateTimePickerDialog.OnDateTimeSetListener;
import net.micode.notes.ui.NoteEditText.OnTextViewChangeListener;
import net.micode.notes.widget.NoteWidgetProvider_2x;
import net.micode.notes.widget.NoteWidgetProvider_4x;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class ChangeLoginPasswordActivity extends Activity {
EditText OldPassword;
EditText NewPassword;
EditText ReWritePassword;
Button Acknowledged;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.change_login_password_activity);
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
| WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
OldPassword=(EditText) findViewById(R.id.old_password);
NewPassword=(EditText) findViewById(R.id.new_password);
ReWritePassword=(EditText) findViewById(R.id.ack_password);
Acknowledged=(Button)findViewById(R.id.Bt_Acknowledged);
Acknowledged.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String old_password = OldPassword.getText().toString();
String new_password = NewPassword.getText().toString();
String ack_password = ReWritePassword.getText().toString();
SharedPreferences pref=getSharedPreferences("user management",MODE_PRIVATE);
String login_password=pref.getString("password","");
if(old_password.equals("")==true || new_password.equals("")==true || ack_password.equals("")==true) {
Toast.makeText(ChangeLoginPasswordActivity.this, "密码不能为空", Toast.LENGTH_SHORT).show();
}else if (new_password.equals(ack_password) == false) {
Toast.makeText(ChangeLoginPasswordActivity.this, "新建密码与重复密码不匹配,请重新输入密码", Toast.LENGTH_SHORT).show();
ReWritePassword.setText("");
}else if(old_password.equals(login_password) == false){
Toast.makeText(ChangeLoginPasswordActivity.this, "原有密码错误,请重新输入密码", Toast.LENGTH_SHORT).show();
OldPassword.setText("");
}
else if (new_password.equals(ack_password) == true && old_password.equals(login_password) == true){
SharedPreferences.Editor editor=getSharedPreferences("user management", MODE_PRIVATE).edit();
editor.putString("password",new_password);
editor.apply();
Toast.makeText(ChangeLoginPasswordActivity.this, "修改密码成功", Toast.LENGTH_SHORT).show();
Intent intent=new Intent(ChangeLoginPasswordActivity.this, LoginActivity.class);
startActivity(intent);
finish();
}
}
});
}
@Override
public void onBackPressed() {
Intent intent=new Intent(ChangeLoginPasswordActivity.this, LoginActivity.class);
startActivity(intent);
finish();
}
}

@ -0,0 +1,163 @@
package net.micode.notes.ui;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.app.SearchManager;
import android.appwidget.AppWidgetManager;
import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.style.BackgroundColorSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.TextNote;
import net.micode.notes.model.WorkingNote;
import net.micode.notes.model.WorkingNote.NoteSettingChangedListener;
import net.micode.notes.tool.DataUtils;
import net.micode.notes.tool.ResourceParser;
import net.micode.notes.tool.ResourceParser.TextAppearanceResources;
import net.micode.notes.ui.DateTimePickerDialog.OnDateTimeSetListener;
import net.micode.notes.ui.NoteEditText.OnTextViewChangeListener;
import net.micode.notes.widget.NoteWidgetProvider_2x;
import net.micode.notes.widget.NoteWidgetProvider_4x;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class LoginActivity extends Activity{
private EditText accountEdit;
private EditText passwordEdit;
private Button login;
private Button cancel;
private Button change;
private long last_login_time = 0 ;
public static final long MAX_LOGIN_TIME = 9999999;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
SharedPreferences pref=getSharedPreferences("user management",MODE_PRIVATE);
boolean user_boolean = pref.getBoolean("user",false);//获取用户是否设置了密码
if(!user_boolean) //User_boolean = false时没有设置密码直接跳转到便签主界面
{
SharedPreferences.Editor editor=getSharedPreferences("user management", MODE_PRIVATE).edit();
editor.putString("password","123456");
editor.putBoolean("user",true);
editor.apply();
}
SharedPreferences login_time_get = getSharedPreferences("login time",MODE_PRIVATE);
boolean is_first_login = login_time_get.getBoolean("is_first_login",false);
setContentView(R.layout.login_activity);
accountEdit = (EditText) findViewById(R.id.account);
passwordEdit = (EditText) findViewById(R.id.password);
login = (Button) findViewById(R.id.login);
cancel = (Button) findViewById(R.id.cancel);
change = (Button) findViewById(R.id.change_password);
long current_time = System.currentTimeMillis();
cancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(LoginActivity.this, R.string.app_already_quit, Toast.LENGTH_LONG).show();
finish();
}
});
Long current_login_time = login_time_get.getLong("current login time",0);
if((is_first_login)&&(current_time - current_login_time <= MAX_LOGIN_TIME)){
SharedPreferences.Editor editor=getSharedPreferences("login time", MODE_PRIVATE).edit();
editor.putLong("current login time",System.currentTimeMillis());
editor.apply();
Intent intent = new Intent(LoginActivity.this,NotesListActivity.class);
startActivity(intent);
finish();
}
else{
if(!is_first_login){
SharedPreferences.Editor editor=getSharedPreferences("login time", MODE_PRIVATE).edit();
editor.putLong("current login time",System.currentTimeMillis());
editor.putBoolean("is_first_login",true);
editor.apply();
}
login.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
String account = accountEdit.getText().toString();
String password = passwordEdit.getText().toString();
SharedPreferences pref=getSharedPreferences("user management",MODE_PRIVATE);
String share_password=pref.getString("password","");
if(account.equals("hei") && password.equals(share_password)){
ProgressDialog progressDialog = new ProgressDialog(LoginActivity.this);
progressDialog.setTitle(R.string.Loading);
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(true);
progressDialog.show();;
Intent intent = new Intent(LoginActivity.this,NotesListActivity.class);
startActivity(intent);
finish();
}else {
Toast.makeText(LoginActivity.this, R.string.invalid,Toast.LENGTH_SHORT).show();
}
}
});
change.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(LoginActivity.this,ChangeLoginPasswordActivity.class);
startActivity(intent);
finish();
}
});
}
}
}

@ -0,0 +1,76 @@
package net.micode.notes.ui;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.app.SearchManager;
import android.appwidget.AppWidgetManager;
import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.style.BackgroundColorSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.TextNote;
import net.micode.notes.model.WorkingNote;
import net.micode.notes.model.WorkingNote.NoteSettingChangedListener;
import net.micode.notes.tool.DataUtils;
import net.micode.notes.tool.ResourceParser;
import net.micode.notes.tool.ResourceParser.TextAppearanceResources;
import net.micode.notes.ui.DateTimePickerDialog.OnDateTimeSetListener;
import net.micode.notes.ui.NoteEditText.OnTextViewChangeListener;
import net.micode.notes.widget.NoteWidgetProvider_2x;
import net.micode.notes.widget.NoteWidgetProvider_4x;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class LoginView extends Activity
{
Handler mHandler=new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_view);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(LoginView.this, LoginActivity.class);
startActivity(intent);
finish();
}
},2000);
}
}

@ -19,6 +19,7 @@ package net.micode.notes.ui;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.PendingIntent;
import android.app.SearchManager;
import android.appwidget.AppWidgetManager;
@ -28,6 +29,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.Spannable;
@ -43,6 +45,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
@ -68,6 +71,7 @@ import net.micode.notes.widget.NoteWidgetProvider_4x;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -91,6 +95,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
sBgSelectorBtnsMap.put(R.id.iv_bg_blue, ResourceParser.BLUE);
sBgSelectorBtnsMap.put(R.id.iv_bg_green, ResourceParser.GREEN);
sBgSelectorBtnsMap.put(R.id.iv_bg_white, ResourceParser.WHITE);
sBgSelectorBtnsMap.put(R.id.iv_ph_duck, ResourceParser.DUCK);
}
private static final Map<Integer, Integer> sBgSelectorSelectionMap = new HashMap<Integer, Integer>();
@ -100,8 +106,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
sBgSelectorSelectionMap.put(ResourceParser.BLUE, R.id.iv_bg_blue_select);
sBgSelectorSelectionMap.put(ResourceParser.GREEN, R.id.iv_bg_green_select);
sBgSelectorSelectionMap.put(ResourceParser.WHITE, R.id.iv_bg_white_select);
}
sBgSelectorSelectionMap.put(ResourceParser.DUCK, R.id.iv_ph_duck_select);
}//
//选择便签字体大小的界选择器的吧
private static final Map<Integer, Integer> sFontSizeBtnsMap = new HashMap<Integer, Integer>();
static {
sFontSizeBtnsMap.put(R.id.ll_font_large, ResourceParser.TEXT_LARGE);
@ -269,11 +277,20 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
private void initNoteScreen() {
String defaultText = getIntent().getStringExtra(Notes.INTENT_EXTRA_TEMPLE_TEXT);
if(defaultText!=null){
saveNote();//否则会增加一个null的奇怪现象
mWorkingNote.setWorkingText(mWorkingNote.getContent()+defaultText);
mNoteEditor.setText(mWorkingNote.getContent()); // 将defaultText的值写入到笔记编辑器中
}
// Toast.makeText(getApplicationContext(), defaultText, Toast.LENGTH_SHORT).show();
mNoteEditor.setTextAppearance(this, TextAppearanceResources
.getTexAppearanceResource(mFontSizeId));
if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
switchToListMode(mWorkingNote.getContent());
} else {
;
mNoteEditor.setText(getHighlightQueryResult(mWorkingNote.getContent(), mUserQuery));
mNoteEditor.setSelection(mNoteEditor.getText().length());
}
@ -287,6 +304,43 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mWorkingNote.getModifiedDate(), DateUtils.FORMAT_SHOW_DATE
| DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME
| DateUtils.FORMAT_SHOW_YEAR));
// String mPassword=mWorkingNote.getPassword();
// if (mWorkingNote.getPassword()!=null){
// final AlertDialog.Builder builder = new AlertDialog.Builder(this);
// View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
// //编辑Text
// final EditText etName = (EditText) view.findViewById(R.id.et_foler_name);
// etName.setText("");
// etName.setHint("请输入密码");
// builder.setTitle("密码检验");
// builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// //获取输入的字符串
// String password = etName.getText().toString();
// Log.d("mPassword: ", mPassword);
// Log.d("password: ", password);
// //判断密码正确性
// if (!password.equals(mPassword)) {
// Log.d("密码不正确,正确密码是:",mPassword);
// dialog.dismiss();
// onBackPressed();
// }
// }
// });
// builder.setNegativeButton("cancel", new DialogInterface.OnClickListener(){
// @Override
// public void onClick(DialogInterface dialog, int which) {
// dialog.dismiss();
// onBackPressed();
// }
// });
// final Dialog dialog = builder.setView(view).show();
// dialog.show();
// }
// else{
// Toast.makeText(NoteEditActivity.this,"还没有设置密码", Toast.LENGTH_SHORT).show();
// }
/**
* TODO: Add the menu for setting alert. Currently disable it because the DateTimePicker
@ -540,6 +594,39 @@ public class NoteEditActivity extends Activity implements OnClickListener,
} else if (itemId == R.id.menu_delete_remind) {
mWorkingNote.setAlertDate(0, false);
}
else if (itemId == R.id.menu_enter_private_mode){
if(mWorkingNote.getPassword()==null){
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text,null);
final EditText etName = (EditText)view.findViewById(R.id.et_foler_name);
etName.setText("");
etName.setHint("请输入密码");
builder.setTitle("为便签设置新密码");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String password = etName.getText().toString();
mWorkingNote.setPassword(password);
if ( mWorkingNote.getPassword() != null ){
Toast.makeText(NoteEditActivity.this,"密码设置成功", Toast.LENGTH_SHORT).show();
}
InputMethodManager inputMethodManager =(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
dialog.dismiss();
}
});
builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
}
});
final Dialog dialog = builder.setView(view).show();
}
}
return true;
}

@ -39,7 +39,7 @@ public class NoteItemData {
NoteColumns.SNIPPET,
NoteColumns.TYPE,
NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE,
NoteColumns.WIDGET_TYPE, NoteColumns.PASSWORD
};
private static final int ID_COLUMN = 0;
@ -54,6 +54,7 @@ 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 long mId;
private long mAlertDate;
@ -70,6 +71,8 @@ public class NoteItemData {
private String mName;
private String mPhoneNumber;
private String mPassword;
private boolean mIsLastItem;
private boolean mIsFirstItem;
private boolean mIsOnlyOneItem;
@ -91,6 +94,8 @@ 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);
mPhoneNumber = "";
if (mParentId == Notes.ID_CALL_RECORD_FOLDER) {
@ -197,6 +202,9 @@ public class NoteItemData {
public int getType() {
return mType;
}
public String getmPassword(){
return mPassword;
}
public int getWidgetType() {
return mWidgetType;
@ -221,4 +229,11 @@ public class NoteItemData {
public static int getNoteType(Cursor cursor) {
return cursor.getInt(TYPE_COLUMN);
}
public boolean hasPassword(){
if(mPassword.length()!=0&&mPassword!=null){
return true;
}
return false;
}
}

File diff suppressed because it is too large Load Diff

@ -32,6 +32,7 @@ import net.micode.notes.tool.ResourceParser.NoteItemBgResources;
public class NotesListItem extends LinearLayout {
private ImageView mAlert;
private ImageView mLock;
private TextView mTitle;
private TextView mTime;
private TextView mCallName;
@ -84,8 +85,16 @@ public class NotesListItem extends LinearLayout {
+ context.getString(R.string.format_folder_files_count,
data.getNotesCount()));
mAlert.setVisibility(View.GONE);
// if(data.has)
} else {
mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet()));
if(data.getmPassword()==null){
mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet()));
}else {
mTitle.setText("便签已加密");
}
//
// mTitle.setText("Jiami");
if (data.hasAlert()) {
mAlert.setImageResource(R.drawable.clock);
mAlert.setVisibility(View.VISIBLE);

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 789 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输入原有密码:"/>
<EditText
android:id="@+id/old_password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输入新建密码:"/>
<EditText
android:id="@+id/new_password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="再次输入密码:"/>
<EditText
android:id="@+id/ack_password"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/Bt_Acknowledged"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.LoginActivity"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="center">
<TextView
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="18sp"
android:text="@string/prompt_account" />
<EditText
android:id="@+id/account"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="center">
<TextView
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/prompt_password"
android:textSize="18sp" />
<EditText
android:id="@+id/password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:inputType="textPassword" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="center">
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/prompt_login" />
<Button
android:id="@+id/cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/cancel" />
<Button
android:id="@+id/change_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text='修改密码'/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,23 @@
<?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"
android:background="@drawable/login_view_photo_2">
<TextView
android:id="@+id/login_view_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:keepScreenOn="true"
android:text="快放假了家人们"
android:textSize="50sp"
android:textStyle="bold"
android:textColor="#1CAC78"
/>
</LinearLayout>

@ -0,0 +1,18 @@
<?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/editTextText"
android:layout_width="match_parent"
android:layout_height="182dp"
android:layout_weight="@android:dimen/dialog_min_width_major"
android:ems="20"
android:gravity="center"
android:inputType="text"
android:text="选择你的模版"
android:textSize="50sp"
android:visibility="visible" />
</LinearLayout>

@ -46,6 +46,12 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@drawable/title_alert" />
<!-- <ImageView-->
<!-- android:id="@+id/iv_alert_lock"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="center_vertical"-->
<!-- android:background="@drawable/lock_private" />-->
<TextView
android:id="@+id/tv_alert_date"
@ -127,7 +133,7 @@
android:id="@+id/note_bg_color_selector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/note_edit_color_selector_panel"
android:background="@drawable/note_edit_color_selector_panel_test"
android:layout_marginTop="30dip"
android:layout_marginRight="8dip"
android:layout_gravity="top|right"
@ -235,6 +241,26 @@
android:visibility="gone"
android:src="@drawable/selected" />
</FrameLayout>
<FrameLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="@+id/iv_ph_duck"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/iv_ph_duck_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:focusable="false"
android:visibility="gone"
android:src="@drawable/selected" />
</FrameLayout>
</LinearLayout>
<LinearLayout

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<EditText
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/set_password"
android:layout_width="fill_parent"
android:hint="@string/hint_foler_name"
android:layout_height="fill_parent" />

@ -49,4 +49,9 @@
<item
android:id="@+id/menu_delete_remind"
android:title="@string/menu_remove_remind" />
<item
android:id="@+id/menu_enter_private_mode"
android:title="Enter private mode"/>
</menu>

@ -21,4 +21,7 @@
<item
android:id="@+id/menu_new_note"
android:title="@string/notelist_menu_new"/>
</menu>
<item
android:id="@+id/menu_new_folder"
android:title="@string/menu_create_folder"/>
</menu>

@ -132,4 +132,16 @@
<item quantity="other"><xliff:g id="number" example="15">%1$s</xliff:g> results for \"<xliff:g id="search" example="???">%2$s</xliff:g>\"</item>
</plurals>
<string name="login_view_text">玛卡巴卡斗志昂扬</string>
<string name="activity_login_view">LoginView</string>
<string name="prompt_account">用户名:</string>
<string name="prompt_password">密码:</string>
<string name="prompt_login">登录</string>
<string name="cancel">取消</string>
<string name="app_already_quit">程序已退出</string>
<string name="Loading">正在登录,你给我等着</string>
<string name="invalid">有人抢银行啦</string>
<string name="font_mode_change">Font mode change</string>
</resources>

@ -63,7 +63,7 @@
</style>
<style name="NoteActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:displayOptions" />
<item name="android:visibility">gone</item>
<!--<item name="android:displayOptions"/>-->
<item name="android:visibility">visible</item>
</style>
</resources>
</resources>

Loading…
Cancel
Save