Improved hide/show of the status bar + fix invisible messages when coming back to chat fragment
This commit is contained in:
parent
bc954e9320
commit
8fb6fa9f5d
3 changed files with 43 additions and 42 deletions
|
@ -194,7 +194,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
if (savedInstanceState != null) {
|
||||
messagesFilterLimit = savedInstanceState.getInt("messagesFilterLimit");
|
||||
}
|
||||
displayChat(displayName, pictureUri);
|
||||
displayChatHeader(displayName, pictureUri);
|
||||
|
||||
uploadServerUri = LinphonePreferences.instance().getSharingPictureServerUrl();
|
||||
|
||||
|
@ -341,7 +341,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
});
|
||||
}
|
||||
|
||||
private void displayChat(String displayName, String pictureUri) {
|
||||
private void displayChatHeader(String displayName, String pictureUri) {
|
||||
if (displayName == null && getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) {
|
||||
contactName.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
|
||||
} else if (displayName == null) {
|
||||
|
@ -355,14 +355,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
} else {
|
||||
contactPicture.setImageResource(R.drawable.unknown_small);
|
||||
}
|
||||
|
||||
if (messagesFilterLimit == 0)
|
||||
invalidate();
|
||||
else {
|
||||
invalidate(messagesFilterLimit);
|
||||
}
|
||||
|
||||
scrollToEnd();
|
||||
}
|
||||
|
||||
private int checkId(int id) {
|
||||
|
@ -494,7 +486,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
draft = "";
|
||||
message.setText(draft);
|
||||
}
|
||||
displayChat(displayName, pictureUri);
|
||||
|
||||
displayChatHeader(displayName, pictureUri);
|
||||
displayMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -601,6 +595,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
}
|
||||
|
||||
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
|
||||
|
||||
displayMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -608,6 +604,15 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
sendTextMessage();
|
||||
}
|
||||
|
||||
private void displayMessages() {
|
||||
messagesLayout.removeAllViews();
|
||||
messagesArePresentButHidden = false;
|
||||
messagesFilterLimit = 0;
|
||||
previousMessageID = 0;
|
||||
invalidate();
|
||||
scrollToEnd();
|
||||
}
|
||||
|
||||
private void sendTextMessage() {
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();
|
||||
|
|
|
@ -137,15 +137,27 @@ public class DialerFragment extends Fragment {
|
|||
super.onAttach(activity);
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().updateDialerFragment(this);
|
||||
LinphoneActivity.instance().showStatusBar();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
|
||||
LinphoneActivity.instance().hideStatusBar();
|
||||
}
|
||||
}
|
||||
super.onDetach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.DIALER);
|
||||
LinphoneActivity.instance().updateDialerFragment(this);
|
||||
LinphoneActivity.instance().showStatusBar();
|
||||
}
|
||||
|
||||
// Force speaker for tablets
|
||||
|
@ -161,6 +173,16 @@ public class DialerFragment extends Fragment {
|
|||
resetLayout(isCallTransferOngoing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
|
||||
LinphoneActivity.instance().hideStatusBar();
|
||||
}
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
public void resetLayout(boolean callTransfer) {
|
||||
isCallTransferOngoing = callTransfer;
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
|
|
|
@ -227,7 +227,7 @@ public class LinphoneActivity extends FragmentActivity implements
|
|||
return getResources().getBoolean(R.bool.isTablet);
|
||||
}
|
||||
|
||||
private void hideStatusBar() {
|
||||
public void hideStatusBar() {
|
||||
if (isTablet()) {
|
||||
return;
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ public class LinphoneActivity extends FragmentActivity implements
|
|||
findViewById(R.id.fragmentContainer).setPadding(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
private void showStatusBar() {
|
||||
public void showStatusBar() {
|
||||
if (isTablet()) {
|
||||
return;
|
||||
}
|
||||
|
@ -343,13 +343,6 @@ public class LinphoneActivity extends FragmentActivity implements
|
|||
}
|
||||
|
||||
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
|
||||
if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
|
||||
if (newFragmentType == FragmentsAvailable.DIALER) {
|
||||
showStatusBar();
|
||||
} else {
|
||||
hideStatusBar();
|
||||
}
|
||||
}
|
||||
if (statusFragment != null) {
|
||||
statusFragment.closeStatusBar();
|
||||
}
|
||||
|
@ -1250,6 +1243,8 @@ public class LinphoneActivity extends FragmentActivity implements
|
|||
|
||||
displayMissedCalls(LinphoneManager.getLc().getMissedCallsCount());
|
||||
|
||||
LinphoneManager.getInstance().changeStatusToOnline();
|
||||
|
||||
if (LinphoneManager.getLc().getCalls().length > 0) {
|
||||
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
|
||||
LinphoneCall.State callState = call.getState();
|
||||
|
@ -1257,14 +1252,6 @@ public class LinphoneActivity extends FragmentActivity implements
|
|||
startActivity(new Intent(this, IncomingCallActivity.class));
|
||||
}
|
||||
}
|
||||
|
||||
LinphoneManager.getInstance().changeStatusToOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
LinphoneManager.getInstance().changeStatusToAway();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1356,20 +1343,7 @@ public class LinphoneActivity extends FragmentActivity implements
|
|||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!isTablet()) {
|
||||
int backStackEntryCount = getSupportFragmentManager().getBackStackEntryCount();
|
||||
if (backStackEntryCount <= 1) {
|
||||
showStatusBar();
|
||||
}
|
||||
|
||||
if (currentFragment == FragmentsAvailable.SETTINGS) {
|
||||
showStatusBar();
|
||||
updateAnimationsState();
|
||||
} else if (currentFragment == FragmentsAvailable.CHATLIST) {
|
||||
//Hack to ensure display the status bar on some devices
|
||||
showStatusBar();
|
||||
}
|
||||
} else {
|
||||
if (isTablet()) {
|
||||
if (currentFragment == FragmentsAvailable.SETTINGS) {
|
||||
updateAnimationsState();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue