Java Code Examples for org.telegram.messenger.AndroidUtilities#getTypeface()

The following examples show how to use org.telegram.messenger.AndroidUtilities#getTypeface() . 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: TextStyleSpan.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public Typeface getTypeface() {
    if ((flags & FLAG_STYLE_MONO) != 0 || (flags & FLAG_STYLE_QUOTE) != 0) {
        return Typeface.MONOSPACE;
    } else if ((flags & FLAG_STYLE_BOLD) != 0 && (flags & FLAG_STYLE_ITALIC) != 0) {
        return AndroidUtilities.getTypeface("fonts/rmediumitalic.ttf");
    } else if ((flags & FLAG_STYLE_BOLD) != 0) {
        return AndroidUtilities.getTypeface("fonts/rmedium.ttf");
    } else if ((flags & FLAG_STYLE_ITALIC) != 0) {
        return AndroidUtilities.getTypeface("fonts/ritalic.ttf");
    } else {
        return null;
    }
}
 
Example 2
Source File: TextStyleSpan.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public Typeface getTypeface() {
    if ((flags & FLAG_STYLE_MONO) != 0 || (flags & FLAG_STYLE_QUOTE) != 0) {
        return Typeface.MONOSPACE;
    } else if ((flags & FLAG_STYLE_BOLD) != 0 && (flags & FLAG_STYLE_ITALIC) != 0) {
        return AndroidUtilities.getTypeface("fonts/rmediumitalic.ttf");
    } else if ((flags & FLAG_STYLE_BOLD) != 0) {
        return AndroidUtilities.getTypeface("fonts/rmedium.ttf");
    } else if ((flags & FLAG_STYLE_ITALIC) != 0) {
        return AndroidUtilities.getTypeface("fonts/ritalic.ttf");
    } else {
        return null;
    }
}
 
Example 3
Source File: FragmentContextView.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void checkLocationString() {
    if (!(fragment instanceof ChatActivity) || titleTextView == null) {
        return;
    }
    ChatActivity chatActivity = (ChatActivity) fragment;
    long dialogId = chatActivity.getDialogId();
    int currentAccount = chatActivity.getCurrentAccount();
    ArrayList<TLRPC.Message> messages = LocationController.getInstance(currentAccount).locationsCache.get(dialogId);
    if (!firstLocationsLoaded) {
        LocationController.getInstance(currentAccount).loadLiveLocations(dialogId);
        firstLocationsLoaded = true;
    }

    int locationSharingCount = 0;
    TLRPC.User notYouUser = null;
    if (messages != null) {
        int currentUserId = UserConfig.getInstance(currentAccount).getClientUserId();
        int date = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
        for (int a = 0; a < messages.size(); a++) {
            TLRPC.Message message = messages.get(a);
            if (message.media == null) {
                continue;
            }
            if (message.date + message.media.period > date) {
                if (notYouUser == null && message.from_id != currentUserId) {
                    notYouUser = MessagesController.getInstance(currentAccount).getUser(message.from_id);
                }
                locationSharingCount++;
            }
        }
    }
    if (lastLocationSharingCount == locationSharingCount) {
        return;
    }
    lastLocationSharingCount = locationSharingCount;

    String liveLocation = LocaleController.getString("LiveLocationContext", R.string.LiveLocationContext);
    String fullString;
    if (locationSharingCount == 0) {
        fullString = liveLocation;
    } else {
        int otherSharingCount = locationSharingCount - 1;
        if (LocationController.getInstance(currentAccount).isSharingLocation(dialogId)) {
            if (otherSharingCount != 0) {
                if (otherSharingCount == 1 && notYouUser != null) {
                    fullString = String.format("%1$s - %2$s", liveLocation, LocaleController.formatString("SharingYouAndOtherName", R.string.SharingYouAndOtherName, UserObject.getFirstName(notYouUser)));
                } else {
                    fullString = String.format("%1$s - %2$s %3$s", liveLocation, LocaleController.getString("ChatYourSelfName", R.string.ChatYourSelfName), LocaleController.formatPluralString("AndOther", otherSharingCount));
                }
            } else {
                fullString = String.format("%1$s - %2$s", liveLocation, LocaleController.getString("ChatYourSelfName", R.string.ChatYourSelfName));
            }
        } else {
            if (otherSharingCount != 0) {
                fullString = String.format("%1$s - %2$s %3$s", liveLocation, UserObject.getFirstName(notYouUser), LocaleController.formatPluralString("AndOther", otherSharingCount));
            } else {
                fullString = String.format("%1$s - %2$s", liveLocation, UserObject.getFirstName(notYouUser));
            }
        }
    }
    if (fullString.equals(lastString)) {
        return;
    }
    lastString = fullString;
    int start = fullString.indexOf(liveLocation);
    SpannableStringBuilder stringBuilder = new SpannableStringBuilder(fullString);
    titleTextView.setEllipsize(TextUtils.TruncateAt.END);
    if (start >= 0) {
        TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), 0, Theme.getColor(Theme.key_inappPlayerPerformer));
        stringBuilder.setSpan(span, start, start + liveLocation.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    }
    titleTextView.setText(stringBuilder);
}
 
Example 4
Source File: TypefaceSpan.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public boolean isItalic() {
    return typeface == AndroidUtilities.getTypeface("fonts/ritalic.ttf");
}
 
Example 5
Source File: TypefaceSpan.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public boolean isBold() {
    return typeface == AndroidUtilities.getTypeface("fonts/rmedium.ttf");
}
 
Example 6
Source File: FragmentContextView.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void checkLocationString() {
    if (!(fragment instanceof ChatActivity) || titleTextView == null) {
        return;
    }
    ChatActivity chatActivity = (ChatActivity) fragment;
    long dialogId = chatActivity.getDialogId();
    int currentAccount = chatActivity.getCurrentAccount();
    ArrayList<TLRPC.Message> messages = LocationController.getInstance(currentAccount).locationsCache.get(dialogId);
    if (!firstLocationsLoaded) {
        LocationController.getInstance(currentAccount).loadLiveLocations(dialogId);
        firstLocationsLoaded = true;
    }

    int locationSharingCount = 0;
    TLRPC.User notYouUser = null;
    if (messages != null) {
        int currentUserId = UserConfig.getInstance(currentAccount).getClientUserId();
        int date = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
        for (int a = 0; a < messages.size(); a++) {
            TLRPC.Message message = messages.get(a);
            if (message.media == null) {
                continue;
            }
            if (message.date + message.media.period > date) {
                if (notYouUser == null && message.from_id != currentUserId) {
                    notYouUser = MessagesController.getInstance(currentAccount).getUser(message.from_id);
                }
                locationSharingCount++;
            }
        }
    }
    if (lastLocationSharingCount == locationSharingCount) {
        return;
    }
    lastLocationSharingCount = locationSharingCount;

    String liveLocation = LocaleController.getString("LiveLocationContext", R.string.LiveLocationContext);
    String fullString;
    if (locationSharingCount == 0) {
        fullString = liveLocation;
    } else {
        int otherSharingCount = locationSharingCount - 1;
        if (LocationController.getInstance(currentAccount).isSharingLocation(dialogId)) {
            if (otherSharingCount != 0) {
                if (otherSharingCount == 1 && notYouUser != null) {
                    fullString = String.format("%1$s - %2$s", liveLocation, LocaleController.formatString("SharingYouAndOtherName", R.string.SharingYouAndOtherName, UserObject.getFirstName(notYouUser)));
                } else {
                    fullString = String.format("%1$s - %2$s %3$s", liveLocation, LocaleController.getString("ChatYourSelfName", R.string.ChatYourSelfName), LocaleController.formatPluralString("AndOther", otherSharingCount));
                }
            } else {
                fullString = String.format("%1$s - %2$s", liveLocation, LocaleController.getString("ChatYourSelfName", R.string.ChatYourSelfName));
            }
        } else {
            if (otherSharingCount != 0) {
                fullString = String.format("%1$s - %2$s %3$s", liveLocation, UserObject.getFirstName(notYouUser), LocaleController.formatPluralString("AndOther", otherSharingCount));
            } else {
                fullString = String.format("%1$s - %2$s", liveLocation, UserObject.getFirstName(notYouUser));
            }
        }
    }
    if (fullString.equals(lastString)) {
        return;
    }
    lastString = fullString;
    int start = fullString.indexOf(liveLocation);
    SpannableStringBuilder stringBuilder = new SpannableStringBuilder(fullString);
    titleTextView.setEllipsize(TextUtils.TruncateAt.END);
    if (start >= 0) {
        TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), 0, Theme.getColor(Theme.key_inappPlayerPerformer));
        stringBuilder.setSpan(span, start, start + liveLocation.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    }
    titleTextView.setText(stringBuilder);
}
 
Example 7
Source File: TextStyleSpan.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public boolean isBoldItalic() {
    return style.getTypeface() == AndroidUtilities.getTypeface("fonts/rmediumitalic.ttf");
}
 
Example 8
Source File: TextStyleSpan.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public boolean isItalic() {
    return style.getTypeface() == AndroidUtilities.getTypeface("fonts/ritalic.ttf");
}
 
Example 9
Source File: TextStyleSpan.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public boolean isBold() {
    return style.getTypeface() == AndroidUtilities.getTypeface("fonts/rmedium.ttf");
}
 
Example 10
Source File: TypefaceSpan.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public boolean isItalic() {
    return typeface == AndroidUtilities.getTypeface("fonts/ritalic.ttf");
}
 
Example 11
Source File: TypefaceSpan.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public boolean isBold() {
    return typeface == AndroidUtilities.getTypeface("fonts/rmedium.ttf");
}
 
Example 12
Source File: FragmentContextView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void checkLocationString()
{
    if (!(fragment instanceof ChatActivity) || titleTextView == null)
    {
        return;
    }
    ChatActivity chatActivity = (ChatActivity) fragment;
    long dialogId = chatActivity.getDialogId();
    int currentAccount = chatActivity.getCurrentAccount();
    ArrayList<TLRPC.Message> messages = LocationController.getInstance(currentAccount).locationsCache.get(dialogId);
    if (!firstLocationsLoaded)
    {
        LocationController.getInstance(currentAccount).loadLiveLocations(dialogId);
        firstLocationsLoaded = true;
    }

    int locationSharingCount = 0;
    TLRPC.User notYouUser = null;
    if (messages != null)
    {
        int currentUserId = UserConfig.getInstance(currentAccount).getClientUserId();
        int date = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
        for (int a = 0; a < messages.size(); a++)
        {
            TLRPC.Message message = messages.get(a);
            if (message.media == null)
            {
                continue;
            }
            if (message.date + message.media.period > date)
            {
                if (notYouUser == null && message.from_id != currentUserId)
                {
                    notYouUser = MessagesController.getInstance(currentAccount).getUser(message.from_id);
                }
                locationSharingCount++;
            }
        }
    }
    if (lastLocationSharingCount == locationSharingCount)
    {
        return;
    }
    lastLocationSharingCount = locationSharingCount;

    String liveLocation = LocaleController.getString("AttachLiveLocation", R.string.AttachLiveLocation);
    String fullString;
    if (locationSharingCount == 0)
    {
        fullString = liveLocation;
    }
    else
    {
        int otherSharingCount = locationSharingCount - 1;
        if (LocationController.getInstance(currentAccount).isSharingLocation(dialogId))
        {
            if (otherSharingCount != 0)
            {
                if (otherSharingCount == 1 && notYouUser != null)
                {
                    fullString = String.format("%1$s - %2$s", liveLocation, LocaleController.formatString("SharingYouAndOtherName", R.string.SharingYouAndOtherName, UserObject.getFirstName(notYouUser)));
                }
                else
                {
                    fullString = String.format("%1$s - %2$s %3$s", liveLocation, LocaleController.getString("ChatYourSelfName", R.string.ChatYourSelfName), LocaleController.formatPluralString("AndOther", otherSharingCount));
                }
            }
            else
            {
                fullString = String.format("%1$s - %2$s", liveLocation, LocaleController.getString("ChatYourSelfName", R.string.ChatYourSelfName));
            }
        }
        else
        {
            if (otherSharingCount != 0)
            {
                fullString = String.format("%1$s - %2$s %3$s", liveLocation, UserObject.getFirstName(notYouUser), LocaleController.formatPluralString("AndOther", otherSharingCount));
            }
            else
            {
                fullString = String.format("%1$s - %2$s", liveLocation, UserObject.getFirstName(notYouUser));
            }
        }
    }
    if (lastString != null && fullString.equals(lastString))
    {
        return;
    }
    lastString = fullString;
    int start = fullString.indexOf(liveLocation);
    SpannableStringBuilder stringBuilder = new SpannableStringBuilder(fullString);
    titleTextView.setEllipsize(TextUtils.TruncateAt.END);
    if (start >= 0)
    {
        TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), 0, Theme.getColor(Theme.key_inappPlayerPerformer));
        stringBuilder.setSpan(span, start, start + liveLocation.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    }
    titleTextView.setText(stringBuilder);
}
 
Example 13
Source File: TextStyleSpan.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public boolean isBoldItalic() {
    return style.getTypeface() == AndroidUtilities.getTypeface("fonts/rmediumitalic.ttf");
}
 
Example 14
Source File: TextStyleSpan.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public boolean isItalic() {
    return style.getTypeface() == AndroidUtilities.getTypeface("fonts/ritalic.ttf");
}
 
Example 15
Source File: TextStyleSpan.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public boolean isBold() {
    return style.getTypeface() == AndroidUtilities.getTypeface("fonts/rmedium.ttf");
}
 
Example 16
Source File: TypefaceSpan.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public boolean isItalic() {
    return typeface == AndroidUtilities.getTypeface("fonts/ritalic.ttf");
}
 
Example 17
Source File: TypefaceSpan.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public boolean isBold() {
    return typeface == AndroidUtilities.getTypeface("fonts/rmedium.ttf");
}
 
Example 18
Source File: FragmentContextView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void checkLocationString()
{
    if (!(fragment instanceof ChatActivity) || titleTextView == null)
    {
        return;
    }
    ChatActivity chatActivity = (ChatActivity) fragment;
    long dialogId = chatActivity.getDialogId();
    int currentAccount = chatActivity.getCurrentAccount();
    ArrayList<TLRPC.Message> messages = LocationController.getInstance(currentAccount).locationsCache.get(dialogId);
    if (!firstLocationsLoaded)
    {
        LocationController.getInstance(currentAccount).loadLiveLocations(dialogId);
        firstLocationsLoaded = true;
    }

    int locationSharingCount = 0;
    TLRPC.User notYouUser = null;
    if (messages != null)
    {
        int currentUserId = UserConfig.getInstance(currentAccount).getClientUserId();
        int date = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
        for (int a = 0; a < messages.size(); a++)
        {
            TLRPC.Message message = messages.get(a);
            if (message.media == null)
            {
                continue;
            }
            if (message.date + message.media.period > date)
            {
                if (notYouUser == null && message.from_id != currentUserId)
                {
                    notYouUser = MessagesController.getInstance(currentAccount).getUser(message.from_id);
                }
                locationSharingCount++;
            }
        }
    }
    if (lastLocationSharingCount == locationSharingCount)
    {
        return;
    }
    lastLocationSharingCount = locationSharingCount;

    String liveLocation = LocaleController.getString("AttachLiveLocation", R.string.AttachLiveLocation);
    String fullString;
    if (locationSharingCount == 0)
    {
        fullString = liveLocation;
    }
    else
    {
        int otherSharingCount = locationSharingCount - 1;
        if (LocationController.getInstance(currentAccount).isSharingLocation(dialogId))
        {
            if (otherSharingCount != 0)
            {
                if (otherSharingCount == 1 && notYouUser != null)
                {
                    fullString = String.format("%1$s - %2$s", liveLocation, LocaleController.formatString("SharingYouAndOtherName", R.string.SharingYouAndOtherName, UserObject.getFirstName(notYouUser)));
                }
                else
                {
                    fullString = String.format("%1$s - %2$s %3$s", liveLocation, LocaleController.getString("ChatYourSelfName", R.string.ChatYourSelfName), LocaleController.formatPluralString("AndOther", otherSharingCount));
                }
            }
            else
            {
                fullString = String.format("%1$s - %2$s", liveLocation, LocaleController.getString("ChatYourSelfName", R.string.ChatYourSelfName));
            }
        }
        else
        {
            if (otherSharingCount != 0)
            {
                fullString = String.format("%1$s - %2$s %3$s", liveLocation, UserObject.getFirstName(notYouUser), LocaleController.formatPluralString("AndOther", otherSharingCount));
            }
            else
            {
                fullString = String.format("%1$s - %2$s", liveLocation, UserObject.getFirstName(notYouUser));
            }
        }
    }
    if (lastString != null && fullString.equals(lastString))
    {
        return;
    }
    lastString = fullString;
    int start = fullString.indexOf(liveLocation);
    SpannableStringBuilder stringBuilder = new SpannableStringBuilder(fullString);
    titleTextView.setEllipsize(TextUtils.TruncateAt.END);
    if (start >= 0)
    {
        TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), 0, Theme.getColor(Theme.key_inappPlayerPerformer));
        stringBuilder.setSpan(span, start, start + liveLocation.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    }
    titleTextView.setText(stringBuilder);
}
 
Example 19
Source File: TypefaceSpan.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public boolean isItalic() {
    return typeface == AndroidUtilities.getTypeface("fonts/ritalic.ttf");
}
 
Example 20
Source File: TypefaceSpan.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public boolean isBold() {
    return typeface == AndroidUtilities.getTypeface("fonts/rmedium.ttf");
}