具体维护了模板标签

main
XinqiQin 2 months ago
parent c8f69ba232
commit b15d17c232

@ -75,7 +75,7 @@ public class IatDemo extends Activity implements OnClickListener {
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.iatdemo);
SpeechUtility.createUtility(this, "appid=" + getString(R.string.appid));
SpeechUtility.createUtility(this, "appid=" + getString(R.string.appid));//qxq:初始化
languageEntries = getResources().getStringArray(R.array.iat_language_entries);
languageValues = getResources().getStringArray(R.array.iat_language_value);
initLayout();

@ -73,6 +73,11 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Locale;
import androidx.annotation.RequiresApi;
@ -840,6 +845,50 @@ public class NoteEditActivity extends Activity implements OnClickListener,
protected void onResume() {//当Activity恢复到前台时调用。主要负责初始化笔记界面。
super.onResume();
initNoteScreen();
initEditText();//初始化便签模板
//initImage();//初始化图片,这里应当实现为converttoimage在initNoteScreen中
}
private void initEditText() {
InputStream in = null;
//根据传入值的不同类型,加载不同的文字到便签中
switch (getIntent().getIntExtra("open_mode", 0)) {
case 1://创建事件便签
in = getResources().openRawResource(R.raw.event);
break;
case 2://创建联系人便签
in = getResources().openRawResource(R.raw.contact);
break;
case 3://创建账号便签
in = getResources().openRawResource(R.raw.passwd);
break;
default://创建普通便签
break;
}
//下面一段代码基本是仿照setAppInfoFromRawRes方法从资源里添加文本
if (in == null) return;
Editable edit = mNoteEditor.getText();
StringBuilder sb = new StringBuilder();//代表一个字符序列可变的字符串,线程不安全,但性能较高
try (InputStreamReader isr = new InputStreamReader(in); BufferedReader br = new BufferedReader(isr);) {
//使用指定的字符集读取字节并将它们解码为字符
//缓冲区流读入
char[] buf = new char[1024];
int len = 0;
while ((len = br.read(buf)) > 0) {//read读取一个字符若读取到末尾则返回-1这里是加载到buf中
sb.append(buf, 0, len);//从buf里0开始的len长度的字符串加载到sb后
}
} catch (IOException e) {
e.printStackTrace();
}
edit.append(sb.toString());
mNoteEditor.setText(edit);
if (in != null) {
try {
in.close();
} catch (IOException e) {
Log.e(TAG, "initEditText " + e.toString());
}
}
}
/**

@ -693,18 +693,6 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
builder.show();
}
/**
*
*
*/
private void createNewNote() {
// 构造意图并指定动作为插入或编辑以及初始文件夹ID
Intent intent = new Intent(this, NoteEditActivity.class);//this-当前activity的上下文,NoteEditActivity.class-要启动的activity的类
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);//设置意图的动作
intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mCurrentFolderId);//传递参数
// 启动该意图并期待返回结果
this.startActivityForResult(intent, REQUEST_CODE_NEW_NODE);
}
/**
@ -848,13 +836,47 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
// 根据视图ID执行相应的操作
switch (v.getId()) {
case R.id.btn_new_note:
createNewNote();
//createNewNote();
showNoteType();
break;
default:
break;
}
}
/**
*
*
*/
private void createNewNote(int openMode) {
// 构造意图并指定动作为插入或编辑以及初始文件夹ID
Intent intent = new Intent(this, NoteEditActivity.class);//this-当前activity的上下文,NoteEditActivity.class-要启动的activity的类
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);//设置意图的动作
intent.putExtra("open_mode", openMode);//打开不同模板
intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mCurrentFolderId);//传递参数
// 启动该意图并期待返回结果
this.startActivityForResult(intent, REQUEST_CODE_NEW_NODE);
}
AlertDialog alertDialog1;
public void showNoteType(){//mine 12
final String[] items = {"普通便签", "事件便签", "联系人便签", "密码便签"};
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
alertBuilder.setTitle("选择创建的便签");
alertBuilder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//对createNewNote方法进行了调用
// 参数i即使代表所选单选按钮的排列次序也代表打开便签模板的类型
createNewNote(i);
Toast.makeText(NotesListActivity.this, items[i], Toast.LENGTH_SHORT).show();
alertDialog1.dismiss();
}
});
alertDialog1 = alertBuilder.create();
alertDialog1.show();
}
/**
*
@ -1211,7 +1233,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
break;
}
case R.id.menu_new_note: {
createNewNote(); // 创建新笔记
//createNewNote(); //qxq:创建新笔记
//showNoteType();
createNewNote(0);
break;
}
case R.id.menu_search: {//qxq:为什么这里源代码没有加入{}

@ -27,6 +27,7 @@ import com.iflytek.cloud.IdentityVerifier;
import com.iflytek.cloud.InitListener;
import com.iflytek.cloud.SpeechConstant;
import com.iflytek.cloud.SpeechError;
import com.iflytek.cloud.SpeechUtility;
//import com.iflytek.speech.util.FaceUtil;
import net.micode.notes.ui.speech.util.FaceUtil;
//import com.iflytek.voicedemo.IdentifyGroup.GroupManagerActivity;
@ -77,6 +78,9 @@ public class OnlineFaceDemo extends Activity implements View.OnClickListener {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.online_facedemo);
SpeechUtility.createUtility(this, "appid=" + getString(R.string.appid));//qxq:初始化
findViewById(R.id.online_pick).setOnClickListener(OnlineFaceDemo.this);
findViewById(R.id.online_reg).setOnClickListener(OnlineFaceDemo.this);
findViewById(R.id.online_verify).setOnClickListener(OnlineFaceDemo.this);

Loading…
Cancel
Save