fixed file selection workflow for FTP/HTTP

This commit is contained in:
Philipp Crocoll 2013-10-07 07:11:47 +02:00
parent 6f22ad012e
commit 4da67d42c0
10 changed files with 33 additions and 30 deletions

View File

@ -20,7 +20,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>False</Optimize> <Optimize>False</Optimize>
<OutputPath>bin\Debug</OutputPath> <OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;INCLUDE_TWOFISH;INCLUDE_KEYBOARD;INCLUDE_KEYTRANSFORM;INCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE</DefineConstants> <DefineConstants>DEBUG;EXCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_KEYTRANSFORM;EXCLUDE_FILECHOOSER;EXCLUDE_JAVAFILESTORAGE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause> <ConsolePause>False</ConsolePause>

View File

@ -20,7 +20,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;INCLUDE_TWOFISH;INCLUDE_KEYBOARD;INCLUDE_KEYTRANSFORM;INCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE</DefineConstants> <DefineConstants>TRACE;DEBUG;EXCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_KEYTRANSFORM;EXCLUDE_FILECHOOSER;EXCLUDE_JAVAFILESTORAGE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>

View File

@ -35,7 +35,7 @@ public class Utils {
public static boolean doLog() public static boolean doLog()
{ {
return true; return false;
//return BuildConfig.DEBUG; //not working with Mono for Android //return BuildConfig.DEBUG; //not working with Mono for Android
} }

View File

@ -278,7 +278,7 @@ namespace keepass2android
confirmButton.Click += (sender, e) => confirmButton.Click += (sender, e) =>
{ {
App.Kp2a.GetFileStorage(_ioConnection) App.Kp2a.GetFileStorage(_ioConnection)
.PrepareFileUsage(new FileStorageSetupInitiatorActivity(this, OnActivityResult), _ioConnection, 0); .PrepareFileUsage(new FileStorageSetupInitiatorActivity(this, OnActivityResult, null), _ioConnection, 0);
}; };
/*CheckBox checkBox = (CheckBox) FindViewById(Resource.Id.show_password); /*CheckBox checkBox = (CheckBox) FindViewById(Resource.Id.show_password);

View File

@ -337,9 +337,9 @@
<string name="ChangeLog_title">Change log</string> <string name="ChangeLog_title">Change log</string>
<string name="ChangeLog_0_9"> <string name="ChangeLog_0_9">
<b>Version 0.9</b>\n <b>Version 0.9 preview</b>\n
* Support for Dropbox (Keepass2Android regular edition only)\n * Integrated Dropbox support (read/write databases; Keepass2Android regular edition only)\n
* Integrated custom filechooser (based on android-filechooser by HBA) * Integrated custom file browser (based on android-filechooser by HBA)
</string> </string>

View File

@ -148,7 +148,7 @@ namespace keepass2android
{ {
const string fileProviderAuthority = "keepass2android.keepass2android.android-filechooser.localfile"; const string fileProviderAuthority = "keepass2android.keepass2android.android-filechooser.localfile";
#if !EXCLUDE_FILECHOOSER
Intent i = Keepass2android.Kp2afilechooser.Kp2aFileChooserBridge.GetLaunchFileChooserIntent(act, Intent i = Keepass2android.Kp2afilechooser.Kp2aFileChooserBridge.GetLaunchFileChooserIntent(act,
fileProviderAuthority, fileProviderAuthority,
defaultPath); defaultPath);
@ -156,6 +156,9 @@ namespace keepass2android
i.PutExtra("group.pals.android.lib.ui.filechooser.FileChooserActivity.save_dialog", true); i.PutExtra("group.pals.android.lib.ui.filechooser.FileChooserActivity.save_dialog", true);
act.StartActivityForResult(i, requestCodeBrowse); act.StartActivityForResult(i, requestCodeBrowse);
#else
Toast.MakeText(act, "File Chooser excluded!",ToastLength.Long).Show();
#endif
} }
public static string IntentToFilename(Intent data, Context ctx) public static string IntentToFilename(Intent data, Context ctx)

View File

@ -445,7 +445,7 @@ namespace keepass2android
if (resultCode == KeePass.ExitFileStorageSelectionOk) if (resultCode == KeePass.ExitFileStorageSelectionOk)
{ {
#if !EXCLUDE_FILECHOOSER
string protocolId = data.GetStringExtra("protocolId"); string protocolId = data.GetStringExtra("protocolId");
if (protocolId == "androidget") if (protocolId == "androidget")
@ -456,18 +456,16 @@ namespace keepass2android
} }
else else
{ {
App.Kp2a.GetFileStorage(protocolId).StartSelectFile(new FileStorageSetupInitiatorActivity(this, OnActivityResult), false, 0, protocolId); App.Kp2a.GetFileStorage(protocolId).StartSelectFile(new FileStorageSetupInitiatorActivity(this,
OnActivityResult,
defaultPath =>
{
ShowFilenameDialog(true, false, false, defaultPath, GetString(Resource.String.enter_filename_details_url),
Intents.RequestCodeFileBrowseForOpen);
}
), false, 0, protocolId);
} }
#else
Toast.MakeText(this, "TODO: make this more flexible.", ToastLength.Long).Show();
IOConnectionInfo ioc = new IOConnectionInfo
{
Path = Environment.ExternalStorageDirectory+"/keepass/keepass.kdbx"
};
LaunchPasswordActivityForIoc(ioc);
#endif
} }
@ -515,7 +513,7 @@ namespace keepass2android
#endif #endif
} }
} }
#if !EXCLUDE_FILECHOOSER
private void StartFileChooser(string defaultPath) private void StartFileChooser(string defaultPath)
{ {
Kp2aLog.Log("FSA: defaultPath="+defaultPath); Kp2aLog.Log("FSA: defaultPath="+defaultPath);
@ -531,7 +529,7 @@ namespace keepass2android
StartActivityForResult(i, Intents.RequestCodeFileBrowseForOpen); StartActivityForResult(i, Intents.RequestCodeFileBrowseForOpen);
} }
#endif
protected override void OnResume() protected override void OnResume()
{ {
base.OnResume(); base.OnResume();

View File

@ -10,16 +10,14 @@ using Android.Runtime;
using Android.Views; using Android.Views;
using Android.Widget; using Android.Widget;
using KeePassLib.Serialization; using KeePassLib.Serialization;
using Keepass2android.Javafilestorage;
using keepass2android.Io; using keepass2android.Io;
using JavaFileStorage = Keepass2android.Javafilestorage.JavaFileStorage;
namespace keepass2android.fileselect namespace keepass2android.fileselect
{ {
[Activity(Label = "@string/filestorage_setup_title",Theme="@style/Base")] [Activity(Label = "@string/filestorage_setup_title",Theme="@style/Base")]
public class FileStorageSetupActivity : Activity, IFileStorageSetupActivity public class FileStorageSetupActivity : Activity, IFileStorageSetupActivity
#if !EXCLUDE_JAVAFILESTORAGE #if !EXCLUDE_JAVAFILESTORAGE
,IJavaFileStorageFileStorageSetupActivity ,Keepass2android.Javafilestorage.IJavaFileStorageFileStorageSetupActivity
#endif #endif
{ {
protected override void OnCreate(Bundle bundle) protected override void OnCreate(Bundle bundle)

View File

@ -2,7 +2,6 @@ using System;
using Android.App; using Android.App;
using Android.Content; using Android.Content;
using KeePassLib.Serialization; using KeePassLib.Serialization;
using Keepass2android.Javafilestorage;
using keepass2android.Io; using keepass2android.Io;
using keepass2android.fileselect; using keepass2android.fileselect;
@ -11,17 +10,22 @@ namespace keepass2android
public class FileStorageSetupInitiatorActivity: public class FileStorageSetupInitiatorActivity:
#if !EXCLUDE_JAVAFILESTORAGE #if !EXCLUDE_JAVAFILESTORAGE
Java.Lang.Object Java.Lang.Object
,IJavaFileStorageFileStorageSetupInitiatorActivity ,Keepass2android.Javafilestorage.IJavaFileStorageFileStorageSetupInitiatorActivity
,
#endif #endif
, IFileStorageSetupInitiatorActivity IFileStorageSetupInitiatorActivity
{ {
private readonly Activity _activity; private readonly Activity _activity;
private readonly Action<int, Result, Intent> _onActivityResult; private readonly Action<int, Result, Intent> _onActivityResult;
private readonly Action<string> _startManualFileSelect;
public FileStorageSetupInitiatorActivity(Activity activity, Action<int,Result,Intent> onActivityResult) public FileStorageSetupInitiatorActivity(Activity activity,
Action<int,Result,Intent> onActivityResult,
Action<String> startManualFileSelect)
{ {
_activity = activity; _activity = activity;
_onActivityResult = onActivityResult; _onActivityResult = onActivityResult;
_startManualFileSelect = startManualFileSelect;
} }
public void StartSelectFileProcess(IOConnectionInfo ioc, bool isForSave, int requestCode) public void StartSelectFileProcess(IOConnectionInfo ioc, bool isForSave, int requestCode)
@ -60,7 +64,7 @@ namespace keepass2android
public void PerformManualFileSelect(bool isForSave, int requestCode, string protocolId) public void PerformManualFileSelect(bool isForSave, int requestCode, string protocolId)
{ {
throw new NotImplementedException(); _startManualFileSelect(protocolId + "://");
} }
public void StartFileUsageProcess(string p0, int p1) public void StartFileUsageProcess(string p0, int p1)

View File

@ -24,7 +24,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>False</Optimize> <Optimize>False</Optimize>
<OutputPath>bin\Debug</OutputPath> <OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;INCLUDE_TWOFISH;INCLUDE_KEYBOARD;INCLUDE_KEYTRANSFORM;INCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE</DefineConstants> <DefineConstants>DEBUG;EXCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_KEYTRANSFORM;EXCLUDE_FILECHOOSER;EXCLUDE_JAVAFILESTORAGE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause> <ConsolePause>False</ConsolePause>