正在查看: Delta Chat v1.58.3 应用的 ConversationActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Delta Chat v1.58.3 应用的 ConversationActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.thoughtcrime.securesms;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.util.Pair;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.FragmentActivity;
import com.b44t.messenger.DcChat;
import com.b44t.messenger.DcContact;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcMsg;
import com.b44t.messenger.rpc.Rpc;
import com.b44t.messenger.rpc.RpcException;
import com.b44t.messenger.util.concurrent.ListenableFuture;
import com.b44t.messenger.util.concurrent.SettableFuture;
import java.io.File;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;
import kotlinx.coroutines.scheduling.WorkQueueKt;
import org.thoughtcrime.securesms.ConversationActivity;
import org.thoughtcrime.securesms.ConversationFragment;
import org.thoughtcrime.securesms.EphemeralMessagesDialog;
import org.thoughtcrime.securesms.MuteDialog;
import org.thoughtcrime.securesms.TransportOption;
import org.thoughtcrime.securesms.TransportOptions;
import org.thoughtcrime.securesms.attachments.UriAttachment;
import org.thoughtcrime.securesms.audio.AudioRecorder;
import org.thoughtcrime.securesms.audio.AudioSlidePlayer;
import org.thoughtcrime.securesms.components.AnimatingToggle;
import org.thoughtcrime.securesms.components.AttachmentTypeSelector;
import org.thoughtcrime.securesms.components.ComposeText;
import org.thoughtcrime.securesms.components.HidingLinearLayout;
import org.thoughtcrime.securesms.components.InputAwareLayout;
import org.thoughtcrime.securesms.components.InputPanel;
import org.thoughtcrime.securesms.components.KeyboardAwareLinearLayout;
import org.thoughtcrime.securesms.components.ScaleStableImageView;
import org.thoughtcrime.securesms.components.SendButton;
import org.thoughtcrime.securesms.components.emoji.MediaKeyboard;
import org.thoughtcrime.securesms.connect.AccountManager;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.connect.DirectShareUtil;
import org.thoughtcrime.securesms.messagerequests.MessageRequestsBottomView;
import org.thoughtcrime.securesms.mms.AttachmentManager;
import org.thoughtcrime.securesms.mms.AudioSlide;
import org.thoughtcrime.securesms.mms.GlideApp;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.mms.QuoteModel;
import org.thoughtcrime.securesms.mms.SlideDeck;
import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.providers.PersistentBlobProvider;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.Prefs;
import org.thoughtcrime.securesms.util.RelayUtil;
import org.thoughtcrime.securesms.util.SendRelayedMessageUtil;
import org.thoughtcrime.securesms.util.ServiceUtil;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener;
import org.thoughtcrime.securesms.util.guava.Optional;
import org.thoughtcrime.securesms.util.views.ProgressDialog;
import org.thoughtcrime.securesms.videochat.VideochatUtil;
public class ConversationActivity extends PassphraseRequiredActionBarActivity implements ConversationFragment.ConversationFragmentListener, AttachmentManager.AttachmentListener, SearchView.OnQueryTextListener, DcEventCenter.DcEventDelegate, KeyboardAwareLinearLayout.OnKeyboardShownListener, InputPanel.Listener, InputPanel.MediaListener {
public static final String ACCOUNT_ID_EXTRA = "account_id";
protected static final int ACTION_SAVE_DRAFT = 2;
protected static final int ACTION_SEND_OUT = 1;
public static final String CHAT_ID_EXTRA = "chat_id";
public static final String FROM_ARCHIVED_CHATS_EXTRA = "from_archived";
private static final int GROUP_EDIT = 6;
private static final int PICK_CONTACT = 4;
private static final int PICK_DOCUMENT = 2;
private static final int PICK_GALLERY = 1;
private static final int PICK_WEBXDC = 9;
private static final int RECORD_VIDEO = 8;
public static final String STARTING_POSITION_EXTRA = "starting_position";
private static final String TAG = "ConversationActivity";
private static final int TAKE_PHOTO = 7;
public static final String TEXT_EXTRA = "draft_text";
private ImageButton attachButton;
private AttachmentManager attachmentManager;
private AttachmentTypeSelector attachmentTypeSelector;
private AudioRecorder audioRecorder;
private ScaleStableImageView backgroundView;
private AnimatingToggle buttonToggle;
private int chatId;
private View composePanel;
protected ComposeText composeText;
private InputAwareLayout container;
private ApplicationContext context;
private DcContext dcContext;
private MediaKeyboard emojiPicker;
private FrameLayout emojiPickerContainer;
private ConversationFragment fragment;
private GlideRequests glideRequests;
private InputPanel inputPanel;
private MessageRequestsBottomView messageRequestBottomView;
private ProgressDialog progressDialog;
protected HidingLinearLayout quickAttachmentToggle;
private Recipient recipient;
private Rpc rpc;
private SendButton sendButton;
protected ConversationTitleView titleView;
private DcChat dcChat = new DcChat(0, 0);
private final boolean isSecureText = true;
private boolean isDefaultSms = true;
private boolean isSecurityInitialized = false;
private boolean successfulForwardingAttempt = false;
private boolean isEditing = false;
private int beforeSearchComposeVisibility = 0;
private Menu searchMenu = null;
private int[] searchResult = new int[0];
private int searchResultPosition = -1;
private Toast lastToast = null;
public boolean onQueryTextSubmit(String str) {
return true;
}
@Override
public boolean runOnMain() {
return DcEventCenter.DcEventDelegate.CC.$default$runOnMain(this);
}
@Override
protected void onCreate(Bundle bundle, boolean z) {
?? applicationContext = ApplicationContext.getInstance(getApplicationContext());
this.context = applicationContext;
this.dcContext = DcHelper.getContext(applicationContext);
this.rpc = DcHelper.getRpc(this.context);
supportRequestWindowFeature(PICK_WEBXDC);
setContentView(R.layout.conversation_activity);
TypedArray obtainStyledAttributes = obtainStyledAttributes(new int[]{R.attr.conversation_background});
int color = obtainStyledAttributes.getColor(0, -1);
obtainStyledAttributes.recycle();
getWindow().getDecorView().setBackgroundColor(color);
this.fragment = (ConversationFragment) initFragment(R.id.fragment_content, new ConversationFragment());
initializeActionBar();
initializeViews();
initializeResources();
initializeSecurity(false, this.isDefaultSms).addListener(new AssertedSuccessListener<Boolean>() {
class C00021 extends AssertedSuccessListener<Boolean> {
C00021() {
}
public void onSuccess(Boolean bool) {
if (bool == null || !bool.booleanValue()) {
return;
}
Util.runOnMain(new Runnable() {
@Override
public final void run() {
ConversationActivity.AnonymousClass1.C00021.this.m1203xe85032b1();
}
});
}
void m1203xe85032b1() {
if (ConversationActivity.this.fragment == null || !ConversationActivity.this.fragment.isResumed()) {
Log.w(ConversationActivity.TAG, "Wanted to move to the last seen position, but the fragment was in an invalid state");
} else {
ConversationActivity.this.fragment.moveToLastSeen();
}
}
}
public void onSuccess(Boolean bool) {
ConversationActivity.this.initializeDraft().addListener(new C00021());
}
});
DcEventCenter eventCenter = DcHelper.getEventCenter(this);
eventCenter.addObserver(2020, this);
eventCenter.addObserver(2021, this);
eventCenter.addObserver(2030, this);
if (!isMultiUser()) {
eventCenter.addObserver(2005, this);
eventCenter.addObserver(2015, this);
}
handleRelaying();
}
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (isFinishing()) {
return;
}
if (!Util.isEmpty(this.composeText) || this.attachmentManager.isAttachmentPresent()) {
processComposeControls(2);
this.attachmentManager.clear(this.glideRequests, false);
this.composeText.setText("");
}
setIntent(intent);
initializeResources();
initializeSecurity(false, this.isDefaultSms).addListener(new AssertedSuccessListener<Boolean>() {
public void onSuccess(Boolean bool) {
ConversationActivity.this.initializeDraft();
}
});
handleRelaying();
ConversationFragment conversationFragment = this.fragment;
if (conversationFragment != null) {
conversationFragment.onNewIntent();
}
}
private void handleRelaying() {
if (RelayUtil.isForwarding(this)) {
handleForwarding();
} else if (RelayUtil.isSharing(this)) {
handleSharing();
}
ConversationListRelayingActivity.finishActivity();
}
@Override
protected void onResume() {
super.onResume();
initializeEnabledCheck();
this.composeText.setTransport(this.sendButton.getSelectedTransport());
this.titleView.setTitle(this.glideRequests, this.dcChat);
DcHelper.getNotificationCenter(this).updateVisibleChat(this.dcContext.getAccountId(), this.chatId);
this.attachmentManager.onResume();
}
protected void onPause() {
super.onPause();
processComposeControls(2);
DcHelper.getNotificationCenter(this).clearVisibleChat();
if (isFinishing()) {
overridePendingTransition(R.anim.fade_scale_in, R.anim.slide_to_right);
}
this.inputPanel.onPause();
AudioSlidePlayer.stopAll();
}
public void onConfigurationChanged(Configuration configuration) {
Log.i(TAG, "onConfigurationChanged(" + configuration.orientation + ")");
super.onConfigurationChanged(configuration);
this.composeText.setTransport(this.sendButton.getSelectedTransport());
if (this.emojiPicker != null && this.container.getCurrentInput() == this.emojiPicker) {
this.container.hideAttachedInput(true);
}
this.emojiPicker = null;
initializeBackground();
}
protected void onDestroy() {
DcHelper.getEventCenter(this).removeObservers(this);
super.onDestroy();
}
public void onActivityResult(int i, int i2, Intent intent) {
int itemCount;
AttachmentManager.MediaType mediaType;
super.onActivityResult(i, i2, intent);
if (i2 == -1) {
if (intent != null || i == 7 || i == 8) {
if (i == 1) {
Uri data = intent.getData();
if (data != null) {
String mimeType = MediaUtil.getMimeType(this, data);
if (MediaUtil.isGif(mimeType)) {
mediaType = AttachmentManager.MediaType.GIF;
} else {
mediaType = MediaUtil.isVideo(mimeType) ? AttachmentManager.MediaType.VIDEO : AttachmentManager.MediaType.IMAGE;
}
setMedia(data, mediaType);
return;
}
ClipData clipData = intent.getClipData();
if (clipData == null || (itemCount = clipData.getItemCount()) <= 0) {
return;
}
final ArrayList arrayList = new ArrayList(itemCount);
for (int i3 = 0; i3 < itemCount; i3++) {
arrayList.add(clipData.getItemAt(i3).getUri());
}
askSendingFiles(arrayList, new Runnable() {
@Override
public final void run() {
ConversationActivity.this.m1196x17f71699(arrayList);
}
});
return;
}
if (i == 2) {
setMedia(intent.getData(), MediaUtil.isAudioType(MediaUtil.getMimeType(this, intent.getData())) ? AttachmentManager.MediaType.AUDIO : AttachmentManager.MediaType.DOCUMENT);
return;
}
if (i == 4) {
addAttachmentContactInfo(intent.getIntExtra(AttachContactActivity.CONTACT_ID_EXTRA, 0));
return;
}
if (i != 31424) {
switch (i) {
case 6:
DcChat chat = this.dcContext.getChat(this.chatId);
this.dcChat = chat;
this.titleView.setTitle(this.glideRequests, chat);
break;
case 7:
if (this.attachmentManager.getImageCaptureUri() != null) {
setMedia(this.attachmentManager.getImageCaptureUri(), AttachmentManager.MediaType.IMAGE);
break;
}
break;
case 8:
Uri data2 = intent != null ? intent.getData() : null;
if (data2 == null) {
data2 = this.attachmentManager.getVideoCaptureUri();
}
if (data2 != null) {
setMedia(data2, AttachmentManager.MediaType.VIDEO);
break;
} else {
Toast.makeText((Context) this, (CharSequence) "No video returned from system", 1).show();
break;
}
case PICK_WEBXDC:
setMedia(intent.getData(), AttachmentManager.MediaType.DOCUMENT);
break;
}
return;
}
setMedia(intent.getData(), AttachmentManager.MediaType.IMAGE);
}
}
}
void m1196x17f71699(final ArrayList arrayList) {
Util.runOnAnyBackgroundThread(new Runnable() {
@Override
public final void run() {
ConversationActivity.this.m1195x186d7c98(arrayList);
}
});
}
void m1195x186d7c98(ArrayList arrayList) {
SendRelayedMessageUtil.sendMultipleMsgs(this, this.chatId, arrayList, null);
}
public void startActivity(Intent intent) {
if (intent.getStringExtra("com.android.browser.application_id") != null) {
intent.removeExtra("com.android.browser.application_id");
}
try {
super.startActivity(intent);
} catch (ActivityNotFoundException e) {
Log.w(TAG, e);
Toast.makeText((Context) this, R.string.no_app_to_handle_data, 1).show();
}
}
public boolean onPrepareOptionsMenu(final Menu menu) {
MenuItem findItem;
menu.clear();
getMenuInflater().inflate(R.menu.conversation, menu);
if (this.dcChat.isSelfTalk() || this.dcChat.isBroadcast()) {
menu.findItem(R.id.menu_mute_notifications).setVisible(false);
} else if (this.dcChat.isMuted()) {
menu.findItem(R.id.menu_mute_notifications).setTitle(R.string.menu_unmute);
}
if (!Prefs.isLocationStreamingEnabled(this)) {
menu.findItem(R.id.menu_show_map).setVisible(false);
}
if (!this.dcChat.canSend() || this.dcChat.isBroadcast() || this.dcChat.isMailingList()) {
menu.findItem(R.id.menu_ephemeral_messages).setVisible(false);
}
if (isMultiUser() && this.dcChat.canSend() && !this.dcChat.isBroadcast() && !this.dcChat.isMailingList()) {
menu.findItem(R.id.menu_leave).setVisible(true);
}
if (isArchived()) {
menu.findItem(R.id.menu_archive_chat).setTitle(R.string.menu_unarchive_chat);
}
Util.redMenuItem(menu, R.id.menu_leave);
Util.redMenuItem(menu, R.id.menu_clear_chat);
Util.redMenuItem(menu, R.id.menu_delete_chat);
try {
MenuItem findItem2 = menu.findItem(R.id.menu_search_chat);
findItem2.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem menuItem) {
ConversationActivity.this.searchExpand(menu, menuItem);
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
ConversationActivity.this.searchCollapse(menu, menuItem);
return true;
}
});
SearchView actionView = findItem2.getActionView();
actionView.setOnQueryTextListener(this);
actionView.setQueryHint(getString(R.string.search));
actionView.setIconifiedByDefault(true);
ImageView imageView = (ImageView) actionView.findViewById(R.id.search_close_btn);
if (imageView != null) {
imageView.setEnabled(false);
imageView.setImageDrawable(null);
}
} catch (Exception e) {
Log.e(TAG, "cannot set up in-chat-search: ", e);
}
if ((!this.dcChat.canSend() || this.isEditing) && (findItem = menu.findItem(R.id.menu_add_attachment)) != null) {
findItem.setVisible(false);
}
super.onPrepareOptionsMenu(menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
super.onOptionsItemSelected(menuItem);
int itemId = menuItem.getItemId();
if (itemId == R.id.menu_add_attachment) {
handleAddAttachment();
return true;
}
if (itemId == R.id.menu_leave) {
handleLeaveGroup();
return true;
}
if (itemId == R.id.menu_archive_chat) {
handleArchiveChat();
return true;
}
if (itemId == R.id.menu_clear_chat) {
this.fragment.handleClearChat();
return true;
}
if (itemId == R.id.menu_delete_chat) {
handleDeleteChat();
return true;
}
if (itemId == R.id.menu_mute_notifications) {
handleMuteNotifications();
return true;
}
if (itemId == R.id.menu_show_map) {
WebxdcActivity.openMaps(this, this.chatId);
return true;
}
if (itemId == R.id.menu_search_up) {
handleMenuSearchNext(false);
return true;
}
if (itemId == R.id.menu_search_down) {
handleMenuSearchNext(true);
return true;
}
if (itemId == 16908332) {
handleReturnToConversationList();
return true;
}
if (itemId != R.id.menu_ephemeral_messages) {
return false;
}
handleEphemeralMessages();
return true;
}
public void onBackPressed() {
if (this.container.isInputOpen()) {
this.container.hideCurrentInput(this.composeText);
} else {
handleReturnToConversationList();
}
}
@Override
public void onKeyboardShown() {
this.inputPanel.onKeyboardShown();
}
public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
Permissions.onRequestPermissionsResult((Activity) this, i, strArr, iArr);
}
public void setDraftText(String str) {
this.composeText.setText(str);
ComposeText composeText = this.composeText;
composeText.setSelection(composeText.getText().length());
}
public void hideSoftKeyboard() {
this.container.hideCurrentInput(this.composeText);
}
private void handleEphemeralMessages() {
EphemeralMessagesDialog.show(this, this.dcContext.getChatEphemeralTimer(this.chatId), new EphemeralMessagesDialog.EphemeralMessagesInterface() {
@Override
public final void onTimeSelected(long j) {
ConversationActivity.this.m1180x6ebb2d76(j);
}
});
}
void m1180x6ebb2d76(long j) {
this.dcContext.setChatEphemeralTimer(this.chatId, (int) j);
}
private void handleReturnToConversationList() {
handleReturnToConversationList(null);
}
private void handleReturnToConversationList(Bundle bundle) {
Intent intent = new Intent((Context) this, (Class<?>) (getIntent().getBooleanExtra(FROM_ARCHIVED_CHATS_EXTRA, false) ? ConversationListArchiveActivity.class : ConversationListActivity.class));
intent.setFlags(67108864);
if (bundle != null) {
intent.putExtras(bundle);
}
startActivity(intent);
finish();
}
private void handleMuteNotifications() {
if (!this.dcChat.isMuted()) {
MuteDialog.show(this, new MuteDialog.MuteSelectionListener() {
@Override
public final void onMuted(long j) {
ConversationActivity.this.m1185x9aa5fb3d(j);
}
});
} else {
this.dcContext.setChatMuteDuration(this.chatId, 0L);
this.titleView.setTitle(this.glideRequests, this.dcChat);
}
}
void m1185x9aa5fb3d(long j) {
this.dcContext.setChatMuteDuration(this.chatId, j);
this.titleView.setTitle(this.glideRequests, this.dcChat);
}
private void handleProfile() {
Intent intent = new Intent((Context) this, (Class<?>) ProfileActivity.class);
intent.putExtra("chat_id", this.chatId);
intent.putExtra(ProfileActivity.FROM_CHAT, true);
startActivity(intent);
overridePendingTransition(0, 0);
}
private void handleLeaveGroup() {
Util.redPositiveButton(new AlertDialog.Builder(this).setMessage(getString(R.string.ask_leave_group)).setPositiveButton(R.string.menu_leave_group, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ConversationActivity.this.m1184x19b15be1(dialogInterface, i);
}
}).setNegativeButton(R.string.cancel, (DialogInterface.OnClickListener) null).show());
}
void m1184x19b15be1(DialogInterface dialogInterface, int i) {
this.dcContext.removeContactFromChat(this.chatId, 1);
Toast.makeText((Context) this, (CharSequence) getString(R.string.done), 0).show();
}
private void handleArchiveChat() {
int i = !isArchived() ? 1 : 0;
this.dcContext.setChatVisibility(this.chatId, i);
Toast.makeText((Context) this, (CharSequence) getString(R.string.done), 0).show();
if (i == 1) {
finish();
} else {
this.dcChat = this.dcContext.getChat(this.chatId);
}
}
private void handleDeleteChat() {
Util.redPositiveButton(new AlertDialog.Builder(this).setMessage(getResources().getString(R.string.ask_delete_named_chat, this.dcChat.getName())).setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ConversationActivity.this.m1179x342226bd(dialogInterface, i);
}
}).setNegativeButton(R.string.cancel, (DialogInterface.OnClickListener) null).show());
}
void m1179x342226bd(DialogInterface dialogInterface, int i) {
this.dcContext.deleteChat(this.chatId);
DirectShareUtil.clearShortcut(this, this.chatId);
finish();
}
public void handleAddAttachment() {
if (this.attachmentTypeSelector == null) {
this.attachmentTypeSelector = new AttachmentTypeSelector(this, getSupportLoaderManager(), new AttachmentTypeListener(), this.chatId);
}
this.attachmentTypeSelector.show(this, this.attachButton);
}
private void handleSecurityChange(boolean z, boolean z2) {
Log.i(TAG, "handleSecurityChange(" + z + ", " + z2 + ")");
if (this.isSecurityInitialized && z && z2 == this.isDefaultSms) {
return;
}
this.isDefaultSms = z2;
this.isSecurityInitialized = true;
this.sendButton.resetAvailableTransports();
this.sendButton.setDefaultTransport(TransportOption.Type.NORMAL_MAIL);
}
private void handleForwarding() {
DcChat chat = this.dcContext.getChat(this.chatId);
if (chat.isSelfTalk()) {
SendRelayedMessageUtil.immediatelyRelay((Activity) this, this.chatId);
return;
}
String name = chat.getName();
if (!chat.isMultiUser()) {
int[] chatContacts = this.dcContext.getChatContacts(this.chatId);
if (chatContacts.length == 1 || chatContacts.length == 2) {
name = this.dcContext.getContact(chatContacts[0]).getDisplayName();
}
}
new AlertDialog.Builder(this).setMessage(getString(R.string.ask_forward, new Object[]{name})).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ConversationActivity.this.m1181xabba0998(dialogInterface, i);
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ConversationActivity.this.m1182xab43a399(dialogInterface, i);
}
}).setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
ConversationActivity.this.m1183xaacd3d9a(dialogInterface);
}
}).show();
}
void m1181xabba0998(DialogInterface dialogInterface, int i) {
SendRelayedMessageUtil.immediatelyRelay((Activity) this, this.chatId);
this.successfulForwardingAttempt = true;
}
void m1182xab43a399(DialogInterface dialogInterface, int i) {
finish();
}
void m1183xaacd3d9a(DialogInterface dialogInterface) {
finish();
}
private void askSendingFiles(ArrayList<Uri> arrayList, final Runnable runnable) {
String format = String.format(getString(R.string.ask_send_files_to_chat), Integer.valueOf(arrayList.size()), this.dcChat.getName());
if (SendRelayedMessageUtil.containsVideoType(this.context, arrayList)) {
format = format + "\n\n" + getString(R.string.videos_sent_without_recoding);
}
new AlertDialog.Builder(this).setMessage(format).setCancelable(false).setNegativeButton(android.R.string.cancel, (DialogInterface.OnClickListener) null).setPositiveButton(R.string.menu_send, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
runnable.run();
}
}).show();
}
private void handleSharing() {
ArrayList<Uri> sharedUris = RelayUtil.getSharedUris(this);
int sharedContactId = RelayUtil.getSharedContactId(this);
if (sharedUris.size() > 1) {
askSendingFiles(sharedUris, new Runnable() {
@Override
public final void run() {
ConversationActivity.this.m1186x7fcd970();
}
});
return;
}
if (sharedContactId != 0) {
addAttachmentContactInfo(sharedContactId);
} else if (sharedUris.isEmpty()) {
this.dcContext.setDraft(this.chatId, SendRelayedMessageUtil.createMessage(this, null, RelayUtil.getSharedText(this)));
} else {
this.dcContext.setDraft(this.chatId, SendRelayedMessageUtil.createMessage(this, sharedUris.get(0), RelayUtil.getSharedText(this)));
}
initializeDraft();
}
void m1186x7fcd970() {
SendRelayedMessageUtil.immediatelyRelay((Activity) this, this.chatId);
}
public ListenableFuture<Boolean> initializeDraft() {
this.isEditing = false;
final SettableFuture settableFuture = new SettableFuture();
DcMsg draft = this.dcContext.getDraft(this.chatId);
final String sharedText = RelayUtil.getSharedText(this);
if (!draft.isOk()) {
if (TextUtils.isEmpty(sharedText)) {
settableFuture.set(false);
} else {
this.composeText.setText(sharedText);
settableFuture.set(true);
}
updateToggleButtonState();
return settableFuture;
}
if (TextUtils.isEmpty(sharedText)) {
sharedText = draft.getText();
}
if (!sharedText.isEmpty()) {
this.composeText.setText(sharedText);
ComposeText composeText = this.composeText;
composeText.setSelection(composeText.getText().length());
}
DcMsg quotedMsg = draft.getQuotedMsg();
if (quotedMsg == null) {
this.inputPanel.clearQuoteWithoutAnimation();
} else {
handleReplyMessage(quotedMsg);
}
String file = draft.getFile();
if (file.isEmpty() || !new File(file).exists()) {
settableFuture.set(Boolean.valueOf(!sharedText.isEmpty()));
updateToggleButtonState();
return settableFuture;
}
ListenableFuture.Listener<Boolean> listener = new ListenableFuture.Listener<Boolean>() {
public void onSuccess(Boolean bool) {
settableFuture.set(Boolean.valueOf(bool.booleanValue() || !sharedText.isEmpty()));
ConversationActivity.this.updateToggleButtonState();
}
public void onFailure(ExecutionException executionException) {
settableFuture.set(Boolean.valueOf(!sharedText.isEmpty()));
ConversationActivity.this.updateToggleButtonState();
}
};
int type = draft.getType();
if (type == 20) {
setMedia(draft, AttachmentManager.MediaType.IMAGE).addListener(listener);
} else if (type == 21) {
setMedia(draft, AttachmentManager.MediaType.GIF).addListener(listener);
} else if (type == 40) {
setMedia(draft, AttachmentManager.MediaType.AUDIO).addListener(listener);
} else if (type == 50) {
setMedia(draft, AttachmentManager.MediaType.VIDEO).addListener(listener);
} else {
setMedia(draft, AttachmentManager.MediaType.DOCUMENT).addListener(listener);
}
return settableFuture;
}
private void initializeEnabledCheck() {
this.inputPanel.setEnabled(true);
this.sendButton.setEnabled(true);
this.attachButton.setEnabled(true);
}
private ListenableFuture<Boolean> initializeSecurity(boolean z, boolean z2) {
SettableFuture settableFuture = new SettableFuture();
handleSecurityChange(z || isMultiUser(), z2);
settableFuture.set(true);
return settableFuture;
}
private void initializeViews() {
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar == null) {
throw new AssertionError();
}
this.titleView = (ConversationTitleView) supportActionBar.getCustomView();
this.buttonToggle = (AnimatingToggle) ViewUtil.findById((Activity) this, R.id.button_toggle);
this.sendButton = (SendButton) ViewUtil.findById((Activity) this, R.id.send_button);
this.attachButton = (ImageButton) ViewUtil.findById((Activity) this, R.id.attach_button);
this.composeText = (ComposeText) ViewUtil.findById((Activity) this, R.id.embedded_text_editor);
this.emojiPickerContainer = (FrameLayout) ViewUtil.findById((Activity) this, R.id.emoji_picker_container);
this.composePanel = ViewUtil.findById((Activity) this, R.id.bottom_panel);
this.container = (InputAwareLayout) ViewUtil.findById((Activity) this, R.id.layout_container);
this.quickAttachmentToggle = (HidingLinearLayout) ViewUtil.findById((Activity) this, R.id.quick_attachment_toggle);
this.inputPanel = (InputPanel) ViewUtil.findById((Activity) this, R.id.bottom_panel);
this.backgroundView = (ScaleStableImageView) ViewUtil.findById((Activity) this, R.id.conversation_background);
this.messageRequestBottomView = (MessageRequestsBottomView) ViewUtil.findById((Activity) this, R.id.conversation_activity_message_request_bottom_bar);
ImageButton imageButton = (ImageButton) ViewUtil.findById((Activity) this, R.id.quick_camera_toggle);
this.container.addOnKeyboardShownListener(this);
this.container.addOnKeyboardHiddenListener(this.backgroundView);
this.container.addOnKeyboardShownListener(this.backgroundView);
this.inputPanel.setListener(this);
this.inputPanel.setMediaListener(this);
this.attachmentTypeSelector = null;
this.attachmentManager = new AttachmentManager(this, this);
this.audioRecorder = new AudioRecorder(this);
SendButtonListener sendButtonListener = new SendButtonListener();
ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
this.composeText.setOnEditorActionListener(sendButtonListener);
this.attachButton.setOnClickListener(new AttachButtonListener());
this.attachButton.setOnLongClickListener(new AttachButtonLongClickListener());
this.sendButton.setOnClickListener(sendButtonListener);
this.sendButton.setEnabled(true);
this.sendButton.addOnTransportChangedListener(new TransportOptions.OnTransportChangedListener() {
@Override
public final void onChange(TransportOption transportOption, boolean z) {
ConversationActivity.this.m1191x3835d0c7(transportOption, z);
}
});
this.titleView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ConversationActivity.this.m1192x37bf6ac8(view);
}
});
this.titleView.setOnBackClickedListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ConversationActivity.this.m1193x374904c9(view);
}
});
this.composeText.setOnKeyListener(composeKeyPressedListener);
this.composeText.addTextChangedListener(composeKeyPressedListener);
this.composeText.setOnEditorActionListener(sendButtonListener);
this.composeText.setOnClickListener(composeKeyPressedListener);
this.composeText.setOnFocusChangeListener(composeKeyPressedListener);
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ConversationActivity.this.m1194x36d29eca(view);
}
});
initializeBackground();
}
void m1191x3835d0c7(TransportOption transportOption, boolean z) {
this.composeText.setTransport(transportOption);
this.buttonToggle.getBackground().invalidateSelf();
}
void m1192x37bf6ac8(View view) {
handleProfile();
}
void m1193x374904c9(View view) {
handleReturnToConversationList();
}
void m1194x36d29eca(View view) {
this.attachmentManager.capturePhoto(this, 7);
}
private void initializeBackground() {
Drawable drawable;
String backgroundImagePath = Prefs.getBackgroundImagePath(this, this.dcContext.getAccountId());
if (!backgroundImagePath.isEmpty()) {
drawable = Drawable.createFromPath(backgroundImagePath);
} else if (DynamicTheme.isDarkTheme(this)) {
drawable = getResources().getDrawable(R.drawable.background_hd_dark);
} else {
drawable = getResources().getDrawable(R.drawable.background_hd);
}
this.backgroundView.setImageDrawable(drawable);
}
protected void initializeActionBar() {
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar == null) {
throw new AssertionError();
}
supportActionBar.setDisplayHomeAsUpEnabled(false);
supportActionBar.setCustomView(R.layout.conversation_title_view);
supportActionBar.setDisplayShowCustomEnabled(true);
supportActionBar.setDisplayShowTitleEnabled(false);
Toolbar parent = supportActionBar.getCustomView().getParent();
parent.setPadding(0, 0, 0, 0);
parent.setContentInsetsAbsolute(0, 0);
}
private void initializeResources() {
int intExtra = getIntent().getIntExtra("account_id", this.dcContext.getAccountId());
if (intExtra != this.dcContext.getAccountId()) {
AccountManager.getInstance().switchAccount(this.context, intExtra);
this.dcContext = this.context.dcContext;
this.fragment.dcContext = this.context.dcContext;
initializeBackground();
}
int intExtra2 = getIntent().getIntExtra("chat_id", -1);
this.chatId = intExtra2;
if (intExtra2 == 0) {
throw new IllegalStateException("can't display a conversation for no chat.");
}
this.dcChat = this.dcContext.getChat(intExtra2);
this.recipient = new Recipient((Context) this, this.dcChat);
this.glideRequests = GlideApp.with((FragmentActivity) this);
setComposePanelVisibility();
initializeContactRequest();
}
private void setComposePanelVisibility() {
if (this.dcChat.canSend()) {
this.composePanel.setVisibility(0);
this.attachmentManager.setHidden(false);
} else {
this.composePanel.setVisibility(8);
this.attachmentManager.setHidden(true);
hideSoftKeyboard();
}
}
public void addAttachment(int i) {
switch (i) {
case 1:
AttachmentManager.selectGallery(this, 1);
break;
case 2:
AttachmentManager.selectDocument(this, 2);
break;
case 3:
new VideochatUtil().invite(this, this.chatId);
break;
case 4:
startContactChooserActivity();
break;
case 5:
this.attachmentManager.capturePhoto(this, 7);
break;
case 6:
AttachmentManager.selectLocation(this, this.chatId);
break;
case 7:
this.attachmentManager.captureVideo(this, 8);
break;
case 8:
AttachmentManager.selectWebxdc(this, PICK_WEBXDC);
break;
}
}
private void startContactChooserActivity() {
Intent intent = new Intent((Context) this, (Class<?>) AttachContactActivity.class);
intent.putExtra(ContactSelectionListFragment.ALLOW_CREATION, false);
startActivityForResult(intent, 4);
}
private ListenableFuture<Boolean> setMedia(Uri uri, AttachmentManager.MediaType mediaType) {
if (uri == null) {
return new SettableFuture(false);
}
return this.attachmentManager.setMedia(this.glideRequests, uri, null, mediaType, 0, 0, this.chatId);
}
private ListenableFuture<Boolean> setMedia(DcMsg dcMsg, AttachmentManager.MediaType mediaType) {
return this.attachmentManager.setMedia(this.glideRequests, Uri.fromFile(new File(dcMsg.getFile())), dcMsg, mediaType, 0, 0, this.chatId);
}
private void addAttachmentContactInfo(int i) {
if (i == 0) {
return;
}
try {
setMedia(PersistentBlobProvider.getInstance().create(this, this.rpc.makeVcard(this.dcContext.getAccountId(), new int[]{i}).getBytes(), MediaUtil.OCTET, "vcard.vcf"), AttachmentManager.MediaType.DOCUMENT);
} catch (RpcException e) {
Log.e(TAG, "makeVcard() failed", e);
}
}
private boolean isMultiUser() {
return this.dcChat.isMultiUser();
}
private boolean isArchived() {
return this.dcChat.getVisibility() == 1;
}
protected ListenableFuture<Integer> processComposeControls(int i) {
return processComposeControls(i, this.composeText.getTextTrimmed(), this.attachmentManager.isAttachmentPresent() ? this.attachmentManager.buildSlideDeck() : null);
}
protected ListenableFuture<Integer> processComposeControls(final int i, final String str, final SlideDeck slideDeck) {
final SettableFuture settableFuture = new SettableFuture();
final Optional<QuoteModel> quote = this.inputPanel.getQuote();
final boolean z = this.isEditing;
if (i == 1) {
this.composeText.setText("");
this.inputPanel.clearQuote();
}
Util.runOnAnyBackgroundThread(new Runnable() {
@Override
public final void run() {
ConversationActivity.this.m1202x90b02730(z, quote, i, str, settableFuture, slideDeck);
}
});
return settableFuture;
}
void m1202x90b02730(boolean r16, org.thoughtcrime.securesms.util.guava.Optional r17, int r18, java.lang.String r19, com.b44t.messenger.util.concurrent.SettableFuture r20, org.thoughtcrime.securesms.mms.SlideDeck r21) {
throw new UnsupportedOperationException("Method not decompiled: org.thoughtcrime.securesms.ConversationActivity.m1202x90b02730(boolean, org.thoughtcrime.securesms.util.guava.Optional, int, java.lang.String, com.b44t.messenger.util.concurrent.SettableFuture, org.thoughtcrime.securesms.mms.SlideDeck):void");
}
void m1197x9cb68316() {
this.attachmentManager.clear(this.glideRequests, false);
}
void m1198x9c401d17() {
if (isFinishing()) {
return;
}
this.progressDialog = ProgressDialog.show(this, "", getString(R.string.one_moment), true, false);
}
void m1199x9bc9b718() {
try {
ProgressDialog progressDialog = this.progressDialog;
if (progressDialog != null) {
progressDialog.dismiss();
}
} catch (IllegalArgumentException unused) {
}
}
void m1200x9b535119() {
Toast.makeText((Context) this, (CharSequence) this.dcContext.getLastError(), 1).show();
}
void m1201x9adceb1a() {
sendComplete(this.dcChat.getId());
}
protected void sendComplete(int i) {
boolean z = i != this.chatId;
this.chatId = i;
ConversationFragment conversationFragment = this.fragment;
if (conversationFragment == null || !conversationFragment.isVisible() || isFinishing()) {
return;
}
this.fragment.setLastSeen(-1L);
if (z) {
this.fragment.reload(this.recipient, i);
DcHelper.getNotificationCenter(this).updateVisibleChat(this.dcContext.getAccountId(), i);
}
this.fragment.scrollToBottom();
this.attachmentManager.cleanup();
}
public void updateToggleButtonState() {
if (this.inputPanel.isRecordingInLockedMode()) {
this.buttonToggle.display(this.sendButton);
this.quickAttachmentToggle.hide();
} else if (!this.isEditing && this.composeText.getText().length() == 0 && !this.attachmentManager.isAttachmentPresent()) {
this.buttonToggle.display(this.attachButton);
this.quickAttachmentToggle.show();
} else {
this.buttonToggle.display(this.sendButton);
this.quickAttachmentToggle.hide();
}
}
@Override
public void onRecorderPermissionRequired() {
Permissions.with((Activity) this).request("android.permission.RECORD_AUDIO").ifNecessary().withPermanentDenialDialog(getString(R.string.perm_explain_access_to_mic_denied)).execute();
}
@Override
public void onRecorderStarted() {
this.fragment.hideAddReactionView();
ServiceUtil.getVibrator(this).vibrate(20L);
getWindow().addFlags(WorkQueueKt.BUFFER_CAPACITY);
this.audioRecorder.startRecording();
}
@Override
public void onRecorderLocked() {
updateToggleButtonState();
setRequestedOrientation(-1);
}
@Override
public void onRecorderFinished() {
updateToggleButtonState();
ServiceUtil.getVibrator(this).vibrate(20L);
getWindow().clearFlags(WorkQueueKt.BUFFER_CAPACITY);
this.audioRecorder.stopRecording().addListener(new AnonymousClass5());
}
class AnonymousClass5 implements ListenableFuture.Listener<Pair<Uri, Long>> {
AnonymousClass5() {
}
public void onSuccess(final Pair<Uri, Long> pair) {
AudioSlide audioSlide = new AudioSlide((Context) ConversationActivity.this, (Uri) pair.first, ((Long) pair.second).longValue(), MediaUtil.AUDIO_AAC, true);
SlideDeck slideDeck = new SlideDeck();
slideDeck.addSlide(audioSlide);
ConversationActivity.this.processComposeControls(1, "", slideDeck).addListener(new AssertedSuccessListener<Integer>() {
public void onSuccess(Integer num) {
new AsyncTask<Void, Void, Void>() {
@Override
public Void doInBackground(Void... voidArr) {
PersistentBlobProvider.getInstance().delete(ConversationActivity.this, (Uri) pair.first);
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
}
});
}
public void onFailure(ExecutionException executionException) {
Toast.makeText((Context) ConversationActivity.this, R.string.chat_unable_to_record_audio, 1).show();
}
}
@Override
public void onRecorderCanceled() {
updateToggleButtonState();
ServiceUtil.getVibrator(this).vibrate(50L);
getWindow().clearFlags(WorkQueueKt.BUFFER_CAPACITY);
this.audioRecorder.stopRecording().addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() {
public void onFailure(ExecutionException executionException) {
}
public void onSuccess(final Pair<Uri, Long> pair) {
new AsyncTask<Void, Void, Void>() {
@Override
public Void doInBackground(Void... voidArr) {
PersistentBlobProvider.getInstance().delete(ConversationActivity.this, (Uri) pair.first);
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
}
});
}
private void reloadEmojiPicker() {
this.emojiPickerContainer.removeAllViews();
MediaKeyboard mediaKeyboard = (MediaKeyboard) LayoutInflater.from(this).inflate(R.layout.conversation_activity_emojidrawer_stub, (ViewGroup) this.emojiPickerContainer, false);
this.emojiPicker = mediaKeyboard;
this.emojiPickerContainer.addView(mediaKeyboard);
this.inputPanel.setMediaKeyboard(this.emojiPicker);
}
@Override
public void onEmojiToggle() {
if (this.emojiPicker == null) {
reloadEmojiPicker();
}
InputAwareLayout.InputView currentInput = this.container.getCurrentInput();
InputAwareLayout.InputView inputView = this.emojiPicker;
if (currentInput == inputView) {
this.container.showSoftkey(this.composeText);
} else {
this.container.show(this.composeText, inputView);
}
}
@Override
public void onQuoteDismissed() {
if (this.isEditing) {
this.composeText.setText("");
}
this.isEditing = false;
}
@Override
public void onMediaSelected(Uri uri, String str) {
if (this.isEditing) {
return;
}
if (MediaUtil.isImageType(str)) {
sendSticker(uri, str);
} else if (MediaUtil.isVideoType(str)) {
setMedia(uri, AttachmentManager.MediaType.VIDEO);
} else if (MediaUtil.isAudioType(str)) {
setMedia(uri, AttachmentManager.MediaType.AUDIO);
}
}
private void sendSticker(Uri uri, String str) {
String realPath = new UriAttachment(uri, null, str, 1, 0L, 0, 0, null, null, false).getRealPath(this);
Optional<QuoteModel> quote = this.inputPanel.getQuote();
this.inputPanel.clearQuote();
DcMsg dcMsg = new DcMsg(this.dcContext, 23);
if (quote.isPresent()) {
dcMsg.setQuote(quote.get().getQuotedMsg());
}
dcMsg.setFileAndDeduplicate(realPath, (String) null, (String) null);
this.dcContext.sendMsg(this.chatId, dcMsg);
}
private class AttachmentTypeListener implements AttachmentTypeSelector.AttachmentClickedListener {
private AttachmentTypeListener() {
}
@Override
public void onClick(int i) {
ConversationActivity.this.addAttachment(i);
}
@Override
public void onQuickAttachment(Uri uri) {
Intent intent = new Intent();
intent.setData(uri);
ConversationActivity.this.onActivityResult(1, -1, intent);
}
}
private class SendButtonListener implements View.OnClickListener, TextView.OnEditorActionListener {
private SendButtonListener() {
}
@Override
public void onClick(View view) {
if (ConversationActivity.this.inputPanel.isRecordingInLockedMode()) {
ConversationActivity.this.inputPanel.releaseRecordingLock();
} else if (ConversationActivity.this.composeText.getTextTrimmed().length() < 1 && !ConversationActivity.this.attachmentManager.isAttachmentPresent()) {
Toast.makeText((Context) ConversationActivity.this, R.string.chat_please_enter_message, 0).show();
} else {
ConversationActivity.this.processComposeControls(1).addListener(new AssertedSuccessListener<Integer>() {
public void onSuccess(Integer num) {
DcHelper.getNotificationCenter(ConversationActivity.this).maybePlaySendSound(ConversationActivity.this.dcChat);
}
});
}
}
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
if (i != 4) {
return false;
}
ConversationActivity.this.sendButton.performClick();
return true;
}
}
private class AttachButtonListener implements View.OnClickListener {
private AttachButtonListener() {
}
@Override
public void onClick(View view) {
ConversationActivity.this.fragment.hideAddReactionView();
ConversationActivity.this.handleAddAttachment();
}
}
private class AttachButtonLongClickListener implements View.OnLongClickListener {
private AttachButtonLongClickListener() {
}
@Override
public boolean onLongClick(View view) {
return ConversationActivity.this.sendButton.performLongClick();
}
}
class ComposeKeyPressedListener implements View.OnKeyListener, View.OnClickListener, TextWatcher, View.OnFocusChangeListener {
int beforeLength;
@Override
public void onFocusChange(View view, boolean z) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
private ComposeKeyPressedListener() {
}
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
if (keyEvent.getAction() != 0 || i != 66 || !Prefs.isEnterSendsEnabled(ConversationActivity.this)) {
return false;
}
ConversationActivity.this.sendButton.dispatchKeyEvent(new KeyEvent(0, 66));
ConversationActivity.this.sendButton.dispatchKeyEvent(new KeyEvent(1, 66));
return true;
}
@Override
public void onClick(View view) {
ConversationActivity.this.container.showSoftkey(ConversationActivity.this.composeText);
}
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
this.beforeLength = ConversationActivity.this.composeText.getTextTrimmed().length();
}
@Override
public void afterTextChanged(Editable editable) {
if (ConversationActivity.this.composeText.getTextTrimmed().length() == 0 || this.beforeLength == 0) {
ComposeText composeText = ConversationActivity.this.composeText;
final ConversationActivity conversationActivity = ConversationActivity.this;
composeText.postDelayed(new Runnable() {
@Override
public final void run() {
ConversationActivity.this.updateToggleButtonState();
}
}, 50L);
}
}
}
@Override
public void handleReplyMessage(DcMsg dcMsg) {
if (this.isEditing) {
this.composeText.setText("");
}
this.isEditing = false;
Recipient recipient = new Recipient((Context) this, this.dcContext.getContact(dcMsg.getFromId()));
SlideDeck slideDeck = new SlideDeck();
if (dcMsg.getType() != 10) {
slideDeck.addSlide(MediaUtil.getSlideForMsg(this, dcMsg));
}
this.inputPanel.setQuote(GlideApp.with((FragmentActivity) this), dcMsg, dcMsg.getTimestamp(), recipient, dcMsg.getSummarytext(500), slideDeck, false);
this.inputPanel.clickOnComposeInput();
}
@Override
public void handleEditMessage(DcMsg dcMsg) {
this.isEditing = true;
Recipient recipient = new Recipient((Context) this, this.dcContext.getContact(dcMsg.getFromId()));
SlideDeck slideDeck = new SlideDeck();
this.inputPanel.setQuote(GlideApp.with((FragmentActivity) this), dcMsg, dcMsg.getTimestamp(), recipient, dcMsg.getSummarytext(500), slideDeck, true);
setDraftText(dcMsg.getText());
this.inputPanel.clickOnComposeInput();
}
@Override
public void onAttachmentChanged() {
handleSecurityChange(true, this.isDefaultSms);
updateToggleButtonState();
}
@Override
public void handleEvent(DcEvent dcEvent) {
int id = dcEvent.getId();
if ((id == 2020 && dcEvent.getData1Int() == this.chatId) || ((id == 2021 && dcEvent.getData1Int() == this.chatId) || id == 2030)) {
DcChat chat = this.dcContext.getChat(this.chatId);
this.dcChat = chat;
this.titleView.setTitle(this.glideRequests, chat);
initializeSecurity(true, this.isDefaultSms);
setComposePanelVisibility();
initializeContactRequest();
return;
}
if ((id == 2005 || id == 2015) && dcEvent.getData1Int() == this.chatId) {
DcContact dcContact = this.recipient.getDcContact();
this.titleView.setSeenRecently(dcContact != null ? this.dcContext.getContact(dcContact.getId()).wasSeenRecently() : false);
}
}
private void updateResultCounter(int i, int i2) {
Menu menu = this.searchMenu;
if (menu != null) {
MenuItem findItem = menu.findItem(R.id.menu_search_counter);
if (i != -1) {
findItem.setTitle(String.format("%d/%d", Integer.valueOf(i2 == 0 ? 0 : i + 1), Integer.valueOf(i2)));
findItem.setVisible(true);
} else {
findItem.setVisible(false);
}
}
}
public void searchExpand(Menu menu, MenuItem menuItem) {
this.searchMenu = menu;
this.beforeSearchComposeVisibility = this.composePanel.getVisibility();
this.composePanel.setVisibility(8);
makeSearchMenuVisible(menu, menuItem, true);
}
public void searchCollapse(Menu menu, MenuItem menuItem) {
this.searchMenu = null;
this.composePanel.setVisibility(this.beforeSearchComposeVisibility);
makeSearchMenuVisible(menu, menuItem, false);
}
private void handleMenuSearchNext(boolean z) {
int[] iArr = this.searchResult;
if (iArr.length <= 0) {
if (z) {
this.fragment.scrollToBottom();
return;
} else {
this.fragment.scrollToTop();
return;
}
}
int i = this.searchResultPosition + (z ? 1 : -1);
this.searchResultPosition = i;
if (i < 0) {
this.searchResultPosition = iArr.length - 1;
}
if (this.searchResultPosition >= iArr.length) {
this.searchResultPosition = 0;
}
this.fragment.scrollToMsgId(iArr[this.searchResultPosition]);
updateResultCounter(this.searchResultPosition, this.searchResult.length);
}
public boolean onQueryTextChange(String str) {
Toast toast = this.lastToast;
if (toast != null) {
toast.cancel();
this.lastToast = null;
}
String trim = str.trim();
int[] searchMsgs = this.dcContext.searchMsgs(this.chatId, trim);
this.searchResult = searchMsgs;
if (searchMsgs.length > 0) {
int length = searchMsgs.length - 1;
this.searchResultPosition = length;
this.fragment.scrollToMsgId(searchMsgs[length]);
updateResultCounter(this.searchResultPosition, this.searchResult.length);
} else {
this.searchResultPosition = -1;
if (trim.isEmpty()) {
updateResultCounter(-1, 0);
} else {
String string = getString(R.string.search_no_result_for_x, new Object[]{trim});
Toast toast2 = this.lastToast;
if (toast2 != null) {
toast2.cancel();
}
Toast makeText = Toast.makeText((Context) this, (CharSequence) string, 0);
this.lastToast = makeText;
makeText.show();
updateResultCounter(0, 0);
}
}
return true;
}
public void initializeContactRequest() {
if (!this.dcChat.isHalfBlocked()) {
this.messageRequestBottomView.setVisibility(8);
return;
}
this.messageRequestBottomView.setVisibility(0);
this.messageRequestBottomView.setAcceptOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ConversationActivity.this.m1187x55bd2cab(view);
}
});
if (this.dcChat.isProtectionBroken()) {
this.messageRequestBottomView.setBlockText(R.string.more_info_desktop);
final String displayName = this.dcContext.getContact(this.recipient.getDcContact().getId()).getDisplayName();
this.messageRequestBottomView.setBlockOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ConversationActivity.this.m1188x5546c6ac(displayName, view);
}
});
this.messageRequestBottomView.setQuestion(getString(R.string.chat_protection_broken, new Object[]{displayName}));
this.messageRequestBottomView.setAcceptText(R.string.ok);
return;
}
if (this.dcChat.getType() == 120) {
this.messageRequestBottomView.setBlockText(R.string.delete);
this.messageRequestBottomView.setBlockOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ConversationActivity.this.m1189x54d060ad(view);
}
});
this.messageRequestBottomView.setQuestion(null);
} else {
this.messageRequestBottomView.setBlockText(R.string.block);
this.messageRequestBottomView.setBlockOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ConversationActivity.this.m1190x5459faae(view);
}
});
this.messageRequestBottomView.setQuestion(null);
}
}
void m1187x55bd2cab(View view) {
this.dcContext.acceptChat(this.chatId);
this.messageRequestBottomView.setVisibility(8);
this.composePanel.setVisibility(0);
}
void m1188x5546c6ac(String str, View view) {
DcHelper.showVerificationBrokenDialog(this, str);
}
void m1189x54d060ad(View view) {
handleDeleteChat();
}
void m1190x5459faae(View view) {
DcHelper.getEventCenter(this).removeObserver(2030, this);
this.dcContext.blockChat(this.chatId);
Bundle bundle = new Bundle();
bundle.putInt(ConversationListFragment.RELOAD_LIST, 1);
handleReturnToConversationList(bundle);
}
}