Search in sources :

Example 6 with BackDrawable

use of net.iGap.messenger.ui.toolBar.BackDrawable 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;
}
Also used : EditText(android.widget.EditText) FragmentTransaction(androidx.fragment.app.FragmentTransaction) ToolbarItems(net.iGap.messenger.ui.toolBar.ToolbarItems) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) Intent(android.content.Intent) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 7 with BackDrawable

use of net.iGap.messenger.ui.toolBar.BackDrawable in project iGap-Android by KianIranian-STDG.

the class RegisteredContactsFragment method multi_select.

public void multi_select(int position) {
    if (contactsToolbar.isInActionMode()) {
        if (position < 0 && results.get(position) == null) {
            return;
        }
        if (selectedList.containsKey(results.get(position).getPhone())) {
            selectedList.remove(results.get(position).getPhone());
        } else {
            selectedList.put(results.get(position).getPhone(), true);
        }
        if (selectedList.size() > 0) {
            contactsToolbar.showActionToolbar();
            ImageView imageView = contactsToolbar.backIcon;
            contactsToolbar.setBackIconToNull();
            BackDrawable backDrawable = new BackDrawable(true);
            backDrawable.setRotation(1, true);
            backDrawable.setRotatedColor(Theme.getInstance().getPrimaryTextColor(getContext()));
            contactsToolbar.setBackIcon(backDrawable);
            contactsToolbar.removeView(imageView);
            if (selectedList.size() > 1) {
                editItem.setVisibility(View.GONE);
            } else {
                editItem.setVisibility(View.VISIBLE);
            }
            multiSelectCounter.setNumber(selectedList.size(), true);
        } else {
            contactsToolbar.hideActionToolbar();
            contactsToolbar.setBackIcon(new BackDrawable(false));
            setMultiSelectState(isMultiSelect);
        }
        refreshAdapter(position, false);
    }
}
Also used : BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) ImageView(android.widget.ImageView) CircleImageView(net.iGap.module.CircleImageView)

Example 8 with BackDrawable

use of net.iGap.messenger.ui.toolBar.BackDrawable 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();
    }
}
Also used : ViewGroup(android.view.ViewGroup) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Theme(net.iGap.module.Theme) RecyclerView(androidx.recyclerview.widget.RecyclerView) ViewTreeObserver(android.view.ViewTreeObserver) DiscoveryAdapter(net.iGap.adapter.items.discovery.DiscoveryAdapter) HelperToolbar(net.iGap.helper.HelperToolbar) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 9 with BackDrawable

use of net.iGap.messenger.ui.toolBar.BackDrawable 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;
}
Also used : Bundle(android.os.Bundle) KeyEvent(android.view.KeyEvent) LayoutInflater(android.view.LayoutInflater) ToolbarItem(net.iGap.messenger.ui.toolBar.ToolbarItem) ViewGroup(android.view.ViewGroup) G(net.iGap.G) Color(android.graphics.Color) Gravity(android.view.Gravity) Nullable(androidx.annotation.Nullable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) FragmentSecurityViewModel(net.iGap.viewmodel.FragmentSecurityViewModel) Fragment(androidx.fragment.app.Fragment) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) R(net.iGap.R) LayoutCreator(net.iGap.helper.LayoutCreator) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) NotNull(org.jetbrains.annotations.NotNull) FragmentFragmentSecurityBinding(net.iGap.databinding.FragmentFragmentSecurityBinding) HelperFragment(net.iGap.helper.HelperFragment) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) DataBindingUtil(androidx.databinding.DataBindingUtil) ToolbarItem(net.iGap.messenger.ui.toolBar.ToolbarItem) Bundle(android.os.Bundle) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) HelperFragment(net.iGap.helper.HelperFragment) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 10 with BackDrawable

use of net.iGap.messenger.ui.toolBar.BackDrawable 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));
}
Also used : IVandActivityAdapter(net.iGap.adapter.IVandActivityAdapter) ArrayList(java.util.ArrayList) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) RecyclerView(androidx.recyclerview.widget.RecyclerView) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Aggregations

BackDrawable (net.iGap.messenger.ui.toolBar.BackDrawable)32 Toolbar (net.iGap.messenger.ui.toolBar.Toolbar)28 ViewGroup (android.view.ViewGroup)10 RecyclerView (androidx.recyclerview.widget.RecyclerView)10 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)9 HelperFragment (net.iGap.helper.HelperFragment)9 Bundle (android.os.Bundle)7 View (android.view.View)7 ArrayList (java.util.ArrayList)7 Intent (android.content.Intent)6 TextView (android.widget.TextView)6 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)6 SuppressLint (android.annotation.SuppressLint)5 NonNull (androidx.annotation.NonNull)5 Fragment (androidx.fragment.app.Fragment)5 DialogAction (com.afollestad.materialdialogs.DialogAction)5 AnimatorSet (android.animation.AnimatorSet)4 FrameLayout (android.widget.FrameLayout)4 ToolbarItem (net.iGap.messenger.ui.toolBar.ToolbarItem)4 Theme (net.iGap.module.Theme)4