protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.activity_events); base.debugTextView = (EditText)FindViewById (Resource.Id.debug_output_field_events); selectEventButton = (Button)FindViewById (Resource.Id.select_event_button); sendEventButton = (Button)FindViewById (Resource.Id.send_event_button); EventHandler<DialogClickEventArgs> handler = (s, o) => { // save off selected event selectEventButton.Text = items [o.Which]; lastSelectedEvent = items [o.Which]; sendEventButton.Enabled = true; }; selectEventButton.Click += (sender, e) => { AlertDialog.Builder builder = new AlertDialog.Builder (this); builder.SetTitle ("Select Event"); builder.SetItems (items, handler); builder.Show(); }; // set up click listener for when event is sent sendEventButton.Click += (sender, e) => { tapjoyEvent = new TJEvent(this, lastSelectedEvent, null, eventCallback); tapjoyEvent.EnableAutoPresent(true); tapjoyEvent.Send(); }; }
public Task<ModifyOperation> ShowEditSelectionDialog() { tcs = new TaskCompletionSource<ModifyOperation>(); var builder = new AlertDialog.Builder(Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity); builder.SetTitle(Strings.ChooseLabel); builder.SetItems(itemsForEditList.ToArray(), OnSelectItemForCreation); builder.SetNegativeButton(Strings.CancelLabel, (d, t) => (d as Dialog).Dismiss()); builder.Show(); return tcs.Task; }
protected override Dialog CreateDialog(Context context) { var setting = Cell as SelectionSetting; var builder = new AlertDialog.Builder(context); builder.SetTitle(setting.Title); var options = setting.Options; builder.SetItems(options.Values.ToArray<string>(), new SelectionApplier { Values = options.Keys.ToList<string>(), Setting = setting }); return builder.Create(); }
public static void ShowListPopup(Context context, int titleId, int itemArray, Action<int> callback) { var themeId = Settings.DarkTheme ? Resource.Style.AlertThemeDark : Resource.Style.AlertThemeLight; var builder = new AlertDialog.Builder(new ContextThemeWrapper(context, themeId)); builder.SetTitle(titleId); builder.SetIcon(Resource.Drawable.ic_launcher); builder.SetItems(itemArray, (sender, args) => callback(args.Which)); builder.SetCancelable(true); builder.SetNegativeButton(Resource.String.cancel, delegate { }); var alertDialog = builder.Create(); alertDialog.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()); }
protected override void OnElementChanged(ElementChangedEventArgs<Page> e) { base.OnElementChanged(e); var page = e.NewElement as MainPage; if (page != null) { MessagingCenter.Subscribe(page, "KillActionSheet", (MainPage sender) => { if (actionSheet != null) actionSheet.Dismiss(); }); MessagingCenter.Subscribe(page, "DisplayCustomAndroidActionSheet", (MainPage sender, CustomAndroidActionSheetArguments args) => { var builder = new AlertDialog.Builder (Forms.Context); builder.SetTitle(args.Title); var items = args.Buttons.ToArray(); builder.SetItems(items, (sender2, args2) => args.Result.TrySetResult(items[args2.Which])); if (args.Cancel != null) builder.SetPositiveButton(args.Cancel, delegate { args.Result.TrySetResult(args.Cancel); }); if (args.Destruction != null) builder.SetNegativeButton(args.Destruction, delegate { args.Result.TrySetResult(args.Destruction); }); actionSheet = builder.Create(); builder.Dispose(); actionSheet.SetCanceledOnTouchOutside(true); actionSheet.CancelEvent += (sender3, ee) => args.SetResult(null); actionSheet.Show(); }); } }
public override bool OnOptionsItemSelected (IMenuItem item) { //Show a list of theme choices to pick from var adBuilder = new AlertDialog.Builder (this); adBuilder.SetTitle ("Change Theme"); var themeNames = FlatUI.FlatUI.GetThemeNames (); adBuilder.SetItems (themeNames, (sender, e) => { var newThemeName = themeNames[e.Which]; var newTheme = FlatUI.FlatUI.GetTheme(newThemeName); ChangeTheme(newTheme); }); adBuilder.Create ().Show (); return true; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // grab our resource file View view = inflater.Inflate(Resource.Layout.Springboard, container, false); // let the springboard elements setup their buttons foreach( SpringboardElement element in Elements ) { element.OnCreateView( view ); element.Button.SetOnTouchListener( this ); } view.SetOnTouchListener( this ); view.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_BackgroundColor ) ); // set the task we wish to have active ActivateElement( Elements[ ActiveElementIndex ] ); // setup our profile pic button, which displays either their profile picture or an icon if they're not logged in / don't have a pic ProfileImageButton = view.FindViewById<Button>( Resource.Id.springboard_profile_image ); ProfileImageButton.Click += (object sender, EventArgs e) => { // if we're logged in, manage their profile pic if( RockMobileUser.Instance.LoggedIn == true ) { ManageProfilePic( ); } else { // otherwise, use it to let them log in StartModalFragment( LoginFragment ); } }; Typeface fontFace = Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( PrivateControlStylingConfig.Icon_Font_Primary ); ProfileImageButton.SetTypeface( fontFace, TypefaceStyle.Normal ); ProfileImageButton.SetTextSize( Android.Util.ComplexUnitType.Dip, PrivateSpringboardConfig.ProfileSymbolFontSize ); ProfileImageButton.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ) ); ProfileImageButton.LayoutParameters.Width = (int)Rock.Mobile.Graphics.Util.UnitToPx( 140 ); ProfileImageButton.LayoutParameters.Height = (int)Rock.Mobile.Graphics.Util.UnitToPx( 140 ); ProfileImageButton.SetBackgroundColor( Color.Transparent ); // create and add a simple circle to border the image RelativeLayout layout = view.FindViewById<RelativeLayout>( Resource.Id.springboard_profile_image_layout ); layout.SetBackgroundColor( Color.Transparent ); CircleView circle = new Rock.Mobile.PlatformSpecific.Android.Graphics.CircleView( Activity.BaseContext ); //note: these are converted from dp to pixels, so don't do it here. circle.StrokeWidth = 4; circle.Color = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ); circle.SetBackgroundColor( Color.Transparent ); circle.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent ); ( (RelativeLayout.LayoutParams)circle.LayoutParameters ).AddRule( LayoutRules.CenterInParent ); circle.LayoutParameters.Width = (int)Rock.Mobile.Graphics.Util.UnitToPx( 150 ); circle.LayoutParameters.Height = (int)Rock.Mobile.Graphics.Util.UnitToPx( 150 ); layout.AddView( circle ); // setup our login button LoginProfileButton = view.FindViewById<Button>( Resource.Id.springboard_login_button ); LoginProfileButton.Click += (object sender, EventArgs e) => { // if we're logged in, it'll be the profile one if( RockMobileUser.Instance.LoggedIn == true ) { StartModalFragment( ProfileFragment ); } else { // else it'll be the login one StartModalFragment( LoginFragment ); } }; // setup the textView for rendering either "Tap to Personalize" or "View Profile" ViewProfileLabel = view.FindViewById<TextView>( Resource.Id.view_profile ); ViewProfileLabel.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ) ); ViewProfileLabel.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Light ), TypefaceStyle.Normal ); ViewProfileLabel.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize ); // get the size of the display. We will use this rather than Resources.DeviceManager because this // is absolute and won't change based on orientation Point displaySize = new Point( ); Activity.WindowManager.DefaultDisplay.GetSize( displaySize ); float displayWidth = displaySize.X; float revealPercent = MainActivity.IsLandscapeWide( ) ? PrivatePrimaryNavBarConfig.Landscape_RevealPercentage_Android : PrivatePrimaryNavBarConfig.Portrait_RevealPercentage_Android; // setup the width of the springboard area and campus selector ProfileContainer = view.FindViewById<LinearLayout>( Resource.Id.springboard_profile_image_container ); ProfileContainer.LayoutParameters.Width = (int) ( displayWidth * revealPercent ); // setup the textView for rendering the user's name when they're logged in "Welcome: Jered" ProfilePrefix = view.FindViewById<TextView>( Resource.Id.profile_prefix ); ProfilePrefix.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Light ), TypefaceStyle.Normal ); ProfilePrefix.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Large_FontSize ); ProfilePrefix.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ) ); ProfilePrefix.Text = SpringboardStrings.LoggedIn_Prefix; ProfilePrefix.Measure( 0, 0 ); ProfileName = view.FindViewById<TextView>( Resource.Id.profile_name ); ProfileName.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ) ); ProfileName.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Bold ), TypefaceStyle.Normal ); ProfileName.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Large_FontSize ); ProfileName.SetMaxLines( 1 ); ProfileName.Ellipsize = Android.Text.TextUtils.TruncateAt.End; CampusContainer = view.FindViewById<View>( Resource.Id.campus_container ); CampusContainer.LayoutParameters.Width = (int) ( displayWidth * revealPercent ); CampusContainer.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_BackgroundColor ) ); View seperator = view.FindViewById<View>( Resource.Id.end_seperator ); seperator.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color ) ); // setup the bottom campus / settings selector CampusText = CampusContainer.FindViewById<TextView>( Resource.Id.campus_selection_text ); CampusText.Ellipsize = Android.Text.TextUtils.TruncateAt.End; CampusText.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ) ); CampusText.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Regular ), TypefaceStyle.Normal ); CampusText.SetTextSize(Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize ); CampusText.SetSingleLine( ); TextView settingsIcon = CampusContainer.FindViewById<TextView>( Resource.Id.campus_selection_icon ); settingsIcon.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( PrivateControlStylingConfig.Icon_Font_Primary ), TypefaceStyle.Normal ); settingsIcon.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ) ); settingsIcon.SetTextSize( Android.Util.ComplexUnitType.Dip, PrivateSpringboardConfig.CampusSelectSymbolSize ); settingsIcon.Text = PrivateSpringboardConfig.CampusSelectSymbol; // set the campus text to whatever their profile has set for viewing. CampusText.Text = string.Format( SpringboardStrings.Viewing_Campus, RockGeneralData.Instance.Data.CampusIdToName( RockMobileUser.Instance.ViewingCampus ) ).ToUpper( ); // setup the campus selection button. Button campusSelectionButton = CampusContainer.FindViewById<Button>( Resource.Id.campus_selection_button ); campusSelectionButton.Click += (object sender, EventArgs e ) => { // build an alert dialog containing all the campus choices AlertDialog.Builder builder = new AlertDialog.Builder( Activity ); Java.Lang.ICharSequence [] campusStrings = new Java.Lang.ICharSequence[ RockGeneralData.Instance.Data.Campuses.Count ]; for( int i = 0; i < RockGeneralData.Instance.Data.Campuses.Count; i++ ) { campusStrings[ i ] = new Java.Lang.String( App.Shared.Network.RockGeneralData.Instance.Data.Campuses[ i ].Name ); } // launch the dialog, and on selection, update the viewing campus text. builder.SetItems( campusStrings, delegate(object s, DialogClickEventArgs clickArgs) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { // get the ID for the campus they selected string campusTitle = campusStrings[ clickArgs.Which ].ToString( ); RockMobileUser.Instance.ViewingCampus = RockGeneralData.Instance.Data.CampusNameToId( campusTitle ); // build a label showing what they picked RefreshCampusSelection( ); }); }); builder.Show( ); }; Billboard = new NotificationBillboard( displayWidth, Rock.Mobile.PlatformSpecific.Android.Core.Context ); Billboard.SetLabel( SpringboardStrings.TakeNotesNotificationIcon, PrivateControlStylingConfig.Icon_Font_Primary, ControlStylingConfig.Small_FontSize, SpringboardStrings.TakeNotesNotificationLabel, ControlStylingConfig.Font_Light, ControlStylingConfig.Small_FontSize, ControlStylingConfig.TextField_ActiveTextColor, ControlStylingConfig.Springboard_Element_SelectedColor, delegate { // find the Notes task, activate it, and tell it to jump to the read page. foreach( SpringboardElement element in Elements ) { if ( element.Task as Droid.Tasks.Notes.NotesTask != null ) { ActivateElement( element ); PerformTaskAction( PrivateGeneralConfig.TaskAction_NotesRead ); } } } ); Billboard.Hide( ); return view; }
void InternalSetPage(Page page) { if (!Forms.IsInitialized) throw new InvalidOperationException("Call Forms.Init (Activity, Bundle) before this"); if (_canvas != null) { _canvas.SetPage(page); return; } var busyCount = 0; MessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) => { busyCount = Math.Max(0, enabled ? busyCount + 1 : busyCount - 1); if (!Forms.SupportsProgress) return; SetProgressBarIndeterminate(true); UpdateProgressBarVisibility(busyCount > 0); }); UpdateProgressBarVisibility(busyCount > 0); MessagingCenter.Subscribe(this, Page.AlertSignalName, (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(); }); MessagingCenter.Subscribe(this, Page.ActionSheetSignalName, (Page sender, ActionSheetArguments arguments) => { var builder = new AlertDialog.Builder(this); builder.SetTitle(arguments.Title); string[] items = arguments.Buttons.ToArray(); builder.SetItems(items, (sender2, args) => { arguments.Result.TrySetResult(items[args.Which]); }); if (arguments.Cancel != null) builder.SetPositiveButton(arguments.Cancel, delegate { arguments.Result.TrySetResult(arguments.Cancel); }); if (arguments.Destruction != null) builder.SetNegativeButton(arguments.Destruction, delegate { arguments.Result.TrySetResult(arguments.Destruction); }); AlertDialog dialog = builder.Create(); builder.Dispose(); //to match current functionality of renderer we set cancelable on outside //and return null dialog.SetCanceledOnTouchOutside(true); dialog.CancelEvent += (sender3, e) => { arguments.SetResult(null); }; dialog.Show(); }); _canvas = new Platform(this); if (_application != null) _application.Platform = _canvas; _canvas.SetPage(page); _layout.AddView(_canvas.GetViewGroup()); }
void SpinnerAnsprechpartner_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Up) { if (_stateFragment._ansprechpartnern.Count > 0) { // If there are Ansprechpartner, just show as default AlertDialog.Builder builder = new AlertDialog.Builder(_activity); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(_activity.Resources.GetString(Resource.String.SelectAnsprechpartner)); builder.SetItems(BusinessLayer.Ansprechpartner.ConvertToStringList(_stateFragment._ansprechpartnern, _activity.BaseContext.Resources.Configuration.Locale.Language.ToUpper()), delegate(object senderDlg, DialogClickEventArgs eDlg) { _spinnerAnsprechpartner.SetSelection(eDlg.Which); _stateFragment.SpinnerItemSelected(eDlg.Which); }); builder.SetPositiveButton(Android.Resource.String.Ok, delegate(object o, DialogClickEventArgs ea) { builder = null; }); builder.Create(); builder.Show(); } else { // If there is no Ansprechpartner just show a Dialog messaging "There is no Contact" AlertDialog.Builder builder = new AlertDialog.Builder(_activity); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(_activity.Resources.GetString(Resource.String.SelectAnsprechpartner)); builder.SetItems(new string[]{_activity.GetString(Resource.String.NoAnsprechpartner)}, delegate(object senderDlg, DialogClickEventArgs eDlg) { }); builder.SetPositiveButton(Android.Resource.String.Ok, delegate(object o, DialogClickEventArgs ea) { builder = null; }); builder.Create(); builder.Show(); } } }
void SpinnerLand_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Up) { builder = new AlertDialog.Builder(_activity); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(_activity.Resources.GetString(Resource.String.SelectCountry)); builder.SetItems(BusinessLayer.Country.ConvertToStringList(BusinessLayer.UtilityClasses.countries, _activity.BaseContext.Resources.Configuration.Locale.Language.ToUpper()), delegate(object senderDlg, DialogClickEventArgs eDlg) { _spinnerLand.SetSelection(eDlg.Which); }); builder.SetPositiveButton(Android.Resource.String.Ok, delegate(object o, DialogClickEventArgs ea) { builder = null; }); builder.Create(); builder.Show(); } }
public PlayerView(Player player, TitleDatabase database, MainActivity activity) { this.player = player; this.database = database; this.activity = activity; this.load_button = activity.FindViewById<Button>(Resource.Id.SelectButton); this.play_button = activity.FindViewById<Button>(Resource.Id.PlayButton); this.stop_button = activity.FindViewById<Button>(Resource.Id.StopButton); this.rescan_button = activity.FindViewById<Button>(Resource.Id.RescanButton); this.seekbar = activity.FindViewById<SeekBar>(Resource.Id.SongSeekbar); this.title_text_view = activity.FindViewById<TextView>(Resource.Id.SongTitleTextView); this.timeline_text_view = activity.FindViewById<TextView>(Resource.Id.TimelineTextView); PlayerEnabled = false; var ifs = IsolatedStorageFile.GetUserStoreForApplication (); if (!ifs.FileExists ("songdirs.txt")) load_button.Enabled = false; load_button.Click += delegate { var db = new AlertDialog.Builder (activity); db.SetTitle ("Select Music Folder"); List<string> dirlist = new List<string> (); if (ifs.FileExists ("history.txt")) dirlist.Add (from_history_tag); using (var sr = new StreamReader (ifs.OpenFile ("songdirs.txt", FileMode.Open))) foreach (var s in sr.ReadToEnd ().Split ('\n')) if (!String.IsNullOrEmpty (s)) dirlist.Add (s); var dirs = dirlist.ToArray (); db.SetItems (dirs, delegate (object o, DialogClickEventArgs e) { string dir = dirs [(int) e.Which]; ProcessFileSelectionDialog (dir, delegate (string mus) { player.SelectFile (mus); player.Play (); }); }); var dlg = db.Show (); }; play_button.Click += delegate { try { if (player.IsPlaying) { player.Pause (); } else { player.Play (); } } catch (Exception ex) { play_button.Text = ex.Message; } }; stop_button.Click += delegate { player.Stop (); }; rescan_button.Click += delegate { var db = new AlertDialog.Builder(activity); db.SetMessage ("Scan music directories. This operation takes a while."); db.SetPositiveButton ("OK", delegate { CreateSongDirectoryList (); load_button.Enabled = true; }); db.SetCancelable (true); db.SetNegativeButton ("Cancel", delegate {}); db.Show (); }; }
void OnMapCenterButtonClick (object sender, EventArgs args) { string[] items = new string[] {GetString(Resource.String.menu_screen_map_location_mylocation), GetString(Resource.String.menu_screen_map_location_game)}; // Show selection dialog for location AlertDialog.Builder builder = new AlertDialog.Builder(ctrl); builder.SetTitle(Resource.String.menu_screen_map_location_header); builder.SetItems(items.ToArray(), delegate(object s, DialogClickEventArgs e) { if (e.Which == 0) { _followLocation = true; FocusOnLocation(); } if (e.Which == 1) { _followLocation = false; FocusOnGame(); } }); AlertDialog alert = builder.Create(); alert.Show(); }
void ProcessFileSelectionDialog(string dir, Action<string> action) { var l = new List<string> (); if (dir == from_history_tag) { l.AddRange (player.GetPlayHistory ()); } else { if (Directory.Exists (dir)) foreach (var file in Directory.GetFiles (dir, "*.ogg")) l.Add (file); } var db = new AlertDialog.Builder(activity); if (l.Count == 0) db.SetMessage ("No music files there"); else { db.SetTitle ("Select Music File"); var files = (from f in l select database.GetTitle (f, (int) new FileInfo (f).Length) ?? Path.GetFileName (f)).ToArray (); db.SetItems (files, delegate (object o, DialogClickEventArgs e) { int idx = (int) e.Which; title_text_view.Text = files [idx]; action (l [idx]); }); } db.Show().Show(); }
private async void OnVibratePatternClick(object sender, EventArgs e) { using (var builder = new AlertDialog.Builder(Activity)) { VibrationType[] values = VibrationType.Values(); string[] names = new string[values.Length]; for (int i = 0; i < names.Length; i++) { names[i] = values[i].ToString(); } builder.SetItems(names, (dialog, args) => { mSelectedVibrationType = values[args.Which]; ((Dialog) dialog).Dismiss(); RefreshControls(); }); builder.SetTitle("Select vibration type:"); builder.Show(); } }
public void OnClick(View v) { switch (v.Id) { case Resource.Id.addExpenseDelete: if (CurrentExpense != null && CurrentExpense.Id != -1) DeleteExpense (); else Dismiss (); break; case Resource.Id.addExpenseSave: SaveExpense (); break; case Resource.Id.addExpenseCancel: Dismiss (); break; case Resource.Id.addExpenseAddPhoto: var choices = new List<string> (); choices.Add (activity.Resources.GetString (Resource.String.Gallery)); if (mediaPicker.IsCameraAvailable) choices.Add (activity.Resources.GetString (Resource.String.Camera)); AlertDialog.Builder takePictureDialog = new AlertDialog.Builder (activity); takePictureDialog.SetTitle ("Select:"); takePictureDialog.SetItems (choices.ToArray (), (innerSender, innerE) => { if (innerE.Which == 0) { mediaPicker.PickPhotoAsync ().ContinueWith (t => { if (t.IsCanceled) return; activity.RunOnUiThread (() => { expenseAddPhoto.Visibility = ViewStates.Gone; imageBitmap = BitmapFactory.DecodeStream (t.Result.GetStream ()); imageBitmap = Extensions.ResizeBitmap (imageBitmap, Constants.MaxWidth, Constants.MaxHeight); expensePhoto.SetImageBitmap (imageBitmap); expenseViewModel.Photo = new ExpensePhoto { ExpenseId = CurrentExpense.Id }; }); }); } else if (innerE.Which == 1) { //camera StoreCameraMediaOptions options = new StoreCameraMediaOptions (); options.Directory = "FieldService"; options.Name = "FieldService.jpg"; mediaPicker.TakePhotoAsync (options).ContinueWith (t => { if (t.IsCanceled) return; activity.RunOnUiThread (() => { expenseAddPhoto.Visibility = ViewStates.Gone; imageBitmap = BitmapFactory.DecodeStream (t.Result.GetStream ()); imageBitmap = Extensions.ResizeBitmap (imageBitmap, Constants.MaxWidth, Constants.MaxHeight); expensePhoto.SetImageBitmap (imageBitmap); expenseViewModel.Photo = new ExpensePhoto { ExpenseId = CurrentExpense.Id }; }); }); } }); takePictureDialog.Show (); break; } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { // Currently in a layout without a container, so no reason to create our view. return null; } View view = inflater.Inflate(Resource.Layout.Profile, container, false); view.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) ); RelativeLayout navBar = view.FindViewById<RelativeLayout>( Resource.Id.navbar_relative_layout ); navBar.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) ); // setup the name section RelativeLayout backgroundView = view.FindViewById<RelativeLayout>( Resource.Id.name_background ); ControlStyling.StyleBGLayer( backgroundView ); NickNameField = backgroundView.FindViewById<EditText>( Resource.Id.nickNameText ); ControlStyling.StyleTextField( NickNameField, ProfileStrings.NickNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); NickNameField.AfterTextChanged += (sender, e) => { Dirty = true; }; NickNameField.InputType |= InputTypes.TextFlagCapWords; View borderView = backgroundView.FindViewById<View>( Resource.Id.middle_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); LastNameField = backgroundView.FindViewById<EditText>( Resource.Id.lastNameText ); ControlStyling.StyleTextField( LastNameField, ProfileStrings.LastNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); LastNameField.AfterTextChanged += (sender, e) => { Dirty = true; }; LastNameField.InputType |= InputTypes.TextFlagCapWords; // setup the contact section EmailLayer = view.FindViewById<RelativeLayout>( Resource.Id.email_background ); ControlStyling.StyleBGLayer( EmailLayer ); EmailBGColor = ControlStylingConfig.BG_Layer_Color; EmailField = EmailLayer.FindViewById<EditText>( Resource.Id.emailAddressText ); ControlStyling.StyleTextField( EmailField, ProfileStrings.EmailPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); EmailField.AfterTextChanged += (sender, e) => { Dirty = true; }; backgroundView = view.FindViewById<RelativeLayout>( Resource.Id.cellphone_background ); ControlStyling.StyleBGLayer( backgroundView ); borderView = backgroundView.FindViewById<View>( Resource.Id.middle_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); CellPhoneField = backgroundView.FindViewById<EditText>( Resource.Id.cellPhoneText ); ControlStyling.StyleTextField( CellPhoneField, ProfileStrings.CellPhonePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); CellPhoneField.AfterTextChanged += (sender, e) => { Dirty = true; }; CellPhoneField.AddTextChangedListener(new PhoneNumberFormattingTextWatcher()); // setup the address section backgroundView = view.FindViewById<RelativeLayout>( Resource.Id.address_background ); ControlStyling.StyleBGLayer( backgroundView ); StreetField = backgroundView.FindViewById<EditText>( Resource.Id.streetAddressText ); ControlStyling.StyleTextField( StreetField, ProfileStrings.StreetPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); StreetField.AfterTextChanged += (sender, e) => { Dirty = true; }; borderView = backgroundView.FindViewById<View>( Resource.Id.street_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); CityField = backgroundView.FindViewById<EditText>( Resource.Id.cityAddressText ); ControlStyling.StyleTextField( CityField, ProfileStrings.CityPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); CityField.AfterTextChanged += (sender, e) => { Dirty = true; }; borderView = backgroundView.FindViewById<View>( Resource.Id.city_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); StateField = backgroundView.FindViewById<EditText>( Resource.Id.stateAddressText ); ControlStyling.StyleTextField( StateField, ProfileStrings.StatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); StateField.AfterTextChanged += (sender, e) => { Dirty = true; }; borderView = backgroundView.FindViewById<View>( Resource.Id.state_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); ZipField = backgroundView.FindViewById<EditText>( Resource.Id.zipAddressText ); ControlStyling.StyleTextField( ZipField, ProfileStrings.ZipPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ZipField.AfterTextChanged += (sender, e) => { Dirty = true; }; // personal backgroundView = view.FindViewById<RelativeLayout>( Resource.Id.personal_background ); ControlStyling.StyleBGLayer( backgroundView ); BirthdateField = backgroundView.FindViewById<EditText>( Resource.Id.birthdateText ); ControlStyling.StyleTextField( BirthdateField, ProfileStrings.BirthdatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); BirthdateField.FocusableInTouchMode = false; BirthdateField.Focusable = false; Button birthdateButton = backgroundView.FindViewById<Button>( Resource.Id.birthdateButton ); birthdateButton.Click += (object sender, EventArgs e ) => { // setup the initial date to use ( either now, or the date in the field ) DateTime initialDateTime = DateTime.Now; if( string.IsNullOrEmpty( BirthdateField.Text ) == false ) { initialDateTime = DateTime.Parse( BirthdateField.Text ); } // build our LayoutInflater dateInflate = LayoutInflater.From( Activity ); DatePicker newPicker = (DatePicker)dateInflate.Inflate( Resource.Layout.DatePicker, null ); newPicker.Init( initialDateTime.Year, initialDateTime.Month - 1, initialDateTime.Day, this ); Dialog dialog = new Dialog( Activity ); dialog.AddContentView( newPicker, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent ) ); dialog.Show( ); }; borderView = backgroundView.FindViewById<View>( Resource.Id.middle_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); // Gender GenderField = view.FindViewById<EditText>( Resource.Id.genderText ); ControlStyling.StyleTextField( GenderField, ProfileStrings.GenderPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); GenderField.FocusableInTouchMode = false; GenderField.Focusable = false; Button genderButton = backgroundView.FindViewById<Button>( Resource.Id.genderButton ); genderButton.Click += (object sender, EventArgs e ) => { AlertDialog.Builder builder = new AlertDialog.Builder( Activity ); Java.Lang.ICharSequence [] strings = new Java.Lang.ICharSequence[] { new Java.Lang.String( RockGeneralData.Instance.Data.Genders[ 1 ] ), new Java.Lang.String( RockGeneralData.Instance.Data.Genders[ 2 ] ), }; builder.SetItems( strings, delegate(object s, DialogClickEventArgs clickArgs) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { GenderField.Text = RockGeneralData.Instance.Data.Genders[ clickArgs.Which + 1 ]; Dirty = true; }); }); builder.Show( ); }; borderView = backgroundView.FindViewById<View>( Resource.Id.campus_middle_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); // Campus CampusField = view.FindViewById<EditText>( Resource.Id.campusText ); ControlStyling.StyleTextField( CampusField, ProfileStrings.CampusPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); CampusField.FocusableInTouchMode = false; CampusField.Focusable = false; Button campusButton = backgroundView.FindViewById<Button>( Resource.Id.campusButton ); campusButton.Click += (object sender, EventArgs e ) => { // build an alert dialog containing all the campus choices AlertDialog.Builder builder = new AlertDialog.Builder( Activity ); builder.SetTitle( ProfileStrings.SelectCampus_SourceTitle ); Java.Lang.ICharSequence [] campusStrings = new Java.Lang.ICharSequence[ RockGeneralData.Instance.Data.Campuses.Count ]; for( int i = 0; i < RockGeneralData.Instance.Data.Campuses.Count; i++ ) { campusStrings[ i ] = new Java.Lang.String( RockGeneralData.Instance.Data.Campuses[ i ].Name ); } // launch the dialog, and on selection, update the viewing campus text. builder.SetItems( campusStrings, delegate(object s, DialogClickEventArgs clickArgs) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { int campusIndex = clickArgs.Which; CampusField.Text = RockGeneralData.Instance.Data.Campuses[ campusIndex ].Name; Dirty = true; }); }); builder.Show( ); }; // Done buttons DoneButton = view.FindViewById<Button>( Resource.Id.doneButton ); ControlStyling.StyleButton( DoneButton, ProfileStrings.DoneButtonTitle, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); LogoutButton = view.FindViewById<Button>( Resource.Id.logoutButton ); ControlStyling.StyleButton( LogoutButton, ProfileStrings.LogoutButtonTitle, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); LogoutButton.Background = null; DoneButton.Click += (object sender, EventArgs e) => { if( Dirty == true ) { if ( ValidateInput( ) ) { // Since they made changes, confirm they want to save them. AlertDialog.Builder builder = new AlertDialog.Builder( Activity ); builder.SetTitle( ProfileStrings.SubmitChangesTitle ); Java.Lang.ICharSequence [] strings = new Java.Lang.ICharSequence[] { new Java.Lang.String( GeneralStrings.Yes ), new Java.Lang.String( GeneralStrings.No ), new Java.Lang.String( GeneralStrings.Cancel ) }; builder.SetItems( strings, delegate(object s, DialogClickEventArgs clickArgs) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { switch( clickArgs.Which ) { case 0: SubmitChanges( ); SpringboardParent.ModalFragmentDone( null ); break; case 1: SpringboardParent.ModalFragmentDone( null ); break; case 2: break; } }); }); builder.Show( ); } } else { SpringboardParent.ModalFragmentDone( null ); } }; LogoutButton.Click += (object sender, EventArgs e) => { // Since they made changes, confirm they want to save them. AlertDialog.Builder builder = new AlertDialog.Builder( Activity ); builder.SetTitle( ProfileStrings.LogoutTitle ); Java.Lang.ICharSequence [] strings = new Java.Lang.ICharSequence[] { new Java.Lang.String( GeneralStrings.Yes ), new Java.Lang.String( GeneralStrings.No ) }; builder.SetItems( strings, delegate(object s, DialogClickEventArgs clickArgs) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { switch( clickArgs.Which ) { case 0: RockMobileUser.Instance.LogoutAndUnbind( ); SpringboardParent.ModalFragmentDone( null ); break; case 1: break; } }); }); builder.Show( ); }; return view; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { // Currently in a layout without a container, so no reason to create our view. return null; } View view = inflater.Inflate(Resource.Layout.Register, container, false); view.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) ); view.SetOnTouchListener( this ); RelativeLayout layoutView = view.FindViewById<RelativeLayout>( Resource.Id.scroll_linear_background ); ProgressBarBlocker = view.FindViewById<RelativeLayout>( Resource.Id.progressBarBlocker ); ProgressBarBlocker.Visibility = ViewStates.Gone; ProgressBarBlocker.LayoutParameters = new RelativeLayout.LayoutParams( 0, 0 ); ProgressBarBlocker.LayoutParameters.Width = NavbarFragment.GetFullDisplayWidth( ); ProgressBarBlocker.LayoutParameters.Height = this.Resources.DisplayMetrics.HeightPixels; ResultView = new UIResultView( layoutView, new System.Drawing.RectangleF( 0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels ), OnResultViewDone ); RelativeLayout navBar = view.FindViewById<RelativeLayout>( Resource.Id.navbar_relative_layout ); navBar.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) ); // setup the username UserNameLayer = view.FindViewById<RelativeLayout>( Resource.Id.username_background ); ControlStyling.StyleBGLayer( UserNameLayer ); UserNameText = UserNameLayer.FindViewById<EditText>( Resource.Id.userNameText ); ControlStyling.StyleTextField( UserNameText, RegisterStrings.UsernamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); UserNameBGColor = ControlStylingConfig.BG_Layer_Color; UserNameText.InputType |= InputTypes.TextFlagCapWords; View borderView = UserNameLayer.FindViewById<View>( Resource.Id.username_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); // password PasswordLayer = view.FindViewById<RelativeLayout>( Resource.Id.password_background ); ControlStyling.StyleBGLayer( PasswordLayer ); PasswordText = PasswordLayer.FindViewById<EditText>( Resource.Id.passwordText ); PasswordText.InputType |= InputTypes.TextVariationPassword; ControlStyling.StyleTextField( PasswordText, RegisterStrings.PasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); PasswordBGColor = ControlStylingConfig.BG_Layer_Color; borderView = PasswordLayer.FindViewById<View>( Resource.Id.password_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); ConfirmPasswordLayer = view.FindViewById<RelativeLayout>( Resource.Id.confirmPassword_background ); ControlStyling.StyleBGLayer( ConfirmPasswordLayer ); ConfirmPasswordText = ConfirmPasswordLayer.FindViewById<EditText>( Resource.Id.confirmPasswordText ); ConfirmPasswordText.InputType |= InputTypes.TextVariationPassword; ControlStyling.StyleTextField( ConfirmPasswordText, RegisterStrings.ConfirmPasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); ConfirmPasswordBGColor = ControlStylingConfig.BG_Layer_Color; // setup the name section NickNameLayer = view.FindViewById<RelativeLayout>( Resource.Id.firstname_background ); ControlStyling.StyleBGLayer( NickNameLayer ); NickNameText = NickNameLayer.FindViewById<EditText>( Resource.Id.nickNameText ); ControlStyling.StyleTextField( NickNameText, RegisterStrings.NickNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); NickNameBGColor = ControlStylingConfig.BG_Layer_Color; NickNameText.InputType |= InputTypes.TextFlagCapWords; borderView = NickNameLayer.FindViewById<View>( Resource.Id.middle_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); LastNameLayer = view.FindViewById<RelativeLayout>( Resource.Id.lastname_background ); ControlStyling.StyleBGLayer( LastNameLayer ); LastNameText = LastNameLayer.FindViewById<EditText>( Resource.Id.lastNameText ); ControlStyling.StyleTextField( LastNameText, RegisterStrings.LastNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); LastNameBGColor = ControlStylingConfig.BG_Layer_Color; LastNameText.InputType |= InputTypes.TextFlagCapWords; // setup the cell phone section CellPhoneLayer = view.FindViewById<RelativeLayout>( Resource.Id.cellphone_background ); ControlStyling.StyleBGLayer( CellPhoneLayer ); CellPhoneText = CellPhoneLayer.FindViewById<EditText>( Resource.Id.cellPhoneText ); ControlStyling.StyleTextField( CellPhoneText, RegisterStrings.CellPhonePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); CellPhoneText.AddTextChangedListener(new PhoneNumberFormattingTextWatcher()); // email layer EmailLayer = view.FindViewById<RelativeLayout>( Resource.Id.email_background ); ControlStyling.StyleBGLayer( EmailLayer ); borderView = EmailLayer.FindViewById<View>( Resource.Id.middle_border ); borderView.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) ); EmailText = EmailLayer.FindViewById<EditText>( Resource.Id.emailAddressText ); ControlStyling.StyleTextField( EmailText, RegisterStrings.EmailPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize ); EmailBGColor = ControlStylingConfig.BG_Layer_Color; // Register button RegisterButton = view.FindViewById<Button>( Resource.Id.registerButton ); ControlStyling.StyleButton( RegisterButton, RegisterStrings.RegisterButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); CancelButton = view.FindViewById<Button>( Resource.Id.cancelButton ); ControlStyling.StyleButton( CancelButton, GeneralStrings.Cancel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize ); CancelButton.Background = null; RegisterButton.Click += (object sender, EventArgs e) => { RegisterUser( ); }; CancelButton.Click += (object sender, EventArgs e) => { // Since they made changes, confirm they want to save them. AlertDialog.Builder builder = new AlertDialog.Builder( Activity ); builder.SetTitle( RegisterStrings.ConfirmCancelReg ); Java.Lang.ICharSequence [] strings = new Java.Lang.ICharSequence[] { new Java.Lang.String( GeneralStrings.Yes ), new Java.Lang.String( GeneralStrings.No ) }; builder.SetItems( strings, delegate(object s, DialogClickEventArgs clickArgs) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { switch( clickArgs.Which ) { case 0: SpringboardParent.ModalFragmentDone( null ); break; case 1: break; } }); }); builder.Show( ); }; return view; }
private async void OnChooseThemeClick(object sender, EventArgs e) { using (var builder = new AlertDialog.Builder(Activity)) { PropertyInfo[] themes = typeof(BandTheme).GetProperties().Where(p => p.Name.EndsWith("Theme")).ToArray(); builder.SetItems(themes.Select(x => x.Name).ToArray(), (dialog, args) => { mViewTheme.Theme = (BandTheme) themes[args.Which].GetValue(null); ((Dialog) dialog).Dismiss(); RefreshControls(); }); builder.SetTitle("Select theme:"); builder.Show(); } }
void OnMapTypeButtonClick (object sender, EventArgs args) { string[] items = new string[] {GetString(Resource.String.menu_screen_map_type_google_maps), GetString(Resource.String.menu_screen_map_type_google_satelitte), GetString(Resource.String.menu_screen_map_type_google_terrain), GetString(Resource.String.menu_screen_map_type_google_hybrid), GetString(Resource.String.menu_screen_map_type_osm), GetString(Resource.String.menu_screen_map_type_ocm), GetString(Resource.String.menu_screen_map_type_none) }; // Show selection dialog for location AlertDialog.Builder builder = new AlertDialog.Builder(ctrl); builder.SetTitle(Resource.String.menu_screen_map_type_header); builder.SetItems(items.ToArray(), delegate(object s, DialogClickEventArgs e) { SetMapType (e.Which); Main.Prefs.SetInt("map_source", e.Which); }); AlertDialog alert = builder.Create(); alert.Show(); }
void ManageProfilePic( ) { // only allow picture taking if they're logged in if( RockMobileUser.Instance.LoggedIn && NavbarFragment.ShouldSpringboardAllowInput( ) ) { // setup the chooser dialog so they can pick the photo source AlertDialog.Builder builder = new AlertDialog.Builder( Activity ); builder.SetTitle( SpringboardStrings.ProfilePicture_SourceTitle ); Java.Lang.ICharSequence [] strings = new Java.Lang.ICharSequence[] { new Java.Lang.String( SpringboardStrings.ProfilePicture_SourcePhotoLibrary ), new Java.Lang.String( SpringboardStrings.ProfilePicture_SourceCamera ), new Java.Lang.String( GeneralStrings.Cancel ) }; builder.SetItems( strings, delegate(object sender, DialogClickEventArgs clickArgs) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { switch( clickArgs.Which ) { // Photo Library case 0: { Rock.Mobile.Media.PlatformImagePicker.Instance.PickImage( Rock.Mobile.PlatformSpecific.Android.Core.Context, delegate(object s, Rock.Mobile.Media.PlatformImagePicker.ImagePickEventArgs args) { // android returns a path TO the image if( args.Image != null ) { ImageCropperPendingFilePath = (string) args.Image; } }); break; } // Camera case 1: { if( Rock.Mobile.Media.PlatformCamera.Instance.IsAvailable( ) ) { // start up the camera and get our picture. // JHM 4-24-15 - The camera requires an SD Card, so use that path for our temp file. // JHM 8-31-15 - We can't use Environment.GetFolderPath because Android cameras won't save to it. Java.IO.File externalDir = Rock.Mobile.PlatformSpecific.Android.Core.Context.GetExternalFilesDir( null ); if( externalDir != null ) { string jpgFilename = externalDir.ToString( ) + "cameratemp.jpg"; Rock.Mobile.Media.PlatformCamera.Instance.CaptureImage( new Java.IO.File( jpgFilename ), null, delegate(object s, Rock.Mobile.Media.PlatformCamera.CaptureImageEventArgs args) { // flag that we want the cropper to start up on resume. // we cannot launch it now because we need to wait for the camera // activity to end and the navBar fragment to resume if( args.Result == true ) { // if the image path is valid, we have a picture. // Otherwise, they pressed cancel, so don't do anything. if( args.ImagePath != null ) { ImageCropperPendingFilePath = args.ImagePath; } } else { // couldn't get the picture DisplayError( SpringboardStrings.ProfilePicture_Error_Title, SpringboardStrings.ProfilePicture_Error_Message ); } }); } else { // error accessing their storage. no dice. DisplayError( SpringboardStrings.ExternalDir_Error_Title, SpringboardStrings.ExternalDir_Error_Message ); } } else { // nope DisplayError( SpringboardStrings.Camera_Error_Title, SpringboardStrings.Camera_Error_Message ); } break; } // Cancel case 2: { break; } } }); }); builder.Show( ); } }
void CommandSelected(Command c) { // Save for later use if there are more than one target _com = c; if (_com.CmdWith) { // Display WorksWith list to user targets = _com.TargetObjects; if (targets.Count == 0) { // We don't have any target, so display empty text AlertDialog.Builder builder = new AlertDialog.Builder(ctrl); builder.SetTitle(c.Text); builder.SetMessage(_com.EmptyTargetListText); builder.SetNeutralButton(Resource.String.ok, (sender, e) => {}); builder.Show(); } else { // We have a list of commands, so show this to the user string[] targetNames = new string[targets.Count]; for(int i = 0; i < targets.Count; i++) targetNames[i] = targets[i].Name; AlertDialog.Builder builder = new AlertDialog.Builder(ctrl); builder.SetTitle(c.Text); builder.SetItems(targetNames, OnTargetListClicked); builder.SetNeutralButton(Resource.String.cancel, (sender, e) => {}); builder.Show(); } } else { // Execute command _com.Execute (); } }
// If there are multiple bands, the "choose band" button is enabled and // launches a dialog where we can select the band to use. private void OnChooseBandClick(object sender, EventArgs e) { using (var builder = new AlertDialog.Builder(Activity)) { string[] names = new string[mPairedBands.Length]; for (int i = 0; i < names.Length; i++) { names[i] = mPairedBands[i].Name; } builder.SetItems(names, (dialog, args) => { mSelectedBandIndex = args.Which; ((Dialog) dialog).Dismiss(); RefreshControls(); }); builder.SetTitle("Select band:"); builder.Show(); } }
void PickAccount (object sender, EventArgs e) { if (state.IsSending) { return; } if (state.Accounts == null) { return; } if (state.Accounts.Count == 0) { AddAccount (); } else { var addAccountTitle = GetAddAccountTitle (); var items = state.Accounts.Select (x => x.Username).OrderBy (x => x).Concat (new [] { addAccountTitle }).ToArray (); var builder = new AlertDialog.Builder (this); builder.SetTitle ("Pick an account"); builder.SetItems ( items, (ds, de) => { var item = items [de.Which]; if (item == addAccountTitle) { AddAccount (); } else { state.ActiveAccount = state.Accounts.FirstOrDefault (x => x.Username == item); UpdateAccountUI (); } }); var alert = builder.Create (); alert.Show (); } }
public void SelectCampus(object sender, EventArgs e ) { // build an alert dialog containing all the campus choices AlertDialog.Builder builder = new AlertDialog.Builder( Activity ); Java.Lang.ICharSequence [] campusStrings = new Java.Lang.ICharSequence[ RockGeneralData.Instance.Data.Campuses.Count ]; for( int i = 0; i < RockGeneralData.Instance.Data.Campuses.Count; i++ ) { campusStrings[ i ] = new Java.Lang.String( App.Shared.Network.RockGeneralData.Instance.Data.Campuses[ i ].Name ); } builder.SetTitle( new Java.Lang.String( SpringboardStrings.SelectCampus_SourceTitle ) ); // launch the dialog, and on selection, update the viewing campus text. builder.SetItems( campusStrings, delegate(object s, DialogClickEventArgs clickArgs) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { // get the ID for the campus they selected string campusTitle = campusStrings[ clickArgs.Which ].ToString( ); RockMobileUser.Instance.ViewingCampus = RockGeneralData.Instance.Data.CampusNameToId( campusTitle ); // build a label showing what they picked RefreshCampusSelection( ); }); }); builder.Show( ); }
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView (inflater, container, savedInstanceState); var view = inflater.Inflate (Resource.Layout.ConfirmationsLayout, null, true); signatureImage = view.FindViewById<ImageView> (Resource.Id.confirmationsSignature); photoListView = view.FindViewById<ListView> (Resource.Id.confirmationPhotoList); photoListView.ItemClick += (sender, e) => { var image = view.FindViewById<ImageView> (Resource.Id.photoListViewImage); if (image != null) { int index = (int)image.Tag; var photo = Photos.ElementAtOrDefault (index); photoDialog = new PhotoDialog (Activity); photoDialog.Activity = Activity; photoDialog.Assignment = Assignment; photoDialog.Photo = photo; photoDialog.Show (); } }; var addPhoto = view.FindViewById<Button> (Resource.Id.confirmationsAddPhoto); if (Assignment != null) { addPhoto.Enabled = !Assignment.IsHistory; } addPhoto.Click += (sender, e) => { var choices = new List<string> (); choices.Add (Resources.GetString (Resource.String.Gallery)); if (mediaPicker.IsCameraAvailable) { choices.Add (Resources.GetString (Resource.String.Camera)); } AlertDialog.Builder takePictureDialog = new AlertDialog.Builder (Activity); takePictureDialog.SetTitle ("Select:"); takePictureDialog.SetItems (choices.ToArray (), (innerSender, innerE) => { if (innerE.Which == 0) { //gallery mediaPicker.PickPhotoAsync ().ContinueWith (t => { if (t.IsCanceled) return; Activity.RunOnUiThread (() => { photoDialog = new PhotoDialog (Activity); photoDialog.Activity = Activity; photoDialog.Assignment = Assignment; photoDialog.PhotoStream = t.Result.GetStream (); photoDialog.Show (); }); }); } else if (innerE.Which == 1) { //camera StoreCameraMediaOptions options = new StoreCameraMediaOptions (); options.Directory = "FieldService"; options.Name = "FieldService.jpg"; mediaPicker.TakePhotoAsync (options).ContinueWith (t => { if (t.IsCanceled) return; Activity.RunOnUiThread (() => { photoDialog = new PhotoDialog (Activity); photoDialog.Activity = Activity; photoDialog.Assignment = Assignment; photoDialog.PhotoStream = t.Result.GetStream (); photoDialog.Show (); }); }); } }); takePictureDialog.Show (); }; var addSignature = view.FindViewById<Button> (Resource.Id.confirmationsAddSignature); if (Assignment != null) { addSignature.Enabled = !Assignment.IsHistory; } addSignature.Click += (sender, e) => { signatureDialog = new SignatureDialog (Activity); signatureDialog.Activity = Activity; signatureDialog.Assignment = Assignment; signatureDialog.Show (); }; var completeSignature = view.FindViewById<Button> (Resource.Id.confirmationsComplete); if (Assignment != null) { completeSignature.Enabled = Assignment.CanComplete; } completeSignature.Click += (sender, e) => { if (assignmentViewModel.Signature == null) { AlertDialog.Builder builder = new AlertDialog.Builder (Activity); builder .SetTitle (string.Empty) .SetMessage ("No signature!") .SetPositiveButton ("Ok", (innerSender, innere) => { }) .Show (); return; } completeSignature.Enabled = false; Assignment.Status = AssignmentStatus.Complete; assignmentViewModel.SaveAssignmentAsync (Assignment) .ContinueWith (_ => { Activity.RunOnUiThread (() => { completeSignature.Enabled = true; Activity.Finish (); }); }); }; ReloadListView (); ReloadSignature (); return view; }
public void OnButtonClicked(object sender, EventArgs e) { // Sound and vibration if it is selected ctrl.Feedback(); if (commands.Count == 1) { // Don't update anymore _refresh.Abort(); // We have only one command, so we don't need an extra dialog CommandSelected(commands[0]); } else { // We have a list of commands, so show this to the user string[] commandNames = new string[commands.Count]; for(int i = 0; i < commands.Count; i++) commandNames[i] = commands[i].Text; AlertDialog.Builder builder = new AlertDialog.Builder(ctrl); builder.SetTitle(Resource.String.screen_detail_commands); builder.SetItems(commandNames, OnCommandListClicked); builder.SetNeutralButton(Resource.String.cancel, (s, args) => {}); builder.Show(); } }
public void SpinnerStatus_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Up) { AlertDialog.Builder builder = new AlertDialog.Builder(_activity); builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle(_activity.Resources.GetString(Resource.String.SelectStatus)); builder.SetItems(_stateFragment._taskStatus.ToArray(), delegate(object senderDlg, DialogClickEventArgs eDlg) { _spinnerStatus.SetSelection(eDlg.Which); }); builder.SetPositiveButton(Android.Resource.String.Ok, delegate(object o, DialogClickEventArgs ea) { builder = null; }); builder.Create(); builder.Show(); } }
protected override Dialog OnCreateDialog(int id) { switch (id) { case DIALOG_YES_NO_MESSAGE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_YES_NO_OLD_SCHOOL_MESSAGE: { var builder = new AlertDialog.Builder (this, Android.App.AlertDialog.ThemeTraditional); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_YES_NO_HOLO_LIGHT_MESSAGE: { var builder = new AlertDialog.Builder (this, Android.App.AlertDialog.ThemeHoloLight); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_YES_NO_LONG_MESSAGE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_msg); builder.SetMessage (Resource.String.alert_dialog_two_buttons_msg); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); builder.SetNeutralButton (Resource.String.alert_dialog_something, NeutralClicked); return builder.Create (); } case DIALOG_YES_NO_ULTRA_LONG_MESSAGE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_msg); builder.SetMessage (Resource.String.alert_dialog_two_buttons2ultra_msg); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); builder.SetNeutralButton (Resource.String.alert_dialog_something, NeutralClicked); return builder.Create (); } case DIALOG_LIST: { var builder = new AlertDialog.Builder (this); builder.SetTitle (Resource.String.select_dialog); builder.SetItems (Resource.Array.select_dialog_items, ListClicked); return builder.Create (); } case DIALOG_PROGRESS: { progress_dialog = new ProgressDialog (this); progress_dialog.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); progress_dialog.SetTitle (Resource.String.select_dialog); progress_dialog.SetProgressStyle (ProgressDialogStyle.Horizontal); progress_dialog.Max = MAX_PROGRESS; progress_dialog.SetButton (Android.App.Dialog.InterfaceConsts.ButtonPositive, GetText (Resource.String.alert_dialog_ok), OkClicked); progress_dialog.SetButton (Android.App.Dialog.InterfaceConsts.ButtonNegative, GetText (Resource.String.alert_dialog_cancel), CancelClicked); return progress_dialog; } case DIALOG_SINGLE_CHOICE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_single_choice); builder.SetSingleChoiceItems (Resource.Array.select_dialog_items2, 0, ListClicked); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_MULTIPLE_CHOICE: { var builder = new AlertDialog.Builder (this); builder.SetIcon (Resource.Drawable.ic_popup_reminder); builder.SetTitle (Resource.String.alert_dialog_multi_choice); builder.SetMultiChoiceItems (Resource.Array.select_dialog_items3, new bool[] { false, true, false, true, false, false, false }, MultiListClicked); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_MULTIPLE_CHOICE_CURSOR: { var projection = new string[] { BaseColumns.Id, Contacts.PeopleColumns.DisplayName, Contacts.PeopleColumns.SendToVoicemail }; var cursor = ManagedQuery (ContactsContract.Contacts.ContentUri, projection, null, null, null); var builder = new AlertDialog.Builder (this); builder.SetIcon (Resource.Drawable.ic_popup_reminder); builder.SetTitle (Resource.String.alert_dialog_multi_choice_cursor); builder.SetMultiChoiceItems (cursor, Contacts.PeopleColumns.SendToVoicemail, Contacts.PeopleColumns.DisplayName, MultiListClicked); return builder.Create (); } case DIALOG_TEXT_ENTRY: { // This example shows how to add a custom layout to an AlertDialog var factory = LayoutInflater.From (this); var text_entry_view = factory.Inflate (Resource.Layout.alert_dialog_text_entry, null); var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_text_entry); builder.SetView (text_entry_view); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } } return null; }
private void showPreferencePopup() { var settings = new Settings(this); var connections = settings.GetConnections(); if (connections.Count == 0) return; // not yet any items string[] items = connections.Select(p => p.Server + ":" + p.Port).ToArray(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Choix du serveur"); builder.SetPositiveButton("Ajouter", delegate(object sender, DialogClickEventArgs e) { // Let the popup close and show the normal login form }); builder.SetNegativeButton("Gérer", delegate(object sender, DialogClickEventArgs e) { this.openConnectionManager(); }); builder.SetItems(items, delegate(object sender, DialogClickEventArgs e) { var index = (int)e.Which; var connection = connections[index]; this.loginAsync(connection.ServerID, connection.Server, connection.Port); }); var alert = builder.Create(); alert.Show(); }