48
48
import nl .hnogames .domoticz .Interfaces .setCommandReceiver ;
49
49
import nl .hnogames .domoticz .MainActivity ;
50
50
import nl .hnogames .domoticz .R ;
51
+ import nl .hnogames .domoticz .Utils .NotificationUtil ;
51
52
import nl .hnogames .domoticz .Utils .SharedPrefUtil ;
52
53
import nl .hnogames .domoticz .Utils .UsefulBits ;
53
54
@@ -91,9 +92,8 @@ protected void onHandleIntent(Intent intent) {
91
92
for (Geofence geofence : geoFenceEvent .getTriggeringGeofences ()) {
92
93
LocationInfo locationFound = mSharedPrefs .getLocation (Integer .valueOf (geofence .getRequestId ()));
93
94
Log .d (TAG , "Triggered geofence location: " + locationFound .getName ());
94
-
95
95
if (mSharedPrefs .isGeofenceNotificationsEnabled ())
96
- sendNotification ("Entering " + locationFound .getName (), "Entering one of the locations" );
96
+ NotificationUtil . sendSimpleNotification ("Entering " + locationFound .getName (), "Entering one of the locations" , this );
97
97
98
98
if (locationFound .getSwitchidx () > 0 ) {
99
99
handleSwitch (locationFound .getSwitchidx (), true );
@@ -103,9 +103,8 @@ protected void onHandleIntent(Intent intent) {
103
103
for (Geofence geofence : geoFenceEvent .getTriggeringGeofences ()) {
104
104
LocationInfo locationFound = mSharedPrefs .getLocation (Integer .valueOf (geofence .getRequestId ()));
105
105
Log .d (TAG , "Triggered geofence location: " + locationFound .getName ());
106
-
107
106
if (mSharedPrefs .isGeofenceNotificationsEnabled ())
108
- sendNotification ("Leaving " + locationFound .getName (), "Leaving one of the locations" );
107
+ NotificationUtil . sendSimpleNotification ("Leaving " + locationFound .getName (), "Leaving one of the locations" , this );
109
108
110
109
if (locationFound .getSwitchidx () > 0 ) {
111
110
handleSwitch (locationFound .getSwitchidx (), false );
@@ -192,20 +191,6 @@ private void onErrorHandling(Exception error)
192
191
}
193
192
}
194
193
195
- private void sendNotification (String title , String text ) {
196
- NotificationCompat .Builder builder =
197
- new NotificationCompat .Builder (this )
198
- .setSmallIcon (R .drawable .ic_launcher )
199
- .setContentTitle (title )
200
- .setContentText (text );
201
- int NOTIFICATION_ID = 12345 ;
202
-
203
- Intent targetIntent = new Intent (this , MainActivity .class );
204
- PendingIntent contentIntent = PendingIntent .getActivity (this , 0 , targetIntent , PendingIntent .FLAG_UPDATE_CURRENT );
205
- builder .setContentIntent (contentIntent );
206
- NotificationManager nManager = (NotificationManager ) getSystemService (Context .NOTIFICATION_SERVICE );
207
- nManager .notify (NOTIFICATION_ID , builder .build ());
208
- }
209
194
210
195
211
196
@ Override
0 commit comments