mirror of
https://github.com/bitwarden/mobile
synced 2025-12-13 06:43:17 +00:00
Add Share app Extension on iOS for Send (re-PR) (#1660)
* WIP Add Share app extension on iOS for Send * Added Share app extension on iOS for Send and some code fixes as well * Updated iOS csprojs configs to linkskip the new extension project and also added AdHoc and AppStore configurations to iOS.ShareExtension.csproj * Code clean up and transformed bundle resources into links to the already used pngs of the main iOS project on ShareExtension * Updated build.yml to include provisioning profile for iOS Share extension * Adding in the missing provisioning profile * Removed .DS_Store from the iOS.ShareExtension csproj Resources * switching out the share extension profile * Added Share extension provisioning profile configuration on export options app store for github and also removed custom info.plist config for localhost which is not necessary * Moved property so that it's grouped with the full ones * Added AppCenter Crashes package to Core and updated FireAndForget Task Extension * Updated bundle reference of FontAwesome.ttf to bwi-font.ttf in order for it to compile on ShareExtension Co-authored-by: Joseph Flinn <joseph.s.flinn@gmail.com> Co-authored-by: Álison Fernandes <vvolkgang@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
ef6184a05b
commit
f8a7eb4c94
@@ -10,6 +10,9 @@ 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;
|
||||
|
||||
@@ -46,6 +49,7 @@ namespace Bit.App.Pages
|
||||
};
|
||||
private bool _disableHideEmail;
|
||||
private bool _sendOptionsPolicyInEffect;
|
||||
private bool _copyInsteadOfShareAfterSaving;
|
||||
|
||||
public SendAddEditPageViewModel()
|
||||
{
|
||||
@@ -97,6 +101,7 @@ namespace Bit.App.Pages
|
||||
public bool ShareOnSave { get; set; }
|
||||
public bool DisableHideEmailControl { get; set; }
|
||||
public bool IsAddFromShare { get; set; }
|
||||
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; }
|
||||
@@ -175,6 +180,15 @@ namespace Bit.App.Pages
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool CopyInsteadOfShareAfterSaving
|
||||
{
|
||||
get => _copyInsteadOfShareAfterSaving;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _copyInsteadOfShareAfterSaving, value);
|
||||
TriggerPropertyChanged(nameof(ShareOnSaveText));
|
||||
}
|
||||
}
|
||||
public SendView Send
|
||||
{
|
||||
get => _send;
|
||||
@@ -397,25 +411,36 @@ namespace Bit.App.Pages
|
||||
EditMode ? AppResources.SendUpdated : AppResources.NewSendCreated);
|
||||
}
|
||||
|
||||
if (IsAddFromShare && Device.RuntimePlatform == Device.Android)
|
||||
if (!CopyInsteadOfShareAfterSaving)
|
||||
{
|
||||
_deviceActionService.CloseMainApp();
|
||||
await CloseAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await Page.Navigation.PopModalAsync();
|
||||
}
|
||||
|
||||
|
||||
if (ShareOnSave)
|
||||
{
|
||||
var savedSend = await _sendService.GetAsync(sendId);
|
||||
if (savedSend != null)
|
||||
{
|
||||
var savedSendView = await savedSend.DecryptAsync();
|
||||
await AppHelpers.ShareSendUrlAsync(savedSendView);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (CopyInsteadOfShareAfterSaving)
|
||||
{
|
||||
await CloseAsync();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (ApiException e)
|
||||
@@ -427,9 +452,37 @@ 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);
|
||||
@@ -455,14 +508,7 @@ namespace Bit.App.Pages
|
||||
if (!SendEnabled)
|
||||
{
|
||||
await _platformUtilsService.ShowDialogAsync(AppResources.SendDisabledWarning);
|
||||
if (IsAddFromShare && Device.RuntimePlatform == Device.Android)
|
||||
{
|
||||
_deviceActionService.CloseMainApp();
|
||||
}
|
||||
else
|
||||
{
|
||||
await Page.Navigation.PopModalAsync();
|
||||
}
|
||||
await CloseAsync();
|
||||
return;
|
||||
}
|
||||
if (Send != null)
|
||||
|
||||
Reference in New Issue
Block a user