Revert to using a chat fragment, but load it in a separated activity on phones to still have the rotation feature

This commit is contained in:
Sylvain Berfini 2015-03-13 14:23:03 +01:00
parent 459ba85533
commit af7048f125
6 changed files with 1160 additions and 1069 deletions

View file

@ -95,7 +95,8 @@
android:visibility="gone" android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.33" /> android:layout_weight="0.33"
android:paddingBottom="10dp" />
</LinearLayout> </LinearLayout>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragmentContainer"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -33,7 +33,8 @@ public enum FragmentsAvailable {
ABOUT_INSTEAD_OF_CHAT, ABOUT_INSTEAD_OF_CHAT,
ACCOUNT_SETTINGS, ACCOUNT_SETTINGS,
SETTINGS, SETTINGS,
CHATLIST; CHATLIST,
CHAT;
public boolean shouldAnimate() { public boolean shouldAnimate() {
return true; return true;
@ -71,6 +72,9 @@ public enum FragmentsAvailable {
case ACCOUNT_SETTINGS: case ACCOUNT_SETTINGS:
return SETTINGS.isRightOf(fragment) || fragment == SETTINGS; return SETTINGS.isRightOf(fragment) || fragment == SETTINGS;
case CHAT:
return CHATLIST.isRightOf(fragment) || fragment == CHATLIST;
default: default:
return false; return false;
} }
@ -87,6 +91,9 @@ public enum FragmentsAvailable {
case EDIT_CONTACT: case EDIT_CONTACT:
return fragment == CONTACT || fragment == CONTACTS; return fragment == CONTACT || fragment == CONTACTS;
case CHAT:
return fragment == CHATLIST;
default: default:
return false; return false;
} }

View file

@ -314,9 +314,8 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
changeCurrentFragment(newFragmentType, extras, false); changeCurrentFragment(newFragmentType, extras, false);
} }
@SuppressWarnings("incomplete-switch")
private void changeCurrentFragment(FragmentsAvailable newFragmentType, Bundle extras, boolean withoutAnimation) { private void changeCurrentFragment(FragmentsAvailable newFragmentType, Bundle extras, boolean withoutAnimation) {
if (newFragmentType == currentFragment) { if (newFragmentType == currentFragment && newFragmentType != FragmentsAvailable.CHAT) {
return; return;
} }
nextFragment = newFragmentType; nextFragment = newFragmentType;
@ -382,6 +381,11 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
newFragment = new ChatListFragment(); newFragment = new ChatListFragment();
messageListFragment = new Fragment(); messageListFragment = new Fragment();
break; break;
case CHAT:
newFragment = new ChatFragment();
break;
default:
break;
} }
if (newFragment != null) { if (newFragment != null) {
@ -610,14 +614,32 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
String displayName = lAddress.getDisplayName(); String displayName = lAddress.getDisplayName();
String pictureUri = uri == null ? null : uri.toString(); String pictureUri = uri == null ? null : uri.toString();
Intent intent = new Intent(this, ChatActivity.class); if (currentFragment == FragmentsAvailable.CHATLIST || currentFragment == FragmentsAvailable.CHAT) {
intent.putExtra("SipUri", sipUri); if (isTablet()) {
if (lAddress.getDisplayName() != null) { Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
intent.putExtra("DisplayName", displayName); if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT) {
intent.putExtra("PictureUri", pictureUri); ChatFragment chatFragment = (ChatFragment) fragment2;
chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri);
} else {
Bundle extras = new Bundle();
extras.putString("SipUri", sipUri);
if (lAddress.getDisplayName() != null) {
extras.putString("DisplayName", displayName);
extras.putString("PictureUri", pictureUri);
}
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
}
} else {
Intent intent = new Intent(this, ChatActivity.class);
intent.putExtra("SipUri", sipUri);
if (lAddress.getDisplayName() != null) {
intent.putExtra("DisplayName", displayName);
intent.putExtra("PictureUri", pictureUri);
}
startOrientationSensor();
startActivityForResult(intent, CHAT_ACTIVITY);
}
} }
startOrientationSensor();
startActivityForResult(intent, CHAT_ACTIVITY);
LinphoneService.instance().resetMessageNotifCount(); LinphoneService.instance().resetMessageNotifCount();
LinphoneService.instance().removeMessageNotification(); LinphoneService.instance().removeMessageNotification();
@ -698,6 +720,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
aboutSettings.setSelected(true); aboutSettings.setSelected(true);
break; break;
case CHATLIST: case CHATLIST:
case CHAT:
chat.setSelected(true); chat.setSelected(true);
break; break;
} }