便签加密功能

pull/1/head
Kk-juejuezi 3 years ago
commit e64b753472

@ -15,7 +15,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;
@ -30,6 +32,8 @@ 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;
@ -46,11 +50,16 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
import android.view.inputmethod.InputMethodManager;
=======
import android.widget.Button;
>>>>>>> 8c352e6399667edb8fde9a423fcc254e47cee228:src/main/java/ui/NoteEditActivity.java
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;
@ -71,6 +80,7 @@ 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;
@ -90,6 +100,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
public ImageView ibSetBgColor;
}
//使用Map实现数据存储
private static final Map<Integer, Integer> sBgSelectorBtnsMap = new HashMap<Integer, Integer>();
static {
sBgSelectorBtnsMap.put(R.id.iv_bg_yellow, ResourceParser.YELLOW);
@ -131,7 +142,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;
@ -165,6 +176,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
//字符数量计数显示
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -176,6 +188,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
}
initResources();
count();
read();
}
/**
@ -216,7 +229,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
}
//如果ID在数据库中未找到
if (!DataUtils.visibleInNoteDatabase(getContentResolver(), noteId, Notes.TYPE_NOTE)) {
Intent jump = new Intent(this, NotesListActivity.class);
Intent jump = new Intent(this, net.micode.notes.ui.NotesListActivity.class);
startActivity(jump);
//程序将跳转到上面声明的intent——jump
showToast(R.string.error_note_not_exist);
@ -402,6 +415,20 @@ 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);
@ -468,7 +495,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);
@ -487,6 +514,8 @@ 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);
}
}//************************存在问题
@ -545,6 +574,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
return true;
}
@Override
/*
*
@ -553,6 +583,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
//根据菜单的id来编剧相关项目
<<<<<<< HEAD:src/main/java/net/micode/notes/ui/NoteEditActivity.java
case R.id.locker:
//为便签上锁
final AlertDialog.Builder create_password = new AlertDialog.Builder(this);
@ -603,6 +634,9 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
mWorkingNote.setPassword("","");
Toast.makeText(NoteEditActivity.this,"Password unlocked successfully",Toast.LENGTH_SHORT).show();
break;
=======
>>>>>>> 8c352e6399667edb8fde9a423fcc254e47cee228:src/main/java/ui/NoteEditActivity.java
case R.id.menu_new_note:
//创建一个新的便签
createNewNote();
@ -674,7 +708,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
*
*/
private void setReminder() {
DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis());
net.micode.notes.ui.DateTimePickerDialog d = new net.micode.notes.ui.DateTimePickerDialog(this, System.currentTimeMillis());
// 建立修改时间日期的对话框
d.setOnDateTimeSetListener(new OnDateTimeSetListener() {
public void OnDateTimeSet(AlertDialog dialog, long date) {
@ -766,7 +800,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
* NotesPreferenceActivity
*/
private boolean isSyncMode() {
return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
return net.micode.notes.ui.NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
}
/*
@ -783,7 +817,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
saveNote();
}
if (mWorkingNote.getNoteId() > 0) {
Intent intent = new Intent(this, AlarmReceiver.class);
Intent intent = new Intent(this, net.micode.notes.ui.AlarmReceiver.class);
intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId()));
//若有有运行的便签就是建立一个链接器将标签id都存在uri中
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
@ -826,19 +860,19 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
}
//没有编辑框的话直接返回
for (int i = index + 1; i < childCount; i++) {
((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
((net.micode.notes.ui.NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
.setIndex(i - 1);
//通过id把编辑框存在便签编辑框中
}
mEditTextList.removeViewAt(index);
//删除特定位置的视图
NoteEditText edit = null;
net.micode.notes.ui.NoteEditText edit = null;
if(index == 0) {
edit = (NoteEditText) mEditTextList.getChildAt(0).findViewById(
edit = (net.micode.notes.ui.NoteEditText) mEditTextList.getChildAt(0).findViewById(
R.id.et_edit_text);
} else {
edit = (NoteEditText) mEditTextList.getChildAt(index - 1).findViewById(
edit = (net.micode.notes.ui.NoteEditText) mEditTextList.getChildAt(index - 1).findViewById(
R.id.et_edit_text);
}
//通过id把编辑框存在空的NoteEditText中
@ -864,11 +898,11 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
View view = getListItem(text, index);
mEditTextList.addView(view, index);
//建立一个新的视图并添加到编辑文本框内
NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
net.micode.notes.ui.NoteEditText edit = (net.micode.notes.ui.NoteEditText) view.findViewById(R.id.et_edit_text);
edit.requestFocus();//请求优先操作
edit.setSelection(0);//定位到起始位置
for (int i = index + 1; i < mEditTextList.getChildCount(); i++) {
((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
((net.micode.notes.ui.NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
.setIndex(i);
//遍历子文本框并设置对应对下标
}
@ -933,7 +967,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 NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
final net.micode.notes.ui.NoteEditText edit = (net.micode.notes.ui.NoteEditText) view.findViewById(R.id.et_edit_text);
edit.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
//创建一个文本编辑框并设置可见性
CheckBox cb = ((CheckBox) view.findViewById(R.id.cb_edit_item));
@ -1020,7 +1054,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen
for (int i = 0; i < mEditTextList.getChildCount(); i++) {
View view = mEditTextList.getChildAt(i);
//遍历所有子编辑框的视图
NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
net.micode.notes.ui.NoteEditText edit = (net.micode.notes.ui.NoteEditText) view.findViewById(R.id.et_edit_text);
if (!TextUtils.isEmpty(edit.getText())) {
//若文本不为空
if (((CheckBox) view.findViewById(R.id.cb_edit_item)).isChecked()) {
@ -1194,6 +1228,31 @@ 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();
// }
// });
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

@ -31,15 +31,26 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_modified_date"
android:layout_width="0dip"
android:layout_width="300dip"
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"
@ -63,11 +74,17 @@
android:layout_marginRight="8dip" />
<ImageButton
<<<<<<< HEAD
android:id="@+id/image_button"
=======
android:id="@+id/btn_set_bg_color"
>>>>>>> 8c352e6399667edb8fde9a423fcc254e47cee228
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@drawable/bg_btn_set_color" />
</LinearLayout>
<LinearLayout
@ -76,12 +93,12 @@
android:layout_height="fill_parent"
android:orientation="vertical">
<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: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:layout_width="fill_parent"

@ -17,7 +17,9 @@
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_insert_image"
android:title="insert image"/>
<item
android:id="@+id/locker"
android:title="@string/note_lock"/>
@ -28,14 +30,13 @@
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,7 +17,8 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">超级便签</string>
<string name="app_name">note</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>
@ -38,6 +39,7 @@
<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 -->

Loading…
Cancel
Save