combine projects into one
This commit is contained in:
12
Gallery.Share/Views/GalleryItemPage.xaml
Normal file
12
Gallery.Share/Views/GalleryItemPage.xaml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<ui:AdaptedPage
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:ui="clr-namespace:Gallery.Resources.UI"
|
||||
x:Class="Gallery.Views.GalleryItemPage"
|
||||
x:Name="galleryItemPage"
|
||||
BindingContext="{x:Reference galleryItemPage}">
|
||||
<ContentPage.Content>
|
||||
|
||||
</ContentPage.Content>
|
||||
</ui:AdaptedPage>
|
15
Gallery.Share/Views/GalleryItemPage.xaml.cs
Normal file
15
Gallery.Share/Views/GalleryItemPage.xaml.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Gallery.Resources.UI;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Gallery.Views
|
||||
{
|
||||
public partial class GalleryItemPage : AdaptedPage
|
||||
{
|
||||
public GalleryItemPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,8 @@
|
||||
x:Class="Gallery.Views.GalleryPage"
|
||||
x:Name="yanderePage"
|
||||
BackgroundColor="{DynamicResource WindowColor}"
|
||||
BindingContext="{x:Reference yanderePage}">
|
||||
BindingContext="{x:Reference yanderePage}"
|
||||
Title="{Binding Source.Name}">
|
||||
<ContentPage.Content>
|
||||
<Grid>
|
||||
<ScrollView x:Name="scrollView" Scrolled="ScrollView_Scrolled"
|
||||
|
38
Gallery.Share/Views/OptionPage.xaml
Normal file
38
Gallery.Share/Views/OptionPage.xaml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<ui:AdaptedPage
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:r="clr-namespace:Gallery.Resources"
|
||||
xmlns:ui="clr-namespace:Gallery.Resources.UI"
|
||||
x:Class="Gallery.Views.OptionPage"
|
||||
x:Name="optionPage"
|
||||
BindingContext="{x:Reference optionPage}"
|
||||
Title="{r:Text Option}">
|
||||
<ContentPage.Content>
|
||||
<TableView Intent="Settings" VerticalOptions="Start"
|
||||
BackgroundColor="{DynamicResource OptionBackColor}">
|
||||
<TableRoot>
|
||||
<TableSection Title="{r:Text About}">
|
||||
<ui:OptionTextCell Title="{r:Text Version}" Detail="{Binding Version}"/>
|
||||
</TableSection>
|
||||
<TableSection Title="{r:Text Gallery}">
|
||||
<ui:OptionEntryCell Title="{r:Text DownloadThreads}"
|
||||
Text="{Binding DownloadThreads, Mode=TwoWay}"
|
||||
Keyboard="Numeric" Placeholder="1~10"/>
|
||||
</TableSection>
|
||||
<TableSection Title="{r:Text Proxy}">
|
||||
<ui:OptionSwitchCell Title="{r:Text Enabled}"
|
||||
IsToggled="{Binding IsProxied, Mode=TwoWay}"/>
|
||||
</TableSection>
|
||||
<TableSection Title="{r:Text Detail}">
|
||||
<ui:OptionEntryCell Title="{r:Text ProxyHost}"
|
||||
Text="{Binding ProxyHost, Mode=TwoWay}"
|
||||
Keyboard="Url" Placeholder="www.example.com"/>
|
||||
<ui:OptionEntryCell Title="{r:Text ProxyPort}"
|
||||
Text="{Binding ProxyPort, Mode=TwoWay}"
|
||||
Keyboard="Numeric" Placeholder="8080"/>
|
||||
</TableSection>
|
||||
</TableRoot>
|
||||
</TableView>
|
||||
</ContentPage.Content>
|
||||
</ui:AdaptedPage>
|
152
Gallery.Share/Views/OptionPage.xaml.cs
Normal file
152
Gallery.Share/Views/OptionPage.xaml.cs
Normal file
@ -0,0 +1,152 @@
|
||||
using System;
|
||||
using Gallery.Resources.UI;
|
||||
using Gallery.Util;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Gallery.Views
|
||||
{
|
||||
public partial class OptionPage : AdaptedPage
|
||||
{
|
||||
public static readonly BindableProperty VersionProperty = BindableProperty.Create(nameof(Version), typeof(string), typeof(OptionPage));
|
||||
|
||||
public string Version
|
||||
{
|
||||
get => (string)GetValue(VersionProperty);
|
||||
set => SetValue(VersionProperty, value);
|
||||
}
|
||||
|
||||
public static readonly BindableProperty DownloadThreadsProperty = BindableProperty.Create(nameof(DownloadThreads), typeof(string), typeof(OptionPage));
|
||||
public static readonly BindableProperty IsProxiedProperty = BindableProperty.Create(nameof(IsProxied), typeof(bool), typeof(OptionPage));
|
||||
public static readonly BindableProperty ProxyHostProperty = BindableProperty.Create(nameof(ProxyHost), typeof(string), typeof(OptionPage));
|
||||
public static readonly BindableProperty ProxyPortProperty = BindableProperty.Create(nameof(ProxyPort), typeof(string), typeof(OptionPage));
|
||||
|
||||
public string DownloadThreads
|
||||
{
|
||||
get => (string)GetValue(DownloadThreadsProperty);
|
||||
set => SetValue(DownloadThreadsProperty, value);
|
||||
}
|
||||
public bool IsProxied
|
||||
{
|
||||
get => (bool)GetValue(IsProxiedProperty);
|
||||
set => SetValue(IsProxiedProperty, value);
|
||||
}
|
||||
public string ProxyHost
|
||||
{
|
||||
get => (string)GetValue(ProxyHostProperty);
|
||||
set => SetValue(ProxyHostProperty, value);
|
||||
}
|
||||
public string ProxyPort
|
||||
{
|
||||
get => (string)GetValue(ProxyPortProperty);
|
||||
set => SetValue(ProxyPortProperty, value);
|
||||
}
|
||||
|
||||
|
||||
public OptionPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
#if OBSOLETE
|
||||
#if __IOS__
|
||||
string version = Foundation.NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleShortVersionString").ToString();
|
||||
int build = int.Parse(Foundation.NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleVersion").ToString());
|
||||
#elif __ANDROID__
|
||||
var context = Android.App.Application.Context;
|
||||
var manager = context.PackageManager;
|
||||
var info = manager.GetPackageInfo(context.PackageName, 0);
|
||||
|
||||
string version = info.VersionName;
|
||||
long build = info.LongVersionCode;
|
||||
#endif
|
||||
Version = $"{version} ({build})";
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
|
||||
Version = $"{AppInfo.VersionString} ({AppInfo.BuildString})";
|
||||
DownloadThreads = Config.DownloadThreads.ToString();
|
||||
var proxy = Config.Proxy;
|
||||
if (proxy != null)
|
||||
{
|
||||
IsProxied = true;
|
||||
ProxyHost = proxy.Address.Host;
|
||||
ProxyPort = proxy.Address.Port.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
IsProxied = false;
|
||||
ProxyHost = Preferences.Get(Config.ProxyHostKey, string.Empty);
|
||||
ProxyPort = Preferences.Get(Config.ProxyPortKey, string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
base.OnDisappearing();
|
||||
|
||||
var proxied = IsProxied;
|
||||
|
||||
if (int.TryParse(DownloadThreads, out int threads) && threads > 0 && threads <= 10 && threads != Config.DownloadThreads)
|
||||
{
|
||||
Preferences.Set(Config.DownloadThreadsKey, threads);
|
||||
Config.DownloadThreads = threads;
|
||||
#if DEBUG
|
||||
Log.Print($"will use {threads} threads to download image");
|
||||
#endif
|
||||
}
|
||||
|
||||
var proxy = Config.Proxy;
|
||||
var h = ProxyHost?.Trim();
|
||||
int.TryParse(ProxyPort, out int pt);
|
||||
if (proxied &&
|
||||
!string.IsNullOrEmpty(h) &&
|
||||
pt > 0 && pt < 65535)
|
||||
{
|
||||
if (proxy == null ||
|
||||
proxy.Address.Host != h ||
|
||||
proxy.Address.Port != pt)
|
||||
{
|
||||
Preferences.Set(Config.IsProxiedKey, true);
|
||||
Preferences.Set(Config.ProxyHostKey, h);
|
||||
Preferences.Set(Config.ProxyPortKey, pt);
|
||||
try
|
||||
{
|
||||
if (h.IndexOf(':') >= 0)
|
||||
{
|
||||
h = $"[{h}]";
|
||||
}
|
||||
var uri = new Uri($"http://{h}:{pt}");
|
||||
Config.Proxy = new System.Net.WebProxy(uri);
|
||||
#if DEBUG
|
||||
Log.Print($"set proxy to: {uri}");
|
||||
#endif
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("on.disappearing", $"failed to parse proxy: {h}:{pt}, error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Preferences.Set(Config.IsProxiedKey, false);
|
||||
Preferences.Set(Config.ProxyHostKey, h);
|
||||
if (pt > 0)
|
||||
{
|
||||
Preferences.Set(Config.ProxyPortKey, pt);
|
||||
}
|
||||
if (proxy != null)
|
||||
{
|
||||
Config.Proxy = null;
|
||||
#if DEBUG
|
||||
Log.Print("clear proxy");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user