pull/10/head
pbyhqr72x 3 years ago
commit 652c61b8d9

@ -16,11 +16,12 @@
--> -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="net.micode.notes" package="net.micode.notes"
android:versionCode="1" android:versionCode="1"
android:versionName="0.1" > android:versionName="0.1" >
<uses-sdk android:minSdkVersion="14" /> <!--uses-sdk android:minSdkVersion="14" /-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
@ -41,8 +42,9 @@
android:label="@string/app_name" android:label="@string/app_name"
android:launchMode="singleTop" android:launchMode="singleTop"
android:theme="@style/NoteTheme" android:theme="@style/NoteTheme"
android:uiOptions="splitActionBarWhenNarrow"
android:windowSoftInputMode="adjustPan" > android:windowSoftInputMode="adjustPan" >
<!--android:uiOptions="splitActionBarWhenNarrow"-->
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -79,6 +81,14 @@
android:name="android.app.searchable" android:name="android.app.searchable"
android:resource="@xml/searchable" /> android:resource="@xml/searchable" />
</activity> </activity>
<activity
android:name=".ui.PassWordEditActivity"
android:theme="@style/NoteActionBarStyle">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<provider <provider
android:name="net.micode.notes.data.NotesProvider" android:name="net.micode.notes.data.NotesProvider"

@ -0,0 +1,57 @@
<?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/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/set_password"
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>

@ -15,8 +15,7 @@
limitations under the License. limitations under the License.
--> -->
<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto" <FrameLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/list_background" android:background="@drawable/list_background"
@ -59,10 +58,9 @@
<ImageButton <ImageButton
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:background="@drawable/bg_btn_set_color" /> android:background="@drawable/bg_btn_set_color" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -73,17 +71,17 @@
<ImageView <ImageView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="49dp" android:layout_height="7dip"
android:background="@drawable/bg_color_btn_mask" /> android:background="@drawable/bg_color_btn_mask" />
<ScrollView <ScrollView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="0dip" android:layout_height="0dip"
android:layout_gravity="left|top"
android:layout_weight="1" android:layout_weight="1"
android:fadingEdgeLength="0dip" android:scrollbars="none"
android:overScrollMode="never" android:overScrollMode="never"
android:scrollbars="none"> android:layout_gravity="left|top"
android:fadingEdgeLength="0dip">
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -93,43 +91,37 @@
android:id="@+id/note_edit_view" android:id="@+id/note_edit_view"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:autoLink="all"
android:background="@null"
android:gravity="left|top" android:gravity="left|top"
android:lineSpacingMultiplier="1.2" android:background="@null"
android:autoLink="all"
android:linksClickable="false" android:linksClickable="false"
android:minLines="12" android:minLines="12"
android:textAppearance="@style/TextAppearancePrimaryItem" /> android:textAppearance="@style/TextAppearancePrimaryItem"
android:lineSpacingMultiplier="1.2" />
<LinearLayout <LinearLayout
android:id="@+id/note_edit_list" android:id="@+id/note_edit_list"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="-10dip"
android:orientation="vertical" android:orientation="vertical"
android:layout_marginLeft="-10dip"
android:visibility="gone" /> android:visibility="gone" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
<ImageView <ImageView
android:id="@+id/m_locker" android:layout_width="fill_parent"
android:layout_width="match_parent" android:layout_height="7dip"
android:layout_height="wrap_content" android:background="@drawable/bg_color_btn_mask" />
android:background="#4CAF50"
android:src="@drawable/bg_color_btn_mask"
tools:src="@android:drawable/ic_lock_idle_lock" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<ImageView <ImageView
android:id="@+id/btn_set_bg_color" android:id="@+id/btn_set_bg_color"
android:layout_width="111dp" android:layout_height="43dip"
android:layout_height="64dp" android:layout_width="wrap_content"
android:layout_gravity="top|right" android:background="@drawable/bg_color_btn_mask"
android:background="@drawable/bg_color_btn_mask" /> android:layout_gravity="top|right" />
<LinearLayout <LinearLayout
android:id="@+id/note_bg_color_selector" android:id="@+id/note_bg_color_selector"
@ -405,5 +397,4 @@
android:src="@drawable/selected" /> android:src="@drawable/selected" />
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

@ -39,13 +39,13 @@
<ListView <ListView
android:id="@+id/notes_list" android:id="@+id/notes_list"
android:layout_width="464dp" android:layout_width="fill_parent"
android:layout_height="0dip" android:layout_height="0dip"
android:layout_weight="1" android:layout_weight="1"
android:cacheColorHint="@null" android:cacheColorHint="@null"
android:listSelector="@android:color/transparent"
android:divider="@null" android:divider="@null"
android:fadingEdge="@null" android:fadingEdge="@null" />
android:listSelector="@android:color/transparent" />
</LinearLayout> </LinearLayout>
<Button <Button

@ -45,4 +45,10 @@
<item <item
android:id="@+id/menu_delete_remind" android:id="@+id/menu_delete_remind"
android:title="@string/menu_remove_remind" /> android:title="@string/menu_remove_remind" />
<item
android:id="@+id/menu_set_passwd"
android:title="Set password" />
<item
android:id="@+id/menu_delete_passwd"
android:title="Delete password" />
</menu> </menu>

@ -49,4 +49,10 @@
<item <item
android:id="@+id/menu_delete_remind" android:id="@+id/menu_delete_remind"
android:title="@string/menu_remove_remind" /> android:title="@string/menu_remove_remind" />
<item
android:id="@+id/menu_set_passwd"
android:title="Set password" />
<item
android:id="@+id/menu_delete_passwd"
android:title="Delete password" />
</menu> </menu>

@ -61,7 +61,8 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," + NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," + NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0," + NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.PASSWORD+ " INTEGER NOT NULL DEFAULT 0" + NoteColumns.PASSWORD+ " TEXT NOT NULL DEFAULT ''" +
//NoteColumns.PASSWORD+ " INTEGER NOT NULL DEFAULT 0" +
")"; ")";
private static final String CREATE_DATA_TABLE_SQL = private static final String CREATE_DATA_TABLE_SQL =

@ -17,14 +17,12 @@
package net.micode.notes.gtask.remote; package net.micode.notes.gtask.remote;
import android.annotation.TargetApi;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import net.micode.notes.R; import net.micode.notes.R;
import net.micode.notes.ui.NotesListActivity; import net.micode.notes.ui.NotesListActivity;
@ -65,7 +63,6 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
}); });
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void showNotification(int tickerId, String content) { private void showNotification(int tickerId, String content) {
Notification notification = new Notification(R.drawable.notification, mContext Notification notification = new Notification(R.drawable.notification, mContext
.getString(tickerId), System.currentTimeMillis()); .getString(tickerId), System.currentTimeMillis());
@ -80,17 +77,8 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext, pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
NotesListActivity.class), 0); NotesListActivity.class), 0);
} }
//notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content, //notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
// pendingIntent); // pendingIntent);
notification = new Notification.Builder(mContext)
.setContentIntent(pendingIntent)
.setTicker(mContext.getString(R.string.app_name))
.setContentTitle(mContext.getString(R.string.app_name))
.setContentText(content)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.icon_app)
.build();
notification.icon = R.drawable.icon_app;
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification); mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
} }

@ -64,19 +64,6 @@ public class WorkingNote {
//新添加的密码变量 //新添加的密码变量
private String mPassword; private String mPassword;
/**
* 便访
* @param password 访
*/
public void setPassword(String password){
//将该类的mPassword属性设置为新的访问密码
mPassword = password;
//将修改后的便签密码写入到便签数据库中
mNote.setNoteValue(NoteColumns.PASSWORD,mPassword);
}
public String getmPassword(){
return mPassword;
}
public static final String[] DATA_PROJECTION = new String[] { public static final String[] DATA_PROJECTION = new String[] {
DataColumns.ID, DataColumns.ID,
DataColumns.CONTENT, DataColumns.CONTENT,
@ -117,8 +104,41 @@ public class WorkingNote {
private static final int NOTE_WIDGET_TYPE_COLUMN = 4; private static final int NOTE_WIDGET_TYPE_COLUMN = 4;
private static final int NOTE_MODIFIED_DATE_COLUMN = 5; private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
//密码 //密码
private static final int NOTE_PASSWORD_COLUMN=6; private static final int NOTE_PASSWORD_COLUMN=6;
/**
* 便访
* @param password 访
*/
public void setPassword(String password){
//将该类的mPassword属性设置为新的访问密码
mPassword = password;
//将修改后的便签密码写入到便签数据库中
mNote.setNoteValue(NoteColumns.PASSWORD,mPassword);
}
public boolean hasPassword()
{
if (mPassword!=null && mPassword.length()!=0)
//if (!mPassword.equals(""))
{
Log.d("密码是:", String.valueOf(true));
Log.d("密码是",mPassword);
return true;
}
else{
Log.d("密码是:", String.valueOf(false));
return false;
}
}
//获取密码
public String getmPassword(){
return mPassword;
}
// New note construct // New note construct
private WorkingNote(Context context, long folderId) { private WorkingNote(Context context, long folderId) {
mContext = context; mContext = context;
@ -130,6 +150,8 @@ public class WorkingNote {
mIsDeleted = false; mIsDeleted = false;
mMode = 0; mMode = 0;
mWidgetType = Notes.TYPE_WIDGET_INVALIDE; mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
//导入便签
loadNote();
} }
// Existing note construct // Existing note construct

@ -78,7 +78,6 @@ public class DateTimePickerDialog extends AlertDialog implements OnClickListener
DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_DATE |
DateUtils.FORMAT_SHOW_TIME; DateUtils.FORMAT_SHOW_TIME;
flag |= mIs24HourView ? DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_24HOUR; flag |= mIs24HourView ? DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_24HOUR;
//flag =DateUtils.FORMAT_24HOUR;
setTitle(DateUtils.formatDateTime(this.getContext(), date, flag)); setTitle(DateUtils.formatDateTime(this.getContext(), date, flag));
} }

@ -19,6 +19,7 @@ package net.micode.notes.ui;
import android.app.Activity; import android.app.Activity;
import android.app.AlarmManager; import android.app.AlarmManager;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.SearchManager; import android.app.SearchManager;
import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManager;
@ -43,6 +44,7 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
@ -62,11 +64,6 @@ import net.micode.notes.tool.ResourceParser;
import net.micode.notes.tool.ResourceParser.TextAppearanceResources; import net.micode.notes.tool.ResourceParser.TextAppearanceResources;
import net.micode.notes.ui.DateTimePickerDialog.OnDateTimeSetListener; import net.micode.notes.ui.DateTimePickerDialog.OnDateTimeSetListener;
import net.micode.notes.ui.NoteEditText.OnTextViewChangeListener; import net.micode.notes.ui.NoteEditText.OnTextViewChangeListener;
import net.micode.notes.ui.PasswordView;
import android.app.Dialog;
import android.view.inputmethod.InputMethodManager;
import net.micode.notes.widget.NoteWidgetProvider_2x; import net.micode.notes.widget.NoteWidgetProvider_2x;
import net.micode.notes.widget.NoteWidgetProvider_4x; import net.micode.notes.widget.NoteWidgetProvider_4x;
@ -87,10 +84,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
public TextView tvAlertDate; public TextView tvAlertDate;
public ImageView ibSetBgColor; public ImageView ibSetBgColor;
//方便后边增加一个点击监听器
public ImageView ibSetBgLocker;
} }
private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>(); private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>();
@ -137,7 +130,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private View mFontSizeSelector; private View mFontSizeSelector;
private EditText mNoteEditor; private EditText mNoteEditor;
private View mNoteEditorPanel; private View mNoteEditorPanel;
@ -158,8 +150,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private String mUserQuery; private String mUserQuery;
private Pattern mPattern; private Pattern mPattern;
//密码
private String mPassword;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -279,11 +269,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
super.onResume(); super.onResume();
initNoteScreen(); initNoteScreen();
} }
//检验密码
private void initNoteScreen() { private void checkPassword(){
//读密码
final String mPassword=mWorkingNote.getmPassword();
//密码验证 //密码验证
mPassword = mWorkingNote.getmPassword(); if (mPassword!=null && mPassword.length()!=0) {
if (mPassword!=null) {
//创建dialog插入edittext用户输入密码并做出检验。 //创建dialog插入edittext用户输入密码并做出检验。
final AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog.Builder builder = new AlertDialog.Builder(this);
View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null); View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
@ -321,7 +312,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
final Dialog dialog = builder.setView(view).show(); final Dialog dialog = builder.setView(view).show();
dialog.show(); dialog.show();
} }
}
private void initNoteScreen() {
//检验密码
//checkPassword();
mNoteEditor.setTextAppearance(this, TextAppearanceResources mNoteEditor.setTextAppearance(this, TextAppearanceResources
.getTexAppearanceResource(mFontSizeId)); .getTexAppearanceResource(mFontSizeId));
if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) { if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
@ -348,8 +342,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
showAlertHeader(); showAlertHeader();
} }
private void showAlertHeader() { private void showAlertHeader() {
if (mWorkingNote.hasClockAlert()) { if (mWorkingNote.hasClockAlert()) {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
@ -425,10 +417,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
mNoteHeaderHolder.ivAlertIcon = (ImageView) findViewById(R.id.iv_alert_icon); mNoteHeaderHolder.ivAlertIcon = (ImageView) findViewById(R.id.iv_alert_icon);
mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date); mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date);
mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color); mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color);
//增加一个监听器
mNoteHeaderHolder.ibSetBgLocker= (ImageView) findViewById(R.id.m_locker);
mNoteHeaderHolder.ibSetBgLocker.setOnClickListener(this);
mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this); mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this);
mNoteEditor = (EditText) findViewById(R.id.note_edit_view); mNoteEditor = (EditText) findViewById(R.id.note_edit_view);
mNoteEditorPanel = findViewById(R.id.sv_note_edit); mNoteEditorPanel = findViewById(R.id.sv_note_edit);
@ -437,6 +425,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
ImageView iv = (ImageView) findViewById(id); ImageView iv = (ImageView) findViewById(id);
iv.setOnClickListener(this); iv.setOnClickListener(this);
} }
mFontSizeSelector = findViewById(R.id.font_size_selector); mFontSizeSelector = findViewById(R.id.font_size_selector);
for (int id : sFontSizeBtnsMap.keySet()) { for (int id : sFontSizeBtnsMap.keySet()) {
View view = findViewById(id); View view = findViewById(id);
@ -487,10 +476,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
int id = v.getId(); int id = v.getId();
if (id == R.id.btn_set_bg_color) { if (id == R.id.btn_set_bg_color) {
mNoteBgColorSelector.setVisibility(View.VISIBLE); mNoteBgColorSelector.setVisibility(View.VISIBLE);
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility( findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(View.VISIBLE);
View.VISIBLE); } else if (sBgSelectorBtnsMap.containsKey(id)) {
}
else if (sBgSelectorBtnsMap.containsKey(id)) {
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility( findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.GONE); View.GONE);
mWorkingNote.setBgColorId(sBgSelectorBtnsMap.get(id)); mWorkingNote.setBgColorId(sBgSelectorBtnsMap.get(id));
@ -509,44 +496,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
} }
mFontSizeSelector.setVisibility(View.GONE); mFontSizeSelector.setVisibility(View.GONE);
} }
//添加设置密码的点击
if (id==R.id.m_locker){
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();
}
} }
@Override @Override
@ -554,6 +503,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
if(clearSettingState()) { if(clearSettingState()) {
return; return;
} }
saveNote(); saveNote();
super.onBackPressed(); super.onBackPressed();
} }
@ -598,6 +548,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
} else { } else {
menu.findItem(R.id.menu_delete_remind).setVisible(false); menu.findItem(R.id.menu_delete_remind).setVisible(false);
} }
//如果一设置密码,显示删除密码选项,否则,显示设置密码选项
/**if (mWorkingNote.hasPassword()) {
menu.findItem(R.id.menu_set_passwd).setVisible(false);
} else {
menu.findItem(R.id.menu_delete_passwd).setVisible(false);
}*/
return true; return true;
} }
@ -643,11 +599,64 @@ public class NoteEditActivity extends Activity implements OnClickListener,
case R.id.menu_delete_remind: case R.id.menu_delete_remind:
mWorkingNote.setAlertDate(0, false); mWorkingNote.setAlertDate(0, false);
break; break;
//设置密码
case R.id.menu_set_passwd:
setPassword();
break;
//删除密码
case R.id.menu_delete_passwd:
//删除密码前要检验密码
checkPassword();
deletePassword();
break;
default: default:
break; break;
} }
return true; return true;
} }
//设置密码函数
public void setPassword(){
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();
}
//删除密码函数
public void deletePassword()
{
mWorkingNote.setPassword("");
}
private void setReminder() { private void setReminder() {
DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis()); DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis());

@ -19,7 +19,6 @@ package net.micode.notes.ui;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import net.micode.notes.data.Contact; import net.micode.notes.data.Contact;
import net.micode.notes.data.Notes; import net.micode.notes.data.Notes;
@ -41,7 +40,6 @@ public class NoteItemData {
NoteColumns.TYPE, NoteColumns.TYPE,
NoteColumns.WIDGET_ID, NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE, NoteColumns.WIDGET_TYPE,
NoteColumns.PASSWORD,//密码
}; };
private static final int ID_COLUMN = 0; private static final int ID_COLUMN = 0;
@ -56,8 +54,6 @@ public class NoteItemData {
private static final int TYPE_COLUMN = 9; private static final int TYPE_COLUMN = 9;
private static final int WIDGET_ID_COLUMN = 10; private static final int WIDGET_ID_COLUMN = 10;
private static final int WIDGET_TYPE_COLUMN = 11; private static final int WIDGET_TYPE_COLUMN = 11;
//密码
private static final int PASSWORD_COLUMN=12;
private long mId; private long mId;
private long mAlertDate; private long mAlertDate;
@ -73,8 +69,6 @@ public class NoteItemData {
private int mWidgetType; private int mWidgetType;
private String mName; private String mName;
private String mPhoneNumber; private String mPhoneNumber;
//密码
private String mPassword;
private boolean mIsLastItem; private boolean mIsLastItem;
private boolean mIsFirstItem; private boolean mIsFirstItem;
@ -98,10 +92,6 @@ public class NoteItemData {
mWidgetId = cursor.getInt(WIDGET_ID_COLUMN); mWidgetId = cursor.getInt(WIDGET_ID_COLUMN);
mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN); mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);
//增加读取密码
mPassword= cursor.getString(PASSWORD_COLUMN);
mPhoneNumber = ""; mPhoneNumber = "";
if (mParentId == Notes.ID_CALL_RECORD_FOLDER) { if (mParentId == Notes.ID_CALL_RECORD_FOLDER) {
mPhoneNumber = DataUtils.getCallNumberByNoteId(context.getContentResolver(), mId); mPhoneNumber = DataUtils.getCallNumberByNoteId(context.getContentResolver(), mId);
@ -118,24 +108,6 @@ public class NoteItemData {
} }
checkPostion(cursor); checkPostion(cursor);
} }
//读取对应小米便签的密码
public String getPassword(){
String password=mPassword;
//System.out(password);
Log.d("getPassword密码是",password);
return password;
}
//判断是否设置了密码
public boolean hasPassword(){
String password=mPassword;
//System.out(password);
Log.d("hasPassword密码是",password);
Object o = "";
if (password.equals(o)){
return false;
}
return true;
}
private void checkPostion(Cursor cursor) { private void checkPostion(Cursor cursor) {
mIsLastItem = cursor.isLast() ? true : false; mIsLastItem = cursor.isLast() ? true : false;

@ -875,7 +875,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
Intent intent = new Intent(from, NotesPreferenceActivity.class); Intent intent = new Intent(from, NotesPreferenceActivity.class);
from.startActivityIfNeeded(intent, -1); from.startActivityIfNeeded(intent, -1);
} }
//修改为继承Activity便于包含Context。Builder函数的参数要求是Context。extends Activity
private class OnListItemClickListener implements OnItemClickListener { private class OnListItemClickListener implements OnItemClickListener {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
@ -895,10 +895,14 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
if (item.getType() == Notes.TYPE_FOLDER if (item.getType() == Notes.TYPE_FOLDER
|| item.getType() == Notes.TYPE_SYSTEM) { || item.getType() == Notes.TYPE_SYSTEM) {
openFolder(item); openFolder(item);
} } else if (item.getType() == Notes.TYPE_NOTE) {
//判断为点击的是便签 //打开PassWordEditAcitivity类并传递noteid
else if (item.getType() == Notes.TYPE_NOTE) { Intent intent = new Intent(NotesListActivity.this, PassWordEditActivity.class);
openNode(item); long noteId = item.getId();
intent.putExtra("noteId", noteId);
startActivity(intent);
//
//openNode(item);
} else { } else {
Log.e(TAG, "Wrong note type in NOTE_LIST"); Log.e(TAG, "Wrong note type in NOTE_LIST");
} }

@ -0,0 +1,93 @@
package net.micode.notes.ui;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.os.Bundle;
import android.widget.Toast;
import net.micode.notes.R;
import net.micode.notes.model.WorkingNote;
//这是一个检验密码的Activity之后会添加其他。
public class PassWordEditActivity extends Activity {
//用来输入密码和一个按钮
EditText passWord;
Button set_password;
//储存要验证的便签的密码
String mPassword;
//要验证的便签
WorkingNote mWorkingNote=null;
Intent intent;
@Override
protected void onCreate(Bundle savedInstanceState) {
intent = getIntent();
if (savedInstanceState == null && !initActivityState()) {
finish();
return;
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_password);
//不知道作用
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
//
boolean User_boolean = mWorkingNote.hasPassword();//获取用户是否设置了密码
if(!User_boolean) //User_boolean = false时没有设置密码直接跳转到便签主界面
{
Intent intent=new Intent(PassWordEditActivity.this,NoteEditActivity.class);
intent.setAction("android.intent.action.VIEW");
intent.putExtra(Intent.EXTRA_UID, mWorkingNote.getNoteId());
startActivity(intent);
PassWordEditActivity.this.finish();
}
passWord=(EditText) findViewById(R.id.password);
set_password=(Button)findViewById(R.id.set_password);
set_password.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//获取输入密码
String password=passWord.getText().toString();
if(password.equals(mPassword)){
Intent intent=new Intent(PassWordEditActivity.this,NoteEditActivity.class);
intent.setAction("android.intent.action.VIEW");
intent.putExtra(Intent.EXTRA_UID, mWorkingNote.getNoteId());
startActivity(intent);
finish();
}
else{
Toast.makeText(PassWordEditActivity.this, "密码错误", Toast.LENGTH_SHORT).show();
passWord.setText("");//把密码框内输入过的错误密码清空
}
}
}
);
}
private boolean initActivityState() {
mWorkingNote = null;
long noteId = intent.getLongExtra("noteId",-1);
if (noteId!=-1) {
//得到要验证的便签
mWorkingNote = WorkingNote.load(PassWordEditActivity.this, noteId);
//获取该便签密码
mPassword=mWorkingNote.getmPassword();
return true;
}
return false;
}
}
Loading…
Cancel
Save