Fix crash at launch on Android O
This commit is contained in:
parent
07bce56251
commit
7bc0335d06
19 changed files with 131 additions and 53 deletions
|
@ -7,5 +7,5 @@
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="16"
|
android:minSdkVersion="16"
|
||||||
android:targetSdkVersion="25"/>
|
android:targetSdkVersion="26"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
14
build.gradle
14
build.gradle
|
@ -43,7 +43,7 @@ dependencies {
|
||||||
androidTestCompile 'junit:junit:4.12'
|
androidTestCompile 'junit:junit:4.12'
|
||||||
compile group: 'org.apache.commons', name: 'commons-compress', version: '1.14'
|
compile group: 'org.apache.commons', name: 'commons-compress', version: '1.14'
|
||||||
if (firebaseEnable()) {
|
if (firebaseEnable()) {
|
||||||
compile 'com.google.firebase:firebase-messaging:11.0.2'
|
compile 'com.google.firebase:firebase-messaging:11.0.4'
|
||||||
} else {
|
} else {
|
||||||
compile fileTree(include: 'gcm.jar', dir: 'libs')
|
compile fileTree(include: 'gcm.jar', dir: 'libs')
|
||||||
compile 'com.android.support:support-v4:+'
|
compile 'com.android.support:support-v4:+'
|
||||||
|
@ -183,10 +183,12 @@ android.applicationVariants.all { variant ->
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
task runApplication << {
|
task runApplication {
|
||||||
def result = exec {
|
doLast {
|
||||||
executable = android.getAdbExecutable().toString()
|
def result = exec {
|
||||||
ignoreExitValue true
|
executable = android.getAdbExecutable().toString()
|
||||||
args = ['shell', 'monkey', '-p', getPackageName(), '-c', 'android.intent.category.LAUNCHER', '1']
|
ignoreExitValue true
|
||||||
|
args = ['shell', 'monkey', '-p', getPackageName(), '-c', 'android.intent.category.LAUNCHER', '1']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
|
import android.*;
|
||||||
|
import android.Manifest;
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
import android.content.ContentProviderOperation;
|
import android.content.ContentProviderOperation;
|
||||||
|
@ -42,6 +44,7 @@ import org.linphone.core.LinphoneFriend;
|
||||||
import org.linphone.core.LinphoneFriendImpl;
|
import org.linphone.core.LinphoneFriendImpl;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
import org.linphone.mediastream.Version;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -171,9 +174,15 @@ public class ContactsManager extends ContentObserver {
|
||||||
public boolean hasContactsAccess() {
|
public boolean hasContactsAccess() {
|
||||||
if (context == null)
|
if (context == null)
|
||||||
return false;
|
return false;
|
||||||
int contacts = context.getPackageManager().checkPermission(android.Manifest.permission.READ_CONTACTS, context.getPackageName());
|
boolean contactsR = (PackageManager.PERMISSION_GRANTED ==
|
||||||
|
context.getPackageManager().checkPermission(android.Manifest.permission.READ_CONTACTS, context.getPackageName()));
|
||||||
|
boolean contactsW = true;
|
||||||
context.getPackageManager();
|
context.getPackageManager();
|
||||||
return contacts == PackageManager.PERMISSION_GRANTED && !context.getResources().getBoolean(R.bool.force_use_of_linphone_friends);
|
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
||||||
|
contactsW = (PackageManager.PERMISSION_GRANTED ==
|
||||||
|
context.getPackageManager().checkPermission(Manifest.permission.WRITE_CONTACTS, context.getPackageName()));
|
||||||
|
}
|
||||||
|
return contactsW && contactsR && !context.getResources().getBoolean(R.bool.force_use_of_linphone_friends);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLinphoneContactsPrefered(boolean isPrefered) {
|
public void setLinphoneContactsPrefered(boolean isPrefered) {
|
||||||
|
|
|
@ -751,7 +751,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
mTimer.schedule(lTask, 0, 20);
|
mTimer.schedule(lTask, 0, 20);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
Log.e(e);
|
|
||||||
Log.e(e, "Cannot start linphone");
|
Log.e(e, "Cannot start linphone");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1180,6 +1179,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneAddress from = message.getFrom();
|
LinphoneAddress from = message.getFrom();
|
||||||
|
String to = message.getTo().asString();
|
||||||
|
|
||||||
String textMessage = (message.getFileTransferInformation() != null) ?
|
String textMessage = (message.getFileTransferInformation() != null) ?
|
||||||
getString(R.string.content_description_incoming_file) : message.getText();
|
getString(R.string.content_description_incoming_file) : message.getText();
|
||||||
|
@ -1187,9 +1187,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(from);
|
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(from);
|
||||||
if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat_message_notification)) {
|
if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat_message_notification)) {
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), contact.getFullName(), textMessage);
|
LinphoneService.instance().displayMessageNotification(to, from.asStringUriOnly(), contact.getFullName(), textMessage);
|
||||||
} else {
|
} else {
|
||||||
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), from.getUserName(), textMessage);
|
LinphoneService.instance().displayMessageNotification(to, from.asStringUriOnly(), from.getUserName(), textMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1205,15 +1205,16 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
}
|
}
|
||||||
|
|
||||||
final LinphoneAddress from = message.getFrom();
|
final LinphoneAddress from = message.getFrom();
|
||||||
|
String to = message.getTo().asString();
|
||||||
try {
|
try {
|
||||||
final LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(from);
|
final LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(from);
|
||||||
if (LinphoneActivity.instance().isOnBackground()) {
|
if (LinphoneActivity.instance().isOnBackground()) {
|
||||||
if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat_message_notification)) {
|
if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat_message_notification)) {
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), contact.getFullName()
|
LinphoneService.instance().displayMessageNotification(to, from.asStringUriOnly(), contact.getFullName()
|
||||||
, getString(R.string.message_cant_be_decrypted_notif));
|
, getString(R.string.message_cant_be_decrypted_notif));
|
||||||
} else {
|
} else {
|
||||||
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), from.getUserName()
|
LinphoneService.instance().displayMessageNotification(to, from.asStringUriOnly(), from.getUserName()
|
||||||
, getString(R.string.message_cant_be_decrypted_notif));
|
, getString(R.string.message_cant_be_decrypted_notif));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,6 +431,7 @@ public final class LinphoneService extends Service {
|
||||||
Log.e(e, "Couldn't find startForeground or stopForeground");
|
Log.e(e, "Couldn't find startForeground or stopForeground");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, ContactsManager.getInstance());
|
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, ContactsManager.getInstance());
|
||||||
|
|
||||||
if (displayServiceNotification()) {
|
if (displayServiceNotification()) {
|
||||||
|
@ -586,7 +587,7 @@ public final class LinphoneService extends Service {
|
||||||
resetIntentLaunchedOnNotificationClick();
|
resetIntentLaunchedOnNotificationClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayMessageNotification(String fromSipUri, String fromName, String message) {
|
public void displayMessageNotification(String to, String fromSipUri, String fromName, String message) {
|
||||||
Intent notifIntent = new Intent(this, LinphoneActivity.class);
|
Intent notifIntent = new Intent(this, LinphoneActivity.class);
|
||||||
notifIntent.putExtra("GoToChat", true);
|
notifIntent.putExtra("GoToChat", true);
|
||||||
notifIntent.putExtra("ChatContactSipUri", fromSipUri);
|
notifIntent.putExtra("ChatContactSipUri", fromSipUri);
|
||||||
|
@ -622,7 +623,7 @@ public final class LinphoneService extends Service {
|
||||||
} else {
|
} else {
|
||||||
bm = BitmapFactory.decodeResource(getResources(), R.drawable.topbar_avatar);
|
bm = BitmapFactory.decodeResource(getResources(), R.drawable.topbar_avatar);
|
||||||
}
|
}
|
||||||
mMsgNotif = Compatibility.createMessageNotification(getApplicationContext(), mMsgNotifCount, fromName, message, bm, notifContentIntent);
|
mMsgNotif = Compatibility.createMessageNotification(getApplicationContext(), mMsgNotifCount, to, fromName, message, bm, notifContentIntent);
|
||||||
|
|
||||||
notifyWrapper(MESSAGE_NOTIF_ID, mMsgNotif);
|
notifyWrapper(MESSAGE_NOTIF_ID, mMsgNotif);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import android.widget.TextView;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ApiElevenPlus.java
|
ApiElevenPlus.java
|
||||||
Copyright (C) 2012 Belledonne Communications, Grenoble, France
|
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
|
@ -85,14 +85,14 @@ public class ApiElevenPlus {
|
||||||
.setWhen(System.currentTimeMillis())
|
.setWhen(System.currentTimeMillis())
|
||||||
.setLargeIcon(contactIcon).getNotification();
|
.setLargeIcon(contactIcon).getNotification();
|
||||||
notif.flags |= Notification.FLAG_ONGOING_EVENT;
|
notif.flags |= Notification.FLAG_ONGOING_EVENT;
|
||||||
|
|
||||||
return notif;
|
return notif;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static Notification createNotification(Context context, String title, String message, int icon, int level, Bitmap largeIcon, PendingIntent intent, boolean isOngoingEvent) {
|
public static Notification createNotification(Context context, String title, String message, int icon, int level, Bitmap largeIcon, PendingIntent intent, boolean isOngoingEvent) {
|
||||||
Notification notif;
|
Notification notif;
|
||||||
|
|
||||||
if (largeIcon != null) {
|
if (largeIcon != null) {
|
||||||
notif = new Notification.Builder(context)
|
notif = new Notification.Builder(context)
|
||||||
.setContentTitle(title)
|
.setContentTitle(title)
|
||||||
|
@ -114,40 +114,40 @@ public class ApiElevenPlus {
|
||||||
if (isOngoingEvent) {
|
if (isOngoingEvent) {
|
||||||
notif.flags |= Notification.FLAG_ONGOING_EVENT;
|
notif.flags |= Notification.FLAG_ONGOING_EVENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return notif;
|
return notif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Intent prepareAddContactIntent(String displayName, String sipUri) {
|
public static Intent prepareAddContactIntent(String displayName, String sipUri) {
|
||||||
Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
|
Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
|
||||||
intent.putExtra(ContactsContract.Intents.Insert.NAME, displayName);
|
intent.putExtra(ContactsContract.Intents.Insert.NAME, displayName);
|
||||||
|
|
||||||
if (sipUri != null && sipUri.startsWith("sip:")) {
|
if (sipUri != null && sipUri.startsWith("sip:")) {
|
||||||
sipUri = sipUri.substring(4);
|
sipUri = sipUri.substring(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<ContentValues> data = new ArrayList<ContentValues>();
|
ArrayList<ContentValues> data = new ArrayList<ContentValues>();
|
||||||
ContentValues sipAddressRow = new ContentValues();
|
ContentValues sipAddressRow = new ContentValues();
|
||||||
sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE);
|
sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE);
|
||||||
sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri);
|
sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri);
|
||||||
data.add(sipAddressRow);
|
data.add(sipAddressRow);
|
||||||
intent.putParcelableArrayListExtra(Insert.DATA, data);
|
intent.putParcelableArrayListExtra(Insert.DATA, data);
|
||||||
|
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Intent prepareEditContactIntentWithSipAddress(int id, String sipUri) {
|
public static Intent prepareEditContactIntentWithSipAddress(int id, String sipUri) {
|
||||||
Intent intent = new Intent(Intent.ACTION_EDIT, Contacts.CONTENT_URI);
|
Intent intent = new Intent(Intent.ACTION_EDIT, Contacts.CONTENT_URI);
|
||||||
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id);
|
Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id);
|
||||||
intent.setData(contactUri);
|
intent.setData(contactUri);
|
||||||
|
|
||||||
ArrayList<ContentValues> data = new ArrayList<ContentValues>();
|
ArrayList<ContentValues> data = new ArrayList<ContentValues>();
|
||||||
ContentValues sipAddressRow = new ContentValues();
|
ContentValues sipAddressRow = new ContentValues();
|
||||||
sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE);
|
sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE);
|
||||||
sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri);
|
sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri);
|
||||||
data.add(sipAddressRow);
|
data.add(sipAddressRow);
|
||||||
intent.putParcelableArrayListExtra(Insert.DATA, data);
|
intent.putParcelableArrayListExtra(Insert.DATA, data);
|
||||||
|
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import android.app.AlarmManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
|
||||||
/*ApiNineteenPlus.java
|
/*ApiNineteenPlus.java
|
||||||
Copyright (C) 2012 Belledonne Communications, Grenoble, France
|
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -11,7 +11,7 @@ import android.view.ViewTreeObserver;
|
||||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
/*
|
/*
|
||||||
ApiSixteenPlus.java
|
ApiSixteenPlus.java
|
||||||
Copyright (C) 2012 Belledonne Communications, Grenoble, France
|
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
|
@ -74,13 +74,13 @@ public class ApiSixteenPlus {
|
||||||
.setWhen(System.currentTimeMillis())
|
.setWhen(System.currentTimeMillis())
|
||||||
.setLargeIcon(contactIcon).build();
|
.setLargeIcon(contactIcon).build();
|
||||||
notif.flags |= Notification.FLAG_ONGOING_EVENT;
|
notif.flags |= Notification.FLAG_ONGOING_EVENT;
|
||||||
|
|
||||||
return notif;
|
return notif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Notification createNotification(Context context, String title, String message, int icon, int level, Bitmap largeIcon, PendingIntent intent, boolean isOngoingEvent,int priority) {
|
public static Notification createNotification(Context context, String title, String message, int icon, int level, Bitmap largeIcon, PendingIntent intent, boolean isOngoingEvent,int priority) {
|
||||||
Notification notif;
|
Notification notif;
|
||||||
|
|
||||||
if (largeIcon != null) {
|
if (largeIcon != null) {
|
||||||
notif = new Notification.Builder(context)
|
notif = new Notification.Builder(context)
|
||||||
.setContentTitle(title)
|
.setContentTitle(title)
|
||||||
|
@ -104,12 +104,12 @@ public class ApiSixteenPlus {
|
||||||
if (isOngoingEvent) {
|
if (isOngoingEvent) {
|
||||||
notif.flags |= Notification.FLAG_ONGOING_EVENT;
|
notif.flags |= Notification.FLAG_ONGOING_EVENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return notif;
|
return notif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
|
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
|
||||||
viewTreeObserver.removeOnGlobalLayoutListener(keyboardListener);
|
viewTreeObserver.removeOnGlobalLayoutListener(keyboardListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Notification createMissedCallNotification(Context context, String title, String text, PendingIntent intent) {
|
public static Notification createMissedCallNotification(Context context, String title, String text, PendingIntent intent) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import android.view.ViewTreeObserver;
|
||||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
/*
|
/*
|
||||||
ApiTwentyOnePlus.java
|
ApiTwentyOnePlus.java
|
||||||
Copyright (C) 2012 Belledonne Communications, Grenoble, France
|
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
|
@ -43,7 +43,7 @@ public class ApiTwentyOnePlus {
|
||||||
} else {
|
} else {
|
||||||
title = context.getString(R.string.unread_messages).replace("%i", String.valueOf(msgCount));
|
title = context.getString(R.string.unread_messages).replace("%i", String.valueOf(msgCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification notif = new Notification.Builder(context)
|
Notification notif = new Notification.Builder(context)
|
||||||
.setContentTitle(title)
|
.setContentTitle(title)
|
||||||
.setContentText(msg)
|
.setContentText(msg)
|
||||||
|
@ -75,13 +75,13 @@ public class ApiTwentyOnePlus {
|
||||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||||
.setPriority(Notification.PRIORITY_HIGH)
|
.setPriority(Notification.PRIORITY_HIGH)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return notif;
|
return notif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Notification createNotification(Context context, String title, String message, int icon, int level, Bitmap largeIcon, PendingIntent intent, boolean isOngoingEvent,int priority) {
|
public static Notification createNotification(Context context, String title, String message, int icon, int level, Bitmap largeIcon, PendingIntent intent, boolean isOngoingEvent,int priority) {
|
||||||
Notification notif;
|
Notification notif;
|
||||||
|
|
||||||
if (largeIcon != null) {
|
if (largeIcon != null) {
|
||||||
notif = new Notification.Builder(context)
|
notif = new Notification.Builder(context)
|
||||||
.setContentTitle(title)
|
.setContentTitle(title)
|
||||||
|
@ -104,12 +104,12 @@ public class ApiTwentyOnePlus {
|
||||||
.setPriority(priority)
|
.setPriority(priority)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
return notif;
|
return notif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
|
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
|
||||||
viewTreeObserver.removeOnGlobalLayoutListener(keyboardListener);
|
viewTreeObserver.removeOnGlobalLayoutListener(keyboardListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Notification createMissedCallNotification(Context context, String title, String text, PendingIntent intent) {
|
public static Notification createMissedCallNotification(Context context, String title, String text, PendingIntent intent) {
|
||||||
|
|
63
src/android/org/linphone/compatibility/ApiTwentySixPlus.java
Normal file
63
src/android/org/linphone/compatibility/ApiTwentySixPlus.java
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
package org.linphone.compatibility;
|
||||||
|
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
|
||||||
|
import org.linphone.R;
|
||||||
|
|
||||||
|
/*
|
||||||
|
ApiTwentyThreePlus.java
|
||||||
|
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
|
This program 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 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @author Erwan Croze
|
||||||
|
*/
|
||||||
|
@TargetApi(26)
|
||||||
|
public class ApiTwentySixPlus {
|
||||||
|
public static Notification createMessageNotification(Context context,
|
||||||
|
int msgCount, String msgSender, String msg, Bitmap contactIcon,
|
||||||
|
PendingIntent intent) {
|
||||||
|
String title;
|
||||||
|
if (msgCount == 1) {
|
||||||
|
title = msgSender;
|
||||||
|
} else {
|
||||||
|
title = context.getString(R.string.unread_messages)
|
||||||
|
.replace("%i", String.valueOf(msgCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
Notification notif = new Notification.Builder(context)
|
||||||
|
.setContentTitle(title)
|
||||||
|
.setContentText(msg)
|
||||||
|
.setSmallIcon(R.drawable.topbar_chat_notification)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.setContentIntent(intent)
|
||||||
|
.setDefaults(
|
||||||
|
Notification.DEFAULT_LIGHTS
|
||||||
|
| Notification.DEFAULT_SOUND
|
||||||
|
| Notification.DEFAULT_VIBRATE)
|
||||||
|
.setWhen(System.currentTimeMillis())
|
||||||
|
.setLargeIcon(contactIcon)
|
||||||
|
.setNumber(msgCount)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return notif;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import android.annotation.TargetApi;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ApiTwentyThreePlus.java
|
ApiTwentyThreePlus.java
|
||||||
Copyright (C) 2012 Belledonne Communications, Grenoble, France
|
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.linphone.compatibility;
|
package org.linphone.compatibility;
|
||||||
/*
|
/*
|
||||||
Compatibility.java
|
Compatibility.java
|
||||||
Copyright (C) 2012 Belledonne Communications, Grenoble, France
|
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
|
@ -59,9 +59,11 @@ public class Compatibility {
|
||||||
return notif;
|
return notif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Notification createMessageNotification(Context context, int msgCount, String msgSender, String msg, Bitmap contactIcon, PendingIntent intent) {
|
public static Notification createMessageNotification(Context context, int msgCount,String to, String msgSender, String msg, Bitmap contactIcon, PendingIntent intent) {
|
||||||
Notification notif = null;
|
Notification notif = null;
|
||||||
if (Version.sdkAboveOrEqual(Version.API21_LOLLIPOP_50)) {
|
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
|
||||||
|
|
||||||
|
} else if (Version.sdkAboveOrEqual(Version.API21_LOLLIPOP_50)) {
|
||||||
return ApiTwentyOnePlus.createMessageNotification(context, msgCount, msgSender, msg, contactIcon, intent);
|
return ApiTwentyOnePlus.createMessageNotification(context, msgCount, msgSender, msg, contactIcon, intent);
|
||||||
} else if (Version.sdkAboveOrEqual(Version.API16_JELLY_BEAN_41)) {
|
} else if (Version.sdkAboveOrEqual(Version.API16_JELLY_BEAN_41)) {
|
||||||
notif = ApiSixteenPlus.createMessageNotification(context, msgCount, msgSender, msg, contactIcon, intent);
|
notif = ApiSixteenPlus.createMessageNotification(context, msgCount, msgSender, msg, contactIcon, intent);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1256246ac90a750e8911e273ba14cf4a6517ee29
|
Subproject commit a37f4186b528d4e9b40e61b933dcf8df15735f64
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7524da1a0548af6ee11ea910858af322161207c4
|
Subproject commit a9d91af675923cdc1bce3091e6ba828d9297de32
|
|
@ -1 +1 @@
|
||||||
Subproject commit f7dbb868d48b4ff7d0891618c60842dba73d2f14
|
Subproject commit bac70d8b6c787bc204ea9bd60f8b1d0263b36447
|
|
@ -1 +1 @@
|
||||||
Subproject commit c06b7e9eb1c46aa3ab2981a334e6961e5ed744db
|
Subproject commit 0773a40cfd475fa357fd1ffcf825e5e5b6e0b9d5
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0399162c4c6e778c73e549e49aba7e364234d148
|
Subproject commit a96d04c7b4c112e3084a0ad1bd3bda7a11ff4ca4
|
|
@ -1 +1 @@
|
||||||
Subproject commit 98fa0c6c0da29b715b0db5e2e37a7c16567dec7b
|
Subproject commit 9cb2c3eaf0dd65d64c414090ffdbc2c913a16113
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6e05a7f50f9f3acfbf634cddf8a0a1b4e95c378c
|
Subproject commit 8c8a83bc74c3547138eb48c27877ac90ab4a360b
|
Loading…
Reference in a new issue