Better call quality indicator
This commit is contained in:
parent
9905ea33ed
commit
421a23846b
1 changed files with 20 additions and 11 deletions
|
@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -27,9 +28,9 @@ import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
|
import org.linphone.core.LinphoneCall.State;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.Log;
|
import org.linphone.core.Log;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
|
||||||
|
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
@ -64,8 +65,8 @@ public abstract class AbstractCalleesActivity extends ListActivity implements Li
|
||||||
|
|
||||||
private Set<Chronometer> mChronometers = new HashSet<Chronometer>();
|
private Set<Chronometer> mChronometers = new HashSet<Chronometer>();
|
||||||
|
|
||||||
private float oldQuality = 0;
|
private Handler callqualityHandler;
|
||||||
private Runnable mCallQualityUpdater;
|
private List<View> viewsToUpdateCallQuality;
|
||||||
@Override
|
@Override
|
||||||
/**
|
/**
|
||||||
* Called by the child classes AFTER their own onCreate.
|
* Called by the child classes AFTER their own onCreate.
|
||||||
|
@ -213,25 +214,33 @@ public abstract class AbstractCalleesActivity extends ListActivity implements Li
|
||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void registerCallQualityListener(final View v, final LinphoneCall call) {
|
protected final void initCallQualityListener() {
|
||||||
final Handler callqualityHandler = new Handler();
|
callqualityHandler = new Handler();
|
||||||
callqualityHandler.postDelayed(mCallQualityUpdater = new Runnable(){
|
viewsToUpdateCallQuality = new ArrayList<View>();
|
||||||
|
callqualityHandler.postDelayed(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (call==null){
|
if (viewsToUpdateCallQuality == null) {
|
||||||
mCallQualityUpdater=null;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newQuality = call.getCurrentQuality();
|
for (View v : viewsToUpdateCallQuality) {
|
||||||
if ((int) newQuality != oldQuality){
|
LinphoneCall call = (LinphoneCall) v.getTag();
|
||||||
|
float newQuality = call.getCurrentQuality();
|
||||||
updateQualityOfSignalIcon(v, newQuality);
|
updateQualityOfSignalIcon(v, newQuality);
|
||||||
oldQuality = newQuality;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
callqualityHandler.postDelayed(this, 1000);
|
callqualityHandler.postDelayed(this, 1000);
|
||||||
}
|
}
|
||||||
},1000);
|
},1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected final void registerCallQualityListener(final View v, final LinphoneCall call) {
|
||||||
|
if (viewsToUpdateCallQuality == null && callqualityHandler == null) {
|
||||||
|
initCallQualityListener();
|
||||||
|
}
|
||||||
|
v.setTag(call);
|
||||||
|
viewsToUpdateCallQuality.add(v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue