Search in sources :

Example 11 with Toolbar

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

the class FragmentLanguage method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    languageToolbar = new Toolbar(getContext());
    languageToolbar.setBackIcon(new BackDrawable(false));
    languageToolbar.setTitle(getString(R.string.language));
    languageToolbar.setListener(i -> {
        switch(i) {
            case -1:
                popBackStackFragment();
                break;
        }
    });
    binding.flLayoutToolbar.addView(languageToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
    viewModel.getRefreshActivityForChangeLanguage().observe(getViewLifecycleOwner(), language -> {
        if (getActivity() instanceof ActivityEnhanced && language != null) {
            G.updateResources(getActivity().getBaseContext());
            if (G.twoPaneMode) {
                Fragment frg;
                frg = getActivity().getSupportFragmentManager().findFragmentById(R.id.mainFrame);
                FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
                ft.detach(frg);
                ft.attach(frg);
                ft.commit();
            }
            /*((ActivityEnhanced) getActivity()).onRefreshActivity(false, language);*/
            /*if (getActivity() instanceof ActivityRegistration) {*/
            getActivity().onBackPressed();
        /*}*/
        }
    });
    viewModel.getGoBack().observe(getViewLifecycleOwner(), isGoBack -> {
        if (isGoBack != null && isGoBack) {
            removeFromBaseFragment(this);
        }
    });
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) ActivityEnhanced(net.iGap.activities.ActivityEnhanced) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) Fragment(androidx.fragment.app.Fragment) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 12 with Toolbar

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

the class FragmentPrivacyAndSecurity method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    privacyAndSecurityToolbar = new Toolbar(getContext());
    privacyAndSecurityToolbar.setBackIcon(new BackDrawable(false));
    privacyAndSecurityToolbar.setTitle(getString(R.string.st_title_Privacy_Security));
    privacyAndSecurityToolbar.setListener(i -> {
        switch(i) {
            case -1:
                popBackStackFragment();
                break;
        }
    });
    fragmentPrivacyAndSecurityBinding.fpsLayoutToolbar.addView(privacyAndSecurityToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
    new RequestUserContactsGetBlockedList().userContactsGetBlockedList();
    RealmPrivacy.getUpdatePrivacyFromServer();
    fragmentPrivacyAndSecurityBinding.parentPrivacySecurity.setOnClickListener(view1 -> {
    });
    new RequestUserProfileGetSelfRemove().userProfileGetSelfRemove();
    fragmentPrivacyAndSecurityViewModel.goToBlockedUserPage.observe(getViewLifecycleOwner(), go -> {
        if (getActivity() != null && go != null && go) {
            new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentBlockedUser()).setReplace(false).load();
        }
    });
    fragmentPrivacyAndSecurityViewModel.goToPassCodePage.observe(getViewLifecycleOwner(), go -> {
        if (getActivity() != null && go != null && go) {
            new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentPassCode()).setReplace(false).load();
        }
    });
    fragmentPrivacyAndSecurityViewModel.goToSecurityPage.observe(getViewLifecycleOwner(), go -> {
        if (getActivity() != null && go != null && go) {
            new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentSecurity()).setReplace(false).load();
        }
    });
    fragmentPrivacyAndSecurityViewModel.goToActiveSessionsPage.observe(getViewLifecycleOwner(), go -> {
        if (getActivity() != null && go != null && go) {
            new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentActiveSessions()).setReplace(false).load();
        }
    });
}
Also used : RequestUserProfileGetSelfRemove(net.iGap.request.RequestUserProfileGetSelfRemove) RequestUserContactsGetBlockedList(net.iGap.request.RequestUserContactsGetBlockedList) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) HelperFragment(net.iGap.helper.HelperFragment) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 13 with Toolbar

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

the class FragmentPassCode method onViewCreated.

@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    initDataBinding();
    passCodeToolbar = new Toolbar(getContext());
    passCodeToolbar.setBackIcon(new BackDrawable(false));
    passCodeToolbar.setTitle(getString(R.string.two_step_pass_code));
    ToolbarItem toolbarItem;
    toolbarItem = passCodeToolbar.addItem(rippleOkTag, R.string.icon_sent, Color.WHITE);
    passCodeToolbar.setListener(i -> {
        switch(i) {
            case -1:
                popBackStackFragment();
                AppUtils.closeKeyboard(view);
                break;
            case rippleOkTag:
                fragmentPassCodeViewModel.onClickRippleOk(view);
                break;
        }
    });
    fragmentPassCodeBinding.fpcLayoutToolbar.addView(passCodeToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
    toolbarItem.setVisibility(View.GONE);
    // observe to show tick (ok) button or not
    fragmentPassCodeViewModel.rippleOkVisibility.observe(getViewLifecycleOwner(), visibility -> {
        if (visibility != null) {
            if (visibility == View.VISIBLE) {
                toolbarItem.setVisibility(View.VISIBLE);
            } else {
                toolbarItem.setVisibility(View.GONE);
            }
        }
    });
    fragmentPassCodeViewModel.passCodeStateChangeListener.observe(getViewLifecycleOwner(), aBoolean -> {
        if (getActivity() != null) {
            ((ActivityMain) getActivity()).updatePassCodeState();
        }
    });
    boolean isLinePattern;
    if (isPattern) {
        SharedPreferences sharedPreferences = G.currentActivity.getSharedPreferences(SHP_SETTING.FILE_NAME, MODE_PRIVATE);
        isLinePattern = sharedPreferences.getBoolean(SHP_SETTING.KEY_PATTERN_TACTILE_DRAWN, true);
    } else {
        isLinePattern = true;
    }
    // Set the current view more
    fragmentPassCodeBinding.patternLockView.setViewMode(PatternLockView.PatternViewMode.WRONG);
    // Set the pattern in stealth mode (pattern drawing is hidden)
    fragmentPassCodeBinding.patternLockView.setInStealthMode(!isLinePattern);
    // Enables vibration feedback when the pattern is drawn
    fragmentPassCodeBinding.patternLockView.setTactileFeedbackEnabled(true);
    // Disables any input from the pattern lock view completely
    fragmentPassCodeBinding.patternLockView.setInputEnabled(true);
}
Also used : ToolbarItem(net.iGap.messenger.ui.toolBar.ToolbarItem) ActivityMain(net.iGap.activities.ActivityMain) SharedPreferences(android.content.SharedPreferences) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 14 with Toolbar

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

the class FragmentChatSettings method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable 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);
    }
    chatSettingsToolbar = new Toolbar(getContext());
    chatSettingsToolbar.setBackIcon(new BackDrawable(false));
    chatSettingsToolbar.setTitle(getString(R.string.chat_setting));
    chatSettingsToolbar.setListener(i -> {
        switch(i) {
            case -1:
                popBackStackFragment();
                break;
        }
    });
    binding.fcsLayoutToolbar.addView(chatSettingsToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
    binding.themeColorList.setLayoutManager(new LinearLayoutManager(binding.themeColorList.getContext(), RecyclerView.HORIZONTAL, G.isAppRtl));
    binding.themeColorList.hasFixedSize();
    binding.themeColorList.setNestedScrollingEnabled(false);
    binding.themeColorList.setAdapter(adapter);
    viewModel.getChatBackground();
    setChatReceivedChatBubble(new Theme().getReceivedChatBubbleColor(getContext()));
    setChatSendBubble(new Theme().getSendChatBubbleColor(getContext()));
    if (getContext() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        StatusBarUtil.setColor(getActivity(), new Theme().getPrimaryDarkColor(getContext()), 50);
    }
    viewModel.getGoToChatBackgroundPage().observe(getViewLifecycleOwner(), go -> {
        if (getActivity() != null && go != null && go) {
            new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentChatBackground()).setReplace(false).load();
        }
    });
    viewModel.getGoToDateFragment().observe(getViewLifecycleOwner(), go -> {
        if (getActivity() != null && go != null && go)
            new HelperFragment(getActivity().getSupportFragmentManager(), new FragmentData()).setReplace(false).load();
    });
    viewModel.getThemeList().observe(getViewLifecycleOwner(), themeList -> {
        if (themeList != null && binding.themeColorList.getAdapter() instanceof ThemeColorListAdapter) {
            ((ThemeColorListAdapter) binding.themeColorList.getAdapter()).setData(themeList);
        }
    });
    viewModel.getSelectedThemePosition().observe(getViewLifecycleOwner(), selectedPosition -> {
        if (selectedPosition != null && binding.themeColorList.getAdapter() instanceof ThemeColorListAdapter) {
            ((ThemeColorListAdapter) binding.themeColorList.getAdapter()).setSelectedTheme(selectedPosition);
        }
    });
    viewModel.getUpdateNewTheme().observe(getViewLifecycleOwner(), isUpdate -> {
        if (getActivity() != null && isUpdate != null && isUpdate) {
            /*if (Theme.isUnderLollipop()) {
                    if (getActivity() instanceof ActivityEnhanced) {
                        ((ActivityEnhanced) getActivity()).onRefreshActivity(true, "");
                    }
                } else {*/
            Fragment frg;
            frg = getActivity().getSupportFragmentManager().findFragmentByTag(FragmentChatSettings.class.getName());
            FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
            ft.detach(frg);
            ft.attach(frg);
            ft.commit();
        /*}*/
        }
    });
    viewModel.getUpdateTwoPaneView().observe(getViewLifecycleOwner(), isUpdate -> {
        if (getActivity() != null && isUpdate != null && isUpdate) {
            Fragment frg;
            frg = getActivity().getSupportFragmentManager().findFragmentById(R.id.mainFrame);
            FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
            ft.detach(frg);
            ft.attach(frg);
            ft.commit();
        }
    });
    viewModel.getUpdateTextSizeSampleView().observe(getViewLifecycleOwner(), textSize -> {
        if (textSize != null) {
            binding.message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
            binding.senderMessage.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
        }
    });
    viewModel.getSetChatBackground().observe(getViewLifecycleOwner(), backgroundPath -> {
        if (getActivity() != null && backgroundPath != null) {
            File f = new File(backgroundPath);
            if (f.exists()) {
                try {
                    Log.wtf(this.getClass().getName(), "set image");
                    Drawable d = Drawable.createFromPath(f.getAbsolutePath());
                    binding.chatBackgroundImage.setImageDrawable(d);
                } catch (OutOfMemoryError e) {
                    ActivityManager activityManager = (ActivityManager) getActivity().getSystemService(ACTIVITY_SERVICE);
                    ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
                    activityManager.getMemoryInfo(memoryInfo);
                }
            } else {
                try {
                    binding.chatBackgroundImage.setImageResource(0);
                    binding.chatBackgroundImage.setBackgroundColor(Color.parseColor(backgroundPath));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    });
    viewModel.getSetChatBackgroundDefault().observe(getViewLifecycleOwner(), drawableRes -> {
        if (drawableRes != null) {
            binding.chatBackgroundImage.setImageResource(R.drawable.chat_default_background_pattern);
        }
    });
}
Also used : Drawable(android.graphics.drawable.Drawable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ActivityManager(android.app.ActivityManager) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) ThemeColorListAdapter(net.iGap.adapter.ThemeColorListAdapter) FragmentTransaction(androidx.fragment.app.FragmentTransaction) Theme(net.iGap.module.Theme) HelperFragment(net.iGap.helper.HelperFragment) File(java.io.File) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Example 15 with Toolbar

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

the class FragmentActiveSessions method onViewCreated.

@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    languageToolbar = new Toolbar(getContext());
    languageToolbar.setBackIcon(new BackDrawable(false));
    languageToolbar.setTitle(getString(R.string.Active_Sessions));
    languageToolbar.setListener(i -> {
        switch(i) {
            case -1:
                removeFromBaseFragment(FragmentActiveSessions.this);
                break;
        }
    });
    ViewGroup layoutToolbar = view.findViewById(R.id.fas_layout_toolbar);
    layoutToolbar.addView(languageToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
    prgWaiting = view.findViewById(R.id.stas_prgWaiting);
    AppUtils.setProgresColler(prgWaiting);
    prgWaiting.setVisibility(View.VISIBLE);
    fastItemAdapter = new FastItemAdapter();
    rcvContent = view.findViewById(R.id.stas_rcvContent);
    rcvContent.setLayoutManager(new LinearLayoutManager(rcvContent.getContext()));
    rcvContent.setItemAnimator(new DefaultItemAnimator());
    rcvContent.setAdapter(fastItemAdapter);
    G.onUserSessionGetActiveList = session -> G.handler.post(() -> {
        for (int i = 0; i < session.size(); i++) {
            StructSessions item = new StructSessions();
            item.setSessionId(session.get(i).getSessionId());
            item.setName(session.get(i).getAppName());
            item.setAppId(session.get(i).getAppId());
            item.setBuildVersion(session.get(i).getAppBuildVersion());
            item.setAppVersion(session.get(i).getAppVersion());
            item.setPlatform(session.get(i).getPlatform());
            item.setPlatformVersion(session.get(i).getPlatformVersion());
            item.setDevice(session.get(i).getDevice());
            item.setDeviceName(session.get(i).getDeviceName());
            item.setLanguage(session.get(i).getLanguage());
            item.setCountry(session.get(i).getCountry());
            item.setCurrent(session.get(i).getCurrent());
            item.setCreateTime(session.get(i).getCreateTime());
            item.setActiveTime(session.get(i).getActiveTime());
            item.setIp(session.get(i).getIp());
            if (item.isCurrent()) {
                structItems.add(0, item);
            } else {
                structItems.add(item);
            }
            list.add(item);
        }
        itemAdapter();
    });
    new RequestUserSessionGetActiveList().userSessionGetActiveList();
    G.onUserSessionTerminate = new OnUserSessionTerminate() {

        @Override
        public void onUserSessionTerminate(final Long messageId) {
            G.handler.post(() -> {
                G.fragmentActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
                prgWaiting.setVisibility(View.GONE);
                for (int i = 0; i < list.size(); i++) {
                    if (list.get(i).getSessionId() == messageId) {
                        int j = fastItemAdapter.getPosition(list.get(i).getSessionId());
                        if (j >= 0) {
                            fastItemAdapter.remove(j);
                            list.remove(i);
                        }
                    }
                }
            });
        }

        @Override
        public void onTimeOut() {
            G.handler.post(() -> {
                G.fragmentActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
                prgWaiting.setVisibility(View.GONE);
                HelperError.showSnackMessage(G.fragmentActivity.getResources().getString(R.string.error), false);
            });
        }

        @Override
        public void onError() {
            G.handler.post(() -> {
                G.fragmentActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
                prgWaiting.setVisibility(View.GONE);
                HelperError.showSnackMessage(G.fragmentActivity.getResources().getString(R.string.error), false);
            });
        }
    };
    fastItemAdapter.withSelectable(true);
    fastItemAdapter.withOnClickListener((v, adapter, item, position) -> {
        if (item instanceof AdapterActiveSessions) {
            if (((AdapterActiveSessions) item).getItem().isCurrent()) {
            } else {
                new MaterialDialog.Builder(G.fragmentActivity).title(R.string.active_session_title).content(R.string.active_session_content).positiveText(R.string.yes).negativeText(R.string.no).onPositive(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        prgWaiting.setVisibility(View.VISIBLE);
                        G.fragmentActivity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
                        new RequestUserSessionTerminate().userSessionTerminate(((AdapterActiveSessions) item).getItem().getSessionId());
                    }
                }).show();
            }
        } else {
            final int size = list.size();
            if (size > 1) {
                new MaterialDialog.Builder(G.fragmentActivity).title(R.string.active_session_all_title).content(R.string.active_session_all_content).positiveText(R.string.yes).negativeText(R.string.no).onPositive(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        // click on AdapterActiveSessionsHeader
                        v.setVisibility(View.GONE);
                        for (int i = 0; i < size; i++) {
                            if (!list.get(i).isCurrent()) {
                                new RequestUserSessionTerminate().userSessionTerminate(list.get(i).getSessionId());
                            }
                        }
                    }
                }).show();
            }
        }
        return false;
    });
}
Also used : RequestUserSessionTerminate(net.iGap.request.RequestUserSessionTerminate) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ViewGroup(android.view.ViewGroup) FastItemAdapter(com.mikepenz.fastadapter.commons.adapters.FastItemAdapter) OnUserSessionTerminate(net.iGap.observers.interfaces.OnUserSessionTerminate) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) AdapterActiveSessions(net.iGap.adapter.items.AdapterActiveSessions) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(androidx.annotation.NonNull) StructSessions(net.iGap.module.structs.StructSessions) RequestUserSessionGetActiveList(net.iGap.request.RequestUserSessionGetActiveList) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

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