From 14de22f5aad91ea3167efc0326e7c2fd7fe00376 Mon Sep 17 00:00:00 2001 From: Guy Tepper Date: Sun, 8 Oct 2023 15:37:52 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20-=20Improve=20urgent=20message?= =?UTF-8?q?=20title=20display=20(#335)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - truncate urgent message title - remove html tags and entities from message body - announcement card darker background --- android/app/build.gradle | 4 +- .../announcements/announcement-card.tsx | 8 ++-- .../announcements/announcements-utils.tsx | 6 +++ .../announcements/urgent-announcements.tsx | 5 ++- .../planner/Important-announcement-bar.tsx | 18 ++++++++- ios/BetterRail.xcodeproj/project.pbxproj | 40 +++++++++---------- ios/BetterRail/Info.plist | 2 +- ios/BetterRailWidget/Info.plist | 2 +- ios/StationIntent/Info.plist | 2 +- ios/WatchBetterRail Extension/Info.plist | 2 +- ios/WatchBetterRail/Info.plist | 2 +- 11 files changed, 58 insertions(+), 33 deletions(-) create mode 100644 app/components/announcements/announcements-utils.tsx diff --git a/android/app/build.gradle b/android/app/build.gradle index fb2e3387..013b7b62 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -120,8 +120,8 @@ android { applicationId "com.betterrail" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 73 - versionName "2.2.0" + versionCode 74 + versionName "2.2.1" missingDimensionStrategy "store", "play" } diff --git a/app/components/announcements/announcement-card.tsx b/app/components/announcements/announcement-card.tsx index 8681954a..aaf24de3 100644 --- a/app/components/announcements/announcement-card.tsx +++ b/app/components/announcements/announcement-card.tsx @@ -3,6 +3,7 @@ import TouchableScale from "react-native-touchable-scale" import { fontScale, spacing, color } from "../../theme" import { Text } from "../text/text" import { openLink } from "../../utils/helpers/open-link" +import { removeHtmlTagsAndEntities } from "./announcements-utils" const ANNOUNCEMENT_CARD: ViewStyle = { minHeight: 80 * fontScale, @@ -12,7 +13,7 @@ const ANNOUNCEMENT_CARD: ViewStyle = { paddingHorizontal: spacing[3], borderRadius: Platform.select({ ios: 12, android: 8 }), - backgroundColor: Platform.select({ ios: color.tertiaryBackground, android: color.inputBackground }), + backgroundColor: Platform.select({ ios: color.secondaryBackground, android: color.inputBackground }), shadowColor: color.palette.black, shadowOffset: { height: 0, width: 0 }, shadowOpacity: 0.05, @@ -21,7 +22,7 @@ const ANNOUNCEMENT_CARD: ViewStyle = { const TITLE_STYLE: TextStyle = { fontFamily: "Heebo", - color: color.primary, + color: color.primaryLighter, fontSize: 16, marginBottom: spacing[0], } @@ -41,7 +42,8 @@ export const AnnouncementCard = ({ title, body, link }: AnnouncementCardProps) = openLink(link)}> {title && {title}} - {body} + + {removeHtmlTagsAndEntities(body)} ) diff --git a/app/components/announcements/announcements-utils.tsx b/app/components/announcements/announcements-utils.tsx new file mode 100644 index 00000000..e81a2dc0 --- /dev/null +++ b/app/components/announcements/announcements-utils.tsx @@ -0,0 +1,6 @@ +/** + * Remove HTML tags and HTML entities from a given string. + */ +export function removeHtmlTagsAndEntities(input: string) { + return input.replace(/<[^>]+>|&[^;]+;/g, "") +} diff --git a/app/components/announcements/urgent-announcements.tsx b/app/components/announcements/urgent-announcements.tsx index 7efe5cbe..9e2b4b98 100644 --- a/app/components/announcements/urgent-announcements.tsx +++ b/app/components/announcements/urgent-announcements.tsx @@ -8,6 +8,7 @@ import { Text } from "../text/text" import { Screen } from "../screen/screen" import { useIsDarkMode } from "../../hooks" import { AnnouncementCard } from "./announcement-card" +import { removeHtmlTagsAndEntities } from "./announcements-utils" export const UrgentAnnouncements = () => { const isDarkMode = useIsDarkMode() @@ -17,8 +18,8 @@ export const UrgentAnnouncements = () => { 📣 - {messages?.map((m) => ( - + {messages?.map((message, index) => ( + ))} diff --git a/app/screens/planner/Important-announcement-bar.tsx b/app/screens/planner/Important-announcement-bar.tsx index 4b98331d..0c0b2c05 100644 --- a/app/screens/planner/Important-announcement-bar.tsx +++ b/app/screens/planner/Important-announcement-bar.tsx @@ -4,6 +4,7 @@ import Animated, { useAnimatedStyle, useSharedValue, withDelay, withTiming } fro import { color, fontScale } from "../../theme" import { useNavigation } from "@react-navigation/native" import analytics from "@react-native-firebase/analytics" +import { removeHtmlTagsAndEntities } from "../../components/announcements/announcements-utils" const TEXT_STYLE: TextStyle = { color: color.whiteText, @@ -63,8 +64,23 @@ export function ImportantAnnouncementBar({ title }: { title: string }) { onPress={navigateToAnnouncements} > - {title} + {truncateString(removeHtmlTagsAndEntities(title), 5)} ) } + +function truncateString(inputString, numWords) { + // Split the input string into an array of words + const words = inputString.split(" ") + + // Take the first 'numWords' words and join them back into a string + const truncatedString = words.slice(0, numWords).join(" ") + + // Add "..." to the end if there are more words in the original string + if (words.length > numWords) { + return truncatedString + " ..." + } else { + return truncatedString + } +} diff --git a/ios/BetterRail.xcodeproj/project.pbxproj b/ios/BetterRail.xcodeproj/project.pbxproj index d87d3abb..c3a21287 100644 --- a/ios/BetterRail.xcodeproj/project.pbxproj +++ b/ios/BetterRail.xcodeproj/project.pbxproj @@ -1156,14 +1156,14 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = BetterRail/BetterRailDebug.entitlements; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX; ENABLE_BITCODE = NO; INFOPLIST_FILE = BetterRail/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 2.2.0; + MARKETING_VERSION = 2.2.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1196,13 +1196,13 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX; INFOPLIST_FILE = BetterRail/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 2.2.0; + MARKETING_VERSION = 2.2.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1359,14 +1359,14 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; "CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=watchos*]" = UE6BVYPPFX; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = WatchBetterRail_Extension; INFOPLIST_FILE = WatchBetterRail/Info.plist; - MARKETING_VERSION = 2.2.0; + MARKETING_VERSION = 2.2.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG"; @@ -1401,14 +1401,14 @@ "CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=watchos*]" = UE6BVYPPFX; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = WatchBetterRail_Extension; INFOPLIST_FILE = WatchBetterRail/Info.plist; - MARKETING_VERSION = 2.2.0; + MARKETING_VERSION = 2.2.1; MTL_FAST_MATH = YES; OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE"; PRODUCT_BUNDLE_IDENTIFIER = "il.co.better-rail.watchkitapp"; @@ -1437,7 +1437,7 @@ CODE_SIGN_ENTITLEMENTS = "WatchBetterRail Extension/WatchBetterRail Extension.entitlements"; "CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=watchos*]" = UE6BVYPPFX; @@ -1445,7 +1445,7 @@ GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "WatchBetterRail Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 2.2.0; + MARKETING_VERSION = 2.2.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG"; @@ -1478,7 +1478,7 @@ "CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=watchos*]" = UE6BVYPPFX; @@ -1486,7 +1486,7 @@ GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "WatchBetterRail Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 2.2.0; + MARKETING_VERSION = 2.2.1; MTL_FAST_MATH = YES; OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE"; PRODUCT_BUNDLE_IDENTIFIER = "il.co.better-rail.watchkitapp.watchkitextension"; @@ -1516,7 +1516,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = BetterRailWidgetExtensionDebug.entitlements; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX; @@ -1524,7 +1524,7 @@ INFOPLIST_FILE = BetterRailWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 2.2.0; + MARKETING_VERSION = 2.2.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG"; @@ -1557,7 +1557,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX; @@ -1565,7 +1565,7 @@ INFOPLIST_FILE = BetterRailWidget/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 16.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 2.2.0; + MARKETING_VERSION = 2.2.1; MTL_FAST_MATH = YES; OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE"; PRODUCT_BUNDLE_IDENTIFIER = "il.co.better-rail.BetterRailWidget"; @@ -1590,7 +1590,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = StationIntent/StationIntentDebug.entitlements; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX; @@ -1598,7 +1598,7 @@ INFOPLIST_FILE = StationIntent/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 2.2.0; + MARKETING_VERSION = 2.2.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG"; @@ -1629,7 +1629,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX; @@ -1637,7 +1637,7 @@ INFOPLIST_FILE = StationIntent/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 2.2.0; + MARKETING_VERSION = 2.2.1; MTL_FAST_MATH = YES; OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE"; PRODUCT_BUNDLE_IDENTIFIER = "il.co.better-rail.StationIntent"; diff --git a/ios/BetterRail/Info.plist b/ios/BetterRail/Info.plist index 392e5594..2d8daff4 100644 --- a/ios/BetterRail/Info.plist +++ b/ios/BetterRail/Info.plist @@ -23,7 +23,7 @@ CFBundleSignature ???? CFBundleVersion - 10 + 3 ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes diff --git a/ios/BetterRailWidget/Info.plist b/ios/BetterRailWidget/Info.plist index ed8aa94e..2dc31726 100644 --- a/ios/BetterRailWidget/Info.plist +++ b/ios/BetterRailWidget/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 10 + 3 NSExtension NSExtensionPointIdentifier diff --git a/ios/StationIntent/Info.plist b/ios/StationIntent/Info.plist index f6966602..8531d803 100644 --- a/ios/StationIntent/Info.plist +++ b/ios/StationIntent/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 10 + 3 NSExtension NSExtensionAttributes diff --git a/ios/WatchBetterRail Extension/Info.plist b/ios/WatchBetterRail Extension/Info.plist index 98e07170..e688a98d 100644 --- a/ios/WatchBetterRail Extension/Info.plist +++ b/ios/WatchBetterRail Extension/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 10 + 3 CLKComplicationPrincipalClass $(PRODUCT_MODULE_NAME).ComplicationController NSExtension diff --git a/ios/WatchBetterRail/Info.plist b/ios/WatchBetterRail/Info.plist index eef7ee52..d053b690 100644 --- a/ios/WatchBetterRail/Info.plist +++ b/ios/WatchBetterRail/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 10 + 3 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait