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) {
|
if (savedInstanceState != null) {
|
||||||
messagesFilterLimit = savedInstanceState.getInt("messagesFilterLimit");
|
messagesFilterLimit = savedInstanceState.getInt("messagesFilterLimit");
|
||||||
}
|
}
|
||||||
displayChat(displayName, pictureUri);
|
displayChatHeader(displayName, pictureUri);
|
||||||
|
|
||||||
uploadServerUri = LinphonePreferences.instance().getSharingPictureServerUrl();
|
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)) {
|
if (displayName == null && getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) {
|
||||||
contactName.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
|
contactName.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
|
||||||
} else if (displayName == null) {
|
} else if (displayName == null) {
|
||||||
|
@ -355,14 +355,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
} else {
|
} else {
|
||||||
contactPicture.setImageResource(R.drawable.unknown_small);
|
contactPicture.setImageResource(R.drawable.unknown_small);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messagesFilterLimit == 0)
|
|
||||||
invalidate();
|
|
||||||
else {
|
|
||||||
invalidate(messagesFilterLimit);
|
|
||||||
}
|
|
||||||
|
|
||||||
scrollToEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int checkId(int id) {
|
private int checkId(int id) {
|
||||||
|
@ -494,7 +486,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
draft = "";
|
draft = "";
|
||||||
message.setText(draft);
|
message.setText(draft);
|
||||||
}
|
}
|
||||||
displayChat(displayName, pictureUri);
|
|
||||||
|
displayChatHeader(displayName, pictureUri);
|
||||||
|
displayMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -601,6 +595,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
|
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
displayMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -608,6 +604,15 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
sendTextMessage();
|
sendTextMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displayMessages() {
|
||||||
|
messagesLayout.removeAllViews();
|
||||||
|
messagesArePresentButHidden = false;
|
||||||
|
messagesFilterLimit = 0;
|
||||||
|
previousMessageID = 0;
|
||||||
|
invalidate();
|
||||||
|
scrollToEnd();
|
||||||
|
}
|
||||||
|
|
||||||
private void sendTextMessage() {
|
private void sendTextMessage() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();
|
boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();
|
||||||
|
|
|
@ -137,15 +137,27 @@ public class DialerFragment extends Fragment {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().updateDialerFragment(this);
|
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
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.DIALER);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.DIALER);
|
||||||
LinphoneActivity.instance().updateDialerFragment(this);
|
LinphoneActivity.instance().updateDialerFragment(this);
|
||||||
|
LinphoneActivity.instance().showStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force speaker for tablets
|
// Force speaker for tablets
|
||||||
|
@ -161,6 +173,16 @@ public class DialerFragment extends Fragment {
|
||||||
resetLayout(isCallTransferOngoing);
|
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) {
|
public void resetLayout(boolean callTransfer) {
|
||||||
isCallTransferOngoing = callTransfer;
|
isCallTransferOngoing = callTransfer;
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
|
|
@ -227,7 +227,7 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
return getResources().getBoolean(R.bool.isTablet);
|
return getResources().getBoolean(R.bool.isTablet);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideStatusBar() {
|
public void hideStatusBar() {
|
||||||
if (isTablet()) {
|
if (isTablet()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
findViewById(R.id.fragmentContainer).setPadding(0, 0, 0, 0);
|
findViewById(R.id.fragmentContainer).setPadding(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showStatusBar() {
|
public void showStatusBar() {
|
||||||
if (isTablet()) {
|
if (isTablet()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -343,13 +343,6 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
|
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) {
|
if (statusFragment != null) {
|
||||||
statusFragment.closeStatusBar();
|
statusFragment.closeStatusBar();
|
||||||
}
|
}
|
||||||
|
@ -1250,6 +1243,8 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
|
|
||||||
displayMissedCalls(LinphoneManager.getLc().getMissedCallsCount());
|
displayMissedCalls(LinphoneManager.getLc().getMissedCallsCount());
|
||||||
|
|
||||||
|
LinphoneManager.getInstance().changeStatusToOnline();
|
||||||
|
|
||||||
if (LinphoneManager.getLc().getCalls().length > 0) {
|
if (LinphoneManager.getLc().getCalls().length > 0) {
|
||||||
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
|
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
|
||||||
LinphoneCall.State callState = call.getState();
|
LinphoneCall.State callState = call.getState();
|
||||||
|
@ -1257,14 +1252,6 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
startActivity(new Intent(this, IncomingCallActivity.class));
|
startActivity(new Intent(this, IncomingCallActivity.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneManager.getInstance().changeStatusToOnline();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
LinphoneManager.getInstance().changeStatusToAway();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1356,20 +1343,7 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isTablet()) {
|
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 (currentFragment == FragmentsAvailable.SETTINGS) {
|
if (currentFragment == FragmentsAvailable.SETTINGS) {
|
||||||
updateAnimationsState();
|
updateAnimationsState();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue