Merge pull request 'display alarm notification' (#20) from SD-224 into develop

Reviewed-on: #20
This commit is contained in:
CiufudeanDani 2022-04-04 07:07:40 +00:00
commit 73d2cedfba

View File

@ -1688,64 +1688,63 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
SM.Debug("Unit imei:" + tempArr[0]); SM.Debug("Unit imei:" + tempArr[0]);
String unitIMEI = tempArr[0]; String unitIMEI = tempArr[0];
// change Visual Elements
setImei(unitIMEI);
switch (msg.opCode) {
case 135:
setMess("speed " + tempArr[1]);
break;
case 136:
setMess("landmark " + tempArr[1]);
break;
case 137:
setMess("zone " + tempArr[1]);
break;
case 140:
setMess("telemetry " + tempArr[1]);
break;
default:
// 138
setMess("emergency");
}
myHandler.post(updateResultsAlarm);
if ((msg.opCode == 138) && (AppParams.crtTab == AppParams.Tabs.live)) {
SuperVehicle superVehicle = getSuperVehHash().get(Long.parseLong(unitIMEI));
if (superVehicle != null) {
//if is not check i need to force check to put on the map
boolean forceChecked = false;
if (!superVehicle.needUpdate) {
superVehicle.needUpdate = true;
forceChecked = true;
}
try {
int x = 0;
if (forceChecked) {
for (Vehicle veh : getAllVehicle()) {
if (veh.imei.compareTo(unitIMEI) == 0) break;
x++;
}
} else x = -1;
if (getLiveActivity() != null) {
if (x != getAllVehicle().size())
getLiveActivity().emergencyAlarmReceived(x, superVehicle.lat, superVehicle.lng);
else
getLiveActivity().emergencyAlarmReceived(-1, superVehicle.lat, superVehicle.lng);
}
} catch (Exception ex) {
SM.Debug(HASH_ERROR_MESSAGE + ex);
}
}
}
//list for SMS //list for SMS
if (AppParams.crtTab == AppParams.Tabs.alarms) { if (AppParams.crtTab == AppParams.Tabs.alarms) {
SM.Debug("currentActivity instanceof AlarmActivity - newSMS | " + tempArr[0] + " | " + tempArr[1]); SM.Debug("currentActivity instanceof AlarmActivity - newSMS | " + tempArr[0] + " | " + tempArr[1]);
getAlarms(AppParams.USERID); getAlarms(AppParams.USERID);
} }
// if tab is not TextTab
if (tabHost.getCurrentTab() != 5) {
// change Visual Elements
setImei(unitIMEI);
switch (msg.opCode) {
case 135:
setMess("speed " + tempArr[1]);
break;
case 136:
setMess("landmark " + tempArr[1]);
break;
case 137:
setMess("zone " + tempArr[1]);
break;
case 140:
setMess("telemetry " + tempArr[1]);
break;
default:
// 138
setMess("emergency");
}
myHandler.post(updateResultsAlarm);
if ((msg.opCode == 138) && (AppParams.crtTab == AppParams.Tabs.live)) {
SuperVehicle superVehicle = getSuperVehHash().get(Long.parseLong(unitIMEI));
if (superVehicle != null) {
//if is not check i need to force check to put on the map
boolean forceChecked = false;
if (!superVehicle.needUpdate) {
superVehicle.needUpdate = true;
forceChecked = true;
}
try {
int x = 0;
if (forceChecked) {
for (Vehicle veh : getAllVehicle()) {
if (veh.imei.compareTo(unitIMEI) == 0) break;
x++;
}
} else x = -1;
if (getLiveActivity() != null) {
if (x != getAllVehicle().size())
getLiveActivity().emergencyAlarmReceived(x, superVehicle.lat, superVehicle.lng);
else
getLiveActivity().emergencyAlarmReceived(-1, superVehicle.lat, superVehicle.lng);
}
} catch (Exception ex) {
SM.Debug(HASH_ERROR_MESSAGE + ex);
}
}
}
}
} }
@Override @Override
@ -2052,7 +2051,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
.setAutoCancel(true) .setAutoCancel(true)
.setContentIntent(pendingIntent); .setContentIntent(pendingIntent);
Log.v("test111", "test");
NotificationManagerCompat managerCompat = NotificationManagerCompat.from(context); NotificationManagerCompat managerCompat = NotificationManagerCompat.from(context);
managerCompat.notify(icon, builder.build()); managerCompat.notify(icon, builder.build());
} }