|
|
|
@ -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) {
|
|
|
|
|
//Toast.makeText(CodeView.this,"TTS暂时不支持这种语言朗读",50000).show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
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();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
}
|