Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
FrayxRulez committed Feb 28, 2018
2 parents 0fe8dfa + 0d922fc commit 923e1e1
Show file tree
Hide file tree
Showing 175 changed files with 95,467 additions and 95,359 deletions.
2 changes: 1 addition & 1 deletion Unigram/Unigram/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ private async void OnStartSync(CoreDispatcher dispatcher)
// current.SystemGroupKind = JumpListSystemGroupKind.None;
// current.Items.Clear();

// var cloud = JumpListItem.CreateWithArguments(string.Format("from_id={0}", SettingsHelper.UserId), Strings.Android.SavedMessages);
// var cloud = JumpListItem.CreateWithArguments(string.Format("from_id={0}", SettingsHelper.UserId), Strings.Resources.SavedMessages);
// cloud.Logo = new Uri("ms-appx:///Assets/JumpList/SavedMessages/SavedMessages.png");

// current.Items.Add(cloud);
Expand Down
2 changes: 1 addition & 1 deletion Unigram/Unigram/Common/Locale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static class Locale

static Locale()
{
_loader = ResourceLoader.GetForViewIndependentUse("Android");
_loader = ResourceLoader.GetForViewIndependentUse("Resources");

AddRules(new String[]{"bem", "brx", "da", "de", "el", "en", "eo", "es", "et", "fi", "fo", "gl", "he", "iw", "it", "nb",
"nl", "nn", "no", "sv", "af", "bg", "bn", "ca", "eu", "fur", "fy", "gu", "ha", "is", "ku",
Expand Down
34 changes: 17 additions & 17 deletions Unigram/Unigram/Common/MessageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedE
}
#endregion

private static bool IsAnyCharacterRightToLeft(string s)
public static bool IsAnyCharacterRightToLeft(string s)
{
//if (s.Length > 2)
//{
Expand Down Expand Up @@ -316,20 +316,20 @@ public static async void NavigateToShare(string text, bool hasUrl)
await ForwardView.GetForCurrentView().ShowAsync(text, hasUrl);
}

public static async void NavigateToSocks(IProtoService protoService, string server, int port, string user, string pass)
public static async void NavigateToSocks(IProtoService protoService, string server, int port, string username, string password)
{
var userText = user != null ? string.Format($"{Strings.Android.UseProxyUsername}: {user}\n", user) : string.Empty;
var passText = pass != null ? string.Format($"{Strings.Android.UseProxyPassword}: {pass}\n", pass) : string.Empty;
var confirm = await TLMessageDialog.ShowAsync($"{Strings.Android.EnableProxyAlert}\n\n{Strings.Android.UseProxyAddress}: {server}\n{Strings.Android.UseProxyPort}: {port}\n{userText}{passText}\n{Strings.Android.EnableProxyAlert2}", Strings.Android.Proxy, Strings.Android.ConnectingToProxyEnable, Strings.Android.Cancel);
var userText = username != null ? string.Format($"{Strings.Resources.UseProxyUsername}: {username}\n", username) : string.Empty;
var passText = password != null ? string.Format($"{Strings.Resources.UseProxyPassword}: {password}\n", password) : string.Empty;
var confirm = await TLMessageDialog.ShowAsync($"{Strings.Resources.EnableProxyAlert}\n\n{Strings.Resources.UseProxyAddress}: {server}\n{Strings.Resources.UseProxyPort}: {port}\n{userText}{passText}\n{Strings.Resources.EnableProxyAlert2}", Strings.Resources.Proxy, Strings.Resources.ConnectingToProxyEnable, Strings.Resources.Cancel);
if (confirm == ContentDialogResult.Primary)
{
SettingsHelper.ProxyServer = server;
SettingsHelper.ProxyServer = server ?? string.Empty;
SettingsHelper.ProxyPort = port;
SettingsHelper.ProxyUsername = user;
SettingsHelper.ProxyPassword = pass;
SettingsHelper.ProxyUsername = username ?? string.Empty;
SettingsHelper.ProxyPassword = password ?? string.Empty;
SettingsHelper.IsProxyEnabled = true;

protoService.Send(new SetProxy(new ProxySocks5(server, port, user, pass)));
protoService.Send(new SetProxy(new ProxySocks5(server, port, username, password)));
}
}

Expand Down Expand Up @@ -431,7 +431,7 @@ public static async void NavigateToInviteLink(IProtoService protoService, INavig
var import = await protoService.SendAsync(new JoinChatByInviteLink(link));
if (import is Ok)
{
await TLMessageDialog.ShowAsync("Joined", Strings.Android.AppName, Strings.Android.OK);
await TLMessageDialog.ShowAsync("Joined", Strings.Resources.AppName, Strings.Resources.OK);
}
else if (import is Error error)
{
Expand All @@ -442,17 +442,17 @@ public static async void NavigateToInviteLink(IProtoService protoService, INavig
}
if (error.TypeEquals(TLErrorType.INVITE_HASH_EMPTY) || error.TypeEquals(TLErrorType.INVITE_HASH_INVALID) || error.TypeEquals(TLErrorType.INVITE_HASH_EXPIRED))
{
//MessageBox.Show(Strings.Resources.GroupNotExistsError, Strings.Resources.Error, 0);
//MessageBox.Show(Strings.Additional.GroupNotExistsError, Strings.Additional.Error, 0);
return;
}
else if (error.TypeEquals(TLErrorType.USERS_TOO_MUCH))
{
//MessageBox.Show(Strings.Resources.UsersTooMuch, Strings.Resources.Error, 0);
//MessageBox.Show(Strings.Additional.UsersTooMuch, Strings.Additional.Error, 0);
return;
}
else if (error.TypeEquals(TLErrorType.BOTS_TOO_MUCH))
{
//MessageBox.Show(Strings.Resources.BotsTooMuch, Strings.Resources.Error, 0);
//MessageBox.Show(Strings.Additional.BotsTooMuch, Strings.Additional.Error, 0);
return;
}
else if (error.TypeEquals(TLErrorType.USER_ALREADY_PARTICIPANT))
Expand All @@ -474,7 +474,7 @@ public static async void NavigateToInviteLink(IProtoService protoService, INavig
}
if (error.TypeEquals(TLErrorType.INVITE_HASH_EMPTY) || error.TypeEquals(TLErrorType.INVITE_HASH_INVALID) || error.TypeEquals(TLErrorType.INVITE_HASH_EXPIRED))
{
//MessageBox.Show(Strings.Resources.GroupNotExistsError, Strings.Resources.Error, 0);
//MessageBox.Show(Strings.Additional.GroupNotExistsError, Strings.Additional.Error, 0);
await TLMessageDialog.ShowAsync("This invite link is broken or has expired.", "Warning", "OK");
return;
}
Expand Down Expand Up @@ -559,7 +559,7 @@ public static void Hyperlink_ContextRequested(UIElement sender, ContextRequested
{
var link = text.SelectedText;

var copy = new MenuFlyoutItem { Text = Strings.Android.Copy, DataContext = link };
var copy = new MenuFlyoutItem { Text = Strings.Resources.Copy, DataContext = link };

copy.Click += LinkCopy_Click;

Expand All @@ -583,8 +583,8 @@ public static void Hyperlink_ContextRequested(UIElement sender, ContextRequested
return;
}

var open = new MenuFlyoutItem { Text = Strings.Android.Open, DataContext = link };
var copy = new MenuFlyoutItem { Text = Strings.Android.Copy, DataContext = link };
var open = new MenuFlyoutItem { Text = Strings.Resources.Open, DataContext = link };
var copy = new MenuFlyoutItem { Text = Strings.Resources.Copy, DataContext = link };

open.Click += LinkOpen_Click;
copy.Click += LinkCopy_Click;
Expand Down
4 changes: 2 additions & 2 deletions Unigram/Unigram/Common/TdExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public static string GetTitle(this Audio audio)
}
else
{
return $"{performer ?? Strings.Android.AudioUnknownArtist} - {title ?? Strings.Android.AudioUnknownTitle}";
return $"{performer ?? Strings.Resources.AudioUnknownArtist} - {title ?? Strings.Resources.AudioUnknownTitle}";
}
}

Expand Down Expand Up @@ -504,7 +504,7 @@ public static string GetFullName(this User user)
{
if (user.Type is UserTypeDeleted)
{
return Strings.Android.HiddenName;
return Strings.Resources.HiddenName;
}

return string.IsNullOrEmpty(user.LastName) ? user.FirstName : $"{user.FirstName} {user.LastName}";
Expand Down
68 changes: 38 additions & 30 deletions Unigram/Unigram/Common/Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,51 +22,59 @@ public class Theme : ResourceDictionary

public Theme()
{
isolatedStore = ApplicationData.Current.LocalSettings.CreateContainer("Theme", ApplicationDataCreateDisposition.Always);
Current = this;
Update();
try
{
isolatedStore = ApplicationData.Current.LocalSettings.CreateContainer("Theme", ApplicationDataCreateDisposition.Always);
Current = this;
Update();

this.Add("MessageServiceForegroundBrush", GetBrushOrDefault("MessageServiceForegroundBrush", Colors.White));
this.Add("MessageServiceBackgroundBrush", GetBrushOrDefault("MessageServiceBackgroundBrush", Color.FromArgb(0x66, 0x7A, 0x8A, 0x96)));
this.Add("MessageServiceBackgroundPressedBrush", GetBrushOrDefault("MessageServiceBackgroundPressedBrush", Color.FromArgb(0x88, 0x7A, 0x8A, 0x96)));
this.Add("MessageServiceForegroundBrush", GetBrushOrDefault("MessageServiceForegroundBrush", Colors.White));
this.Add("MessageServiceBackgroundBrush", GetBrushOrDefault("MessageServiceBackgroundBrush", Color.FromArgb(0x66, 0x7A, 0x8A, 0x96)));
this.Add("MessageServiceBackgroundPressedBrush", GetBrushOrDefault("MessageServiceBackgroundPressedBrush", Color.FromArgb(0x88, 0x7A, 0x8A, 0x96)));

this.Add("MessageFontSize", GetValueOrDefault("MessageFontSize", 15d));
this.Add("MessageFontSize", GetValueOrDefault("MessageFontSize", 15d));
}
catch { }
}

public void Update()
{
var accent = App.Current.Resources.MergedDictionaries.FirstOrDefault(x => x.Source.AbsoluteUri.EndsWith("Accent.xaml"));
if (accent == null)
{
return;
}

var fileName = FileUtils.GetFileName("colors.palette");
if (File.Exists(fileName))
try
{
var text = File.ReadAllText(fileName);
var accent = App.Current.Resources.MergedDictionaries.FirstOrDefault(x => x.Source.AbsoluteUri.EndsWith("Accent.xaml"));
if (accent == null)
{
return;
}

try
var fileName = FileUtils.GetFileName("colors.palette");
if (File.Exists(fileName))
{
var dictionary = XamlReader.Load(text) as ResourceDictionary;
if (dictionary == null)
var text = File.ReadAllText(fileName);

try
{
return;
var dictionary = XamlReader.Load(text) as ResourceDictionary;
if (dictionary == null)
{
return;
}

accent.MergedDictionaries.Clear();
accent.MergedDictionaries.Add(dictionary);
}
catch
{
File.Delete(fileName);
Update();
}

accent.MergedDictionaries.Clear();
accent.MergedDictionaries.Add(dictionary);
}
catch
else
{
File.Delete(fileName);
Update();
accent.MergedDictionaries.Clear();
}
}
else
{
accent.MergedDictionaries.Clear();
}
catch { }
}

#region Settings
Expand Down
5 changes: 5 additions & 0 deletions Unigram/Unigram/Common/UnigramNavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public UnigramNavigationService(IProtoService protoService, Frame frame)

public async void NavigateToChat(Chat chat, long? message = null, string accessToken = null)
{
if (chat == null)
{
return;
}

if (chat.Type is ChatTypePrivate privata)
{
var user = _protoService.GetUser(privata.UserId);
Expand Down
2 changes: 1 addition & 1 deletion Unigram/Unigram/Common/XamlResourceLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class XamlResourceLoader : CustomXamlResourceLoader

public XamlResourceLoader()
{
_loader = ResourceLoader.GetForViewIndependentUse("Android");
_loader = ResourceLoader.GetForViewIndependentUse("Resources");
}

protected override object GetResource(string resourceId, string objectType, string propertyName, string propertyType)
Expand Down
Loading

0 comments on commit 923e1e1

Please sign in to comment.