Merge pull request #4 from xamarin/forms-recipes
Storing credentials recipe added.
|
@ -0,0 +1,19 @@
|
||||||
|
Any raw assets you want to be deployed with your application can be placed in
|
||||||
|
this directory (and child directories) and given a Build Action of "AndroidAsset".
|
||||||
|
|
||||||
|
These files will be deployed with your package and will be accessible using Android's
|
||||||
|
AssetManager, like this:
|
||||||
|
|
||||||
|
public class ReadAsset : Activity
|
||||||
|
{
|
||||||
|
protected override void OnCreate (Bundle bundle)
|
||||||
|
{
|
||||||
|
base.OnCreate (bundle);
|
||||||
|
|
||||||
|
InputStream input = Assets.Open ("my_asset.txt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Additionally, some Android functions will automatically load asset files:
|
||||||
|
|
||||||
|
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
|
|
@ -0,0 +1,50 @@
|
||||||
|
using System.Linq;
|
||||||
|
using StoreCredentials.Droid;
|
||||||
|
using Xamarin.Auth;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
[assembly: Dependency (typeof(CredentialsService))]
|
||||||
|
namespace StoreCredentials.Droid
|
||||||
|
{
|
||||||
|
public class CredentialsService : ICredentialsService
|
||||||
|
{
|
||||||
|
public string UserName {
|
||||||
|
get {
|
||||||
|
var account = AccountStore.Create (Forms.Context).FindAccountsForService (App.AppName).FirstOrDefault ();
|
||||||
|
return (account != null) ? account.Username : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Password {
|
||||||
|
get {
|
||||||
|
var account = AccountStore.Create (Forms.Context).FindAccountsForService (App.AppName).FirstOrDefault ();
|
||||||
|
return (account != null) ? account.Properties ["Password"] : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveCredentials (string userName, string password)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace (userName) && !string.IsNullOrWhiteSpace (password)) {
|
||||||
|
Account account = new Account {
|
||||||
|
Username = userName
|
||||||
|
};
|
||||||
|
account.Properties.Add ("Password", password);
|
||||||
|
AccountStore.Create (Forms.Context).Save (account, App.AppName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteCredentials ()
|
||||||
|
{
|
||||||
|
var account = AccountStore.Create (Forms.Context).FindAccountsForService (App.AppName).FirstOrDefault ();
|
||||||
|
if (account != null) {
|
||||||
|
AccountStore.Create (Forms.Context).Delete (account, App.AppName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool DoCredentialsExist ()
|
||||||
|
{
|
||||||
|
return AccountStore.Create (Forms.Context).FindAccountsForService (App.AppName).Any () ? true : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
using Android.App;
|
||||||
|
using Android.Content;
|
||||||
|
using Android.Content.PM;
|
||||||
|
using Android.Runtime;
|
||||||
|
using Android.Views;
|
||||||
|
using Android.Widget;
|
||||||
|
using Android.OS;
|
||||||
|
|
||||||
|
namespace StoreCredentials.Droid
|
||||||
|
{
|
||||||
|
[Activity (Label = "StoreCredentials.Droid", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
|
||||||
|
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
|
||||||
|
{
|
||||||
|
protected override void OnCreate (Bundle bundle)
|
||||||
|
{
|
||||||
|
base.OnCreate (bundle);
|
||||||
|
|
||||||
|
global::Xamarin.Forms.Forms.Init (this, bundle);
|
||||||
|
|
||||||
|
LoadApplication (new App ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.storecredentials">
|
||||||
|
<uses-sdk android:minSdkVersion="15" />
|
||||||
|
<application android:label="StoreCredentials">
|
||||||
|
</application>
|
||||||
|
</manifest>
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using Android.App;
|
||||||
|
|
||||||
|
// Information about this assembly is defined by the following attributes.
|
||||||
|
// Change them to the values specific to your project.
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle ("StoreCredentials.Droid")]
|
||||||
|
[assembly: AssemblyDescription ("")]
|
||||||
|
[assembly: AssemblyConfiguration ("")]
|
||||||
|
[assembly: AssemblyCompany ("")]
|
||||||
|
[assembly: AssemblyProduct ("")]
|
||||||
|
[assembly: AssemblyCopyright ("davidbritch")]
|
||||||
|
[assembly: AssemblyTrademark ("")]
|
||||||
|
[assembly: AssemblyCulture ("")]
|
||||||
|
|
||||||
|
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||||
|
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||||
|
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion ("1.0.0")]
|
||||||
|
|
||||||
|
// The following attributes are used to specify the signing key for the assembly,
|
||||||
|
// if desired. See the Mono documentation for more information about signing.
|
||||||
|
|
||||||
|
//[assembly: AssemblyDelaySign(false)]
|
||||||
|
//[assembly: AssemblyKeyFile("")]
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
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.
|
82
cross-platform/xamarin-forms/StoreCredentials/Droid/Resources/Resource.designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
#pragma warning disable 1591
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
// <autogenerated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Mono Runtime Version: 4.0.30319.17020
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </autogenerated>
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[assembly: Android.Runtime.ResourceDesignerAttribute("StoreCredentials.Droid.Resource", IsApplication=true)]
|
||||||
|
|
||||||
|
namespace StoreCredentials.Droid
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
|
||||||
|
public partial class Resource
|
||||||
|
{
|
||||||
|
|
||||||
|
static Resource()
|
||||||
|
{
|
||||||
|
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UpdateIdValues()
|
||||||
|
{
|
||||||
|
global::Xamarin.Forms.Platform.Resource.String.ApplicationName = global::StoreCredentials.Droid.Resource.String.ApplicationName;
|
||||||
|
global::Xamarin.Forms.Platform.Resource.String.Hello = global::StoreCredentials.Droid.Resource.String.Hello;
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
static Attribute()
|
||||||
|
{
|
||||||
|
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Attribute()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class Drawable
|
||||||
|
{
|
||||||
|
|
||||||
|
// aapt resource value: 0x7f020000
|
||||||
|
public const int icon = 2130837504;
|
||||||
|
|
||||||
|
static Drawable()
|
||||||
|
{
|
||||||
|
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drawable()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class String
|
||||||
|
{
|
||||||
|
|
||||||
|
// aapt resource value: 0x7f030001
|
||||||
|
public const int ApplicationName = 2130903041;
|
||||||
|
|
||||||
|
// aapt resource value: 0x7f030000
|
||||||
|
public const int Hello = 2130903040;
|
||||||
|
|
||||||
|
static String()
|
||||||
|
{
|
||||||
|
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma warning restore 1591
|
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/Droid/Resources/drawable-hdpi/icon.png
Normal file
После Ширина: | Высота: | Размер: 1.4 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/Droid/Resources/drawable-xhdpi/icon.png
Normal file
После Ширина: | Высота: | Размер: 1.7 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/Droid/Resources/drawable-xxhdpi/icon.png
Normal file
После Ширина: | Высота: | Размер: 2.3 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/Droid/Resources/drawable/icon.png
Normal file
После Ширина: | Высота: | Размер: 1.4 KiB |
|
@ -0,0 +1,103 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<ProjectGuid>{34025984-011D-4FB1-B406-A7286304BABF}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<RootNamespace>StoreCredentials.Droid</RootNamespace>
|
||||||
|
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
|
||||||
|
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
|
||||||
|
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||||
|
<AndroidResgenClass>Resource</AndroidResgenClass>
|
||||||
|
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
|
||||||
|
<AndroidApplication>True</AndroidApplication>
|
||||||
|
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||||
|
<AssemblyName>StoreCredentials.Droid</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v5.1</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AndroidLinkMode>None</AndroidLinkMode>
|
||||||
|
<ConsolePause>false</ConsolePause>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
|
||||||
|
<ConsolePause>false</ConsolePause>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="Mono.Android" />
|
||||||
|
<Reference Include="Xamarin.Forms.Platform.Android">
|
||||||
|
<HintPath>..\packages\Xamarin.Forms.1.5.0.6447\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="FormsViewGroup">
|
||||||
|
<HintPath>..\packages\Xamarin.Forms.1.5.0.6447\lib\MonoAndroid10\FormsViewGroup.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Forms.Core">
|
||||||
|
<HintPath>..\packages\Xamarin.Forms.1.5.0.6447\lib\MonoAndroid10\Xamarin.Forms.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Forms.Xaml">
|
||||||
|
<HintPath>..\packages\Xamarin.Forms.1.5.0.6447\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Forms.Platform">
|
||||||
|
<HintPath>..\packages\Xamarin.Forms.1.5.0.6447\lib\MonoAndroid10\Xamarin.Forms.Platform.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Android.Support.v4">
|
||||||
|
<HintPath>..\packages\Xamarin.Android.Support.v4.23.0.1.3\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Auth.Android">
|
||||||
|
<HintPath>..\Components\xamarin.auth-1.2.3.1\lib\android\Xamarin.Auth.Android.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\StoreCredentials\StoreCredentials.csproj">
|
||||||
|
<Project>{39F7BCA7-D6B2-40D6-863A-9C712421A297}</Project>
|
||||||
|
<Name>StoreCredentials</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="MainActivity.cs" />
|
||||||
|
<Compile Include="Resources\Resource.designer.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="CredentialsService.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\AboutResources.txt" />
|
||||||
|
<None Include="Properties\AndroidManifest.xml" />
|
||||||
|
<None Include="Assets\AboutAssets.txt" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Resources\layout\" />
|
||||||
|
<Folder Include="Resources\values\" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\drawable\icon.png" />
|
||||||
|
<AndroidResource Include="Resources\drawable-hdpi\icon.png" />
|
||||||
|
<AndroidResource Include="Resources\drawable-xhdpi\icon.png" />
|
||||||
|
<AndroidResource Include="Resources\drawable-xxhdpi\icon.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||||
|
<Import Project="..\packages\Xamarin.Forms.1.5.0.6447\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.1.5.0.6447\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
|
||||||
|
<ItemGroup>
|
||||||
|
<XamarinComponentReference Include="xamarin.auth">
|
||||||
|
<Version>1.2.3.1</Version>
|
||||||
|
<Visible>False</Visible>
|
||||||
|
</XamarinComponentReference>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Xamarin.Android.Support.v4" version="23.0.1.3" targetFramework="MonoAndroid51" />
|
||||||
|
<package id="Xamarin.Forms" version="1.5.0.6447" targetFramework="MonoAndroid51" />
|
||||||
|
</packages>
|
|
@ -0,0 +1,3 @@
|
||||||
|
This recipe shows how to securely store data in an account store that's backed by Keychain services in iOS, and the `KeyStore` class in Android.
|
||||||
|
|
||||||
|
The full recipe can be found [here](http://developer.xamarin.com/recipes/cross-platform/xamarin-forms/store-credentials/).
|
|
@ -0,0 +1,57 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StoreCredentials", "StoreCredentials\StoreCredentials.csproj", "{39F7BCA7-D6B2-40D6-863A-9C712421A297}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StoreCredentials.iOS", "iOS\StoreCredentials.iOS.csproj", "{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StoreCredentials.Droid", "Droid\StoreCredentials.Droid.csproj", "{34025984-011D-4FB1-B406-A7286304BABF}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Debug|iPhoneSimulator = Debug|iPhoneSimulator
|
||||||
|
Release|iPhone = Release|iPhone
|
||||||
|
Release|iPhoneSimulator = Release|iPhoneSimulator
|
||||||
|
Debug|iPhone = Debug|iPhone
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
|
||||||
|
{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
|
||||||
|
{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||||
|
{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||||
|
{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||||
|
{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||||
|
{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}.Release|Any CPU.ActiveCfg = Release|iPhone
|
||||||
|
{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}.Release|Any CPU.Build.0 = Release|iPhone
|
||||||
|
{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||||
|
{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}.Release|iPhone.Build.0 = Release|iPhone
|
||||||
|
{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||||
|
{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||||
|
{34025984-011D-4FB1-B406-A7286304BABF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{34025984-011D-4FB1-B406-A7286304BABF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{34025984-011D-4FB1-B406-A7286304BABF}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||||
|
{34025984-011D-4FB1-B406-A7286304BABF}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||||
|
{34025984-011D-4FB1-B406-A7286304BABF}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||||
|
{34025984-011D-4FB1-B406-A7286304BABF}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||||
|
{34025984-011D-4FB1-B406-A7286304BABF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{34025984-011D-4FB1-B406-A7286304BABF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{34025984-011D-4FB1-B406-A7286304BABF}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||||
|
{34025984-011D-4FB1-B406-A7286304BABF}.Release|iPhone.Build.0 = Release|Any CPU
|
||||||
|
{34025984-011D-4FB1-B406-A7286304BABF}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||||
|
{34025984-011D-4FB1-B406-A7286304BABF}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||||
|
{39F7BCA7-D6B2-40D6-863A-9C712421A297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{39F7BCA7-D6B2-40D6-863A-9C712421A297}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{39F7BCA7-D6B2-40D6-863A-9C712421A297}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||||
|
{39F7BCA7-D6B2-40D6-863A-9C712421A297}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||||
|
{39F7BCA7-D6B2-40D6-863A-9C712421A297}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||||
|
{39F7BCA7-D6B2-40D6-863A-9C712421A297}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||||
|
{39F7BCA7-D6B2-40D6-863A-9C712421A297}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{39F7BCA7-D6B2-40D6-863A-9C712421A297}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{39F7BCA7-D6B2-40D6-863A-9C712421A297}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||||
|
{39F7BCA7-D6B2-40D6-863A-9C712421A297}.Release|iPhone.Build.0 = Release|Any CPU
|
||||||
|
{39F7BCA7-D6B2-40D6-863A-9C712421A297}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||||
|
{39F7BCA7-D6B2-40D6-863A-9C712421A297}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,34 @@
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace StoreCredentials
|
||||||
|
{
|
||||||
|
public class App : Application
|
||||||
|
{
|
||||||
|
public static string AppName { get { return "StoreAccountInfoApp"; } }
|
||||||
|
|
||||||
|
public App ()
|
||||||
|
{
|
||||||
|
if (DependencyService.Get<ICredentialsService> ().DoCredentialsExist ()) {
|
||||||
|
MainPage = new NavigationPage (new HomePage ());
|
||||||
|
} else {
|
||||||
|
MainPage = new NavigationPage (new LoginPage ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnStart ()
|
||||||
|
{
|
||||||
|
// Handle when your app starts
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnSleep ()
|
||||||
|
{
|
||||||
|
// Handle when your app sleeps
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnResume ()
|
||||||
|
{
|
||||||
|
// Handle when your app resumes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace StoreCredentials
|
||||||
|
{
|
||||||
|
public static class Constants
|
||||||
|
{
|
||||||
|
public static string Username = "Xamarin";
|
||||||
|
public static string Password = "password";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="StoreCredentials.HomePage"
|
||||||
|
Title="Home Page">
|
||||||
|
<ContentPage.ToolbarItems>
|
||||||
|
<ToolbarItem Text="Logout" Clicked="OnLogoutButtonClicked" />
|
||||||
|
</ContentPage.ToolbarItems>
|
||||||
|
<ContentPage.Content>
|
||||||
|
<StackLayout>
|
||||||
|
<Label Text="Main app content goes here" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage.Content>
|
||||||
|
</ContentPage>
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace StoreCredentials
|
||||||
|
{
|
||||||
|
public partial class HomePage : ContentPage
|
||||||
|
{
|
||||||
|
public HomePage ()
|
||||||
|
{
|
||||||
|
InitializeComponent ();
|
||||||
|
}
|
||||||
|
|
||||||
|
async void OnLogoutButtonClicked (object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DependencyService.Get<ICredentialsService> ().DeleteCredentials ();
|
||||||
|
Navigation.InsertPageBefore (new LoginPage (), this);
|
||||||
|
await Navigation.PopAsync ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
using System;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace StoreCredentials
|
||||||
|
{
|
||||||
|
public class HomePageCS : ContentPage
|
||||||
|
{
|
||||||
|
public HomePageCS ()
|
||||||
|
{
|
||||||
|
var toolbarItem = new ToolbarItem {
|
||||||
|
Text = "Logout"
|
||||||
|
};
|
||||||
|
toolbarItem.Clicked += OnLogoutButtonClicked;
|
||||||
|
ToolbarItems.Add (toolbarItem);
|
||||||
|
|
||||||
|
Title = "Home Page";
|
||||||
|
Content = new StackLayout {
|
||||||
|
Children = {
|
||||||
|
new Label {
|
||||||
|
Text = "Main app content goes here",
|
||||||
|
HorizontalOptions = LayoutOptions.Center,
|
||||||
|
VerticalOptions = LayoutOptions.CenterAndExpand
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async void OnLogoutButtonClicked (object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DependencyService.Get<ICredentialsService> ().DeleteCredentials ();
|
||||||
|
Navigation.InsertPageBefore (new LoginPage (), this);
|
||||||
|
await Navigation.PopAsync ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
namespace StoreCredentials
|
||||||
|
{
|
||||||
|
public interface ICredentialsService
|
||||||
|
{
|
||||||
|
string UserName { get; }
|
||||||
|
|
||||||
|
string Password { get; }
|
||||||
|
|
||||||
|
void SaveCredentials (string userName, string password);
|
||||||
|
|
||||||
|
void DeleteCredentials ();
|
||||||
|
|
||||||
|
bool DoCredentialsExist ();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="StoreCredentials.LoginPage"
|
||||||
|
Title="Login Page">
|
||||||
|
<ContentPage.Content>
|
||||||
|
<StackLayout VerticalOptions="StartAndExpand">
|
||||||
|
<Label Text="Username" />
|
||||||
|
<Entry x:Name="usernameEntry" Placeholder="username" />
|
||||||
|
<Label Text="Password" />
|
||||||
|
<Entry x:Name="passwordEntry" IsPassword="true" />
|
||||||
|
<Button Text="Login" Clicked="OnLoginButtonClicked" />
|
||||||
|
<Label x:Name="messageLabel" />
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage.Content>
|
||||||
|
</ContentPage>
|
|
@ -0,0 +1,42 @@
|
||||||
|
using System;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace StoreCredentials
|
||||||
|
{
|
||||||
|
public partial class LoginPage : ContentPage
|
||||||
|
{
|
||||||
|
ICredentialsService storeService;
|
||||||
|
|
||||||
|
public LoginPage ()
|
||||||
|
{
|
||||||
|
InitializeComponent ();
|
||||||
|
|
||||||
|
storeService = DependencyService.Get<ICredentialsService> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
async void OnLoginButtonClicked (object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string userName = usernameEntry.Text;
|
||||||
|
string password = passwordEntry.Text;
|
||||||
|
|
||||||
|
var isValid = AreCredentialsCorrect (userName, password);
|
||||||
|
if (isValid) {
|
||||||
|
bool doCredentialsExist = storeService.DoCredentialsExist ();
|
||||||
|
if (!doCredentialsExist) {
|
||||||
|
storeService.SaveCredentials (userName, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
Navigation.InsertPageBefore (new HomePage (), this);
|
||||||
|
await Navigation.PopAsync ();
|
||||||
|
} else {
|
||||||
|
messageLabel.Text = "Login failed";
|
||||||
|
passwordEntry.Text = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AreCredentialsCorrect (string username, string password)
|
||||||
|
{
|
||||||
|
return username == Constants.Username && password == Constants.Password;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace StoreCredentials
|
||||||
|
{
|
||||||
|
public class LoginPageCS : ContentPage
|
||||||
|
{
|
||||||
|
ICredentialsService storeService;
|
||||||
|
Entry usernameEntry;
|
||||||
|
Entry passwordEntry;
|
||||||
|
Label messageLabel;
|
||||||
|
|
||||||
|
public LoginPageCS ()
|
||||||
|
{
|
||||||
|
storeService = DependencyService.Get<ICredentialsService> ();
|
||||||
|
|
||||||
|
usernameEntry = new Entry {
|
||||||
|
Placeholder = "username"
|
||||||
|
};
|
||||||
|
passwordEntry = new Entry {
|
||||||
|
IsPassword = true
|
||||||
|
};
|
||||||
|
messageLabel = new Label ();
|
||||||
|
var loginButton = new Button {
|
||||||
|
Text = "Login"
|
||||||
|
};
|
||||||
|
loginButton.Clicked += OnLoginButtonClicked;
|
||||||
|
|
||||||
|
Title = "Login Page";
|
||||||
|
Content = new StackLayout {
|
||||||
|
VerticalOptions = LayoutOptions.StartAndExpand,
|
||||||
|
Children = {
|
||||||
|
new Label { Text = "Username" },
|
||||||
|
usernameEntry,
|
||||||
|
new Label { Text = "Password" },
|
||||||
|
passwordEntry,
|
||||||
|
loginButton,
|
||||||
|
messageLabel
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async void OnLoginButtonClicked (object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string userName = usernameEntry.Text;
|
||||||
|
string password = passwordEntry.Text;
|
||||||
|
|
||||||
|
var isValid = AreCredentialsCorrect (userName, password);
|
||||||
|
if (isValid) {
|
||||||
|
bool doCredentialsExist = storeService.DoCredentialsExist ();
|
||||||
|
if (!doCredentialsExist) {
|
||||||
|
storeService.SaveCredentials (userName, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
Navigation.InsertPageBefore (new HomePage (), this);
|
||||||
|
await Navigation.PopAsync ();
|
||||||
|
} else {
|
||||||
|
messageLabel.Text = "Login failed";
|
||||||
|
passwordEntry.Text = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AreCredentialsCorrect (string username, string password)
|
||||||
|
{
|
||||||
|
return username == Constants.Username && password == Constants.Password;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
// Information about this assembly is defined by the following attributes.
|
||||||
|
// Change them to the values specific to your project.
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle ("StoreCredentials")]
|
||||||
|
[assembly: AssemblyDescription ("")]
|
||||||
|
[assembly: AssemblyConfiguration ("")]
|
||||||
|
[assembly: AssemblyCompany ("")]
|
||||||
|
[assembly: AssemblyProduct ("")]
|
||||||
|
[assembly: AssemblyCopyright ("davidbritch")]
|
||||||
|
[assembly: AssemblyTrademark ("")]
|
||||||
|
[assembly: AssemblyCulture ("")]
|
||||||
|
|
||||||
|
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||||
|
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||||
|
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion ("1.0.*")]
|
||||||
|
|
||||||
|
// The following attributes are used to specify the signing key for the assembly,
|
||||||
|
// if desired. See the Mono documentation for more information about signing.
|
||||||
|
|
||||||
|
//[assembly: AssemblyDelaySign(false)]
|
||||||
|
//[assembly: AssemblyKeyFile("")]
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<ProjectGuid>{39F7BCA7-D6B2-40D6-863A-9C712421A297}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<RootNamespace>StoreCredentials</RootNamespace>
|
||||||
|
<AssemblyName>StoreCredentials</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<ConsolePause>false</ConsolePause>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<ConsolePause>false</ConsolePause>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="App.cs" />
|
||||||
|
<Compile Include="ICredentialsService.cs" />
|
||||||
|
<Compile Include="LoginPage.xaml.cs">
|
||||||
|
<DependentUpon>LoginPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="HomePage.xaml.cs">
|
||||||
|
<DependentUpon>HomePage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LoginPageCS.cs" />
|
||||||
|
<Compile Include="HomePageCS.cs" />
|
||||||
|
<Compile Include="Constants.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||||
|
<Import Project="..\packages\Xamarin.Forms.1.5.0.6447\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.1.5.0.6447\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Xamarin.Forms.Core">
|
||||||
|
<HintPath>..\packages\Xamarin.Forms.1.5.0.6447\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Forms.Xaml">
|
||||||
|
<HintPath>..\packages\Xamarin.Forms.1.5.0.6447\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Forms.Platform">
|
||||||
|
<HintPath>..\packages\Xamarin.Forms.1.5.0.6447\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="LoginPage.xaml">
|
||||||
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="HomePage.xaml">
|
||||||
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Xamarin.Forms" version="1.5.0.6447" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
|
||||||
|
</packages>
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using Foundation;
|
||||||
|
using UIKit;
|
||||||
|
|
||||||
|
namespace StoreCredentials.iOS
|
||||||
|
{
|
||||||
|
[Register ("AppDelegate")]
|
||||||
|
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
|
||||||
|
{
|
||||||
|
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
|
||||||
|
{
|
||||||
|
global::Xamarin.Forms.Forms.Init ();
|
||||||
|
|
||||||
|
LoadApplication (new App ());
|
||||||
|
|
||||||
|
return base.FinishedLaunching (app, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
using System.Linq;
|
||||||
|
using StoreCredentials.iOS;
|
||||||
|
using Xamarin.Auth;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
[assembly: Dependency (typeof(CredentialsService))]
|
||||||
|
namespace StoreCredentials.iOS
|
||||||
|
{
|
||||||
|
public class CredentialsService : ICredentialsService
|
||||||
|
{
|
||||||
|
public string UserName {
|
||||||
|
get {
|
||||||
|
var account = AccountStore.Create ().FindAccountsForService (App.AppName).FirstOrDefault ();
|
||||||
|
return (account != null) ? account.Username : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Password {
|
||||||
|
get {
|
||||||
|
var account = AccountStore.Create ().FindAccountsForService (App.AppName).FirstOrDefault ();
|
||||||
|
return (account != null) ? account.Properties ["Password"] : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveCredentials (string userName, string password)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace (userName) && !string.IsNullOrWhiteSpace (password)) {
|
||||||
|
Account account = new Account {
|
||||||
|
Username = userName
|
||||||
|
};
|
||||||
|
account.Properties.Add ("Password", password);
|
||||||
|
AccountStore.Create ().Save (account, App.AppName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteCredentials ()
|
||||||
|
{
|
||||||
|
var account = AccountStore.Create ().FindAccountsForService (App.AppName).FirstOrDefault ();
|
||||||
|
if (account != null) {
|
||||||
|
AccountStore.Create ().Delete (account, App.AppName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DoCredentialsExist ()
|
||||||
|
{
|
||||||
|
return AccountStore.Create ().FindAccountsForService (App.AppName).Any () ? true : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
|
После Ширина: | Высота: | Размер: 33 KiB |
После Ширина: | Высота: | Размер: 20 KiB |
|
@ -0,0 +1,64 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>StoreCredentials</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.companyname.storecredentials</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
|
<key>MinimumOSVersion</key>
|
||||||
|
<string>7.0</string>
|
||||||
|
<key>UIDeviceFamily</key>
|
||||||
|
<array>
|
||||||
|
<integer>1</integer>
|
||||||
|
<integer>2</integer>
|
||||||
|
</array>
|
||||||
|
<key>UIRequiredDeviceCapabilities</key>
|
||||||
|
<array>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleIconFiles</key>
|
||||||
|
<array>
|
||||||
|
<string>Icon-60@2x</string>
|
||||||
|
<string>Icon-60@3x</string>
|
||||||
|
<string>Icon-76</string>
|
||||||
|
<string>Icon-76@2x</string>
|
||||||
|
<string>Default</string>
|
||||||
|
<string>Default@2x</string>
|
||||||
|
<string>Default-568h</string>
|
||||||
|
<string>Default-568h@2x</string>
|
||||||
|
<string>Default-Landscape</string>
|
||||||
|
<string>Default-Landscape@2x</string>
|
||||||
|
<string>Default-Portrait</string>
|
||||||
|
<string>Default-Portrait@2x</string>
|
||||||
|
<string>Icon-Small-40</string>
|
||||||
|
<string>Icon-Small-40@2x</string>
|
||||||
|
<string>Icon-Small-40@3x</string>
|
||||||
|
<string>Icon-Small</string>
|
||||||
|
<string>Icon-Small@2x</string>
|
||||||
|
<string>Icon-Small@3x</string>
|
||||||
|
</array>
|
||||||
|
<key>UILaunchStoryboardName</key>
|
||||||
|
<string>LaunchScreen</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using Foundation;
|
||||||
|
using UIKit;
|
||||||
|
|
||||||
|
namespace StoreCredentials.iOS
|
||||||
|
{
|
||||||
|
public class Application
|
||||||
|
{
|
||||||
|
// This is the main entry point of the application.
|
||||||
|
static void Main (string[] args)
|
||||||
|
{
|
||||||
|
// if you want to use a different Application Delegate class from "AppDelegate"
|
||||||
|
// you can specify it here.
|
||||||
|
UIApplication.Main (args, null, "AppDelegate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Default-568h@2x.png
Normal file
После Ширина: | Высота: | Размер: 8.7 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Default-Portrait.png
Normal file
После Ширина: | Высота: | Размер: 10 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Default-Portrait@2x.png
Normal file
После Ширина: | Высота: | Размер: 34 KiB |
После Ширина: | Высота: | Размер: 7.1 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Default@2x.png
Normal file
После Ширина: | Высота: | Размер: 8.2 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Icon-60@2x.png
Normal file
После Ширина: | Высота: | Размер: 1.7 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Icon-60@3x.png
Normal file
После Ширина: | Высота: | Размер: 21 KiB |
После Ширина: | Высота: | Размер: 1.2 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Icon-76@2x.png
Normal file
После Ширина: | Высота: | Размер: 2.2 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Icon-Small-40.png
Normal file
После Ширина: | Высота: | Размер: 729 B |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Icon-Small-40@2x.png
Normal file
После Ширина: | Высота: | Размер: 1.2 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Icon-Small-40@3x.png
Normal file
После Ширина: | Высота: | Размер: 12 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Icon-Small.png
Normal file
После Ширина: | Высота: | Размер: 1.1 KiB |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Icon-Small@2x.png
Normal file
После Ширина: | Высота: | Размер: 955 B |
Двоичные данные
cross-platform/xamarin-forms/StoreCredentials/iOS/Resources/Icon-Small@3x.png
Normal file
После Ширина: | Высота: | Размер: 7.1 KiB |
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="X5k-f2-b5h">
|
||||||
|
<dependencies>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="gAE-YM-kbH">
|
||||||
|
<objects>
|
||||||
|
<viewController id="X5k-f2-b5h" sceneMemberID="viewController">
|
||||||
|
<layoutGuides>
|
||||||
|
<viewControllerLayoutGuide type="top" id="Y8P-hJ-Z43"/>
|
||||||
|
<viewControllerLayoutGuide type="bottom" id="9ZL-r4-8FZ"/>
|
||||||
|
</layoutGuides>
|
||||||
|
<view key="view" contentMode="scaleToFill" id="yd7-JS-zBw">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" misplaced="YES" image="Icon-60.png" translatesAutoresizingMaskIntoConstraints="NO" id="23">
|
||||||
|
<rect key="frame" x="270" y="270" width="60" height="60"/>
|
||||||
|
<rect key="contentStretch" x="0.0" y="0.0" width="0.0" height="0.0"/>
|
||||||
|
</imageView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" red="0.20392156862745098" green="0.59607843137254901" blue="0.85882352941176465" alpha="1" colorSpace="calibratedRGB"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="23" firstAttribute="centerY" secondItem="yd7-JS-zBw" secondAttribute="centerY" priority="1" id="39"/>
|
||||||
|
<constraint firstItem="23" firstAttribute="centerX" secondItem="yd7-JS-zBw" secondAttribute="centerX" priority="1" id="41"/>
|
||||||
|
</constraints>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="XAI-xm-WK6" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="349" y="339"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
<resources>
|
||||||
|
<image name="Icon-60.png" width="180" height="180"/>
|
||||||
|
</resources>
|
||||||
|
</document>
|
|
@ -0,0 +1,132 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
|
||||||
|
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<ProjectGuid>{0366472A-80F1-41ED-BD2C-8F3A3D0E7662}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>StoreCredentials.iOS</RootNamespace>
|
||||||
|
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||||
|
<AssemblyName>StoreCredentials.iOS</AssemblyName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<ConsolePause>false</ConsolePause>
|
||||||
|
<MtouchArch>i386</MtouchArch>
|
||||||
|
<MtouchLink>None</MtouchLink>
|
||||||
|
<MtouchDebug>true</MtouchDebug>
|
||||||
|
<MtouchProfiling>true</MtouchProfiling>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||||
|
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||||
|
<ConsolePause>false</ConsolePause>
|
||||||
|
<CodesignKey>iPhone Developer</CodesignKey>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<MtouchArch>i386</MtouchArch>
|
||||||
|
<ConsolePause>false</ConsolePause>
|
||||||
|
<MtouchLink>None</MtouchLink>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<ConsolePause>false</ConsolePause>
|
||||||
|
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||||
|
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||||
|
<MtouchProfiling>true</MtouchProfiling>
|
||||||
|
<CodesignKey>iPhone Developer</CodesignKey>
|
||||||
|
<MtouchDebug>true</MtouchDebug>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="Xamarin.iOS" />
|
||||||
|
<Reference Include="Xamarin.Forms.Platform.iOS">
|
||||||
|
<HintPath>..\packages\Xamarin.Forms.1.5.0.6447\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Forms.Core">
|
||||||
|
<HintPath>..\packages\Xamarin.Forms.1.5.0.6447\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Forms.Xaml">
|
||||||
|
<HintPath>..\packages\Xamarin.Forms.1.5.0.6447\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Forms.Platform">
|
||||||
|
<HintPath>..\packages\Xamarin.Forms.1.5.0.6447\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Xamarin.Auth.iOS">
|
||||||
|
<HintPath>..\Components\xamarin.auth-1.2.3.1\lib\ios-unified\Xamarin.Auth.iOS.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\StoreCredentials\StoreCredentials.csproj">
|
||||||
|
<Project>{39F7BCA7-D6B2-40D6-863A-9C712421A297}</Project>
|
||||||
|
<Name>StoreCredentials</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BundleResource Include="Resources\Default.png" />
|
||||||
|
<BundleResource Include="Resources\Default%402x.png" />
|
||||||
|
<BundleResource Include="Resources\Default-568h%402x.png" />
|
||||||
|
<BundleResource Include="Resources\Default-Portrait.png" />
|
||||||
|
<BundleResource Include="Resources\Default-Portrait%402x.png" />
|
||||||
|
<BundleResource Include="Resources\Icon-60%402x.png" />
|
||||||
|
<BundleResource Include="Resources\Icon-60%403x.png" />
|
||||||
|
<BundleResource Include="Resources\Icon-76.png" />
|
||||||
|
<BundleResource Include="Resources\Icon-76%402x.png" />
|
||||||
|
<BundleResource Include="Resources\Icon-Small.png" />
|
||||||
|
<BundleResource Include="Resources\Icon-Small%402x.png" />
|
||||||
|
<BundleResource Include="Resources\Icon-Small%403x.png" />
|
||||||
|
<BundleResource Include="Resources\Icon-Small-40.png" />
|
||||||
|
<BundleResource Include="Resources\Icon-Small-40%402x.png" />
|
||||||
|
<BundleResource Include="Resources\Icon-Small-40%403x.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Info.plist" />
|
||||||
|
<None Include="Entitlements.plist" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Main.cs" />
|
||||||
|
<Compile Include="AppDelegate.cs" />
|
||||||
|
<Compile Include="CredentialsService.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ITunesArtwork Include="ITunesArtwork" />
|
||||||
|
<ITunesArtwork Include="ITunesArtwork%402x" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||||
|
<Import Project="..\packages\Xamarin.Forms.1.5.0.6447\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.1.5.0.6447\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
|
||||||
|
<ItemGroup>
|
||||||
|
<XamarinComponentReference Include="xamarin.auth">
|
||||||
|
<Version>1.2.3.1</Version>
|
||||||
|
<Visible>False</Visible>
|
||||||
|
</XamarinComponentReference>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Xamarin.Forms" version="1.5.0.6447" targetFramework="xamarinios10" />
|
||||||
|
</packages>
|