Skip to content

Commit 75855bc

Browse files
committed
Add spell check setting
Fixes #197
1 parent d7eec9c commit 75855bc

File tree

8 files changed

+67
-2
lines changed

8 files changed

+67
-2
lines changed

Signal-Windows.Lib/GlobalSettingsManager.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public enum ShowNotificationTextSettings
2525
}
2626
private const string BlockScreenshots = "BlockScreenshots";
2727
private const string EnableReadReceipts = "EnableReadReceipts";
28+
private const string SpellCheck = "SpellCheck";
2829

2930
private static ApplicationDataContainer localSettings;
3031
private static IReadOnlyDictionary<string, ApplicationDataContainer> Containers
@@ -95,6 +96,18 @@ public static bool EnableReadReceiptsSetting
9596
}
9697
}
9798

99+
public static bool SpellCheckSetting
100+
{
101+
get
102+
{
103+
return GetSetting(Containers[ChatsAndMediaContainer], SpellCheck, true);
104+
}
105+
set
106+
{
107+
Containers[ChatsAndMediaContainer].Values[SpellCheck] = value;
108+
}
109+
}
110+
98111
private static T GetSetting<T>(ApplicationDataContainer container, string key, T defaultValue)
99112
{
100113
if (container.Values.ContainsKey(key))

Signal-Windows/Controls/Conversation.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
<RowDefinition Height="Auto"/>
128128
</Grid.RowDefinitions>
129129
<local:AddedAttachment Grid.Row="0" Grid.ColumnSpan="2" x:Name="AddedAttachmentDisplay" AllowFocusOnInteraction="False" OnCancelAttachmentButtonClicked="AddedAttachmentDisplay_OnCancelAttachmentButtonClicked"/>
130-
<local:UserInput Grid.Row="1" x:Name="UserInputBar" SendMessageVisibility="{x:Bind SendMessageVisible, Mode=OneWay}" BlockedVisibility="{x:Bind Blocked, Mode=OneWay}" SendButtonEnabled="{x:Bind SendButtonEnabled, Mode=OneWay}" OnSendMessageButtonClicked="UserInputBar_OnSendMessageButtonClicked" OnEnterKeyPressed="UserInputBar_OnEnterKeyPressed" OnUnblockButtonClicked="UserInputBar_OnUnblockButtonClicked" OnInputTextBoxTextChanged="UpdateSendButtonIcon"/>
130+
<local:UserInput Grid.Row="1" x:Name="UserInputBar" SendMessageVisibility="{x:Bind SendMessageVisible, Mode=OneWay}" BlockedVisibility="{x:Bind Blocked, Mode=OneWay}" SendButtonEnabled="{x:Bind SendButtonEnabled, Mode=OneWay}" SpellCheckEnabled="{x:Bind SpellCheckEnabled, Mode=OneWay}" OnSendMessageButtonClicked="UserInputBar_OnSendMessageButtonClicked" OnEnterKeyPressed="UserInputBar_OnEnterKeyPressed" OnUnblockButtonClicked="UserInputBar_OnUnblockButtonClicked" OnInputTextBoxTextChanged="UpdateSendButtonIcon"/>
131131
</Grid>
132132
</Grid>
133133
</UserControl>

Signal-Windows/Controls/Conversation.xaml.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ public bool SendMessageVisible
121121
set { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SendMessageVisible))); }
122122
}
123123

124+
private bool spellCheckEnabled;
125+
public bool SpellCheckEnabled
126+
{
127+
get { return spellCheckEnabled; }
128+
set { spellCheckEnabled = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SpellCheckEnabled))); }
129+
}
130+
124131
public Conversation()
125132
{
126133
this.InitializeComponent();
@@ -202,6 +209,7 @@ public void Load(SignalConversation conversation)
202209
UserInputBar.FocusTextBox();
203210
DisposeCurrentThread();
204211
UpdateHeader(conversation);
212+
SpellCheckEnabled = GlobalSettingsManager.SpellCheckSetting;
205213

206214
/*
207215
* When selecting a small (~650 messages) conversation after a bigger (~1800 messages) one,

Signal-Windows/Controls/UserInput.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<ColumnDefinition Width="*"/>
1919
<ColumnDefinition Width="Auto"/>
2020
</Grid.ColumnDefinitions>
21-
<TextBox Grid.Row="1" Grid.Column="0" x:Name="InputTextBox" VerticalAlignment="Center" PlaceholderText="Type a message" BorderBrush="{x:Null}" BorderThickness="0" TextWrapping="Wrap" InputScope="Chat" Visibility="{x:Bind SendMessageVisibility, Mode=OneWay}" MaxLength="2000" KeyDown="InputTextBox_KeyDown" TextChanged="InputTextBox_TextChanged"/>
21+
<TextBox Grid.Row="1" Grid.Column="0" x:Name="InputTextBox" VerticalAlignment="Center" PlaceholderText="Type a message" BorderBrush="{x:Null}" BorderThickness="0" TextWrapping="Wrap" InputScope="Chat" Visibility="{x:Bind SendMessageVisibility, Mode=OneWay}" MaxLength="2000" KeyDown="InputTextBox_KeyDown" TextChanged="InputTextBox_TextChanged" IsSpellCheckEnabled="{x:Bind SpellCheckEnabled, Mode=OneWay}"/>
2222
<Button x:Name="SendMessageButton" Grid.Row="1" Grid.Column="1" VerticalAlignment="Bottom" Width="50" VerticalContentAlignment="Stretch" MinHeight="50" Visibility="{x:Bind SendMessageVisibility, Mode=OneWay}" AllowFocusOnInteraction="False" IsEnabled="{x:Bind SendButtonEnabled, Mode=OneWay}" Click="SendMessageButton_Click" Background="{x:Bind SendButtonBackground}">
2323
<SymbolIcon x:Name="SendMessageButtonSymbol" Symbol="Attach"/>
2424
</Button>

Signal-Windows/Controls/UserInput.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ public Visibility SendMessageVisibility
8989
public static readonly DependencyProperty SendMessageVisibilityProperty =
9090
DependencyProperty.Register("SendMessageVisibility", typeof(Visibility), typeof(UserInput), null);
9191

92+
public bool SpellCheckEnabled
93+
{
94+
get { return (bool)GetValue(SpellCheckEnabledProperty); }
95+
set { SetValue(SpellCheckEnabledProperty, value); }
96+
}
97+
98+
// Using a DependencyProperty as the backing store for SendMessageVisibility. This enables animation, styling, binding, etc...
99+
public static readonly DependencyProperty SpellCheckEnabledProperty =
100+
DependencyProperty.Register("SpellCheckEnabled", typeof(bool), typeof(UserInput), null);
101+
92102
private void SendMessageButton_Click(object sender, RoutedEventArgs e)
93103
{
94104
OnSendMessageButtonClicked?.Invoke();

Signal-Windows/ViewModels/ChatsAndMediaSettingsPageViewModel.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,27 @@
44
using System.Text;
55
using System.Threading.Tasks;
66
using GalaSoft.MvvmLight;
7+
using Signal_Windows.Lib;
78

89
namespace Signal_Windows.ViewModels
910
{
1011
public class ChatsAndMediaSettingsPageViewModel : ViewModelBase
1112
{
13+
private bool spellCheck;
14+
public bool SpellCheck
15+
{
16+
get { return spellCheck; }
17+
set { spellCheck = value; RaisePropertyChanged(nameof(SpellCheck)); }
18+
}
19+
20+
public void OnNavigatedTo()
21+
{
22+
SpellCheck = GlobalSettingsManager.SpellCheckSetting;
23+
}
24+
25+
public void SpellCheckToggleSwitch_Toggled(bool value)
26+
{
27+
GlobalSettingsManager.SpellCheckSetting = value;
28+
}
1229
}
1330
}

Signal-Windows/Views/ChatsAndMediaSettingsPage.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<Grid.RowDefinitions>
2121
<RowDefinition Height="Auto"/>
2222
<RowDefinition Height="Auto"/>
23+
<RowDefinition Height="Auto"/>
2324
</Grid.RowDefinitions>
2425
<Grid>
2526
<Grid.RowDefinitions>
@@ -70,6 +71,14 @@
7071
</StackPanel>
7172
<Button Grid.Row="3" Content="Trim all conversations now" Margin="0,8,0,0" IsEnabled="False"/>
7273
</Grid>
74+
<Grid Grid.Row="2" Margin="0,16,0,0">
75+
<Grid.RowDefinitions>
76+
<RowDefinition Height="Auto"/>
77+
<RowDefinition/>
78+
</Grid.RowDefinitions>
79+
<TextBlock Text="Spell Check" Style="{StaticResource SubtitleTextBlockStyle}"/>
80+
<ToggleSwitch x:Name="SpellCheckToggleSwitch" Grid.Row="1" Margin="0,8" IsOn="{x:Bind Vm.SpellCheck, Mode=TwoWay}" Toggled="SpellCheckToggleSwitch_Toggled"/>
81+
</Grid>
7382
</Grid>
7483
</ScrollViewer>
7584
</Grid>

Signal-Windows/Views/ChatsAndMediaSettingsPage.xaml.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using System.Runtime.InteropServices.WindowsRuntime;
6+
using Signal_Windows.Lib;
67
using Signal_Windows.ViewModels;
78
using Windows.Foundation;
89
using Windows.Foundation.Collections;
@@ -37,6 +38,7 @@ public ChatsAndMediaSettingsPageViewModel Vm
3738
protected override void OnNavigatedTo(NavigationEventArgs e)
3839
{
3940
Utils.EnableBackButton(BackButton_Click);
41+
Vm.OnNavigatedTo();
4042
}
4143

4244
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
@@ -49,5 +51,11 @@ private void BackButton_Click(object sender, BackRequestedEventArgs e)
4951
Frame.GoBack();
5052
e.Handled = true;
5153
}
54+
55+
private void SpellCheckToggleSwitch_Toggled(object sender, RoutedEventArgs e)
56+
{
57+
var toggleSwitch = sender as ToggleSwitch;
58+
Vm.SpellCheckToggleSwitch_Toggled(toggleSwitch.IsOn);
59+
}
5260
}
5361
}

0 commit comments

Comments
 (0)