blob: 1f0e9c6bc7c813d7f87fb13925049c2eccc0b9e4 [file] [log] [blame]
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -04001/*
Sébastien Blinab53ada2019-01-02 17:23:00 -05002 * Copyright (C) 2004-2019 Savoir-faire Linux Inc.
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -04003 *
4 * Author: Hadrien De Sousa <hadrien.desousa@savoirfairelinux.com>
Adrien Béraud64538722018-03-15 17:34:00 -04005 * Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -04006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21package cx.ring.conversation;
22
Pierre Duchemine0c3a492018-02-01 16:22:45 -050023import java.io.File;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040024
25import javax.inject.Inject;
Adrien Béraudace37a22018-06-22 14:58:36 -040026import javax.inject.Named;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040027
28import cx.ring.daemon.Blob;
29import cx.ring.facades.ConversationFacade;
Adrien Béraud20d42212018-03-02 14:40:38 -050030import cx.ring.model.Account;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040031import cx.ring.model.CallContact;
32import cx.ring.model.Conference;
33import cx.ring.model.Conversation;
Adrien Béraud7c505112018-03-20 16:03:28 -040034import cx.ring.model.DataTransfer;
Rayan Osseiran6f415662019-10-25 14:23:25 -040035import cx.ring.model.Interaction;
Hadrien De Sousa6cd2bd22018-01-02 16:11:32 -050036import cx.ring.model.RingError;
Aline Bonnet15fdf0a2017-04-26 17:02:58 -040037import cx.ring.model.SipCall;
Pierre Duchemin1fa61922018-01-18 10:09:02 -050038import cx.ring.model.TrustRequest;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040039import cx.ring.model.Uri;
40import cx.ring.mvp.RootPresenter;
41import cx.ring.services.AccountService;
42import cx.ring.services.ContactService;
Pierre Duchemin4af6b392018-02-02 11:23:56 -050043import cx.ring.services.DeviceRuntimeService;
Hadrien De Sousa45fb21b2017-12-14 11:06:48 -050044import cx.ring.services.HardwareService;
Hadrien De Sousa6cd2bd22018-01-02 16:11:32 -050045import cx.ring.services.VCardService;
Hadrien De Sousa0dc83162017-11-10 16:15:18 -050046import cx.ring.utils.Log;
Adrien Béraudace37a22018-06-22 14:58:36 -040047import cx.ring.utils.StringUtils;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040048import cx.ring.utils.VCardUtils;
Adrien Béraudace37a22018-06-22 14:58:36 -040049import io.reactivex.Scheduler;
50import io.reactivex.disposables.CompositeDisposable;
51import io.reactivex.schedulers.Schedulers;
Adrien Béraud7aa7a9e2018-06-29 19:50:32 -040052import io.reactivex.subjects.BehaviorSubject;
53import io.reactivex.subjects.Subject;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040054
Adrien Béraudace37a22018-06-22 14:58:36 -040055public class ConversationPresenter extends RootPresenter<ConversationView> {
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040056
Hadrien De Sousa0dc83162017-11-10 16:15:18 -050057 private static final String TAG = ConversationPresenter.class.getSimpleName();
Adrien Béraud68f1adb2018-07-18 18:35:21 -040058 private final ContactService mContactService;
Adrien Béraudace37a22018-06-22 14:58:36 -040059 private final AccountService mAccountService;
Adrien Béraudace37a22018-06-22 14:58:36 -040060 private final HardwareService mHardwareService;
61 private final ConversationFacade mConversationFacade;
62 private final VCardService mVCardService;
63 private final DeviceRuntimeService mDeviceRuntimeService;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040064
65 private Conversation mConversation;
Pierre Duchemin1fa61922018-01-18 10:09:02 -050066 private Uri mContactRingId;
Hadrien De Sousa0dc83162017-11-10 16:15:18 -050067 private String mAccountId;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040068
Adrien Béraudace37a22018-06-22 14:58:36 -040069 private CompositeDisposable mConversationDisposable;
Adrien Béraud7aa7a9e2018-06-29 19:50:32 -040070 private final CompositeDisposable mVisibilityDisposable = new CompositeDisposable();
Adrien Béraudace37a22018-06-22 14:58:36 -040071
72 @Inject
73 @Named("UiScheduler")
74 protected Scheduler mUiScheduler;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040075
Adrien Béraud7aa7a9e2018-06-29 19:50:32 -040076 private final Subject<Conversation> mConversationSubject = BehaviorSubject.create();
77
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040078 @Inject
Adrien Béraud64538722018-03-15 17:34:00 -040079 public ConversationPresenter(ContactService contactService,
80 AccountService accountService,
Hadrien De Sousa45fb21b2017-12-14 11:06:48 -050081 HardwareService hardwareService,
Hadrien De Sousa0dc83162017-11-10 16:15:18 -050082 ConversationFacade conversationFacade,
Hadrien De Sousa6cd2bd22018-01-02 16:11:32 -050083 VCardService vCardService,
Adrien Béraud7c505112018-03-20 16:03:28 -040084 DeviceRuntimeService deviceRuntimeService) {
Adrien Béraud64538722018-03-15 17:34:00 -040085 this.mContactService = contactService;
86 this.mAccountService = accountService;
Hadrien De Sousa45fb21b2017-12-14 11:06:48 -050087 this.mHardwareService = hardwareService;
Hadrien De Sousa0dc83162017-11-10 16:15:18 -050088 this.mConversationFacade = conversationFacade;
Hadrien De Sousa6cd2bd22018-01-02 16:11:32 -050089 this.mVCardService = vCardService;
Pierre Duchemin1fa61922018-01-18 10:09:02 -050090 this.mDeviceRuntimeService = deviceRuntimeService;
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040091 }
92
93 @Override
Adrien Béraudace37a22018-06-22 14:58:36 -040094 public void bindView(ConversationView view) {
95 super.bindView(view);
Adrien Béraud7aa7a9e2018-06-29 19:50:32 -040096 mCompositeDisposable.add(mVisibilityDisposable);
97 if (mConversationDisposable == null && mConversation != null)
98 initView(mConversation, view);
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -040099 }
100
Pierre Duchemin1fa61922018-01-18 10:09:02 -0500101 public void init(Uri contactRingId, String accountId) {
Adrien Béraudace37a22018-06-22 14:58:36 -0400102 Log.w(TAG, "init " + contactRingId + " " + accountId);
Hadrien De Sousa0dc83162017-11-10 16:15:18 -0500103 mContactRingId = contactRingId;
104 mAccountId = accountId;
Adrien Béraude5ec8952018-07-11 15:14:44 -0400105 Account account = mAccountService.getAccount(accountId);
106 if (account != null)
107 initContact(account, contactRingId, getView());
Rayan Osseiran6f415662019-10-25 14:23:25 -0400108
109 mCompositeDisposable.add(mConversationFacade.loadConversationHistory(account, contactRingId).observeOn(mUiScheduler).subscribe(this::setConversation, e -> getView().goToHome()));
110
111
Adrien Béraudace37a22018-06-22 14:58:36 -0400112 }
Pierre Duchemine0c3a492018-02-01 16:22:45 -0500113
Adrien Béraudace37a22018-06-22 14:58:36 -0400114 private void setConversation(final Conversation conversation) {
115 if (conversation == null || mConversation == conversation)
116 return;
117 mConversation = conversation;
Adrien Béraud7aa7a9e2018-06-29 19:50:32 -0400118 mConversationSubject.onNext(conversation);
119 ConversationView view = getView();
120 if (view != null)
121 initView(conversation, view);
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400122 }
123
124 public void pause() {
Adrien Béraud7aa7a9e2018-06-29 19:50:32 -0400125 mVisibilityDisposable.clear();
Adrien Béraudace37a22018-06-22 14:58:36 -0400126 if (mConversation != null) {
Adrien Béraud64538722018-03-15 17:34:00 -0400127 mConversation.setVisible(false);
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400128 }
129 }
130
131 public void resume() {
Adrien Béraudace37a22018-06-22 14:58:36 -0400132 Log.w(TAG, "resume " + mConversation + " " + mAccountId + " " + mContactRingId);
Adrien Béraud7aa7a9e2018-06-29 19:50:32 -0400133 mVisibilityDisposable.clear();
Adrien Béraude5ec8952018-07-11 15:14:44 -0400134 mVisibilityDisposable.add(mConversationSubject
135 .firstOrError()
136 .subscribe(conversation -> {
137 conversation.setVisible(true);
Rayan Osseiranecc4b682019-07-02 13:36:49 -0400138 updateOngoingCallView();
Adrien Béraude5ec8952018-07-11 15:14:44 -0400139 mConversationFacade.readMessages(mAccountService.getAccount(mAccountId), conversation);
Rayan Osseiran6f415662019-10-25 14:23:25 -0400140 }, e -> Log.e(TAG, "Error loading conversation", e)));
Adrien Béraudace37a22018-06-22 14:58:36 -0400141 }
142
Rayan Osseiran6f415662019-10-25 14:23:25 -0400143 private CallContact initContact(final Account account, final Uri uri,
144 final ConversationView view) {
Adrien Béraudace37a22018-06-22 14:58:36 -0400145 CallContact contact;
146 if (account.isRing()) {
147 String rawId = uri.getRawRingId();
148 contact = account.getContact(rawId);
149 if (contact == null) {
150 contact = account.getContactFromCache(uri);
Adrien Béraudbf81ead2019-06-29 00:16:43 -0400151 TrustRequest req = account.getRequest(uri);
Adrien Béraudace37a22018-06-22 14:58:36 -0400152 if (req == null) {
Adrien Béraude5ec8952018-07-11 15:14:44 -0400153 view.switchToUnknownView(contact.getRingUsername());
Adrien Béraudace37a22018-06-22 14:58:36 -0400154 } else {
Adrien Béraude5ec8952018-07-11 15:14:44 -0400155 view.switchToIncomingTrustRequestView(req.getDisplayname());
Adrien Béraudace37a22018-06-22 14:58:36 -0400156 }
157 } else {
Adrien Béraude5ec8952018-07-11 15:14:44 -0400158 view.switchToConversationView();
Adrien Béraudace37a22018-06-22 14:58:36 -0400159 }
160 Log.w(TAG, "initContact " + contact.getUsername());
161 if (contact.getUsername() == null) {
162 mAccountService.lookupAddress(mAccountId, "", rawId);
163 }
Pierre Duchemin1fa61922018-01-18 10:09:02 -0500164 } else {
Adrien Béraudace37a22018-06-22 14:58:36 -0400165 contact = mContactService.findContact(account, uri);
Adrien Béraude5ec8952018-07-11 15:14:44 -0400166 view.switchToConversationView();
Pierre Duchemin1fa61922018-01-18 10:09:02 -0500167 }
Adrien Béraud78ae7b92018-08-25 19:04:17 -0400168 view.displayContact(contact);
Adrien Béraudace37a22018-06-22 14:58:36 -0400169 return contact;
170 }
171
172 private void initView(final Conversation c, final ConversationView view) {
173 Log.w(TAG, "initView");
174 if (mConversationDisposable == null) {
175 mConversationDisposable = new CompositeDisposable();
176 mCompositeDisposable.add(mConversationDisposable);
177 }
178 mConversationDisposable.clear();
179 view.hideNumberSpinner();
180
181 Account account = mAccountService.getAccount(mAccountId);
Adrien Béraudace37a22018-06-22 14:58:36 -0400182
Rayan Osseiran6f415662019-10-25 14:23:25 -0400183
Adrien Béraudace37a22018-06-22 14:58:36 -0400184 mConversationDisposable.add(c.getSortedHistory()
Adrien Béraudf2c76ed2019-05-25 03:36:48 -0400185 .subscribe(view::refreshView, e -> Log.e(TAG, "Can't update element", e)));
Adrien Bérauda084cd12018-12-31 12:49:12 -0500186 mConversationDisposable.add(c.getCleared()
Adrien Béraud08eb45e2019-02-18 01:58:12 -0500187 .observeOn(mUiScheduler)
Rayan Osseiran6f415662019-10-25 14:23:25 -0400188 .subscribe(view::refreshView, e -> Log.e(TAG, "Can't update elements", e)));
Adrien Béraud9ec82442019-02-18 01:55:16 -0500189 mConversationDisposable.add(mContactService.getLoadedContact(c.getAccountId(), c.getContact())
Adrien Béraudace37a22018-06-22 14:58:36 -0400190 .observeOn(mUiScheduler)
Rayan Osseiran6f415662019-10-25 14:23:25 -0400191 .subscribe(contact -> initContact(account, mContactRingId, view), e -> Log.e(TAG, "Can't get contact", e)));
Adrien Béraudace37a22018-06-22 14:58:36 -0400192 mConversationDisposable.add(c.getUpdatedElements()
193 .observeOn(mUiScheduler)
Rayan Osseiran6f415662019-10-25 14:23:25 -0400194 .subscribe(elementTuple -> {
195 switch(elementTuple.second) {
196 case ADD:
197 view.addElement(elementTuple.first);
198 break;
199 case UPDATE:
200 view.updateElement(elementTuple.first);
201 break;
202 case REMOVE:
203 view.removeElement(elementTuple.first);
204 break;
205 }
206 }, e -> Log.e(TAG, "Can't update element", e)));
Adrien Béraudace37a22018-06-22 14:58:36 -0400207 mConversationDisposable.add(c.getCalls()
208 .observeOn(mUiScheduler)
Rayan Osseiran6f415662019-10-25 14:23:25 -0400209 .subscribe(calls -> updateOngoingCallView(), e -> Log.e(TAG, "Can't update call view", e)));
Adrien Béraud0f3ee3d2018-12-08 22:03:54 -0500210 mConversationDisposable.add(c.getColor()
211 .observeOn(mUiScheduler)
Rayan Osseiran6f415662019-10-25 14:23:25 -0400212 .subscribe(view::setConversationColor, e -> Log.e(TAG, "Can't update conversation color", e)));
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400213 }
214
Adrien Béraud0f3ee3d2018-12-08 22:03:54 -0500215 public void openContact() {
Adrien Béraud91f88742019-09-09 00:46:46 -0400216 if (mConversation != null)
217 getView().goToContactActivity(mAccountId, mConversation.getContact().getPrimaryNumber());
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400218 }
219
Hadrien De Sousa0dc83162017-11-10 16:15:18 -0500220 public void sendTextMessage(String message) {
Adrien Béraud91f88742019-09-09 00:46:46 -0400221 if (StringUtils.isEmpty(message) || mConversation == null) {
Adrien Béraudace37a22018-06-22 14:58:36 -0400222 return;
223 }
224 Conference conference = mConversation.getCurrentCall();
225 if (conference == null || !conference.isOnGoing()) {
Adrien Bérauda9220662018-07-27 15:59:47 -0400226 mConversationFacade.sendTextMessage(mAccountId, mConversation, mContactRingId, message).subscribe();
Adrien Béraudace37a22018-06-22 14:58:36 -0400227 } else {
228 mConversationFacade.sendTextMessage(mConversation, conference, message);
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400229 }
230 }
231
Pierre Duchemine0c3a492018-02-01 16:22:45 -0500232 public void selectFile() {
233 getView().openFilePicker();
234 }
235
Adrien Béraud64538722018-03-15 17:34:00 -0400236 public void sendFile(File file) {
Adrien Béraudbb3fe862019-02-12 20:44:29 -0500237 mConversationFacade.sendFile(mAccountId, mContactRingId, file).subscribe();
Pierre Duchemine0c3a492018-02-01 16:22:45 -0500238 }
239
amine younes7c56f312019-06-10 11:34:25 -0400240 /**
241 * Gets the absolute path of the file dataTransfer and sends both the DataTransfer and the
242 * found path to the ConversationView in order to start saving the file
Rayan Osseiran6f415662019-10-25 14:23:25 -0400243 *
244 * @param interaction an interaction representing a datat transfer
amine younes7c56f312019-06-10 11:34:25 -0400245 */
Rayan Osseiran6f415662019-10-25 14:23:25 -0400246 public void saveFile(Interaction interaction) {
247 DataTransfer transfer = (DataTransfer) interaction;
248 String fileAbsolutePath = getDeviceRuntimeService().
amine younes7c56f312019-06-10 11:34:25 -0400249 getConversationPath(transfer.getPeerId(), transfer.getStoragePath())
Rayan Osseiran6f415662019-10-25 14:23:25 -0400250 .getAbsolutePath();
251 getView().startSaveFile(transfer, fileAbsolutePath);
Adrien Béraud7c505112018-03-20 16:03:28 -0400252 }
253
Rayan Osseiran6f415662019-10-25 14:23:25 -0400254 public void shareFile(Interaction interaction) {
255 DataTransfer file = (DataTransfer) interaction;
Adrien Béraudfcf457f2018-04-03 17:46:34 -0400256 File path = getDeviceRuntimeService().getConversationPath(file.getPeerId(), file.getStoragePath());
257 getView().shareFile(path);
258 }
259
Rayan Osseiran6f415662019-10-25 14:23:25 -0400260 public void openFile(Interaction interaction) {
261 DataTransfer file = (DataTransfer) interaction;
Adrien Béraudb2b3f442018-12-01 17:42:38 -0500262 File path = getDeviceRuntimeService().getConversationPath(file.getPeerId(), file.getStoragePath());
263 getView().openFile(path);
264 }
265
Rayan Osseiran6f415662019-10-25 14:23:25 -0400266 public void deleteConversationItem(Interaction element) {
Rayan Osseirane634a562019-05-29 13:44:55 -0400267 mConversationFacade.deleteConversationItem(element);
268 }
269
Rayan Osseiran6f415662019-10-25 14:23:25 -0400270 public void cancelMessage(Interaction message) {
Rayan Osseirane634a562019-05-29 13:44:55 -0400271 mConversationFacade.cancelMessage(message);
Adrien Béraud7c505112018-03-20 16:03:28 -0400272 }
273
Hadrien De Sousa6cd2bd22018-01-02 16:11:32 -0500274 public void sendTrustRequest() {
Adrien Béraud0acf5a12018-08-02 13:40:40 -0400275 final String accountId = mAccountId;
276 final Uri contactId = mContactRingId;
Adrien Béraudbdfb5e12019-02-18 15:46:44 -0500277 mVCardService.loadSmallVCard(accountId, VCardService.MAX_SIZE_REQUEST)
278 .subscribeOn(Schedulers.computation())
279 .subscribe(vCard -> {
280 mAccountService.sendTrustRequest(accountId, contactId.getRawRingId(), Blob.fromString(VCardUtils.vcardToString(vCard)));
281 CallContact contact = mContactService.findContact(mAccountService.getAccount(accountId), contactId);
282 if (contact == null) {
283 Log.e(TAG, "sendTrustRequest: not able to find contact");
284 return;
285 }
286 contact.setStatus(CallContact.Status.REQUEST_SENT);
287 });
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400288 }
289
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400290 public void clickOnGoingPane() {
Adrien Beraud4f644382017-07-21 17:01:51 -0400291 Conference conf = mConversation.getCurrentCall();
292 if (conf != null) {
293 getView().goToCallActivity(conf.getId());
294 } else {
Hadrien De Sousa0dc83162017-11-10 16:15:18 -0500295 getView().displayOnGoingCallPane(false);
Adrien Beraud4f644382017-07-21 17:01:51 -0400296 }
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400297 }
298
Hadrien De Sousa203164c2017-12-05 17:41:42 -0500299 public void callWithAudioOnly(boolean audioOnly) {
Adrien Béraudd3bf4e42018-02-14 14:44:41 +0100300 if (audioOnly && !mHardwareService.hasMicrophone()) {
Hadrien De Sousa45fb21b2017-12-14 11:06:48 -0500301 getView().displayErrorToast(RingError.NO_MICROPHONE);
302 return;
303 }
304
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400305 Conference conf = mConversation.getCurrentCall();
Rayan Osseiraned9feeb2019-07-05 16:04:30 -0400306 if (conf != null
307 && !conf.getParticipants().isEmpty()
Rayan Osseiran6f415662019-10-25 14:23:25 -0400308 && conf.getParticipants().get(0).getCallStatus() != SipCall.CallStatus.INACTIVE
309 && conf.getParticipants().get(0).getCallStatus() != SipCall.CallStatus.FAILURE) {
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400310 getView().goToCallActivity(conf.getId());
311 } else {
Pierre Duchemin1fa61922018-01-18 10:09:02 -0500312 getView().goToCallActivityWithResult(mAccountId, mContactRingId.getRawUriString(), audioOnly);
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400313 }
314 }
315
Adrien Béraudace37a22018-06-22 14:58:36 -0400316 private void updateOngoingCallView() {
Adrien Béraud20d42212018-03-02 14:40:38 -0500317 Conference conf = mConversation.getCurrentCall();
Rayan Osseiran6f415662019-10-25 14:23:25 -0400318 if (conf != null && (conf.getState() == SipCall.CallStatus.CURRENT || conf.getState() == SipCall.CallStatus.HOLD || conf.getState() == SipCall.CallStatus.RINGING)) {
Adrien Béraud20d42212018-03-02 14:40:38 -0500319 getView().displayOnGoingCallPane(true);
320 } else {
321 getView().displayOnGoingCallPane(false);
322 }
Hadrien De Sousaec95e5e2017-03-21 15:28:23 -0400323 }
324
Pierre Duchemin1fa61922018-01-18 10:09:02 -0500325 public void onBlockIncomingContactRequest() {
326 String accountId = mAccountId == null ? mAccountService.getCurrentAccount().getAccountID() : mAccountId;
Adrien Béraudace37a22018-06-22 14:58:36 -0400327 mConversationFacade.discardRequest(accountId, mContactRingId);
Pierre Duchemin1fa61922018-01-18 10:09:02 -0500328 mAccountService.removeContact(accountId, mContactRingId.getHost(), true);
Pierre Duchemin1fa61922018-01-18 10:09:02 -0500329
330 getView().goToHome();
331 }
332
333 public void onRefuseIncomingContactRequest() {
334 String accountId = mAccountId == null ? mAccountService.getCurrentAccount().getAccountID() : mAccountId;
Pierre Duchemin1fa61922018-01-18 10:09:02 -0500335
Adrien Béraudace37a22018-06-22 14:58:36 -0400336 mConversationFacade.discardRequest(accountId, mContactRingId);
Pierre Duchemin1fa61922018-01-18 10:09:02 -0500337 getView().goToHome();
338 }
339
340 public void onAcceptIncomingContactRequest() {
Adrien Béraudace37a22018-06-22 14:58:36 -0400341 mConversationFacade.acceptRequest(mAccountId, mContactRingId);
342 getView().switchToConversationView();
343 }
Pierre Duchemin1fa61922018-01-18 10:09:02 -0500344
Adrien Béraudace37a22018-06-22 14:58:36 -0400345 public void onAddContact() {
346 sendTrustRequest();
Pierre Duchemin1fa61922018-01-18 10:09:02 -0500347 getView().switchToConversationView();
348 }
349
Pierre Duchemin4af6b392018-02-02 11:23:56 -0500350 public DeviceRuntimeService getDeviceRuntimeService() {
351 return mDeviceRuntimeService;
352 }
Pierre Duchemindf6cb5a2018-02-09 18:05:21 -0500353
354 public void noSpaceLeft() {
355 Log.e(TAG, "configureForFileInfoTextMessage: no space left on device");
356 getView().displayErrorToast(RingError.NO_SPACE_LEFT);
357 }
Adrien Béraud0f3ee3d2018-12-08 22:03:54 -0500358
359 public void setConversationColor(int color) {
360 mCompositeDisposable.add(mConversationSubject
361 .firstElement()
362 .subscribe(conversation -> conversation.setColor(color)));
363 }
Rayan Osseiran38206c62019-05-15 14:49:03 -0400364
365 public void cameraPermissionChanged(boolean isGranted) {
366 if (isGranted && mHardwareService.isVideoAvailable()) {
Adrien Béraud99931dd2019-08-27 16:52:01 -0400367 mHardwareService.initVideo().subscribe();
Rayan Osseiran38206c62019-05-15 14:49:03 -0400368 }
369 }
370
Adrien Béraude32ab742018-08-25 21:15:08 -0400371}