Notifications improvements

This commit is contained in:
Sylvain Berfini 2018-11-22 17:34:02 +01:00
parent 2d905fba50
commit fec86cacc8
7 changed files with 26 additions and 9 deletions

View file

@ -931,10 +931,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
changeCurrentFragment(FragmentsAvailable.ACCOUNT_SETTINGS, bundle);
}
public StatusFragment getStatusFragment() {
return statusFragment;
}
public void refreshMissedChatCountDisplay() {
displayMissedChats(LinphoneManager.getInstance().getUnreadMessageCount());
}
@ -958,6 +954,9 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
missedChats.clearAnimation();
missedChats.setVisibility(View.GONE);
}
if (currentFragment == FragmentsAvailable.CHAT_LIST) {
((ChatRoomsFragment)fragment).invalidate();
}
}
public void displayCustomToast(final String message, final int duration) {

View file

@ -189,6 +189,12 @@ public class ChatRoomsFragment extends Fragment implements ContactsUpdatedListen
}
}
public void invalidate() {
if (mChatRoomsAdapter != null) {
mChatRoomsAdapter.notifyDataSetChanged();
}
}
@Override
public void onResume() {
super.onResume();

View file

@ -30,10 +30,12 @@ import android.graphics.Bitmap;
import android.graphics.drawable.Icon;
import org.linphone.R;
import org.linphone.mediastream.Log;
import org.linphone.notifications.Notifiable;
import org.linphone.notifications.NotifiableMessage;
import org.linphone.notifications.NotificationBroadcastReceiver;
import static org.linphone.compatibility.Compatibility.CHAT_NOTIFICATIONS_GROUP;
import static org.linphone.compatibility.Compatibility.INTENT_LOCAL_IDENTITY;
import static org.linphone.compatibility.Compatibility.INTENT_NOTIF_ID;
import static org.linphone.compatibility.Compatibility.INTENT_REPLY_NOTIF_ACTION;
@ -64,20 +66,24 @@ public class ApiTwentyEightPlus {
for (NotifiableMessage message : notif.getMessages()) {
Icon userIcon = Icon.createWithBitmap(message.getSenderBitmap());
Person user = new Person.Builder().setName(message.getSender()).setIcon(userIcon).build();
style.addMessage(message.getMessage(), message.getTime(), user);
style.addMessage(message.getMessage(), message.getTime() * 1000, user);
}
if (notif.isGroup()) {
style.setConversationTitle(notif.getGroupTitle());
}
style.setGroupConversation(notif.isGroup());
Log.e("System current time " + System.currentTimeMillis());
Log.e("Message timestamp " + notif.getMessages().get(0).getTime());
return new Notification.Builder(context, context.getString(R.string.notification_channel_id))
.setSmallIcon(R.drawable.topbar_chat_notification)
.setAutoCancel(true)
.setContentIntent(intent)
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS)
.setLargeIcon(contactIcon)
.setCategory(Notification.CATEGORY_MESSAGE)
.setGroup(CHAT_NOTIFICATIONS_GROUP)
.setVisibility(Notification.VISIBILITY_PRIVATE)
.setPriority(Notification.PRIORITY_HIGH)
.setNumber(notif.getMessages().size())

View file

@ -32,6 +32,7 @@ import org.linphone.notifications.Notifiable;
import org.linphone.notifications.NotifiableMessage;
import org.linphone.notifications.NotificationBroadcastReceiver;
import static org.linphone.compatibility.Compatibility.CHAT_NOTIFICATIONS_GROUP;
import static org.linphone.compatibility.Compatibility.INTENT_ANSWER_CALL_NOTIF_ACTION;
import static org.linphone.compatibility.Compatibility.INTENT_HANGUP_CALL_NOTIF_ACTION;
import static org.linphone.compatibility.Compatibility.INTENT_LOCAL_IDENTITY;
@ -79,9 +80,10 @@ public class ApiTwentyFourPlus {
.setSmallIcon(R.drawable.topbar_chat_notification)
.setAutoCancel(true)
.setContentIntent(intent)
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS)
.setLargeIcon(contactIcon)
.setCategory(Notification.CATEGORY_MESSAGE)
.setGroup(CHAT_NOTIFICATIONS_GROUP)
.setVisibility(Notification.VISIBILITY_PRIVATE)
.setPriority(Notification.PRIORITY_HIGH)
.setNumber(notif.getMessages().size())

View file

@ -51,7 +51,8 @@ public class ApiTwentyOnePlus {
.setAutoCancel(true)
.setContentIntent(intent)
.setDefaults(Notification.DEFAULT_SOUND
| Notification.DEFAULT_VIBRATE)
| Notification.DEFAULT_VIBRATE
| Notification.DEFAULT_LIGHTS)
.setLargeIcon(contactIcon)
.setLights(ContextCompat.getColor(context, R.color.notification_color_led),
context.getResources().getInteger(R.integer.notification_ms_on),

View file

@ -35,6 +35,7 @@ import org.linphone.notifications.Notifiable;
import org.linphone.notifications.NotifiableMessage;
import org.linphone.notifications.NotificationBroadcastReceiver;
import static org.linphone.compatibility.Compatibility.CHAT_NOTIFICATIONS_GROUP;
import static org.linphone.compatibility.Compatibility.INTENT_ANSWER_CALL_NOTIF_ACTION;
import static org.linphone.compatibility.Compatibility.INTENT_HANGUP_CALL_NOTIF_ACTION;
import static org.linphone.compatibility.Compatibility.INTENT_LOCAL_IDENTITY;
@ -112,9 +113,10 @@ public class ApiTwentySixPlus {
.setSmallIcon(R.drawable.topbar_chat_notification)
.setAutoCancel(true)
.setContentIntent(intent)
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS)
.setLargeIcon(contactIcon)
.setCategory(Notification.CATEGORY_MESSAGE)
.setGroup(CHAT_NOTIFICATIONS_GROUP)
.setVisibility(Notification.VISIBILITY_PRIVATE)
.setPriority(Notification.PRIORITY_HIGH)
.setNumber(notif.getMessages().size())

View file

@ -32,6 +32,7 @@ import org.linphone.mediastream.Version;
import org.linphone.notifications.Notifiable;
public class Compatibility {
public static final String CHAT_NOTIFICATIONS_GROUP = "CHAT_NOTIF_GROUP";
public static final String KEY_TEXT_REPLY = "key_text_reply";
public static final String INTENT_NOTIF_ID = "NOTIFICATION_ID";
public static final String INTENT_REPLY_NOTIF_ACTION = "org.linphone.REPLY_ACTION";