mirror of
https://github.com/bitwarden/mobile
synced 2025-12-27 05:33:23 +00:00
clear cache and open file on iOS
This commit is contained in:
@@ -5,5 +5,6 @@
|
||||
void CopyToClipboard(string text);
|
||||
bool OpenFile(byte[] fileData, string id, string fileName);
|
||||
bool CanOpenFile(string fileName);
|
||||
void ClearCache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Bit.App
|
||||
private readonly ILocalizeService _localizeService;
|
||||
private readonly IAppInfoService _appInfoService;
|
||||
private readonly IAppSettingsService _appSettingsService;
|
||||
private readonly IDeviceActionService _deviceActionService;
|
||||
|
||||
public App(
|
||||
string uri,
|
||||
@@ -45,7 +46,8 @@ namespace Bit.App
|
||||
IGoogleAnalyticsService googleAnalyticsService,
|
||||
ILocalizeService localizeService,
|
||||
IAppInfoService appInfoService,
|
||||
IAppSettingsService appSettingsService)
|
||||
IAppSettingsService appSettingsService,
|
||||
IDeviceActionService deviceActionService)
|
||||
{
|
||||
_uri = uri;
|
||||
_databaseService = databaseService;
|
||||
@@ -59,6 +61,7 @@ namespace Bit.App
|
||||
_localizeService = localizeService;
|
||||
_appInfoService = appInfoService;
|
||||
_appSettingsService = appSettingsService;
|
||||
_deviceActionService = deviceActionService;
|
||||
|
||||
SetCulture();
|
||||
SetStyles();
|
||||
@@ -110,6 +113,7 @@ namespace Bit.App
|
||||
await Task.Run(() => FullSyncAsync()).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await Task.Run(() => _deviceActionService.ClearCache()).ConfigureAwait(false);
|
||||
Debug.WriteLine("OnStart");
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ namespace Bit.App.Controls
|
||||
Detail = new Label
|
||||
{
|
||||
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
|
||||
LineBreakMode = LineBreakMode.TailTruncation,
|
||||
Style = (Style)Application.Current.Resources["text-muted"],
|
||||
HorizontalOptions = LayoutOptions.End,
|
||||
VerticalOptions = LayoutOptions.Center
|
||||
|
||||
@@ -8,6 +8,7 @@ using Xamarin.Forms;
|
||||
using XLabs.Ioc;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.App.Utilities;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
@@ -38,6 +39,7 @@ namespace Bit.App.Pages
|
||||
public LabeledValueCell UriCell { get; set; }
|
||||
public LabeledValueCell NotesCell { get; set; }
|
||||
private EditLoginToolBarItem EditItem { get; set; }
|
||||
public List<AttachmentViewCell> AttachmentCells { get; set; }
|
||||
|
||||
private void Init()
|
||||
{
|
||||
@@ -108,7 +110,7 @@ namespace Bit.App.Pages
|
||||
Intent = TableIntent.Settings,
|
||||
EnableScrolling = true,
|
||||
HasUnevenRows = true,
|
||||
EnableSelection = false,
|
||||
EnableSelection = true,
|
||||
Root = new TableRoot
|
||||
{
|
||||
LoginInformationSection,
|
||||
@@ -185,6 +187,7 @@ namespace Bit.App.Pages
|
||||
Table.Root.Add(NotesSection);
|
||||
}
|
||||
|
||||
CleanupAttachmentCells();
|
||||
if(!Model.ShowAttachments && Table.Root.Contains(AttachmentsSection))
|
||||
{
|
||||
Table.Root.Remove(AttachmentsSection);
|
||||
@@ -192,12 +195,16 @@ namespace Bit.App.Pages
|
||||
else if(Model.ShowAttachments && !Table.Root.Contains(AttachmentsSection))
|
||||
{
|
||||
AttachmentsSection = new TableSection(AppResources.Attachments);
|
||||
AttachmentCells = new List<AttachmentViewCell>();
|
||||
foreach(var attachment in Model.Attachments)
|
||||
{
|
||||
AttachmentsSection.Add(new AttachmentViewCell(attachment, async () =>
|
||||
var attachmentCell = new AttachmentViewCell(attachment, async () =>
|
||||
{
|
||||
await OpenAttachmentAsync(attachment);
|
||||
}));
|
||||
});
|
||||
AttachmentCells.Add(attachmentCell);
|
||||
AttachmentsSection.Add(attachmentCell);
|
||||
attachmentCell.InitEvents();
|
||||
}
|
||||
Table.Root.Add(AttachmentsSection);
|
||||
}
|
||||
@@ -209,6 +216,18 @@ namespace Bit.App.Pages
|
||||
{
|
||||
NotesCell.Tapped -= NotesCell_Tapped;
|
||||
EditItem.Dispose();
|
||||
CleanupAttachmentCells();
|
||||
}
|
||||
|
||||
private void CleanupAttachmentCells()
|
||||
{
|
||||
if(AttachmentCells != null)
|
||||
{
|
||||
foreach(var cell in AttachmentCells)
|
||||
{
|
||||
cell.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OpenAttachmentAsync(VaultViewLoginPageModel.Attachment attachment)
|
||||
@@ -274,7 +293,7 @@ namespace Bit.App.Pages
|
||||
}
|
||||
}
|
||||
|
||||
public class AttachmentViewCell : LabeledRightDetailCell
|
||||
public class AttachmentViewCell : LabeledRightDetailCell, IDisposable
|
||||
{
|
||||
private readonly Action _tapped;
|
||||
|
||||
@@ -285,9 +304,18 @@ namespace Bit.App.Pages
|
||||
Detail.Text = attachment.SizeName;
|
||||
Icon.Source = "download";
|
||||
BackgroundColor = Color.White;
|
||||
}
|
||||
|
||||
public void InitEvents()
|
||||
{
|
||||
Tapped += AttachmentViewCell_Tapped;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Tapped -= AttachmentViewCell_Tapped;
|
||||
}
|
||||
|
||||
private void AttachmentViewCell_Tapped(object sender, EventArgs e)
|
||||
{
|
||||
_tapped?.Invoke();
|
||||
|
||||
@@ -20,9 +20,9 @@ namespace Bit.App
|
||||
private void Init()
|
||||
{
|
||||
//BaseAddress = new Uri("http://169.254.80.80:4000"); // Desktop from VS Android Emulator
|
||||
BaseAddress = new Uri("http://192.168.1.4:4000"); // Desktop
|
||||
//BaseAddress = new Uri("http://192.168.1.3:4000"); // Desktop
|
||||
//BaseAddress = new Uri("https://preview-api.bitwarden.com"); // Preview
|
||||
// BaseAddress = new Uri("https://api.bitwarden.com"); // Production
|
||||
BaseAddress = new Uri("https://api.bitwarden.com"); // Production
|
||||
DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ namespace Bit.App
|
||||
private void Init()
|
||||
{
|
||||
//BaseAddress = new Uri("http://169.254.80.80:33656"); // Desktop from VS Android Emulator
|
||||
BaseAddress = new Uri("http://192.168.1.4:33656"); // Desktop
|
||||
//BaseAddress = new Uri("http://192.168.1.3:33656"); // Desktop
|
||||
//BaseAddress = new Uri("https://identity-api.bitwarden.com"); // Preview
|
||||
//BaseAddress = new Uri("https://identity.bitwarden.com"); // Production
|
||||
BaseAddress = new Uri("https://identity.bitwarden.com"); // Production
|
||||
DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user