Commit b2fb65e0 by Ramesh Babu Puvvadi

added new changes

parent f4cbf453
......@@ -37,6 +37,8 @@
<array>
<string>tel</string>
</array>
<key>NSAppleMusicUsageDescription</key>
<string>This app requires access to your music usage description</string>
<key>NSCameraUsageDescription</key>
<string>Camera access is required to capture</string>
<key>NSPhotoLibraryAddUsageDescription</key>
......
......@@ -3,8 +3,8 @@ import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
class FirebaseApi {
final _firebasemessaging = FirebaseMessaging.instance;
final _firebasemessaging = FirebaseMessaging.instance;
Future<void> initNotifications() async {
await _firebasemessaging.requestPermission();
final fcmToken = await _firebasemessaging.getToken();
......@@ -15,8 +15,11 @@ class FirebaseApi {
Future<void> handleBackgroundMessage(RemoteMessage message) async {
await Firebase.initializeApp();
//print('Title :${message.notification?.title}');
//print('Title :${message.notification?.body}');
//print('Title :${message.data}');
if (kDebugMode) {
print('Firebase title :${message.notification?.title}');
print('Firebase body :${message.notification?.body}');
print('Firebase data :${message.data}');
}
}
}
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:storemonitor/Screens/Constants.dart';
import 'package:video_player/video_player.dart';
......@@ -7,10 +8,7 @@ class VideoApp extends StatefulWidget {
final String id;
final String comment;
const VideoApp({Key? key,
required this.message,
required this.id,
required this.comment}): super(key: key);
const VideoApp({Key? key, required this.message, required this.id, required this.comment}): super(key: key);
@override
_VideoAppState createState() => _VideoAppState();
......@@ -25,49 +23,28 @@ class _VideoAppState extends State<VideoApp> {
@override
void initState() {
super.initState();
isdata = widget.message;
//List<String> parts = isdata.split('/');
// // Find the part that contains the file ID
// String? fileId;
// for (String part in parts) {
// if (part.startsWith('d/')) {
// fileId = part.substring(2);
// print('if Condition: $fileId');
// break;
// }
// }
// if (fileId != null) {
// print('File ID: $fileId');
// } else {
// print('File ID not found in the link');
// }
isdata = widget.message;
String googleDriveFileUrl = isdata;
// Split the URL by '/'
List<String> urlParts = googleDriveFileUrl.split('/');
int indexOfD = urlParts.indexOf('d');
// The file ID is the part after 'd'
String fileId = urlParts.elementAt(indexOfD + 1);
//print('Testing : $urlParts[5]');
// The fileId is the first part after the last '/'
//String fileId = urlParts.last;
print('File ID: $fileId');
List<String> urlParts = googleDriveFileUrl.split('/');
int indexOfD = urlParts.indexOf('d');
String fileId = urlParts.elementAt(indexOfD + 1);
if (kDebugMode) {
print('File ID: $fileId');
}
videoUrl = 'https://drive.google.com/uc?export=view&id=$fileId';
print('VideoLink : $videoUrl');
if (kDebugMode) {
print('VideoLink : $videoUrl');
}
_controller = VideoPlayerController.networkUrl(Uri.parse(videoUrl))
..initialize().then((_) {
setState(() {
_controller.seekTo(const Duration(microseconds: 1));
_controller.play();
true;
});
});
setState(() {
_controller.seekTo(const Duration(microseconds: 1));
_controller.play();
true;
});
});
}
// void _initializeVideoPlayer() async {
// videoUrl =
// 'https://drive.google.com/uc?export=view&id=1QVUJ34BKRilfchA_0ppmM3gFIPvYIl7i';
......
......@@ -382,30 +382,22 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
void startListening() {
_logEvent('start listening');
lastWords = '';
lastError = '';
final pauseFor = int.tryParse(_pauseForController.text);
lastWords = '';
lastError = '';
final pauseFor = int.tryParse(_pauseForController.text);
final listenFor = int.tryParse(_listenForController.text);
final options = SpeechListenOptions(
onDevice: _onDevice,
listenMode: ListenMode.confirmation,
cancelOnError: true,
partialResults: true,
autoPunctuation: true,
enableHapticFeedback: true);
// Note that `listenFor` is the maximum, not the minimum, on some
// systems recognition will be stopped before this value is reached.
// Similarly `pauseFor` is a maximum not a minimum and may be ignored
// on some devices.
final options = SpeechListenOptions(onDevice: _onDevice,listenMode: ListenMode.confirmation,cancelOnError: true, partialResults: true,autoPunctuation: true,enableHapticFeedback: true );
speech.listen(
onResult: resultListener,
listenFor: Duration(seconds: listenFor ?? 30),
pauseFor: Duration(seconds: pauseFor ?? 3),
localeId: _currentLocaleId,
onResult : resultListener,
listenFor: Duration(seconds: listenFor ?? 30),
pauseFor : Duration(seconds: pauseFor ?? 3),
localeId : _currentLocaleId,
onSoundLevelChange: soundLevelListener,
listenOptions: options,
);
setState(() {});
}
void stopListening() {
......@@ -426,21 +418,18 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
// This callback is invoked each time new recognition results are
// available after `listen` is called.
void resultListener(SpeechRecognitionResult result) {
_logEvent(
'Result listener final: ${result.finalResult}, words: ${result.recognizedWords}');
_logEvent('Result listener final: ${result.finalResult}, words: ${result.recognizedWords}');
if (kDebugMode) {
print(
'\nTesting listener final: ${result.finalResult}, words: ${result.recognizedWords}');
print('\nTesting listener final: ${result.finalResult}, words: ${result.recognizedWords}');
}
setState(() async {
//lastWords = '${result.recognizedWords} - ${result.finalResult}';
lastWords = result.recognizedWords;
if (result.finalResult) {
if (kDebugMode) {
print('Final Result: $lastWords');
}
//await Future.delayed(Duration.zero);
remotevalidate(lastWords);
}
});
......@@ -449,23 +438,20 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
void soundLevelListener(double level) {
minSoundLevel = min(minSoundLevel, level);
maxSoundLevel = max(maxSoundLevel, level);
// _logEvent('sound level $level: $minSoundLevel - $maxSoundLevel ');
setState(() {
this.level = level;
});
}
void errorListener(SpeechRecognitionError error) {
_logEvent(
'Received error status: $error, listening: ${speech.isListening}');
_logEvent('Received error status: $error, listening: ${speech.isListening}');
setState(() {
lastError = '${error.errorMsg} - ${error.permanent}';
});
}
void statusListener(String status) {
_logEvent(
'Received listener status: $status, listening: ${speech.isListening}');
_logEvent('Received listener status: $status, listening: ${speech.isListening}');
setState(() {
lastStatus = status;
});
......@@ -478,6 +464,7 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
// debugPrint(selectedVal);
//}
void _logEvent(String eventDescription) {
if (_logEvents) {
var eventTime = DateTime.now().toIso8601String();
......@@ -491,7 +478,7 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
print('Hitting from Keyboard or voice !!!!!!!!!!!!$lastWords');
}
//String res = await RemoteData().getSpeechResponse(lastWords, userid!);
String res = await RemoteData().getSpeechResponse(lastWords, userid!);
String res = await RemoteData().getSpeechResponse(lastWords, userid!);
//var response = jsonDecode(res);
Map<String, dynamic> jsonResponse = jsonDecode(res);
//List<dynamic> output1 = jsonResponse['output1'];
......@@ -511,8 +498,7 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
if (kDebugMode) {
print('DataFetching1 $zoneValue');
}
Data dataInstance =
Data(question: lastWords, answer: zoneValue, image: 'None');
Data dataInstance = Data(question: lastWords, answer: zoneValue, image: 'None');
await ftts.setLanguage('en-IN');
//await ftts.setLanguage("en-IN");
await ftts.setSpeechRate(0.5); //speed of speech
......@@ -525,20 +511,14 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
print(await ftts.getVoices);
}
await ftts.setVoice({'name': 'Rishi', 'locale': 'en-IN'});
//await ftts.setVoice(ftts.getDefaultVoice());
//await ftts.setIosAudioCategory(
//[IosTextToSpeechAudioCategory.playAndRecord,
//IosTextToSpeechAudioCategoryOptions.defaultToSpeaker],
//);
await ftts.setIosAudioCategory(
IosTextToSpeechAudioCategory.playback,
[
IosTextToSpeechAudioCategoryOptions.allowBluetooth,
[ IosTextToSpeechAudioCategoryOptions.allowBluetooth,
IosTextToSpeechAudioCategoryOptions.allowBluetoothA2DP,
IosTextToSpeechAudioCategoryOptions.mixWithOthers,
IosTextToSpeechAudioCategoryOptions.defaultToSpeaker
],
IosTextToSpeechAudioMode.defaultMode);
IosTextToSpeechAudioCategoryOptions.defaultToSpeaker ],
IosTextToSpeechAudioMode.defaultMode
);
} else {
await ftts.setVoice({'name': ' Rishi', "locale": "en-IN"});
}
......@@ -589,7 +569,6 @@ class _SpeechSampleAppState extends State<SpeechSampleApp1> {
setState(() {
data = data;
});
lastWords = '';
setState(() {});
}
......
......@@ -109,6 +109,7 @@ class _CheckRegistration extends State<CheckRegistration> {
),
),
),
// ElevatedButton(
// onPressed: () {
// if (_empId.text.isNotEmpty) {
......@@ -171,11 +172,11 @@ class _CheckRegistration extends State<CheckRegistration> {
_empId.text == '';
_empId.clear();
Constants('Check Registration', 'Registered Sucessfully')
.showAlertDialog(context, false);
.showAlertDialog(context, true);
} else {
Navigator.pop(context);
Constants('Check Registration', 'Registation Failed')
.showAlertDialog(context, false);
.showAlertDialog(context, true);
file.delete();
//Navigator.of(context).pop();
}
......
......@@ -50,33 +50,25 @@ class _IssueVideos extends State<IssueVideos> {
Future<void> loadData() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String? userId = prefs.getString("storeName");
//print(userId);
storesList = (json.decode(userId!) as List<dynamic>)
.map((map) => map['name'] as String)
.toList();
//print(storesList);
int index = storesList!.indexWhere((item) => item.contains(isMeeters));
setState(() {
selectedDropdownItem = storesList![index];
//print(selectedDropdownItem);
getData(selectedDropdownItem!);
});
}
void getData(String name) async {
if (kDebugMode) {
print("Second Class Hitting");
}
bool isInternetConnected = await Constants.checkInternetConnectivity();
if (isInternetConnected) {
showDialog(
context: context,
builder: (context) {
return const Center(
child: CircularProgressIndicator(
color: Color.fromARGB(255, 29, 20, 34)));
});
context: context,
builder: (context) {
return const Center(child: CircularProgressIndicator(color: Color.fromARGB(255, 29, 20, 34)));
}
);
final respon = await RemoteData().getIssueVideos(name);
Map<String, dynamic> responseMap = jsonDecode(respon);
if (kDebugMode) {
......@@ -87,13 +79,10 @@ class _IssueVideos extends State<IssueVideos> {
setState(() {
notificationslist;
});
//Navigator.of(context).pop();
} else {
//print('response $responseMap');
issue = Issue.fromJson(responseMap);
notificationslist = issue!.data;
if (notificationslist!.isNotEmpty) {
//Navigator.of(context).pop();
setState(() {
notificationslist;
});
......
......@@ -62,6 +62,7 @@ class _SignUpState extends State<SignUp> {
}
String jsonStr = json.encode(normalArray);
Navigator.pop(context);
print('User Level :$userResponse.level');
Constants.saveLoginCredentials(userResponse.empName, _email.text,
jsonStr, '', userResponse.level, true);
Navigator.pushReplacement(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment