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" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</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"
|
<activity android:name="org.linphone.setup.SetupActivity"
|
||||||
android:theme="@style/NoTitle"
|
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"
|
xmlns:linphone="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/top_layout"
|
||||||
android:background="@drawable/background" >
|
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
|
<LinearLayout
|
||||||
android:id="@+id/header"
|
android:id="@+id/header"
|
||||||
|
@ -14,7 +51,7 @@
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_below="@+id/topbar"
|
||||||
android:layout_centerHorizontal="true">
|
android:layout_centerHorizontal="true">
|
||||||
|
|
||||||
<org.linphone.ui.AvatarWithShadow
|
<org.linphone.ui.AvatarWithShadow
|
||||||
|
@ -30,7 +67,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:textColor="@color/text_contrast" />
|
android:textColor="@color/text_contrast" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -74,6 +110,7 @@
|
||||||
android:paddingLeft="10dp" />
|
android:paddingLeft="10dp" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
|
android:imeOptions="flagNoExtractUi"
|
||||||
android:textCursorDrawable="@null"
|
android:textCursorDrawable="@null"
|
||||||
android:id="@+id/message"
|
android:id="@+id/message"
|
||||||
android:inputType="textMultiLine"
|
android:inputType="textMultiLine"
|
||||||
|
|
|
@ -301,6 +301,7 @@
|
||||||
<string name="button_edit">Modifier</string>
|
<string name="button_edit">Modifier</string>
|
||||||
<string name="button_cancel">Annuler</string>
|
<string name="button_cancel">Annuler</string>
|
||||||
<string name="button_ok">Valider</string>
|
<string name="button_ok">Valider</string>
|
||||||
|
<string name="button_back">Retour</string>
|
||||||
<string name="button_all_contacts">Tous</string>
|
<string name="button_all_contacts">Tous</string>
|
||||||
<string name="button_sip_contacts">SIP</string>
|
<string name="button_sip_contacts">SIP</string>
|
||||||
<string name="button_add_contact">+ Contact</string>
|
<string name="button_add_contact">+ Contact</string>
|
||||||
|
|
|
@ -303,6 +303,7 @@
|
||||||
<string name="button_edit">Edit</string>
|
<string name="button_edit">Edit</string>
|
||||||
<string name="button_cancel">Cancel</string>
|
<string name="button_cancel">Cancel</string>
|
||||||
<string name="button_ok">Okay</string>
|
<string name="button_ok">Okay</string>
|
||||||
|
<string name="button_back">Back</string>
|
||||||
<string name="button_all_contacts">All</string>
|
<string name="button_all_contacts">All</string>
|
||||||
<string name="button_sip_contacts">SIP</string>
|
<string name="button_sip_contacts">SIP</string>
|
||||||
<string name="button_add_contact">New contact</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,
|
ABOUT_INSTEAD_OF_CHAT,
|
||||||
ACCOUNT_SETTINGS,
|
ACCOUNT_SETTINGS,
|
||||||
SETTINGS,
|
SETTINGS,
|
||||||
CHATLIST,
|
CHATLIST;
|
||||||
CHAT;
|
|
||||||
|
|
||||||
public boolean shouldAddToBackStack() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldAnimate() {
|
public boolean shouldAnimate() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -68,9 +63,6 @@ public enum FragmentsAvailable {
|
||||||
case CHATLIST:
|
case CHATLIST:
|
||||||
return DIALER.isRightOf(fragment) || fragment == DIALER;
|
return DIALER.isRightOf(fragment) || fragment == DIALER;
|
||||||
|
|
||||||
case CHAT:
|
|
||||||
return CHATLIST.isRightOf(fragment) || fragment == CHATLIST;
|
|
||||||
|
|
||||||
case ABOUT_INSTEAD_OF_SETTINGS:
|
case ABOUT_INSTEAD_OF_SETTINGS:
|
||||||
case SETTINGS:
|
case SETTINGS:
|
||||||
return CHATLIST.isRightOf(fragment) || fragment == CHATLIST || fragment == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT;
|
return CHATLIST.isRightOf(fragment) || fragment == CHATLIST || fragment == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT;
|
||||||
|
@ -95,9 +87,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
private static final int FIRST_LOGIN_ACTIVITY = 101;
|
private static final int FIRST_LOGIN_ACTIVITY = 101;
|
||||||
private static final int REMOTE_PROVISIONING_LOGIN_ACTIVITY = 102;
|
private static final int REMOTE_PROVISIONING_LOGIN_ACTIVITY = 102;
|
||||||
private static final int CALL_ACTIVITY = 19;
|
private static final int CALL_ACTIVITY = 19;
|
||||||
|
private static final int CHAT_ACTIVITY = 21;
|
||||||
|
|
||||||
private static LinphoneActivity instance;
|
private static LinphoneActivity instance;
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
private RelativeLayout contacts, history, settings, chat, aboutChat, aboutSettings;
|
private RelativeLayout contacts, history, settings, chat, aboutChat, aboutSettings;
|
||||||
private FragmentsAvailable currentFragment, nextFragment;
|
private FragmentsAvailable currentFragment, nextFragment;
|
||||||
private List<FragmentsAvailable> fragmentsHistory;
|
private List<FragmentsAvailable> fragmentsHistory;
|
||||||
private Fragment dialerFragment, messageListenerFragment, messageListFragment, friendStatusListenerFragment;
|
private Fragment dialerFragment, messageListFragment, friendStatusListenerFragment;
|
||||||
private SavedState dialerSavedState;
|
private SavedState dialerSavedState;
|
||||||
private boolean preferLinphoneContacts = false, isAnimationDisabled = false, isContactPresenceDisabled = true;
|
private boolean preferLinphoneContacts = false, isAnimationDisabled = false, isContactPresenceDisabled = true;
|
||||||
private List<Contact> contactList, sipContactList;
|
private List<Contact> contactList, sipContactList;
|
||||||
|
@ -262,7 +263,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
|
|
||||||
@SuppressWarnings("incomplete-switch")
|
@SuppressWarnings("incomplete-switch")
|
||||||
private void changeCurrentFragment(FragmentsAvailable newFragmentType, Bundle extras, boolean withoutAnimation) {
|
private void changeCurrentFragment(FragmentsAvailable newFragmentType, Bundle extras, boolean withoutAnimation) {
|
||||||
if (newFragmentType == currentFragment && newFragmentType != FragmentsAvailable.CHAT) {
|
if (newFragmentType == currentFragment) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nextFragment = newFragmentType;
|
nextFragment = newFragmentType;
|
||||||
|
@ -324,10 +325,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
case ABOUT_INSTEAD_OF_SETTINGS:
|
case ABOUT_INSTEAD_OF_SETTINGS:
|
||||||
newFragment = new AboutFragment();
|
newFragment = new AboutFragment();
|
||||||
break;
|
break;
|
||||||
case CHAT:
|
|
||||||
newFragment = new ChatFragment();
|
|
||||||
messageListenerFragment = newFragment;
|
|
||||||
break;
|
|
||||||
case CHATLIST:
|
case CHATLIST:
|
||||||
newFragment = new ChatListFragment();
|
newFragment = new ChatListFragment();
|
||||||
messageListFragment = new Fragment();
|
messageListFragment = new Fragment();
|
||||||
|
@ -378,20 +375,12 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newFragmentType != FragmentsAvailable.DIALER
|
||||||
if (newFragmentType == FragmentsAvailable.DIALER
|
|| newFragmentType != FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT
|
||||||
|| newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT
|
|| newFragmentType != FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS
|
||||||
|| newFragmentType == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS
|
|| newFragmentType != FragmentsAvailable.CONTACTS
|
||||||
|| newFragmentType == FragmentsAvailable.SETTINGS
|
|| newFragmentType != FragmentsAvailable.CHATLIST
|
||||||
|| newFragmentType == FragmentsAvailable.CONTACTS
|
|| newFragmentType != FragmentsAvailable.HISTORY) {
|
||||||
|| 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());
|
||||||
|
@ -568,24 +557,15 @@ 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();
|
||||||
|
|
||||||
if (currentFragment == FragmentsAvailable.CHATLIST || currentFragment == FragmentsAvailable.CHAT) {
|
Intent intent = new Intent(this, ChatActivity.class);
|
||||||
Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
intent.putExtra("SipUri", sipUri);
|
||||||
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT) {
|
if (lAddress.getDisplayName() != null) {
|
||||||
ChatFragment chatFragment = (ChatFragment) fragment2;
|
intent.putExtra("DisplayName", displayName);
|
||||||
chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri);
|
intent.putExtra("PictureUri", 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);
|
|
||||||
}
|
}
|
||||||
|
startOrientationSensor();
|
||||||
|
startActivityForResult(intent, CHAT_ACTIVITY);
|
||||||
|
|
||||||
LinphoneService.instance().resetMessageNotifCount();
|
LinphoneService.instance().resetMessageNotifCount();
|
||||||
LinphoneService.instance().removeMessageNotification();
|
LinphoneService.instance().removeMessageNotification();
|
||||||
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
||||||
|
@ -664,7 +644,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
case ABOUT_INSTEAD_OF_SETTINGS:
|
case ABOUT_INSTEAD_OF_SETTINGS:
|
||||||
aboutSettings.setSelected(true);
|
aboutSettings.setSelected(true);
|
||||||
break;
|
break;
|
||||||
case CHAT:
|
|
||||||
case CHATLIST:
|
case CHATLIST:
|
||||||
chat.setSelected(true);
|
chat.setSelected(true);
|
||||||
break;
|
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);
|
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) {
|
public void updateChatListFragment(ChatListFragment fragment) {
|
||||||
messageListFragment = fragment;
|
messageListFragment = fragment;
|
||||||
}
|
}
|
||||||
|
@ -740,16 +713,10 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
||||||
LinphoneAddress from = cr.getPeerAddress();
|
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
||||||
ChatFragment chatFragment = ((ChatFragment) messageListenerFragment);
|
if (messageListFragment != null && messageListFragment.isVisible()) {
|
||||||
if (messageListenerFragment != null && messageListenerFragment.isVisible() && chatFragment.getSipUri().equals(from.asStringUriOnly())) {
|
((ChatListFragment) messageListFragment).refresh();
|
||||||
chatFragment.onMessageReceived(from, message);
|
}
|
||||||
} else if (LinphoneService.isReady()) {
|
|
||||||
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
|
||||||
if (messageListFragment != null && messageListFragment.isVisible()) {
|
|
||||||
((ChatListFragment) messageListFragment).refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMissedChatCount() {
|
public void updateMissedChatCount() {
|
||||||
|
@ -1374,7 +1341,12 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
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();
|
boolean isBackgroundModeActive = LinphonePreferences.instance().isBackgroundModeEnabled();
|
||||||
if (!isBackgroundModeActive) {
|
if (!isBackgroundModeActive) {
|
||||||
stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
|
stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||||
|
|
Loading…
Reference in a new issue