-
-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ability to change chat background, other fixes and improvements
- Loading branch information
1 parent
c9ed0ec
commit 20eee33
Showing
19 changed files
with
415 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.UI; | ||
|
||
namespace Telegram.Api.TL | ||
{ | ||
public partial class TLWallPaperSolid | ||
{ | ||
private Color? _backgroundColor; | ||
public Color BackgroundColor | ||
{ | ||
get | ||
{ | ||
if (_backgroundColor == null) | ||
_backgroundColor = Windows.UI.Color.FromArgb(0xFF, | ||
(byte)((BgColor >> 16) & 0xFF), | ||
(byte)((BgColor >> 8) & 0xFF), | ||
(byte)((BgColor & 0xFF))); | ||
|
||
return _backgroundColor.Value; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Telegram.Api.Aggregator; | ||
using Telegram.Api.Helpers; | ||
using Unigram.Common; | ||
using Unigram.Views; | ||
using Windows.Storage; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Media.Imaging; | ||
using Windows.UI.Xaml.Shapes; | ||
|
||
namespace Unigram.Controls | ||
{ | ||
public class DialogBackgroundPresenter : ContentControl, IHandle<string> | ||
{ | ||
private DialogBackground _defaultBackground; | ||
private Image _imageBackground; | ||
private Rectangle _colorBackground; | ||
|
||
public DialogBackgroundPresenter() | ||
{ | ||
Reload(); | ||
UnigramContainer.Current.ResolveType<ITelegramEventAggregator>().Subscribe(this); | ||
} | ||
|
||
public void Handle(string message) | ||
{ | ||
if (message.Equals("Wallpaper")) | ||
{ | ||
Reload(); | ||
} | ||
} | ||
|
||
private async void Reload() | ||
{ | ||
var selectedBackground = ApplicationSettings.Current.SelectedBackground; | ||
var selectedColor = ApplicationSettings.Current.SelectedColor; | ||
|
||
if (selectedColor == 0) | ||
{ | ||
if (selectedBackground != 1000001) | ||
{ | ||
var item = await ApplicationData.Current.LocalFolder.TryGetItemAsync(FileUtils.GetTempFilePath("wallpaper.jpg")); | ||
if (item is StorageFile file) | ||
{ | ||
if (_imageBackground == null) | ||
_imageBackground = new Image { Stretch = Stretch.UniformToFill }; | ||
|
||
using (var stream = await file.OpenReadAsync()) | ||
{ | ||
var bitmap = new BitmapImage(); | ||
await bitmap.SetSourceAsync(stream); | ||
_imageBackground.Source = bitmap; | ||
} | ||
|
||
Content = _imageBackground; | ||
} | ||
} | ||
else | ||
{ | ||
if (_defaultBackground == null) | ||
_defaultBackground = new DialogBackground(); | ||
|
||
Content = _defaultBackground; | ||
} | ||
} | ||
else | ||
{ | ||
if (_colorBackground == null) | ||
_colorBackground = new Rectangle(); | ||
|
||
_colorBackground.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(0xFF, | ||
(byte)((selectedColor >> 16) & 0xFF), | ||
(byte)((selectedColor >> 8) & 0xFF), | ||
(byte)((selectedColor & 0xFF)))); | ||
|
||
Content = _colorBackground; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.