mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 20:19:42 +01:00
parent
649df4ef07
commit
3f58e260c0
@ -30,6 +30,9 @@ import android.view.ViewGroup;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.work.Data;
|
||||||
|
import androidx.work.OneTimeWorkRequest;
|
||||||
|
import androidx.work.WorkManager;
|
||||||
import autodagger.AutoInjector;
|
import autodagger.AutoInjector;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import com.bluelinelabs.conductor.RouterTransaction;
|
import com.bluelinelabs.conductor.RouterTransaction;
|
||||||
@ -41,6 +44,8 @@ import com.nextcloud.talk.adapters.items.MenuItem;
|
|||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
import com.nextcloud.talk.controllers.base.BaseController;
|
import com.nextcloud.talk.controllers.base.BaseController;
|
||||||
import com.nextcloud.talk.events.BottomSheetLockEvent;
|
import com.nextcloud.talk.events.BottomSheetLockEvent;
|
||||||
|
import com.nextcloud.talk.jobs.DeleteConversationWorker;
|
||||||
|
import com.nextcloud.talk.jobs.LeaveConversationWorker;
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
import com.nextcloud.talk.models.database.UserEntity;
|
||||||
import com.nextcloud.talk.models.json.rooms.Conversation;
|
import com.nextcloud.talk.models.json.rooms.Conversation;
|
||||||
import com.nextcloud.talk.utils.DisplayUtils;
|
import com.nextcloud.talk.utils.DisplayUtils;
|
||||||
@ -75,6 +80,8 @@ public class CallMenuController extends BaseController implements FlexibleAdapte
|
|||||||
private MenuType menuType;
|
private MenuType menuType;
|
||||||
private Intent shareIntent;
|
private Intent shareIntent;
|
||||||
|
|
||||||
|
private UserEntity currentUser;
|
||||||
|
|
||||||
public CallMenuController(Bundle args) {
|
public CallMenuController(Bundle args) {
|
||||||
super(args);
|
super(args);
|
||||||
this.conversation = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_ROOM));
|
this.conversation = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_ROOM));
|
||||||
@ -128,7 +135,7 @@ public class CallMenuController extends BaseController implements FlexibleAdapte
|
|||||||
menuItems.add(new MenuItem(getResources().getString(R.string.nc_configure_room), 0, null));
|
menuItems.add(new MenuItem(getResources().getString(R.string.nc_configure_room), 0, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
UserEntity currentUser = userUtils.getCurrentUser();
|
currentUser = userUtils.getCurrentUser();
|
||||||
|
|
||||||
if (conversation.isFavorite()) {
|
if (conversation.isFavorite()) {
|
||||||
menuItems.add(new MenuItem(getResources().getString(R.string.nc_remove_from_favorites), 97, DisplayUtils.getTintedDrawable(getResources(), R.drawable.ic_star_border_black_24dp, R.color.grey_600)));
|
menuItems.add(new MenuItem(getResources().getString(R.string.nc_remove_from_favorites), 97, DisplayUtils.getTintedDrawable(getResources(), R.drawable.ic_star_border_black_24dp, R.color.grey_600)));
|
||||||
@ -209,21 +216,37 @@ public class CallMenuController extends BaseController implements FlexibleAdapte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tag > 0) {
|
if (tag > 0) {
|
||||||
bundle.putInt(BundleKeys.KEY_OPERATION_CODE, tag);
|
if (tag == 1 || tag == 9) {
|
||||||
if (tag != 2 && tag != 4 && tag != 6 && tag != 7) {
|
Data data;
|
||||||
eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
|
if ((data = getWorkerData()) != null) {
|
||||||
getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle))
|
if (tag == 1) {
|
||||||
.pushChangeHandler(new HorizontalChangeHandler())
|
OneTimeWorkRequest leaveConversationWorker =
|
||||||
.popChangeHandler(new HorizontalChangeHandler()));
|
new OneTimeWorkRequest.Builder(LeaveConversationWorker.class).setInputData(data).build();
|
||||||
} else if (tag != 7) {
|
WorkManager.getInstance().enqueue(leaveConversationWorker);
|
||||||
getRouter().pushController(RouterTransaction.with(new EntryMenuController(bundle))
|
} else {
|
||||||
.pushChangeHandler(new HorizontalChangeHandler())
|
OneTimeWorkRequest deleteConversationWorker =
|
||||||
.popChangeHandler(new HorizontalChangeHandler()));
|
new OneTimeWorkRequest.Builder(DeleteConversationWorker.class).setInputData(data).build();
|
||||||
|
WorkManager.getInstance().enqueue(deleteConversationWorker);
|
||||||
|
}
|
||||||
|
eventBus.post(new BottomSheetLockEvent(true, 0, false, true));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
bundle.putParcelable(BundleKeys.KEY_MENU_TYPE, Parcels.wrap(MenuType.SHARE));
|
bundle.putInt(BundleKeys.KEY_OPERATION_CODE, tag);
|
||||||
getRouter().pushController(RouterTransaction.with(new CallMenuController(bundle))
|
if (tag != 2 && tag != 4 && tag != 6 && tag != 7) {
|
||||||
.pushChangeHandler(new HorizontalChangeHandler())
|
eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
|
||||||
.popChangeHandler(new HorizontalChangeHandler()));
|
getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle))
|
||||||
|
.pushChangeHandler(new HorizontalChangeHandler())
|
||||||
|
.popChangeHandler(new HorizontalChangeHandler()));
|
||||||
|
} else if (tag != 7) {
|
||||||
|
getRouter().pushController(RouterTransaction.with(new EntryMenuController(bundle))
|
||||||
|
.pushChangeHandler(new HorizontalChangeHandler())
|
||||||
|
.popChangeHandler(new HorizontalChangeHandler()));
|
||||||
|
} else {
|
||||||
|
bundle.putParcelable(BundleKeys.KEY_MENU_TYPE, Parcels.wrap(MenuType.SHARE));
|
||||||
|
getRouter().pushController(RouterTransaction.with(new CallMenuController(bundle))
|
||||||
|
.pushChangeHandler(new HorizontalChangeHandler())
|
||||||
|
.popChangeHandler(new HorizontalChangeHandler()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,4 +280,16 @@ public class CallMenuController extends BaseController implements FlexibleAdapte
|
|||||||
public enum MenuType {
|
public enum MenuType {
|
||||||
REGULAR, SHARE
|
REGULAR, SHARE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Data getWorkerData() {
|
||||||
|
if (!TextUtils.isEmpty(conversation.getToken())) {
|
||||||
|
Data.Builder data = new Data.Builder();
|
||||||
|
data.putString(BundleKeys.KEY_ROOM_TOKEN, conversation.getToken());
|
||||||
|
data.putLong(BundleKeys.KEY_INTERNAL_USER_ID, currentUser.getId());
|
||||||
|
return data.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -184,13 +184,6 @@ public class OperationsMenuController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (operationCode) {
|
switch (operationCode) {
|
||||||
case 1:
|
|
||||||
ncApi.removeSelfFromRoom(credentials, ApiUtils.getUrlForRemoveSelfFromRoom(currentUser.getBaseUrl(), conversation.getToken()))
|
|
||||||
.subscribeOn(Schedulers.newThread())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.retry(1)
|
|
||||||
.subscribe(operationsObserver);
|
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
ncApi.renameRoom(credentials, ApiUtils.getRoom(currentUser.getBaseUrl(), conversation.getToken()),
|
ncApi.renameRoom(credentials, ApiUtils.getRoom(currentUser.getBaseUrl(), conversation.getToken()),
|
||||||
conversation.getName())
|
conversation.getName())
|
||||||
@ -232,14 +225,6 @@ public class OperationsMenuController extends BaseController {
|
|||||||
.retry(1)
|
.retry(1)
|
||||||
.subscribe(operationsObserver);
|
.subscribe(operationsObserver);
|
||||||
break;
|
break;
|
||||||
case 9:
|
|
||||||
ncApi.deleteRoom(credentials, ApiUtils.getRoom(currentUser.getBaseUrl(),
|
|
||||||
conversation.getToken()))
|
|
||||||
.subscribeOn(Schedulers.newThread())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.retry(1)
|
|
||||||
.subscribe(operationsObserver);
|
|
||||||
break;
|
|
||||||
case 10:
|
case 10:
|
||||||
ncApi.getRoom(credentials, ApiUtils.getRoom(baseUrl, conversationToken))
|
ncApi.getRoom(credentials, ApiUtils.getRoom(baseUrl, conversationToken))
|
||||||
.subscribeOn(Schedulers.newThread())
|
.subscribeOn(Schedulers.newThread())
|
||||||
|
Loading…
Reference in New Issue
Block a user