static void AddToLibrary(ActionSheet controller, MediaItemBase item) { if (!ShouldShowAddToLibrary(item)) { return; } controller.Add("Add to Library", async() => { var onlineSong = item as OnlineSong; if (onlineSong?.TrackData?.ServiceType == ServiceType.YouTube) { //Prompt for meta data var editor = new SongTagEditor { Song = onlineSong }; await GetCurrentViewController().PresentViewControllerAsync(new UINavigationController(editor), true); var s = await editor.GetValues(); if (!s) { return; } } var success = await MusicManager.Shared.AddToLibrary(item); if (!success) { App.ShowAlert("Error", "There was an error please try again"); } }); }
static void AddOfflineButtons(ActionSheet controller, MediaItemBase item) { if (item is RadioStation) { return; } var song = item as Song; if (song != null) { bool canOffline = false; foreach (var serviceType in song.ServiceTypes) { switch (serviceType) { case ServiceType.iPod: case ServiceType.FileSystem: return; case ServiceType.Amazon: case ServiceType.DropBox: case ServiceType.Google: canOffline = true; break; } } if (!canOffline) { return; } } var localTitle = item.ShouldBeLocal() || item.OfflineCount > 0 ? "Remove from Device" : "Download to Device"; controller.Add(localTitle, () => { OfflineManager.Shared.ToggleOffline(item); }); }
SettingsElement CreateLanguagePicker(string title) { SettingsElement element = null; var currentCulture = string.IsNullOrWhiteSpace(Settings.LanguageOverride) ? Strings.Default : new CultureInfo(Settings.LanguageOverride).NativeName; element = new SettingsElement(title, () => { var sheet = new ActionSheet(title); sheet.Add(Strings.Default, () => { Settings.LanguageOverride = null; }); cultures.ForEach(x => sheet.Add(x.NativeName, () => { Strings.Culture = x; Settings.LanguageOverride = x.Name; element.Value = x.NativeName; })); sheet.Show(this, TableView); }) { style = UITableViewCellStyle.Value1, Value = currentCulture, }; return(element); }
static void AddRadioStationButton(ActionSheet controller, MediaItemBase item) { //TODO check if we can add station to the item; if (!SouldShowStartRadio(item)) { return; } controller.Add("Start Radio Station", async() => { using (new Spinner("Creating Station")) { try { var station = await MusicManager.Shared.CreateRadioStation(item); if (station != null) { PlaybackManager.Shared.Play(station); } else { App.ShowAlert("Error", "There was an error creating the radio station"); } } catch (Exception ex) { LogManager.Shared.Report(ex); } } }); }
public void ShowNowPlaying(UIView view) { var song = Database.Main.GetObject <Song, TempSong>(Settings.CurrentSong); if (string.IsNullOrWhiteSpace(song?.Id)) { return; } var controller = new ActionSheet(song.Name, song.DetailText); if (ShouldShowPlayVideoButton(song)) { controller.Add("Play Video", () => { PlaybackManager.Shared.PlayNow(song, true); }); } AddNavigateTo(controller, song); AddPlaylistButtons(controller, song); AddShuffleButton(controller, song); AddRadioStationButton(controller, song); AddToLibrary(controller, song); AddRemoveFromLibrary(controller, song); AddOfflineButtons(controller, song); controller.Add("Cancel", null, true); PresentController(controller, view); }
public void ShowActionSheet() { var menuView = new ActionSheet(this); menuView.SetCancelButtonTitle("取消");// before add items menuView.AddItems(new []{ "支付宝", "微信", "财付通", "银联" }); menuView.SetItemClickListener(this); menuView.SetCancelableOnTouchMenuOutside(true); menuView.ShowMenu(); }
static void PresentController(ActionSheet controller, UIView fromView) { var current = GetCurrentViewController(); if (current == null) { return; } controller.Show(current, fromView); }
static void AddShuffleButton(ActionSheet controller, MediaItemBase item) { if (!ShouldShowShuffle(item)) { return; } controller.Add("Shuffle", () => { Settings.ShuffleSongs = true; PlaybackManager.Shared.Play(item); }); }
public override bool StartNotifyActionSheet(string title, string[] buttons, string[] javascriptCallBackFunctions) { using (var pool = new NSAutoreleasePool()) { var thread = new Thread(ShowActionSheet); ActionSheet sheet = new ActionSheet(); sheet.Title = title; sheet.Buttons = buttons; sheet.JsCallbackFunctions = javascriptCallBackFunctions; thread.Start(sheet); } return(true); }
public bool ContainsRow(int index) { if (Range.Contains(_ActionRanges, index)) { return(ActionSheet.ContainsRow(index)); } if (Range.Contains(_CraftActionRanges, index)) { return(CraftActionSheet.ContainsRow(index)); } return(false); }
static void AddRemoveFromLibrary(ActionSheet controller, MediaItemBase item) { if (!ShouldRemoveFromLibrary(item)) { return; } controller.Add("Remove from Library", async() => { var success = await MusicManager.Shared.Delete(item); //TODO: Show Alert Console.WriteLine(success); }); }
public ActionSheet CreateController(MediaItemBase song) { var controller = new ActionSheet(song.Name, song.DetailText); AddPlaybackButtons(controller, song); AddShuffleButton(controller, song); AddPlaylistButtons(controller, song); AddRadioStationButton(controller, song); AddToLibrary(controller, song); AddRemoveFromLibrary(controller, song); AddOfflineButtons(controller, song); controller.Add("Cancel", null, true); return(controller); }
static void AddNavigateTo(ActionSheet controller, MediaItemBase item) { var song = item as Song; if (song == null) { return; } if (!string.IsNullOrWhiteSpace(song.AlbumId)) { controller.Add("Go to Album", () => { NotificationManager.Shared.ProcGoToAlbum(song.AlbumId); }); } controller.Add("Go to Artist", () => { NotificationManager.Shared.ProcGoToArtist(song.ArtistId); }); }
private async Task ShowActionSheet() { var actionSheet = new ActionSheet <int>() { Message = "Message", Title = "Title" }; actionSheet.AddOption("Option1", 1); actionSheet.AddOption("Option2", 2); actionSheet.AddOption("Option3", 3); actionSheet.AddCancel("Cancel"); var result = await dialogsService.ShowActionSheet(actionSheet); if (result != default) { dialogsService.Toast(result.ToString()); } }
static void AddOfflineButtons(ActionSheet controller, MediaItemBase item) { if (item is RadioStation || item is AutoPlaylist) { return; } var song = item as Song; if (song != null) { bool canOffline = song.ServiceTypes.Any(x => AllowedOffLineTypes.Contains(x)); if (!canOffline) { return; } } var localTitle = item.ShouldBeLocal() || item.OfflineCount > 0 ? "Remove from Device" : "Download to Device"; controller.Add(localTitle, () => { OfflineManager.Shared.ToggleOffline(item); }); }
SettingsElement CreateThemePicker(string title) { SettingsElement element = null; element = new SettingsElement(title, () => { var sheet = new ActionSheet("Theme"); MusicPlayer.iOS.Style.AvailableStyles.ForEach(x => sheet.Add(x.Id, () => { Settings.CurrentStyle = x.Id; element.Value = x.Id; })); sheet.Show(this, TableView); }) { style = UITableViewCellStyle.Value1, Value = Settings.CurrentStyle, }; return(element); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button> (Resource.Id.myButton); button.Click += delegate { var actionSheet = new ActionSheet(); actionSheet.Other_Button_Title = new List <string> () { "Option1", "Option2" }; actionSheet.SetActionSheetListener(this); actionSheet.Show(SupportFragmentManager); }; }
private void ShowActionSheet(object sheet) { ActionSheet actionSheet = (ActionSheet)sheet; UIApplication.SharedApplication.InvokeOnMainThread(delegate { if (actionSheet.Title == null) { actionSheet.Title = ""; // null value cannot be passed to UIActionSheet constructor. } string cancelButton = null; string[] buttons = new string[0]; if (IPhoneUtils.GetInstance().IsIPad()) { // For iPad, cancelButton cannot be specified. It has to be included as an "other" button. buttons = actionSheet.Buttons; } else { if (actionSheet.Buttons != null && actionSheet.Buttons.Length > 0) { buttons = new string[actionSheet.Buttons.Length - 1]; cancelButton = actionSheet.Buttons[0]; for (int i = 1; i < actionSheet.Buttons.Length; i++) { buttons[i - 1] = actionSheet.Buttons[i]; } } else { // default cancelButton = "Cancel"; } } UIActionSheet uiSheet = new UIActionSheet(actionSheet.Title, new ActionSheetDelegate(actionSheet.JsCallbackFunctions), cancelButton, null, buttons); uiSheet.ShowInView(IPhoneServiceLocator.CurrentDelegate.MainUIViewController().View); }); }
void ReleaseDesignerOutlets() { if (ActionSheet != null) { ActionSheet.Dispose(); ActionSheet = null; } if (OKAlert != null) { OKAlert.Dispose(); OKAlert = null; } if (OKCancelAlert != null) { OKCancelAlert.Dispose(); OKCancelAlert = null; } if (TextInputAlert != null) { TextInputAlert.Dispose(); TextInputAlert = null; } }
public static void AddPlaylistButtons(ActionSheet controller, MediaItemBase item) { if (!ShouldShowAddPlaylist(item)) { return; } controller.Add("Add to Playlist", async() => { try { var playlistPicker = new PlaylistPickerViewController { FilterBy = item, ShouldHideMenu = true }; PresentController(new UINavigationController(playlistPicker)); var playlist = await playlistPicker.SelectPlaylist(); Console.WriteLine(playlist); using (new Spinner("Adding to Playlist")) { var success = await MusicManager.Shared.AddToPlaylist(item, playlist); if (!success) { App.ShowAlert("Error adding to playlist", "Please try again later"); } } } catch (TaskCanceledException canceledException) { Console.WriteLine("Canceled"); } catch (Exception ex) { App.ShowAlert("Error adding to playlist", "Please try again later"); LogManager.Shared.Report(ex); } }); }
static void AddPlaybackButtons(ActionSheet controller, MediaItemBase item) { if (!ShouldShowQueueButtons(item)) { return; } if (ShouldShowPlayNowButton(item)) { controller.Add("Play", () => { PlaybackManager.Shared.Play(item); }); } if (ShouldShowPlayVideoButton(item)) { controller.Add("Play Video", () => { PlaybackManager.Shared.PlayNow(item as Song, true); }); } controller.Add("Play Next", () => { PlaybackManager.Shared.PlayNext(item); }); controller.Add("Add to Queue", () => { PlaybackManager.Shared.AddtoQueue(item); }); }
public SettingViewController() : base(UITableViewStyle.Plain, null) { Title = Strings.Settings; accountsSection = new MenuSection("Accounts") { (addNewAccountElement = new SettingsElement("Add Streaming Service", async() => { try{ var vc = new ServicePickerViewController(); this.PresentModalViewController(new UINavigationController(vc), true); var service = await vc.GetServiceTypeAsync(); await ApiManager.Shared.CreateAndLogin(service); UpdateAccounts(); } catch (TaskCanceledException) { } catch (Exception ex) { Console.WriteLine(ex); } })), (lastFmElement = string.IsNullOrEmpty(ApiConstants.LastFmApiKey) ? null : new SettingsSwitch("Last.FM", Settings.LastFmEnabled)), (twitterScrobbleElement = new SettingsSwitch("Auto Tweet", Settings.TwitterEnabled) { Detail = Settings.TwitterDisplay }), new SettingsSwitch("Import iPod Music", Settings.IncludeIpod) { ValueUpdated = ToggleIPod }, new MenuHelpTextElement( "Automatically imports and plays music from your local library. This saves data and space on your phone."), }; Root = new RootElement(Strings.Settings) { accountsSection, new MenuSection(Strings.Playback) { new SettingsSwitch(Strings.EnableLikeOnTheLockScreen, Settings.ThubsUpOnLockScreen) { ValueUpdated = (b => { Settings.ThubsUpOnLockScreen = b; RemoteControlHandler.SetupThumbsUp(); }) }, new MenuHelpTextElement(Strings.EnableLikeHint), new SettingsSwitch(Strings.EnableGaplessPlayback, Settings.ThubsUpOnLockScreen) { ValueUpdated = (b => { Settings.ThubsUpOnLockScreen = b; RemoteControlHandler.SetupThumbsUp(); }) }, new MenuHelpTextElement(Strings.EnableGapplessHint), new SettingsSwitch(Strings.PlayVideosWhenAvailable, Settings.PreferVideos) { ValueUpdated = (b => { Settings.PreferVideos = b; }) }, new MenuHelpTextElement(Strings.PlaysMusicVideoHint), new SettingsSwitch(Strings.PlayCleanVersionsOfSongs, Settings.FilterExplicit) { ValueUpdated = (b => { Settings.FilterExplicit = b; }) }, new MenuHelpTextElement(Strings.PlayesCleanVersionOfSongsHint), }, new MenuSection(Strings.Streaming) { new SettingsSwitch(Strings.DisableAllAccess, Settings.DisableAllAccess) { ValueUpdated = (on) => { Settings.DisableAllAccess = on; } }, new MenuHelpTextElement(Strings.DisableAllAccessHint), (CreateQualityPicker(Strings.CellularAudioQuality, Settings.MobileStreamQuality, (q) => Settings.MobileStreamQuality = q)), (CreateQualityPicker(Strings.WifiAudioQuality, Settings.WifiStreamQuality, (q) => Settings.WifiStreamQuality = q)), (CreateQualityPicker(Strings.VideoQuality, Settings.VideoStreamQuality, (q) => Settings.VideoStreamQuality = q)), (CreateQualityPicker(Strings.OfflineAudioQuality, Settings.DownloadStreamQuality, (q) => Settings.DownloadStreamQuality = q)), new MenuHelpTextElement(Strings.QualityHints) }, new MenuSection(Strings.Feedback) { new SettingsElement(Strings.SendFeedback, SendFeedback) { TextColor = iOS.Style.DefaultStyle.MainTextColor }, new SettingsElement($"{Strings.PleaseRate} {AppDelegate.AppName}", RateAppStore) { TextColor = iOS.Style.DefaultStyle.MainTextColor }, (ratingMessage = new MenuHelpTextElement(Strings.NobodyHasRatedYet)) }, new MenuSection(Strings.Settings) { CreateThemePicker("Theme"), new SettingsElement(Strings.ResyncDatabase, () => { Settings.ResetApiModes(); ApiManager.Shared.ReSync(); }), new MenuHelpTextElement(Strings.ResyncDatabaseHint), new SettingsElement(Strings.DownloadQueue, () => NavigationController.PushViewController(new DownloadViewController(), true)), (songsElement = new SettingsElement(Strings.SongsCount)) } }; if (lastFmElement != null) { lastFmElement.ValueUpdated = async b => { if (!b) { Settings.LastFmEnabled = false; ScrobbleManager.Shared.LogOut(); return; } var success = false; try { success = await ScrobbleManager.Shared.LoginToLastFm(); } catch (TaskCanceledException ex) { lastFmElement.Value = Settings.LastFmEnabled = false; TableView.ReloadData(); return; } Settings.LastFmEnabled = success; if (success) { return; } lastFmElement.Value = false; ReloadData(); App.ShowAlert($"{Strings.ErrorLoggingInto} Last.FM", Strings.PleaseTryAgain); }; } twitterScrobbleElement.ValueUpdated = async b => { if (!b) { Settings.TwitterEnabled = false; Settings.TwitterDisplay = ""; Settings.TwitterAccount = ""; twitterScrobbleElement.Detail = ""; return; } var store = new ACAccountStore(); var accountType = store.FindAccountType(ACAccountType.Twitter); var success = false; var result = await store.RequestAccessAsync(accountType); success = result.Item1; if (!success) { Settings.TwitterEnabled = false; twitterScrobbleElement.Value = false; ReloadData(); return; } var accounts = store.FindAccounts(accountType); if ((accounts?.Length ?? 0) == 0) { Settings.TwitterEnabled = false; twitterScrobbleElement.Value = false; ReloadData(); return; } if (accounts?.Length == 1) { Settings.TwitterEnabled = true; var a = accounts[0]; Settings.TwitterAccount = a.Identifier; twitterScrobbleElement.Detail = Settings.TwitterDisplay = a.UserFullName; ReloadData(); return; } var sheet = new ActionSheet("Twitter"); foreach (var a in accounts) { sheet.Add(a.Identifier, () => { Settings.TwitterEnabled = true; Settings.TwitterAccount = a.Identifier; twitterScrobbleElement.Detail = Settings.TwitterDisplay = a.UserFullName; ReloadData(); }); } sheet.Add(Strings.Nevermind, null, true); sheet.Show(this, TableView); }; }
public void onOtherButtonClick(ActionSheet actionSheet, int index) { System.Console.WriteLine(index); }
public void onDismiss(ActionSheet actionSheet, bool isCancel) { System.Console.WriteLine("onDismiss"); }