use of net.iGap.module.AttachFile in project iGap-Android by KianIranian-STDG.
the class FragmentChatBackground method onViewCreated.
@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewModel.init();
toolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setRightIcons(R.string.icon_other_vertical_dots, R.string.icon_sent, R.string.icon_retry).setLogoShown(true).setDefaultTitle(getString(R.string.st_title_Background)).setListener(this);
binding.fcbLayoutToolbar.addView(toolbar.getView());
toolbar.getSecondRightButton().setVisibility(View.GONE);
binding.rcvContent.setAdapter(new AdapterChatBackground(viewModel.getOnImageWallpaperListClick()));
viewModel.getLoadSelectedImage().observe(getViewLifecycleOwner(), wallpaper -> {
if (wallpaper != null) {
binding.stchfFullImage.setBackground(null);
binding.stchfFullImage.setImageDrawable(Drawable.createFromPath(new File(wallpaper.getImagePath()).getAbsolutePath()));
if (wallpaper.isNew()) {
toolbar.getSecondRightButton().setVisibility(View.VISIBLE);
toolbar.getThirdRightButton().setVisibility(View.GONE);
} else {
toolbar.getSecondRightButton().setVisibility(View.GONE);
toolbar.getThirdRightButton().setVisibility(View.VISIBLE);
}
}
});
viewModel.getShowAddImage().observe(getViewLifecycleOwner(), isShow -> {
if (getActivity() != null && isShow != null && isShow) {
new MaterialDialog.Builder(getActivity()).title(R.string.choose_picture).negativeText(R.string.cancel).items(R.array.profile).itemsCallback(new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
AttachFile attachFile = new AttachFile(getActivity());
if (text.toString().equals(getString(R.string.from_camera))) {
try {
attachFile.requestTakePicture(FragmentChatBackground.this);
} catch (IOException e) {
e.printStackTrace();
}
} else {
try {
attachFile.requestOpenGalleryForImageSingleSelect(FragmentChatBackground.this);
} catch (IOException e) {
e.printStackTrace();
}
}
dialog.dismiss();
}
}).show();
}
});
viewModel.getLoadSelectedColor().observe(getViewLifecycleOwner(), colorValue -> {
if (colorValue != null) {
binding.stchfFullImage.setImageDrawable(null);
binding.stchfFullImage.setBackgroundColor(colorValue.getColor());
if (colorValue.isNew()) {
toolbar.getSecondRightButton().setVisibility(View.VISIBLE);
toolbar.getThirdRightButton().setVisibility(View.GONE);
} else {
toolbar.getSecondRightButton().setVisibility(View.GONE);
toolbar.getThirdRightButton().setVisibility(View.VISIBLE);
}
}
});
viewModel.getMenuList().observe(getViewLifecycleOwner(), menuList -> {
if (getContext() != null && menuList != null) {
new TopSheetDialog(getContext()).setListDataWithResourceId(menuList, -1, position -> viewModel.onMenuItemClicked(position)).show();
}
});
viewModel.getLoadChatBackgroundImage().observe(getViewLifecycleOwner(), isLoad -> {
if (binding.rcvContent.getAdapter() instanceof AdapterChatBackground && isLoad != null) {
((AdapterChatBackground) binding.rcvContent.getAdapter()).wallpaperList(isLoad);
}
});
viewModel.getLoadChatBackgroundSolidColor().observe(getViewLifecycleOwner(), isLoad -> {
if (binding.rcvContent.getAdapter() instanceof AdapterChatBackground && isLoad != null) {
((AdapterChatBackground) binding.rcvContent.getAdapter()).setSolidColor(isLoad);
}
});
viewModel.getGoBack().observe(getViewLifecycleOwner(), isGoBack -> {
if (getActivity() instanceof ActivityMain && isGoBack != null) {
if (isGoBack) {
((ActivityMain) getActivity()).chatBackgroundChanged();
}
getActivity().onBackPressed();
}
});
}
use of net.iGap.module.AttachFile in project iGap-Android by KianIranian-STDG.
the class EditGroupFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewModel.onCreateFragment(this);
HelperToolbar mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLogoShown(true).setLeftIcon(R.string.icon_back).setRightIcons(R.string.icon_sent).setDefaultTitle(G.context.getResources().getString(R.string.tab_edit)).setListener(new ToolbarListener() {
@Override
public void onLeftIconClickListener(View view) {
popBackStackFragment();
}
@Override
public void onRightIconClickListener(View view) {
viewModel.setData(binding.groupNameEditText.getEditableText().toString(), binding.groupDescriptionEditText.getEditableText().toString());
hideKeyboard();
}
});
binding.toolbar.addView(mHelperToolbar.getView());
// mHelperToolbar.getTextViewLogo().setText(R.string.tab_edit);
attachFile = new AttachFile(G.fragmentActivity);
viewModel.goToMembersPage.observe(getViewLifecycleOwner(), b -> {
if (b != null && b) {
showListForCustomRole(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.ALL.toString());
}
});
viewModel.goToAdministratorPage.observe(getViewLifecycleOwner(), b -> {
if (b != null && b) {
showListForCustomRole(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.ADMIN.toString());
}
});
viewModel.goToPermissionPage.observe(getViewLifecycleOwner(), new Observer<Boolean>() {
@Override
public void onChanged(@Nullable Boolean b) {
}
});
viewModel.goBack.observe(getViewLifecycleOwner(), aBoolean -> popBackStackFragment());
viewModel.showSelectImageDialog.observe(getViewLifecycleOwner(), aBoolean -> {
if (aBoolean != null && aBoolean) {
startDialogSelectPicture();
}
});
viewModel.closePageImediatly.observe(getViewLifecycleOwner(), isClose -> {
if (isClose == null || !isClose)
return;
popBackStackFragment();
});
viewModel.showDialogChatHistory.observe(getViewLifecycleOwner(), aBoolean -> {
if (getActivity() != null && aBoolean != null && aBoolean) {
showDialog();
}
});
viewModel.goToModeratorPage.observe(getViewLifecycleOwner(), aBoolean -> showListForCustomRole(ProtoGroupGetMemberList.GroupGetMemberList.FilterRole.MODERATOR.toString()));
viewModel.initEmoji.observe(getViewLifecycleOwner(), aBoolean -> {
// if (aBoolean != null) {
// emojiPopup.toggle();
// }
});
viewModel.showDialogLeaveGroup.observe(getViewLifecycleOwner(), aBoolean -> {
if (aBoolean != null && aBoolean) {
groupLeft();
}
});
viewModel.goToRoomListPage.observe(getViewLifecycleOwner(), go -> {
if (getActivity() instanceof ActivityMain && go != null && go) {
((ActivityMain) getActivity()).removeAllFragmentFromMain();
}
});
viewModel.getOnGroupAvatarUpdated().observe(getViewLifecycleOwner(), roomId -> {
if (roomId != null && roomId == viewModel.roomId) {
setAvatar();
}
});
// setUpEmojiPopup();
setAvatar();
}
use of net.iGap.module.AttachFile in project iGap-Android by KianIranian-STDG.
the class FragmentChat method startPageFastInitialize.
/**
* set just important item to view in onCreate and load another objects in onResume
* actions : set app color, load avatar, set background, set title, set status chat or member for group or channel
*/
private void startPageFastInitialize() {
Bundle extras = getArguments();
if (extras != null) {
mRoomId = extras.getLong("RoomId");
isGoingFromUserLink = extras.getBoolean("GoingFromUserLink");
isNotJoin = extras.getBoolean("ISNotJoin");
userName = extras.getString("UserName");
messageId = extras.getLong("MessageId");
documentId = extras.getLong("DocumentId");
chatPeerId = extras.getLong("peerId");
}
attachFile = new AttachFile(G.fragmentActivity);
RealmRoom realmRoom = getRoom();
pageSettings();
// avi = (AVLoadingIndicatorView) rootView.findViewById(R.id.avi);
verifiedIcon.setVisibility(View.GONE);
/**
* need this info for load avatar
*/
if (realmRoom != null) {
chatType = realmRoom.getType();
if (chatType == CHAT) {
chatPeerId = realmRoom.getChatRoom().getPeerId();
RealmRegisteredInfo realmRegisteredInfo = DbManager.getInstance().doRealmTask(realm -> {
return RealmRegisteredInfo.getRegistrationInfo(realm, chatPeerId);
});
if (realmRegisteredInfo != null) {
title = realmRegisteredInfo.getDisplayName();
lastSeen = realmRegisteredInfo.getLastSeen();
userStatus = realmRegisteredInfo.getStatus();
isBot = realmRegisteredInfo.isBot();
if (isBot) {
if (getMessagesCount() == 0) {
layoutMute.setVisibility(View.VISIBLE);
txtChannelMute.setText(R.string.start);
iconChannelMute.setText("");
View layoutAttach = rootView.findViewById(R.id.layout_attach_file);
layoutAttach.setVisibility(View.GONE);
layoutMute.setOnClickListener(v -> {
if (!isChatReadOnly) {
edtChat.setText("/Start");
imvSendButton.performClick();
removeStartButton();
}
});
isShowStartButton = true;
}
}
if (realmRegisteredInfo.isVerified()) {
verifiedIcon.setVisibility(View.VISIBLE);
}
} else {
/**
* when userStatus isn't EXACTLY lastSeen time not used so don't need
* this time and also this time not exist in room info
*/
title = realmRoom.getTitle();
userStatus = G.fragmentActivity.getResources().getString(R.string.last_seen_recently);
}
} else {
mRoomId = realmRoom.getId();
title = realmRoom.getTitle();
if (chatType == GROUP && realmRoom.getGroupRoom() != null) {
groupParticipantsCountLabel = realmRoom.getGroupRoom().getParticipantsCountLabel();
isPublicGroup = roomIsPublic = !realmRoom.getGroupRoom().isPrivate();
} else if (chatType == CHANNEL && realmRoom.getChannelRoom() != null) {
groupParticipantsCountLabel = realmRoom.getChannelRoom().getParticipantsCountLabel();
showVoteChannel = realmRoom.getChannelRoom().isReactionStatus();
if (realmRoom.getChannelRoom().isVerified()) {
verifiedIcon.setVisibility(View.VISIBLE);
}
roomIsPublic = !realmRoom.getChannelRoom().isPrivate();
}
}
if (chatType == CHAT) {
setUserStatus(userStatus, lastSeen);
} else if ((chatType == GROUP) || (chatType == CHANNEL)) {
if (groupParticipantsCountLabel != null) {
if (HelperString.isNumeric(groupParticipantsCountLabel) && Integer.parseInt(groupParticipantsCountLabel) == 1) {
mToolbar.setSubTitle(groupParticipantsCountLabel + " " + G.fragmentActivity.getResources().getString(R.string.one_member_chat));
} else {
mToolbar.setSubTitle(groupParticipantsCountLabel + " " + G.fragmentActivity.getResources().getString(R.string.member_chat));
}
// avi.setVisibility(View.GONE);
}
}
} else if (chatPeerId != 0) {
/**
* when user start new chat this block will be called
*/
chatType = CHAT;
RealmRegisteredInfo realmRegisteredInfo = DbManager.getInstance().doRealmTask(realm -> {
return RealmRegisteredInfo.getRegistrationInfo(realm, chatPeerId);
});
title = realmRegisteredInfo.getDisplayName();
lastSeen = realmRegisteredInfo.getLastSeen();
userStatus = realmRegisteredInfo.getStatus();
setUserStatus(userStatus, lastSeen);
}
if (title != null) {
mToolbar.setTitle(EmojiManager.getInstance().replaceEmoji(title, null));
}
/**
* change english number to persian number
*/
if (HelperCalander.isPersianUnicode) {
mToolbar.setTitle(EmojiManager.getInstance().replaceEmoji(mToolbar.getTitleTextView().getText().toString(), mToolbar.getTitleTextView().getPaint().getFontMetricsInt()));
mToolbar.setSubTitle(convertToUnicodeFarsiNumber(mToolbar.getSubTitleText()));
}
/**
* hint: don't check isCloudRoom with (( RealmRoom.isCloudRoom(mRoomId, realm); ))
* because in first time room not exist in RealmRoom and value is false always.
* so just need to check this value with chatPeerId
*/
if (chatPeerId == AccountManager.getInstance().getCurrentUser().getId()) {
isCloudRoom = true;
}
viewAttachFile = rootView.findViewById(R.id.layout_attach_file);
iconMute = mToolbar.getMuteIcon();
if (realmRoom != null) {
iconMute.setVisibility(realmRoom.getMute() ? View.VISIBLE : View.GONE);
isMuteNotification = realmRoom.getMute();
isChatReadOnly = realmRoom.getReadOnly();
}
// gone video , voice button call then if status was ok visible them
// mHelperToolbar.getSecondRightButton().setVisibility(View.GONE);
callItem.setVisibility(View.GONE);
if (isChatReadOnly) {
viewAttachFile.setVisibility(View.GONE);
(rootView.findViewById(R.id.chl_recycler_view_chat)).setPadding(0, 0, 0, 0);
} else if (chatType == CHAT && AccountManager.getInstance().getCurrentUser().getId() != chatPeerId && !isBot) {
// gone or visible view call
RealmCallConfig callConfig = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmCallConfig.class).findFirst();
});
if (callConfig != null) {
if (callConfig.isVoice_calling()) {
// mHelperToolbar.getSecondRightButton().setVisibility(View.VISIBLE);
callItem.setVisibility(View.VISIBLE);
} else {
callItem.setVisibility(View.VISIBLE);
// mHelperToolbar.getSecondRightButton().setVisibility(View.GONE);
}
} else {
new RequestSignalingGetConfiguration().signalingGetConfiguration();
}
}
createMoreItems();
manageExtraLayout();
}
use of net.iGap.module.AttachFile in project iGap-Android by KianIranian-STDG.
the class FragmentChatBackground method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
String filePath = null;
switch(requestCode) {
case AttachFile.request_code_TAKE_PICTURE:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
ImageHelper.correctRotateImage(AttachFile.mCurrentPhotoPath, true);
filePath = AttachFile.mCurrentPhotoPath;
} else {
ImageHelper.correctRotateImage(AttachFile.imagePath, true);
filePath = AttachFile.imagePath;
}
break;
case AttachFile.request_code_image_from_gallery_single_select:
if (data != null && data.getData() != null) {
if (getActivity() != null) {
AttachFile attachFile = new AttachFile(getActivity());
filePath = attachFile.saveGalleryPicToLocal(AttachFile.getFilePathFromUri(data.getData()));
}
}
break;
}
viewModel.setUserCustomImage(filePath);
}
}
use of net.iGap.module.AttachFile in project iGap-Android by KianIranian-STDG.
the class SelectImageBottomSheetDialog method checkCameraAndLoadImage.
private void checkCameraAndLoadImage() {
boolean isCameraButtonSheet = sharedPreferences.getBoolean(SHP_SETTING.KEY_CAMERA_BUTTON_SHEET, true);
if (isCameraButtonSheet) {
try {
HelperPermission.getCameraPermission(G.fragmentActivity, new OnGetPermission() {
@Override
public void Allow() {
G.handler.post(new Runnable() {
@Override
public void run() {
fastItemAdapter.add(new AdapterCamera("", new OnClickCamera() {
@Override
public void onclickCamera() {
try {
dismiss();
if (getActivity() != null) {
new AttachFile(getActivity()).requestTakePicture(SelectImageBottomSheetDialog.this);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}).withIdentifier(99));
for (int i = 0; i < FragmentEditImage.itemGalleryList.size(); i++) {
fastItemAdapter.add(new BottomSheetItem(FragmentEditImage.itemGalleryList.get(i), onPathAdapterBottomSheet).withIdentifier(100 + i));
}
isPermissionCamera = true;
}
});
G.handler.postDelayed(new Runnable() {
@Override
public void run() {
if (isAdded()) {
/*showBottomSheet();*/
}
}
}, 100);
}
@Override
public void deny() {
loadImageGallery();
}
});
} catch (IOException e) {
e.printStackTrace();
}
} else {
loadImageGallery();
}
}
Aggregations