Compare commits

..

18 Commits

Author SHA1 Message Date
dc2cb825bb resoving merge 2022-04-08 18:25:53 +03:00
f6cb72368d Merge pull request 'fix unit selection' (#25) from SD-221 into develop
Reviewed-on: #25
2022-04-08 11:50:39 +00:00
97b7e2d9a7 fix unit selection 2022-04-08 14:48:07 +03:00
33d00c27d7 Merge pull request 'display satelite map' (#24) from SD-220 into develop
Reviewed-on: #24
2022-04-08 10:54:18 +00:00
cc78f29f26 display satelite map 2022-04-08 13:52:16 +03:00
e7c3672b93 Merge pull request 'update info bubble box info' (#23) from SD-219 into develop
Reviewed-on: #23
2022-04-07 10:32:52 +00:00
feb7bd654c update info bubble box info 2022-04-07 13:31:23 +03:00
539170109d Merge pull request 'when receiving a new alarm && current tab is alarms, refresh alarm list' (#22) from SD-224 into develop
Reviewed-on: #22
2022-04-07 10:16:35 +00:00
0bdd161d69 when receiving a new alarm && current tab is alarms, refresh alarm list 2022-04-07 13:14:58 +03:00
680dd0f803 Merge pull request 'fix login button display when internet connection is available' (#21) from SD-217 into develop
Reviewed-on: #21
2022-04-06 07:05:25 +00:00
0b890b74e0 fix login button display when internet connection is available 2022-04-06 10:03:37 +03:00
73d2cedfba Merge pull request 'display alarm notification' (#20) from SD-224 into develop
Reviewed-on: #20
2022-04-04 07:07:40 +00:00
5c075ee168 display alarm notification 2022-04-04 09:59:49 +03:00
1299ff2d2e Merge pull request 'make messages view match parent' (#19) from SD-225 into develop
Reviewed-on: #19
2022-04-04 05:58:15 +00:00
8ab29576c5 make messages view match parent 2022-04-04 08:56:52 +03:00
d9a031a46d Merge pull request 'feature/notifications' (#18) from feature/notifications into develop
Reviewed-on: #18
2022-04-01 07:03:54 +00:00
ba0dc850f7 display notifications 2022-03-31 14:12:03 +03:00
ca4255943a clean code 2022-03-30 12:52:38 +03:00
10 changed files with 137 additions and 173 deletions

View File

@ -255,13 +255,12 @@ public abstract class AbstractSDParentActivity extends TabActivity {
return res;
}
public boolean getAlarms(long userID)
{
if(tcp == null)
public boolean getAlarms(long userID) {
if (tcp == null)
return false;
boolean res = tcp.Write("0.0", "#27#" + userID + "#");
if(res)
if (res)
SM.Debug("Message [GetAlarms] sent to app server");
else
SM.Debug("Could not send message [GetAlarms]!!");

View File

@ -1,7 +1,6 @@
package com.safemobile.services;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
@ -12,16 +11,14 @@ import com.safemobile.lib.SM;
import com.safemobile.lib.TCPmsg;
public class TCPmsgParser implements Runnable{
public class TCPmsgParser implements Runnable {
public boolean run = true;
private TCPmsg _msg;
private static List<ITCPListener> _listeners = new ArrayList<ITCPListener>();
private static final List<ITCPListener> _listeners = new ArrayList<>();
private Thread TCPmsgParserThread;
public TCPmsgParser()
{
public TCPmsgParser() {
TCPmsgParserThread = new Thread(this, "TCPmsgParserThread");
TCPmsgParserThread.start(); // (2) Start the thread.
}
@ -38,177 +35,151 @@ public class TCPmsgParser implements Runnable{
_listeners.clear();
}
public int getListenersSize()
{
return _listeners.size();
}
private synchronized void _fireLoginEvent() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onLoginReceived( event );
for (ITCPListener listener : _listeners) {
listener.onLoginReceived(event);
}
}
private synchronized void _fireGPSEvent() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onGPSReceived(event);
for (ITCPListener listener : _listeners) {
listener.onGPSReceived(event);
}
}
private synchronized void _fireSMSEvent() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onSMSReceived( event );
for (ITCPListener listener : _listeners) {
listener.onSMSReceived(event);
}
}
private synchronized void _fireLastSMSEvent() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onLastSMSsReceived(event);
for (ITCPListener listener : _listeners) {
listener.onLastSMSsReceived(event);
}
}
private synchronized void _fireVehEvent() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onVehiclesReceived( event );
for (ITCPListener listener : _listeners) {
listener.onVehiclesReceived(event);
}
}
private synchronized void _fireNewSMS() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onNewSMSReceived(event);
for (ITCPListener listener : _listeners) {
listener.onNewSMSReceived(event);
}
}
private synchronized void _fireSMSconfirm() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onSMSAckReceived(event);
for (ITCPListener listener : _listeners) {
listener.onSMSAckReceived(event);
}
}
private synchronized void _fireLastPos() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onLastPositionsReceived(event);
for (ITCPListener listener : _listeners) {
listener.onLastPositionsReceived(event);
}
}
private synchronized void _fireRadioEvent() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onRadioMsgReceived(event);
for (ITCPListener listener : _listeners) {
listener.onRadioMsgReceived(event);
}
}
private synchronized void _fireHistPos() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onHistoryPositionsReceived(event);
for (ITCPListener listener : _listeners) {
listener.onHistoryPositionsReceived(event);
}
}
private synchronized void _fireHistCount() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onHistoryPositionsCountReceived(event);
for (ITCPListener listener : _listeners) {
listener.onHistoryPositionsCountReceived(event);
}
}
private synchronized void _fireAlarmList() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onAlarmsReceived(event);
for (ITCPListener listener : _listeners) {
listener.onAlarmsReceived(event);
}
}
private synchronized void _fireAlarmACK() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).onAlarmAckReceived(event);
for (ITCPListener listener : _listeners) {
listener.onAlarmAckReceived(event);
}
}
private synchronized void _fireAlarmLive() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next() ).alarmLiveReceived(event);
for (ITCPListener listener : _listeners) {
listener.alarmLiveReceived(event);
}
}
private synchronized void _fireRecordList() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next()).onRecordingsListReceived(event);
for (ITCPListener listener : _listeners) {
listener.onRecordingsListReceived(event);
}
}
private synchronized void _fireRecordPlay() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next()).onRecordingPlayReceived(event);
for (ITCPListener listener : _listeners) {
listener.onRecordingPlayReceived(event);
}
}
private synchronized void _firePOLLEvent() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next()).onPollReceived(event);
for (ITCPListener listener : _listeners) {
listener.onPollReceived(event);
}
}
private synchronized void _fireConnectionReplyEvent() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next()).onConnectionReplyReceived(event);
for (ITCPListener listener : _listeners) {
listener.onConnectionReplyReceived(event);
}
}
private synchronized void _fireContactsReceivedEvent() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next()).onContactsListReceived(event);
for (ITCPListener listener : _listeners) {
listener.onContactsListReceived(event);
}
}
private synchronized void _fireRecordingsReceivedEvent() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next()).onRecordingsListReceived(event);
for (ITCPListener listener : _listeners) {
listener.onRecordingsListReceived(event);
}
}
private synchronized void _fireTextMessagesReceivedEvent() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next()).onTextMessagesListReceived(event);
for (ITCPListener listener : _listeners) {
listener.onTextMessagesListReceived(event);
}
}
@ -216,64 +187,56 @@ public class TCPmsgParser implements Runnable{
private synchronized void _fireRecordingPlayReceivedEvent() {
TCPEvent event = new TCPEvent( this, _msg );
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next()).onRecordingPlayReceived(event);
for (ITCPListener listener : _listeners) {
listener.onRecordingPlayReceived(event);
}
}
public static synchronized void _fireTCPConnectionDownEvent(boolean previuosWasConnectionUp) {
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next()).onTCPConnectionDown(previuosWasConnectionUp);
for (ITCPListener listener : _listeners) {
listener.onTCPConnectionDown(previuosWasConnectionUp);
}
}
public static synchronized void _fireTCPConnectionUpEvent(boolean previuosWasConnectionUp) {
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next()).onTCPConnectionUp(previuosWasConnectionUp);
for (ITCPListener listener : _listeners) {
listener.onTCPConnectionUp(previuosWasConnectionUp);
}
}
public static synchronized void _fireonTCPConnectionStatusEvent(boolean isConnectionUp, boolean previuosWasConnectionUp) {
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next()).onTCPConnectionStatusReceived(isConnectionUp, previuosWasConnectionUp);
for (ITCPListener listener : _listeners) {
listener.onTCPConnectionStatusReceived(isConnectionUp, previuosWasConnectionUp);
}
}
public static synchronized void _firePONGReceivedEvent() {
Iterator<ITCPListener> listeners = _listeners.iterator();
while( listeners.hasNext() ) {
( (ITCPListener) listeners.next()).onPONGReceived();
for (ITCPListener listener : _listeners) {
listener.onPONGReceived();
}
}
@Override
public void run()
{
while(run)
{
//SM.Debug("TCPmsgParser waiting for data...");
public void run() {
while(run) {
sleep(1);
if(TCPhandler.msgList==null)
if (TCPhandler.msgList == null)
continue;
if(!TCPhandler.msgList.isEmpty())
{
try
{
if(!TCPhandler.msgList.isEmpty()) {
try {
_msg = TCPhandler.msgList.poll();
if(_msg == null)
continue;
if(_msg.OK == false)
if(!_msg.OK)
continue;
//parse the rest of the message;
switch(_msg.opCode)
{
case 40: /* login */{
@ -286,22 +249,21 @@ public class TCPmsgParser implements Runnable{
break;
}
case 42: /* Text Message */{
_fireSMSEvent();
break;
}
case 43: /* Last text message */ {
_fireLastSMSEvent();
break;
}
case OperationCodes.TM_ACK:{
_fireSMSconfirm();
break;
}
case OperationCodes.TM_ACK_SD:{
case OperationCodes.TM_ACK:
case OperationCodes.TM_ACK_SD: {
_fireSMSconfirm();
break;
}
@ -326,12 +288,13 @@ public class TCPmsgParser implements Runnable{
break;
}
case 50: /* radio */ {
_fireRadioEvent();
break;
}
case 46: {
case 46:{
_fireHistPos();
break;
}
@ -341,11 +304,13 @@ public class TCPmsgParser implements Runnable{
break;
}
case 47: /* alert list */ {
_fireAlarmList();
break;
}
case 48: /* alert ack */ {
_fireAlarmACK();
break;
@ -403,37 +368,27 @@ public class TCPmsgParser implements Runnable{
default:
break;
}
}
catch(Exception ex)
{
catch(Exception ex) {
try {
if(TCPhandler.msgList.size() > 0)
_msg = TCPhandler.msgList.remove(0);
}
catch(NoSuchElementException exe)
{
} catch(NoSuchElementException exe) {
SM.Exception("TCP msg Parser", "NoSuchElementException");
}
}
}
}
/*
catch (Exception e)
{
SM.Debug("Error on fire Event:"+e.toString());
break;
}
}*/
SM.Debug("TCPmsgParser listen thread stoped.");
}
private void sleep(int miliseconds) {
try {
Thread.sleep(miliseconds);
} catch (InterruptedException e) {
}
} catch (InterruptedException ignored) { }
}
public void clearMsgList()
@ -441,17 +396,14 @@ public class TCPmsgParser implements Runnable{
TCPhandler.msgList.clear();
}
public void Stop()
{
public void Stop() {
run = false;
// stop thread
if(TCPmsgParserThread != null)
{
if(TCPmsgParserThread != null) {
Thread moribund = TCPmsgParserThread;
TCPmsgParserThread = null;
moribund.interrupt();
}
SM.Debug("Stoping TCPmsgParser");
}
}

View File

@ -78,6 +78,4 @@ dependencies {
// add Gson
implementation 'com.google.code.gson:gson:2.8.6'
//retrofit
}

View File

@ -42,7 +42,6 @@ public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter {
public GoogleMapsInfoBubble(LayoutInflater layoutInflater, Context context) {
isLiveTab = false;
this.context = context;
// this.superVehHash = vehicles;
mWindow = layoutInflater.inflate(R.layout.map_marker_info_bubble, null);
}
@ -73,7 +72,7 @@ public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter {
}
} else {
try {
position = Integer.getInteger(marker.getTitle());
position = Integer.parseInt(marker.getTitle());
} catch (Exception e) {
Log.v(TAG, "Unable to parse Google Maps Info Bubble title on History");
}

View File

@ -100,6 +100,17 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
}
});
ImageView mapType = findViewById(R.id.changeMapTypeHeader);
mapType.setOnClickListener(view -> {
if (googleMap.getMapType() != GoogleMap.MAP_TYPE_SATELLITE) {
mapType.setImageResource(R.drawable.map);
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
} else {
mapType.setImageResource(R.drawable.satellite);
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
});
setDate();
}

View File

@ -145,11 +145,11 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
// image View for changing map type satellite or map
ImageView changeMapTypeImageView = findViewById(R.id.changeMapType);
changeMapTypeImageView.setOnClickListener(v -> {
if (googleMap.getMapType() == GoogleMap.MAP_TYPE_SATELLITE) {
changeMapTypeImageView.setImageResource(R.drawable.satellite);
if (googleMap.getMapType() != GoogleMap.MAP_TYPE_SATELLITE) {
changeMapTypeImageView.setImageResource(R.drawable.map);
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
} else {
changeMapTypeImageView.setImageResource(R.drawable.map);
changeMapTypeImageView.setImageResource(R.drawable.satellite);
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
});
@ -687,7 +687,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
// change check image for selected value
VehiclesGridViewAdapter.ViewHolder viewLive = (VehiclesGridViewAdapter.ViewHolder) view.getTag();
if (Boolean.TRUE.equals(displayedVehicles.get(position)))
if (displayedVehicles.get(position))
viewLive.imgViewChecked.setImageResource(R.drawable.checked);
else
viewLive.imgViewChecked.setImageResource(R.drawable.unchecked);
@ -695,16 +695,16 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
// check if all values are identical
boolean identical = true;
for (Boolean displ : displayedVehicles)
if (!Objects.equals(displ, displayedVehicles.get(0))) {
if (displ != displayedVehicles.get(0)) {
identical = false;
break;
}
// change image when all values are identical
if (identical && Boolean.TRUE.equals(displayedVehicles.get(0))) {
if (identical && displayedVehicles.get(0)) {
imageViewCheckAll.setSelected(true);
imageViewCheckAll.setBackgroundResource(R.drawable.check_all);
} else if (identical && Boolean.TRUE.equals(!displayedVehicles.get(0))) {
} else {
imageViewCheckAll.setSelected(false);
imageViewCheckAll.setBackgroundResource(R.drawable.uncheck_all);
}

View File

@ -21,11 +21,16 @@ public class NotificationActivity extends Activity{
// broadcast intent
Intent i = new Intent();
switch(key)
{
case AppParams.messageNotif: i.setAction(NOTIFICATION_MESSAGE_INTENT); break;
case AppParams.alertNotif: i.setAction(NOTIFICATION_ALERT_INTENT); break;
case AppParams.pollNotif: i.setAction(NOTIFICATION_POLL_INTENT); break;
switch(key) {
case AppParams.messageNotif:
i.setAction(NOTIFICATION_MESSAGE_INTENT);
break;
case AppParams.alertNotif:
i.setAction(NOTIFICATION_ALERT_INTENT);
break;
case AppParams.pollNotif:
i.setAction(NOTIFICATION_POLL_INTENT);
break;
}
getBaseContext().sendBroadcast(i);
@ -35,6 +40,4 @@ public class NotificationActivity extends Activity{
/* Finish activity and return to parent activity */
finish();
}
}

View File

@ -89,6 +89,8 @@
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="@+id/layoutNewMessage"
android:layout_width="350dp"

View File

@ -166,7 +166,7 @@
<GridView
android:id="@+id/gridView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:background="#999999"
android:drawSelectorOnTop="false"
android:horizontalSpacing="0dp"

View File

@ -164,7 +164,7 @@
<GridView
android:id="@+id/gridView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:background="#999999"
android:drawSelectorOnTop="false"
android:horizontalSpacing="0dp"