Java Code Examples for org.telegram.ui.Components.AlertsCreator#showSimpleAlert()

The following examples show how to use org.telegram.ui.Components.AlertsCreator#showSimpleAlert() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PeopleNearbyActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void openGroupCreate() {
    if (!canCreateGroup) {
        AlertsCreator.showSimpleAlert(PeopleNearbyActivity.this, LocaleController.getString("YourLocatedChannelsTooMuch", R.string.YourLocatedChannelsTooMuch));
        return;
    }
    groupCreateActivity = new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_NEARBY_GROUP_CREATE);
    groupCreateActivity.setGroupCreateAddress(currentGroupCreateAddress, currentGroupCreateDisplayAddress, currentGroupCreateLocation);
    presentFragment(groupCreateActivity);
}
 
Example 2
Source File: PeopleNearbyActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void openGroupCreate() {
    if (!canCreateGroup) {
        AlertsCreator.showSimpleAlert(PeopleNearbyActivity.this, LocaleController.getString("YourLocatedChannelsTooMuch", R.string.YourLocatedChannelsTooMuch));
        return;
    }
    groupCreateActivity = new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_NEARBY_GROUP_CREATE);
    groupCreateActivity.setGroupCreateAddress(currentGroupCreateAddress, currentGroupCreateDisplayAddress, currentGroupCreateLocation);
    presentFragment(groupCreateActivity);
}
 
Example 3
Source File: ThemeSetUrlActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private boolean checkUrl(final String url, boolean alert) {
    if (checkRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(checkRunnable);
        checkRunnable = null;
        lastCheckName = null;
        if (checkReqId != 0) {
            ConnectionsManager.getInstance(currentAccount).cancelRequest(checkReqId, true);
        }
    }
    lastNameAvailable = false;
    if (url != null) {
        if (url.startsWith("_") || url.endsWith("_")) {
            setCheckText(LocaleController.getString("SetUrlInvalid", R.string.SetUrlInvalid), Theme.key_windowBackgroundWhiteRedText4);
            return false;
        }
        for (int a = 0; a < url.length(); a++) {
            char ch = url.charAt(a);
            if (a == 0 && ch >= '0' && ch <= '9') {
                if (alert) {
                    AlertsCreator.showSimpleAlert(this, LocaleController.getString("Theme", R.string.Theme), LocaleController.getString("SetUrlInvalidStartNumber", R.string.SetUrlInvalidStartNumber));
                } else {
                    setCheckText(LocaleController.getString("SetUrlInvalidStartNumber", R.string.SetUrlInvalidStartNumber), Theme.key_windowBackgroundWhiteRedText4);
                }
                return false;
            }
            if (!(ch >= '0' && ch <= '9' || ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch == '_')) {
                if (alert) {
                    AlertsCreator.showSimpleAlert(this, LocaleController.getString("Theme", R.string.Theme), LocaleController.getString("SetUrlInvalid", R.string.SetUrlInvalid));
                } else {
                    setCheckText(LocaleController.getString("SetUrlInvalid", R.string.SetUrlInvalid), Theme.key_windowBackgroundWhiteRedText4);
                }
                return false;
            }
        }
    }
    if (url == null || url.length() < 5) {
        if (alert) {
            AlertsCreator.showSimpleAlert(this, LocaleController.getString("Theme", R.string.Theme), LocaleController.getString("SetUrlInvalidShort", R.string.SetUrlInvalidShort));
        } else {
            setCheckText(LocaleController.getString("SetUrlInvalidShort", R.string.SetUrlInvalidShort), Theme.key_windowBackgroundWhiteRedText4);
        }
        return false;
    }
    if (url.length() > 64) {
        if (alert) {
            AlertsCreator.showSimpleAlert(this, LocaleController.getString("Theme", R.string.Theme), LocaleController.getString("SetUrlInvalidLong", R.string.SetUrlInvalidLong));
        } else {
            setCheckText(LocaleController.getString("SetUrlInvalidLong", R.string.SetUrlInvalidLong), Theme.key_windowBackgroundWhiteRedText4);
        }
        return false;
    }

    if (!alert) {
        String currentUrl = info != null && info.slug != null ? info.slug : "";
        if (url.equals(currentUrl)) {
            setCheckText(LocaleController.formatString("SetUrlAvailable", R.string.SetUrlAvailable, url), Theme.key_windowBackgroundWhiteGreenText);
            return true;
        }

        setCheckText(LocaleController.getString("SetUrlChecking", R.string.SetUrlChecking), Theme.key_windowBackgroundWhiteGrayText8);
        lastCheckName = url;
        checkRunnable = () -> {
            TLRPC.TL_account_createTheme req = new TLRPC.TL_account_createTheme();
            req.slug = url;
            req.title = "";
            req.document = new TLRPC.TL_inputDocumentEmpty();
            checkReqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                checkReqId = 0;
                if (lastCheckName != null && lastCheckName.equals(url)) {
                    if (error == null || !"THEME_SLUG_INVALID".equals(error.text) && !"THEME_SLUG_OCCUPIED".equals(error.text)) {
                        setCheckText(LocaleController.formatString("SetUrlAvailable", R.string.SetUrlAvailable, url), Theme.key_windowBackgroundWhiteGreenText);
                        lastNameAvailable = true;
                    } else {
                        setCheckText(LocaleController.getString("SetUrlInUse", R.string.SetUrlInUse), Theme.key_windowBackgroundWhiteRedText4);
                        lastNameAvailable = false;
                    }
                }
            }), ConnectionsManager.RequestFlagFailOnServerErrors);
        };
        AndroidUtilities.runOnUIThread(checkRunnable, 300);
    }
    return true;
}
 
Example 4
Source File: ThemeSetUrlActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private boolean checkUrl(final String url, boolean alert) {
    if (checkRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(checkRunnable);
        checkRunnable = null;
        lastCheckName = null;
        if (checkReqId != 0) {
            ConnectionsManager.getInstance(currentAccount).cancelRequest(checkReqId, true);
        }
    }
    lastNameAvailable = false;
    if (url != null) {
        if (url.startsWith("_") || url.endsWith("_")) {
            setCheckText(LocaleController.getString("SetUrlInvalid", R.string.SetUrlInvalid), Theme.key_windowBackgroundWhiteRedText4);
            return false;
        }
        for (int a = 0; a < url.length(); a++) {
            char ch = url.charAt(a);
            if (a == 0 && ch >= '0' && ch <= '9') {
                if (alert) {
                    AlertsCreator.showSimpleAlert(this, LocaleController.getString("Theme", R.string.Theme), LocaleController.getString("SetUrlInvalidStartNumber", R.string.SetUrlInvalidStartNumber));
                } else {
                    setCheckText(LocaleController.getString("SetUrlInvalidStartNumber", R.string.SetUrlInvalidStartNumber), Theme.key_windowBackgroundWhiteRedText4);
                }
                return false;
            }
            if (!(ch >= '0' && ch <= '9' || ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch == '_')) {
                if (alert) {
                    AlertsCreator.showSimpleAlert(this, LocaleController.getString("Theme", R.string.Theme), LocaleController.getString("SetUrlInvalid", R.string.SetUrlInvalid));
                } else {
                    setCheckText(LocaleController.getString("SetUrlInvalid", R.string.SetUrlInvalid), Theme.key_windowBackgroundWhiteRedText4);
                }
                return false;
            }
        }
    }
    if (url == null || url.length() < 5) {
        if (alert) {
            AlertsCreator.showSimpleAlert(this, LocaleController.getString("Theme", R.string.Theme), LocaleController.getString("SetUrlInvalidShort", R.string.SetUrlInvalidShort));
        } else {
            setCheckText(LocaleController.getString("SetUrlInvalidShort", R.string.SetUrlInvalidShort), Theme.key_windowBackgroundWhiteRedText4);
        }
        return false;
    }
    if (url.length() > 64) {
        if (alert) {
            AlertsCreator.showSimpleAlert(this, LocaleController.getString("Theme", R.string.Theme), LocaleController.getString("SetUrlInvalidLong", R.string.SetUrlInvalidLong));
        } else {
            setCheckText(LocaleController.getString("SetUrlInvalidLong", R.string.SetUrlInvalidLong), Theme.key_windowBackgroundWhiteRedText4);
        }
        return false;
    }

    if (!alert) {
        String currentUrl = info != null && info.slug != null ? info.slug : "";
        if (url.equals(currentUrl)) {
            setCheckText(LocaleController.formatString("SetUrlAvailable", R.string.SetUrlAvailable, url), Theme.key_windowBackgroundWhiteGreenText);
            return true;
        }

        setCheckText(LocaleController.getString("SetUrlChecking", R.string.SetUrlChecking), Theme.key_windowBackgroundWhiteGrayText8);
        lastCheckName = url;
        checkRunnable = () -> {
            TLRPC.TL_account_createTheme req = new TLRPC.TL_account_createTheme();
            req.slug = url;
            req.title = "";
            req.document = new TLRPC.TL_inputDocumentEmpty();
            checkReqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                checkReqId = 0;
                if (lastCheckName != null && lastCheckName.equals(url)) {
                    if (error == null || !"THEME_SLUG_INVALID".equals(error.text) && !"THEME_SLUG_OCCUPIED".equals(error.text)) {
                        setCheckText(LocaleController.formatString("SetUrlAvailable", R.string.SetUrlAvailable, url), Theme.key_windowBackgroundWhiteGreenText);
                        lastNameAvailable = true;
                    } else {
                        setCheckText(LocaleController.getString("SetUrlInUse", R.string.SetUrlInUse), Theme.key_windowBackgroundWhiteRedText4);
                        lastNameAvailable = false;
                    }
                }
            }), ConnectionsManager.RequestFlagFailOnServerErrors);
        };
        AndroidUtilities.runOnUIThread(checkRunnable, 300);
    }
    return true;
}