Code improvements + keep dialer number upon rotation
This commit is contained in:
parent
c20ebad33d
commit
085ac38d53
5 changed files with 21 additions and 36 deletions
|
@ -796,7 +796,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
if (mLc.isIncomingInvitePending() && on) {
|
||||
handsetON = true;
|
||||
mLc.acceptCall(mLc.getCurrentCall());
|
||||
LinphoneActivity.instance().startIncallActivity(mLc.getCurrentCall());
|
||||
LinphoneActivity.instance().startIncallActivity();
|
||||
} else if (on && CallActivity.isInstanciated()) {
|
||||
handsetON = true;
|
||||
CallActivity.instance().setSpeakerEnabled(true);
|
||||
|
@ -1177,7 +1177,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
if (LinphoneManager.getInstance() != null) {
|
||||
LinphoneManager.getInstance().routeAudioToReceiver();
|
||||
if (LinphoneActivity.instance() != null)
|
||||
LinphoneActivity.instance().startIncallActivity(call);
|
||||
LinphoneActivity.instance().startIncallActivity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -529,13 +529,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
transaction.replace(R.id.fragmentContainer2, new EmptyFragment());
|
||||
}
|
||||
|
||||
/*if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
|
||||
if (newFragmentType.isRightOf(currentFragment)) {
|
||||
transaction.setCustomAnimations(R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left, R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right);
|
||||
} else {
|
||||
transaction.setCustomAnimations(R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right, R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left);
|
||||
}
|
||||
}*/
|
||||
transaction.replace(R.id.fragmentContainer, newFragment);
|
||||
}
|
||||
transaction.commitAllowingStateLoss();
|
||||
|
@ -558,7 +551,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
}
|
||||
|
||||
public void displayHistoryDetail(String sipUri, CallLog log) {
|
||||
Address lAddress = null;
|
||||
Address lAddress;
|
||||
LinphoneContact c = null;
|
||||
|
||||
lAddress = Factory.instance().createAddress(sipUri);
|
||||
|
@ -911,13 +904,15 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
}
|
||||
}
|
||||
|
||||
public void updateDialerFragment(DialerFragment fragment) {
|
||||
public void updateDialerFragment() {
|
||||
// Hack to maintain soft input flags
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
}
|
||||
|
||||
public void goToDialerFragment() {
|
||||
changeCurrentFragment(FragmentsAvailable.DIALER, null);
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("SipUri", "");
|
||||
changeCurrentFragment(FragmentsAvailable.DIALER, extras);
|
||||
dialer_selected.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
@ -937,7 +932,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("Account", accountNumber);
|
||||
changeCurrentFragment(FragmentsAvailable.ACCOUNT_SETTINGS, bundle);
|
||||
//settings.setSelected(true);
|
||||
}
|
||||
|
||||
public StatusFragment getStatusFragment() {
|
||||
|
@ -973,7 +967,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
LayoutInflater inflater = getLayoutInflater();
|
||||
View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot));
|
||||
|
||||
TextView toastText = (TextView) layout.findViewById(R.id.toastMessage);
|
||||
TextView toastText = layout.findViewById(R.id.toastMessage);
|
||||
toastText.setText(message);
|
||||
|
||||
final Toast toast = new Toast(getApplicationContext());
|
||||
|
@ -1027,7 +1021,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
LinphoneManager.getInstance().newOutgoingCall(address);
|
||||
}
|
||||
|
||||
public void startIncallActivity(Call currentCall) {
|
||||
public void startIncallActivity() {
|
||||
Intent intent = new Intent(this, CallActivity.class);
|
||||
startOrientationSensor();
|
||||
startActivityForResult(intent, CALL_ACTIVITY);
|
||||
|
@ -1090,14 +1084,14 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
selectMenu(FragmentsAvailable.DIALER);
|
||||
DialerFragment dialerFragment = DialerFragment.instance();
|
||||
if (dialerFragment != null) {
|
||||
((DialerFragment) dialerFragment).resetLayout(callTransfer);
|
||||
(dialerFragment).resetLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public void resetClassicMenuLayoutAndGoBackToCallIfStillRunning() {
|
||||
DialerFragment dialerFragment = DialerFragment.instance();
|
||||
if (dialerFragment != null) {
|
||||
((DialerFragment) dialerFragment).resetLayout(true);
|
||||
(dialerFragment).resetLayout();
|
||||
}
|
||||
|
||||
if (LinphoneManager.isInstanciated() && LinphoneManager.getLc().getCallsNb() > 0) {
|
||||
|
@ -1105,7 +1099,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
if (call.getState() == Call.State.IncomingReceived) {
|
||||
startActivity(new Intent(LinphoneActivity.this, CallIncomingActivity.class));
|
||||
} else {
|
||||
startIncallActivity(call);
|
||||
startIncallActivity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1423,7 +1417,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
} else if (onCallStateChanged == State.OutgoingInit || onCallStateChanged == State.OutgoingProgress || onCallStateChanged == State.OutgoingRinging) {
|
||||
startActivity(new Intent(this, CallOutgoingActivity.class));
|
||||
} else {
|
||||
startIncallActivity(call);
|
||||
startIncallActivity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1503,7 +1497,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
} else if (extras != null && extras.getBoolean("Notification", false)) {
|
||||
if (LinphoneManager.getLc().getCallsNb() > 0) {
|
||||
Call call = LinphoneManager.getLc().getCalls()[0];
|
||||
startIncallActivity(call);
|
||||
startIncallActivity();
|
||||
}
|
||||
} else if (extras != null && extras.getBoolean("StartCall", false)) {
|
||||
if (CallActivity.isInstanciated()) {
|
||||
|
|
|
@ -321,7 +321,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
|||
return;
|
||||
}
|
||||
LinphoneManager.getInstance().routeAudioToReceiver();
|
||||
LinphoneActivity.instance().startIncallActivity(mCall);
|
||||
LinphoneActivity.instance().startIncallActivity();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
|
|||
if (!LinphoneActivity.isInstanciated()) {
|
||||
return;
|
||||
}
|
||||
LinphoneActivity.instance().startIncallActivity(mCall);
|
||||
LinphoneActivity.instance().startIncallActivity();
|
||||
finish();
|
||||
return;
|
||||
} else if (state == State.Error) {
|
||||
|
@ -171,7 +171,7 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
|
|||
if (!LinphoneActivity.isInstanciated()) {
|
||||
return;
|
||||
}
|
||||
LinphoneActivity.instance().startIncallActivity(mCall);
|
||||
LinphoneActivity.instance().startIncallActivity();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ public class DialerFragment extends Fragment {
|
|||
private CallButton mCall;
|
||||
private ImageView mAddContact;
|
||||
private OnClickListener addContactListener, cancelListener, transferListener;
|
||||
private boolean shouldEmptyAddressField = true;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
|
@ -114,13 +113,11 @@ public class DialerFragment extends Fragment {
|
|||
}
|
||||
};
|
||||
|
||||
resetLayout(isCallTransferOngoing);
|
||||
resetLayout();
|
||||
|
||||
if (getArguments() != null) {
|
||||
shouldEmptyAddressField = false;
|
||||
String number = getArguments().getString("SipUri");
|
||||
String displayName = getArguments().getString("DisplayName");
|
||||
String photo = getArguments().getString("PhotoUri");
|
||||
mAddress.setText(number);
|
||||
if (displayName != null) {
|
||||
mAddress.setDisplayedName(displayName);
|
||||
|
@ -152,7 +149,7 @@ public class DialerFragment extends Fragment {
|
|||
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.DIALER);
|
||||
LinphoneActivity.instance().updateDialerFragment(this);
|
||||
LinphoneActivity.instance().updateDialerFragment();
|
||||
LinphoneActivity.instance().showStatusBar();
|
||||
}
|
||||
|
||||
|
@ -163,12 +160,7 @@ public class DialerFragment extends Fragment {
|
|||
((LinearLayout) numpad).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (shouldEmptyAddressField) {
|
||||
mAddress.setText("");
|
||||
} else {
|
||||
shouldEmptyAddressField = true;
|
||||
}
|
||||
resetLayout(isCallTransferOngoing);
|
||||
resetLayout();
|
||||
|
||||
String addressWaitingToBeCalled = LinphoneActivity.instance().mAddressWaitingToBeCalled;
|
||||
if (addressWaitingToBeCalled != null) {
|
||||
|
@ -180,7 +172,7 @@ public class DialerFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
public void resetLayout(boolean callTransfer) {
|
||||
public void resetLayout() {
|
||||
if (!LinphoneActivity.isInstanciated()) {
|
||||
return;
|
||||
}
|
||||
|
@ -219,7 +211,6 @@ public class DialerFragment extends Fragment {
|
|||
}
|
||||
|
||||
public void displayTextInAddressBar(String numberOrSipAddress) {
|
||||
shouldEmptyAddressField = false;
|
||||
mAddress.setText(numberOrSipAddress);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue