Commit b2fb65e0 by Ramesh Babu Puvvadi

added new changes

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