Performances improvements

This commit is contained in:
Sylvain Berfini 2019-06-17 15:44:11 +02:00
parent f81910644a
commit 45254d3261
19 changed files with 66 additions and 162 deletions

View file

@ -441,11 +441,13 @@ public class LinphoneManager implements SensorEventListener {
mPrefs.getLinphoneFactoryConfig(), mPrefs.getLinphoneFactoryConfig(),
mContext); mContext);
mCore.addListener(mCoreListener); mCore.addListener(mCoreListener);
if (isPush) { if (isPush) {
Log.w( Log.w(
"[Manager] We are here because of a received push notification, enter background mode before starting the Core"); "[Manager] We are here because of a received push notification, enter background mode before starting the Core");
mCore.enterBackground(); mCore.enterBackground();
} }
mCore.start(); mCore.start();
TimerTask lTask = TimerTask lTask =
new TimerTask() { new TimerTask() {

View file

@ -21,7 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import android.Manifest; import android.Manifest;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -30,6 +29,8 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import java.util.ArrayList;
import java.util.Collection;
import org.linphone.LinphoneManager; import org.linphone.LinphoneManager;
import org.linphone.R; import org.linphone.R;
import org.linphone.call.CallActivity; import org.linphone.call.CallActivity;
@ -40,15 +41,14 @@ import org.linphone.core.Core;
import org.linphone.core.CoreListenerStub; import org.linphone.core.CoreListenerStub;
import org.linphone.core.tools.Log; import org.linphone.core.tools.Log;
import org.linphone.settings.LinphonePreferences; import org.linphone.settings.LinphonePreferences;
import org.linphone.views.AddressAware;
import org.linphone.views.AddressText; import org.linphone.views.AddressText;
import org.linphone.views.CallButton; import org.linphone.views.CallButton;
import org.linphone.views.Digit;
import org.linphone.views.EraseButton; import org.linphone.views.EraseButton;
public class DialerActivity extends MainActivity implements AddressText.AddressChangedListener { public class DialerActivity extends MainActivity implements AddressText.AddressChangedListener {
private static final String ACTION_CALL_LINPHONE = "org.linphone.intent.action.CallLaunched"; private static final String ACTION_CALL_LINPHONE = "org.linphone.intent.action.CallLaunched";
private AddressAware mNumpad;
private AddressText mAddress; private AddressText mAddress;
private CallButton mStartCall, mAddCall, mTransferCall; private CallButton mStartCall, mAddCall, mTransferCall;
private ImageView mAddContact, mBackToCall; private ImageView mAddContact, mBackToCall;
@ -91,11 +91,6 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
mTransferCall.setAddressWidget(mAddress); mTransferCall.setAddressWidget(mAddress);
mTransferCall.setIsTransfer(true); mTransferCall.setIsTransfer(true);
mNumpad = findViewById(R.id.numpad);
if (mNumpad != null) {
mNumpad.setAddressWidget(mAddress);
}
mAddContact = findViewById(R.id.add_contact); mAddContact = findViewById(R.id.add_contact);
mAddContact.setEnabled(false); mAddContact.setEnabled(false);
mAddContact.setOnClickListener( mAddContact.setOnClickListener(
@ -144,6 +139,7 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
Manifest.permission.READ_CONTACTS Manifest.permission.READ_CONTACTS
}; };
setUpNumpad(dialerView);
handleIntentParams(getIntent()); handleIntentParams(getIntent());
} }
@ -164,15 +160,6 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
core.addListener(mListener); core.addListener(mListener);
} }
boolean isOrientationLandscape =
getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE;
if (isOrientationLandscape && !isTablet()) {
((LinearLayout) mNumpad).setVisibility(View.GONE);
} else {
((LinearLayout) mNumpad).setVisibility(View.VISIBLE);
}
updateLayout(); updateLayout();
enableVideoPreviewIfTablet(true); enableVideoPreviewIfTablet(true);
} }
@ -296,4 +283,24 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
mAddress.setText(addressToCall); mAddress.setText(addressToCall);
} }
} }
private void setUpNumpad(View view) {
if (view == null) return;
for (Digit v : retrieveChildren((ViewGroup) view, Digit.class)) {
v.setAddressWidget(mAddress);
}
}
private <T> Collection<T> retrieveChildren(ViewGroup viewGroup, Class<T> clazz) {
final Collection<T> views = new ArrayList<>();
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View v = viewGroup.getChildAt(i);
if (v instanceof ViewGroup) {
views.addAll(retrieveChildren((ViewGroup) v, clazz));
} else {
if (clazz.isInstance(v)) views.add(clazz.cast(v));
}
}
return views;
}
} }

View file

@ -70,7 +70,6 @@ import org.linphone.settings.LinphonePreferences;
import org.linphone.utils.AndroidAudioManager; import org.linphone.utils.AndroidAudioManager;
import org.linphone.utils.LinphoneUtils; import org.linphone.utils.LinphoneUtils;
import org.linphone.views.ContactAvatar; import org.linphone.views.ContactAvatar;
import org.linphone.views.Numpad;
public class CallActivity extends LinphoneGenericActivity public class CallActivity extends LinphoneGenericActivity
implements CallStatusBarFragment.StatsClikedListener, implements CallStatusBarFragment.StatsClikedListener,
@ -109,7 +108,6 @@ public class CallActivity extends LinphoneGenericActivity
private ImageView mPause, mSwitchCamera, mRecordingInProgress; private ImageView mPause, mSwitchCamera, mRecordingInProgress;
private ImageView mExtrasButtons, mAddCall, mTransferCall, mRecordCall, mConference; private ImageView mExtrasButtons, mAddCall, mTransferCall, mRecordCall, mConference;
private ImageView mAudioRoute, mRouteEarpiece, mRouteSpeaker, mRouteBluetooth; private ImageView mAudioRoute, mRouteEarpiece, mRouteSpeaker, mRouteBluetooth;
private Numpad mNumpad;
private TextView mContactName, mMissedMessages; private TextView mContactName, mMissedMessages;
private ProgressBar mVideoInviteInProgress; private ProgressBar mVideoInviteInProgress;
private Chronometer mCallTimer; private Chronometer mCallTimer;
@ -300,15 +298,16 @@ public class CallActivity extends LinphoneGenericActivity
} }
}); });
mNumpad = findViewById(R.id.numpad);
ImageView numpadButton = findViewById(R.id.dialer); ImageView numpadButton = findViewById(R.id.dialer);
numpadButton.setOnClickListener( numpadButton.setOnClickListener(
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
mNumpad.setVisibility( findViewById(R.id.numpad)
mNumpad.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE); .setVisibility(
findViewById(R.id.numpad).getVisibility() == View.VISIBLE
? View.GONE
: View.VISIBLE);
} }
}); });

View file

@ -443,8 +443,8 @@ public class ContactsManager extends ContentObserver implements FriendListListen
private synchronized boolean refreshSipContact(Friend lf) { private synchronized boolean refreshSipContact(Friend lf) {
LinphoneContact contact = (LinphoneContact) lf.getUserData(); LinphoneContact contact = (LinphoneContact) lf.getUserData();
if (contact != null) {
if (contact != null) {
if (LinphoneService.instance().getResources().getBoolean(R.bool.use_linphone_tag)) { if (LinphoneService.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
// Inserting Linphone information in Android contact if the parameter is enabled // Inserting Linphone information in Android contact if the parameter is enabled
if (LinphonePreferences.instance() if (LinphonePreferences.instance()
@ -457,10 +457,10 @@ public class ContactsManager extends ContentObserver implements FriendListListen
if (!mSipContacts.contains(contact)) { if (!mSipContacts.contains(contact)) {
mSipContacts.add(contact); mSipContacts.add(contact);
return true; return true;
} }
} }
return false; return false;
} }

View file

@ -26,7 +26,6 @@ import android.provider.ContactsContract;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import org.linphone.LinphoneManager; import org.linphone.LinphoneManager;
import org.linphone.LinphoneService; import org.linphone.LinphoneService;
import org.linphone.R; import org.linphone.R;
@ -78,12 +77,8 @@ public class LinphoneContact extends AndroidContact
@Override @Override
public int compareTo(LinphoneContact contact) { public int compareTo(LinphoneContact contact) {
String fullName = String fullName = getFullName() != null ? getFullName() : "";
getFullName() != null ? getFullName().toUpperCase(Locale.getDefault()) : ""; String contactFullName = contact.getFullName() != null ? contact.getFullName() : "";
String contactFullName =
contact.getFullName() != null
? contact.getFullName().toUpperCase(Locale.getDefault())
: "";
if (fullName.equals(contactFullName)) { if (fullName.equals(contactFullName)) {
if (getAndroidId() != null) { if (getAndroidId() != null) {

View file

@ -23,6 +23,7 @@ import android.annotation.SuppressLint;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@ -37,18 +38,17 @@ import org.linphone.settings.LinphonePreferences;
@SuppressLint("AppCompatCustomView") @SuppressLint("AppCompatCustomView")
public class Digit extends Button implements AddressAware { public class Digit extends Button implements AddressAware {
private AddressText mAddress;
private boolean mPlayDtmf; private boolean mPlayDtmf;
private AddressText mAddress;
public Digit(Context context, AttributeSet attrs, int style) { public Digit(Context context, AttributeSet attrs, int style) {
super(context, attrs, style); super(context, attrs, style);
setLongClickable(true); init(context, attrs);
} }
public Digit(Context context, AttributeSet attrs) { public Digit(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
setLongClickable(true); init(context, attrs);
} }
public Digit(Context context) { public Digit(Context context) {
@ -56,12 +56,12 @@ public class Digit extends Button implements AddressAware {
setLongClickable(true); setLongClickable(true);
} }
public void setAddressWidget(AddressText address) { private void init(Context context, AttributeSet attrs) {
mAddress = address; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Numpad);
} mPlayDtmf = 1 == a.getInt(R.styleable.Numpad_play_dtmf, 1);
a.recycle();
public void setPlayDtmf(boolean play) { setLongClickable(true);
mPlayDtmf = play;
} }
@Override @Override
@ -85,6 +85,11 @@ public class Digit extends Button implements AddressAware {
} }
} }
@Override
public void setAddressWidget(AddressText address) {
mAddress = address;
}
private class DialKeyListener implements OnClickListener, OnTouchListener, OnLongClickListener { private class DialKeyListener implements OnClickListener, OnTouchListener, OnLongClickListener {
final char mKeyCode; final char mKeyCode;
boolean mIsDtmfStarted; boolean mIsDtmfStarted;

View file

@ -1,74 +0,0 @@
package org.linphone.views;
/*
NumpadView.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.
*/
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import java.util.ArrayList;
import java.util.Collection;
import org.linphone.R;
public class Numpad extends LinearLayout implements AddressAware {
private final boolean mPlayDtmf;
public Numpad(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Numpad);
mPlayDtmf = 1 == a.getInt(R.styleable.Numpad_play_dtmf, 1);
a.recycle();
LayoutInflater.from(context).inflate(R.layout.numpad, this);
setLongClickable(true);
}
@Override
protected final void onFinishInflate() {
for (Digit v : retrieveChildren(this, Digit.class)) {
v.setPlayDtmf(mPlayDtmf);
}
super.onFinishInflate();
}
public void setAddressWidget(AddressText address) {
for (AddressAware v : retrieveChildren(this, AddressAware.class)) {
v.setAddressWidget(address);
}
}
private <T> Collection<T> retrieveChildren(ViewGroup viewGroup, Class<T> clazz) {
final Collection<T> views = new ArrayList<>();
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View v = viewGroup.getChildAt(i);
if (v instanceof ViewGroup) {
views.addAll(retrieveChildren((ViewGroup) v, clazz));
} else {
if (clazz.isInstance(v)) views.add(clazz.cast(v));
}
}
return views;
}
}

View file

@ -130,7 +130,7 @@
</RelativeLayout> </RelativeLayout>
<org.linphone.views.Numpad <include layout="@layout/numpad"
android:id="@+id/numpad" android:id="@+id/numpad"
android:visibility="gone" android:visibility="gone"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -138,8 +138,7 @@
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:background="@color/toolbar_color" android:background="@color/toolbar_color" />
android:contentDescription="@string/content_description_numpad" />
</RelativeLayout> </RelativeLayout>

View file

@ -3,16 +3,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/dialer"
android:layout_width="300dp"
android:layout_height="460dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="50dp"
android:background="?attr/backgroundColor"
android:visibility="gone"/>
<RelativeLayout <RelativeLayout
android:id="@+id/address_bar" android:id="@+id/address_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -49,16 +39,6 @@
</RelativeLayout> </RelativeLayout>
<org.linphone.views.Numpad
android:id="@+id/numpad"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/controls"
android:layout_below="@id/address_bar"
android:layout_centerInParent="true"
android:padding="10dp"
android:visibility="gone" />
<ImageView <ImageView
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -70,10 +70,10 @@
</RelativeLayout> </RelativeLayout>
<org.linphone.views.Numpad <include layout="@layout/numpad"
android:id="@+id/numpad" android:id="@+id/numpad"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_above="@id/controls" android:layout_above="@id/controls"
android:layout_below="@id/address_bar" android:layout_below="@id/address_bar"
android:layout_centerInParent="true" android:layout_centerInParent="true"

View file

@ -70,10 +70,10 @@
</RelativeLayout> </RelativeLayout>
<org.linphone.views.Numpad <include layout="@layout/numpad"
android:id="@+id/numpad" android:id="@+id/numpad"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_above="@id/controls" android:layout_above="@id/controls"
android:layout_below="@id/address_bar" android:layout_below="@id/address_bar"
android:layout_centerInParent="true" android:layout_centerInParent="true"

View file

@ -122,7 +122,7 @@
</RelativeLayout> </RelativeLayout>
<org.linphone.views.Numpad <include layout="@layout/numpad"
android:id="@+id/numpad" android:id="@+id/numpad"
android:visibility="gone" android:visibility="gone"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -130,8 +130,7 @@
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:background="@color/toolbar_color" android:background="@color/toolbar_color" />
android:contentDescription="@string/content_description_numpad" />
</RelativeLayout> </RelativeLayout>

View file

@ -33,8 +33,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/menu" android:layout_above="@+id/menu"
android:layout_below="@id/top_bar" android:layout_below="@id/top_bar">
android:background="?attr/backgroundColor">
<TextView <TextView
android:id="@+id/contact_name" android:id="@+id/contact_name"

View file

@ -6,7 +6,6 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/backgroundColor"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout

View file

@ -2,7 +2,6 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="80dp"
android:background="?attr/backgroundColor"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingTop="5dp" android:paddingTop="5dp"

View file

@ -3,15 +3,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/dialer"
android:layout_width="300dp"
android:layout_height="460dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="50dp"
android:visibility="gone"/>
<RelativeLayout <RelativeLayout
android:id="@+id/address_bar" android:id="@+id/address_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -49,7 +40,7 @@
</RelativeLayout> </RelativeLayout>
<org.linphone.views.Numpad <include layout="@layout/numpad"
android:id="@+id/numpad" android:id="@+id/numpad"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="?attr/backgroundColor">
<TableRow <TableRow
android:layout_weight="1" android:layout_weight="1"
@ -27,6 +28,7 @@
android:background="@drawable/numpad_three" android:background="@drawable/numpad_three"
android:soundEffectsEnabled="true" android:soundEffectsEnabled="true"
android:text="3" /> android:text="3" />
</TableRow> </TableRow>
<TableRow <TableRow
@ -53,6 +55,7 @@
android:background="@drawable/numpad_six" android:background="@drawable/numpad_six"
android:soundEffectsEnabled="true" android:soundEffectsEnabled="true"
android:text="6" /> android:text="6" />
</TableRow> </TableRow>
<TableRow <TableRow
@ -79,6 +82,7 @@
android:background="@drawable/numpad_nine" android:background="@drawable/numpad_nine"
android:soundEffectsEnabled="true" android:soundEffectsEnabled="true"
android:text="9" /> android:text="9" />
</TableRow> </TableRow>
<TableRow <TableRow
@ -105,6 +109,7 @@
android:background="@drawable/numpad_sharp" android:background="@drawable/numpad_sharp"
android:soundEffectsEnabled="true" android:soundEffectsEnabled="true"
android:text="#" /> android:text="#" />
</TableRow> </TableRow>
</TableLayout> </TableLayout>

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="DialerDigit" parent="@android:style/TextAppearance.Medium"> <style name="DialerDigit" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">50dp</item> <item name="android:layout_width">50dp</item>
<item name="android:layout_height">50dp</item> <item name="android:layout_height">50dp</item>

View file

@ -94,7 +94,7 @@
<bool name="use_big_pictures_to_preview_images_file_transfers">true</bool> <bool name="use_big_pictures_to_preview_images_file_transfers">true</bool>
<bool name="show_sip_uri_in_chat">false</bool> <bool name="show_sip_uri_in_chat">false</bool>
<bool name="hide_empty_one_to_one_chat_rooms">true</bool> <bool name="hide_empty_one_to_one_chat_rooms">true</bool>
<bool name="create_most_recent_chat_rooms_shortcuts">true</bool> <bool name="create_most_recent_chat_rooms_shortcuts">false</bool>
<bool name="force_end_to_end_encryption_in_chat">false</bool> <bool name="force_end_to_end_encryption_in_chat">false</bool>
<!-- Contacts --> <!-- Contacts -->