|
|
|
@ -49,6 +49,7 @@ import android.view.View;
|
|
|
|
|
import android.view.View.OnClickListener;
|
|
|
|
|
import android.view.View.OnFocusChangeListener;
|
|
|
|
|
import android.view.View.OnKeyListener;
|
|
|
|
|
import android.view.ViewStub;
|
|
|
|
|
import android.view.inputmethod.EditorInfo;
|
|
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
@ -68,13 +69,12 @@ import org.thoughtcrime.securesms.components.KeyboardAwareLinearLayout;
|
|
|
|
|
import org.thoughtcrime.securesms.components.KeyboardAwareLinearLayout.OnKeyboardShownListener;
|
|
|
|
|
import org.thoughtcrime.securesms.components.SendButton;
|
|
|
|
|
import org.thoughtcrime.securesms.components.emoji.EmojiDrawer.EmojiEventListener;
|
|
|
|
|
import org.thoughtcrime.securesms.components.emoji.EmojiPopup;
|
|
|
|
|
import org.thoughtcrime.securesms.components.emoji.EmojiDrawer;
|
|
|
|
|
import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
|
|
|
|
|
import org.thoughtcrime.securesms.contacts.ContactAccessor;
|
|
|
|
|
import org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData;
|
|
|
|
|
import org.thoughtcrime.securesms.components.camera.HidingImageButton;
|
|
|
|
|
import org.thoughtcrime.securesms.components.camera.QuickAttachmentDrawer.AttachmentDrawerListener;
|
|
|
|
|
import org.thoughtcrime.securesms.components.camera.QuickAttachmentDrawer.DrawerState;
|
|
|
|
|
import org.thoughtcrime.securesms.components.camera.QuickAttachmentDrawer;
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
|
|
@ -178,7 +178,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
private AttachmentManager attachmentManager;
|
|
|
|
|
private BroadcastReceiver securityUpdateReceiver;
|
|
|
|
|
private BroadcastReceiver groupUpdateReceiver;
|
|
|
|
|
private Optional<EmojiPopup> emojiPopup = Optional.absent();
|
|
|
|
|
private Optional<EmojiDrawer> emojiDrawer = Optional.absent();
|
|
|
|
|
private EmojiToggle emojiToggle;
|
|
|
|
|
protected HidingImageButton quickAttachmentToggle;
|
|
|
|
|
private QuickAttachmentDrawer quickAttachmentDrawer;
|
|
|
|
@ -267,7 +267,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
@Override public void onConfigurationChanged(Configuration newConfig) {
|
|
|
|
|
super.onConfigurationChanged(newConfig);
|
|
|
|
|
quickAttachmentDrawer.onConfigurationChanged();
|
|
|
|
|
hideEmojiPopup(false);
|
|
|
|
|
hideEmojiDrawer(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -276,7 +276,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
if (recipients != null) recipients.removeListener(this);
|
|
|
|
|
if (securityUpdateReceiver != null) unregisterReceiver(securityUpdateReceiver);
|
|
|
|
|
if (groupUpdateReceiver != null) unregisterReceiver(groupUpdateReceiver);
|
|
|
|
|
if (isEmojiDrawerOpen()) hideEmojiPopup(false);
|
|
|
|
|
if (isEmojiDrawerOpen()) hideEmojiDrawer(false);
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -384,8 +384,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onBackPressed() {
|
|
|
|
|
Log.w(TAG, "onBackPressed()");
|
|
|
|
|
if (isEmojiDrawerOpen()) {
|
|
|
|
|
hideEmojiPopup(false);
|
|
|
|
|
Log.w(TAG, "hiding emoji popup");
|
|
|
|
|
hideEmojiDrawer(false);
|
|
|
|
|
} else if (quickAttachmentDrawer.isOpen()) {
|
|
|
|
|
quickAttachmentDrawer.close();
|
|
|
|
|
} else {
|
|
|
|
@ -395,7 +397,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onKeyboardShown() {
|
|
|
|
|
hideEmojiPopup(true);
|
|
|
|
|
hideEmojiDrawer(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////// Event Handlers
|
|
|
|
@ -866,10 +868,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private EmojiPopup getEmojiPopup() {
|
|
|
|
|
if (!emojiPopup.isPresent()) {
|
|
|
|
|
EmojiPopup emojiPopup = new EmojiPopup(container);
|
|
|
|
|
emojiPopup.setEmojiEventListener(new EmojiEventListener() {
|
|
|
|
|
private EmojiDrawer getEmojiDrawer() {
|
|
|
|
|
if (!emojiDrawer.isPresent()) {
|
|
|
|
|
EmojiDrawer emojiDrawer = (EmojiDrawer)((ViewStub)findViewById(R.id.emoji_drawer_stub)).inflate();
|
|
|
|
|
emojiDrawer.setEmojiEventListener(new EmojiEventListener() {
|
|
|
|
|
@Override public void onKeyEvent(KeyEvent keyEvent) {
|
|
|
|
|
composeText.dispatchKeyEvent(keyEvent);
|
|
|
|
|
}
|
|
|
|
@ -879,28 +881,33 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
composeText.insertEmoji(emoji);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.emojiPopup = Optional.of(emojiPopup);
|
|
|
|
|
this.emojiDrawer = Optional.of(emojiDrawer);
|
|
|
|
|
}
|
|
|
|
|
return emojiPopup.get();
|
|
|
|
|
return emojiDrawer.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showEmojiPopup() {
|
|
|
|
|
getEmojiPopup().show();
|
|
|
|
|
private void showEmojiDrawer() {
|
|
|
|
|
getEmojiDrawer().show(container);
|
|
|
|
|
emojiToggle.setToIme();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void hideEmojiPopup(boolean expectingKeyboard) {
|
|
|
|
|
protected void hideEmojiDrawer(boolean expectingKeyboard) {
|
|
|
|
|
if (isEmojiDrawerOpen()) {
|
|
|
|
|
getEmojiPopup().dismiss();
|
|
|
|
|
if (!expectingKeyboard || container.isLandscape()) {
|
|
|
|
|
container.unpadForCustomKeyboard();
|
|
|
|
|
getEmojiDrawer().dismiss();
|
|
|
|
|
} else {
|
|
|
|
|
container.postOnKeyboardOpen(new Runnable() {
|
|
|
|
|
@Override public void run() {
|
|
|
|
|
getEmojiDrawer().dismiss();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
emojiToggle.setToEmoji();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isEmojiDrawerOpen() {
|
|
|
|
|
return emojiPopup.isPresent() && emojiPopup.get().isShowing();
|
|
|
|
|
return emojiDrawer.isPresent() && emojiDrawer.get().isShowing();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initializeResources() {
|
|
|
|
@ -1358,12 +1365,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
Log.w(TAG, "EmojiToggleListener onClick()");
|
|
|
|
|
if (isEmojiDrawerOpen()) {
|
|
|
|
|
hideEmojiPopup(true);
|
|
|
|
|
hideEmojiDrawer(true);
|
|
|
|
|
openKeyboardForComposition();
|
|
|
|
|
} else {
|
|
|
|
|
container.postOnKeyboardClose(new Runnable() {
|
|
|
|
|
@Override public void run() {
|
|
|
|
|
showEmojiPopup();
|
|
|
|
|
showEmojiDrawer();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
quickAttachmentDrawer.close();
|
|
|
|
@ -1378,7 +1385,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
InputMethodManager input = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
input.hideSoftInputFromWindow(composeText.getWindowToken(), 0);
|
|
|
|
|
composeText.clearFocus();
|
|
|
|
|
hideEmojiPopup(false);
|
|
|
|
|
hideEmojiDrawer(false);
|
|
|
|
|
quickAttachmentDrawer.open();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1426,7 +1433,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
hideEmojiPopup(true);
|
|
|
|
|
hideEmojiDrawer(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -1454,7 +1461,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|
|
|
|
@Override
|
|
|
|
|
public void onFocusChange(View v, boolean hasFocus) {
|
|
|
|
|
if (hasFocus && isEmojiDrawerOpen()) {
|
|
|
|
|
hideEmojiPopup(true);
|
|
|
|
|
hideEmojiDrawer(true);
|
|
|
|
|
} else if (hasFocus && quickAttachmentDrawer.isOpen()) {
|
|
|
|
|
quickAttachmentDrawer.close();
|
|
|
|
|
}
|
|
|
|
|