use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.
the class ElectricityBillListFrag method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
HelperToolbar mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLeftIcon(R.string.icon_back).setLifecycleOwner(getViewLifecycleOwner()).setListener(new ToolbarListener() {
@Override
public void onLeftIconClickListener(View view) {
popBackStackFragment();
}
@Override
public void onRightIconClickListener(View view) {
List<Integer> items = new ArrayList<>();
items.add(R.string.elecBill_cell_deleteAccount);
new TopSheetDialog(getContext()).setListDataWithResourceId(items, -1, position -> {
if (position == 0) {
final MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.elecBill_deleteAccount_title).content(R.string.elecBill_deleteAccount_desc).positiveText(R.string.elecBill_deleteAccount_pos).negativeText(R.string.elecBill_deleteAccount_neg).positiveColor(getContext().getResources().getColor(R.color.red)).widgetColor(new Theme().getAccentColor(getContext())).onPositive((dialog1, which) -> viewModel.deleteAccount()).build();
dialog.show();
}
}).show();
}
}).setLogoShown(true);
LinearLayout toolbarLayout = binding.Toolbar;
toolbarLayout.addView(mHelperToolbar.getView());
binding.billRecycler.setHasFixedSize(true);
onDataChangedListener();
viewModel.getBillsList();
}
use of net.iGap.module.Theme 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.module.Theme in project iGap-Android by KianIranian-STDG.
the class FragmentProfile method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewModel.getGoToWalletPage().observe(getViewLifecycleOwner(), phoneNumber -> {
if (getActivity() != null && phoneNumber != null) {
// getActivity().startActivityForResult(new HelperWallet().goToWallet(getActivity(), new Intent(getActivity(), WalletActivity.class), phoneNumber, false), WALLET_REQUEST_CODE);
}
});
viewModel.getGoToAddMemberPage().observe(getViewLifecycleOwner(), aBoolean -> {
if (getActivity() != null && aBoolean != null && aBoolean) {
try {
Fragment fragment = RegisteredContactsFragment.newInstance(true, false, RegisteredContactsFragment.ADD);
new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
} catch (Exception e) {
e.getStackTrace();
}
}
});
viewModel.goToChatPage.observe(getViewLifecycleOwner(), data -> {
if (getActivity() != null && data != null) {
new GoToChatActivity(data.getRoomId()).setPeerID(data.getPeerId()).startActivity(getActivity());
}
});
viewModel.goToScannerPage.observe(getViewLifecycleOwner(), go -> {
if (go != null && go) {
try {
HelperPermission.getCameraPermission(getActivity(), new OnGetPermission() {
@Override
public void Allow() throws IllegalStateException {
IntentIntegrator integrator = new IntentIntegrator(getActivity());
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE);
integrator.setRequestCode(ActivityMain.requestCodeQrCode);
integrator.setBeepEnabled(false);
integrator.setPrompt("");
integrator.initiateScan();
}
@Override
public void deny() {
showDeniedPermissionMessage(G.context.getString(R.string.permission_camera));
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
});
viewModel.checkLocationPermission.observe(getViewLifecycleOwner(), isCheck -> {
if (isCheck != null && isCheck) {
try {
HelperPermission.getLocationPermission(getActivity(), new OnGetPermission() {
@Override
public void Allow() {
viewModel.haveLocationPermission();
}
@Override
public void deny() {
showDeniedPermissionMessage(G.context.getString(R.string.permission_location));
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
});
viewModel.shareInviteLink.observe(getViewLifecycleOwner(), link -> {
if (link != null) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, link);
sendIntent.setType("text/plain");
Intent openInChooser = Intent.createChooser(sendIntent, "Open in...");
startActivity(openInChooser);
}
});
viewModel.goToContactsPage.observe(getViewLifecycleOwner(), go -> {
if (getActivity() != null && go != null && go) {
new HelperFragment(getActivity().getSupportFragmentManager(), RegisteredContactsFragment.newInstance(false, false, RegisteredContactsFragment.CONTACTS)).setReplace(false).load();
}
});
viewModel.goToUserScorePage.observe(getViewLifecycleOwner(), go -> {
if (getActivity() != null && go != null && go) {
new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentUserScore()).setReplace(false).load();
}
});
viewModel.goToIGapMapPage.observe(getViewLifecycleOwner(), isGo -> {
if (getActivity() != null && isGo != null && isGo) {
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentiGapMap.getInstance()).setReplace(false).load();
}
});
viewModel.goToFAQPage.observe(getViewLifecycleOwner(), link -> {
if (link != null) {
HelperUrl.openBrowser(link);
}
});
viewModel.goToSettingPage.observe(getViewLifecycleOwner(), go -> {
if (getActivity() != null && go != null && go) {
new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentSetting()).setReplace(false).load();
}
});
viewModel.getUpdateNewTheme().observe(getViewLifecycleOwner(), isUpdate -> {
if (getActivity() != null && isUpdate != null && isUpdate) {
Fragment frg;
frg = getActivity().getSupportFragmentManager().findFragmentByTag(BottomNavigationFragment.class.getName());
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.detach(frg);
ft.attach(frg);
ft.commit();
}
});
viewModel.showDialogBeLastVersion.observe(getViewLifecycleOwner(), isShow -> {
if (getActivity() != null && isShow != null && isShow) {
new MaterialDialog.Builder(getActivity()).cancelable(false).title(R.string.app_version_change_log).titleGravity(GravityEnum.CENTER).titleColor(new Theme().getPrimaryColor(getActivity())).content(R.string.updated_version_title).contentGravity(GravityEnum.CENTER).positiveText(R.string.ok).itemsGravity(GravityEnum.START).show();
}
});
viewModel.showDialogUpdate.observe(getViewLifecycleOwner(), body -> {
if (getActivity() != null && body != null) {
new MaterialDialog.Builder(getActivity()).cancelable(false).title(R.string.app_version_change_log).titleGravity(GravityEnum.CENTER).titleColor(new Theme().getPrimaryColor(getActivity())).content(body).contentGravity(GravityEnum.CENTER).positiveText(R.string.startUpdate).itemsGravity(GravityEnum.START).onPositive((dialog, which) -> {
String url = BuildConfig.UPDATE_LINK;
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}).negativeText(R.string.cancel).show();
}
});
}
use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.
the class FragmentMap method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle saveInctanceState) {
super.onViewCreated(view, saveInctanceState);
/* */
/**/
/* itemIcon = (MaterialDesignTextView) view.findViewById(R.id.mf_icon);*/
rvIcon = view.findViewById(R.id.rv_icon);
Drawable mDrawableSkip = ContextCompat.getDrawable(getContext(), R.drawable.ic_circle_shape);
if (mDrawableSkip != null) {
mDrawableSkip.setColorFilter(new PorterDuffColorFilter(new Theme().getPrimaryColor(getContext()), PorterDuff.Mode.SRC_IN));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
rvIcon.setBackground(mDrawableSkip);
}
}
imgProfile = view.findViewById(R.id.mf_imgProfile);
rvSendPosition = view.findViewById(R.id.mf_rv_send_position);
rvSeePosition = view.findViewById(R.id.mf_rv_see_position);
rvSendPosition.setEnabled(false);
accuracy = view.findViewById(R.id.mf_txt_accuracy);
accuracy.setText(getResources().getString(R.string.get_location_data));
txtTitle = view.findViewById(R.id.mf_txt_message);
txtUserName = view.findViewById(R.id.mf_txt_userName);
txtDistance = view.findViewById(R.id.mf_txt_distance);
txtDistance.setText(getResources().getString(R.string.calculation));
txtUserName.setTextColor(new Theme().getPrimaryColor(getContext()));
accuracy.setTextColor(new Theme().getPrimaryColor(getContext()));
txtDistance.setTextColor(new Theme().getPrimaryColor(getContext()));
rvSendPosition.setBackgroundColor(new Theme().getPrimaryColor(getContext()));
txtTitle.setTextColor(new Theme().getPrimaryColor(getContext()));
fabOpenMap = view.findViewById(R.id.mf_fab_openMap);
fabOpenMap.setBackgroundTintList(ColorStateList.valueOf(new Theme().getButtonColor(getContext())));
fabOpenMap.setColorFilter(Color.WHITE);
bundle = getArguments();
if (bundle != null) {
latitude = bundle.getDouble(FragmentMap.Latitude);
longitude = bundle.getDouble(FragmentMap.Longitude);
mode = (Mode) bundle.getSerializable(PosoitionMode);
if (mode == Mode.sendPosition) {
if (G.onHelperSetAction != null) {
G.onHelperSetAction.onAction(ProtoGlobal.ClientAction.SENDING_LOCATION);
}
}
initComponent(view, bundle.getInt("type", 0), bundle.getLong("roomId", 00), bundle.getString("senderId", null));
} else {
close();
}
}
use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.
the class DefaultRoundDialog method show.
@Override
public AlertDialog show() {
AlertDialog dialog = this.create();
dialog.getWindow().setBackgroundDrawable(new Theme().tintDrawable(ContextCompat.getDrawable(getContext(), R.drawable.dialog_background_dark), getContext(), R.attr.rootBackgroundColor));
dialog.show();
return dialog;
}
Aggregations