Add friendlist subscription
This commit is contained in:
parent
516b37bc8d
commit
4ade655473
11 changed files with 102 additions and 7 deletions
|
@ -95,6 +95,19 @@
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
android:src="@drawable/led_connected" />
|
android:src="@drawable/led_connected" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/friendLinphone"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
android:src="@drawable/linphone_user" />
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -7,6 +7,8 @@ contact="Linphone Android" <sip:linphone.android@unknown-host>
|
||||||
use_info=0
|
use_info=0
|
||||||
use_ipv6=0
|
use_ipv6=0
|
||||||
keepalive_period=30000
|
keepalive_period=30000
|
||||||
|
rls_uri=sip:rls@sip1.linphone.org
|
||||||
|
use_rls_presence=1
|
||||||
|
|
||||||
[video]
|
[video]
|
||||||
size=qvga
|
size=qvga
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
<string name="pref_bandwidth_limit_key">pref_bandwidth_limit_key</string>
|
<string name="pref_bandwidth_limit_key">pref_bandwidth_limit_key</string>
|
||||||
<string name="pref_animation_enable_key">pref_animation_enable_key</string>
|
<string name="pref_animation_enable_key">pref_animation_enable_key</string>
|
||||||
<string name="pref_escape_plus_key">pref_escape_plus_key</string>
|
<string name="pref_escape_plus_key">pref_escape_plus_key</string>
|
||||||
|
<string name="pref_friendlist_subscribe_key">pref_friendlist_subscribe_key</string>
|
||||||
<string name="pref_echo_cancellation_key">pref_echo_cancellation_key</string>
|
<string name="pref_echo_cancellation_key">pref_echo_cancellation_key</string>
|
||||||
<string name="pref_autostart_key">pref_autostart_key</string>
|
<string name="pref_autostart_key">pref_autostart_key</string>
|
||||||
<string name="pref_enable_outbound_proxy_key">Outbound proxy</string>
|
<string name="pref_enable_outbound_proxy_key">Outbound proxy</string>
|
||||||
|
|
|
@ -204,6 +204,7 @@
|
||||||
<string name="pref_avpf">AVPF</string>
|
<string name="pref_avpf">AVPF</string>
|
||||||
<string name="pref_avpf_rr_interval"> AVPF regular RTCP interval in seconds (between 1 and 5)</string>
|
<string name="pref_avpf_rr_interval"> AVPF regular RTCP interval in seconds (between 1 and 5)</string>
|
||||||
<string name="pref_escape_plus">Replace + by 00</string>
|
<string name="pref_escape_plus">Replace + by 00</string>
|
||||||
|
<string name="pref_friendlist_subscribe">Friendlist subscribe</string>
|
||||||
<string name="pref_auth_userid">Auth userid</string>
|
<string name="pref_auth_userid">Auth userid</string>
|
||||||
<string name="pref_help_auth_userid">Enter authentication userid (optional)</string>
|
<string name="pref_help_auth_userid">Enter authentication userid (optional)</string>
|
||||||
<string name="pref_display_name">Display name</string>
|
<string name="pref_display_name">Display name</string>
|
||||||
|
|
|
@ -72,6 +72,10 @@
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/pref_escape_plus"
|
android:title="@string/pref_escape_plus"
|
||||||
android:key="@string/pref_escape_plus_key"/>
|
android:key="@string/pref_escape_plus_key"/>
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:title="@string/pref_friendlist_subscribe"
|
||||||
|
android:key="@string/pref_friendlist_subscribe_key"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
||||||
}
|
}
|
||||||
preference.setSummary(newValue.toString());
|
preference.setSummary(newValue.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
OnPreferenceChangeListener prefixChangedListener = new OnPreferenceChangeListener() {
|
OnPreferenceChangeListener prefixChangedListener = new OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -234,6 +234,14 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
OnPreferenceChangeListener friendlistSubscribeListener = new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
boolean value = (Boolean) newValue;
|
||||||
|
LinphoneManager.getInstance().subscribeFriendList(value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
OnPreferenceChangeListener disableChangedListener = new OnPreferenceChangeListener() {
|
OnPreferenceChangeListener disableChangedListener = new OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
@ -365,6 +373,12 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
||||||
if(!isNewAccount){
|
if(!isNewAccount){
|
||||||
escape.setChecked(mPrefs.getReplacePlusByZeroZero(n));
|
escape.setChecked(mPrefs.getReplacePlusByZeroZero(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckBoxPreference friendlistSubscribe = (CheckBoxPreference) advanced.getPreference(8);
|
||||||
|
friendlistSubscribe.setOnPreferenceChangeListener(friendlistSubscribeListener);
|
||||||
|
if(!isNewAccount){
|
||||||
|
escape.setChecked(mPrefs.getReplacePlusByZeroZero(n));
|
||||||
|
}
|
||||||
|
|
||||||
PreferenceCategory manage = (PreferenceCategory) getPreferenceScreen().findPreference(getString(R.string.pref_manage_key));
|
PreferenceCategory manage = (PreferenceCategory) getPreferenceScreen().findPreference(getString(R.string.pref_manage_key));
|
||||||
final CheckBoxPreference disable = (CheckBoxPreference) manage.getPreference(0);
|
final CheckBoxPreference disable = (CheckBoxPreference) manage.getPreference(0);
|
||||||
|
|
|
@ -459,6 +459,7 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckBox delete = (CheckBox) view.findViewById(R.id.delete);
|
CheckBox delete = (CheckBox) view.findViewById(R.id.delete);
|
||||||
|
ImageView linphoneFriend = (ImageView) view.findViewById(R.id.friendLinphone);
|
||||||
|
|
||||||
TextView name = (TextView) view.findViewById(R.id.name);
|
TextView name = (TextView) view.findViewById(R.id.name);
|
||||||
name.setText(contact.getFullName());
|
name.setText(contact.getFullName());
|
||||||
|
@ -474,7 +475,13 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
||||||
separatorText.setText(String.valueOf(fullName.charAt(0)));
|
separatorText.setText(String.valueOf(fullName.charAt(0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(contact.isInLinphoneFriendList()){
|
||||||
|
linphoneFriend.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
linphoneFriend.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
ImageView icon = (ImageView) view.findViewById(R.id.contact_picture);
|
ImageView icon = (ImageView) view.findViewById(R.id.contact_picture);
|
||||||
if (contact.hasPhoto()) {
|
if (contact.hasPhoto()) {
|
||||||
LinphoneUtils.setImagePictureFromUri(getActivity(), icon, contact.getPhotoUri(), contact.getThumbnailUri());
|
LinphoneUtils.setImagePictureFromUri(getActivity(), icon, contact.getPhotoUri(), contact.getThumbnailUri());
|
||||||
|
|
|
@ -50,13 +50,16 @@ import org.linphone.ui.AddressText;
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.FragmentManager;
|
import android.app.FragmentManager;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
@ -1122,6 +1125,9 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
getIntent().putExtra("PreviousActivity", 0);
|
getIntent().putExtra("PreviousActivity", 0);
|
||||||
|
|
||||||
|
if(LinphonePreferences.instance().isFriendlistsubscriptionEnabled()){
|
||||||
|
LinphoneManager.getInstance().subscribeFriendList(!isApplicationBroughtToBackground(this));
|
||||||
|
}
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(mListener);
|
lc.removeListener(mListener);
|
||||||
|
@ -1129,7 +1135,28 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isApplicationBroughtToBackground(final Activity activity) {
|
||||||
|
ActivityManager activityManager = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
|
List<ActivityManager.RunningTaskInfo> tasks = activityManager.getRunningTasks(1);
|
||||||
|
|
||||||
|
// Check the top Activity against the list of Activities contained in the Application's package.
|
||||||
|
if (!tasks.isEmpty()) {
|
||||||
|
ComponentName topActivity = tasks.get(0).topActivity;
|
||||||
|
try {
|
||||||
|
PackageInfo pi = activity.getPackageManager().getPackageInfo(activity.getPackageName(), PackageManager.GET_ACTIVITIES);
|
||||||
|
for (ActivityInfo activityInfo : pi.activities) {
|
||||||
|
if(topActivity.getClassName().equals(activityInfo.name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch( PackageManager.NameNotFoundException e) {
|
||||||
|
return false; // Never happens.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void checkAndRequestExternalStoragePermission() {
|
public void checkAndRequestExternalStoragePermission() {
|
||||||
if (LinphonePreferences.instance().writeExternalStoragePermAsked()) {
|
if (LinphonePreferences.instance().writeExternalStoragePermAsked()) {
|
||||||
return;
|
return;
|
||||||
|
@ -1171,7 +1198,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
|
|
||||||
public void checkAndRequestPermission(String permission, int result) {
|
public void checkAndRequestPermission(String permission, int result) {
|
||||||
if (getPackageManager().checkPermission(permission, getPackageName()) != PackageManager.PERMISSION_GRANTED) {
|
if (getPackageManager().checkPermission(permission, getPackageName()) != PackageManager.PERMISSION_GRANTED) {
|
||||||
ActivityCompat.requestPermissions(this, new String[]{ permission }, result);
|
ActivityCompat.requestPermissions(this, new String[]{permission}, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1244,6 +1271,9 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
refreshAccounts();
|
refreshAccounts();
|
||||||
|
|
||||||
updateMissedChatCount();
|
updateMissedChatCount();
|
||||||
|
if(LinphonePreferences.instance().isFriendlistsubscriptionEnabled()){
|
||||||
|
LinphoneManager.getInstance().subscribeFriendList(true);
|
||||||
|
}
|
||||||
|
|
||||||
displayMissedCalls(LinphoneManager.getLc().getMissedCallsCount());
|
displayMissedCalls(LinphoneManager.getLc().getMissedCallsCount());
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneFriend;
|
import org.linphone.core.LinphoneFriend;
|
||||||
import org.linphone.core.LinphoneFriend.SubscribePolicy;
|
import org.linphone.core.LinphoneFriend.SubscribePolicy;
|
||||||
|
import org.linphone.core.PresenceBasicStatus;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.content.ContentProviderOperation;
|
import android.content.ContentProviderOperation;
|
||||||
|
@ -446,6 +447,10 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
return friend != null;
|
return friend != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInLinphoneFriendList() {
|
||||||
|
return (friend != null && friend.getPresenceModel() != null && friend.getPresenceModel().getBasicStatus().equals(PresenceBasicStatus.Open));
|
||||||
|
}
|
||||||
|
|
||||||
public void setFriend(LinphoneFriend f) {
|
public void setFriend(LinphoneFriend f) {
|
||||||
friend = f;
|
friend = f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,7 +221,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
userAgent.append("LinphoneAndroid/" + mServiceContext.getPackageManager().getPackageInfo(mServiceContext.getPackageName(),0).versionCode);
|
userAgent.append("LinphoneAndroid/" + mServiceContext.getPackageManager().getPackageInfo(mServiceContext.getPackageName(),0).versionCode);
|
||||||
userAgent.append(" (");
|
userAgent.append(" (");
|
||||||
userAgent.append("Linphone/" + LinphoneManager.getLc().getVersion() + "; ");
|
userAgent.append("Linphone/" + LinphoneManager.getLc().getVersion() + "; ");
|
||||||
userAgent.append(Build.DEVICE + " " + Build.MODEL + " Android/" + Build.VERSION.SDK_INT);
|
userAgent.append(Build.DEVICE + " " + Build.MODEL + " Android/" + Build.VERSION.SDK_INT);
|
||||||
userAgent.append(")");
|
userAgent.append(")");
|
||||||
return userAgent.toString();
|
return userAgent.toString();
|
||||||
}
|
}
|
||||||
|
@ -379,6 +379,15 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void subscribeFriendList(boolean enabled){
|
||||||
|
LinphoneCore lc = getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if(lc != null ) {
|
||||||
|
LinphoneFriendList mFriendList = (lc.getFriendLists())[0];
|
||||||
|
mFriendList.enableSubscriptions(enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static synchronized final LinphoneManager getInstance() {
|
public static synchronized final LinphoneManager getInstance() {
|
||||||
if (instance != null) return instance;
|
if (instance != null) return instance;
|
||||||
|
|
||||||
|
@ -667,6 +676,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
mLc.setCallLogsDatabasePath(mCallLogDatabaseFile);
|
mLc.setCallLogsDatabasePath(mCallLogDatabaseFile);
|
||||||
mLc.setFriendsDatabasePath(mFriendsDatabaseFile);
|
mLc.setFriendsDatabasePath(mFriendsDatabaseFile);
|
||||||
mLc.setUserCertificatesPath(mUserCertificatePath);
|
mLc.setUserCertificatesPath(mUserCertificatePath);
|
||||||
|
subscribeFriendList(mPrefs.isFriendlistsubscriptionEnabled());
|
||||||
//mLc.setCallErrorTone(Reason.NotFound, mErrorToneFile);
|
//mLc.setCallErrorTone(Reason.NotFound, mErrorToneFile);
|
||||||
|
|
||||||
int availableCores = Runtime.getRuntime().availableProcessors();
|
int availableCores = Runtime.getRuntime().availableProcessors();
|
||||||
|
@ -897,7 +907,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
Log.i("New global state [",state,"]");
|
Log.i("New global state [",state,"]");
|
||||||
if (state == GlobalState.GlobalOn){
|
if (state == GlobalState.GlobalOn){
|
||||||
try {
|
try {
|
||||||
initLiblinphone(lc);
|
initLiblinphone(lc);
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
Log.e(e);
|
Log.e(e);
|
||||||
}
|
}
|
||||||
|
@ -1032,7 +1042,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == State.CallUpdatedByRemote) {
|
if (state == State.CallUpdatedByRemote) {
|
||||||
// If the correspondent proposes video while audio call
|
// If the correspondent proposes video while audio call
|
||||||
boolean remoteVideo = call.getRemoteParams().getVideoEnabled();
|
boolean remoteVideo = call.getRemoteParams().getVideoEnabled();
|
||||||
|
|
|
@ -662,6 +662,15 @@ public class LinphonePreferences {
|
||||||
prxCfg.done();
|
prxCfg.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFriendlistsubscriptionEnabled() {
|
||||||
|
return getConfig().getBool("app", "friendlist_subscription_enabled", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enabledFriendlistSubscription(boolean enabled) {
|
||||||
|
getConfig().setBool("app", "friendlist_subscription_enabled", enabled);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void setDefaultAccount(int accountIndex) {
|
public void setDefaultAccount(int accountIndex) {
|
||||||
LinphoneProxyConfig[] prxCfgs = getLc().getProxyConfigList();
|
LinphoneProxyConfig[] prxCfgs = getLc().getProxyConfigList();
|
||||||
if (accountIndex >= 0 && accountIndex < prxCfgs.length)
|
if (accountIndex >= 0 && accountIndex < prxCfgs.length)
|
||||||
|
|
Loading…
Reference in a new issue