dongjiaqi_branch
djq 1 year ago
parent 1b8f3c93d4
commit 206821f8f4

@ -20,7 +20,6 @@
android:versionCode="1"
android:versionName="0.1" >
<uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
@ -35,21 +34,74 @@
<application
android:icon="@drawable/icon_app"
android:label="@string/app_name" >
<activity
android:name=".ui.NotesListActivity"
android:name=".ui.LoginActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/NoteTheme"
android:uiOptions="splitActionBarWhenNarrow"
android:windowSoftInputMode="adjustPan" >
<!--android:uiOptions="splitActionBarWhenNarrow"-->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.ChangePassword"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/NoteTheme"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name=".ui.CreatePassword"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/NoteTheme"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name=".ui.DeletePassword"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/NoteTheme"
android:windowSoftInputMode="adjustPan" >
</activity>
<!-- <activity
android:name=".ui.SearchActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
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:theme="@style/NoteTheme"
android:windowSoftInputMode="adjustPan" >
<!--android:uiOptions="splitActionBarWhenNarrow"-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity
android:name=".ui.NoteEditActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
@ -57,33 +109,39 @@
android:theme="@style/NoteTheme" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.INSERT_OR_EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/text_note" />
<data android:mimeType="vnd.android.cursor.item/call_note" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.INSERT_OR_EDIT" />
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/text_note" />
<data android:mimeType="vnd.android.cursor.item/call_note" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/text_note" />
<data android:mimeType="vnd.android.cursor.item/call_note" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<!-- <meta-data>必须包括android:name这个属性而且其值必须为"android.app.searchable"-->
<!-- 还必须包括android:resource这个属性它指定了我们的search dialog的配置文件。-->
</activity>
<provider
android:name="net.micode.notes.data.NotesProvider"
android:authorities="micode_notes"
android:multiprocess="true" />
android:exported="false"
android:multiprocess="true">
</provider>
<receiver
android:name=".widget.NoteWidgetProvider_2x"
@ -98,6 +156,7 @@
android:name="android.appwidget.provider"
android:resource="@xml/widget_2x_info" />
</receiver>
<receiver
android:name=".widget.NoteWidgetProvider_4x"
android:label="@string/app_widget4x4" >
@ -146,5 +205,6 @@
<meta-data
android:name="android.app.default_searchable"
android:value=".ui.NoteEditActivity" />
</application>
</manifest>
</manifest>

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)

@ -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="200dp"
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="200dp"
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="200dp"
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,38 @@
<?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="200dp"
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,56 @@
<?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/lg_user"-->
<!-- android:layout_width="150dp"-->
<!-- android:layout_height="wrap_content" />-->
<!-- </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/lg_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/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"/>
<!-- <Button-->
<!-- android:id="@+id/lg_registered"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="注册"/>-->
</LinearLayout>
</LinearLayout>

@ -0,0 +1,54 @@
<?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/rg_password01"
android:layout_width="200dp"
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/rg_password02"
android:layout_width="200dp"
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/rg_registered"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认"/>
</LinearLayout>
</LinearLayout>

@ -24,8 +24,7 @@
android:layout_width="120dip"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
/>
android:focusableInTouchMode="true" />
<NumberPicker
android:id="@+id/hour"

@ -15,9 +15,8 @@
limitations under the License.
-->
<EditText
xmlns:android="http://schemas.android.com/apk/res/android"
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/et_foler_name"
android:layout_width="fill_parent"
android:hint="@string/hint_foler_name"
android:layout_height="fill_parent" />
android:layout_height="fill_parent"
android:hint="@string/hint_foler_name" />

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="100dp"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 子控件内容 -->
<EditText
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/et_foler_name"
android:layout_width="fill_parent"
android:hint="@string/hint_foler_name"
android:layout_height="fill_parent" />
</LinearLayout>

@ -33,11 +33,11 @@
<TextView
android:id="@+id/tv_modified_date"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="361dp"
android:layout_height="match_parent"
android:layout_gravity="left|center_vertical"
android:layout_marginRight="8dip"
android:layout_weight="1"
android:textAppearance="@style/TextAppearanceSecondaryItem" />
<ImageView
@ -71,7 +71,7 @@
<ImageView
android:layout_width="fill_parent"
android:layout_height="7dip"
android:layout_height="30dp"
android:background="@drawable/bg_color_btn_mask" />
<ScrollView
@ -92,6 +92,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left|top"
android:typeface="serif"
android:background="@null"
android:autoLink="all"
android:linksClickable="false"
@ -118,10 +119,10 @@
<ImageView
android:id="@+id/btn_set_bg_color"
android:layout_height="43dip"
android:layout_width="wrap_content"
android:background="@drawable/bg_color_btn_mask"
android:layout_gravity="top|right" />
android:layout_height="47dp"
android:layout_gravity="top|right"
android:background="@drawable/bg_color_btn_mask" />
<LinearLayout
android:id="@+id/note_bg_color_selector"

@ -36,6 +36,7 @@
android:singleLine="true"
android:textColor="#FFEAD1AE"
android:textSize="@dimen/text_font_size_medium" />
<!-- GONE 隐藏,不可见并且不占用位置-->
<ListView
android:id="@+id/notes_list"
@ -43,9 +44,9 @@
android:layout_height="0dip"
android:layout_weight="1"
android:cacheColorHint="@null"
android:listSelector="@android:color/transparent"
android:divider="@null"
android:fadingEdge="@null" />
android:fadingEdge="@null"
android:listSelector="@android:color/transparent" />
</LinearLayout>
<Button
@ -55,4 +56,5 @@
android:layout_height="wrap_content"
android:focusable="false"
android:layout_gravity="bottom" />
<!-- 写便签按钮的实现-->
</FrameLayout>

@ -18,6 +18,10 @@
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_font_change"
android:title="@string/menu_font_change" />
<item
android:id="@+id/menu_delete"
android:title="@string/menu_delete" />

@ -15,8 +15,12 @@
limitations under the License.
-->
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_font_change"
android:title="@string/menu_font_change" />
<item
android:id="@+id/menu_new_note"
@ -49,4 +53,6 @@
<item
android:id="@+id/menu_delete_remind"
android:title="@string/menu_remove_remind" />
</menu>

@ -36,4 +36,21 @@
<item
android:id="@+id/menu_search"
android:title="@string/menu_search"/>
<item
android:id="@+id/menu_secret"
android:title="Set_secret" />
<item
android:id="@+id/menu_quit_secret"
android:title="Quit_secret" />
<item
android:id="@+id/menu_createlogin"
android:title="CreateLogin" />
<item
android:id="@+id/menu_deletelogin"
android:title="Deletelogin" />
<item
android:id="@+id/menu_changelogin"
android:title="Changelogin" />
</menu>

@ -21,4 +21,13 @@
<item
android:id="@+id/menu_new_note"
android:title="@string/notelist_menu_new"/>
<item
android:id="@+id/menu_secret"
android:title="Set_secret"/>
<item
android:id="@+id/menu_quit_secret"
android:title="Quit_secret"/>
</menu>

@ -17,6 +17,10 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="Set_secret">私密模式</string>
<string name="Quit_secret">退出私密模式</string>
<string name="app_name">便签</string>
<string name="app_widget2x2">便签2x2</string>
<string name="app_widget4x4">便签4x4</string>

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
@ -17,6 +17,9 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="Set_secret">私密模式</string>
<string name="Quit_secret">退出私密模式</string>
<string name="app_name">便簽</string>
<string name="app_widget2x2">便簽2x2</string>
<string name="app_widget4x4">便簽4x4</string>

@ -20,5 +20,5 @@
<dimen name="text_font_size_large">26sp</dimen>
<dimen name="text_font_size_medium">20sp</dimen>
<dimen name="text_font_size_normal">17sp</dimen>
<dimen name="text_font_size_small">14sp</dimen>
<dimen name="text_font_size_small">14sp</dimen>x
</resources>

@ -47,6 +47,7 @@
<string name="menu_setting">Settings</string>
<string name="menu_search">Search</string>
<string name="menu_delete">Delete</string>
<string name="menu_font_change">Font_change</string>
<string name="menu_move">Move to folder</string>
<string name="menu_select_title">%d selected</string>
<string name="menu_select_none">Nothing selected, the operation is invalid</string>
@ -120,6 +121,10 @@
<string name="call_record_folder_name">Call notes</string>
<string name="hint_foler_name">Input name</string>
<string name="Set_secret">私密模式</string>
<string name="Quit_secret">退出私密模式</string>
<string name="search_label">Searching Notes</string>
<string name="search_hint">Search notes</string>
<string name="search_setting_description">Text in your notes</string>

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

@ -35,7 +35,6 @@ public class Notes {
public static final int TYPE_NOTE = 0;
public static final int TYPE_FOLDER = 1;
public static final int TYPE_SYSTEM = 2;
/**
* Following IDs are system folders' identifiers
* {@link Notes#ID_ROOT_FOLDER } is default folder
@ -103,7 +102,6 @@ public class Notes {
*/
public static final String MODIFIED_DATE = "modified_date";
/**
* Alert date
* <P> Type: INTEGER (long) </P>
@ -185,8 +183,8 @@ public class Notes {
}
/**
* DataColumns
* 访使便
* DataColumns便
* 访便使便便
*/
public interface DataColumns {
/**
@ -260,6 +258,7 @@ public class Notes {
* <P> Type: TEXT </P>
*/
public static final String DATA5 = "data5";
}
/**

@ -77,9 +77,9 @@ 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,
/** notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
pendingIntent);
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);**/
}
@Override

@ -35,6 +35,7 @@ import java.util.ArrayList;
public class Note {
private ContentValues mNoteDiffValues;
private NoteData mNoteData;
private static final String TAG = "Note";

@ -78,7 +78,8 @@ public class WorkingNote {
NoteColumns.BG_COLOR_ID,
NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE,
NoteColumns.MODIFIED_DATE
NoteColumns.MODIFIED_DATE,
// NoteColumns.PASSWORD
};
private static final int DATA_ID_COLUMN = 0;
@ -101,6 +102,9 @@ public class WorkingNote {
private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
// New note construct
private WorkingNote(Context context, long folderId) {
mContext = context;
@ -130,13 +134,14 @@ public class WorkingNote {
null, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
if (cursor.moveToFirst()) {//从数据库查询结果中提取相关数据,并进行相应的处理和赋值操作。
mFolderId = cursor.getLong(NOTE_PARENT_ID_COLUMN);
mBgColorId = cursor.getInt(NOTE_BG_COLOR_ID_COLUMN);
mWidgetId = cursor.getInt(NOTE_WIDGET_ID_COLUMN);
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);
}
cursor.close();
} else {
@ -146,7 +151,7 @@ public class WorkingNote {
loadNoteData();
}
private void loadNoteData() {
private void loadNoteData() {//加载便签数据
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
DataColumns.NOTE_ID + "=?", new String[] {
String.valueOf(mNoteId)
@ -174,6 +179,7 @@ public class WorkingNote {
}
}
//创建一个空白的新建便签
public static WorkingNote createEmptyNote(Context context, long folderId, int widgetId,
int widgetType, int defaultBgColorId) {
WorkingNote note = new WorkingNote(context, folderId);
@ -183,7 +189,7 @@ public class WorkingNote {
return note;
}
public static WorkingNote load(Context context, long id) {
public static WorkingNote load(Context context, long id) {//加载一个已经存在便签来创建一个工作便签对象
return new WorkingNote(context, id, 0);
}
@ -287,7 +293,6 @@ public class WorkingNote {
mNote.setTextData(DataColumns.CONTENT, mContent);
}
}
public void convertToCallNote(String phoneNumber, long callDate) {
mNote.setCallData(CallNote.CALL_DATE, String.valueOf(callDate));
mNote.setCallData(CallNote.PHONE_NUMBER, phoneNumber);
@ -333,7 +338,11 @@ public class WorkingNote {
public long getFolderId() {
return mFolderId;
}
/*
public String getmPassword() {
return mPassword;
}
*/
public int getWidgetId() {
return mWidgetId;
}

@ -0,0 +1,81 @@
package net.micode.notes.ui;
import android.annotation.SuppressLint;
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;
import net.micode.notes.R;
public class ChangePassword extends Activity{
EditText OldPassword;//声明了旧密码的文本编辑框
EditText NewPassword;
EditText AckPassword;//确认密码
Button Acknowledged;//声明了一个确认按钮
@SuppressLint("MissingInflatedId")//使用注解忽略缺少的布局资源ID的警告。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);//调用父类的onCreate方法
setContentView(R.layout.activity_change_loginpassword);//按照所给的布局文件进行当前页面布局
//设置软键盘的显示模式通过findViewById方法来获取布局文件中各种文本编辑框和按钮
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);
AckPassword=(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 = AckPassword.getText().toString();
//用getSharedPreferences方法来获取名为“user management”的对象用来存储数据
//从SharedPreferences中来获取密码值作为登录密码
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(ChangePassword.this, "密码不能为空", Toast.LENGTH_SHORT).show();//进行一个消息提示
}
else if (new_password.equals(ack_password) == false) {
Toast.makeText(ChangePassword.this, "新建密码与重复密码不匹配,请重新输入密码", Toast.LENGTH_SHORT).show();
AckPassword.setText("");//清空文本框
}
else if(old_password.equals(login_password) == false){
Toast.makeText(ChangePassword.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(ChangePassword.this, "修改密码成功", Toast.LENGTH_SHORT).show();
Intent intent=new Intent(ChangePassword.this,NotesListActivity.class);//创建一个意图对象
startActivity(intent);//用该意图对象来启动NotesListActivity类
finish();//结束当前的活动
}
}
});
}
/*
@Override
public void onBackPressed() {
Intent intent=new Intent(ChangePassword.this,NotesListActivity.class);
startActivity(intent);
finish();
}
*/
}

@ -0,0 +1,71 @@
package net.micode.notes.ui;
import android.annotation.SuppressLint;
import android.view.View;//可视化界面
import android.app.Activity;//完成函数周期
import android.view.WindowManager;
import android.widget.Button;//实现按钮
import android.widget.EditText;//输入显示
import android.widget.Toast;//设计让登录界面无法被跳过
import android.os.Bundle;//获取输入密码
import android.content.SharedPreferences;
import android.content.Intent;//数据交互
import android.util.Log;
import net.micode.notes.R;
public class CreatePassword extends Activity {
EditText password01;
EditText password02;
Button registered;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_set_loginpassword);
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
| WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
password01=(EditText) findViewById(R.id.rg_password01);
password02=(EditText) findViewById(R.id.rg_password02);
registered=(Button)findViewById(R.id.rg_registered);
registered.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String text02 = password01.getText().toString();
String text03 = password02.getText().toString();
if(text02.equals("")==true) {
Toast.makeText(CreatePassword.this, "密码不能为空", Toast.LENGTH_SHORT).show();
}
else if (text02.equals(text03) == false) {
Toast.makeText(CreatePassword.this, "密码不匹配,请重新输入密码", Toast.LENGTH_SHORT).show();
password02.setText("");
}
else if (text02.equals(text03) == true){
SharedPreferences.Editor editor=getSharedPreferences("user management",
MODE_PRIVATE).edit();
editor.putBoolean("user",true);//true表示已经设置登录密码
editor.putString("password",text02);
editor.apply();
Log.d("RegisterLoginPassword","password is "+text02);
Toast.makeText(CreatePassword.this, "设置密码成功", Toast.LENGTH_SHORT).show();
Intent intent=new Intent(CreatePassword.this,NotesListActivity.class);
startActivity(intent);
finish();
}
}
});
}
/*
@Override
public void onBackPressed() {
Intent intent=new Intent(CreatePassword.this,NotesListActivity.class);
startActivity(intent);
finish();
}
*/
}

@ -0,0 +1,65 @@
package net.micode.notes.ui;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import net.micode.notes.R;
public class DeletePassword extends Activity{
EditText password01;
Button Acknowledged;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_delete_loginpassword);
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
| WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
password01=(EditText) findViewById(R.id.old_password);
Acknowledged=(Button)findViewById(R.id.Bt_Acknowledged);
Acknowledged.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String text02 = password01.getText().toString();
if(text02.equals("")==true) {
Toast.makeText(DeletePassword.this, "密码不能为空", Toast.LENGTH_SHORT).show();
}
SharedPreferences pref=getSharedPreferences("user management",MODE_PRIVATE);
String password = pref.getString("password","");
if(password.equals("")==false&&password.equals(text02)==true){
SharedPreferences.Editor editor=getSharedPreferences("user management",
MODE_PRIVATE).edit();
editor.putBoolean("user",false);//false表示已经设置登录密码
editor.putString("password","");
editor.apply();
Toast.makeText(DeletePassword.this, "已经删除登录密码", Toast.LENGTH_SHORT).show();
Intent intent=new Intent(DeletePassword.this,NotesListActivity.class);
startActivity(intent);
finish();
}
else{
Toast.makeText(DeletePassword.this, "密码错误", Toast.LENGTH_SHORT).show();
password01.setText("");//把密码框内输入过的错误密码清空
}
}
});
}
/*
@Override
public void onBackPressed() {
Intent intent=new Intent(DeletePassword.this,NotesListActivity.class);
startActivity(intent);
finish();
}
*/
}

@ -0,0 +1,68 @@
package net.micode.notes.ui;
import android.view.View;//可视化界面
import android.app.Activity;//完成函数周期
import android.view.WindowManager;
import android.widget.Button;//实现按钮
import android.widget.EditText;//输入显示
import android.widget.Toast;//设计让登录界面无法被跳过
import android.os.Bundle;//获取输入密码
import android.content.SharedPreferences;
import android.content.Intent;//数据交互
import net.micode.notes.R;
public class LoginActivity extends Activity {
EditText lg_password;
Button lg_login;
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==false){
Intent intent=new Intent(LoginActivity.this,NotesListActivity.class);
startActivity(intent);
finish();
}
setContentView(R.layout.activity_login);
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
);
lg_password =(EditText)findViewById(R.id.lg_password);
lg_login=(Button)findViewById(R.id.login);
lg_login.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
SharedPreferences pref=getSharedPreferences("user management",MODE_PRIVATE);
String password=pref.getString("password","");
if(password.equals("")==false&&password.equals(lg_password.getText().toString())==true){
Intent intent=new Intent(LoginActivity.this,NotesListActivity.class);
startActivity(intent);
finish();
}
else{
Toast.makeText(LoginActivity.this,"密码错误",Toast.LENGTH_SHORT).show();
lg_password.setText("");
}
}
});
}
public void onClick(View v) {
SharedPreferences pref =getSharedPreferences("user management",MODE_PRIVATE);
String password =pref.getString("password","");
if(password.equals("")==false && password.equals(lg_password.getText().toString())==true) {
Intent intent = new Intent(LoginActivity.this, NotesListActivity.class);
startActivity(intent);
finish();
}
else{
Toast.makeText(LoginActivity.this,"密码错误",Toast.LENGTH_SHORT).show();
lg_password.setText("");
}
}
}

@ -28,6 +28,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;
@ -71,6 +72,14 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.app.AlertDialog.Builder;
public class NoteEditActivity extends Activity implements OnClickListener,
NoteSettingChangedListener, OnTextViewChangeListener {
@ -185,9 +194,9 @@ public class NoteEditActivity extends Activity implements OnClickListener,
* then jump to the NotesListActivity
*/
mWorkingNote = null;
if (TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())) {
long noteId = intent.getLongExtra(Intent.EXTRA_UID, 0);
mUserQuery = "";
if (TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())) {//如果当前请求是查看便签请求
long noteId = intent.getLongExtra(Intent.EXTRA_UID, 0);//获取便签的ID
mUserQuery = "";//清空用户查询内容
/**
* Starting from the searched result
@ -203,8 +212,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
showToast(R.string.error_note_not_exist);
finish();
return false;
} else {
mWorkingNote = WorkingNote.load(this, noteId);
} else {//ID在数据库中找到了
mWorkingNote = WorkingNote.load(this, noteId);//用WorkingNote中的load方法讲便签内容整个放到一个过渡类型的当前工作便签中
if (mWorkingNote == null) {
Log.e(TAG, "load note failed with note id" + noteId);
finish();
@ -214,7 +223,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
} else if(TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) {
} else if(TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) {//刚刚创建的一个新便签
// New note
long folderId = intent.getLongExtra(Notes.INTENT_EXTRA_FOLDER_ID, 0);
int widgetId = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_ID,
@ -234,7 +243,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
long noteId = 0;
if ((noteId = DataUtils.getNoteIdByPhoneNumberAndCallDate(getContentResolver(),
phoneNumber, callDate)) > 0) {
mWorkingNote = WorkingNote.load(this, noteId);
mWorkingNote = WorkingNote.load(this, noteId);//加载便签的结果赋值给mworkingnote,存放当前正在工作的便签信息。
if (mWorkingNote == null) {
Log.e(TAG, "load call note failed with note id" + noteId);
finish();
@ -242,12 +251,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
} else {
mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId,
widgetType, bgResId);
widgetType, bgResId);//调用createEmptyNote方法创建一个新的便签
mWorkingNote.convertToCallNote(phoneNumber, callDate);
}
} else {
mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType,
bgResId);
bgResId);//
}
getWindow().setSoftInputMode(
@ -258,14 +267,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
finish();
return false;
}
mWorkingNote.setOnSettingStatusChangedListener(this);
mWorkingNote.setOnSettingStatusChangedListener(this);//设计便签状态,改变监听器
return true;
}
@Override
protected void onResume() {
super.onResume();
initNoteScreen();
initNoteScreen();//根据mWorkingNote中的内容初始化便签的各个控件。
}
private void initNoteScreen() {
@ -319,17 +328,18 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
@Override
//在Activity即将被销毁时的回调方法用于保存当前Activity的状态以便在Activity被恢复时能够正确地加载之前的状态。
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
super.onSaveInstanceState(outState);//用于保存Activity实例状态的方法调用
/**
* For new note without note id, we should firstly save it to
* generate a id. If the editing note is not worth saving, there
* is no id which is equivalent to create new note
*/
if (!mWorkingNote.existInDatabase()) {
saveNote();
if (!mWorkingNote.existInDatabase()) {//创建一个新的标签时先在数据库匹配
saveNote();//如果不存在,在数据库中存储
}
outState.putLong(Intent.EXTRA_UID, mWorkingNote.getNoteId());
outState.putLong(Intent.EXTRA_UID, mWorkingNote.getNoteId());//将ID存储到outState对象中
Log.d(TAG, "Save working note id: " + mWorkingNote.getNoteId() + " onSaveInstanceState");
}
@ -374,7 +384,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mNoteEditor = (EditText) findViewById(R.id.note_edit_view);
mNoteEditorPanel = findViewById(R.id.sv_note_edit);
mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector);
for (int id : sBgSelectorBtnsMap.keySet()) {
for (int id : sBgSelectorBtnsMap.keySet()) {//用于遍历 sBgSelectorBtnsMap 集合中的每个键(即布局文件中 ImageView 控件的 ID
ImageView iv = (ImageView) findViewById(id);
iv.setOnClickListener(this);
}
@ -427,10 +437,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
public void onClick(View v) {
int id = v.getId();
//通过v.getId()获取点击事件的View的ID。然后根据不同的ID进行不同的逻辑处理
if (id == R.id.btn_set_bg_color) {
mNoteBgColorSelector.setVisibility(View.VISIBLE);
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
- View.VISIBLE);
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(View.VISIBLE);
} else if (sBgSelectorBtnsMap.containsKey(id)) {
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.GONE);
@ -507,52 +517,169 @@ public class NoteEditActivity extends Activity implements OnClickListener,
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_new_note:
createNewNote();
break;
case R.id.menu_delete:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.alert_title_delete));
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setMessage(getString(R.string.alert_message_delete_note));
builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
deleteCurrentNote();
finish();
}
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.show();
break;
case R.id.menu_font_size:
mFontSizeSelector.setVisibility(View.VISIBLE);
findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE);
break;
case R.id.menu_list_mode:
mWorkingNote.setCheckListMode(mWorkingNote.getCheckListMode() == 0 ?
TextNote.MODE_CHECK_LIST : 0);
break;
case R.id.menu_share:
getWorkingText();
sendTo(this, mWorkingNote.getContent());
break;
case R.id.menu_send_to_desktop:
sendToDesktop();
break;
case R.id.menu_alert:
setReminder();
break;
case R.id.menu_delete_remind:
mWorkingNote.setAlertDate(0, false);
break;
default:
break;
int itemId = item.getItemId();
//在这个方法中首先获取被点击的选项的ID然后根据ID的不同执行相应的操作
if (itemId == R.id.menu_new_note) {
createNewNote();
}
/*else if(itemId==R.id.menu_set_password) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
final 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();
//设置密码
mWorkingNote.setPassword(password);
//设置密码成功提示
Toast.makeText(NoteEditActivity.this, "密码设置成功", Toast.LENGTH_SHORT).show();
//关闭软键盘
InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
//关闭dialog
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();
dialog.show();
} else if(itemId==R.id.menu_delete_password) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
final View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text,null);
//编辑Text
final EditText etName = (EditText)view.findViewById(R.id.et_foler_name);
builder.setTitle("确定要删除密码吗?");
etName.setText("");
etName.setHint("请输入密码核实身份");
String mPassword = mWorkingNote.getmPassword();
builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String password = etName.getText().toString();//获取输入字符
if(password.equals(mPassword)) {
Toast.makeText(NoteEditActivity.this, "身份校验正确,密码删除成功", Toast.LENGTH_SHORT).show();
mWorkingNote.setPassword(null);//删除密码
//关闭dialog
dialog.dismiss();
}
else{
Toast.makeText(NoteEditActivity.this, "身份校验错误,密码删除失败", Toast.LENGTH_SHORT).show();
//关闭dialog
dialog.dismiss();
}
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
final Dialog dialog = builder.setView(view).show();
dialog.show();
}
*/
else if (itemId == R.id.menu_delete) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.alert_title_delete));
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setMessage(getString(R.string.alert_message_delete_note));
builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
deleteCurrentNote();
finish();
}
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.show();
} else if (itemId == R.id.menu_font_size) {
mFontSizeSelector.setVisibility(View.VISIBLE);
findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE);
} else if (itemId == R.id.menu_list_mode) {
mWorkingNote.setCheckListMode(mWorkingNote.getCheckListMode() == 0 ?
TextNote.MODE_CHECK_LIST : 0);
} else if (itemId == R.id.menu_share) {
getWorkingText();
sendTo(this, mWorkingNote.getContent());
} else if (itemId == R.id.menu_send_to_desktop) {
sendToDesktop();
} else if (itemId == R.id.menu_alert) {
setReminder();
} else if (itemId == R.id.menu_delete_remind) {
mWorkingNote.setAlertDate(0, false);
} else if (itemId == R.id.menu_font_change){
showSingleAlertDiglog();
}
return true;
}
public void showSingleAlertDiglog(){
final String[] items ={"默认-普通","默认-非衬线","默认-衬线","默认-等宽"};
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
alertBuilder.setTitle("选择字体");
alertBuilder.setSingleChoiceItems(items, 0, new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
switch (i)
{
case 0:
mNoteEditor.setTypeface(Typeface.DEFAULT);
break;
case 1:
mNoteEditor.setTypeface(Typeface.SANS_SERIF);
break;
case 2:
mNoteEditor.setTypeface(Typeface.SERIF);
break;
case 3:
mNoteEditor.setTypeface(Typeface.MONOSPACE);
break;
}
Toast.makeText(NoteEditActivity.this,items[i],
Toast.LENGTH_SHORT).show();
}
});
alertBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
AlertDialog alertDialog1 = alertBuilder.create();
alertDialog1.dismiss();
}
});
alertBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
AlertDialog alertDialog1 = alertBuilder.create();
alertDialog1.dismiss();
}
});
AlertDialog alertDialog1 = alertBuilder.create();
alertDialog1.show();
}
private void setReminder() {
DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis());
d.setOnDateTimeSetListener(new OnDateTimeSetListener() {
@ -574,7 +701,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
context.startActivity(intent);
}
private void createNewNote() {
private void createNewNote() {//新建便签
// Firstly, save current editing notes
saveNote();
@ -583,13 +710,15 @@ public class NoteEditActivity extends Activity implements OnClickListener,
Intent intent = new Intent(this, NoteEditActivity.class);
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mWorkingNote.getFolderId());
startActivity(intent);
//然后创建一个新的Intent对象指定要启动的NoteEditActivity类并设置Action为Intent.ACTION_INSERT_OR_EDIT
// 并通过Extra传递当前便签所在文件夹的ID。
startActivity(intent);//启动新的NoteEditActivity。
}
private void deleteCurrentNote() {
if (mWorkingNote.existInDatabase()) {
private void deleteCurrentNote() {//删除便签(需要加入一个删除密码)
if (mWorkingNote.existInDatabase()) {//判断当前便签是否在数据库中
HashSet<Long> ids = new HashSet<Long>();
long id = mWorkingNote.getNoteId();
long id = mWorkingNote.getNoteId();//如果存在则获取当前便签的ID并将其添加到一个HashSet对象中。
if (id != Notes.ID_ROOT_FOLDER) {
ids.add(id);
} else {
@ -805,9 +934,9 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return hasChecked;
}
private boolean saveNote() {
getWorkingText();
boolean saved = mWorkingNote.saveNote();
private boolean saveNote() {//保存当前正在编辑的笔记的文本内容
getWorkingText();//获取正在编辑的笔记的文本内容
boolean saved = mWorkingNote.saveNote();//保存在吗WorkingNote对象中
if (saved) {
/**
* There are two modes from List view to edit view, open one note,

@ -39,7 +39,8 @@ public class NoteItemData {
NoteColumns.SNIPPET,
NoteColumns.TYPE,
NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE,
NoteColumns.WIDGET_TYPE
};
private static final int ID_COLUMN = 0;
@ -54,6 +55,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;
@ -67,6 +69,7 @@ public class NoteItemData {
private int mType;
private int mWidgetId;
private int mWidgetType;
// private String myPassword;
private String mName;
private String mPhoneNumber;
@ -91,7 +94,7 @@ public class NoteItemData {
mType = cursor.getInt(TYPE_COLUMN);
mWidgetId = cursor.getInt(WIDGET_ID_COLUMN);
mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);
//myPassword =cursor.getString(PASSWORD_COLUMN);
mPhoneNumber = "";
if (mParentId == Notes.ID_CALL_RECORD_FOLDER) {
mPhoneNumber = DataUtils.getCallNumberByNoteId(context.getContentResolver(), mId);

@ -79,6 +79,8 @@ import java.io.InputStreamReader;
import java.util.HashSet;
public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener {
public static int secret_mode = 0;//初始化为0表示进入隐私模式
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
private static final int FOLDER_LIST_QUERY_TOKEN = 1;
@ -139,12 +141,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.note_list);
initResources();
initResources();//初始化资源
/**
* Insert an introduction when user firstly use this application
*/
setAppInfoFromRawRes();
setAppInfoFromRawRes();//将之前写过的便签加载进入
}
@Override
@ -319,28 +321,26 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
return true;
}
switch (item.getItemId()) {
case R.id.delete:
AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
builder.setTitle(getString(R.string.alert_title_delete));
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setMessage(getString(R.string.alert_message_delete_notes,
mNotesListAdapter.getSelectedCount()));
builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
batchDelete();
}
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.show();
break;
case R.id.move:
startQueryDestinationFolders();
break;
default:
return false;
int itemId = item.getItemId();
if (itemId == R.id.delete) {
AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
builder.setTitle(getString(R.string.alert_title_delete));
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setMessage(getString(R.string.alert_message_delete_notes,
mNotesListAdapter.getSelectedCount()));
builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
batchDelete();
}
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.show();
} else if (itemId == R.id.move) {
startQueryDestinationFolders();
} else {
return false;
}
return true;
}
@ -411,10 +411,35 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
private void startAsyncNotesListQuery() {
String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION
: NORMAL_SELECTION;
mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] {
String.valueOf(mCurrentFolderId)
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
if(secret_mode == 0) {
mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[]{
String.valueOf(mCurrentFolderId)
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
}
else {
String str1 = "0";
String[] PROJECTION = new String[]{ //定义一个新的PROJECTION数组只换掉SNIPPET
NoteColumns.ID,
NoteColumns.ALERTED_DATE,
NoteColumns.BG_COLOR_ID,
NoteColumns.CREATED_DATE,
NoteColumns.HAS_ATTACHMENT,
//NoteColumns.MODIFIED_DATE,
"1",
NoteColumns.NOTES_COUNT,
NoteColumns.PARENT_ID,
//NoteColumns.SNIPPET,
str1,
NoteColumns.TYPE,
NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE,
};
mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
Notes.CONTENT_NOTE_URI, PROJECTION, selection, new String[]{
String.valueOf(mCurrentFolderId)
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
}
}
private final class BackgroundQueryHandler extends AsyncQueryHandler {
@ -558,12 +583,8 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_new_note:
createNewNote();
break;
default:
break;
if (v.getId() == R.id.btn_new_note) {
createNewNote();
}
}
@ -775,45 +796,111 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
} else {
Log.e(TAG, "Wrong state:" + mState);
}
if(secret_mode == 1)
menu.findItem(R.id.menu_secret).setVisible(false);
else
menu.findItem(R.id.menu_quit_secret).setVisible(false);
return true;
}
private void change_password() {
Intent intent=new Intent(NotesListActivity.this,ChangePassword.class);
startActivity(intent);
finish();
}
private void delete_password() {
Intent intent=new Intent(NotesListActivity.this, DeletePassword.class);
startActivity(intent);
finish();
}
private void set_login_password() {
Intent intent=new Intent(NotesListActivity.this, CreatePassword.class);
startActivity(intent);
finish();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_new_folder: {
showCreateOrModifyFolderDialog(true);
break;
}
case R.id.menu_export_text: {
exportNoteToText();
break;
}
case R.id.menu_sync: {
if (isSyncMode()) {
if (TextUtils.equals(item.getTitle(), getString(R.string.menu_sync))) {
GTaskSyncService.startSync(this);
} else {
GTaskSyncService.cancelSync(this);
}
int login_mode=-1;
SharedPreferences pref=getSharedPreferences("user management",MODE_PRIVATE);
boolean User_boolean = pref.getBoolean("user",false);
if(User_boolean==true){
login_mode=1;
}
else{
login_mode=0;
}
int itemId = item.getItemId();
if (itemId == R.id.menu_new_folder) {
showCreateOrModifyFolderDialog(true);
} else if (itemId == R.id.menu_export_text) {
exportNoteToText();
} else if (itemId == R.id.menu_sync) {
if (isSyncMode()) {
if (TextUtils.equals(item.getTitle(), getString(R.string.menu_sync))) {
GTaskSyncService.startSync(this);
} else {
startPreferenceActivity();
GTaskSyncService.cancelSync(this);
}
break;
}
case R.id.menu_setting: {
} else {
startPreferenceActivity();
break;
}
case R.id.menu_new_note: {
createNewNote();
break;
} else if (itemId == R.id.menu_setting) {
startPreferenceActivity();
} else if (itemId == R.id.menu_new_note) {
createNewNote();
} else if (itemId == R.id.menu_search) {
onSearchRequested();
}
else if (itemId == R.id.menu_createlogin) { //设置登录密码功能
if(login_mode == 0)//没有设置密码
set_login_password();
else{
Toast.makeText(NotesListActivity.this,"您已经设置了密码",Toast.LENGTH_SHORT).show();
}
case R.id.menu_search:
onSearchRequested();
break;
default:
break;
}
else if (itemId == R.id.menu_deletelogin){
if(login_mode==1) {
delete_password();
}
else {
Toast.makeText(NotesListActivity.this, "您还没有设置密码", Toast.LENGTH_SHORT).show();
}
}
else if (itemId ==R.id.menu_changelogin) {
if (login_mode == 1) {
change_password();
}
else{
Toast.makeText(NotesListActivity.this,"您还没有设置密码",Toast.LENGTH_SHORT).show();
}
}
else if (itemId == R.id.menu_secret){
secret_mode = 1;
startAsyncNotesListQuery();
Toast.makeText(this,"您已进入隐私模式",Toast.LENGTH_SHORT).show();
}
else if (itemId == R.id.menu_quit_secret){
secret_mode = 0;
AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
dialog.setTitle("提醒");
dialog.setMessage("您确认退出隐私模式吗?");
dialog.setCancelable(false);
dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startAsyncNotesListQuery();
Toast.makeText(NotesListActivity.this,"您已退出隐私模式",Toast.LENGTH_SHORT).show();
}
});
dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which){}
});
dialog.show();
}
return true;
}

@ -32,6 +32,14 @@ import net.micode.notes.tool.ResourceParser;
import net.micode.notes.ui.NoteEditActivity;
import net.micode.notes.ui.NotesListActivity;
/**
* @Package: net.micode.notes.widget
* @ClassName: NoteWidgetProvider
* @Description:
* AppWidgetProvider便
* @Author: Dong Jiaqi
* @CreateDate: 12/28/2023 19:31 PM
*/
public abstract class NoteWidgetProvider extends AppWidgetProvider {
public static final String [] PROJECTION = new String [] {
NoteColumns.ID,
@ -45,6 +53,13 @@ public abstract class NoteWidgetProvider extends AppWidgetProvider {
private static final String TAG = "NoteWidgetProvider";
/**
* 便
* 便便widget_idIDAppWidgetManager.INVALID_APPWIDGET_ID
* widget_idID
* @param context ContentResolver
* @param appWidgetIds 便IDIDAppWidgetManager便
*/
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
ContentValues values = new ContentValues();
@ -57,6 +72,13 @@ public abstract class NoteWidgetProvider extends AppWidgetProvider {
}
}
/**
* ID便Cursor
* ContentResolverquery()便便ID便
* @param context ContentResolver
* @param widgetId 便ID
* @return
*/
private Cursor getNoteWidgetInfo(Context context, int widgetId) {
return context.getContentResolver().query(Notes.CONTENT_NOTE_URI,
PROJECTION,
@ -65,10 +87,28 @@ public abstract class NoteWidgetProvider extends AppWidgetProvider {
null);
}
/**
* 便
* update()contextappWidgetManagerappWidgetIdsforceUpdatefalse
* 便
* @param context AppWidgetManager
* @param appWidgetManager AppWidgetManager便
* @param appWidgetIds 便IDIDAppWidgetManager便
*/
protected void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
update(context, appWidgetManager, appWidgetIds, false);
}
/**
*
* true"widget_under_visit_mode"NotesListActivity
* falsesnippetNoteEditActivity
* @param context
* @param appWidgetManager AppWidgetManager
* @param appWidgetIds ID
* @param privacyMode
*/
private void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds,
boolean privacyMode) {
for (int i = 0; i < appWidgetIds.length; i++) {

@ -23,7 +23,15 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.tool.ResourceParser;
/**
* @Package: net.micode.notes.widget
* @ClassName: NoteWidgetProvider_2x
* @Description:
* NoteWidgetProvider
* NoteWidgetProvider_2x2x2
* @Author: Dong Jiaqi
* @CreateDate: 12/29/2023 19:30 PM
*/
public class NoteWidgetProvider_2x extends NoteWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

@ -23,7 +23,15 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.tool.ResourceParser;
/**
* @Package: net.micode.notes.widget
* @ClassName: NoteWidgetProvider_4x
* @Description:
* NoteWidgetProvider
* NoteWidgetProvider_4x4x4
* @Author: Dong Jiaqi
* @CreateDate: 12/29/2023 19:40 PM
*/
public class NoteWidgetProvider_4x extends NoteWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

Loading…
Cancel
Save