Added call options to incall audio view
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/add_call_over" />
|
||||
<item
|
||||
android:drawable="@drawable/add_call_default" />
|
||||
</selector>
|
Before Width: | Height: | Size: 7 KiB |
BIN
res/drawable/call_state_ringing_default.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
11
res/drawable/options.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/options_over" />
|
||||
<item android:state_enabled="false"
|
||||
android:drawable="@drawable/options_disabled" />
|
||||
<item android:state_selected="true"
|
||||
android:drawable="@drawable/options_selected" />
|
||||
<item
|
||||
android:drawable="@drawable/options_default" />
|
||||
</selector>
|
9
res/drawable/options_add_call.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/options_add_over" />
|
||||
<item android:state_enabled="false"
|
||||
android:drawable="@drawable/options_add_disabled" />
|
||||
<item
|
||||
android:drawable="@drawable/options_add_default" />
|
||||
</selector>
|
BIN
res/drawable/options_add_default.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
res/drawable/options_add_disabled.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
res/drawable/options_add_over.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
res/drawable/options_selected.png
Normal file
After Width: | Height: | Size: 8 KiB |
9
res/drawable/options_transfer.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/options_transfer_over" />
|
||||
<item android:state_enabled="false"
|
||||
android:drawable="@drawable/options_transfer_disabled" />
|
||||
<item
|
||||
android:drawable="@drawable/options_transfer_default" />
|
||||
</selector>
|
BIN
res/drawable/options_transfer_default.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
res/drawable/options_transfer_disabled.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
res/drawable/options_transfer_over.png
Normal file
After Width: | Height: | Size: 6 KiB |
|
@ -3,7 +3,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
<RelativeLayout
|
||||
android:id="@+id/calls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<LinearLayout
|
||||
android:id="@+id/menu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
@ -40,13 +40,81 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="0.5">
|
||||
android:layout_weight="0.5">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:layout_weight="0.25"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:layout_weight="0.25"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:layout_weight="0.25"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/transfer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:src="@drawable/options_transfer"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_weight="0.25" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="0.5">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:layout_weight="0.25"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:layout_weight="0.25"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:layout_weight="0.25"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/addCall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:src="@drawable/options_add_call"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_weight="0.25" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="0.5">
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_switch_video"
|
||||
android:id="@+id/video"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:layout_weight="0.25"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/video_off" />
|
||||
|
@ -55,7 +123,7 @@
|
|||
android:contentDescription="@string/content_description_toggle_micro"
|
||||
android:id="@+id/micro"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:src="@drawable/micro_on"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_weight="0.25"/>
|
||||
|
@ -64,27 +132,26 @@
|
|||
android:contentDescription="@string/content_description_toggle_speaker"
|
||||
android:id="@+id/speaker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:src="@drawable/speaker_off"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_weight="0.25"/>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_add_call"
|
||||
android:id="@+id/addCall"
|
||||
android:id="@+id/options"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/add_call"
|
||||
android:layout_height="75dp"
|
||||
android:src="@drawable/options"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_weight="0.25"/>
|
||||
android:layout_weight="0.25" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="0.5">
|
||||
android:layout_weight="0.5">
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_pause"
|
||||
|
|
|
@ -32,9 +32,9 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Chronometer;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
|
@ -42,12 +42,14 @@ import android.widget.TextView;
|
|||
*/
|
||||
public class AudioCallFragment extends Fragment {
|
||||
private static AudioCallFragment instance;
|
||||
private FrameLayout callsList;
|
||||
private RelativeLayout callsList;
|
||||
private LayoutInflater inflater;
|
||||
private ViewGroup container;
|
||||
private static final int rowHeight = 75; // Value set in active_call.xml
|
||||
private static final int rowImageHeight = 100; // Value set in active_call.xml
|
||||
private static final int rowThickRatio = 85; // Ratio dependent from the image
|
||||
private static final int topMargin = (int) ((rowHeight * rowThickRatio) / 100);
|
||||
private static final int topMarginWithImage = topMargin + rowImageHeight;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
|
@ -57,16 +59,24 @@ public class AudioCallFragment extends Fragment {
|
|||
this.container = container;
|
||||
|
||||
View view = inflater.inflate(R.layout.audio, container, false);
|
||||
callsList = (FrameLayout) view.findViewById(R.id.calls);
|
||||
callsList = (RelativeLayout) view.findViewById(R.id.calls);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void displayCall(Resources resources, LinearLayout callView, LinphoneCall call, int index, boolean hide) {
|
||||
private void displayCall(Resources resources, LinearLayout callView, LinphoneCall call, int index) {
|
||||
String sipUri = call.getRemoteAddress().asStringUriOnly();
|
||||
LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||
Uri pictureUri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, callView.getContext().getContentResolver());
|
||||
|
||||
|
||||
setContactName(callView, lAddress, sipUri, resources);
|
||||
boolean hide = displayCallStatusIconAndReturnCallPaused(callView, call);
|
||||
displayOrHideContactPicture(callView, pictureUri, hide);
|
||||
setRowBackgroundAndPadding(callView, resources, index);
|
||||
registerCallDurationTimer(callView, call);
|
||||
}
|
||||
|
||||
private void setContactName(LinearLayout callView, LinphoneAddress lAddress, String sipUri, Resources resources) {
|
||||
TextView contact = (TextView) callView.findViewById(R.id.contactNameOrNumber);
|
||||
if (lAddress.getDisplayName() == null) {
|
||||
if (resources.getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) {
|
||||
|
@ -77,14 +87,25 @@ public class AudioCallFragment extends Fragment {
|
|||
} else {
|
||||
contact.setText(lAddress.getDisplayName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean displayCallStatusIconAndReturnCallPaused(LinearLayout callView, LinphoneCall call) {
|
||||
boolean isCallPaused;
|
||||
ImageView callState = (ImageView) callView.findViewById(R.id.callStatus);
|
||||
if (call.getState() == State.Paused || call.getState() == State.PausedByRemote) {
|
||||
if (call.getState() == State.Paused || call.getState() == State.PausedByRemote || call.getState() == State.Pausing) {
|
||||
callState.setImageResource(R.drawable.pause_default);
|
||||
isCallPaused = true;
|
||||
} else if (call.getState() == State.OutgoingInit || call.getState() == State.OutgoingProgress || call.getState() == State.OutgoingRinging) {
|
||||
callState.setImageResource(R.drawable.call_state_ringing_default);
|
||||
isCallPaused = false;
|
||||
} else {
|
||||
callState.setImageResource(R.drawable.play_default);
|
||||
isCallPaused = false;
|
||||
}
|
||||
|
||||
return isCallPaused;
|
||||
}
|
||||
|
||||
private void displayOrHideContactPicture(LinearLayout callView, Uri pictureUri, boolean hide) {
|
||||
ImageView contactPicture = (ImageView) callView.findViewById(R.id.contactPicture);
|
||||
if (pictureUri != null) {
|
||||
LinphoneUtils.setImagePictureFromUri(callView.getContext(), contactPicture, Uri.parse(pictureUri.toString()), R.drawable.unknown_small);
|
||||
|
@ -92,15 +113,15 @@ public class AudioCallFragment extends Fragment {
|
|||
if (hide) {
|
||||
contactPicture.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setRowBackgroundAndPadding(LinearLayout callView, Resources resources, int index) {
|
||||
if (index == 0) {
|
||||
callView.findViewById(R.id.row).setBackgroundResource(R.drawable.sel_call_first);
|
||||
} else {
|
||||
callView.findViewById(R.id.row).setBackgroundResource(R.drawable.sel_call);
|
||||
callView.setPadding(0, LinphoneUtils.pixelsToDpi(resources, topMargin * index), 0, 0);
|
||||
}
|
||||
|
||||
registerCallDurationTimer(callView, call);
|
||||
}
|
||||
|
||||
private void registerCallDurationTimer(View v, LinphoneCall call) {
|
||||
|
@ -148,12 +169,11 @@ public class AudioCallFragment extends Fragment {
|
|||
}
|
||||
|
||||
callsList.removeAllViews();
|
||||
int callsNb = LinphoneManager.getLc().getCallsNb();
|
||||
int index = 0;
|
||||
|
||||
for (LinphoneCall call : LinphoneManager.getLc().getCalls()) {
|
||||
LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.active_call, container, false);
|
||||
displayCall(resources, callView, call, index, index != callsNb - 1);
|
||||
displayCall(resources, callView, call, index);
|
||||
callsList.addView(callView);
|
||||
index++;
|
||||
}
|
||||
|
|
|
@ -80,9 +80,8 @@ public class DialerFragment extends Fragment {
|
|||
LinphoneActivity.instance().resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
|
||||
}
|
||||
};
|
||||
mAddContact.setOnClickListener(addContactListener);
|
||||
|
||||
mAddContact.setEnabled(!(LinphoneActivity.isInstanciated() && LinphoneActivity.instance().isInCallLayout()));
|
||||
resetLayout();
|
||||
|
||||
if (getArguments() != null) {
|
||||
String number = getArguments().getString("SipUri");
|
||||
|
|
|
@ -57,7 +57,7 @@ public class InCallActivity extends FragmentActivity implements
|
|||
private Handler mHandler = new Handler();
|
||||
private Handler controlsHandler = new Handler();
|
||||
private Runnable mControls;
|
||||
private ImageView video, micro, speaker, addCall, pause, hangUp, dialer, switchCamera;
|
||||
private ImageView video, micro, speaker, addCall, pause, hangUp, dialer, switchCamera, options, transfer;
|
||||
private StatusFragment status;
|
||||
private AudioCallFragment audioCallFragment;
|
||||
private VideoCallFragment videoCallFragment;
|
||||
|
@ -123,6 +123,12 @@ public class InCallActivity extends FragmentActivity implements
|
|||
addCall = (ImageView) findViewById(R.id.addCall);
|
||||
addCall.setOnClickListener(this);
|
||||
addCall.setEnabled(false);
|
||||
transfer = (ImageView) findViewById(R.id.transfer);
|
||||
transfer.setOnClickListener(this);
|
||||
transfer.setEnabled(false);
|
||||
options = (ImageView) findViewById(R.id.options);
|
||||
options.setOnClickListener(this);
|
||||
options.setEnabled(false);
|
||||
pause = (ImageView) findViewById(R.id.pause);
|
||||
pause.setOnClickListener(this);
|
||||
pause.setEnabled(false);
|
||||
|
@ -142,10 +148,12 @@ public class InCallActivity extends FragmentActivity implements
|
|||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
options.setEnabled(true);
|
||||
video.setEnabled(true);
|
||||
micro.setEnabled(true);
|
||||
speaker.setEnabled(true);
|
||||
addCall.setEnabled(true);
|
||||
transfer.setEnabled(true);
|
||||
pause.setEnabled(true);
|
||||
dialer.setEnabled(true);
|
||||
|
||||
|
@ -220,6 +228,12 @@ public class InCallActivity extends FragmentActivity implements
|
|||
videoCallFragment.switchCamera();
|
||||
}
|
||||
}
|
||||
else if (id == R.id.transfer) {
|
||||
|
||||
}
|
||||
else if (id == R.id.options) {
|
||||
hideOrDisplayCallOptions();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -410,6 +424,94 @@ public class InCallActivity extends FragmentActivity implements
|
|||
switchCamera.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void hideOrDisplayCallOptions() {
|
||||
if (addCall.getVisibility() == View.VISIBLE) {
|
||||
if (getResources().getBoolean(R.bool.disable_animations)) {
|
||||
transfer.setVisibility(View.INVISIBLE);
|
||||
addCall.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
final Animation animAddCall = AnimationUtils.loadAnimation(this, R.anim.slide_out_top_to_bottom);
|
||||
animAddCall.setAnimationListener(new AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
addCall.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
Animation animTransfer = AnimationUtils.loadAnimation(this, R.anim.slide_out_top_to_bottom);
|
||||
animTransfer.setAnimationListener(new AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
transfer.setVisibility(View.INVISIBLE);
|
||||
addCall.startAnimation(animAddCall);
|
||||
}
|
||||
});
|
||||
transfer.startAnimation(animTransfer);
|
||||
}
|
||||
} else {
|
||||
if (getResources().getBoolean(R.bool.disable_animations)) {
|
||||
transfer.setVisibility(View.VISIBLE);
|
||||
addCall.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
final Animation animTransfer = AnimationUtils.loadAnimation(this, R.anim.slide_in_bottom_to_top);
|
||||
animTransfer.setAnimationListener(new AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
transfer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
}
|
||||
});
|
||||
|
||||
Animation animAddCall = AnimationUtils.loadAnimation(this, R.anim.slide_in_bottom_to_top);
|
||||
animAddCall.setAnimationListener(new AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
addCall.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
transfer.startAnimation(animTransfer);
|
||||
}
|
||||
});
|
||||
addCall.startAnimation(animAddCall);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCallRunning(LinphoneCall call)
|
||||
{
|
||||
LinphoneCall.State state = call.getState();
|
||||
|
|