Fix tablet problem with fragments and add dispaly name in history
This commit is contained in:
parent
10f6c732d1
commit
4b251b6cfd
5 changed files with 50 additions and 38 deletions
|
@ -109,6 +109,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/footer_history"
|
||||
android:src="@drawable/footer_history"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -129,9 +130,11 @@
|
|||
style="@style/font18"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="15dp"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"/>
|
||||
android:layout_margin="20dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:visibility="visible"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -209,8 +212,10 @@
|
|||
style="@style/font18"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="15dp"
|
||||
android:layout_margin="20dp"
|
||||
android:gravity="center"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -160,15 +160,23 @@ public class ContactEditorFragment extends Fragment {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Contact updatedContact = contactsManager.findContactWithDisplayName(contactsManager.getDisplayName(firstName.getText().toString(), lastName.getText().toString()));
|
||||
if(updatedContact != null) {
|
||||
LinphoneActivity.instance().displayContact(updatedContact, false);
|
||||
if(isNewContact) {
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
} else {
|
||||
LinphoneActivity.instance().displayContacts(false);
|
||||
if (LinphoneActivity.instance().getResources().getBoolean(R.bool.isTablet)) {
|
||||
if(ContactsListFragment.isInstanciated()) {
|
||||
ContactsListFragment.instance().invalidate();
|
||||
}
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
} else {
|
||||
Contact updatedContact = contactsManager.findContactWithDisplayName(contactsManager.getDisplayName(firstName.getText().toString(), lastName.getText().toString()));
|
||||
if (updatedContact != null) {
|
||||
LinphoneActivity.instance().displayContact(updatedContact, false);
|
||||
} else {
|
||||
LinphoneActivity.instance().displayContacts(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(LinphoneActivity.instance().getResources().getBoolean(R.bool.isTablet))
|
||||
ContactsListFragment.instance().invalidate();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -78,10 +78,6 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
|||
contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
|
||||
|
||||
contactName = (TextView) view.findViewById(R.id.contact_name);
|
||||
if (displayName == null) {
|
||||
displayName = LinphoneUtils.getUsernameFromAddress(sipUri);
|
||||
}
|
||||
|
||||
contactAddress = (TextView) view.findViewById(R.id.contact_address);
|
||||
|
||||
callDirection = (ImageView) view.findViewById(R.id.direction);
|
||||
|
@ -95,13 +91,6 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
|||
}
|
||||
|
||||
private void displayHistory(String status, String callTime, String callDate) {
|
||||
contactName.setText(displayName == null ? sipUri : displayName);
|
||||
if (displayName == null) {
|
||||
contactAddress.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
|
||||
} else {
|
||||
contactAddress.setText(sipUri);
|
||||
}
|
||||
|
||||
if (status.equals(getResources().getString(R.string.missed))) {
|
||||
callDirection.setImageResource(R.drawable.call_missed);
|
||||
} else if (status.equals(getResources().getString(R.string.incoming))) {
|
||||
|
@ -114,21 +103,29 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
|||
Long longDate = Long.parseLong(callDate);
|
||||
date.setText(LinphoneUtils.timestampToHumanDate(getActivity(),longDate,getString(R.string.history_detail_date_format)));
|
||||
|
||||
LinphoneAddress lAddress;
|
||||
LinphoneAddress lAddress = null;
|
||||
try {
|
||||
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||
Contact contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||
if (contact != null) {
|
||||
LinphoneUtils.setImagePictureFromUri(view.getContext(),contactPicture,contact.getPhotoUri(),contact.getThumbnailUri());
|
||||
addToContacts.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
contactPicture.setImageResource(R.drawable.avatar);
|
||||
addToContacts.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} catch (LinphoneCoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
if(lAddress != null) {
|
||||
contactAddress.setText(lAddress.asStringUriOnly());
|
||||
Contact contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||
if (contact != null) {
|
||||
contactName.setText(contact.getName());
|
||||
LinphoneUtils.setImagePictureFromUri(view.getContext(),contactPicture,contact.getPhotoUri(),contact.getThumbnailUri());
|
||||
addToContacts.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
contactName.setText(displayName == null ? LinphoneUtils.getAddressDisplayName(sipUri) : displayName);
|
||||
contactPicture.setImageResource(R.drawable.avatar);
|
||||
addToContacts.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
contactAddress.setText(sipUri);
|
||||
contactName.setText(displayName == null ? LinphoneUtils.getAddressDisplayName(sipUri) : displayName);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeDisplayedHistory(String sipUri, String displayName, String pictureUri, String status, String callTime, String callDate) {
|
||||
|
|
|
@ -442,7 +442,7 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
|||
|
||||
Contact c = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), address);
|
||||
String displayName = null;
|
||||
final String sipUri = address.asStringUriOnly();
|
||||
final String sipUri = address.asString();
|
||||
if(c != null){
|
||||
displayName = c.getName();
|
||||
LinphoneUtils.setImagePictureFromUri(view.getContext(),holder.contactPicture,c.getPhotoUri(),c.getThumbnailUri());
|
||||
|
|
|
@ -109,7 +109,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
private ChatFragment chatFragment;
|
||||
private Fragment.SavedState dialerSavedState;
|
||||
private boolean newProxyConfig;
|
||||
private boolean isAnimationDisabled = true, preferLinphoneContacts = false;
|
||||
private boolean isAnimationDisabled = true, preferLinphoneContacts = false, emptyFragment = false;
|
||||
private OrientationEventListener mOrientationHelper;
|
||||
private LinphoneCoreListenerBase mListener;
|
||||
private LinearLayout mTabBar;
|
||||
|
@ -459,13 +459,14 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
hideStatusBar();
|
||||
}
|
||||
}
|
||||
|
||||
emptyFragment = false;
|
||||
LinearLayout ll = (LinearLayout) findViewById(R.id.fragmentContainer2);
|
||||
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
|
||||
if(newFragmentType == FragmentsAvailable.EMPTY){
|
||||
ll.setVisibility(View.VISIBLE);
|
||||
emptyFragment = true;
|
||||
transaction.replace(R.id.fragmentContainer2, newFragment);
|
||||
transaction.commitAllowingStateLoss();
|
||||
getFragmentManager().executePendingTransactions();
|
||||
|
@ -481,6 +482,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
if (newFragmentType == FragmentsAvailable.EMPTY) {
|
||||
ll.setVisibility(View.VISIBLE);
|
||||
transaction.replace(R.id.fragmentContainer2, new EmptyFragment());
|
||||
emptyFragment = true;
|
||||
}
|
||||
|
||||
if (newFragmentType == FragmentsAvailable.DIALER
|
||||
|
@ -532,7 +534,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
}
|
||||
Contact c = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);
|
||||
|
||||
String displayName = c != null ? c.getName() : null;
|
||||
String displayName = c != null ? c.getName() : LinphoneUtils.getAddressDisplayName(sipUri);
|
||||
String pictureUri = c != null && c.getPhotoUri() != null ? c.getPhotoUri().toString() : null;
|
||||
|
||||
String status;
|
||||
|
@ -552,10 +554,10 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
||||
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.HISTORY_DETAIL) {
|
||||
HistoryDetailFragment historyDetailFragment = (HistoryDetailFragment) fragment2;
|
||||
historyDetailFragment.changeDisplayedHistory(sipUri, displayName, pictureUri, status, callTime, callDate);
|
||||
historyDetailFragment.changeDisplayedHistory(lAddress.asStringUriOnly(), displayName, pictureUri, status, callTime, callDate);
|
||||
} else {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("SipUri", sipUri);
|
||||
extras.putString("SipUri", lAddress.asString());
|
||||
if (displayName != null) {
|
||||
extras.putString("DisplayName", displayName);
|
||||
extras.putString("PictureUri", pictureUri);
|
||||
|
@ -671,7 +673,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
|
||||
if (currentFragment == FragmentsAvailable.CHAT_LIST || currentFragment == FragmentsAvailable.CHAT) {
|
||||
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
||||
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT) {
|
||||
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT && !emptyFragment) {
|
||||
ChatFragment chatFragment = (ChatFragment) fragment2;
|
||||
chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue