Skip to content

Commit

Permalink
Badge removing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
akrol95 committed Oct 25, 2024
1 parent 8803bd8 commit 5d021f0
Show file tree
Hide file tree
Showing 28 changed files with 95 additions and 104 deletions.
3 changes: 0 additions & 3 deletions BMM.Api/Implementation/Models/Question.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ public class Question
{
public Question(int id,
string type,
string pageTitle,
string questionImageLink,
string questionText,
string questionSubtext,
Expand All @@ -19,7 +18,6 @@ public Question(int id,
{
Id = id;
Type = type;
PageTitle = pageTitle;
QuestionImageLink = questionImageLink;
QuestionText = questionText;
QuestionSubtext = questionSubtext;
Expand All @@ -35,7 +33,6 @@ public Question(int id,

public int Id { get; }
public string Type { get; }
public string PageTitle { get; }
public string QuestionImageLink { get; }
public string QuestionText { get; }
public string QuestionSubtext { get; }
Expand Down
4 changes: 2 additions & 2 deletions BMM.Core/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ public override void Initialize()
Mvx.IoCProvider.RegisterType<IDocumentFilter, NullFilter>();
Mvx.IoCProvider.RegisterType<IDownloadedTracksOnlyFilter, DownloadedTracksOnlyFilter>();

Mvx.IoCProvider.LazyConstructAndRegisterSingleton<IBadgeService, BadgeService>();

Mvx.IoCProvider.RegisterType<IPlayerErrorHandler, PlayerErrorHandler>();
Mvx.IoCProvider.LazyConstructAndRegisterSingleton<IPlayerAnalytics, PlayerAnalytics>();
Mvx.IoCProvider.LazyConstructAndRegisterSingleton<IPlaybackHistoryService, PlaybackHistoryService>();
Expand Down Expand Up @@ -288,8 +290,6 @@ public override void Initialize()
Mvx.IoCProvider.RegisterType<IGuardInvoker, GuardInvoker>();
Mvx.IoCProvider.LazyConstructAndRegisterSingleton<ITimeDiagnosticTool, TimeDiagnosticTool>();

Mvx.IoCProvider.LazyConstructAndRegisterSingleton<IBadgeService, BadgeService>();

Mvx.IoCProvider.LazyConstructAndRegisterSingleton<IDocumentsPOFactory, DocumentsPOFactory>();
Mvx.IoCProvider.LazyConstructAndRegisterSingleton<ITrackPOFactory, TrackPOFactory>();
Mvx.IoCProvider.LazyConstructAndRegisterSingleton<ITrackCollectionPOFactory, TrackCollectionPOFactory>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected override async Task OnFinally()
{
await base.OnFinally();
await PlayerViewModel.RaisePropertyChanged(nameof(PlayerViewModel.HasLeftButton));
await PlayerViewModel.RaisePropertyChanged(nameof(PlayerViewModel.HasBccButton));
await PlayerViewModel.RaisePropertyChanged(nameof(PlayerViewModel.HasWatchButton));
PlayerViewModel.LeftButtonClickedCommand.RaiseCanExecuteChanged();
}
}
Expand Down
2 changes: 1 addition & 1 deletion BMM.Core/Models/Enums/TileStatusTextIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ public enum TileStatusTextIcon
{
None,
Play,
Dot
Badge
}
2 changes: 1 addition & 1 deletion BMM.Core/Models/POs/Tiles/ContinueListeningTilePO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private async Task<TileStatusTextIcon> GetTileStatusIcon(bool isCurrentlySelecte
return TileStatusTextIcon.None;

await _badgeService.Set();
return TileStatusTextIcon.Dot;
return TileStatusTextIcon.Badge;
}

private async Task<bool> CheckHasBadge()
Expand Down
12 changes: 6 additions & 6 deletions BMM.Core/Translation/en/Translations.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions BMM.Core/Translation/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,10 @@
"OptionAppVersionHeader": "App version",
"OptionDeleteAccountHeader": "Delete Account",
"OptionDeleteAccountText": "Request that your account is deleted.",
"OptionBibleStudyBadgeHeader": "Bible Study Notification badge",
"OptionBibleStudyBadgeText": "Show a notification in home to help you remember to listen to the daily episode.",
"OptionBibleStudyOnHomeHeader": "Bible Study on Home",
"OptionBibleStudyOnHomeText": "Show your Bible Study status on the home screen",
"OptionNotificationBadgeHeader": "Bible Study Notification badge",
"OptionNotificationBadgeText": "Show a notification in home to help you remember to listen to the daily episode.",
"OptionBibleStudyHeader": "Bible Study on Home",
"OptionBibleStudyText": "Show your Bible Study status on the home screen",
"AppInfoTitle": "App information",
"AppInfoAppVersion": "App version: ",
"AppInfoManufacturer": "Manufacturer: ",
Expand Down Expand Up @@ -617,7 +617,7 @@
},
"AchievementsViewModel": {
"Title": "Achievements",
"NoAchievementsTitle": "A place for your Bible Study Achievements",
"NoAchievementsSubtitle": "When you earn achievements in Bible Studies to start collecting them here."
"EmptyTitle": "A place for your Bible Study Achievements",
"EmptySubtitle": "When you earn achievements in Bible Studies to start collecting them here."
}
}
8 changes: 1 addition & 7 deletions BMM.Core/ViewModels/ExploreNewestViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class ExploreNewestViewModel : DocumentsViewModel
private readonly MvxSubscriptionToken _listeningStreakChangedMessageToken;
private readonly MvxSubscriptionToken _playbackStatusChangedMessageToken;
private readonly IDeviceInfo _deviceInfo;
private readonly IBadgeService _badgeService;

public ExploreNewestViewModel(
IStreakObserver streakObserver,
Expand All @@ -60,8 +59,7 @@ public ExploreNewestViewModel(
IListeningStreakPOFactory listeningStreakPOFactory,
IAddToQueueAdditionalMusic addToQueueAdditionalMusic,
ICheckAndShowAchievementUnlockedScreenAction checkAndShowAchievementUnlockedScreenAction,
IDeviceInfo deviceInfo,
IBadgeService badgeService)
IDeviceInfo deviceInfo)
{
_streakObserver = streakObserver;
_settings = settings;
Expand All @@ -74,16 +72,13 @@ public ExploreNewestViewModel(
_addToQueueAdditionalMusic = addToQueueAdditionalMusic;
_checkAndShowAchievementUnlockedScreenAction = checkAndShowAchievementUnlockedScreenAction;
_deviceInfo = deviceInfo;
_badgeService = badgeService;
_listeningStreakChangedMessageToken = Messenger.Subscribe<ListeningStreakChangedMessage>(ListeningStreakChanged);
_playbackStatusChangedMessageToken = Messenger.Subscribe<PlaybackStatusChangedMessage>(PlaybackStateChanged);
_prepareTileCarouselItemsAction.AttachDataContext(this);
TrackInfoProvider = new TypeKnownTrackInfoProvider();
BadgeChangedInteraction = new BmmInteraction();
}

public IMvxAsyncCommand<Type> NavigateToViewModelCommand => _navigateToViewModelAction.Command;
public IBmmInteraction BadgeChangedInteraction { get; }

private void ListeningStreakChanged(ListeningStreakChangedMessage message)
{
Expand Down Expand Up @@ -116,7 +111,6 @@ public override async Task<IEnumerable<IDocumentPO>> LoadItems(CachePolicy polic
var docsWithCoversCarousel = await _prepareCoversCarouselItemsAction.ExecuteGuarded(filteredDocs);
var presentationItems = await _prepareTileCarouselItemsAction.ExecuteGuarded(docsWithCoversCarousel);
SetAdditionalElements(presentationItems);
BadgeChangedInteraction?.Raise();
return presentationItems;
}

Expand Down
4 changes: 2 additions & 2 deletions BMM.Core/ViewModels/Interfaces/IPlayerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public interface IPlayerViewModel : IBaseViewModel
IMvxAsyncCommand NavigateToLanguageChangeCommand { get; }
ITrackModel CurrentTrack { get; }
bool HasLeftButton { get; }
bool HasBccButton { get; }
bool HasWatchButton { get; }
bool HasExternalRelations { get; set; }
MvxCommand LeftButtonClickedCommand { get; }
MvxCommand WatchBccButtonClickedCommand { get; }
MvxCommand WatchButtonClickedCommand { get; }
string LeftButtonLink { get; set; }
string TrackLanguage { get; set; }
PlayerLeftButtonType? LeftButtonType { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions BMM.Core/ViewModels/PlayerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public sealed class PlayerViewModel : PlayerBaseViewModel, IPlayerViewModel, IMv
public MvxCommand SkipForwardCommand { get; }
public MvxCommand SkipBackwardCommand { get; }
public MvxCommand LeftButtonClickedCommand { get; }
public MvxCommand WatchBccButtonClickedCommand { get; }
public MvxCommand WatchButtonClickedCommand { get; }
public string LeftButtonLink { get; set; }

public bool IsShuffleEnabled
Expand Down Expand Up @@ -131,7 +131,7 @@ public string WatchBccMediaLink
public bool CanNavigateToLanguageChange => NavigateToLanguageChangeCommand.CanExecute();

public bool HasLeftButton => LeftButtonClickedCommand.CanExecute();
public bool HasBccButton => WatchBccButtonClickedCommand.CanExecute();
public bool HasWatchButton => WatchButtonClickedCommand.CanExecute();

public string PlayingText => _queueLength > 0 ? TextSource.GetText(Translations.PlayerViewModel_PlayingCount, _currentIndex + 1, _queueLength) : string.Empty;

Expand Down Expand Up @@ -163,7 +163,7 @@ public PlayerViewModel(
SkipForwardCommand = new MvxCommand(() => MediaPlayer.JumpForward());
SkipBackwardCommand = new MvxCommand(() => MediaPlayer.JumpBackward());
LeftButtonClickedCommand = new MvxCommand(LeftButtonClicked, () => HasTranscription || !string.IsNullOrEmpty(LeftButtonLink));
WatchBccButtonClickedCommand = new MvxCommand(BccMediaClicked, () => !string.IsNullOrEmpty(WatchBccMediaLink));
WatchButtonClickedCommand = new MvxCommand(BccMediaClicked, () => !string.IsNullOrEmpty(WatchBccMediaLink));

SeekToPositionCommand = new MvxCommand<long>(position =>
{
Expand Down
8 changes: 4 additions & 4 deletions BMM.Core/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,15 @@ private async Task<List<IListItem>> BuildHomeScreenSection()
},
new CheckboxListItemPO
{
Title = TextSource[Translations.SettingsViewModel_OptionBibleStudyOnHomeHeader],
Text = TextSource[Translations.SettingsViewModel_OptionBibleStudyOnHomeText],
Title = TextSource[Translations.SettingsViewModel_OptionBibleStudyHeader],
Text = TextSource[Translations.SettingsViewModel_OptionBibleStudyText],
IsChecked = await _settingsStorage.GetBibleStudyOnHomeEnabled(),
OnChanged = sender => _settingsStorage.SetBibleStudyOnHomeEnabled(sender.IsChecked)
},
new CheckboxListItemPO
{
Title = TextSource[Translations.SettingsViewModel_OptionBibleStudyBadgeHeader],
Text = TextSource[Translations.SettingsViewModel_OptionBibleStudyBadgeText],
Title = TextSource[Translations.SettingsViewModel_OptionNotificationBadgeHeader],
Text = TextSource[Translations.SettingsViewModel_OptionNotificationBadgeText],
IsChecked = await _settingsStorage.GetBibleStudyBadgeEnabled(),
OnChanged = sender =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using BMM.Core.GuardedActions.Settings.Interfaces;
using BMM.Core.Implementations;
using BMM.Core.Implementations.Analytics;
using BMM.Core.Implementations.Badge;
using BMM.Core.Implementations.Caching;
using BMM.Core.Implementations.Connection;
using BMM.Core.Implementations.Device;
Expand Down Expand Up @@ -61,6 +62,8 @@ public class SettingsViewModelTests : BaseViewModelTests
private Mock<INotificationPermissionService> _notificationPermissionService;
private Mock<IChangeNotificationSettingStateAction> _changeNotificationSettingStateAction;
private Mock<IResetAchievementAction> _resetAchievementAction;
private Mock<IMvxNavigationService> _mvxNavigationService;
private Mock<IBadgeService> _badgeService;

public override void SetUp()
{
Expand Down Expand Up @@ -112,6 +115,8 @@ public override void SetUp()
_notificationPermissionService = new Mock<INotificationPermissionService>();
_changeNotificationSettingStateAction= new Mock<IChangeNotificationSettingStateAction>();
_resetAchievementAction = new Mock<IResetAchievementAction>();
_mvxNavigationService = new Mock<IMvxNavigationService>();
_badgeService = new Mock<IBadgeService>();

_textSource.Setup(x => x.GetText(It.IsAny<string>())).Returns(String.Empty);

Expand Down Expand Up @@ -148,7 +153,8 @@ public SettingsViewModel CreateSettingsViewModel()
_changeNotificationSettingStateAction.Object,
_resetAchievementAction.Object,
_featurePreviewPermission.Object,
new Mock<IMvxNavigationService>().Object
_mvxNavigationService.Object,
_badgeService.Object
);

settingsViewModel.TextSource = TextResource.Object;
Expand Down
11 changes: 8 additions & 3 deletions BMM.UI.Android/Application/Fragments/MenuFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,23 @@ private void SetBadgeOnTabBarItem()
{
if (!_badgeService.IsBadgeSet)
{
if (_iconContainer != null && _iconContainer.HasChild(_badgeView))
_iconContainer.RemoveView(_badgeView);

RemoveBadge();
return;
}

RemoveBadge();
var notificationItemView = _navigationView.FindViewById(Resource.Id.page_1);
var inflater = (LayoutInflater)Context.GetSystemService(Android.Content.Context.LayoutInflaterService);
_badgeView = inflater.Inflate(Resource.Layout.badge, null);
_iconContainer = (FrameLayout)notificationItemView;
_iconContainer.AddView(_badgeView);
});
}

private void RemoveBadge()
{
if (_iconContainer != null && _iconContainer.HasChild(_badgeView))
_iconContainer.RemoveView(_badgeView);
}
}
}
16 changes: 8 additions & 8 deletions BMM.UI.Android/Application/Fragments/PlayerFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class PlayerFragment : BaseFragment<PlayerViewModel>, SeekBar.IOnSeekBarC
private Button _leftButton;
private int _leftButtonOriginalPadding;
private bool _hasTranscription;
private Button _watchBccButton;
private Button _watchButton;

protected override bool ShouldClearMenuItemsAtStart => false;

Expand Down Expand Up @@ -156,7 +156,7 @@ public override View OnCreateView(LayoutInflater inflater, ViewGroup container,
_backgroundAccentColor = Context.GetColorFromResource(Resource.Color.background_two_color);
_titleLabel = view.FindViewById<TextView>(Resource.Id.TitleLabel);
_leftButton = view.FindViewById<Button>(Resource.Id.LeftButton);
_watchBccButton = view.FindViewById<Button>(Resource.Id.WatchBccButton);
_watchButton = view.FindViewById<Button>(Resource.Id.WatchButton);
_coverContainer!.ClipToOutline = true;
_leftButtonOriginalPadding = _leftButton.PaddingRight;

Expand Down Expand Up @@ -414,29 +414,29 @@ private void UpdateTitleSize()
if (Context == null)
return;

SetWatchBccButtonPosition();
SetWatchButtonButtonPosition();

int coverBottom = _coverContainer!.Bottom;
int watchBccButtonSizeToSubtract = _watchBccButton.Visibility == ViewStates.Visible
? _watchBccButton.MeasuredHeight
int WatchButtonSizeToSubtract = _watchButton.Visibility == ViewStates.Visible
? _watchButton.MeasuredHeight
: default;
int titleLabelBottom = _titleLabel.Bottom;
int margin = Resources.GetDimensionPixelSize(Resource.Dimension.margin_xmedium);

int desiredTitleLabelHeight = titleLabelBottom
- coverBottom
- watchBccButtonSizeToSubtract
- WatchButtonSizeToSubtract
- margin
- _coverShadowLayout.PaddingTop;
_titleLabel.UpdateHeight(desiredTitleLabelHeight);
});
}

private void SetWatchBccButtonPosition()
private void SetWatchButtonButtonPosition()
{
int[] location = new int[2];
_coverContainer.GetLocationInWindow(location);
_watchBccButton.SetY(location[1] + _coverContainer.MeasuredHeight);
_watchButton.SetY(location[1] + _coverContainer.MeasuredHeight);
}

private void SetSizes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public TileStatusTextIcon TileStatusTextIcon
{
switch (_tileStatusTextIcon)
{
case TileStatusTextIcon.Dot:
case TileStatusTextIcon.Badge:
_playingStatusIcon!.Text = ContinueListeningTilePO.NotificationBadgeIcon;
_playingStatusIcon.SetTextColor(ItemView.Context.GetColorFromResource(Resource.Color.radio_color));
break;
Expand Down
4 changes: 2 additions & 2 deletions BMM.UI.Android/Resources/layout/fragment_achievements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
local:layout_constraintEnd_toEndOf="parent"
local:layout_constraintBottom_toTopOf="@+id/NoAchievementsSubtitle"
local:MvxBind="Visibility InvertedVisibility(AreAchievementsVisible)"
local:MvxLang="Text AchievementsViewModel_NoAchievementsTitle"
local:MvxLang="Text AchievementsViewModel_EmptyTitle"
style="@style/Heading3" />

<TextView
Expand All @@ -48,7 +48,7 @@
local:layout_constraintEnd_toEndOf="parent"
local:layout_constraintBottom_toBottomOf="parent"
local:MvxBind="Visibility InvertedVisibility(AreAchievementsVisible)"
local:MvxLang="Text AchievementsViewModel_NoAchievementsSubtitle"
local:MvxLang="Text AchievementsViewModel_EmptySubtitle"
style="@style/Paragraph1" />

</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit 5d021f0

Please sign in to comment.