1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-20 17:33:15 +00:00

Revert "Add Share app Extension on iOS for Send (#1647)" (#1655)

This reverts commit 75ed72f91b.
This commit is contained in:
Federico Maccaroni
2021-11-19 17:00:54 -03:00
committed by GitHub
parent 75ed72f91b
commit 7d42d19ae3
30 changed files with 132 additions and 1357 deletions

View File

@@ -21,7 +21,6 @@ namespace Bit.App.Models
public string SaveCardCode { get; set; }
public bool IosExtension { get; set; }
public Tuple<SendType, string, byte[], string> CreateSend { get; set; }
public bool CopyInsteadOfShareAfterSaving { get; set; }
public void SetAllFrom(AppOptions o)
{
@@ -45,7 +44,6 @@ namespace Bit.App.Models
SaveCardCode = o.SaveCardCode;
IosExtension = o.IosExtension;
CreateSend = o.CreateSend;
CopyInsteadOfShareAfterSaving = o.CopyInsteadOfShareAfterSaving;
}
}
}

View File

@@ -234,10 +234,9 @@
Margin="10,0,0,0" />
</StackLayout>
</StackLayout>
<StackLayout
StyleClass="box-row, box-row-switch">
<StackLayout StyleClass="box-row, box-row-switch">
<Label
Text="{Binding ShareOnSaveText}"
Text="{u:I18n ShareOnSave}"
StyleClass="box-label-regular"
VerticalOptions="Center"
HorizontalOptions="StartAndExpand" />

View File

@@ -7,9 +7,6 @@ using Bit.App.Utilities;
using Bit.Core.Abstractions;
using Bit.Core.Enums;
using Bit.Core.Utilities;
#if !FDROID
using Microsoft.AppCenter.Crashes;
#endif
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
@@ -25,9 +22,6 @@ namespace Bit.App.Pages
private AppOptions _appOptions;
private SendAddEditPageViewModel _vm;
public Action OnClose { get; set; }
public Action AfterSubmit { get; set; }
public SendAddEditPage(
AppOptions appOptions = null,
string sendId = null,
@@ -88,66 +82,42 @@ namespace Bit.App.Pages
protected override async void OnAppearing()
{
base.OnAppearing();
try
if (!await AppHelpers.IsVaultTimeoutImmediateAsync())
{
if (!await AppHelpers.IsVaultTimeoutImmediateAsync())
await _vaultTimeoutService.CheckVaultTimeoutAsync();
}
if (await _vaultTimeoutService.IsLockedAsync())
{
return;
}
await _vm.InitAsync();
_broadcasterService.Subscribe(nameof(SendAddEditPage), message =>
{
if (message.Command == "selectFileResult")
{
await _vaultTimeoutService.CheckVaultTimeoutAsync();
Device.BeginInvokeOnMainThread(() =>
{
var data = message.Data as Tuple<byte[], string>;
_vm.FileData = data.Item1;
_vm.FileName = data.Item2;
});
}
if (await _vaultTimeoutService.IsLockedAsync())
});
await LoadOnAppearedAsync(_scrollView, true, async () =>
{
var success = await _vm.LoadAsync();
if (!success)
{
await Navigation.PopModalAsync();
return;
}
await _vm.InitAsync();
_broadcasterService.Subscribe(nameof(SendAddEditPage), message =>
await HandleCreateRequest();
if (!_vm.EditMode && string.IsNullOrWhiteSpace(_vm.Send?.Name))
{
if (message.Command == "selectFileResult")
{
Device.BeginInvokeOnMainThread(() =>
{
var data = message.Data as Tuple<byte[], string>;
_vm.FileData = data.Item1;
_vm.FileName = data.Item2;
});
}
});
await LoadOnAppearedAsync(_scrollView, true, async () =>
{
var success = await _vm.LoadAsync();
if (!success)
{
await CloseAsync();
return;
}
await HandleCreateRequest();
if (!_vm.EditMode && string.IsNullOrWhiteSpace(_vm.Send?.Name))
{
RequestFocus(_nameEntry);
}
AdjustToolbar();
});
}
catch (Exception ex)
{
#if !FDROID
Crashes.TrackError(ex);
#endif
await CloseAsync();
}
}
private async Task CloseAsync()
{
if (OnClose is null)
{
await Navigation.PopModalAsync();
}
else
{
OnClose();
}
RequestFocus(_nameEntry);
}
AdjustToolbar();
});
}
protected override bool OnBackButtonPressed()
@@ -230,11 +200,7 @@ namespace Bit.App.Pages
{
if (DoOnce())
{
var submitted = await _vm.SubmitAsync();
if (submitted)
{
AfterSubmit?.Invoke();
}
await _vm.SubmitAsync();
}
}
@@ -268,7 +234,7 @@ namespace Bit.App.Pages
{
if (await _vm.DeleteAsync())
{
await CloseAsync();
await Navigation.PopModalAsync();
}
}
}
@@ -308,7 +274,7 @@ namespace Bit.App.Pages
{
if (await _vm.DeleteAsync())
{
await CloseAsync();
await Navigation.PopModalAsync();
}
}
}
@@ -317,7 +283,7 @@ namespace Bit.App.Pages
{
if (DoOnce())
{
await CloseAsync();
await Navigation.PopModalAsync();
}
}
@@ -340,7 +306,6 @@ namespace Bit.App.Pages
}
_vm.IsAddFromShare = true;
_vm.CopyInsteadOfShareAfterSaving = _appOptions.CopyInsteadOfShareAfterSaving;
var name = _appOptions.CreateSend.Item2;
_vm.Send.Name = name;

View File

@@ -9,9 +9,6 @@ using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Models.View;
using Bit.Core.Utilities;
#if !FDROID
using Microsoft.AppCenter.Crashes;
#endif
using Xamarin.Essentials;
using Xamarin.Forms;
@@ -48,7 +45,6 @@ namespace Bit.App.Pages
};
private bool _disableHideEmail;
private bool _sendOptionsPolicyInEffect;
private bool _copyInsteadOfShareAfterSaving;
public SendAddEditPageViewModel()
{
@@ -100,16 +96,6 @@ namespace Bit.App.Pages
public bool ShareOnSave { get; set; }
public bool DisableHideEmailControl { get; set; }
public bool IsAddFromShare { get; set; }
public bool CopyInsteadOfShareAfterSaving
{
get => _copyInsteadOfShareAfterSaving;
set
{
SetProperty(ref _copyInsteadOfShareAfterSaving, value);
TriggerPropertyChanged(nameof(ShareOnSaveText));
}
}
public string ShareOnSaveText => CopyInsteadOfShareAfterSaving ? AppResources.CopySendLinkOnSave : AppResources.ShareOnSave;
public List<KeyValuePair<string, SendType>> TypeOptions { get; }
public List<KeyValuePair<string, string>> DeletionTypeOptions { get; }
public List<KeyValuePair<string, string>> ExpirationTypeOptions { get; }
@@ -410,36 +396,25 @@ namespace Bit.App.Pages
EditMode ? AppResources.SendUpdated : AppResources.NewSendCreated);
}
if (!CopyInsteadOfShareAfterSaving)
if (IsAddFromShare && Device.RuntimePlatform == Device.Android)
{
await CloseAsync();
_deviceActionService.CloseMainApp();
}
else
{
await Page.Navigation.PopModalAsync();
}
if (ShareOnSave)
{
var savedSend = await _sendService.GetAsync(sendId);
if (savedSend != null)
{
var savedSendView = await savedSend.DecryptAsync();
if (CopyInsteadOfShareAfterSaving)
{
await AppHelpers.CopySendUrlAsync(savedSendView);
// wait so that the user sees the message before the view gets dismissed
await Task.Delay(1300);
}
else
{
await AppHelpers.ShareSendUrlAsync(savedSendView);
}
await AppHelpers.ShareSendUrlAsync(savedSendView);
}
}
if (CopyInsteadOfShareAfterSaving)
{
await CloseAsync();
}
return true;
}
catch (ApiException e)
@@ -451,37 +426,9 @@ namespace Bit.App.Pages
AppResources.AnErrorHasOccurred);
}
}
catch (Exception ex)
{
await _deviceActionService.HideLoadingAsync();
#if !FDROID
Crashes.TrackError(ex);
#endif
await _platformUtilsService.ShowDialogAsync(AppResources.AnErrorHasOccurred);
}
return false;
}
private async Task CloseAsync()
{
if (IsAddFromShare)
{
if (Device.RuntimePlatform == Device.Android)
{
_deviceActionService.CloseMainApp();
return;
}
if (Page is SendAddEditPage sendPage && sendPage.OnClose != null)
{
sendPage.OnClose();
return;
}
}
await Page.Navigation.PopModalAsync();
}
public async Task<bool> RemovePasswordAsync()
{
return await AppHelpers.RemoveSendPasswordAsync(SendId);
@@ -507,7 +454,14 @@ namespace Bit.App.Pages
if (!SendEnabled)
{
await _platformUtilsService.ShowDialogAsync(AppResources.SendDisabledWarning);
await CloseAsync();
if (IsAddFromShare && Device.RuntimePlatform == Device.Android)
{
_deviceActionService.CloseMainApp();
}
else
{
await Page.Navigation.PopModalAsync();
}
return;
}
if (Send != null)

View File

@@ -3724,11 +3724,5 @@ namespace Bit.App.Resources {
return ResourceManager.GetString("Sending", resourceCulture);
}
}
public static string CopySendLinkOnSave {
get {
return ResourceManager.GetString("CopySendLinkOnSave", resourceCulture);
}
}
}
}

View File

@@ -2090,16 +2090,10 @@
<data name="InvalidVerificationCode" xml:space="preserve">
<value>Invalid Verification Code.</value>
</data>
<data name="RequestOTP" xml:space="preserve">
<value>Request one-time password</value>
</data>
<data name="SendCode" xml:space="preserve">
<value>Send Code</value>
</data>
<data name="Sending" xml:space="preserve">
<value>Sending</value>
</data>
<data name="CopySendLinkOnSave" xml:space="preserve">
<value>Copy Send link on save</value>
</data>
</root>