小米便签添加密码功能实现

pull/2/head
wangziyang 3 years ago
parent 7d085c7395
commit e96aa944d1

@ -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) <!-- 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) <!-- Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/create_user_dialog_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_color_btn_mask"
android:minWidth="200dp"
android:orientation="vertical"
android:padding="10dp"
android:paddingBottom="30dp"
android:paddingTop="30dp">
<EditText
android:id="@+id/text_info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/bg_color_btn_mask"
android:gravity="center|left"
android:hint="请输入密钥"
android:minHeight="40dp"
android:textSize="18sp" />
<Button
android:id="@+id/btn_save_pop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="确定" />
</LinearLayout>

@ -49,4 +49,7 @@
<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_encoding"
android:title="@string/menu_encoding" />
</menu> </menu>

@ -36,4 +36,8 @@
<item <item
android:id="@+id/menu_search" android:id="@+id/menu_search"
android:title="@string/menu_search"/> android:title="@string/menu_search"/>
<item
android:id="@+id/menu_new_note"
android:title="@string/menu_new_note"/>
</menu> </menu>

@ -71,6 +71,8 @@
<string name="alert_message_delete_note">确认要删除该条便签吗?</string> <string name="alert_message_delete_note">确认要删除该条便签吗?</string>
<string name="alert_message_delete_folder">确认删除文件夹及所包含的便签吗?</string> <string name="alert_message_delete_folder">确认删除文件夹及所包含的便签吗?</string>
<string name="format_move_notes_to_folder">已将所选 %1$d 条便签移到 %2$s 文件夹</string> <string name="format_move_notes_to_folder">已将所选 %1$d 条便签移到 %2$s 文件夹</string>
<string name="menu_encoding">编码</string>
<string name="menu_new_note">新建便签</string>
<!-- export text --> <!-- export text -->
<string name="error_sdcard_unmounted">SD卡被占用不能操作</string> <string name="error_sdcard_unmounted">SD卡被占用不能操作</string>
<string name="error_sdcard_export">导出文本时发生错误请检查SD卡</string> <string name="error_sdcard_export">导出文本时发生错误请检查SD卡</string>
@ -119,6 +121,7 @@
<string name="search">便签</string> <string name="search">便签</string>
<string name="datetime_dialog_ok">设置</string> <string name="datetime_dialog_ok">设置</string>
<string name="datetime_dialog_cancel">取消</string> <string name="datetime_dialog_cancel">取消</string>
<string name="InputPassword">输入密码</string>
<plurals name="search_results_title"> <plurals name="search_results_title">
<item quantity="other"><xliff:g id="NUMBER">%1$s</xliff:g> 条符合“<xliff:g id="SEARCH">%2$s</xliff:g>”的搜索结果</item> <item quantity="other"><xliff:g id="NUMBER">%1$s</xliff:g> 条符合“<xliff:g id="SEARCH">%2$s</xliff:g>”的搜索结果</item>
</plurals> </plurals>

@ -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) <!-- Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)

@ -75,6 +75,8 @@
<string name="alert_message_delete_notes">Confirm to delete the selected %d notes?</string> <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="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="format_move_notes_to_folder">Have moved selected %1$d notes to %2$s folder</string>
<string name="menu_encoding">encoding</string>
<string name="menu_new_note">NewNote</string>
<!-- Error information --> <!-- Error information -->
<string name="error_sdcard_unmounted">SD card busy, not available now</string> <string name="error_sdcard_unmounted">SD card busy, not available now</string>
<string name="error_sdcard_export">Export failed, please check SD card</string> <string name="error_sdcard_export">Export failed, please check SD card</string>
@ -119,7 +121,7 @@
<string name="button_delete">Delete</string> <string name="button_delete">Delete</string>
<string name="call_record_folder_name">Call notes</string> <string name="call_record_folder_name">Call notes</string>
<string name="hint_foler_name">Input name</string> <string name="hint_foler_name">Input name</string>
<string name="InputPassword">Input Password</string>
<string name="search_label">Searching Notes</string> <string name="search_label">Searching Notes</string>
<string name="search_hint">Search notes</string> <string name="search_hint">Search notes</string>
<string name="search_setting_description">Text in your notes</string> <string name="search_setting_description">Text in your notes</string>

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

@ -165,6 +165,10 @@ public class Notes {
* <P> Type : INTEGER (long) </P> * <P> Type : INTEGER (long) </P>
*/ */
public static final String VERSION = "version"; public static final String VERSION = "version";
public static final String PASSWORD = "password";
} }
public interface DataColumns { public interface DataColumns {

@ -60,7 +60,8 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
NoteColumns.LOCAL_MODIFIED + " INTEGER NOT NULL DEFAULT 0," + NoteColumns.LOCAL_MODIFIED + " INTEGER NOT NULL DEFAULT 0," +
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 + " TEXT NOT NULL DEFAULT ''" +
")"; ")";
private static final String CREATE_DATA_TABLE_SQL = private static final String CREATE_DATA_TABLE_SQL =
@ -321,6 +322,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
upgradeToV4(db); upgradeToV4(db);
oldVersion++; oldVersion++;
} }
if (oldVersion == 4){
upgradeToV5(db);
oldVersion++;
}
if (reCreateTriggers) { if (reCreateTriggers) {
reCreateNoteTableTriggers(db); reCreateNoteTableTriggers(db);
@ -359,4 +364,8 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ " INTEGER NOT NULL DEFAULT 0"); + " INTEGER NOT NULL DEFAULT 0");
} }
private void upgradeToV5(SQLiteDatabase db){
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.PASSWORD
+ " INTEGER NOT NULL DEFAULT 0");
}
} }

@ -77,8 +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);*/
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification); mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
} }

@ -72,8 +72,6 @@ public class Note {
public void setNoteValue(String key, String value) { public void setNoteValue(String key, String value) {
mNoteDiffValues.put(key, value); mNoteDiffValues.put(key, value);
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
} }
public void setTextData(String key, String value) { public void setTextData(String key, String value) {

@ -20,6 +20,7 @@ import android.appwidget.AppWidgetManager;
import android.content.ContentUris; import android.content.ContentUris;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.print.PrinterId;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
@ -39,6 +40,8 @@ public class WorkingNote {
private long mNoteId; private long mNoteId;
// Note content // Note content
private String mContent; private String mContent;
private String mPassword;
// Note mode // Note mode
private int mMode; private int mMode;
@ -62,6 +65,9 @@ public class WorkingNote {
private NoteSettingChangedListener mNoteSettingStatusListener; private NoteSettingChangedListener mNoteSettingStatusListener;
public static final String[] DATA_PROJECTION = new String[] { public static final String[] DATA_PROJECTION = new String[] {
DataColumns.ID, DataColumns.ID,
DataColumns.CONTENT, DataColumns.CONTENT,
@ -78,7 +84,8 @@ public class WorkingNote {
NoteColumns.BG_COLOR_ID, NoteColumns.BG_COLOR_ID,
NoteColumns.WIDGET_ID, NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE, NoteColumns.WIDGET_TYPE,
NoteColumns.MODIFIED_DATE NoteColumns.MODIFIED_DATE,
NoteColumns.PASSWORD,
}; };
private static final int DATA_ID_COLUMN = 0; private static final int DATA_ID_COLUMN = 0;
@ -101,6 +108,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;
// New note construct // New note construct
private WorkingNote(Context context, long folderId) { private WorkingNote(Context context, long folderId) {
mContext = context; mContext = context;
@ -137,6 +146,7 @@ public class WorkingNote {
mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN); mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN);
mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN); mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN);
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN); mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
mPassword = cursor.getString(NOTE_PASSWORD_COLUMN);
} }
cursor.close(); cursor.close();
} else { } else {
@ -294,6 +304,15 @@ public class WorkingNote {
mNote.setNoteValue(NoteColumns.PARENT_ID, String.valueOf(Notes.ID_CALL_RECORD_FOLDER)); mNote.setNoteValue(NoteColumns.PARENT_ID, String.valueOf(Notes.ID_CALL_RECORD_FOLDER));
} }
public void setPassword(String password){
mPassword = password;
mNote.setNoteValue(NoteColumns.PASSWORD,mPassword);
}
public String getmPassword(){
return mPassword;
}
public boolean hasClockAlert() { public boolean hasClockAlert() {
return (mAlertDate > 0 ? true : false); return (mAlertDate > 0 ? true : false);
} }
@ -342,6 +361,7 @@ public class WorkingNote {
return mWidgetType; return mWidgetType;
} }
public interface NoteSettingChangedListener { public interface NoteSettingChangedListener {
/** /**
* Called when the background color of current note has just changed * Called when the background color of current note has just changed

@ -77,7 +77,7 @@ public class DateTimePickerDialog extends AlertDialog implements OnClickListener
DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_YEAR |
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_12HOUR;
setTitle(DateUtils.formatDateTime(this.getContext(), date, flag)); setTitle(DateUtils.formatDateTime(this.getContext(), date, flag));
} }

@ -19,6 +19,8 @@ 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.AlertDialog.Builder;
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;
@ -65,6 +67,8 @@ import net.micode.notes.ui.NoteEditText.OnTextViewChangeListener;
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;
import net.micode.notes.ui.text;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
@ -82,6 +86,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
public TextView tvAlertDate; public TextView tvAlertDate;
public ImageView ibSetBgColor; public ImageView ibSetBgColor;
} }
private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>(); private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>();
@ -149,6 +155,15 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private String mUserQuery; private String mUserQuery;
private Pattern mPattern; private Pattern mPattern;
private text t;
public void settext(String str1){
t.setStr(str1);
}
public String Gettext(){
return t.GetStr();
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -269,6 +284,35 @@ public class NoteEditActivity extends Activity implements OnClickListener,
} }
private void initNoteScreen() { private void initNoteScreen() {
final String mPassword = mWorkingNote.getmPassword();
if(mPassword != null && mPassword.length() != 0) {
View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
//编辑Text
final EditText inputServer = (EditText) view.findViewById(R.id.et_foler_name);
inputServer.setText("");
inputServer.setHint("请输入密码");
;
AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("密码校验");
builder.setIcon(android.R.drawable.ic_dialog_info).setView(inputServer);
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
onBackPressed();
}
});
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String password = inputServer.getText().toString();
if (!password.equals(mPassword)) {
dialog.dismiss();
onBackPressed();
}
}
});
final Dialog dialog = builder.setView(view).show();
dialog.show();
}
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) {
@ -293,6 +337,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
* is not ready * is not ready
*/ */
showAlertHeader(); showAlertHeader();
} }
private void showAlertHeader() { private void showAlertHeader() {
@ -430,7 +476,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
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);
@ -505,6 +551,27 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return true; return true;
} }
private void encoding(){
//final EditText inputServer = new EditText(this);
View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
//编辑Text
final EditText inputServer = (EditText) view.findViewById(R.id.et_foler_name);
AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("请输入密钥");
builder.setIcon(android.R.drawable.ic_dialog_info).setView(inputServer).setNegativeButton("Cancel", null);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which) {
String string = inputServer.getText().toString();
mWorkingNote.setPassword(string);
}
} ).show();
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
@ -547,6 +614,9 @@ 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_encoding:
encoding();
break;
default: default:
break; break;
} }

@ -0,0 +1,12 @@
package net.micode.notes.ui;
public class text {
private String str;
public void setStr(String str0){
str = str0;
}
public String GetStr(){
return str;
}
}
Loading…
Cancel
Save