Compare commits
3 Commits
target-sdk
...
bug-2378-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3ae3233fe | ||
|
|
bc464b0eba | ||
|
|
c9be806b01 |
@@ -3,14 +3,15 @@ using Android.Content;
|
||||
|
||||
namespace keepass2android.Io
|
||||
{
|
||||
public partial class PCloudFileStorage: JavaFileStorage
|
||||
public class PCloudFileStorage: JavaFileStorage
|
||||
{
|
||||
private const string ClientId = "CkRWTQXY6Lm";
|
||||
|
||||
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
|
||||
@@ -18,6 +19,23 @@ namespace keepass2android.Io
|
||||
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
|
||||
Binary file not shown.
BIN
src/PCloudBindings/Jars/pcloud-sdk-android-1.8.1.aar
Normal file
BIN
src/PCloudBindings/Jars/pcloud-sdk-android-1.8.1.aar
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/PCloudBindings/Jars/pcloud-sdk-java-core-1.8.1.jar
Normal file
BIN
src/PCloudBindings/Jars/pcloud-sdk-java-core-1.8.1.jar
Normal file
Binary file not shown.
@@ -56,7 +56,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="Jars\AboutJars.txt" />
|
||||
<None Include="Additions\AboutAdditions.txt" />
|
||||
<LibraryProjectZip Include="Jars\pcloud-sdk-android-1.2.0.aar" />
|
||||
<LibraryProjectZip Include="Jars\pcloud-sdk-android-1.8.1.aar" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TransformFile Include="Transforms\Metadata.xml" />
|
||||
@@ -72,6 +72,6 @@
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<EmbeddedReferenceJar Include="Jars\pcloud-sdk-java-core-1.2.0.jar" />
|
||||
<EmbeddedReferenceJar Include="Jars\pcloud-sdk-java-core-1.8.1.jar" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -47,8 +47,8 @@ dependencies {
|
||||
implementation('com.onedrive.sdk:onedrive-sdk-android:1.2.0') {
|
||||
transitive = false
|
||||
}
|
||||
implementation 'com.pcloud.sdk:java-core:1.2.0'
|
||||
implementation 'com.pcloud.sdk:android:1.2.0'
|
||||
implementation 'com.pcloud.sdk:java-core:1.8.1'
|
||||
implementation 'com.pcloud.sdk:android:1.8.1'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
implementation 'com.microsoft.services.msa:msa-auth:0.8.6'
|
||||
implementation 'com.microsoft.aad:adal:1.14.0'
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.pcloud.sdk.ApiError;
|
||||
import com.pcloud.sdk.Authenticators;
|
||||
import com.pcloud.sdk.AuthorizationActivity;
|
||||
import com.pcloud.sdk.AuthorizationData;
|
||||
import com.pcloud.sdk.AuthorizationRequest;
|
||||
import com.pcloud.sdk.AuthorizationResult;
|
||||
import com.pcloud.sdk.Call;
|
||||
import com.pcloud.sdk.DataSource;
|
||||
@@ -47,11 +48,19 @@ public class PCloudFileStorage extends JavaFileStorageBase
|
||||
|
||||
private ApiClient apiClient;
|
||||
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.clientId = clientId;
|
||||
this.protocolId = protocolId;
|
||||
this.sharedPrefPrefix = sharedPrefPrefix;
|
||||
|
||||
this.apiClient = createApiClientFromSharedPrefs();
|
||||
android.util.Log.d("KP2A", "Init pcloud with protocol " + protocolId + ", prefix=" + sharedPrefPrefix + ", clientId=" + clientId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,7 +95,8 @@ public class PCloudFileStorage extends JavaFileStorageBase
|
||||
|
||||
@Override
|
||||
public String getProtocolId() {
|
||||
return "pcloud";
|
||||
|
||||
return protocolId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,11 +238,17 @@ public class PCloudFileStorage extends JavaFileStorageBase
|
||||
finishActivityWithSuccess(activity);
|
||||
} else if (!activity.getState().getBoolean("hasStartedAuth", false)) {
|
||||
Activity castedActivity = (Activity)activity;
|
||||
Intent authIntent = AuthorizationActivity.createIntent(castedActivity, this.clientId);
|
||||
AuthorizationRequest req = AuthorizationRequest.create()
|
||||
.setClientId(this.clientId)
|
||||
.setType(AuthorizationRequest.Type.TOKEN)
|
||||
.setForceAccessApproval(true)
|
||||
.build();
|
||||
Intent authIntent = AuthorizationActivity.createIntent(castedActivity, req);
|
||||
castedActivity.startActivityForResult(authIntent, PCLOUD_AUTHORIZATION_REQUEST_CODE);
|
||||
activity.getState().putBoolean("hasStartedAuth", true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -273,7 +289,7 @@ public class PCloudFileStorage extends JavaFileStorageBase
|
||||
}
|
||||
|
||||
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 apiHost = prefs.getString(SHARED_PREF_API_HOST, null);
|
||||
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_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="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="filestoragename_pcloudall">PCloud (Full access)</string>
|
||||
<string name="filestoragename_onedrive">OneDrive</string>
|
||||
<string name="filestoragename_onedrive2">OneDrive</string>
|
||||
<string name="filestoragename_onedrive2_full">All files and shared files</string>
|
||||
|
||||
@@ -751,7 +751,8 @@ namespace keepass2android
|
||||
new NetFtpFileStorage(LocaleManager.LocalizedAppContext, this),
|
||||
new WebDavFileStorage(this),
|
||||
new PCloudFileStorage(LocaleManager.LocalizedAppContext, this),
|
||||
new MegaFileStorage(App.Context),
|
||||
new PCloudFileStorageAll(LocaleManager.LocalizedAppContext, this),
|
||||
new MegaFileStorage(App.Context),
|
||||
//new LegacyWebDavStorage(this),
|
||||
//new LegacyFtpStorage(this),
|
||||
#endif
|
||||
|
||||
@@ -1979,6 +1979,12 @@
|
||||
<SubType>Designer</SubType>
|
||||
</AndroidResource>
|
||||
</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" />
|
||||
<!-- 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.
|
||||
|
||||
Reference in New Issue
Block a user