diff --git a/src/KeePassLib2Android/KeePassLib2Android.csproj b/src/KeePassLib2Android/KeePassLib2Android.csproj index 9ed5983f..77748fc3 100644 --- a/src/KeePassLib2Android/KeePassLib2Android.csproj +++ b/src/KeePassLib2Android/KeePassLib2Android.csproj @@ -20,7 +20,7 @@ full False bin\Debug - DEBUG;INCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE;INCLUDE_KEYTRANSFORM + DEBUG;EXCLUDE_TWOFISH;INCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE;EXCLUDE_KEYTRANSFORM prompt 4 False diff --git a/src/KeePassLib2Android/Resources/Resource.designer.cs b/src/KeePassLib2Android/Resources/Resource.designer.cs index 4d1611d0..8208d60e 100644 --- a/src/KeePassLib2Android/Resources/Resource.designer.cs +++ b/src/KeePassLib2Android/Resources/Resource.designer.cs @@ -2,7 +2,7 @@ //------------------------------------------------------------------------------ // // Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.34003 +// Laufzeitversion:4.0.30319.34011 // // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn // der Code erneut generiert wird. diff --git a/src/KeePassLib2Android/Serialization/IOConnection.cs b/src/KeePassLib2Android/Serialization/IOConnection.cs index b3daaa2f..d7a3a5ef 100644 --- a/src/KeePassLib2Android/Serialization/IOConnection.cs +++ b/src/KeePassLib2Android/Serialization/IOConnection.cs @@ -362,22 +362,56 @@ namespace KeePassLib.Serialization public override void Close() { base.Close(); - RepeatWithDigestOnFail(ioc, req => + + WebRequest testReq = WebRequest.Create(ioc.Path); + if (testReq is HttpWebRequest) { - req.Headers.Add("Translate: f"); - - if (method != null) - req.Method = method; - var data = this.ToArray(); - - using (Stream s = req.GetRequestStream()) + RepeatWithDigestOnFail(ioc, req => { - s.Write(data, 0, data.Length); - req.GetResponse(); - s.Close(); + req.Headers.Add("Translate: f"); + + if (method != null) + req.Method = method; + var data = this.ToArray(); + + using (Stream s = req.GetRequestStream()) + { + s.Write(data, 0, data.Length); + req.GetResponse(); + s.Close(); + } + }); + } + else + { + try + { + uploadData(IOConnection.CreateWebClient(ioc, false)); } - }); + catch (WebException ex) + { + //todo: does this make sense for FTP at all? Remove? + if ((ex.Response is HttpWebResponse) && (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.Unauthorized)) + uploadData(IOConnection.CreateWebClient(ioc, true)); + else + throw; + } + } + + + } + + void uploadData(WebClient webClient) + { + if (method != null) + { + webClient.UploadData(destinationFilePath, method, this.ToArray()); + } + else + { + webClient.UploadData(destinationFilePath, this.ToArray()); + } } diff --git a/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj b/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj index 8e4b49ad..8dc9f5a0 100644 --- a/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj +++ b/src/Kp2aBusinessLogic/Kp2aBusinessLogic.csproj @@ -20,7 +20,7 @@ full false bin\Debug\ - TRACE;DEBUG;INCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE;INCLUDE_KEYTRANSFORM + TRACE;DEBUG;EXCLUDE_TWOFISH;INCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE;EXCLUDE_KEYTRANSFORM prompt 4 diff --git a/src/Kp2aUnitTests/MainActivity.cs b/src/Kp2aUnitTests/MainActivity.cs index 17b674f0..5636946b 100644 --- a/src/Kp2aUnitTests/MainActivity.cs +++ b/src/Kp2aUnitTests/MainActivity.cs @@ -18,15 +18,15 @@ namespace Kp2aUnitTests { TestRunner runner = new TestRunner(); // Run all tests from this assembly - //runner.AddTests(Assembly.GetExecutingAssembly()); + runner.AddTests(Assembly.GetExecutingAssembly()); //runner.AddTests(new List { typeof(TestSynchronizeCachedDatabase)}); //runner.AddTests(typeof(TestLoadDb).GetMethod("LoadErrorWithCertificateTrustFailure")); //runner.AddTests(typeof(TestLoadDb).GetMethod("LoadWithAcceptedCertificateTrustFailure")); - - runner.AddTests(new List { typeof(TestLoadDb) }); + + //runner.AddTests(new List { typeof(TestLoadDb) }); //runner.AddTests(new List { typeof(TestCachingFileStorage) }); //runner.AddTests(typeof(TestLoadDb).GetMethod("TestLoadKdb1")); - //runner.AddTests(typeof(TestLoadDb).GetMethod("TestLoadWithKeyfileOnly")); + //runner.AddTests(typeof(TestLoadDb).GetMethod("LoadAndSaveFromRemote1And1Ftp")); //runner.AddTests(typeof(TestLoadDb).GetMethod("TestLoadKdbpWithPasswordOnly")); //runner.AddTests(typeof(TestSaveDb).GetMethod("TestLoadKdbxAndSaveKdbp_TestIdenticalFiles")); return runner; diff --git a/src/Kp2aUnitTests/Resources/Resource.Designer.cs b/src/Kp2aUnitTests/Resources/Resource.Designer.cs index 641b4a6a..c93b7129 100644 --- a/src/Kp2aUnitTests/Resources/Resource.Designer.cs +++ b/src/Kp2aUnitTests/Resources/Resource.Designer.cs @@ -2,7 +2,7 @@ //------------------------------------------------------------------------------ // // Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.34003 +// Laufzeitversion:4.0.30319.34011 // // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn // der Code erneut generiert wird. diff --git a/src/Kp2aUnitTests/TestLoadDb.cs b/src/Kp2aUnitTests/TestLoadDb.cs index f66f0d06..20c30160 100644 --- a/src/Kp2aUnitTests/TestLoadDb.cs +++ b/src/Kp2aUnitTests/TestLoadDb.cs @@ -200,6 +200,32 @@ namespace Kp2aUnitTests } + [TestMethod] + public void LoadAndSaveFromRemote1And1Ftp() + { + var ioc = RemoteIoc1and1Ftp; //note: this property is defined in "TestLoadDbCredentials.cs" which is deliberately excluded from Git because the credentials are not public! + var app = new TestKp2aApp(); + app.CreateNewDatabase(); + + bool loadSuccesful = false; + LoadDb task = new LoadDb(app, ioc, null, CreateKey("test"), null, new ActionOnFinish((success, message) => + { + if (!success) + Android.Util.Log.Debug("KP2ATest", "error loading db: " + message); + loadSuccesful = success; + }) + ); + ProgressTask pt = new ProgressTask(app, Application.Context, task); + Android.Util.Log.Debug("KP2ATest", "Running ProgressTask"); + pt.Run(); + pt.JoinWorkerThread(); + Android.Util.Log.Debug("KP2ATest", "PT.run finished"); + Assert.IsTrue(loadSuccesful, "didn't succesfully load database :-("); + + Assert.IsTrue(TrySaveDatabase(app), "didn't successfully save database."); + + } + [TestMethod] public void LoadFromRemote1And1NonExisting() diff --git a/src/java/KP2ASoftKeyboard2/java/res/xml/prefs.xml b/src/java/KP2ASoftKeyboard2/java/res/xml/prefs.xml index def5a8bc..8ddfdc18 100644 --- a/src/java/KP2ASoftKeyboard2/java/res/xml/prefs.xml +++ b/src/java/KP2ASoftKeyboard2/java/res/xml/prefs.xml @@ -53,6 +53,13 @@ android:persistent="true" android:defaultValue="true" /> + + + + Suggest.LARGE_DICTIONARY_THRESHOLD / 4) { - haveDictionary = true; + //somewhat a hack. But simply querying the dictionary will always return an English + //dictionary in KP2A so if we get a dict, we wouldn't know if it's language specific + if (locale.getLanguage().equals("en")) + { + haveDictionary = true; } else { BinaryDictionary plug = PluginManager.getDictionary(getApplicationContext(), locale.getLanguage()); if (plug != null) { - bd.close(); - bd = plug; - haveDictionary = true; + plug.close(); + haveDictionary = true; } } - bd.close(); conf.locale = saveLocale; res.updateConfiguration(conf, res.getDisplayMetrics()); return haveDictionary; diff --git a/src/keepass2android/GroupEditActivity.cs b/src/keepass2android/GroupEditActivity.cs index c0589d03..efbbb83d 100644 --- a/src/keepass2android/GroupEditActivity.cs +++ b/src/keepass2android/GroupEditActivity.cs @@ -145,7 +145,8 @@ namespace keepass2android protected override void OnResume() { base.OnResume(); - _design.ReapplyTheme(); + //DON'T: _design.ReapplyTheme(); + // (This causes endless loop creating/recreating. More correct: ReapplyDialogTheme (which doesn't exist) Not required anyways...) } } } diff --git a/src/keepass2android/Properties/AndroidManifest_net.xml b/src/keepass2android/Properties/AndroidManifest_net.xml index 8edd3f37..c4aa42bd 100644 --- a/src/keepass2android/Properties/AndroidManifest_net.xml +++ b/src/keepass2android/Properties/AndroidManifest_net.xml @@ -1,5 +1,5 @@  - + @@ -44,6 +44,15 @@ + + + + + + + + diff --git a/src/keepass2android/Resources/Resource.designer.cs b/src/keepass2android/Resources/Resource.designer.cs index 17329b4e..dcae1d16 100644 --- a/src/keepass2android/Resources/Resource.designer.cs +++ b/src/keepass2android/Resources/Resource.designer.cs @@ -2,7 +2,7 @@ //------------------------------------------------------------------------------ // // Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.34003 +// Laufzeitversion:4.0.30319.34011 // // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn // der Code erneut generiert wird. @@ -6384,6 +6384,9 @@ namespace keepass2android // aapt resource value: 0x7f0e00c3 public const int BaseLight = 2131624131; + // aapt resource value: 0x7f0e00c5 + public const int BaseLight_Dialog = 2131624133; + // aapt resource value: 0x7f0e00b5 public const int BottomBarActionButton = 2131624117; @@ -6393,8 +6396,8 @@ namespace keepass2android // aapt resource value: 0x7f0e00c1 public const int DialogDark = 2131624129; - // aapt resource value: 0x7f0e00c5 - public const int DialogLight = 2131624133; + // aapt resource value: 0x7f0e00c6 + public const int DialogLight = 2131624134; // aapt resource value: 0x7f0e00b1 public const int EditEntryButton = 2131624113; @@ -6648,8 +6651,8 @@ namespace keepass2android // aapt resource value: 0x7f0e00c2 public const int ThemeDark = 2131624130; - // aapt resource value: 0x7f0e00c6 - public const int ThemeLight = 2131624134; + // aapt resource value: 0x7f0e00c7 + public const int ThemeLight = 2131624135; // aapt resource value: 0x7f0e00a8 public const int WhiteOnBlack = 2131624104; diff --git a/src/keepass2android/Resources/values-v14/styles_light.xml b/src/keepass2android/Resources/values-v14/styles_light.xml index c2fadbd0..a3428c00 100644 --- a/src/keepass2android/Resources/values-v14/styles_light.xml +++ b/src/keepass2android/Resources/values-v14/styles_light.xml @@ -35,7 +35,11 @@ - + + + + diff --git a/src/keepass2android/Utils/ActivityDesign.cs b/src/keepass2android/Utils/ActivityDesign.cs index ced31f94..73118fd9 100644 --- a/src/keepass2android/Utils/ActivityDesign.cs +++ b/src/keepass2android/Utils/ActivityDesign.cs @@ -27,13 +27,17 @@ namespace keepass2android public void ReapplyTheme() { - int newTheme = UseDarkTheme ? Resource.Style.ThemeDark : Resource.Style.ThemeLight; - if (newTheme != _currentThemeId) + if (HasThemes()) { - Kp2aLog.Log("recreating due to theme change."); - _activity.Recreate(); + int newTheme = UseDarkTheme ? Resource.Style.ThemeDark : Resource.Style.ThemeLight; + if (newTheme != _currentThemeId) + { + Kp2aLog.Log("recreating due to theme change."); + _activity.Recreate(); + } } + } private bool UseDarkTheme diff --git a/src/keepass2android/app/App.cs b/src/keepass2android/app/App.cs index b1102b49..15ffa5e0 100644 --- a/src/keepass2android/app/App.cs +++ b/src/keepass2android/app/App.cs @@ -24,6 +24,7 @@ using Android.Content; using Android.Graphics.Drawables; using Android.OS; using Android.Runtime; +using Android.Views; using Android.Widget; using KeePassLib; using KeePassLib.Cryptography.Cipher; @@ -517,7 +518,10 @@ namespace keepass2android internal void ShowToast(string message) { var handler = new Handler(Looper.MainLooper); - handler.Post(() => { Toast.MakeText(Application.Context, message, ToastLength.Long).Show(); }); + handler.Post(() => { var toast = Toast.MakeText(Application.Context, message, ToastLength.Long); + toast.SetGravity(GravityFlags.Center, 0, 0); + toast.Show(); + }); } public void CouldntSaveToRemote(IOConnectionInfo ioc, Exception e) diff --git a/src/keepass2android/keepass2android.csproj b/src/keepass2android/keepass2android.csproj index 19989677..9f1e8717 100644 --- a/src/keepass2android/keepass2android.csproj +++ b/src/keepass2android/keepass2android.csproj @@ -30,7 +30,7 @@ full false bin\Debug - DEBUG;EXCLUDE_TWOFISH;EXCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;EXCLUDE_JAVAFILESTORAGE;EXCLUDE_KEYTRANSFORM + DEBUG;EXCLUDE_TWOFISH;INCLUDE_KEYBOARD;EXCLUDE_FILECHOOSER;INCLUDE_JAVAFILESTORAGE;EXCLUDE_KEYTRANSFORM prompt 4 False @@ -576,8 +576,6 @@ - -