diff --git a/apps/picsa-apps/extension-app-native/android/app/build.gradle b/apps/picsa-apps/extension-app-native/android/app/build.gradle index cd02d1979..b1d52c9dc 100644 --- a/apps/picsa-apps/extension-app-native/android/app/build.gradle +++ b/apps/picsa-apps/extension-app-native/android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "io.picsa.extension" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 3043004 - versionName "3.43.4" + versionCode 3044000 + versionName "3.44.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. diff --git a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html index ea079b5c6..338d95b30 100644 --- a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html +++ b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.html @@ -1 +1,8 @@ - +@if(videoData()){ + +@if(videoResource(); as resource){ + + +} } @else { +

Video not found

+} diff --git a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts index 3958ceaa1..1a41af201 100644 --- a/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts +++ b/apps/picsa-tools/farmer-content/src/app/components/step-video/step-video.component.ts @@ -1,9 +1,8 @@ import { CommonModule } from '@angular/common'; import { Component, computed, input } from '@angular/core'; import { ConfigurationService } from '@picsa/configuration/src'; -import { ILocaleCode } from '@picsa/data'; import { IPicsaVideo, IPicsaVideoData } from '@picsa/data/resources'; -import { PICSA_FARMER_VIDEO_RESOURCES_HASHMAP } from '@picsa/data/resources'; +import { RESOURCE_VIDEO_HASHMAP } from '@picsa/data/resources'; import { ResourcesComponentsModule } from '@picsa/resources/src/app/components/components.module'; /** @@ -25,25 +24,51 @@ export class FarmerStepVideoComponent { videoData = input.required(); videoResource = computed(() => { - const { language_code } = this.configurationService.userSettings(); + // HACK - when identifying video to show user cannot rely solely on language_code as + // that populates 'global_en' when different country used (should be zm_en) + // So instead use country_code specified and language part of localeCode + const { country_code: userCountry, language_code } = this.configurationService.userSettings(); + const [_, userLanguage] = language_code.split('_'); const availableVideos = this.videoData().children; - const video = this.selectDefaultVideo(language_code, availableVideos); - // HACK - lookup resource entry which should be given by same id - const resource = PICSA_FARMER_VIDEO_RESOURCES_HASHMAP[video.id]; - return resource; + // HACK - select best video recommendation. TODO - show toggle options in future + const [video] = this.filterAvailableVideos(userCountry, userLanguage, availableVideos); + if (video) { + // HACK - lookup resource entry which should be given by same id + const resource = RESOURCE_VIDEO_HASHMAP[video.id]; + return resource; + } + return undefined; }); constructor(private configurationService: ConfigurationService) {} - private selectDefaultVideo(locale_code: ILocaleCode, videos: IPicsaVideo[]) { - // prioritise video in same locale - const localeVideo = videos.find((v) => v.locale_code === locale_code); - if (localeVideo) return localeVideo; - - // TODO - fallback video to same language different locale - // TODO - track preference for video size (when supported in future, currently all 360p) + private filterAvailableVideos(userCountry: string, userLanguage: string, videos: IPicsaVideo[] = []) { + const rankedVideos = videos + .map((v) => ({ ...v, _rank: getVideoRank(userCountry, userLanguage, v) })) + .filter(({ _rank }) => _rank > 0) + .sort((a, b) => a._rank - b._rank); // default fallback to first video entry - return videos[0]; + return rankedVideos; } } + +function getVideoRank(userCountry: string, userLanguage: string, video: IPicsaVideo) { + const [audio, subtitle] = video.locale_codes; + const [audioCountry, audioLanguage] = audio.split('_'); + const subtitleLanguage = subtitle?.split('_')[1]; + + // 1 - same country and audio + if (audioCountry === userCountry && audioLanguage === userLanguage) return 1; + // 2 - same country and user language subtitle + if (audioCountry === userCountry && subtitleLanguage === userLanguage) return 2; + // 3 - global video with user language audio + if (audioCountry === 'global' && audioLanguage === userLanguage) return 3; + // 4 - global video with user language subtitle + if (audioCountry === 'global' && subtitleLanguage === userLanguage) return 4; + // 5 - return all videos for global users + if (userCountry === 'global') return 5; + // 6 - return global fallback + if (audioCountry === 'global' && audioLanguage === 'en') return 6; + return -1; +} diff --git a/apps/picsa-tools/farmer-content/src/app/pages/home/farmer-home.component.html b/apps/picsa-tools/farmer-content/src/app/pages/home/farmer-home.component.html index 3930a4c5c..69d59c352 100644 --- a/apps/picsa-tools/farmer-content/src/app/pages/home/farmer-home.component.html +++ b/apps/picsa-tools/farmer-content/src/app/pages/home/farmer-home.component.html @@ -14,9 +14,9 @@

{{ step.title | translate }}

@for(tag of step.tags; track tag){ - {{ tag.label | translate }} + {{ tag.label | translate }} } @for(tool of step.tools; track tool){ - {{ tool.label | translate }} + {{ tool.label | translate }} }
diff --git a/apps/picsa-tools/farmer-content/src/app/pages/home/farmer-home.component.scss b/apps/picsa-tools/farmer-content/src/app/pages/home/farmer-home.component.scss index 2ac754d63..03a913d19 100644 --- a/apps/picsa-tools/farmer-content/src/app/pages/home/farmer-home.component.scss +++ b/apps/picsa-tools/farmer-content/src/app/pages/home/farmer-home.component.scss @@ -79,12 +79,10 @@ button.mat-mdc-icon-button.nav-button { background: var(--tag-background, black); padding: 8px; color: white; - .step-tag { - } } -.tag.tool-tag { +.tag { --tag-background: var(--color-primary); } -.tag.step-tag { +.tag[data-color='secondary'] { --tag-background: var(--color-secondary); } diff --git a/apps/picsa-tools/farmer-content/src/app/pages/module-home/module-home.component.html b/apps/picsa-tools/farmer-content/src/app/pages/module-home/module-home.component.html index 2d9bf4fd1..507b5ced5 100644 --- a/apps/picsa-tools/farmer-content/src/app/pages/module-home/module-home.component.html +++ b/apps/picsa-tools/farmer-content/src/app/pages/module-home/module-home.component.html @@ -28,7 +28,7 @@

{{ content.title | translate }}

@case ("video") { - slideshow + {{ step.tabMatIcon || 'slideshow' }} {{ step.tabLabel || 'video' | translate }}
@@ -36,7 +36,18 @@

{{ content.title | translate }}

}
- + } + + @case ("video_playlist") { + + {{ step.tabMatIcon || 'slideshow' }} + {{ step.tabLabel || 'video' | translate }} + +
+ @for(video of step.videos; track video.id){ + + } +
} } } @@ -55,7 +66,7 @@

{{ content.title | translate }}

} - @if(photoAlbum(); as album){ + @if(content.showReviewSection){ @if(photoAlbum(); as album){ perm_media @@ -67,7 +78,7 @@

{{ content.title | translate }}

- } + } } -@if(downloadStatus==='ready'){ +@if(downloadStatus==='ready' || downloadStatus==='error'){