feature/apk_versioning_mechanism #7
@ -21,6 +21,7 @@ import com.google.android.gms.maps.model.Polyline;
|
||||
import com.google.android.gms.maps.model.PolylineOptions;
|
||||
import com.safemobile.lib.AppParams;
|
||||
import com.safemobile.lib.HistPos;
|
||||
import com.safemobile.lib.OperationCodes;
|
||||
import com.safemobile.lib.SM;
|
||||
import com.safemobile.lib.Vehicle;
|
||||
|
||||
@ -38,6 +39,7 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
||||
private Spinner spinnerVehicle;
|
||||
private ImageView changeMapType, checkTraffic, slideLayoutImage;
|
||||
private LinearLayout layoutTraffic, slidelayout, layoutVehicles;
|
||||
private Date startDate, endDate;
|
||||
|
||||
private ArrayList<Vehicle> allVehicle = new ArrayList<>();
|
||||
private ArrayList<String> allVehicleNames = new ArrayList<>();
|
||||
@ -88,6 +90,9 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
||||
// });
|
||||
|
||||
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) {
|
||||
@ -110,9 +115,9 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
||||
|
||||
private void setDate() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Date endDate = calendar.getTime();
|
||||
endDate = calendar.getTime();
|
||||
calendar.add(Calendar.DATE, -1);
|
||||
Date startDate = calendar.getTime();
|
||||
startDate = calendar.getTime();
|
||||
|
||||
LinearLayout layoutStartPicker = findViewById(R.id.layoutStartPicker);
|
||||
TextView textViewDate = findViewById(R.id.textViewStartDate);
|
||||
|
@ -1539,79 +1539,69 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
SM.Debug("tmpHist seqID:"+tmpHist.seqID);
|
||||
//
|
||||
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 (firstHistData) {
|
||||
try {
|
||||
for(int i=0;i<all;i++)
|
||||
HistMsgList.add(false);
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Error on init hashTable:"+e.toString());
|
||||
SM.Debug("Error on init hashTable:"+ e);
|
||||
}
|
||||
firstHistData =false;
|
||||
}
|
||||
|
||||
HistMsgList.set(pos-1, true);
|
||||
for(int i=0;i<(all);i++)
|
||||
{
|
||||
if (!HistMsgList.get(i))
|
||||
{
|
||||
for (int i = 0; i < all; i++) {
|
||||
if (!HistMsgList.get(i)) {
|
||||
SendDataToMap =false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else SendDataToMap =true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} else
|
||||
SendDataToMap =true;
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Error on parse: "+ e);
|
||||
}
|
||||
if (SendDataToMap) {
|
||||
Collections.sort(HistPosList, (Comparator<Object>) (o1, o2) -> {
|
||||
HistPos p1 = (HistPos) o1;
|
||||
HistPos p2 = (HistPos) o2;
|
||||
if (p1.timeGMT<p2.timeGMT) return -1;
|
||||
else if (p1.timeGMT==p2.timeGMT) return 0;
|
||||
else return 1;
|
||||
if (p1.timeGMT < p2.timeGMT)
|
||||
return -1;
|
||||
else if (p1.timeGMT == p2.timeGMT)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
});
|
||||
|
||||
//list for live
|
||||
if(AppParams.crtTab == AppParams.Tabs.history)
|
||||
{
|
||||
//SM.Debug("+++++ duda +++++");
|
||||
try
|
||||
{
|
||||
//Thread.sleep(100);
|
||||
if(historyActivity != null)
|
||||
{
|
||||
if (AppParams.crtTab == AppParams.Tabs.history) {
|
||||
try {
|
||||
if(historyActivity != null) {
|
||||
// cancel last update
|
||||
historyActivity.UpdateCancel();
|
||||
|
||||
Thread.sleep(101);
|
||||
if (HistPosList.size()<2000)
|
||||
{
|
||||
if ((HistPosList.size()==1) && (HistPosList.get(0).timeGMT==0))
|
||||
if (HistPosList.size() < 2000) {
|
||||
if (HistPosList.size() == 1 && HistPosList.get(0).timeGMT == 0)
|
||||
;// do nothing is not data message
|
||||
else
|
||||
historyActivity.UpdateNrPos(HistPosList.size());
|
||||
Thread.sleep(100);
|
||||
|
||||
historyActivity.UpdateMap();
|
||||
}
|
||||
else
|
||||
} else
|
||||
historyActivity.UpdateUnableDisp(); // update with more than 200 points
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SM.Debug("Error load hash:"+ex.toString());
|
||||
catch (Exception ex) {
|
||||
SM.Debug("Error load hash: "+ ex);
|
||||
}
|
||||
}
|
||||
SM.Debug("Got HistPost msg.data: " + msg.data);
|
||||
}
|
||||
}
|
||||
else SM.Debug("Drop history data");
|
||||
} else
|
||||
SM.Debug("Drop history data");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1620,12 +1610,9 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
TCPmsg msg= event.msg();
|
||||
RadioMSG rmsg = new RadioMSG(msg);
|
||||
|
||||
if(!NOSOUND)
|
||||
{
|
||||
|
||||
if (!NOSOUND) {
|
||||
// update Zone and Channel
|
||||
if(radioActivity != null && rmsg.zac !=null)
|
||||
{
|
||||
if (radioActivity != null && rmsg.zac != null) {
|
||||
// update Zone and Channel in the allRadio List
|
||||
for (RadioGW radio: allRadios) {
|
||||
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;
|
||||
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 + ")");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//list for SMS
|
||||
if(AppParams.crtTab == AppParams.Tabs.radio)
|
||||
{
|
||||
if (AppParams.crtTab == AppParams.Tabs.radio) {
|
||||
SM.Debug("#### RadioActivity");
|
||||
// set crt activity to Radio
|
||||
crtActivity = RADIO;
|
||||
|
||||
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.rStatus!=null? "rStatus" + rmsg.rStatus.toString() : "rStatus = null"));
|
||||
SM.Debug("## " + (rmsg.zac!=null? "zac" + rmsg.zac : "zac = 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);
|
||||
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
|
||||
for (RadioGW radio : allRadios) {
|
||||
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+ ")");
|
||||
@ -1675,13 +1653,10 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
radioActivity.UpdateRadioStatus(rmsg.rStatus.status);
|
||||
}
|
||||
//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+ ")");
|
||||
|
||||
// check if radioID and radioGW_ID needs to be changed
|
||||
if (crtRadio != null && (crtRadio.GW_ID != rmsg.incCall.gwID || crtRadio.ID != rmsg.incCall.rgwID)) {
|
||||
|
||||
for(RadioGW radio: allRadios) {
|
||||
if(radio.GW_ID == rmsg.incCall.gwID && radio.ID == rmsg.incCall.rgwID) {
|
||||
crtRadio = radio;
|
||||
@ -1691,31 +1666,23 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
}
|
||||
}
|
||||
|
||||
if(crtRadio != null)
|
||||
{
|
||||
if(crtRadio != null) {
|
||||
if(rmsg.incCall.callStatus == 3)
|
||||
{
|
||||
inCall = false;
|
||||
}
|
||||
else
|
||||
inCall = true;
|
||||
|
||||
radioActivity.UpdateBroadcastCall(rmsg.incCall.Imei,rmsg.incCall.callType,rmsg.incCall.groupId,rmsg.incCall.callStatus);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rmsg.incCall !=null)
|
||||
{
|
||||
} else {
|
||||
if (rmsg.incCall !=null) {
|
||||
crtActivity = 0;
|
||||
//incCall - update UI in Radio Activity
|
||||
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
|
||||
if(crtRadio != null && (crtRadio.GW_ID != rmsg.incCall.gwID || crtRadio.ID != rmsg.incCall.rgwID)) {
|
||||
|
||||
for(RadioGW radio: allRadios) {
|
||||
if(radio.GW_ID == rmsg.incCall.gwID && radio.ID == rmsg.incCall.rgwID) {
|
||||
crtRadio = radio;
|
||||
@ -1725,25 +1692,19 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
}
|
||||
}
|
||||
|
||||
if (crtRadio != null)
|
||||
{
|
||||
if(rmsg.incCall.callStatus == 3)
|
||||
{
|
||||
if (crtRadio != null) {
|
||||
if(rmsg.incCall.callStatus == 3) {
|
||||
inCall = false;
|
||||
// update recordings list
|
||||
if(AppParams.crtTab == AppParams.Tabs.recordings)
|
||||
{
|
||||
if(AppParams.crtTab == AppParams.Tabs.recordings) {
|
||||
// no recording is playing
|
||||
if(recordingsActivity != null && recordingsActivity.playingPosition < 0)
|
||||
getRecordings(crtRadio.GW_ID, crtRadio.ID);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
inCall = true;
|
||||
radioActivity.UpdateBroadcastCall(rmsg.incCall.Imei,rmsg.incCall.callType,rmsg.incCall.groupId,rmsg.incCall.callStatus);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if(rmsg.rStatus !=null && radioActivity!=null)
|
||||
{
|
||||
if(rmsg.rStatus !=null && radioActivity!=null) {
|
||||
// update status in the allRadio List
|
||||
for(RadioGW radio: allRadios) {
|
||||
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))
|
||||
radioActivity.UpdateRadioStatus(rmsg.rStatus.status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// save RadioList
|
||||
if(rmsg.RadioGWList!=null)
|
||||
{
|
||||
if (rmsg.RadioGWList!=null) {
|
||||
allRadios = rmsg.RadioGWList;
|
||||
if(crtRadio == null)
|
||||
{
|
||||
if (crtRadio == null) {
|
||||
crtRadio = allRadios.get(0);
|
||||
SM.Debug("rmsg set 0 crtRadio GW_ID:"+crtRadio.GW_ID+" ID:"+crtRadio.ID+")");
|
||||
|
||||
notifyBroadcast(OperationCodes.RADIOID_CHANGED+"");
|
||||
}
|
||||
}
|
||||
|
||||
// save crt Radio ID and GW
|
||||
if(rmsg.zac !=null)
|
||||
{
|
||||
if (rmsg.zac !=null) {
|
||||
for (RadioGW radio: allRadios) {
|
||||
if (radio.GW_ID == rmsg.zac.gwID && radio.ID == rmsg.zac.rgwID)
|
||||
crtRadio = radio;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(AppParams.crtTab == AppParams.Tabs.recordings)
|
||||
{
|
||||
if(recordingsActivity != null && rmsg.RadioGWList!=null)
|
||||
{
|
||||
if (AppParams.crtTab == AppParams.Tabs.recordings) {
|
||||
if (recordingsActivity != null && rmsg.RadioGWList!=null) {
|
||||
SM.Debug("GetRecordings Request + crtRadio:"+ crtRadio.toString());
|
||||
getRecordings(crtRadio.GW_ID, crtRadio.ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// used when a unit is enabled / disabled
|
||||
if (rmsg.suStatus !=null) {
|
||||
SM.Debug("ENABLED/DISABLED " + rmsg.suStatus);
|
||||
notifyBroadcast(OperationCodes.UNIT_STATUS_UPDATE+"", rmsg.suStatus.imei + "#" +rmsg.suStatus.status);
|
||||
}
|
||||
else
|
||||
} else
|
||||
SM.Debug("SUStatus is null");
|
||||
}
|
||||
|
||||
@ -1820,21 +1768,17 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
String[] tempArr =msg.data.split("#");
|
||||
SM.Debug("Unit imei:" + tempArr[0]);
|
||||
String UnitIMEI =tempArr[0];
|
||||
//SM.Debug("Message:" + tempArr[1]);
|
||||
|
||||
//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]);
|
||||
getAlarms(AppParams.USERID);
|
||||
}
|
||||
// if tab is not TextTab
|
||||
if(tabHost.getCurrentTab() != 5)
|
||||
{
|
||||
if (tabHost.getCurrentTab() != 5) {
|
||||
// change Visual Elements
|
||||
setImei(UnitIMEI);
|
||||
switch (msg.opCode)
|
||||
{
|
||||
switch (msg.opCode) {
|
||||
case 135: setMess("speed "+tempArr[1]);
|
||||
break;
|
||||
case 136: setMess("landmark "+tempArr[1]);
|
||||
@ -1850,40 +1794,31 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
}
|
||||
myHandler.post(UpdateResultsAlarm);
|
||||
|
||||
if ((msg.opCode==138)&&(AppParams.crtTab == AppParams.Tabs.live))
|
||||
{
|
||||
if(getSuperVehHash().get(Long.parseLong(UnitIMEI)) != null)
|
||||
{
|
||||
if ((msg.opCode==138)&&(AppParams.crtTab == AppParams.Tabs.live)) {
|
||||
if(getSuperVehHash().get(Long.parseLong(UnitIMEI)) != null) {
|
||||
//if is not check i need to force check to put on the map
|
||||
Boolean forceChecked =false;
|
||||
if (!getSuperVehHash().get(Long.parseLong(UnitIMEI)).needUpdate)
|
||||
{
|
||||
if (!getSuperVehHash().get(Long.parseLong(UnitIMEI)).needUpdate) {
|
||||
getSuperVehHash().get(Long.parseLong(UnitIMEI)).needUpdate =true;
|
||||
forceChecked =true;
|
||||
}
|
||||
try
|
||||
{
|
||||
try {
|
||||
int x = 0;
|
||||
if (forceChecked)
|
||||
{
|
||||
for (Vehicle veh : getAllVehicle())
|
||||
{
|
||||
if (forceChecked) {
|
||||
for (Vehicle veh : getAllVehicle()) {
|
||||
if (veh.imei.compareTo(UnitIMEI)==0) break;
|
||||
x++;
|
||||
}
|
||||
}
|
||||
else x = -1;
|
||||
if(liveActivity != null)
|
||||
{
|
||||
} else
|
||||
x = -1;
|
||||
if (liveActivity != null) {
|
||||
if (x!= getAllVehicle().size())
|
||||
liveActivity.emergencyAlarmReceived(x , getSuperVehHash().get(Long.parseLong(UnitIMEI)).lat, getSuperVehHash().get(Long.parseLong(UnitIMEI)).lng);
|
||||
else
|
||||
liveActivity.emergencyAlarmReceived(-1, getSuperVehHash().get(Long.parseLong(UnitIMEI)).lat, getSuperVehHash().get(Long.parseLong(UnitIMEI)).lng);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SM.Debug("Error load hash:"+ex.toString());
|
||||
} catch (Exception ex) {
|
||||
SM.Debug("Error load hash: "+ ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1897,10 +1832,8 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
SM.Debug("am primit lista cu Recording");
|
||||
|
||||
//list for SMS
|
||||
if(AppParams.crtTab == AppParams.Tabs.recordings)
|
||||
{
|
||||
for(Recording rec: Records.recordList)
|
||||
{
|
||||
if (AppParams.crtTab == AppParams.Tabs.recordings) {
|
||||
for(Recording rec: Records.recordList) {
|
||||
// set the name to be displayed
|
||||
if (rec.typeID == 1)
|
||||
rec.NameForDisplay = AppParams.USERNAME;
|
||||
@ -1909,7 +1842,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
rec.NameForDisplay = getSuperVehHash().get((long)rec.subID).name;
|
||||
}
|
||||
}
|
||||
|
||||
// save recodings to AppParams
|
||||
AppParams.recordings = Records.recordList;
|
||||
|
||||
@ -1926,13 +1858,11 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
@Override
|
||||
public void onContactsListReceived(TCPEvent event) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextMessagesListReceived(TCPEvent event) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1942,7 +1872,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
|
||||
// send a broadcast
|
||||
notifyBroadcast(OperationCodes.TCP_CONNECTION_DOWN + "");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1959,31 +1888,17 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
public void onPONGReceived() {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// Create runnable for posting
|
||||
public final Runnable showPopUpRUN = new Runnable() {
|
||||
public void run() {
|
||||
updateResultsInUi("realpha");
|
||||
}
|
||||
};
|
||||
|
||||
// Create runnable for posting
|
||||
final Runnable UpdateResultsAlarm = new Runnable() {
|
||||
public void run() {
|
||||
updateResultsAlarmInUi("realpha");
|
||||
}
|
||||
};
|
||||
final Runnable UpdateResultsAlarm = () -> updateResultsAlarmInUi("realpha");
|
||||
|
||||
public void updateResultsAlarmInUi(String animation) {
|
||||
// Back in the UI thread
|
||||
// set TextViews
|
||||
if(tcp!=null && !AppParams.DEMO)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(tcp!=null && !AppParams.DEMO) {
|
||||
try {
|
||||
activePopupType= MsgType.ALARM;
|
||||
imageViewPopUp.setImageResource(R.drawable.siren_on);
|
||||
slideTabsText.setText(getString(R.string.newAlarm));
|
||||
@ -2003,35 +1918,25 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
|
||||
// create Notification
|
||||
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
|
||||
final Runnable UpdateResultsPoll = new Runnable() {
|
||||
public void run() {
|
||||
|
||||
updateResultsPollInUi("realpha");
|
||||
}
|
||||
};
|
||||
final Runnable UpdateResultsPoll = () -> updateResultsPollInUi("realpha");
|
||||
|
||||
public void updateResultsPollInUi(String animation) {
|
||||
// Back in the UI thread
|
||||
// set TextViews
|
||||
String from = "";
|
||||
Vehicle fromVehicle = null;
|
||||
Vehicle fromVehicle;
|
||||
if ((fromVehicle = getVehicle4Imei(getImei())) != null)
|
||||
from = fromVehicle.name;
|
||||
|
||||
if(tcp!=null && !AppParams.DEMO)
|
||||
{
|
||||
if (tcp!=null && !AppParams.DEMO) {
|
||||
activePopupType =MsgType.POLL;
|
||||
imageViewPopUp.setImageResource(R.drawable.poll);
|
||||
slideTabsText.setText("Poll Reply");
|
||||
@ -2046,9 +1951,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
anim.reset();
|
||||
layoutNewMessage.clearAnimation();
|
||||
layoutNewMessage.startAnimation(anim);
|
||||
}
|
||||
else if (AppParams.DEMO)
|
||||
{
|
||||
} else if (AppParams.DEMO) {
|
||||
activePopupType =MsgType.POLL;
|
||||
imageViewPopUp.setImageResource(R.drawable.poll);
|
||||
slideTabsText.setText("Poll Reply");
|
||||
@ -2056,14 +1959,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
textViewNMMessage.setText(getMess());
|
||||
// show layout
|
||||
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
|
||||
@ -2071,17 +1966,12 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
}
|
||||
|
||||
// Create runnable for posting
|
||||
final Runnable UpdateResults = new Runnable() {
|
||||
public void run() {
|
||||
updateResultsInUi("realpha");
|
||||
}
|
||||
};
|
||||
final Runnable UpdateResults = () -> updateResultsInUi("realpha");
|
||||
|
||||
public void updateResultsInUi(String animation) {
|
||||
// Back in the UI thread
|
||||
// set TextViews
|
||||
if(tcp!=null && !AppParams.DEMO)
|
||||
{
|
||||
if(tcp!=null && !AppParams.DEMO) {
|
||||
activePopupType = MsgType.SMS;
|
||||
imageViewPopUp.setImageResource(R.drawable.message);
|
||||
slideTabsText.setText("New Message");
|
||||
@ -2096,9 +1986,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
anim.reset();
|
||||
layoutNewMessage.clearAnimation();
|
||||
layoutNewMessage.startAnimation(anim);
|
||||
}
|
||||
else if(AppParams.DEMO)
|
||||
{
|
||||
} else if(AppParams.DEMO) {
|
||||
setMess("i got your sms");
|
||||
activePopupType = MsgType.SMS;
|
||||
imageViewPopUp.setImageResource(R.drawable.message);
|
||||
@ -2110,11 +1998,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
|
||||
// create Notification
|
||||
createNotification(AppParams.messageNotif);
|
||||
/*
|
||||
Animation anim = AnimationUtils.loadAnimation(this, R.anim.realpha);
|
||||
layoutNewMessage.clearAnimation();
|
||||
layoutNewMessage.startAnimation(anim);
|
||||
*/
|
||||
}
|
||||
|
||||
// create Notification
|
||||
@ -2130,8 +2013,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
Vehicle veh = getVehicle4Imei(getImei());
|
||||
|
||||
int icon_value = icon;
|
||||
switch(icon)
|
||||
{
|
||||
switch(icon) {
|
||||
case AppParams.messageNotif:
|
||||
contentText = "\"" + getMess() + "\"";
|
||||
contentTitle = "New Message from " + getImei();
|
||||
@ -2179,11 +2061,9 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
|
||||
|
||||
// return vehicle according to imei
|
||||
private Vehicle getVehicle4Imei(String imei)
|
||||
{
|
||||
private Vehicle getVehicle4Imei(String imei) {
|
||||
Vehicle veh = null;
|
||||
for(Vehicle vehicle: getAllVehicle())
|
||||
//SM.Debug("Vehicle name:"+vehicle.name+" IMEI:"+vehicle.imei);
|
||||
if(vehicle.imei.equals(imei))
|
||||
veh = vehicle;
|
||||
return veh;
|
||||
@ -2191,10 +2071,8 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
|
||||
|
||||
@Override
|
||||
public void enableMenuButtons(boolean enable)
|
||||
{
|
||||
if(enable)
|
||||
{
|
||||
public void enableMenuButtons(boolean enable) {
|
||||
if (enable) {
|
||||
buttonAlarms.setEnabled(true);
|
||||
buttonHistory.setEnabled(true);
|
||||
buttonLive.setEnabled(true);
|
||||
@ -2202,9 +2080,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
buttonText.setEnabled(true);
|
||||
buttonRadio.setEnabled(true);
|
||||
buttonSetup.setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// disable all buttons
|
||||
buttonAlarms.setEnabled(false);
|
||||
buttonHistory.setEnabled(false);
|
||||
@ -2217,10 +2093,8 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
}
|
||||
|
||||
// load settings
|
||||
public void loadSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
public void loadSettings() {
|
||||
try {
|
||||
// get Preferences for SafeDispatch
|
||||
AppParams.prefs = getSharedPreferences(getPackageName(), MODE_PRIVATE);
|
||||
// get default IP
|
||||
@ -2231,24 +2105,19 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
AppParams.LANGUAGE = AppParams.prefs.getString("language", "en");
|
||||
|
||||
SM.Debug("PORT: " + AppParams.PORT + " | IP: " + AppParams.IP);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
} catch(Exception ex) {
|
||||
Log.e("Exception", "loadSettings exception");
|
||||
}
|
||||
}
|
||||
|
||||
@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 width =400;
|
||||
double dlat = Math.abs(latMax - latMin);
|
||||
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;
|
||||
//return 17;
|
||||
}
|
||||
|
||||
// Center latitude in radians
|
||||
@ -2261,173 +2130,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
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:
|
||||
//101 -allcall init
|
||||
//111 -allcall stop
|
||||
@ -2435,10 +2137,8 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
//112 -prvcall stop
|
||||
//103 -grpcall init
|
||||
//113 -grpcall stop
|
||||
public void SendPTT(int callType, int id, int gwID, int rgwid, long userID)
|
||||
{
|
||||
if(tcp!= null)
|
||||
{
|
||||
public void SendPTT(int callType, int id, int gwID, int rgwid, long userID) {
|
||||
if(tcp!= null) {
|
||||
try {
|
||||
Thread.sleep(300);
|
||||
} catch (InterruptedException e) {
|
||||
@ -2447,21 +2147,18 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
boolean res = tcp.Write("0.0", "#30#"+callType+"#"+gwID+"."+rgwid+"." + id+"#"+userID+"#");
|
||||
if(res){
|
||||
SM.Debug("Message (SendPTT) sent to app server");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
SM.Debug("Could not send message(SendPTT)!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected class ConnectTask extends AsyncTask<String, Void, TCPhandler>
|
||||
{
|
||||
protected class ConnectTask extends AsyncTask<String, Void, TCPhandler> {
|
||||
@Override
|
||||
protected TCPhandler doInBackground(String... params) {
|
||||
|
||||
switch(Integer.parseInt(params[0]))
|
||||
{
|
||||
switch(Integer.parseInt(params[0])) {
|
||||
case OperationCodes.TCP_CONNECTION_REQ:
|
||||
|
||||
SM.Exception("TCP CONNECTION REQ!!!");
|
||||
@ -2521,12 +2218,9 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
case OperationCodes.GetHistoryPositions:
|
||||
getHistoryPositions(Integer.parseInt(params[1]), Long.parseLong(params[2]), Long.parseLong(params[3]));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -2555,8 +2249,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
|
||||
/* Display Toast messages*/
|
||||
@Override
|
||||
public void displayToast(final String msg)
|
||||
{
|
||||
public void displayToast(final String msg) {
|
||||
myHandler.post(() -> Toast.makeText(context, msg, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
@ -2607,37 +2300,22 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recreateTCPConnection()
|
||||
{
|
||||
if(!AppParams.DEMO)
|
||||
{
|
||||
public void recreateTCPConnection() {
|
||||
if(!AppParams.DEMO) {
|
||||
if(tcpParser!=null)
|
||||
tcpParser.clearMsgList();
|
||||
|
||||
//showLoadingDialog("Getting users from database...");
|
||||
myHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(myService != null)
|
||||
{
|
||||
myHandler.post(() -> {
|
||||
if(myService != null) {
|
||||
myService.stopTCPConnection();
|
||||
myService.recreateTCPConnection();
|
||||
new ConnectTask().execute(new String[] {OperationCodes.TCP_CONNECTION_REQ + ""});
|
||||
|
||||
// add a new ITCPListener
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -2645,7 +2323,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
public void removeITCPListener() {
|
||||
if(tcpParser != null)
|
||||
tcpParser.clearITCPListeners();
|
||||
//tcpParser.removeTCPListener(itcpListener);
|
||||
}
|
||||
|
||||
|
||||
@ -2657,7 +2334,6 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
private void notifyBroadcast(String action) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(action);
|
||||
//intent.putExtra("extra", extra);
|
||||
getBaseContext().sendBroadcast(intent);
|
||||
}
|
||||
|
||||
@ -2666,13 +2342,12 @@ public class TabLayoutActivity extends AbstractSDParentActivity{
|
||||
private void notifyBroadcast(String action, Object object) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(action);
|
||||
if(action == OperationCodes.UNIT_STATUS_UPDATE+"")
|
||||
if(action.equals(OperationCodes.UNIT_STATUS_UPDATE + ""))
|
||||
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));
|
||||
else
|
||||
intent.putExtra("extra", new SerializedObject(object, action));
|
||||
getBaseContext().sendBroadcast(intent);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user