Tablet: Fix new chat conversation and display first listview element
This commit is contained in:
parent
3866fde790
commit
f68df2c584
7 changed files with 112 additions and 106 deletions
|
@ -449,23 +449,26 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
|
||||
LinphoneAddress lAddress = null;
|
||||
try {
|
||||
lAddress = lc.interpretUrl(sipUri);
|
||||
} catch (Exception e){
|
||||
//TODO Error popup and quit chat
|
||||
}
|
||||
if(sipUri == null){
|
||||
initNewChatConversation();
|
||||
} else {
|
||||
try {
|
||||
lAddress = lc.interpretUrl(sipUri);
|
||||
} catch (Exception e) {
|
||||
//TODO Error popup and quit chat
|
||||
}
|
||||
|
||||
if (lAddress != null) {
|
||||
chatRoom = lc.getChatRoom(lAddress);
|
||||
chatRoom.markAsRead();
|
||||
LinphoneActivity.instance().updateMissedChatCount();
|
||||
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||
if(chatRoom != null) {
|
||||
displayChatHeader(lAddress);
|
||||
dispayMessageList();
|
||||
if (lAddress != null) {
|
||||
chatRoom = lc.getChatRoom(lAddress);
|
||||
chatRoom.markAsRead();
|
||||
LinphoneActivity.instance().updateMissedChatCount();
|
||||
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||
if (chatRoom != null) {
|
||||
displayChatHeader(lAddress);
|
||||
dispayMessageList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void dispayMessageList() {
|
||||
|
|
|
@ -185,14 +185,10 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
hideAndDisplayMessageIfNoChat();
|
||||
}
|
||||
|
||||
private boolean isVersionUsingNewChatStorage() {
|
||||
try {
|
||||
Context context = LinphoneActivity.instance();
|
||||
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode >= 2200;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
public void displayFirstChat(){
|
||||
if(mConversations.size() > 0) {
|
||||
LinphoneActivity.instance().displayChat(mConversations.get(0));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -324,33 +320,6 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
LinphoneActivity.instance().displayChat(sipUri);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean importAndroidStoredMessagedIntoLibLinphoneStorage() {
|
||||
Log.w("Importing previous messages into new database...");
|
||||
try {
|
||||
ChatStorage db = LinphoneActivity.instance().getChatStorage();
|
||||
List<String> conversations = db.getChatList();
|
||||
for (int j = conversations.size() - 1; j >= 0; j--) {
|
||||
String correspondent = conversations.get(j);
|
||||
LinphoneChatRoom room = LinphoneManager.getLc().getOrCreateChatRoom(correspondent);
|
||||
for (ChatMessage message : db.getMessages(correspondent)) {
|
||||
LinphoneChatMessage msg = room.createLinphoneChatMessage(message.getMessage(), message.getUrl(), message.getStatus(), Long.parseLong(message.getTimestamp()), true, message.isIncoming());
|
||||
if (message.getImage() != null) {
|
||||
String path = saveImageAsFile(message.getId(), message.getImage());
|
||||
if (path != null)
|
||||
msg.setExternalBodyUrl(path);
|
||||
}
|
||||
msg.store();
|
||||
}
|
||||
db.removeDiscussion(correspondent);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private String saveImageAsFile(int id, Bitmap bm) {
|
||||
try {
|
||||
|
|
|
@ -322,6 +322,12 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
|||
invalidate();
|
||||
}
|
||||
|
||||
public void displayFirstContact(){
|
||||
if(contactsList.getAdapter().getCount() > 0){
|
||||
LinphoneActivity.instance().displayContact((Contact) contactsList.getAdapter().getItem(0),false);
|
||||
}
|
||||
}
|
||||
|
||||
private void searchContacts() {
|
||||
searchContacts(searchField.getText().toString());
|
||||
}
|
||||
|
|
|
@ -123,6 +123,17 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
|||
}
|
||||
}
|
||||
|
||||
public void displayFirstLog(){
|
||||
if(mLogs.size() > 0){
|
||||
LinphoneCallLog log = mLogs.get(0);
|
||||
if (log.getDirection() == CallDirection.Incoming) {
|
||||
LinphoneActivity.instance().displayHistoryDetail(mLogs.get(0).getFrom().toString(), mLogs.get(0));
|
||||
} else {
|
||||
LinphoneActivity.instance().displayHistoryDetail(mLogs.get(0).getTo().toString(), mLogs.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeCallLogs(){
|
||||
int size = historyList.getAdapter().getCount();
|
||||
for(int i=0; i<size; i++) {
|
||||
|
|
|
@ -105,7 +105,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
private ImageView cancel;
|
||||
private FragmentsAvailable currentFragment, nextFragment;
|
||||
private List<FragmentsAvailable> fragmentsHistory;
|
||||
private Fragment dialerFragment, messageListFragment;
|
||||
private Fragment dialerFragment, chatListFragment, historyListFragment, contactListFragment;
|
||||
private ChatFragment chatFragment;
|
||||
private Fragment.SavedState dialerSavedState;
|
||||
private boolean newProxyConfig;
|
||||
|
@ -191,8 +191,8 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
cr.markAsRead();
|
||||
}
|
||||
displayMissedChats(getUnreadMessageCount());
|
||||
if (messageListFragment != null && messageListFragment.isVisible()) {
|
||||
((ChatListFragment) messageListFragment).refresh();
|
||||
if (chatListFragment != null && chatListFragment.isVisible()) {
|
||||
((ChatListFragment) chatListFragment).refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,12 +351,14 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
switch (newFragmentType) {
|
||||
case HISTORY_LIST:
|
||||
newFragment = new HistoryListFragment();
|
||||
historyListFragment = newFragment;
|
||||
break;
|
||||
case HISTORY_DETAIL:
|
||||
newFragment = new HistoryDetailFragment();
|
||||
break;
|
||||
case CONTACTS_LIST:
|
||||
newFragment = new ContactsListFragment();
|
||||
contactListFragment = newFragment;
|
||||
break;
|
||||
case CONTACT_DETAIL:
|
||||
newFragment = new ContactDetailsFragment();
|
||||
|
@ -382,7 +384,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
break;
|
||||
case CHAT_LIST:
|
||||
newFragment = new ChatListFragment();
|
||||
messageListFragment = newFragment;
|
||||
chatListFragment = newFragment;
|
||||
break;
|
||||
case CHAT:
|
||||
newFragment = new ChatFragment();
|
||||
|
@ -617,67 +619,66 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
return;
|
||||
}
|
||||
|
||||
if(sipUri == null) {
|
||||
Bundle extras = new Bundle();
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
|
||||
} else {
|
||||
LinphoneAddress lAddress;
|
||||
String pictureUri = null;
|
||||
String thumbnailUri = null;
|
||||
String displayName = null;
|
||||
|
||||
LinphoneAddress lAddress = null;
|
||||
if(sipUri != null) {
|
||||
try {
|
||||
lAddress = LinphoneManager.getLc().interpretUrl(sipUri);
|
||||
} catch (LinphoneCoreException e) {
|
||||
//TODO display error message
|
||||
Log.e("Cannot display chat",e);
|
||||
Log.e("Cannot display chat", e);
|
||||
return;
|
||||
}
|
||||
Contact contact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);
|
||||
String displayName = contact != null ? contact.getName() : null;
|
||||
displayName = contact != null ? contact.getName() : null;
|
||||
|
||||
String pictureUri = null;
|
||||
String thumbnailUri = null;
|
||||
if(contact != null && contact.getPhotoUri() != null){
|
||||
if (contact != null && contact.getPhotoUri() != null) {
|
||||
pictureUri = contact.getPhotoUri().toString();
|
||||
thumbnailUri = contact.getThumbnailUri().toString();
|
||||
}
|
||||
|
||||
if (currentFragment == FragmentsAvailable.CHAT_LIST || currentFragment == FragmentsAvailable.CHAT) {
|
||||
Fragment fragment2 = getFragmentManager().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);
|
||||
extras.putString("ThumbnailUri", thumbnailUri);
|
||||
}
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
|
||||
}
|
||||
} else {
|
||||
if(isTablet()){
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, null);
|
||||
displayChat(sipUri);
|
||||
} else {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("SipUri", sipUri);
|
||||
if (lAddress.getDisplayName() != null) {
|
||||
extras.putString("DisplayName", displayName);
|
||||
extras.putString("PictureUri", pictureUri);
|
||||
extras.putString("ThumbnailUri", thumbnailUri);
|
||||
}
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
|
||||
}
|
||||
}
|
||||
|
||||
if (messageListFragment != null && messageListFragment.isVisible()) {
|
||||
((ChatListFragment) messageListFragment).refresh();
|
||||
}
|
||||
|
||||
LinphoneService.instance().resetMessageNotifCount();
|
||||
LinphoneService.instance().removeMessageNotification();
|
||||
displayMissedChats(getUnreadMessageCount());
|
||||
}
|
||||
|
||||
if (currentFragment == FragmentsAvailable.CHAT_LIST || currentFragment == FragmentsAvailable.CHAT) {
|
||||
Fragment fragment2 = getFragmentManager().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 (sipUri != null && lAddress.getDisplayName() != null) {
|
||||
extras.putString("DisplayName", displayName);
|
||||
extras.putString("PictureUri", pictureUri);
|
||||
extras.putString("ThumbnailUri", thumbnailUri);
|
||||
}
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
|
||||
}
|
||||
} else {
|
||||
if(isTablet()){
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, null);
|
||||
displayChat(sipUri);
|
||||
} else {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("SipUri", sipUri);
|
||||
if (sipUri != null && lAddress.getDisplayName() != null) {
|
||||
extras.putString("DisplayName", displayName);
|
||||
extras.putString("PictureUri", pictureUri);
|
||||
extras.putString("ThumbnailUri", thumbnailUri);
|
||||
}
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
|
||||
}
|
||||
}
|
||||
|
||||
if (chatListFragment != null && chatListFragment.isVisible()) {
|
||||
((ChatListFragment) chatListFragment).refresh();
|
||||
}
|
||||
|
||||
LinphoneService.instance().resetMessageNotifCount();
|
||||
LinphoneService.instance().removeMessageNotification();
|
||||
displayMissedChats(getUnreadMessageCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -690,15 +691,30 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
history_selected.setVisibility(View.VISIBLE);
|
||||
LinphoneManager.getLc().resetMissedCallsCount();
|
||||
displayMissedCalls(0);
|
||||
if(isTablet()) {
|
||||
if (historyListFragment != null && historyListFragment.isVisible()) {
|
||||
((HistoryListFragment) historyListFragment).displayFirstLog();
|
||||
}
|
||||
}
|
||||
} else if (id == R.id.contacts) {
|
||||
changeCurrentFragment(FragmentsAvailable.CONTACTS_LIST, null);
|
||||
contacts_selected.setVisibility(View.VISIBLE);
|
||||
if(isTablet()) {
|
||||
if (contactListFragment != null && contactListFragment.isVisible()) {
|
||||
((ContactsListFragment) contactListFragment).displayFirstContact();
|
||||
}
|
||||
}
|
||||
} else if (id == R.id.dialer) {
|
||||
changeCurrentFragment(FragmentsAvailable.DIALER, null);
|
||||
dialer_selected.setVisibility(View.VISIBLE);
|
||||
} else if (id == R.id.chat) {
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, null);
|
||||
chat_selected.setVisibility(View.VISIBLE);
|
||||
if(isTablet()) {
|
||||
if (chatListFragment != null && chatListFragment.isVisible()) {
|
||||
((ChatListFragment) chatListFragment).displayFirstChat();
|
||||
}
|
||||
}
|
||||
} else if (id == R.id.cancel){
|
||||
hideTopBar();
|
||||
displayDialer();
|
||||
|
@ -765,7 +781,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
}
|
||||
|
||||
public void updateChatListFragment(ChatListFragment fragment) {
|
||||
messageListFragment = fragment;
|
||||
chatListFragment = fragment;
|
||||
}
|
||||
|
||||
public void updateStatusFragment(StatusFragment fragment) {
|
||||
|
@ -826,8 +842,8 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
|
||||
public int onMessageSent(String to, String message) {
|
||||
getChatStorage().deleteDraft(to);
|
||||
if (messageListFragment != null && messageListFragment.isVisible()) {
|
||||
((ChatListFragment) messageListFragment).refresh();
|
||||
if (chatListFragment != null && chatListFragment.isVisible()) {
|
||||
((ChatListFragment) chatListFragment).refresh();
|
||||
}
|
||||
|
||||
return getChatStorage().saveTextMessage("", to, message, System.currentTimeMillis());
|
||||
|
|
|
@ -267,7 +267,8 @@ public class ConferenceAndMultiCall extends SampleTest {
|
|||
|
||||
private void startConference() {
|
||||
startTwoCalls();
|
||||
|
||||
|
||||
solo.clickOnView(solo.getView(org.linphone.R.id.options));
|
||||
solo.clickOnView(solo.getView(org.linphone.R.id.conference));
|
||||
solo.sleep(1000);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public class Contacts extends SampleTest {
|
|||
Assert.assertTrue(solo.searchText(iContext.getString(org.linphone.test.R.string.contact_name)));
|
||||
|
||||
solo.clickOnText(iContext.getString(org.linphone.test.R.string.contact_name));
|
||||
solo.clickOnView(solo.getView(org.linphone.R.id.delete_contact));
|
||||
solo.clickOnView(solo.getView(org.linphone.R.id.deleteContact));
|
||||
solo.sleep(1000);
|
||||
solo.clickOnView(solo.getView(org.linphone.R.id.delete_button));
|
||||
|
||||
|
|
Loading…
Reference in a new issue