|
|
@@ -20,7 +20,12 @@ import android.widget.Toast;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.andreabaccega.widget.FormEditText;
|
|
|
+import com.iflytek.cloud.speech.RecognizerResult;
|
|
|
+import com.iflytek.cloud.speech.SpeechError;
|
|
|
+import com.iflytek.cloud.ui.RecognizerDialogListener;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
+import com.xzjmyk.pm.activity.audio.voicerecognition.JsonParser;
|
|
|
+import com.xzjmyk.pm.activity.audio.voicerecognition.VoiceToWord;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.circle.SendShuoshuoActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
@@ -41,7 +46,7 @@ import java.util.Map;
|
|
|
/**
|
|
|
* Created by FANGlh on 2016/11/1.
|
|
|
*/
|
|
|
-public class WorkDailyAddActivity extends BaseActivity {
|
|
|
+public class WorkDailyAddActivity extends BaseActivity implements RecognizerDialogListener {
|
|
|
|
|
|
private static final int DAILY_SUBMITTED_SUCCESSFULLY = 1101; //提交请求成功后返回
|
|
|
private static final int CLEAR_AF_UPDATE_DOC_STATE = 1208;
|
|
|
@@ -174,6 +179,9 @@ public class WorkDailyAddActivity extends BaseActivity {
|
|
|
}
|
|
|
};
|
|
|
private String fromqzone;
|
|
|
+ private ImageView voice_summary;
|
|
|
+ private ImageView voice_plan;
|
|
|
+ private ImageView voice_experience;
|
|
|
|
|
|
|
|
|
public void doGrabJobContent(int mkeyValue) {
|
|
|
@@ -212,8 +220,57 @@ public class WorkDailyAddActivity extends BaseActivity {
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
initView();
|
|
|
+ doVoiceClickEvent();
|
|
|
}
|
|
|
+ String voicewords = new String();
|
|
|
+ private int voice_type = 0;
|
|
|
+ private void doVoiceClickEvent() {
|
|
|
+ final VoiceToWord voice = new VoiceToWord(WorkDailyAddActivity.this,"534e3fe2");
|
|
|
+ voice.setRecognizerDialogListener(this); //自己调用自己
|
|
|
+ voice_summary.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ voice_type = 1;
|
|
|
+ voice.GetWordFromVoice();
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
+ voice_plan.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ voice_type = 2;
|
|
|
+ voice.GetWordFromVoice();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ voice_experience.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ voice_type = 3;
|
|
|
+ voice.GetWordFromVoice();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onResult(RecognizerResult recognizerResult, boolean b) {
|
|
|
+ String text = JsonParser.parseIatResult(recognizerResult.getResultString());
|
|
|
+ System.out.println(text);
|
|
|
+ Toast.makeText(mContext, text, Toast.LENGTH_LONG).show();
|
|
|
+ voicewords = voicewords + text;
|
|
|
+
|
|
|
+ if (voice_type == 1){
|
|
|
+ add_summary.setText(voicewords);
|
|
|
+ }else if (voice_type == 2){
|
|
|
+ add_plan.setText(voicewords);
|
|
|
+ }else if (voice_type == 3){
|
|
|
+ add_experience.setText(voicewords);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(SpeechError speechError) {
|
|
|
+
|
|
|
+ }
|
|
|
@Override
|
|
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
|
|
menu.clear();
|
|
|
@@ -314,6 +371,9 @@ public class WorkDailyAddActivity extends BaseActivity {
|
|
|
summary_limit_tv = (TextView) findViewById(R.id.summary_limit_tv);
|
|
|
plan_limit_tv = (TextView) findViewById(R.id.plan_limit_tv);
|
|
|
experience_limit_tv = (TextView) findViewById(R.id.experience_limit_tv);
|
|
|
+ voice_summary = (ImageView) findViewById(R.id.voice_summary_iv);
|
|
|
+ voice_plan = (ImageView) findViewById(R.id.voice_plan_iv);
|
|
|
+ voice_experience = (ImageView) findViewById(R.id.voice_experience_iv);
|
|
|
|
|
|
// 对输入的三项内容进行动态监听限制字数,只提醒,不限制输入
|
|
|
add_summary.addTextChangedListener(new TextWatcher() {
|
|
|
@@ -442,6 +502,9 @@ public class WorkDailyAddActivity extends BaseActivity {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void showsubmitDialog() {
|
|
|
@@ -576,6 +639,7 @@ public class WorkDailyAddActivity extends BaseActivity {
|
|
|
|
|
|
private OnFinishOa onFinishOa;
|
|
|
|
|
|
+
|
|
|
interface OnFinishOa{
|
|
|
void onFinish();
|
|
|
}
|