2013-10-25 17:19:00 +02:00
|
|
|
/*
|
2013-12-20 20:25:49 +01:00
|
|
|
* This is the source code of Telegram for Android v. 1.3.2.
|
2013-10-25 17:19:00 +02:00
|
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
|
|
* You should have received a copy of the license in this archive (see LICENSE).
|
|
|
|
*
|
|
|
|
* Copyright Nikolai Kudashov, 2013.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui;
|
|
|
|
|
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.content.DialogInterface;
|
2014-11-06 22:34:47 +01:00
|
|
|
import android.content.res.Configuration;
|
2014-10-31 20:02:29 +01:00
|
|
|
import android.os.Build;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.os.Bundle;
|
2014-11-06 22:34:47 +01:00
|
|
|
import android.view.Gravity;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.view.LayoutInflater;
|
2014-10-07 22:14:27 +02:00
|
|
|
import android.view.MotionEvent;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2014-11-06 22:34:47 +01:00
|
|
|
import android.view.ViewTreeObserver;
|
|
|
|
import android.view.animation.AccelerateDecelerateInterpolator;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.widget.AbsListView;
|
|
|
|
import android.widget.AdapterView;
|
2014-07-10 23:15:39 +02:00
|
|
|
import android.widget.CheckBox;
|
2014-06-04 01:31:48 +02:00
|
|
|
import android.widget.EditText;
|
2014-11-06 22:34:47 +01:00
|
|
|
import android.widget.FrameLayout;
|
|
|
|
import android.widget.ImageView;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.widget.ListView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.android.AndroidUtilities;
|
|
|
|
import org.telegram.android.LocaleController;
|
2014-10-31 20:02:29 +01:00
|
|
|
import org.telegram.android.MessageObject;
|
2014-02-28 23:28:25 +01:00
|
|
|
import org.telegram.messenger.TLRPC;
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.android.ContactsController;
|
|
|
|
import org.telegram.android.MessagesController;
|
|
|
|
import org.telegram.android.MessagesStorage;
|
2014-08-22 16:24:33 +02:00
|
|
|
import org.telegram.android.NotificationCenter;
|
2013-10-25 17:19:00 +02:00
|
|
|
import org.telegram.messenger.R;
|
|
|
|
import org.telegram.messenger.UserConfig;
|
2014-10-31 20:02:29 +01:00
|
|
|
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
2014-11-13 21:10:14 +01:00
|
|
|
import org.telegram.ui.Adapters.DialogsAdapter;
|
|
|
|
import org.telegram.ui.Adapters.DialogsSearchAdapter;
|
2014-11-06 22:34:47 +01:00
|
|
|
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
|
|
|
|
import org.telegram.ui.AnimationCompat.ViewProxy;
|
2014-11-10 12:05:22 +01:00
|
|
|
import org.telegram.ui.Cells.UserCell;
|
2014-02-04 19:36:55 +01:00
|
|
|
import org.telegram.ui.Cells.DialogCell;
|
2014-11-13 21:10:14 +01:00
|
|
|
import org.telegram.ui.ActionBar.ActionBar;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
|
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
|
|
|
import org.telegram.ui.ActionBar.MenuDrawable;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
public class MessagesActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
|
|
|
private ListView messagesListView;
|
2014-11-13 21:10:14 +01:00
|
|
|
private DialogsAdapter dialogsAdapter;
|
|
|
|
private DialogsSearchAdapter dialogsSearchAdapter;
|
2014-11-17 03:44:57 +01:00
|
|
|
private View searchEmptyView;
|
2013-10-25 17:19:00 +02:00
|
|
|
private View progressView;
|
2014-10-07 22:14:27 +02:00
|
|
|
private View emptyView;
|
2014-11-06 22:34:47 +01:00
|
|
|
private ImageView floatingButton;
|
|
|
|
private int prevPosition;
|
|
|
|
private int prevTop;
|
|
|
|
private boolean scrollUpdated;
|
|
|
|
private boolean floatingHidden;
|
|
|
|
private final AccelerateDecelerateInterpolator floatingInterpolator = new AccelerateDecelerateInterpolator();
|
2014-10-31 20:02:29 +01:00
|
|
|
|
2014-06-04 01:31:48 +02:00
|
|
|
private String selectAlertString;
|
2014-10-04 17:56:09 +02:00
|
|
|
private String selectAlertStringGroup;
|
2013-10-25 17:19:00 +02:00
|
|
|
private boolean serverOnly = false;
|
|
|
|
|
|
|
|
private static boolean dialogsLoaded = false;
|
|
|
|
private boolean searching = false;
|
|
|
|
private boolean searchWas = false;
|
|
|
|
private boolean onlySelect = false;
|
|
|
|
private long selectedDialog;
|
|
|
|
|
2014-06-04 01:31:48 +02:00
|
|
|
private MessagesActivityDelegate delegate;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2014-09-24 04:17:27 +02:00
|
|
|
private long openedDialogId = 0;
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
public static interface MessagesActivityDelegate {
|
2014-07-10 23:15:39 +02:00
|
|
|
public abstract void didSelectDialog(MessagesActivity fragment, long dialog_id, boolean param);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
2014-06-04 01:31:48 +02:00
|
|
|
public MessagesActivity(Bundle args) {
|
|
|
|
super(args);
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
@Override
|
|
|
|
public boolean onFragmentCreate() {
|
|
|
|
super.onFragmentCreate();
|
2014-08-22 16:24:33 +02:00
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.dialogsNeedReload);
|
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
|
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
|
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatUpdated);
|
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
|
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
|
2014-09-24 04:17:27 +02:00
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.openedChatChanged);
|
2013-10-25 17:19:00 +02:00
|
|
|
if (getArguments() != null) {
|
2014-06-04 01:31:48 +02:00
|
|
|
onlySelect = arguments.getBoolean("onlySelect", false);
|
|
|
|
serverOnly = arguments.getBoolean("serverOnly", false);
|
|
|
|
selectAlertString = arguments.getString("selectAlertString");
|
2014-10-04 17:56:09 +02:00
|
|
|
selectAlertStringGroup = arguments.getString("selectAlertStringGroup");
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2013-12-20 20:25:49 +01:00
|
|
|
if (!dialogsLoaded) {
|
2014-03-22 23:31:55 +01:00
|
|
|
MessagesController.getInstance().loadDialogs(0, 0, 100, true);
|
2013-12-20 20:25:49 +01:00
|
|
|
dialogsLoaded = true;
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFragmentDestroy() {
|
|
|
|
super.onFragmentDestroy();
|
2014-08-22 16:24:33 +02:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.dialogsNeedReload);
|
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
|
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.encryptedChatUpdated);
|
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.contactsDidLoaded);
|
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.appDidLogout);
|
2014-09-24 04:17:27 +02:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.openedChatChanged);
|
2013-10-25 17:19:00 +02:00
|
|
|
delegate = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-04 01:31:48 +02:00
|
|
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
2013-10-25 17:19:00 +02:00
|
|
|
if (fragmentView == null) {
|
2014-11-11 23:16:17 +01:00
|
|
|
ActionBarMenu menu = actionBar.createMenu();
|
2014-06-04 01:31:48 +02:00
|
|
|
menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
|
|
|
|
@Override
|
|
|
|
public void onSearchExpand() {
|
|
|
|
searching = true;
|
|
|
|
if (messagesListView != null) {
|
|
|
|
messagesListView.setEmptyView(searchEmptyView);
|
2014-10-07 22:14:27 +02:00
|
|
|
emptyView.setVisibility(View.GONE);
|
2014-10-31 20:02:29 +01:00
|
|
|
progressView.setVisibility(View.GONE);
|
2014-11-06 22:34:47 +01:00
|
|
|
if (!onlySelect) {
|
|
|
|
floatingButton.setVisibility(View.GONE);
|
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSearchCollapse() {
|
|
|
|
searching = false;
|
|
|
|
searchWas = false;
|
|
|
|
if (messagesListView != null) {
|
2014-11-14 16:40:15 +01:00
|
|
|
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
|
|
|
|
searchEmptyView.setVisibility(View.GONE);
|
|
|
|
emptyView.setVisibility(View.GONE);
|
|
|
|
progressView.setVisibility(View.VISIBLE);
|
|
|
|
messagesListView.setEmptyView(progressView);
|
|
|
|
} else {
|
|
|
|
messagesListView.setEmptyView(emptyView);
|
|
|
|
searchEmptyView.setVisibility(View.GONE);
|
|
|
|
progressView.setVisibility(View.GONE);
|
|
|
|
}
|
2014-11-06 22:34:47 +01:00
|
|
|
if (!onlySelect) {
|
|
|
|
floatingButton.setVisibility(View.VISIBLE);
|
|
|
|
floatingHidden = true;
|
|
|
|
ViewProxy.setTranslationY(floatingButton, AndroidUtilities.dp(100));
|
|
|
|
hideFloatingButton(false);
|
|
|
|
}
|
2014-11-13 21:10:14 +01:00
|
|
|
if (messagesListView.getAdapter() != dialogsAdapter) {
|
|
|
|
messagesListView.setAdapter(dialogsAdapter);
|
|
|
|
dialogsAdapter.notifyDataSetChanged();
|
2014-11-06 22:34:47 +01:00
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
2014-11-13 21:10:14 +01:00
|
|
|
if (dialogsSearchAdapter != null) {
|
|
|
|
dialogsSearchAdapter.searchDialogs(null, false);
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(EditText editText) {
|
|
|
|
String text = editText.getText().toString();
|
|
|
|
if (text.length() != 0) {
|
|
|
|
searchWas = true;
|
2014-11-13 21:10:14 +01:00
|
|
|
if (dialogsSearchAdapter != null) {
|
|
|
|
messagesListView.setAdapter(dialogsSearchAdapter);
|
|
|
|
dialogsSearchAdapter.notifyDataSetChanged();
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
2014-10-31 20:02:29 +01:00
|
|
|
if (searchEmptyView != null && messagesListView.getEmptyView() == emptyView) {
|
2014-06-04 01:31:48 +02:00
|
|
|
messagesListView.setEmptyView(searchEmptyView);
|
2014-10-07 22:14:27 +02:00
|
|
|
emptyView.setVisibility(View.GONE);
|
2014-10-31 20:02:29 +01:00
|
|
|
progressView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
2014-11-13 21:10:14 +01:00
|
|
|
if (dialogsSearchAdapter != null) {
|
|
|
|
dialogsSearchAdapter.searchDialogs(text, serverOnly);
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (onlySelect) {
|
2014-11-11 23:16:17 +01:00
|
|
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
|
|
|
actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
|
2014-06-04 01:31:48 +02:00
|
|
|
} else {
|
2014-11-11 23:16:17 +01:00
|
|
|
actionBar.setBackButtonDrawable(new MenuDrawable());
|
|
|
|
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
2014-11-11 23:16:17 +01:00
|
|
|
actionBar.setBackOverlay(R.layout.updating_state_layout);
|
2014-06-04 01:31:48 +02:00
|
|
|
|
2014-11-11 23:16:17 +01:00
|
|
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
2014-06-04 01:31:48 +02:00
|
|
|
@Override
|
|
|
|
public void onItemClick(int id) {
|
2014-11-07 21:10:12 +01:00
|
|
|
if (id == -1) {
|
2014-06-04 01:31:48 +02:00
|
|
|
if (onlySelect) {
|
|
|
|
finishFragment();
|
2014-11-07 21:10:12 +01:00
|
|
|
} else if (parentLayout != null) {
|
|
|
|
parentLayout.getDrawerLayoutContainer().openDrawer(false);
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-02-28 23:28:25 +01:00
|
|
|
searching = false;
|
|
|
|
searchWas = false;
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
fragmentView = inflater.inflate(R.layout.messages_list, container, false);
|
|
|
|
|
2014-11-13 21:10:14 +01:00
|
|
|
dialogsAdapter = new DialogsAdapter(getParentActivity(), serverOnly);
|
2014-11-17 23:04:31 +01:00
|
|
|
dialogsSearchAdapter = new DialogsSearchAdapter(getParentActivity(), !onlySelect);
|
2014-11-13 21:10:14 +01:00
|
|
|
dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.MessagesActivitySearchAdapterDelegate() {
|
2014-10-31 20:02:29 +01:00
|
|
|
@Override
|
|
|
|
public void searchStateChanged(boolean search) {
|
|
|
|
if (searching && searchWas && messagesListView != null) {
|
|
|
|
progressView.setVisibility(search ? View.VISIBLE : View.GONE);
|
|
|
|
searchEmptyView.setVisibility(search ? View.GONE : View.VISIBLE);
|
|
|
|
messagesListView.setEmptyView(search ? progressView : searchEmptyView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2013-10-25 17:19:00 +02:00
|
|
|
|
|
|
|
messagesListView = (ListView)fragmentView.findViewById(R.id.messages_list_view);
|
2014-11-13 21:10:14 +01:00
|
|
|
messagesListView.setAdapter(dialogsAdapter);
|
2014-10-31 20:02:29 +01:00
|
|
|
if (Build.VERSION.SDK_INT >= 11) {
|
|
|
|
messagesListView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
|
|
|
|
progressView = fragmentView.findViewById(R.id.progressLayout);
|
2014-11-13 21:10:14 +01:00
|
|
|
dialogsAdapter.notifyDataSetChanged();
|
2014-11-17 03:44:57 +01:00
|
|
|
searchEmptyView = fragmentView.findViewById(R.id.search_empty_view);
|
2014-10-07 22:14:27 +02:00
|
|
|
searchEmptyView.setOnTouchListener(new View.OnTouchListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
emptyView = fragmentView.findViewById(R.id.list_empty_view);
|
|
|
|
emptyView.setOnTouchListener(new View.OnTouchListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2014-11-17 03:44:57 +01:00
|
|
|
|
|
|
|
|
2014-03-22 23:31:55 +01:00
|
|
|
TextView textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text1);
|
|
|
|
textView.setText(LocaleController.getString("NoChats", R.string.NoChats));
|
|
|
|
textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text2);
|
2014-11-17 03:44:57 +01:00
|
|
|
textView.setText(LocaleController.getString("NoChatsHelp", R.string.NoChatsHelp));
|
|
|
|
textView = (TextView)fragmentView.findViewById(R.id.search_empty_text);
|
|
|
|
textView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2014-11-06 22:34:47 +01:00
|
|
|
floatingButton = (ImageView)fragmentView.findViewById(R.id.floating_button);
|
|
|
|
floatingButton.setVisibility(onlySelect ? View.GONE : View.VISIBLE);
|
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)floatingButton.getLayoutParams();
|
|
|
|
layoutParams.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(14) : 0;
|
|
|
|
layoutParams.rightMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(14);
|
|
|
|
layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM;
|
|
|
|
floatingButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("destroyAfterSelect", true);
|
|
|
|
presentFragment(new ContactsActivity(args));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-03-22 23:31:55 +01:00
|
|
|
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
|
2013-10-25 17:19:00 +02:00
|
|
|
searchEmptyView.setVisibility(View.GONE);
|
2014-10-07 22:14:27 +02:00
|
|
|
emptyView.setVisibility(View.GONE);
|
2014-11-14 16:40:15 +01:00
|
|
|
progressView.setVisibility(View.VISIBLE);
|
2014-10-31 20:02:29 +01:00
|
|
|
messagesListView.setEmptyView(progressView);
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
2014-11-14 16:40:15 +01:00
|
|
|
messagesListView.setEmptyView(emptyView);
|
|
|
|
searchEmptyView.setVisibility(View.GONE);
|
2013-10-25 17:19:00 +02:00
|
|
|
progressView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
messagesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
2014-10-31 20:02:29 +01:00
|
|
|
if (messagesListView == null || messagesListView.getAdapter() == null) {
|
2014-10-21 22:35:16 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
long dialog_id = 0;
|
2014-10-31 20:02:29 +01:00
|
|
|
int message_id = 0;
|
|
|
|
BaseFragmentAdapter adapter = (BaseFragmentAdapter)messagesListView.getAdapter();
|
2014-11-13 21:10:14 +01:00
|
|
|
if (adapter == dialogsAdapter) {
|
|
|
|
TLRPC.TL_dialog dialog = dialogsAdapter.getItem(i);
|
2014-10-31 20:02:29 +01:00
|
|
|
if (dialog == null) {
|
|
|
|
return;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-10-31 20:02:29 +01:00
|
|
|
dialog_id = dialog.id;
|
2014-11-13 21:10:14 +01:00
|
|
|
} else if (adapter == dialogsSearchAdapter) {
|
|
|
|
Object obj = dialogsSearchAdapter.getItem(i);
|
2014-10-31 20:02:29 +01:00
|
|
|
if (obj instanceof TLRPC.User) {
|
|
|
|
dialog_id = ((TLRPC.User) obj).id;
|
2014-11-13 21:10:14 +01:00
|
|
|
if (dialogsSearchAdapter.isGlobalSearch(i)) {
|
2014-10-31 20:02:29 +01:00
|
|
|
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
|
|
|
users.add((TLRPC.User)obj);
|
|
|
|
MessagesController.getInstance().putUsers(users, false);
|
|
|
|
MessagesStorage.getInstance().putUsersAndChats(users, null, false, true);
|
|
|
|
}
|
|
|
|
} else if (obj instanceof TLRPC.Chat) {
|
|
|
|
if (((TLRPC.Chat) obj).id > 0) {
|
|
|
|
dialog_id = -((TLRPC.Chat) obj).id;
|
|
|
|
} else {
|
|
|
|
dialog_id = AndroidUtilities.makeBroadcastId(((TLRPC.Chat) obj).id);
|
|
|
|
}
|
|
|
|
} else if (obj instanceof TLRPC.EncryptedChat) {
|
|
|
|
dialog_id = ((long)((TLRPC.EncryptedChat) obj).id) << 32;
|
|
|
|
} else if (obj instanceof MessageObject) {
|
|
|
|
MessageObject messageObject = (MessageObject)obj;
|
|
|
|
dialog_id = messageObject.getDialogId();
|
|
|
|
message_id = messageObject.messageOwner.id;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-10-31 20:02:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dialog_id == 0) {
|
|
|
|
return;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-10-21 22:35:16 +02:00
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
if (onlySelect) {
|
2014-07-10 23:15:39 +02:00
|
|
|
didSelectResult(dialog_id, true, false);
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
2014-06-04 01:31:48 +02:00
|
|
|
Bundle args = new Bundle();
|
2013-10-25 17:19:00 +02:00
|
|
|
int lower_part = (int)dialog_id;
|
2014-07-27 12:53:00 +02:00
|
|
|
int high_id = (int)(dialog_id >> 32);
|
2013-10-25 17:19:00 +02:00
|
|
|
if (lower_part != 0) {
|
2014-07-27 12:53:00 +02:00
|
|
|
if (high_id == 1) {
|
|
|
|
args.putInt("chat_id", lower_part);
|
2014-07-27 00:28:33 +02:00
|
|
|
} else {
|
2014-07-27 12:53:00 +02:00
|
|
|
if (lower_part > 0) {
|
|
|
|
args.putInt("user_id", lower_part);
|
|
|
|
} else if (lower_part < 0) {
|
|
|
|
args.putInt("chat_id", -lower_part);
|
|
|
|
}
|
2014-07-27 00:28:33 +02:00
|
|
|
}
|
2014-07-27 12:53:00 +02:00
|
|
|
} else {
|
|
|
|
args.putInt("enc_id", high_id);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-10-31 20:02:29 +01:00
|
|
|
if (message_id != 0) {
|
|
|
|
args.putInt("message_id", message_id);
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
if (openedDialogId == dialog_id) {
|
|
|
|
return;
|
|
|
|
}
|
2014-11-13 21:10:14 +01:00
|
|
|
dialogsAdapter.setOpenedDialogId(openedDialogId = dialog_id);
|
2014-11-11 23:16:17 +01:00
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
presentFragment(new ChatActivity(args));
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
messagesListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
|
2014-06-14 10:36:01 +02:00
|
|
|
if (onlySelect || searching && searchWas || getParentActivity() == null) {
|
2013-10-25 17:19:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
TLRPC.TL_dialog dialog;
|
|
|
|
if (serverOnly) {
|
2014-03-22 23:31:55 +01:00
|
|
|
if (i >= MessagesController.getInstance().dialogsServerOnly.size()) {
|
2013-10-25 17:19:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
2014-03-22 23:31:55 +01:00
|
|
|
dialog = MessagesController.getInstance().dialogsServerOnly.get(i);
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
2014-03-22 23:31:55 +01:00
|
|
|
if (i >= MessagesController.getInstance().dialogs.size()) {
|
2013-10-25 17:19:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
2014-03-22 23:31:55 +01:00
|
|
|
dialog = MessagesController.getInstance().dialogs.get(i);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
selectedDialog = dialog.id;
|
|
|
|
|
2014-06-04 01:31:48 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
2014-03-22 23:31:55 +01:00
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2014-07-31 02:50:12 +02:00
|
|
|
int lower_id = (int)selectedDialog;
|
|
|
|
int high_id = (int)(selectedDialog >> 32);
|
|
|
|
|
2014-11-17 03:44:57 +01:00
|
|
|
final boolean isChat = lower_id < 0 && high_id != 1;
|
|
|
|
builder.setItems(new CharSequence[]{LocaleController.getString("ClearHistory", R.string.ClearHistory),
|
|
|
|
isChat ? LocaleController.getString("DeleteChat", R.string.DeleteChat) : LocaleController.getString("Delete", R.string.Delete)}, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, final int which) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
if (which == 0) {
|
|
|
|
builder.setMessage(LocaleController.getString("AreYouSureClearHistory", R.string.AreYouSureClearHistory));
|
|
|
|
} else {
|
|
|
|
if (isChat) {
|
2014-07-10 23:15:39 +02:00
|
|
|
builder.setMessage(LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit));
|
|
|
|
} else {
|
|
|
|
builder.setMessage(LocaleController.getString("AreYouSureDeleteThisChat", R.string.AreYouSureDeleteThisChat));
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-11-17 03:44:57 +01:00
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
MessagesController.getInstance().deleteDialog(selectedDialog, 0, which == 0);
|
|
|
|
if (which != 0) {
|
|
|
|
if (isChat) {
|
|
|
|
MessagesController.getInstance().deleteUserFromChat((int) -selectedDialog, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), null);
|
|
|
|
}
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats, selectedDialog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
showAlertDialog(builder);
|
|
|
|
}
|
|
|
|
});
|
2014-03-22 23:31:55 +01:00
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
2014-06-07 01:35:21 +02:00
|
|
|
showAlertDialog(builder);
|
2013-10-25 17:19:00 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
messagesListView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
|
|
|
@Override
|
|
|
|
public void onScrollStateChanged(AbsListView absListView, int i) {
|
2014-05-25 00:47:05 +02:00
|
|
|
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
2014-07-03 00:39:05 +02:00
|
|
|
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
2014-05-25 00:47:05 +02:00
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
|
|
|
if (searching && searchWas) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (visibleItemCount > 0) {
|
2014-03-22 23:31:55 +01:00
|
|
|
if (absListView.getLastVisiblePosition() == MessagesController.getInstance().dialogs.size() && !serverOnly || absListView.getLastVisiblePosition() == MessagesController.getInstance().dialogsServerOnly.size() && serverOnly) {
|
|
|
|
MessagesController.getInstance().loadDialogs(MessagesController.getInstance().dialogs.size(), MessagesController.getInstance().dialogsServerOnly.size(), 100, true);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
2014-11-06 22:34:47 +01:00
|
|
|
|
|
|
|
if (floatingButton.getVisibility() != View.GONE) {
|
|
|
|
final View topChild = absListView.getChildAt(0);
|
|
|
|
int firstViewTop = 0;
|
|
|
|
if (topChild != null) {
|
|
|
|
firstViewTop = topChild.getTop();
|
|
|
|
}
|
|
|
|
boolean goingDown;
|
|
|
|
boolean changed = true;
|
|
|
|
if (prevPosition == firstVisibleItem) {
|
|
|
|
final int topDelta = prevTop - firstViewTop;
|
|
|
|
goingDown = firstViewTop < prevTop;
|
|
|
|
changed = Math.abs(topDelta) > 1;
|
|
|
|
} else {
|
|
|
|
goingDown = firstVisibleItem > prevPosition;
|
|
|
|
}
|
|
|
|
if (changed && scrollUpdated) {
|
|
|
|
hideFloatingButton(goingDown);
|
|
|
|
}
|
|
|
|
prevPosition = firstVisibleItem;
|
|
|
|
prevTop = firstViewTop;
|
|
|
|
scrollUpdated = true;
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
|
|
|
if (parent != null) {
|
|
|
|
parent.removeView(fragmentView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fragmentView;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
2014-06-04 18:00:42 +02:00
|
|
|
super.onResume();
|
2014-11-13 21:10:14 +01:00
|
|
|
if (dialogsAdapter != null) {
|
|
|
|
dialogsAdapter.notifyDataSetChanged();
|
2014-10-31 20:02:29 +01:00
|
|
|
}
|
2014-11-13 21:10:14 +01:00
|
|
|
if (dialogsSearchAdapter != null) {
|
|
|
|
dialogsSearchAdapter.notifyDataSetChanged();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-06 22:34:47 +01:00
|
|
|
@Override
|
|
|
|
public void onConfigurationChanged(Configuration newConfig) {
|
|
|
|
super.onConfigurationChanged(newConfig);
|
|
|
|
if (!onlySelect && floatingButton != null) {
|
|
|
|
floatingButton.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
|
|
@Override
|
|
|
|
public void onGlobalLayout() {
|
|
|
|
ViewProxy.setTranslationY(floatingButton, floatingHidden ? AndroidUtilities.dp(100) : 0);
|
|
|
|
if (floatingButton != null) {
|
|
|
|
if (Build.VERSION.SDK_INT < 16) {
|
|
|
|
floatingButton.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
|
|
|
} else {
|
|
|
|
floatingButton.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
@Override
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
public void didReceivedNotification(int id, Object... args) {
|
2014-08-22 16:24:33 +02:00
|
|
|
if (id == NotificationCenter.dialogsNeedReload) {
|
2014-11-13 21:10:14 +01:00
|
|
|
if (dialogsAdapter != null) {
|
|
|
|
dialogsAdapter.notifyDataSetChanged();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
if (messagesListView != null) {
|
2014-03-22 23:31:55 +01:00
|
|
|
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
|
2013-10-25 17:19:00 +02:00
|
|
|
searchEmptyView.setVisibility(View.GONE);
|
2014-10-07 22:14:27 +02:00
|
|
|
emptyView.setVisibility(View.GONE);
|
2014-10-31 20:02:29 +01:00
|
|
|
messagesListView.setEmptyView(progressView);
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
2014-11-17 03:44:57 +01:00
|
|
|
if (searching && searchWas) {
|
|
|
|
messagesListView.setEmptyView(searchEmptyView);
|
|
|
|
emptyView.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
messagesListView.setEmptyView(emptyView);
|
|
|
|
searchEmptyView.setVisibility(View.GONE);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
progressView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.emojiDidLoaded) {
|
2013-10-25 17:19:00 +02:00
|
|
|
if (messagesListView != null) {
|
2014-02-04 19:36:55 +01:00
|
|
|
updateVisibleRows(0);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.updateInterfaces) {
|
2014-02-04 19:36:55 +01:00
|
|
|
updateVisibleRows((Integer)args[0]);
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.appDidLogout) {
|
2013-10-25 17:19:00 +02:00
|
|
|
dialogsLoaded = false;
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.encryptedChatUpdated) {
|
2014-02-04 19:36:55 +01:00
|
|
|
updateVisibleRows(0);
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.contactsDidLoaded) {
|
2014-02-04 19:36:55 +01:00
|
|
|
updateVisibleRows(0);
|
2014-09-24 04:17:27 +02:00
|
|
|
} else if (id == NotificationCenter.openedChatChanged) {
|
|
|
|
if (!serverOnly && AndroidUtilities.isTablet()) {
|
2014-09-30 00:48:11 +02:00
|
|
|
boolean close = (Boolean)args[1];
|
|
|
|
long dialog_id = (Long)args[0];
|
|
|
|
if (close) {
|
|
|
|
if (dialog_id == openedDialogId) {
|
|
|
|
openedDialogId = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
openedDialogId = dialog_id;
|
|
|
|
}
|
2014-11-13 21:10:14 +01:00
|
|
|
dialogsAdapter.setOpenedDialogId(openedDialogId);
|
2014-11-11 23:16:17 +01:00
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-06 22:34:47 +01:00
|
|
|
private void hideFloatingButton(boolean hide) {
|
|
|
|
if (floatingHidden == hide) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
floatingHidden = hide;
|
|
|
|
ObjectAnimatorProxy animator = ObjectAnimatorProxy.ofFloatProxy(floatingButton, "translationY", floatingHidden ? AndroidUtilities.dp(100) : 0).setDuration(300);
|
|
|
|
animator.setInterpolator(floatingInterpolator);
|
|
|
|
animator.start();
|
|
|
|
}
|
|
|
|
|
2014-02-04 19:36:55 +01:00
|
|
|
private void updateVisibleRows(int mask) {
|
|
|
|
if (messagesListView == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int count = messagesListView.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View child = messagesListView.getChildAt(a);
|
|
|
|
if (child instanceof DialogCell) {
|
2014-09-24 04:17:27 +02:00
|
|
|
DialogCell cell = (DialogCell) child;
|
2014-11-11 23:16:17 +01:00
|
|
|
if ((mask & MessagesController.UPDATE_MASK_SELECT_DIALOG) != 0) {
|
|
|
|
if (!serverOnly && AndroidUtilities.isTablet()) {
|
|
|
|
if (cell.getDialogId() == openedDialogId) {
|
|
|
|
child.setBackgroundColor(0x0f000000);
|
|
|
|
} else {
|
|
|
|
child.setBackgroundColor(0);
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
2014-11-11 23:16:17 +01:00
|
|
|
} else {
|
|
|
|
cell.update(mask);
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
2014-11-10 12:05:22 +01:00
|
|
|
} else if (child instanceof UserCell) {
|
|
|
|
((UserCell) child).update(mask);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-04 01:31:48 +02:00
|
|
|
public void setDelegate(MessagesActivityDelegate delegate) {
|
|
|
|
this.delegate = delegate;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
2014-09-24 04:17:27 +02:00
|
|
|
public MessagesActivityDelegate getDelegate() {
|
|
|
|
return delegate;
|
|
|
|
}
|
|
|
|
|
2014-07-10 23:15:39 +02:00
|
|
|
private void didSelectResult(final long dialog_id, boolean useAlert, final boolean param) {
|
2014-10-04 17:56:09 +02:00
|
|
|
if (useAlert && selectAlertString != null && selectAlertStringGroup != null) {
|
2014-06-14 10:36:01 +02:00
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
2014-04-02 19:36:57 +02:00
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
2013-10-25 17:19:00 +02:00
|
|
|
int lower_part = (int)dialog_id;
|
2014-07-27 12:53:00 +02:00
|
|
|
int high_id = (int)(dialog_id >> 32);
|
2013-10-25 17:19:00 +02:00
|
|
|
if (lower_part != 0) {
|
2014-07-27 12:53:00 +02:00
|
|
|
if (high_id == 1) {
|
2014-08-22 16:24:33 +02:00
|
|
|
TLRPC.Chat chat = MessagesController.getInstance().getChat(lower_part);
|
2014-02-04 19:36:55 +01:00
|
|
|
if (chat == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-10-04 17:56:09 +02:00
|
|
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertStringGroup, chat.title));
|
2014-07-27 00:28:33 +02:00
|
|
|
} else {
|
2014-07-27 12:53:00 +02:00
|
|
|
if (lower_part > 0) {
|
2014-08-22 16:24:33 +02:00
|
|
|
TLRPC.User user = MessagesController.getInstance().getUser(lower_part);
|
2014-07-27 12:53:00 +02:00
|
|
|
if (user == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, ContactsController.formatName(user.first_name, user.last_name)));
|
2014-07-27 12:53:00 +02:00
|
|
|
} else if (lower_part < 0) {
|
2014-08-22 16:24:33 +02:00
|
|
|
TLRPC.Chat chat = MessagesController.getInstance().getChat(-lower_part);
|
2014-07-27 12:53:00 +02:00
|
|
|
if (chat == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-10-04 17:56:09 +02:00
|
|
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertStringGroup, chat.title));
|
2014-07-27 00:28:33 +02:00
|
|
|
}
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
2014-07-27 12:53:00 +02:00
|
|
|
} else {
|
2014-08-22 16:24:33 +02:00
|
|
|
TLRPC.EncryptedChat chat = MessagesController.getInstance().getEncryptedChat(high_id);
|
|
|
|
TLRPC.User user = MessagesController.getInstance().getUser(chat.user_id);
|
2014-07-27 12:53:00 +02:00
|
|
|
if (user == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, ContactsController.formatName(user.first_name, user.last_name)));
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-07-10 23:15:39 +02:00
|
|
|
CheckBox checkBox = null;
|
2014-07-20 01:31:49 +02:00
|
|
|
/*if (delegate instanceof ChatActivity) {
|
2014-07-10 23:15:39 +02:00
|
|
|
checkBox = new CheckBox(getParentActivity());
|
|
|
|
checkBox.setText(LocaleController.getString("ForwardFromMyName", R.string.ForwardFromMyName));
|
|
|
|
checkBox.setChecked(false);
|
|
|
|
builder.setView(checkBox);
|
2014-07-20 01:31:49 +02:00
|
|
|
}*/
|
2014-07-10 23:15:39 +02:00
|
|
|
final CheckBox checkBoxFinal = checkBox;
|
2013-10-25 17:19:00 +02:00
|
|
|
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
2014-07-10 23:15:39 +02:00
|
|
|
didSelectResult(dialog_id, false, checkBoxFinal != null && checkBoxFinal.isChecked());
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.Cancel, null);
|
2014-06-07 01:35:21 +02:00
|
|
|
showAlertDialog(builder);
|
2014-07-10 23:15:39 +02:00
|
|
|
if (checkBox != null) {
|
|
|
|
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)checkBox.getLayoutParams();
|
|
|
|
if (layoutParams != null) {
|
|
|
|
layoutParams.rightMargin = layoutParams.leftMargin = AndroidUtilities.dp(10);
|
|
|
|
checkBox.setLayoutParams(layoutParams);
|
|
|
|
}
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
|
|
|
if (delegate != null) {
|
2014-07-10 23:15:39 +02:00
|
|
|
delegate.didSelectDialog(MessagesActivity.this, dialog_id, param);
|
2013-10-25 17:19:00 +02:00
|
|
|
delegate = null;
|
|
|
|
} else {
|
|
|
|
finishFragment();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|