Hide input when group is marked as not active.

Fix bug where input panel gets shown when you long press a message.
This commit is contained in:
Mikunj 2020-04-09 13:23:51 +10:00
parent f149065a30
commit 45220bfa70

View File

@ -317,7 +317,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private Button makeDefaultSmsButton; private Button makeDefaultSmsButton;
private Button registerButton; private Button registerButton;
private InputAwareLayout container; private InputAwareLayout container;
private View composePanel;
protected Stub<ReminderView> reminderView; protected Stub<ReminderView> reminderView;
private Stub<UnverifiedBannerView> unverifiedBannerView; private Stub<UnverifiedBannerView> unverifiedBannerView;
private Stub<GroupShareProfileView> groupShareProfileView; private Stub<GroupShareProfileView> groupShareProfileView;
@ -552,7 +551,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
updateTitleTextView(recipient); updateTitleTextView(recipient);
updateSubtitleTextView(); updateSubtitleTextView();
setActionBarColor(recipient.getColor()); setActionBarColor(recipient.getColor());
setBlockedUserState(recipient, isSecureText, isDefaultSms); updateInputUI(recipient, isSecureText, isDefaultSms);
setGroupShareProfileReminder(recipient); setGroupShareProfileReminder(recipient);
calculateCharactersRemaining(); calculateCharactersRemaining();
@ -645,7 +644,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
updateTitleTextView(recipient); updateTitleTextView(recipient);
updateSubtitleTextView(); updateSubtitleTextView();
NotificationChannels.updateContactChannelName(this, recipient); NotificationChannels.updateContactChannelName(this, recipient);
setBlockedUserState(recipient, isSecureText, isDefaultSms); updateInputUI(recipient, isSecureText, isDefaultSms);
supportInvalidateOptionsMenu(); supportInvalidateOptionsMenu();
break; break;
case TAKE_PHOTO: case TAKE_PHOTO:
@ -858,6 +857,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
searchViewModel.onSearchClosed(); searchViewModel.onSearchClosed();
searchNav.setVisibility(View.GONE); searchNav.setVisibility(View.GONE);
inputPanel.setVisibility(View.VISIBLE); inputPanel.setVisibility(View.VISIBLE);
updateInputUI(recipient, isSecureText, isDefaultSms);
fragment.onSearchQueryUpdated(null); fragment.onSearchQueryUpdated(null);
invalidateOptionsMenu(); invalidateOptionsMenu();
return true; return true;
@ -1343,7 +1343,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
calculateCharactersRemaining(); calculateCharactersRemaining();
supportInvalidateOptionsMenu(); supportInvalidateOptionsMenu();
setBlockedUserState(recipient, isSecureText, isDefaultSms); updateInputUI(recipient, isSecureText, isDefaultSms);
} }
///// Initializers ///// Initializers
@ -1627,7 +1627,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
unblockButton = ViewUtil.findById(this, R.id.unblock_button); unblockButton = ViewUtil.findById(this, R.id.unblock_button);
makeDefaultSmsButton = ViewUtil.findById(this, R.id.make_default_sms_button); makeDefaultSmsButton = ViewUtil.findById(this, R.id.make_default_sms_button);
registerButton = ViewUtil.findById(this, R.id.register_button); registerButton = ViewUtil.findById(this, R.id.register_button);
composePanel = ViewUtil.findById(this, R.id.bottom_panel);
container = ViewUtil.findById(this, R.id.layout_container); container = ViewUtil.findById(this, R.id.layout_container);
reminderView = ViewUtil.findStubById(this, R.id.reminder_stub); reminderView = ViewUtil.findStubById(this, R.id.reminder_stub);
unverifiedBannerView = ViewUtil.findStubById(this, R.id.unverified_banner_stub); unverifiedBannerView = ViewUtil.findStubById(this, R.id.unverified_banner_stub);
@ -1835,7 +1834,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
updateTitleTextView(recipient); updateTitleTextView(recipient);
updateSubtitleTextView(); updateSubtitleTextView();
// titleView.setVerified(identityRecords.isVerified()); // titleView.setVerified(identityRecords.isVerified());
setBlockedUserState(recipient, isSecureText, isDefaultSms); updateInputUI(recipient, isSecureText, isDefaultSms);
setActionBarColor(recipient.getColor()); setActionBarColor(recipient.getColor());
setGroupShareProfileReminder(recipient); setGroupShareProfileReminder(recipient);
updateReminders(recipient.hasSeenInviteReminder()); updateReminders(recipient.hasSeenInviteReminder());
@ -2043,29 +2042,29 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
setStatusBarColor(getResources().getColor(R.color.action_bar_background)); setStatusBarColor(getResources().getColor(R.color.action_bar_background));
} }
private void setBlockedUserState(Recipient recipient, boolean isSecureText, boolean isDefaultSms) { private void updateInputUI(Recipient recipient, boolean isSecureText, boolean isDefaultSms) {
if (recipient.isGroupRecipient() && recipient.getAddress().isRSSFeed()) { if (recipient.isGroupRecipient() && !isActiveGroup()) {
unblockButton.setVisibility(View.GONE); unblockButton.setVisibility(View.GONE);
composePanel.setVisibility(View.GONE); inputPanel.setVisibility(View.GONE);
makeDefaultSmsButton.setVisibility(View.GONE); makeDefaultSmsButton.setVisibility(View.GONE);
registerButton.setVisibility(View.GONE); registerButton.setVisibility(View.GONE);
} else if (recipient.isBlocked()) { } else if (recipient.isBlocked()) {
unblockButton.setVisibility(View.VISIBLE); unblockButton.setVisibility(View.VISIBLE);
composePanel.setVisibility(View.GONE); inputPanel.setVisibility(View.GONE);
makeDefaultSmsButton.setVisibility(View.GONE); makeDefaultSmsButton.setVisibility(View.GONE);
registerButton.setVisibility(View.GONE); registerButton.setVisibility(View.GONE);
} else if (!isSecureText && isPushGroupConversation()) { } else if (!isSecureText && isPushGroupConversation()) {
unblockButton.setVisibility(View.GONE); unblockButton.setVisibility(View.GONE);
composePanel.setVisibility(View.GONE); inputPanel.setVisibility(View.GONE);
makeDefaultSmsButton.setVisibility(View.GONE); makeDefaultSmsButton.setVisibility(View.GONE);
registerButton.setVisibility(View.VISIBLE); registerButton.setVisibility(View.VISIBLE);
} else if (!isSecureText && !isDefaultSms) { } else if (!isSecureText && !isDefaultSms) {
unblockButton.setVisibility(View.GONE); unblockButton.setVisibility(View.GONE);
composePanel.setVisibility(View.GONE); inputPanel.setVisibility(View.GONE);
makeDefaultSmsButton.setVisibility(View.VISIBLE); makeDefaultSmsButton.setVisibility(View.VISIBLE);
registerButton.setVisibility(View.GONE); registerButton.setVisibility(View.GONE);
} else { } else {
composePanel.setVisibility(View.VISIBLE); inputPanel.setVisibility(View.VISIBLE);
unblockButton.setVisibility(View.GONE); unblockButton.setVisibility(View.GONE);
makeDefaultSmsButton.setVisibility(View.GONE); makeDefaultSmsButton.setVisibility(View.GONE);
registerButton.setVisibility(View.GONE); registerButton.setVisibility(View.GONE);
@ -2125,7 +2124,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
} }
private boolean isActiveGroup() { private boolean isActiveGroup() {
if (!isGroupConversation()) return false; if (!isGroupConversation() || recipient.getAddress().isRSSFeed()) return false;
Optional<GroupRecord> record = DatabaseFactory.getGroupDatabase(this).getGroup(getRecipient().getAddress().toGroupString()); Optional<GroupRecord> record = DatabaseFactory.getGroupDatabase(this).getGroup(getRecipient().getAddress().toGroupString());
return record.isPresent() && record.get().isActive(); return record.isPresent() && record.get().isActive();
@ -2314,7 +2313,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
String hint = enabled ? "Message" : "Pending session request"; String hint = enabled ? "Message" : "Pending session request";
inputPanel.setHint(hint); inputPanel.setHint(hint);
inputPanel.setEnabled(enabled); inputPanel.setEnabled(enabled);
if (enabled) { if (enabled && inputPanel.getVisibility() == View.VISIBLE) {
inputPanel.composeText.requestFocus(); inputPanel.composeText.requestFocus();
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(inputPanel.composeText, 0); inputMethodManager.showSoftInput(inputPanel.composeText, 0);
@ -2939,6 +2938,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override @Override
public void handleReplyMessage(MessageRecord messageRecord) { public void handleReplyMessage(MessageRecord messageRecord) {
if (recipient.isGroupRecipient() && !isActiveGroup()) { return; }
Recipient author; Recipient author;
if (messageRecord.isOutgoing()) { if (messageRecord.isOutgoing()) {