Search in sources :

Example 1 with BottomSheetLockEvent

use of com.nextcloud.talk.events.BottomSheetLockEvent in project talk-android by nextcloud.

the class CallMenuController method onItemClick.

@Override
public boolean onItemClick(View view, int position) {
    Bundle bundle = new Bundle();
    bundle.putParcelable(BundleKeys.KEY_ROOM, Parcels.wrap(room));
    if (menuType.equals(MenuType.REGULAR)) {
        MenuItem menuItem = (MenuItem) adapter.getItem(position);
        if (menuItem != null) {
            int tag = menuItem.getTag();
            if (tag == 5) {
                room.setPassword("");
            }
            if (tag > 0 && tag < 10) {
                bundle.putInt(BundleKeys.KEY_OPERATION_CODE, tag);
                if (tag != 2 && tag != 4 && tag != 6 && tag != 7) {
                    eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
                    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()));
                }
            }
        }
    } else if (menuType.equals(MenuType.SHARE) && position != 0) {
        AppItem appItem = (AppItem) adapter.getItem(position);
        if (appItem != null && getActivity() != null) {
            if (!room.hasPassword) {
                shareIntent.putExtra(Intent.EXTRA_TEXT, ShareUtils.getStringForIntent(getActivity(), null, userUtils, room));
                Intent intent = new Intent(shareIntent);
                intent.setComponent(new ComponentName(appItem.getPackageName(), appItem.getName()));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                eventBus.post(new BottomSheetLockEvent(true, 0, false, true));
                getActivity().startActivity(intent);
            } else {
                bundle.putInt(BundleKeys.KEY_OPERATION_CODE, 7);
                bundle.putParcelable(BundleKeys.KEY_SHARE_INTENT, Parcels.wrap(shareIntent));
                bundle.putString(BundleKeys.KEY_APP_ITEM_PACKAGE_NAME, appItem.getPackageName());
                bundle.putString(BundleKeys.KEY_APP_ITEM_NAME, appItem.getName());
                getRouter().pushController(RouterTransaction.with(new EntryMenuController(bundle)).pushChangeHandler(new HorizontalChangeHandler()).popChangeHandler(new HorizontalChangeHandler()));
            }
        }
    } else if (menuType.equals(MenuType.NEW_CONVERSATION) && position != 0) {
        MenuItem menuItem = (MenuItem) adapter.getItem(position);
        if (menuItem != null) {
            if (menuItem.getTag() == 1) {
                eventBus.post(new BottomSheetLockEvent(true, 0, false, true));
                bundle = new Bundle();
                bundle.putBoolean(BundleKeys.KEY_NEW_CONVERSATION, true);
                getParentController().getParentController().getRouter().pushController((RouterTransaction.with(new ContactsController(bundle)).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler())));
            } else {
                bundle = new Bundle();
                bundle.putInt(BundleKeys.KEY_OPERATION_CODE, 10);
                getRouter().pushController(RouterTransaction.with(new EntryMenuController(bundle)).pushChangeHandler(new HorizontalChangeHandler()).popChangeHandler(new HorizontalChangeHandler()));
            }
        }
    }
    return true;
}
Also used : ContactsController(com.nextcloud.talk.controllers.ContactsController) Bundle(android.os.Bundle) MenuItem(com.nextcloud.talk.adapters.items.MenuItem) Intent(android.content.Intent) VerticalChangeHandler(com.bluelinelabs.conductor.changehandler.VerticalChangeHandler) HorizontalChangeHandler(com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler) BottomSheetLockEvent(com.nextcloud.talk.events.BottomSheetLockEvent) AppItem(com.nextcloud.talk.adapters.items.AppItem) ComponentName(android.content.ComponentName)

Example 2 with BottomSheetLockEvent

use of com.nextcloud.talk.events.BottomSheetLockEvent in project talk-android by nextcloud.

the class EntryMenuController method onProceedButtonClick.

@OnClick(R.id.ok_button)
public void onProceedButtonClick() {
    Bundle bundle;
    if (operationCode == 99) {
        eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
        bundle = new Bundle();
        bundle.putParcelable(BundleKeys.KEY_ROOM, Parcels.wrap(room));
        bundle.putString(BundleKeys.KEY_CALL_URL, callUrl);
        bundle.putString(BundleKeys.KEY_CALL_PASSWORD, editText.getText().toString());
        bundle.putInt(BundleKeys.KEY_OPERATION_CODE, operationCode);
        getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle)).pushChangeHandler(new HorizontalChangeHandler()).popChangeHandler(new HorizontalChangeHandler()));
    } else if (operationCode != 7 && operationCode != 10 && operationCode != 11) {
        eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
        bundle = new Bundle();
        if (operationCode == 4 || operationCode == 6) {
            room.setPassword(editText.getText().toString());
        } else {
            room.setName(editText.getText().toString());
        }
        bundle.putParcelable(BundleKeys.KEY_ROOM, Parcels.wrap(room));
        bundle.putInt(BundleKeys.KEY_OPERATION_CODE, operationCode);
        getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle)).pushChangeHandler(new HorizontalChangeHandler()).popChangeHandler(new HorizontalChangeHandler()));
    } else if (operationCode == 7) {
        if (getActivity() != null) {
            shareIntent.putExtra(Intent.EXTRA_TEXT, ShareUtils.getStringForIntent(getActivity(), editText.getText().toString(), userUtils, room));
            Intent intent = new Intent(shareIntent);
            intent.setComponent(new ComponentName(packageName, name));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            getActivity().startActivity(intent);
            eventBus.post(new BottomSheetLockEvent(true, 0, false, true));
        }
    } else if (operationCode != 11) {
        eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
        bundle = new Bundle();
        bundle.putInt(BundleKeys.KEY_OPERATION_CODE, operationCode);
        bundle.putString(BundleKeys.KEY_CALL_URL, editText.getText().toString());
        getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle)).pushChangeHandler(new HorizontalChangeHandler()).popChangeHandler(new HorizontalChangeHandler()));
    } else if (operationCode == 11) {
        eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
        originalBundle.putString(BundleKeys.KEY_CONVERSATION_NAME, editText.getText().toString());
        getRouter().pushController(RouterTransaction.with(new OperationsMenuController(originalBundle)).pushChangeHandler(new HorizontalChangeHandler()).popChangeHandler(new HorizontalChangeHandler()));
    }
}
Also used : BottomSheetLockEvent(com.nextcloud.talk.events.BottomSheetLockEvent) Bundle(android.os.Bundle) Intent(android.content.Intent) ComponentName(android.content.ComponentName) HorizontalChangeHandler(com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler) OnClick(butterknife.OnClick)

Example 3 with BottomSheetLockEvent

use of com.nextcloud.talk.events.BottomSheetLockEvent in project talk-android by nextcloud.

the class OperationsMenuController method showResultImage.

private void showResultImage(boolean everythingOK, boolean isGuestSupportError) {
    progressBar.setVisibility(View.GONE);
    if (everythingOK) {
        resultImageView.setImageDrawable(DisplayUtils.getTintedDrawable(getResources(), R.drawable.ic_check_circle_black_24dp, R.color.nc_darkGreen));
    } else {
        resultImageView.setImageDrawable(DisplayUtils.getTintedDrawable(getResources(), R.drawable.ic_cancel_black_24dp, R.color.nc_darkRed));
    }
    resultImageView.setVisibility(View.VISIBLE);
    if (everythingOK) {
        resultsTextView.setText(R.string.nc_all_ok_operation);
    } else {
        resultsTextView.setTextColor(getResources().getColor(R.color.nc_darkRed));
        if (!isGuestSupportError) {
            resultsTextView.setText(R.string.nc_failed_to_perform_operation);
        } else {
            resultsTextView.setText(R.string.nc_failed_signaling_settings);
            webButton.setOnClickListener(v -> {
                eventBus.post(new BottomSheetLockEvent(true, 0, false, true));
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(callUrl));
                startActivity(browserIntent);
                new BottomSheetLockEvent(true, 0, false, true);
            });
            webButton.setVisibility(View.VISIBLE);
        }
    }
    resultsTextView.setVisibility(View.VISIBLE);
    if (everythingOK) {
        eventBus.post(new BottomSheetLockEvent(true, 2500, true, true));
    } else {
        resultImageView.setImageDrawable(DisplayUtils.getTintedDrawable(getResources(), R.drawable.ic_cancel_black_24dp, R.color.nc_darkRed));
        okButton.setOnClickListener(v -> eventBus.post(new BottomSheetLockEvent(true, 0, operationCode != 99 && operationCode != 10, true)));
        okButton.setVisibility(View.VISIBLE);
    }
}
Also used : BottomSheetLockEvent(com.nextcloud.talk.events.BottomSheetLockEvent) Intent(android.content.Intent)

Example 4 with BottomSheetLockEvent

use of com.nextcloud.talk.events.BottomSheetLockEvent in project talk-android by nextcloud.

the class OperationsMenuController method initiateCall.

private void initiateCall() {
    eventBus.post(new BottomSheetLockEvent(true, 0, true, true));
    Bundle bundle = new Bundle();
    bundle.putString(BundleKeys.KEY_ROOM_TOKEN, room.getToken());
    bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(userEntity));
    if (baseUrl != null && !baseUrl.equals(userEntity.getBaseUrl())) {
        bundle.putString(BundleKeys.KEY_MODIFIED_BASE_URL, baseUrl);
    }
    bundle.putString(BundleKeys.KEY_CALL_SESSION, callSession);
    Intent callIntent = new Intent(getActivity(), CallActivity.class);
    callIntent.putExtras(bundle);
    if (getActivity() != null) {
        InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
        }
    }
    startActivity(callIntent);
}
Also used : BottomSheetLockEvent(com.nextcloud.talk.events.BottomSheetLockEvent) Bundle(android.os.Bundle) Intent(android.content.Intent) InputMethodManager(android.view.inputmethod.InputMethodManager)

Aggregations

Intent (android.content.Intent)4 BottomSheetLockEvent (com.nextcloud.talk.events.BottomSheetLockEvent)4 Bundle (android.os.Bundle)3 ComponentName (android.content.ComponentName)2 HorizontalChangeHandler (com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler)2 InputMethodManager (android.view.inputmethod.InputMethodManager)1 OnClick (butterknife.OnClick)1 VerticalChangeHandler (com.bluelinelabs.conductor.changehandler.VerticalChangeHandler)1 AppItem (com.nextcloud.talk.adapters.items.AppItem)1 MenuItem (com.nextcloud.talk.adapters.items.MenuItem)1 ContactsController (com.nextcloud.talk.controllers.ContactsController)1