protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.play); //彈出視窗解說: AlertDialog.Builder alert_play = new AlertDialog.Builder(this); // For initial tips dialog if (counter == 0) { alert_play.SetTitle("注意事項"); alert_play.SetMessage("1. 請確認影片畫質是否正常且人臉完全包覆於合理範圍中,若不符合請\u201C返回操作\u201C重新測謊.\n" + "2. 確認無誤後,即可\u201C上傳檔案\u201C進行測謊分析.\n" + "3. 點選\u201C查看結果\u201C觀看測謊結果!!!"); alert_play.SetIcon(Android.Resource.Drawable.IcDialogInfo); alert_play.SetPositiveButton(" ok", new EventHandler <DialogClickEventArgs>((sender, e) => { })); alert_play.Show(); counter++; } // 跑馬燈 TextView play_tv = FindViewById <TextView>(Resource.Id.playtextview); play_tv.Selected = true; FindViewById <Button>(Resource.Id.btn_back).Click += Back_Click; //FindViewById<Button>(Resource.Id.btn_upload).Click += Back_Upload; FindViewById <Button>(Resource.Id.btn_play).Click += Back_Play; FindViewById <Button>(Resource.Id.btn_result).Click += Back_Result; }
public static AlertDialog CreateConnectDialog(EditText participantEditText, EventHandler <DialogClickEventArgs> callParticipantsClickListener, EventHandler <DialogClickEventArgs> cancelClickListener, Context context) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); alertDialogBuilder.SetIcon(Resource.Drawable.ic_call_black_24dp); alertDialogBuilder.SetTitle("Connect to a room"); alertDialogBuilder.SetPositiveButton("Connect", callParticipantsClickListener); alertDialogBuilder.SetNegativeButton("Cancel", cancelClickListener); alertDialogBuilder.SetCancelable(false); SetRoomNameFieldInDialog(participantEditText, alertDialogBuilder, context); return(alertDialogBuilder.Create()); }
// 繪製提示方框的 SurfaceHolderCallBack 3個function實作結束 //-------------------------------------------------------------- // 錄製影像函式定義 /* * void Rec_Click(object sender, EventArgs e) * { * Button btn = sender as Button; * timerViewer = FindViewById<TextView>(Resource.Id.counter); * if (!isRecing) * { * btn.Text = "測謊中"; * btn.Clickable = false; * Camera.StopPreview(); * Camera.Unlock(); * _MediaRecorder.SetCamera(Camera); * _MediaRecorder.SetMaxDuration(6000); * _MediaRecorder.SetVideoSource(VideoSource.Default); * _MediaRecorder.SetAudioSource(AudioSource.Mic); * _MediaRecorder.SetProfile( * CamcorderProfile.Get(CamcorderQuality.High)); * * _MediaRecorder.SetOutputFile(rec_video_uri); * * _MediaRecorder.SetPreviewDisplay(_Holder.Surface); * _MediaRecorder.SetOrientationHint * (_SurfaceHolderCallBack.RotataDegrees); * _MediaRecorder.Prepare(); * _MediaRecorder.Start(); * RunUpdateLoop(btn, e); * * } * else * { * btn.Clickable = true; * btn.Text = "開始測謊"; * _MediaRecorder.Stop(); * Camera.Reconnect(); * Camera.StartPreview(); * timerViewer.Text = "Recording Time: 0.0 s"; * } * isRecing = !isRecing; * } */ // For Testing three video recording: void Rec_Click(object sender, EventArgs e) { Button btn = sender as Button; timerViewer = FindViewById <TextView>(Resource.Id.counter); AlertDialog.Builder alert_rec = new AlertDialog.Builder(this); alert_rec.SetTitle("Recording Video_1"); alert_rec.SetMessage("第一題請要求受測者誠實回答問題,按下OK開始錄製影像."); alert_rec.SetIcon(Android.Resource.Drawable.IcDialogInfo); alert_rec.SetNegativeButton(" ok", new EventHandler <DialogClickEventArgs>((sender2, e2) => { if (!isRecing) { btn.Text = "測謊中"; btn.Clickable = false; Camera.StopPreview(); Camera.Unlock(); _MediaRecorder.SetCamera(Camera); _MediaRecorder.SetMaxDuration(6000); _MediaRecorder.SetVideoSource(VideoSource.Default); _MediaRecorder.SetAudioSource(AudioSource.Mic); _MediaRecorder.SetProfile( CamcorderProfile.Get(CamcorderQuality.High)); _MediaRecorder.SetOutputFile(rec_video_uri_1); _MediaRecorder.SetPreviewDisplay(_Holder.Surface); _MediaRecorder.SetOrientationHint (_SurfaceHolderCallBack.RotataDegrees); _MediaRecorder.Prepare(); _MediaRecorder.Start(); RunUpdateLoop_first(btn, e); } else { btn.Clickable = true; btn.Text = "開始測謊"; _MediaRecorder.Stop(); Camera.Reconnect(); Camera.StartPreview(); timerViewer.Text = "Recording Time: 0.0 s"; } isRecing = !isRecing; })); alert_rec.Show(); }
// End private async void RunUpdateLoop_End(object sender, EventArgs e) { Button btn = sender as Button; Double count = 0.0; while (count <= 6.1) { if (count <= 6) { await Task.Delay(100); count = count + 0.1; timerViewer.Text = string.Format("Recording Time: {0,2:0.0} s", count); } else { btn.Clickable = true; btn.Text = "開始測謊"; _MediaRecorder.Stop(); Camera.Reconnect(); Camera.StartPreview(); timerViewer.Text = "Recording Time: 0.0 s"; isRecing = !isRecing; AlertDialog.Builder alert_upload = new AlertDialog.Builder(this); alert_upload.SetTitle("Uploading Files"); alert_upload.SetMessage("按下OK上傳三個測謊檔並分析!!"); alert_upload.SetIcon(Android.Resource.Drawable.IcDialogInfo); alert_upload.SetNegativeButton(" ok", new EventHandler <DialogClickEventArgs>((sender2, e2) => { // Show uploading progress: progressDialog = new ProgressDialog(this); progressDialog.SetMessage("上傳中,請稍等..."); progressDialog.Show(); // Call uploading function new UploadFileAsync().Execute(""); })); alert_upload.Show(); return; } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); // 防止發生預期錯誤用: StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.SetVmPolicy(builder.Build()); // 顯示最上方的app名稱 //Android.Support.V7.Widget.Toolbar toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); //SetSupportActionBar(toolbar); FindViewById <Button>(Resource.Id.btn_rec).Click += Rec_Click; FindViewById <Button>(Resource.Id.btn_view).Click += View_Click; // 跑馬燈 TextView tv = FindViewById <TextView>(Resource.Id.mytv); tv.Selected = true; // 設定使用說明的按鈕 AlertDialog.Builder alert_tips = new AlertDialog.Builder(this); // For Button_Tips AlertDialog.Builder alert_initial = new AlertDialog.Builder(this); // For initial tips dialog if (show_time == 0) { alert_initial.SetTitle("使用順序"); alert_initial.SetMessage("1. 測謊規則 -> 開始測謊 -> 查看影像.\n2. 請詳細閱讀\u201C測謊規則\u201C.\n3. 閱讀完畢後,即可\u201C開始測謊\u201C.\n4. \u201C查看影像\u201C可預覽影像,方便確認影像品質!"); alert_initial.SetIcon(Android.Resource.Drawable.IcDialogInfo); alert_initial.SetPositiveButton(" ok", new EventHandler <DialogClickEventArgs>((sender, e) => { })); alert_initial.Show(); show_time++; } FindViewById <Button>(Resource.Id.btn_tips).Click += (sender, e) => { alert_tips.SetTitle("測謊說明"); alert_tips.SetMessage("1. 確保受測者臉部完全包覆於黃色提示框內.\n" + "2. 請確保問題可讓受測者於6秒內回答完畢,敘述問題完畢後,即可按下**開始測謊**錄製影像,6秒後將自動停止錄影.\n" + "3. 錄製完畢後,按下**查看影像**預覽影像品質.\n" + "4. 請確認影片品質並檢查Wi-Fi功能是否開啟,無誤即可按下**上傳檔案**,等待數秒後即獲得測謊結果.\n" + "5. 最後,由衷的邀請您按下**填寫回饋單**,給予我們寶貴的建議,謝謝體驗!!!"); alert_tips.SetIcon(Android.Resource.Drawable.IcDialogInfo); alert_tips.Show(); }; alert_tips.SetPositiveButton(" ok", new EventHandler <DialogClickEventArgs>((sender, e) => { })); // 相機與錄製功能設定 _MediaRecorder = new MediaRecorder(); Camera = Camera.Open(); surfaceView = FindViewById <SurfaceView>(Resource.Id.surfaceView); _Holder = surfaceView.Holder; _SurfaceHolderCallBack = new SurfaceHolderCallBack(this, Camera, _MediaRecorder); _Holder.AddCallback(_SurfaceHolderCallBack); _Holder.SetType(SurfaceType.PushBuffers); // For rectangle on surfaceview sv_rec = FindViewById <SurfaceView>(Resource.Id.surface_rec); holder = sv_rec.Holder; sv_rec.Holder.SetFormat(Android.Graphics.Format.Transparent); holder.SetFormat(Android.Graphics.Format.Transparent); sv_rec.SetZOrderMediaOverlay(true); sv_rec.SetZOrderOnTop(true); holder.AddCallback(this); } // End of OnCreate()
// Second private async void RunUpdateLoop_second(object sender, EventArgs e) { Button btn = sender as Button; Double count = 0.0; while (count <= 6.1) { if (count <= 6) { await Task.Delay(100); count = count + 0.1; timerViewer.Text = string.Format("Recording Time: {0,2:0.0} s", count); } else { btn.Clickable = true; btn.Text = "開始測謊"; _MediaRecorder.Stop(); Camera.Reconnect(); Camera.StartPreview(); timerViewer.Text = "Recording Time: 0.0 s"; isRecing = !isRecing; AlertDialog.Builder alert_rec = new AlertDialog.Builder(this); alert_rec.SetTitle("Recording Video_3"); alert_rec.SetMessage("第3題請詢問想測謊的問題,按下OK開始錄製影像."); alert_rec.SetIcon(Android.Resource.Drawable.IcDialogInfo); alert_rec.SetNegativeButton(" ok", new EventHandler <DialogClickEventArgs>((sender2, e2) => { if (!isRecing) { btn.Text = "測謊中"; btn.Clickable = false; Camera.StopPreview(); Camera.Unlock(); _MediaRecorder.SetCamera(Camera); _MediaRecorder.SetMaxDuration(6000); _MediaRecorder.SetVideoSource(VideoSource.Default); _MediaRecorder.SetAudioSource(AudioSource.Mic); _MediaRecorder.SetProfile( CamcorderProfile.Get(CamcorderQuality.High)); _MediaRecorder.SetOutputFile(rec_video_uri_3); _MediaRecorder.SetPreviewDisplay(_Holder.Surface); _MediaRecorder.SetOrientationHint (_SurfaceHolderCallBack.RotataDegrees); _MediaRecorder.Prepare(); _MediaRecorder.Start(); RunUpdateLoop_End(btn, e); } else { btn.Clickable = true; btn.Text = "開始測謊"; _MediaRecorder.Stop(); Camera.Reconnect(); Camera.StartPreview(); timerViewer.Text = "Recording Time: 0.0 s"; } isRecing = !isRecing; })); alert_rec.Show(); return; } } }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { alert = new AlertDialog.Builder(Activity, Resource.Style.HelpDialogTheme); alert.SetTitle(Resources.GetString(Resource.String.hint_message)); alert.SetIcon(Resource.Drawable.hiphop_transparent); sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(Activity); sharedPreferencesEditor = sharedPreferences.Edit(); switch (Type) { case HelpWindows.AutomaticAudioHelp: message = Resources.GetString(Resource.String.auto_audio_message); // once the user clicks on any dialog option, onboarding is considered finised, and thus the onboaring values are set to false alert.SetPositiveButton(Resources.GetString(Resource.String.keep_feature_on), (senderAlert, args) => { sharedPreferencesEditor.PutBoolean(Resources.GetString(Resource.String.pref_auto_start_audio_key_onboarding), false); sharedPreferencesEditor.PutBoolean(Resources.GetString(Resource.String.pref_auto_start_audio_key), true); sharedPreferencesEditor.Commit(); OnCloseDialogAction(); Toast.MakeText(Activity, Resources.GetString(Resource.String.choice_keep_audio), ToastLength.Short).Show(); Activity.FragmentManager.BeginTransaction().Hide(this).Commit(); }); alert.SetNegativeButton(Resources.GetString(Resource.String.disregard_feature), (senderAlert, args) => { sharedPreferencesEditor.PutBoolean(Resources.GetString(Resource.String.pref_auto_start_audio_key_onboarding), false); sharedPreferencesEditor.PutBoolean(Resources.GetString(Resource.String.pref_auto_start_audio_key), false); sharedPreferencesEditor.Commit(); OnCloseDialogAction(); Toast.MakeText(Activity, Resources.GetString(Resource.String.choice_disregard_audio), ToastLength.Short).Show(); }); break; case HelpWindows.AutomaticSwitchHelp: message = Resources.GetString(Resource.String.auto_switch_message); alert.SetPositiveButton(Resources.GetString(Resource.String.keep_feature_on), (senderAlert, args) => { sharedPreferencesEditor.PutBoolean(Resources.GetString(Resource.String.pref_auto_switch_page_key_onboarding), false); sharedPreferencesEditor.PutBoolean(Resources.GetString(Resource.String.pref_auto_page_switch_key), true); sharedPreferencesEditor.Commit(); OnCloseDialogAction(); Toast.MakeText(Activity, Resources.GetString(Resource.String.choice_keep_switch_pages), ToastLength.Short).Show(); }); alert.SetNegativeButton(Resources.GetString(Resource.String.disregard_feature), (senderAlert, args) => { sharedPreferencesEditor.PutBoolean(Resources.GetString(Resource.String.pref_auto_switch_page_key_onboarding), false); sharedPreferencesEditor.PutBoolean(Resources.GetString(Resource.String.pref_auto_page_switch_key), false); sharedPreferencesEditor.Commit(); OnCloseDialogAction(); Toast.MakeText(Activity, Resources.GetString(Resource.String.choice_disregard_switch_pages), ToastLength.Short).Show(); }); break; default: break; } alert.SetMessage(message); return(alert.Create()); }