Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
Hiding the vibrate setting if vibration is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
COM8 committed Aug 13, 2019
1 parent 91da54e commit f82bd94
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 7 deletions.
4 changes: 1 addition & 3 deletions Data_Manager2/Classes/Toast/ToastHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.Toolkit.Uwp.Notifications;
using Shared.Classes;
using Windows.Data.Xml.Dom;
using Windows.Foundation.Metadata;
using Windows.Phone.Devices.Notification;
using Windows.UI.Notifications;

Expand Down Expand Up @@ -229,9 +228,8 @@ private static void popToastReduced()
lastVibration = DateTime.Now;

// Vibrate:
if (ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice") && !Settings.getSettingBoolean(SettingsConsts.DISABLE_VIBRATION_FOR_NEW_CHAT_MESSAGES))
if (DeviceFamilyHelper.SupportsVibration() && !Settings.getSettingBoolean(SettingsConsts.DISABLE_VIBRATION_FOR_NEW_CHAT_MESSAGES))
{

VibrationDevice.GetDefault().Vibrate(VIBRATE_TS);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using Windows.System.Profile;
using Windows.Foundation.Metadata;
using Windows.System.Profile;
using Windows.UI.ViewManagement;

namespace UWPX_UI_Context.Classes
namespace Shared.Classes
{
public enum DeviceFamilyType
{
Expand Down Expand Up @@ -88,6 +89,15 @@ public static bool ShouldShowBackButton()
|| type == DeviceFamilyType.IoT;
}

/// <summary>
/// Checks whether the device supports vibration and has the specific APIs available.
/// </summary>
/// <returns>True if the device has a vibration motor and the required APIs available.</returns>
public static bool SupportsVibration()
{
return ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice");
}

#endregion
//--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
#region --Misc Methods (Public)--
Expand Down
1 change: 1 addition & 0 deletions Shared/Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<Compile Include="Classes\Collections\ITimedEntry.cs" />
<Compile Include="Classes\Collections\TimedListEntry.cs" />
<Compile Include="Classes\Collections\TSTimedList.cs" />
<Compile Include="Classes\DeviceFamilyHelper.cs" />
<Compile Include="Classes\Network\AbstractDownloadableObject.cs" />
<Compile Include="Classes\Network\DownloadError.cs" />
<Compile Include="Classes\Network\DownloadHandler.cs" />
Expand Down
1 change: 1 addition & 0 deletions UWPX_UI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Data_Manager2.Classes.Toast;
using Logging;
using Microsoft.AppCenter.Push;
using Shared.Classes;
using UWPX_UI.Dialogs;
using UWPX_UI.Pages;
using UWPX_UI_Context.Classes;
Expand Down
1 change: 1 addition & 0 deletions UWPX_UI/Controls/CustomSettingsTitleBarControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Shared.Classes;
using UWPX_UI.Pages;
using UWPX_UI.Pages.Settings;
using UWPX_UI_Context.Classes;
Expand Down
1 change: 1 addition & 0 deletions UWPX_UI/Controls/CustomTitleBarControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Shared.Classes;
using UWPX_UI.Controls.Toolkit.MasterDetailsView;
using UWPX_UI.Pages;
using UWPX_UI_Context.Classes;
Expand Down
3 changes: 2 additions & 1 deletion UWPX_UI/Pages/Settings/ChatSettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
IsOn="{x:Bind VIEW_MODEL.MODEL.AdvancedChatMessageProcessing, Mode=TwoWay}"/>
<ToggleSwitch x:Name="enableVibrateForNewMessage_tgls"
Header="Vibrate device for new messages"
IsOn="{x:Bind VIEW_MODEL.MODEL.VibrateForNewChatMessages, Mode=TwoWay}"/>
IsOn="{x:Bind VIEW_MODEL.MODEL.VibrateForNewChatMessages, Mode=TwoWay}"
Visibility="{x:Bind VIEW_MODEL.MODEL.VibrationSupported, Mode=TwoWay, Converter={StaticResource BoolVisibilityValueConverter}}"/>
<ToggleSwitch x:Name="enablePlaySoundForNewMessage_tgls"
Header="Play sound for new messages"
IsOn="{x:Bind VIEW_MODEL.MODEL.PlaySoundForNewChatMessages, Mode=TwoWay}"/>
Expand Down
1 change: 1 addition & 0 deletions UWPX_UI/Pages/Settings/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.ObjectModel;
using System.Text;
using Microsoft.Toolkit.Uwp.UI.Animations;
using Shared.Classes;
using UWPX_UI_Context.Classes;
using UWPX_UI_Context.Classes.DataContext.Pages;
using UWPX_UI_Context.Classes.DataTemplates;
Expand Down
1 change: 1 addition & 0 deletions UWPX_UI_Context/Classes/AppUpdateHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Data_Manager2.Classes.DBTables;
using Data_Manager2.Classes.DBTables.Omemo;
using Logging;
using Shared.Classes;
using Shared.Classes.SQLite;
using Windows.ApplicationModel;
using XMPP_API.Classes.Network;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public int ShowAccountColor
get => _ShowAccountColor;
set => SetIntProperty(ref _ShowAccountColor, value, SettingsConsts.CHAT_SHOW_ACCOUNT_COLOR);
}
private bool _VibrationSupported;
public bool VibrationSupported
{
get => _VibrationSupported;
set => SetProperty(ref _VibrationSupported, value);
}

#endregion
//--------------------------------------------------------Constructor:----------------------------------------------------------------\\
Expand Down Expand Up @@ -123,6 +129,9 @@ private void LoadSettings()

// OMEMO:
EnableOmemoForNewChats = Settings.getSettingBoolean(SettingsConsts.ENABLE_OMEMO_BY_DEFAULT_FOR_NEW_CHATS);

// Misc:
VibrationSupported = DeviceFamilyHelper.SupportsVibration();
}

private bool SetBoolProperty(ref bool storage, bool value, string settingsToken, [CallerMemberName] string propertyName = null)
Expand Down
1 change: 0 additions & 1 deletion UWPX_UI_Context/UWPX_UI_Context.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@
<Compile Include="Classes\DataTemplates\SettingsPageButtonDataTemplate.cs" />
<Compile Include="Classes\DataTemplates\UintDataTemplate.cs" />
<Compile Include="Classes\DataTemplates\XMPPClientDataTemplate.cs" />
<Compile Include="Classes\DeviceFamilyHelper.cs" />
<Compile Include="Classes\Events\NavigatedToContactInfoPageEventArgs.cs" />
<Compile Include="Classes\Events\OnErrorEventArgs.cs" />
<Compile Include="Classes\Localisation.cs" />
Expand Down

0 comments on commit f82bd94

Please sign in to comment.