move PCL project to shared

This commit is contained in:
2020-05-11 00:44:12 +08:00
parent 8b891cc692
commit 98007c98e4
11 changed files with 191 additions and 122 deletions

View File

@@ -1,9 +0,0 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "<Pending>")]
[assembly: SuppressMessage("Style", "IDE0066:Convert switch statement to expression", Justification = "<Pending>")]

View File

@@ -1,32 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.6.0.726" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.3.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="UI\" />
<Folder Include="Utils\" />
<Folder Include="UI\Theme\" />
<Folder Include="Resources\" />
<Folder Include="Resources\Languages\" />
<Folder Include="Illust\" />
</ItemGroup>
<ItemGroup>
<None Remove="Resources\Languages\zh-CN.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Languages\zh-CN.xml" />
</ItemGroup>
</Project>

102
Pixiview/Pixiview.projitems Normal file
View File

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>{57C27E64-049B-4EE8-9308-BCAFE329E8E8}</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Pixiview</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)AppShell.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)OptionPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Illust\FavoritesPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Illust\MainPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Illust\RankingPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Illust\RecommendsPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Illust\UserIllustPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Illust\ViewIllustPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Resources\Languages\zh-CN.xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)App.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AppShell.xaml.cs">
<DependentUpon>AppShell.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)AssemblyInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)OptionPage.xaml.cs">
<DependentUpon>OptionPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Illust\FavoritesPage.xaml.cs">
<DependentUpon>FavoritesPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Illust\IllustCollectionPage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Illust\MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Illust\RankingPage.xaml.cs">
<DependentUpon>RankingPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Illust\RecommendsPage.xaml.cs">
<DependentUpon>RecommendsPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Illust\UserIllustPage.xaml.cs">
<DependentUpon>UserIllustPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Illust\ViewIllustPage.xaml.cs">
<DependentUpon>ViewIllustPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Utils\Converters.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\Extensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\IEnvironmentService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\IFileStore.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\IllustData.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\LongPressEffect.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\Stores.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Resources\PlatformCulture.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Resources\ResourceHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\AdaptedPage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\CardView.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\CircleUIs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\FlowLayout.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\OptionCell.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\SegmentedControl.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\StyleDefinition.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\Theme\DarkTheme.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\Theme\LightTheme.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\Theme\ThemeBase.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Illust\" />
<Folder Include="$(MSBuildThisFileDirectory)Utils\" />
<Folder Include="$(MSBuildThisFileDirectory)Resources\" />
<Folder Include="$(MSBuildThisFileDirectory)Resources\Languages\" />
<Folder Include="$(MSBuildThisFileDirectory)UI\" />
<Folder Include="$(MSBuildThisFileDirectory)UI\Theme\" />
</ItemGroup>
</Project>

11
Pixiview/Pixiview.shproj Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{57C27E64-049B-4EE8-9308-BCAFE329E8E8}</ProjectGuid>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<Import Project="Pixiview.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Xml.Linq;
using System.Xml;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
@@ -65,29 +65,41 @@ namespace Pixiview.Resources
{
try
{
#if __IOS__
var langId = $"Pixiview.iOS.Resources.Languages.{lang.Language}.xml";
var langCodeId = $"Pixiview.iOS.Resources.Languages.{lang.LanguageCode}.xml";
#else
var langId = $"Pixiview.Android.Resources.Languages.{lang.Language}.xml";
var langCodeId = $"Pixiview.Android.Resources.Languages.{lang.LanguageCode}.xml";
#endif
var assembly = IntrospectionExtensions.GetTypeInfo(typeof(LanguageResource)).Assembly;
var names = assembly.GetManifestResourceNames();
var name = names.FirstOrDefault(n
=> string.Equals(n, $"Pixiview.Resources.Languages.{lang.Language}.xml", StringComparison.OrdinalIgnoreCase)
|| string.Equals(n, $"Pixiview.Resources.Languages.{lang.LanguageCode}.xml", StringComparison.OrdinalIgnoreCase));
=> string.Equals(n, langId, StringComparison.OrdinalIgnoreCase)
|| string.Equals(n, langCodeId, StringComparison.OrdinalIgnoreCase));
if (name == null)
{
name = "Pixiview.Resources.Languages.zh-CN.xml";
#if __IOS__
name = "Pixiview.iOS.Resources.Languages.zh-CN.xml";
#else
name = "Pixiview.Android.Resources.Languages.zh-CN.xml";
#endif
}
XDocument xml;
var xml = new XmlDocument();
using (var stream = assembly.GetManifestResourceStream(name))
{
xml = XDocument.Load(stream);
xml.Load(stream);
}
strings = new Dictionary<string, string>();
foreach (var ele in xml.Root.Elements())
foreach (XmlElement ele in xml.DocumentElement) // .Root.Elements()
{
strings[ele.Name.LocalName] = ele.Value;
strings[ele.Name] = ele.InnerText; // .LocalName Value
}
}
catch
catch (Exception ex)
{
// load failed
App.DebugError("language.ctor", $"failed to load xml resource: {ex.Message}");
}
}
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Xamarin.Forms;
namespace Pixiview.UI
@@ -48,7 +47,7 @@ namespace Pixiview.UI
public event EventHandler<ValueChangedEventArgs> ValueChanged;
[EditorBrowsable(EditorBrowsableState.Never)]
//[EditorBrowsable(EditorBrowsableState.Never)]
public void SendValueChanged()
{
ValueChanged?.Invoke(this, new ValueChangedEventArgs { NewValue = SelectedSegmentIndex });

View File

@@ -57,57 +57,54 @@ namespace Pixiview.UI
{
return _isFullscreenDevice.Value;
}
if (Device.RuntimePlatform == Device.iOS)
#if __IOS__
try
{
try
var model = DeviceInfo.Model;
if (model == "iPhone10,3")
{
var model = DeviceInfo.Model;
if (model == "iPhone10,3")
// iPhone X
_isFullscreenDevice = true;
}
else if (model.StartsWith("iPhone"))
{
var vs = model.Substring(6).Split(',');
if (vs.Length == 2 && int.TryParse(vs[0], out int main) && int.TryParse(vs[1], out int sub))
{
// iPhone X
_isFullscreenDevice = true;
// iPhone X/XS/XR or iPhone 11
_isFullscreenDevice = (main == 10 && sub >= 6) || (main > 10);
}
else if (model.StartsWith("iPhone"))
{
var vs = model.Substring(6).Split(',');
if (vs.Length == 2 && int.TryParse(vs[0], out int main) && int.TryParse(vs[1], out int sub))
{
// iPhone X/XS/XR or iPhone 11
_isFullscreenDevice = (main == 10 && sub >= 6) || (main > 10);
}
else
{
_isFullscreenDevice = false;
}
}
else if (model.StartsWith("iPad8,"))
{
// iPad 11-inch or 12.9-inch (3rd+)
_isFullscreenDevice = true;
}
#if DEBUG
else
{
// iPad or Simulator
var name = DeviceInfo.Name;
_isFullscreenDevice = name.StartsWith("iPhone X")
|| name.StartsWith("iPhone 11")
|| name.StartsWith("iPad Pro (11-inch)")
|| name.StartsWith("iPad Pro (12.9-inch) (3rd generation)")
|| name.StartsWith("iPad Pro (12.9-inch) (4th generation)");
_isFullscreenDevice = false;
}
#endif
}
catch (Exception ex)
else if (model.StartsWith("iPad8,"))
{
App.DebugError("device.get", $"failed to get the device model. {ex.Message}");
// iPad 11-inch or 12.9-inch (3rd+)
_isFullscreenDevice = true;
}
#if DEBUG
else
{
// iPad or Simulator
var name = DeviceInfo.Name;
_isFullscreenDevice = name.StartsWith("iPhone X")
|| name.StartsWith("iPhone 11")
|| name.StartsWith("iPad Pro (11-inch)")
|| name.StartsWith("iPad Pro (12.9-inch) (3rd generation)")
|| name.StartsWith("iPad Pro (12.9-inch) (4th generation)");
}
#endif
}
else
catch (Exception ex)
{
// TODO:
_isFullscreenDevice = false;
App.DebugError("device.get", $"failed to get the device model. {ex.Message}");
}
#else
// TODO:
_isFullscreenDevice = false;
#endif
if (_isFullscreenDevice == null)
{
_isFullscreenDevice = false;

View File

@@ -36,7 +36,7 @@ namespace Pixiview.Utils
{
try
{
return Connectivity.NetworkAccess == NetworkAccess.Internet;
return Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.Internet;
}
catch
{