feature/apk_versioning_mechanism #7

Merged
CiufudeanDani merged 12 commits from feature/apk_versioning_mechanism into develop 2022-03-22 13:19:48 +00:00
2 changed files with 303 additions and 623 deletions
Showing only changes of commit 4420af337d - Show all commits

View File

@ -21,6 +21,7 @@ import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions; import com.google.android.gms.maps.model.PolylineOptions;
import com.safemobile.lib.AppParams; import com.safemobile.lib.AppParams;
import com.safemobile.lib.HistPos; import com.safemobile.lib.HistPos;
import com.safemobile.lib.OperationCodes;
import com.safemobile.lib.SM; import com.safemobile.lib.SM;
import com.safemobile.lib.Vehicle; import com.safemobile.lib.Vehicle;
@ -38,6 +39,7 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
private Spinner spinnerVehicle; private Spinner spinnerVehicle;
private ImageView changeMapType, checkTraffic, slideLayoutImage; private ImageView changeMapType, checkTraffic, slideLayoutImage;
private LinearLayout layoutTraffic, slidelayout, layoutVehicles; private LinearLayout layoutTraffic, slidelayout, layoutVehicles;
private Date startDate, endDate;
private ArrayList<Vehicle> allVehicle = new ArrayList<>(); private ArrayList<Vehicle> allVehicle = new ArrayList<>();
private ArrayList<String> allVehicleNames = new ArrayList<>(); private ArrayList<String> allVehicleNames = new ArrayList<>();
@ -88,6 +90,9 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
// }); // });
setDate(); setDate();
parentTab.executeNetworkStuff(new String[] {OperationCodes.GetHistoryPositions + "", allVehicle.get(spinnerVehicle.getSelectedItemPosition()).sc_id + "",
(startDate.getTime()/ 1000L) + "", (endDate.getTime()/ 1000L) + ""});
} }
private void displayHistory(ArrayList<HistPos> demoPositions) { private void displayHistory(ArrayList<HistPos> demoPositions) {
@ -110,9 +115,9 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
private void setDate() { private void setDate() {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
Date endDate = calendar.getTime(); endDate = calendar.getTime();
calendar.add(Calendar.DATE, -1); calendar.add(Calendar.DATE, -1);
Date startDate = calendar.getTime(); startDate = calendar.getTime();
LinearLayout layoutStartPicker = findViewById(R.id.layoutStartPicker); LinearLayout layoutStartPicker = findViewById(R.id.layoutStartPicker);
TextView textViewDate = findViewById(R.id.textViewStartDate); TextView textViewDate = findViewById(R.id.textViewStartDate);

View File

@ -1539,79 +1539,69 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
SM.Debug("tmpHist seqID:"+tmpHist.seqID); SM.Debug("tmpHist seqID:"+tmpHist.seqID);
// //
int pos = Integer.parseInt(tmpHist.seqID.substring(0,tmpHist.seqID.indexOf('.'))); int pos = Integer.parseInt(tmpHist.seqID.substring(0,tmpHist.seqID.indexOf('.')));
int all = Integer.parseInt(tmpHist.seqID.substring(tmpHist.seqID.indexOf('.')+1,tmpHist.seqID.length())); int all = Integer.parseInt(tmpHist.seqID.substring(tmpHist.seqID.indexOf('.') + 1));
if (all != 0) { if (all != 0) {
if (firstHistData) { if (firstHistData) {
try { try {
for(int i=0;i<all;i++) for(int i=0;i<all;i++)
HistMsgList.add(false); HistMsgList.add(false);
} catch (Exception e) { } catch (Exception e) {
SM.Debug("Error on init hashTable:"+e.toString()); SM.Debug("Error on init hashTable:"+ e);
} }
firstHistData =false; firstHistData =false;
} }
HistMsgList.set(pos-1, true); HistMsgList.set(pos-1, true);
for(int i=0;i<(all);i++) for (int i = 0; i < all; i++) {
{ if (!HistMsgList.get(i)) {
if (!HistMsgList.get(i))
{
SendDataToMap =false; SendDataToMap =false;
break; break;
} }
} }
} } else
else SendDataToMap =true; SendDataToMap =true;
} } catch (Exception e) {
catch (Exception e)
{
SM.Debug("Error on parse: "+ e); SM.Debug("Error on parse: "+ e);
} }
if (SendDataToMap) { if (SendDataToMap) {
Collections.sort(HistPosList, (Comparator<Object>) (o1, o2) -> { Collections.sort(HistPosList, (Comparator<Object>) (o1, o2) -> {
HistPos p1 = (HistPos) o1; HistPos p1 = (HistPos) o1;
HistPos p2 = (HistPos) o2; HistPos p2 = (HistPos) o2;
if (p1.timeGMT<p2.timeGMT) return -1; if (p1.timeGMT < p2.timeGMT)
else if (p1.timeGMT==p2.timeGMT) return 0; return -1;
else return 1; else if (p1.timeGMT == p2.timeGMT)
return 0;
else
return 1;
}); });
//list for live //list for live
if(AppParams.crtTab == AppParams.Tabs.history) if (AppParams.crtTab == AppParams.Tabs.history) {
{ try {
//SM.Debug("+++++ duda +++++"); if(historyActivity != null) {
try
{
//Thread.sleep(100);
if(historyActivity != null)
{
// cancel last update // cancel last update
historyActivity.UpdateCancel(); historyActivity.UpdateCancel();
Thread.sleep(101); Thread.sleep(101);
if (HistPosList.size()<2000) if (HistPosList.size() < 2000) {
{ if (HistPosList.size() == 1 && HistPosList.get(0).timeGMT == 0)
if ((HistPosList.size()==1) && (HistPosList.get(0).timeGMT==0))
;// do nothing is not data message ;// do nothing is not data message
else else
historyActivity.UpdateNrPos(HistPosList.size()); historyActivity.UpdateNrPos(HistPosList.size());
Thread.sleep(100); Thread.sleep(100);
historyActivity.UpdateMap(); historyActivity.UpdateMap();
} } else
else
historyActivity.UpdateUnableDisp(); // update with more than 200 points historyActivity.UpdateUnableDisp(); // update with more than 200 points
} }
} }
catch (Exception ex) catch (Exception ex) {
{ SM.Debug("Error load hash: "+ ex);
SM.Debug("Error load hash:"+ex.toString());
} }
} }
SM.Debug("Got HistPost msg.data: " + msg.data); SM.Debug("Got HistPost msg.data: " + msg.data);
} }
} } else
else SM.Debug("Drop history data"); SM.Debug("Drop history data");
} }
@Override @Override
@ -1620,12 +1610,9 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
TCPmsg msg= event.msg(); TCPmsg msg= event.msg();
RadioMSG rmsg = new RadioMSG(msg); RadioMSG rmsg = new RadioMSG(msg);
if(!NOSOUND) if (!NOSOUND) {
{
// update Zone and Channel // update Zone and Channel
if(radioActivity != null && rmsg.zac !=null) if (radioActivity != null && rmsg.zac != null) {
{
// update Zone and Channel in the allRadio List // update Zone and Channel in the allRadio List
for (RadioGW radio: allRadios) { for (RadioGW radio: allRadios) {
if (radio.GW_ID == rmsg.zac.gwID && radio.ID == rmsg.zac.rgwID) { if (radio.GW_ID == rmsg.zac.gwID && radio.ID == rmsg.zac.rgwID) {
@ -1636,38 +1623,29 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
AppParams.crtZoneAndChannel = rmsg.zac; AppParams.crtZoneAndChannel = rmsg.zac;
notifyBroadcast(OperationCodes.CHANNEL_BRDCST+""); notifyBroadcast(OperationCodes.CHANNEL_BRDCST+"");
//radioActivity.UpdateZoneCH(rmsg.zac.rgwID, rmsg.zac.gwID, rmsg.zac.zoneNr, rmsg.zac.channelNr);
SM.Debug("Received from Apps -> UpdateZoneCH(" + rmsg.zac.rgwID + "," + rmsg.zac.gwID + "," + rmsg.zac.zoneNr + "," + rmsg.zac.channelNr + ")"); SM.Debug("Received from Apps -> UpdateZoneCH(" + rmsg.zac.rgwID + "," + rmsg.zac.gwID + "," + rmsg.zac.zoneNr + "," + rmsg.zac.channelNr + ")");
} }
//list for SMS //list for SMS
if(AppParams.crtTab == AppParams.Tabs.radio) if (AppParams.crtTab == AppParams.Tabs.radio) {
{
SM.Debug("#### RadioActivity"); SM.Debug("#### RadioActivity");
// set crt activity to Radio // set crt activity to Radio
crtActivity = RADIO; crtActivity = RADIO;
SM.Debug("## " + (rmsg.RadioGWList!=null? "RadioGWList" + rmsg.RadioGWList.size() : "RadioGWList = null")); SM.Debug("## " + (rmsg.RadioGWList!=null? "RadioGWList" + rmsg.RadioGWList.size() : "RadioGWList = null"));
SM.Debug("## " + (rmsg.zac!=null? "zac" + rmsg.zac.toString() : "zac = null")); SM.Debug("## " + (rmsg.zac!=null? "zac" + rmsg.zac : "zac = null"));
SM.Debug("## " + (rmsg.rStatus!=null? "rStatus" + rmsg.rStatus.toString() : "rStatus = null")); SM.Debug("## " + (rmsg.rStatus!=null? "rStatus" + rmsg.rStatus : "rStatus = null"));
if(radioActivity!= null && rmsg.RadioGWList!=null) if (radioActivity != null && rmsg.RadioGWList != null) {
{
radioActivity.UpdateRadios(rmsg.RadioGWList); radioActivity.UpdateRadios(rmsg.RadioGWList);
SM.Debug("Received from Apps -> UpdateRadios( count:" + rmsg.RadioGWList.size() + ")"); SM.Debug("Received from Apps -> UpdateRadios( count:" + rmsg.RadioGWList.size() + ")");
} }
if (radioActivity != null &&rmsg.rStatus != null) {
if(radioActivity != null &&rmsg.rStatus !=null)
{
// update status in the crtRadio List // update status in the crtRadio List
for (RadioGW radio : allRadios) { for (RadioGW radio : allRadios) {
if (radio.GW_ID == rmsg.rStatus.gwID && radio.ID == rmsg.rStatus.rgwID) if (radio.GW_ID == rmsg.rStatus.gwID && radio.ID == rmsg.rStatus.rgwID)
radio.isOnline = (rmsg.rStatus.status == 1 ? true : false); radio.isOnline = rmsg.rStatus.status == 1;
} }
SM.Debug("Received from Apps -> UpdateRadioStatus(" + rmsg.rStatus.rgwID + "," + rmsg.rStatus.gwID + "," + rmsg.rStatus.status+ ")"); SM.Debug("Received from Apps -> UpdateRadioStatus(" + rmsg.rStatus.rgwID + "," + rmsg.rStatus.gwID + "," + rmsg.rStatus.status+ ")");
@ -1675,13 +1653,10 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
radioActivity.UpdateRadioStatus(rmsg.rStatus.status); radioActivity.UpdateRadioStatus(rmsg.rStatus.status);
} }
//incCall //incCall
if (radioActivity != null && rmsg.incCall !=null) if (radioActivity != null && rmsg.incCall !=null) {
{
SM.Debug("Received from Apps -> UpdateBroadcastCall(" + rmsg.incCall.Imei + "," + rmsg.incCall.callType + "," + rmsg.incCall.groupId+ ")"); SM.Debug("Received from Apps -> UpdateBroadcastCall(" + rmsg.incCall.Imei + "," + rmsg.incCall.callType + "," + rmsg.incCall.groupId+ ")");
// check if radioID and radioGW_ID needs to be changed // check if radioID and radioGW_ID needs to be changed
if (crtRadio != null && (crtRadio.GW_ID != rmsg.incCall.gwID || crtRadio.ID != rmsg.incCall.rgwID)) { if (crtRadio != null && (crtRadio.GW_ID != rmsg.incCall.gwID || crtRadio.ID != rmsg.incCall.rgwID)) {
for(RadioGW radio: allRadios) { for(RadioGW radio: allRadios) {
if(radio.GW_ID == rmsg.incCall.gwID && radio.ID == rmsg.incCall.rgwID) { if(radio.GW_ID == rmsg.incCall.gwID && radio.ID == rmsg.incCall.rgwID) {
crtRadio = radio; crtRadio = radio;
@ -1691,31 +1666,23 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
} }
} }
if(crtRadio != null) if(crtRadio != null) {
{
if(rmsg.incCall.callStatus == 3) if(rmsg.incCall.callStatus == 3)
{
inCall = false; inCall = false;
}
else else
inCall = true; inCall = true;
radioActivity.UpdateBroadcastCall(rmsg.incCall.Imei,rmsg.incCall.callType,rmsg.incCall.groupId,rmsg.incCall.callStatus); radioActivity.UpdateBroadcastCall(rmsg.incCall.Imei,rmsg.incCall.callType,rmsg.incCall.groupId,rmsg.incCall.callStatus);
} }
} }
} } else {
else if (rmsg.incCall !=null) {
{
if (rmsg.incCall !=null)
{
crtActivity = 0; crtActivity = 0;
//incCall - update UI in Radio Activity //incCall - update UI in Radio Activity
SM.Debug("Received from Apps -> UpdateBroadcastCall(" + rmsg.incCall.Imei + "," + rmsg.incCall.callType + "," + rmsg.incCall.groupId+ ")"); SM.Debug("Received from Apps -> UpdateBroadcastCall(" + rmsg.incCall.Imei + "," + rmsg.incCall.callType + "," + rmsg.incCall.groupId+ ")");
// check if radioID and radioGW_ID needs to be changed // check if radioID and radioGW_ID needs to be changed
if(crtRadio != null && (crtRadio.GW_ID != rmsg.incCall.gwID || crtRadio.ID != rmsg.incCall.rgwID)) { if(crtRadio != null && (crtRadio.GW_ID != rmsg.incCall.gwID || crtRadio.ID != rmsg.incCall.rgwID)) {
for(RadioGW radio: allRadios) { for(RadioGW radio: allRadios) {
if(radio.GW_ID == rmsg.incCall.gwID && radio.ID == rmsg.incCall.rgwID) { if(radio.GW_ID == rmsg.incCall.gwID && radio.ID == rmsg.incCall.rgwID) {
crtRadio = radio; crtRadio = radio;
@ -1725,25 +1692,19 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
} }
} }
if (crtRadio != null) if (crtRadio != null) {
{ if(rmsg.incCall.callStatus == 3) {
if(rmsg.incCall.callStatus == 3)
{
inCall = false; inCall = false;
// update recordings list // update recordings list
if(AppParams.crtTab == AppParams.Tabs.recordings) if(AppParams.crtTab == AppParams.Tabs.recordings) {
{
// no recording is playing // no recording is playing
if(recordingsActivity != null && recordingsActivity.playingPosition < 0) if(recordingsActivity != null && recordingsActivity.playingPosition < 0)
getRecordings(crtRadio.GW_ID, crtRadio.ID); getRecordings(crtRadio.GW_ID, crtRadio.ID);
} }
} } else
else
inCall = true; inCall = true;
radioActivity.UpdateBroadcastCall(rmsg.incCall.Imei,rmsg.incCall.callType,rmsg.incCall.groupId,rmsg.incCall.callStatus); radioActivity.UpdateBroadcastCall(rmsg.incCall.Imei,rmsg.incCall.callType,rmsg.incCall.groupId,rmsg.incCall.callStatus);
} }
} }
if(rmsg.RadioGWList!=null && radioActivity!=null) if(rmsg.RadioGWList!=null && radioActivity!=null)
@ -1753,8 +1714,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
radioActivity.UpdateZoneCH(rmsg.zac.rgwID, rmsg.zac.gwID, rmsg.zac.zoneNr, rmsg.zac.channelNr); radioActivity.UpdateZoneCH(rmsg.zac.rgwID, rmsg.zac.gwID, rmsg.zac.zoneNr, rmsg.zac.channelNr);
} }
if(rmsg.rStatus !=null && radioActivity!=null) if(rmsg.rStatus !=null && radioActivity!=null) {
{
// update status in the allRadio List // update status in the allRadio List
for(RadioGW radio: allRadios) { for(RadioGW radio: allRadios) {
if(radio.GW_ID == rmsg.rStatus.gwID && radio.ID == rmsg.rStatus.rgwID) if(radio.GW_ID == rmsg.rStatus.gwID && radio.ID == rmsg.rStatus.rgwID)
@ -1764,51 +1724,39 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
if ((crtRadio != null)&&(crtRadio.GW_ID == rmsg.rStatus.gwID)&&(crtRadio.ID == rmsg.rStatus.rgwID)) if ((crtRadio != null)&&(crtRadio.GW_ID == rmsg.rStatus.gwID)&&(crtRadio.ID == rmsg.rStatus.rgwID))
radioActivity.UpdateRadioStatus(rmsg.rStatus.status); radioActivity.UpdateRadioStatus(rmsg.rStatus.status);
} }
} }
// save RadioList // save RadioList
if(rmsg.RadioGWList!=null) if (rmsg.RadioGWList!=null) {
{
allRadios = rmsg.RadioGWList; allRadios = rmsg.RadioGWList;
if(crtRadio == null) if (crtRadio == null) {
{
crtRadio = allRadios.get(0); crtRadio = allRadios.get(0);
SM.Debug("rmsg set 0 crtRadio GW_ID:"+crtRadio.GW_ID+" ID:"+crtRadio.ID+")"); SM.Debug("rmsg set 0 crtRadio GW_ID:"+crtRadio.GW_ID+" ID:"+crtRadio.ID+")");
notifyBroadcast(OperationCodes.RADIOID_CHANGED+""); notifyBroadcast(OperationCodes.RADIOID_CHANGED+"");
} }
} }
// save crt Radio ID and GW // save crt Radio ID and GW
if(rmsg.zac !=null) if (rmsg.zac !=null) {
{
for (RadioGW radio: allRadios) { for (RadioGW radio: allRadios) {
if (radio.GW_ID == rmsg.zac.gwID && radio.ID == rmsg.zac.rgwID) if (radio.GW_ID == rmsg.zac.gwID && radio.ID == rmsg.zac.rgwID)
crtRadio = radio; crtRadio = radio;
} }
} }
if (AppParams.crtTab == AppParams.Tabs.recordings) {
if(AppParams.crtTab == AppParams.Tabs.recordings) if (recordingsActivity != null && rmsg.RadioGWList!=null) {
{
if(recordingsActivity != null && rmsg.RadioGWList!=null)
{
SM.Debug("GetRecordings Request + crtRadio:"+ crtRadio.toString()); SM.Debug("GetRecordings Request + crtRadio:"+ crtRadio.toString());
getRecordings(crtRadio.GW_ID, crtRadio.ID); getRecordings(crtRadio.GW_ID, crtRadio.ID);
} }
} }
} }
// used when a unit is enabled / disabled // used when a unit is enabled / disabled
if (rmsg.suStatus !=null) { if (rmsg.suStatus !=null) {
SM.Debug("ENABLED/DISABLED " + rmsg.suStatus); SM.Debug("ENABLED/DISABLED " + rmsg.suStatus);
notifyBroadcast(OperationCodes.UNIT_STATUS_UPDATE+"", rmsg.suStatus.imei + "#" +rmsg.suStatus.status); notifyBroadcast(OperationCodes.UNIT_STATUS_UPDATE+"", rmsg.suStatus.imei + "#" +rmsg.suStatus.status);
} } else
else
SM.Debug("SUStatus is null"); SM.Debug("SUStatus is null");
} }
@ -1820,21 +1768,17 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
String[] tempArr =msg.data.split("#"); String[] tempArr =msg.data.split("#");
SM.Debug("Unit imei:" + tempArr[0]); SM.Debug("Unit imei:" + tempArr[0]);
String UnitIMEI =tempArr[0]; String UnitIMEI =tempArr[0];
//SM.Debug("Message:" + tempArr[1]);
//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 tab is not TextTab
if(tabHost.getCurrentTab() != 5) if (tabHost.getCurrentTab() != 5) {
{
// change Visual Elements // change Visual Elements
setImei(UnitIMEI); setImei(UnitIMEI);
switch (msg.opCode) switch (msg.opCode) {
{
case 135: setMess("speed "+tempArr[1]); case 135: setMess("speed "+tempArr[1]);
break; break;
case 136: setMess("landmark "+tempArr[1]); case 136: setMess("landmark "+tempArr[1]);
@ -1850,40 +1794,31 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
} }
myHandler.post(UpdateResultsAlarm); myHandler.post(UpdateResultsAlarm);
if ((msg.opCode==138)&&(AppParams.crtTab == AppParams.Tabs.live)) if ((msg.opCode==138)&&(AppParams.crtTab == AppParams.Tabs.live)) {
{ if(getSuperVehHash().get(Long.parseLong(UnitIMEI)) != null) {
if(getSuperVehHash().get(Long.parseLong(UnitIMEI)) != null)
{
//if is not check i need to force check to put on the map //if is not check i need to force check to put on the map
Boolean forceChecked =false; Boolean forceChecked =false;
if (!getSuperVehHash().get(Long.parseLong(UnitIMEI)).needUpdate) if (!getSuperVehHash().get(Long.parseLong(UnitIMEI)).needUpdate) {
{
getSuperVehHash().get(Long.parseLong(UnitIMEI)).needUpdate =true; getSuperVehHash().get(Long.parseLong(UnitIMEI)).needUpdate =true;
forceChecked =true; forceChecked =true;
} }
try try {
{
int x = 0; int x = 0;
if (forceChecked) if (forceChecked) {
{ for (Vehicle veh : getAllVehicle()) {
for (Vehicle veh : getAllVehicle())
{
if (veh.imei.compareTo(UnitIMEI)==0) break; if (veh.imei.compareTo(UnitIMEI)==0) break;
x++; x++;
} }
} } else
else x = -1; x = -1;
if(liveActivity != null) if (liveActivity != null) {
{
if (x!= getAllVehicle().size()) if (x!= getAllVehicle().size())
liveActivity.emergencyAlarmReceived(x , getSuperVehHash().get(Long.parseLong(UnitIMEI)).lat, getSuperVehHash().get(Long.parseLong(UnitIMEI)).lng); liveActivity.emergencyAlarmReceived(x , getSuperVehHash().get(Long.parseLong(UnitIMEI)).lat, getSuperVehHash().get(Long.parseLong(UnitIMEI)).lng);
else else
liveActivity.emergencyAlarmReceived(-1, getSuperVehHash().get(Long.parseLong(UnitIMEI)).lat, getSuperVehHash().get(Long.parseLong(UnitIMEI)).lng); liveActivity.emergencyAlarmReceived(-1, getSuperVehHash().get(Long.parseLong(UnitIMEI)).lat, getSuperVehHash().get(Long.parseLong(UnitIMEI)).lng);
} }
} } catch (Exception ex) {
catch (Exception ex) SM.Debug("Error load hash: "+ ex);
{
SM.Debug("Error load hash:"+ex.toString());
} }
} }
} }
@ -1897,10 +1832,8 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
SM.Debug("am primit lista cu Recording"); SM.Debug("am primit lista cu Recording");
//list for SMS //list for SMS
if(AppParams.crtTab == AppParams.Tabs.recordings) if (AppParams.crtTab == AppParams.Tabs.recordings) {
{ for(Recording rec: Records.recordList) {
for(Recording rec: Records.recordList)
{
// set the name to be displayed // set the name to be displayed
if (rec.typeID == 1) if (rec.typeID == 1)
rec.NameForDisplay = AppParams.USERNAME; rec.NameForDisplay = AppParams.USERNAME;
@ -1909,7 +1842,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
rec.NameForDisplay = getSuperVehHash().get((long)rec.subID).name; rec.NameForDisplay = getSuperVehHash().get((long)rec.subID).name;
} }
} }
// save recodings to AppParams // save recodings to AppParams
AppParams.recordings = Records.recordList; AppParams.recordings = Records.recordList;
@ -1926,13 +1858,11 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
@Override @Override
public void onContactsListReceived(TCPEvent event) { public void onContactsListReceived(TCPEvent event) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override @Override
public void onTextMessagesListReceived(TCPEvent event) { public void onTextMessagesListReceived(TCPEvent event) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override @Override
@ -1942,7 +1872,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
// send a broadcast // send a broadcast
notifyBroadcast(OperationCodes.TCP_CONNECTION_DOWN + ""); notifyBroadcast(OperationCodes.TCP_CONNECTION_DOWN + "");
} }
@Override @Override
@ -1959,31 +1888,17 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
public void onPONGReceived() { public void onPONGReceived() {
} }
}); });
} }
// Create runnable for posting // Create runnable for posting
public final Runnable showPopUpRUN = new Runnable() { final Runnable UpdateResultsAlarm = () -> updateResultsAlarmInUi("realpha");
public void run() {
updateResultsInUi("realpha");
}
};
// Create runnable for posting
final Runnable UpdateResultsAlarm = new Runnable() {
public void run() {
updateResultsAlarmInUi("realpha");
}
};
public void updateResultsAlarmInUi(String animation) { public void updateResultsAlarmInUi(String animation) {
// Back in the UI thread // Back in the UI thread
// set TextViews // set TextViews
if(tcp!=null && !AppParams.DEMO) if(tcp!=null && !AppParams.DEMO) {
{ try {
try
{
activePopupType= MsgType.ALARM; activePopupType= MsgType.ALARM;
imageViewPopUp.setImageResource(R.drawable.siren_on); imageViewPopUp.setImageResource(R.drawable.siren_on);
slideTabsText.setText(getString(R.string.newAlarm)); slideTabsText.setText(getString(R.string.newAlarm));
@ -2003,35 +1918,25 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
// create Notification // create Notification
createNotification(AppParams.alertNotif); createNotification(AppParams.alertNotif);
} catch (Exception ex) {
SM.Debug("Erorr on update alarm:"+ ex);
} }
catch (Exception ex)
{
SM.Debug("Erorr on update alarm:"+ex.toString());
}
} }
} }
// Create runnable for posting // Create runnable for posting
final Runnable UpdateResultsPoll = new Runnable() { final Runnable UpdateResultsPoll = () -> updateResultsPollInUi("realpha");
public void run() {
updateResultsPollInUi("realpha");
}
};
public void updateResultsPollInUi(String animation) { public void updateResultsPollInUi(String animation) {
// Back in the UI thread // Back in the UI thread
// set TextViews // set TextViews
String from = ""; String from = "";
Vehicle fromVehicle = null; Vehicle fromVehicle;
if ((fromVehicle = getVehicle4Imei(getImei())) != null) if ((fromVehicle = getVehicle4Imei(getImei())) != null)
from = fromVehicle.name; from = fromVehicle.name;
if(tcp!=null && !AppParams.DEMO) if (tcp!=null && !AppParams.DEMO) {
{
activePopupType =MsgType.POLL; activePopupType =MsgType.POLL;
imageViewPopUp.setImageResource(R.drawable.poll); imageViewPopUp.setImageResource(R.drawable.poll);
slideTabsText.setText("Poll Reply"); slideTabsText.setText("Poll Reply");
@ -2046,9 +1951,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
anim.reset(); anim.reset();
layoutNewMessage.clearAnimation(); layoutNewMessage.clearAnimation();
layoutNewMessage.startAnimation(anim); layoutNewMessage.startAnimation(anim);
} } else if (AppParams.DEMO) {
else if (AppParams.DEMO)
{
activePopupType =MsgType.POLL; activePopupType =MsgType.POLL;
imageViewPopUp.setImageResource(R.drawable.poll); imageViewPopUp.setImageResource(R.drawable.poll);
slideTabsText.setText("Poll Reply"); slideTabsText.setText("Poll Reply");
@ -2056,14 +1959,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
textViewNMMessage.setText(getMess()); textViewNMMessage.setText(getMess());
// show layout // show layout
layoutNewMessage.setVisibility(View.VISIBLE); layoutNewMessage.setVisibility(View.VISIBLE);
/*
Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
if(animation.equals("realpha"))
anim = AnimationUtils.loadAnimation(this, R.anim.realpha);
anim.reset();
layoutNewMessage.clearAnimation();
layoutNewMessage.startAnimation(anim);
*/
} }
// create Notification // create Notification
@ -2071,17 +1966,12 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
} }
// Create runnable for posting // Create runnable for posting
final Runnable UpdateResults = new Runnable() { final Runnable UpdateResults = () -> updateResultsInUi("realpha");
public void run() {
updateResultsInUi("realpha");
}
};
public void updateResultsInUi(String animation) { public void updateResultsInUi(String animation) {
// Back in the UI thread // Back in the UI thread
// set TextViews // set TextViews
if(tcp!=null && !AppParams.DEMO) if(tcp!=null && !AppParams.DEMO) {
{
activePopupType = MsgType.SMS; activePopupType = MsgType.SMS;
imageViewPopUp.setImageResource(R.drawable.message); imageViewPopUp.setImageResource(R.drawable.message);
slideTabsText.setText("New Message"); slideTabsText.setText("New Message");
@ -2096,9 +1986,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
anim.reset(); anim.reset();
layoutNewMessage.clearAnimation(); layoutNewMessage.clearAnimation();
layoutNewMessage.startAnimation(anim); layoutNewMessage.startAnimation(anim);
} } else if(AppParams.DEMO) {
else if(AppParams.DEMO)
{
setMess("i got your sms"); setMess("i got your sms");
activePopupType = MsgType.SMS; activePopupType = MsgType.SMS;
imageViewPopUp.setImageResource(R.drawable.message); imageViewPopUp.setImageResource(R.drawable.message);
@ -2110,11 +1998,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
// create Notification // create Notification
createNotification(AppParams.messageNotif); createNotification(AppParams.messageNotif);
/*
Animation anim = AnimationUtils.loadAnimation(this, R.anim.realpha);
layoutNewMessage.clearAnimation();
layoutNewMessage.startAnimation(anim);
*/
} }
// create Notification // create Notification
@ -2130,8 +2013,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
Vehicle veh = getVehicle4Imei(getImei()); Vehicle veh = getVehicle4Imei(getImei());
int icon_value = icon; int icon_value = icon;
switch(icon) switch(icon) {
{
case AppParams.messageNotif: case AppParams.messageNotif:
contentText = "\"" + getMess() + "\""; contentText = "\"" + getMess() + "\"";
contentTitle = "New Message from " + getImei(); contentTitle = "New Message from " + getImei();
@ -2179,11 +2061,9 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
// return vehicle according to imei // return vehicle according to imei
private Vehicle getVehicle4Imei(String imei) private Vehicle getVehicle4Imei(String imei) {
{
Vehicle veh = null; Vehicle veh = null;
for(Vehicle vehicle: getAllVehicle()) for(Vehicle vehicle: getAllVehicle())
//SM.Debug("Vehicle name:"+vehicle.name+" IMEI:"+vehicle.imei);
if(vehicle.imei.equals(imei)) if(vehicle.imei.equals(imei))
veh = vehicle; veh = vehicle;
return veh; return veh;
@ -2191,10 +2071,8 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
@Override @Override
public void enableMenuButtons(boolean enable) public void enableMenuButtons(boolean enable) {
{ if (enable) {
if(enable)
{
buttonAlarms.setEnabled(true); buttonAlarms.setEnabled(true);
buttonHistory.setEnabled(true); buttonHistory.setEnabled(true);
buttonLive.setEnabled(true); buttonLive.setEnabled(true);
@ -2202,9 +2080,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
buttonText.setEnabled(true); buttonText.setEnabled(true);
buttonRadio.setEnabled(true); buttonRadio.setEnabled(true);
buttonSetup.setEnabled(true); buttonSetup.setEnabled(true);
} } else {
else
{
// disable all buttons // disable all buttons
buttonAlarms.setEnabled(false); buttonAlarms.setEnabled(false);
buttonHistory.setEnabled(false); buttonHistory.setEnabled(false);
@ -2217,10 +2093,8 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
} }
// load settings // load settings
public void loadSettings() public void loadSettings() {
{ try {
try
{
// get Preferences for SafeDispatch // get Preferences for SafeDispatch
AppParams.prefs = getSharedPreferences(getPackageName(), MODE_PRIVATE); AppParams.prefs = getSharedPreferences(getPackageName(), MODE_PRIVATE);
// get default IP // get default IP
@ -2231,24 +2105,19 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
AppParams.LANGUAGE = AppParams.prefs.getString("language", "en"); AppParams.LANGUAGE = AppParams.prefs.getString("language", "en");
SM.Debug("PORT: " + AppParams.PORT + " | IP: " + AppParams.IP); SM.Debug("PORT: " + AppParams.PORT + " | IP: " + AppParams.IP);
} } catch(Exception ex) {
catch(Exception ex)
{
Log.e("Exception", "loadSettings exception"); Log.e("Exception", "loadSettings exception");
} }
} }
@Override @Override
public double best_zoom(double latMax, double latMin, double lngMax, double lngMin) public double best_zoom(double latMax, double latMin, double lngMax, double lngMin) {
{
double height =400; double height =400;
double width =400; double width =400;
double dlat = Math.abs(latMax - latMin); double dlat = Math.abs(latMax - latMin);
double dlon = Math.abs(lngMax - lngMin); double dlon = Math.abs(lngMax - lngMin);
if(dlat == 0 && dlon == 0) if(dlat == 0 && dlon == 0) {
{
if ((latMax == latMin)&&(latMax ==0)&&(lngMax == lngMin)&&(lngMax ==0)) return 2; if ((latMax == latMin)&&(latMax ==0)&&(lngMax == lngMin)&&(lngMax ==0)) return 2;
//return 17;
} }
// Center latitude in radians // Center latitude in radians
@ -2261,173 +2130,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
return (z1 > z0) ? (17-z1) : (17-z0); return (z1 > z0) ? (17-z1) : (17-z0);
} }
/*
public void getVehs()
{
boolean res = tcp.Write("0.0", "#21#"+AppParams.USERID+"#");
if(res){
SM.Debug("Message (getVehs) sent to app server");
}else{
SM.Debug("Could not send message(getVehs)!!");
}
}
public void getLastPos()
{
boolean res = tcp.Write("0.0", "#25#");
if(res){
SM.Debug("Message (getLastPOS) sent to app server");
}else{
SM.Debug("Could not send message(getLastSMS)!!");
}
}
public void optionForUnit(int radioCode, int opCode, int sc_id, int value)
{
boolean res = tcp.Write("0.0", "#"+radioCode+"#"+opCode+"#" + sc_id+"#" +value + "#");
if(res){
SM.Debug("Message (optionForUnit) sent to app server radioCode:"+radioCode+ " opCode:"+opCode+ " sc_id:"+sc_id+ " value:"+value);
}else{
SM.Debug("Could not send message(optionForUnit)!!");
}
}
public void getSMS4unit(int sc_id, long timeGMT)
{
boolean res = tcp.Write("0.0", "#22#"+sc_id+"#" +timeGMT+"#");
if(res){
SM.Debug("Message (getLastSMS) sent to app server");
}else{
SM.Debug("Could not send message(getLastSMS)!!");
}
}
public void getLastSMS()
{
boolean res = tcp.Write("0.0", "#23#");
if(res){
SM.Debug("Message (getLastSMS) sent to app server");
}else{
SM.Debug("Could not send message(getLastSMS)!!");
}
}
public void SendSMS(String seqID,int sc_id, String txt)
{
boolean res = tcp.Write(seqID, "#24#" + AppParams.USERID + "#" + sc_id + "#" + txt + "#");
if(res){
SM.Debug("Message (SendSMS) sent to app server sc_id:"+sc_id+ " txt:"+txt);
}else{
SM.Debug("Could not send message(getLastSMS)!!");
}
}
public void SendAlarmACK(int alarm_id, int type)
{
boolean res = tcp.Write("0.0", "#28#" + alarm_id + "#" + type + "#");
if(res){
SM.Debug("Message (SendAlarmACK) sent to app server alarm_id:"+alarm_id+ " type:"+type);
}else{
SM.Debug("Could not send message(SendAlarmACK)!!");
}
}
public void SendPlayRequest(long record_id)
{
boolean res = tcp.Write("0.0", "#18#" + record_id + "#");
if(res){
SM.Debug("Message (SendPlayRequest) sent to app server record_id:"+record_id);
}else{
SM.Debug("Could not send message(SendPlayRequest)!!");
}
}
public void SendDekey()
{
boolean res = tcp.Write("0.0", "#30#160#" +crtRadio.GW_ID+"."+crtRadio.ID+ "#");
if(res){
SM.Debug("Message (SendDekey) sent to app server record_id");
}else{
SM.Debug("Could not send message(SendPlayRequest)!!");
}
}
public void getHistoryPos(int sc_id, long timeGMTStart, long timeGMTStop)
{
HistSeqID = "1."+Integer.toString((int) (System.currentTimeMillis() / 1000L));
boolean res = tcp.Write(HistSeqID,"#26#"+sc_id+"#"+timeGMTStart+"#"+timeGMTStop+"#");
if(res){
SM.Debug("Message (getHistoryPos) sent to app server");
}else{
SM.Debug("Could not send message(getLastSMS)!!");
}
}
public void RadioGetRadioList()
{
boolean res = tcp.Write("0.0", "#30#100#");
if(res){
SM.Debug("Message (RadioGetRadioList) sent to app server");
}else{
SM.Debug("Could not send message(getLastSMS)!!");
}
}
// if zoneNr=0 and channelNR =0 then function acts as GET
public void getSetZoneAndChannel(int gwID, int rgwID, int zoneNR, int channelNR)
{
boolean res = tcp.Write("0.0", "#30#104#" + gwID + "#" + rgwID + "#" + zoneNR + "#" +channelNR +"#");
if(res){
SM.Debug("Message (GetSetZoneAndChannel) sent to app server zoneNR:"+zoneNR+ " channelNR:"+channelNR);
}else{
SM.Debug("Could not send message(GetSetZoneAndChannel)!!");
}
}
// send radioCode=30
//Enable/Disable opcode=150 value(1/0)
//Remote monitor = 161
//Poll = 154
public void getRadioStatus(int gwID, int rgwID)
{
boolean res = tcp.Write("0.0", "#30#99#" + gwID + "#" + rgwID + "#");
if(res){
SM.Debug("Message (RadioGetRadioList) sent to app server || gwID: " + gwID + " | rgwID: " + rgwID);
}else{
SM.Debug("Could not send message(getLastSMS)!!");
}
}
public void getAlarms()
{
boolean res = tcp.Write("0.0", "#27#"); // = tcp.Write("0.0", "#30#99#" + gwID + "#" + rgwID + "#");
if(res){
SM.Debug("Message (GetAlarms) sent to app server");
}else{
SM.Debug("Could not send message(GetAlarms)!!");
}
}
public void getRecordings()
{
boolean res = tcp.Write("0.0", "#29#"+AppParams.USERID+"#"+crtRadio.GW_ID+"#"+crtRadio.ID+"#");
if(res){
SM.Debug("Message (GetRecordings) sent to app server");
}else{
SM.Debug("Could not send message(GetRecordings)!!");
}
}
*/
//callType: //callType:
//101 -allcall init //101 -allcall init
//111 -allcall stop //111 -allcall stop
@ -2435,10 +2137,8 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
//112 -prvcall stop //112 -prvcall stop
//103 -grpcall init //103 -grpcall init
//113 -grpcall stop //113 -grpcall stop
public void SendPTT(int callType, int id, int gwID, int rgwid, long userID) public void SendPTT(int callType, int id, int gwID, int rgwid, long userID) {
{ if(tcp!= null) {
if(tcp!= null)
{
try { try {
Thread.sleep(300); Thread.sleep(300);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -2447,21 +2147,18 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
boolean res = tcp.Write("0.0", "#30#"+callType+"#"+gwID+"."+rgwid+"." + id+"#"+userID+"#"); boolean res = tcp.Write("0.0", "#30#"+callType+"#"+gwID+"."+rgwid+"." + id+"#"+userID+"#");
if(res){ if(res){
SM.Debug("Message (SendPTT) sent to app server"); SM.Debug("Message (SendPTT) sent to app server");
} } else {
else{
SM.Debug("Could not send message(SendPTT)!!"); SM.Debug("Could not send message(SendPTT)!!");
} }
} }
} }
protected class ConnectTask extends AsyncTask<String, Void, TCPhandler> protected class ConnectTask extends AsyncTask<String, Void, TCPhandler> {
{
@Override @Override
protected TCPhandler doInBackground(String... params) { protected TCPhandler doInBackground(String... params) {
switch(Integer.parseInt(params[0])) switch(Integer.parseInt(params[0])) {
{
case OperationCodes.TCP_CONNECTION_REQ: case OperationCodes.TCP_CONNECTION_REQ:
SM.Exception("TCP CONNECTION REQ!!!"); SM.Exception("TCP CONNECTION REQ!!!");
@ -2521,12 +2218,9 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
case OperationCodes.GetHistoryPositions: case OperationCodes.GetHistoryPositions:
getHistoryPositions(Integer.parseInt(params[1]), Long.parseLong(params[2]), Long.parseLong(params[3])); getHistoryPositions(Integer.parseInt(params[1]), Long.parseLong(params[2]), Long.parseLong(params[3]));
break; break;
} }
return null; return null;
} }
} }
@ -2555,8 +2249,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
/* Display Toast messages*/ /* Display Toast messages*/
@Override @Override
public void displayToast(final String msg) public void displayToast(final String msg) {
{
myHandler.post(() -> Toast.makeText(context, msg, Toast.LENGTH_SHORT).show()); myHandler.post(() -> Toast.makeText(context, msg, Toast.LENGTH_SHORT).show());
} }
@ -2607,37 +2300,22 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
} }
@Override @Override
public void recreateTCPConnection() public void recreateTCPConnection() {
{ if(!AppParams.DEMO) {
if(!AppParams.DEMO)
{
if(tcpParser!=null) if(tcpParser!=null)
tcpParser.clearMsgList(); tcpParser.clearMsgList();
//showLoadingDialog("Getting users from database..."); myHandler.post(() -> {
myHandler.post(new Runnable() { if(myService != null) {
@Override
public void run() {
if(myService != null)
{
myService.stopTCPConnection(); myService.stopTCPConnection();
myService.recreateTCPConnection(); myService.recreateTCPConnection();
new ConnectTask().execute(new String[] {OperationCodes.TCP_CONNECTION_REQ + ""}); new ConnectTask().execute(new String[] {OperationCodes.TCP_CONNECTION_REQ + ""});
// add a new ITCPListener // add a new ITCPListener
tcpParser(); tcpParser();
//tcp.updateTCPparameters(AppParams.IP, AppParams.PORT);
} }
// recreate tcp
//myService.updateTCPparameters(AppParams.IP, AppParams.PORT);
//myService.recreateTCPConnection();
//tcpInit();
SM.Debug("RECREATE TCP","IP: " + AppParams.IP + " | Port: " + AppParams.PORT); SM.Debug("RECREATE TCP","IP: " + AppParams.IP + " | Port: " + AppParams.PORT);
}
}); });
} }
} }
@ -2645,7 +2323,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
public void removeITCPListener() { public void removeITCPListener() {
if(tcpParser != null) if(tcpParser != null)
tcpParser.clearITCPListeners(); tcpParser.clearITCPListeners();
//tcpParser.removeTCPListener(itcpListener);
} }
@ -2657,7 +2334,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
private void notifyBroadcast(String action) { private void notifyBroadcast(String action) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(action); intent.setAction(action);
//intent.putExtra("extra", extra);
getBaseContext().sendBroadcast(intent); getBaseContext().sendBroadcast(intent);
} }
@ -2666,13 +2342,12 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
private void notifyBroadcast(String action, Object object) { private void notifyBroadcast(String action, Object object) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(action); intent.setAction(action);
if(action == OperationCodes.UNIT_STATUS_UPDATE+"") if(action.equals(OperationCodes.UNIT_STATUS_UPDATE + ""))
intent.putExtra("unitStatus", (String)object); intent.putExtra("unitStatus", (String)object);
else if(action == OperationCodes.BLUETOOTH_TETHER+"") else if(action.equals(OperationCodes.BLUETOOTH_TETHER + ""))
intent.putExtra("tether", Boolean.parseBoolean((String)object)); intent.putExtra("tether", Boolean.parseBoolean((String)object));
else else
intent.putExtra("extra", new SerializedObject(object, action)); intent.putExtra("extra", new SerializedObject(object, action));
getBaseContext().sendBroadcast(intent); getBaseContext().sendBroadcast(intent);
} }
} }