SLAM/mobile/src/main/java/de/vanitasvitae/slam/receiver/MessageReadReceiver.java

43 lines
1.7 KiB
Java
Raw Normal View History

2018-01-27 03:33:50 +01:00
/*
2018-02-12 02:08:56 +01:00
* Copyright 2018 Paul Schaub
2018-01-27 03:33:50 +01:00
*
2018-02-12 02:08:56 +01:00
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
2018-01-27 03:33:50 +01:00
*
2018-02-12 02:08:56 +01:00
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
2018-01-27 03:33:50 +01:00
*
2018-02-12 02:08:56 +01:00
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2018-01-27 03:33:50 +01:00
*/
package de.vanitasvitae.slam.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationManagerCompat;
import android.util.Log;
import de.vanitasvitae.slam.service.MyMessagingService;
public class MessageReadReceiver extends BroadcastReceiver {
private static final String TAG = MessageReadReceiver.class.getSimpleName();
@Override
public void onReceive(Context context, Intent intent) {
if (MyMessagingService.READ_ACTION.equals(intent.getAction())) {
int conversationId = intent.getIntExtra(MyMessagingService.CONVERSATION_ID, -1);
if (conversationId != -1) {
Log.d(TAG, "Conversation " + conversationId + " was read");
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.cancel(conversationId);
}
}
}
}