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

Commit

Permalink
Initial Check-in
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhama committed Jan 15, 2014
1 parent 16d37ad commit 9404ea4
Show file tree
Hide file tree
Showing 229 changed files with 61,007 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .nuget/NuGet.Config
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
Binary file added .nuget/NuGet.exe
Binary file not shown.
136 changes: 136 additions & 0 deletions .nuget/NuGet.targets
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>

<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>

<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
</PropertyGroup>

<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://www.nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<!-- Windows specific commands -->
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
</PropertyGroup>

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
<PackagesConfig>packages.config</PackagesConfig>
</PropertyGroup>

<PropertyGroup>
<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>

<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>

<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>

<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>

<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
</Target>

<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />

<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
Condition=" '$(OS)' != 'Windows_NT' " />

<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true"
Condition=" '$(OS)' == 'Windows_NT' " />
</Target>

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>
6 changes: 4 additions & 2 deletions README.md
@@ -1,4 +1,6 @@
tinder
Tinder App for Windows Phone
======

Tinder App for Windows Phone
Tinder is a cool iPhone/Android app and I thought it would be great to have it on Windows Phone. This project is the result of about two nights of work on bringing the app to Windows Phone. The app is now fully functional, but still is a bit rough around the edges. This is definitely not an example of my best code. I had no intention of open-sourcing this when I started, but I thought that some other Windows Phone developers out there might find it interesting, so here it is, freely licensed, do whatever you'd like with it.

- Brian P. Hamachek
113 changes: 113 additions & 0 deletions TinderApp.Library/API/Client.cs
@@ -0,0 +1,113 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Diagnostics;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace TinderApp.Lib.API
{
public class Client
{
private static string _authToken = "";

private static HttpClient _client = null;

static Client()
{
_client = new HttpClient();
_client.DefaultRequestHeaders.Add("Accept-Language", "en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5");
_client.DefaultRequestHeaders.Add("Accept", "*/*");
_client.DefaultRequestHeaders.Add("UserAgent", "Tinder/3.0.2 (iPhone; iOS 7.1; Scale/2.00)");
_client.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate");
_client.BaseAddress = new Uri(Constants.BASE_URL);
}

public static String AuthToken
{
get
{
return _authToken;
}
set
{
_authToken = value;
if (string.IsNullOrEmpty(value))
{
_client.DefaultRequestHeaders.Remove("Authorization");
_client.DefaultRequestHeaders.Remove("X-Auth-Token");
}
else
{
_client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Token", "token=\"" + value + "\"");
_client.DefaultRequestHeaders.Add("X-Auth-Token", value);
}
}
}

public async static Task<T> Get<T>(string resource)
{
var response = await _client.GetAsync(resource);
if (response.IsSuccessStatusCode)
{
string responseData = await response.Content.ReadAsStringAsync();

Debug.WriteLine(responseData);

JsonSerializerSettings settings = new JsonSerializerSettings();
settings.DateParseHandling = DateParseHandling.DateTime;
settings.DefaultValueHandling = DefaultValueHandling.Populate;
settings.NullValueHandling = NullValueHandling.Include;
settings.TypeNameHandling = TypeNameHandling.None;

return JsonConvert.DeserializeObject<T>(responseData);
}

throw new Exception(response.ReasonPhrase);
}

public async static Task Get(string resource)
{
var response = await _client.GetAsync(resource);
if (response.IsSuccessStatusCode)
{
string responseData = await response.Content.ReadAsStringAsync();
Debug.WriteLine(responseData);
return;
}

throw new Exception(response.ReasonPhrase);
}

public async static Task<T> Post<T>(string resource, object body)
{
string postData = JsonConvert.SerializeObject(body, new IsoDateTimeConverter());

var response = await _client.PostAsync(resource, new StringContent(postData, Encoding.UTF8, "application/json"));
if (response.IsSuccessStatusCode)
{
string responseData = await response.Content.ReadAsStringAsync();
Debug.WriteLine(responseData);
return JsonConvert.DeserializeObject<T>(responseData);
}

throw new Exception(response.ReasonPhrase);
}

public async static Task Post(string resource, object body)
{
string postData = JsonConvert.SerializeObject(body, new IsoDateTimeConverter());

var response = await _client.PostAsync(resource, new StringContent(postData, Encoding.UTF8, "application/json"));
if (response.IsSuccessStatusCode)
{
string responseData = await response.Content.ReadAsStringAsync();
Debug.WriteLine(responseData);
return;
}

throw new Exception(response.ReasonPhrase);
}
}
}
14 changes: 14 additions & 0 deletions TinderApp.Library/API/Constants.cs
@@ -0,0 +1,14 @@
using System;

namespace TinderApp.Lib.API
{
public class Constants
{
public const string BASE_URL = @"https://api.gotinder.com/";

public static string GetURL(string relativeUrl)
{
return String.Format("{0}{1}", BASE_URL, relativeUrl);
}
}
}
19 changes: 19 additions & 0 deletions TinderApp.Library/AuthRequest.cs
@@ -0,0 +1,19 @@
using System.Threading.Tasks;
using TinderApp.Lib.API;

namespace TinderApp.Lib
{
public class AuthRequest
{
public string facebook_id { get; set; }

public string facebook_token { get; set; }

public async Task<AuthResponse> Send()
{
AuthResponse response = await Client.Post<AuthResponse>("auth", this);
Client.AuthToken = response.token;
return response;
}
}
}
13 changes: 13 additions & 0 deletions TinderApp.Library/AuthResponse.cs
@@ -0,0 +1,13 @@
namespace TinderApp.Lib
{
public class AuthResponse
{
public Globals globals { get; set; }

public string token { get; set; }

public User user { get; set; }

public Versions versions { get; set; }
}
}
15 changes: 15 additions & 0 deletions TinderApp.Library/BioUpdate.cs
@@ -0,0 +1,15 @@
using System.Threading.Tasks;
using TinderApp.Lib.API;

namespace TinderApp.Library
{
public class BioUpdate
{
public string Bio { get; set; }

public async Task SaveProfile()
{
await Client.Post("profile", this);
}
}
}
34 changes: 34 additions & 0 deletions TinderApp.Library/ConsentManager.cs
@@ -0,0 +1,34 @@
using System;

namespace TinderApp.Library
{
public class Consent
{
public Boolean IsConsented { get; set; }
}

public class ConsentManager
{
public static Boolean HasConsented
{
get
{
try
{
return Coding4Fun.Toolkit.Storage.Serializer.Open<Consent>("HasConsented").IsConsented;
}
catch
{
return false;
}
}
set
{
if (value)
{
Coding4Fun.Toolkit.Storage.Serializer.Save<Consent>("HasConsented", new Consent() { IsConsented = true });
}
}
}
}
}
20 changes: 20 additions & 0 deletions TinderApp.Library/Converters/BoolToVisibilityConverter.cs
@@ -0,0 +1,20 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace TinderApp.Library.Converters
{
public class BoolToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? Visibility.Visible : Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

0 comments on commit 9404ea4

Please sign in to comment.