Kk-juejuezi 3 years ago
parent 8956b85771
commit 6c1c997620

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

@ -60,7 +60,9 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
NoteColumns.LOCAL_MODIFIED + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.PASSWORD + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.TAG_PASSWORD + " TEXT NOT NULL DEFAULT ''" +
")";//数据库中需要存储的项目的名称,就相当于创建一个表格的表头的内容。
private static final String CREATE_DATA_TABLE_SQL =
@ -325,6 +327,16 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
oldVersion++;
}
if(oldVersion == 4){
upgradeToV5(db);
oldVersion++;
}
if(oldVersion == 5){
upgradeToV6(db);
oldVersion++;
}
if (reCreateTriggers) {
reCreateNoteTableTriggers(db);
reCreateDataTableTriggers(db);
@ -362,4 +374,14 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ " INTEGER NOT NULL DEFAULT 0");
}//更新到V4版本,但是不知道V2、V3、V4是什么意思
private void upgradeToV5(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.PASSWORD
+ " INTEGER NOT NULL DEFAULT 0");
}
private void upgradeToV6(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.TAG_PASSWORD
+ " INTEGER NOT NULL DEFAULT 0");
}
}

@ -40,6 +40,9 @@ public class WorkingNote {
// Note content
private String mContent;
// Note mode
private String mPassword = "";
private String mTag = "";
//note password,initial = 0
private int mMode;
private long mAlertDate;
@ -80,7 +83,9 @@ public class WorkingNote {
NoteColumns.BG_COLOR_ID,
NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE,
NoteColumns.MODIFIED_DATE
NoteColumns.MODIFIED_DATE,
NoteColumns.PASSWORD,
NoteColumns.TAG_PASSWORD
};
private static final int DATA_ID_COLUMN = 0;
@ -103,6 +108,10 @@ public class WorkingNote {
private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
private static final int NOTE_PASSWORD_COLUMN = 6;
private static final int NOTE_TAG_PASSWORD_COLUMN = 7;
// New note construct
public WorkingNote(Context context, long folderId) {
mContext = context;
@ -143,6 +152,8 @@ public class WorkingNote {
mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN);
mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN);
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
mPassword = cursor.getString(NOTE_PASSWORD_COLUMN);
mTag = cursor.getString(NOTE_TAG_PASSWORD_COLUMN);
}
cursor.close();
// 若不存在,报错
@ -418,4 +429,16 @@ public class WorkingNote {
*/
void onCheckListModeChanged(int oldMode, int newMode);
}
/**便
*
* @param password 访
*/
public void setPassword(String password,String tag){
mPassword = password;
mTag = tag;
mNote.setNoteValue(NoteColumns.PASSWORD,String.valueOf(mPassword));
mNote.setNoteValue(NoteColumns.TAG_PASSWORD,String.valueOf(mTag));
}
}

@ -16,11 +16,9 @@
package net.micode.notes.ui;
import android.Manifest;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.PendingIntent;
import android.app.SearchManager;
import android.appwidget.AppWidgetManager;
@ -32,8 +30,6 @@ import android.content.SharedPreferences;
import android.graphics.Paint;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.speech.tts.TextToSpeech;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.Spannable;
@ -50,12 +46,11 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -76,7 +71,6 @@ import net.micode.notes.widget.NoteWidgetProvider_4x;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -96,9 +90,6 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
public ImageView ibSetBgColor;
}
//使用Map实现数据存储
final String[] mPermissionList = new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE};
private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>();
static {
sBgSelectorBtnsMap.put(R.id.iv_bg_yellow, ResourceParser.YELLOW);
@ -140,7 +131,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
private static final String TAG = "NoteEditActivity";
private HeadViewHolder mNoteHeaderHolder;
private TextToSpeech mTTS;
private View mHeadViewPanel;
//私有化一个界面操作mHeadViewPanel对表头的操作
private View mNoteBgColorSelector;
@ -174,7 +165,6 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
//字符数量计数显示
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -186,7 +176,6 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
}
initResources();
count();
read();
}
/**
@ -227,7 +216,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
}
//如果ID在数据库中未找到
if (!DataUtils.visibleInNoteDatabase(getContentResolver(), noteId, Notes.TYPE_NOTE)) {
Intent jump = new Intent(this, net.micode.notes.ui.NotesListActivity.class);
Intent jump = new Intent(this, NotesListActivity.class);
startActivity(jump);
//程序将跳转到上面声明的intent——jump
showToast(R.string.error_note_not_exist);
@ -307,7 +296,8 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
}
private void initNoteScreen() {
//对界面的初始化操作
//对便签的初始化操作
mNoteEditor.setTextAppearance(this, TextAppearanceResources
.getTexAppearanceResource(mFontSizeId));
//设置外观
@ -412,20 +402,6 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
}
private void initResources() {
mTTS = new TextToSpeech(this, new OnInitListener() {
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = mTTS.setLanguage(Locale.US);
if (result != TextToSpeech.LANG_COUNTRY_AVAILABLE && result != TextToSpeech.LANG_AVAILABLE) {
//ToastmakeTextCodeViewthisTTS暂时不支持这种语言朗读50000show()
}
}
}
});
mHeadViewPanel = findViewById(R.id.note_title);
mNoteHeaderHolder = new HeadViewHolder();
mNoteHeaderHolder.tvModified = (TextView) findViewById(R.id.tv_modified_date);
@ -492,7 +468,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
if (id == R.id.btn_set_bg_color) {
mNoteBgColorSelector.setVisibility(View.VISIBLE);
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.VISIBLE);
- View.VISIBLE);
} else if (sBgSelectorBtnsMap.containsKey(id)) {
findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(
View.GONE);
@ -511,8 +487,6 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
}
mFontSizeSelector.setVisibility(View.GONE);
}else if (id==R.id.read_note){
mTTS.speak(mNoteEditor.getText().toString(),TextToSpeech.QUEUE_FLUSH,null);
}
}//************************存在问题
@ -571,7 +545,6 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
return true;
}
@Override
/*
*
@ -580,14 +553,56 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
//根据菜单的id来编剧相关项目
case R.id.action_insert_image:
//绑定按钮的点击响应获取危险权限这里的100是申请码可以自己定义整数即可
ActivityCompat.requestPermissions(NoteEditActivity.this, mPermissionList, 100);
//用于获取焦点,否则插入图片时没有响应
mNoteEditor.getFocusable();
mNoteEditor.insertImage(realPathFromUri, realPathFromUri + "\" style=\"max-width:100%");
case R.id.locker:
//为便签上锁
final AlertDialog.Builder create_password = new AlertDialog.Builder(this);
//创建关于上锁操作的对话框
final View view = LayoutInflater.from(this).inflate(R.layout.buttom,null);
//???
final EditText etName = (EditText)view.findViewById(R.id.password);
final EditText etTag = (EditText)view.findViewById(R.id.tag);
//???
etName.setText("");
etName.setHint(" Please input your password");
etTag.setText("");
etTag.setHint(" Please input your tag");
create_password.setTitle(getString(R.string.alert_set_password));
//设置标题为Set your password
create_password.setNegativeButton("OK", new DialogInterface.OnClickListener() {//设置监听,获取输入的字符串
@Override
public void onClick(DialogInterface dialog, int which) {
String password = etName.getText().toString();
String tag = etTag.getText().toString();
//获取输入的字符串
mWorkingNote.setPassword(password,tag);
//设置密码
Toast.makeText(NoteEditActivity.this,"Password created successfully",Toast.LENGTH_SHORT).show();
//设置密码成功的消息弹窗
InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
//关闭软键盘
dialog.dismiss();
//关闭dialog
}
});
create_password.setPositiveButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//关闭软键盘
Toast.makeText(NoteEditActivity.this,"Canceling...",Toast.LENGTH_SHORT).show();
InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
}
});
final Dialog dialog = create_password.setView(view).show();//error
dialog.show();
break;
case R.id.unlocker:
mWorkingNote.setPassword("","");
Toast.makeText(NoteEditActivity.this,"Password unlocked successfully",Toast.LENGTH_SHORT).show();
break;
case R.id.menu_new_note:
//创建一个新的便签
createNewNote();
@ -659,7 +674,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
*
*/
private void setReminder() {
net.micode.notes.ui.DateTimePickerDialog d = new net.micode.notes.ui.DateTimePickerDialog(this, System.currentTimeMillis());
DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis());
// 建立修改时间日期的对话框
d.setOnDateTimeSetListener(new OnDateTimeSetListener() {
public void OnDateTimeSet(AlertDialog dialog, long date) {
@ -751,7 +766,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
* NotesPreferenceActivity
*/
private boolean isSyncMode() {
return net.micode.notes.ui.NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
}
/*
@ -768,7 +783,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
saveNote();
}
if (mWorkingNote.getNoteId() > 0) {
Intent intent = new Intent(this, net.micode.notes.ui.AlarmReceiver.class);
Intent intent = new Intent(this, AlarmReceiver.class);
intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId()));
//若有有运行的便签就是建立一个链接器将标签id都存在uri中
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
@ -811,19 +826,19 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
}
//没有编辑框的话直接返回
for (int i = index + 1; i < childCount; i++) {
((net.micode.notes.ui.NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
.setIndex(i - 1);
//通过id把编辑框存在便签编辑框中
}
mEditTextList.removeViewAt(index);
//删除特定位置的视图
net.micode.notes.ui.NoteEditText edit = null;
NoteEditText edit = null;
if(index == 0) {
edit = (net.micode.notes.ui.NoteEditText) mEditTextList.getChildAt(0).findViewById(
edit = (NoteEditText) mEditTextList.getChildAt(0).findViewById(
R.id.et_edit_text);
} else {
edit = (net.micode.notes.ui.NoteEditText) mEditTextList.getChildAt(index - 1).findViewById(
edit = (NoteEditText) mEditTextList.getChildAt(index - 1).findViewById(
R.id.et_edit_text);
}
//通过id把编辑框存在空的NoteEditText中
@ -849,11 +864,11 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
View view = getListItem(text, index);
mEditTextList.addView(view, index);
//建立一个新的视图并添加到编辑文本框内
net.micode.notes.ui.NoteEditText edit = (net.micode.notes.ui.NoteEditText) view.findViewById(R.id.et_edit_text);
NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
edit.requestFocus();//请求优先操作
edit.setSelection(0);//定位到起始位置
for (int i = index + 1; i < mEditTextList.getChildCount(); i++) {
((net.micode.notes.ui.NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
.setIndex(i);
//遍历子文本框并设置对应对下标
}
@ -918,7 +933,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
private View getListItem(String item, int index) {
View view = LayoutInflater.from(this).inflate(R.layout.note_edit_list_item, null);
//创建一个视图
final net.micode.notes.ui.NoteEditText edit = (net.micode.notes.ui.NoteEditText) view.findViewById(R.id.et_edit_text);
final NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
edit.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
//创建一个文本编辑框并设置可见性
CheckBox cb = ((CheckBox) view.findViewById(R.id.cb_edit_item));
@ -1005,7 +1020,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
for (int i = 0; i < mEditTextList.getChildCount(); i++) {
View view = mEditTextList.getChildAt(i);
//遍历所有子编辑框的视图
net.micode.notes.ui.NoteEditText edit = (net.micode.notes.ui.NoteEditText) view.findViewById(R.id.et_edit_text);
NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
if (!TextUtils.isEmpty(edit.getText())) {
//若文本不为空
if (((CheckBox) view.findViewById(R.id.cb_edit_item)).isChecked()) {
@ -1179,32 +1194,6 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
public void afterTextChanged(Editable s) {
textView.setText("字符数: " + currentLength);
}
});
}
public void read() {
ImageButton read = findViewById(R.id.read_note);
read.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mTTS.speak(mNoteEditor.getText().toString(),TextToSpeech.QUEUE_FLUSH,null);
}
});
}
// final String[] mPermissionList = new String[]{
// Manifest.permission.WRITE_EXTERNAL_STORAGE,
// Manifest.permission.READ_EXTERNAL_STORAGE};
// findViewById(R.id.action_insert_image).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
////绑定按钮的点击响应获取危险权限这里的100是申请码可以自己定义整数即可
// ActivityCompat.requestPermissions(NoteEditActivity.this, mPermissionList, 100);
////用于获取焦点,否则插入图片时没有响应
// mNoteEditor.focusEditor();
// }
// });
}

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

@ -936,7 +936,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (view instanceof NotesListItem) {
NoteItemData item = ((NotesListItem) view).getItemData();
final NoteItemData item = ((NotesListItem) view).getItemData();
if (mNotesListAdapter.isInChoiceMode()) {
if (item.getType() == Notes.TYPE_NOTE) {
position = position - mNotesListView.getHeaderViewsCount();
@ -952,7 +952,46 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
|| item.getType() == Notes.TYPE_SYSTEM) {
openFolder(item);
} else if (item.getType() == Notes.TYPE_NOTE) {
final AlertDialog.Builder check_password = new AlertDialog.Builder(NotesListActivity.this);
//this is what???
final View view_check = LayoutInflater.from(NotesListActivity.this).inflate(R.layout.dialog_edit_text,null);
final EditText etName = (EditText)view_check.findViewById(R.id.et_foler_name);
if (item.hasPassword()){
openNode(item);
}
else{
etName.setText("");
etName.setHint(" Input the right password");
check_password.setTitle("Check your password");
check_password.setPositiveButton("Cancel", new DialogInterface.OnClickListener() {//设置Cancel按钮
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(NotesListActivity.this,"Canceling...",Toast.LENGTH_SHORT).show();
InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
}
});
check_password.setNegativeButton("OK", new DialogInterface.OnClickListener() {//设置OK按钮
@Override
public void onClick(DialogInterface dialog, int which) {
String password = etName.getText().toString();
if (password.equals(item.getPassword())){
Toast.makeText(NotesListActivity.this,"Oh!!!You are right!",Toast.LENGTH_SHORT).show();
InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
dialog.dismiss();
openNode(item);
}
else {
Toast.makeText(NotesListActivity.this,"You are wrong...",Toast.LENGTH_SHORT).show();
}
}
});
final Dialog dialog = check_password.setView(view_check).show();//view is wrong
dialog.show();
}
} else {
Log.e(TAG, "Wrong note type in NOTE_LIST");
}

@ -38,6 +38,7 @@ public class NotesListItem extends LinearLayout {
private TextView mCallName; //
private NoteItemData mItemData; //标签数据
private CheckBox mCheckBox; //打钩框
private ImageView mLocker;//锁图片
/*初始化基本信息*/
public NotesListItem(Context context) {
@ -49,6 +50,7 @@ public class NotesListItem extends LinearLayout {
mTime = (TextView) findViewById(R.id.tv_time);
mCallName = (TextView) findViewById(R.id.tv_name);
mCheckBox = (CheckBox) findViewById(android.R.id.checkbox);
mLocker = (ImageView) findViewById(R.id.iv_locker);
}
///根据data的属性对各个控件的属性的控制主要是可见性Visibility内容setText格式setTextAppearance
public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) {
@ -58,8 +60,8 @@ public class NotesListItem extends LinearLayout {
} else {
mCheckBox.setVisibility(View.GONE);
}
mItemData = data;
///设置控件属性一共三种情况由data的id和父id是否与保存到文件夹的id一致来决定
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
mCallName.setVisibility(View.GONE);
@ -82,6 +84,7 @@ public class NotesListItem extends LinearLayout {
} else {
mAlert.setVisibility(View.GONE);
}
} else {
mCallName.setVisibility(View.GONE);
mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem);
@ -101,6 +104,16 @@ public class NotesListItem extends LinearLayout {
}
}
}
mLocker.setImageResource(R.drawable.title_locker);
if (data.hasPassword()){
mLocker.setVisibility(GONE);
}
else {
mLocker.setVisibility(VISIBLE);
String text = " 不给你看哟~" + " (tag:" + data.getmTAG() + ")";
mTitle.setText(text);
}
///设置内容获取相关时间从data里编辑的日期中获取
mTime. setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate()));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
<EditText
android:id="@+id/tag"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
</LinearLayout>

@ -31,26 +31,15 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_modified_date"
android:layout_width="300dip"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="left|center_vertical"
android:layout_marginRight="8dip"
android:textAppearance="@style/TextAppearanceSecondaryItem" />
<ImageButton
android:id="@+id/read_note"
android:layout_width="25dp"
android:layout_height="25dp"
android:background="@drawable/laba"
android:layout_gravity="center|center_vertical"
android:layout_marginHorizontal="@dimen/text_font_size_large" />
<ImageView
android:id="@+id/iv_alert_icon"
android:layout_width="wrap_content"
@ -72,14 +61,13 @@
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="8dip" />
<ImageButton
android:id="@+id/btn_set_bg_color"
android:id="@+id/image_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@drawable/bg_btn_set_color" />
</LinearLayout>
<LinearLayout
@ -88,12 +76,12 @@
android:layout_height="fill_parent"
android:orientation="vertical">
<!-- <ImageView-->
<!-- android:id="@+id/btn_set_bg_color"-->
<!-- android:layout_width="wrap_content"-->
<!-- androidight="43dip"-->
<!-- android:layout_gravity="top|right"-->
<!-- android:background="@drawable/bg_color_btn_mask" />:layout_he-->
<ImageView
android:id="@+id/btn_set_bg_color"
android:layout_width="wrap_content"
android:layout_height="43dip"
android:layout_gravity="top|right"
android:background="@drawable/bg_color_btn_mask" />
<ImageView
android:layout_width="fill_parent"
@ -103,11 +91,11 @@
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_gravity="left|top"
android:layout_weight="1"
android:scrollbars="none"
android:fadingEdgeLength="0dip"
android:overScrollMode="never"
android:layout_gravity="left|top"
android:fadingEdgeLength="0dip">
android:scrollbars="none">
<LinearLayout
android:layout_width="fill_parent"
@ -127,11 +115,12 @@
<LinearLayout
android:id="@+id/note_edit_list"
android:layout_width="fill_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="-10dip"
android:orientation="vertical"
android:visibility="gone" />
</LinearLayout>
</ScrollView>

@ -69,6 +69,12 @@
android:clickable="false"
android:visibility="gone" />
</LinearLayout>
<ImageView
android:id="@+id/iv_locker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@drawable/title_locker" />
<ImageView
android:id="@+id/iv_alert_icon"

@ -17,20 +17,25 @@
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/locker"
android:title="@string/note_lock"/>
<item
android:id="@+id/action_insert_image"
android:title="insert image"/>
android:id="@+id/unlocker"
android:title="@string/note_unlock"/>
<item
android:id="@+id/menu_new_note"
android:title="@string/notelist_menu_new"/>
<item
android:id="@+id/menu_delete"
android:title="@string/menu_delete"/>
<item
android:id="@+id/menu_font_size"
android:title="@string/menu_font_size"/>
<item
android:id="@+id/menu_delete"
android:title="@string/menu_delete" />
<item
android:id="@+id/menu_list_mode"
android:title="@string/menu_list_mode" />

@ -17,13 +17,14 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">note</string>
<string name="app_name">超级便签</string>
<string name="app_widget2x2">Notes 2x2</string>
<string name="app_widget4x4">Notes 4x4</string>
<string name="widget_havenot_content">No associated note found, click to create associated note.</string>
<string name="widget_under_visit_mode">Privacy modecan not see note content</string>
<string name="notelist_string_info">...</string>
<string name="note_lock">Lock</string>
<string name="note_unlock">Unlock</string>
<string name="notelist_menu_new">Add note</string>
<string name="delete_remind_time_message">Delete reminder successfully</string>
<string name="set_remind_time_message">Set reminder</string>
@ -37,7 +38,6 @@
<string name="note_link_web">Browse web</string>
<string name="note_link_other">Open map</string>
<!-- Text export file information -->
<string name="read_note">read_note</string>
<string name="file_path">/MIUI/notes/</string>
<string name="file_name_txt_format">notes_%s.txt</string>
<!-- notes list string -->
@ -77,6 +77,8 @@
<string name="alert_message_delete_notes">Confirm to delete the selected %d notes?</string>
<string name="alert_message_delete_note">Confirm to delete this note?</string>
<string name="format_move_notes_to_folder">Have moved selected %1$d notes to %2$s folder</string>
<string name="alert_set_password">Set your password and tag</string>;
<!-- Error information -->
<string name="error_sdcard_unmounted">SD card busy, not available now</string>
<string name="error_sdcard_export">Export failed, please check SD card</string>

Loading…
Cancel
Save