Compare commits
No commits in common. "d9a031a46d837a8b8cc0bc46f1cb6573679b8b0b" and "b2fdb1c8d717ec4c0f0050a0f57681da9bbfdbfc" have entirely different histories.
d9a031a46d
...
b2fdb1c8d7
@ -1,6 +1,7 @@
|
||||
package com.safemobile.services;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
@ -11,14 +12,16 @@ 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 final List<ITCPListener> _listeners = new ArrayList<>();
|
||||
private static List<ITCPListener> _listeners = new ArrayList<ITCPListener>();
|
||||
private Thread TCPmsgParserThread;
|
||||
|
||||
public TCPmsgParser() {
|
||||
public TCPmsgParser()
|
||||
{
|
||||
TCPmsgParserThread = new Thread(this, "TCPmsgParserThread");
|
||||
TCPmsgParserThread.start(); // (2) Start the thread.
|
||||
}
|
||||
@ -35,151 +38,177 @@ public class TCPmsgParser implements Runnable {
|
||||
_listeners.clear();
|
||||
}
|
||||
|
||||
public int getListenersSize()
|
||||
{
|
||||
return _listeners.size();
|
||||
}
|
||||
|
||||
private synchronized void _fireLoginEvent() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onLoginReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onLoginReceived( event );
|
||||
}
|
||||
}
|
||||
private synchronized void _fireGPSEvent() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onGPSReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onGPSReceived(event);
|
||||
}
|
||||
}
|
||||
private synchronized void _fireSMSEvent() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onSMSReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onSMSReceived( event );
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireLastSMSEvent() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onLastSMSsReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onLastSMSsReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireVehEvent() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onVehiclesReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onVehiclesReceived( event );
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireNewSMS() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onNewSMSReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onNewSMSReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireSMSconfirm() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onSMSAckReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onSMSAckReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireLastPos() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onLastPositionsReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onLastPositionsReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireRadioEvent() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onRadioMsgReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onRadioMsgReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireHistPos() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onHistoryPositionsReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onHistoryPositionsReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireHistCount() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onHistoryPositionsCountReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onHistoryPositionsCountReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireAlarmList() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onAlarmsReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onAlarmsReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireAlarmACK() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onAlarmAckReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).onAlarmAckReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireAlarmLive() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.alarmLiveReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next() ).alarmLiveReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireRecordList() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onRecordingsListReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next()).onRecordingsListReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireRecordPlay() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onRecordingPlayReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next()).onRecordingPlayReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _firePOLLEvent() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onPollReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next()).onPollReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireConnectionReplyEvent() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onConnectionReplyReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next()).onConnectionReplyReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireContactsReceivedEvent() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onContactsListReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next()).onContactsListReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireRecordingsReceivedEvent() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onRecordingsListReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next()).onRecordingsListReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void _fireTextMessagesReceivedEvent() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onTextMessagesListReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next()).onTextMessagesListReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,55 +216,66 @@ public class TCPmsgParser implements Runnable {
|
||||
private synchronized void _fireRecordingPlayReceivedEvent() {
|
||||
TCPEvent event = new TCPEvent( this, _msg );
|
||||
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onRecordingPlayReceived(event);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next()).onRecordingPlayReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static synchronized void _fireTCPConnectionDownEvent(boolean previuosWasConnectionUp) {
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onTCPConnectionDown(previuosWasConnectionUp);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next()).onTCPConnectionDown(previuosWasConnectionUp);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void _fireTCPConnectionUpEvent(boolean previuosWasConnectionUp) {
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onTCPConnectionUp(previuosWasConnectionUp);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next()).onTCPConnectionUp(previuosWasConnectionUp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static synchronized void _fireonTCPConnectionStatusEvent(boolean isConnectionUp, boolean previuosWasConnectionUp) {
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onTCPConnectionStatusReceived(isConnectionUp, previuosWasConnectionUp);
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next()).onTCPConnectionStatusReceived(isConnectionUp, previuosWasConnectionUp);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void _firePONGReceivedEvent() {
|
||||
for (ITCPListener listener : _listeners) {
|
||||
listener.onPONGReceived();
|
||||
Iterator<ITCPListener> listeners = _listeners.iterator();
|
||||
while( listeners.hasNext() ) {
|
||||
( (ITCPListener) listeners.next()).onPONGReceived();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while(run) {
|
||||
public void run()
|
||||
{
|
||||
while(run)
|
||||
{
|
||||
//SM.Debug("TCPmsgParser waiting for data...");
|
||||
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)
|
||||
if(_msg.OK == false)
|
||||
continue;
|
||||
//parse the rest of the message;
|
||||
|
||||
switch(_msg.opCode) {
|
||||
switch(_msg.opCode)
|
||||
{
|
||||
case 40:{
|
||||
_fireLoginEvent();
|
||||
break;
|
||||
@ -256,8 +296,11 @@ public class TCPmsgParser implements Runnable {
|
||||
break;
|
||||
}
|
||||
|
||||
case OperationCodes.TM_ACK:
|
||||
case OperationCodes.TM_ACK_SD: {
|
||||
case OperationCodes.TM_ACK:{
|
||||
_fireSMSconfirm();
|
||||
break;
|
||||
}
|
||||
case OperationCodes.TM_ACK_SD:{
|
||||
_fireSMSconfirm();
|
||||
break;
|
||||
}
|
||||
@ -360,23 +403,38 @@ 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 ignored) { }
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearMsgList()
|
||||
@ -384,14 +442,17 @@ 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");
|
||||
}
|
||||
|
||||
}
|
@ -78,4 +78,6 @@ dependencies {
|
||||
|
||||
// add Gson
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
|
||||
//retrofit
|
||||
}
|
||||
|
@ -21,16 +21,11 @@ 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);
|
||||
@ -40,4 +35,6 @@ public class NotificationActivity extends Activity{
|
||||
/* Finish activity and return to parent activity */
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
@ -74,7 +74,6 @@ import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
@ -95,8 +94,6 @@ import android.widget.Toast;
|
||||
import android.widget.TabHost.TabSpec;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
public class TabLayoutActivity extends AbstractSDParentActivity {
|
||||
|
||||
@ -1234,7 +1231,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
|
||||
getMessageActivity().updateSMS(sms.smsList);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
SM.Debug("Error on smsReceived:" + ex);
|
||||
SM.Debug("Error on smsReceived:" + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1465,7 +1462,7 @@ 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));
|
||||
int all = Integer.parseInt(tmpHist.seqID.substring(tmpHist.seqID.indexOf('.') + 1, tmpHist.seqID.length()));
|
||||
if (all != 0) {
|
||||
if (Boolean.TRUE.equals(getFirstHistoryData())) {
|
||||
try {
|
||||
@ -1707,11 +1704,13 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
|
||||
case 137:
|
||||
setMess("zone " + tempArr[1]);
|
||||
break;
|
||||
case 138:
|
||||
setMess("emergency");
|
||||
break;
|
||||
case 140:
|
||||
setMess("telemetry " + tempArr[1]);
|
||||
break;
|
||||
default:
|
||||
// 138
|
||||
setMess("emergency");
|
||||
}
|
||||
myHandler.post(updateResultsAlarm);
|
||||
@ -1990,7 +1989,10 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
|
||||
|
||||
public void createNotification(int icon) {
|
||||
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
String contentTitle, contentText;
|
||||
String tickerText = "SafeMobile Dispatch: New Message from " + getImei();
|
||||
String contentTitle = "New Message from " + getImei();
|
||||
String contentText = "\"" + getMess() + "\"";
|
||||
|
||||
Vehicle veh = getVehicle4Imei(getImei());
|
||||
|
||||
int iconValue = icon;
|
||||
@ -2003,6 +2005,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
|
||||
case AppParams.pollNotif:
|
||||
contentText = "\"" + getMess() + "\"";
|
||||
contentTitle = "Poll Reply from " + (veh != null ? getVehicle4Imei(getImei()).name : getImei());
|
||||
tickerText = "SafeMobile Dispatch: Poll Reply from " + (veh != null ? getVehicle4Imei(getImei()).name : getImei());
|
||||
icon = R.drawable.poll;
|
||||
break;
|
||||
case AppParams.alertNotif:
|
||||
@ -2011,53 +2014,34 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
|
||||
vehName = getString(R.string.from) + ": " + getVehicle4Imei(getImei()).name;
|
||||
contentText = "\"" + getMess() + "\"";
|
||||
contentTitle = getString(R.string.newAlarm) + vehName;
|
||||
icon = R.drawable.arrow_down;
|
||||
tickerText = "SafeMobile Dispatch: " + getString(R.string.newAlarm) + vehName;
|
||||
icon = R.drawable.alert;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + icon);
|
||||
}
|
||||
|
||||
Notification notification = new Notification(icon, tickerText, System.currentTimeMillis());
|
||||
|
||||
// set intent to be opened on NotificationClick
|
||||
/* Notification */
|
||||
Intent intent = new Intent(this, NotificationActivity.class);
|
||||
intent.putExtra("key", iconValue);
|
||||
Intent notificationIntent = new Intent(this, NotificationActivity.class);
|
||||
notificationIntent.putExtra("key", iconValue);
|
||||
|
||||
// cancel old notification
|
||||
mNotificationManager.cancel(icon);
|
||||
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, NOTIFICATION_ACTIVITY_RESULT, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
createNotificationChannel(icon, contentTitle, contentText, pendingIntent);
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(context, NOTIFICATION_ACTIVITY_RESULT, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
// flag that the notification will be closed when clicked
|
||||
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||
notification.number = 1; // the same notification will be shown;
|
||||
notification.tickerText = tickerText; // notification text when arrives
|
||||
notification.sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.new_sms);
|
||||
// add notification to the manager
|
||||
mNotificationManager.notify(icon, notification);
|
||||
}
|
||||
|
||||
private void createNotificationChannel(int icon, String title, String text, PendingIntent pendingIntent) {
|
||||
// Create the NotificationChannel, but only on API 26+ because
|
||||
// the NotificationChannel class is new and not in the support library
|
||||
String notificationChannelID = String.valueOf(icon);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
CharSequence name = "Notification Channel";
|
||||
int importance = NotificationManager.IMPORTANCE_HIGH;
|
||||
NotificationChannel channel = new NotificationChannel(notificationChannelID, name, importance);
|
||||
// Register the channel with the system; you can't change the importance
|
||||
// or other notification behaviors after this
|
||||
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, notificationChannelID)
|
||||
.setSmallIcon(icon)
|
||||
.setContentTitle(title)
|
||||
.setContentText(text)
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||
.setAutoCancel(true)
|
||||
.setContentIntent(pendingIntent);
|
||||
|
||||
Log.v("test111", "test");
|
||||
NotificationManagerCompat managerCompat = NotificationManagerCompat.from(context);
|
||||
managerCompat.notify(icon, builder.build());
|
||||
}
|
||||
|
||||
|
||||
// return vehicle according to imei
|
||||
private Vehicle getVehicle4Imei(String imei) {
|
||||
Vehicle veh = null;
|
||||
@ -2201,7 +2185,7 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
|
||||
|
||||
setVehicleStatus(Integer.parseInt(params[1]), Integer.parseInt(params[2]), Integer.parseInt(params[3]), Integer.parseInt(params[4]));
|
||||
} catch (Exception ex) {
|
||||
SM.Exception("Paramas -> setVehicleStatus", "EXCeption ex " + ex);
|
||||
SM.Exception("Paramas -> setVehicleStatus", "EXCeption ex " + ex.toString());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2232,6 +2216,21 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
|
||||
new ConnectTask().execute(params);
|
||||
}
|
||||
|
||||
public class ConnectParserTask extends AsyncTask<String, Void, TCPhandler> {
|
||||
@Override
|
||||
protected TCPhandler doInBackground(String... params) {
|
||||
if (myService != null)
|
||||
tcpParser = myService.getTCPmsgParser();
|
||||
|
||||
// add TCPParserListener
|
||||
if (tcpParser != null) {
|
||||
SM.Debug("## tcpParser != null ", "#### call tcpParserListener(");
|
||||
tcpParserListener();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* Display Toast messages*/
|
||||
@Override
|
||||
public void displayToast(final String msg) {
|
||||
@ -2341,8 +2340,10 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
SM.Debug("onRequestPermissionsResult", "[requestCode] " + requestCode);
|
||||
String permission = "";
|
||||
switch (requestCode) {
|
||||
case PermissionModule.RECORD_AUDIO_PERMISSION_REQUEST_CODE:
|
||||
permission = Manifest.permission.RECORD_AUDIO;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + requestCode);
|
||||
@ -2393,9 +2394,10 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
|
||||
|
||||
private void waitForUserInput(Boolean result) {
|
||||
if (result) {
|
||||
final int requestCode = 1202;
|
||||
//navigate to application's settings
|
||||
String action = ProviderSettingsHelper.getAction(ProviderSettingsStatus.APPLICATION_DETAILS);
|
||||
if (action == null || action.equals(""))
|
||||
if (action == null || action == "")
|
||||
return;
|
||||
|
||||
boolean isActionApplicationDetailsSettings = action.equals(ProviderSettingsHelper.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
|
@ -89,8 +89,6 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layoutNewMessage"
|
||||
android:layout_width="350dp"
|
||||
|
Loading…
Reference in New Issue
Block a user