App Permission popup Page Implemented
This commit is contained in:
parent
33ace30e6b
commit
3bb59d6ae4
@ -3,11 +3,66 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="GMCabsDriverAssistantSolution.Views.AppPermissiontSetDialogPage"
|
x:Class="GMCabsDriverAssistantSolution.Views.AppPermissiontSetDialogPage"
|
||||||
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
|
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
|
||||||
Size="300,300">
|
Size="380,380"
|
||||||
<VerticalStackLayout>
|
Color="Transparent">
|
||||||
<Label
|
<Frame BackgroundColor="White" CornerRadius="10">
|
||||||
Text="AppPermissiontSetDialogPage"
|
<StackLayout Orientation="Vertical">
|
||||||
VerticalOptions="Center"
|
<StackLayout x:Name="PermissionAllocationLayout" VerticalOptions="StartAndExpand">
|
||||||
HorizontalOptions="Center" />
|
<Label Text="To get reliable bookings notifications you need to change some settings for the Driver App"
|
||||||
</VerticalStackLayout>
|
VerticalTextAlignment="Center"
|
||||||
|
VerticalOptions="CenterAndExpand"
|
||||||
|
HorizontalOptions="CenterAndExpand"
|
||||||
|
FontSize="20"
|
||||||
|
HorizontalTextAlignment="Center"
|
||||||
|
FontFamily="Bold"/>
|
||||||
|
<StackLayout VerticalOptions="EndAndExpand" Margin="10,2,0,0">
|
||||||
|
<Button Text="Change" Clicked="Permission_Clicked" TextColor="White" FontSize="20" />
|
||||||
|
</StackLayout>
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout x:Name="PermissionLayout" VerticalOptions="StartAndExpand" Orientation="Vertical">
|
||||||
|
<StackLayout x:Name="LocationLayout" Orientation="Vertical" Margin="0,-40,0,0">
|
||||||
|
<Label Text="Location Tracking needs to be set to always"
|
||||||
|
VerticalTextAlignment="Center"
|
||||||
|
VerticalOptions="CenterAndExpand"
|
||||||
|
HorizontalOptions="CenterAndExpand"
|
||||||
|
FontSize="20"
|
||||||
|
HorizontalTextAlignment="Center"
|
||||||
|
FontFamily="Bold"/>
|
||||||
|
<StackLayout VerticalOptions="EndAndExpand" Margin="10,2,0,0">
|
||||||
|
<Button Text="Change" Clicked="Location_Clicked" TextColor="White" FontSize="20" />
|
||||||
|
</StackLayout>
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout x:Name="BatteyOptimisedLayout" Orientation="Vertical" Margin="0,10,0,0">
|
||||||
|
<Label Text="You need to turn off battery optimisation for the Driver App"
|
||||||
|
VerticalTextAlignment="Center"
|
||||||
|
VerticalOptions="CenterAndExpand"
|
||||||
|
HorizontalOptions="CenterAndExpand"
|
||||||
|
FontSize="20"
|
||||||
|
HorizontalTextAlignment="Center"
|
||||||
|
FontFamily="Bold"/>
|
||||||
|
<StackLayout VerticalOptions="EndAndExpand" Margin="10,2,0,0">
|
||||||
|
<!--<Button Text="Change" Clicked="Batteryoptimisation_Clicked" TextColor="White" FontSize="20" />-->
|
||||||
|
<Button Text="Change" Clicked="Batteryoptimisation_Clicked" TextColor="White" FontSize="20"></Button>
|
||||||
|
</StackLayout>
|
||||||
|
</StackLayout>
|
||||||
|
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout x:Name="LocationWarningLayout" VerticalOptions="StartAndExpand">
|
||||||
|
<Label Text="If you ignore location tracking then bookings will be disabled"
|
||||||
|
VerticalTextAlignment="Center"
|
||||||
|
VerticalOptions="CenterAndExpand"
|
||||||
|
HorizontalOptions="CenterAndExpand"
|
||||||
|
FontSize="20"
|
||||||
|
HorizontalTextAlignment="Center"
|
||||||
|
FontFamily="Bold"/>
|
||||||
|
<StackLayout VerticalOptions="EndAndExpand" Margin="10,2,0,0">
|
||||||
|
<Button Text="Change" Clicked="ChangeLocation_Clicked" TextColor="White" FontSize="20" />
|
||||||
|
</StackLayout>
|
||||||
|
</StackLayout>
|
||||||
|
|
||||||
|
<StackLayout VerticalOptions="EndAndExpand" Margin="10,10,0,10">
|
||||||
|
<Button Text="Ignore" Clicked="Ignore_Clicked" TextColor="White" FontSize="20" />
|
||||||
|
</StackLayout>
|
||||||
|
</StackLayout>
|
||||||
|
</Frame>
|
||||||
</toolkit:Popup>
|
</toolkit:Popup>
|
@ -1,11 +1,149 @@
|
|||||||
using CommunityToolkit.Maui.Views;
|
using CommunityToolkit.Maui.Views;
|
||||||
|
using GMCabsDriverAssistant.Services;
|
||||||
|
using GMCabsDriverAssistant.Utils;
|
||||||
|
|
||||||
namespace GMCabsDriverAssistantSolution.Views;
|
namespace GMCabsDriverAssistantSolution.Views;
|
||||||
|
|
||||||
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
public partial class AppPermissiontSetDialogPage : Popup
|
public partial class AppPermissiontSetDialogPage : Popup
|
||||||
{
|
{
|
||||||
|
#region Fields
|
||||||
|
bool isLocationPermitted, isBatteryOptimizationDisabled;
|
||||||
|
string flag;
|
||||||
|
#endregion
|
||||||
|
#region Constructor
|
||||||
public AppPermissiontSetDialogPage(Page page, string flag)
|
public AppPermissiontSetDialogPage(Page page, string flag)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.flag = flag;
|
||||||
|
isLocationPermitted = Preferences.Get(SecureStorageData.IsLocationPermitted, false);
|
||||||
|
isBatteryOptimizationDisabled = Preferences.Get(SecureStorageData.IsBatteryOptimizationDisabled, false);
|
||||||
|
PermissionAllocationLayout.IsVisible = true;
|
||||||
|
PermissionLayout.IsVisible = false;
|
||||||
|
LocationWarningLayout.IsVisible = false;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
|
||||||
|
private async void Ignore_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (isLocationPermitted)
|
||||||
|
{
|
||||||
|
if (flag == Constant.FROM_PERMISSION_PAGE)
|
||||||
|
{
|
||||||
|
//Dismiss(null);
|
||||||
|
Close();
|
||||||
|
await ShowSplashScreen();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Dismiss(null);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (LocationWarningLayout.IsVisible)
|
||||||
|
{
|
||||||
|
if (flag == Constant.FROM_PERMISSION_PAGE)
|
||||||
|
{
|
||||||
|
//Dismiss(null);
|
||||||
|
Close();
|
||||||
|
await ShowSplashScreen();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Dismiss(null);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PermissionAllocationLayout.IsVisible = false;
|
||||||
|
PermissionLayout.IsVisible = false;
|
||||||
|
LocationWarningLayout.IsVisible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
|
private void Permission_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
PermissionAllocationLayout.IsVisible = false;
|
||||||
|
PermissionLayout.IsVisible = true;
|
||||||
|
LocationWarningLayout.IsVisible = false;
|
||||||
|
if (Device.RuntimePlatform == Device.iOS)
|
||||||
|
{
|
||||||
|
BatteyOptimisedLayout.IsVisible = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isLocationPermitted)
|
||||||
|
{
|
||||||
|
PermissionLayout.IsVisible = true;
|
||||||
|
LocationLayout.IsVisible = false;
|
||||||
|
}
|
||||||
|
if (isBatteryOptimizationDisabled)
|
||||||
|
{
|
||||||
|
PermissionLayout.IsVisible = true;
|
||||||
|
BatteyOptimisedLayout.IsVisible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Location_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//Dismiss(null);
|
||||||
|
Close();
|
||||||
|
await Permissions.RequestAsync<Permissions.LocationAlways>();
|
||||||
|
var status = await OnLocationCheck();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Batteryoptimisation_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//Dismiss(null);
|
||||||
|
Close();
|
||||||
|
if (!DependencyService.Get<IBatteryInfo>().CheckIsIgnoringBatteryOptimizations())
|
||||||
|
{
|
||||||
|
DependencyService.Get<IBatteryInfo>().StartSetting();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void ChangeLocation_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//Dismiss(null);
|
||||||
|
Close();
|
||||||
|
await Permissions.RequestAsync<Permissions.LocationAlways>();
|
||||||
|
var status = await OnLocationCheck();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
private async Task ShowSplashScreen()
|
||||||
|
{
|
||||||
|
await Shell.Current.GoToAsync($"//{nameof(SplashPage)}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PermissionStatus> OnLocationCheck()
|
||||||
|
{
|
||||||
|
|
||||||
|
var status = await Permissions.CheckStatusAsync<Permissions.LocationAlways>();
|
||||||
|
if (status == PermissionStatus.Granted)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ((DeviceInfo.Platform == DevicePlatform.Android && int.Parse(DeviceInfo.VersionString) >= 12) || DeviceInfo.Platform == DevicePlatform.iOS)
|
||||||
|
{
|
||||||
|
AppInfo.ShowSettingsUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user