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