Skip to content
This repository has been archived by the owner on Apr 30, 2023. It is now read-only.

Commit

Permalink
Unified API ヽ(´ー`)ノ
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheesebaron committed Jan 21, 2015
1 parent 2f81b4f commit 8e57a7c
Show file tree
Hide file tree
Showing 34 changed files with 146 additions and 142 deletions.
6 changes: 3 additions & 3 deletions AppId/Touch/AppId.Touch.csproj
Expand Up @@ -6,7 +6,7 @@
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2E4FF295-9763-4D2A-BDF7-838CF0E5886C}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>Cheesebaron.MvxPlugins.AppId</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
Expand Down Expand Up @@ -47,13 +47,13 @@
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\AppId.Core.csproj">
<Project>{19159A7C-569A-4A2A-B4DC-A2305F384E23}</Project>
<Name>AppId.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>
4 changes: 2 additions & 2 deletions AppId/Touch/AppIdGenerator.cs
@@ -1,5 +1,5 @@
//---------------------------------------------------------------------------------
// Copyright 2013 Tomasz Cielecki (tomasz@ostebaronen.dk)
// Copyright 2013-2015 Tomasz Cielecki (tomasz@ostebaronen.dk)
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Expand All @@ -15,7 +15,7 @@
//---------------------------------------------------------------------------------

using System;
using MonoTouch.UIKit;
using UIKit;

namespace Cheesebaron.MvxPlugins.AppId
{
Expand Down
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0EBF0D71-7D85-45DC-90DD-B85C50B01FCE}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>Cheesebaron.MvxPlugins.AzureAccessControl.Touch</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
Expand Down Expand Up @@ -41,8 +41,9 @@
<Compile Include="Views\DefaultLoginIdentityProviderTableViewController.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="BTProgressHUD">
<HintPath>..\..\submodules\BTProgressHUD\BTProgressHUD\bin\classic\Debug\BTProgressHUD.dll</HintPath>
<Reference Include="BTProgressHUD, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Components\btprogresshud-1.15\lib\ios-unified\BTProgressHUD.dll</HintPath>
</Reference>
<Reference Include="Cirrious.CrossCore">
<HintPath>..\..\submodules\MvvmCross\bin\Debug\Mvx\Touch\Cirrious.CrossCore.dll</HintPath>
Expand Down Expand Up @@ -86,7 +87,7 @@
<Reference Include="System.Windows" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Settings\Cheesebaron.MvxPlugins.Settings\Cheesebaron.MvxPlugins.Settings.csproj">
Expand All @@ -102,5 +103,11 @@
<Name>AzureAccessControl.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
</Project>
<ItemGroup>
<XamarinComponentReference Include="btprogresshud">
<Visible>False</Visible>
<Version>1.15</Version>
</XamarinComponentReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>
Expand Up @@ -22,8 +22,8 @@
using Cirrious.CrossCore.Touch.Platform;
using Cirrious.CrossCore.Touch.Views;
using Cirrious.MvvmCross.Plugins.Messenger;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;

namespace Cheesebaron.MvxPlugins.AzureAccessControl.Touch
{
Expand Down
@@ -1,5 +1,5 @@
//---------------------------------------------------------------------------------
// Copyright 2013 Tomasz Cielecki (tomasz@ostebaronen.dk)
// Copyright 2013-2015 Tomasz Cielecki (tomasz@ostebaronen.dk)
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Expand All @@ -15,15 +15,15 @@
//---------------------------------------------------------------------------------

using System;
using System.Drawing;
using System.Text;

using Cheesebaron.MvxPlugins.AzureAccessControl.Messages;

using Cirrious.CrossCore;
using Cirrious.MvvmCross.Plugins.Messenger;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using CoreGraphics;
using Foundation;
using UIKit;

namespace Cheesebaron.MvxPlugins.AzureAccessControl.Touch.Views
{
Expand Down Expand Up @@ -76,7 +76,7 @@ public override void ViewDidLoad()
if (!string.IsNullOrEmpty(IdentityProviderName))
Title = IdentityProviderName;

_webView = new UIWebView(new RectangleF(0,0, View.Bounds.Width, View.Bounds.Height))
_webView = new UIWebView(new CGRect(0,0, View.Bounds.Width, View.Bounds.Height))
{
AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleBottomMargin
};
Expand Down Expand Up @@ -128,7 +128,7 @@ private bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewN
return false;
}

internal class LoginConnectionDelegate : NSUrlConnectionDelegate
internal class LoginConnectionDelegate : NSUrlConnectionDataDelegate
{
private readonly AccessControlWebAuthController _controller;
private NSMutableData _data;
Expand Down
@@ -1,5 +1,5 @@
//---------------------------------------------------------------------------------
// Copyright 2013 Tomasz Cielecki (tomasz@ostebaronen.dk)
// Copyright 2013-2015 Tomasz Cielecki (tomasz@ostebaronen.dk)
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Expand Down Expand Up @@ -31,8 +31,8 @@
using Cirrious.MvvmCross.Dialog.Touch;
using Cirrious.MvvmCross.ViewModels;
using CrossUI.Touch.Dialog.Elements;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;

namespace Cheesebaron.MvxPlugins.AzureAccessControl.Touch.Views
{
Expand Down Expand Up @@ -108,7 +108,8 @@ public override void ViewDidLoad()
Root.Remove(_loginDetailSection);
});

_loadingToken = ViewModel.WeakSubscribe(() => ViewModel.LoadingIdentityProviders, (sender, args) => InvokeOnMainThread(() =>
_loadingToken = ViewModel.WeakSubscribe(() => ViewModel.LoadingIdentityProviders,
(sender, args) => InvokeOnMainThread(() =>
{
if (ViewModel.LoadingIdentityProviders)
{
Expand Down Expand Up @@ -158,9 +159,9 @@ private void LoginDefaultProvider()
ViewModel.LoginSelectedIdentityProviderCommand.Execute(provider);
}

public Task<int> ShowAlert(string title, string message, params string[] buttons)
public Task<nint> ShowAlert(string title, string message, params string[] buttons)
{
var tcs = new TaskCompletionSource<int>();
var tcs = new TaskCompletionSource<nint>();
var alert = new UIAlertView
{
Title = title,
Expand Down Expand Up @@ -213,7 +214,8 @@ protected virtual void SetItemsSource(IEnumerable value)
_itemsSource = value;
if (_itemsSource != null && !(_itemsSource is IList))
MvxBindingTrace.Trace(MvxTraceLevel.Warning,
"Binding to IEnumerable rather than IList - this can be inefficient, especially for large lists");
@"Binding to IEnumerable rather than IList - this can be inefficient,
especially for large lists");
var newObservable = _itemsSource as INotifyCollectionChanged;
if (newObservable != null)
_subscription = newObservable.WeakSubscribe(OnItemsSourceCollectionChanged);
Expand Down Expand Up @@ -260,7 +262,12 @@ public class CustomStringElement
public CustomStringElement()
{
this.CreateBindingContext();
this.DelayBind(() => this.CreateBinding().For(me => me.Caption).To<DefaultIdentityProviderViewModel>(p => p.Name).Apply());
this.DelayBind(
() =>
this.CreateBinding()
.For(me => me.Caption)
.To<DefaultIdentityProviderViewModel>(p => p.Name)
.Apply());
}


Expand All @@ -269,7 +276,10 @@ public CustomStringElement()
protected override UITableViewCell GetCellImpl(UITableView tv)
{
var uiTableViewCell = tv.DequeueReusableCell(Value == null ? Skey : SkeyValue) ??
new UITableViewCell(Value == null ? UITableViewCellStyle.Default : UITableViewCellStyle.Value1, Skey)
new UITableViewCell(
Value == null ?
UITableViewCellStyle.Default :
UITableViewCellStyle.Value1, Skey)
{
SelectionStyle = UITableViewCellSelectionStyle.Blue
};
Expand Down
6 changes: 3 additions & 3 deletions Connectivity/Touch/Connectivity.Touch.csproj
Expand Up @@ -6,7 +6,7 @@
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6A795862-873A-40DE-AC3D-A39B34DE5923}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>Cheesebaron.MvxPlugins.Connectivity</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
Expand Down Expand Up @@ -62,7 +62,7 @@
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>
58 changes: 32 additions & 26 deletions Connectivity/Touch/Reachability.cs
Expand Up @@ -2,26 +2,35 @@
* reachability.cs from
* https://github.com/xamarin/monotouch-samples/blob/master/ReachabilitySample/reachability.cs
*
* Copyright 2009-2011 Novell Inc and the individuals listed
* on the ChangeLog entries.
*
* Copyright 2011 Xamarin Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 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:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 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.Net;
using MonoTouch.SystemConfiguration;
using MonoTouch.CoreFoundation;
using SystemConfiguration;
using CoreFoundation;

namespace Cheesebaron.MvxPlugins.Connectivity
{
Expand Down Expand Up @@ -55,7 +64,7 @@ public static bool IsReachableWithoutRequiringConnection(NetworkReachabilityFlag
// Is the host reachable with the current network configuration
public static bool IsHostReachable(string host)
{
if (host == null || host.Length == 0)
if (string.IsNullOrEmpty(host))
return false;

using (var r = new NetworkReachability(host))
Expand Down Expand Up @@ -90,36 +99,34 @@ static void OnChange(NetworkReachabilityFlags flags)
// out parameter
//
static NetworkReachability adHocWiFiNetworkReachability;

public static bool IsAdHocWiFiNetworkAvailable(out NetworkReachabilityFlags flags)
{
if (adHocWiFiNetworkReachability == null)
{
adHocWiFiNetworkReachability = new NetworkReachability(new IPAddress(new byte[] { 169, 254, 0, 0 }));
adHocWiFiNetworkReachability.SetCallback(OnChange);
adHocWiFiNetworkReachability.SetNotification(OnChange);
adHocWiFiNetworkReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
}

if (!adHocWiFiNetworkReachability.TryGetFlags(out flags))
return false;

return IsReachableWithoutRequiringConnection(flags);
return adHocWiFiNetworkReachability.TryGetFlags(out flags) && IsReachableWithoutRequiringConnection(flags);
}

static NetworkReachability defaultRouteReachability;

static bool IsNetworkAvailable(out NetworkReachabilityFlags flags)
{
if (defaultRouteReachability == null)
{
defaultRouteReachability = new NetworkReachability(new IPAddress(0));
defaultRouteReachability.SetCallback(OnChange);
defaultRouteReachability.SetNotification(OnChange);
defaultRouteReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
}
if (!defaultRouteReachability.TryGetFlags(out flags))
return false;
return IsReachableWithoutRequiringConnection(flags);
return defaultRouteReachability.TryGetFlags(out flags) && IsReachableWithoutRequiringConnection(flags);
}

static NetworkReachability remoteHostReachability;

public static NetworkStatus RemoteHostStatus()
{
NetworkReachabilityFlags flags;
Expand All @@ -133,7 +140,7 @@ public static NetworkStatus RemoteHostStatus()
// this only happens when you create NetworkReachability from a hostname
reachable = remoteHostReachability.TryGetFlags(out flags);

remoteHostReachability.SetCallback(OnChange);
remoteHostReachability.SetNotification(OnChange);
remoteHostReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
}
else
Expand All @@ -155,10 +162,9 @@ public static NetworkStatus InternetConnectionStatus()
{
NetworkReachabilityFlags flags;
bool defaultNetworkAvailable = IsNetworkAvailable(out flags);
if (defaultNetworkAvailable)
if (defaultNetworkAvailable && ((flags & NetworkReachabilityFlags.IsDirect) != 0))
{
if ((flags & NetworkReachabilityFlags.IsDirect) != 0)
return NetworkStatus.NotReachable;
return NetworkStatus.NotReachable;
}
else if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
return NetworkStatus.ReachableViaCarrierDataNetwork;
Expand Down
6 changes: 3 additions & 3 deletions Notifications/Touch/Notifications.Touch.csproj
Expand Up @@ -6,7 +6,7 @@
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6F32FBE1-5D8C-42BB-8DC7-F199DAB71271}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>Cheesebaron.MvxPlugins.Notifications</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
Expand Down Expand Up @@ -77,7 +77,7 @@
<Reference Include="System.Json" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>

0 comments on commit 8e57a7c

Please sign in to comment.