diff --git a/src/AndroidFileChooserBinding/AndroidFileChooserBinding.csproj b/src/AndroidFileChooserBinding/AndroidFileChooserBinding.csproj index 3b3be243..3fe01d37 100644 --- a/src/AndroidFileChooserBinding/AndroidFileChooserBinding.csproj +++ b/src/AndroidFileChooserBinding/AndroidFileChooserBinding.csproj @@ -55,8 +55,8 @@ - - Jars\app-debug.aar + + Jars\android-filechooser-release.aar diff --git a/src/JavaFileStorageBindings/JavaFileStorageBindings.csproj b/src/JavaFileStorageBindings/JavaFileStorageBindings.csproj index dd77e6e9..7ca7564e 100644 --- a/src/JavaFileStorageBindings/JavaFileStorageBindings.csproj +++ b/src/JavaFileStorageBindings/JavaFileStorageBindings.csproj @@ -64,8 +64,8 @@ - - Jars\app-debug.aar + + Jars\JavaFileStorage-debug.aar @@ -75,81 +75,6 @@ - - - Jars\json_simple-1.1.jar - - - - - Jars\google-api-client-1.16.0-rc.jar - - - - - Jars\google-api-client-android-1.16.0-rc.jar - - - - - Jars\google-api-services-drive-v2-rev102-1.16.0-rc.jar - - - - - Jars\google-http-client-1.16.0-rc.jar - - - - - Jars\google-http-client-android-1.16.0-rc.jar - - - - - Jars\google-http-client-gson-1.16.0-rc.jar - - - - - Jars\google-http-client-jackson-1.16.0-rc.jar - - - - - Jars\google-http-client-jackson2-1.16.0-rc.jar - - - - - Jars\google-oauth-client-1.16.0-rc.jar - - - - - Jars\gson-2.1.jar - - - - - Jars\httpmime-4.0.3.jar - - - - - Jars\jackson-core-2.1.3.jar - - - - - Jars\jackson-core-asl-1.9.11.jar - - - - - Jars\jsr305-1.3.9.jar - - - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/src/Kp2aBusinessLogic/IKp2aApp.cs b/src/Kp2aBusinessLogic/IKp2aApp.cs index 0c92c942..ce6f00a4 100644 --- a/src/Kp2aBusinessLogic/IKp2aApp.cs +++ b/src/Kp2aBusinessLogic/IKp2aApp.cs @@ -9,6 +9,7 @@ using KeePassLib; using KeePassLib.Keys; using KeePassLib.Serialization; using keepass2android.Io; +using Keepass2android.Javafilestorage; namespace keepass2android { @@ -28,7 +29,7 @@ namespace keepass2android /// Interface through which Activities and the logic layer can access some app specific functionalities and Application static data /// /// This also contains methods which are UI specific and should be replacable for testing. - public interface IKp2aApp: ICertificateValidationHandler + public interface IKp2aApp : ICertificateValidationHandler { /// /// Locks the currently open database, quicklocking if available (unless false is passed for allowQuickUnlock) @@ -106,5 +107,6 @@ namespace keepass2android bool CheckForDuplicateUuids { get; } + ICertificateErrorHandler CertificateErrorHandler { get; } } } \ No newline at end of file diff --git a/src/Kp2aBusinessLogic/Io/DropboxFileStorage.cs b/src/Kp2aBusinessLogic/Io/DropboxFileStorage.cs index 20dd1ecf..e4b3e774 100644 --- a/src/Kp2aBusinessLogic/Io/DropboxFileStorage.cs +++ b/src/Kp2aBusinessLogic/Io/DropboxFileStorage.cs @@ -6,7 +6,7 @@ namespace keepass2android.Io public partial class DropboxFileStorage: JavaFileStorage { public DropboxFileStorage(Context ctx, IKp2aApp app) : - base(new Keepass2android.Javafilestorage.DropboxFileStorage(ctx, AppKey, AppSecret), app) + base(new Keepass2android.Javafilestorage.DropboxV2Storage(ctx, AppKey, AppSecret), app) { } @@ -16,7 +16,7 @@ namespace keepass2android.Io public partial class DropboxAppFolderFileStorage: JavaFileStorage { public DropboxAppFolderFileStorage(Context ctx, IKp2aApp app) : - base(new Keepass2android.Javafilestorage.DropboxAppFolderFileStorage(ctx, AppKey, AppSecret), app) + base(new Keepass2android.Javafilestorage.DropboxV2AppFolderStorage(ctx, AppKey, AppSecret), app) { } diff --git a/src/Kp2aBusinessLogic/Io/JavaFileStorage.cs b/src/Kp2aBusinessLogic/Io/JavaFileStorage.cs index fa584281..716d47f9 100644 --- a/src/Kp2aBusinessLogic/Io/JavaFileStorage.cs +++ b/src/Kp2aBusinessLogic/Io/JavaFileStorage.cs @@ -21,7 +21,7 @@ namespace keepass2android.Io { protected string Protocol { get { return _jfs.ProtocolId; } } - public IEnumerable SupportedProtocols { get { yield return Protocol; } } + public virtual IEnumerable SupportedProtocols { get { yield return Protocol; } } private readonly IJavaFileStorage _jfs; diff --git a/src/Kp2aBusinessLogic/Io/SkyDriveFileStorage.cs b/src/Kp2aBusinessLogic/Io/SkyDriveFileStorage.cs deleted file mode 100644 index 663036fe..00000000 --- a/src/Kp2aBusinessLogic/Io/SkyDriveFileStorage.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; - -using Android.App; -using Android.Content; -using Android.OS; -using Android.Runtime; -using Android.Views; -using Android.Widget; -using KeePassLib.Serialization; -#if !EXCLUDE_JAVAFILESTORAGE -using Keepass2android.Javafilestorage; - -namespace keepass2android.Io -{ - public class SkyDriveFileStorage: JavaFileStorage - { - private const string ClientId = "000000004010C234"; - - public SkyDriveFileStorage(Context ctx, IKp2aApp app) : - base(new Keepass2android.Javafilestorage.SkyDriveFileStorage(ClientId, ctx), app) - { - } - - - } -} -#endif \ No newline at end of file diff --git a/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj b/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj index 0ff26287..015203d8 100644 --- a/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj +++ b/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj @@ -96,7 +96,8 @@ - + + diff --git a/src/java/JavaFileStorage/app/build.gradle b/src/java/JavaFileStorage/app/build.gradle index 0874801c..fb7b28f1 100644 --- a/src/java/JavaFileStorage/app/build.gradle +++ b/src/java/JavaFileStorage/app/build.gradle @@ -33,14 +33,14 @@ dependencies { compile 'com.google.android.gms:play-services:4.0.30' - compile('com.google.api-client:google-api-client-xml:1.17.0-rc') { + /* compile('com.google.api-client:google-api-client-xml:1.16.0-rc') { + exclude group: 'com.google.android.google-play-services' + }*/ + compile 'com.google.http-client:google-http-client-gson:1.16.0-rc' + compile('com.google.api-client:google-api-client-android:1.16.0-rc') { exclude group: 'com.google.android.google-play-services' } - compile 'com.google.http-client:google-http-client-gson:1.17.0-rc' - compile('com.google.api-client:google-api-client-android:1.17.0-rc') { - exclude group: 'com.google.android.google-play-services' - } - compile 'com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc' + compile 'com.google.apis:google-api-services-drive:v2-rev102-1.16.0-rc' //compile 'com.dropbox.core:dropbox-core-sdk:2.0.1' //compile group: 'com.dropbox.core', name: 'dropbox-core-sdk', version: '0-SNAPSHOT', changing: true @@ -52,7 +52,6 @@ dependencies { compile ('com.onedrive.sdk:onedrive-sdk-android:1.2+') { transitive = false } - // Include the gson dependency compile ('com.google.code.gson:gson:2.3.1') compile ('com.microsoft.services.msa:msa-auth:0.8.+') compile ('com.microsoft.aad:adal:1.1.+') diff --git a/src/java/JavaFileStorage/app/libs/commons-logging-1.1.1.jar b/src/java/JavaFileStorage/app/libs/commons-logging-1.1.1.jar deleted file mode 100644 index 8758a96b..00000000 Binary files a/src/java/JavaFileStorage/app/libs/commons-logging-1.1.1.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/dropbox-android-sdk-1.6.2.jar b/src/java/JavaFileStorage/app/libs/dropbox-android-sdk-1.6.2.jar deleted file mode 100644 index 997663e8..00000000 Binary files a/src/java/JavaFileStorage/app/libs/dropbox-android-sdk-1.6.2.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/google-api-client-1.16.0-rc.jar b/src/java/JavaFileStorage/app/libs/google-api-client-1.16.0-rc.jar deleted file mode 100644 index 4097d1bf..00000000 Binary files a/src/java/JavaFileStorage/app/libs/google-api-client-1.16.0-rc.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/google-api-client-android-1.16.0-rc.jar b/src/java/JavaFileStorage/app/libs/google-api-client-android-1.16.0-rc.jar deleted file mode 100644 index f938da9e..00000000 Binary files a/src/java/JavaFileStorage/app/libs/google-api-client-android-1.16.0-rc.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/google-api-services-drive-v2-rev102-1.16.0-rc.jar b/src/java/JavaFileStorage/app/libs/google-api-services-drive-v2-rev102-1.16.0-rc.jar deleted file mode 100644 index 5baa6abc..00000000 Binary files a/src/java/JavaFileStorage/app/libs/google-api-services-drive-v2-rev102-1.16.0-rc.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/google-http-client-1.16.0-rc.jar b/src/java/JavaFileStorage/app/libs/google-http-client-1.16.0-rc.jar deleted file mode 100644 index e10f42d4..00000000 Binary files a/src/java/JavaFileStorage/app/libs/google-http-client-1.16.0-rc.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/google-http-client-android-1.16.0-rc.jar b/src/java/JavaFileStorage/app/libs/google-http-client-android-1.16.0-rc.jar deleted file mode 100644 index 447db5e9..00000000 Binary files a/src/java/JavaFileStorage/app/libs/google-http-client-android-1.16.0-rc.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/google-http-client-jackson-1.16.0-rc.jar b/src/java/JavaFileStorage/app/libs/google-http-client-jackson-1.16.0-rc.jar deleted file mode 100644 index 411d2238..00000000 Binary files a/src/java/JavaFileStorage/app/libs/google-http-client-jackson-1.16.0-rc.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/google-http-client-jackson2-1.16.0-rc.jar b/src/java/JavaFileStorage/app/libs/google-http-client-jackson2-1.16.0-rc.jar deleted file mode 100644 index 23175261..00000000 Binary files a/src/java/JavaFileStorage/app/libs/google-http-client-jackson2-1.16.0-rc.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/google-oauth-client-1.16.0-rc.jar b/src/java/JavaFileStorage/app/libs/google-oauth-client-1.16.0-rc.jar deleted file mode 100644 index fb07f9be..00000000 Binary files a/src/java/JavaFileStorage/app/libs/google-oauth-client-1.16.0-rc.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/httpclient-4.0.3.jar b/src/java/JavaFileStorage/app/libs/httpclient-4.0.3.jar deleted file mode 100644 index fd0d3774..00000000 Binary files a/src/java/JavaFileStorage/app/libs/httpclient-4.0.3.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/httpcore-4.0.1.jar b/src/java/JavaFileStorage/app/libs/httpcore-4.0.1.jar deleted file mode 100644 index 4638daa5..00000000 Binary files a/src/java/JavaFileStorage/app/libs/httpcore-4.0.1.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/httpmime-4.0.3.jar b/src/java/JavaFileStorage/app/libs/httpmime-4.0.3.jar deleted file mode 100644 index 0dfd3312..00000000 Binary files a/src/java/JavaFileStorage/app/libs/httpmime-4.0.3.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/jackson-core-2.1.3.jar b/src/java/JavaFileStorage/app/libs/jackson-core-2.1.3.jar deleted file mode 100644 index f47619f4..00000000 Binary files a/src/java/JavaFileStorage/app/libs/jackson-core-2.1.3.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/jackson-core-asl-1.9.11.jar b/src/java/JavaFileStorage/app/libs/jackson-core-asl-1.9.11.jar deleted file mode 100644 index 145fc489..00000000 Binary files a/src/java/JavaFileStorage/app/libs/jackson-core-asl-1.9.11.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/json_simple-1.1.jar b/src/java/JavaFileStorage/app/libs/json_simple-1.1.jar deleted file mode 100644 index f395f414..00000000 Binary files a/src/java/JavaFileStorage/app/libs/json_simple-1.1.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/libs/jsr305-1.3.9.jar b/src/java/JavaFileStorage/app/libs/jsr305-1.3.9.jar deleted file mode 100644 index a9afc661..00000000 Binary files a/src/java/JavaFileStorage/app/libs/jsr305-1.3.9.jar and /dev/null differ diff --git a/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/OneDriveStorage.java b/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/OneDriveStorage.java index d329f26f..6a97617f 100644 --- a/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/OneDriveStorage.java +++ b/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/OneDriveStorage.java @@ -63,7 +63,7 @@ public class OneDriveStorage extends JavaFileStorageBase @Override public void startSelectFile(FileStorageSetupInitiatorActivity activity, boolean isForSave, int requestCode) { - initAuthenticator((Activity)activity); + initAuthenticator((Activity)activity.getActivity()); String path = getProtocolId()+":///"; Log.d("KP2AJ", "startSelectFile "+path+", connected: "+path); @@ -113,8 +113,8 @@ public class OneDriveStorage extends JavaFileStorageBase @Override public void prepareFileUsage(FileStorageSetupInitiatorActivity activity, String path, int requestCode, boolean alwaysReturnSuccess) { - initAuthenticator((Activity)activity); - if (isConnected((Activity)activity)) + initAuthenticator((Activity)activity.getActivity()); + if (isConnected((Activity)activity.getActivity())) { Intent intent = new Intent(); intent.putExtra(EXTRA_PATH, path); @@ -151,58 +151,7 @@ public class OneDriveStorage extends JavaFileStorageBase @Override public void onResume(final FileStorageSetupActivity activity) { - Log.d("KP2AJ", "onResume"); - if (activity.getProcessName().equals(PROCESS_NAME_SELECTFILE)) - activity.getState().putString(EXTRA_PATH, activity.getPath()); - JavaFileStorage.FileStorageSetupActivity storageSetupAct = activity; - - if (storageSetupAct.getState().containsKey("hasStartedAuth")) - { - Log.d("KP2AJ", "auth started"); - - - if (oneDriveClient != null) { - Log.d("KP2AJ", "auth successful"); - try { - - finishActivityWithSuccess(activity); - return; - - } catch (Exception e) { - Log.d("KP2AJ", "finish with error: " + e.toString()); - finishWithError(activity, e); - return; - } - } - - - Log.i(TAG, "authenticating not succesful"); - Intent data = new Intent(); - data.putExtra(EXTRA_ERROR_MESSAGE, "authenticating not succesful"); - ((Activity)activity).setResult(Activity.RESULT_CANCELED, data); - ((Activity)activity).finish(); - } - else - { - Log.d("KP2AJ", "Starting auth"); - new AsyncTask() { - - @Override - protected Object doInBackground(Object... params) { - return buildClient((Activity)activity); - } - - @Override - protected void onPostExecute(Object o) { - oneDriveClient = (IOneDriveClient) o; - finishActivityWithSuccess(activity); - - } - }.execute(); - storageSetupAct.getState().putBoolean("hasStartedAuth", true); - - } } @@ -375,8 +324,63 @@ public class OneDriveStorage extends JavaFileStorageBase } @Override - public void onStart(FileStorageSetupActivity activity) { + public void onStart(final FileStorageSetupActivity activity) { + Log.d("KP2AJ", "onStart"); + if (activity.getProcessName().equals(PROCESS_NAME_SELECTFILE)) + activity.getState().putString(EXTRA_PATH, activity.getPath()); + JavaFileStorage.FileStorageSetupActivity storageSetupAct = activity; + + if (oneDriveClient != null) { + Log.d("KP2AJ", "auth successful"); + try { + + finishActivityWithSuccess(activity); + return; + + } catch (Exception e) { + Log.d("KP2AJ", "finish with error: " + e.toString()); + finishWithError(activity, e); + return; + } + } + + + { + Log.d("KP2AJ", "Starting auth"); + new AsyncTask() { + + @Override + protected Object doInBackground(Object... params) { + try { + return buildClient((Activity) activity); + } catch (Exception e) { + return null; + } + } + + @Override + protected void onPostExecute(Object o) { + if (o == null) + { + Log.i(TAG, "authenticating not successful"); + Intent data = new Intent(); + data.putExtra(EXTRA_ERROR_MESSAGE, "authenticating not succesful"); + ((Activity)activity).setResult(Activity.RESULT_CANCELED, data); + ((Activity)activity).finish(); + + } + else + { + Log.i(TAG, "authenticating successful"); + + oneDriveClient = (IOneDriveClient) o; + finishActivityWithSuccess(activity); + } + } + }.execute(); + + } } @Override diff --git a/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/WebDavStorage.java b/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/WebDavStorage.java index 6f07f0e0..27d1a0b2 100644 --- a/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/WebDavStorage.java +++ b/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/WebDavStorage.java @@ -22,7 +22,6 @@ import java.security.KeyManagementException; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -36,6 +35,7 @@ import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; +import keepass2android.javafilestorage.webdav.ConnectionInfo; import keepass2android.javafilestorage.webdav.DecoratedTrustManager; import keepass2android.javafilestorage.webdav.PropfindXmlParser; import keepass2android.javafilestorage.webdav.WebDavUtil; @@ -61,12 +61,6 @@ public class WebDavStorage extends JavaFileStorageBase { return scheme + "://" + encode(username)+":"+encode(password)+"@"+url; } - static class ConnectionInfo { - String URL; - String username; - String password; - } - private ConnectionInfo splitStringToConnectionInfo(String filename) throws UnsupportedEncodingException { ConnectionInfo ci = new ConnectionInfo(); diff --git a/src/java/android-filechooser-AS/.idea/workspace.xml b/src/java/android-filechooser-AS/.idea/workspace.xml index 4058d83b..ba6987b0 100644 --- a/src/java/android-filechooser-AS/.idea/workspace.xml +++ b/src/java/android-filechooser-AS/.idea/workspace.xml @@ -30,21 +30,41 @@ - + - + - + - - + + + + + + + + + + + + + + + + + + + + + + @@ -71,6 +91,8 @@ @@ -106,8 +128,8 @@ - + @@ -115,10 +137,24 @@ + + + + + - + @@ -363,7 +399,7 @@ - + @@ -379,11 +415,11 @@ - + - + @@ -419,6 +455,14 @@ + + + + + + + + @@ -426,7 +470,7 @@ - + @@ -452,8 +496,80 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/FragmentFiles.java b/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/FragmentFiles.java index 4bb609f3..c5167a44 100644 --- a/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/FragmentFiles.java +++ b/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/FragmentFiles.java @@ -1022,6 +1022,7 @@ public class FragmentFiles extends Fragment implements * showCannotConnectToServiceAndWaitForTheUserToFinish(). */ String errMsg = null; + boolean errorMessageInDialog = false; @Override protected Bundle doInBackground(Void... params) { @@ -1031,46 +1032,77 @@ public class FragmentFiles extends Fragment implements Uri path = (Uri) (savedInstanceState != null ? savedInstanceState .getParcelable(CURRENT_LOCATION) : null); + if (mRoot != null) { + Uri queryUri = BaseFile.genContentUriApi(mRoot.getAuthority()) + .buildUpon() + .appendPath(BaseFile.CMD_CHECK_CONNECTION) + .appendQueryParameter( + BaseFile.PARAM_SOURCE, + mRoot.getLastPathSegment()).build(); + Cursor cursor = getActivity().getContentResolver().query( + queryUri, + null, null, null, null); + if (cursor != null) { + cursor.moveToFirst(); + + errMsg = getString(R.string.afc_msg_cannot_connect_to_file_provider_service) + " " + cursor.getString(0); + errorMessageInDialog = true; + return null; + } + + } + + try + { /* * Selected file */ - if (path == null) { - path = (Uri) getArguments().getParcelable( - FileChooserActivity.EXTRA_SELECT_FILE); - if (path != null - && BaseFileProviderUtils.fileExists(getActivity(), - path)) - path = BaseFileProviderUtils.getParentFile( - getActivity(), path); - } + if (path == null) { + path = (Uri) getArguments().getParcelable( + FileChooserActivity.EXTRA_SELECT_FILE); + + if (path != null + && BaseFileProviderUtils.fileExists(getActivity(), + path)) + path = BaseFileProviderUtils.getParentFile( + getActivity(), path); + } /* * Rootpath */ - if (path == null - || !BaseFileProviderUtils.isDirectory(getActivity(), - path)) { - path = mRoot; - } + if (path == null + || !BaseFileProviderUtils.isDirectory(getActivity(), + path)) { + path = mRoot; + } /* * Last location */ - if (path == null - && DisplayPrefs.isRememberLastLocation(getActivity())) { - String lastLocation = DisplayPrefs - .getLastLocation(getActivity()); - if (lastLocation != null) - path = Uri.parse(lastLocation); + if (path == null + && DisplayPrefs.isRememberLastLocation(getActivity())) { + String lastLocation = DisplayPrefs + .getLastLocation(getActivity()); + if (lastLocation != null) + path = Uri.parse(lastLocation); + } + + if (path == null + || !BaseFileProviderUtils.isDirectory(getActivity(), + path)) + path = BaseFileProviderUtils.getDefaultPath( + getActivity(), + path == null ? mFileProviderAuthority : path + .getAuthority()); + } + catch (Exception ex) + { + errMsg = getString(R.string.afc_msg_cannot_connect_to_file_provider_service) + " " + ex.toString(); + errorMessageInDialog = true; + return null; } - if (path == null - || !BaseFileProviderUtils.isDirectory(getActivity(), - path)) - path = BaseFileProviderUtils.getDefaultPath( - getActivity(), - path == null ? mFileProviderAuthority : path - .getAuthority()); if (path == null) return null; @@ -1110,8 +1142,25 @@ public class FragmentFiles extends Fragment implements getLoaderManager().initLoader(mIdLoaderData, result, FragmentFiles.this); } else if (errMsg != null) { - Dlg.toast(getActivity(), errMsg, Dlg.LENGTH_SHORT); - getActivity().finish(); + if (errorMessageInDialog) + { + Dlg.showError(getActivity(), + errMsg, + new DialogInterface.OnCancelListener() { + + @Override + public void onCancel(DialogInterface dialog) { + getActivity().setResult(Activity.RESULT_FIRST_USER); + getActivity().finish(); + }// onCancel() + }); + } + else + { + Dlg.toast(getActivity(), errMsg, Dlg.LENGTH_SHORT); + getActivity().finish(); + } + } else showCannotConnectToServiceAndWaitForTheUserToFinish(); }// onPostExecute() @@ -1153,7 +1202,7 @@ public class FragmentFiles extends Fragment implements @Override public void onCancel(DialogInterface dialog) { - getActivity().setResult(Activity.RESULT_CANCELED); + getActivity().setResult(Activity.RESULT_FIRST_USER); getActivity().finish(); }// onCancel() }); @@ -1812,8 +1861,10 @@ public class FragmentFiles extends Fragment implements setCurrentLocation((Uri) result.getParcelable(PATH)); getLoaderManager().restartLoader(mIdLoaderData, result, FragmentFiles.this); - } else if (errMsg != null) + } else if (errMsg != null) { + Dlg.toast(getActivity(), errMsg, Dlg.LENGTH_SHORT); + } else showCannotConnectToServiceAndWaitForTheUserToFinish(); }// onPostExecute() diff --git a/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/providers/BaseFileProviderUtils.java b/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/providers/BaseFileProviderUtils.java index d06988fe..4b6daaff 100644 --- a/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/providers/BaseFileProviderUtils.java +++ b/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/providers/BaseFileProviderUtils.java @@ -216,6 +216,9 @@ public class BaseFileProviderUtils { BaseFile.COLUMN_TYPE, BaseFile.COLUMN_MODIFICATION_TIME, BaseFile.COLUMN_ICON_ID }; + public static final String[] CONNECTION_CHECK_CURSOR_COLUMNS = {"error"}; + + /** * Creates new cursor which holds default properties of a base file for * client to access. diff --git a/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/providers/basefile/BaseFileContract.java b/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/providers/basefile/BaseFileContract.java index 705b3993..bbdf77b8 100644 --- a/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/providers/basefile/BaseFileContract.java +++ b/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/providers/basefile/BaseFileContract.java @@ -124,6 +124,7 @@ public class BaseFileContract { */ public static final String PATH_API = "api"; + /* * COMMANDS. */ @@ -187,6 +188,9 @@ public class BaseFileContract { */ public static final String CMD_SHUTDOWN = "shutdown"; + + public static final String CMD_CHECK_CONNECTION = "check_connection"; + /* * PARAMETERS. */ diff --git a/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/providers/basefile/BaseFileProvider.java b/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/providers/basefile/BaseFileProvider.java index 389aa755..519e73a5 100644 --- a/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/providers/basefile/BaseFileProvider.java +++ b/src/java/android-filechooser-AS/app/src/main/java/group/pals/android/lib/ui/filechooser/providers/basefile/BaseFileProvider.java @@ -51,6 +51,12 @@ public abstract class BaseFileProvider extends ContentProvider { */ protected static final int URI_API_COMMAND = 4; + /** + * Check if connection to the file service is ok. + */ + protected static final int URI_CHECK_CONNECTION = 5; + + /** * A {@link UriMatcher} instance. */ @@ -79,8 +85,9 @@ public abstract class BaseFileProvider extends ContentProvider { switch (URI_MATCHER.match(uri)) { case URI_API: case URI_API_COMMAND: - case URI_DIRECTORY: - return BaseFile.CONTENT_TYPE; + case URI_DIRECTORY : + case URI_CHECK_CONNECTION: + return BaseFile.CONTENT_TYPE; case URI_FILE: return BaseFile.CONTENT_ITEM_TYPE; diff --git a/src/java/android-filechooser-AS/app/src/main/java/keepass2android/kp2afilechooser/Kp2aFileProvider.java b/src/java/android-filechooser-AS/app/src/main/java/keepass2android/kp2afilechooser/Kp2aFileProvider.java index 8e06c7f3..160ee800 100644 --- a/src/java/android-filechooser-AS/app/src/main/java/keepass2android/kp2afilechooser/Kp2aFileProvider.java +++ b/src/java/android-filechooser-AS/app/src/main/java/keepass2android/kp2afilechooser/Kp2aFileProvider.java @@ -8,6 +8,7 @@ package keepass2android.kp2afilechooser; import java.io.File; +import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -22,6 +23,7 @@ import android.database.Cursor; import android.database.MatrixCursor; import android.database.MatrixCursor.RowBuilder; import android.net.Uri; +import android.support.annotation.Nullable; import android.util.Log; import group.pals.android.lib.ui.filechooser.R; import group.pals.android.lib.ui.filechooser.providers.BaseFileProviderUtils; @@ -216,6 +218,41 @@ public abstract class Kp2aFileProvider extends BaseFileProvider { } }// query() + @Nullable + private MatrixCursor getCheckConnectionCursor(Uri uri) { + try + { + checkConnection(uri); + return null; + } + catch (Exception e) + { + MatrixCursor matrixCursor = new MatrixCursor(BaseFileProviderUtils.CONNECTION_CHECK_CURSOR_COLUMNS); + RowBuilder newRow = matrixCursor.newRow(); + String message = e.getLocalizedMessage(); + if (message == null) + message = e.getMessage(); + if (message == null) + message = e.toString(); + newRow.add(message); + return matrixCursor; + } + } + + private void checkConnection(Uri uri) throws Exception { + try + { + String path = Uri.parse( + uri.getQueryParameter(BaseFile.PARAM_SOURCE)).toString(); + getFileEntry(path); + + } + catch (FileNotFoundException ex) + { + return; + } + } + /* * UTILITIES */ @@ -256,7 +293,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider { { String path = Uri.parse( - uri.getQueryParameter(BaseFile.PARAM_SOURCE)).toString(); + uri.getQueryParameter(BaseFile.PARAM_SOURCE)).toString(); String parentPath = getParentPath(path); @@ -306,6 +343,9 @@ public abstract class Kp2aFileProvider extends BaseFileProvider { // mMapInterruption.put(mMapInterruption.keyAt(i), true); // } + } else if (BaseFile.CMD_CHECK_CONNECTION.equals(lastPathSegment)) + { + return getCheckConnectionCursor(uri); } return matrixCursor; @@ -538,9 +578,15 @@ public abstract class Kp2aFileProvider extends BaseFileProvider { if (Utils.doLog()) Log.d(CLASSNAME, "getFileEntryCached: not in cache :-( " + filename); - - //it's not -> query the information. - FileEntry newEntry = getFileEntry(filename); + + FileEntry newEntry ; + try { + //it's not -> query the information. + newEntry = getFileEntry(filename); + } catch (Exception e) { + e.printStackTrace(); + return null; + } if (!cacheBlockedFiles.contains(filename)) updateFileEntryCache(newEntry); @@ -729,7 +775,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider { - protected abstract FileEntry getFileEntry(String path); + protected abstract FileEntry getFileEntry(String path) throws Exception; /** * Lists all file inside {@code dirName}. diff --git a/src/keepass2android/FileSelectHelper.cs b/src/keepass2android/FileSelectHelper.cs index dbedd41d..0fb32944 100644 --- a/src/keepass2android/FileSelectHelper.cs +++ b/src/keepass2android/FileSelectHelper.cs @@ -63,6 +63,37 @@ namespace keepass2android #endif } + private void ShowHttpDialog(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.httpcredentials, null); + builder.SetView(dlgContents); + builder.SetPositiveButton(Android.Resource.String.Ok, + (sender, args) => + { + string host = dlgContents.FindViewById(Resource.Id.http_url).Text; + + string user = dlgContents.FindViewById(Resource.Id.http_user).Text; + string password = dlgContents.FindViewById(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(host, user, + password); + onStartBrowse(httpPath); + }); + EventHandler evtH = new EventHandler((sender, e) => onCancel()); + + builder.SetNegativeButton(Android.Resource.String.Cancel, evtH); + builder.SetTitle(activity.GetString(Resource.String.enter_http_login_title)); + Dialog dialog = builder.Create(); + + dialog.Show(); +#endif + } + private void ShowFtpDialog(Activity activity, Util.FileSelectedHandler onStartBrowse, Action onCancel) { #if !NoNet @@ -89,7 +120,7 @@ namespace keepass2android EventHandler evtH = new EventHandler((sender, e) => onCancel()); builder.SetNegativeButton(Android.Resource.String.Cancel, evtH); - builder.SetTitle(activity.GetString(Resource.String.enter_sftp_login_title)); + builder.SetTitle(activity.GetString(Resource.String.enter_ftp_login_title)); Dialog dialog = builder.Create(); dialog.Show(); @@ -100,9 +131,11 @@ namespace keepass2android public void PerformManualFileSelect(string defaultPath) { if (defaultPath.StartsWith("sftp://")) - ShowSftpDialog(_activity, StartFileChooser, ReturnCancel); + ShowSftpDialog(_activity, ReturnFileOrStartFileChooser, ReturnCancel); else if ((defaultPath.StartsWith("ftp://")) || (defaultPath.StartsWith("ftps://"))) - ShowFtpDialog(_activity, StartFileChooser, ReturnCancel); + ShowFtpDialog(_activity, ReturnFileOrStartFileChooser, ReturnCancel); + else if ((defaultPath.StartsWith("http://")) || (defaultPath.StartsWith("https://"))) + ShowHttpDialog(_activity, ReturnFileOrStartFileChooser, ReturnCancel, defaultPath); else { Func onOpen = OnOpenButton; @@ -118,6 +151,20 @@ namespace keepass2android } } + private bool ReturnFileOrStartFileChooser(string filename) + { + int lastSlashPos = filename.LastIndexOf('/'); + int lastDotPos = filename.LastIndexOf('.'); + if (lastSlashPos >= lastDotPos) //no dot after last slash or == in case neither / nor . + { + //looks like a folder. + return StartFileChooser(filename); + } + //looks like a file + IocSelected(IOConnectionInfo.FromPath(filename)); + return true; + } + private void ReturnCancel() { if (OnCancel != null) diff --git a/src/keepass2android/FileStorageSelectionActivity.cs b/src/keepass2android/FileStorageSelectionActivity.cs index e6c52b90..68fff53c 100644 --- a/src/keepass2android/FileStorageSelectionActivity.cs +++ b/src/keepass2android/FileStorageSelectionActivity.cs @@ -48,7 +48,10 @@ namespace keepass2android //show all supported protocols: foreach (IFileStorage fs in App.Kp2a.FileStorages) _displayedProtocolIds.AddRange(fs.SupportedProtocols); - + + //this is there for legacy reasons, new protocol is onedrive + _displayedProtocolIds.Remove("skydrive"); + //special handling for local files: if (!Util.IsKitKatOrLater) { diff --git a/src/keepass2android/Properties/AndroidManifest_debug.xml b/src/keepass2android/Properties/AndroidManifest_debug.xml index 5ca9d4ff..58aed9e2 100644 --- a/src/keepass2android/Properties/AndroidManifest_debug.xml +++ b/src/keepass2android/Properties/AndroidManifest_debug.xml @@ -4,7 +4,7 @@ - + diff --git a/src/keepass2android/Properties/AndroidManifest_net.xml b/src/keepass2android/Properties/AndroidManifest_net.xml index 0b87c6ef..1487d13f 100644 --- a/src/keepass2android/Properties/AndroidManifest_net.xml +++ b/src/keepass2android/Properties/AndroidManifest_net.xml @@ -7,7 +7,7 @@ - + diff --git a/src/keepass2android/Resources/drawable-mdpi/ic_storage_skydrive.png b/src/keepass2android/Resources/drawable-mdpi/ic_storage_skydrive.png deleted file mode 100644 index fe207bab..00000000 Binary files a/src/keepass2android/Resources/drawable-mdpi/ic_storage_skydrive.png and /dev/null differ diff --git a/src/keepass2android/Resources/drawable-xhdpi/ic_storage_skydrive.png b/src/keepass2android/Resources/drawable-xhdpi/ic_storage_skydrive.png deleted file mode 100644 index 6528dd31..00000000 Binary files a/src/keepass2android/Resources/drawable-xhdpi/ic_storage_skydrive.png and /dev/null differ diff --git a/src/keepass2android/Resources/values-bg-rBG/strings.xml b/src/keepass2android/Resources/values-bg-rBG/strings.xml index 5cf3ceda..718f3134 100644 --- a/src/keepass2android/Resources/values-bg-rBG/strings.xml +++ b/src/keepass2android/Resources/values-bg-rBG/strings.xml @@ -358,7 +358,7 @@ Dropbox (KP2A папка) Ако не искате да дадете KP2A достъп до пълен живея, можете да изберете тази опция. Тя ще поиска достъп само до папката приложения/Keepass2Android. Това е особено подходящ, когато създавате нова база данни. Ако вече имате база данни, щракнете върху тази опция, за да създаде папката, след което поставете вашия файл в папката (от вашия компютър) и след това изберете тази опция отново за отваряне на файла. Google Drive - OneDrive + OneDrive SFTP (SSH прехвърляне на файлове) Файла достъп инициализация Database местоположение diff --git a/src/keepass2android/Resources/values-ca/strings.xml b/src/keepass2android/Resources/values-ca/strings.xml index 3c15c1b1..c61e4fa7 100644 --- a/src/keepass2android/Resources/values-ca/strings.xml +++ b/src/keepass2android/Resources/values-ca/strings.xml @@ -425,7 +425,7 @@ Això emmagatzemarà la contrasenya mestra d\'aquest Dropbox (carpeta de KP2A) Si no voleu donar accés KP2A al seu Dropbox complet, podeu seleccionar aquesta opció. Es sol·licitarà només l\'accés a la carpeta Apps/Keepass2Android. Això és especialment adequat quan es crea una nova base de dades. Si ja teniu una base de dades, feu clic a aquesta opció per crear la carpeta, a continuació, posar el seu arxiu dins la carpeta (des del seu PC) i llavors seleccioni aquesta opció nou per obrir l\'arxiu. Google Drive - OneDrive + OneDrive SFTP (SSH Transferència de fitxer) Selector d\'arxiu de sistema Inicialització d\'accés a arxiu diff --git a/src/keepass2android/Resources/values-cs/strings.xml b/src/keepass2android/Resources/values-cs/strings.xml index 2c82ca55..4c9f1a5a 100644 --- a/src/keepass2android/Resources/values-cs/strings.xml +++ b/src/keepass2android/Resources/values-cs/strings.xml @@ -425,7 +425,7 @@ Dropbox (KP2A složka) Pokud nechcete, aby měl KP2A plný přístup k vašemu Dropbox účtu, může vybrat tuto možnost. Bude vyžadován pouze přístup ke složce Apps/Keepass2Android. Toto je vhodné zejména při vytváření nové databáze. Pokud již máte databázi, zvolte na tuto možnost pro vytvoření složky, poté umístěte soubor (z PC) do této složky a zvolte tuto možnost znovu pro otevření souboru. Google Drive - OneDrive + OneDrive SFTP (SSH přenos souborů) Výběr systému souborů Inicializace přístupu k souboru diff --git a/src/keepass2android/Resources/values-de/strings.xml b/src/keepass2android/Resources/values-de/strings.xml index 145a1c6d..4795c7ad 100644 --- a/src/keepass2android/Resources/values-de/strings.xml +++ b/src/keepass2android/Resources/values-de/strings.xml @@ -423,7 +423,7 @@ Der Android Robot wird genutzt und wurde modifiziert basierend auf Arbeiten, die Dropbox (KP2A-Ordner) Wenn du Keepass2Android nicht den Zugriff auf die gesamte Dropbox erlauben möchtest, kannst du diese Option wählen. Dann musst du nur Zugriff auf den Ordner Apps/Keepass2Android gewähren. Das ist besonders sinnvoll, wenn du eine neue Datenbank anlegst. Wenn du schon eine Datenbank hast, kannst du diese Option wählen um den Ordner anzulegen, und dann die Datei (vom PC aus) in den neuen Ordner kopieren. Wähle die Option dann nochmal zum Laden der Datei. Google Drive - OneDrive + OneDrive SFTP (SSH File Transfer) Android-Dateibrowser Dateizugriff initialisieren diff --git a/src/keepass2android/Resources/values-es/strings.xml b/src/keepass2android/Resources/values-es/strings.xml index 69bab0e3..5f9bf84a 100644 --- a/src/keepass2android/Resources/values-es/strings.xml +++ b/src/keepass2android/Resources/values-es/strings.xml @@ -424,7 +424,7 @@ mediante la autenticación de huellas dactilares. Esto permite desbloquear la ba Dropbox (carpeta KP2A) Si no quieres que KP2A acceda a todo tu contenido en Dropbox, selecciona esta opción. Solicitará acceso sólo a la carpeta Apps/Keepass2Android. Esta opción esta especialmente pensada para cuándo se crea una nueva base de datos. Si tienes una base de datos pre-existente, haz click en esta opción para crear la carpeta. Luego mueve el archivo hasta esta carpeta (desde tu computador) y finalmente selecciona esta opción nuevamente para abrir el archivo. Google Drive - OneDrive + OneDrive SFTP (SSH transferencia de archivos) Selector de archivo del sistema Inicialización de acceso de archivo diff --git a/src/keepass2android/Resources/values-fi/strings.xml b/src/keepass2android/Resources/values-fi/strings.xml index 648b44c1..6e989430 100644 --- a/src/keepass2android/Resources/values-fi/strings.xml +++ b/src/keepass2android/Resources/values-fi/strings.xml @@ -425,7 +425,7 @@ Mahdollistaa tietokannan avauksen sormenjälkitunnistautumista käyttämällä. Dropbox (KP2A kansio) Jos et halua antaa KP2A pääsyä koko Dropboxiin, voit valita tämän vaihtoehdon. Se pyytää vain Keepass2Android-kansion käyttöoikeuksia. Tämä on erityisen hyvä kun luodaan uusi tietokanta. Jos sinulla on jo tietokanta, valitsemalla tämän vaihtoehdon voit luoda kansion, Sijoita sen jälkeen tiedosto kansioon (tietokoneesta) ja valitse sitten tämä vaihtoehto uudelleen avaamalla tiedosto. Google Drive - OneDrive + OneDrive SFTP (SSH-tiedostonsiirto) Järjestelmän tiedostonvalitsin Tiedoston käytön alustaminen diff --git a/src/keepass2android/Resources/values-fr/strings.xml b/src/keepass2android/Resources/values-fr/strings.xml index 55db403a..fd05f8b3 100644 --- a/src/keepass2android/Resources/values-fr/strings.xml +++ b/src/keepass2android/Resources/values-fr/strings.xml @@ -422,7 +422,7 @@ Cela va stocker votre mot de passe maître sur cet appareil, chiffré avec Andro Dropbox (dossier KP2A) Si vous ne voulez pas donner l\'accès KP2A à votre espace Dropbox complet, vous pouvez sélectionner cette option. Seul l\'accès au dossier Apps/Keepass2Android sera demandé. Ceci est particulièrement adapté lorsque vous créez une nouvelle base de données. Si vous avez déjà une base de données, cliquez sur cette option pour créer le dossier, puis placez votre fichier dans le dossier (à partir de votre PC) et puis sélectionnez à nouveau cette option pour ouvrir le fichier. Google Drive - OneDrive + OneDrive SFTP (SSH File Transfer) Sélecteur de fichier système Initialisation de l\'accès aux fichiers diff --git a/src/keepass2android/Resources/values-hu/strings.xml b/src/keepass2android/Resources/values-hu/strings.xml index d94db4f9..8a71395d 100644 --- a/src/keepass2android/Resources/values-hu/strings.xml +++ b/src/keepass2android/Resources/values-hu/strings.xml @@ -427,7 +427,7 @@ Az adatbázist módosíthatja, a szinkronizálásra később is lesz lehetőség Dropbox (KPA2 mappa) Válassza ezt az opciót, ha nem akarja, hogy a KP2A a teljes Dropbox tárhelyhez hozzáférjen. A KP2A csak az Apps/Keepass2Android könyvtárhoz fog hozzáférést igényelni. Ha már meglévő, de máshol tárolt adatbázist kíván ilyen módon elérni, akkor válassza ezt az opciót a könyvtár létrehozásához, majd helyezze át az adatbázisfájlt a létrehozott könyvtárba (például egy PC-ről), majd válassza még egyszer ezt az opciót a fájl megnyitásához. Google Drive - OneDrive + OneDrive SFTP (SSH File Transfer) Alapértelmezett fájlválasztó A fájlhozzáférés inicializálása diff --git a/src/keepass2android/Resources/values-it/strings.xml b/src/keepass2android/Resources/values-it/strings.xml index 7d4bd9ec..9d13c76a 100644 --- a/src/keepass2android/Resources/values-it/strings.xml +++ b/src/keepass2android/Resources/values-it/strings.xml @@ -422,7 +422,7 @@ Questo memorizzerà la password principale su questo dispositivo, cifrata con il Dropbox (cartella KP2A) Se non vuoi dare a KP2A accesso completo al tuo Dropbox, puoi selezionare questa opzione. Richiederà solo l\'accesso alla cartella Apps/Keepass2Android. Ciò è particolarmente indicato quando si crea un nuovo database. Se hai già un database, fai click su questa opzione per creare la cartella, poi spostaci dentro il file (dal PC), quindi seleziona di nuovo questa opzione per aprire il file. Google Drive - OneDrive + OneDrive SFTP (SSH File Transfer) Selettore file di sistema Inizializzazione dell\'accesso al file diff --git a/src/keepass2android/Resources/values-ja/strings.xml b/src/keepass2android/Resources/values-ja/strings.xml index 0551260f..f96579be 100644 --- a/src/keepass2android/Resources/values-ja/strings.xml +++ b/src/keepass2android/Resources/values-ja/strings.xml @@ -425,7 +425,7 @@ Dropbox (KP2A フォルダー) Dropbox の全てに KP2A がアクセスできるようにしたくない場合にこのオプションを選択してください。このオプションを選択すると、Apps/Keepass2Android フォルダーだけにアクセスを要求します。これは特に新しいデータベースを作成するときに向いています。既にデータベースがある場合は、このオプションを選択してフォルダーを作成し、その後 (PC から) フォルダー内にファイルを配置し、そのファイルを開く際にもう一度このオプションを選択します。 Google ドライブ - OneDrive + OneDrive SFTP (SSH ファイル転送) システム ファイル ピッカー ファイルのアクセスの初期化 diff --git a/src/keepass2android/Resources/values-nb/strings.xml b/src/keepass2android/Resources/values-nb/strings.xml index 54073009..db20567f 100644 --- a/src/keepass2android/Resources/values-nb/strings.xml +++ b/src/keepass2android/Resources/values-nb/strings.xml @@ -355,7 +355,7 @@ Dropbox (KP2A-mappe) Hvis du ikke vil gi KP2A tilgang til hele Dropbox-mappen din, kan du velge dette alternativet. KP2A vil da bare spørre om tilgang til mappen Apps/Keepass2Android. Dette er spesielt egnet når du oppretter en ny database. Hvis du allerede har en database, trykk på dette alternativet for å opprette mappen, for deretter å plassere filen i mappen (fra en PC) og velge dette alternativet igjen for å åpne filen. Google Disk - OneDrive + OneDrive SFTP (SSH File Transfer) Hovedpassord Databasen din er kryptert med passordet du angir her. Velg et sterkt passord for å sikre databasen! Tips: Lag en setning eller to og bruk de første bokstavene til ordene som et passord. Inkluder skilletegn. diff --git a/src/keepass2android/Resources/values-nl/strings.xml b/src/keepass2android/Resources/values-nl/strings.xml index eb92a32f..78b24e40 100644 --- a/src/keepass2android/Resources/values-nl/strings.xml +++ b/src/keepass2android/Resources/values-nl/strings.xml @@ -422,7 +422,7 @@ Dit zal uw hoofdwachtwoord op dit apparaat opslaan. Het wordt versleuteld door d Dropbox (KP2A map) Als u KP2A volledige toegang tot dropbox wilt geven, kiest u deze optie. Het zal alleen toegang vragen tot de map Apps/Keepass2Android. Dit is met name geschikt bij het maken van een nieuwe database. Als u al een database heeft, gebruik deze optie om de map te maken, plaats daarna het bestand in de map (vanaf uw PC) en kies deze optie opnieuw om het bestand te openen. Google Drive - OneDrive + OneDrive SFTP (SSH File Transfer) Systeem bestand kiezer Bestandstoegang initaliseren diff --git a/src/keepass2android/Resources/values-pl/strings.xml b/src/keepass2android/Resources/values-pl/strings.xml index de665a60..889b7aa8 100644 --- a/src/keepass2android/Resources/values-pl/strings.xml +++ b/src/keepass2android/Resources/values-pl/strings.xml @@ -424,7 +424,7 @@ To zachowa twoje hasła główne na tym urządzeniu. Dropbox (folder KP2A) Jeżeli nie chcesz dać KP2A pełnego dostępu do wszystkich folderów Dropbox, możesz wybrać tę opcję. Aplikacja zażąda dostępu jedynie do folderu Aplikacje/Keepass2Android. Jest to szczególnie przydatne podczas tworzenia nowej bazy danych. Jeżeli już posiadasz bazę danych, kliknij w tę opcję aby utworzyć folder, następnie umieść swój plik w folderze (ze swojego PC) i wybierz tę opcję ponownie aby otworzyć plik. Google Drive - OneDrive + OneDrive SFTP (transfer plików przez SSH) Systemowa przeglądarka plików Inicjowanie dostępu do pliku diff --git a/src/keepass2android/Resources/values-pt-rBR/strings.xml b/src/keepass2android/Resources/values-pt-rBR/strings.xml index 5c78c937..e239e537 100644 --- a/src/keepass2android/Resources/values-pt-rBR/strings.xml +++ b/src/keepass2android/Resources/values-pt-rBR/strings.xml @@ -424,7 +424,7 @@ Dropbox (pasta KP2A) Se você não quiser dar acesso KP2A para o seu Dropbox completo, você pode selecionar esta opção. Ele irá solicitar somente acesso para a pasta Apps/Keepass2Android. Isto é especialmente adequado ao criar um novo banco de dados. Se você já tiver um banco de dados, clique nesta opção para criar a pasta, em seguida, colocar o arquivo dentro da pasta (a partir de seu PC) e em seguida, selecione esta opção novamente para abrir o arquivo. Google Drive - OneDrive + OneDrive SFTP (SSH transferência de arquivos) Seletor de arquivo de sistema Inicialização do arquivo de acesso diff --git a/src/keepass2android/Resources/values-pt-rPT/strings.xml b/src/keepass2android/Resources/values-pt-rPT/strings.xml index 3f75f9ea..1498069b 100644 --- a/src/keepass2android/Resources/values-pt-rPT/strings.xml +++ b/src/keepass2android/Resources/values-pt-rPT/strings.xml @@ -334,7 +334,7 @@ Muito útil se existirem muitos resultados iguais. HTTP (WebDav) Dropbox Google Drive - OneDrive + OneDrive SFTP (transferência de ficheiros por SSH) Localização da base de dados Alterar o local diff --git a/src/keepass2android/Resources/values-ro/strings.xml b/src/keepass2android/Resources/values-ro/strings.xml index a46b21b1..bb460bbe 100644 --- a/src/keepass2android/Resources/values-ro/strings.xml +++ b/src/keepass2android/Resources/values-ro/strings.xml @@ -402,7 +402,7 @@ Dropbox (folder KP2A) Dacă nu doriți să oferiți KP2A acces la tot Dropbox-ul, poți selecta această opțiune. Aceasta va solicita acces doar la folderul Apps/Keepass2Android. Acest lucru este ideal când creați o bază de date nouă. Dacă ai deja o bază de date, apasă această opțiune pentru a crea folderul, puneți baza de date în folder (de pe PC) apoi selectați opțiunea aceasta din nou pentru a deschide fișierul. Google Drive - OneDrive + OneDrive SFTP (SSH File Transfer) Selector de fisiere sistem Iniţializare acces fişier diff --git a/src/keepass2android/Resources/values-ru/strings.xml b/src/keepass2android/Resources/values-ru/strings.xml index 5be6cabd..212b9a26 100644 --- a/src/keepass2android/Resources/values-ru/strings.xml +++ b/src/keepass2android/Resources/values-ru/strings.xml @@ -425,7 +425,7 @@ Dropbox (папка KP2A) Если Вы не хотите предоставлять полный доступ к Dropbox, то можете выбрать эту опцию. Будет запрошен доступ только к папке Apps/Keepass2Android. Это особенно удобно при создании нового файла. Если у вас уже есть файл с данными, выберите этот параметр, чтобы создать папку. После скопируйте базу в папку (с компьютера) и повторно выберите эту опцию для открытия файла. Диск Google - OneDrive + OneDrive SFTP (SSH передача файлов) Системный выбор файла Инициализация доступа к файлу diff --git a/src/keepass2android/Resources/values-sk/strings.xml b/src/keepass2android/Resources/values-sk/strings.xml index 1bc8b1c9..44b5a5ff 100644 --- a/src/keepass2android/Resources/values-sk/strings.xml +++ b/src/keepass2android/Resources/values-sk/strings.xml @@ -425,7 +425,7 @@ Dropbox (priečinok KP2A) Túto možnosť si môžete vybrať, ak nechcete, aby mal KP2A úplný prístup k úložisku Dropbox. Bude sa vyžadovať iba prístup k priečinku Apps/Keepass2Android. Táto možnosť je vhodná pri vytváraní novej databázy. Ak už máte nejakú databázu, kliknite na túto možnosť pre vytvorenie nového priečinka, potom vložte súbor do priečinka (z PC) a potom znovu vyberte túto možnosť pre otvorenie súboru. Google Drive - OneDrive + OneDrive SFTP (SSH File Transfer) Systémový prehliadač súborov Inicializácia prístupu k súboru diff --git a/src/keepass2android/Resources/values-sl/strings.xml b/src/keepass2android/Resources/values-sl/strings.xml index 6a8835b9..09998b09 100644 --- a/src/keepass2android/Resources/values-sl/strings.xml +++ b/src/keepass2android/Resources/values-sl/strings.xml @@ -425,7 +425,7 @@ Dropbox (mapa KP2A) Če dostopa KP2A ne želite dati celemu Dropboxu, lahko izberete to možnost. Zahtevala bo samo dostop do mape Apps/Keepass2Android. To je posebej primerno ob ustvarjanju nove podatkovne zbirke. Če jo že imate, kliknite na to možnost, da ustvarite mapo, v njo vstavite svojo datoteko (iz računalnika) in ponovno izberete to možnost, da datoteko odprete. Google Drive - OneDrive + OneDrive SFTP (prenos datotek SSH) Sistemski izbirnik datotek Začenjanje dostopa do datoteke diff --git a/src/keepass2android/Resources/values-sv/strings.xml b/src/keepass2android/Resources/values-sv/strings.xml index a50becbc..f4afe122 100644 --- a/src/keepass2android/Resources/values-sv/strings.xml +++ b/src/keepass2android/Resources/values-sv/strings.xml @@ -238,7 +238,7 @@ HTTPS (WebDav) Dropbox Google Drive - OneDrive + OneDrive SFTP (SSH File Transfer) Databasplacering Ändra plats diff --git a/src/keepass2android/Resources/values-tr/strings.xml b/src/keepass2android/Resources/values-tr/strings.xml index c234727c..cf052bc3 100644 --- a/src/keepass2android/Resources/values-tr/strings.xml +++ b/src/keepass2android/Resources/values-tr/strings.xml @@ -415,7 +415,7 @@ Dropbox(KP2A Klasörü) Dropbox heabınıza tam erişim vermek istemiyorsanız, bu seçeneği seçebilirsiniz. Keepass2Android sadece klasör erişimi isteyecek. Özellikle yeni bir veritabanı oluştururken bu uygundur. Bir veritabanınız varsa, klasör oluşturmak için bu seçeneği seçin ve dosyanızı oluşan klasöre taşıyın (bilgisayardan). Dosyayı açmak için bu seçeneği tekrar seçin. Google Drive - OneDrive + OneDrive SFTP (SSH dosya aktarımı) Sistem dosyası seçicisi Dosya erişimi başlatma diff --git a/src/keepass2android/Resources/values-uk/strings.xml b/src/keepass2android/Resources/values-uk/strings.xml index 77fdbc48..a8508f87 100644 --- a/src/keepass2android/Resources/values-uk/strings.xml +++ b/src/keepass2android/Resources/values-uk/strings.xml @@ -425,7 +425,7 @@ Dropbox (папка KP2A) Якщо ви не бажаєте надати KP2A до всього вашого Dropbox, ви можете вибрати цю опцію. Вона запитає доступ лише до каталогу Apps/Keepass2Android. Це особливо зручно при створенні нового файлу. Якщо ви вже маєте файл з даними, виберіть цю опцію для створення каталогу, після цього покладіть свій файл до цього каталогу (з комп\'ютеру) та виберыть цю опцію знову для відкриття файлу. Диск Google - OneDrive + OneDrive SFTP (SSH File Transfer) Системний вибір файлу Ініціалізація доступу до файлу diff --git a/src/keepass2android/Resources/values-vi/strings.xml b/src/keepass2android/Resources/values-vi/strings.xml index 3cf176f8..56bd99c5 100644 --- a/src/keepass2android/Resources/values-vi/strings.xml +++ b/src/keepass2android/Resources/values-vi/strings.xml @@ -360,7 +360,7 @@ Dropbox (thư mục KP2A) Nếu bạn không muốn cấp cho KP2A quyền truy cập đầy đủ vô Dropbox, bạn có thể chọn tùy chọn này. Nó sẽ chỉ yêu cầu quyền truy cập vô thư mục Apps/Keepass2Android. Điều này đặc biệt thích hợp khi tạo cơ sở dữ liệu mới. Nếu bạn đã có một cơ sở dữ liệu, hãy nhấp vào tùy chọn này để tạo thư mục, sau đó đặt tập tin của bạn bên trong thư mục (từ máy tính của bạn) và sau đó chọn tùy chọn này một lần nữa để mở tập tin. Google Drive - OneDrive + OneDrive SFTP (bộ chuyển tập tin SSH) Khởi tạo truy cập tập tin Vị trí cơ sở dữ liệu diff --git a/src/keepass2android/Resources/values-zh-rCN/strings.xml b/src/keepass2android/Resources/values-zh-rCN/strings.xml index 643083bd..f3694a82 100644 --- a/src/keepass2android/Resources/values-zh-rCN/strings.xml +++ b/src/keepass2android/Resources/values-zh-rCN/strings.xml @@ -423,7 +423,7 @@ Dropbox(KP2A 文件夹) 如果你不想让 KP2A 访问整个 Dropbox,您可以选中此选项。它将只有访问 应用/Keepass2Android 文件夹的权限。特别适合创建一个新的数据库。如果您已经有一个数据库,点击此选项将创建该新文件夹,然后将你在电脑上的数据库文件放在此文件夹内,然后再选该选项,并以打开该文件。 Google Drive - OneDrive + OneDrive SFTP(SSH 文件传输) 系统文件选择器 初始化文件访问 diff --git a/src/keepass2android/Resources/values-zh-rTW/strings.xml b/src/keepass2android/Resources/values-zh-rTW/strings.xml index c56de9a4..d59c4cf6 100644 --- a/src/keepass2android/Resources/values-zh-rTW/strings.xml +++ b/src/keepass2android/Resources/values-zh-rTW/strings.xml @@ -387,7 +387,7 @@ Dropbox (KP2A 資料夾) 如果你不想要給 KP2A 你完整的 Dropbox 訪問權限,您可以選擇此選項。它將請求只訪問應用程式/Keepass2Android 資料夾。這特別適合創建新資料庫時。如果你已經有一個資料庫,請按一下此選項可創建該資料夾,然後 (從您的 PC) 將檔放在資料夾的內部,然後選擇此選項用,再打開檔案。 Google 雲端硬碟 - OneDrive + OneDrive SFTP (SSH 檔案傳輸) 系統檔選擇器 檔案存取權限初始化 diff --git a/src/keepass2android/Resources/values/strings.xml b/src/keepass2android/Resources/values/strings.xml index fbd9aede..6204e3f9 100644 --- a/src/keepass2android/Resources/values/strings.xml +++ b/src/keepass2android/Resources/values/strings.xml @@ -471,12 +471,18 @@ Tell me more! No, I don\'t like it that much - host (ex: 192.168.0.1) + Enter WebDav login data: + URL of folder or file (ex: mycloud.me.com/webdav/) + + host (ex: 192.168.0.1) port Initial directory (optional): Enter SFTP login data: - Select the storage type: + Enter FTP login data: + + + Select the storage type: Local file @@ -489,8 +495,8 @@ Dropbox (KP2A folder) 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. Google Drive - OneDrive - SFTP (SSH File Transfer) + OneDrive + SFTP (SSH File Transfer) System file picker File access initialization diff --git a/src/keepass2android/SelectStorageLocationActivity.cs b/src/keepass2android/SelectStorageLocationActivity.cs index c6e85123..7c2d3963 100644 --- a/src/keepass2android/SelectStorageLocationActivity.cs +++ b/src/keepass2android/SelectStorageLocationActivity.cs @@ -101,6 +101,10 @@ namespace keepass2android { IocSelected(ioc,browseRequestCode); }; + fileSelectHelper.OnCancel += (sender, args) => + { + ReturnCancel(); + }; App.Kp2a.GetFileStorage(protocolId).StartSelectFile(new FileStorageSetupInitiatorActivity(this, OnActivityResult, diff --git a/src/keepass2android/app/App.cs b/src/keepass2android/app/App.cs index 56a478a8..c728f687 100644 --- a/src/keepass2android/app/App.cs +++ b/src/keepass2android/app/App.cs @@ -38,6 +38,8 @@ using TwofishCipher; using Keepass2android.Pluginsdk; using keepass2android.Io; using keepass2android.addons.OtpKeyProv; +using Keepass2android.Javafilestorage; +using GoogleDriveFileStorage = keepass2android.Io.GoogleDriveFileStorage; namespace keepass2android { @@ -509,9 +511,10 @@ namespace keepass2android new DropboxFileStorage(Application.Context, this), new DropboxAppFolderFileStorage(Application.Context, this), new GoogleDriveFileStorage(Application.Context, this), - new SkyDriveFileStorage(Application.Context, this), + new OneDriveFileStorage(Application.Context, this), new SftpFileStorage(this), new NetFtpFileStorage(Application.Context, this), + new WebDavFileStorage(this), #endif #endif new LocalFileStorage(this) @@ -530,24 +533,21 @@ namespace keepass2android }); } + public bool AlwaysFailOnValidationError() + { + return true; + } + + public bool OnValidationError() + { + return false; + } + public RemoteCertificateValidationCallback CertificateValidationCallback { get { - var prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context); - - ValidationMode validationMode = ValidationMode.Warn; - - string strValMode = prefs.GetString(Application.Context.Resources.GetString(Resource.String.AcceptAllServerCertificates_key), - Application.Context.Resources.GetString(Resource.String.AcceptAllServerCertificates_default)); - - if (strValMode == "IGNORE") - validationMode = ValidationMode.Ignore; - else if (strValMode == "ERROR") - validationMode = ValidationMode.Error; - ; - - switch (validationMode) + switch (GetValidationMode()) { case ValidationMode.Ignore: return (sender, certificate, chain, errors) => true; @@ -555,11 +555,7 @@ namespace keepass2android return (sender, certificate, chain, errors) => { if (errors != SslPolicyErrors.None) - ShowToast(Application.Context.GetString(Resource.String.CertificateWarning, - new Java.Lang.Object[] - { - errors.ToString() - })); + ShowValidationWarning(errors.ToString()); return true; }; @@ -579,6 +575,22 @@ namespace keepass2android } + private ValidationMode GetValidationMode() + { + var prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context); + + ValidationMode validationMode = ValidationMode.Warn; + + string strValMode = prefs.GetString(Application.Context.Resources.GetString(Resource.String.AcceptAllServerCertificates_key), + Application.Context.Resources.GetString(Resource.String.AcceptAllServerCertificates_default)); + + if (strValMode == "IGNORE") + validationMode = ValidationMode.Ignore; + else if (strValMode == "ERROR") + validationMode = ValidationMode.Error; + return validationMode; + } + public bool CheckForDuplicateUuids { get @@ -588,6 +600,49 @@ namespace keepass2android } } + public ICertificateErrorHandler CertificateErrorHandler + { + get { return new CertificateErrorHandlerImpl(this); } + } + + public class CertificateErrorHandlerImpl : Java.Lang.Object, Keepass2android.Javafilestorage.ICertificateErrorHandler + { + private readonly Kp2aApp _app; + + public CertificateErrorHandlerImpl(Kp2aApp app) + { + _app = app; + } + + public bool AlwaysFailOnValidationError() + { + return _app.GetValidationMode() == ValidationMode.Error; + } + + + public bool OnValidationError(string errorMessage) + { + switch (_app.GetValidationMode()) + { + case ValidationMode.Ignore: + return true; + case ValidationMode.Warn: + _app.ShowValidationWarning(errorMessage); + return true; + case ValidationMode.Error: + return false; + default: + throw new Exception("Unexpected Validation mode!"); + } + + } + } + + private void ShowValidationWarning(string error) + { + ShowToast(Application.Context.GetString(Resource.String.CertificateWarning, error)); + } + public enum ValidationMode { diff --git a/src/keepass2android/keepass2android.csproj b/src/keepass2android/keepass2android.csproj index 1d51b4d4..edf04db7 100644 --- a/src/keepass2android/keepass2android.csproj +++ b/src/keepass2android/keepass2android.csproj @@ -38,7 +38,12 @@ False Xamarin True - armeabi;armeabi-v7a;x86 + armeabi,armeabi-v7a,x86 + True + SdkOnly + False + False + False full @@ -294,6 +299,9 @@ Designer + + Designer + False @@ -424,7 +432,7 @@ - + @@ -702,7 +710,9 @@ - + + Designer + Designer @@ -722,7 +732,9 @@ - + + Designer + Designer @@ -1103,7 +1115,7 @@ - +