Java Code Examples for org.telegram.messenger.MessagesStorage#IntCallback

The following examples show how to use org.telegram.messenger.MessagesStorage#IntCallback . 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: AlertsCreator.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public static AlertDialog.Builder createContactsPermissionDialog(final Activity parentActivity, final MessagesStorage.IntCallback callback)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
    builder.setTopImage(R.drawable.permissions_contacts, Theme.getColor(Theme.key_dialogTopBackground));
    builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("ContactsPermissionAlert", R.string.ContactsPermissionAlert)));
    builder.setPositiveButton(LocaleController.getString("ContactsPermissionAlertContinue", R.string.ContactsPermissionAlertContinue), (dialog, which) -> callback.run(1));
    builder.setNegativeButton(LocaleController.getString("ContactsPermissionAlertNotNow", R.string.ContactsPermissionAlertNotNow), (dialog, which) -> callback.run(0));
    return builder;
}
 
Example 2
Source File: AlertsCreator.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public static AlertDialog.Builder createContactsPermissionDialog(final Activity parentActivity, final MessagesStorage.IntCallback callback)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
    builder.setTopImage(R.drawable.permissions_contacts, Theme.getColor(Theme.key_dialogTopBackground));
    builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("ContactsPermissionAlert", R.string.ContactsPermissionAlert)));
    builder.setPositiveButton(LocaleController.getString("ContactsPermissionAlertContinue", R.string.ContactsPermissionAlertContinue), (dialog, which) -> callback.run(1));
    builder.setNegativeButton(LocaleController.getString("ContactsPermissionAlertNotNow", R.string.ContactsPermissionAlertNotNow), (dialog, which) -> callback.run(0));
    return builder;
}
 
Example 3
Source File: AlertsCreator.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static AlertDialog.Builder createContactsPermissionDialog(final Activity parentActivity, final MessagesStorage.IntCallback callback) {
    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
    builder.setTopImage(R.drawable.permissions_contacts, Theme.getColor(Theme.key_dialogTopBackground));
    builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("ContactsPermissionAlert", R.string.ContactsPermissionAlert)));
    builder.setPositiveButton(LocaleController.getString("ContactsPermissionAlertContinue", R.string.ContactsPermissionAlertContinue), (dialog, which) -> callback.run(1));
    builder.setNegativeButton(LocaleController.getString("ContactsPermissionAlertNotNow", R.string.ContactsPermissionAlertNotNow), (dialog, which) -> callback.run(0));
    return builder;
}
 
Example 4
Source File: AlertsCreator.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public static AlertDialog.Builder createContactsPermissionDialog(final Activity parentActivity, final MessagesStorage.IntCallback callback) {
    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
    builder.setTopImage(R.drawable.permissions_contacts, Theme.getColor(Theme.key_dialogTopBackground));
    builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("ContactsPermissionAlert", R.string.ContactsPermissionAlert)));
    builder.setPositiveButton(LocaleController.getString("ContactsPermissionAlertContinue", R.string.ContactsPermissionAlertContinue), (dialog, which) -> callback.run(1));
    builder.setNegativeButton(LocaleController.getString("ContactsPermissionAlertNotNow", R.string.ContactsPermissionAlertNotNow), (dialog, which) -> callback.run(0));
    return builder;
}
 
Example 5
Source File: AlertsCreator.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public static Dialog createLocationUpdateDialog(final Activity parentActivity, TLRPC.User user, final MessagesStorage.IntCallback callback)
{
    final int selected[] = new int[1];

    String[] descriptions = new String[]{
            LocaleController.getString("SendLiveLocationFor15m", R.string.SendLiveLocationFor15m),
            LocaleController.getString("SendLiveLocationFor1h", R.string.SendLiveLocationFor1h),
            LocaleController.getString("SendLiveLocationFor8h", R.string.SendLiveLocationFor8h),
    };

    final LinearLayout linearLayout = new LinearLayout(parentActivity);
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    TextView titleTextView = new TextView(parentActivity);
    if (user != null)
    {
        titleTextView.setText(LocaleController.formatString("LiveLocationAlertPrivate", R.string.LiveLocationAlertPrivate, UserObject.getFirstName(user)));
    }
    else
    {
        titleTextView.setText(LocaleController.getString("LiveLocationAlertGroup", R.string.LiveLocationAlertGroup));
    }
    titleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    titleTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    linearLayout.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 0, 24, 8));

    for (int a = 0; a < descriptions.length; a++)
    {
        RadioColorCell cell = new RadioColorCell(parentActivity);
        cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
        cell.setTag(a);
        cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
        cell.setTextAndValue(descriptions[a], selected[0] == a);
        linearLayout.addView(cell);
        cell.setOnClickListener(v ->
        {
            int num = (Integer) v.getTag();
            selected[0] = num;
            int count = linearLayout.getChildCount();
            for (int a1 = 0; a1 < count; a1++)
            {
                View child = linearLayout.getChildAt(a1);
                if (child instanceof RadioColorCell)
                {
                    ((RadioColorCell) child).setChecked(child == v, true);
                }
            }
        });
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
    builder.setTopImage(new ShareLocationDrawable(parentActivity, false), Theme.getColor(Theme.key_dialogTopBackground));
    builder.setView(linearLayout);
    builder.setPositiveButton(LocaleController.getString("ShareFile", R.string.ShareFile), (dialog, which) ->
    {
        int time;
        if (selected[0] == 0)
        {
            time = 15 * 60;
        }
        else if (selected[0] == 1)
        {
            time = 60 * 60;
        }
        else
        {
            time = 8 * 60 * 60;
        }
        callback.run(time);
    });
    builder.setNeutralButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    return builder.create();
}
 
Example 6
Source File: AlertsCreator.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public static Dialog createLocationUpdateDialog(final Activity parentActivity, TLRPC.User user, final MessagesStorage.IntCallback callback)
{
    final int selected[] = new int[1];

    String[] descriptions = new String[]{
            LocaleController.getString("SendLiveLocationFor15m", R.string.SendLiveLocationFor15m),
            LocaleController.getString("SendLiveLocationFor1h", R.string.SendLiveLocationFor1h),
            LocaleController.getString("SendLiveLocationFor8h", R.string.SendLiveLocationFor8h),
    };

    final LinearLayout linearLayout = new LinearLayout(parentActivity);
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    TextView titleTextView = new TextView(parentActivity);
    if (user != null)
    {
        titleTextView.setText(LocaleController.formatString("LiveLocationAlertPrivate", R.string.LiveLocationAlertPrivate, UserObject.getFirstName(user)));
    }
    else
    {
        titleTextView.setText(LocaleController.getString("LiveLocationAlertGroup", R.string.LiveLocationAlertGroup));
    }
    titleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    titleTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    linearLayout.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 0, 24, 8));

    for (int a = 0; a < descriptions.length; a++)
    {
        RadioColorCell cell = new RadioColorCell(parentActivity);
        cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
        cell.setTag(a);
        cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
        cell.setTextAndValue(descriptions[a], selected[0] == a);
        linearLayout.addView(cell);
        cell.setOnClickListener(v ->
        {
            int num = (Integer) v.getTag();
            selected[0] = num;
            int count = linearLayout.getChildCount();
            for (int a1 = 0; a1 < count; a1++)
            {
                View child = linearLayout.getChildAt(a1);
                if (child instanceof RadioColorCell)
                {
                    ((RadioColorCell) child).setChecked(child == v, true);
                }
            }
        });
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
    builder.setTopImage(new ShareLocationDrawable(parentActivity, false), Theme.getColor(Theme.key_dialogTopBackground));
    builder.setView(linearLayout);
    builder.setPositiveButton(LocaleController.getString("ShareFile", R.string.ShareFile), (dialog, which) ->
    {
        int time;
        if (selected[0] == 0)
        {
            time = 15 * 60;
        }
        else if (selected[0] == 1)
        {
            time = 60 * 60;
        }
        else
        {
            time = 8 * 60 * 60;
        }
        callback.run(time);
    });
    builder.setNeutralButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    return builder.create();
}
 
Example 7
Source File: AlertsCreator.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public static void showCustomNotificationsDialog(BaseFragment parentFragment, long did, int globalType, ArrayList<NotificationsSettingsActivity.NotificationException> exceptions, int currentAccount, MessagesStorage.IntCallback callback) {
    showCustomNotificationsDialog(parentFragment, did, globalType, exceptions, currentAccount, callback, null);
}
 
Example 8
Source File: AlertsCreator.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public static Dialog createLocationUpdateDialog(final Activity parentActivity, TLRPC.User user, final MessagesStorage.IntCallback callback) {
    final int[] selected = new int[1];

    String[] descriptions = new String[]{
            LocaleController.getString("SendLiveLocationFor15m", R.string.SendLiveLocationFor15m),
            LocaleController.getString("SendLiveLocationFor1h", R.string.SendLiveLocationFor1h),
            LocaleController.getString("SendLiveLocationFor8h", R.string.SendLiveLocationFor8h),
    };

    final LinearLayout linearLayout = new LinearLayout(parentActivity);
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    TextView titleTextView = new TextView(parentActivity);
    if (user != null) {
        titleTextView.setText(LocaleController.formatString("LiveLocationAlertPrivate", R.string.LiveLocationAlertPrivate, UserObject.getFirstName(user)));
    } else {
        titleTextView.setText(LocaleController.getString("LiveLocationAlertGroup", R.string.LiveLocationAlertGroup));
    }
    titleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    titleTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    linearLayout.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 0, 24, 8));

    for (int a = 0; a < descriptions.length; a++) {
        RadioColorCell cell = new RadioColorCell(parentActivity);
        cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
        cell.setTag(a);
        cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
        cell.setTextAndValue(descriptions[a], selected[0] == a);
        linearLayout.addView(cell);
        cell.setOnClickListener(v -> {
            int num = (Integer) v.getTag();
            selected[0] = num;
            int count = linearLayout.getChildCount();
            for (int a1 = 0; a1 < count; a1++) {
                View child = linearLayout.getChildAt(a1);
                if (child instanceof RadioColorCell) {
                    ((RadioColorCell) child).setChecked(child == v, true);
                }
            }
        });
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
    builder.setTopImage(new ShareLocationDrawable(parentActivity, 0), Theme.getColor(Theme.key_dialogTopBackground));
    builder.setView(linearLayout);
    builder.setPositiveButton(LocaleController.getString("ShareFile", R.string.ShareFile), (dialog, which) -> {
        int time;
        if (selected[0] == 0) {
            time = 15 * 60;
        } else if (selected[0] == 1) {
            time = 60 * 60;
        } else {
            time = 8 * 60 * 60;
        }
        callback.run(time);
    });
    builder.setNeutralButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    return builder.create();
}
 
Example 9
Source File: AlertsCreator.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public static void showCustomNotificationsDialog(BaseFragment parentFragment, long did, int globalType, ArrayList<NotificationsSettingsActivity.NotificationException> exceptions, int currentAccount, MessagesStorage.IntCallback callback) {
    showCustomNotificationsDialog(parentFragment, did, globalType, exceptions, currentAccount, callback, null);
}
 
Example 10
Source File: AlertsCreator.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public static Dialog createLocationUpdateDialog(final Activity parentActivity, TLRPC.User user, final MessagesStorage.IntCallback callback) {
    final int[] selected = new int[1];

    String[] descriptions = new String[]{
            LocaleController.getString("SendLiveLocationFor15m", R.string.SendLiveLocationFor15m),
            LocaleController.getString("SendLiveLocationFor1h", R.string.SendLiveLocationFor1h),
            LocaleController.getString("SendLiveLocationFor8h", R.string.SendLiveLocationFor8h),
    };

    final LinearLayout linearLayout = new LinearLayout(parentActivity);
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    TextView titleTextView = new TextView(parentActivity);
    if (user != null) {
        titleTextView.setText(LocaleController.formatString("LiveLocationAlertPrivate", R.string.LiveLocationAlertPrivate, UserObject.getFirstName(user)));
    } else {
        titleTextView.setText(LocaleController.getString("LiveLocationAlertGroup", R.string.LiveLocationAlertGroup));
    }
    titleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    titleTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    linearLayout.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 0, 24, 8));

    for (int a = 0; a < descriptions.length; a++) {
        RadioColorCell cell = new RadioColorCell(parentActivity);
        cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
        cell.setTag(a);
        cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
        cell.setTextAndValue(descriptions[a], selected[0] == a);
        linearLayout.addView(cell);
        cell.setOnClickListener(v -> {
            int num = (Integer) v.getTag();
            selected[0] = num;
            int count = linearLayout.getChildCount();
            for (int a1 = 0; a1 < count; a1++) {
                View child = linearLayout.getChildAt(a1);
                if (child instanceof RadioColorCell) {
                    ((RadioColorCell) child).setChecked(child == v, true);
                }
            }
        });
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
    builder.setTopImage(new ShareLocationDrawable(parentActivity, 0), Theme.getColor(Theme.key_dialogTopBackground));
    builder.setView(linearLayout);
    builder.setPositiveButton(LocaleController.getString("ShareFile", R.string.ShareFile), (dialog, which) -> {
        int time;
        if (selected[0] == 0) {
            time = 15 * 60;
        } else if (selected[0] == 1) {
            time = 60 * 60;
        } else {
            time = 8 * 60 * 60;
        }
        callback.run(time);
    });
    builder.setNeutralButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    return builder.create();
}