本文整理汇总了Java中org.telegram.messenger.LocaleController.getString方法的典型用法代码示例。如果您正苦于以下问题:Java LocaleController.getString方法的具体用法?Java LocaleController.getString怎么用?Java LocaleController.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.telegram.messenger.LocaleController
的用法示例。
在下文中一共展示了LocaleController.getString方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHeaderAllTitles
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
private String getHeaderAllTitles() {
switch (dialogsType) {
case 3:
return LocaleController.getString("Users", R.string.Users);
case 4:
case 9:
return LocaleController.getString("Groups", R.string.Groups);
case 5:
return LocaleController.getString("Channels", R.string.Channels);
case 6:
return LocaleController.getString("Bots", R.string.Bots);
case 7:
return LocaleController.getString("SuperGroups", R.string.SuperGroups);
case 8:
return LocaleController.getString("Favorites", R.string.Favorites);
default:
return getHeaderTitle();
}
}
示例2: getHeaderTitle
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
private String getHeaderTitle() {
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
int value = themePrefs.getInt("chatsHeaderTitle", 0);
String title = LocaleController.getString("AppName", R.string.AppName);
TLRPC.User user = UserConfig.getCurrentUser();
if (value == 1) {
title = LocaleController.getString("ShortAppName", R.string.ShortAppName);
} else if (value == 2) {
if (user != null && (user.first_name != null || user.last_name != null)) {
title = ContactsController.formatName(user.first_name, user.last_name);
}
} else if (value == 3) {
if (user != null && user.username != null && user.username.length() != 0) {
title = "@" + user.username;
}
} else if (value == 4) {
title = "";
}
return title;
}
示例3: updateTypeCell
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
private void updateTypeCell() {
String type = currentChat.username == null || currentChat.username.length() == 0 ? LocaleController.getString("ChannelTypePrivate", R.string.ChannelTypePrivate) : LocaleController.getString("ChannelTypePublic", R.string.ChannelTypePublic);
if (currentChat.megagroup) {
typeCell.setTextAndValue(LocaleController.getString("GroupType", R.string.GroupType), type, false);
} else {
typeCell.setTextAndValue(LocaleController.getString("ChannelType", R.string.ChannelType), type, false);
}
if (currentChat.creator && (info == null || info.can_set_username)) {
typeCell.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putInt("chat_id", chatId);
ChannelEditTypeActivity fragment = new ChannelEditTypeActivity(args);
fragment.setInfo(info);
presentFragment(fragment);
}
});
typeCell.setTextColor(0xff212121);
typeCell.setTextValueColor(0xff2f8cc9);
} else {
typeCell.setOnClickListener(null);
typeCell.setTextColor(0xffa8a8a8);
typeCell.setTextValueColor(0xffa8a8a8);
}
}
示例4: setText
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
public void setText(String text) {
if (text == null || text.length() == 0) {
setVisibility(GONE);
return;
}
if (text != null && oldText != null && text.equals(oldText)) {
return;
}
oldText = text;
setVisibility(VISIBLE);
if (AndroidUtilities.isTablet()) {
width = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
} else {
width = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f);
}
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
String help = LocaleController.getString("BotInfoTitle", R.string.BotInfoTitle);
stringBuilder.append(help);
stringBuilder.append("\n\n");
stringBuilder.append(text);
MessageObject.addLinks(stringBuilder);
stringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), 0, help.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
Emoji.replaceEmoji(stringBuilder, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
try {
textLayout = new StaticLayout(stringBuilder, textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
width = 0;
height = textLayout.getHeight() + AndroidUtilities.dp(4 + 18);
int count = textLayout.getLineCount();
for (int a = 0; a < count; a++) {
width = (int) Math.ceil(Math.max(width, textLayout.getLineWidth(a) + textLayout.getLineLeft(a)));
}
} catch (Exception e) {
FileLog.e("tmessage", e);
}
width += AndroidUtilities.dp(4 + 18);
}
示例5: didReceivedNotification
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.updateInterfaces) {
int mask = (Integer) args[0];
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
updateUserData();
}
} else if (id == NotificationCenter.userInfoDidLoaded) {
TLRPC.User user = UserConfig.getCurrentUser();
if (aboutLinkCell != null && user.id == (Integer) args[0]) {
//Log.e("SettingsActivity","userInfoDidLoaded " + (Integer) args[0]);
String about = MessagesController.getInstance().getUserAbout(user.id);
String value;
if (about != null && about.length() > 0) {
value = about;
} else {
if (userAbout != null && userAbout.length() > 0) {
value = userAbout;
} else {
value = LocaleController.getString("UsernameEmpty", R.string.UsernameEmpty);
}
//value = LocaleController.getString("UsernameEmpty", R.string.UsernameEmpty);
}
//Log.e("SettingsActivity","userInfoDidLoaded " + args[0] + " " + value);
aboutLinkCell.setTextAndValue(value, LocaleController.getString("Bio", R.string.Bio), false);
aboutLinkCell.setMultilineText(true);
}
}
}
示例6: getHeaderName
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
@Override
public String getHeaderName() {
return LocaleController.getString("YourPhone", R.string.YourPhone);
}
示例7: getHeaderName
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
@Override
public String getHeaderName() {
return LocaleController.getString("YourCode", R.string.YourCode);
}
示例8: onActivityResultFragment
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
String name = null;
if (ringtone != null) {
Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone);
if (rng != null) {
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
name = LocaleController.getString("SoundDefault", R.string.SoundDefault);
} else {
name = rng.getTitle(getParentActivity());
}
rng.stop();
}
}
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
if (requestCode == messageSoundRow) {
if (name != null && ringtone != null) {
editor.putString("GlobalSound", name);
editor.putString("GlobalSoundPath", ringtone.toString());
} else {
editor.putString("GlobalSound", "NoSound");
editor.putString("GlobalSoundPath", "NoSound");
}
} else if (requestCode == groupSoundRow) {
if (name != null && ringtone != null) {
editor.putString("GroupSound", name);
editor.putString("GroupSoundPath", ringtone.toString());
} else {
editor.putString("GroupSound", "NoSound");
editor.putString("GroupSoundPath", "NoSound");
}
}
editor.commit();
listView.invalidateViews();
}
}
示例9: measureTime
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
private void measureTime(MessageObject messageObject) {
boolean hasSign = !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0 && messageObject.messageOwner.post;
TLRPC.User signUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
if (hasSign && signUser == null) {
hasSign = false;
}
String timeString;
TLRPC.User author = null;
if (currentMessageObject.isFromUser()) {
author = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
}
if (messageObject.messageOwner.via_bot_id == 0 && messageObject.messageOwner.via_bot_name == null && (author == null || !author.bot) && (messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_EDITED) != 0) {
timeString = LocaleController.getString("EditedMessage", R.string.EditedMessage) + " " + LocaleController.getInstance().formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
} else {
timeString = LocaleController.getInstance().formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
}
if (hasSign) {
currentTimeString = ", " + timeString;
} else {
currentTimeString = timeString;
}
timeTextWidth = timeWidth = (int) Math.ceil(timePaint.measureText(currentTimeString));
if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) {
currentViewsString = String.format("%s", LocaleController.formatShortNumber(Math.max(1, messageObject.messageOwner.views), null));
viewsTextWidth = (int) Math.ceil(timePaint.measureText(currentViewsString));
timeWidth += viewsTextWidth + Theme.viewsCountDrawable[0].getIntrinsicWidth() + dp(10);
}
if (hasSign) {
if (availableTimeWidth == 0) {
availableTimeWidth = dp(1000);
}
CharSequence name = ContactsController.formatName(signUser.first_name, signUser.last_name).replace('\n', ' ');
int widthForSign = availableTimeWidth - timeWidth;
int width = (int) Math.ceil(timePaint.measureText(name, 0, name.length()));
if (width > widthForSign) {
name = TextUtils.ellipsize(name, timePaint, widthForSign, TextUtils.TruncateAt.END);
width = widthForSign;
}
currentTimeString = name + currentTimeString;
timeTextWidth += width;
timeWidth += width;
}
}
示例10: updateSubtitle
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
public void updateSubtitle() {
TLRPC.User user = parentFragment.getCurrentUser();
TLRPC.Chat chat = parentFragment.getCurrentChat();
CharSequence printString = MessagesController.getInstance().printingStrings.get(parentFragment.getDialogId());
if (printString != null) {
printString = TextUtils.replace(printString, new String[]{"..."}, new String[]{""});
}
if (printString == null || printString.length() == 0 || ChatObject.isChannel(chat) && !chat.megagroup) {
setTypingAnimation(false);
if (chat != null) {
TLRPC.ChatFull info = parentFragment.getCurrentChatInfo();
if (ChatObject.isChannel(chat)) {
if (info != null && info.participants_count != 0) {
if (chat.megagroup && info.participants_count <= 200) {
if (onlineCount > 1 && info.participants_count != 0) {
subtitleTextView.setText(String.format("%s, %s", LocaleController.formatPluralString("Members", info.participants_count), LocaleController.formatPluralString("Online", onlineCount)));
} else {
subtitleTextView.setText(LocaleController.formatPluralString("Members", info.participants_count));
}
} else {
int result[] = new int[1];
String shortNumber = LocaleController.formatShortNumber(info.participants_count, result);
String text = LocaleController.formatPluralString("Members", result[0]).replace(String.format("%d", result[0]), shortNumber);
subtitleTextView.setText(text);
}
} else {
if (chat.megagroup) {
subtitleTextView.setText(LocaleController.getString("Loading", R.string.Loading).toLowerCase());
} else {
if ((chat.flags & TLRPC.CHAT_FLAG_IS_PUBLIC) != 0) {
subtitleTextView.setText(LocaleController.getString("ChannelPublic", R.string.ChannelPublic).toLowerCase());
} else {
subtitleTextView.setText(LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate).toLowerCase());
}
}
}
} else {
if (ChatObject.isKickedFromChat(chat)) {
subtitleTextView.setText(LocaleController.getString("YouWereKicked", R.string.YouWereKicked));
} else if (ChatObject.isLeftFromChat(chat)) {
subtitleTextView.setText(LocaleController.getString("YouLeft", R.string.YouLeft));
} else {
int count = chat.participants_count;
if (info != null && info.participants != null) {
count = info.participants.participants.size();
}
if (onlineCount > 1 && count != 0) {
subtitleTextView.setText(String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount)));
} else {
subtitleTextView.setText(LocaleController.formatPluralString("Members", count));
}
}
}
} else if (user != null) {
user = MessagesController.getInstance().getUser(user.id);
String newStatus;
if (user.id == 333000 || user.id == 777000) {
newStatus = LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications);
} else if (user.bot) {
newStatus = LocaleController.getString("Bot", R.string.Bot);
} else {
newStatus = LocaleController.formatUserStatus(user);
}
subtitleTextView.setText(newStatus);
}
} else {
subtitleTextView.setText(printString);
setTypingAnimation(true);
}
}
示例11: createMuteAlert
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
public static Dialog createMuteAlert(Context context, final long dialog_id) {
if (context == null) {
return null;
}
BottomSheet.Builder builder = new BottomSheet.Builder(context);
builder.setTitle(LocaleController.getString("Notifications", R.string.Notifications));
CharSequence[] items = new CharSequence[]{
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Hours", 1)),
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Hours", 8)),
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Days", 2)),
LocaleController.getString("MuteDisable", R.string.MuteDisable)
};
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int untilTime = ConnectionsManager.getInstance().getCurrentTime();
if (i == 0) {
untilTime += 60 * 60;
} else if (i == 1) {
untilTime += 60 * 60 * 8;
} else if (i == 2) {
untilTime += 60 * 60 * 48;
} else if (i == 3) {
untilTime = Integer.MAX_VALUE;
}
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
long flags;
if (i == 3) {
editor.putInt("notify2_" + dialog_id, 2);
flags = 1;
} else {
editor.putInt("notify2_" + dialog_id, 3);
editor.putInt("notifyuntil_" + dialog_id, untilTime);
flags = ((long) untilTime << 32) | 1;
}
NotificationsController.getInstance().removeNotificationsForDialog(dialog_id);
MessagesStorage.getInstance().setDialogFlags(dialog_id, flags);
editor.commit();
TLRPC.TL_dialog dialog = MessagesController.getInstance().dialogs_dict.get(dialog_id);
if (dialog != null) {
dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
dialog.notify_settings.mute_until = untilTime;
}
NotificationsController.updateServerNotificationsSettings(dialog_id);
}
}
);
return builder.create();
}
示例12: formatRulesString
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
private String formatRulesString(boolean isGroup) {
ArrayList<TLRPC.PrivacyRule> privacyRules = ContactsController.getInstance().getPrivacyRules(isGroup);
if (privacyRules.size() == 0) {
return LocaleController.getString("LastSeenNobody", R.string.LastSeenNobody);
}
int type = -1;
int plus = 0;
int minus = 0;
for (int a = 0; a < privacyRules.size(); a++) {
TLRPC.PrivacyRule rule = privacyRules.get(a);
if (rule instanceof TLRPC.TL_privacyValueAllowUsers) {
plus += rule.users.size();
} else if (rule instanceof TLRPC.TL_privacyValueDisallowUsers) {
minus += rule.users.size();
} else if (rule instanceof TLRPC.TL_privacyValueAllowAll) {
type = 0;
} else if (rule instanceof TLRPC.TL_privacyValueDisallowAll) {
type = 1;
} else {
type = 2;
}
}
if (type == 0 || type == -1 && minus > 0) {
if (minus == 0) {
return LocaleController.getString("LastSeenEverybody", R.string.LastSeenEverybody);
} else {
return LocaleController.formatString("LastSeenEverybodyMinus", R.string.LastSeenEverybodyMinus, minus);
}
} else if (type == 2 || type == -1 && minus > 0 && plus > 0) {
if (plus == 0 && minus == 0) {
return LocaleController.getString("LastSeenContacts", R.string.LastSeenContacts);
} else {
if (plus != 0 && minus != 0) {
return LocaleController.formatString("LastSeenContactsMinusPlus", R.string.LastSeenContactsMinusPlus, minus, plus);
} else if (minus != 0) {
return LocaleController.formatString("LastSeenContactsMinus", R.string.LastSeenContactsMinus, minus);
} else {
return LocaleController.formatString("LastSeenContactsPlus", R.string.LastSeenContactsPlus, plus);
}
}
} else if (type == 1 || plus > 0) {
if (plus == 0) {
return LocaleController.getString("LastSeenNobody", R.string.LastSeenNobody);
} else {
return LocaleController.formatString("LastSeenNobodyPlus", R.string.LastSeenNobodyPlus, plus);
}
}
return "unknown";
}
示例13: onBindViewHolder
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
switch (holder.getItemViewType()) {
case 0:
ArrayList<TLRPC.TL_messages_stickerSet> arrayList = StickersQuery.getStickerSets(currentType);
int row = position - stickersStartRow;
((StickerSetCell) holder.itemView).setStickersSet(arrayList.get(row), row != arrayList.size() - 1);
break;
case 1:
if (position == featuredInfoRow) {
String text = LocaleController.getString("FeaturedStickersInfo", R.string.FeaturedStickersInfo);
String botName = "@stickers";
int index = text.indexOf(botName);
if (index != -1) {
try {
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text);
URLSpanNoUnderline spanNoUnderline = new URLSpanNoUnderline("@stickers") {
@Override
public void onClick(View widget) {
MessagesController.openByUserName("stickers", StickersActivity.this, 1);
}
};
stringBuilder.setSpan(spanNoUnderline, index, index + botName.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
((TextInfoPrivacyCell) holder.itemView).setText(stringBuilder);
} catch (Exception e) {
FileLog.e("tmessages", e);
((TextInfoPrivacyCell) holder.itemView).setText(text);
}
} else {
((TextInfoPrivacyCell) holder.itemView).setText(text);
}
} else if (position == archivedInfoRow) {
if (currentType == StickersQuery.TYPE_IMAGE) {
((TextInfoPrivacyCell) holder.itemView).setText(LocaleController.getString("ArchivedStickersInfo", R.string.ArchivedStickersInfo));
} else {
((TextInfoPrivacyCell) holder.itemView).setText(LocaleController.getString("ArchivedMasksInfo", R.string.ArchivedMasksInfo));
}
} else if (position == masksInfoRow) {
((TextInfoPrivacyCell) holder.itemView).setText(LocaleController.getString("MasksInfo", R.string.MasksInfo));
}
break;
case 2:
if (position == featuredRow) {
int count = StickersQuery.getUnreadStickerSets().size();
((TextSettingsCell) holder.itemView).setTextAndValue(LocaleController.getString("FeaturedStickers", R.string.FeaturedStickers), count != 0 ? String.format("%d", count) : "", false);
} else if (position == archivedRow) {
if (currentType == StickersQuery.TYPE_IMAGE) {
((TextSettingsCell) holder.itemView).setText(LocaleController.getString("ArchivedStickers", R.string.ArchivedStickers), false);
} else {
((TextSettingsCell) holder.itemView).setText(LocaleController.getString("ArchivedMasks", R.string.ArchivedMasks), false);
}
} else if (position == masksRow) {
((TextSettingsCell) holder.itemView).setText(LocaleController.getString("Masks", R.string.Masks), true);
}
break;
}
}
示例14: createMuteAlert
import org.telegram.messenger.LocaleController; //导入方法依赖的package包/类
public static Dialog createMuteAlert(Context context, final long dialog_id) {
if (context == null) {
return null;
}
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(LocaleController.getString("Notifications", R.string.Notifications));
CharSequence[] items = new CharSequence[]{
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Hours", 1)),
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Hours", 8)),
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Days", 2)),
LocaleController.getString("MuteDisable", R.string.MuteDisable)
};
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int untilTime = ConnectionsManager.getInstance().getCurrentTime();
if (i == 0) {
untilTime += 60 * 60;
} else if (i == 1) {
untilTime += 60 * 60 * 8;
} else if (i == 2) {
untilTime += 60 * 60 * 48;
} else if (i == 3) {
untilTime = Integer.MAX_VALUE;
}
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
long flags;
if (i == 3) {
editor.putInt("notify2_" + dialog_id, 2);
flags = 1;
} else {
editor.putInt("notify2_" + dialog_id, 3);
editor.putInt("notifyuntil_" + dialog_id, untilTime);
flags = ((long) untilTime << 32) | 1;
}
NotificationsController.getInstance().removeNotificationsForDialog(dialog_id);
MessagesStorage.getInstance().setDialogFlags(dialog_id, flags);
editor.commit();
TLRPC.TL_dialog dialog = MessagesController.getInstance().dialogs_dict.get(dialog_id);
if (dialog != null) {
dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
dialog.notify_settings.mute_until = untilTime;
}
NotificationsController.updateServerNotificationsSettings(dialog_id);
}
}
);
return builder.create();
}