Bigger contacts in contacts list + friend presence started
This commit is contained in:
parent
fbc88fba33
commit
38b6acb880
23 changed files with 395 additions and 42 deletions
|
@ -4,7 +4,6 @@
|
|||
<classpathentry excluding="org/linphone/mediastream/MediastreamerActivity.java" kind="src" path="submodules/linphone/mediastreamer2/java/src"/>
|
||||
<classpathentry kind="src" path="submodules/linphone/java/j2se"/>
|
||||
<classpathentry kind="src" path="submodules/linphone/java/common"/>
|
||||
<classpathentry kind="src" path="submodules/linphone/coreapi/help/java"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry exported="true" kind="lib" path="libs/aXMLRPC.jar"/>
|
||||
|
|
BIN
res/drawable-xhdpi/friend_add.png
Normal file
BIN
res/drawable-xhdpi/friend_add.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 531 B |
BIN
res/drawable-xhdpi/friend_remove.png
Normal file
BIN
res/drawable-xhdpi/friend_remove.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 541 B |
|
@ -18,18 +18,20 @@
|
|||
android:layout_marginBottom="10dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_contact_picture"
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_weight="2.3"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/unknown_small" />
|
||||
|
||||
|
@ -38,11 +40,24 @@
|
|||
android:lines="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3"
|
||||
android:layout_toRightOf="@id/icon"
|
||||
android:layout_centerVertical="true"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="@android:color/black"
|
||||
android:layout_marginLeft="10dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/friendStatus"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_marginRight="20dp"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/led_connected" />
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -39,5 +39,18 @@
|
|||
android:paddingRight="5dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/chat_icon_over" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/addFriend"
|
||||
android:visibility="gone"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:contentDescription="@string/content_description_dial_back"
|
||||
android:gravity="right"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/friend_add" />
|
||||
|
||||
</TableRow>
|
36
res/layout/new_friend_request_dialog.xml
Normal file
36
res/layout/new_friend_request_dialog.xml
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:text="@string/linphone_friend_new_request_desc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/call_update_yes"
|
||||
android:id="@+id/yes" />
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/call_update_no"
|
||||
android:id="@+id/no" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -323,4 +323,10 @@
|
|||
<string name="image_saved">Image sauvegardée</string>
|
||||
<string name="image_not_saved">Erreur, image non sauvegardée</string>
|
||||
|
||||
<string name="pref_linphone_friend_title">Amis</string>
|
||||
<string name="pref_auto_accept_friends_title">Nouveaux amis</string>
|
||||
<string name="pref_auto_accept_friends_desc">Toujours accepter les nouvelles demandes d\'amis</string>
|
||||
<string name="linphone_friend_new_request_title">Requête d\'ami</string>
|
||||
<string name="linphone_friend_new_request_desc">voudrait être partager son status avec vous et voir le votre.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
<bool name="display_call_stats">true</bool>
|
||||
|
||||
<bool name="enable_linphone_friends">false</bool>
|
||||
|
||||
<!-- Behavior Settings -->
|
||||
<bool name="allow_chat_multiline">false</bool>
|
||||
<bool name="call_last_log_if_adress_is_empty">true</bool>
|
||||
|
|
|
@ -88,4 +88,6 @@
|
|||
<string name="push_reg_id_key">push_reg_id_key</string>
|
||||
<string name="push_sender_id_key">push_sender_id_key</string>
|
||||
<string name="pref_push_notification_key">pref_push_notification_key</string>
|
||||
|
||||
<string name="pref_auto_accept_friends_key">pref_auto_accept_friends_key</string>
|
||||
</resources>
|
||||
|
|
|
@ -374,4 +374,10 @@
|
|||
<string name="image_saved">Image saved</string>
|
||||
<string name="image_not_saved">Error, image not saved</string>
|
||||
|
||||
<string name="pref_linphone_friend_title">Friends</string>
|
||||
<string name="pref_auto_accept_friends_title">New friends</string>
|
||||
<string name="pref_auto_accept_friends_desc">utomatically accept new friend requests</string>
|
||||
<string name="linphone_friend_new_request_title">Friend request</string>
|
||||
<string name="linphone_friend_new_request_desc">wants to share it\'s presence status with you and be aware of yours.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -217,6 +217,17 @@
|
|||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_linphone_friend_title">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/pref_auto_accept_friends_key"
|
||||
android:title="@string/pref_auto_accept_friends_title"
|
||||
android:summary="@string/pref_auto_accept_friends_desc"
|
||||
android:defaultValue="false"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_advanced">
|
||||
|
||||
|
@ -273,7 +284,7 @@
|
|||
android:title="@string/pref_media_encryption"
|
||||
android:key="@string/pref_media_encryption_key"
|
||||
android:defaultValue="@string/pref_media_encryption_key_none" />
|
||||
|
||||
|
||||
<PreferenceScreen
|
||||
android:title="@string/pref_audio_hacks_title"
|
||||
android:layout="@layout/hidden">
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.LinphoneFriend;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -37,6 +38,7 @@ public class Contact implements Serializable {
|
|||
private transient Uri photoUri;
|
||||
private transient Bitmap photo;
|
||||
private List<String> numerosOrAddresses;
|
||||
private LinphoneFriend friend;
|
||||
|
||||
public Contact(String id, String name) {
|
||||
super();
|
||||
|
@ -61,6 +63,14 @@ public class Contact implements Serializable {
|
|||
this.photo = picture;
|
||||
}
|
||||
|
||||
public void setFriend(LinphoneFriend friend) {
|
||||
this.friend = friend;
|
||||
}
|
||||
|
||||
public LinphoneFriend getFriend() {
|
||||
return friend;
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
|
@ -80,10 +90,6 @@ public class Contact implements Serializable {
|
|||
public List<String> getNumerosOrAddresses() {
|
||||
return numerosOrAddresses;
|
||||
}
|
||||
|
||||
public void setNumerosOrAddresses(List<String> numerosOrAddresses) {
|
||||
this.numerosOrAddresses = numerosOrAddresses;
|
||||
}
|
||||
|
||||
public void refresh(ContentResolver cr) {
|
||||
this.numerosOrAddresses = Compatibility.extractContactNumbersAndAddresses(id, cr);
|
||||
|
|
|
@ -31,6 +31,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -126,6 +127,35 @@ public class ContactFragment extends Fragment implements OnClickListener {
|
|||
}
|
||||
}
|
||||
|
||||
final String finalNumberOrAddress = numberOrAddress;
|
||||
ImageView friend = (ImageView) v.findViewById(R.id.addFriend);
|
||||
if (getResources().getBoolean(R.bool.enable_linphone_friends) && !displayChatAddressOnly) {
|
||||
friend.setVisibility(View.VISIBLE);
|
||||
|
||||
boolean isAlreadyAFriend = LinphoneManager.getLc().findFriendByAddress(finalNumberOrAddress) != null;
|
||||
if (!isAlreadyAFriend) {
|
||||
friend.setImageResource(R.drawable.friend_add);
|
||||
friend.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (LinphoneActivity.instance().newFriend(contact, finalNumberOrAddress)) {
|
||||
displayContact(ContactFragment.this.inflater, ContactFragment.this.view);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
friend.setImageResource(R.drawable.friend_remove);
|
||||
friend.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (LinphoneActivity.instance().removeFriend(contact, finalNumberOrAddress)) {
|
||||
displayContact(ContactFragment.this.inflater, ContactFragment.this.view);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
controls.addView(v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
import java.util.List;
|
||||
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.LinphoneFriend;
|
||||
import org.linphone.core.OnlineStatus;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -45,6 +48,8 @@ import android.widget.TextView;
|
|||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class ContactsFragment extends Fragment implements OnClickListener, OnItemClickListener {
|
||||
private Handler mHandler = new Handler();
|
||||
|
||||
private LayoutInflater mInflater;
|
||||
private ListView contactsList;
|
||||
private TextView allContacts, linphoneContacts, newContact, noSipContact, noContact;
|
||||
|
@ -176,8 +181,18 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
|||
onlyDisplayLinphoneContacts = LinphoneActivity.instance().isLinphoneContactsPrefered();
|
||||
}
|
||||
|
||||
changeContactsAdapter();
|
||||
contactsList.setSelectionFromTop(lastKnownPosition, 0);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
lastKnownPosition = contactsList.getFirstVisiblePosition();
|
||||
changeContactsAdapter();
|
||||
contactsList.setSelectionFromTop(lastKnownPosition, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class ContactsListAdapter extends BaseAdapter implements SectionIndexer {
|
||||
|
@ -246,6 +261,23 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
|||
icon.setImageBitmap(bitmapUnknown);
|
||||
}
|
||||
|
||||
ImageView friendStatus = (ImageView) view.findViewById(R.id.friendStatus);
|
||||
LinphoneFriend friend = contact.getFriend();
|
||||
if (friend != null) {
|
||||
friendStatus.setVisibility(View.VISIBLE);
|
||||
if (friend.getStatus() == OnlineStatus.Online) {
|
||||
friendStatus.setImageResource(R.drawable.led_connected);
|
||||
} else if (friend.getStatus() == OnlineStatus.Busy || friend.getStatus() == OnlineStatus.DoNotDisturb) {
|
||||
friendStatus.setImageResource(R.drawable.led_error);
|
||||
} else if (friend.getStatus() == OnlineStatus.Away || friend.getStatus() == OnlineStatus.BeRightBack) {
|
||||
friendStatus.setImageResource(R.drawable.led_inprogress);
|
||||
} else if (friend.getStatus() == OnlineStatus.Offline) {
|
||||
friendStatus.setImageResource(R.drawable.led_disconnected);
|
||||
} else {
|
||||
friendStatus.setImageResource(R.drawable.call_quality_indicator_0);
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,11 @@ import org.linphone.core.LinphoneCallLog.CallStatus;
|
|||
import org.linphone.core.LinphoneChatMessage;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneFriend;
|
||||
import org.linphone.core.Log;
|
||||
import org.linphone.core.OnlineStatus;
|
||||
import org.linphone.mediastream.Version;
|
||||
import org.linphone.setup.SetupActivity;
|
||||
import org.linphone.ui.AddressText;
|
||||
|
@ -55,6 +58,7 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.Fragment.SavedState;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
@ -70,6 +74,7 @@ import android.view.ViewGroup;
|
|||
import android.view.WindowManager;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
@ -96,7 +101,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
private LinearLayout menu, mark;
|
||||
private RelativeLayout contacts, history, settings, chat, aboutChat, aboutSettings;
|
||||
private FragmentsAvailable currentFragment, nextFragment;
|
||||
private Fragment dialerFragment, messageListenerFragment, messageListFragment;
|
||||
private Fragment dialerFragment, messageListenerFragment, messageListFragment, friendStatusListenerFragment;
|
||||
private SavedState dialerSavedState;
|
||||
private ChatStorage chatStorage;
|
||||
private boolean preferLinphoneContacts = false, isAnimationDisabled = false;
|
||||
|
@ -244,6 +249,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
break;
|
||||
case CONTACTS:
|
||||
newFragment = new ContactsFragment();
|
||||
friendStatusListenerFragment = newFragment;
|
||||
break;
|
||||
case CONTACT:
|
||||
newFragment = new ContactFragment();
|
||||
|
@ -863,6 +869,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
}
|
||||
|
||||
private int mAlwaysChangingPhoneAngle = -1;
|
||||
private AcceptNewFriendDialog acceptNewFriendDialog;
|
||||
private class LocalOrientationEventListener extends OrientationEventListener {
|
||||
public LocalOrientationEventListener(Context context) {
|
||||
super(context);
|
||||
|
@ -924,6 +931,111 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
return preferLinphoneContacts;
|
||||
}
|
||||
|
||||
private void refreshStatus(OnlineStatus status) {
|
||||
if (LinphoneManager.isInstanciated()) {
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setPresenceInfo(0, "", status);
|
||||
}
|
||||
}
|
||||
|
||||
public void onNewSubscriptionRequestReceived(LinphoneFriend friend, String sipUri) {
|
||||
sipUri = sipUri.replace("<", "").replace(">", "");
|
||||
Log.d("New friend request from " + sipUri);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if (prefs.getBoolean(getString(R.string.pref_auto_accept_friends_key), false)) {
|
||||
Contact contact = findContactWithSipAddress(sipUri);
|
||||
if (contact != null) {
|
||||
friend.enableSubscribes(true);
|
||||
try {
|
||||
LinphoneManager.getLc().addFriend(friend);
|
||||
contact.setFriend(friend);
|
||||
} catch (LinphoneCoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Contact contact = findContactWithSipAddress(sipUri);
|
||||
if (contact != null) {
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
acceptNewFriendDialog = new AcceptNewFriendDialog(contact, sipUri);
|
||||
acceptNewFriendDialog.show(fm, "New Friend Request Dialog");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Contact findContactWithSipAddress(String sipUri) {
|
||||
if (!sipUri.startsWith("sip:")) {
|
||||
sipUri = "sip:" + sipUri;
|
||||
}
|
||||
|
||||
for (Contact contact : sipContactList) {
|
||||
for (String addr : contact.getNumerosOrAddresses()) {
|
||||
if (addr.equals(sipUri)) {
|
||||
return contact;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onNotifyPresenceReceived(LinphoneFriend friend) {
|
||||
Log.d("friend " + friend.getAddress() + " has a new status: " + friend.getStatus().toString());
|
||||
if (currentFragment == FragmentsAvailable.CONTACTS && friendStatusListenerFragment != null) {
|
||||
((ContactsFragment) friendStatusListenerFragment).invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean newFriend(Contact contact, String sipUri) {
|
||||
Log.d("Adding friend :" + sipUri + " associated with contact " + contact.getName());
|
||||
LinphoneFriend friend = LinphoneCoreFactory.instance().createLinphoneFriend(sipUri);
|
||||
friend.enableSubscribes(true);
|
||||
friend.setIncSubscribePolicy(LinphoneFriend.SubscribePolicy.SPAccept);
|
||||
try {
|
||||
LinphoneManager.getLc().addFriend(friend);
|
||||
contact.setFriend(friend);
|
||||
return true;
|
||||
} catch (LinphoneCoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void acceptNewFriend(Contact contact, String sipUri, boolean accepted) {
|
||||
acceptNewFriendDialog.dismissAllowingStateLoss();
|
||||
if (accepted) {
|
||||
newFriend(contact, sipUri);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean removeFriend(Contact contact, String sipUri) {
|
||||
Log.d("Removing friend :" + sipUri + " associated with contact " + contact.getName());
|
||||
LinphoneFriend friend = LinphoneManager.getLc().findFriendByAddress(sipUri);
|
||||
if (friend != null) {
|
||||
friend.enableSubscribes(false);
|
||||
LinphoneManager.getLc().removeFriend(friend);
|
||||
contact.setFriend(null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void searchFriendAndAddToContact(Contact contact) {
|
||||
if (contact == null || contact.getNumerosOrAddresses() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String sipUri : contact.getNumerosOrAddresses()) {
|
||||
if (LinphoneUtils.isSipAddress(sipUri)) {
|
||||
LinphoneFriend friend = LinphoneManager.getLc().findFriendByAddress(sipUri);
|
||||
if (friend != null) {
|
||||
friend.enableSubscribes(true);
|
||||
friend.setIncSubscribePolicy(LinphoneFriend.SubscribePolicy.SPAccept);
|
||||
contact.setFriend(friend);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareContactsInBackground() {
|
||||
contactCursor = Compatibility.getContactsCursor(getContentResolver());
|
||||
sipContactCursor = Compatibility.getSIPContactsCursor(getContentResolver());
|
||||
|
@ -932,9 +1044,12 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
Thread sipContactsHandler = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
for (int i = 0; i < sipContactCursor.getCount(); i++) {
|
||||
Contact contact = Compatibility.getContact(getContentResolver(), sipContactCursor, i);
|
||||
contact.refresh(getContentResolver());
|
||||
if (getResources().getBoolean(R.bool.enable_linphone_friends)) {
|
||||
searchFriendAndAddToContact(contact);
|
||||
}
|
||||
sipContactList.add(contact);
|
||||
}
|
||||
}
|
||||
|
@ -944,7 +1059,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
Thread contactsHandler = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
for (int i = 0; i < contactCursor.getCount(); i++) {
|
||||
Contact contact = Compatibility.getContact(getContentResolver(), contactCursor, i);
|
||||
contactList.add(contact);
|
||||
|
@ -993,6 +1107,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
}
|
||||
|
||||
public void exit() {
|
||||
refreshStatus(OnlineStatus.Offline);
|
||||
finish();
|
||||
stopService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||
}
|
||||
|
@ -1044,6 +1159,14 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
startActivity(new Intent(this, IncomingCallActivity.class));
|
||||
}
|
||||
}
|
||||
|
||||
refreshStatus(OnlineStatus.Online);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
refreshStatus(OnlineStatus.Away);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1130,6 +1253,42 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
class AcceptNewFriendDialog extends DialogFragment {
|
||||
private Contact contact;
|
||||
private String sipUri;
|
||||
|
||||
public AcceptNewFriendDialog(Contact c, String a) {
|
||||
contact = c;
|
||||
sipUri = a;
|
||||
// Empty constructor required for DialogFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.new_friend_request_dialog, container);
|
||||
|
||||
getDialog().setTitle(R.string.linphone_friend_new_request_title);
|
||||
|
||||
Button yes = (Button) view.findViewById(R.id.yes);
|
||||
yes.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
acceptNewFriend(contact, sipUri, true);
|
||||
}
|
||||
});
|
||||
|
||||
Button no = (Button) view.findViewById(R.id.no);
|
||||
no.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
acceptNewFriend(contact, sipUri, false);
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface ContactPicked {
|
||||
|
|
|
@ -883,8 +883,18 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
public void byeReceived(LinphoneCore lc, String from) {}
|
||||
public void displayMessage(LinphoneCore lc, String message) {}
|
||||
public void show(LinphoneCore lc) {}
|
||||
public void newSubscriptionRequest(LinphoneCore lc,LinphoneFriend lf,String url) {}
|
||||
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {}
|
||||
|
||||
public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url) {
|
||||
for (LinphoneSimpleListener listener : getSimpleListeners(LinphoneActivity.class)) {
|
||||
((LinphoneActivity) listener).onNewSubscriptionRequestReceived(lf, url);
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {
|
||||
for (LinphoneSimpleListener listener : getSimpleListeners(LinphoneActivity.class)) {
|
||||
((LinphoneActivity) listener).onNotifyPresenceReceived(lf);
|
||||
}
|
||||
}
|
||||
|
||||
public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,
|
||||
LinphoneAddress from, String message) {
|
||||
|
|
|
@ -163,7 +163,6 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
Compatibility.setNotificationLatestEventInfo(mNotif, this, mNotificationTitle, "", mNotifContentIntent);
|
||||
|
||||
LinphoneManager.createAndStart(this, this);
|
||||
LinphoneManager.getLc().setPresenceInfo(0, null, OnlineStatus.Online);
|
||||
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
||||
mWifiLock = mWifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, this.getPackageName()+"-wifi-call-lock");
|
||||
mWifiLock.setReferenceCounted(false);
|
||||
|
@ -197,6 +196,8 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
LinphoneManager.getLc().setPresenceInfo(0, "", OnlineStatus.Online);
|
||||
}
|
||||
|
||||
private enum IncallIconState {INCALL, PAUSE, VIDEO, IDLE}
|
||||
|
@ -459,8 +460,8 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
|
||||
@Override
|
||||
public synchronized void onDestroy() {
|
||||
instance=null;
|
||||
LinphoneManager.getLc().setPresenceInfo(0, null, OnlineStatus.Offline);
|
||||
LinphoneManager.getLc().setPresenceInfo(0, "", OnlineStatus.Offline);
|
||||
instance = null;
|
||||
LinphoneManager.destroy();
|
||||
|
||||
// Make sure our notification is gone.
|
||||
|
|
|
@ -75,6 +75,7 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
|
|||
private static final int ACCOUNTS_SETTINGS_ID = 1;
|
||||
private static final int WIZARD_SETTINGS_ID = 2;
|
||||
private static final int CAMERA_SETTINGS_ID = 6;
|
||||
private static final int FRIENDS_SETTINGS_ID = 7;
|
||||
private static final int WIZARD_INTENT = 1;
|
||||
|
||||
public PreferencesFragment() {
|
||||
|
@ -104,6 +105,12 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
|
|||
uncheckDisableAndHideCheckbox(R.string.pref_animation_enable_key);
|
||||
}
|
||||
|
||||
if (!getResources().getBoolean(R.bool.enable_linphone_friends)) {
|
||||
PreferenceCategory friends = (PreferenceCategory) getPreferenceScreen().getPreference(FRIENDS_SETTINGS_ID);
|
||||
friends.removeAll();
|
||||
friends.setLayoutResource(R.layout.hidden);
|
||||
}
|
||||
|
||||
addTransportChecboxesListener();
|
||||
|
||||
ecCalibratePref = (CheckBoxPreference) findPreference(pref_echo_canceller_calibration_key);
|
||||
|
|
|
@ -184,19 +184,21 @@ public class StatusFragment extends Fragment {
|
|||
public void run() {
|
||||
statusLed.setImageResource(getStatusIconResource(state, true));
|
||||
statusText.setText(getStatusIconText(state));
|
||||
if (getResources().getBoolean(R.bool.lock_statusbar)) {
|
||||
statusText.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (LinphoneManager.isInstanciated()) {
|
||||
LinphoneManager.getLc().refreshRegisters();
|
||||
try {
|
||||
if (getResources().getBoolean(R.bool.lock_statusbar)) {
|
||||
statusText.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (LinphoneManager.isInstanciated()) {
|
||||
LinphoneManager.getLc().refreshRegisters();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// setMiniLedsForEachAccount();
|
||||
populateSliderContent();
|
||||
sliderContentAccounts.invalidate();
|
||||
});
|
||||
}
|
||||
// setMiniLedsForEachAccount();
|
||||
populateSliderContent();
|
||||
sliderContentAccounts.invalidate();
|
||||
} catch (IllegalStateException ise) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ class LinphoneAuthInfoImpl implements LinphoneAuthInfo {
|
|||
public void setPassword(String password) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("not implemeneted yet");
|
||||
|
||||
}
|
||||
public void setRealm(String realm) {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -741,4 +741,20 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
public PayloadType findPayloadType(String mime, int clockRate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private native void removeFriend(long ptr, long lf);
|
||||
@Override
|
||||
public void removeFriend(LinphoneFriend lf) {
|
||||
removeFriend(nativePtr, lf.getNativePtr());
|
||||
}
|
||||
|
||||
private native long getFriendByAddress(long ptr, String sipUri);
|
||||
@Override
|
||||
public LinphoneFriend findFriendByAddress(String sipUri) {
|
||||
long ptr = getFriendByAddress(nativePtr, sipUri);
|
||||
if (ptr == 0) {
|
||||
return null;
|
||||
}
|
||||
return new LinphoneFriendImpl(ptr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
package org.linphone.core;
|
||||
|
||||
class LinphoneFriendImpl implements LinphoneFriend {
|
||||
import java.io.Serializable;
|
||||
|
||||
class LinphoneFriendImpl implements LinphoneFriend, Serializable {
|
||||
protected final long nativePtr;
|
||||
private native long newLinphoneFriend(String friendUri);
|
||||
private native void setAddress(long nativePtr,long friend);
|
||||
|
@ -48,14 +50,12 @@ class LinphoneFriendImpl implements LinphoneFriend {
|
|||
}
|
||||
public void setAddress(LinphoneAddress anAddress) {
|
||||
this.setAddress(nativePtr, ((LinphoneAddressImpl)anAddress).nativePtr);
|
||||
|
||||
}
|
||||
public LinphoneAddress getAddress() {
|
||||
return new LinphoneAddressImpl(getAddress(nativePtr));
|
||||
}
|
||||
public void setIncSubscribePolicy(SubscribePolicy policy) {
|
||||
setIncSubscribePolicy(nativePtr,policy.mValue);
|
||||
|
||||
}
|
||||
public SubscribePolicy getIncSubscribePolicy() {
|
||||
return SubscribePolicy.fromInt(getIncSubscribePolicy(nativePtr)) ;
|
||||
|
@ -66,7 +66,6 @@ class LinphoneFriendImpl implements LinphoneFriend {
|
|||
public boolean isSubscribesEnabled() {
|
||||
return isSubscribesEnabled(nativePtr);
|
||||
}
|
||||
|
||||
public OnlineStatus getStatus() {
|
||||
return OnlineStatus.fromInt(getStatus(nativePtr));
|
||||
}
|
||||
|
@ -76,5 +75,7 @@ class LinphoneFriendImpl implements LinphoneFriend {
|
|||
public void done() {
|
||||
done(nativePtr);
|
||||
}
|
||||
|
||||
public long getNativePtr() {
|
||||
return nativePtr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b09cb1daad42c6c3cfc1128bb74e92a5e8076c6e
|
||||
Subproject commit 1cc0a418af4718014a614afdbe6f1cd7690a4ccf
|
Loading…
Reference in a new issue