private void ExtraAction(PowerAction action) { switch (action) { case PowerAction.PowerUp: case PowerAction.PowerDown: var powerUpOrDownFrag = new PowerUpDownFragment(Presenter.Balances[_walletPager.CurrentItem], action); powerUpOrDownFrag.SetTargetFragment(this, WalletFragmentPowerUpOrDownRequestCode); ((BaseActivity)Activity).OpenNewContentFragment(powerUpOrDownFrag); break; case PowerAction.CancelPowerDown: var alertAction = new ActionAlertDialog(Activity, string.Format(AppSettings.LocalizationManager.GetText(LocalizationKeys.CancelPowerDownAlert), Presenter.Balances[_walletPager.CurrentItem].ToWithdraw.ToBalanceValueString()), string.Empty, AppSettings.LocalizationManager.GetText(LocalizationKeys.Yes), AppSettings.LocalizationManager.GetText(LocalizationKeys.No), AutoLinkAction); alertAction.AlertAction += () => { var userInfo = Presenter.Balances[_walletPager.CurrentItem].UserInfo; if (string.IsNullOrEmpty(userInfo.ActiveKey)) { var intent = new Intent(Activity, typeof(ActiveSignInActivity)); intent.PutExtra(ActiveSignInActivity.ActiveSignInUserName, userInfo.Login); intent.PutExtra(ActiveSignInActivity.ActiveSignInChain, (int)userInfo.Chain); StartActivityForResult(intent, ActiveSignInActivity.ActiveKeyRequestCode); return; } CancelPowerDown(); }; alertAction.Show(); break; } }
private void PowerBtnOnClick(object sender, EventArgs e) { if (_powerAmount <= 0) { return; } if (string.IsNullOrEmpty(_balance.UserInfo.ActiveKey)) { var intent = new Intent(Activity, typeof(ActiveSignInActivity)); intent.PutExtra(ActiveSignInActivity.ActiveSignInUserName, _balance.UserInfo.Login); intent.PutExtra(ActiveSignInActivity.ActiveSignInChain, (int)_balance.UserInfo.Chain); StartActivityForResult(intent, ActiveSignInActivity.ActiveKeyRequestCode); return; } var doPowerConfirmation = AppSettings.LocalizationManager.GetText(LocalizationKeys.PowerUpDownConfirmation, _powerActionText.ToLower(), _powerAmount, _balance.CurrencyType); var actionAlert = new ActionAlertDialog(Context, doPowerConfirmation, AppSettings.LocalizationManager.GetText(string.Empty), AppSettings.LocalizationManager.GetText(LocalizationKeys.Yes), AppSettings.LocalizationManager.GetText(LocalizationKeys.No), AutoLinkAction, Orientation.Vertical); actionAlert.AlertAction += DoPowerAction; actionAlert.Show(); }
private async void PostAction(ActionType type, Post post) { switch (type) { case ActionType.Like: { if (!AppSettings.User.HasPostingPermission) { return; } var exception = await Presenter.TryVote(post); if (!IsInitialized) { return; } if (exception == null && Activity is RootActivity root) { root.TryUpdateProfile(); } Context.ShowAlert(exception); break; } case ActionType.VotersLikes: case ActionType.VotersFlags: { if (post == null) { return; } var isLikers = type == ActionType.VotersLikes; Activity.Intent.PutExtra(PostUrlExtraPath, post.Url); Activity.Intent.PutExtra(PostNetVotesExtraPath, isLikers ? post.NetLikes : post.NetFlags); Activity.Intent.PutExtra(VotersFragment.VotersType, isLikers); ((BaseActivity)Activity).OpenNewContentFragment(new VotersFragment()); break; } case ActionType.Comments: { if (post == null) { return; } ((BaseActivity)Activity).OpenNewContentFragment(new CommentsFragment(post, post.Children == 0)); break; } case ActionType.Profile: { if (post == null) { return; } ((BaseActivity)Activity).OpenNewContentFragment(new ProfileFragment(post.Author)); break; } case ActionType.Flag: { if (!AppSettings.User.HasPostingPermission) { return; } var exception = await Presenter.TryFlag(post); if (!IsInitialized) { return; } if (exception == null && Activity is RootActivity root) { root.TryUpdateProfile(); } Context.ShowAlert(exception); break; } case ActionType.Hide: { Presenter.HidePost(post); break; } case ActionType.Delete: { var actionAlert = new ActionAlertDialog(Context, AppSettings.LocalizationManager.GetText(LocalizationKeys.DeleteAlertTitle), AppSettings.LocalizationManager.GetText(LocalizationKeys.DeleteAlertMessage), AppSettings.LocalizationManager.GetText(LocalizationKeys.Delete), AppSettings.LocalizationManager.GetText(LocalizationKeys.Cancel), AutoLinkAction); actionAlert.AlertAction += async() => { var exception = await Presenter.TryDeletePost(post); if (!IsInitialized) { return; } Context.ShowAlert(exception); }; actionAlert.Show(); break; } case ActionType.Share: { var shareIntent = new Intent(Intent.ActionSend); shareIntent.SetType("text/plain"); shareIntent.PutExtra(Intent.ExtraSubject, post.Title); shareIntent.PutExtra(Intent.ExtraText, string.Format(AppSettings.User.Chain == KnownChains.Steem ? Constants.SteemPostUrl : Constants.GolosPostUrl, post.Url)); StartActivity(Intent.CreateChooser(shareIntent, AppSettings.LocalizationManager.GetText(LocalizationKeys.Sharepost))); break; } case ActionType.Photo: { OpenPost(post); break; } case ActionType.Promote: { var actionAlert = new PromoteAlertDialog(Context, post, AutoLinkAction); actionAlert.Window.RequestFeature(WindowFeatures.NoTitle); actionAlert.Show(); break; } } }
private async void CommentAction(ActionType type, Post post) { switch (type) { case ActionType.Like: { if (AppSettings.User.HasPostingPermission) { var exception = await Presenter.TryVote(post); if (!IsInitialized) { return; } Context.ShowAlert(exception, ToastLength.Short); } else { var intent = new Intent(Context, typeof(WelcomeActivity)); StartActivity(intent); } break; } case ActionType.Profile: { if (post == null) { return; } if (AppSettings.User.Login != post.Author) { ((BaseActivity)Activity).OpenNewContentFragment(new ProfileFragment(post.Author)); } break; } case ActionType.VotersLikes: case ActionType.VotersFlags: { if (post == null) { return; } var isLikers = type == ActionType.VotersLikes; Activity.Intent.PutExtra(PostUrlExtraPath, post.Url.Substring(post.Url.LastIndexOf("@", StringComparison.Ordinal))); Activity.Intent.PutExtra(PostNetVotesExtraPath, isLikers ? post.NetLikes : post.NetFlags); Activity.Intent.PutExtra(VotersFragment.VotersType, isLikers); ((BaseActivity)Activity).OpenNewContentFragment(new VotersFragment()); break; } case ActionType.Flag: { if (AppSettings.User.HasPostingPermission) { var exception = await Presenter.TryFlag(post); if (!IsInitialized) { return; } Context.ShowAlert(exception, ToastLength.Short); } else { var intent = new Intent(Context, typeof(WelcomeActivity)); StartActivity(intent); } break; } case ActionType.Hide: { Presenter.HidePost(post); break; } case ActionType.Reply: { if (post == null) { return; } if (!_textInput.Text.StartsWith($"@{post.Author}")) { _textInput.Text = $"@{post.Author} {_textInput.Text}"; _textInput.SetSelection(_textInput.Text.Length); } OpenKeyboard(); break; } case ActionType.Edit: { _editComment = post; _editComment.Editing = true; _textInput.Text = post.Body; _textInput.SetSelection(post.Body.Length); _textInputShape.SetColor(Style.R254G249B229); _textInput.Background = _textInputShape; _editControls.Visibility = ViewStates.Visible; _postBtn.Visibility = ViewStates.Gone; _rootLayout.ViewTreeObserver.GlobalLayout += ViewTreeObserverOnGlobalLayout; OpenKeyboard(); break; } case ActionType.Delete: { var actionAlert = new ActionAlertDialog(Activity, AppSettings.LocalizationManager.GetText(LocalizationKeys.DeleteAlertTitle), AppSettings.LocalizationManager.GetText(LocalizationKeys.DeleteAlertMessage), AppSettings.LocalizationManager.GetText(LocalizationKeys.Delete), AppSettings.LocalizationManager.GetText(LocalizationKeys.Cancel), AutoLinkAction); actionAlert.AlertAction += async() => { var exception = await Presenter.TryDeleteComment(post, _post); if (!IsInitialized) { return; } Context.ShowAlert(exception); }; actionAlert.Show(); break; } } }