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.content.res.Resources;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Chronometer;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -92,6 +94,23 @@ public class AudioCallFragment extends Fragment {
|
||||||
} else {
|
} else {
|
||||||
callView.findViewById(R.id.row).setBackgroundResource(R.drawable.sel_call);
|
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
|
@Override
|
||||||
|
@ -119,6 +138,10 @@ public class AudioCallFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshCallList(Resources resources) {
|
public void refreshCallList(Resources resources) {
|
||||||
|
if (callsList == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
callsList.removeAllViews();
|
callsList.removeAllViews();
|
||||||
int callsNb = LinphoneManager.getLc().getCallsNb();
|
int callsNb = LinphoneManager.getLc().getCallsNb();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
|
@ -124,6 +124,7 @@ public class DialerFragment extends Fragment {
|
||||||
mAddContact.setOnClickListener(cancelListener);
|
mAddContact.setOnClickListener(cancelListener);
|
||||||
} else {
|
} else {
|
||||||
mCall.setImageResource(R.drawable.call);
|
mCall.setImageResource(R.drawable.call);
|
||||||
|
mAddContact.setEnabled(true);
|
||||||
mAddContact.setImageResource(R.drawable.add_contact);
|
mAddContact.setImageResource(R.drawable.add_contact);
|
||||||
mAddContact.setOnClickListener(addContactListener);
|
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.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnCallEncryptionChangedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnCallEncryptionChangedListener;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
||||||
|
@ -28,8 +30,10 @@ import org.linphone.core.LinphoneCallParams;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
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;
|
||||||
import android.view.animation.Animation.AnimationListener;
|
import android.view.animation.Animation.AnimationListener;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
|
import android.widget.Chronometer;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
@ -62,6 +67,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
private VideoCallFragment videoCallFragment;
|
private VideoCallFragment videoCallFragment;
|
||||||
private boolean isSpeakerEnabled = false, isMicMuted = false, isVideoEnabled = false;
|
private boolean isSpeakerEnabled = false, isMicMuted = false, isVideoEnabled = false;
|
||||||
private LinearLayout mControlsLayout;
|
private LinearLayout mControlsLayout;
|
||||||
|
private Set<Chronometer> mChronometers = new HashSet<Chronometer>();
|
||||||
|
|
||||||
static final boolean isInstanciated() {
|
static final boolean isInstanciated() {
|
||||||
return instance != null;
|
return instance != null;
|
||||||
|
@ -148,11 +154,15 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
pause.setEnabled(true);
|
pause.setEnabled(true);
|
||||||
dialer.setEnabled(true);
|
dialer.setEnabled(true);
|
||||||
|
|
||||||
|
if (!isVideoActivatedInSettings()) {
|
||||||
|
video.setEnabled(false);
|
||||||
|
} else {
|
||||||
if (isVideoEnabled) {
|
if (isVideoEnabled) {
|
||||||
video.setImageResource(R.drawable.video_on);
|
video.setImageResource(R.drawable.video_on);
|
||||||
} else {
|
} else {
|
||||||
video.setImageResource(R.drawable.video_off);
|
video.setImageResource(R.drawable.video_off);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isSpeakerEnabled) {
|
if (isSpeakerEnabled) {
|
||||||
speaker.setImageResource(R.drawable.speaker_on);
|
speaker.setImageResource(R.drawable.speaker_on);
|
||||||
|
@ -173,6 +183,12 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
status = statusFragment;
|
status = statusFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isVideoActivatedInSettings() {
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
boolean settingsVideoEnabled = prefs.getBoolean(getString(R.string.pref_video), false);
|
||||||
|
return settingsVideoEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
int id = v.getId();
|
int id = v.getId();
|
||||||
|
|
Loading…
Reference in a new issue