Search in sources :

Example 26 with Toolbar

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

the class FragmentWebView method setupToolbar.

private void setupToolbar(View view) {
    webViewToolbar = new Toolbar(getContext());
    webViewToolbar.setBackIcon(new BackDrawable(false));
    webViewToolbar.setTitle(getString(R.string.igap));
    ViewGroup layoutToolbar = view.findViewById(R.id.fwv_layout_toolbar);
    layoutToolbar.addView(webViewToolbar);
    webViewToolbar.setListener(i -> {
        if (i == -1) {
            onBackClicked();
        }
    });
}
Also used : ViewGroup(android.view.ViewGroup) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 27 with Toolbar

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

the class ChargeFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    scrollView = view.findViewById(R.id.scroll_payment);
    contactButton = view.findViewById(R.id.frame_contact);
    historyButton = view.findViewById(R.id.frame_history);
    buttonAmount = view.findViewById(R.id.choose_amount);
    buttonChargeType = view.findViewById(R.id.btn_charge_type);
    amountPlusButton = view.findViewById(R.id.add_amount);
    amountMinesButton = view.findViewById(R.id.low_amount);
    editTextNumber = view.findViewById(R.id.phoneNumber);
    buttonEnter = view.findViewById(R.id.btn_pay);
    progressBar = view.findViewById(R.id.loadingView);
    iconRemove = view.findViewById(R.id.btnRemoveSearch);
    recyclerViewOperator = view.findViewById(R.id.lstOperator);
    imageViewAvatar = view.findViewById(R.id.avatar);
    compositeDisposable = new CompositeDisposable();
    chargeApi = new RetrofitFactory().getChargeRetrofit();
    progressBar.setVisibility(View.VISIBLE);
    // get phoneNumber AND peerId
    Bundle bundle = this.getArguments();
    if (bundle != null) {
        phoneNumber = bundle.getString("phoneNumber", "");
        peerId = bundle.getLong("peerId", 0);
    }
    // init toolbar
    FrameLayout toolbarContainer = view.findViewById(R.id.charge_toolbar);
    Toolbar toolbar = new Toolbar(requireContext());
    toolbar.setTitle(getString(R.string.buy_charge));
    toolbar.setBackIcon(new BackDrawable(false));
    toolbarContainer.addView(toolbar, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 64, Gravity.TOP));
    toolbar.setListener(i -> {
        if (i == -1) {
            getActivity().onBackPressed();
        }
    });
    if (G.themeColor == Theme.DARK) {
        historyButton.setBackground(getContext().getResources().getDrawable(R.drawable.shape_payment_charge_dark));
        contactButton.setBackground(getContext().getResources().getDrawable(R.drawable.shape_payment_charge_dark));
    }
    paymentRepository = PaymentRepository.getInstance();
    paymentRepository.getConfigs(TokenContainer.getInstance().getToken(), config -> {
        if (config != null) {
            this.config = config;
            initForm();
        }
    });
    favoriteNumberCall = chargeApi.getFavoriteChargeNUmber();
}
Also used : Bundle(android.os.Bundle) FrameLayout(android.widget.FrameLayout) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) RetrofitFactory(net.iGap.api.apiService.RetrofitFactory) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 28 with Toolbar

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

the class InternetFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Bundle bundle = this.getArguments();
    if (bundle != null) {
        phoneNumber = bundle.getString("phoneNumber", "");
        peerId = bundle.getLong("peerId", 0);
    }
    frameContact = view.findViewById(R.id.frame_contact);
    frameHistory = view.findViewById(R.id.frame_history);
    editTextNumber = view.findViewById(R.id.phoneNumber);
    goNextButton = view.findViewById(R.id.btn_nextpage);
    radioGroup = view.findViewById(R.id.rdGroup);
    progressBar = view.findViewById(R.id.loadingView);
    removeButton = view.findViewById(R.id.btnRemoveSearch);
    lstOperator = view.findViewById(R.id.lstOperator);
    scrollView = view.findViewById(R.id.scroll_payment);
    avatar = view.findViewById(R.id.avatar);
    toolbarContainer = view.findViewById(R.id.toolbar);
    toolbar = new Toolbar(getContext());
    toolbar.setTitle(getString(R.string.buy_internet_package_title));
    toolbar.setBackIcon(new BackDrawable(false));
    toolbarContainer.addView(toolbar, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 64, Gravity.TOP));
    toolbar.setListener(i -> {
        if (i == -1) {
            getActivity().onBackPressed();
        }
    });
    lstOperator.setLayoutManager(new GridLayoutManager(getContext(), 3, RecyclerView.VERTICAL, false));
    if (G.themeColor == Theme.DARK) {
        frameHistory.setBackground(getContext().getResources().getDrawable(R.drawable.shape_payment_charge_dark));
        frameContact.setBackground(getContext().getResources().getDrawable(R.drawable.shape_payment_charge_dark));
    }
    String userToken = TokenContainer.getInstance().getToken();
    paymentRepository = PaymentRepository.getInstance();
    progressBar.setVisibility(View.VISIBLE);
    paymentRepository.getConfigs(userToken, config -> {
        if (config != null && getActivity() != null) {
            this.config = config;
            initForm();
        }
    });
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) Bundle(android.os.Bundle) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 29 with Toolbar

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

the class QRCodePaymentFragment method initToolbar.

@SuppressLint("ResourceType")
private void initToolbar() {
    mToolbar = new Toolbar(getActivity());
    mToolbar.setTitle(G.isAppRtl ? R.string.logo_igap_fa : R.string.logo_igap_en);
    mToolbar.setBackIcon(new BackDrawable(false));
    mToolbar.setListener(i -> {
        if (i == -1) {
            getActivity().onBackPressed();
        }
    });
    mBinding.toolbarContainer.addView(mToolbar, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 64, Gravity.TOP));
}
Also used : BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) SuppressLint(android.annotation.SuppressLint)

Example 30 with Toolbar

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

the class RegisteredContactsFragment method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable final Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    if (getContext() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        StatusBarUtil.setColor(getActivity(), new Theme().getPrimaryDarkColor(getContext()), 50);
    }
    G.onContactImport = this;
    G.onUserContactdelete = this;
    G.onContactsGetList = this;
    tryRequest = 0;
    realmRecyclerView = view.findViewById(R.id.recycler_view);
    FrameLayout toolbarLayout = view.findViewById(R.id.frg_contact_ll_toolbar_layout);
    contactsToolbar = new Toolbar(getContext());
    mediaContainer = new FragmentMediaContainer(getContext(), this);
    mediaContainer.setListener(i -> {
        switch(i) {
            case FragmentMediaContainer.CALL_TAG:
                getActivity().startActivity(new Intent(getContext(), CallActivity.class));
                break;
            case FragmentMediaContainer.MEDIA_TAG:
                if (!MusicPlayer.isVoice) {
                    Intent intent = new Intent(context, ActivityMain.class);
                    intent.putExtra(ActivityMain.openMediaPlayer, true);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    getActivity().startActivity(intent);
                }
                break;
            case FragmentMediaContainer.PLAY_TAG:
                break;
        }
    });
    ToolbarItems toolbarItems = contactsToolbar.createToolbarItems();
    contactsToolbar.setTitle(getString(R.string.contacts));
    contactsToolbar.setBackIcon(new BackDrawable(false));
    if (isContact) {
        ToolbarItem moreItem = toolbarItems.addItemWithWidth(moreItemTag, R.string.icon_other_vertical_dots, 54);
        addItem = moreItem.addSubItem(addUserTag, R.string.icon_add, getResources().getString(R.string.menu_add_contact));
        moreItem.addSubItem(syncContactTag, R.string.icon_beeptunes_sync, getResources().getString(R.string.sync_contact));
        moreItem.addSubItem(inviteContactTag, R.string.icon_add_contact, getResources().getString(R.string.Invite_Friends));
        if (PassCode.getInstance().isPassCode()) {
            passCodeItem = toolbarItems.addItemWithWidth(passCodeTag, R.string.icon_unlock, 54);
        }
    }
    searchItem = toolbarItems.addItemWithWidth(searchTag, R.string.icon_search, 54).setIsSearchBox(true).setActionBarMenuItemSearchListener(new ToolbarItem.ActionBarMenuItemSearchListener() {

        @Override
        public void onSearchExpand() {
            isSearchEnabled = true;
            inSearchMode = true;
        }

        @Override
        public void onSearchCollapse() {
            isSearchEnabled = false;
            inSearchMode = false;
            loadContacts();
        }

        @Override
        public void onTextChanged(EditText editText) {
            String text = null;
            try {
                text = java.net.URLDecoder.decode(editText.getText().toString(), "UTF-8");
                if (text.length() > 0) {
                    searchText = text;
                    loadContact(text);
                } else {
                    loadContacts();
                }
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
    });
    if (!isContact) {
        contactsToolbar.setBackIcon(new BackDrawable(false));
        toolbarItems.addItemWithWidth(addUserTag, R.string.icon_add_contact, 54);
    } else {
        toolbarItems.addItemWithWidth(codeScannerTag, R.string.icon_QR_code, 54);
    }
    if (mPageMode == CALL) {
        contactsToolbar.setTitle(getString(R.string.make_call));
    } else if (mPageMode == ADD) {
        contactsToolbar.setTitle(getString(R.string.create_chat));
    }
    createActionMode();
    toolbarLayout.addView(mediaContainer, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 38, Gravity.BOTTOM, 0, 60, 0, 0));
    toolbarLayout.addView(contactsToolbar);
    contactsToolbar.setListener(i -> {
        switch(i) {
            case -1:
                if (!isContact) {
                    if (!contactsToolbar.isSearchFieldVisible()) {
                        popBackStackFragment();
                    }
                } else {
                    if (isMultiSelect) {
                        contactsToolbar.hideActionToolbar();
                        contactsToolbar.setBackIcon(new BackDrawable(false));
                        setMultiSelectState(isMultiSelect);
                    } else {
                        if (!isSearchEnabled) {
                            requireActivity().onBackPressed();
                        }
                    }
                }
                break;
            case editTag:
                if (results != null) {
                    for (RealmContacts realmContacts : results) {
                        if (realmContacts.getPhone() == (Long) selectedList.keySet().toArray()[0]) {
                            FragmentAddContact fragment = FragmentAddContact.newInstance(realmContacts.getId(), "+" + realmContacts.getPhone(), realmContacts.getFirst_name(), realmContacts.getLast_name(), FragmentAddContact.ContactMode.EDIT, (name1, family1) -> loadContacts());
                            if (getActivity() != null)
                                new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
                            contactsToolbar.hideActionToolbar();
                            setMultiSelectState(isMultiSelect);
                            contactsToolbar.setBackIcon(null);
                            return;
                        }
                    }
                }
                break;
            case deleteTag:
                new MaterialDialog.Builder(G.fragmentActivity).title(R.string.to_delete_contact).content(R.string.delete_text).positiveText(R.string.B_ok).onPositive((dialog, which) -> {
                    for (ArrayMap.Entry<Long, Boolean> entry : selectedList.entrySet()) {
                        new RequestUserContactsDelete().contactsDelete("" + entry.getKey());
                    }
                    setMultiSelectState(true);
                    contactsToolbar.hideActionToolbar();
                    contactsToolbar.setBackIcon(null);
                }).negativeText(R.string.B_cancel).show();
                break;
            case addUserTag:
                if (mActionMode != null) {
                    mActionMode.finish();
                }
                if (getActivity() != null) {
                    FragmentAddContact fragment = FragmentAddContact.newInstance(null, FragmentAddContact.ContactMode.ADD);
                    new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
                }
                break;
            case multiSelectTag:
                showDialog();
                break;
            case codeScannerTag:
                onCodeScannerClickListener();
                break;
            case syncContactTag:
                if (isMultiSelect)
                    setMultiSelectState(true);
                ContactUtils.syncContacts();
                break;
            case inviteContactTag:
                try {
                    HelperPermission.getContactPermision(getContext(), new OnGetPermission() {

                        @Override
                        public void Allow() {
                            HelperTracker.sendTracker(HelperTracker.TRACKER_INVITE_FRIEND);
                            new HelperFragment(getActivity().getSupportFragmentManager(), new LocalContactFragment()).setReplace(false).load();
                        }

                        @Override
                        public void deny() {
                            showDeniedPermissionMessage(G.context.getString(R.string.permission_contact));
                        }
                    });
                } catch (IOException e) {
                    e.printStackTrace();
                }
                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;
        }
    });
    if (isContact) {
        Contacts.localPhoneContactId = 0;
        Contacts.getContact = true;
    }
    prgMainLoader = view.findViewById(R.id.fc_loader_main);
    btnAddNewGroupCall = view.findViewById(R.id.menu_layout_new_group_call);
    btnDialNumber = view.findViewById(R.id.menu_layout_btn_dial_number);
    btnAddNewGroup = view.findViewById(R.id.menu_layout_add_new_group);
    btnAddNewChannel = view.findViewById(R.id.menu_layout_add_new_channel);
    fastScroller = view.findViewById(R.id.fs_contact_fastScroller);
    prgWaitingLoadList = view.findViewById(R.id.prgWaiting_loadList);
    realmRecyclerView.setAdapter(new ContactListAdapter());
    if (!inSearchMode)
        loadContacts();
    switch(mPageMode) {
        case CALL:
            btnDialNumber.setVisibility(View.GONE);
            if (addItem != null) {
            // addItem.setVisibility(View.GONE);
            }
            break;
        case ADD:
            btnAddNewChannel.setVisibility(View.VISIBLE);
            btnAddNewGroup.setVisibility(View.VISIBLE);
            break;
        case CONTACTS:
    }
    realmRecyclerView = view.findViewById(R.id.recycler_view);
    realmRecyclerView.setLayoutManager(new ScrollingLinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false, 1000));
    realmRecyclerView.setNestedScrollingEnabled(false);
    fastScroller.setRecyclerView(realmRecyclerView);
    onClickRecyclerView = (v, position) -> {
        if (isMultiSelect) {
            multi_select(position);
        }
    };
    onLongClickRecyclerView = (v, position) -> {
        if (!isMultiSelect) {
            isMultiSelect = true;
            refreshAdapter(0, true);
            if (!contactsToolbar.isInActionMode()) {
                setPageShowingMode(4);
            }
        }
        multi_select(position);
    };
    try {
        if (getPermission && isContact) {
            getPermission = false;
            HelperPermission.getContactPermision(getContext(), new OnGetPermission() {

                @Override
                public void Allow() throws IOException {
                    /**
                     * if contacts size is zero send request for get contacts list
                     * for insure that contacts not exist really or not
                     */
                    LoginActions.importContact();
                    prgMainLoader.setVisibility(View.GONE);
                }

                @Override
                public void deny() {
                    if (results.size() == 0) {
                        new RequestUserContactsGetList().userContactGetList();
                    }
                    prgMainLoader.setVisibility(View.GONE);
                }
            });
        } else {
            if (results.size() == 0) {
                LoginActions.importContact();
            }
            prgMainLoader.setVisibility(View.GONE);
        }
    } catch (IOException e) {
        e.printStackTrace();
        prgMainLoader.setVisibility(View.GONE);
    }
    btnAddNewChannel.setOnClickListener(v -> {
        if (getActivity() != null) {
            FragmentNewGroup fragment = FragmentNewGroup.newInstance();
            Bundle bundle_ = new Bundle();
            bundle_.putString("TYPE", "NewChanel");
            fragment.setArguments(bundle_);
            new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
        }
    });
    btnAddNewGroup.setOnClickListener(v -> {
        if (getActivity() != null) {
            Fragment fragment = ContactGroupFragment.newInstance();
            Bundle bundle1 = new Bundle();
            bundle1.putLong("RoomId", -127);
            bundle1.putString("LIMIT", "5000");
            bundle1.putString("TYPE", ProtoGlobal.Room.Type.GROUP.name());
            bundle1.putBoolean("NewRoom", true);
            fragment.setArguments(bundle1);
            if (FragmentNewGroup.onRemoveFragmentNewGroup != null) {
                Log.wtf(this.getClass().getName(), "onRemoveFragmentNewGroup");
                FragmentNewGroup.onRemoveFragmentNewGroup.onRemove();
            }
            new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
        }
    });
    btnDialNumber.setOnClickListener(v -> {
        if (getActivity() != null) {
            new HelperFragment(getActivity().getSupportFragmentManager(), new DailNumberFragment()).setReplace(false).load();
        }
    });
    // todo: fixed it ,effect in load time
    if (isMultiSelect) {
        refreshAdapter(0, true);
        if (!contactsToolbar.isInActionMode()) {
            Log.wtf(this.getClass().getName(), "setPageShowingMode 4");
            setPageShowingMode(4);
        }
        isLongClick = true;
    }
}
Also used : ScrollingLinearLayoutManager(net.iGap.module.ScrollingLinearLayoutManager) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) CallActivity(net.iGap.activities.CallActivity) Fragment(androidx.fragment.app.Fragment) BottomSheetFragment(net.iGap.module.dialog.bottomsheet.BottomSheetFragment) HelperFragment(net.iGap.helper.HelperFragment) ScanCodeQRCodePaymentFragment(net.iGap.fragments.qrCodePayment.fragments.ScanCodeQRCodePaymentFragment) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) ToolbarItem(net.iGap.messenger.ui.toolBar.ToolbarItem) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) EditText(android.widget.EditText) FragmentMediaContainer(net.iGap.messenger.ui.components.FragmentMediaContainer) Bundle(android.os.Bundle) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ArrayMap(androidx.collection.ArrayMap) Intent(android.content.Intent) IOException(java.io.IOException) RequestUserContactsDelete(net.iGap.request.RequestUserContactsDelete) FrameLayout(android.widget.FrameLayout) ToolbarItems(net.iGap.messenger.ui.toolBar.ToolbarItems) Theme(net.iGap.module.Theme) RequestUserContactsGetList(net.iGap.request.RequestUserContactsGetList) HelperFragment(net.iGap.helper.HelperFragment) RealmContacts(net.iGap.realm.RealmContacts)

Aggregations

Toolbar (net.iGap.messenger.ui.toolBar.Toolbar)30 BackDrawable (net.iGap.messenger.ui.toolBar.BackDrawable)29 ViewGroup (android.view.ViewGroup)11 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)11 HelperFragment (net.iGap.helper.HelperFragment)10 Bundle (android.os.Bundle)8 RecyclerView (androidx.recyclerview.widget.RecyclerView)8 Intent (android.content.Intent)7 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)7 FrameLayout (android.widget.FrameLayout)6 Nullable (androidx.annotation.Nullable)6 Fragment (androidx.fragment.app.Fragment)6 View (android.view.View)5 NonNull (androidx.annotation.NonNull)5 DialogAction (com.afollestad.materialdialogs.DialogAction)5 ToolbarItem (net.iGap.messenger.ui.toolBar.ToolbarItem)5 ToolbarItems (net.iGap.messenger.ui.toolBar.ToolbarItems)5 Theme (net.iGap.module.Theme)5 SuppressLint (android.annotation.SuppressLint)4 Gravity (android.view.Gravity)4