Change behavior back button
This commit is contained in:
parent
e8e049083a
commit
1c2419bcd0
2 changed files with 30 additions and 37 deletions
|
@ -293,8 +293,8 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
||||||
contacts = contactsList;
|
contacts = contactsList;
|
||||||
cursor = c;
|
cursor = c;
|
||||||
|
|
||||||
margin = LinphoneUtils.pixelsToDpi(getResources(), 10);
|
margin = LinphoneUtils.pixelsToDpi(LinphoneActivity.instance().getResources(), 10);
|
||||||
bitmapUnknown = BitmapFactory.decodeResource(getResources(), R.drawable.unknown_small);
|
bitmapUnknown = BitmapFactory.decodeResource(LinphoneActivity.instance().getResources(), R.drawable.unknown_small);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
|
|
|
@ -377,13 +377,23 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
R.anim.slide_out_right_to_left);
|
R.anim.slide_out_right_to_left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
getSupportFragmentManager().popBackStackImmediate(newFragmentType.toString(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
|
||||||
} catch (java.lang.IllegalStateException e) {
|
|
||||||
|
|
||||||
|
|
||||||
|
if (newFragmentType == FragmentsAvailable.DIALER
|
||||||
|
|| newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT
|
||||||
|
|| newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS
|
||||||
|
|| newFragmentType == FragmentsAvailable.SETTINGS
|
||||||
|
|| newFragmentType == FragmentsAvailable.CONTACTS
|
||||||
|
|| newFragmentType == FragmentsAvailable.CHATLIST
|
||||||
|
|| newFragmentType == FragmentsAvailable.HISTORY) {
|
||||||
|
try {
|
||||||
|
getSupportFragmentManager().popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
|
} catch (java.lang.IllegalStateException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
transaction.addToBackStack(newFragmentType.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.addToBackStack(newFragmentType.toString());
|
|
||||||
transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString());
|
transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString());
|
||||||
transaction.commitAllowingStateLoss();
|
transaction.commitAllowingStateLoss();
|
||||||
getSupportFragmentManager().executePendingTransactions();
|
getSupportFragmentManager().executePendingTransactions();
|
||||||
|
@ -431,21 +441,24 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
getSupportFragmentManager().popBackStackImmediate(newFragmentType.toString(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
|
||||||
} catch (java.lang.IllegalStateException e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
transaction.addToBackStack(newFragmentType.toString());
|
|
||||||
transaction.replace(R.id.fragmentContainer, newFragment);
|
transaction.replace(R.id.fragmentContainer, newFragment);
|
||||||
}
|
}
|
||||||
transaction.commitAllowingStateLoss();
|
transaction.commitAllowingStateLoss();
|
||||||
getSupportFragmentManager().executePendingTransactions();
|
getSupportFragmentManager().executePendingTransactions();
|
||||||
|
|
||||||
currentFragment = newFragmentType;
|
currentFragment = newFragmentType;
|
||||||
if (currentFragment == FragmentsAvailable.DIALER) {
|
if (newFragmentType == FragmentsAvailable.DIALER
|
||||||
fragmentsHistory.clear();
|
|| newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT
|
||||||
|
|| newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS
|
||||||
|
|| newFragmentType == FragmentsAvailable.SETTINGS
|
||||||
|
|| newFragmentType == FragmentsAvailable.CONTACTS
|
||||||
|
|| newFragmentType == FragmentsAvailable.CHATLIST
|
||||||
|
|| newFragmentType == FragmentsAvailable.HISTORY) {
|
||||||
|
try {
|
||||||
|
getSupportFragmentManager().popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
|
} catch (java.lang.IllegalStateException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fragmentsHistory.add(currentFragment);
|
fragmentsHistory.add(currentFragment);
|
||||||
}
|
}
|
||||||
|
@ -1374,26 +1387,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
if (currentFragment == FragmentsAvailable.SETTINGS) {
|
if (currentFragment == FragmentsAvailable.SETTINGS) {
|
||||||
updateAnimationsState();
|
updateAnimationsState();
|
||||||
}
|
}
|
||||||
|
|
||||||
fragmentsHistory.remove(fragmentsHistory.size() - 1);
|
|
||||||
if (fragmentsHistory.size() > 0) {
|
|
||||||
FragmentsAvailable newFragmentType = fragmentsHistory.get(fragmentsHistory.size() - 1);
|
|
||||||
LinearLayout ll = (LinearLayout) findViewById(R.id.fragmentContainer2);
|
|
||||||
if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment)) {
|
|
||||||
ll.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
if (newFragmentType == FragmentsAvailable.DIALER
|
|
||||||
|| newFragmentType == FragmentsAvailable.ABOUT
|
|
||||||
|| newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT
|
|
||||||
|| newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS
|
|
||||||
|| newFragmentType == FragmentsAvailable.SETTINGS
|
|
||||||
|| newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS) {
|
|
||||||
ll.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
ll.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) {
|
} else if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) {
|
||||||
|
|
Loading…
Reference in a new issue