Improved navigation with back button
This commit is contained in:
parent
0c29c26685
commit
6ddbf29bca
2 changed files with 20 additions and 36 deletions
|
@ -51,24 +51,18 @@ public class ChatActivity extends MainActivity {
|
||||||
|
|
||||||
Fragment currentFragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
|
Fragment currentFragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
|
||||||
if (currentFragment == null) {
|
if (currentFragment == null) {
|
||||||
if (getIntent() != null && getIntent().getExtras() != null) {
|
showChatRooms();
|
||||||
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
|
// Remove the SIP Uri from the intent so a click on chat button will go back to list
|
||||||
getIntent().removeExtra("RemoteSipUri");
|
getIntent().removeExtra("RemoteSipUri");
|
||||||
} else {
|
} else {
|
||||||
showChatRooms();
|
|
||||||
if (isTablet()) {
|
if (isTablet()) {
|
||||||
showEmptyChildFragment();
|
showEmptyChildFragment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleIntentExtras(getIntent());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,6 +117,11 @@ public class ChatActivity extends MainActivity {
|
||||||
private void handleIntentExtras(Intent intent) {
|
private void handleIntentExtras(Intent intent) {
|
||||||
if (intent == null) return;
|
if (intent == null) return;
|
||||||
|
|
||||||
|
Fragment currentFragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
|
||||||
|
if (currentFragment == null || !(currentFragment instanceof ChatRoomsFragment)) {
|
||||||
|
showChatRooms();
|
||||||
|
}
|
||||||
|
|
||||||
String sharedText = null;
|
String sharedText = null;
|
||||||
String sharedFiles = null;
|
String sharedFiles = null;
|
||||||
|
|
||||||
|
@ -152,13 +151,6 @@ public class ChatActivity extends MainActivity {
|
||||||
if (intent.getExtras() != null) {
|
if (intent.getExtras() != null) {
|
||||||
Bundle extras = intent.getExtras();
|
Bundle extras = intent.getExtras();
|
||||||
handleRemoteSipUriInIntentExtras(extras);
|
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);
|
remoteAddress = Factory.instance().createAddress(remoteSipUri);
|
||||||
}
|
}
|
||||||
// Don't make it a child on smartphones to have a working back button
|
// Don't make it a child on smartphones to have a working back button
|
||||||
showChatRoom(localAddress, remoteAddress, isTablet());
|
showChatRoom(localAddress, remoteAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,27 +48,18 @@ public class ContactsActivity extends MainActivity {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
Fragment currentFragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
|
Fragment currentFragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
|
||||||
|
|
||||||
if (currentFragment == null) {
|
if (currentFragment == null) {
|
||||||
|
showContactsList();
|
||||||
|
|
||||||
if (getIntent() != null && getIntent().getExtras() != null) {
|
if (getIntent() != null && getIntent().getExtras() != null) {
|
||||||
Bundle extras = getIntent().getExtras();
|
Bundle extras = getIntent().getExtras();
|
||||||
if (isTablet() || !extras.containsKey("Contact")) {
|
|
||||||
showContactsList();
|
|
||||||
}
|
|
||||||
handleIntentExtras(extras);
|
handleIntentExtras(extras);
|
||||||
|
|
||||||
} else if (getIntent() != null && getIntent().getData() != null) {
|
} else if (getIntent() != null && getIntent().getData() != null) {
|
||||||
Uri uri = getIntent().getData();
|
Uri uri = getIntent().getData();
|
||||||
|
|
||||||
if (isTablet()) {
|
|
||||||
showContactsList();
|
|
||||||
}
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("uri", uri.toString());
|
bundle.putString("ContactUri", uri.toString());
|
||||||
handleIntentExtras(bundle);
|
handleIntentExtras(bundle);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
showContactsList();
|
|
||||||
if (isTablet()) {
|
if (isTablet()) {
|
||||||
showEmptyChildFragment();
|
showEmptyChildFragment();
|
||||||
}
|
}
|
||||||
|
@ -91,7 +82,7 @@ public class ContactsActivity extends MainActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intent.getData() != null) {
|
if (intent.getData() != null) {
|
||||||
bundle.putString("uri", intent.getDataString());
|
bundle.putString("ContactUri", intent.getDataString());
|
||||||
}
|
}
|
||||||
|
|
||||||
handleIntentExtras(bundle);
|
handleIntentExtras(bundle);
|
||||||
|
@ -134,27 +125,28 @@ public class ContactsActivity extends MainActivity {
|
||||||
private void handleIntentExtras(Bundle extras) {
|
private void handleIntentExtras(Bundle extras) {
|
||||||
if (extras == null) return;
|
if (extras == null) return;
|
||||||
|
|
||||||
if (isTablet()) {
|
Fragment currentFragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
|
||||||
|
if (currentFragment == null || !(currentFragment instanceof ContactsFragment)) {
|
||||||
showContactsList();
|
showContactsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extras.containsKey("uri")) {
|
if (extras.containsKey("ContactUri")) {
|
||||||
String uri = extras.getString("uri");
|
String uri = extras.getString("ContactUri");
|
||||||
Uri contactUri = Uri.parse(uri);
|
Uri contactUri = Uri.parse(uri);
|
||||||
String id = ContactsManager.getInstance().getAndroidContactIdFromUri(contactUri);
|
String id = ContactsManager.getInstance().getAndroidContactIdFromUri(contactUri);
|
||||||
|
|
||||||
LinphoneContact linphoneContact =
|
LinphoneContact linphoneContact =
|
||||||
ContactsManager.getInstance().findContactFromAndroidId(id);
|
ContactsManager.getInstance().findContactFromAndroidId(id);
|
||||||
if (linphoneContact != null) {
|
if (linphoneContact != null) {
|
||||||
showContactDetails(linphoneContact, isTablet());
|
showContactDetails(linphoneContact);
|
||||||
}
|
}
|
||||||
} else if (extras.containsKey("Contact")) {
|
} else if (extras.containsKey("Contact")) {
|
||||||
LinphoneContact contact = (LinphoneContact) extras.get("Contact");
|
LinphoneContact contact = (LinphoneContact) extras.get("Contact");
|
||||||
|
|
||||||
if (extras.containsKey("Edit")) {
|
if (extras.containsKey("Edit")) {
|
||||||
showContactEdit(contact, extras, isTablet());
|
showContactEdit(contact, extras, true);
|
||||||
} else {
|
} else {
|
||||||
showContactDetails(contact, isTablet());
|
showContactDetails(contact);
|
||||||
}
|
}
|
||||||
} else if (extras.containsKey("CreateOrEdit")) {
|
} else if (extras.containsKey("CreateOrEdit")) {
|
||||||
mEditOnClick = extras.getBoolean("CreateOrEdit");
|
mEditOnClick = extras.getBoolean("CreateOrEdit");
|
||||||
|
|
Loading…
Reference in a new issue