use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.
the class StoryFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
if (getContext() == null)
return super.onCreateView(inflater, container, savedInstanceState);
Toolbar storyToolbar = new Toolbar(getContext());
storyToolbar.setTitle(isAppRtl ? R.string.logo_igap_fa : R.string.logo_igap_en);
ToolbarItems toolbarItems = storyToolbar.createToolbarItems();
toolbarItems.addItemWithWidth(codeScannerTag, R.string.icon_QR_code, 54);
storyToolbar.setListener(i -> {
switch(i) {
case codeScannerTag:
onCodeScannerClickListener();
break;
}
});
FrameLayout rootView = new FrameLayout(new ContextThemeWrapper(context, R.style.IGapRootViewStyle));
rootView.addView(storyToolbar, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.TOP));
swipeRefreshLayout = new SwipeRefreshLayout(context);
swipeRefreshLayout.setRefreshing(false);
rootView.addView(swipeRefreshLayout, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, Gravity.TOP, 0, LayoutCreator.getDimen(R.dimen.toolbar_height), 0, 0));
recyclerListView = new RecyclerListView(getContext());
adapter = new ListAdapter();
recyclerListView.setAdapter(adapter);
recyclerListView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
recyclerListView.setClipToPadding(false);
recyclerListView.setPadding(0, 0, 0, LayoutCreator.dp(30));
swipeRefreshLayout.addView(recyclerListView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, Gravity.CENTER, 0, 0, 0, 0));
progressBar = new ProgressBar(context);
progressBar.setVisibility(View.GONE);
rootView.addView(progressBar, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER));
actionButtonsRootView = new LinearLayout(context);
actionButtonsRootView.setOrientation(LinearLayout.VERTICAL);
rootView.addView(actionButtonsRootView, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isAppRtl ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, 16, 0, 16, 16));
customStatusActionLayout = new FrameLayout(context);
Drawable customStatusDrawable = Theme.createSimpleSelectorCircleDrawable(LayoutCreator.dp(56), Theme.getInstance().getToolbarBackgroundColor(context), Theme.getInstance().getAccentColor(context));
customStatusActionLayout.setBackground(customStatusDrawable);
IconView customStatusAddButton = new IconView(context);
customStatusAddButton.setIcon(R.string.icon_edit);
customStatusAddButton.setIconColor(Color.WHITE);
customStatusActionLayout.addView(customStatusAddButton);
actionButtonsRootView.addView(customStatusActionLayout, LayoutCreator.createLinear(42, 42, Gravity.CENTER, 0, 0, 0, 0));
floatActionLayout = new FrameLayout(context);
Drawable drawable = Theme.createSimpleSelectorCircleDrawable(LayoutCreator.dp(56), Theme.getInstance().getToolbarBackgroundColor(context), Theme.getInstance().getAccentColor(context));
floatActionLayout.setBackground(drawable);
IconView addButton = new IconView(context);
addButton.setIcon(R.string.icon_camera);
addButton.setIconColor(Color.WHITE);
floatActionLayout.addView(addButton);
actionButtonsRootView.addView(floatActionLayout, LayoutCreator.createLinear(52, 52, Gravity.CENTER, 0, 10, 0, 0));
return rootView;
}
use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.
the class MainFragment method createToolBar.
@Override
public View createToolBar(Context context) {
toolbar = new Toolbar(context);
toolbar.setTitle(isAppRtl ? R.string.logo_igap_fa : R.string.logo_igap_en);
toolbar.setOnClickListener(view -> recyclerView.smoothScrollToPosition(0));
ToolbarItems toolbarItems = toolbar.createToolbarItems();
searchItem = toolbarItems.addItem(0, R.string.icon_search, Color.WHITE).setIsSearchBox(true).setActionBarMenuItemSearchListener(new ToolbarItem.ActionBarMenuItemSearchListener() {
@Override
public void onSearchExpand() {
toolbar.setBackIcon(new BackDrawable(false));
if (getActivity() != null) {
searchFragment = SearchFragment.newInstance();
FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out);
fragmentView.setId(R.id.mainFragmentView);
fragmentTransaction.replace(fragmentView.getId(), searchFragment).commit();
}
}
@Override
public boolean canCollapseSearch() {
return super.canCollapseSearch();
}
@Override
public void onSearchCollapse() {
toolbar.setBackIcon(null);
searchFragment.onSearchCollapsed();
}
@Override
public void onTextChanged(EditText editText) {
super.onTextChanged(editText);
searchFragment.onTextChanged(editText.getText().toString());
}
});
toolbarItems.addItemWithWidth(codeScannerTag, R.string.icon_QR_code, 54);
if (PassCode.getInstance().isPassCode()) {
passCodeItem = toolbar.addItem(passCodeTag, R.string.icon_unlock, Color.WHITE);
}
createActionMode();
toolbar.setListener(i -> {
Log.i("abbasiMainFragment", "createToolBar: " + i);
switch(i) {
case -1:
if (toolbar.isInActionMode()) {
disableMultiSelect();
}
break;
case codeScannerTag:
onCodeScannerClickListener();
break;
case passCodeTag:
if (passCodeItem == null) {
return;
}
if (ActivityMain.isLock) {
passCodeItem.setIcon(R.string.icon_unlock);
ActivityMain.isLock = false;
HelperPreferences.getInstance().putBoolean(SHP_SETTING.FILE_NAME, SHP_SETTING.KEY_LOCK_STARTUP_STATE, false);
} else {
passCodeItem.setIcon(R.string.icon_lock);
ActivityMain.isLock = true;
HelperPreferences.getInstance().putBoolean(SHP_SETTING.FILE_NAME, SHP_SETTING.KEY_LOCK_STARTUP_STATE, true);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
Intent intent = new Intent(getActivity(), ActivityEnterPassCode.class);
startActivity(intent);
} else {
Intent intent = new Intent(getActivity(), ActivityEnterPassCode.class);
requireActivity().overridePendingTransition(R.anim.slide_in_right_slow, R.anim.slide_out_left_slow);
startActivity(intent);
}
}
checkPassCodeVisibility();
break;
case muteTag:
muteNotification();
break;
case pinTag:
setPinToTop();
break;
case leaveTag:
confirmActionForRemoveSelected();
break;
case clearHistoryTag:
confirmActionForClearHistoryOfSelected();
break;
case markAsReadTag:
markAsRead();
break;
case readAllTag:
readAllRoom();
break;
}
});
searchItem.getSearchEditText().setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
hideKeyboard();
return true;
}
return false;
});
return toolbar;
}
use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.
the class DiscoveryFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
HelperTracker.sendTracker(HelperTracker.TRACKER_DISCOVERY_PAGE);
page = getArguments().getInt("page");
if (getContext() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
StatusBarUtil.setColor(getActivity(), new Theme().getPrimaryDarkColor(getContext()), 50);
}
// uncomment this lines after added small avatar and discovery setting
discoveryToolbar = new Toolbar(getContext());
discoveryToolbar.setTitle(G.isAppRtl ? R.string.logo_igap_fa : R.string.logo_igap_en);
if (page != 0) {
discoveryToolbar.setBackIcon(new BackDrawable(false));
} else {
discoveryToolbar.addItem(codeScannerTag, R.string.icon_QR_code, Color.WHITE);
passCodeItem = discoveryToolbar.addItem(passCodeTag, R.string.icon_lock, Color.WHITE);
}
checkPassCodeVisibility();
discoveryToolbar.setListener(i -> {
switch(i) {
case -1:
popBackStackFragment();
break;
case codeScannerTag:
onCodeScannerClickListener();
break;
case passCodeTag:
if (passCodeItem == null) {
return;
}
if (ActivityMain.isLock) {
passCodeItem.setIcon(R.string.icon_unlock);
ActivityMain.isLock = false;
HelperPreferences.getInstance().putBoolean(SHP_SETTING.FILE_NAME, SHP_SETTING.KEY_LOCK_STARTUP_STATE, false);
} else {
passCodeItem.setIcon(R.string.icon_lock);
ActivityMain.isLock = true;
HelperPreferences.getInstance().putBoolean(SHP_SETTING.FILE_NAME, SHP_SETTING.KEY_LOCK_STARTUP_STATE, true);
}
checkPassCodeVisibility();
break;
}
});
ViewGroup layoutToolbar = view.findViewById(R.id.fd_layout_toolbar);
layoutToolbar.addView(discoveryToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
pullToRefresh = view.findViewById(R.id.pullToRefresh);
emptyRecycle = view.findViewById(R.id.emptyRecycle);
rcDiscovery = view.findViewById(R.id.rcDiscovery);
rcDiscovery.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// Ensure you call it only once
rcDiscovery.getViewTreeObserver().removeOnGlobalLayoutListener(this);
// Here you can get the size :)
if (rcDiscovery.getAdapter() instanceof DiscoveryAdapter) {
((DiscoveryAdapter) rcDiscovery.getAdapter()).setWidth(rcDiscovery.getWidth());
}
}
});
/**
*detect scroll down or up for tapcell send request
*/
pullToRefresh.setOnRefreshListener(() -> {
scroll = 1;
setRefreshing(true);
boolean isSend = updateOrFetchRecycleViewData();
rcDiscovery.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dy <= 0) {
return;
} else {
if (scroll == 1)
BottomNavigationFragment.isShowedAdd = false;
}
scroll++;
}
});
if (!isSend) {
setRefreshing(false);
HelperError.showSnackMessage(getString(R.string.wallet_error_server), false);
}
});
emptyRecycle.setOnClickListener(v -> {
boolean isSend = updateOrFetchRecycleViewData();
if (!isSend) {
HelperError.showSnackMessage(getString(R.string.wallet_error_server), false);
}
});
// load user avatar in toolbar
// avatarHandler.getAvatar(new ParamWithAvatarType(mHelperToolbar.getAvatarSmall(), G.userId).avatarType(AvatarHandler.AvatarType.USER).showMain());
rcDiscovery.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
rcDiscovery.setAdapter(new DiscoveryAdapter(getActivity(), rcDiscovery.getWidth(), discoveryArrayList));
if (discoveryArrayList == null) {
tryToUpdateOrFetchRecycleViewData(0);
}
if (needToReload) {
updateOrFetchRecycleViewData();
}
}
use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.
the class FragmentSecurity method onViewCreated.
@Override
public void onViewCreated(@NotNull final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
securityToolbar = new Toolbar(getContext());
securityToolbar.setBackIcon(new BackDrawable(false));
securityToolbar.setTitle(getString(R.string.two_step_pass_code));
ToolbarItem toolbarItem;
toolbarItem = securityToolbar.addItem(rippleOkTag, R.string.icon_sent, Color.WHITE);
securityToolbar.setListener(i -> {
switch(i) {
case -1:
fragmentSecurityViewModel.onClickRippleBack(view);
break;
case rippleOkTag:
fragmentSecurityViewModel.onClickRippleOk(view);
break;
}
});
fragmentSecurityBinding.ffsLayoutToolbar.addView(securityToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
toolbarItem.setVisibility(View.GONE);
fragmentSecurityViewModel.titleToolbar.observe(G.fragmentActivity, s -> securityToolbar.setTitle(s));
fragmentSecurityViewModel.rippleOkVisibility.observe(G.fragmentActivity, visibility -> toolbarItem.setVisibility(visibility));
fragmentSecurityViewModel.goToSetSecurityPassword.observe(getViewLifecycleOwner(), password -> {
if (getActivity() != null && password != null) {
FragmentSetSecurityPassword fragmentSetSecurityPassword = new FragmentSetSecurityPassword();
Bundle bundle = new Bundle();
bundle.putString("OLD_PASSWORD", password);
fragmentSetSecurityPassword.setArguments(bundle);
new HelperFragment(getActivity().getSupportFragmentManager(), fragmentSetSecurityPassword).load();
}
});
fragmentSecurityViewModel.showForgetPasswordDialog.observe(getViewLifecycleOwner(), listRes -> {
if (getActivity() != null && listRes != null) {
new MaterialDialog.Builder(getActivity()).title(R.string.set_recovery_dialog_title).items(listRes).itemsCallback((dialog, view1, which, text) -> fragmentSecurityViewModel.forgetPassword(text.equals(getString(R.string.recovery_by_email_dialog)))).show();
}
});
fragmentSecurityViewModel.goToSecurityRecoveryPage.observe(getViewLifecycleOwner(), data -> {
if (getActivity() != null && data != null) {
FragmentSecurityRecovery fragmentSecurityRecovery = new FragmentSecurityRecovery();
Bundle bundle = new Bundle();
bundle.putSerializable("PAGE", data.getSecurity());
bundle.putString("QUESTION_ONE", data.getQuestionOne());
bundle.putString("QUESTION_TWO", data.getQuestionTwo());
bundle.putString("PATERN_EMAIL", data.getEmailPattern());
bundle.putBoolean("IS_EMAIL", data.isEmail());
bundle.putBoolean("IS_CONFIRM_EMAIL", data.isConfirmEmail());
fragmentSecurityRecovery.setArguments(bundle);
new HelperFragment(getActivity().getSupportFragmentManager(), fragmentSecurityRecovery).load();
}
});
onPopBackStackFragment = this::popBackStackFragment;
}
use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.
the class FragmentIVandActivities method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
iVandActivityAdapter = new IVandActivityAdapter(new ArrayList<>());
retry = view.findViewById(R.id.retry);
emptyActivitiesText = view.findViewById(R.id.emptyActivitiesText);
isLoading = false;
pullToRefresh = view.findViewById(R.id.pullToRefresh);
pullToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
boolean isSend = updateOrFetchRecycleViewData(0);
if (!isSend) {
turnOffRefresh(false);
HelperError.showSnackMessage(getString(R.string.wallet_error_server), false);
}
}
});
retry.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isSend = updateOrFetchRecycleViewData(0);
if (!isSend) {
HelperError.showSnackMessage(getString(R.string.wallet_error_server), false);
}
}
});
recyclerView = view.findViewById(R.id.recyclerView);
LinearLayoutManager layoutManager = new LinearLayoutManager(G.currentActivity);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(iVandActivityAdapter);
DividerItemDecoration itemDecorator = new DividerItemDecoration(requireContext(), layoutManager.getOrientation());
itemDecorator.setDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.divider_rv));
recyclerView.addItemDecoration(itemDecorator);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (existMoreItem && !isLoading) {
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
if (linearLayoutManager != null && linearLayoutManager.findLastCompletelyVisibleItemPosition() == iVandActivityAdapter.getItemCount() - 1) {
boolean isSend = updateOrFetchRecycleViewData(iVandActivityAdapter.getItemCountWithoutLoadingItem());
iVandActivityAdapter.addLoadingItem();
iVandActivityAdapter.notifyItemInserted(iVandActivityAdapter.getItemCount() - 1);
if (isSend) {
isLoading = true;
}
}
}
}
});
ivAndActivitiesToolbar = new Toolbar(getContext());
ivAndActivitiesToolbar.setTitle(getString(R.string.ivand_activities_title));
ivAndActivitiesToolbar.setBackIcon(new BackDrawable(false));
ivAndActivitiesToolbar.setListener(i -> {
switch(i) {
case -1:
if (getActivity() != null) {
getActivity().onBackPressed();
}
break;
}
});
binding.toolbar.addView(ivAndActivitiesToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
}
Aggregations