Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/app/router/main_shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -739,36 +739,36 @@ class _MainShellState extends State<MainShell> with WidgetsBindingObserver {
return [
PollingRegistration(
listener: context.read<UserRepository>(),
interval: const Duration(seconds: EnvironmentConfig.USER_REPOSITORY_POLLING_INTERVAL_SECONDS),
interval: Duration(seconds: EnvironmentConfig.USER_REPOSITORY_POLLING_INTERVAL_SECONDS),
),
PollingRegistration(
listener: context.read<SystemInfoRepository>(),
interval: const Duration(seconds: EnvironmentConfig.SYSTEM_INFO_REPOSITORY_POLLING_INTERVAL_SECONDS),
interval: Duration(seconds: EnvironmentConfig.SYSTEM_INFO_REPOSITORY_POLLING_INTERVAL_SECONDS),
),
if (supportsExtensions)
PollingRegistration(
listener: context.read<ExternalContactsRepository>(),
interval: const Duration(seconds: EnvironmentConfig.EXTERNAL_CONTACTS_REPOSITORY_POLLING_INTERVAL_SECONDS),
interval: Duration(seconds: EnvironmentConfig.EXTERNAL_CONTACTS_REPOSITORY_POLLING_INTERVAL_SECONDS),
),
if (isVoicemailsEnabled)
PollingRegistration(
listener: context.read<VoicemailRepository>(),
interval: const Duration(seconds: EnvironmentConfig.VOICEMAIL_REPOSITORY_POLLING_INTERVAL_SECONDS),
interval: Duration(seconds: EnvironmentConfig.VOICEMAIL_REPOSITORY_POLLING_INTERVAL_SECONDS),
),
if (cliSettingsRepository is CallerIdSettingsRepositoryRemoteImpl)
PollingRegistration(
listener: cliSettingsRepository,
interval: const Duration(seconds: EnvironmentConfig.CALLER_ID_SETTINGS_REPOSITORY_POLLING_INTERVAL_SECONDS),
interval: Duration(seconds: EnvironmentConfig.CALLER_ID_SETTINGS_REPOSITORY_POLLING_INTERVAL_SECONDS),
),
if (favoritesRepository is FavoritesRepositorySyncableImpl)
PollingRegistration(
listener: favoritesRepository,
interval: const Duration(seconds: EnvironmentConfig.FAVORITES_REPOSITORY_POLLING_INTERVAL_SECONDS),
interval: Duration(seconds: EnvironmentConfig.FAVORITES_REPOSITORY_POLLING_INTERVAL_SECONDS),
),
if (sipSubscriptionsRepository is SipSubscriptionsRepositorySyncableImpl)
PollingRegistration(
listener: sipSubscriptionsRepository,
interval: const Duration(seconds: EnvironmentConfig.SIP_SUBSCRIPTIONS_REPOSITORY_POLLING_INTERVAL_SECONDS),
interval: Duration(seconds: EnvironmentConfig.SIP_SUBSCRIPTIONS_REPOSITORY_POLLING_INTERVAL_SECONDS),
),
];
}
Expand Down
14 changes: 11 additions & 3 deletions lib/common/logging/logzio_logging_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ class LogzioLoggingService implements RemoteLoggingService {
static LogzioLoggingService? fromEnvironment(bool enabled) {
if (!enabled) return null;

const url = EnvironmentConfig.REMOTE_LOGZIO_LOGGING_URL;
const token = EnvironmentConfig.REMOTE_LOGZIO_LOGGING_TOKEN;
final url = EnvironmentConfig.REMOTE_LOGZIO_LOGGING_URL;
final token = EnvironmentConfig.REMOTE_LOGZIO_LOGGING_TOKEN;
if (url == null || token == null) return null;

final minLevel = Level.LEVELS.firstWhere((l) => l.name == EnvironmentConfig.REMOTE_LOGZIO_LOG_LEVEL);
final minLevel = Level.LEVELS.firstWhere(
(l) => l.name == EnvironmentConfig.REMOTE_LOGZIO_LOG_LEVEL,
orElse: () {
_logger.warning(
'Unknown REMOTE_LOGZIO_LOG_LEVEL "${EnvironmentConfig.REMOTE_LOGZIO_LOG_LEVEL}"; defaulting to INFO',
);
return Level.INFO;
},
);

return LogzioLoggingService(
url: url,
Expand Down
2 changes: 1 addition & 1 deletion lib/data/feature_access.dart
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ abstract final class CallMapper {
isBlindTransferEnabled: transferConfig.enableBlindTransfer,
isAttendedTransferEnabled: transferConfig.enableAttendedTransfer,
),
triggerConfig: const CallTriggerConfig(
triggerConfig: CallTriggerConfig(
smsFallback: SmsFallbackTriggerConfig(
enabled: EnvironmentConfig.CALL_TRIGGER_MECHANISM_SMS,
available: EnvironmentConfig.CALL_TRIGGER_MECHANISM_SMS,
Expand Down
231 changes: 184 additions & 47 deletions lib/environment_config.dart

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class AutoprovisionScreenPage extends StatelessWidget {
final tenantId = this.tenantId ?? '';
final oldTenant = context.read<AppBloc>().state.session.tenantId;

const defaultCoreUrl = EnvironmentConfig.CORE_URL ?? EnvironmentConfig.DEMO_CORE_URL;
final defaultCoreUrl = EnvironmentConfig.CORE_URL ?? EnvironmentConfig.DEMO_CORE_URL;
final coreUrl = this.coreUrl;
final oldCoreUrl = context.read<AppBloc>().state.session.coreUrl;

const coreVersionConstraint = EnvironmentConfig.CORE_VERSION_CONSTRAINT;
final coreVersionConstraint = EnvironmentConfig.CORE_VERSION_CONSTRAINT;
final config = AutoprovisionConfig(
configToken: configToken,
oldToken: oldToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NumberCdrsScreenPage extends StatelessWidget {
return BlocProvider(
create: (context) =>
NumberCdrsLogCubit(number, context.read<CdrsLocalRepository>(), context.read<CdrsRemoteRepository>())..init(),
child: NumberCdrsScreen(title: const Text(EnvironmentConfig.APP_NAME), videoVisible: videoVisible),
child: NumberCdrsScreen(title: Text(EnvironmentConfig.APP_NAME), videoVisible: videoVisible),
);
}
}
2 changes: 1 addition & 1 deletion lib/features/cdrs/view/recent_cdrs_screen_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RecentCdrsScreenPage extends StatelessWidget {
),
],
child: RecentCdrsScreen(
title: const Text(EnvironmentConfig.APP_NAME),
title: Text(EnvironmentConfig.APP_NAME),
transferEnabled: featureAccess.callConfig.capabilities.isBlindTransferEnabled,
videoEnabled: featureAccess.callConfig.capabilities.isVideoCallEnabled,
chatsEnabled: featureAccess.messagingConfig.chatsPresent,
Expand Down
2 changes: 1 addition & 1 deletion lib/features/contacts/view/contacts_screen_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ContactsScreenPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final widget = ContactsScreen(
title: const Text(EnvironmentConfig.APP_NAME),
title: Text(EnvironmentConfig.APP_NAME),
sourceTypes: sourceTypes,
sourceTypeWidgetBuilder: _contactSourceTypeWidgetBuilder,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/features/favorites/view/favorites_screen_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FavoritesScreenPage extends StatelessWidget {
final cdrsEnabled = featureAccess.bottomMenuConfig.getTabEnabled<RecentsBottomMenuTab>()?.supportsCallHistory;

final widget = FavoritesScreen(
title: const Text(EnvironmentConfig.APP_NAME),
title: Text(EnvironmentConfig.APP_NAME),
transferEnabled: featureAccess.callConfig.capabilities.isBlindTransferEnabled,
videoEnabled: featureAccess.callConfig.capabilities.isVideoCallEnabled,
chatsEnabled: featureAccess.messagingConfig.chatsPresent,
Expand Down
2 changes: 1 addition & 1 deletion lib/features/keypad/view/keypad_screen_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class KeypadScreenPage extends StatelessWidget {
final featureAccess = context.read<FeatureAccess>();

final widget = KeypadScreen(
title: const Text(EnvironmentConfig.APP_NAME),
title: Text(EnvironmentConfig.APP_NAME),
videoEnabled: featureAccess.callConfig.capabilities.isVideoCallEnabled,
transferEnabled: featureAccess.callConfig.capabilities.isBlindTransferEnabled,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/features/push_tokens/bloc/push_tokens_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class PushTokensBloc extends Bloc<PushTokensEvent, PushTokensState> implements P
// In other statuses except of updating an success it will stop retrying.
@visibleForTesting
Future<void> retrieveAndStoreFcmToken() async {
const vapidKey = EnvironmentConfig.FCM_VAPID_KEY;
final vapidKey = EnvironmentConfig.FCM_VAPID_KEY;

final initialStatus = await pushEnvironment.getAvailability();

Expand Down
2 changes: 1 addition & 1 deletion lib/features/recents/view/recents_screen_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RecentsScreenPage extends StatelessWidget {
final featureAccess = context.read<FeatureAccess>();

final widget = RecentsScreen(
title: const Text(EnvironmentConfig.APP_NAME),
title: Text(EnvironmentConfig.APP_NAME),
transferEnabled: featureAccess.callConfig.capabilities.isBlindTransferEnabled,
videoEnabled: featureAccess.callConfig.capabilities.isVideoCallEnabled,
chatsEnabled: featureAccess.messagingConfig.chatsPresent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AboutScreenPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
const appAboutUrl = EnvironmentConfig.APP_ABOUT_URL;
final appAboutUrl = EnvironmentConfig.APP_ABOUT_URL;
final appMetadataProvider = context.read<AppMetadataProvider>();
final appInfo = context.read<AppInfo>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class UserAgreementScreenPage extends StatelessWidget {
Widget build(BuildContext context) {
final appTermsAndConditionsUrl = context.read<FeatureAccess>().termsConfig.configData.uri;

const appName = EnvironmentConfig.APP_NAME;
final appName = EnvironmentConfig.APP_NAME;
final screen = UserAgreementScreen(appTermsAndConditionsUrl: appTermsAndConditionsUrl.toString(), appName: appName);
return screen;
}
Expand Down
8 changes: 4 additions & 4 deletions screenshots/integration_test/take_screenshots_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,25 @@ void main() {
takeScreenshotTestWidgets('main_screen__favorites', () {
return ScreenshotApp(
appBloc: appContext.appBloc,
child: const MainScreenScreenshot(MainFlavor.favorites, Text(EnvironmentConfig.APP_NAME)),
child: MainScreenScreenshot(MainFlavor.favorites, Text(EnvironmentConfig.APP_NAME)),
);
});
takeScreenshotTestWidgets('main_screen__recents', () {
return ScreenshotApp(
appBloc: appContext.appBloc,
child: const MainScreenScreenshot(MainFlavor.recents, Text(EnvironmentConfig.APP_NAME)),
child: MainScreenScreenshot(MainFlavor.recents, Text(EnvironmentConfig.APP_NAME)),
);
});
takeScreenshotTestWidgets('main_screen__keypad', () {
return ScreenshotApp(
appBloc: appContext.appBloc,
child: const MainScreenScreenshot(MainFlavor.keypad, Text(EnvironmentConfig.APP_NAME)),
child: MainScreenScreenshot(MainFlavor.keypad, Text(EnvironmentConfig.APP_NAME)),
);
});
takeScreenshotTestWidgets('main_screen__keypad_dialing', () {
return ScreenshotApp(
appBloc: appContext.appBloc,
child: const MainScreenScreenshot(MainFlavor.keypad, Text(EnvironmentConfig.APP_NAME), keypadDialing: true),
child: MainScreenScreenshot(MainFlavor.keypad, Text(EnvironmentConfig.APP_NAME), keypadDialing: true),
);
});
});
Expand Down
13 changes: 5 additions & 8 deletions screenshots/lib/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,21 @@ class _IndexInputScreenState extends State<IndexInputScreen> {
ScreenshotApp(appBloc: appBloc, child: const LoginSignUpVerifyScreenshot()),
ScreenshotApp(
appBloc: appBloc,
child: const MainScreenScreenshot(MainFlavor.favorites, Text(EnvironmentConfig.APP_NAME)),
child: MainScreenScreenshot(MainFlavor.favorites, Text(EnvironmentConfig.APP_NAME)),
),
ScreenshotApp(
appBloc: appBloc,
child: const MainScreenScreenshot(MainFlavor.recents, Text(EnvironmentConfig.APP_NAME)),
child: MainScreenScreenshot(MainFlavor.recents, Text(EnvironmentConfig.APP_NAME)),
),
ScreenshotApp(appBloc: appBloc, child: MainScreenScreenshot(MainFlavor.keypad, Text(EnvironmentConfig.APP_NAME))),
ScreenshotApp(
appBloc: appBloc,
child: const MainScreenScreenshot(MainFlavor.keypad, Text(EnvironmentConfig.APP_NAME)),
),
ScreenshotApp(
appBloc: appBloc,
child: const MainScreenScreenshot(MainFlavor.keypad, Text(EnvironmentConfig.APP_NAME), keypadDialing: true),
child: MainScreenScreenshot(MainFlavor.keypad, Text(EnvironmentConfig.APP_NAME), keypadDialing: true),
),
ScreenshotApp(
appBloc: appBloc,
child: Builder(
builder: (context) => const MainScreenScreenshot(MainFlavor.messaging, Text(EnvironmentConfig.APP_NAME)),
builder: (context) => MainScreenScreenshot(MainFlavor.messaging, Text(EnvironmentConfig.APP_NAME)),
),
),
ScreenshotApp(appBloc: appBloc, child: const SettingScreenScreenshot()),
Expand Down
2 changes: 1 addition & 1 deletion screenshots/lib/screenshots/main_screen_screenshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class _MainScreenScreenshotState extends State<MainScreenScreenshot> {
BlocProvider<UnreadCountCubit>(create: (_) => MockUnreadCountCubit.withUnreadMessages()),
],
child: ConversationsScreen(
title: const Text(EnvironmentConfig.APP_NAME),
title: Text(EnvironmentConfig.APP_NAME),
// Dual tabs expose the chat/sms tab bar (its TabController is local, so switching
// works) for the interactive preview; the snapshot stays chat-only.
initialTabsState: widget.interactive
Expand Down
95 changes: 95 additions & 0 deletions test/environment_config_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import 'package:flutter_test/flutter_test.dart';

import 'package:webtrit_phone/environment_config.dart';

void main() {
group('EnvRegistry', () {
late EnvRegistry registry;

setUp(() => registry = EnvRegistry());

test('string: override wins; empty and missing fall back to compile-time', () {
registry.apply({'A': 'override'});
expect(registry.string('A', 'default'), 'override');

registry.apply({'A': ''});
expect(registry.string('A', 'default'), 'default');

registry.apply({});
expect(registry.string('A', 'default'), 'default');
});

test('stringOrNull: empty and missing fall back (may be null)', () {
registry.apply({'A': ''});
expect(registry.stringOrNull('A', null), isNull);
expect(registry.stringOrNull('A', 'd'), 'd');

registry.apply({'A': 'x'});
expect(registry.stringOrNull('A', 'd'), 'x');
});

test('boolean: true/false honoured; malformed and empty fall back', () {
registry.apply({'B': 'TRUE'});
expect(registry.boolean('B', false), isTrue);

registry.apply({'B': 'false'});
expect(registry.boolean('B', true), isFalse);

registry.apply({'B': 'yes'}); // malformed -> compile-time
expect(registry.boolean('B', true), isTrue);

registry.apply({'B': ''}); // empty -> compile-time
expect(registry.boolean('B', true), isTrue);

registry.apply({});
expect(registry.boolean('B', false), isFalse);
});

test('integer: numeric honoured; malformed and empty fall back', () {
registry.apply({'N': '42'});
expect(registry.integer('N', 1), 42);

registry.apply({'N': 'abc'});
expect(registry.integer('N', 7), 7);

registry.apply({'N': ''});
expect(registry.integer('N', 7), 7);
});

test('has / clear', () {
registry.apply({'A': 'x'});
expect(registry.has('A'), isTrue);

registry.clear();
expect(registry.has('A'), isFalse);
});
});

group('EnvironmentConfig overrides', () {
tearDown(EnvironmentConfig.clearOverrides);

test('APP_NAME reflects an override and falls back when empty/cleared', () {
EnvironmentConfig.applyOverrides({EnvironmentConfig.APP_NAME__NAME: 'Custom'});
expect(EnvironmentConfig.APP_NAME, 'Custom');

EnvironmentConfig.applyOverrides({EnvironmentConfig.APP_NAME__NAME: ''});
expect(EnvironmentConfig.APP_NAME, 'WebTrit');

EnvironmentConfig.clearOverrides();
expect(EnvironmentConfig.APP_NAME, 'WebTrit');
});

test('a non-positive polling-interval override falls back to the default', () {
const name = EnvironmentConfig.USER_REPOSITORY_POLLING_INTERVAL_SECONDS__NAME;

EnvironmentConfig.applyOverrides({name: '0'});
expect(EnvironmentConfig.USER_REPOSITORY_POLLING_INTERVAL_SECONDS, 10);

EnvironmentConfig.applyOverrides({name: '-5'});
expect(EnvironmentConfig.USER_REPOSITORY_POLLING_INTERVAL_SECONDS, 10);

EnvironmentConfig.applyOverrides({name: '30'});
expect(EnvironmentConfig.USER_REPOSITORY_POLLING_INTERVAL_SECONDS, 30);
});
});
}
Loading