diff --git a/Andro2UWP.sln b/Andro2UWP.sln
index a122648..eb8e090 100644
--- a/Andro2UWP.sln
+++ b/Andro2UWP.sln
@@ -7,17 +7,10 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Andro2UWP.Shared", "Andro2U
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Andro2UWP.Droid", "Andro2UWP\Andro2UWP.Droid\Andro2UWP.Droid.csproj", "{275B3515-3BBF-4541-A575-8674D2ECE676}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Andro2UWP.iOS", "Andro2UWP\Andro2UWP.iOS\Andro2UWP.iOS.csproj", "{26B683D4-3464-4DD6-8EBE-135CC7F76C2E}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Andro2UWP.UWP", "Andro2UWP\Andro2UWP.UWP\Andro2UWP.UWP.csproj", "{E92E8F8F-6BBB-4E5B-8D76-0CDA640E84F3}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Andro2UWP.Wasm", "Andro2UWP\Andro2UWP.Wasm\Andro2UWP.Wasm.csproj", "{BF4E7441-36FD-425C-96B9-B8CB0AB138C2}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneDrive.Sdk.Authentication.Xamarin.Android", "Andro2UWP\OneDrive.Sdk.Authentication.Xamarin.Android\OneDrive.Sdk.Authentication.Xamarin.Android.csproj", "{B68F871E-A9E1-40CB-92A7-0F602504895B}"
-EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
- Andro2UWP\Andro2UWP.Shared\Andro2UWP.Shared.projitems*{275b3515-3bbf-4541-a575-8674d2ece676}*SharedItemsImports = 4
Andro2UWP\Andro2UWP.Shared\Andro2UWP.Shared.projitems*{6279c845-92f8-4333-ab99-3d213163593c}*SharedItemsImports = 13
Andro2UWP\Andro2UWP.Shared\Andro2UWP.Shared.projitems*{e92e8f8f-6bbb-4e5b-8d76-0cda640e84f3}*SharedItemsImports = 4
EndGlobalSection
@@ -120,38 +113,6 @@ Global
{275B3515-3BBF-4541-A575-8674D2ECE676}.Release|x86.ActiveCfg = Release|Any CPU
{275B3515-3BBF-4541-A575-8674D2ECE676}.Release|x86.Build.0 = Release|Any CPU
{275B3515-3BBF-4541-A575-8674D2ECE676}.Release|x86.Deploy.0 = Release|Any CPU
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Ad-Hoc|Any CPU.ActiveCfg = Ad-Hoc|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Ad-Hoc|ARM.ActiveCfg = Ad-Hoc|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Ad-Hoc|iPhoneSimulator
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Ad-Hoc|iPhoneSimulator.Build.0 = Ad-Hoc|iPhoneSimulator
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Ad-Hoc|x64.ActiveCfg = Ad-Hoc|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Ad-Hoc|x86.ActiveCfg = Ad-Hoc|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.AppStore|Any CPU.ActiveCfg = AppStore|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.AppStore|ARM.ActiveCfg = AppStore|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.AppStore|iPhone.Build.0 = AppStore|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.AppStore|iPhoneSimulator.ActiveCfg = AppStore|iPhoneSimulator
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.AppStore|iPhoneSimulator.Build.0 = AppStore|iPhoneSimulator
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.AppStore|x64.ActiveCfg = AppStore|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.AppStore|x86.ActiveCfg = AppStore|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Debug|Any CPU.ActiveCfg = Debug|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Debug|ARM.ActiveCfg = Debug|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Debug|iPhone.ActiveCfg = Debug|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Debug|iPhone.Build.0 = Debug|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Debug|x64.ActiveCfg = Debug|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Debug|x86.ActiveCfg = Debug|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Release|Any CPU.ActiveCfg = Release|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Release|ARM.ActiveCfg = Release|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Release|iPhone.ActiveCfg = Release|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Release|iPhone.Build.0 = Release|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Release|x64.ActiveCfg = Release|iPhone
- {26B683D4-3464-4DD6-8EBE-135CC7F76C2E}.Release|x86.ActiveCfg = Release|iPhone
{E92E8F8F-6BBB-4E5B-8D76-0CDA640E84F3}.Ad-Hoc|Any CPU.ActiveCfg = Release|x64
{E92E8F8F-6BBB-4E5B-8D76-0CDA640E84F3}.Ad-Hoc|Any CPU.Build.0 = Release|x64
{E92E8F8F-6BBB-4E5B-8D76-0CDA640E84F3}.Ad-Hoc|Any CPU.Deploy.0 = Release|x64
@@ -214,102 +175,6 @@ Global
{E92E8F8F-6BBB-4E5B-8D76-0CDA640E84F3}.Release|x86.ActiveCfg = Release|x86
{E92E8F8F-6BBB-4E5B-8D76-0CDA640E84F3}.Release|x86.Build.0 = Release|x86
{E92E8F8F-6BBB-4E5B-8D76-0CDA640E84F3}.Release|x86.Deploy.0 = Release|x86
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.AppStore|Any CPU.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.AppStore|ARM.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.AppStore|ARM.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.AppStore|iPhone.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.AppStore|x64.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.AppStore|x64.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.AppStore|x86.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.AppStore|x86.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Debug|ARM.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Debug|iPhone.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Debug|iPhone.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Debug|x64.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Debug|x64.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Debug|x86.ActiveCfg = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Debug|x86.Build.0 = Debug|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Release|Any CPU.Build.0 = Release|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Release|ARM.ActiveCfg = Release|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Release|ARM.Build.0 = Release|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Release|iPhone.ActiveCfg = Release|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Release|iPhone.Build.0 = Release|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Release|x64.ActiveCfg = Release|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Release|x64.Build.0 = Release|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Release|x86.ActiveCfg = Release|Any CPU
- {BF4E7441-36FD-425C-96B9-B8CB0AB138C2}.Release|x86.Build.0 = Release|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.AppStore|Any CPU.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.AppStore|ARM.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.AppStore|ARM.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.AppStore|iPhone.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.AppStore|x64.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.AppStore|x64.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.AppStore|x86.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.AppStore|x86.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Debug|ARM.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Debug|iPhone.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Debug|iPhone.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Debug|x64.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Debug|x64.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Debug|x86.ActiveCfg = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Debug|x86.Build.0 = Debug|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Release|Any CPU.Build.0 = Release|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Release|ARM.ActiveCfg = Release|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Release|ARM.Build.0 = Release|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Release|iPhone.ActiveCfg = Release|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Release|iPhone.Build.0 = Release|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Release|x64.ActiveCfg = Release|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Release|x64.Build.0 = Release|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Release|x86.ActiveCfg = Release|Any CPU
- {B68F871E-A9E1-40CB-92A7-0F602504895B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Andro2UWP/Andro2UWP.Droid/Andro2UWP.Droid.csproj b/Andro2UWP/Andro2UWP.Droid/Andro2UWP.Droid.csproj
index a689966..990ac30 100644
--- a/Andro2UWP/Andro2UWP.Droid/Andro2UWP.Droid.csproj
+++ b/Andro2UWP/Andro2UWP.Droid/Andro2UWP.Droid.csproj
@@ -69,20 +69,23 @@
-
- 1.24.0
+
+
+ 2.0.7
-
- 4.34.0
+
+ 1.0.10
-
- 2.0.4
+
+ 13.0.1
3.0.1
-
-
+
+
@@ -98,7 +101,6 @@
-
@@ -129,12 +131,6 @@
-
-
- {b68f871e-a9e1-40cb-92a7-0f602504895b}
- OneDrive.Sdk.Authentication.Xamarin.Android
-
-
diff --git a/Andro2UWP/Andro2UWP.Droid/Main.cs b/Andro2UWP/Andro2UWP.Droid/Main.cs
index 70cfc23..7e3e320 100644
--- a/Andro2UWP/Andro2UWP.Droid/Main.cs
+++ b/Andro2UWP/Andro2UWP.Droid/Main.cs
@@ -23,7 +23,8 @@ namespace Andro2UWP.Droid
public class Application : Windows.UI.Xaml.NativeApplication
{
public Application(IntPtr javaReference, JniHandleOwnership transfer)
- : base(() => new App(), javaReference, transfer) // linia dla nowszej wersji
+ // : base(new App(), javaReference, transfer) // linia dla starszej wersji
+ : base(() => new App(), javaReference, transfer) // linia dla nowszej wersji
{
ConfigureUniversalImageLoader();
}
diff --git a/Andro2UWP/Andro2UWP.Droid/MainActivity.cs b/Andro2UWP/Andro2UWP.Droid/MainActivity.cs
index b628b46..f78c584 100644
--- a/Andro2UWP/Andro2UWP.Droid/MainActivity.cs
+++ b/Andro2UWP/Andro2UWP.Droid/MainActivity.cs
@@ -18,7 +18,7 @@ public class MainActivity : Windows.UI.Xaml.ApplicationActivity
protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
- Uno.OneDrive.Connector.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
+ //Uno.OneDrive.Connector.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
}
}
}
diff --git a/Andro2UWP/Andro2UWP.Droid/OnedriveDroid.cs b/Andro2UWP/Andro2UWP.Droid/OnedriveDroid.cs
deleted file mode 100644
index 7dd20d8..0000000
--- a/Andro2UWP/Andro2UWP.Droid/OnedriveDroid.cs
+++ /dev/null
@@ -1,973 +0,0 @@
-// LeversonCarlos
-// Xamarin.OneDrive.Connector
-
-// https://github.com/LeversonCarlos/Xamarin.OneDrive.Connector
-
-using Android.App;
-using Android.Content;
-using Microsoft.Identity.Client;
-using System;
-using System.Threading.Tasks;
-using System.Net.Http;
-using System.Net;
-using System.Threading;
-using System.Linq;
-using System.Runtime.Serialization;
-using System.Collections.Generic;
-
-namespace Uno.OneDrive
-{
-
- #region "Xamarin.OneDrive.Connector"
- partial class Connector
- {
-
- public static void SetAuthenticationContinuationEventArgs(int requestCode, Result resultCode, Intent data)
- {
- Microsoft.Identity.Client.AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
- }
-
- }
-
-
- internal class Configs : IDisposable
- {
-
- public string ClientID { get; set; }
- public string[] Scopes { get; set; }
-
- internal string RedirectUri { get; set; }
- internal object UiParent { get; set; }
-
- public void Dispose()
- {
- this.UiParent = null;
- }
-
- }
-
- internal class DependencyImplementation : IDependency
- {
- internal Context _activity;
- internal string _redirectUrl;
-
- public void Initialize(Configs configs)
- {
- if (_activity != null)
- {
- configs.UiParent = _activity;
- }
- else
- {
- // Uno.UI.BaseActivity.Current; // Android.App.Application.Context;
- // Xamarin.Forms.Forms.Context as Forms.Platform.Android.FormsAppCompatActivity;
- Context mainActivity = Android.App.Application.Context;
-
- configs.UiParent = mainActivity;
- }
- if (!string.IsNullOrEmpty(_redirectUrl))
- {
- configs.RedirectUri = _redirectUrl;
- }
- else
- {
- //configs.RedirectUri = "https://login.microsoftonline.com/common/oauth2/nativeclient";
- configs.RedirectUri = $"msal{configs.ClientID}://auth";
- }
- }
-
- public async Task GetAuthResult(Microsoft.Identity.Client.IPublicClientApplication client, Configs configs)
- {
-
- Activity aktywnosc = Uno.UI.BaseActivity.Current; // (Activity)configs.UiParent;
- try
- {
- return await client
- .AcquireTokenInteractive(configs.Scopes)
- .WithParentActivityOrWindow(aktywnosc)
- .ExecuteAsync();
- }
- catch (Exception) { throw; }
- }
-
- }
-
- partial class Connector
- {
-
- public static void Init(Context activity) { Init(activity, ""); }
-
- public static void Init(Context activity, string redirectUrl)
- {
- var dependency = (DependencyImplementation)Dependency.Current;
- dependency._activity = activity;
- dependency._redirectUrl = redirectUrl;
- }
-
- }
-
-
- internal interface IDependency
- {
- void Initialize(Configs configs);
- Task GetAuthResult
- (Microsoft.Identity.Client.IPublicClientApplication client, Configs configs);
- }
-
- internal class Dependency
- {
-
- static Lazy implementation = new Lazy(
- () => CreateDependency(), LazyThreadSafetyMode.PublicationOnly);
-
- static IDependency CreateDependency()
- {
- // #pragma warning disable IDE0022 // Use expression body for methods
- return new DependencyImplementation();
- // #pragma warning restore IDE0022 // Use expression body for methods
- }
-
- public static IDependency Current
- {
- get
- {
- IDependency ret = implementation.Value;
- if (ret == null)
- {
- throw new NotImplementedException(
- "This functionality is not implemented in the portable version of this assembly. " +
- "You should reference the NuGet package from your main application project " +
- "in order to reference the platform-specific implementation.");
- }
- return ret;
- }
- }
-
- }
-
- partial class Connector
- {
-
- public async Task ConnectAsync()
- {
- return await this.ConnectorAsync(ConnectorHandler.InnerConnectionConnect);
- }
-
- public async Task DisconnectAsync()
- {
- return await this.ConnectorAsync(ConnectorHandler.InnerConnectionDisconnect);
- }
-
- private async Task ConnectorAsync(string connectorState)
- {
- try
- {
- var httpParam = new StringContent(connectorState);
- var httpMessage = await this.PostAsync(ConnectorHandler.InnerConnectionPath, httpParam);
- if (httpMessage.IsSuccessStatusCode) { return true; }
- else
- {
- var httpReason = httpMessage.ReasonPhrase;
- var httpContent = string.Empty;
- if (httpMessage.Content != null)
- {
- httpContent = await httpMessage.Content.ReadAsStringAsync();
- }
- throw new Exception($"{httpReason}\n{httpContent}");
- }
- }
- catch (Exception) { throw; }
- }
-
- }
-
- public partial class Connector : HttpClient
- {
- const string BaseURL = "https://graph.microsoft.com/v1.0/";
- internal Configs mConfig = null;
- internal bool mWrite = false;
- public Connector(string clientID, params string[] scopes) :
- this(
- new Configs { ClientID = clientID, Scopes = scopes }
- )
- { }
-
- internal Connector(Configs configs) : base(new ConnectorHandler(configs))
- {
- this.BaseAddress = new Uri(BaseURL);
- mConfig = configs;
- foreach (string scope in configs.Scopes)
- {
- if (scope.Contains("Write"))
- mWrite = true;
- }
- }
-
- }
- partial class ConnectorHandler
- {
-
- public HttpResponseMessage CreateMessage(HttpStatusCode statusCode)
- {
- return this.CreateMessage(statusCode, string.Empty);
- }
-
- public HttpResponseMessage CreateMessage(HttpStatusCode statusCode, string content)
- {
- var responseMessage = new HttpResponseMessage(statusCode);
- if (!string.IsNullOrEmpty(content))
- {
- responseMessage.Content = new StringContent(content);
- }
- return responseMessage;
- }
-
- }
-
- internal partial class ConnectorHandler : DelegatingHandler
- {
- Token Token { get; set; }
- internal const string InnerConnectionPath = "Xamarin-OneDrive-Connector";
- internal const string InnerConnectionConnect = "CONNECT";
- internal const string InnerConnectionDisconnect = "DISCONNECT";
-
- public ConnectorHandler(Configs configs)
- {
-
- // VALIDATION
- if (configs == null)
- { throw new NullReferenceException("The configs parameter must be defined with the " +
- "microsoft graph definitions");
- }
-
- if (string.IsNullOrEmpty(configs.ClientID))
- { throw new ArgumentNullException("Your microsoft graph client id must be informed");
- }
-
- if (configs.Scopes == null || configs.Scopes.Length == 0)
- { throw new ArgumentNullException("Your microsoft graph required scopes must be informed");
- }
-
- if (configs.Scopes.Count(x => !string.IsNullOrEmpty(x)) == 0)
- { throw new ArgumentNullException("Your microsoft graph required scopes must be informed");
- }
-
- // INITIALIZATION
- Dependency.Current.Initialize(configs);
- this.Token = new Token(configs);
- this.InnerHandler = new HttpClientHandler();
- }
-
- protected async override Task SendAsync
- (
- HttpRequestMessage request,
- CancellationToken cancellationToken
- )
- {
-
- var InnerConnectionResult = await this.InnerConnectionHandlerAsync(request, cancellationToken);
- if (InnerConnectionResult.StatusCode != HttpStatusCode.SeeOther) { return InnerConnectionResult; }
-
- if (!await this.Token.ConnectAsync())
- {
- return this.CreateMessage(HttpStatusCode.Unauthorized, "The token connect method has failed");
- }
-
- request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer",
- this.Token.CurrentToken);
-
- return await base.SendAsync(request, cancellationToken);
-
- }
-
- private async Task InnerConnectionHandlerAsync(HttpRequestMessage request,
- CancellationToken cancellationToken)
- {
- try
- {
- if (!request.RequestUri.AbsolutePath.EndsWith(InnerConnectionPath))
- {
- return this.CreateMessage(HttpStatusCode.SeeOther);
- }
-
- if (request.Method != HttpMethod.Post || request.Content == null)
- {
- return this.CreateMessage(HttpStatusCode.BadRequest,
- "Method must be POST and content must be CONNECT or DISCONNECT");
- }
-
- var command = await request.Content.ReadAsStringAsync();
-
- if (command == InnerConnectionConnect)
- {
- var result = await this.Token.ConnectAsync();
- if (result)
- {
- return this.CreateMessage(HttpStatusCode.OK);
- }
- else
- {
- return this.CreateMessage(HttpStatusCode.InternalServerError,
- "The token connect method has failed");
- }
- }
- else if (command == InnerConnectionDisconnect)
- {
- await this.Token.DisconnectAsync();
- return this.CreateMessage(HttpStatusCode.OK);
- }
- else
- {
- return this.CreateMessage(HttpStatusCode.BadRequest,
- "Method must be POST and content must be CONNECT or DISCONNECT");
- }
-
- }
- catch (Exception ex)
- {
- return this.CreateMessage(HttpStatusCode.InternalServerError, ex.ToString());
- }
- }
-
- }
- partial class Token
- {
-
- internal async Task AcquireAsync()
- {
- try
- {
- this.AuthResult = await Dependency.Current.GetAuthResult(this.Client, this.Configs);
- return this.IsValid();
- }
- catch (Exception) { throw; }
- }
-
- }
- partial class Token
- {
-
- internal async Task ConnectAsync()
- {
- try
- {
-
- // TOKEN STILL VALID
- if (this.IsValid()) { return true; }
-
- // REFRESH AN EXPIRED TOKEN
- if (await this.RefreshAsync()) { return true; }
-
- // ACQUIRE A NEW TOKEN
- if (await this.AcquireAsync()) { return true; }
-
- // OTHERWISE
- return false;
-
- }
- catch (Exception) { throw; }
- }
-
- internal async Task DisconnectAsync()
- {
- try
- {
- var accounts = await this.Client.GetAccountsAsync();
- if (accounts != null && accounts.Count() != 0)
- {
- foreach (var account in accounts)
- { await this.Client.RemoveAsync(account); }
- }
-
- }
- catch (Exception) { throw; }
- }
-
- }
- partial class Token
- {
- AuthenticationResult AuthResult { get; set; }
-
- internal string CurrentToken
- {
- get
- {
- if (!this.IsValid()) { return string.Empty; }
- return this.AuthResult.AccessToken;
- }
- }
-
- internal bool IsValid()
- {
- if (this.AuthResult == null) { return false; }
- if (string.IsNullOrEmpty(this.AuthResult.AccessToken)) { return false; }
- return (this.AuthResult.ExpiresOn > DateTimeOffset.UtcNow.AddMinutes(5));
- }
-
- }
- partial class Token
- {
-
- internal async Task RefreshAsync()
- {
- try
- {
- var accounts = await this.Client.GetAccountsAsync();
- if (accounts != null && accounts.Count() != 0)
- {
- var account = accounts.FirstOrDefault();
- if (account != null)
- {
- this.AuthResult =
- await this.Client.AcquireTokenSilent(this.Configs.Scopes, account).ExecuteAsync();
- }
- }
- return this.IsValid();
- }
- catch (Exception) { throw; }
- }
-
- }
- internal partial class Token : IDisposable
- {
- internal Configs Configs { get; private set; }
- IPublicClientApplication Client { get; set; }
-
- internal Token(Configs configs)
- {
- this.Configs = configs;
-
- var builder = PublicClientApplicationBuilder.Create(configs.ClientID);
-
- if (!string.IsNullOrEmpty(configs.RedirectUri))
- {
- builder = builder.WithRedirectUri(configs.RedirectUri);
- }
-
- this.Client = builder.Build();
- }
-
- public void Dispose()
- {
- this.Client = null;
- this.AuthResult = null;
- this.Configs.Dispose();
- this.Configs = null;
- }
-
- }
-
- #endregion
-
- #region "Xamarin.OneDrive.Connector.Files"
-
- #region "structy"
- [DataContract]
- public class FileData
- {
-
- [DataMember(Name = "id")]
- public string id { get; set; }
-
- [DataMember(Name = "name")]
- public string FileName { get; set; }
-
- [DataMember(Name = "path")]
- public string FilePath { get; set; }
-
- [DataMember(Name = "createdDateTime")]
- internal string CreatedDateTimeText { get; set; }
- public DateTime? CreatedDateTime { get; set; }
-
- [DataMember(Name = "size")]
- public long? Size { get; set; }
-
- [DataMember(Name = "@microsoft.graph.downloadUrl")]
- internal string downloadUrl { get; set; }
-
- [DataMember(Name = "parentReference")]
- internal FileData parentReference { get; set; }
- public string parentID { get; set; }
-
- [DataMember(Name = "folder")]
- internal FolderData folderData { get; set; }
-
- [DataMember(Name = "file")]
- internal FileDetailsData fileData { get; set; }
-
- }
-
- [DataContract]
- internal class FileDetailsData
- {
-
- [DataMember(Name = "mimeType")]
- internal string mimeType { get; set; }
-
- }
-
- [DataContract]
- internal class FolderData
- {
-
- [DataMember(Name = "childCount")]
- internal int childCount { get; set; }
-
- }
-
- [DataContract]
- internal class SearchData
- {
-
- [DataMember(Name = "value")]
- public List Files { get; set; }
-
- [DataMember(Name = "@odata.nextLink")]
- public string nextLink { get; set; }
-
- }
- #endregion
- #region "folders"
- partial class Connector
- {
- public async Task> GetChildFoldersAsync()
- {
- try
- {
- var httpPath = $"me/drive/root/children";
- var folderList = await GetChildFoldersAsync(httpPath);
- folderList.ForEach(x => x.FilePath = $"/ {x.FileName}");
- return folderList;
- }
- catch (Exception) { throw; }
- }
-
- public async Task> GetChildFoldersAsync(FileData folder)
- {
- // MOJ DODATEK upraszczajacy moje funkcje
- if (folder is null)
- return await GetChildFoldersAsync();
-
- try
- {
- var httpPath = $"me/drive/items/{folder.id}/children";
- var folderList = await GetChildFoldersAsync(httpPath);
- folderList.ForEach(x => x.FilePath = $"{folder.FilePath} / {x.FileName}");
- return folderList;
- }
- catch (Exception) { throw; }
- }
-
- private async Task> GetChildFoldersAsync(string httpPath)
- {
- try
- {
- var folderList = new List();
- httpPath += "?select=id,name,folder&$top=1000";
-
- while (!string.IsNullOrEmpty(httpPath))
- {
-
- // REQUEST DATA FROM SERVER
- var httpMessage = await GetAsync(httpPath);
- if (!httpMessage.IsSuccessStatusCode)
- { throw new Exception(await httpMessage.Content.ReadAsStringAsync()); }
-
- // SERIALIZE AND STORE RESULT
- var httpContent = await httpMessage.Content.ReadAsStreamAsync();
- var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(SearchData));
- var httpResult = (SearchData)serializer.ReadObject(httpContent);
- var folders = httpResult.Files.Where(x => x.folderData != null).ToList();
- folderList.AddRange(folders);
-
- // CHECK IF THERE IS ANOTHER PAGE OF RESULTS
- httpPath = httpResult.nextLink;
- if (!string.IsNullOrEmpty(httpPath))
- { httpPath = httpPath.Replace(BaseAddress.AbsoluteUri, string.Empty); }
-
- }
-
- // NORMALIZE FOLDER's PATHS
- foreach (var folder in folderList)
- {
- if (string.IsNullOrEmpty(folder.FilePath))
- { folder.FilePath = string.Empty; }
-
- var sep = folder.FilePath.IndexOf(":");
- if (sep != -1)
- { folder.FilePath = folder.FilePath.Substring(sep + 1); }
-
- folder.FilePath = Uri.UnescapeDataString(folder.FilePath);
- }
-
- // RESULT
- folderList = folderList
- .OrderBy(x => x.FilePath)
- .ThenBy(x => x.FileName)
- .ToList();
- return folderList;
-
- }
- catch (Exception) { throw; }
- }
-
-
- public async Task> GetChildFilesAsync(FileData folder)
- {
- try
- {
- var fileList = new List();
- var httpPath = $"me/drive/items/{folder.id}/children";
- httpPath += "?select=id,name,createdDateTime,size,file&$top=1000";
-
- while (!string.IsNullOrEmpty(httpPath))
- {
-
- // REQUEST DATA FROM SERVER
- var httpMessage = await GetAsync(httpPath);
- if (!httpMessage.IsSuccessStatusCode)
- { throw new Exception(await httpMessage.Content.ReadAsStringAsync()); }
-
- // SERIALIZE AND STORE RESULT
- var httpContent = await httpMessage.Content.ReadAsStreamAsync();
- var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(SearchData));
- var httpResult = (SearchData)serializer.ReadObject(httpContent);
- var files = httpResult.Files.Where(x => x.fileData != null).ToList();
- fileList.AddRange(files);
-
- // CHECK IF THERE IS ANOTHER PAGE OF RESULTS
- httpPath = httpResult.nextLink;
- if (!string.IsNullOrEmpty(httpPath))
- { httpPath = httpPath.Replace(BaseAddress.AbsoluteUri, string.Empty); }
-
- }
-
- // NORMALIZE FILE's PATHS
- foreach (var file in fileList)
- {
- file.parentID = folder.id;
- file.FilePath = folder.FilePath;
- }
-
- // RESULT
- return fileList;
-
- }
- catch (Exception) { throw; }
- }
- }
- #endregion
- #region "Files"
-
- partial class Connector
- {
- public async Task GetDetailsAsync()
- {
- var httpPath = $"me/drive/root";
- var folder = await GetDetailsAsync(httpPath);
- if (string.IsNullOrEmpty(folder.FilePath))
- { folder.FilePath = "/drive/root:"; }
- return folder;
- }
-
- public async Task GetDetailsAsync(FileData folder)
- {
- var httpPath = $"me/drive/items/{folder.id}";
- return await GetDetailsAsync(httpPath);
- }
-
- private async Task GetDetailsAsync(string httpPath)
- {
- try
- {
- httpPath += "?select=id,name,parentReference";
-
- // REQUEST DATA FROM SERVER
- var httpMessage = await GetAsync(httpPath);
- if (!httpMessage.IsSuccessStatusCode)
- { throw new Exception(await httpMessage.Content.ReadAsStringAsync()); }
-
- // SERIALIZE AND STORE RESULT
- var httpContent = await httpMessage.Content.ReadAsStreamAsync();
- var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(FileData));
- var httpResult = (FileData)serializer.ReadObject(httpContent);
-
- // RESULT
- if (httpResult.parentReference != null)
- { httpResult.FilePath = httpResult.parentReference.FilePath; }
- return httpResult;
-
- }
- catch (Exception) { throw; }
- }
- }
-
- #endregion
-
- #region "upload"
- partial class Connector
- {
-
- public async Task UploadAsync(FileData file, System.IO.Stream content)
- {
- try
- {
-
- var httpPath = $"me/drive/items/{file.id}/content";
- if (string.IsNullOrEmpty(file.id))
- { httpPath = $"me/drive/items/{file.parentID}:/{file.FileName}:/content"; }
- var httpData = new System.Net.Http.StreamContent(content);
- var httpMessage = await PutAsync(httpPath, httpData);
-
- if (!httpMessage.IsSuccessStatusCode)
- { throw new Exception(await httpMessage.Content.ReadAsStringAsync()); }
-
- var httpContent = await httpMessage.Content.ReadAsStreamAsync();
- var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(FileData));
- var httpResult = (FileData)serializer.ReadObject(httpContent);
-
- return httpResult;
-
- }
- catch (Exception) { throw; }
- }
-
- }
- #endregion
-
- #endregion
-
- #region "moje dodatki"
-
- public partial class Connector
- {
-
- public async Task GetThisAppFolderAsync()
- {
- var httpMessage = await GetAsync("drive/special/approot:/");
- if (!httpMessage.IsSuccessStatusCode)
- { throw new Exception(await httpMessage.Content.ReadAsStringAsync()); }
-
- // SERIALIZE AND STORE RESULT
- var httpContent = await httpMessage.Content.ReadAsStreamAsync();
- var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(FileData));
- var httpResult = (FileData)serializer.ReadObject(httpContent);
-
- // RESULT
- if (httpResult.parentReference != null)
- { httpResult.FilePath = httpResult.parentReference.FilePath; }
- return httpResult;
- }
-
-
- public async Task CreateFolder(FileData parentFolder, string folderName)
- {
- // if cannot write, then don't even try
- if (!mWrite)
- return null;
-
- string httpPath;
- if (parentFolder is null)
- {
- // zakladamy folder w glownym (rzadko, albo w ogole nie uzywany bedzie to kod
- httpPath = "me/drive/root/children";
- }
- else
- {
- httpPath = "me/drive/items/" + parentFolder.id + "/children";
- }
-
- var jsonCommand = "{ \"name\": \"" + folderName + "\", \"folder\": { }, \"@microsoft.graph.conflictBehavior\": \"rename\" }";
- var httpData = new StringContent(jsonCommand, System.Text.Encoding.UTF8, "application/json");
- var httpMessage = await PutAsync(httpPath, httpData);
-
- if (!httpMessage.IsSuccessStatusCode)
- { throw new Exception(await httpMessage.Content.ReadAsStringAsync()); }
-
- var httpContent = await httpMessage.Content.ReadAsStreamAsync();
- var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(FileData));
- var httpResult = (FileData)serializer.ReadObject(httpContent);
-
- return httpResult;
-
- }
-
- public async Task OpenOrCreateFolder(FileData parentFolder, string folderName)
- {
- if (parentFolder is null) return null;
- if (string.IsNullOrEmpty(parentFolder.id)) return null;
- if (string.IsNullOrEmpty(folderName)) return null;
-
-
- FileData thisLevel = null;
- foreach (var subfold in await GetChildFoldersAsync(parentFolder))
- {
- if (subfold.FileName == folderName)
- {
- thisLevel = subfold;
- break;
- }
- }
-
- if (thisLevel is null)
- {
- thisLevel = await CreateFolder(parentFolder, folderName);
- }
-
- return null;
-
- }
-
-
- public async Task OpenOrCreateFolder(string folderPath)
- {
- if (string.IsNullOrEmpty(folderPath))
- return null;
-
- folderPath = folderPath.Replace("\\", "/"); // na wszelki wypadek
- string[] pathParts = folderPath.Split("/");
-
- FileData thisLevel = null;
- FileData parentLevel = null;
-
- for (int i = 0; i < pathParts.Count(); i++)
- {
- // jesli zapis jest /cos/cos, to pierwszy / jest do pominiecia, a i tak zaczynamy od root
- if (pathParts[i] == "")
- break;
-
- thisLevel = await OpenOrCreateFolder(parentLevel, pathParts[i]);
-
- if (thisLevel is null)
- return null;
-
- parentLevel = thisLevel;
- }
-
- return thisLevel;
- }
-
- public async Task SaveFile(FileData parentFolder, string fileName, string fileContent)
- {
- // if cannot write, then don't even try
- if (!mWrite)
- return null;
-
- if (parentFolder is null)
- return null; // nie obslugujemy zapisu do glownego katalogu
-
- try
- {
-
- var httpPath = $"me/drive/items/{parentFolder.id}:/{fileName}:/content";
-
- var httpData = new System.Net.Http.StringContent(fileContent);
- var httpMessage = await PutAsync(httpPath, httpData);
-
- if (!httpMessage.IsSuccessStatusCode)
- {
- System.Diagnostics.Debug.WriteLine("--------OneDrive error: \n" + await httpMessage.Content.ReadAsStringAsync());
- return null;
- }
-
- var httpContent = await httpMessage.Content.ReadAsStreamAsync();
- var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(FileData));
- var httpResult = (FileData)serializer.ReadObject(httpContent);
-
- return httpResult;
-
- }
- catch
- {
- return null;
- }
- }
- private async Task ReadFile(string httpPath)
- {
- var httpMessage = await GetAsync(httpPath);
-
- if (!httpMessage.IsSuccessStatusCode)
- {
- System.Diagnostics.Debug.WriteLine("--------OneDrive error: \n" + await httpMessage.Content.ReadAsStringAsync());
- return null;
- }
- return await httpMessage.Content.ReadAsStringAsync();
- }
-
- public async Task ReadFile(FileData file)
- {
- var httpPath = $"me/drive/items/{file.id}/content";
- return await ReadFile(httpPath);
- }
-
- public async Task ReadFile(FileData parentFolder, string fileName)
- {
- if (parentFolder is null)
- return null; // nie obslugujemy zapisu do glownego katalogu
-
- var httpPath = $"me/drive/items/{parentFolder.id}:/{fileName}:/content";
- return await ReadFile(httpPath);
- }
- private async Task GetFileStream(string httpPath)
- {
- var httpMessage = await GetAsync(httpPath);
-
- if (!httpMessage.IsSuccessStatusCode)
- {
- System.Diagnostics.Debug.WriteLine("--------OneDrive error: \n" + await httpMessage.Content.ReadAsStringAsync());
- return null;
- }
-
- return await httpMessage.Content.ReadAsStreamAsync();
- }
-
- public async Task GetFileStream(FileData file)
- {
- var httpPath = $"me/drive/items/{file.id}/content";
- return await GetFileStream(httpPath);
- }
-
- public async Task GetFileStream(FileData parentFolder, string fileName)
- {
- if (parentFolder is null)
- return null; // nie obslugujemy zapisu do glownego katalogu
-
- var httpPath = $"me/drive/items/{parentFolder.id}:/{fileName}:/content";
- return await GetFileStream(httpPath);
- }
-
- public async Task DeleteFile(FileData file)
- {
- if (string.IsNullOrEmpty(file.id))
- throw new ArgumentException("OneDrive.DeleteFile called with null FileData.id");
-
- var httpMessage = await DeleteAsync("drive/items/" + file.id);
- return httpMessage.IsSuccessStatusCode;
- }
-
- public async Task DeleteFile(string httpFilePath)
- {
- if (string.IsNullOrEmpty(httpFilePath))
- throw new ArgumentException("OneDrive.DeleteFile called with null httpFilePath");
-
- if (!httpFilePath.StartsWith("/"))
- httpFilePath = "/" + httpFilePath;
- var httpMessage = await DeleteAsync("drive/root:" + httpFilePath);
- return httpMessage.IsSuccessStatusCode;
- }
-
- public async Task DeleteFile(FileData parentFolder, string fileName)
- {
- if (string.IsNullOrEmpty(parentFolder.id))
- throw new ArgumentException("OneDrive.DeleteFile called with null parentFolder.id");
- if (string.IsNullOrEmpty(fileName))
- throw new ArgumentException("OneDrive.DeleteFile called with null fileName");
-
- var httpMessage = await DeleteAsync("drive/items/" + parentFolder.id + ":/" + fileName);
- return httpMessage.IsSuccessStatusCode;
- }
-
-
- }
- #endregion
-}
diff --git a/Andro2UWP/Andro2UWP.Shared/AccountSelection.xaml.cs b/Andro2UWP/Andro2UWP.Shared/AccountSelection.xaml.cs
index 5e63c19..1b2eca1 100644
--- a/Andro2UWP/Andro2UWP.Shared/AccountSelection.xaml.cs
+++ b/Andro2UWP/Andro2UWP.Shared/AccountSelection.xaml.cs
@@ -2,8 +2,8 @@
namespace Andro2UWP
{
#if __ANDROID__
- using Android.App;
- using Android.Content;
+ using Android.App;
+ using Android.Content;
#endif
using Microsoft.Graph;
using Microsoft.OneDrive.Sdk;
@@ -14,7 +14,7 @@ namespace Andro2UWP
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
-
+
///
/// An empty page that can be used on its own or navigated to within a Frame.
///
@@ -26,7 +26,7 @@ private enum ClientType
Consumer,
ConsumerUwp
}
-
+
// Set these values to your app's ID and return URL.
private readonly string oneDriveForBusinessClientId = "Insert your OneDrive for Business client id";
private readonly string oneDriveForBusinessReturnUrl = "http://localhost:8080";
@@ -36,11 +36,11 @@ private enum ClientType
private readonly string oneDriveConsumerReturnUrl = "msal560b76b6-f929-4200-b8b0-70892f08f94a://auth";//"https://login.live.com/oauth20_desktop.srf";
private readonly string oneDriveConsumerBaseUrl = "https://api.onedrive.com/v1.0";
- private readonly string[] scopes = new string[]
- {
+ private readonly string[] scopes = new string[]
+ {
"onedrive.readonly", // ok! //"onedrive.readwrite", //RnD
"onedrive.appfolder", // ok
- "wl.signin",
+ "wl.signin",
"offline_access"
};
@@ -54,9 +54,9 @@ public AccountSelectionPage()
private async void AccountSelection_Loaded(object sender, RoutedEventArgs e)
{
-
- App app = ((App) Windows.UI.Xaml.Application.Current);
-
+
+ App app = ((App)Windows.UI.Xaml.Application.Current);
+
if (app.uOneDriveClient != null)
{
@@ -71,7 +71,7 @@ private async void AccountSelection_Loaded(object sender, RoutedEventArgs e)
//{
// await adalAuthProvider.SignOutAsync();
//}
-
+
app.uOneDriveClient = null;
}
@@ -106,8 +106,8 @@ private void OnlineId_Click(object sender, RoutedEventArgs e)
private async void InitializeClient(ClientType clientType, RoutedEventArgs e)
{
-
- var app = (App) Windows.UI.Xaml.Application.Current;
+
+ var app = (App)Windows.UI.Xaml.Application.Current;
if (app.uOneDriveClient == null)
{
@@ -132,23 +132,23 @@ private async void InitializeClient(ClientType clientType, RoutedEventArgs e)
app.AuthProvider = adalAuthProvider; // !
*/
-
+
}
else if (clientType == ClientType.ConsumerUwp)
{
- /*
- var onlineIdAuthProvider = new OnlineIdAuthenticationProvider
- (
- this.scopes
- );
+ /*
+ var onlineIdAuthProvider = new OnlineIdAuthenticationProvider
+ (
+ this.scopes
+ );
+
+ authTask = onlineIdAuthProvider.RestoreMostRecentFromCacheOrAuthenticateUserAsync();
- authTask = onlineIdAuthProvider.RestoreMostRecentFromCacheOrAuthenticateUserAsync();
+ app.uOneDriveClient = new OneDriveClient(this.oneDriveConsumerBaseUrl, onlineIdAuthProvider);
+
+ app.AuthProvider = onlineIdAuthProvider; // !
+ */
- app.uOneDriveClient = new OneDriveClient(this.oneDriveConsumerBaseUrl, onlineIdAuthProvider);
-
- app.AuthProvider = onlineIdAuthProvider; // !
- */
-
}
else
{
@@ -163,7 +163,7 @@ private async void InitializeClient(ClientType clientType, RoutedEventArgs e)
);
#else
Android.Content.Context ctxt = Android.App.Application.Context;
-
+
var msaAuthProvider = new MsaAuthenticationProvider
(
ctxt, // RnD
@@ -186,9 +186,9 @@ private async void InitializeClient(ClientType clientType, RoutedEventArgs e)
try
{
//await authTask;
-
+
//app.NavigationStack.Add(new ItemModel(new Item()));
-
+
this.Frame.Navigate(typeof(MainPage), e);
}
catch (Exception ex) //catch (ServiceException exception)
@@ -205,16 +205,16 @@ private async void InitializeClient(ClientType clientType, RoutedEventArgs e)
}
//else
//{
- // Go to Main page
- this.Frame.Navigate(typeof(MainPage), e);
+ // Go to Main page
+ this.Frame.Navigate(typeof(MainPage), e);
//}
-
+
//temp
//this.Frame.Navigate(typeof(MainPage), e);
}//InitializeClient
-
+
}//class end
}//namespace end
diff --git a/Andro2UWP/Andro2UWP.Shared/Andro2UWP.Shared.2021.07.11.zip b/Andro2UWP/Andro2UWP.Shared/Andro2UWP.Shared.2021.07.11.zip
new file mode 100644
index 0000000..1728b45
Binary files /dev/null and b/Andro2UWP/Andro2UWP.Shared/Andro2UWP.Shared.2021.07.11.zip differ
diff --git a/Andro2UWP/Andro2UWP.Shared/Andro2UWP.Shared.projitems b/Andro2UWP/Andro2UWP.Shared/Andro2UWP.Shared.projitems
index 25e5a07..f6faeba 100644
--- a/Andro2UWP/Andro2UWP.Shared/Andro2UWP.Shared.projitems
+++ b/Andro2UWP/Andro2UWP.Shared/Andro2UWP.Shared.projitems
@@ -28,6 +28,7 @@
MainPage.xaml
+
Settings.xaml
@@ -52,9 +53,14 @@
-
+
+
+ Designer
+
-
+
+
+
\ No newline at end of file
diff --git a/Andro2UWP/Andro2UWP.Shared/App.xaml b/Andro2UWP/Andro2UWP.Shared/App.xaml
index 103d8e8..cf5da64 100644
--- a/Andro2UWP/Andro2UWP.Shared/App.xaml
+++ b/Andro2UWP/Andro2UWP.Shared/App.xaml
@@ -3,5 +3,4 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Andro2UWP">
-
diff --git a/Andro2UWP/Andro2UWP.Shared/App.xaml.cs b/Andro2UWP/Andro2UWP.Shared/App.xaml.cs
index 9a4d752..cb35aa2 100644
--- a/Andro2UWP/Andro2UWP.Shared/App.xaml.cs
+++ b/Andro2UWP/Andro2UWP.Shared/App.xaml.cs
@@ -2,7 +2,10 @@
// Shared code
// 2022
-
+//#if __ANDROID__
+//using Android.App;
+//using Android.Content;
+//#endif
using Andro2UWP.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Graph;
@@ -29,7 +32,7 @@
using Windows.UI.Xaml.Navigation;
namespace Andro2UWP
-{
+{
sealed partial class App : Application
{
@@ -100,7 +103,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
// PKAR added wedle https://stackoverflow.com/questions/39262926/uwp-hardware-back-press-work-correctly-in-mobile-but-error-with-pc
rootFrame.Navigated += OnNavigatedAddBackButton;
-
+
Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += OnBackButtonPressed;
//if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
@@ -141,7 +144,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
-
+
// Ensure the current window is active
Windows.UI.Xaml.Window.Current.Activate();
@@ -156,7 +159,7 @@ public void SighOffIfNeeded()
if (app.uOneDriveClient != null)
{
- MsaAuthenticationProvider msaAuthProvider =
+ MsaAuthenticationProvider msaAuthProvider =
app.AuthProvider as MsaAuthenticationProvider;
//var adalAuthProvider = app.AuthProvider as AdalAuthenticationProvider;
@@ -182,7 +185,7 @@ public async void SighInIfNeeded(ClientType clientType, LaunchActivatedEventArgs
{
Frame rootFrame = Windows.UI.Xaml.Window.Current.Content as Frame;
- var app = (App)Application.Current;
+ var app = (App)Application.Current;
if (app.uOneDriveClient == null)
{
@@ -217,7 +220,7 @@ public async void SighInIfNeeded(ClientType clientType, LaunchActivatedEventArgs
// RnD
// = null;
- app.uOneDriveClient =
+ app.uOneDriveClient =
new OneDriveClient
(
GoneDriveConsumerBaseUrl, //this.GoneDriveConsumerBaseUrl,
@@ -225,7 +228,7 @@ public async void SighInIfNeeded(ClientType clientType, LaunchActivatedEventArgs
);
app.AuthProvider = msaAuthProvider; // !
-
+
try
{
@@ -234,7 +237,7 @@ public async void SighInIfNeeded(ClientType clientType, LaunchActivatedEventArgs
//app.NavigationStack.Add(new ItemModel(new Item()));
//this.Frame.Navigate(typeof(MainPage), e);
-
+
}
catch (Exception ex) //catch (ServiceException exception)
{
@@ -245,16 +248,15 @@ public async void SighInIfNeeded(ClientType clientType, LaunchActivatedEventArgs
Debug.WriteLine("AccountSelection - InitializeClient - exception: " + ex.Message);
// TODO : error hadling
-
- // Redirect to MainPage
- rootFrame.Navigate(typeof(MainPage));//, e.Arguments);
+
+ // RnD: Redirect to MainPage from here...
+ //rootFrame.Navigate(typeof(MainPage));//, e.Arguments);
}
}
- // Redirect to MainPage
- // RnD
- rootFrame.Navigate(typeof(MainPage));//, e.Arguments);
+ // RnD: Redirect to MainPage from here...
+ //rootFrame.Navigate(typeof(MainPage));//, e.Arguments);
}//SignInIfNeeded
@@ -312,10 +314,10 @@ static void ConfigureFilters(ILoggerFactory factory)
#endif
*/
}
-
-#endregion
-#region "BackButton"
+ #endregion
+
+ #region "BackButton"
// PKAR added wedle https://stackoverflow.com/questions/39262926/uwp-hardware-back-press-work-correctly-in-mobile-but-error-with-pc
private void OnNavigatedAddBackButton(object sender, NavigationEventArgs e)
{
@@ -343,7 +345,7 @@ private void OnBackButtonPressed(object sender, Windows.UI.Core.BackRequestedEve
{
}
}
-#endregion
+ #endregion
//public static string _timerString = "";
//public static int _timerCount = 0;
@@ -377,7 +379,7 @@ protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs
await LoadNews(false);
int iNewCnt = App.gToasty.Count - iStanPrzed;
-
+
p.k.DebugOut("iStanPo = " + App.gToasty.Count.ToString());
if (iNewCnt > 0)
{
@@ -401,11 +403,11 @@ protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs
public async static System.Threading.Tasks.Task LoadNews(bool bMsg)
{
p.k.DebugOut("LoadNews(" + bMsg.ToString());
-
- if(! await initODandDict(bMsg) )
- {
- return false; // przede wszystkim - odczytanie slownikow na nowo (żeby nie było reset słownika!)
- }
+
+ if (!await initODandDict(bMsg))
+ {
+ return false; // przede wszystkim - odczytanie slownikow na nowo (żeby nie było reset słownika!)
+ }
//await WczytajNowe(bMsg);
await LoadNew(bMsg);
@@ -423,38 +425,57 @@ public static async System.Threading.Tasks.Task EnsureOneDriveOpen(bool bM
}
#if __ANDROID__
+ /*
if (App.gOnedrive != null)
return true;
- await App.AddLogEntry("inicjalizacja gOneDrive",true);
- Uno.OneDrive.Connector.Init(Android.App.Application.Context);
+ await App.AddLogEntry("inicjalizacja gOneDrive", true);
+ Uno.OneDrive.Connector.Init(Android.App.Application.Context);
+
+ string[] scopes = { "Files.ReadWrite" };
+ App.gOnedrive = new Uno.OneDrive.Connector
+ (
+ //"287faaf5-69f4-46e7-977e-1980e19790d0"
+ //"560b76b6-f929-4200-b8b0-70892f08f94a"
+ GoneDriveConsumerClientId,
+ scopes
+ );
- string[] scopes = { "Files.ReadWrite" };
- App.gOnedrive = new Uno.OneDrive.Connector
- (
- //"287faaf5-69f4-46e7-977e-1980e19790d0"
- //"560b76b6-f929-4200-b8b0-70892f08f94a"
- GoneDriveConsumerClientId,
- scopes
- );
-
//RnD
// await App.gOnedrive.DisconnectAsync();
-
+
if (!await App.gOnedrive.ConnectAsync())
- {
- await App.AddLogEntry("FAIL initializing OneDrive",false);
- await p.k.DialogBoxResAsync("errOneDriveInit");
- return false;
- }
+ {
+ await App.AddLogEntry("FAIL initializing OneDrive", false);
+ await p.k.DialogBoxResAsync("errOneDriveInit");
+ return false;
+ }
if (App.gAppFolder is null)
- {
+ {
// to jest to samo niezaleznie od on/off samego konektora
- await App.AddLogEntry("inicjalizacja gAppFolder",true);
+ await App.AddLogEntry("inicjalizacja gAppFolder", true);
App.gAppFolder = await App.gOnedrive.GetThisAppFolderAsync();
}
+ */
+
+ if (p.od.IsOneDriveOpened())
+ return true;
+
+ // if (!bMsg) return false;
+
+ try
+ {
+ if (!await p.od.OpenOneDrive(true, bMsg))
+ return false;
+
+ return true;
+ }
+ catch
+ {
+ //
+ }
#else
if (p.od.IsOneDriveOpened())
return true;
@@ -488,7 +509,8 @@ private static async System.Threading.Tasks.Task LoadFilterDictionary()
string dictionaryFile = "";
#if __ANDROID__
- dictionaryFile = await App.gOnedrive.ReadFile(App.gAppFolder, "toasts.filters.txt");
+ //dictionaryFile = await App.gOnedrive.ReadFile(App.gAppFolder, "toasts.filters.txt");
+ dictionaryFile = await p.od.ReadOneDriveTextFile("Apps/Andro2UWP/toasts.filters.txt");
#else
dictionaryFile = await p.od.ReadOneDriveTextFile("Apps/Andro2UWP/toasts.filters.txt");
#endif
@@ -527,7 +549,7 @@ private static async System.Threading.Tasks.Task LoadFilterDictionary()
//App.glFiltry.Add(new App.JedenFiltr("android", "* is using battery", ""));
//App.glFiltry.Add(new App.JedenFiltr("com.android.vending", "* new updates", ""));
//App.glFiltry.Add(new App.JedenFiltr("com.microsoft.skydrive", "Backing up your photos...", ""));
-
+
}//LoadFilterDictionary end
// WczytajSlownikSource
@@ -537,7 +559,8 @@ private async static System.Threading.Tasks.Task LoadDictionarySource()
string dictionaryFile = "";
#if __ANDROID__
- dictionaryFile = await App.gOnedrive.ReadFile(App.gAppFolder, "sender.renames.txt");
+ //dictionaryFile = await App.gOnedrive.ReadFile(App.gAppFolder, "sender.renames.txt");
+ dictionaryFile = await p.od.ReadOneDriveTextFile("Apps/Andro2UWP/sender.renames.txt");
#else
dictionaryFile = await p.od.ReadOneDriveTextFile("Apps/Andro2UWP/sender.renames.txt");
#endif
@@ -550,7 +573,7 @@ private async static System.Threading.Tasks.Task LoadDictionarySource()
App.gdSenderRenames.Clear();
var dictEntries = dictionaryFile.Split('\n');
-
+
foreach (string entry in dictEntries)
{
if (!string.IsNullOrEmpty(entry))
@@ -564,7 +587,7 @@ private async static System.Threading.Tasks.Task LoadDictionarySource()
}
}
-
+
await App.AddLogEntry("Read " + App.gdSenderRenames.Count.ToString() + " sender.renames entries", false);
}//LoadDictionarySource end
@@ -575,7 +598,8 @@ private static async System.Threading.Tasks.Task CheckPkarFile()
p.k.DebugOut("CheckPkarFile");
string dictionaryFile = "";
#if __ANDROID__
- dictionaryFile = await App.gOnedrive.ReadFile(App.gAppFolder, "pkar.mode.txt");
+ //dictionaryFile = await App.gOnedrive.ReadFile(App.gAppFolder, "pkar.mode.txt");
+ dictionaryFile = await p.od.ReadOneDriveTextFile("Apps/Andro2UWP/pkar.mode.txt");
#else
dictionaryFile = await p.od.ReadOneDriveTextFile("Apps/Andro2UWP/pkar.mode.txt");
#endif
@@ -589,6 +613,7 @@ public static async System.Threading.Tasks.Task initODandDict(bool bMsg)
{
p.k.DebugOut("initODandDict(" + bMsg.ToString());
+ /*
//ProgresywnyRing(true);
if (bMsg) p.k.ProgRingShow(true);
@@ -600,12 +625,13 @@ public static async System.Threading.Tasks.Task initODandDict(bool bMsg)
//ProgresywnyRing(false);
if (bMsg)
- {
- p.k.ProgRingShow(false);
+ {
+ p.k.ProgRingShow(false);
}
-
+
return false;
}
+ */
// Load only when connected to OneDrive
await LoadDictionarySource(); // CAUTION: there is no progressring!
@@ -632,7 +658,7 @@ private async static System.Threading.Tasks.Task LoadNew(bool bMsg)
if (!p.k.GetPlatform("uwp"))
{
- if(bMsg) await p.k.DialogBoxAsync("How did you press it not to be on UWP?");
+ if (bMsg) await p.k.DialogBoxAsync("How did you press it not to be on UWP?");
return;
}
@@ -823,7 +849,7 @@ protected override void OnActivated(IActivatedEventArgs e)
if (rootFrame.Content == null)
{
-
+
//MakeDebugToast("OnActivated - OPEN NULL"); // TODO
rootFrame.Navigate(typeof(MainPage));
@@ -832,7 +858,7 @@ protected override void OnActivated(IActivatedEventArgs e)
Window.Current.Activate();
}
-#region "logfile"
+ #region "logfile"
public static async System.Threading.Tasks.Task GetLogFile()
{
Windows.Storage.StorageFolder oFold = Windows.Storage.ApplicationData.Current.LocalFolder;
@@ -848,12 +874,13 @@ public static async System.Threading.Tasks.Task AddLogEntry(string message, bool
if (onlyInDebug && !p.k.GetSettingsBool("debugLog"))
return;
- var oFile = await GetLogFile();
+ Windows.Storage.StorageFile oFile = await GetLogFile();
if (oFile is null) return;
try
{
- await Windows.Storage.FileIO.AppendTextAsync(oFile, message + "\n", Windows.Storage.Streams.UnicodeEncoding.Utf8);
+ await Windows.Storage.FileIO.AppendTextAsync(
+ oFile, message + "\n", Windows.Storage.Streams.UnicodeEncoding.Utf8);
}
catch
{
@@ -863,7 +890,7 @@ public static async System.Threading.Tasks.Task AddLogEntry(string message, bool
}
-#endregion
+ #endregion
public static List gToasty = new List();
@@ -875,18 +902,21 @@ public static async System.Threading.Tasks.Task AddLogEntry(string message, bool
public static List glFiltry = new List();
#if __ANDROID__
- public static Uno.OneDrive.Connector gOnedrive = null;
- public static Uno.OneDrive.FileData gAppFolder = null;
+ //public static Uno.OneDrive.Connector gOnedrive = null;
+ //public static Uno.OneDrive.FileData gAppFolder = null;
static bool bInOneDriveSending = false;
+ // WriteToast (to OneDrive)
public async void ZapiszToast(JedenToast toast)
{
// uzupelnij dane - mamy tylko czas i glowny tekst
toast.sDevice = gsDeviceName;
toast.iNumber = ++giCurrentNumber;
+
p.k.SetSettingsInt("currentFileNum", giCurrentNumber);
+
await AddLogEntry("numer kolejny: " + giCurrentNumber, true);
gToasty.Add(toast);
@@ -906,7 +936,7 @@ public async void ZapiszToast(JedenToast toast)
// jesli jest siec, to mozemy wyslac do OneDrive wszystkie ktorych jeszcze sie nie wyslalo
for (int iLoop = 0; iLoop < gToasty.Count; iLoop++)
{
- var oItem = gToasty.ElementAt(iLoop);
+ JedenToast oItem = gToasty.ElementAt(iLoop);
if (oItem.bOnOneDrive) continue; // juz wyslany
@@ -914,10 +944,27 @@ public async void ZapiszToast(JedenToast toast)
oItem.sFileName = gsDeviceName + "." + oItem.iNumber.ToString("00000") + "-" +
oItem.dDate.ToString("yyyy.MM.dd_HH.mm") + ".toast.txt";
+
await AddLogEntry("filename: " + oItem.sFileName, false);
- Uno.OneDrive.FileData oSent = await gOnedrive.SaveFile(gAppFolder, oItem.sFileName, oItem.sMessage);
+ // old scheme ("android" onedrive, gAppFolder)
+ //Uno.OneDrive.FileData oSent = await gOnedrive.SaveFile(gAppFolder, oItem.sFileName, oItem.sMessage);
+
+
+ // RnD: new scheme (universil shared code of ondrive service)
+ Windows.Storage.StorageFolder oFold = Windows.Storage.ApplicationData.Current.LocalFolder;
+ Windows.Storage.StorageFile sFile = await oFold.CreateFileAsync(oItem.sFileName,
+ Windows.Storage.CreationCollisionOption.OpenIfExists);
+
+
+ string oSent = await p.od.SaveFileToOneDrive
+ (
+ sFile,
+ "Apps/Andro2UWP",// onedrive special folder
+ oItem.sMessage);
+
+ // RnD: TEST IT!!
// jesli sie nie udalo wyslanie, to nie wysylaj nastepnych
if (oSent is null)
{
@@ -932,7 +979,7 @@ public async void ZapiszToast(JedenToast toast)
bInOneDriveSending = false;
}
-#region "handling accessiblity trigger"
+ #region "handling accessiblity trigger"
//
//
-
+
+
+
-
+
-
+
@@ -91,10 +95,15 @@
+
+
+
+
+
@@ -103,10 +112,15 @@
+
+
+
+
+
diff --git a/Andro2UWP/Andro2UWP.Shared/MainPage.xaml.cs b/Andro2UWP/Andro2UWP.Shared/MainPage.xaml.cs
index e73a875..6263d9c 100644
--- a/Andro2UWP/Andro2UWP.Shared/MainPage.xaml.cs
+++ b/Andro2UWP/Andro2UWP.Shared/MainPage.xaml.cs
@@ -1,4 +1,8 @@
-#if __ANDROID__
+// MainPage
+// Both for UWP and Android
+// 2022
+
+#if __ANDROID__
using Android.App;
#endif
using System;
@@ -18,25 +22,28 @@
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
-
-
+// Andro2UWP namespace
namespace Andro2UWP
{
-
+ // MainPage class
public sealed partial class MainPage : Page
{
+
+ // MainPage
public MainPage()
{
this.InitializeComponent();
- }
+ }//MainPage()
+
+ // uiPage_Loaded
private async void uiPage_Loaded(object sender, RoutedEventArgs e)
{
-#if DEBUG
- p.k.SetSettingsInt("debugLogLevel", 5); // TODO na razie tak, potem trzeba wyciąć
-#endif
- p.k.SetSettingsString("appFailData", ""); // zadnych pozostalosci po poprzednim run
+#if DEBUG
+ p.k.SetSettingsInt("debugLogLevel", 5); // TODO: for now, yes, then you need to cut
+#endif
+ p.k.SetSettingsString("appFailData", ""); // no leftovers from the previous run
p.k.ProgRingInit(true, true);
//p.k.GetAppVers("uiVersion");
@@ -44,10 +51,10 @@ private async void uiPage_Loaded(object sender, RoutedEventArgs e)
App.gsDeviceName = p.k.GetSettingsString("deviceName");
App.giCurrentNumber = p.k.GetSettingsInt("currentFileNum") + 1;
- await App.AddLogEntry("Andro2UWP:MainPage:Loaded called, wartosci:\n deviceName = " + App.gsDeviceName + ",\n currentFileNum =" + App.giCurrentNumber.ToString(), true);
- // sprobuj wczytac tabelke zamian - bo moze cos sie zmienilo od poprzedniego razu
+ await App.AddLogEntry("Andro2UWP:MainPage:Loaded called, values:\n deviceName = " + App.gsDeviceName + ",\n currentFileNum =" + App.giCurrentNumber.ToString(), true);
+ // on early days, when it was necessary to complete a task to ease the burden in the table... in general, this is from the previous time
- // inicjalizacja OneDrive tutaj tylko wtedy, gdy nie pierwsze uruchomienie (bez logowania do OneDrive na pierwszym start app)
+ // initialize OneDrive here only when not first start (without logging into OneDrive on first start app)
try
{
if (p.k.GetSettingsBool("wasInit"))
@@ -58,116 +65,157 @@ private async void uiPage_Loaded(object sender, RoutedEventArgs e)
catch (Exception ex)
{
//Debug.WriteLine(" uiPage_Loaded - initODandDict - exception: " + ex.Message);
- Console.WriteLine(" uiPage_Loaded - initODandDict - exception: " + ex.Message);
}
- // dla UWP nie robimy refresh - dlugo to trwa przeciez
- if (p.k.GetPlatform("android"))
+ // for UWP we do not refresh - it takes a long time
+ // RnD: UWP refresh when app started (Main page loaded)
+ if (1 == 1) //(p.k.GetPlatform("android"))
{
+
+ if (p.k.GetPlatform("uwp"))
+ {
+ if (!await App.LoadNews(true))
+ {
+ return;
+ }
+
+ //if (!await App.initODandDict())
+ // return; // first of all-reading the dictionaries anew (so as not to reset the dictionary!)
+
+ //await App.WczytajNowe();
+ }
+
+
RefreshListView(false);
+
}
#if NETFX_CORE
- // to jest w BottomBar, którego nie ma poza UWP, więc nie można się do niego odwołać :)
+ // this is in BottomBar, which is not present outside UWP, so you can not refer to it :)
if (!p.k.IsFamilyDesktop())
- uiAutoRefresh.IsEnabled = false; // poza Deskop nie ma sensu, bo by OS i tak wyłączał na timeout
+ {
+ // besides the desktop does not make sense, because the OS
+ // and so turned off on timeout
+ uiAutoRefresh.IsEnabled = false;
+ }
else
+ {
uiAutoRefresh.IsChecked = p.k.IsTriggersRegistered("Andro2UWP_Timer");
-#endif
+ }
+#endif
+
+ }//uiPage_Loaded end
- }
#if __ANDROID__
+ // UslugaWlaczona / Service included
private async System.Threading.Tasks.Task UslugaWlaczona()
{
- await App.AddLogEntry("Andro2UWP:MainPage:UslugaWlaczona called", true);
+ await App.AddLogEntry("Andro2UWP:MainPage:Service included called", true);
var am = (Android.Views.Accessibility.AccessibilityManager)
- Android.App.Application.Context.GetSystemService(Android.App.Application.AccessibilityService);
+ Android.App.Application.Context.GetSystemService
+ (
+ Android.App.Application.AccessibilityService
+ );
+
var enabledServices =
- am.GetEnabledAccessibilityServiceList(Android.AccessibilityServices.FeedbackFlags.Generic);
- await App.AddLogEntry("wlaczonych jest " + enabledServices.Count, true );
+ am.GetEnabledAccessibilityServiceList
+ (
+ Android.AccessibilityServices.FeedbackFlags.Generic
+ );
+
+ await App.AddLogEntry("included is " + enabledServices.Count, true );
+
foreach (var enabledService in enabledServices)
{
var enabledServiceInfo = enabledService.ResolveInfo.ServiceInfo;
+
await App.AddLogEntry("np. w " + enabledServiceInfo.PackageName, true);
+
if (enabledServiceInfo.PackageName == Android.App.Application.Context.PackageName)
+ {
return true;
+ }
}
- await App.AddLogEntry("niestety, wylaczona", true);
+
+ await App.AddLogEntry("unfortunately, disabled / wylaczona", true);
return false;
- }
+
+ }//UslugaWlaczona end
#endif
/*
+ // TEMP
+
+ // uiAuth_Click
private void uiAuth_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(AccountSelectionPage));
- }
+ }//uiAuth_Click end
*/
+
+ // uiSettings_Click
private void uiSettings_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(Settings));
- }
+
+ }//uiSettings_Click end
+
+
+ // uiShowLog_Click
private void uiShowLog_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(AppLog));
- }
+ }//uiShowLog_Click end
+
+
+ // uiStartStop_Toggled
private async void uiStartStop_Toggled(object sender, RoutedEventArgs e)
{
- // ten guzik jest tylko Androidowy
-
-#if !__ANDROID__
+ // this button is Android only
+#if __ANDROID__
uiStartStop.IsEnabled = false;
#endif
if (p.k.GetPlatform("uwp"))
{
- p.k.DialogBox("jakim cudem nacisnales to nie bedac na Androidzie?");
-
-#if !__ANDROID__
+ p.k.DialogBox("How did you press this not to be on Android? ;)");
+
uiStartStop.IsEnabled = true;
-#endif
+
return;
}
-
- bool b = true;
-
-#if !__ANDROID__
- b = uiStartStop.IsOn;
-#endif
- if (!b)
+#if __ANDROID__
+ if (!uiStartStop.IsOn)
{
await App.AddLogEntry("Stopping... @" + DateTime.Now.ToString(), false);
App.gbPrzechwytuj = false;
-//#if !__ANDROID__
- // App.gOnedrive?.Dispose();
- // App.gOnedrive = null;
-//#endif
+ //TODO
+ //App.gOnedrive?.Dispose();
+ //App.gOnedrive = null;
-#if !__ANDROID__
uiStartStop.IsEnabled = true;
-#endif
return;
}
- // 2020.06.29: przestawienie OneDrive przed Accessibility, jako ze pkarmode jest z onedrive a zmienia Accessibility
- if (!await App.initODandDict(true)) return; // inicjalizcja OneDrive gdy jeszcze nie bylo, oraz wczytanie slownikow (gdy sie zmienily, wystarczy off/on i juz jest aktualne)
+ // 2020.06.29: Move OneDrive before Accessibility, as pkarmode is
+ // from onedrive and change Accessibility
+
+ // initialize OneDrive when it was not yet, and load words
+ // (when they have changed, just off/on and it is already up to date)
+ if (!await App.initODandDict(true)) return;
+
-#if __ANDROID__
if (!await UslugaWlaczona())
{
-#else
- if (1 ==1)
- {
-#endif
- bool bIgnore = false;
+ bool bIgnore = false;
if(p.k.GetSettingsBool("pkarMode"))
{
@@ -178,60 +226,62 @@ private async void uiStartStop_Toggled(object sender, RoutedEventArgs e)
if (!bIgnore)
{
await p.k.DialogBoxResAsync("msgAccessibilityFirst");
-
-#if __ANDROID__
- var intent = new Android.Content.Intent(Android.Provider.Settings.ActionAccessibilitySettings);
+ var intent = new Android.Content.Intent
+ (
+ Android.Provider.Settings.ActionAccessibilitySettings
+ );
+
Uno.UI.BaseActivity.Current.StartActivity(intent);
-#endif
-#if !__ANDROID__
uiStartStop.IsOn = false;
uiStartStop.IsEnabled = true;
-#endif
+
return;
}
}
+ // Bug ?
+ //p.k.ProgRingShow(true);
- p.k.ProgRingShow(true);
- // jak tu jestesmy, to na pewno jest to wlaczanie przechwytywania
+ // if we're here, it's definitely an interception. =)
await App.AddLogEntry("Starting... @" + DateTime.Now.ToString(), false);
- // ustalenie koniecznych zmiennych
+ // determination of necessary variables
string deviceName = "default";
+
if (string.IsNullOrEmpty(App.gsDeviceName) || App.gsDeviceName == "default")
{
- var AndOSBuildModel = "";
-#if __ANDROID__
- AndOSBuildModel = Android.OS.Build.Model;
-#endif
- deviceName = await p.k.DialogBoxInputDirectAsync
- (p.k.GetLangString("msgEnterDevName"),
- AndOSBuildModel, "resDlgSetName"
+ deviceName =
+ await p.k.DialogBoxInputDirectAsync
+ (
+ p.k.GetLangString("msgEnterDevName"),
+ Android.OS.Build.Model,
+ "resDlgSetName"
);
-
+
if (deviceName != "")
+ {
p.k.SetSettingsString("deviceName", deviceName);
+ }
+
App.gsDeviceName = deviceName;
}
+
await App.AddLogEntry("mamy devicename=" + deviceName, true);
if (!await App.EnsureOneDriveOpen(true))
{
await App.AddLogEntry("FAIL cannot open OneDrive", false);
-#if __ANDROID__
- App.gOnedrive?.Dispose();
- App.gOnedrive = null;
-#endif
+
+ //TODO
+ //App.gOnedrive?.Dispose();
+ //App.gOnedrive = null;
-#if !__ANDROID__
uiStartStop.IsOn = false;
-#endif
p.k.ProgRingShow(false);
-#if !__ANDROID__
+
uiStartStop.IsEnabled = true;
-#endif
return;
}
@@ -240,32 +290,34 @@ private async void uiStartStop_Toggled(object sender, RoutedEventArgs e)
// wszystko gotowe, mozesz wyłapywać
App.gbPrzechwytuj = true;
-#if !__ANDROID__
uiStartStop.IsEnabled = true;
-#endif
+
p.k.ProgRingShow(false);
+#endif
+ }//uiStartStop_Toggled end
- }//..._Toggled end
+ // uiClearList_Click
private async void uiClearList_Click(object sender, RoutedEventArgs e)
{
- // ma byc: resetlisty (zeby pozbyc sie starszych)
+ // to be: resetlisty (to get rid of older ones)
//if (p.k.GetPlatform("uwp"))
//{
- // // visibility off, bo niby jak? tozsame z delete all?
- // await p.k.DialogBoxAsync("jeszcze nie umiem tego zrobic");
+ // // visibility's off, because how? tozsame with delete everything?
+ // await p.k.DialogBoxAsync("I can't do it yet.");
//}
//else
- //{// na Android: czyscimy nie OneDrive, tylko to co na ekranie
+ //{// on Android: we do not clean OneDrive, only what is on the screen
+
+ App.gToasty.Clear();
+
+ uiList.ItemsSource = App.gToasty.ToList();
- App.gToasty.Clear();
-#if !__ANDROID__
- uiList.ItemsSource = App.gToasty.ToList();
-#endif
//}
- }//uiClearList_Click end
+ }//uiClearList_Click end
+
// uiItem_DoubleTapped
@@ -273,43 +325,66 @@ private void uiItem_DoubleTapped(object sender, RoutedEventArgs e)
{
Grid oGrid;
oGrid = sender as Grid;
+
if (oGrid is null) return;
+
+ // Show details
p.k.DialogBox(((App.JedenToast)oGrid.DataContext).sMessage);
- }
+ }//uiItem_DoubleTapped end
+
+
+ // MFIdataContext
private App.JedenToast MFIdataContext(object sender)
{
var mfi = (MenuFlyoutItem)sender;
if (mfi is null)
return null;
return (App.JedenToast)mfi.DataContext;
- }
+
+ }// MFIdataContext end
+
+
+ // uiDetails_Click
private void uiDetails_Click(object sender, RoutedEventArgs e)
{
App.JedenToast toast = MFIdataContext(sender);
+
if (toast is null) return;
+
+ // RnD
+ // Show some toast message (?)
p.k.DialogBox(toast.sMessage);
}
+
+
+ // uiRenameSource_Click
private async void uiRenameSource_Click(object sender, RoutedEventArgs e)
{
if (!p.k.GetPlatform("uwp"))
{
- p.k.DialogBox("jakim cudem to nacisnales bedac na Androidzie?");
-#if !__ANDROID__
+ p.k.DialogBox("how come you pressed it to be on Android? ;)");
+
uiStartStop.IsEnabled = true;
-#endif
+
return;
}
App.JedenToast toast = MFIdataContext(sender);
+
if (toast is null) return;
- var newName = await p.k.DialogBoxInputDirectAsync(
+
+ var newName = await p.k.DialogBoxInputDirectAsync
+ (
p.k.GetLangString("msgSourceShould1") + "'" + toast.sSource + "' " +
- p.k.GetLangString("msgSourceShould2") , toast.sSource);
+ p.k.GetLangString("msgSourceShould2") , toast.sSource
+ );
+
if (string.IsNullOrEmpty(newName)) return;
+
App.gdSenderRenames.Add(toast.sSource, newName);
- // zapisujemy...
+ // we write...
p.k.ProgRingShow(true);
string dictionaryFile = "";
@@ -318,33 +393,43 @@ private async void uiRenameSource_Click(object sender, RoutedEventArgs e)
dictionaryFile = dictionaryFile + entry.Key + "|" + entry.Value + "\n";
}
+// "UWP" ONLY (?) TODO: redo it for Android...
#if ((!__ANDROID__) && (!__WASM__))
await p.od.ReplaceOneDriveFileContent("Apps/Andro2UWP/sender.renames.txt", dictionaryFile);
#endif
RefreshListView(false);
+
p.k.ProgRingShow(false);
- }
+ }//uiRenameSource_Click end
+
+
+ // UsunPliki / Delete files
private async System.Threading.Tasks.Task UsunPliki(List lista, bool bMsg)
{
p.k.ProgRingShow(true, false, 0, lista.Count);
+
#if !__ANDROID__
await p.od.UsunPlikiOneDrive("Apps/Andro2UWP", lista);
for(int iLp = App.gToasty.Count-1; iLp>=0; iLp--)
{
var toast = App.gToasty.ElementAt(iLp);
+
if(lista.Contains(toast.sFileName))
{
App.gToasty.RemoveAt(iLp);
}
}
+
// i pokaz nową wersję listy
RefreshListView(bMsg);
-#endif
+#endif
p.k.ProgRingShow(false);
- }
+ }//UsunPliki
+
+ // uiDeleteThis_Click
private void uiDeleteThis_Click(object sender, RoutedEventArgs e)
{
App.JedenToast toast = MFIdataContext(sender);
@@ -352,36 +437,62 @@ private void uiDeleteThis_Click(object sender, RoutedEventArgs e)
// from list, oraz from OneDrive
- var lista = new List();
+ List lista = new List();
+
lista.Add(toast.sFileName);
+
+ // delete files
UsunPliki(lista, false);
- }
+
+ }//uiDeleteThis_Click end
+
+
+ // uiDeleteOlder_Click
private async void uiDeleteOlder_Click(object sender, RoutedEventArgs e)
{
App.JedenToast toast = MFIdataContext(sender);
+
if (toast is null) return;
- if (!await p.k.DialogBoxYNAsync(p.k.GetLangString("msgSureRemoveOlder") + "\n" + toast.displayDate + " ?"))
+ // Show worning dialog box
+ if
+ (
+ !await p.k.DialogBoxYNAsync(p.k.GetLangString("msgSureRemoveOlder")
+ + "\n" + toast.displayDate + " ?")
+ )
+ {
return;
+ }
// from list, oraz from OneDrive
- var lista = new List();
+ List lista = new List();
+
foreach(var item in App.gToasty)
{
if (item.displayDate.CompareTo(toast.displayDate) < 0)
+ {
lista.Add(item.sFileName);
+ }
}
+
+ // delete files
await UsunPliki(lista,false);
- }
+ }//uiDeleteOlder_Click end
+
+
+ // uiDeleteThisOlder_Click
private async void uiDeleteThisOlder_Click(object sender, RoutedEventArgs e)
{
App.JedenToast toast = MFIdataContext(sender);
if (toast is null) return;
+ // show dialog box
if (!await p.k.DialogBoxYNAsync(p.k.GetLangString("msgSureRemoveThisOlder")))
+ {
return;
+ }
// from list, oraz from OneDrive
var lista = new List();
@@ -390,39 +501,64 @@ private async void uiDeleteThisOlder_Click(object sender, RoutedEventArgs e)
if (item.displayDate.CompareTo(toast.displayDate) <= 0)
lista.Add(item.sFileName);
}
+
+ // delete files
await UsunPliki(lista,false);
- }
+
+ }//uiDeleteThisOlder_Click end
+
+
+ // uiCopy_Click
private void uiCopy_Click(object sender, RoutedEventArgs e)
{
App.JedenToast toast = MFIdataContext(sender);
+
+ // ?
p.k.ClipPut(toast.ToString());
- }
+ }//uiCopy_Click end
+
+
+ // uiDeleteSender_Click
private async void uiDeleteSender_Click(object sender, RoutedEventArgs e)
{
App.JedenToast toast = MFIdataContext(sender);
+
if (toast is null) return;
// from list, oraz from OneDrive
- if (!await p.k.DialogBoxYNAsync(p.k.GetLangString("msgSureRemoveSender") + "\n" + toast.displaySource + " ?"))
+ if
+ (
+ !await p.k.DialogBoxYNAsync(p.k.GetLangString("msgSureRemoveSender") +
+ "\n" + toast.displaySource + " ?")
+ )
+ {
return;
+ }
// from list, oraz from OneDrive
- var lista = new List();
+ List lista = new List();
foreach (var item in App.gToasty)
{
if (item.displaySource == toast.displaySource)
lista.Add(item.sFileName);
}
+
+ // delete files
await UsunPliki(lista,false);
- }
+ }//uiDeleteSender_Click end
+
+
+ // uiCreateFilter_Click
private async void uiCreateFilter_Click(object sender, RoutedEventArgs e)
{
App.JedenToast toast = MFIdataContext(sender);
if (toast is null) return;
var oStack = new Windows.UI.Xaml.Controls.StackPanel();
+
+ // RnD
//var oDlgTitle = new Windows.UI.Xaml.Controls.TextBlock();
//oDlgTitle.Text = "New filter";
//oDlgTitle.HorizontalAlignment = HorizontalAlignment.Center;
@@ -431,6 +567,7 @@ private async void uiCreateFilter_Click(object sender, RoutedEventArgs e)
//oStack.Children.Add(oDlgTitle);
var oPackage = new Windows.UI.Xaml.Controls.TextBox();
+
oPackage.Text = toast.sSource;
oPackage.Header = "Source package:";
oStack.Children.Add(oPackage);
@@ -439,13 +576,16 @@ private async void uiCreateFilter_Click(object sender, RoutedEventArgs e)
oTitle.Header = "Title:";
var oText = new Windows.UI.Xaml.Controls.TextBox();
oText.Header = "Text:";
+
foreach(var linia in toast.sMessage.Split('\n'))
{
if (linia.StartsWith("Title: "))
oTitle.Text = linia.Substring(7);
+
if (linia.StartsWith("Text: "))
oText.Text = linia.Substring(6);
}
+
oStack.Children.Add(oTitle);
oStack.Children.Add(oText);
@@ -456,11 +596,15 @@ private async void uiCreateFilter_Click(object sender, RoutedEventArgs e)
oDlg.Title = p.k.GetLangString("msgAddFilterTitle");
var oCmd = await oDlg.ShowAsync();
+
//#if !NETFX_CORE
// oDlg.Dispose();
//#endif
+
if (oCmd == Windows.UI.Xaml.Controls.ContentDialogResult.Primary)
+ {
return;
+ }
App.glFiltry.Add(new App.JedenFiltr(oPackage.Text, oTitle.Text, oText.Text));
// save filtry
@@ -470,6 +614,7 @@ private async void uiCreateFilter_Click(object sender, RoutedEventArgs e)
string dictionaryFile = "";
+
foreach (var entry in App.glFiltry)
{
dictionaryFile = dictionaryFile + entry.sPackageName + "|" + entry.sTitle + "|" + entry.sText + "\n";
@@ -478,17 +623,20 @@ private async void uiCreateFilter_Click(object sender, RoutedEventArgs e)
#if !__ANDROID__
await p.od.ReplaceOneDriveFileContent("Apps/Andro2UWP/toasts.filters.txt", dictionaryFile);
#endif
- // uiRefreshList_Click(null, null); // <-- to i tak nie filtruje teraz, wiec nie bawimy sie w to
+
+ // uiRefreshList_Click(null, null); // <-- it's not filtering right now anyway, so we're not playing this
+
//ProgresywnyRing(false);
p.k.ProgRingShow(false);
- }
+ }//uiCreateFilter_Click end
+
+ // uiRefreshList_Click
private async void uiRefreshList_Click(object sender, RoutedEventArgs e)
{
-#if !__ANDROID__
- uiRefreshList.IsEnabled = false;
-#endif
+ // obsolete button
+ //uiRefreshList.IsEnabled = false;
if (p.k.GetPlatform("uwp"))
{
@@ -497,20 +645,26 @@ private async void uiRefreshList_Click(object sender, RoutedEventArgs e)
return;
}
- //if (!await App.initODandDict()) return; // przede wszystkim - odczytanie slownikow na nowo (żeby nie było reset słownika!)
+ //if (!await App.initODandDict())
+ // return; // first of all-reading the dictionaries anew (so as not to reset the dictionary!)
+
//await App.WczytajNowe();
}
-#if !__ANDROID__
- uiRefreshList.IsEnabled = true;
-#endif
- //if (sender != null) // nie ma wywołania innego niż z Event guzika, więc zawsze sender <> null?
+ // obsolete button
+ //uiRefreshList.IsEnabled = true;
+
+ //if (sender != null) // there is no call other than from event button, so always sender < > null?
//{
//}
+ // Refresh "toasts" list
RefreshListView(true);
- }
+ }//uiRefreshList_Click end
+
+
+ // RefreshListView
private void RefreshListView(bool bMsg)
{
@@ -545,46 +699,45 @@ private void RefreshListView(bool bMsg)
// dopiero pozniej ją pokaż
if (p.k.GetSettingsBool("sortDescending", true))
{
-#if !__ANDROID__
uiList.ItemsSource = (from item in App.gToasty orderby item.sFileName descending select item).ToList();
-#endif
}
else
{
-#if !__ANDROID__
uiList.ItemsSource = App.gToasty.ToList();
-#endif
}
- // oraz ewentualnie usuń guzik kasowania listy
+ // and possibly delete the Delete List button
if (App.gToasty.Count > 0)
{
if (p.k.GetPlatform("uwp"))
{
#if !__ANDROID__
- uiClearList.Visibility = Visibility.Visible;
+ // Make ClearList button visible
+ //uiClearList.Visibility = Visibility.Visible;
#endif
}
}
- else
+ else
{
if (bMsg) p.k.DialogBoxRes("msgNoData");
if (p.k.GetPlatform("uwp"))
{
#if !__ANDROID__
- uiClearList.Visibility = Visibility.Collapsed;
+ //uiClearList.Visibility = Visibility.Collapsed;
#endif
}
}
+ }//RefreshListView end
- }
+ // [security reason] uiAutoRefresh does not exist outside UWP
#if NETFX_CORE
- // zabezpieczenie - uiAutoRefresh nie istnieje poza UWP
+
+ // uiAutoRefresh_Click
private async void uiAutoRefresh_Click(object sender, RoutedEventArgs e)
{
if(!uiAutoRefresh.IsChecked.HasValue) return;
@@ -596,39 +749,40 @@ private async void uiAutoRefresh_Click(object sender, RoutedEventArgs e)
return;
}
Windows.ApplicationModel.Background.SystemCondition oCondition =
- new Windows.ApplicationModel.Background.SystemCondition(Windows.ApplicationModel.Background.SystemConditionType.InternetAvailable);
+ new Windows.ApplicationModel.Background.SystemCondition
+ (Windows.ApplicationModel.Background.SystemConditionType.InternetAvailable);
+
p.k.RegisterTimerTrigger("Andro2UWP_Timer", 15, false, oCondition);
}
else
{
p.k.UnregisterTriggers("Andro2UWP_Timer");
}
- }
+ }//uiAutoRefresh_Click end
#endif
+ // ProgresywnyRing
//private void ProgresywnyRing(bool sStart)
+ //{
+ // if (sStart)
// {
- // if (sStart)
- // {
- // double dVal;
- // dVal = Math.Min(uiGrid.ActualHeight, uiGrid.ActualWidth) / 2;
- // uiProcesuje.Width = dVal;
- // uiProcesuje.Height = dVal;
-
- // uiProcesuje.Visibility = Visibility.Visible;
- // uiProcesuje.IsActive = true;
- // }
- // else
- // {
- // uiProcesuje.IsActive = false;
- // uiProcesuje.Visibility = Visibility.Collapsed;
- // }
+ // double dVal;
+ // dVal = Math.Min(uiGrid.ActualHeight, uiGrid.ActualWidth) / 2;
+ // uiProcesuje.Width = dVal;
+ // uiProcesuje.Height = dVal;
+ //
+ // uiProcesuje.Visibility = Visibility.Visible;
+ // uiProcesuje.IsActive = true;
// }
+ // else
+ // {
+ // uiProcesuje.IsActive = false;
+ // uiProcesuje.Visibility = Visibility.Collapsed;
+ // }
+ //}//ProgresywnyRing end
+ }//MainPage class end
-
-
- }
-}
+}//namespace end
diff --git a/Andro2UWP/Andro2UWP.Shared/Models/ItemModel.cs b/Andro2UWP/Andro2UWP.Shared/Models/ItemModel.cs
index 339cfcb..f24d181 100644
--- a/Andro2UWP/Andro2UWP.Shared/Models/ItemModel.cs
+++ b/Andro2UWP/Andro2UWP.Shared/Models/ItemModel.cs
@@ -1,4 +1,5 @@
-//
+// ItemModel
+// Shared code
namespace Andro2UWP.Models
{
diff --git a/Andro2UWP/Andro2UWP.UWP/OnedriveUWP.cs b/Andro2UWP/Andro2UWP.Shared/OnedriveUno.cs
similarity index 98%
rename from Andro2UWP/Andro2UWP.UWP/OnedriveUWP.cs
rename to Andro2UWP/Andro2UWP.Shared/OnedriveUno.cs
index 5d87409..3c0879b 100644
--- a/Andro2UWP/Andro2UWP.UWP/OnedriveUWP.cs
+++ b/Andro2UWP/Andro2UWP.Shared/OnedriveUno.cs
@@ -1,4 +1,6 @@
-using System;
+// Shared : One Drive Service "Uno"
+
+using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
@@ -8,8 +10,10 @@
using Andro2UWP;
using Windows.UI.Xaml;
+// p, pkar's thing =)
namespace p
{
+ // od, onedrive class
class od
{
@@ -31,9 +35,8 @@ class od
public static bool IsOneDriveOpened()
{
var app = (App)Application.Current;
-
- //return goOneDriveClnt != null;
- return app.uOneDriveClient != null;
+
+ return app.uOneDriveClient != null;
}
public async static Task OpenOneDrive(bool limitToAppFolder, bool bInteractive)
@@ -47,8 +50,10 @@ public async static Task OpenOneDrive(bool limitToAppFolder, bool bInterac
gInOneDriveCommand = true;
bool bRet = await OpenOneDriveInt(bInteractive);
+
gbLimitToAppFolder = limitToAppFolder;
gInOneDriveCommand = false;
+
return bRet;
}
@@ -342,10 +347,17 @@ public async static Task CopyFileToOneDrive(Windows.Storage.StorageFile
gInOneDriveCommand = false;
return "";
}
- }
+
+ }//
- public async static Task SaveFileToOneDrive(Windows.Storage.StorageFile oFile, string sFolderPath, bool bCanResetWifi)
+ // SaveFileToOneDrive
+ public async static Task SaveFileToOneDrive
+ (
+ Windows.Storage.StorageFile oFile,
+ string sFolderPath,
+ string sMessage //bool bCanResetWifi
+ )
{
var app = (App)Application.Current;
@@ -370,6 +382,7 @@ public async static Task SaveFileToOneDrive(Windows.Storage.StorageFile
try
{
Stream oStream = await oFile.OpenStreamForReadAsync();
+
if (!oStream.CanRead)
{
p.k.CrashMessageAdd("@CopyFileToOneDrive", "not readable stream?");
@@ -427,12 +440,14 @@ public async static Task SaveFileToOneDrive(Windows.Storage.StorageFile
oStream = null;
string sLink = "";
+
if (oItem != null)
{
Microsoft.OneDrive.Sdk.Permission oLink = null/* TODO Change to default(_) if this is not a reference type */;
oLink = await
app.uOneDriveClient.Drive.Items[oItem.Id].CreateLink("view").Request().PostAsync();
+
//goOneDriveClnt.Drive.Items[oItem.Id].CreateLink("view").Request().PostAsync();
sLink = oLink.Link.ToString();
@@ -453,7 +468,9 @@ public async static Task SaveFileToOneDrive(Windows.Storage.StorageFile
gInOneDriveCommand = false;
return "";
}
- }
+
+ }//
+
// ReadOneDriveTextFileId(string sFileId)
public async static Task ReadOneDriveTextFileId(string sFileId)
diff --git a/Andro2UWP/Andro2UWP.Shared/Settings.xaml b/Andro2UWP/Andro2UWP.Shared/Settings.xaml
index 1655618..94ca5e3 100644
--- a/Andro2UWP/Andro2UWP.Shared/Settings.xaml
+++ b/Andro2UWP/Andro2UWP.Shared/Settings.xaml
@@ -36,11 +36,13 @@
-
+
+
+
-
+
+
+
+
+
+
+
+
diff --git a/Andro2UWP/Andro2UWP.Shared/Settings.xaml.cs b/Andro2UWP/Andro2UWP.Shared/Settings.xaml.cs
index d477b15..f35d44d 100644
--- a/Andro2UWP/Andro2UWP.Shared/Settings.xaml.cs
+++ b/Andro2UWP/Andro2UWP.Shared/Settings.xaml.cs
@@ -1,4 +1,8 @@
-using System;
+// Settings page
+// Both for UWP and Android
+// 2022
+
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -13,37 +17,48 @@
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
-// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
+
+// Andro2UWP namespace
namespace Andro2UWP
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
+ // Settings class
public sealed partial class Settings : Page
{
+ // Settings
public Settings()
{
this.InitializeComponent();
- }
+ }//Settings end
+
+ // uiPage_Loaded
private void uiPage_Loaded(object sender, RoutedEventArgs e)
{
// uiVersion.Text = p.k.GetAppVers();
p.k.GetAppVers(uiVersion);
uiCounter.Text = App.giCurrentNumber.ToString();
uiDeviceName.Text = App.gsDeviceName;
+
#if __ANDROID__
if (string.IsNullOrEmpty(App.gsDeviceName) || App.gsDeviceName == "default")
uiDeviceName.Text = Android.OS.Build.Model;
#endif
p.k.GetSettingsBool(uiCreateToasts,"createToasts");
+
p.k.GetSettingsBool(uiSortListMode,"sortDescending", true);
+
p.k.GetSettingsBool(uiDebugLog, "debugLog");
- uiCreateToasts.IsEnabled = false; // jako ze jeszcze bez obslugi tego
+
+ // RnD zone : Toast feature
+ uiCreateToasts.IsEnabled = true;//false; // as yet unattended this
+
//uiHowMany.Text = p.k.GetSettingsInt("howMany", 10).ToString();
- }
+ }//uiPage_Loaded end
+
+
+ // uiPermissAccess_Click
private async void uiPermissAccess_Click(object sender, RoutedEventArgs e)
{
if (p.k.GetPlatform("uwp"))
@@ -55,8 +70,10 @@ private async void uiPermissAccess_Click(object sender, RoutedEventArgs e)
var intent = new Android.Content.Intent(Android.Provider.Settings.ActionAccessibilitySettings);
Uno.UI.BaseActivity.Current.StartActivity(intent);
#endif
- }
+ }//uiPermissAccess_Click end
+
+ // uiPermissBattery_Click
private async void uiPermissBattery_Click(object sender, RoutedEventArgs e)
{
if (p.k.GetPlatform("uwp"))
@@ -69,38 +86,55 @@ private async void uiPermissBattery_Click(object sender, RoutedEventArgs e)
var intent = new Android.Content.Intent(Android.Provider.Settings.ActionIgnoreBatteryOptimizationSettings);
Uno.UI.BaseActivity.Current.StartActivity(intent);
#endif
- // prosba o wlaczenie od Android M:
- // https://stackoverflow.com/questions/39256501/check-if-battery-optimization-is-enabled-or-not-for-an-app
- }
+ // asking for inclusion from Android M:
+ // https://stackoverflow.com/questions/39256501/check-if-battery-optimization-is-enabled-or-not-for-an-app
+
+ }//uiPermissBattery_Click end
+
+ // TODO : realize some Renames set
//private async void uiShowRenames_Click(object sender, RoutedEventArgs e)
//{
- //}
+ //}//uiShowRenames_Click end
+
+ // TODO : realize some Filters set
//private async void uiShowFilters_Click(object sender, RoutedEventArgs e)
//{
- //}
+ //}//uiShowFilters_Click end
+
+ // uiResetList_Click
private async void uiResetList_Click(object sender, RoutedEventArgs e)
{ // Visibility="Collapsed"
if (await p.k.DialogBoxYNAsync("Na pewno wyzerowac aktualną listę?"))
{
}
- }
+ }//uiResetList_Click end
+
+
+ // uiSave_Click
private void uiSave_Click(object sender, RoutedEventArgs e)
{
App.giCurrentNumber = int.Parse(uiCounter.Text);
+
p.k.SetSettingsInt("currentFileNum", App.giCurrentNumber);
+
App.gsDeviceName = uiDeviceName.Text;
p.k.SetSettingsString("deviceName", App.gsDeviceName);
p.k.SetSettingsBool(uiCreateToasts, "createToasts");
+
p.k.SetSettingsBool(uiSortListMode, "sortDescending");
+
p.k.SetSettingsBool(uiDebugLog, "debugLog");
//p.k.SetSettingsInt("howMany", int.Parse(uiHowMany.Text));
Frame.GoBack();
- }
- }
-}
\ No newline at end of file
+
+ }//uiSave_Click end
+
+ }//Settings class end
+
+}//namespace end
\ No newline at end of file
diff --git a/Andro2UWP/Andro2UWP.Shared/Strings/en-us/Resources.resw b/Andro2UWP/Andro2UWP.Shared/Strings/en-us/Resources.resw
index bdff862..113b746 100644
--- a/Andro2UWP/Andro2UWP.Shared/Strings/en-us/Resources.resw
+++ b/Andro2UWP/Andro2UWP.Shared/Strings/en-us/Resources.resw
@@ -271,6 +271,6 @@
Started
- EN-US
+ en-us
\ No newline at end of file
diff --git a/Andro2UWP/Andro2UWP.Shared/pkModuleShared.cs b/Andro2UWP/Andro2UWP.Shared/pkModuleShared.cs
index 855ac9d..a835f9c 100644
--- a/Andro2UWP/Andro2UWP.Shared/pkModuleShared.cs
+++ b/Andro2UWP/Andro2UWP.Shared/pkModuleShared.cs
@@ -1,48 +1,7 @@
-/*
-
-//../../../_mojeSuby/pkarModule-Uno3-1-6.cs
-
-// (...)
-// AddHandler rootFrame.NavigationFailed, AddressOf OnNavigationFailed
-//
-// ' PKAR added wedle https://stackoverflow.com/questions/39262926/uwp-hardware-back-press-work-correctly-in-mobile-but-error-with-pc
-// AddHandler rootFrame.Navigated, AddressOf OnNavigatedAddBackButton
-// AddHandler Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested, AddressOf OnBackButtonPressed
-// (...)
-
-### I already assume the correct Uno my own, without a functional reset
-
-2019.10.25
-* Clipboard for UWP goes as before, for UWP - no NuGet(so you don't have to add Reference as app is UWP only)
-* new feature: DialogBoxInput(uncommented)
-* new function: SetSettingsInt(double) - with conversion(because C # does not convert itself)
-
-2019.09.10
- * new function: GetPlatform(android, uwp, ios, wasm, other) - also as bool, int, string
-
-
-2019.09.03
- * added MakeToast(thanks to Nuget)
- * ..thanks to which I added CrashMessageAdd
- * I added CrashMessageExit
-
-
-2019.08.31
- * turned on full code analysis, and added:
- * .ConfigureAwait(true)[ie default, you could disable this warning]
- * ToString and int.Parse(and similar): cultureinvariant, or currentculture
- * some null tests
-
- 2019.08.27
-* new function: string GetAppVers() - works theoretically for UWP, Android and iOS
-* remake ClipBoard to universal version(requires Nuget)
-* IsMobile: UWP so far, macOS always NO, rest(Android, iOS, WASM) always YES
-* changing the method of obtaining a computer name(maybe universal)
-
-2019.08.26
-* migration to VC
-* comment on what is not crossplatform(upload it to pkarmodule.cs in UWP)
-*/
+// pkModuleShared
+// Both for UWP and Android
+// 2022
+
using System;
using System.Collections.Generic;
@@ -58,13 +17,11 @@
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
-
using System.Threading.Tasks;
using System.Diagnostics;
using Andro2UWP;
-
// ! TODO-s: do Strings:
// "errAnyError", resDlgYes, resDlgNo
@@ -2157,37 +2114,55 @@ public async static Task DialogBoxResYNAsync(string sMsgResId, string sYes
public async static Task DialogBoxInput(string sMsgResId, string sDefaultResId = "", string sYesResId = "resDlgContinue", string sNoResId = "resDlgCancel")
{
string sMsg, sYes, sNo, sDefault;
+
sDefault = "";
+
{
var withBlock = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
+
sMsg = withBlock.GetString(sMsgResId);
+
sYes = withBlock.GetString(sYesResId);
+
sNo = withBlock.GetString(sNoResId);
+
if (!string.IsNullOrEmpty(sDefaultResId))
sDefault = withBlock.GetString(sDefaultResId);
}
if (string.IsNullOrEmpty(sMsg))
sMsg = sMsgResId; // zabezpieczenie na brak string w resource
+
if (string.IsNullOrEmpty(sYes))
sYes = sYesResId;
+
if (string.IsNullOrEmpty(sNo))
sNo = sNoResId;
+
if (string.IsNullOrEmpty(sDefault))
sDefault = sDefaultResId;
+
var oInputTextBox = new TextBox();
+
oInputTextBox.AcceptsReturn = false;
+
oInputTextBox.Text = sDefault;
+
var oDlg = new ContentDialog();
+
oDlg.Content = oInputTextBox;
+
oDlg.PrimaryButtonText = sYes;
+
oDlg.SecondaryButtonText = sNo;
+
oDlg.Title = sMsg;
var oCmd = await oDlg.ShowAsync();
if (oCmd != ContentDialogResult.Primary)
return "";
+
return oInputTextBox.Text;
}
@@ -2228,10 +2203,12 @@ public async static Task DialogBoxInputDirectAsync(string sMsgResId, str
}
var oInputTextBox = new TextBox();
+
oInputTextBox.AcceptsReturn = false;
oInputTextBox.Text = sDefault;
var oDlg = new ContentDialog();
+
oDlg.Content = oInputTextBox;
oDlg.Title = sMsg;
@@ -2245,10 +2222,14 @@ public async static Task DialogBoxInputDirectAsync(string sMsgResId, str
return oInputTextBox.Text;
}
- //
+ // for getting DeviceName, for example
public async static Task DialogBoxInputDirectAsync(string sMsgResId, string Model, string sDefaultResId = "")
{
string sMsg, sYes, sNo, sDefault;
+
+ // My!
+ sYes = "OK";
+
sDefault = "";
{
var withBlock = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
@@ -2271,11 +2252,18 @@ public async static Task DialogBoxInputDirectAsync(string sMsgResId, str
}
var oInputTextBox = new TextBox();
+
oInputTextBox.AcceptsReturn = false;
+
oInputTextBox.Text = sDefault;
var oDlg = new ContentDialog();
+
oDlg.Content = oInputTextBox;
+
+ // My !
+ oDlg.PrimaryButtonText = sYes;
+
oDlg.Title = sMsg;
var oCmd = await oDlg.ShowAsync();
diff --git a/Andro2UWP/Andro2UWP.Shared/priconfig.default.xml b/Andro2UWP/Andro2UWP.Shared/priconfig.default.xml
new file mode 100644
index 0000000..307b020
--- /dev/null
+++ b/Andro2UWP/Andro2UWP.Shared/priconfig.default.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Andro2UWP/Andro2UWP.UWP/Andro2UWP.UWP.csproj b/Andro2UWP/Andro2UWP.UWP/Andro2UWP.UWP.csproj
index a57b5bf..985e9e0 100644
--- a/Andro2UWP/Andro2UWP.UWP/Andro2UWP.UWP.csproj
+++ b/Andro2UWP/Andro2UWP.UWP/Andro2UWP.UWP.csproj
@@ -2,25 +2,23 @@
-
- 2.28.3
-
-
6.2.2
+
+ 2.28.3
+
2.0.4
1.0.10
+
+ 13.0.1
+
@@ -31,18 +29,19 @@
Properties
Andro2UWP
Andro2UWP
- en
+ en-us
UAP
- 10.0.19041.0
- 10.0.14393.0
+ 10.0.15063.0
+ 10.0.15063.0
14
512
{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
Andro2UWP.UWP_TemporaryKey.pfx
- 859D682173EFA93938DD9F35584B7A54BA3AA7FF
+
+
True
False
- True
+ False
Always
arm
0
@@ -126,7 +125,6 @@
-
diff --git a/Andro2UWP/Andro2UWP.UWP/Package.appxmanifest b/Andro2UWP/Andro2UWP.UWP/Package.appxmanifest
index 90a1876..0d37ee6 100644
--- a/Andro2UWP/Andro2UWP.UWP/Package.appxmanifest
+++ b/Andro2UWP/Andro2UWP.UWP/Package.appxmanifest
@@ -1,6 +1,6 @@
-
+
Andro2UWP
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/AccountSession.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/AccountSession.cs
deleted file mode 100644
index 6bf5d03..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/AccountSession.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using System.Collections.Generic;
- using System.Net;
-
- public class AccountSession
- {
- public AccountSession()
- {
- }
-
- public AccountSession(IDictionary authenticationResponseValues, string clientId = null)
- {
- this.ClientId = clientId;
-
- this.ParseAuthenticationResponseValues(authenticationResponseValues);
- }
-
- public string AccessToken { get; set; }
-
- public string AccessTokenType { get; set; }
-
- public string ClientId { get; set; }
-
- public DateTimeOffset ExpiresOnUtc { get; set; }
-
- public string RefreshToken { get; set; }
-
- public string[] Scopes { get; set; }
-
- public string UserId { get; set; }
-
- public bool CanRefresh
- {
- get
- {
- return !string.IsNullOrEmpty(this.RefreshToken);
- }
- }
-
- public bool IsExpiring
- {
- get
- {
- return this.ExpiresOnUtc <= DateTimeOffset.Now.UtcDateTime.AddMinutes(5);
- }
- }
-
- public bool ShouldRefresh
- {
- get
- {
- return string.IsNullOrEmpty(this.AccessToken) || this.IsExpiring;
- }
- }
-
- private void ParseAuthenticationResponseValues(IDictionary authenticationResponseValues)
- {
- if (authenticationResponseValues != null)
- {
- foreach (var value in authenticationResponseValues)
- {
- switch (value.Key)
- {
- case OAuthConstants.AccessTokenKeyName:
- this.AccessToken = value.Value;
- break;
- case OAuthConstants.ExpiresInKeyName:
- this.ExpiresOnUtc = DateTimeOffset.UtcNow.Add(new TimeSpan(0, 0, int.Parse(value.Value)));
- break;
- case OAuthConstants.ScopeKeyName:
- var decodedScopes = WebUtility.UrlDecode(value.Value);
- this.Scopes = string.IsNullOrEmpty(decodedScopes) ? null : decodedScopes.Split(' ');
- break;
- case OAuthConstants.UserIdKeyName:
- this.UserId = value.Value;
- break;
- case OAuthConstants.RefreshTokenKeyName:
- this.RefreshToken = value.Value;
- break;
- }
- }
- }
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/AdalAuthenticationProviderBase.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/AdalAuthenticationProviderBase.cs
deleted file mode 100644
index 881ffdb..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/AdalAuthenticationProviderBase.cs
+++ /dev/null
@@ -1,293 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using System.Net.Http.Headers;
- using System.Linq;
- using System.Net.Http;
- using System.Text;
- using System.Threading.Tasks;
-
- using Microsoft.Graph;
- using Microsoft.IdentityModel.Clients.ActiveDirectory;
-
- public abstract class AdalAuthenticationProviderBase : IAuthenticationProvider
- {
- internal AdalCredentialCache adalCredentialCache;
- internal string currentServiceResourceId;
-
- protected delegate Task AuthenticateUserDelegate(string serviceResourceId, string userId);
- protected delegate Task AuthenticateUserSilentlyDelegate(string serviceResourceId, string userId, bool throwOnError);
-
- protected readonly string clientId;
- protected readonly string returnUrl;
-
- protected IAuthenticationContextWrapper authenticationContextWrapper;
-
- ///
- /// Constructor for unit testing.
- ///
- /// The ID of the client.
- /// The return URL for the client.
- /// The context for authenticating against AAD.
- internal AdalAuthenticationProviderBase(
- string clientId,
- string returnUrl,
- IAuthenticationContextWrapper authenticationContextWrapper)
- {
- this.clientId = clientId;
- this.returnUrl = returnUrl;
- this.adalCredentialCache = new AdalCredentialCache(authenticationContextWrapper.TokenCache);
- this.authenticationContextWrapper = authenticationContextWrapper;
- }
-
- internal AdalAuthenticationProviderBase(
- string clientId,
- string returnUrl,
- AuthenticationContext authenticationContext)
- {
- if (string.IsNullOrEmpty(clientId))
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = "AdalAuthenticationProvider requires a client ID for authenticating users."
- });
- }
-
- this.clientId = clientId;
- this.returnUrl = returnUrl;
-
- if (authenticationContext != null)
- {
- this.authenticationContextWrapper = new AuthenticationContextWrapper(authenticationContext);
- }
- else
- {
- this.authenticationContextWrapper = new AuthenticationContextWrapper(
- new AuthenticationContext(OAuthConstants.ActiveDirectoryAuthenticationServiceUrl));
- }
-
- this.adalCredentialCache = new AdalCredentialCache(this.authenticationContextWrapper.TokenCache);
- }
-
- ///
- /// Gets the instance for the class.
- /// Used for unit testing.
- ///
- internal IAuthenticationContextWrapper AuthenticationContextWrapper
- {
- get
- {
- return this.authenticationContextWrapper;
- }
- }
-
- ///
- /// Gets the client ID for the class. Used for unit testing.
- ///
- internal string ClientId
- {
- get
- {
- return this.clientId;
- }
- }
-
- ///
- /// Gets the return URL for the class. Used for unit testing.
- ///
- internal string ReturnUrl
- {
- get
- {
- return this.returnUrl;
- }
- }
-
- protected abstract AuthenticateUserDelegate AuthenticateUser { get; set; }
-
- protected abstract AuthenticateUserSilentlyDelegate AuthenticateUserSilently { get; set; }
-
- public AccountSession CurrentAccountSession { get; internal set; }
-
- public async Task AuthenticateRequestAsync(HttpRequestMessage request)
- {
- if (this.CurrentAccountSession == null)
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = "Please call one of the AuthenticateUserAsync...() methods to authenticate the user before trying to authenticate a request.",
- });
- }
-
- if (this.CurrentAccountSession.IsExpiring)
- {
- if (!string.IsNullOrEmpty(this.CurrentAccountSession.RefreshToken))
- {
- await this.AuthenticateUserWithRefreshTokenAsync(
- this.CurrentAccountSession.RefreshToken,
- this.currentServiceResourceId).ConfigureAwait(false);
- }
- else
- {
- IAuthenticationResult silentAuthenticationResult = null;
-
- var authenticationFailedErrorMessage = "Failed to retrieve a cached account session or silently retrieve a new access token. Please call AuthenticateUserAsync...() again to re-authenticate.";
-
- try
- {
- silentAuthenticationResult = await this.AuthenticateUserSilently(
- this.currentServiceResourceId,
- this.CurrentAccountSession.UserId,
- true).ConfigureAwait(false);
- }
- catch (Exception exception)
- {
-
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = authenticationFailedErrorMessage
- },
- exception);
- }
-
- this.ValidateAuthenticationResult(silentAuthenticationResult, authenticationFailedErrorMessage);
-
- this.CurrentAccountSession = this.ConvertAuthenticationResultToAccountSession(silentAuthenticationResult);
- }
- }
-
- var accessTokenType = string.IsNullOrEmpty(this.CurrentAccountSession.AccessTokenType)
- ? OAuthConstants.Headers.Bearer
- : this.CurrentAccountSession.AccessTokenType;
-
- request.Headers.Authorization = new AuthenticationHeaderValue(
- accessTokenType,
- this.CurrentAccountSession.AccessToken);
- }
-
- public async Task AuthenticateUserAsync(string serviceResourceId, string userId = null)
- {
- if (string.IsNullOrEmpty(serviceResourceId))
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = "Service resource ID is required to authenticate a user with AuthenticateUserAsync."
- });
- }
-
- this.currentServiceResourceId = serviceResourceId;
-
- IAuthenticationResult authenticationResult = null;
-
- try
- {
- authenticationResult = await this.AuthenticateUserSilently(serviceResourceId, userId, false).ConfigureAwait(false);
-
- this.ValidateAuthenticationResult(authenticationResult);
- }
- catch (Exception)
- {
- // If silent authentication fails swallow the exception and try prompting the user.
- // Reset authenticationResult to null in case we have a failed result object.
- authenticationResult = null;
- }
-
- if (authenticationResult == null)
- {
- if (string.IsNullOrEmpty(returnUrl))
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = "The user could not be silently authenticated and return URL is required to prompt the user for authentication."
- });
- }
-
- try
- {
- authenticationResult = await this.AuthenticateUser(serviceResourceId, userId).ConfigureAwait(false);
- }
- catch (Exception exception)
- {
- BusinessAuthenticationExceptionHelper.HandleAuthenticationException(exception);
- }
-
- if (authenticationResult == null)
- {
- BusinessAuthenticationExceptionHelper.HandleAuthenticationException(null);
- }
- }
-
- this.CurrentAccountSession = this.ConvertAuthenticationResultToAccountSession(authenticationResult);
- }
-
- public abstract Task AuthenticateUserWithRefreshTokenAsync(string refreshToken);
-
- public abstract Task AuthenticateUserWithRefreshTokenAsync(string refreshToken, string serviceResourceId);
-
- public Task SignOutAsync()
- {
- this.adalCredentialCache.Clear();
- this.currentServiceResourceId = null;
- this.CurrentAccountSession = null;
-
- return Task.FromResult(0);
- }
-
- protected AccountSession ConvertAuthenticationResultToAccountSession(IAuthenticationResult authenticationResult)
- {
- if (authenticationResult == null)
- {
- return null;
- }
-
- return new AccountSession
- {
- AccessToken = authenticationResult.AccessToken,
- AccessTokenType = authenticationResult.AccessTokenType,
- ClientId = this.clientId,
- ExpiresOnUtc = authenticationResult.ExpiresOn,
- RefreshToken = authenticationResult.RefreshToken,
- UserId = authenticationResult.UserInfo == null ? null : authenticationResult.UserInfo.UniqueId,
- };
- }
-
- protected UserIdentifier GetUserIdentifierForAuthentication(string userId)
- {
- return string.IsNullOrEmpty(userId)
- ? UserIdentifier.AnyUser
- : new UserIdentifier(userId, UserIdentifierType.OptionalDisplayableId);
- }
-
- protected virtual void ValidateAuthenticationResult(IAuthenticationResult authenticationResult, string errorMessage = null)
- {
- if (string.IsNullOrEmpty(errorMessage))
- {
- errorMessage = "Failed to retrieve a valid authentication result.";
- }
-
- if (authenticationResult == null)
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = errorMessage,
- });
- }
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/AuthenticationResultWrapper.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/AuthenticationResultWrapper.cs
deleted file mode 100644
index fcd6e1e..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/AuthenticationResultWrapper.cs
+++ /dev/null
@@ -1,225 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
-
- using Microsoft.IdentityModel.Clients.ActiveDirectory;
-
- public class AuthenticationResultWrapper : IAuthenticationResult
- {
- private AuthenticationResult authenticationResult;
-
- public AuthenticationResultWrapper(AuthenticationResult authenticationResult)
- {
- this.authenticationResult = authenticationResult;
- }
-
- ///
- /// Gets the access token.
- ///
- public string AccessToken
- {
- get
- {
- if (this.authenticationResult != null)
- {
- return this.authenticationResult.AccessToken;
- }
-
- return null;
- }
- }
-
- ///
- /// Gets the type of the access token.
- ///
- public string AccessTokenType
- {
- get
- {
- if (this.authenticationResult != null)
- {
- return this.authenticationResult.AccessTokenType;
- }
-
- return null;
- }
- }
-
- ///
- /// Gets the point in time in which the access token expires.
- /// This value is calculated based on current UTC time.
- ///
- public DateTimeOffset ExpiresOn
- {
- get
- {
- if (this.authenticationResult != null)
- {
- return this.authenticationResult.ExpiresOn;
- }
-
- return default(DateTimeOffset);
- }
- }
-
- ///
- /// Gets the ID token.
- ///
- public string IdToken
- {
- get
- {
- if (this.authenticationResult != null)
- {
- return this.authenticationResult.IdToken;
- }
-
- return null;
- }
- }
-
- ///
- /// Gets a value indicating whether or not the refresh token can be used for requesting
- /// access tokens for other resources.
- ///
- public bool IsMultipleResourceRefreshToken
- {
- get
- {
- if (this.authenticationResult != null)
- {
- return this.authenticationResult.IsMultipleResourceRefreshToken;
- }
-
- return false;
- }
- }
-
- ///
- /// Gets the refresh token for the current access token.
- ///
- public string RefreshToken
- {
- get
- {
- if (this.authenticationResult != null)
- {
- return this.authenticationResult.RefreshToken;
- }
-
- return null;
- }
- }
-
- ///
- /// Gets an identifier for the tenant from which the access token was acquired.
- ///
- public string TenantId
- {
- get
- {
- if (this.authenticationResult != null)
- {
- return this.authenticationResult.TenantId;
- }
-
- return null;
- }
- }
-
- ///
- /// Gets user information, such as user ID.
- ///
- public IUserInfo UserInfo
- {
- get
- {
- if (this.authenticationResult != null && this.authenticationResult.UserInfo != null)
- {
- return new UserInfoWrapper(this.authenticationResult.UserInfo);
- }
-
- return null;
- }
- }
-
-#if WINRT || WINDOWS_UWP
- ///
- /// Gets the error code if authentication failed.
- ///
- public string Error
- {
- get
- {
- if (this.authenticationResult != null)
- {
- return this.authenticationResult.Error;
- }
-
- return null;
- }
- }
-
- ///
- /// Gets the error description if authentication failed.
- ///
- public string ErrorDescription
- {
- get
- {
- if (this.authenticationResult != null)
- {
- return this.authenticationResult.ErrorDescription;
-
- }
-
- return null;
- }
- }
-
- ///
- /// Gets the of authentication.
- ///
- public AuthenticationStatus Status
- {
- get
- {
- if (this.authenticationResult != null)
- {
- return this.authenticationResult.Status;
- }
-
- return default(AuthenticationStatus);
- }
- }
-
- ///
- /// Gets the authentication status code.
- ///
- public int StatusCode
- {
- get
- {
- if (this.authenticationResult != null)
- {
- return this.authenticationResult.StatusCode;
- }
-
- return default(int);
- }
-
- set
- {
- if (this.authenticationResult != null)
- {
- this.authenticationResult.StatusCode = value;
- }
- }
- }
-#endif
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/BusinessAuthenticationExceptionHelper.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/BusinessAuthenticationExceptionHelper.cs
deleted file mode 100644
index 4f973b1..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/BusinessAuthenticationExceptionHelper.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
-
- using Microsoft.Graph;
-#if DESKTOP
- using Microsoft.IdentityModel.Clients.ActiveDirectory;
-#endif
-
- internal static class BusinessAuthenticationExceptionHelper
- {
- internal static void HandleAuthenticationException(Exception exception)
- {
- bool isCancelled = false;
-
- if (exception != null)
- {
- var serviceException = exception as ServiceException;
- if (serviceException != null)
- {
- throw serviceException;
- }
-
-#if DESKTOP
- var adalException = exception as AdalException;
- if (adalException != null)
- {
- isCancelled = string.Equals(adalException.ErrorCode, OAuthConstants.ErrorCodes.AuthenticationCancelled);
- }
-#endif
- }
-
- if (isCancelled)
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationCancelled,
- Message = "User cancelled authentication.",
- },
- exception);
- }
-
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = "An error occurred during Azure Active Directory authentication.",
- },
- exception);
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/BusinessServiceInformation.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/BusinessServiceInformation.cs
deleted file mode 100644
index 3a80173..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/BusinessServiceInformation.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- public class BusinessServiceInformation
- {
- public string ServiceEndpointBaseUrl { get; set; }
-
- public string ServiceResourceId { get; set; }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/IAuthenticationResult.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/IAuthenticationResult.cs
deleted file mode 100644
index 9f7bfe0..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/IAuthenticationResult.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using Microsoft.IdentityModel.Clients.ActiveDirectory;
-
- public interface IAuthenticationResult
- {
- ///
- /// Gets the access token.
- ///
- string AccessToken { get; }
-
- ///
- /// Gets the type of the access token.
- ///
- string AccessTokenType { get; }
-
- ///
- /// Gets the point in time in which the access token expires.
- /// This value is calculated based on current UTC time.
- ///
- DateTimeOffset ExpiresOn { get; }
-
- ///
- /// Gets the ID token.
- ///
- string IdToken { get; }
-
- ///
- /// Gets a value indicating whether or not the refresh token can be used for requesting
- /// access tokens for other resources.
- ///
- bool IsMultipleResourceRefreshToken { get; }
-
- ///
- /// Gets the refresh token for the current access token.
- ///
- string RefreshToken { get; }
-
- ///
- /// Gets an identifier for the tenant from which the access token was acquired.
- ///
- string TenantId { get; }
-
- ///
- /// Gets user information, such as user ID.
- ///
- IUserInfo UserInfo { get; }
-
-#if WINRT || WINDOWS_UWP
- ///
- /// Gets the error code if authentication failed.
- ///
- string Error { get; }
-
- ///
- /// Gets the error description if authentication failed.
- ///
- string ErrorDescription { get; }
-
- ///
- /// Gets the of authentication.
- ///
- AuthenticationStatus Status { get; }
-
- ///
- /// Gets the authentication status code.
- ///
- int StatusCode { get; set; }
-#endif
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/IUserInfo.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/IUserInfo.cs
deleted file mode 100644
index 0daecdb..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/IUserInfo.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
-
- public interface IUserInfo
- {
- string DisplayableId { get; }
-
- string FamilyName { get; }
-
- string GivenName { get; }
-
- string IdentityProvider { get; }
-
- Uri PasswordChangeUrl { get; }
-
- DateTimeOffset? PasswordExpiresOn { get; }
-
- string UniqueId { get; }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/UserInfoWrapper.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/UserInfoWrapper.cs
deleted file mode 100644
index a3de267..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Business/UserInfoWrapper.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using Microsoft.IdentityModel.Clients.ActiveDirectory;
-
- public class UserInfoWrapper : IUserInfo
- {
- private UserInfo userInfo;
-
- public UserInfoWrapper(UserInfo userInfo)
- {
- this.userInfo = userInfo;
- }
-
- public string DisplayableId
- {
- get
- {
- return this.userInfo.DisplayableId;
- }
- }
-
- public string FamilyName
- {
- get
- {
- return this.userInfo.FamilyName;
- }
- }
-
- public string GivenName
- {
- get
- {
- return this.userInfo.GivenName;
- }
- }
-
- public string IdentityProvider
- {
- get
- {
- return this.userInfo.IdentityProvider;
- }
- }
-
- public Uri PasswordChangeUrl
- {
- get
- {
- return this.userInfo.PasswordChangeUrl;
- }
- }
-
- public DateTimeOffset? PasswordExpiresOn
- {
- get
- {
- return this.userInfo.PasswordExpiresOn;
- }
- }
-
- public string UniqueId
- {
- get
- {
- return this.userInfo.UniqueId;
- }
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/AdalCredentialCache.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/AdalCredentialCache.cs
deleted file mode 100644
index 2fe7119..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/AdalCredentialCache.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) 2015 Microsoft Corporation
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using System.Linq;
-
- using IdentityModel.Clients.ActiveDirectory;
-
- public class AdalCredentialCache : CredentialCache
- {
- private ITokenCache tokenCache;
-
- ///
- /// Instantiates a new, empty .
- ///
- internal AdalCredentialCache(ITokenCache tokenCache)
- {
- this.tokenCache = tokenCache;
- }
-
- ///
- /// Instantiates a new, empty .
- ///
- public AdalCredentialCache()
- : this((byte[])null)
- {
- }
-
- ///
- /// Instantiates a new .
- ///
- /// The cache contents for initialization.
- public AdalCredentialCache(byte[] blob)
- : base()
- {
- this.TokenCache.Deserialize(blob);
- }
-
- internal ITokenCache TokenCache
- {
- get
- {
- if (this.tokenCache == null)
- {
- this.tokenCache = new TokenCacheWrapper();
-
- this.tokenCache.AfterAccess = this.AfterAdalAccess;
- this.tokenCache.BeforeAccess = this.BeforeAdalAccess;
- this.tokenCache.BeforeWrite = this.BeforeAdalWrite;
- }
-
- return this.tokenCache;
- }
-
- set
- {
- this.tokenCache = value;
- }
- }
-
- ///
- /// Gets or sets whether or not the cache state has changed.
- ///
- public override bool HasStateChanged
- {
- get
- {
- return this.TokenCache.HasStateChanged;
- }
- set
- {
- this.TokenCache.HasStateChanged = value;
- }
- }
-
- ///
- /// Gets the contents of the cache.
- ///
- /// The cache contents.
- public override byte[] GetCacheBlob()
- {
- return this.TokenCache.Serialize();
- }
-
- ///
- /// Initializes the cache from the specified contents.
- ///
- /// The cache contents.
- public override void InitializeCacheFromBlob(byte[] cacheBytes)
- {
- this.TokenCache.Deserialize(cacheBytes);
- }
-
- ///
- /// Clears the cache contents.
- ///
- public override void Clear()
- {
- // ADAL caching doesn't notify the delegates of access on Clear(). Call them explicitly
- // for consistency with CredentialCache behavior since the cache is being accessed and written.
- var cacheNotificationArgs = new CredentialCacheNotificationArgs { CredentialCache = this };
-
- this.OnBeforeAccess(cacheNotificationArgs);
- this.OnBeforeWrite(cacheNotificationArgs);
-
- this.TokenCache.Clear();
-
- this.OnAfterAccess(cacheNotificationArgs);
- this.HasStateChanged = true;
- }
-
- internal override void AddToCache(AccountSession accountSession)
- {
- // Let ADAL handle the caching
- }
-
- internal override void DeleteFromCache(AccountSession accountSession)
- {
- var cacheItems = this.TokenCache.ReadItems();
-
- var currentUserItems = cacheItems.Where(
- cacheItem =>
- string.Equals(cacheItem.ClientId, accountSession.ClientId, StringComparison.OrdinalIgnoreCase)
- && string.Equals(cacheItem.UniqueId, accountSession.UserId, StringComparison.OrdinalIgnoreCase));
-
- if (currentUserItems != null)
- {
- foreach (var item in currentUserItems)
- {
- this.TokenCache.DeleteItem(item);
- }
- }
- }
-
- internal override AccountSession GetResultFromCache(string clientId, string userId)
- {
- // Let ADAL handle the caching
- return null;
- }
-
- private void AfterAdalAccess(TokenCacheNotificationArgs args)
- {
- this.OnAfterAccess(new CredentialCacheNotificationArgs { CredentialCache = this });
- }
-
- private void BeforeAdalAccess(TokenCacheNotificationArgs args)
- {
- this.OnBeforeAccess(new CredentialCacheNotificationArgs { CredentialCache = this });
- }
-
- private void BeforeAdalWrite(TokenCacheNotificationArgs args)
- {
- this.OnBeforeWrite(new CredentialCacheNotificationArgs { CredentialCache = this });
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/CredentialCache.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/CredentialCache.cs
deleted file mode 100644
index 9afbc4e..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/CredentialCache.cs
+++ /dev/null
@@ -1,305 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.IO;
-
- using Microsoft.Graph;
-
- ///
- /// Notification delegate for cache access.
- ///
- /// The argument set for the notification.
- public delegate void CredentialCacheNotification(CredentialCacheNotificationArgs args);
-
- public class CredentialCache
- {
- internal readonly IDictionary cacheDictionary =
- new ConcurrentDictionary();
- internal CredentialCacheKey MostRecentlyUsedKey { get; set; }
-
- private const int CacheVersion = 2;
-
- ///
- /// Instantiates a new .
- ///
- /// The for serializing cache contents.
- public CredentialCache()
- : this(null, null)
- {
- }
-
- ///
- /// Instantiates a new .
- ///
- /// The for serializing cache contents.
- public CredentialCache(ISerializer serializer)
- : this(null, serializer)
- {
- }
-
- ///
- /// Instantiates a new .
- ///
- /// The cache contents for initialization.
- /// The for serializing cache contents.
- public CredentialCache(byte[] blob, ISerializer serializer = null)
- {
- this.Serializer = serializer ?? new Serializer();
- this.InitializeCacheFromBlob(blob);
- this.MostRecentlyUsedKey = null;
- }
-
- ///
- /// Gets or sets the notification delegate for before accessing the cache.
- ///
- public virtual CredentialCacheNotification BeforeAccess { get; set; }
-
- ///
- /// Gets or sets the notification delegate for before writing to the cache.
- ///
- public virtual CredentialCacheNotification BeforeWrite { get; set; }
-
- ///
- /// Gets or sets the notification delegate for after accessing the cache.
- ///
- public virtual CredentialCacheNotification AfterAccess { get; set; }
-
- ///
- /// Gets or sets whether or not the cache state has changed.
- ///
- public virtual bool HasStateChanged { get; set; }
-
- protected ISerializer Serializer { get; private set; }
-
- ///
- /// Gets the contents of the cache.
- ///
- /// The cache contents.
- public virtual byte[] GetCacheBlob()
- {
- using (var stream = new MemoryStream())
- using (var binaryReader = new BinaryReader(stream))
- using (var binaryWriter = new BinaryWriter(stream))
- {
- binaryWriter.Write(CredentialCache.CacheVersion);
- binaryWriter.Write(this.cacheDictionary.Count);
- foreach (var cacheItem in this.cacheDictionary)
- {
- binaryWriter.Write(this.Serializer.SerializeObject(cacheItem.Key));
- binaryWriter.Write(this.Serializer.SerializeObject(cacheItem.Value));
- }
-
- var shouldWriteMruKey = this.MostRecentlyUsedKey != null;
- binaryWriter.Write(shouldWriteMruKey); // To tell the reader that MRUKey needs to be read
- if (shouldWriteMruKey)
- {
- binaryWriter.Write(this.Serializer.SerializeObject(this.MostRecentlyUsedKey));
- }
-
- var length = (int)stream.Position;
- stream.Position = 0;
-
- return binaryReader.ReadBytes(length);
- }
- }
-
- ///
- /// Initializes the cache from the specified contents.
- ///
- /// The cache contents.
- public virtual void InitializeCacheFromBlob(byte[] cacheBytes)
- {
- if (cacheBytes == null)
- {
- this.cacheDictionary.Clear();
- }
- else
- {
- using (var stream = new MemoryStream())
- using (var binaryReader = new BinaryReader(stream))
- using (var binaryWriter = new BinaryWriter(stream))
- {
- binaryWriter.Write(cacheBytes);
- stream.Position = 0;
-
- this.cacheDictionary.Clear();
-
- var version = binaryReader.ReadInt32();
-
- if (version != CredentialCache.CacheVersion)
- {
- // If the cache version doesn't match, skip deserialization
- return;
- }
-
- var count = binaryReader.ReadInt32();
-
- for (int i=0; i < count; i++)
- {
- var keyString = binaryReader.ReadString();
- var authResultString = binaryReader.ReadString();
-
- if (!string.IsNullOrEmpty(keyString) && !string.IsNullOrEmpty(authResultString))
- {
- var credentialCacheKey = this.Serializer.DeserializeObject(keyString);
- var authResult = this.Serializer.DeserializeObject(authResultString);
-
- this.cacheDictionary.Add(credentialCacheKey, authResult);
- }
- }
-
- var shouldReadMruKey = binaryReader.ReadBoolean();
- this.MostRecentlyUsedKey = shouldReadMruKey ? this.Serializer.DeserializeObject(binaryReader.ReadString()) : null;
- }
- }
- }
-
- ///
- /// Clears the cache contents.
- ///
- public virtual void Clear()
- {
- var cacheNotificationArgs = new CredentialCacheNotificationArgs { CredentialCache = this };
-
- this.OnBeforeAccess(cacheNotificationArgs);
- this.OnBeforeWrite(cacheNotificationArgs);
-
- this.cacheDictionary.Clear();
-
- this.HasStateChanged = true;
- this.OnAfterAccess(cacheNotificationArgs);
- }
-
- internal virtual void AddToCache(AccountSession accountSession)
- {
- var cacheNotificationArgs = new CredentialCacheNotificationArgs { CredentialCache = this };
-
- this.OnBeforeAccess(cacheNotificationArgs);
- this.OnBeforeWrite(cacheNotificationArgs);
-
- var cacheKey = this.GetKeyForAuthResult(accountSession);
- this.cacheDictionary[cacheKey] = accountSession;
- this.MostRecentlyUsedKey = cacheKey;
-
- this.HasStateChanged = true;
- this.OnAfterAccess(cacheNotificationArgs);
- }
-
- internal virtual void DeleteFromCache(AccountSession accountSession)
- {
- if (accountSession != null)
- {
- var cacheNotificationArgs = new CredentialCacheNotificationArgs { CredentialCache = this };
- this.OnBeforeAccess(cacheNotificationArgs);
- this.OnBeforeWrite(cacheNotificationArgs);
-
- var credentialCacheKey = this.GetKeyForAuthResult(accountSession);
- this.cacheDictionary.Remove(credentialCacheKey);
- if (credentialCacheKey.Equals(this.MostRecentlyUsedKey))
- {
- this.MostRecentlyUsedKey = null;
- }
-
- this.HasStateChanged = true;
-
- this.OnAfterAccess(cacheNotificationArgs);
- }
- }
-
- internal CredentialCacheKey GetKeyForAuthResult(AccountSession accountSession)
- {
- return new CredentialCacheKey
- {
- ClientId = accountSession.ClientId,
- UserId = accountSession.UserId,
- };
- }
-
- internal virtual AccountSession GetResultFromCache(string clientId, string userId)
- {
- var credentialCacheKey = new CredentialCacheKey
- {
- ClientId = clientId,
- UserId = userId,
- };
-
- var cacheNotificationArgs = new CredentialCacheNotificationArgs { CredentialCache = this };
- this.OnBeforeAccess(cacheNotificationArgs);
-
- var result = this.GetResultFromCache(credentialCacheKey);
-
- this.OnAfterAccess(cacheNotificationArgs);
-
- return result;
- }
-
- ///
- /// Gets the most recently read or written result from cache.
- ///
- /// Most recently used result. Null if no cache value is stored
- /// as most recently used (could be that most-recently used value was deleted).
- ///
- internal virtual AccountSession GetMostRecentlyUsedResultFromCache()
- {
- var cacheNotificationArgs = new CredentialCacheNotificationArgs { CredentialCache = this };
- this.OnBeforeAccess(cacheNotificationArgs);
-
- if (this.MostRecentlyUsedKey == null)
- {
- return null;
- }
-
- var result = this.GetResultFromCache(this.MostRecentlyUsedKey);
-
- this.OnAfterAccess(cacheNotificationArgs);
-
- return result;
- }
-
- ///
- /// Actual cache read. Notifications should be sent before & after this method.
- /// Updates this.MostRecentlyUsedKey.
- ///
- /// Key to look up
- /// Result from cache.
- private AccountSession GetResultFromCache(CredentialCacheKey credentialCacheKey)
- {
- AccountSession cacheResult = null;
- if (this.cacheDictionary.TryGetValue(credentialCacheKey, out cacheResult))
- {
- this.MostRecentlyUsedKey = credentialCacheKey;
- }
-
- return cacheResult;
- }
-
- protected void OnAfterAccess(CredentialCacheNotificationArgs args)
- {
- if (this.AfterAccess != null)
- {
- this.AfterAccess(args);
- }
- }
-
- protected void OnBeforeAccess(CredentialCacheNotificationArgs args)
- {
- if (this.BeforeAccess != null)
- {
- this.BeforeAccess(args);
- }
- }
-
- protected void OnBeforeWrite(CredentialCacheNotificationArgs args)
- {
- if (this.BeforeWrite != null)
- {
- this.BeforeWrite(args);
- }
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/CredentialCacheKey.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/CredentialCacheKey.cs
deleted file mode 100644
index 01d2ad3..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/CredentialCacheKey.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
-
- public class CredentialCacheKey
- {
- private const string Delimiter = ";";
-
- public string ClientId { get; set; }
-
- public string UserId { get; set; }
-
- public override bool Equals(object obj)
- {
- var credentialCacheKey = obj as CredentialCacheKey;
-
- return credentialCacheKey != null && credentialCacheKey.GetHashCode() == this.GetHashCode();
- }
-
- public override int GetHashCode()
- {
- return
- (string.Join(
- CredentialCacheKey.Delimiter,
- this.ClientId,
- this.UserId).ToLowerInvariant()).GetHashCode();
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/CredentialCacheNotificationArgs.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/CredentialCacheNotificationArgs.cs
deleted file mode 100644
index d288ec9..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/CredentialCacheNotificationArgs.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- public class CredentialCacheNotificationArgs
- {
- public CredentialCache CredentialCache { get; set; }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/ITokenCache.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/ITokenCache.cs
deleted file mode 100644
index 3eaf5a6..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/ITokenCache.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System.Collections.Generic;
-
- using Microsoft.IdentityModel.Clients.ActiveDirectory;
-
- public interface ITokenCache
- {
- ///
- /// Gets or sets the notification delegate for after accessing the cache.
- ///
- TokenCacheNotification AfterAccess { get; set; }
-
- ///
- /// Gets or sets the notification delegate for before accessing the cache.
- ///
- TokenCacheNotification BeforeAccess { get; set; }
-
- ///
- /// Gets or sets the notification delegate for before writing to the cache.
- ///
- TokenCacheNotification BeforeWrite { get; set; }
-
- ///
- /// Gets or sets whether or not the cache state has changed.
- ///
- bool HasStateChanged { get; set; }
-
- ///
- /// Gets the inner .
- ///
- TokenCache InnerTokenCache { get; }
-
- ///
- /// Clears the cache contents.
- ///
- void Clear();
-
- ///
- /// Deletes the specified from the cache.
- ///
- /// The to delete.
- void DeleteItem(ITokenCacheItem tokenCacheItem);
-
- ///
- /// Initializes the cache from the specified contents.
- ///
- /// The cache contents.
- void Deserialize(byte[] blob);
-
- ///
- /// Returns the collection of s in the cache.
- ///
- /// The collection of s.
- IEnumerable ReadItems();
-
- ///
- /// Gets the contents of the cache.
- ///
- /// The cache contents.
- byte[] Serialize();
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/ITokenCacheItem.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/ITokenCacheItem.cs
deleted file mode 100644
index f4c2cd5..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/ITokenCacheItem.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
-
- using Microsoft.IdentityModel.Clients.ActiveDirectory;
-
- public interface ITokenCacheItem
- {
- ///
- /// Gets the access token.
- ///
- string AccessToken { get; }
-
- ///
- /// Gets the authority.
- ///
- string Authority { get; }
-
- ///
- /// Gets the client ID.
- ///
- string ClientId { get; }
-
- ///
- /// Gets the user's displayable ID.
- ///
- string DisplayableId { get; }
-
- ///
- /// Gets the expiration.
- ///
- DateTimeOffset ExpiresOn { get; }
-
- ///
- /// Gets the family name.
- ///
- string FamilyName { get; }
-
- ///
- /// Gets the given name.
- ///
- string GivenName { get; }
-
- ///
- /// Gets the identity provider name.
- ///
- string IdentityProvider { get; }
-
- ///
- /// Gets the entire ID token if returned by the service or null if no ID token is returned.
- ///
- string IdToken { get; }
-
- ///
- /// Gets the inner .
- ///
- TokenCacheItem InnerCacheItem { get; }
-
- ///
- /// Gets a value indicating whether or not the refresh token applies to multiple resources.
- ///
- bool IsMultipleResourceRefreshToken { get; }
-
- ///
- /// Gets the refresh token associated with the requested access token. Note: not
- /// all operations will return a refresh token.
- ///
- string RefreshToken { get; }
-
- ///
- /// Gets the resource.
- ///
- string Resource { get; }
-
- ///
- /// Get's the user's tenant ID.
- ///
- string TenantId { get; }
-
- ///
- /// Gets the user's unique ID.
- ///
- string UniqueId { get; }
- }
-}
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/TokenCacheItemWrapper.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/TokenCacheItemWrapper.cs
deleted file mode 100644
index dbc44b6..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/TokenCacheItemWrapper.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
-
- using Microsoft.IdentityModel.Clients.ActiveDirectory;
-
- public class TokenCacheItemWrapper : ITokenCacheItem
- {
- ///
- /// Instantiates a new .
- ///
- /// The to store as the inner cache item.
- public TokenCacheItemWrapper(TokenCacheItem tokenCacheItem)
- {
- this.InnerCacheItem = tokenCacheItem;
- }
-
- ///
- /// Gets the access token.
- ///
- public string AccessToken
- {
- get
- {
- return this.InnerCacheItem.AccessToken;
- }
- }
-
- ///
- /// Gets the authority.
- ///
- public string Authority
- {
- get
- {
- return this.InnerCacheItem.Authority;
- }
- }
-
- ///
- /// Gets the client ID.
- ///
- public string ClientId
- {
- get
- {
- return this.InnerCacheItem.ClientId;
- }
- }
-
- ///
- /// Gets the user's displayable ID.
- ///
- public string DisplayableId
- {
- get
- {
- return this.InnerCacheItem.DisplayableId;
- }
- }
-
- ///
- /// Gets the expiration.
- ///
- public DateTimeOffset ExpiresOn
- {
- get
- {
- return this.InnerCacheItem.ExpiresOn;
- }
- }
-
- ///
- /// Gets the family name.
- ///
- public string FamilyName
- {
- get
- {
- return this.InnerCacheItem.FamilyName;
- }
- }
-
- ///
- /// Gets the given name.
- ///
- public string GivenName
- {
- get
- {
- return this.InnerCacheItem.GivenName;
- }
- }
-
- ///
- /// Gets the identity provider name.
- ///
- public string IdentityProvider
- {
- get
- {
- return this.InnerCacheItem.IdentityProvider;
- }
- }
-
- ///
- /// Gets the entire ID token if returned by the service or null if no ID token is returned.
- ///
- public string IdToken
- {
- get
- {
- return this.InnerCacheItem.IdToken;
- }
- }
-
- ///
- /// Gets the inner .
- ///
- public TokenCacheItem InnerCacheItem { get; private set; }
-
- ///
- /// Gets a value indicating whether or not the refresh token applies to multiple resources.
- ///
- public bool IsMultipleResourceRefreshToken
- {
- get
- {
- return this.InnerCacheItem.IsMultipleResourceRefreshToken;
- }
- }
-
- ///
- /// Gets the refresh token associated with the requested access token. Note: not
- /// all operations will return a refresh token.
- ///
- public string RefreshToken
- {
- get
- {
- return this.InnerCacheItem.RefreshToken;
- }
- }
-
- ///
- /// Gets the resource.
- ///
- public string Resource
- {
- get
- {
- return this.InnerCacheItem.Resource;
- }
- }
-
- ///
- /// Get's the user's tenant ID.
- ///
- public string TenantId
- {
- get
- {
- return this.InnerCacheItem.TenantId;
- }
- }
-
- ///
- /// Gets the user's unique ID.
- ///
- public string UniqueId
- {
- get
- {
- return this.InnerCacheItem.UniqueId;
- }
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/TokenCacheWrapper.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/TokenCacheWrapper.cs
deleted file mode 100644
index b0898fc..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Caching/TokenCacheWrapper.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.IdentityModel.Clients.ActiveDirectory;
-
- public class TokenCacheWrapper : ITokenCache
- {
- ///
- /// Instantiates a new .
- ///
- /// The to use as the inner cache.
- public TokenCacheWrapper(TokenCache tokenCache = null)
- {
- this.InnerTokenCache = tokenCache ?? new TokenCache();
- }
-
- ///
- /// Gets or sets the notification delegate for after accessing the cache.
- ///
- public TokenCacheNotification AfterAccess
- {
- get
- {
- return this.InnerTokenCache.AfterAccess;
- }
-
- set
- {
- this.InnerTokenCache.AfterAccess = value;
- }
- }
-
- ///
- /// Gets or sets the notification delegate for before accessing the cache.
- ///
- public TokenCacheNotification BeforeAccess
- {
- get
- {
- return this.InnerTokenCache.BeforeAccess;
- }
-
- set
- {
- this.InnerTokenCache.BeforeAccess = value;
- }
- }
-
- ///
- /// Gets or sets the notification delegate for before writing to the cache.
- ///
- public TokenCacheNotification BeforeWrite
- {
- get
- {
- return this.InnerTokenCache.BeforeWrite;
- }
-
- set
- {
- this.InnerTokenCache.BeforeWrite = value;
- }
- }
-
- ///
- /// Gets or sets whether or not the cache state has changed.
- ///
- public bool HasStateChanged
- {
- get
- {
- return this.InnerTokenCache.HasStateChanged;
- }
-
- set
- {
- this.InnerTokenCache.HasStateChanged = value;
- }
- }
-
- ///
- /// Gets the inner .
- ///
- public TokenCache InnerTokenCache { get; private set; }
-
- ///
- /// Clears the cache contents.
- ///
- public void Clear()
- {
- this.InnerTokenCache.Clear();
- }
-
- ///
- /// Deletes the specified from the cache.
- ///
- /// The to delete.
- public void DeleteItem(ITokenCacheItem tokenCacheItem)
- {
- this.InnerTokenCache.DeleteItem(tokenCacheItem.InnerCacheItem);
- }
-
- ///
- /// Initializes the cache from the specified contents.
- ///
- /// The cache contents.
- public void Deserialize(byte[] blob)
- {
- this.InnerTokenCache.Deserialize(blob);
- }
-
- ///
- /// Returns the collection of s in the cache.
- ///
- /// The collection of s.
- public IEnumerable ReadItems()
- {
- var cacheItems = this.InnerTokenCache.ReadItems();
-
- if (cacheItems != null)
- {
- return cacheItems.Select(cacheItem => new TokenCacheItemWrapper(cacheItem));
- }
-
- return null;
- }
-
- ///
- /// Gets the contents of the cache.
- ///
- /// The cache contents.
- public byte[] Serialize()
- {
- return this.InnerTokenCache.Serialize();
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Discovery Service/DiscoveryService.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Discovery Service/DiscoveryService.cs
deleted file mode 100644
index 3ce006f..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Discovery Service/DiscoveryService.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- ///
- /// Class for deserializing discovery service objects returned from calls to the discovery service.
- ///
- public class DiscoveryService
- {
- ///
- /// Gets or sets the capability for the service.
- ///
- public string Capability { get; set; }
-
- ///
- /// Gets or sets the service API version.
- ///
- public string ServiceApiVersion { get; set; }
-
- ///
- /// Gets or sets the URL for the service endpoint.
- ///
- public string ServiceEndpointUri { get; set; }
-
- ///
- /// Gets or sets the resource for the service.
- ///
- public string ServiceResourceId { get; set; }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Discovery Service/DiscoveryServiceHelperBase.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Discovery Service/DiscoveryServiceHelperBase.cs
deleted file mode 100644
index 6f5bc12..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Discovery Service/DiscoveryServiceHelperBase.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using System.Linq;
- using System.Net.Http;
- using System.Threading.Tasks;
-
- using Microsoft.Graph;
-
- public abstract class DiscoveryServiceHelperBase
- {
- protected IAuthenticationProvider authenticationProvider;
-
- protected DiscoveryServiceHelperBase(IAuthenticationProvider authenticationProvider)
- {
- this.authenticationProvider = authenticationProvider;
- }
-
- ///
- /// Gets the instance for the class.
- /// Used for unit testing.
- ///
- internal IAuthenticationProvider AuthenticationProvider
- {
- get
- {
- return this.authenticationProvider;
- }
- }
-
- protected async Task RetrieveMyFilesServiceResourceAsync()
- {
- using (var httpProvider = new HttpProvider())
- {
- var businessServiceInfo = await this.RetrieveMyFilesServiceResourceAsync(httpProvider).ConfigureAwait(false);
- return businessServiceInfo;
- }
- }
-
- protected async Task RetrieveMyFilesServiceResourceAsync(IHttpProvider httpProvider)
- {
- using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, OAuthConstants.ActiveDirectoryDiscoveryServiceUrl))
- {
- await this.authenticationProvider.AuthenticateRequestAsync(httpRequestMessage).ConfigureAwait(false);
-
- using (var response = await httpProvider.SendAsync(httpRequestMessage).ConfigureAwait(false))
- using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
- {
- var responseValues = httpProvider.Serializer.DeserializeObject(responseStream);
- if (responseValues == null || responseValues.Value == null)
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = "MyFiles capability not found for the current user."
- });
- }
-
- var service = responseValues.Value.FirstOrDefault(value =>
- string.Equals(value.ServiceApiVersion, "v2.0", StringComparison.OrdinalIgnoreCase) &&
- string.Equals(value.Capability, "MyFiles", StringComparison.OrdinalIgnoreCase));
-
- if (service == null)
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = "MyFiles capability with version v2.0 not found for the current user.",
- });
- }
-
- return new BusinessServiceInformation
- {
- ServiceEndpointBaseUrl = service.ServiceEndpointUri,
- ServiceResourceId = service.ServiceResourceId,
- };
- }
- }
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Discovery Service/DiscoveryServiceResponse.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Discovery Service/DiscoveryServiceResponse.cs
deleted file mode 100644
index d96a91d..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Discovery Service/DiscoveryServiceResponse.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System.Collections.Generic;
-
- ///
- /// Class for deserializing responses from the discovery service.
- ///
- public class DiscoveryServiceResponse
- {
- ///
- /// The list of objects returned from the discovery service.
- ///
- public IEnumerable Value { get; set; }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/ICredentialVault.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/ICredentialVault.cs
deleted file mode 100644
index 122f392..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/ICredentialVault.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- public interface ICredentialVault
- {
- ///
- /// Store the CredentialCache somewhere safe. If anything was previously
- /// stored in this vault, it is deleted.
- ///
- /// The cache to be serialized and stored.
- void AddCredentialCacheToVault(CredentialCache credentialCache);
-
- ///
- /// Retrieve the cache information and store it in
- ///
- /// Place to store the retrieved credentials.
- /// True if the cache was successfully retrieved, otherwise false.
- bool RetrieveCredentialCache(CredentialCache credentialCache);
-
- ///
- /// Clear out stored credentials.
- ///
- /// True if the credentials were cleared, otherwise false.
- bool DeleteStoredCredentialCache();
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/IOAuthRequestStringBuilder.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/IOAuthRequestStringBuilder.cs
deleted file mode 100644
index 8839593..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/IOAuthRequestStringBuilder.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- public interface IOAuthRequestStringBuilder
- {
- ///
- /// Gets the request URL for OAuth authentication using the code flow.
- ///
- /// The return URL for the request. Defaults to the service info value.
- /// The OAuth request URL.
- string GetAuthorizationCodeRequestUrl(string appId, string returnUrl, string[] scopes, string userId = null);
-
- ///
- /// Gets the request body for redeeming an authorization code for an access token.
- ///
- /// The authorization code to redeem.
- /// The return URL for the request. Defaults to the service info value.
- /// The request body for the code redemption call.
- string GetCodeRedemptionRequestBody(string code, string appId, string returnUrl, string[] scopes, string clientSecret = null);
-
- ///
- /// Gets the request body for redeeming a refresh token for an access token.
- ///
- /// The refresh token to redeem.
- /// The request body for the redemption call.
- string GetRefreshTokenRequestBody(string refreshToken, string appId, string returnUrl, string[] scopes, string clientSecret = null);
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Microsoft.Graph.Core.dll b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Microsoft.Graph.Core.dll
deleted file mode 100644
index d21dbdb..0000000
Binary files a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Microsoft.Graph.Core.dll and /dev/null differ
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Microsoft.OneDrive.Sdk.dll b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Microsoft.OneDrive.Sdk.dll
deleted file mode 100644
index 4ee8380..0000000
Binary files a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Microsoft.OneDrive.Sdk.dll and /dev/null differ
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/MsaAuthenticationProvider.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/MsaAuthenticationProvider.cs
deleted file mode 100644
index 1f0d686..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/MsaAuthenticationProvider.cs
+++ /dev/null
@@ -1,589 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using System.Net.Http;
- using System.Net.Http.Headers;
- using System.Threading.Tasks;
-
- using Microsoft.Graph;
-
-#if XamarinAndroid
- using Android.Content;
-#endif
-
-#if NETFX_CORE
- using Windows.Security.Authentication.Web;
- using Windows.System.Profile;
-#endif
-
- ///
- /// A default implementation.
- ///
- public class MsaAuthenticationProvider : IAuthenticationProvider
- {
- internal readonly string clientId;
- internal string clientSecret;
- internal string returnUrl;
- internal string[] scopes;
-
- private OAuthHelper oAuthHelper;
-
- internal ICredentialVault credentialVault;
- internal IWebAuthenticationUi webAuthenticationUi;
-
-#if DESKTOP
- ///
- /// Constructs an .
- ///
- public MsaAuthenticationProvider(string clientId, string returnUrl, string[] scopes)
- : this(clientId, /*clientSecret*/ null, returnUrl, scopes, /* credentialCache */ null, /* credentialVault */ null)
- {
- }
-
- ///
- /// Constructs an .
- ///
- public MsaAuthenticationProvider(string clientId, string returnUrl, string[] scopes, ICredentialVault credentialVault)
- : this(clientId, /*clientSecret*/ null, returnUrl, scopes, /* credentialCache */ null, credentialVault)
- {
- }
-
- ///
- /// Constructs an .
- ///
- public MsaAuthenticationProvider(
- string clientId,
- string clientSecret,
- string returnUrl,
- string[] scopes,
- CredentialCache credentialCache,
- ICredentialVault credentialVault)
- : this(clientId, clientSecret, returnUrl, scopes, credentialCache)
- {
- if (credentialVault != null)
- {
- this.CredentialCache.BeforeAccess = cacheArgs =>
- {
- credentialVault.RetrieveCredentialCache(cacheArgs.CredentialCache);
- cacheArgs.CredentialCache.HasStateChanged = false;
- };
- this.CredentialCache.AfterAccess = cacheArgs =>
- {
- if (cacheArgs.CredentialCache.HasStateChanged)
- {
- credentialVault.AddCredentialCacheToVault(cacheArgs.CredentialCache);
- }
- };
- }
- }
-
- ///
- /// Constructs an .
- ///
- public MsaAuthenticationProvider(
- string clientId,
- string clientSecret,
- string returnUrl,
- string[] scopes,
- CredentialCache credentialCache)
- {
- this.clientId = clientId;
- this.clientSecret = clientSecret;
- this.returnUrl = returnUrl;
- this.scopes = scopes;
-
- this.CredentialCache = credentialCache ?? new CredentialCache();
- this.oAuthHelper = new OAuthHelper();
- this.webAuthenticationUi = new FormsWebAuthenticationUi();
- }
-
-#elif NETFX_CORE
-
- ///
- /// Constructs an .
- ///
- public MsaAuthenticationProvider(string clientId, string returnUrl, string[] scopes)
- : this(clientId, returnUrl, scopes, /* credentialCache */ null, /* credentialVault */ null)
- {
- }
-
- ///
- /// Constructs an .
- ///
- public MsaAuthenticationProvider(string clientId, string returnUrl, string[] scopes, ICredentialVault credentialVault)
- : this(clientId, returnUrl, scopes, /* credentialCache */ null, credentialVault)
- {
- }
-
- ///
- /// Constructs an .
- ///
- public MsaAuthenticationProvider(
- string clientId,
- string returnUrl,
- string[] scopes,
- CredentialCache credentialCache,
- ICredentialVault credentialVault)
- : this(clientId, returnUrl, scopes, credentialCache)
- {
- if (credentialVault != null)
- {
- this.CredentialCache.BeforeAccess = cacheArgs =>
- {
- credentialVault.RetrieveCredentialCache(cacheArgs.CredentialCache);
- cacheArgs.CredentialCache.HasStateChanged = false;
- };
- this.CredentialCache.AfterAccess = cacheArgs =>
- {
- if (cacheArgs.CredentialCache.HasStateChanged)
- {
- credentialVault.AddCredentialCacheToVault(cacheArgs.CredentialCache);
- }
- };
- }
- }
-
- ///
- /// Constructs an .
- ///
- public MsaAuthenticationProvider(
- string clientId,
- string returnUrl,
- string[] scopes,
- CredentialCache credentialCache)
- {
- this.clientId = clientId;
- this.clientSecret = null;
-
- this.returnUrl = string.IsNullOrEmpty(returnUrl)
- ? WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString()
- : returnUrl;
-
- this.scopes = scopes;
-
- this.CredentialCache = credentialCache ?? new CredentialCache();
- this.oAuthHelper = new OAuthHelper();
-#if WINRT
- this.webAuthenticationUi = new WebAuthenticationBrokerWebAuthenticationUi();
-#elif WINDOWS_UWP
- // WebAuthenticationBroker is not supported on Windows 10 IoT Core, so if we're running UWP,
- // we need to first check if we're running on IoT Core. If we are, we fall back to our
- // own implementation.
-
- // Our method of detection here isn't bulletproof--more non-IoT device families could fall under
- // this namespace in the future. Unfortunately, using API detection won't work, because the API
- // is AVAILABLE in IoT, it just doesn't actually work.
- if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.IoT")
- {
- this.webAuthenticationUi = new IotCoreFriendlyWebAuthenticationUi();
- }
- else
- {
- this.webAuthenticationUi = new WebAuthenticationBrokerWebAuthenticationUi();
- }
-#endif
- }
-
-#elif XamarinAndroid
-
- ///
- /// Constructs an .
- ///
- public MsaAuthenticationProvider(Context context, string clientId, string returnUrl, string[] scopes)
- : this(context, clientId, /*clientSecret*/ null, returnUrl, scopes, /* credentialCache */ null, /* credentialVault */ null)
- {
- }
-
- ///
- /// Constructs an .
- ///
- public MsaAuthenticationProvider(Context context, string clientId, string returnUrl, string[] scopes, ICredentialVault credentialVault)
- : this(context, clientId, /*clientSecret*/ null, returnUrl, scopes, /* credentialCache */ null, credentialVault)
- {
- }
-
- ///
- /// Constructs an .
- ///
- public MsaAuthenticationProvider(
- Context context,
- string clientId,
- string clientSecret,
- string returnUrl,
- string[] scopes,
- CredentialCache credentialCache,
- ICredentialVault credentialVault)
- : this(context, clientId, clientSecret, returnUrl, scopes, credentialCache)
- {
- if (credentialVault != null)
- {
- this.CredentialCache.BeforeAccess = cacheArgs =>
- {
- credentialVault.RetrieveCredentialCache(cacheArgs.CredentialCache);
- cacheArgs.CredentialCache.HasStateChanged = false;
- };
- this.CredentialCache.AfterAccess = cacheArgs =>
- {
- if (cacheArgs.CredentialCache.HasStateChanged)
- {
- credentialVault.AddCredentialCacheToVault(cacheArgs.CredentialCache);
- }
- };
- }
- }
-
- ///
- /// Constructs an .
- ///
- public MsaAuthenticationProvider(
- Context context,
- string clientId,
- string clientSecret,
- string returnUrl,
- string[] scopes,
- CredentialCache credentialCache)
- : this(clientId, clientSecret, returnUrl, scopes, credentialCache, new AndroidWebAuthenticationUi(context))
- {
- }
-
- ///
- /// Constructs an .
- ///
- internal MsaAuthenticationProvider(
- string clientId,
- string clientSecret,
- string returnUrl,
- string[] scopes,
- CredentialCache credentialCache,
- IWebAuthenticationUi authenticationUi)
- {
- this.clientId = clientId;
- this.clientSecret = clientSecret;
- this.returnUrl = returnUrl;
- this.scopes = scopes;
-
- this.CredentialCache = credentialCache ?? new CredentialCache();
- this.oAuthHelper = new OAuthHelper();
- this.webAuthenticationUi = authenticationUi;
- }
-
-#endif
-
- public CredentialCache CredentialCache { get; private set; }
-
- public AccountSession CurrentAccountSession { get; set; }
-
- ///
- /// Gets whether or not the current client is authenticated.
- ///
- public bool IsAuthenticated
- {
- get
- {
- return this.CurrentAccountSession != null;
- }
- }
-
- ///
- /// Authenticates the provided request object.
- ///
- /// The to authenticate.
- /// The task to await.
- public async Task AuthenticateRequestAsync(HttpRequestMessage request)
- {
- var authResult = await this.ProcessCachedAccountSessionAsync(this.CurrentAccountSession).ConfigureAwait(false);
-
- if (authResult == null)
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = "Unable to retrieve a valid account session for the user. Please call AuthenticateUserAsync to prompt the user to re-authenticate."
- });
- }
-
- if (!string.IsNullOrEmpty(authResult.AccessToken))
- {
- var tokenTypeString = string.IsNullOrEmpty(authResult.AccessTokenType)
- ? OAuthConstants.Headers.Bearer
- : authResult.AccessTokenType;
- request.Headers.Authorization = new AuthenticationHeaderValue(tokenTypeString, authResult.AccessToken);
- }
- }
-
- ///
- /// Signs the current user out.
- ///
- public virtual async Task SignOutAsync()
- {
- if (this.IsAuthenticated)
- {
- await this.SignOutOfBrowserAsync();
-
- this.DeleteUserCredentialsFromCache(this.CurrentAccountSession);
- this.CurrentAccountSession = null;
- }
- }
-
- ///
- /// Get rid of any cookies in the browser
- ///
- /// Task for signout. When task is done, signout is complete.
- public async Task SignOutOfBrowserAsync()
- {
- if (this.webAuthenticationUi != null)
- {
- var requestUri = new Uri(this.oAuthHelper.GetSignOutUrl(this.clientId, this.returnUrl));
-
- try
- {
- await this.webAuthenticationUi.AuthenticateAsync(requestUri, new Uri(this.returnUrl)).ConfigureAwait(false);
- }
- catch (ServiceException serviceException)
- {
- // Sometimes WebAuthenticationBroker can throw authentication cancelled on the sign out call. We don't care
- // about this so swallow the error.
- if (!serviceException.IsMatch(OAuthConstants.ErrorCodes.AuthenticationCancelled))
- {
- throw;
- }
- }
- }
- }
-
- protected void CacheAuthResult(AccountSession accountSession)
- {
- this.CurrentAccountSession = accountSession;
-
- if (this.CredentialCache != null)
- {
- this.CredentialCache.AddToCache(accountSession);
- }
- }
-
- protected void DeleteUserCredentialsFromCache(AccountSession accountSession)
- {
- if (this.CredentialCache != null)
- {
- this.CredentialCache.DeleteFromCache(accountSession);
- }
- }
-
- ///
- /// Retrieves the authentication token. Tries the to retrieve the most recently
- /// used credentials if available.
- ///
- /// The login name of the user, if known.
- /// The authentication token.
- public async Task RestoreMostRecentFromCacheOrAuthenticateUserAsync(string userName = null)
- {
- using (var httpProvider = new HttpProvider())
- {
- await this.RestoreMostRecentFromCacheOrAuthenticateUserAsync(httpProvider, userName).ConfigureAwait(false);
- }
- }
-
- ///
- /// Retrieves the authentication token. Tries the to retrieve the most recently
- /// used credentials if available.
- ///
- /// HttpProvider for any web requests needed for authentication
- /// The login name of the user, if known.
- /// The authentication token.
- public async Task RestoreMostRecentFromCacheOrAuthenticateUserAsync(IHttpProvider httpProvider, string userName = null)
- {
- var authResult = await this.GetMostRecentAuthenticationResultFromCacheAsync(httpProvider).ConfigureAwait(false);
-
- if (authResult == null)
- {
- await this.AuthenticateUserAsync(httpProvider, userName);
- }
- else
- {
- this.CacheAuthResult(authResult);
- }
- }
-
- ///
- /// Retrieves the authentication token. Retrieves the most recently
- /// used credentials if available, without showing the sign in UI if credentials are unavailable.
- ///
- /// The login name of the user, if known.
- /// The authentication token.
- public async Task RestoreMostRecentFromCacheAsync(string userName = null)
- {
- using (var httpProvider = new HttpProvider())
- {
- return await this.RestoreMostRecentFromCacheAsync(httpProvider, userName).ConfigureAwait(false);
- }
- }
-
- ///
- /// Retrieves the authentication token. Retrieves the most recently
- /// used credentials if available, without showing the sign in UI if credentials are unavailable.
- ///
- /// HttpProvider for any web requests needed for authentication
- /// The login name of the user, if known.
- /// The authentication token.
- public async Task RestoreMostRecentFromCacheAsync(IHttpProvider httpProvider, string userName = null)
- {
- var authResult = await this.GetMostRecentAuthenticationResultFromCacheAsync(httpProvider).ConfigureAwait(false);
- if (authResult != null)
- {
- this.CacheAuthResult(authResult);
- }
- return authResult != null;
- }
-
- ///
- /// Retrieves the authentication token.
- ///
- /// The login name of the user, if known.
- /// The authentication token.
- public async Task AuthenticateUserAsync(string userName = null)
- {
- using (var httpProvider = new HttpProvider())
- {
- await this.AuthenticateUserAsync(httpProvider, userName).ConfigureAwait(false);
- }
- }
-
- ///
- /// Retrieves the authentication token.
- ///
- /// HttpProvider for any web requests needed for authentication
- /// The login name of the user, if known.
- /// The authentication token.
- public virtual async Task AuthenticateUserAsync(IHttpProvider httpProvider, string userName = null)
- {
- var authResult = await this.GetAuthenticationResultFromCacheAsync(userName, httpProvider).ConfigureAwait(false);
-
- if (authResult == null)
- {
- // Log the user in if we haven't already pulled their credentials from the cache.
- var code = await this.oAuthHelper.GetAuthorizationCodeAsync(
- this.clientId,
- this.returnUrl,
- this.scopes,
- this.webAuthenticationUi,
- userName).ConfigureAwait(false);
-
- if (!string.IsNullOrEmpty(code))
- {
- authResult = await this.oAuthHelper.RedeemAuthorizationCodeAsync(
- code,
- this.clientId,
- this.clientSecret,
- this.returnUrl,
- this.scopes,
- httpProvider).ConfigureAwait(false);
- }
-
- if (authResult == null || string.IsNullOrEmpty(authResult.AccessToken))
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = "Failed to retrieve a valid authentication token for the user."
- });
- }
- }
-
- this.CacheAuthResult(authResult);
- }
-
- internal async Task GetAuthenticationResultFromCacheAsync(string userId, IHttpProvider httpProvider)
- {
- var accountSession = await this.ProcessCachedAccountSessionAsync(this.CurrentAccountSession, httpProvider).ConfigureAwait(false);
-
- if (accountSession != null)
- {
- return accountSession;
- }
-
- if (string.IsNullOrEmpty(userId) && this.CurrentAccountSession != null)
- {
- userId = this.CurrentAccountSession.UserId;
- }
-
- var cacheResult = this.CredentialCache.GetResultFromCache(
- this.clientId,
- userId);
-
- var processedResult = await this.ProcessCachedAccountSessionAsync(cacheResult, httpProvider).ConfigureAwait(false);
-
- if (processedResult == null && cacheResult != null)
- {
- this.CredentialCache.DeleteFromCache(cacheResult);
- this.CurrentAccountSession = null;
-
- return null;
- }
-
- return processedResult;
- }
-
- internal async Task GetMostRecentAuthenticationResultFromCacheAsync(IHttpProvider httpProvider)
- {
- var cacheResult = this.CredentialCache.GetMostRecentlyUsedResultFromCache();
-
- var processedResult = await this.ProcessCachedAccountSessionAsync(cacheResult, httpProvider).ConfigureAwait(false);
-
- if (processedResult == null && cacheResult != null)
- {
- this.CredentialCache.DeleteFromCache(cacheResult);
- this.CurrentAccountSession = null;
-
- return null;
- }
-
- return processedResult;
- }
-
- internal async Task ProcessCachedAccountSessionAsync(AccountSession accountSession)
- {
- using (var httpProvider = new HttpProvider())
- {
- var processedAccountSession = await this.ProcessCachedAccountSessionAsync(accountSession, httpProvider).ConfigureAwait(false);
- return processedAccountSession;
- }
- }
-
- internal virtual async Task ProcessCachedAccountSessionAsync(AccountSession accountSession, IHttpProvider httpProvider)
- {
- if (accountSession != null)
- {
- var shouldRefresh = accountSession.ShouldRefresh;
-
- // If we don't have an access token or it's expiring see if we can refresh the access token.
- if (shouldRefresh && accountSession.CanRefresh)
- {
- accountSession = await this.oAuthHelper.RedeemRefreshTokenAsync(
- accountSession.RefreshToken,
- this.clientId,
- this.clientSecret,
- this.returnUrl,
- this.scopes,
- httpProvider).ConfigureAwait(false);
-
- if (accountSession != null && !string.IsNullOrEmpty(accountSession.AccessToken))
- {
- return accountSession;
- }
- }
- else if (!shouldRefresh)
- {
- return accountSession;
- }
- }
-
- return null;
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/OAuthConstants.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/OAuthConstants.cs
deleted file mode 100644
index b2a7ec2..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/OAuthConstants.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- public static class OAuthConstants
- {
- public const string AccessTokenKeyName = "access_token";
-
- public const string AuthenticationCancelled = "authentication_cancelled";
-
- public const string AuthorizationCodeGrantType = "authorization_code";
-
- public const string AuthorizationServiceKey = "authorization_service";
-
- public const string ClientIdKeyName = "client_id";
-
- public const string ClientSecretKeyName = "client_secret";
-
- public const string CodeKeyName = "code";
-
- public const string DiscoveryResourceKey = "discovery_resource";
-
- public const string DiscoveryServiceKey = "discovery_service";
-
- public const string ErrorDescriptionKeyName = "error_description";
-
- public const string ErrorKeyName = "error";
-
- public const string ExpiresInKeyName = "expires_in";
-
- public const string GrantTypeKeyName = "grant_type";
-
- public const string RedirectUriKeyName = "redirect_uri";
-
- public const string RefreshTokenKeyName = "refresh_token";
-
- public const string ResponseTypeKeyName = "response_type";
-
- public const string ScopeKeyName = "scope";
-
- public const string TokenResponseTypeValueName = "token";
-
- public const string TokenServiceKey = "token_service";
-
- public const string TokenTypeKeyName = "token_type";
-
- public const string UserIdKeyName = "user_id";
-
- public const string ActiveDirectoryAuthenticationServiceUrl = "https://login.microsoftonline.com/common/oauth2/authorize";
-
- public const string ActiveDirectoryAuthenticationServiceUrlFormatString = "https://login.microsoftonline.com/{0}";
-
- public const string ActiveDirectoryDiscoveryResource = "https://api.office.com/discovery/";
-
- public const string ActiveDirectoryDiscoveryServiceUrl = "https://api.office.com/discovery/v2.0/me/services";
-
- public const string ActiveDirectorySignOutUrl = "https://login.microsoftonline.com/common/oauth2/logout";
-
- public const string MicrosoftAccountAuthenticationServiceUrl = "https://login.live.com/oauth20_authorize.srf";
-
- public const string MicrosoftAccountSignOutUrl = "https://login.live.com/oauth20_logout.srf";
-
- public const string MicrosoftAccountTokenServiceUrl = "https://login.live.com/oauth20_token.srf";
-
- public static class ErrorCodes
- {
- public const string AuthenticationCancelled = "authenticationCancelled";
-
- public const string AuthenticationFailure = "authenticationFailure";
-
- public const string AuthenticationNeverOccured = "authenticationNeverOccured";
- }
-
- public static class Headers
- {
- public const string Bearer = "bearer";
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/OAuthErrorHandler.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/OAuthErrorHandler.cs
deleted file mode 100644
index 9c2603d..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/OAuthErrorHandler.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System.Collections.Generic;
-
- using Microsoft.Graph;
-
- public static class OAuthErrorHandler
- {
- public static void ThrowIfError(IDictionary responseValues)
- {
- if (responseValues != null)
- {
- string error = null;
- string errorDescription = null;
-
- if (responseValues.TryGetValue(OAuthConstants.ErrorDescriptionKeyName, out errorDescription) ||
- responseValues.TryGetValue(OAuthConstants.ErrorKeyName, out error))
- {
- OAuthErrorHandler.ParseAuthenticationError(error, errorDescription);
- }
- }
- }
-
- private static void ParseAuthenticationError(string error, string errorDescription)
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure.ToString(),
- Message = errorDescription ?? error
- });
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/OAuthHelper.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/OAuthHelper.cs
deleted file mode 100644
index e7c502e..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/OAuthHelper.cs
+++ /dev/null
@@ -1,311 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using System.Collections.Generic;
- using System.Net;
- using System.Net.Http;
- using System.Net.Http.Headers;
- using System.Text;
- using System.Threading.Tasks;
-
- using Microsoft.Graph;
-
- public class OAuthHelper
- {
- public async Task GetAuthorizationCodeAsync(
- string clientId,
- string returnUrl,
- string[] scopes,
- IWebAuthenticationUi webAuthenticationUi,
- string userId = null)
- {
- if (webAuthenticationUi != null)
- {
- var requestUri = new Uri(
- this.GetAuthorizationCodeRequestUrl(
- clientId,
- returnUrl,
- scopes,
- userId));
-
- var authenticationResponseValues = await webAuthenticationUi.AuthenticateAsync(
- requestUri,
- new Uri(returnUrl)).ConfigureAwait(false);
-
- OAuthErrorHandler.ThrowIfError(authenticationResponseValues);
-
- string code;
- if (authenticationResponseValues != null && authenticationResponseValues.TryGetValue("code", out code))
- {
- return code;
- }
- }
-
- return null;
- }
-
- ///
- /// Gets the request URL for OAuth authentication using the code flow.
- ///
- /// The ID of the application.
- /// The return URL for the request. Defaults to the service info value.
- /// The OAuth request URL.
- public string GetAuthorizationCodeRequestUrl(string clientId, string returnUrl, string[] scopes, string userId = null)
- {
- var requestUriStringBuilder = new StringBuilder();
- requestUriStringBuilder.Append(OAuthConstants.MicrosoftAccountAuthenticationServiceUrl);
- requestUriStringBuilder.AppendFormat("?{0}={1}", OAuthConstants.RedirectUriKeyName, returnUrl);
- requestUriStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.ClientIdKeyName, clientId);
-
- if (scopes != null)
- {
- requestUriStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.ScopeKeyName, WebUtility.UrlEncode(string.Join(" ", scopes)));
- }
-
- if (!string.IsNullOrEmpty(userId))
- {
- requestUriStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.UserIdKeyName, userId);
- }
-
- requestUriStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.ResponseTypeKeyName, OAuthConstants.CodeKeyName);
-
- return requestUriStringBuilder.ToString();
- }
-
- ///
- /// Gets the request body for redeeming an authorization code for an access token.
- ///
- /// The authorization code to redeem.
- /// The ID of the application.
- /// The return URL for the request. Defaults to the service info value.
- /// The request body for the code redemption call.
- public string GetAuthorizationCodeRedemptionRequestBody(string code, string clientId, string returnUrl, string[] scopes, string clientSecret = null)
- {
- var requestBodyStringBuilder = new StringBuilder();
- requestBodyStringBuilder.AppendFormat("{0}={1}", OAuthConstants.RedirectUriKeyName, returnUrl);
- requestBodyStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.ClientIdKeyName, clientId);
-
- if (scopes != null)
- {
- requestBodyStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.ScopeKeyName, WebUtility.UrlEncode(string.Join(" ", scopes)));
- }
-
- requestBodyStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.CodeKeyName, code);
- requestBodyStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.GrantTypeKeyName, OAuthConstants.AuthorizationCodeGrantType);
-
- if (!string.IsNullOrEmpty(clientSecret))
- {
- requestBodyStringBuilder.AppendFormat("&client_secret={0}", clientSecret);
- }
-
- return requestBodyStringBuilder.ToString();
- }
-
- ///
- /// Gets the request body for redeeming a refresh token for an access token.
- ///
- /// The refresh token to redeem.
- /// The request body for the redemption call.
- public string GetRefreshTokenRequestBody(string refreshToken, string clientId, string returnUrl, string[] scopes, string clientSecret = null)
- {
- var requestBodyStringBuilder = new StringBuilder();
- requestBodyStringBuilder.AppendFormat("{0}={1}", OAuthConstants.RedirectUriKeyName, returnUrl);
- requestBodyStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.ClientIdKeyName, clientId);
-
- if (scopes != null)
- {
- requestBodyStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.ScopeKeyName, WebUtility.UrlEncode(string.Join(" ", scopes)));
- }
-
- requestBodyStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.RefreshTokenKeyName, refreshToken);
- requestBodyStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.GrantTypeKeyName, OAuthConstants.RefreshTokenKeyName);
-
- if (!string.IsNullOrEmpty(clientSecret))
- {
- requestBodyStringBuilder.AppendFormat("&{0}={1}", OAuthConstants.ClientSecretKeyName, clientSecret);
- }
-
- return requestBodyStringBuilder.ToString();
- }
-
- public string GetSignOutUrl(string clientId, string returnUrl)
- {
- return string.Format(
- "{0}?client_id={1}&redirect_uri={2}",
- OAuthConstants.MicrosoftAccountSignOutUrl,
- clientId,
- returnUrl);
- }
-
- public async Task RedeemAuthorizationCodeAsync(
- string authorizationCode,
- string clientId,
- string clientSecret,
- string returnUrl,
- string[] scopes)
- {
- using (var httpProvider = new HttpProvider())
- {
- return await this.RedeemAuthorizationCodeAsync(
- authorizationCode,
- clientId,
- clientSecret,
- returnUrl,
- scopes,
- httpProvider).ConfigureAwait(false);
- }
- }
-
- public async Task RedeemAuthorizationCodeAsync(
- string authorizationCode,
- string clientId,
- string clientSecret,
- string returnUrl,
- string[] scopes,
- IHttpProvider httpProvider)
- {
- if (string.IsNullOrEmpty(authorizationCode))
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = "Authorization code is required to redeem."
- });
- }
-
- return await this.SendTokenRequestAsync(
- this.GetAuthorizationCodeRedemptionRequestBody(
- authorizationCode,
- clientId,
- returnUrl,
- scopes,
- clientSecret),
- httpProvider).ConfigureAwait(false);
- }
-
- public async Task RedeemRefreshTokenAsync(
- string refreshToken,
- string clientId,
- string returnUrl,
- string[] scopes)
- {
- return await this.RedeemRefreshTokenAsync(
- refreshToken,
- clientId,
- /* clientSecret */ null,
- returnUrl,
- scopes,
- /* httpProvider */ null).ConfigureAwait(false);
- }
-
- public async Task RedeemRefreshTokenAsync(
- string refreshToken,
- string clientId,
- string returnUrl,
- string[] scopes,
- IHttpProvider httpProvider)
- {
- return await this.RedeemRefreshTokenAsync(
- refreshToken,
- clientId,
- /* clientSecret */ null,
- returnUrl,
- scopes,
- httpProvider).ConfigureAwait(false);
- }
-
- public async Task RedeemRefreshTokenAsync(
- string refreshToken,
- string clientId,
- string clientSecret,
- string returnUrl,
- string[] scopes)
- {
- return await this.RedeemRefreshTokenAsync(
- refreshToken,
- clientId,
- clientSecret,
- returnUrl,
- scopes,
- /* httpProvider */ null).ConfigureAwait(false);
- }
-
- public async Task RedeemRefreshTokenAsync(
- string refreshToken,
- string clientId,
- string clientSecret,
- string returnUrl,
- string[] scopes,
- IHttpProvider httpProvider)
- {
- if (string.IsNullOrEmpty(refreshToken))
- {
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = "Refresh token is required to redeem."
- });
- }
-
- var tokenRequestBody = this.GetRefreshTokenRequestBody(
- refreshToken,
- clientId,
- returnUrl,
- scopes,
- clientSecret);
-
- if (httpProvider == null)
- {
- return await this.SendTokenRequestAsync(tokenRequestBody);
- }
-
- return await this.SendTokenRequestAsync(tokenRequestBody, httpProvider).ConfigureAwait(false);
- }
-
- public async Task SendTokenRequestAsync(string requestBodyString)
- {
- using (var httpProvider = new HttpProvider())
- {
- return await this.SendTokenRequestAsync(requestBodyString, httpProvider).ConfigureAwait(false);
- }
- }
-
- public async Task SendTokenRequestAsync(string requestBodyString, IHttpProvider httpProvider)
- {
- var httpRequestMessage = new HttpRequestMessage
- (
- HttpMethod.Post,
- OAuthConstants.MicrosoftAccountTokenServiceUrl
- );
-
- httpRequestMessage.Content = new StringContent(requestBodyString, Encoding.UTF8, "application/x-www-form-urlencoded");
-
- using (var authResponse = await httpProvider.SendAsync(httpRequestMessage).ConfigureAwait(false))
- using (var responseStream = await authResponse.Content.ReadAsStreamAsync().ConfigureAwait(false))
- {
- var responseValues =
- httpProvider.Serializer.DeserializeObject>(
- responseStream);
-
- if (responseValues != null)
- {
- OAuthErrorHandler.ThrowIfError(responseValues);
- return new AccountSession(responseValues);
- }
-
- throw new ServiceException(
- new Error
- {
- Code = OAuthConstants.ErrorCodes.AuthenticationFailure,
- Message = "Authentication failed. No response values returned from authentication flow."
- });
- }
- }
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/OAuthRequestStringBuilder.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/OAuthRequestStringBuilder.cs
deleted file mode 100644
index 67ba86a..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/OAuthRequestStringBuilder.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System.Net;
- using System.Text;
-
- public class OAuthRequestStringBuilder : IOAuthRequestStringBuilder
- {
-
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Web/IWebAuthenticationUi.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Common/Web/IWebAuthenticationUi.cs
deleted file mode 100644
index 70a66be..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Common/Web/IWebAuthenticationUi.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
-
- public interface IWebAuthenticationUi
- {
- ///
- /// Displays authentication UI to the user for the specified request URI, returning
- /// the key value pairs from the query string upon reaching the callback URL.
- ///
- /// The request URI.
- /// The callback URI.
- /// The of key value pairs from the callback URI query string.
- Task> AuthenticateAsync(Uri requestUri, Uri callbackUri);
- }
-}
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Activity/AndroidAuthenticationState.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Activity/AndroidAuthenticationState.cs
deleted file mode 100644
index 1358eb2..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Activity/AndroidAuthenticationState.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using System.Collections.Generic;
-
- internal class AndroidAuthenticationState
- {
- private static AndroidAuthenticationState instance = new AndroidAuthenticationState();
- private Dictionary dictionary;
-
- protected AndroidAuthenticationState()
- {
- this.dictionary = new Dictionary();
- }
-
- public static AndroidAuthenticationState Default
- {
- get { return instance; }
- }
-
- public string Add(T state) where T : class
- {
- string key = Guid.NewGuid().ToString();
- this.dictionary.Add(key, state);
- return key;
- }
-
- public T Remove(string key) where T : class
- {
- if (this.dictionary.ContainsKey(key))
- {
- T state = this.dictionary[key] as T;
- this.dictionary.Remove(key);
- return state;
- }
-
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Activity/AndroidWebAuthenticationActivity.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Activity/AndroidWebAuthenticationActivity.cs
deleted file mode 100644
index d5b2c7a..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Activity/AndroidWebAuthenticationActivity.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using Android.App;
- using Android.Content;
- using Android.OS;
- using Android.Content.PM;
- using Android.Webkit;
- using Graph;
- using Android.Views;
-
- [Activity(Label = "OneDrive", Theme = "@android:style/Theme.NoTitleBar", ScreenOrientation = ScreenOrientation.Portrait)]
- public class AndroidWebAuthenticationActivity : Activity
- {
- private WebView webView;
-
- protected override void OnCreate(Bundle savedInstanceState)
- {
- base.OnCreate(savedInstanceState);
- base.SetContentView(Resource.Layout.webform);
- this.webView = base.FindViewById(Resource.Id.webView);
- this.WebAuthenticationUi = this.GetWebAuthenticationUi();
- this.RequestUri = this.GetRequestUri();
- this.CallbackUri = this.GetCallbackUri();
- this.BeginLoadAuthorizationUrl();
- }
-
- public AndroidWebAuthenticationUi WebAuthenticationUi { get; private set; }
-
- private AndroidWebAuthenticationUi GetWebAuthenticationUi()
- {
- if (!base.Intent.HasExtra(AndroidConstants.AuthenticationStateKey))
- {
- return null;
- }
-
- string stateKey = base.Intent.GetStringExtra(AndroidConstants.AuthenticationStateKey);
- return AndroidAuthenticationState.Default.Remove(stateKey);
- }
-
- public Uri RequestUri { get; private set; }
-
- private Uri GetRequestUri()
- {
- if (!base.Intent.HasExtra(AndroidConstants.RequestUriKey))
- {
- return null;
- }
-
- return new Uri(base.Intent.GetStringExtra(AndroidConstants.RequestUriKey));
- }
-
- public Uri CallbackUri { get; private set; }
-
- private Uri GetCallbackUri()
- {
- if (!base.Intent.HasExtra(AndroidConstants.CallbackUriKey))
- {
- return null;
- }
-
- return new Uri(base.Intent.GetStringExtra(AndroidConstants.CallbackUriKey));
- }
-
- private void BeginLoadAuthorizationUrl()
- {
- Client client = new Client(this);
- this.webView.Settings.JavaScriptEnabled = true;
- this.webView.SetWebViewClient(client);
- this.webView.LoadUrl(this.RequestUri.ToString());
- }
-
- private void OnPageFinished(WebView view, string url)
- {
- Uri source = new Uri(url);
- if (source.AbsoluteUri.StartsWith(this.CallbackUri.ToString()))
- {
- var parameters = UrlHelper.GetQueryOptions(source);
- this.WebAuthenticationUi.OnCompleted(new AuthCompletedEventArgs(parameters));
- base.Finish();
- }
- }
-
- public override void OnBackPressed()
- {
- this.WebAuthenticationUi.OnFailed(
- new AuthFailedEventArgs(
- new ServiceException(
- new Error
- {
- Code = "authenticationCanceled",
- Message = "User canceled authentication."
- })));
-
- base.OnBackPressed();
- }
-
- private class Client : WebViewClient
- {
- private AndroidWebAuthenticationActivity activity;
-
- public Client(AndroidWebAuthenticationActivity activity)
- {
- this.activity = activity;
- }
-
- public override bool ShouldOverrideUrlLoading(WebView view, IWebResourceRequest request)
- {
- return false;
- }
-
- public override void OnPageFinished(WebView view, string url)
- {
- this.activity.OnPageFinished(view, url);
- base.OnPageFinished(view, url);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Activity/AuthCompletedEventArgs.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Activity/AuthCompletedEventArgs.cs
deleted file mode 100644
index b3f8826..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Activity/AuthCompletedEventArgs.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using System.Collections.Generic;
-
- public class AuthCompletedEventArgs : EventArgs
- {
- public AuthCompletedEventArgs(IDictionary authorizationParameters)
- {
- this.AuthorizationParameters = authorizationParameters;
- }
-
- public IDictionary AuthorizationParameters { get; private set; }
- }
-}
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Activity/AuthFailedEventArgs.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Activity/AuthFailedEventArgs.cs
deleted file mode 100644
index c851a36..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Activity/AuthFailedEventArgs.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
-
- public class AuthFailedEventArgs : EventArgs
- {
- public AuthFailedEventArgs(Exception error)
- {
- this.Error = error;
- }
-
- public Exception Error { get; private set; }
- }
-}
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/AndroidConstants.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/AndroidConstants.cs
deleted file mode 100644
index df91df7..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/AndroidConstants.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk
-{
- internal static class AndroidConstants
- {
- public const string AuthenticationStateKey = "state";
- public const string RequestUriKey = "requesturi";
- public const string CallbackUriKey = "callbackuri";
- }
-}
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/CredentialVault.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/CredentialVault.cs
deleted file mode 100644
index ba50a91..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/CredentialVault.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using Mono.Security.Cryptography;
- using System;
- using System.IO;
- using System.Security.Cryptography;
-
- public class CredentialVault : ICredentialVault
- {
- private const string VaultNamePrefix = "OneDriveSDK_AuthAdapter";
-
- private string ClientId { get; set; }
-
- private string VaultFileName => $"{VaultNamePrefix}_{this.ClientId}.dat";
-
- private readonly byte[] _additionalEntropy;
-
- public CredentialVault(string clientId)
- {
- if (string.IsNullOrEmpty(clientId))
- {
- throw new ArgumentException("You must provide a clientId");
- }
-
- this.ClientId = clientId;
- this._additionalEntropy = null;
- }
-
- public CredentialVault(string clientId, byte[] secondaryKeyBytes) : this(clientId)
- {
- this._additionalEntropy = secondaryKeyBytes;
- }
-
- public void AddCredentialCacheToVault(CredentialCache credentialCache)
- {
- this.DeleteStoredCredentialCache();
-
- var cacheBlob = this.Protect(credentialCache.GetCacheBlob());
- using (var outStream = File.OpenWrite(GetVaultFilePath()))
- {
- outStream.Write(cacheBlob, 0, cacheBlob.Length);
- }
- }
-
- public bool RetrieveCredentialCache(CredentialCache credentialCache)
- {
- var filePath = this.GetVaultFilePath();
-
- if (File.Exists(filePath))
- {
- credentialCache.InitializeCacheFromBlob(this.Unprotect(File.ReadAllBytes(filePath)));
- return true;
- }
-
- return false;
- }
-
- public bool DeleteStoredCredentialCache()
- {
- var filePath = this.GetVaultFilePath();
-
- if (File.Exists(filePath))
- {
- File.Delete(filePath);
- return true;
- }
-
- return false;
- }
-
- private string GetVaultFilePath()
- {
- return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), this.VaultFileName);
- }
-
- private byte[] Protect(byte[] data)
- {
- // ProtectedData throws UnsupportedPlatform exception, utilizing ManagedProtection directly from Mono
- return ManagedProtection.Protect(data, this._additionalEntropy, DataProtectionScope.CurrentUser);
- }
-
- private byte[] Unprotect(byte[] protectedData)
- {
- // ProtectedData throws UnsupportedPlatform exception, utilizing ManagedProtection directly from Mono
- return ManagedProtection.Unprotect(protectedData, this._additionalEntropy, DataProtectionScope.CurrentUser);
- }
- }
-}
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/ManagedProtection.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/ManagedProtection.cs
deleted file mode 100644
index ac23056..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/ManagedProtection.cs
+++ /dev/null
@@ -1,310 +0,0 @@
-//
-// ManagedProtection.cs -
-// Protect (encrypt) data without (user involved) key management
-//
-// Author:
-// Sebastien Pouliot
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Security.Cryptography;
-using System.Security.Permissions;
-
-namespace Mono.Security.Cryptography
-{
- // Managed Protection Implementation
- //
- // Features
- // * Separate RSA 1536 bits keypairs for each user and the computer
- // * AES 128 bits encryption (separate key for each data protected)
- // * SHA256 digest to ensure integrity
-
- internal static class ManagedProtection
- {
- // FIXME [KeyContainerPermission (SecurityAction.Assert, KeyContainerName = "DAPI",
- // Flags = KeyContainerPermissionFlags.Open | KeyContainerPermissionFlags.Create)]
- public static byte[] Protect(byte[] userData, byte[] optionalEntropy, DataProtectionScope scope)
- {
- if (userData == null)
- throw new ArgumentNullException("userData");
-
- Rijndael aes = Rijndael.Create();
- aes.KeySize = 128;
-
- byte[] encdata = null;
- using (MemoryStream ms = new MemoryStream())
- {
- ICryptoTransform t = aes.CreateEncryptor();
- using (CryptoStream cs = new CryptoStream(ms, t, CryptoStreamMode.Write))
- {
- cs.Write(userData, 0, userData.Length);
- cs.Close();
- encdata = ms.ToArray();
- }
- }
-
- byte[] key = null;
- byte[] iv = null;
- byte[] secret = null;
- byte[] header = null;
- SHA256 hash = SHA256.Create();
-
- try
- {
- key = aes.Key;
- iv = aes.IV;
- secret = new byte[1 + 1 + 16 + 1 + 16 + 1 + 32];
-
- byte[] digest = hash.ComputeHash(userData);
- if ((optionalEntropy != null) && (optionalEntropy.Length > 0))
- {
- // the same optionalEntropy will be required to get the data back
- byte[] mask = hash.ComputeHash(optionalEntropy);
- for (int i = 0; i < 16; i++)
- {
- key[i] ^= mask[i];
- iv[i] ^= mask[i + 16];
- }
- secret[0] = 2; // entropy
- }
- else
- {
- secret[0] = 1; // without entropy
- }
-
- secret[1] = 16; // key size
- Buffer.BlockCopy(key, 0, secret, 2, 16);
- secret[18] = 16; // iv size
- Buffer.BlockCopy(iv, 0, secret, 19, 16);
- secret[35] = 32; // digest size
- Buffer.BlockCopy(digest, 0, secret, 36, 32);
-
- RSAOAEPKeyExchangeFormatter formatter = new RSAOAEPKeyExchangeFormatter(GetKey(scope));
- header = formatter.CreateKeyExchange(secret);
- }
- finally
- {
- if (key != null)
- {
- Array.Clear(key, 0, key.Length);
- key = null;
- }
- if (secret != null)
- {
- Array.Clear(secret, 0, secret.Length);
- secret = null;
- }
-
- if (iv != null)
- {
- Array.Clear(iv, 0, iv.Length);
- iv = null;
- }
-
- aes.Clear();
- hash.Clear();
- }
-
- byte[] result = new byte[header.Length + encdata.Length];
- Buffer.BlockCopy(header, 0, result, 0, header.Length);
- Buffer.BlockCopy(encdata, 0, result, header.Length, encdata.Length);
- return result;
- }
-
- // FIXME [KeyContainerPermission (SecurityAction.Assert, KeyContainerName = "DAPI",
- // Flags = KeyContainerPermissionFlags.Open | KeyContainerPermissionFlags.Decrypt)]
- public static byte[] Unprotect(byte[] encryptedData, byte[] optionalEntropy, DataProtectionScope scope)
- {
- if (encryptedData == null)
- throw new ArgumentNullException("encryptedData");
-
- byte[] decdata = null;
- Rijndael aes = Rijndael.Create();
- RSA rsa = GetKey(scope);
- int headerSize = (rsa.KeySize >> 3);
- bool valid1 = (encryptedData.Length >= headerSize);
-
- if (!valid1)
- headerSize = encryptedData.Length;
-
- byte[] header = new byte[headerSize];
- Buffer.BlockCopy(encryptedData, 0, header, 0, headerSize);
-
- byte[] secret = null;
- byte[] key = null;
- byte[] iv = null;
- bool valid2 = false;
- bool valid3 = false;
- bool valid4 = false;
-
- SHA256 hash = SHA256.Create();
-
- try
- {
- try
- {
- RSAOAEPKeyExchangeDeformatter deformatter = new RSAOAEPKeyExchangeDeformatter(rsa);
- secret = deformatter.DecryptKeyExchange(header);
- valid2 = (secret.Length == 68);
- }
- catch
- {
- valid2 = false;
- }
-
- if (!valid2)
- secret = new byte[68];
-
- // known values for structure (version 1 or 2)
- valid3 = ((secret[1] == 16) && (secret[18] == 16) && (secret[35] == 32));
- key = new byte[16];
- Buffer.BlockCopy(secret, 2, key, 0, 16);
- iv = new byte[16];
- Buffer.BlockCopy(secret, 19, iv, 0, 16);
-
- if ((optionalEntropy != null) && (optionalEntropy.Length > 0))
- {
- // the decrypted data won't be valid if the entropy isn't
- // the same as the one used to protect (encrypt) it
- byte[] mask = hash.ComputeHash(optionalEntropy);
-
- for (int i = 0; i < 16; i++)
- {
- key[i] ^= mask[i];
- iv[i] ^= mask[i + 16];
- }
- valid3 &= (secret[0] == 2); // with entropy
- }
- else
- {
- valid3 &= (secret[0] == 1); // without entropy
- }
-
- using (MemoryStream ms = new MemoryStream())
- {
- ICryptoTransform t = aes.CreateDecryptor(key, iv);
- using (CryptoStream cs = new CryptoStream(ms, t, CryptoStreamMode.Write))
- {
- try
- {
- cs.Write(encryptedData, headerSize, encryptedData.Length - headerSize);
- cs.Close();
- }
- catch
- {
- // whatever, we keep going
- }
- }
- decdata = ms.ToArray();
- }
-
- byte[] digest = hash.ComputeHash(decdata);
- valid4 = true;
-
- for (int i = 0; i < 32; i++)
- {
- if (digest[i] != secret[36 + i])
- valid4 = false;
- }
- }
- finally
- {
- if (key != null)
- {
- Array.Clear(key, 0, key.Length);
- key = null;
- }
-
- if (secret != null)
- {
- Array.Clear(secret, 0, secret.Length);
- secret = null;
- }
-
- if (iv != null)
- {
- Array.Clear(iv, 0, iv.Length);
- iv = null;
- }
-
- aes.Clear();
- hash.Clear();
- }
-
- // single point of error (also limits timing informations)
- if (!valid1 || !valid2 || !valid3 || !valid4)
- {
- if (decdata != null)
- {
- Array.Clear(decdata, 0, decdata.Length);
- decdata = null;
- }
- throw new CryptographicException("Invalid data.");
- }
-
- return decdata;
- }
-
- // private stuff
- private static RSA user;
- private static RSA machine;
- private readonly static object user_lock = new object();
- private readonly static object machine_lock = new object();
-
- private static RSA GetKey(DataProtectionScope scope)
- {
- switch (scope)
- {
- case DataProtectionScope.CurrentUser:
- if (user == null)
- {
- lock (user_lock)
- {
- CspParameters csp = new CspParameters();
- csp.KeyContainerName = "DAPI";
- user = new RSACryptoServiceProvider(1536, csp);
- }
- }
- return user;
- case DataProtectionScope.LocalMachine:
- if (machine == null)
- {
- lock (machine_lock)
- {
- CspParameters csp = new CspParameters();
- csp.KeyContainerName = "DAPI";
- csp.Flags = CspProviderFlags.UseMachineKeyStore;
- machine = new RSACryptoServiceProvider(1536, csp);
- }
- }
- return machine;
- default:
- throw new CryptographicException("Invalid scope.");
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/OneDrive.Sdk.Authentication.Xamarin.Android.csproj b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/OneDrive.Sdk.Authentication.Xamarin.Android.csproj
deleted file mode 100644
index 05e6a3e..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/OneDrive.Sdk.Authentication.Xamarin.Android.csproj
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
- Debug
- AnyCPU
- 8.0.30703
- 2.0
- {B68F871E-A9E1-40CB-92A7-0F602504895B}
- {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- Library
- Properties
- Microsoft.OneDrive.Sdk.Authentication
- Microsoft.OneDrive.Sdk.Authentication.Xamarin.Android
- 512
- Resources\Resource.Designer.cs
- Off
- v12.0
-
-
- true
- full
- false
- bin\Debug\
- TRACE;DEBUG;XamarinAndroid
- prompt
- 4
- false
- true
-
-
- pdbonly
- true
- bin\Release\
- TRACE;XamarinAndroid
- prompt
- 4
- false
- true
-
-
- true
- true
- ..\..\build\35MSSharedLib1024.snk
-
-
-
- ..\..\packages\Microsoft.Graph.Core.1.3.1\lib\MonoAndroid10\Microsoft.Graph.Core.dll
- True
-
-
-
-
- ..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll
- True
-
-
-
-
-
-
-
-
-
-
- AccountSession.cs
-
-
- Caching\CredentialCache.cs
-
-
- Caching\CredentialCacheKey.cs
-
-
- Caching\CredentialCacheNotificationArgs.cs
-
-
- ICredentialVault.cs
-
-
- MsaAuthenticationProvider.cs
-
-
- OAuthConstants.cs
-
-
- OAuthErrorHandler.cs
-
-
- OAuthHelper.cs
-
-
- Web\IWebAuthenticationUi.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Properties/AssemblyInfo.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Properties/AssemblyInfo.cs
deleted file mode 100644
index 8ecb038..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using Android.App;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("OneDrive.Sdk.Authentication.Xamarin.Android")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("OneDrive.Sdk.Authentication.Xamarin.Android")]
-[assembly: AssemblyCopyright("Copyright © 2016")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-[assembly: ComVisible(false)]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0")]
-[assembly: AssemblyFileVersion("1.0.0")]
-
-#if DEBUG
-[assembly: InternalsVisibleTo("Test.OneDrive.Sdk.Authentication.Xamarin.Android")]
-#else
-[assembly: InternalsVisibleTo("Test.OneDrive.Sdk.Authentication.Xamarin.Android, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
-#endif
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Resources/AboutResources.txt b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Resources/AboutResources.txt
deleted file mode 100644
index c2bca97..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Resources/AboutResources.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-Images, layout descriptions, binary blobs and string dictionaries can be included
-in your application as resource files. Various Android APIs are designed to
-operate on the resource IDs instead of dealing with images, strings or binary blobs
-directly.
-
-For example, a sample Android app that contains a user interface layout (main.axml),
-an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
-would keep its resources in the "Resources" directory of the application:
-
-Resources/
- drawable/
- icon.png
-
- layout/
- main.axml
-
- values/
- strings.xml
-
-In order to get the build system to recognize Android resources, set the build action to
-"AndroidResource". The native Android APIs do not operate directly with filenames, but
-instead operate on resource IDs. When you compile an Android application that uses resources,
-the build system will package the resources for distribution and generate a class called "R"
-(this is an Android convention) that contains the tokens for each one of the resources
-included. For example, for the above Resources layout, this is what the R class would expose:
-
-public class R {
- public class drawable {
- public const int icon = 0x123;
- }
-
- public class layout {
- public const int main = 0x456;
- }
-
- public class strings {
- public const int first_string = 0xabc;
- public const int second_string = 0xbcd;
- }
-}
-
-You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
-to reference the layout/main.axml file, or R.strings.first_string to reference the first
-string in the dictionary file values/strings.xml.
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Resources/Resource.Designer.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Resources/Resource.Designer.cs
deleted file mode 100644
index d6fc3ed..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Resources/Resource.Designer.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-#pragma warning disable 1591
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-[assembly: global::Android.Runtime.ResourceDesignerAttribute("Microsoft.OneDrive.Sdk.Authentication.Resource", IsApplication=false)]
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
-
-
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.2.0.155")]
- public partial class Resource
- {
-
- static Resource()
- {
- global::Android.Runtime.ResourceIdManager.UpdateIdValues();
- }
-
- public partial class Attribute
- {
-
- static Attribute()
- {
- global::Android.Runtime.ResourceIdManager.UpdateIdValues();
- }
-
- private Attribute()
- {
- }
- }
-
- public partial class Id
- {
-
- // aapt resource value: 0x7F010000
- public static int webView = 2130771968;
-
- static Id()
- {
- global::Android.Runtime.ResourceIdManager.UpdateIdValues();
- }
-
- private Id()
- {
- }
- }
-
- public partial class Layout
- {
-
- // aapt resource value: 0x7F020000
- public static int webform = 2130837504;
-
- static Layout()
- {
- global::Android.Runtime.ResourceIdManager.UpdateIdValues();
- }
-
- private Layout()
- {
- }
- }
-
- public partial class String
- {
-
- // aapt resource value: 0x7F030000
- public static int ApplicationName = 2130903040;
-
- static String()
- {
- global::Android.Runtime.ResourceIdManager.UpdateIdValues();
- }
-
- private String()
- {
- }
- }
- }
-}
-#pragma warning restore 1591
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Resources/Values/Strings.xml b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Resources/Values/Strings.xml
deleted file mode 100644
index b0217a5..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Resources/Values/Strings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- $projectname$
-
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Resources/layout/webform.axml b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Resources/layout/webform.axml
deleted file mode 100644
index 1d505fb..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Resources/layout/webform.axml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Web/AndroidWebAuthenticationUi.cs b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Web/AndroidWebAuthenticationUi.cs
deleted file mode 100644
index 6a72036..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/Web/AndroidWebAuthenticationUi.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-// ------------------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.OneDrive.Sdk.Authentication
-{
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using Android.Content;
-
- public class AndroidWebAuthenticationUi : IWebAuthenticationUi
- {
- public event EventHandler Completed;
- public event EventHandler Failed;
-
- public AndroidWebAuthenticationUi(Context context)
- {
- this.Context = context;
- }
-
- public Context Context { get; private set; }
-
- public Task> AuthenticateAsync(Uri requestUri, Uri callbackUri)
- {
- TaskCompletionSource> tcs = new TaskCompletionSource>();
-
- this.Completed += (s, e) =>
- {
- tcs.SetResult(e.AuthorizationParameters);
- };
-
- this.Failed += (s, e) =>
- {
- tcs.SetException(e.Error);
- };
-
- string stateKey = AndroidAuthenticationState.Default.Add(this);
- Intent intent = new Intent(this.Context, typeof(AndroidWebAuthenticationActivity));
- intent.PutExtra(AndroidConstants.AuthenticationStateKey, stateKey);
- intent.PutExtra(AndroidConstants.RequestUriKey, requestUri.ToString());
- intent.PutExtra(AndroidConstants.CallbackUriKey, callbackUri.ToString());
- this.Context.StartActivity(intent);
- return tcs.Task;
- }
-
- internal void OnCompleted(AuthCompletedEventArgs e)
- {
- if (Completed != null)
- {
- Completed(this, e);
- }
- }
-
- internal void OnFailed(AuthFailedEventArgs e)
- {
- if (Failed != null)
- {
- Failed(this, e);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/app.config b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/app.config
deleted file mode 100644
index 4429813..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/app.config
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/packages.config b/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/packages.config
deleted file mode 100644
index 8ac8a65..0000000
--- a/Andro2UWP/OneDrive.Sdk.Authentication.Xamarin.Android/packages.config
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/Docs/History-en.txt b/Docs/History-en.txt
new file mode 100644
index 0000000..588fe3b
--- /dev/null
+++ b/Docs/History-en.txt
@@ -0,0 +1,96 @@
+History (Change logs)
+================
+
+MainPage changes
+-----------------
+
+2021.07.22
+* MainPage: List:Context: Copy( do Clip), Delete this and older
+* UWP: delete the clearlist button also with Deletethis
+
+2021.07.18
+* UWP.MainPage: clearlist button, was in XAML but was not supported (and was disabled), in Android it is in the Menu -
+ this is an important button when we receive on two UWP (e.g. on the phone and on the computer I check)
+* but also
+* UWP.OneDrive delete file list: when the file is not present, the function returns an error (not an Exception :) )
+* Andro: additionally adds event.Text ("floor" higher than event.Extras.*)
+
+2020.11.08
+* upgrade to Uno based on 3.1.6-will no longer correctly (unless) TextBlock on Android.10
+* transition to pkarmodule shared (including: ProgRing, ProgBar, WriteTextAsync)
+* adding two libraries because error
+ C:\Users\pkar\.NuGet\packages\ Xamarin.androidx.migration\1.0.0\buildTransitive
+\monoandroid90\Xamarin.Androidx.Migration.targets(131.9): error :
+Could not find 2 Android X assemblies, make sure to install the following NuGet packages:
+...
+ C:\Users\pkar\.nuget\packages\xamarin.androidx.migration\1.0.0\buildTransitive\monoandroid90\Xamarin.AndroidX.Migration.targets(131,9): error : Could not find 2 Android X assemblies, make sure to install the following NuGet packages:
+ C:\Users\pkar\.nuget\packages\xamarin.androidx.migration\1.0.0\buildTransitive\monoandroid90\Xamarin.AndroidX.Migration.targets(131,9): error : - Xamarin.AndroidX.Lifecycle.LiveData
+ C:\Users\pkar\.nuget\packages\xamarin.androidx.migration\1.0.0\buildTransitive\monoandroid90\Xamarin.AndroidX.Migration.targets(131,9): error : - Xamarin.AndroidX.Browser
+ C:\Users\pkar\.nuget\packages\xamarin.androidx.migration\1.0.0\buildTransitive\monoandroid90\Xamarin.AndroidX.Migration.targets(131,9): error : You can also copy-and-paste the following snippet into your .csproj file:
+ C:\Users\pkar\.nuget\packages\xamarin.androidx.migration\1.0.0\buildTransitive\monoandroid90\Xamarin.AndroidX.Migration.targets(131,9): error :
+ C:\Users\pkar\.nuget\packages\xamarin.androidx.migration\1.0.0\buildTransitive\monoandroid90\Xamarin.AndroidX.Migration.targets(131,9): error :
+ pozniej jeszcze:
+ C:\Users\pkar\.nuget\packages\xamarin.androidx.migration\1.0.7.1\buildTransitive\monoandroid90\Xamarin.AndroidX.Migration.targets(131,9): error :
+* komentuję pozostałości po Timerze (Uno001)
+* AddLog z try/catch, bo może na nim wylatywało z błędem?
+
+
+* I don't know why it shows "no date" when opening, without the refresh button-but trying to protect against this message not with the button
+* to the new logo info along with "!App.GB "catch" only when fulldebug (and normally non-log does not swell when disabled)
+
+
+2020.03.06: (win) after deleting older, does a refresh taking into account the sequence (asc/desc)
+
+ STORE v2002. 2002.03.02, Andro/Win
+
+
+// pkModuleShared
+// Both for UWP and Android
+// 2022
+
+
+ pkarModuleShared changes
+----------------------------
+//../../../_mojeSuby/pkarModule-Uno3-1-6.cs
+
+// (...)
+// AddHandler rootFrame.NavigationFailed, AddressOf OnNavigationFailed
+//
+// ' PKAR added wedle https://stackoverflow.com/questions/39262926/uwp-hardware-back-press-work-correctly-in-mobile-but-error-with-pc
+// AddHandler rootFrame.Navigated, AddressOf OnNavigatedAddBackButton
+// AddHandler Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested, AddressOf OnBackButtonPressed
+// (...)
+
+### I already assume the correct Uno my own, without a functional reset
+
+2019.10.25
+* Clipboard for UWP goes as before, for UWP - no NuGet(so you don't have to add Reference as app is UWP only)
+* new feature: DialogBoxInput(uncommented)
+* new function: SetSettingsInt(double) - with conversion(because C # does not convert itself)
+
+2019.09.10
+ * new function: GetPlatform(android, uwp, ios, wasm, other) - also as bool, int, string
+
+
+2019.09.03
+ * added MakeToast(thanks to Nuget)
+ * ..thanks to which I added CrashMessageAdd
+ * I added CrashMessageExit
+
+
+2019.08.31
+ * turned on full code analysis, and added:
+ * .ConfigureAwait(true)[ie default, you could disable this warning]
+ * ToString and int.Parse(and similar): cultureinvariant, or currentculture
+ * some null tests
+
+ 2019.08.27
+* new function: string GetAppVers() - works theoretically for UWP, Android and iOS
+* remake ClipBoard to universal version(requires Nuget)
+* IsMobile: UWP so far, macOS always NO, rest(Android, iOS, WASM) always YES
+* changing the method of obtaining a computer name(maybe universal)
+
+2019.08.26
+* migration to VC
+* comment on what is not crossplatform(upload it to pkarmodule.cs in UWP)
+
diff --git a/Docs/TechDoc01.txt b/Docs/TechDoc01.txt
index d6bef61..c804e72 100644
--- a/Docs/TechDoc01.txt
+++ b/Docs/TechDoc01.txt
@@ -1,16 +1,26 @@
Andro2UWP - Common info
=========
+Privacy policy for 'Andro2UWP' app
Android app
This app takes your Android notifications, and some of them (filtered using rules you set)
send to your OneDrive (folder: Apps/Andro2UWP). You can view it either as simple text files
(from any browser, from any device) or using UWP companion app.
It doesn't use any other data, and it doesn't send anything else anywhere else.
-
+Polityka prywatności aplikacji 'Andro2UWP'
+Aplikacja odczytuje powiadomienia Android, i niektóre z nich (odfiltrowane według utworzonych przez Ciebie reguł)
+wysyła na Twój OneDrive (do katalogu Apps/Andro2UWP). Pliki które tam trafią są zwykłymi plikami tekstowymi,
+możesz je oglądnąć przy pomocy dowolnej przeglądarki z dowolnego urządzenia, albo przy pomocy odpowiedniej aplikacji UWP.
+Aplikacja nie korzysta z żadnych innych Twoich danych, i nie wysyła nic innego nigdzie indziej.
UWP app
This app reads files from your OneDrive (folder: Apps/Andro2UWP), treating it as Android notification sent by Android companion app.
It doesn't use any other data, and only data it send (to same OneDrive folder) are dictionary of renames of notification
sender names and notification filters, both created by you.
+Polityka prywatności aplikacji 'Andro2UWP'
+Aplikacja odczytuje pliki z Twojego OneDrive (z katalogu Apps/Andro2UWP), traktując je jako wysłane przez towarzyszącą
+jej aplikację Android.
+Aplikacja nie korzysta z żadnych innych Twoich danych, a jedyne dane które wysyła (do tego samego folderu OneDrive)
+to tworzone przez Ciebie słownik zmian nazw źródeł powiadomień oraz definicje filtrów powiadomień.
\ No newline at end of file
diff --git a/Docs/_README.md_ b/Docs/_README.md_
deleted file mode 100644
index 6d27fee..0000000
--- a/Docs/_README.md_
+++ /dev/null
@@ -1,83 +0,0 @@
-# Andro2UWP
-
-## About
-
-Fork of famous Andro2UWP project, branch 10.2002.5
-
-Technical version (build) 1.0.6.0
-
-Status: alpha (RnD)
-
-
-## Idea (Goal)
-New solution for whatsapp-telegram-bridge via Android-phone/Win10Mobile phone interconnect...
-idk how to express this idea in English, soory :)))
-
-Old discussion: https://forum.xda-developers.com/t/new-solution-for-whatsapp-telegram-bridge.4211421/
-
-## Progress
-Phases of "building the solution":
-
-[1] RnD +-
-
-[2] Design +-
-
-[3] Tech. project +-
-
-[4] Dev >> [15%]
-
-[5] "Intro" -
-
-
-## Screenshots
-![Shot 1](Images/shot1.png)
-
-
-## Requirenments
-
-Win SDK : 15063
-
-Uno Platform
-
-Targets: ARM; x86
-
-
-## My "Workbench"
-
-Visual Studio 2022 Preview 4
-
-Xamarin workbench
-
-UNO Platform extesion
-
-
-## Refactoring tips:
-
-Build node is slitly fixed (ready to debug after pkarModuleShared.cs "regeneration"... ohh... I found pkModuleShared.cs.org too late... confused))
-
-# Contribute!
-There's still a TON of things missing from this proof-of-concept (MVP) and areas of improvement
-which I just haven't had the time to get to yet.
-- UI Improvements (for GTK, for example, or for each one of supported mutli-platforms)))
-- Additional Language Packages
-- Media Transferring Support: screenshots, etc. (for the brave)
-
-## Solution Layout
-Projects have a DOCs which expands on the internal functionality and layout of that project... it's good for your own R.E.
-There are no DOCs which explains all architecture, API, OneDride auth. and etc. yet... this is just beginning... =)
-
-With best wishes,
-
- [m][e] 2021
-
-
-## Thanks!
-I wanted to put down some thank you's here for folks/projects/websites that were invaluable for helping me get this project into a functional state:
-- [Piotr Karocki](https://github.com/pkar70/) - Great C#/Xamarin/UNO Platform developer
-- [Andro2UWP](https://github.com/pkar70/Andro2UWP) - Original Andro2UWP
-
-
-## License & Copyright
-
-Andro2UWP 1.0.0.0 is RnD project only. AS-IS. No support. Distributed under the MIT License.
-
diff --git a/Images/shot1.png b/Images/shot1.png
index a0f9151..1151cb0 100644
Binary files a/Images/shot1.png and b/Images/shot1.png differ
diff --git a/Images/shot2.png b/Images/shot2.png
index 6762c54..6294a6a 100644
Binary files a/Images/shot2.png and b/Images/shot2.png differ
diff --git a/LICENSE b/LICENSE
index fc612a2..e800001 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2022 Media Explorer
+Copyright (c) 2021 Media Explorer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 55676b1..3bc0ebf 100644
--- a/README.md
+++ b/README.md
@@ -4,10 +4,16 @@
My attempt to recover PKar70's Andro2UWP project, branch 10.2002.5
-Technical version (build) 1.0.7.0
+Technical version (build) 1.0.11.0
Status: alpha (RnD)
+## Progress
+- Merging Goolge and UWP branches' one drive mechanisms - ready
+- RU Localization - added (and symply tested, not ready yet)
+- Android version improved (Sync Engine recovered a partially, zero-size files generated, heh)
+- UWP version demaged after choosing ARM building... so strange :(
+
## Idea (Goal)
New solution for whatsapp-telegram-bridge via Android-phone/Win10Mobile phone "interconnect"
@@ -23,7 +29,7 @@ Phases of "building the solution":
[3] Tech. project +-
-[4] Dev >> [25%]
+[4] Dev >> [35%]
[5] "Intro" -
diff --git a/status.txt b/status.txt
new file mode 100644
index 0000000..693cdc4
--- /dev/null
+++ b/status.txt
@@ -0,0 +1,4 @@
+v1.0.11-alpha
+
+Merging Goolge and UWP branches' one drive mechanisms - ready
+RU Localization - added (and symply tested, not ready yet)
\ No newline at end of file