mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-11-14 21:45:14 -05:00
add better support for OwnCloud (less typing required when selecting a file)
This commit is contained in:
parent
0afe1f97ff
commit
7378e19f99
@ -252,7 +252,7 @@ namespace keepass2android.Io
|
||||
return _jfs.RequiresSetup(IocToPath(ioConnection));
|
||||
}
|
||||
|
||||
public void StartSelectFile(IFileStorageSetupInitiatorActivity activity, bool isForSave, int requestCode, string protocolId)
|
||||
public virtual void StartSelectFile(IFileStorageSetupInitiatorActivity activity, bool isForSave, int requestCode, string protocolId)
|
||||
{
|
||||
Kp2aLog.Log("StartSelectFile " + protocolId);
|
||||
_jfs.StartSelectFile((IJavaFileStorageFileStorageSetupInitiatorActivity) activity, isForSave, requestCode);
|
||||
|
@ -136,6 +136,8 @@ namespace keepass2android
|
||||
ShowFtpDialog(_activity, ReturnFileOrStartFileChooser, ReturnCancel);
|
||||
else if ((defaultPath.StartsWith("http://")) || (defaultPath.StartsWith("https://")))
|
||||
ShowHttpDialog(_activity, ReturnFileOrStartFileChooser, ReturnCancel, defaultPath);
|
||||
else if (defaultPath.StartsWith("owncloud://"))
|
||||
ShowOwncloudDialog(_activity, ReturnFileOrStartFileChooser, ReturnCancel, defaultPath);
|
||||
else
|
||||
{
|
||||
Func<string, Dialog, bool> onOpen = OnOpenButton;
|
||||
@ -151,6 +153,38 @@ namespace keepass2android
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowOwncloudDialog(Activity activity, Util.FileSelectedHandler onStartBrowse, Action onCancel, string defaultPath)
|
||||
{
|
||||
#if !EXCLUDE_JAVAFILESTORAGE && !NoNet
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
View dlgContents = activity.LayoutInflater.Inflate(Resource.Layout.owncloudcredentials, null);
|
||||
builder.SetView(dlgContents);
|
||||
builder.SetPositiveButton(Android.Resource.String.Ok,
|
||||
(sender, args) =>
|
||||
{
|
||||
string host = dlgContents.FindViewById<EditText>(Resource.Id.owncloud_url).Text;
|
||||
|
||||
string user = dlgContents.FindViewById<EditText>(Resource.Id.http_user).Text;
|
||||
string password = dlgContents.FindViewById<EditText>(Resource.Id.http_password).Text;
|
||||
|
||||
string scheme = defaultPath.Substring(defaultPath.IndexOf("://", StringComparison.Ordinal));
|
||||
if (host.Contains("://") == false)
|
||||
host = scheme + "://" + host;
|
||||
string httpPath = new Keepass2android.Javafilestorage.WebDavStorage(null).BuildFullPath(WebDavFileStorage.Owncloud2Webdav(host), user,
|
||||
password);
|
||||
onStartBrowse(httpPath);
|
||||
});
|
||||
EventHandler<DialogClickEventArgs> evtH = new EventHandler<DialogClickEventArgs>((sender, e) => onCancel());
|
||||
|
||||
builder.SetNegativeButton(Android.Resource.String.Cancel, evtH);
|
||||
builder.SetTitle(activity.GetString(Resource.String.enter_owncloud_login_title));
|
||||
Dialog dialog = builder.Create();
|
||||
|
||||
dialog.Show();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
private bool ReturnFileOrStartFileChooser(string filename)
|
||||
{
|
||||
int lastSlashPos = filename.LastIndexOf('/');
|
||||
|
@ -474,6 +474,10 @@
|
||||
<string name="enter_http_login_title">Enter WebDav login data:</string>
|
||||
<string name="hint_http_url">URL of folder or file (ex: mycloud.me.com/webdav/)</string>
|
||||
|
||||
|
||||
<string name="enter_owncloud_login_title">Enter OwnCloud login data:</string>
|
||||
<string name="hint_owncloud_url">OwnCloud URL (ex: owncloud.me.com)</string>
|
||||
|
||||
<string name="hint_sftp_host">host (ex: 192.168.0.1)</string>
|
||||
<string name="hint_sftp_port">port</string>
|
||||
<string name="initial_directory">Initial directory (optional):</string>
|
||||
@ -491,7 +495,8 @@
|
||||
<string name="filestoragename_ftp">FTP</string>
|
||||
<string name="filestoragename_http">HTTP (WebDav)</string>
|
||||
<string name="filestoragename_https">HTTPS (WebDav)</string>
|
||||
<string name="filestoragename_dropbox">Dropbox</string>
|
||||
<string name="filestoragename_owncloud">OwnCloud</string>
|
||||
<string name="filestoragename_dropbox">Dropbox</string>
|
||||
<string name="filestoragename_dropboxKP2A">Dropbox (KP2A folder)</string>
|
||||
<string name="filestoragehelp_dropboxKP2A">If you do not want to give KP2A access to your full Dropbox, you may select this option. It will request only access to the folder Apps/Keepass2Android. This is especially suited when creating a new database. If you already have a database, click this option to create the folder, then place your file inside the folder (from your PC) and then select this option again for opening the file.</string>
|
||||
<string name="filestoragename_gdrive">Google Drive</string>
|
||||
|
@ -1706,6 +1706,9 @@
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\owncloudcredentials.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
<Import Project="..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets" Condition="Exists('..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
Loading…
Reference in New Issue
Block a user