blob: aecfd25806d7db457abb307fd8a56d00b9611077 [file] [log] [blame]
Loïc Siret0202fbf2017-09-28 16:34:28 -04001/*
2 * Copyright (C) 2017 Savoir-faire Linux Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
Aline Bonnet9c6defe2016-12-21 13:21:02 -050018package cx.ring.fragments;
19
Aline Bonnete8e87f62016-12-26 10:54:37 -050020import android.content.Context;
Aline Bonnet87970532017-03-17 11:01:01 -040021import android.content.DialogInterface;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050022import android.content.Intent;
Aline Bonnet830c4c62016-12-27 14:02:02 -050023import android.content.res.Configuration;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050024import android.graphics.Bitmap;
25import android.os.Bundle;
26import android.support.design.widget.Snackbar;
27import android.support.v7.app.ActionBar;
28import android.support.v7.app.AlertDialog;
Aline Bonnete8e87f62016-12-26 10:54:37 -050029import android.support.v7.app.AppCompatActivity;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050030import android.support.v7.widget.DefaultItemAnimator;
31import android.support.v7.widget.LinearLayoutManager;
32import android.support.v7.widget.RecyclerView;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050033import android.view.Menu;
34import android.view.MenuInflater;
35import android.view.MenuItem;
36import android.view.View;
37import android.view.ViewGroup;
38import android.view.inputmethod.EditorInfo;
39import android.widget.EditText;
40import android.widget.Spinner;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050041
Aline Bonnet87970532017-03-17 11:01:01 -040042import java.io.ByteArrayOutputStream;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050043
Aline Bonnet9c6defe2016-12-21 13:21:02 -050044import butterknife.BindView;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050045import butterknife.OnClick;
46import butterknife.OnEditorAction;
47import cx.ring.R;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050048import cx.ring.adapters.ConversationAdapter;
49import cx.ring.adapters.NumberAdapter;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050050import cx.ring.client.CallActivity;
Aline Bonnet830c4c62016-12-27 14:02:02 -050051import cx.ring.client.ConversationActivity;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050052import cx.ring.client.HomeActivity;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040053import cx.ring.conversation.ConversationPresenter;
54import cx.ring.conversation.ConversationView;
Hadrien De Sousa73d6dd72017-09-07 10:54:51 -040055import cx.ring.dependencyinjection.RingInjectionComponent;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050056import cx.ring.model.Account;
57import cx.ring.model.CallContact;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050058import cx.ring.model.Conversation;
59import cx.ring.model.Phone;
60import cx.ring.model.Uri;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040061import cx.ring.mvp.BaseFragment;
Hadrien De Sousaccc947d2017-04-12 14:26:52 -040062import cx.ring.services.NotificationService;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050063import cx.ring.utils.ActionHelper;
Aline Bonnet87970532017-03-17 11:01:01 -040064import cx.ring.utils.BitmapUtils;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050065import cx.ring.utils.ClipboardHelper;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040066import cx.ring.utils.Tuple;
Aline Bonnet87970532017-03-17 11:01:01 -040067import cx.ring.utils.VCardUtils;
68import ezvcard.VCard;
69import ezvcard.parameter.ImageType;
70import ezvcard.property.Photo;
71import ezvcard.property.RawProperty;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050072
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040073public class ConversationFragment extends BaseFragment<ConversationPresenter> implements
Aline Bonnet9c6defe2016-12-21 13:21:02 -050074 Conversation.ConversationActionCallback,
75 ClipboardHelper.ClipboardHelperCallback,
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040076 ConversationView {
Aline Bonnet9c6defe2016-12-21 13:21:02 -050077
Hadrien De Sousaccc947d2017-04-12 14:26:52 -040078 public static final int REQ_ADD_CONTACT = 42;
79 public static final String KEY_CONVERSATION_ID = "CONVERSATION_ID";
80
Aline Bonnet9c6defe2016-12-21 13:21:02 -050081 private static final String TAG = ConversationFragment.class.getSimpleName();
82 private static final String CONVERSATION_DELETE = "CONVERSATION_DELETE";
Aline Bonnet830c4c62016-12-27 14:02:02 -050083 private static final int MIN_SIZE_TABLET = 960;
Aline Bonnet9c6defe2016-12-21 13:21:02 -050084
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040085 @BindView(R.id.msg_input_txt)
86 protected EditText mMsgEditTxt;
87
88 @BindView(R.id.ongoingcall_pane)
Hadrien De Sousaccc947d2017-04-12 14:26:52 -040089 protected ViewGroup mTopPane;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040090
91 @BindView(R.id.hist_list)
92 protected RecyclerView mHistList;
93
94 @BindView(R.id.number_selector)
95 protected Spinner mNumberSpinner;
96
Aline Bonnet9c6defe2016-12-21 13:21:02 -050097 private AlertDialog mDeleteDialog;
98 private boolean mDeleteConversation = false;
99
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500100 private MenuItem mAddContactBtn = null;
101
102 private ConversationAdapter mAdapter = null;
103 private NumberAdapter mNumberAdapter = null;
104
Aline Bonnet830c4c62016-12-27 14:02:02 -0500105 public static Boolean isTabletMode(Context context) {
106 return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
107 && context.getResources().getConfiguration().screenWidthDp >= MIN_SIZE_TABLET;
108 }
109
Thibault Wittemberge05a8e12016-12-12 15:39:36 -0500110 static private int getIndex(Spinner spinner, Uri myString) {
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500111 for (int i = 0, n = spinner.getCount(); i < n; i++)
112 if (((Phone) spinner.getItemAtPosition(i)).getNumber().equals(myString)) {
113 return i;
114 }
115 return 0;
116 }
117
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400118 @Override
119 public void refreshView(final Conversation conversation, Uri number) {
120 getActivity().runOnUiThread(new Runnable() {
121 @Override
122 public void run() {
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400123 if (mAdapter != null) {
124 mAdapter.updateDataset(conversation.getAggregateHistory(), 0);
125
126 if (mAdapter.getItemCount() > 0) {
127 mHistList.smoothScrollToPosition(mAdapter.getItemCount() - 1);
128 }
129 }
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400130 getActivity().invalidateOptionsMenu();
Aline Bonneteb5f7ff2017-01-17 11:09:17 -0500131 }
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400132 });
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500133 }
134
Aline Bonnete8e87f62016-12-26 10:54:37 -0500135 @Override
Hadrien De Sousa73d6dd72017-09-07 10:54:51 -0400136 public int getLayout() {
137 return R.layout.frag_conversation;
138 }
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500139
Hadrien De Sousa73d6dd72017-09-07 10:54:51 -0400140 @Override
141 public void injectFragment(RingInjectionComponent component) {
142 component.inject(this);
143 }
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500144
Hadrien De Sousa73d6dd72017-09-07 10:54:51 -0400145 @Override
146 public void onViewCreated(View view, Bundle savedInstanceState) {
147 super.onViewCreated(view, savedInstanceState);
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500148
Hadrien De Sousaccc947d2017-04-12 14:26:52 -0400149 if (mTopPane != null) {
150 mTopPane.setVisibility(View.GONE);
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500151 }
152
153 LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
154 mLayoutManager.setStackFromEnd(true);
155
156 if (mHistList != null) {
157 mHistList.setLayoutManager(mLayoutManager);
158 mHistList.setAdapter(mAdapter);
159 mHistList.setItemAnimator(new DefaultItemAnimator());
160 }
161
162 // reload delete conversation state (before rotation)
163 mDeleteConversation = savedInstanceState != null && savedInstanceState.getBoolean(CONVERSATION_DELETE);
164
165 setHasOptionsMenu(true);
Aline Bonnete8e87f62016-12-26 10:54:37 -0500166
Alexandre Lision62c69782017-04-04 17:26:44 -0400167 mAdapter = new ConversationAdapter();
168
169 if (mHistList != null) {
170 mHistList.setAdapter(mAdapter);
171 }
172
173 if (mDeleteConversation) {
174 presenter.deleteAction();
Aline Bonnete8e87f62016-12-26 10:54:37 -0500175 }
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500176 }
177
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400178 @Override
179 public void displaySendTrustRequest(final String accountId, final String contactId) {
Aline Bonnet87970532017-03-17 11:01:01 -0400180 android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity());
181 builder.setTitle(R.string.send_request_title);
182 builder.setMessage(R.string.send_request_msg);
183
184 builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
185 @Override
186 public void onClick(DialogInterface dialogInterface, int i) {
187 dialogInterface.cancel();
188 }
189 });
190
191 builder.setPositiveButton(R.string.send_request_button, new DialogInterface.OnClickListener() {
192 @Override
193 public void onClick(DialogInterface dialogInterface, int i) {
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400194 VCard vcard = VCardUtils.loadLocalProfileFromDisk(getActivity().getFilesDir(), accountId);
Alexandre Lision45112682017-03-31 13:49:49 -0400195 if (vcard != null && !vcard.getPhotos().isEmpty()) {
196 // Reduce photo size to fit in one DHT packet
197 Bitmap photo = BitmapUtils.bytesToBitmap(vcard.getPhotos().get(0).getData());
198 photo = BitmapUtils.reduceBitmap(photo, 30000);
199 ByteArrayOutputStream stream = new ByteArrayOutputStream();
200 photo.compress(Bitmap.CompressFormat.PNG, 100, stream);
201 vcard.removeProperties(Photo.class);
202 vcard.addPhoto(new Photo(stream.toByteArray(), ImageType.PNG));
203 vcard.removeProperties(RawProperty.class);
204 }
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400205 presenter.sendTrustRequest(accountId, contactId, vcard);
Aline Bonnet87970532017-03-17 11:01:01 -0400206 }
207 });
208
209 builder.show();
210 }
211
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500212 @OnClick(R.id.msg_send)
Alexandre Lision66a9f9a2017-02-26 20:28:27 -0500213 public void sendMessageText() {
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400214 Uri number = mNumberAdapter == null ?
215 null : ((Phone) mNumberSpinner.getSelectedItem()).getNumber();
216 presenter.sendTextMessage(mMsgEditTxt.getText().toString(), number);
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500217 }
218
219 @OnEditorAction(R.id.msg_input_txt)
Alexandre Lision66a9f9a2017-02-26 20:28:27 -0500220 public boolean actionSendMsgText(int actionId) {
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500221 switch (actionId) {
222 case EditorInfo.IME_ACTION_SEND:
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400223 Uri number = mNumberAdapter == null ?
224 null : ((Phone) mNumberSpinner.getSelectedItem()).getNumber();
225 presenter.sendTextMessage(mMsgEditTxt.getText().toString(), number);
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500226 return true;
227 }
228 return false;
229 }
230
231 @OnClick(R.id.ongoingcall_pane)
Alexandre Lision66a9f9a2017-02-26 20:28:27 -0500232 public void onClick() {
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400233 presenter.clickOnGoingPane();
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500234 }
235
236 @Override
237 public void onPause() {
238 super.onPause();
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400239 presenter.pause();
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500240 }
241
242 @Override
243 public void onResume() {
244 super.onResume();
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400245 presenter.resume();
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500246 }
247
248 @Override
249 public void onDestroy() {
250 if (mDeleteConversation) {
251 mDeleteDialog.dismiss();
252 }
253
254 super.onDestroy();
255 }
256
257 @Override
258 public void onSaveInstanceState(Bundle outState) {
259 super.onSaveInstanceState(outState);
260
261 // persist the delete popup state in case of Activity rotation
262 mDeleteConversation = mDeleteDialog != null && mDeleteDialog.isShowing();
263 outState.putBoolean(CONVERSATION_DELETE, mDeleteConversation);
264 }
265
266 @Override
267 public void onPrepareOptionsMenu(Menu menu) {
268 super.onPrepareOptionsMenu(menu);
Hadrien De Sousaf5774ee2017-05-17 14:04:17 -0400269 presenter.prepareMenu();
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500270 }
271
272 @Override
273 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400274 inflater.inflate(R.menu.conversation_actions, menu);
275 mAddContactBtn = menu.findItem(R.id.menuitem_addcontact);
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500276 }
277
278 @Override
279 public boolean onOptionsItemSelected(MenuItem item) {
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400280 Uri number;
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500281 switch (item.getItemId()) {
282 case android.R.id.home:
283 startActivity(new Intent(getActivity(), HomeActivity.class));
284 return true;
285 case R.id.conv_action_audiocall:
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400286 number = mNumberAdapter == null ?
287 null : ((Phone) mNumberSpinner.getSelectedItem()).getNumber();
Hadrien De Sousaf5774ee2017-05-17 14:04:17 -0400288 presenter.callWithVideo(false, number);
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500289 return true;
290 case R.id.conv_action_videocall:
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400291 number = mNumberAdapter == null ?
292 null : ((Phone) mNumberSpinner.getSelectedItem()).getNumber();
Hadrien De Sousaf5774ee2017-05-17 14:04:17 -0400293 presenter.callWithVideo(true, number);
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500294 return true;
295 case R.id.menuitem_addcontact:
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400296 presenter.addContact();
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500297 return true;
298 case R.id.menuitem_delete:
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400299 presenter.deleteAction();
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500300 return true;
301 case R.id.menuitem_copy_content:
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400302 presenter.copyToClipboard();
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500303 return true;
Aline Bonnet54cf69b2017-03-28 12:03:45 -0400304 case R.id.menuitem_block:
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400305 presenter.blockContact();
Aline Bonnet54cf69b2017-03-28 12:03:45 -0400306 return true;
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500307 default:
308 return super.onOptionsItemSelected(item);
309 }
310 }
311
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500312 @Override
313 public void deleteConversation(Conversation conversation) {
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400314 presenter.deleteConversation();
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500315 }
316
317 @Override
318 public void copyContactNumberToClipboard(String contactNumber) {
319 ClipboardHelper.copyNumberToClipboard(getActivity(), contactNumber, this);
320 }
321
322 @Override
323 public void clipBoardDidCopyNumber(String copiedNumber) {
324 View view = getActivity().findViewById(android.R.id.content);
325 if (view != null) {
326 String snackbarText = getString(R.string.conversation_action_copied_peer_number_clipboard,
Alexandre Lision6fd56c82017-01-30 09:05:54 -0500327 ActionHelper.getShortenedNumber(copiedNumber));
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500328 Snackbar.make(view, snackbarText, Snackbar.LENGTH_LONG).show();
329 }
330 }
331
332 @Override
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400333 protected void initPresenter(ConversationPresenter presenter) {
334 super.initPresenter(presenter);
Hadrien De Sousaccc947d2017-04-12 14:26:52 -0400335 String conversationId = getArguments().getString(KEY_CONVERSATION_ID);
336 Uri number = new Uri(getArguments().getString(CallFragment.KEY_NUMBER));
Hadrien De Sousaf5774ee2017-05-17 14:04:17 -0400337 presenter.init(conversationId, number);
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400338 }
339
340 @Override
341 public void updateView(final String address, final String name, final int state) {
342 getActivity().runOnUiThread(new Runnable() {
343 @Override
344 public void run() {
Aline Bonneteb5f7ff2017-01-17 11:09:17 -0500345 if (state != 0 || mNumberAdapter == null || mNumberAdapter.isEmpty()) {
346 return;
347 }
348
349 for (int i = 0; i < mNumberAdapter.getCount(); i++) {
350 Phone phone = (Phone) mNumberAdapter.getItem(i);
351 if (phone.getNumber() != null) {
352 String ringID = phone.getNumber().getRawUriString();
353 if (address.equals(ringID)) {
354 phone.getNumber().setUsername(name);
355 mNumberAdapter.notifyDataSetChanged();
356 }
357 }
358 }
359 }
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400360 });
361 }
362
363 @Override
Cyrille Béraud35b5a892017-07-22 17:20:13 -0400364 public void displayContactName(final CallContact contact) {
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400365 getActivity().runOnUiThread(new Runnable() {
366 @Override
367 public void run() {
Cyrille Béraud35b5a892017-07-22 17:20:13 -0400368 ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
369 if (actionBar == null) {
370 return;
371 }
372 String displayName = contact.getDisplayName();
373 actionBar.setTitle(displayName);
374 String identity = contact.getRingUsername();
375 if (identity != null && !identity.equals(displayName)) {
376 actionBar.setSubtitle(identity);
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400377 }
Alexandre Lision66a9f9a2017-02-26 20:28:27 -0500378 }
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400379 });
380 }
381
382 @Override
383 public void displayOnGoingCallPane(final boolean display) {
384 getActivity().runOnUiThread(new Runnable() {
385 @Override
386 public void run() {
Hadrien De Sousaccc947d2017-04-12 14:26:52 -0400387 mTopPane.setVisibility(display ? View.GONE : View.VISIBLE);
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400388 }
389 });
390 }
391
392 @Override
Alexandre Lision62c69782017-04-04 17:26:44 -0400393 public void displayContactPhoto(final byte[] photo) {
394 getActivity().runOnUiThread(new Runnable() {
395 @Override
396 public void run() {
397 mAdapter.setPhoto(photo);
398 }
399 });
400 }
401
402 @Override
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400403 public void displayNumberSpinner(final Conversation conversation, final Uri number) {
404 getActivity().runOnUiThread(new Runnable() {
405 @Override
406 public void run() {
407 mNumberSpinner.setVisibility(View.VISIBLE);
408 mNumberAdapter = new NumberAdapter(getActivity(),
409 conversation.getContact(),
410 false);
411 mNumberSpinner.setAdapter(mNumberAdapter);
412 mNumberSpinner.setSelection(getIndex(mNumberSpinner, number));
413 }
414 });
415 }
416
417 @Override
418 public void displayAddContact(final boolean display) {
419 getActivity().runOnUiThread(new Runnable() {
420 @Override
421 public void run() {
422 if (mAddContactBtn != null) {
423 mAddContactBtn.setVisible(display);
424 }
425 }
426 });
427 }
428
429 @Override
430 public void displayDeleteDialog(final Conversation conversation) {
431 getActivity().runOnUiThread(new Runnable() {
432 @Override
433 public void run() {
434 mDeleteDialog = ActionHelper.launchDeleteAction(getActivity(),
435 conversation,
436 ConversationFragment.this);
437 }
438 });
439 }
440
441 @Override
442 public void displayCopyToClipboard(CallContact callContact) {
443 ActionHelper.launchCopyNumberToClipboardFromContact(getActivity(),
444 callContact,
445 this);
446 }
447
448 @Override
449 public void hideNumberSpinner() {
450 getActivity().runOnUiThread(new Runnable() {
451 @Override
452 public void run() {
453 mNumberSpinner.setVisibility(View.GONE);
454 }
455 });
456 }
457
458 @Override
459 public void clearMsgEdit() {
460 mMsgEditTxt.setText("");
461 }
462
463 @Override
464 public void goToHome() {
465 if (getActivity() instanceof ConversationActivity) {
466 getActivity().finish();
Aline Bonneteb5f7ff2017-01-17 11:09:17 -0500467 }
468 }
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400469
470 @Override
471 public void goToAddContact(CallContact callContact) {
472 startActivityForResult(ActionHelper.getAddNumberIntentForContact(callContact), REQ_ADD_CONTACT);
473 }
474
475 @Override
476 public void goToCallActivity(String conferenceId) {
477 startActivity(new Intent(Intent.ACTION_VIEW)
478 .setClass(getActivity().getApplicationContext(), CallActivity.class)
Hadrien De Sousaccc947d2017-04-12 14:26:52 -0400479 .putExtra(NotificationService.KEY_CALL_ID, conferenceId));
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400480 }
481
482 @Override
483 public void goToCallActivityWithResult(Tuple<Account, Uri> guess, boolean hasVideo) {
484 Intent intent = new Intent(CallActivity.ACTION_CALL)
485 .setClass(getActivity().getApplicationContext(), CallActivity.class)
486 .putExtra("account", guess.first.getAccountID())
487 .putExtra("video", hasVideo)
488 .setData(android.net.Uri.parse(guess.second.getRawUriString()));
489 startActivityForResult(intent, HomeActivity.REQUEST_CODE_CALL);
490 }
Aline Bonnet9c6defe2016-12-21 13:21:02 -0500491}