|
|
|
@ -14,6 +14,8 @@ import android.content.SharedPreferences;
|
|
|
|
|
import android.graphics.Paint;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.preference.PreferenceManager;
|
|
|
|
|
import android.speech.tts.TextToSpeech;
|
|
|
|
|
import android.speech.tts.TextToSpeech.OnInitListener;
|
|
|
|
|
import android.text.Spannable;
|
|
|
|
|
import android.text.SpannableString;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
@ -127,21 +129,13 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
"android.permission.WRITE_EXTERNAL_STORAGE" };//权限名称
|
|
|
|
|
|
|
|
|
|
private static final String TAG = "NoteEditActivity";
|
|
|
|
|
|
|
|
|
|
private HeadViewHolder mNoteHeaderHolder;
|
|
|
|
|
|
|
|
|
|
private View mHeadViewPanel;
|
|
|
|
|
|
|
|
|
|
private View mNoteBgColorSelector;
|
|
|
|
|
|
|
|
|
|
private View mFontSizeSelector;
|
|
|
|
|
|
|
|
|
|
private EditText mNoteEditor;
|
|
|
|
|
|
|
|
|
|
private View mNoteEditorPanel;
|
|
|
|
|
|
|
|
|
|
private WorkingNote mWorkingNote;
|
|
|
|
|
|
|
|
|
|
private SharedPreferences mSharedPrefs;
|
|
|
|
|
private int mFontSizeId;
|
|
|
|
|
|
|
|
|
@ -234,6 +228,24 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
initResources();
|
|
|
|
|
|
|
|
|
|
final ImageButton add_img_btn = (ImageButton) findViewById(R.id.add_img_btn);//根据id获取添加图片按钮
|
|
|
|
|
//为点击图片按钮设置监听器
|
|
|
|
|
add_img_btn.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
Log.d(TAG, "onClick: click add image button");
|
|
|
|
|
//ACTION_GET_CONTENT: 允许用户选择特殊种类的数据,并返回(特殊种类的数据:照一张相片或录一段音)
|
|
|
|
|
Intent loadImage = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
|
|
//Category属性用于指定当前动作(Action)被执行的环境.
|
|
|
|
|
//CATEGORY_OPENABLE; 用来指示一个ACTION_GET_CONTENT的intent
|
|
|
|
|
loadImage.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
|
|
loadImage.setType("image/*");
|
|
|
|
|
startActivityForResult(loadImage, PHOTO_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
convertToImage();//将路径显示为图片
|
|
|
|
|
count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -493,6 +505,24 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE;
|
|
|
|
|
}
|
|
|
|
|
mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list);
|
|
|
|
|
|
|
|
|
|
//朗读
|
|
|
|
|
mTTS = new TextToSpeech(this,new TextToSpeech.OnInitListener(){
|
|
|
|
|
@Override
|
|
|
|
|
public void onInit(int status){
|
|
|
|
|
// 判断是否转化成功
|
|
|
|
|
if (status == TextToSpeech.SUCCESS){
|
|
|
|
|
//默认设定语言为中文
|
|
|
|
|
int result = mTTS.setLanguage(Locale.CHINESE);
|
|
|
|
|
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED){
|
|
|
|
|
Toast.makeText(NoteEditActivity.this, "Language not available.", Toast.LENGTH_SHORT).show();
|
|
|
|
|
}else{
|
|
|
|
|
//不支持中文就将语言设置为英文
|
|
|
|
|
mTTS.setLanguage(Locale.US);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -661,6 +691,9 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
setReminder();
|
|
|
|
|
} else if (itemId == R.id.menu_delete_remind) {
|
|
|
|
|
mWorkingNote.setAlertDate(0, false);
|
|
|
|
|
} else if (itemId == R.id.menu_voice){
|
|
|
|
|
Log.d("voiceOut","in");
|
|
|
|
|
textToSpeach();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -1005,6 +1038,11 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
private boolean saveNote() {
|
|
|
|
|
getWorkingText();
|
|
|
|
|
boolean saved = mWorkingNote.saveNote();
|
|
|
|
|
//如果便签内容为空,则删除
|
|
|
|
|
if (TextUtils.isEmpty(mWorkingNote.getContent())) {
|
|
|
|
|
deleteCurrentNote();//删除当前便签
|
|
|
|
|
saved = false; // 标记为未保存
|
|
|
|
|
}
|
|
|
|
|
//运行 getWorkingText()之后保存
|
|
|
|
|
if (saved) {
|
|
|
|
|
/**
|
|
|
|
@ -1300,4 +1338,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @method textToSpeach
|
|
|
|
|
* @description: 朗读功能
|
|
|
|
|
* @date: 2024/1/16 20:21
|
|
|
|
|
* @author: WuShuxian
|
|
|
|
|
*/
|
|
|
|
|
private void textToSpeach(){
|
|
|
|
|
mTTS.speak(mNoteEditor.getText().toString(),TextToSpeech.QUEUE_FLUSH,null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|