Fixed some deprecated symbols with API 24 + a bit of cleanup in Compatibility.java + removed deprecated Contact and ChatMessage classes

This commit is contained in:
Sylvain Berfini 2016-08-02 16:47:58 +02:00
parent f61efe5685
commit 970505e64e
11 changed files with 58 additions and 492 deletions

View file

@ -387,7 +387,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
if(isEditMode) {
deleteChatBubble.setVisibility(View.VISIBLE);
if(message.isOutgoing()){
if (message.isOutgoing()) {
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
layoutParams.setMargins(100, 10, 10, 10);
@ -419,7 +419,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
}
});
if(messagesList.isItemChecked(position)) {
if (messagesList.isItemChecked(position)) {
deleteChatBubble.setChecked(true);
} else {
deleteChatBubble.setChecked(false);
@ -427,7 +427,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
rlayout.addView(v);
} else {
if(message.isOutgoing()){
if (message.isOutgoing()) {
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
layoutParams.setMargins(100, 10, 10, 10);
@ -448,7 +448,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
LinphoneAddress lAddress = null;
if(sipUri == null){
if (sipUri == null) {
initNewChatConversation();
} else {
try {
@ -477,7 +477,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
}
private void displayMessageList() {
if(chatRoom != null) {
if (chatRoom != null) {
if (adapter != null) {
adapter.refreshHistory();
} else {
@ -488,7 +488,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
}
private void displayChatHeader(LinphoneAddress address) {
if(contact != null) {
if (contact != null) {
contactName.setText(contact.getFullName());
} else if(address != null){
contactName.setText(LinphoneUtils.getAddressDisplayName(address));
@ -618,7 +618,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
String draft = getArguments().getString("messageDraft");
message.setText(draft);
if(!newChatConversation) {
if (!newChatConversation) {
initChatRoom(sipUri);
searchContactField.setVisibility(View.GONE);
resultContactsSearch.setVisibility(View.GONE);
@ -626,10 +626,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
}
}
private void selectAllList(boolean isSelectAll){
private void selectAllList(boolean isSelectAll) {
int size = messagesList.getAdapter().getCount();
for(int i=0; i<size; i++) {
messagesList.setItemChecked(i,isSelectAll);
for (int i = 0; i < size; i++) {
messagesList.setItemChecked(i, isSelectAll);
}
}
@ -642,8 +642,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
private void removeChats(){
int size = messagesList.getAdapter().getCount();
for(int i=0; i<size; i++) {
if(messagesList.isItemChecked(i)){
for (int i = 0; i < size; i++) {
if (messagesList.isItemChecked(i)) {
LinphoneChatMessage message = (LinphoneChatMessage) messagesList.getAdapter().getItem(i);
chatRoom.deleteMessage(message);
}

View file

@ -1,117 +0,0 @@
package org.linphone;
import org.linphone.core.LinphoneChatMessage;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
/*
ChatMessage.java
Copyright (C) 2012 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 Sylvain Berfini
* @deprecated
*/
public class ChatMessage {
private String message;
private String timestamp;
private String url;
private boolean incoming;
private int status;
private int id;
private Bitmap image;
private boolean isRead;
public ChatMessage(int id, String message, byte[] rawImage, String timestamp, boolean incoming, int status, boolean read) {
super();
this.id = id;
this.message = message;
this.timestamp = timestamp;
this.incoming = incoming;
this.status = status;
this.image = rawImage != null ? BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length) : null;
this.isRead = read;
}
public ChatMessage(int id, String message, Bitmap image, String timestamp, boolean incoming, int status, boolean read) {
super();
this.id = id;
this.message = message;
this.timestamp = timestamp;
this.incoming = incoming;
this.status = status;
this.image = image;
this.isRead = read;
}
public int getId() {
return id;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public boolean isIncoming() {
return incoming;
}
public void setIncoming(boolean incoming) {
this.incoming = incoming;
}
public void setStatus(int status) {
this.status = status;
}
public LinphoneChatMessage.State getStatus() {
return LinphoneChatMessage.State.fromInt(status);
}
public Bitmap getImage() {
return image;
}
public boolean isRead() {
return isRead;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String toString() {
return this.id + " : " + this.message + " (" + this.url + ") @ " + this.timestamp + ", read= " + this.isRead + ", incoming= " + this.incoming + ", status = " + this.status;
}
}

View file

@ -1,139 +0,0 @@
package org.linphone;
/*
Contact.java
Copyright (C) 2012 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.
*/
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneFriend;
import android.content.ContentResolver;
import android.graphics.Bitmap;
import android.net.Uri;
/**
* @author Sylvain Berfini
* @deprecated
*/
public class Contact implements Serializable {
private static final long serialVersionUID = 3790717505065723499L;
private String id;
private String name;
private transient Uri photoUri;
private transient Uri thumbnailUri;
private transient Bitmap photo;
private List<String> numbersOrAddresses;
private boolean hasFriends;
private LinphoneAddress address;
public Contact(String id, String name) {
super();
this.id = id;
this.name = name;
this.photoUri = null;
this.thumbnailUri = null;
this.hasFriends = false;
this.address = null;
}
public Contact(String id, LinphoneAddress address) {
super();
this.id = id;
this.name = LinphoneUtils.getAddressDisplayName(address);
this.photoUri = null;
this.thumbnailUri = null;
this.address = address;
}
public Contact(String id, String name, Uri photo, Uri thumbnail) {
super();
this.id = id;
this.name = name;
this.photoUri = photo;
this.thumbnailUri = thumbnail;
this.photo = null;
this.hasFriends = false;
this.address = null;
}
public Contact(String id, String name, Uri photo, Uri thumbnail, Bitmap picture) {
super();
this.id = id;
this.name = name;
this.photoUri = photo;
this.thumbnailUri = thumbnail;
this.photo = picture;
this.hasFriends = false;
this.address = null;
}
public boolean hasFriends() {
return hasFriends;
}
public String getID() {
return id;
}
public String getName() {
return name;
}
public LinphoneAddress getLinphoneAddress() {
return address;
}
public Uri getPhotoUri() {
return photoUri;
}
public Uri getThumbnailUri() {
return thumbnailUri;
}
public Bitmap getPhoto() {
return photo;
}
public List<String> getNumbersOrAddresses() {
if (numbersOrAddresses == null)
numbersOrAddresses = new ArrayList<String>();
return numbersOrAddresses;
}
public void refresh(ContentResolver cr) {
this.numbersOrAddresses = Compatibility.extractContactNumbersAndAddresses(id, cr);
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if(lc != null && lc.getFriendList() != null) {
for (LinphoneFriend friend :lc.getFriendList()){
if (id.equals(friend.getRefKey())) {
hasFriends = true;
this.numbersOrAddresses.add(friend.getAddress().asStringUriOnly());
}
}
}
this.name = Compatibility.refreshContactName(cr, id);
}
}

View file

@ -689,6 +689,32 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
}
}
private void initPushNotificationsService() {
try {
Class<?> GCMRegistrar = Class.forName("com.google.android.gcm.GCMRegistrar");
GCMRegistrar.getMethod("checkDevice", Context.class).invoke(null, mServiceContext);
try {
GCMRegistrar.getMethod("checkManifest", Context.class).invoke(null, mServiceContext);
} catch (IllegalStateException e) {
Log.e("[Push Notification] No receiver found", e);
}
final String regId = (String)GCMRegistrar.getMethod("getRegistrationId", Context.class).invoke(null, mServiceContext);
String newPushSenderID = mServiceContext.getString(R.string.push_sender_id);
String currentPushSenderID = LinphonePreferences.instance().getPushNotificationRegistrationID();
if (regId.equals("") || currentPushSenderID == null || !currentPushSenderID.equals(newPushSenderID)) {
GCMRegistrar.getMethod("register", Context.class, String[].class).invoke(null, mServiceContext, new String[]{newPushSenderID});
Log.i("[Push Notification] Storing current sender id = " + newPushSenderID);
} else {
Log.i("[Push Notification] Already registered with id = " + regId);
LinphonePreferences.instance().setPushNotificationRegistrationID(regId);
}
} catch (java.lang.UnsupportedOperationException e) {
Log.i("[Push Notification] Not activated");
} catch (Exception e1) {
Log.i("[Push Notification] Assuming GCM jar is not provided.");
}
}
private synchronized void initLiblinphone(LinphoneCore lc) throws LinphoneCoreException {
mLc = lc;
@ -742,7 +768,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
mLc.migrateCallLogs();
if (mServiceContext.getResources().getBoolean(R.bool.enable_push_id)) {
Compatibility.initPushNotificationService(mServiceContext);
initPushNotificationsService();
}
/*

View file

@ -1,6 +0,0 @@
package org.linphone;
public class OpenGLESDisplay {
public static native void init(int ptr, int width, int height);
public static native void render(int ptr);
}

View file

@ -18,11 +18,11 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import org.linphone.R;
import org.linphone.compatibility.Compatibility;
import android.app.Fragment;
import android.os.Bundle;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
@ -53,7 +53,7 @@ public class LinphoneLoginFragment extends Fragment implements OnClickListener,
password = (EditText) view.findViewById(R.id.assistant_password);
password.addTextChangedListener(this);
forgotPassword = (TextView) view.findViewById(R.id.forgot_password);
forgotPassword.setText(Html.fromHtml("<a href=\"" + url + "\"'>"+ getString(R.string.forgot_password) + "</a>"));
forgotPassword.setText(Compatibility.fromHtml("<a href=\"" + url + "\"'>"+ getString(R.string.forgot_password) + "</a>"));
forgotPassword.setMovementMethod(LinkMovementMethod.getInstance());
displayName = (EditText) view.findViewById(R.id.assistant_display_name);
apply = (Button) view.findViewById(R.id.assistant_apply);

View file

@ -1,11 +1,6 @@
package org.linphone.compatibility;
import org.linphone.LinphonePreferences;
import org.linphone.R;
import org.linphone.mediastream.Log;
import android.annotation.TargetApi;
import android.content.Context;
import android.media.AudioManager;
/*
@ -33,34 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@TargetApi(8)
public class ApiEightPlus {
public static void initPushNotificationService(Context context) {
try {
Class<?> GCMRegistrar = Class.forName("com.google.android.gcm.GCMRegistrar");
// Starting the push notification service
GCMRegistrar.getMethod("checkDevice", Context.class).invoke(null, context);
try {
GCMRegistrar.getMethod("checkManifest", Context.class).invoke(null, context);
} catch (IllegalStateException e){
Log.e("Push notification: No receiver found",e);
}
final String regId = (String)GCMRegistrar.getMethod("getRegistrationId", Context.class).invoke(null, context);
String newPushSenderID = context.getString(R.string.push_sender_id);
String currentPushSenderID = LinphonePreferences.instance().getPushNotificationRegistrationID();
if (regId.equals("") || currentPushSenderID == null || !currentPushSenderID.equals(newPushSenderID)) {
GCMRegistrar.getMethod("register", Context.class, String[].class).invoke(null, context, new String[]{newPushSenderID});
Log.d("Push Notification: storing current sender id = " + newPushSenderID);
} else {
Log.d("Push Notification: already registered with id = " + regId);
LinphonePreferences.instance().setPushNotificationRegistrationID(regId);
}
} catch (java.lang.UnsupportedOperationException e) {
Log.i("Push Notification: not activated");
} catch (Exception e1) {
//assume the jar is not provided
Log.i("Push Notification: assuming GCM jar is not provided.");
}
}
@SuppressWarnings("deprecation")
public static String getAudioManagerEventForBluetoothConnectionStateChangedEvent() {
return AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED;

View file

@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@TargetApi(16)
public class ApiSixteenPlus {
@SuppressWarnings("deprecation")
public static Notification createMessageNotification(Context context,
int msgCount, String msgSender, String msg, Bitmap contactIcon,
PendingIntent intent) {

View file

@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@TargetApi(21)
public class ApiTwentyOnePlus {
@SuppressWarnings("deprecation")
public static Notification createMessageNotification(Context context,
int msgCount, String msgSender, String msg, Bitmap contactIcon,
PendingIntent intent) {

View file

@ -17,79 +17,28 @@ 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.
*/
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.linphone.LinphoneContact;
import org.linphone.core.LinphoneAddress;
import org.linphone.mediastream.Version;
import android.app.Activity;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.ContentProviderOperation;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.media.AudioManager;
import android.net.Uri;
import android.os.PowerManager;
import android.preference.Preference;
import android.provider.Settings;
import android.text.Html;
import android.text.Spanned;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
/**
* @author Sylvain Berfini
*/
public class Compatibility {
public static void overridePendingTransition(Activity activity, int idAnimIn, int idAnimOut) {
if (Version.sdkAboveOrEqual(Version.API05_ECLAIR_20)) {
ApiFivePlus.overridePendingTransition(activity, idAnimIn, idAnimOut);
}
}
public static Intent prepareAddContactIntent(String displayName, String sipUri) {
if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
return ApiElevenPlus.prepareAddContactIntent(displayName, sipUri);
} else {
return ApiFivePlus.prepareAddContactIntent(displayName, sipUri);
}
}
public static Intent prepareEditContactIntent(int id) {
if (Version.sdkAboveOrEqual(Version.API05_ECLAIR_20)) {
return ApiFivePlus.prepareEditContactIntent(id);
}
return null;
}
public static Intent prepareEditContactIntentWithSipAddress(int id, String sipAddress) {
if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
return ApiElevenPlus.prepareEditContactIntentWithSipAddress(id, sipAddress);
} else {
return ApiFivePlus.prepareEditContactIntent(id);
}
}
public static List<String> extractContactNumbersAndAddresses(String id, ContentResolver cr) {
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
return ApiNinePlus.extractContactNumbersAndAddresses(id, cr);
} else {
return ApiFivePlus.extractContactNumbersAndAddresses(id, cr);
}
}
public static List<String> extractContactImAddresses(String id, ContentResolver cr) {
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
return ApiFivePlus.extractContactNumbersAndAddresses(id, cr);
} else {
return null;
}
}
public static Cursor getContactsCursor(ContentResolver cr, List<String> contactsId) {
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
return ApiNinePlus.getContactsCursor(cr, null, contactsId);
@ -98,63 +47,6 @@ public class Compatibility {
}
}
public static Cursor getContactsCursor(ContentResolver cr, String search, List<String> contactsId) {
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
return ApiNinePlus.getContactsCursor(cr, search, contactsId);
} else {
return ApiFivePlus.getContactsCursor(cr, contactsId);
}
}
public static Cursor getSIPContactsCursor(ContentResolver cr, List<String> contactsId) {
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
return ApiNinePlus.getSIPContactsCursor(cr, null, contactsId);
} else {
return ApiFivePlus.getSIPContactsCursor(cr, contactsId);
}
}
public static Cursor getSIPContactsCursor(ContentResolver cr, String search, List<String> contactsId) {
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
return ApiNinePlus.getSIPContactsCursor(cr, search, contactsId);
} else {
return ApiFivePlus.getSIPContactsCursor(cr, contactsId);
}
}
public static Cursor getImContactsCursor(ContentResolver cr) {
return ApiFivePlus.getSIPContactsCursor(cr,null);
}
public static int getCursorDisplayNameColumnIndex(Cursor cursor) {
if (Version.sdkAboveOrEqual(Version.API05_ECLAIR_20)) {
return ApiFivePlus.getCursorDisplayNameColumnIndex(cursor);
}
return -1;
}
public static LinphoneContact getContact(ContentResolver cr, Cursor cursor, int position) {
if (Version.sdkAboveOrEqual(Version.API05_ECLAIR_20)) {
return ApiFivePlus.getContact(cr, cursor, position);
}
return null;
}
public static InputStream getContactPictureInputStream(ContentResolver cr, String id) {
if (Version.sdkAboveOrEqual(Version.API05_ECLAIR_20)) {
return ApiFivePlus.getContactPictureInputStream(cr, id);
}
return null;
}
public static Uri findUriPictureOfContactAndSetDisplayName(LinphoneAddress address, ContentResolver cr) {
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
return ApiNinePlus.findUriPictureOfContactAndSetDisplayName(address, cr);
} else {
return ApiFivePlus.findUriPictureOfContactAndSetDisplayName(address, cr);
}
}
public static Notification createSimpleNotification(Context context, String title, String text, PendingIntent intent) {
Notification notif = null;
@ -218,13 +110,6 @@ public class Compatibility {
}
}
public static String refreshContactName(ContentResolver cr, String id) {
if (Version.sdkAboveOrEqual(Version.API05_ECLAIR_20)) {
return ApiFivePlus.refreshContactName(cr, id);
}
return null;
}
public static CompatibilityScaleGestureDetector getScaleGestureDetector(Context context, CompatibilityScaleGestureListener listener) {
if (Version.sdkAboveOrEqual(Version.API08_FROYO_22)) {
CompatibilityScaleGestureDetector csgd = new CompatibilityScaleGestureDetector(context);
@ -234,29 +119,6 @@ public class Compatibility {
return null;
}
public static void setPreferenceChecked(Preference preference, boolean checked) {
if (Version.sdkAboveOrEqual(Version.API14_ICE_CREAM_SANDWICH_40)) {
ApiFourteenPlus.setPreferenceChecked(preference, checked);
} else {
ApiFivePlus.setPreferenceChecked(preference, checked);
}
}
public static boolean isPreferenceChecked(Preference preference) {
if (Version.sdkAboveOrEqual(Version.API14_ICE_CREAM_SANDWICH_40)) {
return ApiFourteenPlus.isPreferenceChecked(preference);
} else {
return ApiFivePlus.isPreferenceChecked(preference);
}
}
public static void initPushNotificationService(Context context) {
if (Version.sdkAboveOrEqual(Version.API08_FROYO_22)) {
ApiEightPlus.initPushNotificationService(context);
}
}
public static void copyTextToClipboard(Context context, String msg) {
if(Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
ApiElevenPlus.copyTextToClipboard(context, msg);
@ -265,42 +127,6 @@ public class Compatibility {
}
}
public static void addSipAddressToContact(Context context, ArrayList<ContentProviderOperation> ops, String sipAddress) {
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
ApiNinePlus.addSipAddressToContact(context, ops, sipAddress);
} else {
ApiFivePlus.addSipAddressToContact(context, ops, sipAddress);
}
}
public static void addSipAddressToContact(Context context, ArrayList<ContentProviderOperation> ops, String sipAddress, String rawContactID) {
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
ApiNinePlus.addSipAddressToContact(context, ops, sipAddress, rawContactID);
} else {
ApiFivePlus.addSipAddressToContact(context, ops, sipAddress, rawContactID);
}
}
public static void updateSipAddressForContact(ArrayList<ContentProviderOperation> ops, String oldSipAddress, String newSipAddress, String contactID) {
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
ApiNinePlus.updateSipAddressForContact(ops, oldSipAddress, newSipAddress, contactID);
} else {
ApiFivePlus.updateSipAddressForContact(ops, oldSipAddress, newSipAddress, contactID);
}
}
public static void deleteSipAddressFromContact(ArrayList<ContentProviderOperation> ops, String oldSipAddress, String contactID) {
if (Version.sdkAboveOrEqual(Version.API09_GINGERBREAD_23)) {
ApiNinePlus.deleteSipAddressFromContact(ops, oldSipAddress, contactID);
} else {
ApiFivePlus.deleteSipAddressFromContact(ops, oldSipAddress, contactID);
}
}
public static void deleteImAddressFromContact(ArrayList<ContentProviderOperation> ops, String oldSipAddress, String contactID) {
ApiFivePlus.deleteSipAddressFromContact(ops, oldSipAddress, contactID);
}
public static void removeGlobalLayoutListener(ViewTreeObserver viewTreeObserver, OnGlobalLayoutListener keyboardListener) {
if (Version.sdkAboveOrEqual(Version.API16_JELLY_BEAN_41)) {
ApiSixteenPlus.removeGlobalLayoutListener(viewTreeObserver, keyboardListener);
@ -309,15 +135,13 @@ public class Compatibility {
}
}
public static void hideNavigationBar(Activity activity)
{
public static void hideNavigationBar(Activity activity) {
if (Version.sdkAboveOrEqual(Version.API14_ICE_CREAM_SANDWICH_40)) {
ApiFourteenPlus.hideNavigationBar(activity);
}
}
public static void showNavigationBar(Activity activity)
{
public static void showNavigationBar(Activity activity) {
if (Version.sdkAboveOrEqual(Version.API14_ICE_CREAM_SANDWICH_40)) {
ApiFourteenPlus.showNavigationBar(activity);
}
@ -354,4 +178,13 @@ public class Compatibility {
return pm.isScreenOn();
}
}
@SuppressWarnings("deprecation")
public static Spanned fromHtml(String text) {
if (Version.sdkAboveOrEqual(Version.API24_NOUGAT_70)) {
return Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY);
} else {
return Html.fromHtml(text);
}
}
}

View file

@ -31,6 +31,7 @@ import org.linphone.LinphoneContact;
import org.linphone.LinphoneManager;
import org.linphone.LinphoneUtils;
import org.linphone.R;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.LinphoneBuffer;
import org.linphone.core.LinphoneChatMessage;
import org.linphone.core.LinphoneChatMessage.State;
@ -52,7 +53,6 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
@ -312,7 +312,7 @@ public class BubbleChat implements LinphoneChatMessage.LinphoneChatMessageListen
text = text.replaceFirst(link, "<a href=\"" + link + "\">" + linkWithoutScheme + "</a>");
}
return Html.fromHtml(text);
return Compatibility.fromHtml(text);
}
public String getTextMessage() {