Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Status bar overlap #356

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions LiftLog.Maui/Platforms/Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Android;
using System.Globalization;
using Android;
using Android.App;
using Android.Content.PM;
using Android.Content.Res;
Expand Down Expand Up @@ -48,10 +49,14 @@ protected override void OnCreate(Bundle? savedInstanceState)
IPlatformApplication.Current?.Services.GetRequiredService<InsetsManager>();
if (insetsManager is not null)
{
insetsManager.SystemSafeInsetBottom =
$"{WebViewSoftInputPatch.GetNavBarHeight() / Resources!.DisplayMetrics!.Density}px";
insetsManager.SystemSafeInsetTop =
$"{WebViewSoftInputPatch.GetStatusBarHeight() / Resources.DisplayMetrics.Density}px";
insetsManager.SystemSafeInsetBottom = string.Create(
CultureInfo.InvariantCulture,
$"{WebViewSoftInputPatch.GetNavBarHeight() / Resources!.DisplayMetrics!.Density}px"
);
insetsManager.SystemSafeInsetTop = string.Create(
CultureInfo.InvariantCulture,
$"{WebViewSoftInputPatch.GetStatusBarHeight() / Resources.DisplayMetrics.Density}px"
);
ViewCompat.SetOnApplyWindowInsetsListener(
Window!.DecorView,
new WindowInsetsListener(insetsManager!, Resources.DisplayMetrics.Density)
Expand Down Expand Up @@ -86,15 +91,25 @@ WindowInsetsCompat insets
}
if (top == 0 || bottom == 0)
{
insetsManager.SystemSafeInsetBottom =
$"{WebViewSoftInputPatch.GetNavBarHeight() / density}px";
insetsManager.SystemSafeInsetTop =
$"{WebViewSoftInputPatch.GetStatusBarHeight() / density}px";
insetsManager.SystemSafeInsetBottom = string.Create(
CultureInfo.InvariantCulture,
$"{WebViewSoftInputPatch.GetNavBarHeight() / density}px"
);
insetsManager.SystemSafeInsetTop = string.Create(
CultureInfo.InvariantCulture,
$"{WebViewSoftInputPatch.GetStatusBarHeight() / density}px"
);
insetsManager.NotifyInsetsChanged();
return insets;
}
insetsManager.SystemSafeInsetTop = $"{top}px";
insetsManager.SystemSafeInsetBottom = $"{bottom}px";
insetsManager.SystemSafeInsetTop = string.Create(
CultureInfo.InvariantCulture,
$"{top}px"
);
insetsManager.SystemSafeInsetBottom = string.Create(
CultureInfo.InvariantCulture,
$"{bottom}px"
);
insetsManager.NotifyInsetsChanged();
return insets;
}
Expand Down
9 changes: 0 additions & 9 deletions LiftLog.Ui/Pages/Settings/AppConfigPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@
@inject IState<SettingsState> SettingsState
@inject IDispatcher Dispatcher
@inject IThemeProvider ThemeProvider
@inject IDeviceService DeviceService

@inherits Fluxor.Blazor.Web.Components.FluxorComponent

<md-list>
<ListSwitch Headline="@UiStrings.UseImperialUnits" SupportingText="@UiStrings.UseImperialUnitsSubtitle" Value="@SettingsState.Value.UseImperialUnits" OnSwitched="SetUseImperialUnits" />
<ListSwitch Headline="@UiStrings.ShowBodyweight" SupportingText="@UiStrings.ShowBodyweightSubtitle" Value="@SettingsState.Value.ShowBodyweight" OnSwitched="SetShowBodyweight" />
<ListSwitch Headline="@UiStrings.ShowFeed" SupportingText="@UiStrings.ShowFeedSubtitle" Value="@SettingsState.Value.ShowFeed" OnSwitched="SetShowFeed" />
@* If android, we need a status bar fix sometimes *@
@if(DeviceService.GetDeviceType() == DeviceType.Android)
{
<ListSwitch Headline="@UiStrings.StatusBarFix" SupportingText="@UiStrings.StatusBarFixSubtitle" Value="@SettingsState.Value.StatusBarFix" OnSwitched="SetStatusBarFix" />
}

<ListSwitch Headline="@UiStrings.ShowTips" SupportingText="@UiStrings.ShowTipsSubtitle" Value="@SettingsState.Value.ShowTips" OnSwitched="SetShowTips" />
<AppButton Type="AppButtonType.Text" OnClick="ResetTips">@UiStrings.ResetTips</AppButton>
Expand Down Expand Up @@ -48,9 +42,6 @@
private void SetShowTips(bool value)
=> Dispatcher.Dispatch(new SetShowTipsAction(value));

private void SetStatusBarFix(bool value)
=> Dispatcher.Dispatch(new SetStatusBarFixAction(value));

private void ResetTips()
=> Dispatcher.Dispatch(new SetTipToShowAction(1));

Expand Down
10 changes: 0 additions & 10 deletions LiftLog.Ui/Repository/PreferencesRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,6 @@ public async Task<bool> GetShowFeedAsync()
return await preferenceStore.GetItemAsync("showFeed") is "True" or null;
}

public async Task SetStatusBarFixAsync(bool statusBarFix)
{
await preferenceStore.SetItemAsync("statusBarFix", statusBarFix.ToString());
}

public async Task<bool> GetStatusBarFixAsync()
{
return await preferenceStore.GetItemAsync("statusBarFix") is "True";
}

public async Task<bool> GetHasRequestedNotificationPermissionAsync()
{
return await preferenceStore.GetItemAsync("hasRequestedNotificationPermission") is "True";
Expand Down
2 changes: 1 addition & 1 deletion LiftLog.Ui/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@

private string Justify => AppState.Value.BackNavigationUrl is null ? "justify-center" : "justify-start";

private string TopInset => SettingsState.Value.StatusBarFix ? "46px" : InsetsManager.SystemSafeInsetTop;
private string TopInset => InsetsManager.SystemSafeInsetTop;

private RenderFragment? RenderBackButton()
{
Expand Down
2 changes: 1 addition & 1 deletion LiftLog.Ui/Shared/Smart/NavBar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

@code {

private string BottomInset => SettingsState.Value.StatusBarFix ? "32px" : InsetsManager.SystemSafeInsetBottom;
private string BottomInset => InsetsManager.SystemSafeInsetBottom;

protected override void OnInitialized()
{
Expand Down
2 changes: 0 additions & 2 deletions LiftLog.Ui/Store/Settings/SettingsActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public record SetTipToShowAction(int TipToShow);

public record SetShowFeedAction(bool ShowFeed);

public record SetStatusBarFixAction(bool StatusBarFix);

public record ExecuteRemoteBackupAction(RemoteBackupSettings Settings, bool Force = false);

public record RemoteBackupSucceededEvent();
Expand Down
6 changes: 0 additions & 6 deletions LiftLog.Ui/Store/Settings/SettingsEffects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,6 @@ IDispatcher _
await preferencesRepository.SetLastSuccessfulRemoteBackupHashAsync(action.Hash);
}

[EffectMethod]
public async Task HandleStatusBarFixAction(SetStatusBarFixAction action, IDispatcher dispatcher)
{
await preferencesRepository.SetStatusBarFixAsync(action.StatusBarFix);
}

[EffectMethod]
public async Task ExecuteRemoteBackup(ExecuteRemoteBackupAction action, IDispatcher dispatcher)
{
Expand Down
6 changes: 0 additions & 6 deletions LiftLog.Ui/Store/Settings/SettingsReducers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ state with
ShowFeed = action.ShowFeed,
};

[ReducerMethod]
public static SettingsState SetStatusBarFix(
SettingsState state,
SetStatusBarFixAction action
) => state with { StatusBarFix = action.StatusBarFix };

[ReducerMethod]
public static SettingsState SetRestNotifications(
SettingsState state,
Expand Down
2 changes: 0 additions & 2 deletions LiftLog.Ui/Store/Settings/SettingsState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public record SettingsState(
bool ShowTips,
int TipToShow,
bool ShowFeed,
bool StatusBarFix,
bool RestNotifications,
RemoteBackupSettings RemoteBackupSettings,
string LastSuccessfulRemoteBackupHash,
Expand All @@ -34,7 +33,6 @@ bool BackupReminder
ShowTips: true,
TipToShow: 1,
ShowFeed: true,
StatusBarFix: false,
RestNotifications: true,
RemoteBackupSettings: new RemoteBackupSettings(string.Empty, string.Empty, false),
LastSuccessfulRemoteBackupHash: string.Empty,
Expand Down
3 changes: 0 additions & 3 deletions LiftLog.Ui/Store/Settings/SettingsStateInitMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public override async Task InitializeAsync(IDispatcher dispatch, IStore store)
showTips,
tipToShow,
showFeed,
statusBarFix,
restNotifications,
remoteBackupSettings,
lastSuccessfulRemoteBackupHash,
Expand All @@ -32,7 +31,6 @@ public override async Task InitializeAsync(IDispatcher dispatch, IStore store)
preferencesRepository.GetShowTipsAsync(),
preferencesRepository.GetTipToShowAsync(),
preferencesRepository.GetShowFeedAsync(),
preferencesRepository.GetStatusBarFixAsync(),
preferencesRepository.GetRestNotificationsAsync(),
preferencesRepository.GetRemoteBackupSettingsAsync(),
preferencesRepository.GetLastSuccessfulRemoteBackupHashAsync(),
Expand All @@ -48,7 +46,6 @@ public override async Task InitializeAsync(IDispatcher dispatch, IStore store)
ShowTips = showTips,
TipToShow = tipToShow,
ShowFeed = showFeed,
StatusBarFix = statusBarFix,
RestNotifications = restNotifications,
RemoteBackupSettings = remoteBackupSettings,
LastSuccessfulRemoteBackupHash = lastSuccessfulRemoteBackupHash,
Expand Down
6 changes: 0 additions & 6 deletions LiftLog.Ui/i18n/UiStrings.it-IT.resx
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,6 @@
<data name="ShowFeedSubtitle" xml:space="preserve">
<value>Mostra il feed nella barra di navigazione</value>
</data>
<data name="StatusBarFix" xml:space="preserve">
<value>Fix barra di stato</value>
</data>
<data name="StatusBarFixSubtitle" xml:space="preserve">
<value>Risolve il problema della sovrapposizione della barra di stato sui controlli in alcuni dispositivi.</value>
</data>
<data name="ShowTips" xml:space="preserve">
<value>Mostra suggerimenti</value>
</data>
Expand Down
6 changes: 0 additions & 6 deletions LiftLog.Ui/i18n/UiStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -500,12 +500,6 @@
<data name="ShowFeedSubtitle" xml:space="preserve">
<value>Display the feed in the navigation bar</value>
</data>
<data name="StatusBarFix" xml:space="preserve">
<value>Status bar fix</value>
</data>
<data name="StatusBarFixSubtitle" xml:space="preserve">
<value>Fixes the status bar overlapping the page title controls on some devices</value>
</data>
<data name="ShowTips" xml:space="preserve">
<value>Show tips</value>
</data>
Expand Down
Loading