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