小米便签1.1.1 置顶、密码功能 #10

Merged
pbyhqr72x merged 11 commits from develop into master 3 years ago

Binary file not shown.

@ -82,12 +82,12 @@
android:resource="@xml/searchable" /> android:resource="@xml/searchable" />
</activity> </activity>
<activity <activity
android:name=".ui.PassWordEditActivity" android:name=".ui.PassWordEditActivity"
android:theme="@style/NoteActionBarStyle"> android:theme="@style/NoteActionBarStyle">
<intent-filter> <intent-filter>
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/>
</intent-filter> </intent-filter>
</activity> </activity>
<provider <provider

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 B

@ -14,10 +14,63 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<LinearLayout
<EditText
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/et_foler_name" android:layout_width="match_parent"
android:layout_width="fill_parent" android:layout_height="match_parent"
android:hint="@string/hint_foler_name" android:orientation="vertical"
android:layout_height="fill_parent" /> android:gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="@+id/et_foler_name_old_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输入原密码:"/>
<EditText
android:id="@+id/et_foler_name_old"
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:id="@+id/et_foler_name_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="输入新建密码:"/>
<EditText
android:id="@+id/et_foler_name"
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:id="@+id/et_foler_name_again_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认密码:"/>
<EditText
android:id="@+id/et_foler_name_again"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:password="true"/>
</LinearLayout>
</LinearLayout>

@ -17,6 +17,7 @@
<FrameLayout <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/note_item" android:id="@+id/note_item"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent">
@ -75,4 +76,10 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="top|right"/> android:layout_gravity="top|right"/>
<ImageView
android:id="@+id/iv_locker_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"/>
</FrameLayout> </FrameLayout>

@ -62,6 +62,10 @@ public class Notes {
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data"); public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
public interface NoteColumns { public interface NoteColumns {
/**
*
*/
public static final String LOCKER="_locker";
/** /**
* *
*/ */

@ -62,7 +62,8 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," + NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0," + NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.PASSWORD+ " TEXT NOT NULL DEFAULT ''," + NoteColumns.PASSWORD+ " TEXT NOT NULL DEFAULT ''," +
NoteColumns.TOP+" INTEGER NOT NULL DEFAULT 0"+ NoteColumns.TOP+" INTEGER NOT NULL DEFAULT 0,"+
NoteColumns.LOCKER + " INTEGER NOT NULL DEFAULT 0" +
//NoteColumns.PASSWORD+ " INTEGER NOT NULL DEFAULT 0" + //NoteColumns.PASSWORD+ " INTEGER NOT NULL DEFAULT 0" +
")"; ")";
@ -329,6 +330,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
upgradeToV5(db); upgradeToV5(db);
oldVersion++; oldVersion++;
} }
if (oldVersion == 5) {
upgradeToV6(db);
oldVersion++;
}
if (reCreateTriggers) { if (reCreateTriggers) {
reCreateNoteTableTriggers(db); reCreateNoteTableTriggers(db);
@ -371,5 +376,9 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.TOP db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.TOP
+ " INTEGER NOT NULL DEFAULT 0"); + " INTEGER NOT NULL DEFAULT 0");
} }
private void upgradeToV6(SQLiteDatabase db){
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.LOCKER
+ " INTEGER NOT NULL DEFAULT 0");
}
} }

@ -33,13 +33,14 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes.DataColumns; import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.NoteColumns; import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.NotesDatabaseHelper.TABLE; import net.micode.notes.data.NotesDatabaseHelper.TABLE;
import net.micode.notes.gtask.data.SqlNote;
public class NotesProvider extends ContentProvider { public class NotesProvider extends ContentProvider {
private static final UriMatcher mMatcher; private static final UriMatcher mMatcher;
private NotesDatabaseHelper mHelper; private NotesDatabaseHelper mHelper;
//创建帮助找到下了锁的对应的便签
private static NotesDatabaseHelper mFind_Locker_Helper;
private static final String TAG = "NotesProvider"; private static final String TAG = "NotesProvider";
private static final int URI_NOTE = 1; private static final int URI_NOTE = 1;
@ -82,6 +83,7 @@ public class NotesProvider extends ContentProvider {
@Override @Override
public boolean onCreate() { public boolean onCreate() {
mHelper = NotesDatabaseHelper.getInstance(getContext()); mHelper = NotesDatabaseHelper.getInstance(getContext());
mFind_Locker_Helper=NotesDatabaseHelper.getInstance(getContext());
return true; return true;
} }
@ -301,5 +303,25 @@ public class NotesProvider extends ContentProvider {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
//判断是否上锁
public static boolean isLockedNote(Long id) {
SQLiteDatabase db = mFind_Locker_Helper.getReadableDatabase();
Cursor cursor = null;
cursor = db.query(NotesDatabaseHelper.TABLE.NOTE, null, null, null, null, null, null);
//判断游标是否为空
System.out.println(cursor.getCount());
if (cursor.moveToFirst()) {
//遍历游标
for (int index = 1; index < cursor.getCount(); index++) {
if (cursor.getLong(SqlNote.ID_COLUMN) == id && !cursor.getString(SqlNote.LOCKER_COLUMN).equals("0")) {
cursor.close();
return true;
}
cursor.moveToNext();
}
}
cursor.close();
return false;
}
} }

@ -49,7 +49,7 @@ public class SqlNote {
NoteColumns.NOTES_COUNT, NoteColumns.PARENT_ID, NoteColumns.SNIPPET, NoteColumns.TYPE, NoteColumns.NOTES_COUNT, NoteColumns.PARENT_ID, NoteColumns.SNIPPET, NoteColumns.TYPE,
NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE, NoteColumns.SYNC_ID, NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE, NoteColumns.SYNC_ID,
NoteColumns.LOCAL_MODIFIED, NoteColumns.ORIGIN_PARENT_ID, NoteColumns.GTASK_ID, NoteColumns.LOCAL_MODIFIED, NoteColumns.ORIGIN_PARENT_ID, NoteColumns.GTASK_ID,
NoteColumns.VERSION NoteColumns.VERSION,NoteColumns.LOCKER
}; };
public static final int ID_COLUMN = 0; public static final int ID_COLUMN = 0;
@ -85,6 +85,7 @@ public class SqlNote {
public static final int GTASK_ID_COLUMN = 15; public static final int GTASK_ID_COLUMN = 15;
public static final int VERSION_COLUMN = 16; public static final int VERSION_COLUMN = 16;
public static final int LOCKER_COLUMN = 17;
private Context mContext; private Context mContext;

@ -64,6 +64,8 @@ public class WorkingNote {
private NoteSettingChangedListener mNoteSettingStatusListener; private NoteSettingChangedListener mNoteSettingStatusListener;
//新添加的密码变量 //新添加的密码变量
private String mPassword; private String mPassword;
//添加密码标志
private String mLocker;
public static final String[] DATA_PROJECTION = new String[] { public static final String[] DATA_PROJECTION = new String[] {
DataColumns.ID, DataColumns.ID,
@ -85,6 +87,7 @@ public class WorkingNote {
//增加一个密码项 //增加一个密码项
NoteColumns.PASSWORD, NoteColumns.PASSWORD,
NoteColumns.TOP, NoteColumns.TOP,
NoteColumns.LOCKER,
}; };
private static final int DATA_ID_COLUMN = 0; private static final int DATA_ID_COLUMN = 0;
@ -108,6 +111,8 @@ public class WorkingNote {
private static final int NOTE_MODIFIED_DATE_COLUMN = 5; private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
//密码 //密码
private static final int NOTE_PASSWORD_COLUMN=6; private static final int NOTE_PASSWORD_COLUMN=6;
//密码标志
private static final int NOTE_LOCKER_COLUMN=8;
/** /**
@ -140,6 +145,11 @@ public class WorkingNote {
public String getmPassword(){ public String getmPassword(){
return mPassword; return mPassword;
} }
//设置密码标志
public void setLocker(String mlocker){
mLocker=mlocker;//1标志为上锁了 0标志为没有上锁
mNote.setNoteValue(NoteColumns.LOCKER,mLocker);
}
// New note construct // New note construct
private WorkingNote(Context context, long folderId) { private WorkingNote(Context context, long folderId) {
@ -183,6 +193,8 @@ public class WorkingNote {
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN); mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
//密码 //密码
mPassword= cursor.getString(NOTE_PASSWORD_COLUMN); mPassword= cursor.getString(NOTE_PASSWORD_COLUMN);
//密码标志
mLocker=cursor.getString(NOTE_LOCKER_COLUMN);
} }
cursor.close(); cursor.close();
} else { } else {

@ -25,10 +25,14 @@ import android.content.OperationApplicationException;
import android.database.Cursor; import android.database.Cursor;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log; import android.util.Log;
import android.widget.Toast;
import net.micode.notes.data.Notes; import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.CallNote; import net.micode.notes.data.Notes.CallNote;
import net.micode.notes.data.Notes.NoteColumns; import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.NotesProvider;
import net.micode.notes.ui.NoteEditActivity;
import net.micode.notes.ui.NotesListActivity;
import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute; import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute;
import java.util.ArrayList; import java.util.ArrayList;
@ -53,6 +57,12 @@ public class DataUtils {
Log.e(TAG, "Don't delete system folder root"); Log.e(TAG, "Don't delete system folder root");
continue; continue;
} }
/**
*
*/
if (NotesProvider.isLockedNote(id)){
continue;
}
ContentProviderOperation.Builder builder = ContentProviderOperation ContentProviderOperation.Builder builder = ContentProviderOperation
.newDelete(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id)); .newDelete(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id));
operationList.add(builder.build()); operationList.add(builder.build());

@ -151,6 +151,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private String mUserQuery; private String mUserQuery;
private Pattern mPattern; private Pattern mPattern;
//private int flag=0;//作为判断删除密码时有无验证通过
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -279,16 +280,23 @@ public class NoteEditActivity extends Activity implements OnClickListener,
//创建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);
//编辑Text //编辑dialog界面
final EditText etNameOld= (EditText)view.findViewById(R.id.et_foler_name_old);//只需要验证原密码
final EditText etName = (EditText) view.findViewById(R.id.et_foler_name); final EditText etName = (EditText) view.findViewById(R.id.et_foler_name);
etName.setText(""); etName.setVisibility(view.GONE);
etName.setHint("请输入密码"); final TextView etName_View=(TextView)view.findViewById(R.id.et_foler_name_view);
etName_View.setVisibility(view.GONE);
final EditText etNameAgain = (EditText) view.findViewById(R.id.et_foler_name_again);
etNameAgain.setVisibility(view.GONE);
final TextView etNameAgain_View=(TextView)view.findViewById(R.id.et_foler_name_again_view);
etNameAgain_View.setVisibility(view.GONE);
//
builder.setTitle("密码检验"); builder.setTitle("密码检验");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
//获取输入的字符串 //获取输入的字符串
String password = etName.getText().toString(); String password = etNameOld.getText().toString();
Log.d("mPassword: ", mPassword); Log.d("mPassword: ", mPassword);
Log.d("password: ", password); Log.d("password: ", password);
//判断密码正确性 //判断密码正确性
@ -296,22 +304,24 @@ public class NoteEditActivity extends Activity implements OnClickListener,
Log.d("密码不正确,正确密码是:",mPassword); Log.d("密码不正确,正确密码是:",mPassword);
Toast.makeText(NoteEditActivity.this, "密码错误", Toast.LENGTH_SHORT).show(); Toast.makeText(NoteEditActivity.this, "密码错误", Toast.LENGTH_SHORT).show();
dialog.dismiss(); dialog.dismiss();
onBackPressed(); //onBackPressed();
//关闭软键盘 //关闭软键盘
InputMethodManager inputMethodManager = (InputMethodManager) InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE); getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0); inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
} }
else{ else{
Toast.makeText(NoteEditActivity.this, "密码正确", Toast.LENGTH_SHORT).show(); //flag=1;//密码验证正确的标志
deletePassword();
Toast.makeText(NoteEditActivity.this, "密码正确,删除密码成功。", Toast.LENGTH_SHORT).show();
return;
} }
} }
}); });
builder.setNegativeButton("cancel", new DialogInterface.OnClickListener(){ builder.setNegativeButton("cancel", new DialogInterface.OnClickListener(){
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
dialog.dismiss(); finish();
onBackPressed();
} }
}); });
final Dialog dialog = builder.setView(view).show(); final Dialog dialog = builder.setView(view).show();
@ -578,9 +588,15 @@ public class NoteEditActivity extends Activity implements OnClickListener,
builder.setPositiveButton(android.R.string.ok, builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
deleteCurrentNote(); if (!mWorkingNote.hasPassword()) {//判断有无密码,有密码则无法删除
finish(); deleteCurrentNote();
} finish();
}
else{
Toast.makeText(NoteEditActivity.this, "无法删除设密便签", Toast.LENGTH_SHORT).show();
return;
}
}
}); });
builder.setNegativeButton(android.R.string.cancel, null); builder.setNegativeButton(android.R.string.cancel, null);
builder.show(); builder.show();
@ -613,8 +629,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
//删除密码 //删除密码
case R.id.menu_delete_passwd: case R.id.menu_delete_passwd:
//删除密码前要检验密码 //删除密码前要检验密码
checkPassword(); checkPassword();//并且在里边一并执行deletepassword函数
deletePassword();
break; break;
case R.id.top: case R.id.top:
mWorkingNote.setTop((mWorkingNote.getTopId()) == 1 ? "0" : "1"); mWorkingNote.setTop((mWorkingNote.getTopId()) == 1 ? "0" : "1");
@ -629,17 +644,59 @@ public class NoteEditActivity extends Activity implements OnClickListener,
final AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog.Builder builder = new AlertDialog.Builder(this);
final View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text,null); final View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text,null);
//编辑Text //编辑Text
final EditText etName = (EditText)view.findViewById(R.id.et_foler_name); final EditText etNameOld= (EditText)view.findViewById(R.id.et_foler_name_old);//如果设置了密码,这是原密码
etNameOld.setVisibility(view.GONE);
final TextView etNameOld_View=(TextView)view.findViewById(R.id.et_foler_name_old_view);
etNameOld_View.setVisibility(view.GONE);
if (mWorkingNote.hasPassword()){//如果设置了密码
etNameOld.setVisibility(view.VISIBLE);
etNameOld_View.setVisibility(view.VISIBLE);
etNameOld.setText("");
etNameOld.setHint("请输入原密码");
}
final EditText etName = (EditText)view.findViewById(R.id.et_foler_name);//要设置的密码
final EditText etNameAgain=(EditText)view.findViewById(R.id.et_foler_name_again);//确认密码
//final EditText finalEtNameOld = etNameOld;
etName.setText(""); etName.setText("");
etName.setHint("请输入密码"); etName.setHint("请输入密码");
builder.setTitle("为便签设置新密码"); etNameAgain.setText("");
etNameAgain.setHint("请确认密码");
builder.setTitle("设置密码");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
//获取输入的字符串 //获取输入的字符串
String password = etName.getText().toString(); String password = etName.getText().toString();
String password_again=etNameAgain.getText().toString();
String password_old = null;
if (mWorkingNote.hasPassword()){
password_old= etNameOld.getText().toString();
}
//当输入原密码不对时
if (mWorkingNote.hasPassword()) {
if(!password_old.equals(mWorkingNote.getmPassword())) {
Toast.makeText(NoteEditActivity.this, "原密码错误", Toast.LENGTH_SHORT).show();
return;
}
}
//当设置的密码为空的时候
if (password==null || password.length()==0){
//关闭软键盘
InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
dialog.dismiss();
Toast.makeText(NoteEditActivity.this, "密码不能为空", Toast.LENGTH_SHORT).show();
return;
}
//当确认密码不对时
if (!password.equals(password_again)){
Toast.makeText(NoteEditActivity.this, "密码不一致", Toast.LENGTH_SHORT).show();
return;
}
//设置密码 //设置密码
mWorkingNote.setPassword(password); mWorkingNote.setPassword(password);
mWorkingNote.setLocker("1");//设置密码标志为上锁
//设置密码成功提示 //设置密码成功提示
Toast.makeText(NoteEditActivity.this, "密码设置成功", Toast.LENGTH_SHORT).show(); Toast.makeText(NoteEditActivity.this, "密码设置成功", Toast.LENGTH_SHORT).show();
//关闭软键盘 //关闭软键盘
@ -666,6 +723,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
public void deletePassword() public void deletePassword()
{ {
mWorkingNote.setPassword(""); mWorkingNote.setPassword("");
mWorkingNote.setLocker("0");//设置密码标志为没有锁
//onBackPressed();
} }

@ -19,6 +19,7 @@ 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;
@ -40,6 +41,7 @@ public class NoteItemData {
NoteColumns.TYPE, NoteColumns.TYPE,
NoteColumns.WIDGET_ID, NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE, NoteColumns.WIDGET_TYPE,
NoteColumns.LOCKER,
}; };
private static final int ID_COLUMN = 0; private static final int ID_COLUMN = 0;
@ -54,6 +56,8 @@ 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 LOCKER_COLUMN=12;
private long mId; private long mId;
private long mAlertDate; private long mAlertDate;
@ -69,6 +73,8 @@ public class NoteItemData {
private int mWidgetType; private int mWidgetType;
private String mName; private String mName;
private String mPhoneNumber; private String mPhoneNumber;
//密码标志
private String mLocker;
private boolean mIsLastItem; private boolean mIsLastItem;
private boolean mIsFirstItem; private boolean mIsFirstItem;
@ -76,6 +82,17 @@ public class NoteItemData {
private boolean mIsOneNoteFollowingFolder; private boolean mIsOneNoteFollowingFolder;
private boolean mIsMultiNotesFollowingFolder; private boolean mIsMultiNotesFollowingFolder;
//判断是否上锁
public boolean isLocked(){
if(mLocker.equals("0")) {
Log.d("标志是", mLocker);
return false;
}else {
Log.d("标志是", mLocker);
return true;
}
}
public NoteItemData(Context context, Cursor cursor) { public NoteItemData(Context context, Cursor cursor) {
mId = cursor.getLong(ID_COLUMN); mId = cursor.getLong(ID_COLUMN);
mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN); mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN);
@ -91,6 +108,7 @@ public class NoteItemData {
mType = cursor.getInt(TYPE_COLUMN); mType = cursor.getInt(TYPE_COLUMN);
mWidgetId = cursor.getInt(WIDGET_ID_COLUMN); mWidgetId = cursor.getInt(WIDGET_ID_COLUMN);
mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN); mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);
mLocker = cursor.getString(LOCKER_COLUMN);
mPhoneNumber = ""; mPhoneNumber = "";
if (mParentId == Notes.ID_CALL_RECORD_FOLDER) { if (mParentId == Notes.ID_CALL_RECORD_FOLDER) {

@ -910,7 +910,13 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
case SUB_FOLDER: case SUB_FOLDER:
case CALL_RECORD_FOLDER: case CALL_RECORD_FOLDER:
if (item.getType() == Notes.TYPE_NOTE) { if (item.getType() == Notes.TYPE_NOTE) {
openNode(item); //打开PassWordEditAcitivity类并传递noteid
Intent intent = new Intent(NotesListActivity.this, PassWordEditActivity.class);
long noteId = item.getId();
intent.putExtra("noteId", noteId);
startActivity(intent);
//
//openNode(item);
} else { } else {
Log.e(TAG, "Wrong note type in SUB_FOLDER"); Log.e(TAG, "Wrong note type in SUB_FOLDER");
} }

@ -37,7 +37,7 @@ public class NotesListItem extends LinearLayout {
private TextView mCallName; private TextView mCallName;
private NoteItemData mItemData; private NoteItemData mItemData;
private CheckBox mCheckBox; private CheckBox mCheckBox;
private ImageView mLocker;
public NotesListItem(Context context) { public NotesListItem(Context context) {
super(context); super(context);
inflate(context, R.layout.note_item, this); inflate(context, R.layout.note_item, this);
@ -46,6 +46,8 @@ public class NotesListItem extends LinearLayout {
mTime = (TextView) findViewById(R.id.tv_time); mTime = (TextView) findViewById(R.id.tv_time);
mCallName = (TextView) findViewById(R.id.tv_name); mCallName = (TextView) findViewById(R.id.tv_name);
mCheckBox = (CheckBox) findViewById(android.R.id.checkbox); mCheckBox = (CheckBox) findViewById(android.R.id.checkbox);
//添加锁的标志
mLocker =(ImageView)findViewById(R.id.iv_locker_icon);
} }
public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) { public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) {
@ -75,6 +77,14 @@ public class NotesListItem extends LinearLayout {
} else { } else {
mAlert.setVisibility(View.GONE); mAlert.setVisibility(View.GONE);
} }
/**
if(data.isLocked()){
mLocker.setImageResource(R.drawable.ic_lock_idle_lock);
mLocker.setVisibility(View.VISIBLE);
} else{
mLocker.setVisibility(View.GONE);
}
*/
} else { } else {
mCallName.setVisibility(View.GONE); mCallName.setVisibility(View.GONE);
mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem); mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem);
@ -92,6 +102,16 @@ public class NotesListItem extends LinearLayout {
} else { } else {
mAlert.setVisibility(View.GONE); mAlert.setVisibility(View.GONE);
} }
//设置密码标志以及使加密便签内容不可见,未加密则可见。
if(data.isLocked()){
mLocker.setImageResource(R.drawable.ic_lock_idle_lock);
mLocker.setVisibility(View.VISIBLE);
String text = "已加密";
mTitle.setText(text);
} else{
mLocker.setVisibility(View.GONE);
}
//
} }
} }
mTime.setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate())); mTime.setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate()));

Loading…
Cancel
Save