@@ -112,6 +112,8 @@ pub enum IapSubscriptionId {
112112 M :: Value <SentMediaQuality >: PartialEq ,
113113 M :: Value <Option <AutoDownloadSettings >>: PartialEq ,
114114 M :: Value <Option <Duration >>: PartialEq ,
115+ M :: Value <AppTheme >: PartialEq ,
116+ M :: Value <CallsUseLessDataSetting >: PartialEq ,
115117) ) ]
116118pub struct AccountSettings < M : Method + ReferencedTypes > {
117119 pub phone_number_sharing : M :: Value < PhoneSharing > ,
@@ -135,11 +137,12 @@ pub struct AccountSettings<M: Method + ReferencedTypes> {
135137 pub custom_chat_colors : CustomColorMap < M > ,
136138 pub optimize_on_device_storage : M :: Value < bool > ,
137139 pub backup_level : M :: Value < Option < BackupLevel > > ,
138- pub show_sealed_sender_indicators : M :: Value < bool > ,
139140 pub default_sent_media_quality : M :: Value < SentMediaQuality > ,
140141 pub auto_download_settings : M :: Value < Option < AutoDownloadSettings > > ,
141142 pub screen_lock_timeout : M :: Value < Option < Duration > > ,
142143 pub pin_reminders : M :: Value < Option < bool > > ,
144+ pub app_theme : M :: Value < AppTheme > ,
145+ pub calls_use_less_data_setting : M :: Value < CallsUseLessDataSetting > ,
143146}
144147
145148#[ derive( Copy , Clone , Debug , PartialEq , serde:: Serialize ) ]
@@ -154,11 +157,18 @@ pub enum SentMediaQuality {
154157 High ,
155158}
156159
160+ #[ derive( Copy , Clone , Debug , PartialEq , serde:: Serialize ) ]
161+ pub enum NavigationBarSize {
162+ Normal ,
163+ Compact ,
164+ }
165+
157166#[ derive( Debug , serde:: Serialize ) ]
158167#[ cfg_attr( test, derive( PartialEq ) ) ]
159168pub struct AndroidSpecificSettings {
160169 pub use_system_emoji : bool ,
161170 pub screenshot_security : bool ,
171+ pub navigation_bar_size : NavigationBarSize ,
162172}
163173
164174#[ derive( Copy , Clone , Debug , PartialEq , serde:: Serialize ) ]
@@ -178,6 +188,20 @@ pub struct AutoDownloadSettings {
178188 pub documents : AutoDownloadOption ,
179189}
180190
191+ #[ derive( Copy , Clone , Debug , PartialEq , serde:: Serialize ) ]
192+ pub enum AppTheme {
193+ System ,
194+ Light ,
195+ Dark ,
196+ }
197+
198+ #[ derive( Copy , Clone , Debug , PartialEq , serde:: Serialize ) ]
199+ pub enum CallsUseLessDataSetting {
200+ Never ,
201+ MobileDataOnly ,
202+ WifiAndMobileData ,
203+ }
204+
181205#[ derive( Debug , displaydoc:: Display , thiserror:: Error ) ]
182206#[ cfg_attr( test, derive( PartialEq ) ) ]
183207pub enum AccountDataError {
@@ -211,6 +235,12 @@ pub enum AccountDataError {
211235 UnknownSentMediaQuality ,
212236 /// auto download option is UNKNOWN
213237 UnknownAutoDownloadOption ,
238+ /// navigation bar size in Android specific settings is UNKNOWN
239+ UnknownAndroidNavigationBarSize ,
240+ /// app theme is UNKNOWN
241+ UnknownAppTheme ,
242+ /// calls use less data setting is UNKNOWN
243+ UnknownCallsUseLessDataSetting ,
214244}
215245
216246#[ derive( Debug , displaydoc:: Display , thiserror:: Error ) ]
@@ -278,7 +308,8 @@ impl<M: Method + ReferencedTypes, C: ReportUnusualTimestamp> TryIntoWith<Account
278308
279309 let android_specific_settings = androidSpecificSettings
280310 . into_option ( )
281- . map ( AndroidSpecificSettings :: from) ;
311+ . map ( AndroidSpecificSettings :: try_from)
312+ . transpose ( ) ?;
282313
283314 Ok ( AccountData {
284315 profile_key : M :: value ( profile_key) ,
@@ -426,11 +457,12 @@ impl<M: Method + ReferencedTypes, C: ReportUnusualTimestamp> TryIntoWith<Account
426457 customChatColors,
427458 optimizeOnDeviceStorage,
428459 backupTier,
429- showSealedSenderIndicators,
430460 defaultSentMediaQuality,
431461 autoDownloadSettings,
432462 screenLockTimeoutMinutes,
433463 pinReminders,
464+ appTheme,
465+ callsUseLessDataSetting,
434466 special_fields : _,
435467 } = self ;
436468
@@ -482,6 +514,26 @@ impl<M: Method + ReferencedTypes, C: ReportUnusualTimestamp> TryIntoWith<Account
482514 let screen_lock_timeout =
483515 screenLockTimeoutMinutes. map ( |mins| Duration :: from_mins ( mins as u64 ) ) ;
484516
517+ use proto:: account_data:: AppTheme as AppThemeProto ;
518+ let app_theme = match appTheme. enum_value_or_default ( ) {
519+ AppThemeProto :: UNKNOWN_APP_THEME => {
520+ return Err ( AccountDataError :: UnknownAppTheme ) ;
521+ }
522+ AppThemeProto :: SYSTEM => AppTheme :: System ,
523+ AppThemeProto :: LIGHT => AppTheme :: Light ,
524+ AppThemeProto :: DARK => AppTheme :: Dark ,
525+ } ;
526+
527+ use proto:: account_data:: CallsUseLessDataSetting as CallDataProto ;
528+ let calls_use_less_data_setting = match callsUseLessDataSetting. enum_value_or_default ( ) {
529+ CallDataProto :: UNKNOWN_CALL_DATA_SETTING => {
530+ return Err ( AccountDataError :: UnknownCallsUseLessDataSetting ) ;
531+ }
532+ CallDataProto :: NEVER => CallsUseLessDataSetting :: Never ,
533+ CallDataProto :: MOBILE_DATA_ONLY => CallsUseLessDataSetting :: MobileDataOnly ,
534+ CallDataProto :: WIFI_AND_MOBILE_DATA => CallsUseLessDataSetting :: WifiAndMobileData ,
535+ } ;
536+
485537 Ok ( AccountSettings {
486538 phone_number_sharing : M :: value ( phone_number_sharing) ,
487539 default_chat_style : M :: value ( default_chat_style) ,
@@ -505,10 +557,11 @@ impl<M: Method + ReferencedTypes, C: ReportUnusualTimestamp> TryIntoWith<Account
505557 optimize_on_device_storage : M :: value ( optimizeOnDeviceStorage) ,
506558 backup_level : M :: value ( backup_level) ,
507559 auto_download_settings : M :: value ( auto_download_settings) ,
508- show_sealed_sender_indicators : M :: value ( showSealedSenderIndicators) ,
509560 pin_reminders : M :: value ( pinReminders) ,
510561 default_sent_media_quality : M :: value ( default_sent_media_quality) ,
511562 screen_lock_timeout : M :: value ( screen_lock_timeout) ,
563+ app_theme : M :: value ( app_theme) ,
564+ calls_use_less_data_setting : M :: value ( calls_use_less_data_setting) ,
512565 } )
513566 }
514567}
@@ -554,18 +607,30 @@ impl TryFrom<proto::account_data::AutoDownloadSettings> for AutoDownloadSettings
554607 }
555608}
556609
557- impl From < proto:: account_data:: AndroidSpecificSettings > for AndroidSpecificSettings {
558- fn from ( value : proto:: account_data:: AndroidSpecificSettings ) -> Self {
610+ impl TryFrom < proto:: account_data:: AndroidSpecificSettings > for AndroidSpecificSettings {
611+ type Error = AccountDataError ;
612+
613+ fn try_from ( value : proto:: account_data:: AndroidSpecificSettings ) -> Result < Self , Self :: Error > {
559614 use proto:: account_data:: AndroidSpecificSettings as SettingsProto ;
560615 let SettingsProto {
561616 useSystemEmoji,
562617 screenshotSecurity,
618+ navigationBarSize,
563619 special_fields : _,
564620 } = value;
565- Self {
621+ use proto:: account_data:: android_specific_settings:: NavigationBarSize as BarSizeProto ;
622+ let navigation_bar_size = match navigationBarSize. enum_value_or_default ( ) {
623+ BarSizeProto :: UNKNOWN_BAR_SIZE => {
624+ return Err ( AccountDataError :: UnknownAndroidNavigationBarSize ) ;
625+ }
626+ BarSizeProto :: NORMAL => NavigationBarSize :: Normal ,
627+ BarSizeProto :: COMPACT => NavigationBarSize :: Compact ,
628+ } ;
629+ Ok ( Self {
566630 use_system_emoji : useSystemEmoji,
567631 screenshot_security : screenshotSecurity,
568- }
632+ navigation_bar_size,
633+ } )
569634 }
570635}
571636
@@ -629,6 +694,9 @@ mod test {
629694 . into ( ) ,
630695 screenLockTimeoutMinutes : Some ( 42 ) ,
631696 defaultSentMediaQuality : proto:: account_data:: SentMediaQuality :: STANDARD . into ( ) ,
697+ appTheme : proto:: account_data:: AppTheme :: SYSTEM . into ( ) ,
698+ callsUseLessDataSetting :
699+ proto:: account_data:: CallsUseLessDataSetting :: MOBILE_DATA_ONLY . into ( ) ,
632700 ..Default :: default ( )
633701 }
634702 }
@@ -659,14 +727,19 @@ mod test {
659727 Self {
660728 useSystemEmoji : true ,
661729 screenshotSecurity : false ,
730+ navigationBarSize :
731+ proto:: account_data:: android_specific_settings:: NavigationBarSize :: COMPACT
732+ . into ( ) ,
662733 ..Default :: default ( )
663734 }
664735 }
665736 }
666737
667738 impl AndroidSpecificSettings {
668739 pub ( crate ) fn from_proto_test_data ( ) -> Self {
669- proto:: account_data:: AndroidSpecificSettings :: test_data ( ) . into ( )
740+ proto:: account_data:: AndroidSpecificSettings :: test_data ( )
741+ . try_into ( )
742+ . expect ( "valid data" )
670743 }
671744 }
672745
@@ -744,10 +817,11 @@ mod test {
744817 optimize_on_device_storage : false ,
745818 backup_level : Some ( BackupLevel :: Paid ) ,
746819 auto_download_settings : Some ( AutoDownloadSettings :: from_proto_test_data ( ) ) ,
747- show_sealed_sender_indicators : false ,
748820 pin_reminders : None ,
749821 default_sent_media_quality : SentMediaQuality :: Standard ,
750822 screen_lock_timeout : Some ( Duration :: from_mins ( 42 ) ) ,
823+ app_theme : AppTheme :: System ,
824+ calls_use_less_data_setting : CallsUseLessDataSetting :: MobileDataOnly ,
751825 } ,
752826 avatar_url_path : "" . to_string ( ) ,
753827 backup_subscription : Some ( IapSubscriberData {
0 commit comments