Fix issue with incall dialer view

This commit is contained in:
Sylvain Berfini 2012-07-24 13:58:32 +02:00
parent 6db9cffc82
commit 427ed76520
4 changed files with 21 additions and 18 deletions

View file

@ -69,7 +69,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
newContact = (ImageView) view.findViewById(R.id.newContact); newContact = (ImageView) view.findViewById(R.id.newContact);
newContact.setOnClickListener(this); newContact.setOnClickListener(this);
newContact.setEnabled(!LinphoneActivity.instance().isInCallLayout()); newContact.setEnabled(LinphoneManager.getLc().getCallsNb() == 0);
allContacts.setEnabled(onlyDisplayLinphoneContacts); allContacts.setEnabled(onlyDisplayLinphoneContacts);
linphoneContacts.setEnabled(!allContacts.isEnabled()); linphoneContacts.setEnabled(!allContacts.isEnabled());

View file

@ -23,6 +23,7 @@ import org.linphone.ui.AddressText;
import org.linphone.ui.CallButton; import org.linphone.ui.CallButton;
import org.linphone.ui.EraseButton; import org.linphone.ui.EraseButton;
import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -57,7 +58,7 @@ public class DialerFragment extends Fragment {
mCall = (CallButton) view.findViewById(R.id.Call); mCall = (CallButton) view.findViewById(R.id.Call);
mCall.setAddressWidget(mAddress); mCall.setAddressWidget(mAddress);
if (LinphoneActivity.isInstanciated() && LinphoneActivity.instance().isInCallLayout()) { if (LinphoneActivity.isInstanciated() && LinphoneManager.getLc().getCallsNb() > 0) {
mCall.setImageResource(R.drawable.plus); mCall.setImageResource(R.drawable.plus);
} else { } else {
mCall.setImageResource(R.drawable.call); mCall.setImageResource(R.drawable.call);
@ -81,7 +82,7 @@ public class DialerFragment extends Fragment {
LinphoneActivity.instance().resetClassicMenuLayoutAndGoBackToCallIfStillRunning(); LinphoneActivity.instance().resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
} }
}; };
mAddContact.setEnabled(!(LinphoneActivity.isInstanciated() && LinphoneActivity.instance().isInCallLayout())); mAddContact.setEnabled(!(LinphoneActivity.isInstanciated() && LinphoneManager.getLc().getCallsNb() > 0));
resetLayout(); resetLayout();
if (getArguments() != null) { if (getArguments() != null) {
@ -107,6 +108,12 @@ public class DialerFragment extends Fragment {
return instance; return instance;
} }
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
LinphoneActivity.instance().updateDialerFragment(this);
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
@ -114,10 +121,11 @@ public class DialerFragment extends Fragment {
LinphoneActivity.instance().selectMenu(FragmentsAvailable.DIALER); LinphoneActivity.instance().selectMenu(FragmentsAvailable.DIALER);
LinphoneActivity.instance().updateDialerFragment(this); LinphoneActivity.instance().updateDialerFragment(this);
} }
resetLayout();
} }
public void resetLayout() { public void resetLayout() {
if (LinphoneActivity.instance().isInCallLayout()) { if (LinphoneManager.getLc().getCallsNb() > 0) {
mCall.setImageResource(R.drawable.plus); mCall.setImageResource(R.drawable.plus);
mAddress.setText(""); mAddress.setText("");
mAddContact.setImageResource(R.drawable.cancel); mAddContact.setImageResource(R.drawable.cancel);

View file

@ -84,7 +84,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
private SavedState dialerSavedState; private SavedState dialerSavedState;
private ChatStorage chatStorage; private ChatStorage chatStorage;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private boolean isInCallLayout = false;
private List<Contact> contactList, sipContactList; private List<Contact> contactList, sipContactList;
private Cursor contactCursor, sipContactCursor; private Cursor contactCursor, sipContactCursor;
@ -606,16 +605,16 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
} }
private void initInCallMenuLayout() { private void initInCallMenuLayout() {
isInCallLayout = true;
selectMenu(FragmentsAvailable.DIALER); selectMenu(FragmentsAvailable.DIALER);
((DialerFragment) dialerFragment).resetLayout(); if (dialerFragment != null) {
((DialerFragment) dialerFragment).resetLayout();
}
} }
public void resetClassicMenuLayoutAndGoBackToCallIfStillRunning() { public void resetClassicMenuLayoutAndGoBackToCallIfStillRunning() {
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
isInCallLayout = false;
if (dialerFragment != null) { if (dialerFragment != null) {
((DialerFragment) dialerFragment).resetLayout(); ((DialerFragment) dialerFragment).resetLayout();
} }
@ -632,10 +631,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
}); });
} }
public boolean isInCallLayout() {
return isInCallLayout;
}
public FragmentsAvailable getCurrentFragment() { public FragmentsAvailable getCurrentFragment() {
return currentFragment; return currentFragment;
} }

View file

@ -77,11 +77,11 @@ public class Digit extends Button implements AddressAware {
} }
private class DialKeyListener implements OnClickListener, OnTouchListener, OnLongClickListener { private class DialKeyListener implements OnClickListener, OnTouchListener, OnLongClickListener {
final CharSequence mKeyCode; final char mKeyCode;
boolean mIsDtmfStarted; boolean mIsDtmfStarted;
DialKeyListener() { DialKeyListener() {
mKeyCode = Digit.this.getText().subSequence(0, 1); mKeyCode = Digit.this.getText().subSequence(0, 1).charAt(0);
} }
private boolean linphoneServiceReady() { private boolean linphoneServiceReady() {
@ -100,7 +100,7 @@ public class Digit extends Button implements AddressAware {
lc.stopDtmf(); lc.stopDtmf();
mIsDtmfStarted =false; mIsDtmfStarted =false;
if (lc.isIncall()) { if (lc.isIncall()) {
lc.sendDtmf(mKeyCode.charAt(0)); lc.sendDtmf(mKeyCode);
} }
} }
@ -110,7 +110,7 @@ public class Digit extends Button implements AddressAware {
lBegin = mAddress.length(); lBegin = mAddress.length();
} }
if (lBegin >=0) { if (lBegin >=0) {
mAddress.getEditableText().insert(lBegin,mKeyCode); mAddress.getEditableText().insert(lBegin,String.valueOf(mKeyCode));
} }
} }
} }
@ -121,7 +121,7 @@ public class Digit extends Button implements AddressAware {
LinphoneCore lc = LinphoneManager.getLc(); LinphoneCore lc = LinphoneManager.getLc();
if (event.getAction() == MotionEvent.ACTION_DOWN && !mIsDtmfStarted) { if (event.getAction() == MotionEvent.ACTION_DOWN && !mIsDtmfStarted) {
LinphoneManager.getInstance().playDtmf(getContext().getContentResolver(), mKeyCode.charAt(0)); LinphoneManager.getInstance().playDtmf(getContext().getContentResolver(), mKeyCode);
mIsDtmfStarted=true; mIsDtmfStarted=true;
} else { } else {
if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getAction() == MotionEvent.ACTION_UP) {