protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.activity_search); List <note> allNotes = TableAccess.GetAllNotes(); foreach (note n in allNotes) { data.Add(n); } var edtSearch = FindViewById <EditText>(Resource.Id.edtSearch); var lstSearch = FindViewById <ListView>(Resource.Id.lstSearch); adapter = new ArrayAdapter(this, Resource.Layout.listItem, Resource.Id.textView1, data); lstSearch.Adapter = adapter; lstSearch.ItemClick += LstSearch_ItemClick; edtSearch.AddTextChangedListener(this); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); RequestPermissions(); TableAccess.Create(TableAccess.path); if (!Directory.Exists(pathFolder)) { Directory.CreateDirectory(pathFolder); } btnStart = FindViewById <Button>(Resource.Id.btnPlay); btnStop = FindViewById <Button>(Resource.Id.btnStop); btnRecord = FindViewById <Button>(Resource.Id.btnRecord); btnStopRecord = FindViewById <Button>(Resource.Id.btnStopRecord); btnSaveNote = FindViewById <Button>(Resource.Id.btnSaveNote); btnSearch = FindViewById <Button>(Resource.Id.btnSearch); notesListView = FindViewById <ListView>(Resource.Id.notesListView); notesList = TableAccess.GetAllNotes(); foreach (note n in notesList.ToArray()) { if (n.ParentId != -1) { notesList.Remove(n); } } adapter = new NotesListAdapter(this, notesList); notesListView.Adapter = adapter; notesListView.ItemClick += NotesListView_ItemClick; RegisterForContextMenu(notesListView); btnStop.Enabled = false; btnStart.Enabled = false; btnStopRecord.Enabled = false; btnSaveNote.Enabled = false; btnRecord.Click += delegate { RecordAudio(); }; btnStopRecord.Click += delegate { StopRecorder(); }; btnStart.Click += delegate { StartLastRecord(); }; btnStop.Click += delegate { StopLastRecord(); }; btnSaveNote.Click += delegate { SaveNote(); }; btnSearch.Click += delegate { Search(); }; }
private void SaveNote() { string title = string.Empty; List <string> titles = TableAccess.GetAllTitles(); Android.App.AlertDialog.Builder adb = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog ad; EditText et = new EditText(this); et.SetSingleLine(); adb.SetTitle("Save Note"); adb.SetMessage("Type a title and hit enter:"); adb.SetView(et); adb.SetPositiveButton("Save", (senderAlert, args) => { try { System.IO.File.Copy(fileTemp, pathFolder + "/" + title + ".3gp"); TableAccess.AddNewNote(title); notesList.Add(TableAccess.GetNoteFromTitle(title)); } catch (Exception ex) { Toast.MakeText(this, "Could not save file: " + ex, ToastLength.Short).Show(); } adb.Dispose(); }); adb.SetNegativeButton("Cancel", (senderAlert, args) => { adb.Dispose(); }); ad = adb.Show(); ad.GetButton(-1).Enabled = false; et.KeyPress += (object sender, View.KeyEventArgs e) => { if ((e.KeyCode == Keycode.Enter)) { title = StripIllegalChars(et.Text); if (string.IsNullOrEmpty(title)) { Toast.MakeText(this, "Please enter a valid name", ToastLength.Short).Show(); ad.GetButton(-1).Enabled = false; } else if (titles.Contains(title)) { Toast.MakeText(this, "Name already exists, please choose another.", ToastLength.Short).Show(); ad.GetButton(-1).Enabled = false; } else { ad.GetButton(-1).Enabled = true; } } else { ad.GetButton(-1).Enabled = false; } }; }
public override bool OnContextItemSelected(IMenuItem item) { var info = (AdapterView.AdapterContextMenuInfo)item.MenuInfo; var index = item.ItemId; var menuItems = Resources.GetStringArray(Resource.Array.menu); var menuItemName = menuItems[index]; var noteTitle = notesList[info.Position].Title; if (menuItemName.Equals("Rename")) { string newTitle = noteTitle; List <string> titles = TableAccess.GetAllTitles(); Android.App.AlertDialog.Builder adb = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog ad; EditText et = new EditText(this); et.SetSingleLine(); et.Text = noteTitle; adb.SetTitle("Rename Note"); adb.SetMessage("Type a title and hit enter:"); adb.SetView(et); adb.SetPositiveButton("Rename", (senderAlert, args) => { try { notesList.RemoveAt(info.Position); TableAccess.EditName(noteTitle, newTitle); notesList.Add(TableAccess.GetNoteFromTitle(newTitle)); } catch (Exception ex) { Toast.MakeText(this, "Could not save file: " + ex, ToastLength.Short).Show(); } adb.Dispose(); }); adb.SetNegativeButton("Cancel", (senderAlert, args) => { adb.Dispose(); }); ad = adb.Show(); ad.GetButton(-1).Enabled = false; et.KeyPress += (object sender, View.KeyEventArgs e) => { if ((e.KeyCode == Keycode.Enter)) { newTitle = StripIllegalChars(et.Text); if (string.IsNullOrEmpty(newTitle)) { Toast.MakeText(this, "Please enter a valid name", ToastLength.Short).Show(); ad.GetButton(-1).Enabled = false; } else if (titles.Contains(newTitle)) { Toast.MakeText(this, "Name already exists, please choose another.", ToastLength.Short).Show(); ad.GetButton(-1).Enabled = false; } else { ad.GetButton(-1).Enabled = true; } } else { ad.GetButton(-1).Enabled = false; } }; return(true); } else if (menuItemName.Equals("Delete")) { Android.App.AlertDialog.Builder adb = new Android.App.AlertDialog.Builder(this); Android.App.AlertDialog ad; adb.SetTitle("Delete Note"); adb.SetMessage("Are you sure you want to delete this note and all of its replies?"); adb.SetPositiveButton("Delete", (senderAlert, args) => { try { notesList.RemoveAt(info.Position); TableAccess.DeleteRecursive(noteTitle); adapter = new NotesListAdapter(this, notesList); notesListView.Adapter = adapter; } catch (Exception ex) { Toast.MakeText(this, "Could not delete note: " + ex, ToastLength.Short).Show(); } adb.Dispose(); }); adb.SetNegativeButton("Cancel", (senderAlert, args) => { adb.Dispose(); }); ad = adb.Show(); return(true); } ; return(false); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.node_activity); isGrantedPermission = true; fileTemp = pathFolder + "/" + "$temp.3gp"; btnPlayParent = FindViewById <Button>(Resource.Id.btnPlayParent); btnStopParent = FindViewById <Button>(Resource.Id.btnStopParent); btnRecord = FindViewById <Button>(Resource.Id.btnRecord); btnStopRecord = FindViewById <Button>(Resource.Id.btnStopRecord); btnSaveNote = FindViewById <Button>(Resource.Id.btnSaveNote); notesListView = FindViewById <ListView>(Resource.Id.notesListView); btnStopChild = FindViewById <Button>(Resource.Id.btnStopChild); btnPlayChild = FindViewById <Button>(Resource.Id.btnPlayChild); textViewHeader = FindViewById <TextView>(Resource.Id.textViewHeader); parentExtra = Intent.GetStringArrayListExtra("Title and ID"); parentTitle = parentExtra[0]; parentId = Int32.Parse(parentExtra[1]); parentFile = pathFolder + "/" + parentTitle + ".3gp"; textViewHeader.Text = parentTitle; notesList = TableAccess.GetAllNotes(); foreach (note n in notesList.ToArray()) { if (n.ParentId != parentId) { notesList.Remove(n); } } adapter = new NotesListAdapter(this, notesList); notesListView.Adapter = adapter; notesListView.ItemClick += NotesListView_ItemClick; RegisterForContextMenu(notesListView); btnStopChild.Enabled = false; btnPlayChild.Enabled = false; btnStopRecord.Enabled = false; btnSaveNote.Enabled = false; btnRecord.Click += delegate { RecordAudio(); }; btnStopRecord.Click += delegate { StopRecorder(); }; btnPlayChild.Click += delegate { StartLastRecord(); }; btnStopChild.Click += delegate { StopLastRecord(); }; btnSaveNote.Click += delegate { SaveNote(); }; btnPlayParent.Click += delegate { StartParentRecord(); }; }