Chronometer for calls working + some fixes
This commit is contained in:
parent
da4056fb9d
commit
dd64d09eae
3 changed files with 44 additions and 4 deletions
|
@ -26,10 +26,12 @@ import android.app.Activity;
|
|||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Chronometer;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
@ -92,6 +94,23 @@ public class AudioCallFragment extends Fragment {
|
|||
} else {
|
||||
callView.findViewById(R.id.row).setBackgroundResource(R.drawable.sel_call);
|
||||
}
|
||||
|
||||
registerCallDurationTimer(callView, call);
|
||||
}
|
||||
|
||||
private void registerCallDurationTimer(View v, LinphoneCall call) {
|
||||
int callDuration = call.getDuration();
|
||||
if (callDuration == 0 && call.getState() != State.StreamsRunning) {
|
||||
return;
|
||||
}
|
||||
|
||||
Chronometer timer = (Chronometer) v.findViewById(R.id.callTimer);
|
||||
if (timer == null) {
|
||||
throw new IllegalArgumentException("no callee_duration view found");
|
||||
}
|
||||
|
||||
timer.setBase(SystemClock.elapsedRealtime() - 1000 * callDuration);
|
||||
timer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -119,6 +138,10 @@ public class AudioCallFragment extends Fragment {
|
|||
}
|
||||
|
||||
public void refreshCallList(Resources resources) {
|
||||
if (callsList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
callsList.removeAllViews();
|
||||
int callsNb = LinphoneManager.getLc().getCallsNb();
|
||||
int index = 0;
|
||||
|
|
|
@ -124,6 +124,7 @@ public class DialerFragment extends Fragment {
|
|||
mAddContact.setOnClickListener(cancelListener);
|
||||
} else {
|
||||
mCall.setImageResource(R.drawable.call);
|
||||
mAddContact.setEnabled(true);
|
||||
mAddContact.setImageResource(R.drawable.add_contact);
|
||||
mAddContact.setOnClickListener(addContactListener);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@ 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.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.linphone.LinphoneSimpleListener.LinphoneOnCallEncryptionChangedListener;
|
||||
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
||||
|
@ -28,8 +30,10 @@ import org.linphone.core.LinphoneCallParams;
|
|||
import org.linphone.core.LinphoneCore;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
|
@ -39,6 +43,7 @@ import android.view.View.OnClickListener;
|
|||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Chronometer;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
|
@ -62,6 +67,7 @@ public class InCallActivity extends FragmentActivity implements
|
|||
private VideoCallFragment videoCallFragment;
|
||||
private boolean isSpeakerEnabled = false, isMicMuted = false, isVideoEnabled = false;
|
||||
private LinearLayout mControlsLayout;
|
||||
private Set<Chronometer> mChronometers = new HashSet<Chronometer>();
|
||||
|
||||
static final boolean isInstanciated() {
|
||||
return instance != null;
|
||||
|
@ -147,11 +153,15 @@ public class InCallActivity extends FragmentActivity implements
|
|||
addCall.setEnabled(true);
|
||||
pause.setEnabled(true);
|
||||
dialer.setEnabled(true);
|
||||
|
||||
if (isVideoEnabled) {
|
||||
video.setImageResource(R.drawable.video_on);
|
||||
|
||||
if (!isVideoActivatedInSettings()) {
|
||||
video.setEnabled(false);
|
||||
} else {
|
||||
video.setImageResource(R.drawable.video_off);
|
||||
if (isVideoEnabled) {
|
||||
video.setImageResource(R.drawable.video_on);
|
||||
} else {
|
||||
video.setImageResource(R.drawable.video_off);
|
||||
}
|
||||
}
|
||||
|
||||
if (isSpeakerEnabled) {
|
||||
|
@ -172,6 +182,12 @@ public class InCallActivity extends FragmentActivity implements
|
|||
public void updateStatusFragment(StatusFragment statusFragment) {
|
||||
status = statusFragment;
|
||||
}
|
||||
|
||||
private boolean isVideoActivatedInSettings() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean settingsVideoEnabled = prefs.getBoolean(getString(R.string.pref_video), false);
|
||||
return settingsVideoEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
Loading…
Reference in a new issue