use of net.iGap.activities.ActivityMain in project iGap-Android by KianIranian-STDG.
the class GoToChatActivity method startActivity.
public void startActivity(FragmentActivity activity) {
String roomName = "";
if (FragmentChat.mForwardMessages != null || HelperGetDataFromOtherApp.hasSharedData || FragmentChat.structIGSticker != null) {
roomName = DbManager.getInstance().doRealmTask(realm -> {
RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", roomid).findFirst();
if (realmRoom != null) {
if (realmRoom.getReadOnly() || hasSendMessagePermission() || (realmRoom.getType() != ProtoGlobal.Room.Type.CHAT && FragmentChat.structIGSticker != null) || (realmRoom.getType() == ProtoGlobal.Room.Type.CHAT && realmRoom.getChatRoom() != null && RealmRoom.isBot(realmRoom.getChatRoom().getPeerId()))) {
if (activity != null && !(activity).isFinishing()) {
new MaterialDialog.Builder(activity).title(R.string.dialog_readonly_chat).positiveText(R.string.ok).show();
}
return null;
}
return realmRoom.getTitle();
} else if (peerID > 0) {
RealmRegisteredInfo _RegisteredInfo = RealmRegisteredInfo.getRegistrationInfo(realm, peerID);
if (_RegisteredInfo != null) {
return _RegisteredInfo.getDisplayName();
}
}
return "";
});
if (roomName == null) {
return;
}
}
if (HelperGetDataFromOtherApp.hasSharedData) {
String message = G.context.getString(R.string.send_message_to) + " " + roomName;
MaterialDialog.Builder mDialog = new MaterialDialog.Builder(activity).title(message).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
FragmentChat fragmentChat = new FragmentChat();
fragmentChat.setArguments(getBundle());
fragmentChatBackStack(activity);
new HelperFragment(activity.getSupportFragmentManager(), fragmentChat).setReplace(false).load();
}
}).onNegative((dialog, which) -> {
HelperGetDataFromOtherApp.hasSharedData = false;
// revert main rooms list from share mode
if (activity instanceof ActivityMain) {
((ActivityMain) activity).checkHasSharedData(false);
}
}).neutralText(R.string.another_room).onNeutral((dialog, which) -> dialog.dismiss());
if (!activity.isFinishing()) {
mDialog.show();
}
} else if (FragmentChat.structIGSticker != null) {
String message = G.context.getString(R.string.send_message_to) + " " + roomName;
MaterialDialog.Builder mDialog = new MaterialDialog.Builder(activity).title(message).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive((dialog, which) -> {
FragmentChat fragmentChat = new FragmentChat();
fragmentChat.setArguments(getBundle());
fragmentChatBackStack(activity);
new HelperFragment(activity.getSupportFragmentManager(), fragmentChat).setReplace(false).load();
}).onNegative((dialog, which) -> {
FragmentChat.structIGSticker = null;
if (activity instanceof ActivityMain) {
((ActivityMain) activity).checkHasSharedData(false);
}
}).neutralText(R.string.another_room).onNeutral((dialog, which) -> dialog.dismiss());
if (!activity.isFinishing()) {
mDialog.show();
}
} else if (FragmentChat.mForwardMessages != null) {
String message = G.context.getString(R.string.send_forward_to) + " " + roomName + "?";
MaterialDialog.Builder mDialog = new MaterialDialog.Builder(activity).title(message).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
loadChatFragment(activity);
}
}).onNegative((dialog, which) -> {
disableForwardMessage(activity);
FragmentChat.mForwardMessages = null;
}).neutralText(R.string.another_room).onNeutral((dialog, which) -> dialog.dismiss());
if (!(activity).isFinishing()) {
mDialog.show();
}
} else {
loadChatFragment(activity);
}
}
use of net.iGap.activities.ActivityMain in project iGap-Android by KianIranian-STDG.
the class FragmentGroupProfile method onViewCreated.
@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
isNeedResume = true;
// because actionbar not in this view do that and not correct in viewModel
imvGroupAvatar = binding.toolbarAvatar;
imvGroupAvatar.setOnClickListener(v -> viewModel.onClickRippleGroupAvatar());
if (currentRoomAccess != null) {
checkRoomAccess(currentRoomAccess);
roomAccessChangeListener = (realmRoomAccess, changeSet) -> checkRoomAccess(realmRoomAccess);
currentRoomAccess.addChangeListener(roomAccessChangeListener);
}
binding.toolbarMore.setOnClickListener(v -> viewModel.onClickRippleMenu());
binding.toolbarBack.setOnClickListener(v -> popBackStackFragment());
binding.toolbarEdit.setOnClickListener(v -> {
if (getActivity() != null && currentRoomAccess != null && currentRoomAccess.isCanModifyRoom()) {
new HelperFragment(getActivity().getSupportFragmentManager(), EditGroupFragment.newInstance(viewModel.roomId)).setReplace(false).load();
}
});
viewModel.groupName.observe(getViewLifecycleOwner(), s -> {
binding.toolbarTxtNameCollapsed.setText(EmojiManager.getInstance().replaceEmoji(s, binding.toolbarTxtNameCollapsed.getPaint().getFontMetricsInt()));
binding.toolbarTxtNameExpanded.setText(EmojiManager.getInstance().replaceEmoji(s, binding.toolbarTxtNameExpanded.getPaint().getFontMetricsInt()));
});
viewModel.groupNumber.observe(getViewLifecycleOwner(), s -> binding.toolbarTxtStatusExpanded.setText(String.format("%s %s", s, getString(R.string.member))));
viewModel.showMoreMenu.observe(getViewLifecycleOwner(), isShow -> {
if (isShow != null) {
binding.toolbarMore.setVisibility(isShow ? View.VISIBLE : View.GONE);
}
});
viewModel.goToShearedMediaPage.observe(getViewLifecycleOwner(), model -> {
if (getActivity() != null && model != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentShearedMedia.newInstance(model)).setReplace(false).load();
}
});
viewModel.goToShowAvatarPage.observe(getViewLifecycleOwner(), roomId -> {
if (getActivity() != null && roomId != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentShowAvatars.newInstance(roomId, FragmentShowAvatars.From.group)).setReplace(false).load();
}
});
viewModel.showMenu.observe(getViewLifecycleOwner(), menuList -> {
if (getActivity() != null && menuList != null) {
new TopSheetDialog(getActivity()).setListDataWithResourceId(menuList, -1, position -> {
if (menuList.get(position) == R.string.clear_history) {
new MaterialDialog.Builder(getActivity()).title(R.string.clear_history).content(R.string.clear_history_content).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
getMessageController().clearHistoryMessage(viewModel.roomId);
}
}).negativeText(R.string.no).show();
} else if (menuList.get(position) == R.string.group_title_convert_to_public || menuList.get(position) == R.string.group_title_convert_to_private) {
viewModel.convertMenuClick();
}
}).show();
}
});
viewModel.goToShowMemberPage.observe(getViewLifecycleOwner(), type -> {
if (getActivity() != null && type != null) {
FragmentShowMember fragment = FragmentShowMember.newInstance2(this, viewModel.roomId, viewModel.role.toString(), AccountManager.getInstance().getCurrentUser().getId(), type, viewModel.isNeedgetContactlist, true);
new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
}
});
viewModel.showDialogConvertToPublic.observe(getViewLifecycleOwner(), isShow -> {
if (getActivity() != null && isShow != null && isShow) {
new MaterialDialog.Builder(getActivity()).title(getString(R.string.group_title_convert_to_public)).content(getString(R.string.group_text_convert_to_public)).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
setUsername();
}
}).negativeText(R.string.no).show();
}
});
viewModel.showDialogConvertToPrivate.observe(getViewLifecycleOwner(), isShow -> {
if (getActivity() != null && isShow != null && isShow) {
new MaterialDialog.Builder(getActivity()).title(R.string.group_title_convert_to_private).content(R.string.group_text_convert_to_private).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
viewModel.sendRequestRemoveGroupUsername();
}
}).negativeText(R.string.no).show();
}
});
viewModel.showRequestError.observe(getViewLifecycleOwner(), errorMessage -> {
if (errorMessage != null) {
HelperError.showSnackMessage(getString(errorMessage), false);
}
});
viewModel.goToShowCustomListPage.observe(getViewLifecycleOwner(), listItem -> {
if (getActivity() != null && listItem != null) {
ShowCustomList showCustomListFragment = new ShowCustomList();
showCustomListFragment.setFields(ProtoGlobal.Room.Type.GROUP, listItem, (result, message, countForShowLastMessage, list) -> {
for (int i = 0; i < list.size(); i++) {
new RequestGroupAddMember().groupAddMember(viewModel.roomId, list.get(i).peerId, RealmRoomMessage.findCustomMessageId(viewModel.roomId, countForShowLastMessage));
}
});
Bundle bundle = new Bundle();
bundle.putBoolean("DIALOG_SHOWING", true);
bundle.putLong("COUNT_MESSAGE", 0);
showCustomListFragment.setArguments(bundle);
new HelperFragment(getActivity().getSupportFragmentManager(), showCustomListFragment).setReplace(false).load();
}
});
viewModel.goBack.observe(getViewLifecycleOwner(), isGoBack -> {
if (isGoBack != null && isGoBack) {
popBackStackFragment();
}
});
BetterLinkMovementMethod.linkify(Linkify.ALL, binding.description).setOnLinkClickListener((tv, url) -> {
return false;
}).setOnLinkLongClickListener((tv, url) -> {
if (HelperUrl.isTextLink(url)) {
G.isLinkClicked = true;
HelperUrl.openLinkDialog(getActivity(), url);
}
return true;
});
viewModel.groupDescription.observe(getViewLifecycleOwner(), groupDescription -> {
if (getActivity() != null && groupDescription != null) {
binding.description.setText(EmojiManager.getInstance().replaceEmoji(HelperUrl.setUrlLink(getActivity(), groupDescription, true, false, null, true), binding.description.getPaint().getFontMetricsInt()));
}
});
viewModel.goToRoomListPage.observe(getViewLifecycleOwner(), isGo -> {
if (getActivity() instanceof ActivityMain && isGo != null) {
Log.wtf(this.getClass().getName(), "goToRoomListPage observe");
((ActivityMain) getActivity()).removeAllFragmentFromMain();
/*new HelperFragment(getActivity().getSupportFragmentManager()).popBackStack(2);*/
}
});
viewModel.showDialogEditLink.observe(getViewLifecycleOwner(), link -> {
if (getActivity() != null && link != null) {
MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.group_link).positiveText(R.string.array_Copy).customView(createDialogLayout(link), true).widgetColor(new Theme().getPrimaryColor(getContext())).negativeText(R.string.edit).onPositive((dialog1, which) -> {
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("LINK_GROUP", link);
clipboard.setPrimaryClip(clip);
}).onNegative((dialog12, which) -> {
if (viewModel.isPrivate) {
viewModel.sendRequestRevokeGroupUsername();
} else {
setUsername();
}
}).build();
dialog.show();
}
});
viewModel.showDialogCopyLink.observe(getViewLifecycleOwner(), link -> {
if (getActivity() != null && link != null) {
MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.group_link).positiveText(R.string.array_Copy).customView(createDialogLayout(link), true).widgetColor(new Theme().getPrimaryColor(getContext())).onPositive((dialog1, which) -> {
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("LINK_GROUP", link);
clipboard.setPrimaryClip(clip);
Toast.makeText(getActivity(), R.string.copied, Toast.LENGTH_SHORT).show();
}).build();
dialog.show();
}
});
viewModel.goToCustomNotificationPage.observe(getViewLifecycleOwner(), roomId -> {
if (getActivity() != null && roomId != null) {
FragmentNotification fragmentNotification = new FragmentNotification();
Bundle bundle = new Bundle();
bundle.putLong("ID", roomId);
fragmentNotification.setArguments(bundle);
new HelperFragment(getActivity().getSupportFragmentManager(), fragmentNotification).setReplace(false).load();
}
});
viewModel.showDialogLeaveGroup.observe(getViewLifecycleOwner(), isShow -> {
if (isShow != null && isShow) {
groupLeft();
}
});
if (viewModel.role.equals(GroupChatRole.OWNER)) {
binding.editGroupPermission.setVisibility(View.VISIBLE);
binding.editGroupPermission.setOnClickListener(v -> {
openChatEditRightsFragment(viewModel.getRealmRoom());
});
}
initComponent();
attachFile = new AttachFile(getActivity());
G.onGroupAvatarDelete = this;
initialToolbar();
}
use of net.iGap.activities.ActivityMain in project iGap-Android by KianIranian-STDG.
the class FragmentPassCode method onViewCreated.
@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initDataBinding();
passCodeToolbar = new Toolbar(getContext());
passCodeToolbar.setBackIcon(new BackDrawable(false));
passCodeToolbar.setTitle(getString(R.string.two_step_pass_code));
ToolbarItem toolbarItem;
toolbarItem = passCodeToolbar.addItem(rippleOkTag, R.string.icon_sent, Color.WHITE);
passCodeToolbar.setListener(i -> {
switch(i) {
case -1:
popBackStackFragment();
AppUtils.closeKeyboard(view);
break;
case rippleOkTag:
fragmentPassCodeViewModel.onClickRippleOk(view);
break;
}
});
fragmentPassCodeBinding.fpcLayoutToolbar.addView(passCodeToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
toolbarItem.setVisibility(View.GONE);
// observe to show tick (ok) button or not
fragmentPassCodeViewModel.rippleOkVisibility.observe(getViewLifecycleOwner(), visibility -> {
if (visibility != null) {
if (visibility == View.VISIBLE) {
toolbarItem.setVisibility(View.VISIBLE);
} else {
toolbarItem.setVisibility(View.GONE);
}
}
});
fragmentPassCodeViewModel.passCodeStateChangeListener.observe(getViewLifecycleOwner(), aBoolean -> {
if (getActivity() != null) {
((ActivityMain) getActivity()).updatePassCodeState();
}
});
boolean isLinePattern;
if (isPattern) {
SharedPreferences sharedPreferences = G.currentActivity.getSharedPreferences(SHP_SETTING.FILE_NAME, MODE_PRIVATE);
isLinePattern = sharedPreferences.getBoolean(SHP_SETTING.KEY_PATTERN_TACTILE_DRAWN, true);
} else {
isLinePattern = true;
}
// Set the current view more
fragmentPassCodeBinding.patternLockView.setViewMode(PatternLockView.PatternViewMode.WRONG);
// Set the pattern in stealth mode (pattern drawing is hidden)
fragmentPassCodeBinding.patternLockView.setInStealthMode(!isLinePattern);
// Enables vibration feedback when the pattern is drawn
fragmentPassCodeBinding.patternLockView.setTactileFeedbackEnabled(true);
// Disables any input from the pattern lock view completely
fragmentPassCodeBinding.patternLockView.setInputEnabled(true);
}
use of net.iGap.activities.ActivityMain in project iGap-Android by KianIranian-STDG.
the class FragmentGallery method checkVideoMultiSelectAndSendToEdit.
private void checkVideoMultiSelectAndSendToEdit() {
if (mGalleryVideoAdapter == null)
return;
if (mGalleryVideoAdapter.getMultiSelectState()) {
mHelperToolbar.getRightButton().setText(R.string.icon_new_conversation);
if (mGalleryVideoAdapter.getSelectedVideos().size() > 0) {
List<String> videos = new ArrayList<>();
for (GalleryVideoModel video : mGalleryVideoAdapter.getSelectedVideos()) {
videos.add(video.getPath());
}
mGalleryListener.onVideoPickerResult(videos);
popBackStackFragment();
if (getActivity() instanceof ActivityMain) {
((ActivityMain) getActivity()).goneDetailFrameInTabletMode();
}
}
} else {
mHelperToolbar.getRightButton().setText(R.string.icon_close);
}
mGalleryVideoAdapter.setMultiSelectState(!mGalleryVideoAdapter.getMultiSelectState());
}
use of net.iGap.activities.ActivityMain in project iGap-Android by KianIranian-STDG.
the class AccountsDialog method checkForAssigning.
public void checkForAssigning(boolean assign, long id) {
if (assign) {
if (getActivity() instanceof ActivityMain && AccountManager.getInstance().getCurrentUser().getId() != id) {
new AccountHelper().changeAccount(id);
((ActivityMain) getActivity()).updateUiForChangeAccount();
}
dismiss();
} else {
if (getActivity() != null) {
HelperTracker.sendTracker(HelperTracker.TRACKER_ADD_NEW_ACCOUNT);
new AccountHelper().addAccount();
// WebSocketClient.GGFconnectNewAccount();
Intent intent = new Intent(getActivity(), ActivityRegistration.class);
intent.putExtra("add account", true);
getActivity().startActivity(intent);
getActivity().finish();
}
}
}
Aggregations