Java Code Examples for org.telegram.messenger.LocaleController#getString()
The following examples show how to use
org.telegram.messenger.LocaleController#getString() .
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: BlockedUsersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder.getItemViewType() == 0) { TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(MessagesController.getInstance(currentAccount).blockedUsers.keyAt(position)); if (user != null) { String number; if (user.bot) { number = LocaleController.getString("Bot", R.string.Bot).substring(0, 1).toUpperCase() + LocaleController.getString("Bot", R.string.Bot).substring(1); } else if (user.phone != null && user.phone.length() != 0) { number = PhoneFormat.getInstance().format("+" + user.phone); } else { number = LocaleController.getString("NumberUnknown", R.string.NumberUnknown); } ((UserCell) holder.itemView).setData(user, null, number, 0); } } }
Example 2
Source File: ChatUsersActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
public ChooseView(Context context) { super(context); paint = new Paint(Paint.ANTI_ALIAS_FLAG); textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); textPaint.setTextSize(AndroidUtilities.dp(13)); for (int a = 0; a < 7; a++) { String string; switch (a) { case 0: string = LocaleController.getString("SlowmodeOff", R.string.SlowmodeOff); break; case 1: string = LocaleController.formatString("SlowmodeSeconds", R.string.SlowmodeSeconds, 10); break; case 2: string = LocaleController.formatString("SlowmodeSeconds", R.string.SlowmodeSeconds, 30); break; case 3: string = LocaleController.formatString("SlowmodeMinutes", R.string.SlowmodeMinutes, 1); break; case 4: string = LocaleController.formatString("SlowmodeMinutes", R.string.SlowmodeMinutes, 5); break; case 5: string = LocaleController.formatString("SlowmodeMinutes", R.string.SlowmodeMinutes, 15); break; case 6: default: string = LocaleController.formatString("SlowmodeHours", R.string.SlowmodeHours, 1); break; } strings.add(string); sizes.add((int) Math.ceil(textPaint.measureText(string))); } }
Example 3
Source File: ChangePhoneActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public String getHeaderName() { if (currentType == 1) { return phone; } else { return LocaleController.getString("YourCode", R.string.YourCode); } }
Example 4
Source File: AlertsCreator.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public static void showOpenUrlAlert(BaseFragment fragment, String url, boolean punycode, boolean tryTelegraph, boolean ask) { if (fragment == null || fragment.getParentActivity() == null) { return; } long inlineReturn = (fragment instanceof ChatActivity) ? ((ChatActivity) fragment).getInlineReturn() : 0; if (Browser.isInternalUrl(url, null) || !ask) { Browser.openUrl(fragment.getParentActivity(), url, inlineReturn == 0, tryTelegraph); } else { String urlFinal; if (punycode) { try { Uri uri = Uri.parse(url); String host = IDN.toASCII(uri.getHost(), IDN.ALLOW_UNASSIGNED); urlFinal = uri.getScheme() + "://" + host + uri.getPath(); } catch (Exception e) { FileLog.e(e); urlFinal = url; } } else { urlFinal = url; } AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity()); builder.setTitle(LocaleController.getString("OpenUrlTitle", R.string.OpenUrlTitle)); String format = LocaleController.getString("OpenUrlAlert2", R.string.OpenUrlAlert2); int index = format.indexOf("%"); SpannableStringBuilder stringBuilder = new SpannableStringBuilder(String.format(format, urlFinal)); if (index >= 0) { stringBuilder.setSpan(new URLSpan(urlFinal), index, index + urlFinal.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } builder.setMessage(stringBuilder); builder.setMessageTextViewClickable(false); builder.setPositiveButton(LocaleController.getString("Open", R.string.Open), (dialogInterface, i) -> Browser.openUrl(fragment.getParentActivity(), url, inlineReturn == 0, tryTelegraph)); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); fragment.showDialog(builder.create()); } }
Example 5
Source File: DialogsEmptyCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void setType(int value) { if (currentType == value) { return; } currentType = value; String help; int icon; if (currentType == 0) { icon = 0; help = LocaleController.getString("NoChatsHelp", R.string.NoChatsHelp); emptyTextView1.setText(LocaleController.getString("NoChats", R.string.NoChats)); } else if (currentType == 1) { icon = 0; help = LocaleController.getString("NoChatsContactsHelp", R.string.NoChatsContactsHelp); emptyTextView1.setText(LocaleController.getString("NoChats", R.string.NoChats)); } else if (currentType == 2) { imageView.setAutoRepeat(false); icon = R.raw.filter_no_chats; help = LocaleController.getString("FilterNoChatsToDisplayInfo", R.string.FilterNoChatsToDisplayInfo); emptyTextView1.setText(LocaleController.getString("FilterNoChatsToDisplay", R.string.FilterNoChatsToDisplay)); } else { imageView.setAutoRepeat(true); icon = R.raw.filter_new; help = LocaleController.getString("FilterAddingChatsInfo", R.string.FilterAddingChatsInfo); emptyTextView1.setText(LocaleController.getString("FilterAddingChats", R.string.FilterAddingChats)); } if (icon != 0) { imageView.setVisibility(VISIBLE); imageView.setAnimation(icon, 100, 100); imageView.playAnimation(); } else { imageView.setVisibility(GONE); } if (AndroidUtilities.isTablet() && !AndroidUtilities.isSmallTablet()) { help = help.replace('\n', ' '); } emptyTextView2.setText(help); }
Example 6
Source File: LocationActivityAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void updateCell() { if (sendLocationCell != null) { if (locationType == LocationActivity.LOCATION_TYPE_GROUP || customLocation != null) { String address; if (!TextUtils.isEmpty(addressName)) { address = addressName; } else if (customLocation == null && gpsLocation == null || fetchingLocation) { address = LocaleController.getString("Loading", R.string.Loading); } else if (customLocation != null) { address = String.format(Locale.US, "(%f,%f)", customLocation.getLatitude(), customLocation.getLongitude()); } else if (gpsLocation != null) { address = String.format(Locale.US, "(%f,%f)", gpsLocation.getLatitude(), gpsLocation.getLongitude()); } else { address = LocaleController.getString("Loading", R.string.Loading); } if (locationType == LocationActivity.LOCATION_TYPE_GROUP) { sendLocationCell.setText(LocaleController.getString("ChatSetThisLocation", R.string.ChatSetThisLocation), address); } else { sendLocationCell.setText(LocaleController.getString("SendSelectedLocation", R.string.SendSelectedLocation), address); } } else { if (gpsLocation != null) { sendLocationCell.setText(LocaleController.getString("SendLocation", R.string.SendLocation), LocaleController.formatString("AccurateTo", R.string.AccurateTo, LocaleController.formatPluralString("Meters", (int) gpsLocation.getAccuracy()))); } else { sendLocationCell.setText(LocaleController.getString("SendLocation", R.string.SendLocation), LocaleController.getString("Loading", R.string.Loading)); } } } }
Example 7
Source File: PaymentFormActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void updateSavePaymentField() { if (bottomCell[0] == null || sectionCell[2] == null) { return; } if ((paymentForm.password_missing || paymentForm.can_save_credentials) && (webView == null || webView != null && !webviewLoading)) { SpannableStringBuilder text = new SpannableStringBuilder(LocaleController.getString("PaymentCardSavePaymentInformationInfoLine1", R.string.PaymentCardSavePaymentInformationInfoLine1)); if (paymentForm.password_missing) { loadPasswordInfo(); text.append("\n"); int len = text.length(); String str2 = LocaleController.getString("PaymentCardSavePaymentInformationInfoLine2", R.string.PaymentCardSavePaymentInformationInfoLine2); int index1 = str2.indexOf('*'); int index2 = str2.lastIndexOf('*'); text.append(str2); if (index1 != -1 && index2 != -1) { index1 += len; index2 += len; bottomCell[0].getTextView().setMovementMethod(new AndroidUtilities.LinkMovementMethodMy()); text.replace(index2, index2 + 1, ""); text.replace(index1, index1 + 1, ""); text.setSpan(new LinkSpan(), index1, index2 - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } checkCell1.setEnabled(true); bottomCell[0].setText(text); checkCell1.setVisibility(View.VISIBLE); bottomCell[0].setVisibility(View.VISIBLE); sectionCell[2].setBackgroundDrawable(Theme.getThemedDrawable(sectionCell[2].getContext(), R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow)); } else { checkCell1.setVisibility(View.GONE); bottomCell[0].setVisibility(View.GONE); sectionCell[2].setBackgroundDrawable(Theme.getThemedDrawable(sectionCell[2].getContext(), R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow)); } }
Example 8
Source File: ChatListCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override protected void onDraw(Canvas canvas) { int color = Theme.getColor(Theme.key_switchTrack); int r = Color.red(color); int g = Color.green(color); int b = Color.blue(color); button.setColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_radioBackgroundChecked)); rect.set(AndroidUtilities.dp(1), AndroidUtilities.dp(1), getMeasuredWidth() - AndroidUtilities.dp(1), AndroidUtilities.dp(73)); Theme.chat_instantViewRectPaint.setColor(Color.argb((int) (43 * button.getProgress()), r, g, b)); canvas.drawRoundRect(rect, AndroidUtilities.dp(6), AndroidUtilities.dp(6), Theme.chat_instantViewRectPaint); rect.set(0, 0, getMeasuredWidth(), AndroidUtilities.dp(74)); Theme.dialogs_onlineCirclePaint.setColor(Color.argb((int) (31 * (1.0f - button.getProgress())), r, g, b)); canvas.drawRoundRect(rect, AndroidUtilities.dp(6), AndroidUtilities.dp(6), Theme.dialogs_onlineCirclePaint); String text = isThreeLines ? LocaleController.getString("ChatListExpanded", R.string.ChatListExpanded) : LocaleController.getString("ChatListDefault", R.string.ChatListDefault); int width = (int) Math.ceil(textPaint.measureText(text)); textPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); canvas.drawText(text, (getMeasuredWidth() - width) / 2, AndroidUtilities.dp(96), textPaint); for (int a = 0; a < 2; a++) { int cy = AndroidUtilities.dp(a == 0 ? 21 : 53); Theme.dialogs_onlineCirclePaint.setColor(Color.argb(a == 0 ? 204 : 90, r, g, b)); canvas.drawCircle(AndroidUtilities.dp(22), cy, AndroidUtilities.dp(11), Theme.dialogs_onlineCirclePaint); for (int i = 0; i < (isThreeLines ? 3 : 2); i++) { Theme.dialogs_onlineCirclePaint.setColor(Color.argb(i == 0 ? 204 : 90, r, g, b)); if (isThreeLines) { rect.set(AndroidUtilities.dp(41), cy - AndroidUtilities.dp(8.3f - i * 7), getMeasuredWidth() - AndroidUtilities.dp(i == 0 ? 72 : 48), cy - AndroidUtilities.dp(8.3f - 3 - i * 7)); canvas.drawRoundRect(rect, AndroidUtilities.dpf2(1.5f), AndroidUtilities.dpf2(1.5f), Theme.dialogs_onlineCirclePaint); } else { rect.set(AndroidUtilities.dp(41), cy - AndroidUtilities.dp(7 - i * 10), getMeasuredWidth() - AndroidUtilities.dp(i == 0 ? 72 : 48), cy - AndroidUtilities.dp(7 - 4 - i * 10)); canvas.drawRoundRect(rect, AndroidUtilities.dp(2), AndroidUtilities.dp(2), Theme.dialogs_onlineCirclePaint); } } } }
Example 9
Source File: BotHelpCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setText(String text) { if (text == null || text.length() == 0) { setVisibility(GONE); return; } if (text != null && text.equals(oldText)) { return; } oldText = text; setVisibility(VISIBLE); int maxWidth; if (AndroidUtilities.isTablet()) { maxWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f); } else { maxWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f); } String[] lines = text.split("\n"); SpannableStringBuilder stringBuilder = new SpannableStringBuilder(); String help = LocaleController.getString("BotInfoTitle", R.string.BotInfoTitle); stringBuilder.append(help); stringBuilder.append("\n\n"); for (int a = 0; a < lines.length; a++) { stringBuilder.append(lines[a].trim()); if (a != lines.length - 1) { stringBuilder.append("\n"); } } MessageObject.addLinks(false, stringBuilder); stringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), 0, help.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); Emoji.replaceEmoji(stringBuilder, Theme.chat_msgTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false); try { textLayout = new StaticLayout(stringBuilder, Theme.chat_msgTextPaint, maxWidth, 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))); } if (width > maxWidth) { width = maxWidth; } } catch (Exception e) { FileLog.e(e); } width += AndroidUtilities.dp(4 + 18); }
Example 10
Source File: ChangePhoneActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public String getHeaderName() { return LocaleController.getString("ChangePhoneNewNumber", R.string.ChangePhoneNewNumber); }
Example 11
Source File: LoginActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public String getHeaderName() { return LocaleController.getString("YourPhone", R.string.YourPhone); }
Example 12
Source File: ProfileNotificationsActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (data == null) { return; } Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String name = null; if (ringtone != null) { Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone); if (rng != null) { if (requestCode == 13) { if (ringtone.equals(Settings.System.DEFAULT_RINGTONE_URI)) { name = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone); } else { name = rng.getTitle(getParentActivity()); } } else { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } } rng.stop(); } } SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount); SharedPreferences.Editor editor = preferences.edit(); if (requestCode == 12) { if (name != null) { editor.putString("sound_" + dialog_id, name); editor.putString("sound_path_" + dialog_id, ringtone.toString()); } else { editor.putString("sound_" + dialog_id, "NoSound"); editor.putString("sound_path_" + dialog_id, "NoSound"); } } else if (requestCode == 13) { if (name != null) { editor.putString("ringtone_" + dialog_id, name); editor.putString("ringtone_path_" + dialog_id, ringtone.toString()); } else { editor.putString("ringtone_" + dialog_id, "NoSound"); editor.putString("ringtone_path_" + dialog_id, "NoSound"); } } editor.commit(); if (adapter != null) { adapter.notifyItemChanged(requestCode == 13 ? ringtoneRow : soundRow); } } }
Example 13
Source File: CacheControlActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (holder.getItemViewType()) { case 0: TextSettingsCell textCell = (TextSettingsCell) holder.itemView; if (position == databaseRow) { textCell.setTextAndValue(LocaleController.getString("LocalDatabase", R.string.LocalDatabase), AndroidUtilities.formatFileSize(databaseSize), false); } else if (position == cacheRow) { if (calculating) { textCell.setTextAndValue(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), LocaleController.getString("CalculatingSize", R.string.CalculatingSize), false); } else { textCell.setTextAndValue(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), totalSize == 0 ? LocaleController.getString("CacheEmpty", R.string.CacheEmpty) : AndroidUtilities.formatFileSize(totalSize), false); } } else if (position == keepMediaRow) { SharedPreferences preferences = MessagesController.getGlobalMainSettings(); int keepMedia = preferences.getInt("keep_media", 2); String value; if (keepMedia == 0) { value = LocaleController.formatPluralString("Weeks", 1); } else if (keepMedia == 1) { value = LocaleController.formatPluralString("Months", 1); } else if (keepMedia == 3) { value = LocaleController.formatPluralString("Days", 3); } else { value = LocaleController.getString("KeepMediaForever", R.string.KeepMediaForever); } textCell.setTextAndValue(LocaleController.getString("KeepMedia", R.string.KeepMedia), value, false); } break; case 1: TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView; if (position == databaseInfoRow) { privacyCell.setText(LocaleController.getString("LocalDatabaseInfo", R.string.LocalDatabaseInfo)); privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow)); } else if (position == cacheInfoRow) { privacyCell.setText(""); privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow)); } else if (position == keepMediaInfoRow) { privacyCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("KeepMediaInfo", R.string.KeepMediaInfo))); privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow)); } break; } }
Example 14
Source File: LoginActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public String getHeaderName() { return LocaleController.getString("LoginPassword", R.string.LoginPassword); }
Example 15
Source File: CancelAccountDeletionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public String getHeaderName() { return LocaleController.getString("CancelAccountReset", R.string.CancelAccountReset); }
Example 16
Source File: ChangePhoneActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public String getHeaderName() { return LocaleController.getString("YourCode", R.string.YourCode); }
Example 17
Source File: AlertsCreator.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
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 18
Source File: FragmentContextView.java From Telegram with GNU General Public License v2.0 | 4 votes |
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 19
Source File: AlertsCreator.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static Dialog createPopupSelectDialog(Activity parentActivity, final BaseFragment parentFragment, final boolean globalGroup, final boolean globalAll, final Runnable onSelect) { SharedPreferences preferences = MessagesController.getNotificationsSettings(UserConfig.selectedAccount); final int selected[] = new int[1]; if (globalAll) { selected[0] = preferences.getInt("popupAll", 0); } else if (globalGroup) { selected[0] = preferences.getInt("popupGroup", 0); } String descriptions[] = new String[]{ LocaleController.getString("NoPopup", R.string.NoPopup), LocaleController.getString("OnlyWhenScreenOn", R.string.OnlyWhenScreenOn), LocaleController.getString("OnlyWhenScreenOff", R.string.OnlyWhenScreenOff), LocaleController.getString("AlwaysShowPopup", R.string.AlwaysShowPopup) }; final LinearLayout linearLayout = new LinearLayout(parentActivity); linearLayout.setOrientation(LinearLayout.VERTICAL); for (int a = 0; a < descriptions.length; a++) { RadioColorCell cell = new RadioColorCell(parentActivity); cell.setTag(a); cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); 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 -> { selected[0] = (Integer) v.getTag(); final SharedPreferences preferences1 = MessagesController.getNotificationsSettings(UserConfig.selectedAccount); SharedPreferences.Editor editor = preferences1.edit(); editor.putInt(globalGroup ? "popupGroup" : "popupAll", selected[0]); editor.commit(); if (parentFragment != null) { parentFragment.dismissCurrentDialig(); } if (onSelect != null) { onSelect.run(); } }); } AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); builder.setTitle(LocaleController.getString("PopupNotification", R.string.PopupNotification)); builder.setView(linearLayout); builder.setPositiveButton(LocaleController.getString("Cancel", R.string.Cancel), null); return builder.create(); }
Example 20
Source File: AlertsCreator.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
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, (dialogInterface, i) -> { int untilTime = ConnectionsManager.getInstance(UserConfig.selectedAccount).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 = MessagesController.getNotificationsSettings(UserConfig.selectedAccount); 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(UserConfig.selectedAccount).removeNotificationsForDialog(dialog_id); MessagesStorage.getInstance(UserConfig.selectedAccount).setDialogFlags(dialog_id, flags); editor.commit(); TLRPC.TL_dialog dialog = MessagesController.getInstance(UserConfig.selectedAccount).dialogs_dict.get(dialog_id); if (dialog != null) { dialog.notify_settings = new TLRPC.TL_peerNotifySettings(); dialog.notify_settings.mute_until = untilTime; } NotificationsController.getInstance(UserConfig.selectedAccount).updateServerNotificationsSettings(dialog_id); } ); return builder.create(); }