public static void TextViewDialog(Context context, string path, string text = null) { var textView = new TextView(context); textView.SetPadding(10, 10, 10, 10); textView.SetTextSize(ComplexUnitType.Sp, 10f); var scrollView = new ScrollView(context); scrollView.AddView(textView); AlertDialog.Builder dialog = new AlertDialog.Builder(context); dialog.SetView(scrollView); if (text == null) { try { using (StreamReader sr = new StreamReader(path, Encoding.GetEncoding("euc-kr"))) { textView.Text = sr.ReadToEnd(); sr.Close(); } } catch { } } else { textView.Text = text; } dialog.SetPositiveButton("닫기", delegate { }); dialog.Show(); }
public override void ActionSheet(ActionSheetConfig config) { var dlg = new AlertDialog .Builder(this.GetTopActivity()) .SetCancelable(false) .SetTitle(config.Title); if (config.ItemIcon != null || config.Options.Any(x => x.ItemIcon != null)) { var adapter = new ActionSheetListAdapter(this.GetTopActivity(), Android.Resource.Layout.SelectDialogItem, Android.Resource.Id.Text1, config); dlg.SetAdapter(adapter, (s, a) => config.Options[a.Which].Action?.Invoke()); } else { var array = config .Options .Select(x => x.Text) .ToArray(); dlg.SetItems(array, (s, args) => config.Options[args.Which].Action?.Invoke()); } if (config.Destructive != null) dlg.SetNegativeButton(config.Destructive.Text, (s, a) => config.Destructive.Action?.Invoke()); if (config.Cancel != null) dlg.SetNeutralButton(config.Cancel.Text, (s, a) => config.Cancel.Action?.Invoke()); Utils.RequestMainThread(() => dlg.ShowExt()); }
private void MapOnInfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e) { Marker myMarker = e.Marker; ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context); ISharedPreferencesEditor editor = prefs.Edit(); KeyValuePair <Building, List <Workplace> > buildingInstance = CompositeMarkers[myMarker.Id]; TextView markerMenu = FindViewById <TextView>(Resource.Id.marker_menu); PopupMenu menu = new PopupMenu(this, markerMenu); foreach (Workplace workplace in buildingInstance.Value) { FindedWorkplace finded = findedWorkplaces.FirstOrDefault(x => x.WorkplaceId == workplace.Id); menu.Menu.Add("Workplace number:" + workplace.Id.ToString() + ",\nWorkplace cost: " + workplace.Cost.ToString() + ",\nAppropriation: " + finded.AppropriationPercentage.ToString() + ",\nCost approp: " + finded.CostColor + ", Address: " + buildingInstance.Key.Country + ", " + buildingInstance.Key.City + ", " + buildingInstance.Key.Street + ", " + buildingInstance.Key.House.ToString() + ", " + buildingInstance.Key.Flat.ToString()); } menu.MenuItemClick += (s1, arg1) => { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Workplace"); alert.SetMessage(arg1.Item.TitleFormatted.ToString()); alert.SetPositiveButton("Visit", async(senderAlert, arg) => { ISharedPreferences prefs1 = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context); ISharedPreferencesEditor editor1 = prefs1.Edit(); string workplId = arg1.Item.TitleFormatted.ToString().Split(':', ',')[1]; editor1.PutString("workplaceId", workplId); editor1.Apply(); var intent = new Intent(this, typeof(WorkplaceActivity)); StartActivity(intent); }); alert.SetNegativeButton("Cancel", (senderAlert, arg) => { Toast.MakeText(this, "Cancelled!", ToastLength.Short).Show(); }); Dialog dialog = alert.Create(); dialog.Show(); }; menu.DismissEvent += (s2, arg2) => { Console.WriteLine("menu dismissed"); }; menu.Show(); //editor.PutString("restaurant", Markers[myMarker.Id].ToString()); //editor.Apply(); //var intent = new Intent(this, typeof(RestaurantActivity)); //StartActivity(intent); }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { var loc = ServiceLocator.Current.GetInstance <ILocalizedStringProvider>(); var builder = new AlertDialog.Builder(Activity); builder.SetTitle(loc.GetLocalizedString(Localized.ChangeLanguage_Label)); builder.SetAdapter(new LanguageAdapter(Activity), this); return(builder.Create()); }
private void ShowDialog(string title, string messaage) { AlertDialog.Builder alertDiag = new AlertDialog.Builder(this); alertDiag.SetTitle(title); alertDiag.SetMessage(messaage); alertDiag.SetPositiveButton("Okay", (senderAlert, args) => { }); Dialog diag = alertDiag.Create(); diag.Show(); }
void MGV_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("提示"); builder.SetMessage("是否要删除这张照片"); builder.SetPositiveButton(Resource.String.str_cn_confrim, (ss, ee) => { mImageAdapter.mImageViewer.PathList.RemoveAt(e.Position); mImageAdapter.NotifyDataSetChanged(); }); builder.SetNegativeButton(Resource.String.str_cn_cancel, (ss, ee) => { }); builder.Create().Show(); }
private void ShowLogOutConfirmationDialog() { var dialog = new AlertDialog.Builder(this) .SetTitle("Logout") .SetMessage("Are you sure you want to Logout?") .SetCancelable(false) .SetPositiveButton("YES", OnLogOut) .SetNegativeButton("CANCEL", (sender, e) => { }) .Create(); dialog.Show(); }
private void ErrorMessage(string ex) { RunOnUiThread(() => { AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog alert = dialog.Create(); alert.SetTitle("Ошибка программы"); alert.SetMessage(ex); alert.Show(); return; }); }
private void DisplayException(Exception exception) { if (exception == null) { throw new ArgumentNullException(nameof(exception)); } AlertDialog.Builder builder = new AlertDialog.Builder(Context, Resource.Style.MyMaterialTheme); builder.SetTitle(Resource.String.ErrorTitle); builder.SetMessage(exception.Message); builder.SetPositiveButton(Android.Resource.String.Ok, (IDialogInterfaceOnClickListener)null); builder.Show(); }
private void OnTimedEvent(object sender, ElapsedEventArgs e) { RunOnUiThread(() => { AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog alert = dialog.Create(); alert.SetTitle("Вы давно не сохранялись"); alert.SetMessage("Возможно стоит нажать кнопку СОХРАНИТЬ? :)"); alert.Show(); return; }); }
public void OnReceiveMessage(string message) { System.Diagnostics.Debug.WriteLine($"{nameof(OnReceiveMessage)}"); var alert = new AlertDialog.Builder(this) .SetTitle("Message") .SetMessage(message) .SetPositiveButton("OK", (sender, args) => { }) .Create(); alert.Show(); }
private void ShowErrorMessage(string msg) { AlertDialog.Builder alert = new AlertDialog.Builder(this, Resource.Style.Dialog); alert.SetTitle(Resource.String.str_error).SetMessage(msg) .SetPositiveButton(Resource.String.btn_ok, (s, e) => { }); alert.Show(); if (adapter.ItemCount == 0) { userList.ShowLoading(EmptyView.StyleEmptyView.ONLY_TEXT, Resource.String.str_default_search); } }
private void AlertIncomplete(string message) { var alert = new AlertDialog.Builder(this); alert.SetTitle("Incorrect operation"); alert.SetMessage(message); alert.SetNeutralButton("OK", (senderAlert, args) => { alert.Dispose(); }); Dialog dialog = alert.Create(); dialog.Show(); }
private void ProfilePic_Click(object sender, EventArgs e) { //Open Dialog AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.SetTitle("Add Photo"); alertBuilder.SetItems(Resource.Array.upload_photo, this); AlertDialog alertDialog = alertBuilder.Create(); alertDialog.Show(); }
private void OnChangeFullName() { var view = LayoutInflater.Inflate(Resource.Layout.change_fullname_layout, null); // var dlg = new AlertDialog.Builder(this) .SetTitle("Change Name") .SetView(view) .Show(); InputHandler formHandler = new InputHandler(); formHandler.SetBindings(new InputBinding[] { new InputBinding("FirstName", Resource.Id.tb_firstname, true, InputTypes.Text), new InputBinding("LastName", Resource.Id.tb_lastname, true, InputTypes.Text) }, view as ViewGroup); formHandler.SetCustomError("FirstName", "required", "Please enter your first name"); formHandler.SetCustomError("LastName", "required", "Last name is required"); view.FindViewById <Button>(Resource.Id.btn_submit).Click += async delegate { if (formHandler.ValidateInputs(true).Count == 0) { var inputs = formHandler.GetInputs(); using (this.ShowProgress(null, "Applying changes...")) { var proxy = ProxyFactory.GetProxyInstace(); var response = await proxy.ExecuteAsync(API.Endpoints.AccountEndpoints.Update(new BookingSystem.API.Models.DTO.UpdateUserInfo() { FullName = $"{inputs["FirstName"]} {inputs["LastName"]}" })); if (response.Successful) { // Update current user info await proxy.UpdateUserInfoAsync(); // dlg.Dismiss(); Toast.MakeText(this, "Name changed successfully!", ToastLength.Long).Show(); } else { Toast.MakeText(this, response.GetErrorDescription(), ToastLength.Short).Show(); } } } }; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteAccount_Click(object sender, EventArgs e) { LayoutInflater inflater = LayoutInflater.From(this); View view = inflater.Inflate(Resource.Layout.dialog_delete_account, null); AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.SetView(view); var email = view.FindViewById <EditText>(Resource.Id.dialog_delete_email); var password = view.FindViewById <EditText>(Resource.Id.dialog_delete_password); alertBuilder.SetTitle("Delete Account") .SetPositiveButton("Submit", delegate { try { //update current user var user = auth.CurrentUser; if (user != null) { uid = user.Uid; //delete from auth var reauth = auth.CurrentUser.ReauthenticateAsync(EmailAuthProvider .GetCredential(email.Text, password.Text)).ContinueWith(task => { if (task.IsCompletedSuccessfully) { Task result = user.Delete().AddOnCompleteListener(this); Toast.MakeText(this, "Yeah!", ToastLength.Short).Show(); } else { Toast.MakeText(this, "Failed to reauthenticate account.", ToastLength.Short).Show(); } }); } } catch (Exception ex) { Toast.MakeText(this, "Sorry, an error occured during delete", ToastLength.Short).Show(); } }) .SetNegativeButton("No", delegate { alertBuilder.Dispose(); }); AlertDialog alertDialog = alertBuilder.Create(); alertDialog.Show(); }
/// <summary> /// ShowMessage /// </summary> /// <returns></returns> public async Task <string> ShowInputDialog(string title, string hint = null, string messageInput = null, // ReSharper disable once MethodOverloadWithOptionalParameter DialogInputType type = DialogInputType.None, bool isEmpty = false) { var tcs = new TaskCompletionSource <string>(); CrossCurrentActivity.Current.Activity.RunOnUiThread(() => { var builder = new AlertDialog.Builder(CrossCurrentActivity.Current.Activity); var input = new EditText(CrossCurrentActivity.Current.Activity); var lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); lp.SetMargins((int)ConvertScreenValue.ConvertDpToPixel(20, CrossCurrentActivity.Current.Activity), 0, (int)ConvertScreenValue.ConvertDpToPixel(20, CrossCurrentActivity.Current.Activity), 0); input.LayoutParameters = lp; input.SetMaxLines(1); input.SetSingleLine(true); input.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(25) }); input.Text = string.IsNullOrEmpty(messageInput) || isEmpty ? string.Empty : messageInput; input.Hint = string.IsNullOrEmpty(messageInput) && !string.IsNullOrEmpty(hint) ? hint : string.Empty; input.InputType = GetInputType(type); var view = new LinearLayout(CrossCurrentActivity.Current.Activity); var lpView = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); view.LayoutParameters = lpView; view.AddView(input); view.Touch += (sender, args) => KeyboardManager.HideKeyboard(CrossCurrentActivity.Current.Activity, view); view.Click += (sender, args) => KeyboardManager.HideKeyboard(CrossCurrentActivity.Current.Activity, view); var dlg = new Dialog(CrossCurrentActivity.Current.Activity); var dlg1 = dlg; builder.SetTitle(title) .SetView(view) .SetPositiveButton("OK", (s, args) => { KeyboardManager.HideKeyboard(CrossCurrentActivity.Current.Activity, view); tcs.TrySetResult(input.Text); dlg1.Dismiss(); }) .SetNegativeButton("Cancel", (s, args) => { KeyboardManager.HideKeyboard(CrossCurrentActivity.Current.Activity, view); tcs.TrySetResult(null); dlg1.Dismiss(); }); dlg = builder.Create(); dlg.Show(); }); return(await tcs.Task); }
private void ListViewClick(object sender, AdapterView.ItemClickEventArgs e) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle(friendsList[e.Position].Name); alert.SetMessage(friendsList[e.Position].Description); alert.SetPositiveButton("Ok", (senderAlert, args) => { }); RunOnUiThread(() => { alert.Show(); }); }
public void ShowAlertOK(String Message) { ThemedDialog.Builder alert = new ThemedDialog.Builder(_Context); alert.SetTitle("Menu Pick"); alert.SetMessage(Message); alert.SetPositiveButton("OK", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); }
private void DisplayMessage(string message) { var dialog = new AlertDialog.Builder(this, Resource.Style.AlertsDialogTheme) .SetMessage(message) .SetCancelable(true) .SetNegativeButton("OK", (sender, args) => { }) .Create(); dialog.Window.SetBackgroundDrawable(new ColorDrawable(Android.Graphics.Color.Transparent)); dialog.Window.SetElevation(16.0f); dialog.Show(); }
public void showAlert(string title, string text, string buttonLabel) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.SetTitle(title); alert.SetMessage(text); alert.SetPositiveButton(buttonLabel, (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); }
private void ArrowBackOnClick() { var alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder .SetMessage("Do you want to abort quiz?") .SetPositiveButton("Yes", (sender, args) => InitSummaryActivity()) .SetNegativeButton("No", (sender, args) => {}); var alertDialog = alertDialogBuilder.Create(); alertDialog.Show(); }
// Sets up the alert dialog private void ShowAlertDialog(String title, String message) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle(title); builder.SetMessage(message); builder.SetPositiveButton("OK", (sender, e) => { Intent logout = new Intent(this, typeof(MainActivity)); logout.SetFlags(ActivityFlags.ClearTask | ActivityFlags.NewTask); StartActivity(logout); }); builder.Create().Show(); }
/// <summary> /// Dialog for editing first and last name /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditName_Click(object sender, EventArgs e) { LayoutInflater inflater = LayoutInflater.From(this); View view = inflater.Inflate(Resource.Layout.dialog_profile_name, null); AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.SetView(view); var fName = view.FindViewById <EditText>(Resource.Id.dialog_edit_fname); var lName = view.FindViewById <EditText>(Resource.Id.dialog_edit_lname); //string[] fullName = name.Text.Split(" "); //fName.Text = fullName[0]; //lName.Text = fullName[1]; alertBuilder.SetTitle("Edit Name") .SetPositiveButton("Submit", delegate { try { //get current user if (auth.CurrentUser != null) { var document = db.Collection("users").Document(auth.CurrentUser.Uid); var data = new Dictionary <string, Java.Lang.Object>(); data.Add("FName", fName.Text); data.Add("LName", lName.Text); document.Update((IDictionary <string, Java.Lang.Object>)data); Toast.MakeText(this, "Done!", ToastLength.Long).Show(); } else { Toast.MakeText(this, "Something went wrong. Sorry.", ToastLength.Long).Show(); } } catch (Exception ex) { Toast.MakeText(this, "Failed to update. Sorry.", ToastLength.Long).Show(); } }) .SetNegativeButton("Cancel", delegate { alertBuilder.Dispose(); }); AlertDialog alertDialog = alertBuilder.Create(); alertDialog.Show(); }
private void ShowInactiveUserDialog(string cod) { RunOnUiThread(() => { var alert = new AlertDialog.Builder(this); alert.SetMessage( "Nu puteti utiliza aplicatia in momentul de fata pentru ca dispozitivul este asignat unui alt cont." + "Verificati setarile din Sistemul de Monitorizare Pacienti - id: " + cod); alert.SetPositiveButton("Ok", (senderAlert, args) => { Log.Error("LoginActivity", "Ok"); }); Dialog dialog = alert.Create(); dialog.Show(); }); }
public static void MensagemDeSenhaInvalida(Context contexto) { var alert = new AlertDialog.Builder(contexto); alert.SetTitle("Senha Invalida"); alert.SetMessage("A senha deve ser composta de no minímo 8 caracteres"); alert.SetPositiveButton("Ok", (senderAlert, args) => { Toast.MakeText(contexto, "Favor, inserir uma senha válida!", ToastLength.Short).Show(); }); Dialog dialog = alert.Create(); dialog.Show(); }
void Alerta(string title, string message) { alert.Builder adb = new alert.Builder(this); adb.SetTitle(title); adb.SetMessage(message); adb.SetNeutralButton("Aceptar", (senderAlert, args) => { }); alert dialog = adb.Create(); dialog.Show(); }
public static void MensagemDeDataInvalida(Context contexto) { var alert = new AlertDialog.Builder(contexto); alert.SetTitle("Data de Nascimento Invalida"); alert.SetMessage("A Data de Nascimento deve estar de acordo com o modelo: 30/06/2002"); alert.SetPositiveButton("Ok", (senderAlert, args) => { Toast.MakeText(contexto, "Favor, inserir uma data válida!", ToastLength.Short).Show(); }); Dialog dialog = alert.Create(); dialog.Show(); }
private async Task Init() { var cameraStatus = await Permissions.RequestAsync <Permissions.Camera>(); var micStatus = await Permissions.RequestAsync <Permissions.Microphone>(); _webRtcClient = new WebRtcClient(this, _remoteView, _localView, this); var dialogTcs = new TaskCompletionSource <string>(); var linearLayout = new LinearLayout(this); linearLayout.Orientation = Orientation.Vertical; linearLayout.SetPadding(48, 24, 48, 24); var ipAddr = new EditText(this) { Hint = "IP Address", Text = "192.168.1.119" }; var port = new EditText(this) { Hint = "Port", Text = "8080" }; linearLayout.AddView(ipAddr); linearLayout.AddView(port); var alert = new AlertDialog.Builder(this) .SetTitle("Socket Address") .SetView(linearLayout) .SetPositiveButton("OK", (sender, args) => { dialogTcs.TrySetResult($"ws://{ipAddr.Text}:{port.Text}"); }) .Create(); alert.Show(); var wsUrl = await dialogTcs.Task; var okHttpClient = new OkHttpClient.Builder() .ReadTimeout(0, Java.Util.Concurrent.TimeUnit.Milliseconds) .Build(); var request = new Request.Builder() .Url(wsUrl) .Build(); _socket = okHttpClient.NewWebSocket( request, new WebSocketObserver(ReadMessage)); }
/// <summary> /// ShowMessage /// </summary> /// <param name="message"></param> /// <param name="title"></param> /// <param name="firstButtonContent"></param> /// <returns></returns> public async Task <bool?> ShowMessage(string title, string message, string firstButtonContent) { var tcs = new TaskCompletionSource <bool?>(); var builder = new AlertDialog.Builder(CrossCurrentActivity.Current.Activity, Resource.Style.AppCompatAlertDialogStyle); builder.SetTitle(title) .SetMessage(message) .SetCancelable(false) .SetPositiveButton(firstButtonContent, (s, args) => { tcs.TrySetResult(true); }); builder.Create().Show(); return(await tcs.Task); }
public override void OnBackPressed() { var dialog = new AlertDialog.Builder(this); dialog.SetMessage("Are you sure?"); dialog.SetCancelable(true); dialog.SetPositiveButton("YES", (sender, args) => { FinishAffinity(); StartActivity(typeof(MainActivity)); }); dialog.SetNegativeButton("NO", (sender, args) => { }); dialog.Create().Show(); }
void OnAlertRequested(Page sender, AlertArguments arguments) { AlertDialog alert = new AlertDialog.Builder(this).Create(); alert.SetTitle(arguments.Title); alert.SetMessage(arguments.Message); if (arguments.Accept != null) { alert.SetButton((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult(true)); } alert.SetButton((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult(false)); alert.CancelEvent += (o, args) => { arguments.SetResult(false); }; alert.Show(); }
private void InitializeRecyclerView () { RecyclerView recyclerView = FindViewById<RecyclerView> (Resource.Id.HomeLayoutRecyclerView); TodoAdapter adapter = new TodoAdapter (Todos); recyclerView.SetAdapter (adapter); adapter.ItemClickEvent += (object sender, int position) => { var builder = new AlertDialog.Builder(this); builder.SetTitle(Todos[position].Name) .SetMessage(Todos[position].Description) .SetPositiveButton("Got it", delegate {}); builder.Create().Show(); }; recyclerView.SetLayoutManager (new LinearLayoutManager(this, LinearLayoutManager.Vertical, false)); }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.Home); InitializeToolbar (); Todos = TodoFactory.GetTodos (); InitializeRecyclerView (); FloatingActionButton fab = FindViewById<FloatingActionButton> (Resource.Id.fab); fab.Click += (object sender, EventArgs e) => { var builder = new AlertDialog.Builder(this); builder.SetTitle("Notification") .SetMessage("You clicked the Action Button!") .SetPositiveButton("OK", delegate {}); builder.Create().Show(); }; }
public override void ActionSheet(ActionSheetConfig config) { var array = config .Options .Select(x => x.Text) .ToArray(); var dlg = new AlertDialog .Builder(this.getTopActivity()) .SetCancelable(false) .SetTitle(config.Title); dlg.SetItems(array, (sender, args) => config.Options[args.Which].Action.TryExecute()); if (config.Destructive != null) dlg.SetNegativeButton(config.Destructive.Text, (sender, e) => config.Destructive.Action.TryExecute()); if (config.Cancel != null) dlg.SetNeutralButton(config.Cancel.Text, (sender, e) => config.Cancel.Action.TryExecute()); Utils.RequestMainThread(() => dlg.Show()); }
private void ReasonAlert() { AlertDialog.Builder builder = new AlertDialog.Builder(this, Resource.Style.AlertDialogStyle); View dialogView = LayoutInflater.Inflate(Resource.Layout.AlertItem, null); EditText redenedit = dialogView.FindViewById<EditText> (Resource.Id.EditAmount); redenedit.FocusChange += delegate { if(redenedit.HasFocus) redenedit.Text = ""; }; builder.SetTitle("Enter the occasion of your debt"); builder.SetPositiveButton("Confirm", (senderAlert, e) => { CreateDebts(redenedit.Text); }); builder.SetNeutralButton("Cancel", (senderAlert, e) => { //cancelt de dialog }); builder.SetView(dialogView); builder.SetCancelable(true); builder.Show (); }
private void Alert(string message) { AlertDialog.Builder builder = new AlertDialog.Builder(this, Resource.Style.AlertDialogStyle); builder.SetTitle("Error"); builder.SetMessage(message); builder.SetPositiveButton("OK", (senderAlert, e) => { }); builder.Show(); }
void downloadAppFileCompleted (object sender, AsyncCompletedEventArgs e) { RunOnUiThread (() => { progressDialog.Dismiss (); if (downloadedOK) { var installApk = new Intent(Intent.ActionView); installApk.SetDataAndType(Android.Net.Uri.Parse("file://" + fullLatestAppFilename), "application/vnd.android.package-archive"); installApk.SetFlags(ActivityFlags.NewTask); try { StartActivity(installApk); } catch (ActivityNotFoundException ex) { var errorInstalled = new AlertDialog.Builder (this).Create (); errorInstalled.SetTitle (Resources.GetString(Resource.String.download_error)); errorInstalled.SetMessage (string.Format(Resources.GetString(Resource.String.download_error_description), Resources.GetString(Resource.String.app_name) + " " + latestAppVersion)); errorInstalled.Show (); } downloadedOK = false; } else { File.Delete(fullLatestAppFilename); } }); }
private async Task Waitlist() { WorkshopController workshopController = new WorkshopController(); await workshopController.Waitlist(_Workshop.WorkshopId); //show dialog saying canceled var SuccesDialog = new AlertDialog.Builder(this); SuccesDialog.SetMessage("You have successfully been waitlisted!"); SuccesDialog.SetNeutralButton("OK", delegate { Finish(); }); SuccesDialog.Show(); }
/// <summary> /// Switches to the next lesson if available /// </summary> private void NextLesson() { var nextLesson = DataHolder.Current.CurrentModule.GetNextLesson(DataHolder.Current.CurrentLesson); if (nextLesson != null) { DataHolder.Current.CurrentLesson = nextLesson; DataHolder.Current.CurrentIteration = nextLesson.Iterations.First(); InitLesson(); } else { var builder = new AlertDialog.Builder(this); builder.SetTitle(Resource.String.module_finished); builder.SetMessage(Resource.String.module_finished_message); builder.SetCancelable(false); builder.SetPositiveButton(Android.Resource.String.Ok, (s, args) => Finish()); builder.Show(); } }
/// <summary> /// Handles the lesson fragment's lesson finished event /// </summary> /// <param name="sender">sender.</param> /// <param name="e">event args.</param> void LessonFragment_LessonFinished(object sender, EventArgs e) { //Toast.MakeText(this, "Lesson finished!", ToastLength.Short).Show(); var builder = new AlertDialog.Builder(this); builder.SetTitle(Resource.String.lesson_finished); builder.SetMessage(Resource.String.lesson_finished_message); builder.SetCancelable(false); builder.SetPositiveButton(Android.Resource.String.Ok, (s, args) => NextLesson()); builder.Show(); }
// Warns user that they will delete this booking and removes the booking if user presses okay private void CancelBooking() { AlertDialog.Builder cancelAlert = new AlertDialog.Builder(this); cancelAlert.SetTitle(GetString(Resource.String.cancelBooking)); cancelAlert.SetMessage(GetString(Resource.String.areYouSureCancel)); cancelAlert.SetPositiveButton("YES", delegate { if(_Booking.GetType() == typeof(SessionBooking)) { SessionController sessionController = new SessionController(); if (!sessionController.CancelSession(_Booking.ID())) { //show error, stay on page } else { //show dialog saying canceled var SuccesDialog = new AlertDialog.Builder(this); SuccesDialog.SetMessage("Booking has been Canceled!"); SuccesDialog.SetNeutralButton("OK", delegate { Finish(); }); SuccesDialog.Show(); if (bookingType.Equals("Session")) Server.sessionBookingsAltered = true; else Server.workshopBookingsAltered = true; } } else if (_Booking.GetType() == typeof(WorkshopBooking)) { // Code to cancel booking. WorkshopController workshopController = new WorkshopController(); if (!workshopController.CancelBooking(_Booking.ID())) { //show error, stay on page; } else { //show dialog saying cancled var SuccesDialog = new AlertDialog.Builder(this); SuccesDialog.SetMessage("Booking has been Canceled!"); SuccesDialog.SetNeutralButton("OK", delegate { Finish(); }); SuccesDialog.Show(); if (bookingType.Equals("Session")) Server.sessionBookingsAltered = true; else Server.workshopBookingsAltered = true; } } }); cancelAlert.SetNegativeButton("NO", delegate { }); cancelAlert.Show(); }
private void ShowDialog(ListItemAdapter adapter, int itemPosition, string dialogTitle, bool isPayment, bool isHistory) { AlertDialog.Builder builder = new AlertDialog.Builder(this.Activity, Resource.Style.AlertDialogStyle); var debtItem = adapter.Items[itemPosition]; builder.SetTitle(dialogTitle); View dialogView; if (isPayment) { dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.PaymentDialog, null); builder.SetView(dialogView); } else { if (isHistory) { dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.HistoryDialog, null); builder.SetView(dialogView); dialogView.FindViewById<TextView>(Resource.Id.dialogItemDate).Text = debtItem.StringValue; } else { dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.DebtDialog, null); builder.SetView(dialogView); } List<string> tempList = debtItem.FullDescription.Split('-').ToList(); tempList.RemoveAt(0); if (tempList.Count != 0) // check of er producten zijn toegevoegd { tempList.RemoveAt(tempList.Count - 1); } List<ListItem> productList = new List<ListItem>(); for (int i = 0; i < tempList.Count; i += 2) { productList.Add(new ListItem(tempList[i], double.Parse(tempList[i + 1]) / 100)); } ListItemAdapter dialogAdapter = new ListItemAdapter(ListItem.DialogItem, productList); RecyclerView dialogRecyclerView = dialogView.FindViewById<RecyclerView>(Resource.Id.dialogrecyclerview); dialogRecyclerView.SetLayoutManager(new LinearLayoutManager(this.Activity)); dialogRecyclerView.SetAdapter(dialogAdapter); dialogView.FindViewById<TextView>(Resource.Id.dialogItemDescription).Text = debtItem.Description; } dialogView.FindViewById<TextView>(Resource.Id.dialogItemName).Text = debtItem.Name; dialogView.FindViewById<TextView>(Resource.Id.dialogItemValue).Text = debtItem.Value.ToString("N"); dialogView.FindViewById<ImageView>(Resource.Id.dialogItemImage).SetImageResource(debtItem.ImageId); builder.SetCancelable(true); builder.Show(); }
private void FabWcd_Click(object sender, EventArgs e) { if (snackbar != null) { snackbar.Dismiss(); snackbar = null; } if (wcdListAdapter.Count == 0) { Refresh(); if (wcdListAdapter.Count == 0) Show("항목이 없습니다"); return; } List<int> positions = new List<int>(); try { SparseBooleanArray checkedList = listView.CheckedItemPositions; for (int i = 0; i < checkedList.Size(); i++) { if (checkedList.ValueAt(i)) { positions.Add(checkedList.KeyAt(i)); } } if (positions.Count == 0) lastPosition = 0; } catch { return; } View dialogView = LayoutInflater.From(Context).Inflate(Resource.Layout.weld_condition_editor, null); AlertDialog.Builder dialog = new AlertDialog.Builder(Context); dialog.SetView(dialogView); // 에디트텍스트 IList<EditText> etList = new List<EditText>(); etList.Add(dialogView.FindViewById<EditText>(Resource.Id.etOutputData)); etList.Add(dialogView.FindViewById<EditText>(Resource.Id.etOutputType)); etList.Add(dialogView.FindViewById<EditText>(Resource.Id.etSqueezeForce)); etList.Add(dialogView.FindViewById<EditText>(Resource.Id.etMoveTipClearance)); etList.Add(dialogView.FindViewById<EditText>(Resource.Id.etFixedTipClearance)); etList.Add(dialogView.FindViewById<EditText>(Resource.Id.etPannelThickness)); etList.Add(dialogView.FindViewById<EditText>(Resource.Id.etCommandOffset)); int[] etMax = { 2000, 100, 350, 500, 500, 500, 500, 1000, 1000 }; // 임계치 InputMethodManager imm = (InputMethodManager)Context.GetSystemService(Context.InputMethodService); for (int i = 0; i < etList.Count; i++) { EditText et = etList[i]; if (i == 0) // outputData et.Text = wcdListAdapter[lastPosition][i]; // 기본선택된 자료값 가져오기 int maxValue = etMax[i]; // 임계치 설정 et.FocusChange += (object sender1, View.FocusChangeEventArgs e1) => { int n; if (Int32.TryParse(et.Text, out n)) { if (n > maxValue) { n = maxValue; et.Text = n.ToString(); } } }; et.KeyPress += (object sender1, View.KeyEventArgs e1) => { // KeyEventArgs.Handled // 라우트된 이벤트를 처리된 것으로 표시하려면 true이고, // 라우트된 이벤트를 처리되지 않은 것으로 두어 이벤트가 추가로 라우트되도록 허용하려면 false입니다. // 기본값은 false입니다. e1.Handled = false; if (e1.KeyCode == Keycode.Enter || e1.KeyCode == Keycode.Back || e1.KeyCode == Keycode.Escape) { imm.HideSoftInputFromWindow(et.WindowToken, 0); et.ClearFocus(); e1.Handled = true; } }; } var statusText = dialogView.FindViewById<TextView>(Resource.Id.statusText); statusText.Text = wcdListAdapter[lastPosition][0]; if (positions.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (int pos in positions) { sb.Append(pos + 1); sb.Append(" "); } statusText.Text = "수정 항목: " + sb.ToString().TrimEnd(); } else { statusText.Text = "수정 항목: " + (lastPosition + 1).ToString(); } var sampleSeekBar = dialogView.FindViewById<SeekBar>(Resource.Id.sampleSeekBar); sampleSeekBar.Max = wcdListAdapter.Count - 1; sampleSeekBar.Progress = Convert.ToInt32(wcdListAdapter[lastPosition][0]) - 1; sampleSeekBar.ProgressChanged += (object sender1, SeekBar.ProgressChangedEventArgs e1) => { for (int i = 0; i < wcdListAdapter[sampleSeekBar.Progress].Count; i++) { if (etList[i].Text != "") etList[i].Text = wcdListAdapter[sampleSeekBar.Progress][i]; } if (positions.Count == 0) { lastPosition = sampleSeekBar.Progress; statusText.Text = "수정 항목: " + (lastPosition + 1).ToString(); } }; // 선택 시작 var beginSeekBar = dialogView.FindViewById<SeekBar>(Resource.Id.sbBegin); beginSeekBar.Max = wcdListAdapter.Count - 1; beginSeekBar.Progress = 0; // 선택 끝 var endSeekBar = dialogView.FindViewById<SeekBar>(Resource.Id.sbEnd); endSeekBar.Max = wcdListAdapter.Count - 1; endSeekBar.Progress = endSeekBar.Max; beginSeekBar.ProgressChanged += (object sender1, SeekBar.ProgressChangedEventArgs e1) => { if (e1.FromUser) { int sb1Progress = beginSeekBar.Progress; int sb2Progress = endSeekBar.Max - endSeekBar.Progress; if (sb1Progress > sb2Progress) { sb2Progress = sb1Progress; endSeekBar.Progress = endSeekBar.Max - sb1Progress; } if (sb1Progress == 0 && sb2Progress == 0 || sb1Progress == beginSeekBar.Max && sb2Progress == endSeekBar.Max) { if (positions.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (int pos in positions) { sb.Append(pos + 1); sb.Append(" "); } statusText.Text = "수정 항목: " + sb.ToString().TrimEnd(); } else { statusText.Text = "수정 항목: " + (lastPosition + 1).ToString(); } } else { statusText.Text = "수정 범위: " + string.Format("{0}", sb1Progress + 1) + " ~ " + string.Format("{0}", sb2Progress + 1); } } }; endSeekBar.ProgressChanged += (object sender2, SeekBar.ProgressChangedEventArgs e2) => { if (e2.FromUser) { int sb1Progress = beginSeekBar.Progress; int sb2Progress = endSeekBar.Max - endSeekBar.Progress; if (sb2Progress < sb1Progress) { sb1Progress = sb2Progress; beginSeekBar.Progress = sb2Progress; } if (sb1Progress == 0 && sb2Progress == 0 || sb1Progress == beginSeekBar.Max && sb2Progress == endSeekBar.Max) { if (positions.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (int pos in positions) { sb.Append(pos + 1); sb.Append(" "); } statusText.Text = "수정 항목: " + sb.ToString().TrimEnd(); } else { statusText.Text = "수정 항목: " + (lastPosition + 1).ToString(); } } else { statusText.Text = "수정 범위: " + string.Format("{0}", sb1Progress + 1) + " ~ " + string.Format("{0}", sb2Progress + 1); } } }; dialog.SetNegativeButton("취소", delegate { CheckListItem(false); }); dialog.SetPositiveButton("저장", async delegate { int seekBegin = beginSeekBar.Progress + 1; int seekEnd = endSeekBar.Max - endSeekBar.Progress + 1; bool isSeek = !((seekBegin == 1 && seekEnd == 1) || (seekBegin == beginSeekBar.Max + 1 && seekEnd == endSeekBar.Max + 1)); bool isUpdate = false; if (positions.Count == 0) positions.Add(lastPosition); if (isSeek) { positions.Clear(); for (int rowNum = seekBegin - 1; rowNum < seekEnd; rowNum++) { positions.Add(rowNum); } } foreach (int rowNum in positions) { for (int colNum = 1; colNum < wcdListAdapter[rowNum].Count; colNum++) { if (etList[colNum].Text != "") { wcdListAdapter[rowNum][colNum] = etList[colNum].Text; isUpdate = true; } } listView.SetItemChecked(rowNum, false); wcdListAdapter[rowNum].ItemChecked = false; } if (isUpdate) { wcdListAdapter.NotifyDataSetChanged(); await UpdateFileAsync(robotPath, wcdListAdapter); } else { CheckListItem(false); } try { if (wcdListAdapter.Count == 0) fabWcd.SetImageResource(Resource.Drawable.ic_refresh_white); else if (listView.CheckedItemCount == 0) fabWcd.SetImageResource(Resource.Drawable.ic_subject_white); else fabWcd.SetImageResource(Resource.Drawable.ic_edit_white); } catch { } }); dialog.Show(); }
private async Task Book() { // Code to book the workshop WorkshopController workshopController = new WorkshopController(); if (! await workshopController.Book(_Workshop.WorkshopId)) { //show error , stay on page; } else { //show dialog saying booked var SuccesDialog = new AlertDialog.Builder(this); SuccesDialog.SetMessage("You have successfully been booked!"); SuccesDialog.SetNeutralButton("OK", delegate { Finish(); }); SuccesDialog.Show(); } }
private void ShowFailedAlert(string msg) { var registerFailAlert = new SupportAlert.Builder(this); registerFailAlert.SetMessage(msg); registerFailAlert.SetNeutralButton("OK", delegate { }); registerFailAlert.Show(); }
private void ListView_Click(int position) { if (adapter.Count == 0) { Refresh(); if (adapter.Count == 0) Show("항목이 없습니다"); return; } var jobFile = adapter.GetItem(position); if (jobFile.JobCount.Total == 0) { Show("CN 항목이 없습니다"); return; } InputMethodManager imm = (InputMethodManager)Context.GetSystemService(Context.InputMethodService); View dialogView = LayoutInflater.From(Context).Inflate(Resource.Layout.weld_count_editor, null); AlertDialog.Builder dialog = new AlertDialog.Builder(Context); dialog.SetView(dialogView); var statusText = dialogView.FindViewById<TextView>(Resource.Id.statusText); statusText.Text = "계열 수정 (CN: " + jobFile.JobCount.Total.ToString() + "개)"; var linearLayout = dialogView.FindViewById<LinearLayout>(Resource.Id.linearLayout); var etBeginNumber = dialogView.FindViewById<EditText>(Resource.Id.etBeginNumber); var sbBeginNumber = dialogView.FindViewById<SeekBar>(Resource.Id.sampleSeekBar); var etList = new List<EditText>(); for (int i = 0; i < jobFile.Count; i++) { if (jobFile[i].RowType == Job.RowTypes.Spot) { var textInputLayout = new TextInputLayout(Context); var etCN = new EditText(Context); etCN.SetSingleLine(); etCN.SetTextSize(ComplexUnitType.Dip, 12); etCN.InputType = etBeginNumber.InputType; etCN.SetSelectAllOnFocus(true); etCN.Hint = "CN[" + jobFile[i].RowNumber + "]"; etCN.Text = jobFile[i].CN; etCN.Gravity = GravityFlags.Center; etCN.Tag = jobFile[i]; etCN.FocusChange += (object sender1, View.FocusChangeEventArgs e1) => { int beginNumber; if (Int32.TryParse(etCN.Text, out beginNumber)) { if (beginNumber > 255) { beginNumber = 255; etCN.Text = beginNumber.ToString(); } } }; etCN.KeyPress += (object sender1, View.KeyEventArgs e1) => { e1.Handled = false; if (e1.KeyCode == Keycode.Enter || e1.KeyCode == Keycode.Back || e1.KeyCode == Keycode.Escape) { imm.HideSoftInputFromWindow(etCN.WindowToken, 0); etCN.ClearFocus(); e1.Handled = true; } }; textInputLayout.AddView(etCN); linearLayout.AddView(textInputLayout); etList.Add(etCN); } } etBeginNumber.FocusChange += (object sender1, View.FocusChangeEventArgs e1) => { int beginNumber; if (int.TryParse(etBeginNumber.Text, out beginNumber)) { if (beginNumber > 255) { beginNumber = 255; etBeginNumber.Text = beginNumber.ToString(); } sbBeginNumber.Progress = beginNumber - 1; foreach (var et in etList) { et.Text = beginNumber++.ToString(); if (beginNumber > 255) beginNumber = 255; } } }; etBeginNumber.KeyPress += (object sender1, View.KeyEventArgs e1) => { e1.Handled = false; if (e1.KeyCode == Keycode.Enter || e1.KeyCode == Keycode.Back || e1.KeyCode == Keycode.Escape) { imm.HideSoftInputFromWindow(etBeginNumber.WindowToken, 0); etBeginNumber.ClearFocus(); e1.Handled = true; } }; sbBeginNumber.Max = 254; sbBeginNumber.Progress = 0; sbBeginNumber.ProgressChanged += (object sender1, SeekBar.ProgressChangedEventArgs e1) => { int beginNumber = sbBeginNumber.Progress + 1; etBeginNumber.Text = beginNumber.ToString(); }; sbBeginNumber.StopTrackingTouch += (object sender1, SeekBar.StopTrackingTouchEventArgs e1) => { int beginNumber = sbBeginNumber.Progress + 1; etBeginNumber.Text = beginNumber.ToString(); foreach (var et in etList) { et.Text = beginNumber++.ToString(); if (beginNumber > 255) beginNumber = 255; } }; dialog.SetNegativeButton("취소", delegate { }); dialog.SetPositiveButton("저장", delegate { foreach (var et in etList) { var job = (Job)et.Tag; job.CN = et.Text; } if (jobFile.JobCount.Total > 0) { jobFile.SaveFile(); adapter.NotifyDataSetChanged(); listView.RefreshDrawableState(); this.Show((string)("저장 완료: " + jobFile.JobCount.fi.Name)); } }); dialog.Show(); }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { var adb = new AlertDialog.Builder(Activity); adb.SetTitle(Title).SetMessage(Message).SetPositiveButton(Resource.String.ok, delegate{meListener.OnDialogPositiveClick();}); return adb.Create(); }
void OnItemClick(object sender, ListItemEventArgs args) { AlertDialog.Builder builder = new AlertDialog.Builder(this, Resource.Style.AlertDialogStyle); View dialogView = LayoutInflater.Inflate(Resource.Layout.NumberAlertItem, null); EditText Amount = dialogView.FindViewById<EditText> (Resource.Id.EditAmount); Amount.FocusChange += delegate { if(Amount.HasFocus) Amount.Text = ""; }; var tempItem = _adapter.Items[args.Position]; builder.SetTitle("Enter the amount of your payment"); builder.SetPositiveButton("Send", (senderAlert, e) => { Aflossen(tempItem.Name, System.Convert.ToDouble(Amount.Text)); }); builder.SetNeutralButton("Cancel", (senderAlert, e) => { // yay cancel }); builder.SetView(dialogView); builder.SetCancelable(true); builder.Show(); }
// Retrieve latest version of WhatsApp public async Task GetLatestWhatsAppVersion (string pageUrl) { var getVersion = new WebClient(); string htmlAndroid = getVersion.DownloadString (new Uri(pageUrl)); // Get WhatsApp latest version string[] split = htmlAndroid.Split (new char[] { '>' }); int i = 0; while (i < split.Length) { if (split.GetValue (i).ToString ().StartsWith ("Version")) { split = split.GetValue (i).ToString ().Split (new char[] { ' ', '<' }); latestWhatsAppVersion = split.GetValue (1).ToString ().Trim (); break; } i++; } // Display WhatsApp installed and latest version TextView whatsapp_installed_version = FindViewById<TextView> (Resource.Id.whatsapp_installed_version); TextView whatsapp_latest_version = FindViewById<TextView> (Resource.Id.whatsapp_latest_version); installedWhatsAppVersion = PackageManager.GetPackageInfo ("com.whatsapp", 0).VersionName.Trim (); whatsapp_installed_version.Text = installedWhatsAppVersion; whatsapp_latest_version.Text = latestWhatsAppVersion; fullLatestWhatsAppFilename = filename + "WhatsApp_" + latestWhatsAppVersion + ".apk"; // Load Floating Button var fab = FindViewById<FloatingActionButton> (Resource.Id.fab); // Compare installed and latest WhatsApp version if (CompareVersionReceiver.VersionCompare(installedWhatsAppVersion, latestWhatsAppVersion) < 0) { // There is a new version fab.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.ic_download)); // Preference: Autodownload if (prefAutoDownload) { SetDownloadDialog (); var webClient = new WebClient (); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler (downloadProgressChanged); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler (downloadWhatsAppFileCompleted); webClient.DownloadFileAsync (new Uri (whatsAppApk), fullLatestWhatsAppFilename); progressDialog.SetTitle (string.Format(Resources.GetString(Resource.String.downloading), "WhatsApp " + latestWhatsAppVersion + "...")); progressDialog.SetButton (Resources.GetString(Resource.String.cancel_button), (object senderCancel, DialogClickEventArgs eCancel) => {webClient.CancelAsync (); progressDialog.Dismiss ();}); progressDialog.Show (); } else { fab.Click += delegate { SetDownloadDialog (); var webClient = new WebClient (); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler (downloadProgressChanged); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler (downloadWhatsAppFileCompleted); webClient.DownloadFileAsync (new Uri (whatsAppApk), fullLatestWhatsAppFilename); progressDialog.SetTitle (string.Format(Resources.GetString(Resource.String.downloading), "WhatsApp " + latestWhatsAppVersion + "...")); progressDialog.SetButton (Resources.GetString(Resource.String.cancel_button), (object senderCancel, DialogClickEventArgs eCancel) => {webClient.CancelAsync (); progressDialog.Dismiss ();}); progressDialog.Show (); }; } // There is not a new version } else { fab.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.ic_menu_about)); fab.Click += delegate { AlertDialog errorInstalled = new AlertDialog.Builder (this).Create (); errorInstalled.SetTitle (Resources.GetString(Resource.String.latest_installed)); errorInstalled.SetMessage (string.Format(Resources.GetString(Resource.String.latest_installed_description), "WhatsApp " + installedWhatsAppVersion)); errorInstalled.SetButton ((int)DialogButtonType.Positive, Resources.GetString(Resource.String.ok), (object senderClose, DialogClickEventArgs eClose) => errorInstalled.Dismiss ()); errorInstalled.Show (); }; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); //RequestedOrientation = global::Android.Content.PM.ScreenOrientation.Landscape; // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); SignaturePadView signature = FindViewById<SignaturePadView> (Resource.Id.signatureView); if (true) { // Customization activated View root = FindViewById<View> (Resource.Id.rootView); // Activate this to internally use a bitmap to store the strokes // (good for frequent-redraw situations, bad for memory footprint) // signature.UseBitmapBuffer = true; signature.Caption.Text = "Authorization Signature"; signature.Caption.SetTypeface (Typeface.Serif, TypefaceStyle.BoldItalic); signature.Caption.SetTextSize (global::Android.Util.ComplexUnitType.Sp, 16f); signature.SignaturePrompt.Text = ">>"; signature.SignaturePrompt.SetTypeface (Typeface.SansSerif, TypefaceStyle.Normal); signature.SignaturePrompt.SetTextSize (global::Android.Util.ComplexUnitType.Sp, 32f); signature.BackgroundColor = Color.Rgb (255, 255, 200); // a light yellow. signature.StrokeColor = Color.Black; signature.BackgroundImageView.SetImageResource (Resource.Drawable.logo_galaxy_black_64); signature.BackgroundImageView.SetAlpha (16); signature.BackgroundImageView.SetAdjustViewBounds (true); var layout = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); layout.AddRule (LayoutRules.CenterInParent); layout.SetMargins (20, 20, 20, 20); signature.BackgroundImageView.LayoutParameters = layout; // You can change paddings for positioning... var caption = signature.Caption; caption.SetPadding (caption.PaddingLeft, 1, caption.PaddingRight, 25); } // Get our button from the layout resource, // and attach an event to it Button btnSave = FindViewById<Button> (Resource.Id.btnSave); btnSave.Click += delegate { if (signature.IsBlank) {//Display the base line for the user to sign on. AlertDialog.Builder alert = new AlertDialog.Builder (this); alert.SetMessage ("No signature to save."); alert.SetNeutralButton ("Okay", delegate { }); alert.Create ().Show (); } points = signature.Points; }; btnSave.Dispose (); Button btnLoad = FindViewById<Button> (Resource.Id.btnLoad); btnLoad.Click += delegate { if (points != null) signature.LoadPoints (points); }; btnLoad.Dispose (); }
// Retrieve latest version of Beta Updater public async Task GetLatestAppVersion (string pageUrl) { var getVersion = new WebClient(); string htmlAndroid = getVersion.DownloadString (new Uri(pageUrl)); // Get WhatsApp latest version string[] split = htmlAndroid.Split (new char[] { '>' }); int i = 0; while (i < split.Length) { if (split.GetValue (i).ToString ().StartsWith ("v")) { split = split.GetValue (i).ToString ().Split (new char[] { 'v', '<' }); latestAppVersion = split.GetValue (1).ToString ().Trim (); break; } i++; } installedAppVersion = PackageManager.GetPackageInfo ("com.javiersantos.whatsappbetaupdater", 0).VersionName.Trim (); if (CompareVersionReceiver.VersionCompare (installedAppVersion, latestAppVersion) < 0) { appApk = appApk + "v" + latestAppVersion + "/com.javiersantos.whatsappbetaupdater.apk"; AlertDialog appUpdateDialog = new AlertDialog.Builder (this).Create (); appUpdateDialog.SetTitle (string.Format(Resources.GetString(Resource.String.app_update), latestAppVersion)); appUpdateDialog.SetMessage (string.Format(Resources.GetString(Resource.String.app_update_description), Resources.GetString(Resource.String.app_name))); appUpdateDialog.SetButton ((int)DialogButtonType.Positive, Resources.GetString (Resource.String.update_button), (object senderUpdateAppOK, DialogClickEventArgs eUpdateAppOK) => { SetDownloadDialog (); var webClient = new WebClient (); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler (downloadProgressChanged); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler (downloadAppFileCompleted); webClient.DownloadFileAsync (new Uri (appApk), fullLatestAppFilename); progressDialog.SetTitle (string.Format(Resources.GetString(Resource.String.downloading), Resources.GetString(Resource.String.app_name) + " " + latestAppVersion + "...")); progressDialog.SetButton (Resources.GetString(Resource.String.cancel_button), (object senderCancel, DialogClickEventArgs eCancel) => {webClient.CancelAsync (); progressDialog.Dismiss ();}); progressDialog.Show (); }); appUpdateDialog.SetButton ((int)DialogButtonType.Negative, Resources.GetString(Resource.String.cancel_button), (object senderUpdateAppCancel, DialogClickEventArgs eUpdateAppCancel) => appUpdateDialog.Dismiss ()); appUpdateDialog.SetButton ((int)DialogButtonType.Neutral, Resources.GetString(Resource.String.never_button), (object senderUpdateAppNever, DialogClickEventArgs eUpdateAppNever) => {prefs.Edit().PutBoolean("prefShowAppUpdates", false).Commit(); appUpdateDialog.Dismiss (); }); appUpdateDialog.SetCancelable (false); appUpdateDialog.Show (); } }
private void ShowDialog(ListItemAdapter adapter, int itemPosition, string dialogTitle, bool isPendingDialog, bool isPayment, bool isHistory) { AlertDialog.Builder builder = new AlertDialog.Builder(this.Activity, Resource.Style.AlertDialogStyle); var debtItem = adapter.Items[itemPosition]; builder.SetTitle(dialogTitle); if (isPendingDialog) { builder.SetPositiveButton("Accept", (senderAlert, e) => { if (dialogTitle.ToLower().Contains("debt")) { DatabaseInterface.AcceptDebt(debtItem.Id, _persoon.Id, _persoon.Password); Toast.MakeText(this.Activity, "Debt accepted: " + debtItem.Description, ToastLength.Short).Show(); SwipeRefreshLayout.Refreshing = true; this.Refresh(); } else if (dialogTitle.ToLower().Contains("payment")) { string[] user = debtItem.Name.Split(' '); foreach(int debt in _persoon.KrijgPaymentsVanGebruiker(user[1])) DatabaseInterface.AcceptPayment(debt, _persoon.Id, _persoon.Password); Toast.MakeText(this.Activity, "Payment accepted from: " + debtItem.Name, ToastLength.Short).Show(); SwipeRefreshLayout.Refreshing = true; this.Refresh(); } CreateEnvironments(); }); builder.SetNegativeButton("Decline", (s, e) => { if (dialogTitle.ToLower().Contains("debt")) { DatabaseInterface.DeclineDebt(debtItem.Id, _persoon.Id, _persoon.Password); Toast.MakeText(this.Activity, "Debt declined: " + debtItem.Description, ToastLength.Short).Show(); Gegevens.GetServerData(_persoon.Id, _persoon.Password); ((Payscherm)this.Activity).Restart(); } else if (dialogTitle.ToLower().Contains("payment")) { string[] user = debtItem.Name.Split(' '); foreach(int debt in _persoon.KrijgPaymentsVanGebruiker(user[1])) DatabaseInterface.DeclinePayment(debt, _persoon.Id, _persoon.Password); Toast.MakeText(this.Activity, "Payment declined from: " + debtItem.Name, ToastLength.Short).Show(); Gegevens.GetServerData(_persoon.Id, _persoon.Password); ((Payscherm)this.Activity).Restart(); } CreateEnvironments(); }); builder.SetNeutralButton("Cancel", (s, e) => { // dialog cancelt automatisch }); } View dialogView; if (isPayment) { dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.PaymentDialog, null); builder.SetView(dialogView); } else { if (isHistory) { dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.HistoryDialog, null); builder.SetView(dialogView); dialogView.FindViewById<TextView>(Resource.Id.dialogItemDate).Text = debtItem.StringValue; } else { dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.DebtDialog, null); builder.SetView(dialogView); } List<string> tempList = debtItem.FullDescription.Split('-').ToList(); tempList.RemoveAt(0); if (tempList.Count != 0) // check of er producten zijn toegevoegd { tempList.RemoveAt(tempList.Count - 1); } // maak producten aan op basis van een stringlist List<ListItem> productList = new List<ListItem>(); for(int i = 0; i < tempList.Count; i += 2) { productList.Add(new ListItem(tempList[i], double.Parse(tempList[i+1]) / 100)); } ListItemAdapter dialogAdapter = new ListItemAdapter(ListItem.DialogItem, productList); RecyclerView dialogRecyclerView = dialogView.FindViewById<RecyclerView>(Resource.Id.dialogrecyclerview); dialogRecyclerView.SetLayoutManager(new LinearLayoutManager(this.Activity)); dialogRecyclerView.SetAdapter(dialogAdapter); dialogView.FindViewById<TextView>(Resource.Id.dialogItemDescription).Text = debtItem.Description; } dialogView.FindViewById<TextView>(Resource.Id.dialogItemName).Text = debtItem.Name; dialogView.FindViewById<TextView>(Resource.Id.dialogItemValue).Text = debtItem.Value.ToString("N"); dialogView.FindViewById<ImageView>(Resource.Id.dialogItemImage).SetImageResource(debtItem.ImageId); builder.SetCancelable(true); builder.Show(); }
void downloadWhatsAppFileCompleted (object sender, AsyncCompletedEventArgs e) { RunOnUiThread (() => { progressDialog.Dismiss (); if (downloadedOK) { var installApk = new Intent(Intent.ActionView); installApk.SetDataAndType(Android.Net.Uri.Parse("file://" + fullLatestWhatsAppFilename), "application/vnd.android.package-archive"); installApk.SetFlags(ActivityFlags.NewTask); try { StartActivity(installApk); AlertDialog deleteWhatsApp = new AlertDialog.Builder (this).Create (); deleteWhatsApp.SetTitle (Resources.GetString(Resource.String.delete)); deleteWhatsApp.SetMessage (Resources.GetString(Resource.String.delete_description)); deleteWhatsApp.SetButton ((int)DialogButtonType.Positive, Resources.GetString(Resource.String.delete_button_delete), (object senderDelete, DialogClickEventArgs eDelete) => File.Delete(fullLatestWhatsAppFilename)); deleteWhatsApp.SetButton ((int)DialogButtonType.Negative, Resources.GetString(Resource.String.delete_button_cancel), (object senderCancel, DialogClickEventArgs eCancel) => deleteWhatsApp.Dismiss ()); deleteWhatsApp.SetCancelable (false); deleteWhatsApp.Show (); } catch (ActivityNotFoundException ex) { var errorInstalled = new AlertDialog.Builder (this).Create (); errorInstalled.SetTitle (Resources.GetString(Resource.String.download_error)); errorInstalled.SetMessage (string.Format(Resources.GetString(Resource.String.download_error_description), "WhatsApp " + latestWhatsAppVersion)); errorInstalled.Show (); } downloadedOK = false; } else { File.Delete(fullLatestWhatsAppFilename); } }); }
public override void Prompt(PromptConfig config) { Utils.RequestMainThread(() => { var activity = this.getTopActivity(); var txt = new EditText(activity) { Hint = config.Placeholder }; if (config.Text != null) txt.Text = config.Text; this.SetInputType(txt, config.InputType); var builder = new AlertDialog .Builder(activity) .SetCancelable(false) .SetMessage(config.Message) .SetTitle(config.Title) .SetView(txt) .SetPositiveButton(config.OkText, (o, e) => config.OnResult(new PromptResult { Ok = true, Text = txt.Text }) ); if (config.IsCancellable) { builder.SetNegativeButton(config.CancelText, (o, e) => config.OnResult(new PromptResult { Ok = false, Text = txt.Text }) ); } var dialog = builder.Create(); dialog.Window.SetSoftInputMode(SoftInput.StateVisible); dialog.Show(); }); }
public override void Login(LoginConfig config) { var context = this.getTopActivity(); var txtUser = new EditText(context) { Hint = config.LoginPlaceholder, InputType = InputTypes.TextVariationVisiblePassword, Text = config.LoginValue ?? String.Empty }; var txtPass = new EditText(context) { Hint = config.PasswordPlaceholder ?? "*" }; this.SetInputType(txtPass, InputType.Password); var layout = new LinearLayout(context) { Orientation = Orientation.Vertical }; txtUser.SetMaxLines(1); txtPass.SetMaxLines(1); layout.AddView(txtUser, ViewGroup.LayoutParams.MatchParent); layout.AddView(txtPass, ViewGroup.LayoutParams.MatchParent); Utils.RequestMainThread(() => { var dialog = new AlertDialog .Builder(this.getTopActivity()) .SetCancelable(false) .SetTitle(config.Title) .SetMessage(config.Message) .SetView(layout) .SetPositiveButton(config.OkText, (o, e) => config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, true)) ) .SetNegativeButton(config.CancelText, (o, e) => config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, false)) ) .Create(); dialog.Window.SetSoftInputMode(SoftInput.StateVisible); dialog.Show(); }); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.Inflate(Resource.Layout.weld_count_fragment, container, false); var refresher = view.FindViewById<SwipeRefreshLayout>(Resource.Id.srl); if (refresher != null) { refresher.Refresh += delegate { Refresh(forced: true); refresher.Refreshing = false; }; } listView = view.FindViewById<ListView>(Resource.Id.listView); listView.Adapter = adapter; listView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { var builder = new AlertDialog.Builder(Context); builder.SetItems(Resource.Array.select_dialog_items, (object sender1, DialogClickEventArgs e1) => { var items = Resources.GetStringArray(Resource.Array.select_dialog_items); var item = items[(int)e1.Which]; if (e1.Which == 0) { ListView_Click(e.Position); } else if (e1.Which == 1) { Pref.TextViewDialog(Context, null, adapter.GetItem(e.Position).RowText()); } }); builder.Create().Show(); }; listView.ItemLongClick += (object sender, AdapterView.ItemLongClickEventArgs e) => { ListView_Click(e.Position); }; return view; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.Inflate(Resource.Layout.file_list_fragment, container, false); var refresher = view.FindViewById<SwipeRefreshLayout>(Resource.Id.srl); if (refresher != null) { refresher.Refresh += delegate { RefreshFilesList(DirPath); refresher.Refreshing = false; }; } listView = view.FindViewById<ListView>(Resource.Id.listView); listView.Adapter = adapter; listView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { var fileSystemInfo = adapter.GetItem(e.Position); if (e.Position == 0) { RefreshFilesList(Path.GetDirectoryName(fileSystemInfo.FullName)); } else if (fileSystemInfo.IsDirectory()) { RefreshFilesList(fileSystemInfo.FullName); } else { Pref.TextViewDialog(Context, fileSystemInfo.FullName); } }; listView.ItemLongClick += (object sender, AdapterView.ItemLongClickEventArgs e) => { if (e.Position == 0) return; var fileSystemInfo = adapter.GetItem(e.Position); var actionName = fileSystemInfo.IsDirectory() ? "폴더 삭제" : "파일 삭제"; var fileType = fileSystemInfo.IsDirectory() ? "이 폴더를 " : "이 파일을 "; var msg = fileType + "완전히 삭제 하시겠습니까?\n\n" + fileSystemInfo.Name + "\n\n수정한 날짜: " + fileSystemInfo.LastWriteTime.ToString(); var builder = new AlertDialog.Builder(Context); builder.SetTitle(actionName) .SetMessage(msg) .SetNegativeButton("취소", delegate { RefreshFilesList(DirPath); Show("삭제가 취소 되었습니다"); }) .SetPositiveButton("삭제", delegate { try { Directory.Delete(fileSystemInfo.FullName, true); RefreshFilesList(DirPath); } catch { Show("삭제할 수 없습니다"); } }); builder.Create().Show(); }; return view; }