protected override void OnElementChanged(ElementChangedEventArgs <FloatingView> e) { base.OnElementChanged(e); if (e.NewElement == null) { return; } fab = new FloatingActionButton(Context); ViewCompat.SetBackgroundTintList(fab, ColorStateList.ValueOf(Element.ButtonColor.ToAndroid())); fab.UseCompatPadding = true; var elementImage = Element.Image; var imageFile = elementImage?.File; if (imageFile != null) { fab.SetImageDrawable(Context.Resources.GetDrawable(imageFile)); } fab.Click += delegate(object sender, EventArgs ev) { ((IButtonController)Element).SendClicked(); }; SetNativeControl(fab); }
protected override View GenerateContent(DayScheduleItemsArranger.EventItem item) { var grid = new FrameLayout(Context) { LayoutParameters = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent) { Weight = 1 }, Background = ContextCompat.GetDrawable(Context, Resource.Drawable.schedule_item_rounded_rectangle) }; ViewCompat.SetBackgroundTintList(grid, GetBackgroundColorStateList(item.Item)); var tb = new TextView(Context) { LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent) { LeftMargin = ThemeHelper.AsPx(Context, 6), TopMargin = ThemeHelper.AsPx(Context, 6) }, Text = item.Item.Name }; tb.SetTextColor(Color.White); if (item.Item.IsComplete) { tb.SetStrikethrough(true); } grid.AddView(tb); return(grid); }
protected override View GenerateContent(DayScheduleItemsArranger.EventItem item) { var grid = new FrameLayout(Context) { LayoutParameters = new ViewGroup.LayoutParams(ThemeHelper.AsPx(Context, WIDTH_OF_COLLAPSED_ITEM), LayoutParams.MatchParent), Background = ContextCompat.GetDrawable(Context, Resource.Drawable.schedule_item_rounded_rectangle) }; ViewCompat.SetBackgroundTintList(grid, MyFullEventItem.GetBackgroundColorStateList(item.Item)); var tb = new TextView(Context) { //FontSize = 18, Gravity = GravityFlags.CenterHorizontal | GravityFlags.Top, LayoutParameters = new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent) { TopMargin = ThemeHelper.AsPx(Context, 6) }, Text = item.Item.Name.Substring(0, 1) }; tb.SetTextColor(Color.White); grid.AddView(tb); return(grid); }
// Replace the contents of a view (invoked by the layout manager) public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { try { switch (viewHolder) { case OffersAdapterViewHolder holder: { var item = OffersList[position]; if (item != null) { GlideImageLoader.LoadImage(ActivityContext, item.Image, holder.Image, ImageStyle.CenterCrop, ImagePlaceholders.Drawable); holder.Type.Text = Methods.FunString.DecodeString(item.OfferText) + " " + Methods.FunString.DecodeString(item.DiscountedItems); holder.Title.Text = Methods.FunString.SubStringCutOf(Methods.FunString.DecodeString(item.Description), 200); holder.Date.Text = ActivityContext.GetText(Resource.String.Lbl_End_Date) + " : " + item.ExpireDate; ViewCompat.SetBackgroundTintList(holder.Date, ColorStateList.ValueOf(Color.ParseColor(Methods.FunString.RandomColor()))); } break; } } } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
private View CreateCircle(ViewGroup root, BaseViewItemHomeworkExamGrade item) { View view = new View(root.Context) { Background = ContextCompat.GetDrawable(root.Context, Resource.Drawable.circle), LayoutParameters = new LinearLayout.LayoutParams( ThemeHelper.AsPx(Context, 5), ThemeHelper.AsPx(Context, 5)) { RightMargin = ThemeHelper.AsPx(Context, 3) } }; if (item is BaseViewItemHomeworkExam) { ViewCompat.SetBackgroundTintList(view, new ColorStateList(new int[][] { new int[] { } }, new int[] { ColorTools.GetColor((item as BaseViewItemHomeworkExam).GetClassOrNull().Color).ToArgb() })); } return(view); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (Control != null) { ViewCompat.SetBackgroundTintList(Control, ColorStateList.ValueOf(Color.Transparent.ToAndroid())); } }
private void UpdateEnabled() { this.Control.Enabled = this.Element.IsEnabled; if (this.Control.Enabled == false) { ViewCompat.SetBackgroundTintList(this.Control, ColorStateList.ValueOf(this.Element.DisabledColor.ToAndroid())); } else { this.UpdateBackgroundColor(); } }
private void SetBackgroundColors() { ViewCompat.SetBackgroundTintList(this.Control, ColorStateList.ValueOf(this.Element.NormalColor.ToAndroid())); try { this.Control.RippleColor = this.Element.RippleColor.ToAndroid(); } catch (MissingMethodException) { // ignore } }
void ApplyTheme() { if (_textInputLayout == null) { return; } // set text color var textColor = TextColor; UpdateTextColor(Color.FromUint((uint)textColor.ToArgb())); var colors = MaterialColors.CreateEntryUnderlineColors(textColor, textColor.WithAlpha(kFilledTextFieldOnSurfaceAlpha)); // Ensure that we SetBackgroundTintList when focused to override the themes accent color which gets // applied to the underline if (_previousTextColor != textColor) { if (HasFocus) { _previousTextColor = textColor; } ViewCompat.SetBackgroundTintList(_textInputEditText, colors); } // set placeholder color AColor placeholderColor; if (Element.PlaceholderColor == Color.Default) { if (Element.TextColor == Color.Default) { placeholderColor = MaterialColors.Light.OnSurfaceColor; } else { placeholderColor = textColor; } } else { placeholderColor = Element.PlaceholderColor.ToAndroid(); } if (!HasFocus) { placeholderColor = placeholderColor.WithAlpha(kFilledTextFieldOnSurfaceAlpha + kFilledPlaceHolderOffset); } _textInputLayout.DefaultHintTextColor = MaterialColors.CreateEntryFilledPlaceholderColors(placeholderColor); }
public void OnProgressChanged(SeekBar seekBar, int progress, bool fromUser) { if (progress >= 100) { ViewCompat.SetBackgroundTintList(_imageButtonDone, ContextCompat.GetColorStateList(Context, Resource.Color.homework_progress_complete_button_background_completed)); ViewCompat.SetBackgroundTintList(_imageButtonIncomplete, ContextCompat.GetColorStateList(Context, Resource.Color.homework_progress_button_background_unselected)); } else { ViewCompat.SetBackgroundTintList(_imageButtonDone, ContextCompat.GetColorStateList(Context, Resource.Color.homework_progress_button_background_unselected)); ViewCompat.SetBackgroundTintList(_imageButtonIncomplete, ContextCompat.GetColorStateList(Context, Resource.Color.homework_progress_incomplete_button_background)); } }
protected override void OnCreate(Bundle savedInstanceState) { firebaseAnalytics = FirebaseAnalytics.GetInstance(ApplicationContext); base.OnCreate(savedInstanceState); Localise.SetLayoutDirectionByPreference(this); SetContentView(Resource.Layout.record); SupportActionBar.Title = StringResources.recording_ui_title; SupportActionBar.SetDisplayHomeAsUpEnabled(true); var instructionsHeader = FindViewById <TextView>(Resource.Id.recordInstructionsHeader); instructionsHeader.Text = StringResources.recording_ui_instructions_header; InterviewSessionID = Guid.NewGuid().ToString(); var _prefs = Android.Preferences.PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); ConsentType = _prefs.GetString("SESSION_CONSENT", ""); SelectedProjectID = _prefs.GetInt("SelectedProjectID", 0); langId = _prefs.GetInt("SESSION_LANG", 1); var selectedProject = Queries.ProjectById(SelectedProjectID); RecyclerView promptRecyclerView = FindViewById <RecyclerView>(Resource.Id.prompts); promptRecyclerView.SetLayoutManager(new GridLayoutManager(this, 1)); Content project = LanguageChoiceManager.ContentByLanguage(selectedProject, langId); List <Topic> activeTopics = project.Topics.Where((p) => p.IsActive).ToList(); themes = activeTopics; adapter = new TopicAdapter(themes); adapter.ProjectClicked += CheckRecPerm; promptRecyclerView.SetAdapter(adapter); record = FindViewById <FloatingActionButton>(Resource.Id.start); FindViewById <TextView>(Resource.Id.themeTitle).Text = project.Title; Color highlightColor = new Color(ContextCompat.GetColor(this, Resource.Color.colorControlHighlight)); ViewCompat.SetBackgroundTintList(record, Android.Content.Res.ColorStateList.ValueOf(highlightColor)); record.Enabled = false; timer = FindViewById <TextView>(Resource.Id.timer); timer.SetTextColor(highlightColor); record.Click += HandleRecordClick; }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { AndroidFloatingActionButton floatingButton = Control; if (e.PropertyName == nameof(Element.ButtonColor)) { ViewCompat.SetBackgroundTintList(Control, ColorStateList.ValueOf(Element.ButtonColor.ToAndroid())); } if (e.PropertyName == nameof(Element.Image)) { SetImage(floatingButton, Element.Image); } base.OnElementPropertyChanged(sender, e); }
public Button SetButtonTint(Button button) { if (SdkUtils.HasLollipop() && button is AppCompatButton) { ((AppCompatButton)button).SupportBackgroundTintList = ColorStateList.ValueOf( new Color(ContextCompat.GetColor(_context, Resource.Color.hijri_date_picker_accent_color))); } else { ViewCompat.SetBackgroundTintList(button, ColorStateList.ValueOf( new Color(ContextCompat.GetColor(_context, Resource.Color.hijri_date_picker_accent_color)))); } return(button); }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { var fab = Control; if (e.PropertyName == nameof(Element.ButtonColor)) { ViewCompat.SetBackgroundTintList(fab, ColorStateList.ValueOf(Element.ButtonColor.ToAndroid())); } if (e.PropertyName == nameof(Element.Image)) { var elementImage = Element.Image; var imageFile = elementImage?.File; if (imageFile != null) { fab.SetImageDrawable(Context.Resources.GetDrawable(imageFile)); } } if (e.PropertyName == nameof(Element.ToggleFloatingView)) { if (Element.ToggleFloatingView) { if (fab != null) { var animator = ViewCompat.Animate(fab) .SetDuration(500) .ScaleX(0) .ScaleY(0); animator.SetListener(this); animator.Start(); } } else { if (fab != null) { var animator = ViewCompat.Animate(fab) .SetDuration(500) .ScaleX(1) .ScaleY(1); animator.SetListener(this); animator.Start(); } } } base.OnElementPropertyChanged(sender, e); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.new_whisky); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); toolbar.SetTitleTextColor(Android.Graphics.Color.White); SetActionBar(toolbar); CreateRatingBarsListeners(); HandleAddWhiskyEvent(); TextInputEditText whiskyNameTextInput = FindViewById <TextInputEditText>(Resource.Id.whisky_name_text_input); ViewCompat.SetBackgroundTintList(whiskyNameTextInput, ColorStateList.ValueOf(Android.Graphics.Color.Gold)); }
protected override void OnElementChanged(ElementChangedEventArgs <FloatingActionButton> e) { base.OnElementChanged(e); if (e.NewElement == null) { return; } AndroidFloatingActionButton floatingButton = new AndroidFloatingActionButton(Context); ViewCompat.SetBackgroundTintList(floatingButton, ColorStateList.ValueOf(Element.ButtonColor.ToAndroid())); floatingButton.UseCompatPadding = true; SetImage(floatingButton, Element.Image); floatingButton.Click += OnFloatingButtonClick; SetNativeControl(floatingButton); }
protected override void OnElementChanged(ElementChangedEventArgs<MyFloatButton> e) { base.OnElementChanged(e); if (Control == null) { _fab = new FloatingActionButton(Context); _fab.LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); _fab.Clickable = true; _fab.SetImageDrawable(ContextCompat.GetDrawable(Context, Resource.Drawable.add)); ViewCompat.SetBackgroundTintList(_fab, new ColorStateList(new[] {new int[0]}, new int[] {Android.Graphics.Color.ParseColor(e.NewElement.ButtonBackgroundColor)})); SetNativeControl(_fab); } if (e.NewElement != null) { _fab.Click += Fab_Click; } if (e.OldElement != null) { _fab.Click -= Fab_Click; } }
private View CreateCircle(ViewGroup root, BaseViewItemMegaItem item) { View view = new View(root.Context) { Background = ContextCompat.GetDrawable(root.Context, Resource.Drawable.circle), LayoutParameters = new LinearLayout.LayoutParams( ThemeHelper.AsPx(Context, 9), ThemeHelper.AsPx(Context, 9)) { BottomMargin = ThemeHelper.AsPx(Context, 2) } }; if (item is ViewItemTaskOrEvent) { ViewCompat.SetBackgroundTintList(view, MyFullEventItem.GetBackgroundColorStateList(item as ViewItemTaskOrEvent)); } return(view); }
private void UpdateColor() { if (_nativeView == null || _backgroundElement == null || _visualElement == null) { return; } var color = _backgroundElement.Color == Color.Default ? _visualElement.BackgroundColor == Color.Default ? Color.Default : _visualElement.BackgroundColor : _backgroundElement.Color; if (color == Color.Default) { return; } switch (_nativeView) { case MaterialCardView mCardView: mCardView.CardBackgroundColor = ColorStateList.ValueOf(color.ToAndroid()); break; case Chip mChip: mChip.ChipBackgroundColor = ColorStateList.ValueOf(color.ToAndroid()); break; case MaterialButton mButton: var primaryColor = color.ToAndroid(); var alphaPrimaryColor = new AColor( primaryColor.R, primaryColor.G, primaryColor.B, (byte)(0.12 * 255)); ViewCompat.SetBackgroundTintList(mButton, new ColorStateList(ButtonStates, new int[] { primaryColor, alphaPrimaryColor })); break; default: _nativeView.SetColor(color); break; } }
void ApplyTheme() { if (_textInputLayout == null) return; // set text color var textColor = MaterialColors.GetEntryTextColor(Element.TextColor); UpdateTextColor(Color.FromUint((uint)textColor.ToArgb())); var placeHolderColors = MaterialColors.GetPlaceHolderColor(Element.PlaceholderColor, Element.TextColor); var underlineColors = MaterialColors.GetUnderlineColor(Element.TextColor); var colors = MaterialColors.CreateEntryUnderlineColors(underlineColors.FocusedColor, underlineColors.UnFocusedColor); ViewCompat.SetBackgroundTintList(_textInputEditText, colors); if (HasFocus || !string.IsNullOrWhiteSpace(_textInputEditText.Text)) _textInputLayout.DefaultHintTextColor = MaterialColors.CreateEntryFilledPlaceholderColors(placeHolderColors.FloatingColor, placeHolderColors.FloatingColor); else _textInputLayout.DefaultHintTextColor = MaterialColors.CreateEntryFilledPlaceholderColors(placeHolderColors.InlineColor, placeHolderColors.FloatingColor); }
void UpdatePlaceholderColor(bool reset) { int[][] States = { new [] { global::Android.Resource.Attribute.StateFocused }, new [] { -global::Android.Resource.Attribute.StateFocused }, }; var placeHolderColor = new ColorStateList( States, new int[] { Entry.PlaceholderColor.ToAndroid(), Entry.PlaceholderColor.ToAndroid() } ); if (reset) { DefaultHintTextColor = placeHolderColor; } ViewCompat.SetBackgroundTintList(_textInputEditText, placeHolderColor); }
private void ProjectSelected(int position) { ItemSelected(position); var recordButton = FindViewById <FloatingActionButton>(Resource.Id.start); // Has the first topic been selected, i.e. one of the states has changed if (themes.FindAll((p) => p.SelectionState != Topic.SelectedState.never).Count == 1) { var record = FindViewById <FloatingActionButton>(Resource.Id.start); record.SetImageResource(Resource.Drawable.stop_recording); ViewCompat.SetBackgroundTintList(record, Android.Content.Res.ColorStateList.ValueOf(Color.White)); record.Enabled = true; FindViewById <TextView>(Resource.Id.timer).SetTextColor(Color.White); recordButton.Visibility = ViewStates.Visible; recordButton.PerformClick(); } if (_isrecording) { var current = themes.Find((p) => p.SelectionState == Topic.SelectedState.current); Queries.CreateAnnotation(_seconds, InterviewSessionID, current.ID); adapter.PromptSeleted(position); } }
internal void ApplyTheme(Color formsTextColor, Color formsPlaceHolderColor) { if (_disposed) { return; } if (!_isSetup) { _isSetup = true; EditText.FocusChange += OnFocusChange; ResetTextColors(formsTextColor, formsPlaceHolderColor); } else if (formsTextColor != _formsTextColor || _formsPlaceholderColor != formsPlaceHolderColor) { ResetTextColors(formsTextColor, formsPlaceHolderColor); } if (HasFocus) { ViewCompat.SetBackgroundTintList(EditText, _focusedUnderlineColorsList); } else { ViewCompat.SetBackgroundTintList(EditText, _unfocusedUnderlineColorsList); } if (HasFocus || !string.IsNullOrWhiteSpace(EditText.Text)) { this.DefaultHintTextColor = _focusedFilledColorList; } else { this.DefaultHintTextColor = _unfocusedEmptyColorList; } }
public MyCalendarDayView(Context context, MyCalendarView calendarView, CalendarViewModel viewModel) : base(context) { _calendarView = calendarView; _viewModel = viewModel; int margin = ThemeHelper.AsPx(Context, 1); Clickable = true; LayoutParameters = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent); _backgroundView = new View(Context) { LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.MatchParent) { TopMargin = margin, LeftMargin = margin, RightMargin = margin, BottomMargin = margin } }; base.AddView(_backgroundView); _backgroundOverlayView = new View(Context) { LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.MatchParent) { TopMargin = margin, LeftMargin = margin, RightMargin = margin, BottomMargin = margin }, Visibility = ViewStates.Gone }; base.AddView(_backgroundOverlayView); var padding = ThemeHelper.AsPx(Context, 4); _myHomeworkCircles = new MyHomeworkCircles(Context) { LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.WrapContent) { Gravity = GravityFlags.Bottom, LeftMargin = padding, BottomMargin = padding, RightMargin = padding } }; this.AddView(_myHomeworkCircles); _tv = new TextView(Context) { Gravity = GravityFlags.Top | GravityFlags.Right, LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.WrapContent) { TopMargin = ThemeHelper.AsPx(Context, 2), RightMargin = padding } }; _defaultTextColors = _tv.TextColors; this.AddView(_tv); _selectedRectangleView = new View(Context) { LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.MatchParent), Visibility = ViewStates.Gone }; _selectedRectangleView.Background = ContextCompat.GetDrawable(Context, Resource.Drawable.CalendarSelectedDayBorder); ViewCompat.SetBackgroundTintList(_selectedRectangleView, new ColorStateList(new int[][] { new int[0] }, new int[] { ColorTools.GetColor(this.Context, Resource.Color.accent) })); this.AddView(_selectedRectangleView); this.Click += MyCalendarDayView_Click; UpdateSelectedStatus(); _calendarView.SelectedDateChanged += new WeakEventHandler <EventArgs>(_calendarView_SelectedDateChanged).Handler; }
protected override void OnAttached() { var editText = Control as global::Android.Widget.EditText; ViewCompat.SetBackgroundTintList(editText, ColorStateList.ValueOf(LineColor.ToAndroid())); }
public static void SetTargetProperty(object rawValue, object view, PropertyInfo targetProperty, IValueConverter converter, string converterParameter) { try { if (targetProperty == null) { throw new ArgumentNullException(nameof(targetProperty)); } if (view == null) { throw new ArgumentNullException(nameof(view)); } // Use the converter var sourcePropertyValue = converter == null ? rawValue : converter.Convert(rawValue, targetProperty.PropertyType, converterParameter, CultureInfo.CurrentCulture); /* Need some implicit type coercion here. * Perhaps pull that in from Calciums property binding system. */ var property = targetProperty; if (property.PropertyType == typeof(string) && !(sourcePropertyValue is string) && sourcePropertyValue != null) { sourcePropertyValue = sourcePropertyValue.ToString(); } else if (property.PropertyType == typeof(Android.Views.ViewStates)) { if (!(sourcePropertyValue is Android.Views.ViewStates)) { // Implicit visibility converter bool?shouldBeVisible = null; if (sourcePropertyValue is bool boolean) { shouldBeVisible = boolean; } else { // If not null, visible shouldBeVisible = sourcePropertyValue != null; } if (shouldBeVisible != null) { sourcePropertyValue = shouldBeVisible.Value ? Android.Views.ViewStates.Visible : Android.Views.ViewStates.Gone; } } } if (targetProperty.DeclaringType == typeof(TextViewStrikethroughWrapper)) { var wrapper = new TextViewStrikethroughWrapper(view as TextView); targetProperty.SetValue(wrapper, sourcePropertyValue); } else if (view is View androidView && targetProperty.Name == nameof(androidView.BackgroundTintList) && sourcePropertyValue is ColorStateList colorStateList) { // Use ViewCompat since this property didn't exist till API 21 try { ViewCompat.SetBackgroundTintList(androidView, colorStateList); } catch (Java.Lang.RuntimeException) { // This theoretically shouldn't ever fail, yet it seems to fail sometimes due to a null reference exception // which makes no sense. So I'll just catch it. } } else if (targetProperty.Name == nameof(View.HasFocus)) { // Don't do anything, these are only one-way where the viewmodel updates but the view never updates } else { targetProperty.SetValue(view, sourcePropertyValue); } }
protected override void OnCreate(Bundle savedInstanceState) { firebaseAnalytics = FirebaseAnalytics.GetInstance(ApplicationContext); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.record); SetSupportActionBar(FindViewById <Toolbar>(Resource.Id.toolbar)); SupportActionBar.Title = StringResources.recording_ui_title; SupportActionBar.SetDisplayHomeAsUpEnabled(true); var instructionsHeader = FindViewById <TextView>(Resource.Id.recordInstructionsHeader); instructionsHeader.Text = StringResources.recording_ui_instructions_header; InterviewSessionID = Guid.NewGuid().ToString(); var _prefs = Android.Preferences.PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); ConsentType = _prefs.GetString("SESSION_CONSENT", ""); SelectedProjectID = _prefs.GetInt("SelectedProjectID", 0); var selectedProject = Queries.ProjectById(SelectedProjectID); var promptRecyclerView = FindViewById <RecyclerView>(Resource.Id.prompts); promptRecyclerView.SetLayoutManager(new GridLayoutManager(this, 1)); themes = selectedProject.Prompts; adapter = new TopicAdapter(themes); adapter.ProjectClicked += ProjectSelected; promptRecyclerView.SetAdapter(adapter); var record = FindViewById <FloatingActionButton>(Resource.Id.start); ViewCompat.SetBackgroundTintList(record, Android.Content.Res.ColorStateList.ValueOf(Color.LightGray)); record.Enabled = false; var timer = FindViewById <TextView>(Resource.Id.timer); timer.SetTextColor(Color.LightGray); // Note: record has two states: start and stop record. record.Click += delegate { LOG_EVENT("RECORD_CLICKED"); // Change icon between record to stop. record.Selected = !record.Selected; if (record.Selected) { // Override path for re-use as user may record many audios. Store only once. if (string.IsNullOrWhiteSpace(_path)) { var personal = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); _path = System.IO.Path.Combine(personal, DateTimeOffset.Now.ToUnixTimeSeconds() + ".mp3"); } StartRecording(); // TODO: do we want users to record for as long as they desire? RunOnUiThread(async() => { _seconds = 0; while (_isrecording) { SupportActionBar.Title = StringResources.recording_ui_title_active; timer.Text = Queries.FormatFromSeconds(_seconds++); await Task.Delay(1000); } }); } else { ModalToVerifyRecordingEnd(); // This ensures that the state of the Play/Stop icon does not change record.Selected = true; } }; }