Search in sources :

Example 1 with FragmentChat

use of net.iGap.fragments.FragmentChat in project iGap-Android by KianIranian-STDG.

the class GoToChatActivity method startActivity.

public void startActivity(FragmentActivity activity) {
    String roomName = "";
    if (FragmentChat.mForwardMessages != null || HelperGetDataFromOtherApp.hasSharedData || FragmentChat.structIGSticker != null) {
        roomName = DbManager.getInstance().doRealmTask(realm -> {
            RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", roomid).findFirst();
            if (realmRoom != null) {
                if (realmRoom.getReadOnly() || hasSendMessagePermission() || (realmRoom.getType() != ProtoGlobal.Room.Type.CHAT && FragmentChat.structIGSticker != null) || (realmRoom.getType() == ProtoGlobal.Room.Type.CHAT && realmRoom.getChatRoom() != null && RealmRoom.isBot(realmRoom.getChatRoom().getPeerId()))) {
                    if (activity != null && !(activity).isFinishing()) {
                        new MaterialDialog.Builder(activity).title(R.string.dialog_readonly_chat).positiveText(R.string.ok).show();
                    }
                    return null;
                }
                return realmRoom.getTitle();
            } else if (peerID > 0) {
                RealmRegisteredInfo _RegisteredInfo = RealmRegisteredInfo.getRegistrationInfo(realm, peerID);
                if (_RegisteredInfo != null) {
                    return _RegisteredInfo.getDisplayName();
                }
            }
            return "";
        });
        if (roomName == null) {
            return;
        }
    }
    if (HelperGetDataFromOtherApp.hasSharedData) {
        String message = G.context.getString(R.string.send_message_to) + " " + roomName;
        MaterialDialog.Builder mDialog = new MaterialDialog.Builder(activity).title(message).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {

            @Override
            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                FragmentChat fragmentChat = new FragmentChat();
                fragmentChat.setArguments(getBundle());
                fragmentChatBackStack(activity);
                new HelperFragment(activity.getSupportFragmentManager(), fragmentChat).setReplace(false).load();
            }
        }).onNegative((dialog, which) -> {
            HelperGetDataFromOtherApp.hasSharedData = false;
            // revert main rooms list from share mode
            if (activity instanceof ActivityMain) {
                ((ActivityMain) activity).checkHasSharedData(false);
            }
        }).neutralText(R.string.another_room).onNeutral((dialog, which) -> dialog.dismiss());
        if (!activity.isFinishing()) {
            mDialog.show();
        }
    } else if (FragmentChat.structIGSticker != null) {
        String message = G.context.getString(R.string.send_message_to) + " " + roomName;
        MaterialDialog.Builder mDialog = new MaterialDialog.Builder(activity).title(message).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive((dialog, which) -> {
            FragmentChat fragmentChat = new FragmentChat();
            fragmentChat.setArguments(getBundle());
            fragmentChatBackStack(activity);
            new HelperFragment(activity.getSupportFragmentManager(), fragmentChat).setReplace(false).load();
        }).onNegative((dialog, which) -> {
            FragmentChat.structIGSticker = null;
            if (activity instanceof ActivityMain) {
                ((ActivityMain) activity).checkHasSharedData(false);
            }
        }).neutralText(R.string.another_room).onNeutral((dialog, which) -> dialog.dismiss());
        if (!activity.isFinishing()) {
            mDialog.show();
        }
    } else if (FragmentChat.mForwardMessages != null) {
        String message = G.context.getString(R.string.send_forward_to) + " " + roomName + "?";
        MaterialDialog.Builder mDialog = new MaterialDialog.Builder(activity).title(message).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {

            @Override
            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                loadChatFragment(activity);
            }
        }).onNegative((dialog, which) -> {
            disableForwardMessage(activity);
            FragmentChat.mForwardMessages = null;
        }).neutralText(R.string.another_room).onNeutral((dialog, which) -> dialog.dismiss());
        if (!(activity).isFinishing()) {
            mDialog.show();
        }
    } else {
        loadChatFragment(activity);
    }
}
Also used : Bundle(android.os.Bundle) RealmRoomAccess(net.iGap.realm.RealmRoomAccess) ActivityMain(net.iGap.activities.ActivityMain) NonNull(androidx.annotation.NonNull) AccountManager(net.iGap.module.accountManager.AccountManager) DialogAction(com.afollestad.materialdialogs.DialogAction) RealmRoom(net.iGap.realm.RealmRoom) FragmentActivity(androidx.fragment.app.FragmentActivity) G(net.iGap.G) Lifecycle(androidx.lifecycle.Lifecycle) List(java.util.List) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) FragmentChat(net.iGap.fragments.FragmentChat) Fragment(androidx.fragment.app.Fragment) ProtoGlobal(net.iGap.proto.ProtoGlobal) R(net.iGap.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DbManager(net.iGap.module.accountManager.DbManager) Log(android.util.Log) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) ActivityMain(net.iGap.activities.ActivityMain) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(androidx.annotation.NonNull) RealmRoom(net.iGap.realm.RealmRoom) FragmentChat(net.iGap.fragments.FragmentChat)

Example 2 with FragmentChat

use of net.iGap.fragments.FragmentChat in project iGap-Android by KianIranian-STDG.

the class ActivityMain method removeAllFragmentFromMain.

public void removeAllFragmentFromMain() {
    if (G.twoPaneMode) {
        findViewById(R.id.fullScreenFrame).setVisibility(View.GONE);
        Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.mainFrame);
        if (fragment instanceof FragmentChat) {
            getSupportFragmentManager().beginTransaction().remove(fragment).commit();
        }
        getSupportFragmentManager().popBackStack(TabletEmptyChatFragment.class.getName(), 0);
    } else {
        getSupportFragmentManager().popBackStackImmediate(BottomNavigationFragment.class.getName(), 0);
    }
}
Also used : BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) TabletEmptyChatFragment(net.iGap.fragments.TabletEmptyChatFragment) FragmentChat(net.iGap.fragments.FragmentChat) PaymentFragment(net.iGap.fragments.PaymentFragment) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) OpenFragment(net.iGap.observers.interfaces.OpenFragment) TabletEmptyChatFragment(net.iGap.fragments.TabletEmptyChatFragment) BaseFragment(net.iGap.fragments.BaseFragment) CameraStoryFragment(net.iGap.story.CameraStoryFragment) CallSelectFragment(net.iGap.fragments.CallSelectFragment) SearchFragment(net.iGap.fragments.SearchFragment) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment) BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment)

Example 3 with FragmentChat

use of net.iGap.fragments.FragmentChat in project iGap-Android by KianIranian-STDG.

the class ActivityMain method setViewConfigurationChanged.

private void setViewConfigurationChanged() {
    if (G.twoPaneMode) {
        if (G.isLandscape) {
            Log.wtf(this.getClass().getName(), "isLandscape");
            findViewById(R.id.mainFrame).setVisibility(View.VISIBLE);
            findViewById(R.id.roomListFrame).setVisibility(View.VISIBLE);
        } else {
            Log.wtf(this.getClass().getName(), "not Landscape");
            Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.mainFrame);
            if (fragment instanceof FragmentChat) {
                findViewById(R.id.roomListFrame).setVisibility(View.GONE);
            } else {
                findViewById(R.id.mainFrame).setVisibility(View.GONE);
            }
        }
    }
}
Also used : FragmentChat(net.iGap.fragments.FragmentChat) PaymentFragment(net.iGap.fragments.PaymentFragment) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) OpenFragment(net.iGap.observers.interfaces.OpenFragment) TabletEmptyChatFragment(net.iGap.fragments.TabletEmptyChatFragment) BaseFragment(net.iGap.fragments.BaseFragment) CameraStoryFragment(net.iGap.story.CameraStoryFragment) CallSelectFragment(net.iGap.fragments.CallSelectFragment) SearchFragment(net.iGap.fragments.SearchFragment) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment) BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment)

Example 4 with FragmentChat

use of net.iGap.fragments.FragmentChat in project iGap-Android by KianIranian-STDG.

the class ActivityMain method onActivityResult.

/*private void getWallpaperAsDefault() {
        try {
            RealmWallpaper realmWallpaper = DbManager.getInstance().doRealmTask(realm -> {
                return realm.where(RealmWallpaper.class).equalTo("type", ProtoInfoWallpaper.InfoWallpaper.Type.CHAT_BACKGROUND_VALUE).findFirst();
            });
            if (realmWallpaper != null) {
                if (realmWallpaper.getWallPaperList() != null && realmWallpaper.getWallPaperList().size() > 0) {
                    RealmAttachment pf = realmWallpaper.getWallPaperList().get(realmWallpaper.getWallPaperList().size() - 1).getFile();
                    String bigImagePath = G.DIR_CHAT_BACKGROUND + "/" + pf.getCacheId() + "_" + pf.getName();
                    if (!new File(bigImagePath).exists()) {
                        HelperDownloadFile.getInstance().startDownload(ProtoGlobal.RoomMessageType.IMAGE, System.currentTimeMillis() + "", pf.getToken(), pf.getUrl(), pf.getCacheId(), pf.getName(), pf.getSize(), ProtoFileDownload.FileDownload.Selector.FILE, bigImagePath, 2, new HelperDownloadFile.UpdateListener() {
                            @Override
                            public void OnProgress(String mPath, final int progress) {

                                if (progress == 100) {
                                    setDefaultBackground(bigImagePath);
                                }

                            }

                            @Override
                            public void OnError(String token) {
                            }
                        });

                    } else {
                        setDefaultBackground(bigImagePath);

                    }
                } else {
                    getImageListFromServer();
                }
            } else {
                getImageListFromServer();
            }
        } catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
        } catch (NullPointerException e2) {
            e2.printStackTrace();
        } catch (Exception e3) {
            e3.printStackTrace();
        }

    }*/
/*private void setDefaultBackground(String bigImagePath) {
        String finalPath = "";
        try {
            finalPath = HelperSaveFile.saveInPrivateDirectory(this, bigImagePath);
        } catch (IOException e) {
            e.printStackTrace();
        }
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(SHP_SETTING.KEY_PATH_CHAT_BACKGROUND, finalPath);
        editor.putBoolean(SHP_SETTING.KEY_CHAT_BACKGROUND_IS_DEFAULT, true);
        editor.apply();
    }*/
/*private void getImageListFromServer() {
        Log.e("wallpaper", "request in main ");
        G.onGetWallpaper = new OnGetWallpaper() {
            @Override
            public void onGetWallpaperList(final List<ProtoGlobal.Wallpaper> list) {
                Log.e("wallpaper", "resp in main");
                RealmWallpaper.updateField(list, "", ProtoInfoWallpaper.InfoWallpaper.Type.CHAT_BACKGROUND_VALUE);
                G.handler.post(new Runnable() {
                    @Override
                    public void run() {
                        getWallpaperAsDefault();
                    }
                });
            }
        };

        new RequestInfoWallpaper().infoWallpaper(ProtoInfoWallpaper.InfoWallpaper.Type.CHAT_BACKGROUND);
    }*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch(requestCode) {
        case DirectPayHelper.requestCodeDirectPay:
            int errorType = 0;
            switch(resultCode) {
                case 1:
                    /*
                        for example:
                        enData:{"PayInfo":null,"PayData":"cHeOCQFF+29LUGXpTnzpz1yofTqgK+pP0ojhabaKEqUSBvzFuhf86bhUnsPCeMOdRkwzeYnmygZyNhWTmvJ8bc9qJSl7xidX0QV5yMG7wxAfIPaZWiUV8TlRhWyzMUWSS1MW8CGF07yfYHnD7SuwNucsHN3VatM2nwWOu4UXvco=","DataSign":"mhVO8u4Wime9Yh\/abvZskpi3jZdhfmuyLbYnqnjte9jmGGAHWXthDJLhN8Jfl65Wq9OTDIM51+nmQSZokqBCM8YFuMYOdrNLffbRHB5ZEKIAu+acYJhx2XdV\/7N6h9h2iMa77eaC0m0FKhYHlVNK5TDZc8Mz55o2swIhS37Beik=","AutoConfirm":false}
                        message:مبلغ تراکنش کمتر از حد تعیین شده توسط صادرکننده کارت و یا بیشتر از حد مجاز می باشد
                        status:61
                         */
                    DirectPayHelper.setResultOfDirectPay(data.getStringExtra("enData"), 0, null, data.getStringExtra("message"));
                    break;
                case 2:
                    errorType = data.getIntExtra("errorType", 0);
                    break;
                case 5:
                    errorType = data.getIntExtra("errorType", 0);
                    break;
            }
            if (errorType != 0) {
                showErrorTypeMpl(errorType);
            }
            break;
        case CardToCardHelper.requestCodeCardToCard:
            String message = "";
            switch(resultCode) {
                case 2:
                    message = getString(R.string.dialog_canceled);
                    break;
                case 3:
                    message = getString(R.string.server_error);
                    break;
                case 1:
                    break;
            }
            if (data != null && data.getIntExtra("errorType", 0) != 0) {
                message = getErrorTypeMpl(data.getIntExtra("errorType", 0));
            } else {
                if (data != null && data.getStringExtra("message") != null && !data.getStringExtra("message").equals("")) {
                    message = data.getStringExtra("message");
                }
            }
            if (data != null && data.getStringExtra("enData") != null && !data.getStringExtra("enData").equals("")) {
                CardToCardHelper.setResultOfCardToCard(data.getStringExtra("enData"), 0, null, message);
            } else {
                if (message.length() > 0) {
                    HelperError.showSnackMessage(message, false);
                }
            }
            break;
        case requestCodePaymentCharge:
        case requestCodePaymentBill:
            getPaymentResultCode(resultCode, data);
            break;
        case requestCodeQrCode:
            IntentResult result = IntentIntegrator.parseActivityResult(resultCode, data);
            if (result.getContents() != null) {
                new RequestUserVerifyNewDevice().verifyNewDevice(result.getContents());
            }
            break;
        case kuknosRequestCodeQrCode:
            break;
        case WALLET_REQUEST_CODE:
            break;
        case UserScoreViewModel.REQUEST_CODE_QR_IVAND_CODE:
            IntentResult result2 = IntentIntegrator.parseActivityResult(resultCode, data);
            if (result2.getContents() != null) {
                doIvandScore(result2.getContents(), ActivityMain.this);
            }
            break;
        case ERROR_DIALOG_REQUEST_CODE:
            // Adding a fragment via GoogleApiAvailability.showErrorDialogFragment
            // before the instance state is restored throws an error. So instead,
            // set a flag here, which will cause the fragment to delay until
            // onPostResume.
            retryProviderInstall = true;
            break;
        case AttachFile.request_code_trim_video:
            if (resultCode == RESULT_OK) {
                Fragment fragmentGallery = getSupportFragmentManager().findFragmentById(G.twoPaneMode ? R.id.detailFrame : R.id.mainFrame);
                if (fragmentGallery instanceof FragmentGallery) {
                    getSupportFragmentManager().popBackStack();
                    getSupportFragmentManager().popBackStack();
                    goneDetailFrameInTabletMode();
                    Fragment fragmentChat = getSupportFragmentManager().findFragmentByTag(FragmentChat.class.getName());
                    if (fragmentChat instanceof FragmentChat) {
                        ((FragmentChat) fragmentChat).manageTrimVideoResult(data);
                    } else {
                        // todo:// fix fragment chat backstack
                        if (dataTransformer != null) {
                            dataTransformer.transform(AttachFile.request_code_trim_video, data);
                        }
                    }
                }
            }
            break;
        case AttachFile.REQUEST_CODE_PICK_FILE_FROM_INTENT:
            EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.ON_FILE_PICKED_FROM_INTENT, data);
    }
}
Also used : FragmentGallery(net.iGap.fragments.FragmentGallery) IntentResult(com.google.zxing.integration.android.IntentResult) RequestUserVerifyNewDevice(net.iGap.request.RequestUserVerifyNewDevice) FragmentChat(net.iGap.fragments.FragmentChat) PaymentFragment(net.iGap.fragments.PaymentFragment) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) OpenFragment(net.iGap.observers.interfaces.OpenFragment) TabletEmptyChatFragment(net.iGap.fragments.TabletEmptyChatFragment) BaseFragment(net.iGap.fragments.BaseFragment) CameraStoryFragment(net.iGap.story.CameraStoryFragment) CallSelectFragment(net.iGap.fragments.CallSelectFragment) SearchFragment(net.iGap.fragments.SearchFragment) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment) BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) SuppressLint(android.annotation.SuppressLint)

Example 5 with FragmentChat

use of net.iGap.fragments.FragmentChat in project iGap-Android by KianIranian-STDG.

the class HelperFragment method removeAll.

public void removeAll(boolean keepMain) {
    /*if (G.fragmentActivity != null && !G.fragmentActivity.isFinishing()) {*/
    if (fragmentManager != null) {
        if (G.twoPaneMode) {
            Fragment fragment = fragmentManager.findFragmentById(R.id.mainFrame);
            if (fragment instanceof FragmentChat) {
                fragmentManager.beginTransaction().remove(fragment).commit();
            }
            fragmentManager.popBackStack(TabletEmptyChatFragment.class.getName(), 0);
        } else {
            fragmentManager.popBackStack(BottomNavigationFragment.class.getName(), 0);
        }
    }
/*for (int i = fragmentManager.getBackStackEntryCount() - 1; i > -1; i--) {

        }*/
/*for (Fragment fragment : fragmentManager.getFragments()) {
            if (fragment != null) {

                if (keepMain) {
                    if (fragment.getClass().getName().equals(FragmentMain.class.getName())) {
                        continue;
                    }
                    if (fragment.getClass().getName().equals(DiscoveryFragment.class.getName())) {
                        if (fragment.getArguments().getInt("page") == 0) {
                            continue;
                        }
                    }
                    if (fragment instanceof FragmentCall) {
                        if (fragment.getArguments().getBoolean(OPEN_IN_FRAGMENT_MAIN)) {
                            continue;
                        }
                    }

                    fragmentManager.beginTransaction().remove(fragment).commit();
                } else {
                    fragmentManager.beginTransaction().remove(fragment).commit();
                }
            }
        }
        fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);*/
/*}*/
/*if (G.iTowPanModDesinLayout != null) {
            G.iTowPanModDesinLayout.onLayout(ActivityMain.chatLayoutMode.none);
        }*/
}
Also used : BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) TabletEmptyChatFragment(net.iGap.fragments.TabletEmptyChatFragment) FragmentChat(net.iGap.fragments.FragmentChat) EditChannelFragment(net.iGap.fragments.EditChannelFragment) PaymentFragment(net.iGap.fragments.PaymentFragment) Fragment(androidx.fragment.app.Fragment) BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) EditGroupFragment(net.iGap.fragments.EditGroupFragment) TabletEmptyChatFragment(net.iGap.fragments.TabletEmptyChatFragment)

Aggregations

FragmentChat (net.iGap.fragments.FragmentChat)8 Fragment (androidx.fragment.app.Fragment)7 BottomNavigationFragment (net.iGap.fragments.BottomNavigationFragment)6 PaymentFragment (net.iGap.fragments.PaymentFragment)6 TabletEmptyChatFragment (net.iGap.fragments.TabletEmptyChatFragment)6 BaseFragment (net.iGap.fragments.BaseFragment)5 CallSelectFragment (net.iGap.fragments.CallSelectFragment)5 SearchFragment (net.iGap.fragments.SearchFragment)5 DiscoveryFragment (net.iGap.fragments.discovery.DiscoveryFragment)5 HelperFragment (net.iGap.helper.HelperFragment)5 OpenFragment (net.iGap.observers.interfaces.OpenFragment)5 CameraStoryFragment (net.iGap.story.CameraStoryFragment)5 ActivityMain (net.iGap.activities.ActivityMain)2 SuppressLint (android.annotation.SuppressLint)1 Bundle (android.os.Bundle)1 Log (android.util.Log)1 NonNull (androidx.annotation.NonNull)1 FragmentActivity (androidx.fragment.app.FragmentActivity)1 Lifecycle (androidx.lifecycle.Lifecycle)1 DialogAction (com.afollestad.materialdialogs.DialogAction)1