introduce file storage for pcloud with access to all files. current implementation doesn't work in my tests.
This commit is contained in:
@@ -3,14 +3,15 @@ using Android.Content;
|
|||||||
|
|
||||||
namespace keepass2android.Io
|
namespace keepass2android.Io
|
||||||
{
|
{
|
||||||
public partial class PCloudFileStorage: JavaFileStorage
|
public class PCloudFileStorage: JavaFileStorage
|
||||||
{
|
{
|
||||||
private const string ClientId = "CkRWTQXY6Lm";
|
private const string ClientId = "CkRWTQXY6Lm";
|
||||||
|
|
||||||
public PCloudFileStorage(Context ctx, IKp2aApp app) :
|
public PCloudFileStorage(Context ctx, IKp2aApp app) :
|
||||||
base(new Keepass2android.Javafilestorage.PCloudFileStorage(ctx, ClientId), app)
|
base(new Keepass2android.Javafilestorage.PCloudFileStorage(ctx, ClientId, "pcloud", ""), app)
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override bool UserShouldBackup
|
public override bool UserShouldBackup
|
||||||
@@ -18,6 +19,23 @@ namespace keepass2android.Io
|
|||||||
get { return false; }
|
get { return false; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public class PCloudFileStorageAll : JavaFileStorage
|
||||||
|
{
|
||||||
|
private const string ClientId = "FLm22de7bdS";
|
||||||
|
|
||||||
|
public PCloudFileStorageAll(Context ctx, IKp2aApp app) :
|
||||||
|
base(new Keepass2android.Javafilestorage.PCloudFileStorage(ctx, ClientId, "pcloudall", "PCLOUDALL_"), app)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool UserShouldBackup
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -48,11 +48,19 @@ public class PCloudFileStorage extends JavaFileStorageBase
|
|||||||
|
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
private String clientId;
|
private String clientId;
|
||||||
|
private String protocolId;
|
||||||
|
|
||||||
public PCloudFileStorage(Context ctx, String clientId) {
|
///prefix for SHARED_PREF keys so we can distinguish between different instances
|
||||||
|
private String sharedPrefPrefix;
|
||||||
|
|
||||||
|
public PCloudFileStorage(Context ctx, String clientId, String protocolId, String sharedPrefPrefix) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
|
this.protocolId = protocolId;
|
||||||
|
this.sharedPrefPrefix = sharedPrefPrefix;
|
||||||
|
|
||||||
this.apiClient = createApiClientFromSharedPrefs();
|
this.apiClient = createApiClientFromSharedPrefs();
|
||||||
|
android.util.Log.d("KP2A", "Init pcloud with protocol " + protocolId + ", prefix=" + sharedPrefPrefix + ", clientId=" + clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -87,7 +95,8 @@ public class PCloudFileStorage extends JavaFileStorageBase
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProtocolId() {
|
public String getProtocolId() {
|
||||||
return "pcloud";
|
|
||||||
|
return protocolId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -239,6 +248,7 @@ public class PCloudFileStorage extends JavaFileStorageBase
|
|||||||
activity.getState().putBoolean("hasStartedAuth", true);
|
activity.getState().putBoolean("hasStartedAuth", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -279,7 +289,7 @@ public class PCloudFileStorage extends JavaFileStorageBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ApiClient createApiClientFromSharedPrefs() {
|
private ApiClient createApiClientFromSharedPrefs() {
|
||||||
SharedPreferences prefs = this.ctx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
|
SharedPreferences prefs = this.ctx.getSharedPreferences(sharedPrefPrefix + SHARED_PREF_NAME, Context.MODE_PRIVATE);
|
||||||
String authToken = prefs.getString(SHARED_PREF_AUTH_TOKEN, null);
|
String authToken = prefs.getString(SHARED_PREF_AUTH_TOKEN, null);
|
||||||
String apiHost = prefs.getString(SHARED_PREF_API_HOST, null);
|
String apiHost = prefs.getString(SHARED_PREF_API_HOST, null);
|
||||||
return this.createApiClient(authToken, apiHost);
|
return this.createApiClient(authToken, apiHost);
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 554 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
@@ -614,8 +614,9 @@
|
|||||||
<string name="filestoragename_gdrive">Google Drive</string>
|
<string name="filestoragename_gdrive">Google Drive</string>
|
||||||
<string name="filestoragename_gdriveKP2A">Google Drive (KP2A files)</string>
|
<string name="filestoragename_gdriveKP2A">Google Drive (KP2A files)</string>
|
||||||
<string name="filestoragehelp_gdriveKP2A">If you do not want to give KP2A access to your full Google Drive, you may select this option. Note that you need to create a database file first, existing files are not visible to the app. Either choose this option from the Create database screen or, if you already opened a database, by exporting the database choosing this option.</string>
|
<string name="filestoragehelp_gdriveKP2A">If you do not want to give KP2A access to your full Google Drive, you may select this option. Note that you need to create a database file first, existing files are not visible to the app. Either choose this option from the Create database screen or, if you already opened a database, by exporting the database choosing this option.</string>
|
||||||
<string name="filestoragename_pcloud">PCloud</string>
|
<string name="filestoragename_pcloud">PCloud (KP2A folder)</string>
|
||||||
<string name="filestoragehelp_pcloud">This storage type will only request access to the pCloud folder "Applications/Keepass2Android". If you want to use an existing database from your pCloud account, please make sure the file is placed in this pCloud folder.</string>
|
<string name="filestoragehelp_pcloud">This storage type will only request access to the pCloud folder "Applications/Keepass2Android". If you want to use an existing database from your pCloud account, please make sure the file is placed in this pCloud folder.</string>
|
||||||
|
<string name="filestoragename_pcloudall">PCloud (Full access)</string>
|
||||||
<string name="filestoragename_onedrive">OneDrive</string>
|
<string name="filestoragename_onedrive">OneDrive</string>
|
||||||
<string name="filestoragename_onedrive2">OneDrive</string>
|
<string name="filestoragename_onedrive2">OneDrive</string>
|
||||||
<string name="filestoragename_onedrive2_full">All files and shared files</string>
|
<string name="filestoragename_onedrive2_full">All files and shared files</string>
|
||||||
|
|||||||
@@ -751,7 +751,8 @@ namespace keepass2android
|
|||||||
new NetFtpFileStorage(LocaleManager.LocalizedAppContext, this),
|
new NetFtpFileStorage(LocaleManager.LocalizedAppContext, this),
|
||||||
new WebDavFileStorage(this),
|
new WebDavFileStorage(this),
|
||||||
new PCloudFileStorage(LocaleManager.LocalizedAppContext, this),
|
new PCloudFileStorage(LocaleManager.LocalizedAppContext, this),
|
||||||
new MegaFileStorage(App.Context),
|
new PCloudFileStorageAll(LocaleManager.LocalizedAppContext, this),
|
||||||
|
new MegaFileStorage(App.Context),
|
||||||
//new LegacyWebDavStorage(this),
|
//new LegacyWebDavStorage(this),
|
||||||
//new LegacyFtpStorage(this),
|
//new LegacyFtpStorage(this),
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1979,6 +1979,12 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</AndroidResource>
|
</AndroidResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\drawable-xhdpi\ic_storage_pcloudall.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\drawable-mdpi\ic_storage_pcloudall.png" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
Reference in New Issue
Block a user