diff --git a/01src/XiaoMiNotes/MyApplication/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java b/01src/XiaoMiNotes/MyApplication/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java index 96a9ff8..c67a1bc 100644 --- a/01src/XiaoMiNotes/MyApplication/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java +++ b/01src/XiaoMiNotes/MyApplication/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java @@ -28,6 +28,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Paint; +import android.media.MediaPlayer; import android.os.Bundle; import android.preference.PreferenceManager; import android.text.Spannable; @@ -51,6 +52,11 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; +import android.widget.Button; + +import android.speech.tts.TextToSpeech; +import android.speech.tts.UtteranceProgressListener; +import java.util.Locale; import net.micode.notes.R; import net.micode.notes.data.Notes; @@ -72,6 +78,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; + public class NoteEditActivity extends Activity implements OnClickListener, NoteSettingChangedListener, OnTextViewChangeListener { private class HeadViewHolder { @@ -148,12 +155,33 @@ public class NoteEditActivity extends Activity implements OnClickListener, private String mUserQuery; private Pattern mPattern; + private Button readButton; + + private TextToSpeech tts;//接口 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.note_edit); - + tts = new TextToSpeech(this, new TextToSpeech.OnInitListener() {//tts初始化 + @Override + public void onInit(int status) { + if(status == TextToSpeech.SUCCESS) {//设置中文 + int result = tts.setLanguage(Locale.CHINA); + if (result != TextToSpeech.LANG_COUNTRY_AVAILABLE && result != TextToSpeech.LANG_AVAILABLE) { + Toast.makeText(NoteEditActivity.this, "正在跳转", Toast.LENGTH_SHORT).show(); + } + tts.setSpeechRate(1.0f);//速度 + tts.setPitch(1.0f);//音调 + } + } + }); + readButton=findViewById(R.id.readnote);//按钮 + readButton.setOnClickListener(new View.OnClickListener() {//点击阅读 + @Override public void onClick(View view) { + ReadNow(); + } + }); if (savedInstanceState == null && !initActivityState(getIntent())) { finish(); return; @@ -161,6 +189,12 @@ public class NoteEditActivity extends Activity implements OnClickListener, initResources(); } + public void ReadNow(){ + ; + } + + + /** * Current activity may be killed when the memory is low. Once it is killed, for another time * user load this activity, we should restore the former state diff --git a/01src/XiaoMiNotes/MyApplication/app/src/main/res/layout/get_time.xml b/01src/XiaoMiNotes/MyApplication/app/src/main/res/layout/get_time.xml new file mode 100644 index 0000000..8e399f3 --- /dev/null +++ b/01src/XiaoMiNotes/MyApplication/app/src/main/res/layout/get_time.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file