Improved navigation with back button

This commit is contained in:
Sylvain Berfini 2019-06-11 10:57:18 +02:00
parent 0c29c26685
commit 6ddbf29bca
2 changed files with 20 additions and 36 deletions

View file

@ -51,24 +51,18 @@ public class ChatActivity extends MainActivity {
Fragment currentFragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
if (currentFragment == null) {
if (getIntent() != null && getIntent().getExtras() != null) {
Bundle extras = getIntent().getExtras();
if (isTablet() || !extras.containsKey("RemoteSipUri")) {
showChatRooms();
}
handleRemoteSipUriInIntentExtras(extras);
if (getIntent() != null && getIntent().getExtras() != null) {
handleIntentExtras(getIntent());
// Remove the SIP Uri from the intent so a click on chat button will go back to list
getIntent().removeExtra("RemoteSipUri");
} else {
showChatRooms();
if (isTablet()) {
showEmptyChildFragment();
}
}
}
handleIntentExtras(getIntent());
}
@Override
@ -123,6 +117,11 @@ public class ChatActivity extends MainActivity {
private void handleIntentExtras(Intent intent) {
if (intent == null) return;
Fragment currentFragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
if (currentFragment == null || !(currentFragment instanceof ChatRoomsFragment)) {
showChatRooms();
}
String sharedText = null;
String sharedFiles = null;
@ -152,13 +151,6 @@ public class ChatActivity extends MainActivity {
if (intent.getExtras() != null) {
Bundle extras = intent.getExtras();
handleRemoteSipUriInIntentExtras(extras);
} else {
// If there is no extras, make sure the chat rooms list fragment is displayed
Fragment currentFragment =
getFragmentManager().findFragmentById(R.id.fragmentContainer);
if (currentFragment == null || !(currentFragment instanceof ChatRoomsFragment)) {
showChatRooms();
}
}
}
@ -193,7 +185,7 @@ public class ChatActivity extends MainActivity {
remoteAddress = Factory.instance().createAddress(remoteSipUri);
}
// Don't make it a child on smartphones to have a working back button
showChatRoom(localAddress, remoteAddress, isTablet());
showChatRoom(localAddress, remoteAddress);
}
}

View file

@ -48,27 +48,18 @@ public class ContactsActivity extends MainActivity {
super.onStart();
Fragment currentFragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
if (currentFragment == null) {
showContactsList();
if (getIntent() != null && getIntent().getExtras() != null) {
Bundle extras = getIntent().getExtras();
if (isTablet() || !extras.containsKey("Contact")) {
showContactsList();
}
handleIntentExtras(extras);
} else if (getIntent() != null && getIntent().getData() != null) {
Uri uri = getIntent().getData();
if (isTablet()) {
showContactsList();
}
Bundle bundle = new Bundle();
bundle.putString("uri", uri.toString());
bundle.putString("ContactUri", uri.toString());
handleIntentExtras(bundle);
} else {
showContactsList();
if (isTablet()) {
showEmptyChildFragment();
}
@ -91,7 +82,7 @@ public class ContactsActivity extends MainActivity {
}
if (intent.getData() != null) {
bundle.putString("uri", intent.getDataString());
bundle.putString("ContactUri", intent.getDataString());
}
handleIntentExtras(bundle);
@ -134,27 +125,28 @@ public class ContactsActivity extends MainActivity {
private void handleIntentExtras(Bundle extras) {
if (extras == null) return;
if (isTablet()) {
Fragment currentFragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
if (currentFragment == null || !(currentFragment instanceof ContactsFragment)) {
showContactsList();
}
if (extras.containsKey("uri")) {
String uri = extras.getString("uri");
if (extras.containsKey("ContactUri")) {
String uri = extras.getString("ContactUri");
Uri contactUri = Uri.parse(uri);
String id = ContactsManager.getInstance().getAndroidContactIdFromUri(contactUri);
LinphoneContact linphoneContact =
ContactsManager.getInstance().findContactFromAndroidId(id);
if (linphoneContact != null) {
showContactDetails(linphoneContact, isTablet());
showContactDetails(linphoneContact);
}
} else if (extras.containsKey("Contact")) {
LinphoneContact contact = (LinphoneContact) extras.get("Contact");
if (extras.containsKey("Edit")) {
showContactEdit(contact, extras, isTablet());
showContactEdit(contact, extras, true);
} else {
showContactDetails(contact, isTablet());
showContactDetails(contact);
}
} else if (extras.containsKey("CreateOrEdit")) {
mEditOnClick = extras.getBoolean("CreateOrEdit");