Fix default codecs + Modified call stats display

This commit is contained in:
Sylvain Berfini 2012-09-28 11:11:29 +02:00
parent 9313994e38
commit 69a4cf9f6a
7 changed files with 237 additions and 244 deletions

View file

@ -45,140 +45,11 @@
</LinearLayout>
<ViewFlipper
android:id="@+id/flipper"
<org.linphone.ui.AvatarWithShadow
android:id="@+id/contactPicture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingBottom="10dp">
<org.linphone.ui.AvatarWithShadow
android:id="@+id/contactPicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top"
linphone:picture="@drawable/unknown_small" />
<TableLayout
android:id="@+id/audioCallStats"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="5dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:text="@string/call_stats_audio"
android:textStyle="bold"
android:textColor="@color/text_default"
android:textSize="18dp"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:text="@string/call_stats_codec"
android:textStyle="bold"
android:textColor="@android:color/black"
android:textSize="14dp"/>
<TextView
android:id="@+id/audioCodec"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:gravity="right|center_vertical"
android:textColor="@android:color/black"
android:textSize="14dp"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:text="@string/call_stats_upload"
android:textStyle="bold"
android:textColor="@android:color/black"
android:textSize="14dp"/>
<TextView
android:id="@+id/audioUploadBandwith"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:gravity="right|center_vertical"
android:textColor="@android:color/black"
android:textSize="14dp"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:text="@string/call_stats_download"
android:textColor="@android:color/black"
android:textStyle="bold"
android:textSize="14dp"/>
<TextView
android:id="@+id/audioDownloadBandwith"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:gravity="right|center_vertical"
android:textColor="@android:color/black"
android:textSize="14dp"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:text="@string/call_stats_ice"
android:textStyle="bold"
android:textColor="@android:color/black"
android:textSize="14dp"/>
<TextView
android:id="@+id/ice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:gravity="right|center_vertical"
android:textColor="@android:color/black"
android:textSize="14dp"/>
</TableRow>
</TableLayout>
</ViewFlipper>
android:gravity="center_horizontal|top"
linphone:picture="@drawable/unknown_small" />
</LinearLayout>

View file

@ -14,13 +14,143 @@
linphone:handle="@+id/handle"
linphone:content="@+id/content">
<ListView
<RelativeLayout
android:id="@id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stackFromBottom="true"
android:paddingBottom="10dp"
android:background="@android:color/black"/>
android:layout_height="wrap_content">
<TableLayout
android:id="@+id/callStats"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:background="@android:color/black">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:id="@+id/call_stats_title"
android:textStyle="bold"
android:textColor="@color/text_default"
android:textSize="18dp"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:text="@string/call_stats_codec"
android:textStyle="bold"
android:textColor="@android:color/white"
android:textSize="12dp"/>
<TextView
android:id="@+id/codec"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:gravity="right|center_vertical"
android:textColor="@android:color/white"
android:textSize="12dp"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:text="@string/call_stats_upload"
android:textStyle="bold"
android:textColor="@android:color/white"
android:textSize="12dp"/>
<TextView
android:id="@+id/uploadBandwith"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:gravity="right|center_vertical"
android:textColor="@android:color/white"
android:textSize="12dp"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:text="@string/call_stats_download"
android:textColor="@android:color/white"
android:textStyle="bold"
android:textSize="12dp"/>
<TextView
android:id="@+id/downloadBandwith"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:gravity="right|center_vertical"
android:textColor="@android:color/white"
android:textSize="12dp"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:text="@string/call_stats_ice"
android:textStyle="bold"
android:textColor="@android:color/white"
android:textSize="12dp"/>
<TextView
android:id="@+id/ice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:gravity="right|center_vertical"
android:textColor="@android:color/white"
android:textSize="12dp"/>
</TableRow>
</TableLayout>
<ListView
android:id="@+id/accounts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stackFromBottom="true"
android:paddingBottom="10dp"
android:background="@android:color/black"/>
</RelativeLayout>
<RelativeLayout
android:id="@id/handle"

View file

@ -211,9 +211,10 @@
<string name="no_chat_history">Aucun historique de chat.</string>
<string name="call_stats_audio">Audio</string>
<string name="call_stats_video">Vidéo</string>
<string name="call_stats_codec">Codec :</string>
<string name="call_stats_upload">Bande passante envoi :</string>
<string name="call_stats_download">Bande passante reception :</string>
<string name="call_stats_download">Bande passante réception :</string>
<string name="call_stats_ice">Connexion ICE :</string>
<!-- Used by Android to help blind people by describing them images -->

View file

@ -261,6 +261,7 @@
<string name="no_chat_history">No chat history.</string>
<string name="call_stats_audio">Audio</string>
<string name="call_stats_video">Video</string>
<string name="call_stats_codec">Codec:</string>
<string name="call_stats_upload">Upload bandwidth:</string>
<string name="call_stats_download">Download bandwidth:</string>

View file

@ -86,10 +86,12 @@
<CheckBoxPreference
android:key="@string/pref_codec_speex16_key"
android:defaultValue="true"
android:title="@string/pref_codec_speex16"/>
<CheckBoxPreference
android:key="@string/pref_codec_speex8_key"
android:defaultValue="true"
android:title="@string/pref_codec_speex8"/>
<CheckBoxPreference
@ -118,6 +120,7 @@
<CheckBoxPreference
android:key="@string/pref_codec_gsm_key"
android:defaultValue="true"
android:title="@string/pref_codec_gsm"/>
<CheckBoxPreference
@ -131,14 +134,16 @@
<CheckBoxPreference
android:key="@string/pref_codec_silk16_key"
android:title="@string/pref_codec_silk16"/>
android:title="@string/pref_codec_silk16"/>
<CheckBoxPreference
android:key="@string/pref_codec_pcmu_key"
android:defaultValue="true"
android:title="@string/pref_codec_pcmu"/>
<CheckBoxPreference
android:key="@string/pref_codec_pcma_key"
android:defaultValue="true"
android:title="@string/pref_codec_pcma"/>
</PreferenceScreen>

View file

@ -17,13 +17,9 @@ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import java.util.Timer;
import java.util.TimerTask;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCallStats;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.ui.AvatarWithShadow;
@ -31,7 +27,6 @@ import android.app.Activity;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
@ -45,7 +40,6 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.ViewFlipper;
/**
* @author Sylvain Berfini
@ -59,10 +53,6 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
private static final int conferenceMargin = 20;
private static final int topMarginWithImage = topMargin + rowImageHeight + botMarginIfImage;
private static final int FLIPPER_AVATAR_VIEW = 0;
private static final int FLIPPER_AUDIO_STATS_VIEW = 1;
private Handler mHandler = new Handler();
private RelativeLayout callsList;
private LayoutInflater inflater;
private ViewGroup container;
@ -105,7 +95,7 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
setContactName(callView, lAddress, sipUri, resources);
boolean hide = displayCallStatusIconAndReturnCallPaused(callView, call);
displayOrHideContactPictureAndStats(resources, callView, pictureUri, call, hide);
displayOrHideContactPicture(callView, pictureUri, hide);
setRowBackgroundAndPadding(callView, resources, index, call, !hide);
registerCallDurationTimer(callView, call);
previousCallIsActive = !hide;
@ -154,94 +144,11 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
return isCallPaused || isInConference;
}
private void displayOrHideContactPictureAndStats(Resources resources, LinearLayout callView, Uri pictureUri, LinphoneCall call, boolean hide) {
ViewFlipper flipper = (ViewFlipper) callView.findViewById(R.id.flipper);
flipper.setDisplayedChild(FLIPPER_AVATAR_VIEW);
private void displayOrHideContactPicture(LinearLayout callView, Uri pictureUri, boolean hide) {
AvatarWithShadow contactPicture = (AvatarWithShadow) callView.findViewById(R.id.contactPicture);
if (pictureUri != null) {
LinphoneUtils.setImagePictureFromUri(callView.getContext(), contactPicture.getView(), Uri.parse(pictureUri.toString()), R.drawable.unknown_small);
}
if (hide) {
flipper.setVisibility(View.GONE);
}
if (resources.getBoolean(R.bool.display_call_stats)) {
View audioCallstats = callView.findViewById(R.id.audioCallStats);
if (call != null) {
flipper.setEnabled(true);
initAudioStatsRefresher(call, audioCallstats);
initFlipperListeners(flipper);
}
} else {
flipper.setEnabled(false);
}
}
private void initAudioStatsRefresher(final LinphoneCall call, final View view) {
new Thread(new Runnable() {
@Override
public void run() {
final Timer timer = new Timer();
TimerTask lTask = new TimerTask() {
@Override
public void run() {
if (call == null) {
timer.cancel();
return;
}
final LinphoneCallStats audioStats = call.getAudioStats();
if (audioStats != null) {
mHandler.post(new Runnable() {
@Override
public void run() {
TextView codec = (TextView) view.findViewById(R.id.audioCodec);
TextView dl = (TextView) view.findViewById(R.id.audioDownloadBandwith);
TextView ul = (TextView) view.findViewById(R.id.audioUploadBandwith);
TextView ice = (TextView) view.findViewById(R.id.ice);
if (codec == null || dl == null || ul == null || ice == null) {
timer.cancel();
return;
}
codec.setText(call.getCurrentParamsCopy().getUsedAudioCodec().getMime());
dl.setText(String.valueOf((int) audioStats.getDownloadBandwidth()) + " kbits/s");
ul.setText(String.valueOf((int) audioStats.getUploadBandwidth()) + " kbits/s");
ice.setText(audioStats.getIceState().toString());
}
});
}
}
};
timer.scheduleAtFixedRate(lTask, 0, 1500);
}
}).start();
}
private void initFlipperListeners(final ViewFlipper flipper) {
SwipeListener swipeListener = new SwipeListener() {
int currentView = FLIPPER_AVATAR_VIEW;
@Override
public void onLeftToRightSwipe() {
if (currentView == FLIPPER_AVATAR_VIEW) {
currentView = FLIPPER_AUDIO_STATS_VIEW;
} else {
currentView = FLIPPER_AVATAR_VIEW;
}
flipper.setDisplayedChild(currentView);
}
@Override
public void onRightToLeftSwipe() {
if (currentView == FLIPPER_AUDIO_STATS_VIEW) {
currentView = FLIPPER_AVATAR_VIEW;
} else {
currentView = FLIPPER_AUDIO_STATS_VIEW;
}
flipper.setDisplayedChild(currentView);
}
};
flipper.setOnTouchListener(new SwipeGestureDetector(swipeListener));
}
private void setRowBackgroundAndPadding(LinearLayout callView, Resources resources, int index, LinphoneCall call, boolean active) {

View file

@ -19,12 +19,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCallStats;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.MediaEncryption;
import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.PayloadType;
import org.linphone.ui.SlidingDrawer;
import org.linphone.ui.SlidingDrawer.OnDrawerOpenListener;
@ -44,6 +48,7 @@ import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
@ -55,7 +60,8 @@ public class StatusFragment extends Fragment {
private Handler refreshHandler = new Handler();
private TextView statusText, exit;
private ImageView statusLed, callQuality, encryption, background;
private ListView sliderContent;
private ListView sliderContentAccounts;
private TableLayout callStats;
private SlidingDrawer drawer;
// private LinearLayout allAccountsLed;
private Runnable mCallQualityUpdater;
@ -76,6 +82,7 @@ public class StatusFragment extends Fragment {
encryption = (ImageView) view.findViewById(R.id.encryption);
background = (ImageView) view.findViewById(R.id.background);
// allAccountsLed = (LinearLayout) view.findViewById(R.id.moreStatusLed);
callStats = (TableLayout) view.findViewById(R.id.callStats);
drawer = (SlidingDrawer) view.findViewById(R.id.statusBar);
drawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {
@ -85,7 +92,7 @@ public class StatusFragment extends Fragment {
}
});
sliderContent = (ListView) view.findViewById(R.id.content);
sliderContentAccounts = (ListView) view.findViewById(R.id.accounts);
exit = (TextView) view.findViewById(R.id.exit);
exit.setOnClickListener(new OnClickListener() {
@ -149,8 +156,18 @@ public class StatusFragment extends Fragment {
private void populateSliderContent() {
if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null) {
AccountsListAdapter adapter = new AccountsListAdapter();
sliderContent.setAdapter(adapter);
sliderContentAccounts.setVisibility(View.GONE);
callStats.setVisibility(View.GONE);
if (isInCall && getResources().getBoolean(R.bool.display_call_stats)) {
callStats.setVisibility(View.VISIBLE);
LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
initCallStatsRefresher(call, callStats);
} else if (!isInCall) {
sliderContentAccounts.setVisibility(View.VISIBLE);
AccountsListAdapter adapter = new AccountsListAdapter();
sliderContentAccounts.setAdapter(adapter);
}
}
}
@ -166,7 +183,7 @@ public class StatusFragment extends Fragment {
statusText.setText(getStatusIconText(state));
// setMiniLedsForEachAccount();
populateSliderContent();
sliderContent.invalidate();
sliderContentAccounts.invalidate();
}
});
}
@ -294,10 +311,6 @@ public class StatusFragment extends Fragment {
// We are obviously connected
statusLed.setImageResource(R.drawable.led_connected);
statusText.setText(getString(R.string.status_connected));
if (drawer != null) {
drawer.lock();
}
} else {
exit.setVisibility(View.VISIBLE);
statusText.setVisibility(View.VISIBLE);
@ -431,6 +444,71 @@ public class StatusFragment extends Fragment {
zrtpHack.start();
}
private void initCallStatsRefresher(final LinphoneCall call, final View view) {
new Thread(new Runnable() {
@Override
public void run() {
final Timer timer = new Timer();
TimerTask lTask = new TimerTask() {
@Override
public void run() {
if (call == null) {
timer.cancel();
return;
}
final TextView title = (TextView) view.findViewById(R.id.call_stats_title);
final TextView codec = (TextView) view.findViewById(R.id.codec);
final TextView dl = (TextView) view.findViewById(R.id.downloadBandwith);
final TextView ul = (TextView) view.findViewById(R.id.uploadBandwith);
final TextView ice = (TextView) view.findViewById(R.id.ice);
if (codec == null || dl == null || ul == null || ice == null) {
timer.cancel();
return;
}
if (call.getCurrentParamsCopy().getVideoEnabled()) {
final LinphoneCallStats videoStats = call.getVideoStats();
if (videoStats != null) {
mHandler.post(new Runnable() {
@Override
public void run() {
title.setText(getString(R.string.call_stats_video));
PayloadType payload = call.getCurrentParamsCopy().getUsedVideoCodec();
if (payload != null) {
codec.setText(payload.getMime());
}
dl.setText(String.valueOf((int) videoStats.getDownloadBandwidth()) + " kbits/s");
ul.setText(String.valueOf((int) videoStats.getUploadBandwidth()) + " kbits/s");
ice.setText(videoStats.getIceState().toString());
}
});
}
} else {
final LinphoneCallStats audioStats = call.getAudioStats();
if (audioStats != null) {
mHandler.post(new Runnable() {
@Override
public void run() {
title.setText(getString(R.string.call_stats_audio));
PayloadType payload = call.getCurrentParamsCopy().getUsedAudioCodec();
if (payload != null) {
codec.setText(payload.getMime());
}
dl.setText(String.valueOf((int) audioStats.getDownloadBandwidth()) + " kbits/s");
ul.setText(String.valueOf((int) audioStats.getUploadBandwidth()) + " kbits/s");
ice.setText(audioStats.getIceState().toString());
}
});
}
}
}
};
timer.scheduleAtFixedRate(lTask, 0, 1500);
}
}).start();
}
class AccountsListAdapter extends BaseAdapter {
private SharedPreferences prefs;
private List<CheckBox> checkboxes;