Add chat view landscape
This commit is contained in:
parent
e04a5eaaf4
commit
95ae7734a4
10 changed files with 461 additions and 438 deletions
|
@ -107,6 +107,15 @@
|
|||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="org.linphone.ChatActivity"
|
||||
android:theme="@style/NoTitle"
|
||||
android:windowSoftInputMode="adjustPan|adjustResize"
|
||||
android:launchMode="singleTask">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="org.linphone.setup.SetupActivity"
|
||||
android:theme="@style/NoTitle"
|
||||
|
|
BIN
res/drawable-xhdpi/chat_back_default.9.png
Normal file
BIN
res/drawable-xhdpi/chat_back_default.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
res/drawable-xhdpi/chat_back_over.9.png
Normal file
BIN
res/drawable-xhdpi/chat_back_over.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
8
res/drawable/chat_back.xml
Normal file
8
res/drawable/chat_back.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/chat_back_over" />
|
||||
<item
|
||||
android:drawable="@drawable/chat_back_default" />
|
||||
</selector>
|
||||
|
|
@ -3,7 +3,44 @@
|
|||
xmlns:linphone="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/top_layout"
|
||||
android:background="@drawable/background" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/topbar">
|
||||
|
||||
<TextView
|
||||
android:contentDescription="@string/content_description_back"
|
||||
android:id="@+id/back"
|
||||
android:background="@drawable/chat_back"
|
||||
android:text="@string/button_back"
|
||||
android:gravity="center"
|
||||
android:paddingTop="20dp"
|
||||
android:textColor="@drawable/text_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<TextView
|
||||
android:contentDescription="@string/content_description_mark"
|
||||
android:id="@+id/mark"
|
||||
android:background="@drawable/toolsbar_background"
|
||||
android:gravity="center"
|
||||
android:enabled="false"
|
||||
android:paddingTop="20dp"
|
||||
android:textColor="@drawable/text_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/header"
|
||||
|
@ -14,7 +51,7 @@
|
|||
android:paddingRight="10dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_below="@+id/topbar"
|
||||
android:layout_centerHorizontal="true">
|
||||
|
||||
<org.linphone.ui.AvatarWithShadow
|
||||
|
@ -30,7 +67,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="@color/text_contrast" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -74,6 +110,7 @@
|
|||
android:paddingLeft="10dp" />
|
||||
|
||||
<EditText
|
||||
android:imeOptions="flagNoExtractUi"
|
||||
android:textCursorDrawable="@null"
|
||||
android:id="@+id/message"
|
||||
android:inputType="textMultiLine"
|
||||
|
|
|
@ -301,6 +301,7 @@
|
|||
<string name="button_edit">Modifier</string>
|
||||
<string name="button_cancel">Annuler</string>
|
||||
<string name="button_ok">Valider</string>
|
||||
<string name="button_back">Retour</string>
|
||||
<string name="button_all_contacts">Tous</string>
|
||||
<string name="button_sip_contacts">SIP</string>
|
||||
<string name="button_add_contact">+ Contact</string>
|
||||
|
|
|
@ -303,6 +303,7 @@
|
|||
<string name="button_edit">Edit</string>
|
||||
<string name="button_cancel">Cancel</string>
|
||||
<string name="button_ok">Okay</string>
|
||||
<string name="button_back">Back</string>
|
||||
<string name="button_all_contacts">All</string>
|
||||
<string name="button_sip_contacts">SIP</string>
|
||||
<string name="button_add_contact">New contact</string>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -33,12 +33,7 @@ public enum FragmentsAvailable {
|
|||
ABOUT_INSTEAD_OF_CHAT,
|
||||
ACCOUNT_SETTINGS,
|
||||
SETTINGS,
|
||||
CHATLIST,
|
||||
CHAT;
|
||||
|
||||
public boolean shouldAddToBackStack() {
|
||||
return true;
|
||||
}
|
||||
CHATLIST;
|
||||
|
||||
public boolean shouldAnimate() {
|
||||
return true;
|
||||
|
@ -68,9 +63,6 @@ public enum FragmentsAvailable {
|
|||
case CHATLIST:
|
||||
return DIALER.isRightOf(fragment) || fragment == DIALER;
|
||||
|
||||
case CHAT:
|
||||
return CHATLIST.isRightOf(fragment) || fragment == CHATLIST;
|
||||
|
||||
case ABOUT_INSTEAD_OF_SETTINGS:
|
||||
case SETTINGS:
|
||||
return CHATLIST.isRightOf(fragment) || fragment == CHATLIST || fragment == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT;
|
||||
|
@ -95,9 +87,6 @@ public enum FragmentsAvailable {
|
|||
case EDIT_CONTACT:
|
||||
return fragment == CONTACT || fragment == CONTACTS;
|
||||
|
||||
case CHAT:
|
||||
return fragment == CHATLIST;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
private static final int FIRST_LOGIN_ACTIVITY = 101;
|
||||
private static final int REMOTE_PROVISIONING_LOGIN_ACTIVITY = 102;
|
||||
private static final int CALL_ACTIVITY = 19;
|
||||
private static final int CHAT_ACTIVITY = 21;
|
||||
|
||||
private static LinphoneActivity instance;
|
||||
|
||||
|
@ -104,7 +105,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
private RelativeLayout contacts, history, settings, chat, aboutChat, aboutSettings;
|
||||
private FragmentsAvailable currentFragment, nextFragment;
|
||||
private List<FragmentsAvailable> fragmentsHistory;
|
||||
private Fragment dialerFragment, messageListenerFragment, messageListFragment, friendStatusListenerFragment;
|
||||
private Fragment dialerFragment, messageListFragment, friendStatusListenerFragment;
|
||||
private SavedState dialerSavedState;
|
||||
private boolean preferLinphoneContacts = false, isAnimationDisabled = false, isContactPresenceDisabled = true;
|
||||
private List<Contact> contactList, sipContactList;
|
||||
|
@ -262,7 +263,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
private void changeCurrentFragment(FragmentsAvailable newFragmentType, Bundle extras, boolean withoutAnimation) {
|
||||
if (newFragmentType == currentFragment && newFragmentType != FragmentsAvailable.CHAT) {
|
||||
if (newFragmentType == currentFragment) {
|
||||
return;
|
||||
}
|
||||
nextFragment = newFragmentType;
|
||||
|
@ -324,10 +325,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
case ABOUT_INSTEAD_OF_SETTINGS:
|
||||
newFragment = new AboutFragment();
|
||||
break;
|
||||
case CHAT:
|
||||
newFragment = new ChatFragment();
|
||||
messageListenerFragment = newFragment;
|
||||
break;
|
||||
case CHATLIST:
|
||||
newFragment = new ChatListFragment();
|
||||
messageListFragment = new Fragment();
|
||||
|
@ -378,20 +375,12 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
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 {
|
||||
if (newFragmentType != FragmentsAvailable.DIALER
|
||||
|| newFragmentType != FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT
|
||||
|| newFragmentType != FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS
|
||||
|| newFragmentType != FragmentsAvailable.CONTACTS
|
||||
|| newFragmentType != FragmentsAvailable.CHATLIST
|
||||
|| newFragmentType != FragmentsAvailable.HISTORY) {
|
||||
transaction.addToBackStack(newFragmentType.toString());
|
||||
}
|
||||
transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString());
|
||||
|
@ -568,24 +557,15 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
String displayName = lAddress.getDisplayName();
|
||||
String pictureUri = uri == null ? null : uri.toString();
|
||||
|
||||
if (currentFragment == FragmentsAvailable.CHATLIST || currentFragment == FragmentsAvailable.CHAT) {
|
||||
Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
||||
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT) {
|
||||
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 {
|
||||
changeCurrentFragment(FragmentsAvailable.CHATLIST, null);
|
||||
displayChat(sipUri);
|
||||
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);
|
||||
|
||||
LinphoneService.instance().resetMessageNotifCount();
|
||||
LinphoneService.instance().removeMessageNotification();
|
||||
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
||||
|
@ -664,7 +644,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
case ABOUT_INSTEAD_OF_SETTINGS:
|
||||
aboutSettings.setSelected(true);
|
||||
break;
|
||||
case CHAT:
|
||||
case CHATLIST:
|
||||
chat.setSelected(true);
|
||||
break;
|
||||
|
@ -677,12 +656,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
}
|
||||
|
||||
public void updateChatFragment(ChatFragment fragment) {
|
||||
messageListenerFragment = fragment;
|
||||
// Hack to maintain soft input flags
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
}
|
||||
|
||||
public void updateChatListFragment(ChatListFragment fragment) {
|
||||
messageListFragment = fragment;
|
||||
}
|
||||
|
@ -740,16 +713,10 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
|
||||
@Override
|
||||
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
||||
LinphoneAddress from = cr.getPeerAddress();
|
||||
ChatFragment chatFragment = ((ChatFragment) messageListenerFragment);
|
||||
if (messageListenerFragment != null && messageListenerFragment.isVisible() && chatFragment.getSipUri().equals(from.asStringUriOnly())) {
|
||||
chatFragment.onMessageReceived(from, message);
|
||||
} else if (LinphoneService.isReady()) {
|
||||
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
||||
if (messageListFragment != null && messageListFragment.isVisible()) {
|
||||
((ChatListFragment) messageListFragment).refresh();
|
||||
}
|
||||
}
|
||||
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
||||
if (messageListFragment != null && messageListFragment.isVisible()) {
|
||||
((ChatListFragment) messageListFragment).refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMissedChatCount() {
|
||||
|
@ -1374,7 +1341,12 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
|||
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (currentFragment == FragmentsAvailable.DIALER) {
|
||||
if (currentFragment == FragmentsAvailable.DIALER
|
||||
|| currentFragment == FragmentsAvailable.CONTACTS
|
||||
|| currentFragment == FragmentsAvailable.HISTORY
|
||||
|| currentFragment == FragmentsAvailable.CHATLIST
|
||||
|| currentFragment == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT
|
||||
|| currentFragment == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS) {
|
||||
boolean isBackgroundModeActive = LinphonePreferences.instance().isBackgroundModeEnabled();
|
||||
if (!isBackgroundModeActive) {
|
||||
stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||
|
|
Loading…
Reference in a new issue