Skip to content

Commit

Permalink
send UiLanguage as http header (#532)
Browse files Browse the repository at this point in the history
* send UiLanguage as http header

* remove translate locally since it's done on the server.

* add to PlaybackOrigin if a playlist is shared or owned
  • Loading branch information
kkuepper authored Feb 5, 2024
1 parent 2da97cc commit ad0c798
Show file tree
Hide file tree
Showing 28 changed files with 62 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ namespace BMM.Api.Implementation.Clients.Contracts
{
public interface IDiscoverClient
{
Task<IEnumerable<Document>> GetDocuments(string lang, int? age, AppTheme theme, CachePolicy cachePolicy);
Task<IEnumerable<Document>> GetDocuments(int? age, AppTheme theme, CachePolicy cachePolicy);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface IPlaylistClient

Task<Stream> GetCover(int podcastId);

Task<GenericDocumentsHolder> GetDocuments(string lang, int? age, CachePolicy cachePolicy);
Task<GenericDocumentsHolder> GetDocuments(int? age, CachePolicy cachePolicy);

Task<IList<Track>> GetTracks(int podcastId, CachePolicy cachePolicy);
}
Expand Down
8 changes: 4 additions & 4 deletions BMM.Api/Implementation/Clients/Contracts/IStatisticsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ public interface IStatisticsClient

Task<IList<YearInReviewItem>> GetYearInReview();

Task<ProjectProgress> GetProjectProgress(string lang, AppTheme theme);
Task<ProjectProgress> GetProjectProgress(AppTheme theme);

Task<ProjectRules> GetProjectRules(string lang, int projectId);
Task<ProjectRules> GetProjectRules(int projectId);

Task AchievementAcknowledge(string achievementType);

Task DeleteAchievements();
Task PostListeningEvents(IList<ListeningEvent> listeningEvents);
Task<AchievementsHolder> GetAchievements(string lang, AppTheme theme);
Task<IList<Achievement>> GetAchievementsToAcknowledge(string lang, AppTheme theme);
Task<AchievementsHolder> GetAchievements(AppTheme theme);
Task<IList<Achievement>> GetAchievementsToAcknowledge(AppTheme theme);
}
}
3 changes: 1 addition & 2 deletions BMM.Api/Implementation/Clients/DiscoverClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ public class DiscoverClient : BaseClient, IDiscoverClient
public DiscoverClient(IRequestHandler handler, ApiBaseUri baseUri, ILogger logger) : base(handler, baseUri, logger)
{ }

public async Task<IEnumerable<Document>> GetDocuments(string lang, int? age, AppTheme theme, CachePolicy cachePolicy)
public async Task<IEnumerable<Document>> GetDocuments(int? age, AppTheme theme, CachePolicy cachePolicy)
{
var uri = new UriTemplate(ApiUris.Discover);
uri.SetParameter("lang", lang);
if (age.HasValue)
uri.SetParameter("age", age.Value);
uri.SetParameter("theme", theme);
Expand Down
3 changes: 1 addition & 2 deletions BMM.Api/Implementation/Clients/PlaylistClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ public async Task<Stream> GetCover(int podcastId)
return await GetCoverBase(podcastId, ApiUris.PlaylistCover);
}

public Task<GenericDocumentsHolder> GetDocuments(string lang, int? age, CachePolicy cachePolicy)
public Task<GenericDocumentsHolder> GetDocuments(int? age, CachePolicy cachePolicy)
{
var uri = new UriTemplate(ApiUris.PlaylistDocuments);
uri.SetParameter("lang", lang);
uri.SetParameter("age", age);
return Get<GenericDocumentsHolder>(uri);
}
Expand Down
20 changes: 4 additions & 16 deletions BMM.Api/Implementation/Clients/StatisticsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,46 +124,34 @@ public Task<IList<YearInReviewItem>> GetYearInReview()
return Get<IList<YearInReviewItem>>(uri);
}

public async Task<AchievementsHolder> GetAchievements(string lang, AppTheme theme)
public async Task<AchievementsHolder> GetAchievements(AppTheme theme)
{
var uri = new UriTemplate(ApiUris.Achievements);
uri.SetParameter("lang", lang);
uri.SetParameter("theme", theme);
return await Get<AchievementsHolder>(uri);
}

public Task<IList<Achievement>> GetAchievementsToAcknowledge(string lang, AppTheme theme)
public Task<IList<Achievement>> GetAchievementsToAcknowledge(AppTheme theme)
{
var uri = new UriTemplate(ApiUris.AchievementsToAcknowledge);
uri.SetParameter("lang", lang);
uri.SetParameter("theme", theme);
return Get<IList<Achievement>>(uri);
}

public Task<ProjectProgress> GetProjectProgress(string lang, AppTheme theme)
public Task<ProjectProgress> GetProjectProgress(AppTheme theme)
{
var uri = new UriTemplate(ApiUris.ProjectProgress);
uri.SetParameter("lang", lang);
uri.SetParameter("theme", theme);
return Get<ProjectProgress>(uri);
}

public Task<ProjectRules> GetProjectRules(string lang, int projectId)
public Task<ProjectRules> GetProjectRules(int projectId)
{
var uri = new UriTemplate(ApiUris.ProjectRules);
uri.SetParameter("projectId", projectId);
uri.SetParameter("lang", lang);
return Get<ProjectRules>(uri);
}

// public Task GetAchievements(string lang, AppTheme theme)
// {
// var uri = new UriTemplate(ApiUris.StatisticsAchievements);
// uri.SetParameter("lang", lang);
// uri.SetParameter("theme", theme);
// return Get(uri);
// }
//
public Task AchievementAcknowledge(string achievementType)
{
var uri = new UriTemplate(ApiUris.AchievementAcknowledge);
Expand Down
1 change: 1 addition & 0 deletions BMM.Api/Implementation/Constants/HeaderNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public static class HeaderNames
public const string Accept = "Accept";
public const string MobileDownloadAllowed = "MobileDownloadAllowed";
public const string Authorization = "Authorization";
public const string UiLanguage = "UiLanguage";
}
}
1 change: 1 addition & 0 deletions BMM.Core/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public override void Initialize()
Mvx.IoCProvider.RegisterType<ContentLanguageHeaderProvider>();
Mvx.IoCProvider.RegisterType<JsonContentTypeHeaderProvider>();
Mvx.IoCProvider.RegisterType<BmmVersionHeaderProvider>();
Mvx.IoCProvider.RegisterType<UiLanguageHeaderProvider>();
Mvx.IoCProvider.RegisterType<ExperimentIdHeaderProvider>();
Mvx.IoCProvider.RegisterType<ConnectivityHeaderProvider>();
Mvx.IoCProvider.RegisterType<MobileDownloadAllowedHeaderProvider>();
Expand Down
8 changes: 0 additions & 8 deletions BMM.Core/Extensions/TranslationsExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using BMM.Api.Implementation.Models;
using BMM.Api.Implementation.Models.Interfaces;
using BMM.Core.Translation;
using MvvmCross.Localization;

Expand All @@ -16,11 +13,6 @@ public static string ConvertPlaylistAuthorToLabel(this IMvxLanguageBinder mvxLan
return string.Format(mvxLanguageBinder.GetText(Translations.MyContentViewModel_ByFormat), authorName);
}

public static string GetTranslationKey(this ITranslationDetailsHolder translationDetailsHolder)
{
return $"{translationDetailsHolder.TranslationParent}_{translationDetailsHolder.TranslationId}";
}

public static string GetTranslationKey(this Type basicType, string key)
{
return $"{basicType.Name}_{key}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using BMM.Core.GuardedActions.Achievements.Interfaces;
using BMM.Core.GuardedActions.Base;
using BMM.Core.Implementations.Device;
using BMM.Core.Implementations.Languages;
using BMM.Core.Models.POs.Base;
using BMM.Core.Models.POs.BibleStudy;
using BMM.Core.Models.POs.Other;
Expand All @@ -18,18 +17,15 @@ public class PrepareAchievementsAction
IPrepareAchievementsAction
{
private readonly IStatisticsClient _statisticsClient;
private readonly IAppLanguageProvider _appLanguageProvider;
private readonly IDeviceInfo _deviceInfo;
private readonly IMvxNavigationService _mvxNavigationService;

public PrepareAchievementsAction(
IStatisticsClient statisticsClient,
IAppLanguageProvider appLanguageProvider,
IDeviceInfo deviceInfo,
IMvxNavigationService mvxNavigationService)
{
_statisticsClient = statisticsClient;
_appLanguageProvider = appLanguageProvider;
_deviceInfo = deviceInfo;
_mvxNavigationService = mvxNavigationService;
}
Expand All @@ -38,9 +34,7 @@ public PrepareAchievementsAction(

protected override async Task Execute()
{
var achievementHolder = await _statisticsClient.GetAchievements(
_appLanguageProvider.GetAppLanguage(),
await _deviceInfo.GetCurrentTheme());
var achievementHolder = await _statisticsClient.GetAchievements(await _deviceInfo.GetCurrentTheme());

var elementsList = new List<BasePO>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using BMM.Core.GuardedActions.BibleStudy.Interfaces;
using BMM.Core.Helpers.PresentationHints;
using BMM.Core.Implementations.Device;
using BMM.Core.Implementations.Languages;
using BMM.Core.Messages;
using BMM.Core.Models.POs.BibleStudy;
using BMM.Core.Utils;
Expand All @@ -22,26 +21,23 @@ public class CheckAndShowAchievementUnlockedScreenAction : GuardedAction, ICheck
private readonly IStatisticsClient _statisticsClient;
private readonly IMvxNavigationService _mvxNavigationService;
private readonly IMvxMessenger _mvxMessenger;
private readonly IAppLanguageProvider _appLanguageProvider;
private readonly IDeviceInfo _deviceInfo;

public CheckAndShowAchievementUnlockedScreenAction(
IStatisticsClient statisticsClient,
IMvxNavigationService mvxNavigationService,
IMvxMessenger mvxMessenger,
IAppLanguageProvider appLanguageProvider,
IDeviceInfo deviceInfo)
{
_statisticsClient = statisticsClient;
_mvxNavigationService = mvxNavigationService;
_mvxMessenger = mvxMessenger;
_appLanguageProvider = appLanguageProvider;
_deviceInfo = deviceInfo;
}

protected override async Task Execute()
{
var achievements = await _statisticsClient.GetAchievementsToAcknowledge(_appLanguageProvider.GetAppLanguage(), await _deviceInfo.GetCurrentTheme());
var achievements = await _statisticsClient.GetAchievementsToAcknowledge(await _deviceInfo.GetCurrentTheme());

if (!achievements.Any())
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using BMM.Core.GuardedActions.TrackInfo.Interfaces;
using BMM.Core.Helpers;
using BMM.Core.Implementations.Factories.Streak;
using BMM.Core.Implementations.Languages;
using BMM.Core.Implementations.UI;
using BMM.Core.Models.POs.Base.Interfaces;
using BMM.Core.Models.POs.BibleStudy;
Expand All @@ -20,21 +19,17 @@ namespace BMM.Core.GuardedActions.BibleStudy;
public class InitializeBibleStudyRulesViewModelAction : GuardedActionWithParameter<int>, IInitializeBibleStudyRulesViewModelAction
{
private readonly IStatisticsClient _statisticsClient;
private readonly IAppLanguageProvider _appLanguageProvider;

private IBibleStudyRulesViewModel DataContext => this.GetDataContext();

public InitializeBibleStudyRulesViewModelAction(
IStatisticsClient statisticsClient,
IAppLanguageProvider appLanguageProvider)
public InitializeBibleStudyRulesViewModelAction(IStatisticsClient statisticsClient)
{
_statisticsClient = statisticsClient;
_appLanguageProvider = appLanguageProvider;
}

protected override async Task Execute(int projectId)
{
var projectRules = await _statisticsClient.GetProjectRules(_appLanguageProvider.GetAppLanguage(), projectId);
var projectRules = await _statisticsClient.GetProjectRules(projectId);
var items = new List<IBasePO>();

DataContext.Title = projectRules.PageTitle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using BMM.Core.Helpers;
using BMM.Core.Implementations.Device;
using BMM.Core.Implementations.Factories.Streak;
using BMM.Core.Implementations.Languages;
using BMM.Core.Implementations.UI;
using BMM.Core.Models.POs.BibleStudy;
using BMM.Core.Models.POs.Other;
Expand All @@ -27,7 +26,6 @@ public class InitializeBibleStudyViewModelAction : GuardedAction, IInitializeBib
private readonly IMvxNavigationService _mvxNavigationService;
private readonly IDeepLinkHandler _deepLinkHandler;
private readonly IUriOpener _uriOpener;
private readonly IAppLanguageProvider _appLanguageProvider;
private readonly IDeviceInfo _deviceInfo;
private readonly IMediaPlayer _mediaPlayer;

Expand All @@ -41,7 +39,6 @@ public InitializeBibleStudyViewModelAction(
IMvxNavigationService mvxNavigationService,
IDeepLinkHandler deepLinkHandler,
IUriOpener uriOpener,
IAppLanguageProvider appLanguageProvider,
IDeviceInfo deviceInfo,
IMediaPlayer mediaPlayer)
{
Expand All @@ -52,14 +49,13 @@ public InitializeBibleStudyViewModelAction(
_mvxNavigationService = mvxNavigationService;
_deepLinkHandler = deepLinkHandler;
_uriOpener = uriOpener;
_appLanguageProvider = appLanguageProvider;
_deviceInfo = deviceInfo;
_mediaPlayer = mediaPlayer;
}

protected override async Task Execute()
{
var projectProgress = await _statisticsClient.GetProjectProgress(_appLanguageProvider.GetAppLanguage(), await _deviceInfo.GetCurrentTheme());
var projectProgress = await _statisticsClient.GetProjectProgress(await _deviceInfo.GetCurrentTheme());

UpdateUnlockedAchievements(projectProgress);

Expand Down

This file was deleted.

53 changes: 0 additions & 53 deletions BMM.Core/GuardedActions/Documents/TranslateDocsAction.cs

This file was deleted.

12 changes: 0 additions & 12 deletions BMM.Core/GuardedActions/Player/UpdateExternalRelationsAction.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using BMM.Api.Abstraction;
using BMM.Api.Implementation.Models;
using BMM.Api.Utils;
using BMM.Core.Constants;
using BMM.Core.Extensions;
using BMM.Core.GuardedActions.Base;
using BMM.Core.GuardedActions.Player.Interfaces;
using BMM.Core.Implementations;
using BMM.Core.Implementations.FirebaseRemoteConfig;
using BMM.Core.Implementations.Languages;
using BMM.Core.Implementations.Region.Interfaces;
using BMM.Core.Implementations.UI;
using BMM.Core.Models.Enums;
using BMM.Core.Translation;
using BMM.Core.Utils;
using BMM.Core.ViewModels.Interfaces;
using MvvmCross;
using Newtonsoft.Json;

namespace BMM.Core.GuardedActions.Player
{
Expand Down
Loading

0 comments on commit ad0c798

Please sign in to comment.