stealth-mode #27
@ -4,7 +4,9 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import '../../services/contact_service.dart';
|
import '../../services/contact_service.dart';
|
||||||
|
import '../../services/obfuscate_service.dart'; // Import ObfuscateService
|
||||||
import '../contacts/widgets/add_contact_button.dart';
|
import '../contacts/widgets/add_contact_button.dart';
|
||||||
|
import '../../globals.dart' as globals;
|
||||||
|
|
||||||
class CompositionPage extends StatefulWidget {
|
class CompositionPage extends StatefulWidget {
|
||||||
const CompositionPage({super.key});
|
const CompositionPage({super.key});
|
||||||
@ -19,6 +21,9 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
List<Contact> _filteredContacts = [];
|
List<Contact> _filteredContacts = [];
|
||||||
final ContactService _contactService = ContactService();
|
final ContactService _contactService = ContactService();
|
||||||
|
|
||||||
|
// Instantiate the ObfuscateService
|
||||||
|
final ObfuscateService _obfuscateService = ObfuscateService();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -114,16 +119,12 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
: 'No phone number';
|
: 'No phone number';
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
'${contact.displayName.isNotEmpty ? contact.displayName[0] : ''}...${contact.displayName.isNotEmpty ? contact.displayName[contact.displayName.length - 1] : ''}',
|
_obfuscateService.obfuscateData(contact.displayName),
|
||||||
// contact.displayName
|
style: const TextStyle(color: Colors.white),
|
||||||
style:
|
|
||||||
const TextStyle(color: Colors.white),
|
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'${phoneNumber.isNotEmpty ? phoneNumber[0] : ''}...${phoneNumber.isNotEmpty ? phoneNumber[phoneNumber.length - 1] : ''}',
|
_obfuscateService.obfuscateData(phoneNumber),
|
||||||
// phoneNumber,
|
style: const TextStyle(color: Colors.grey),
|
||||||
style:
|
|
||||||
const TextStyle(color: Colors.grey),
|
|
||||||
),
|
),
|
||||||
trailing: Row(
|
trailing: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
1
dialer/lib/globals.dart
Normal file
1
dialer/lib/globals.dart
Normal file
@ -0,0 +1 @@
|
|||||||
|
bool isStealthMode = false;
|
@ -1,13 +1,16 @@
|
|||||||
import 'package:dialer/features/home/home_page.dart';
|
import 'package:dialer/features/home/home_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:dialer/features/contacts/contact_state.dart';
|
import 'package:dialer/features/contacts/contact_state.dart';
|
||||||
|
import 'globals.dart' as globals;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
globals.isStealthMode = String.fromEnvironment('STEALTH', defaultValue: 'false') == 'true';
|
||||||
|
|
||||||
|
runApp(const Dialer());
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class Dialer extends StatelessWidget {
|
||||||
const MyApp({super.key});
|
const Dialer({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
38
dialer/lib/services/obfuscate_service.dart
Normal file
38
dialer/lib/services/obfuscate_service.dart
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// lib/services/obfuscate_service.dart
|
||||||
|
|
||||||
|
import '../../globals.dart' as globals;
|
||||||
|
|
||||||
|
class ObfuscateService {
|
||||||
|
// Private constructor
|
||||||
|
ObfuscateService._privateConstructor();
|
||||||
|
|
||||||
|
// Singleton instance
|
||||||
|
static final ObfuscateService _instance = ObfuscateService._privateConstructor();
|
||||||
|
|
||||||
|
// Factory constructor to return the same instance
|
||||||
|
factory ObfuscateService() {
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Public method to obfuscate data
|
||||||
|
String obfuscateData(String data) {
|
||||||
|
if (globals.isStealthMode) {
|
||||||
|
return _obfuscateData(data);
|
||||||
|
} else {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Private helper method for obfuscation logic
|
||||||
|
String _obfuscateData(String data) {
|
||||||
|
if (data.isNotEmpty) {
|
||||||
|
// Ensure the string has at least two characters to obfuscate
|
||||||
|
if (data.length == 1) {
|
||||||
|
return '${data[0]}';
|
||||||
|
} else {
|
||||||
|
return '${data[0]}...${data[data.length - 1]}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@ import 'package:dialer/main.dart';
|
|||||||
void main() {
|
void main() {
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||||
// Build our app and trigger a frame.
|
// Build our app and trigger a frame.
|
||||||
await tester.pumpWidget(const MyApp());
|
await tester.pumpWidget(const Dialer(stealthMode: false,));
|
||||||
|
|
||||||
// Verify that our counter starts at 0.
|
// Verify that our counter starts at 0.
|
||||||
expect(find.text('0'), findsOneWidget);
|
expect(find.text('0'), findsOneWidget);
|
||||||
|
Loading…
Reference in New Issue
Block a user