update to 11.1.2 (5240)

This commit is contained in:
dkaraush 2024-09-11 01:38:57 +04:00
parent 3d718c8d36
commit cc50db9d67
28 changed files with 235 additions and 107 deletions

View file

@ -15,6 +15,7 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/> <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>

View file

@ -23,7 +23,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" /> <uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<application <application

View file

@ -15,6 +15,7 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/> <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>

View file

@ -23,6 +23,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" /> <uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>

View file

@ -25,6 +25,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
<uses-permission android:name="android.permission.READ_CALL_LOG" /> <uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>

View file

@ -15858,7 +15858,9 @@ public class MessagesController extends BaseController implements NotificationCe
messagesArr.add(message); messagesArr.add(message);
MessageObject obj = new MessageObject(currentAccount, message, usersDict, true, false); MessageObject obj = new MessageObject(currentAccount, message, usersDict, true, false);
pushMessages.add(obj); pushMessages.add(obj);
if (message.from_id.user_id != getUserConfig().getClientUserId()) {
getMessagesStorage().getStorageQueue().postRunnable(() -> AndroidUtilities.runOnUIThread(() -> getNotificationsController().processNewMessages(pushMessages, true, false, null))); getMessagesStorage().getStorageQueue().postRunnable(() -> AndroidUtilities.runOnUIThread(() -> getNotificationsController().processNewMessages(pushMessages, true, false, null)));
}
getMessagesStorage().putMessages(messagesArr, true, true, false, 0, 0, 0); getMessagesStorage().putMessages(messagesArr, true, true, false, 0, 0, 0);
} else { } else {
pushMessages = null; pushMessages = null;

View file

@ -78501,18 +78501,6 @@ public class TLRPC {
public static class TL_messageMediaGiveawayResults_layer186 extends TL_messageMediaGiveawayResults { public static class TL_messageMediaGiveawayResults_layer186 extends TL_messageMediaGiveawayResults {
public static final int constructor = 0xc6991068; public static final int constructor = 0xc6991068;
public boolean only_new_subscribers;
public boolean refunded;
public long channel_id;
public int additional_peers_count;
public int launch_msg_id;
public int winners_count;
public int unclaimed_count;
public ArrayList<Long> winners = new ArrayList<>();
public int months;
public String prize_description;
public int until_date;
public void readParams(AbstractSerializedData stream, boolean exception) { public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception); flags = stream.readInt32(exception);
only_new_subscribers = (flags & 1) != 0; only_new_subscribers = (flags & 1) != 0;

View file

@ -317,8 +317,8 @@ public class BoostsActivity extends GradientHeaderActivity implements Notificati
giveawayCell.setData(prepaidGiveaway, name, info, 0, !item.isLast); giveawayCell.setData(prepaidGiveaway, name, info, 0, !item.isLast);
} else if (prepaidGiveaway instanceof TL_stories.TL_prepaidStarsGiveaway) { } else if (prepaidGiveaway instanceof TL_stories.TL_prepaidStarsGiveaway) {
TL_stories.TL_prepaidStarsGiveaway starsGiveaway = (TL_stories.TL_prepaidStarsGiveaway) prepaidGiveaway; TL_stories.TL_prepaidStarsGiveaway starsGiveaway = (TL_stories.TL_prepaidStarsGiveaway) prepaidGiveaway;
String name = LocaleController.getString(R.string.BoostingStarsPrepaidGiveawayTitle); String name = LocaleController.formatPluralStringComma("BoostingStarsCountPlural", (int) starsGiveaway.stars);
String info = LocaleController.formatPluralStringComma("BoostingStarsCountPlural", (int) starsGiveaway.stars); String info = LocaleController.formatPluralString("AmongWinners", starsGiveaway.quantity);
giveawayCell.setData(prepaidGiveaway, name, info, 0, !item.isLast); giveawayCell.setData(prepaidGiveaway, name, info, 0, !item.isLast);
} }
giveawayCell.setImage(prepaidGiveaway); giveawayCell.setImage(prepaidGiveaway);

View file

@ -46,6 +46,7 @@ import org.telegram.ui.Components.RLottieImageView;
import org.telegram.ui.Components.Switch; import org.telegram.ui.Components.Switch;
import org.telegram.ui.FilterCreateActivity; import org.telegram.ui.FilterCreateActivity;
import org.telegram.ui.PeerColorActivity; import org.telegram.ui.PeerColorActivity;
import org.telegram.ui.Stories.recorder.HintView2;
public class TextCell extends FrameLayout { public class TextCell extends FrameLayout {
@ -534,11 +535,16 @@ public class TextCell extends FrameLayout {
offsetFromImage = getOffsetFromImage(false); offsetFromImage = getOffsetFromImage(false);
textView.setText(text); textView.setText(text);
textView.setRightDrawable(null); textView.setRightDrawable(null);
valueTextView.setText(value == null ? "" : TextUtils.ellipsize(valueText = value, valueTextView.getPaint(), AndroidUtilities.displaySize.x / 2.5f, TextUtils.TruncateAt.END), animated); imageView.setVisibility(VISIBLE);
if (value != null) {
int availableWidth = (int) Math.max(1, AndroidUtilities.displaySize.x - (dp(offsetFromImage) + HintView2.measureCorrectly(text, textView.getTextPaint()) + dp(16)));
valueTextView.setText(value == null ? "" : TextUtils.ellipsize(valueText = value, valueTextView.getPaint(), availableWidth, TextUtils.TruncateAt.END), animated);
} else {
valueTextView.setText("", animated);
}
valueTextView.setVisibility(VISIBLE); valueTextView.setVisibility(VISIBLE);
valueSpoilersTextView.setVisibility(GONE); valueSpoilersTextView.setVisibility(GONE);
valueImageView.setVisibility(GONE); valueImageView.setVisibility(GONE);
imageView.setVisibility(VISIBLE);
imageView.setTranslationX(0); imageView.setTranslationX(0);
imageView.setTranslationY(0); imageView.setTranslationY(0);
imageView.setPadding(0, dp(7), 0, 0); imageView.setPadding(0, dp(7), 0, 0);

View file

@ -295,8 +295,8 @@ public class ChannelBoostLayout extends FrameLayout {
giveawayCell.setData(prepaidGiveaway, name, info, 0, !item.isLast); giveawayCell.setData(prepaidGiveaway, name, info, 0, !item.isLast);
} else if (prepaidGiveaway instanceof TL_stories.TL_prepaidStarsGiveaway) { } else if (prepaidGiveaway instanceof TL_stories.TL_prepaidStarsGiveaway) {
TL_stories.TL_prepaidStarsGiveaway starsGiveaway = (TL_stories.TL_prepaidStarsGiveaway) prepaidGiveaway; TL_stories.TL_prepaidStarsGiveaway starsGiveaway = (TL_stories.TL_prepaidStarsGiveaway) prepaidGiveaway;
String name = LocaleController.getString(R.string.BoostingStarsPrepaidGiveawayTitle); String name = LocaleController.formatPluralStringComma("BoostingStarsCountPlural", (int) starsGiveaway.stars);
String info = LocaleController.formatPluralStringComma("BoostingStarsCountPlural", (int) starsGiveaway.stars); String info = LocaleController.formatPluralString("AmongWinners", starsGiveaway.quantity);
giveawayCell.setData(prepaidGiveaway, name, info, 0, !item.isLast); giveawayCell.setData(prepaidGiveaway, name, info, 0, !item.isLast);
} }
giveawayCell.setImage(prepaidGiveaway); giveawayCell.setImage(prepaidGiveaway);

View file

@ -3932,7 +3932,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
if (ChatObject.isBoostSupported(currentChat) && (getUserConfig().isPremium() || ChatObject.isBoosted(chatInfo) || ChatObject.hasAdminRights(currentChat))) { if (ChatObject.isBoostSupported(currentChat) && (getUserConfig().isPremium() || ChatObject.isBoosted(chatInfo) || ChatObject.hasAdminRights(currentChat))) {
RLottieDrawable drawable = new RLottieDrawable(R.raw.boosts, "" + R.raw.boosts, dp(24), dp(24)); RLottieDrawable drawable = new RLottieDrawable(R.raw.boosts, "" + R.raw.boosts, dp(24), dp(24));
headerItem.lazilyAddSubItem(boost_group, drawable, TextCell.applyNewSpan(LocaleController.getString(ChatObject.isChannelAndNotMegaGroup(currentChat) ? R.string.BoostingBoostChannelMenu : R.string.BoostingBoostGroupMenu))); headerItem.lazilyAddSubItem(boost_group, drawable, LocaleController.getString(ChatObject.isChannelAndNotMegaGroup(currentChat) ? R.string.BoostingBoostChannelMenu : R.string.BoostingBoostGroupMenu));
} }
translateItem = headerItem.lazilyAddSubItem(translate, R.drawable.msg_translate, LocaleController.getString(R.string.TranslateMessage)); translateItem = headerItem.lazilyAddSubItem(translate, R.drawable.msg_translate, LocaleController.getString(R.string.TranslateMessage));
updateTranslateItemVisibility(); updateTranslateItemVisibility();

View file

@ -164,9 +164,9 @@ public class MentionsContainerView extends BlurredFrameLayout implements Notific
@Override @Override
protected int getFlowItemCount() { protected int getFlowItemCount() {
if (adapter.getBotContextSwitch() != null || adapter.getBotWebViewSwitch() != null) { if (adapter.getBotContextSwitch() != null || adapter.getBotWebViewSwitch() != null) {
return getItemCount() - 2; return getItemCount() - 1;
} }
return super.getFlowItemCount() - 1; return super.getFlowItemCount();
} }
}; };
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@ -726,7 +726,6 @@ public class MentionsContainerView extends BlurredFrameLayout implements Notific
if (position == 0) { if (position == 0) {
return; return;
} }
position--;
if (adapter.isStickers()) { if (adapter.isStickers()) {
return; return;
} else if (adapter.getBotContextSwitch() != null || adapter.getBotWebViewSwitch() != null) { } else if (adapter.getBotContextSwitch() != null || adapter.getBotWebViewSwitch() != null) {

View file

@ -6,6 +6,7 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.provider.Settings;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
@ -115,10 +116,10 @@ public class PermissionRequest {
if (whenDone != null) whenDone.run(true); if (whenDone != null) whenDone.run(true);
return; return;
} }
boolean needsPermissionRationale = true; boolean needsPermissionRationale = false;
for (String permission : checkPermissions) { for (String permission : checkPermissions) {
if (!activity.shouldShowRequestPermissionRationale(permission)) { if (activity.shouldShowRequestPermissionRationale(permission)) {
needsPermissionRationale = false; needsPermissionRationale = true;
break; break;
} }
} }
@ -156,12 +157,19 @@ public class PermissionRequest {
} }
} }
public static void requestPermission(String permission, Utilities.Callback<Boolean> whenDone) {
requestPermissions(new String[] { permission }, whenDone != null ? res -> {
whenDone.run(res.length >= 1 && res[0] == PackageManager.PERMISSION_GRANTED);
} : null);
}
public static void requestPermissions(String[] permissions, Utilities.Callback<int[]> whenDone) { public static void requestPermissions(String[] permissions, Utilities.Callback<int[]> whenDone) {
Activity _activity = LaunchActivity.instance; Activity _activity = LaunchActivity.instance;
if (_activity == null) _activity = AndroidUtilities.findActivity(ApplicationLoader.applicationContext); if (_activity == null) _activity = AndroidUtilities.findActivity(ApplicationLoader.applicationContext);
if (_activity == null) return; if (_activity == null) return;
final Activity activity = _activity; final Activity activity = _activity;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
final int code = lastId++; final int code = lastId++;
NotificationCenter.NotificationCenterDelegate[] observer = new NotificationCenter.NotificationCenterDelegate[1]; NotificationCenter.NotificationCenterDelegate[] observer = new NotificationCenter.NotificationCenterDelegate[1];
observer[0] = new NotificationCenter.NotificationCenterDelegate() { observer[0] = new NotificationCenter.NotificationCenterDelegate() {
@ -182,6 +190,13 @@ public class PermissionRequest {
}; };
NotificationCenter.getGlobalInstance().addObserver(observer[0], NotificationCenter.activityPermissionsGranted); NotificationCenter.getGlobalInstance().addObserver(observer[0], NotificationCenter.activityPermissionsGranted);
activity.requestPermissions(permissions, code); activity.requestPermissions(permissions, code);
} else if (whenDone != null) {
int[] res = new int[ permissions.length ];
for (int i = 0; i < permissions.length; ++i) {
res[i] = hasPermission(permissions[i]) ? PackageManager.PERMISSION_GRANTED : PackageManager.PERMISSION_DENIED;
}
whenDone.run(res);
}
} }
public static boolean hasPermission(String permission) { public static boolean hasPermission(String permission) {
@ -197,4 +212,32 @@ public class PermissionRequest {
} }
} }
public static boolean canAskPermission(String permission) {
Activity _activity = LaunchActivity.instance;
if (_activity == null) _activity = AndroidUtilities.findActivity(ApplicationLoader.applicationContext);
if (_activity == null) return false;
final Activity activity = _activity;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return activity.shouldShowRequestPermissionRationale(permission);
} else {
return false;
}
}
public static void showPermissionSettings(String permission) {
Activity _activity = LaunchActivity.instance;
if (_activity == null) _activity = AndroidUtilities.findActivity(ApplicationLoader.applicationContext);
if (_activity == null) return;
final Activity activity = _activity;
final Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
try {
activity.startActivity(intent);
} catch (Exception x) {
FileLog.e(x);
}
}
} }

View file

@ -3,6 +3,7 @@ package org.telegram.ui.Components.Premium.boosts;
import static org.telegram.messenger.AndroidUtilities.dp; import static org.telegram.messenger.AndroidUtilities.dp;
import static org.telegram.messenger.AndroidUtilities.replaceTags; import static org.telegram.messenger.AndroidUtilities.replaceTags;
import static org.telegram.messenger.LocaleController.formatPluralString; import static org.telegram.messenger.LocaleController.formatPluralString;
import static org.telegram.messenger.LocaleController.formatPluralStringComma;
import static org.telegram.messenger.LocaleController.formatString; import static org.telegram.messenger.LocaleController.formatString;
import static org.telegram.messenger.LocaleController.getString; import static org.telegram.messenger.LocaleController.getString;
import static org.telegram.ui.Components.Premium.boosts.SelectorBottomSheet.TYPE_CHANNEL; import static org.telegram.ui.Components.Premium.boosts.SelectorBottomSheet.TYPE_CHANNEL;
@ -514,7 +515,7 @@ public class BoostDialogs {
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(); SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
if (isStars) { if (isStars) {
stringBuilder.append(replaceTags(formatPluralString(isChannel ? "BoostingStarsGiveawayHowItWorksText" : "BoostingStarsGiveawayHowItWorksTextGroup", (int) giveaway.stars, from))); stringBuilder.append(replaceTags(formatPluralStringComma(isChannel ? "BoostingStarsGiveawayHowItWorksText" : "BoostingStarsGiveawayHowItWorksTextGroup", (int) giveaway.stars, from)));
} else { } else {
stringBuilder.append(replaceTags(formatPluralString(isChannel ? "BoostingGiveawayHowItWorksText" : "BoostingGiveawayHowItWorksTextGroup", quantity, from, quantity, months))); stringBuilder.append(replaceTags(formatPluralString(isChannel ? "BoostingGiveawayHowItWorksText" : "BoostingGiveawayHowItWorksTextGroup", quantity, from, quantity, months)));
} }
@ -787,6 +788,10 @@ public class BoostDialogs {
giveaway.quantity = giveawayResults.winners_count + giveawayResults.unclaimed_count; giveaway.quantity = giveawayResults.winners_count + giveawayResults.unclaimed_count;
giveaway.only_new_subscribers = giveawayResults.only_new_subscribers; giveaway.only_new_subscribers = giveawayResults.only_new_subscribers;
giveaway.until_date = giveawayResults.until_date; giveaway.until_date = giveawayResults.until_date;
if ((giveawayResults.flags & 32) != 0) {
giveaway.flags |= 32;
giveaway.stars = giveawayResults.stars;
}
} else { } else {
giveaway = (TLRPC.TL_messageMediaGiveaway) messageObject.messageOwner.media; giveaway = (TLRPC.TL_messageMediaGiveaway) messageObject.messageOwner.media;
} }

View file

@ -731,7 +731,7 @@ public class BoostViaGiftsBottomSheet extends BottomSheetWithRecyclerListView im
items.add(Item.asDivider(LocaleController.getString(R.string.BoostingGiveawayShowWinnersHint), false)); items.add(Item.asDivider(LocaleController.getString(R.string.BoostingGiveawayShowWinnersHint), false));
} else { } else {
items.add(Item.asDivider(AndroidUtilities.replaceSingleTag( items.add(Item.asDivider(AndroidUtilities.replaceSingleTag(
LocaleController.getString(R.string.BoostingGiveawayShowWinnersHint) + "\n\n" + getString(R.string.BoostingStoriesFeaturesAndTerms), LocaleController.getString(R.string.BoostingGiveawayShowWinnersHint) + (selectedBoostType != BoostTypeCell.TYPE_STARS ? "\n\n" + getString(R.string.BoostingStoriesFeaturesAndTerms) : ""),
Theme.key_chat_messageLinkIn, 0, () -> { Theme.key_chat_messageLinkIn, 0, () -> {
PremiumPreviewBottomSheet previewBottomSheet = new PremiumPreviewBottomSheet(getBaseFragment(), currentAccount, null, resourcesProvider); PremiumPreviewBottomSheet previewBottomSheet = new PremiumPreviewBottomSheet(getBaseFragment(), currentAccount, null, resourcesProvider);
previewBottomSheet.setOnDismissListener(dialog -> adapter.setPausedStars(false)); previewBottomSheet.setOnDismissListener(dialog -> adapter.setPausedStars(false));

View file

@ -24,13 +24,13 @@ public class BoostTypeSingleCell extends BoostTypeCell {
public void setGiveaway(TL_stories.PrepaidGiveaway prepaidGiveaway) { public void setGiveaway(TL_stories.PrepaidGiveaway prepaidGiveaway) {
subtitleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextGray3, resourcesProvider)); subtitleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextGray3, resourcesProvider));
titleTextView.setText(LocaleController.getString(R.string.BoostingPreparedGiveawayOne));
if (prepaidGiveaway instanceof TL_stories.TL_prepaidStarsGiveaway) { if (prepaidGiveaway instanceof TL_stories.TL_prepaidStarsGiveaway) {
TL_stories.TL_prepaidStarsGiveaway prepaid = (TL_stories.TL_prepaidStarsGiveaway) prepaidGiveaway; TL_stories.TL_prepaidStarsGiveaway prepaid = (TL_stories.TL_prepaidStarsGiveaway) prepaidGiveaway;
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_STARS); avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_STARS);
String subtitle = LocaleController.formatPluralStringComma("BoostingStarsPreparedGiveawaySubscriptionsPlural", (int) prepaid.stars); titleTextView.setText(LocaleController.formatPluralStringComma("BoostingStarsPreparedGiveawaySubscriptionsPlural", (int) prepaid.stars));
setSubtitle(subtitle); setSubtitle(LocaleController.formatPluralString("AmongWinners", prepaid.quantity));
} else if (prepaidGiveaway instanceof TL_stories.TL_prepaidGiveaway) { } else if (prepaidGiveaway instanceof TL_stories.TL_prepaidGiveaway) {
titleTextView.setText(LocaleController.getString(R.string.BoostingPreparedGiveawayOne));
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_GIFT); avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_GIFT);
TL_stories.TL_prepaidGiveaway prepaid = (TL_stories.TL_prepaidGiveaway) prepaidGiveaway; TL_stories.TL_prepaidGiveaway prepaid = (TL_stories.TL_prepaidGiveaway) prepaidGiveaway;
if (prepaid.months == 12) { if (prepaid.months == 12) {

View file

@ -23,6 +23,7 @@ import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
@ -48,6 +49,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
@ -177,6 +179,7 @@ import org.telegram.ui.Components.ArchiveHelp;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.BlurredRecyclerView; import org.telegram.ui.Components.BlurredRecyclerView;
import org.telegram.ui.Components.PermissionRequest;
import org.telegram.ui.Stars.StarsController; import org.telegram.ui.Stars.StarsController;
import org.telegram.ui.Stars.StarsIntroActivity; import org.telegram.ui.Stars.StarsIntroActivity;
import org.telegram.ui.Stories.StealthModeAlert; import org.telegram.ui.Stories.StealthModeAlert;
@ -6897,6 +6900,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} else { } else {
tosAccepted = true; tosAccepted = true;
} }
final NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
if (tosAccepted && folderId == 0 && checkPermission && !onlySelect && Build.VERSION.SDK_INT >= 23) { if (tosAccepted && folderId == 0 && checkPermission && !onlySelect && Build.VERSION.SDK_INT >= 23) {
Activity activity = getParentActivity(); Activity activity = getParentActivity();
if (activity != null) { if (activity != null) {
@ -6912,18 +6916,18 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (hasNotNotificationsPermission || hasNotContactsPermission || hasNotStoragePermission) { if (hasNotNotificationsPermission || hasNotContactsPermission || hasNotStoragePermission) {
askingForPermissions = true; askingForPermissions = true;
if (hasNotNotificationsPermission && NotificationPermissionDialog.shouldAsk(activity)) { if (hasNotNotificationsPermission && NotificationPermissionDialog.shouldAsk(activity)) {
NotificationPermissionDialog sheet = new NotificationPermissionDialog(activity, granted -> { PermissionRequest.requestPermission(Manifest.permission.POST_NOTIFICATIONS, granted -> {
if (granted) { if (!granted) {
showDialog(new NotificationPermissionDialog(activity, !PermissionRequest.canAskPermission(Manifest.permission.POST_NOTIFICATIONS), granted2 -> {
if (!granted2) return;
if (!PermissionRequest.canAskPermission(Manifest.permission.POST_NOTIFICATIONS)) {
PermissionRequest.showPermissionSettings(Manifest.permission.POST_NOTIFICATIONS);
} else {
activity.requestPermissions(new String[] { Manifest.permission.POST_NOTIFICATIONS }, 1); activity.requestPermissions(new String[] { Manifest.permission.POST_NOTIFICATIONS }, 1);
} }
}));
}
}); });
if (showDialog(sheet) == null) {
try {
sheet.show();
} catch (Throwable throwable) {
FileLog.e(throwable);
}
}
} else if (hasNotContactsPermission && askAboutContacts && getUserConfig().syncContacts && activity.shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) { } else if (hasNotContactsPermission && askAboutContacts && getUserConfig().syncContacts && activity.shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) {
AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> { AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> {
askAboutContacts = param != 0; askAboutContacts = param != 0;
@ -6934,7 +6938,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} else if (hasNotStoragePermission && activity.shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { } else if (hasNotStoragePermission && activity.shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
if (activity instanceof BasePermissionsActivity) { if (activity instanceof BasePermissionsActivity) {
BasePermissionsActivity basePermissionsActivity = (BasePermissionsActivity) activity; BasePermissionsActivity basePermissionsActivity = (BasePermissionsActivity) activity;
showDialog(permissionDialog = basePermissionsActivity.createPermissionErrorAlert(R.raw.permission_request_folder, LocaleController.getString(R.string.PermissionStorageWithHint))); showDialog(permissionDialog = basePermissionsActivity.createPermissionErrorAlert(R.raw.permission_request_folder, getString(R.string.PermissionStorageWithHint)));
} }
} else { } else {
askForPermissons(true); askForPermissons(true);
@ -6942,7 +6946,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} }
}, afterSignup && (hasNotContactsPermission || hasNotNotificationsPermission) ? 4000 : 0); }, afterSignup && (hasNotContactsPermission || hasNotNotificationsPermission) ? 4000 : 0);
} }
} else if (!onlySelect && XiaomiUtilities.isMIUI() && Build.VERSION.SDK_INT >= 19 && !XiaomiUtilities.isCustomPermissionGranted(XiaomiUtilities.OP_SHOW_WHEN_LOCKED)) { } else if (!onlySelect && folderId == 0 && XiaomiUtilities.isMIUI() && Build.VERSION.SDK_INT >= 19 && !XiaomiUtilities.isCustomPermissionGranted(XiaomiUtilities.OP_SHOW_WHEN_LOCKED)) {
if (getParentActivity() == null) { if (getParentActivity() == null) {
return; return;
} }
@ -6951,15 +6955,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} }
showDialog(new AlertDialog.Builder(getParentActivity()) showDialog(new AlertDialog.Builder(getParentActivity())
.setTopAnimation(R.raw.permission_request_apk, AlertsCreator.PERMISSIONS_REQUEST_TOP_ICON_SIZE, false, Theme.getColor(Theme.key_dialogTopBackground)) .setTopAnimation(R.raw.permission_request_apk, AlertsCreator.PERMISSIONS_REQUEST_TOP_ICON_SIZE, false, Theme.getColor(Theme.key_dialogTopBackground))
.setMessage(LocaleController.getString(R.string.PermissionXiaomiLockscreen)) .setMessage(getString(R.string.PermissionXiaomiLockscreen))
.setPositiveButton(LocaleController.getString(R.string.PermissionOpenSettings), (dialog, which) -> { .setPositiveButton(getString(R.string.PermissionOpenSettings), (dialog, which) -> {
Intent intent = XiaomiUtilities.getPermissionManagerIntent(); Intent intent = XiaomiUtilities.getPermissionManagerIntent();
if (intent != null) { if (intent != null) {
try { try {
getParentActivity().startActivity(intent); getParentActivity().startActivity(intent);
} catch (Exception x) { } catch (Exception x) {
try { try {
intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName())); intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
getParentActivity().startActivity(intent); getParentActivity().startActivity(intent);
} catch (Exception xx) { } catch (Exception xx) {
@ -6968,7 +6972,30 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} }
} }
}) })
.setNegativeButton(LocaleController.getString(R.string.ContactsPermissionAlertNotNow), (dialog, which) -> MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askedAboutMiuiLockscreen", true).commit()) .setNegativeButton(getString(R.string.ContactsPermissionAlertNotNow), (dialog, which) -> MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askedAboutMiuiLockscreen", true).commit())
.create());
} else if (folderId == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && !notificationManager.canUseFullScreenIntent()) {
if (getParentActivity() == null) {
return;
}
if (MessagesController.getGlobalNotificationsSettings().getBoolean("askedAboutFSILockscreen", false)) {
return;
}
showDialog(new AlertDialog.Builder(getParentActivity())
.setTopAnimation(R.raw.permission_request_apk, AlertsCreator.PERMISSIONS_REQUEST_TOP_ICON_SIZE, false, Theme.getColor(Theme.key_dialogTopBackground))
.setMessage(getString(R.string.PermissionFSILockscreen))
.setPositiveButton(getString(R.string.PermissionOpenSettings), (dialog, which) -> {
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT);
intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
if (intent != null) {
try {
getParentActivity().startActivity(intent);
} catch (Exception x) {
FileLog.e(x);
}
}
})
.setNegativeButton(getString(R.string.ContactsPermissionAlertNotNow), (dialog, which) -> MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askedAboutFSILockscreen", true).commit())
.create()); .create());
} }
showFiltersHint(); showFiltersHint();
@ -7026,6 +7053,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
updateProxyButton(false, true); updateProxyButton(false, true);
updateStoriesVisibility(false); updateStoriesVisibility(false);
checkSuggestClearDatabase(); checkSuggestClearDatabase();
if (filterTabsView != null && viewPages[0] != null && viewPages[0].dialogsAdapter != null) {
int dialogsType = viewPages[0].dialogsAdapter.getDialogsType();
if (dialogsType == DIALOGS_TYPE_FOLDER1 || dialogsType == DIALOGS_TYPE_FOLDER2) {
MessagesController.DialogFilter dialogFilter = getMessagesController().selectedDialogFilter[dialogsType == DIALOGS_TYPE_FOLDER1 ? 0 : 1];
if (dialogFilter != null) {
filterTabsView.selectTabWithStableId(dialogFilter.localId);
}
}
}
} }
@Override @Override
@ -7863,7 +7899,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
int dialogsType = dialogsAdapter.getDialogsType(); int dialogsType = dialogsAdapter.getDialogsType();
if (dialogsType == DIALOGS_TYPE_FOLDER1 || dialogsType == DIALOGS_TYPE_FOLDER2) { if (dialogsType == DIALOGS_TYPE_FOLDER1 || dialogsType == DIALOGS_TYPE_FOLDER2) {
MessagesController.DialogFilter dialogFilter = getMessagesController().selectedDialogFilter[dialogsType == DIALOGS_TYPE_FOLDER1 ? 0 : 1]; MessagesController.DialogFilter dialogFilter = getMessagesController().selectedDialogFilter[dialogsType == DIALOGS_TYPE_FOLDER1 ? 0 : 1];
filterId = dialogFilter != null ? 0 : dialogFilter.id; filterId = dialogFilter == null ? 0 : dialogFilter.id;
} }
TLObject object = dialogsAdapter.getItem(position); TLObject object = dialogsAdapter.getItem(position);
if (object instanceof TLRPC.User) { if (object instanceof TLRPC.User) {
@ -10214,10 +10250,13 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
return; return;
} }
ArrayList<String> permissons = new ArrayList<>(); ArrayList<String> permissons = new ArrayList<>();
if (Build.VERSION.SDK_INT >= 33 && NotificationPermissionDialog.shouldAsk(activity)) { if (folderId == 0 && Build.VERSION.SDK_INT >= 33 && NotificationPermissionDialog.shouldAsk(activity)) {
if (alert) { if (alert) {
showDialog(new NotificationPermissionDialog(activity, granted -> { showDialog(new NotificationPermissionDialog(activity, !PermissionRequest.canAskPermission(Manifest.permission.POST_NOTIFICATIONS), granted2 -> {
if (granted) { if (!granted2) return;
if (!PermissionRequest.canAskPermission(Manifest.permission.POST_NOTIFICATIONS)) {
PermissionRequest.showPermissionSettings(Manifest.permission.POST_NOTIFICATIONS);
} else {
activity.requestPermissions(new String[] { Manifest.permission.POST_NOTIFICATIONS }, 1); activity.requestPermissions(new String[] { Manifest.permission.POST_NOTIFICATIONS }, 1);
} }
})); }));
@ -10270,7 +10309,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
@Override @Override
protected void onDialogDismiss(Dialog dialog) { protected void onDialogDismiss(Dialog dialog) {
super.onDialogDismiss(dialog); super.onDialogDismiss(dialog);
if (permissionDialog != null && dialog == permissionDialog && getParentActivity() != null) { if (folderId == 0 && permissionDialog != null && dialog == permissionDialog && getParentActivity() != null) {
askForPermissons(false); askForPermissons(false);
} }
} }

View file

@ -46,7 +46,7 @@ public class NotificationPermissionDialog extends BottomSheet implements Notific
private RLottieImageView rLottieImageView; private RLottieImageView rLottieImageView;
private Utilities.Callback<Boolean> whenGranted; private Utilities.Callback<Boolean> whenGranted;
public NotificationPermissionDialog(Context context, Utilities.Callback<Boolean> whenGranted) { public NotificationPermissionDialog(Context context, boolean settings, Utilities.Callback<Boolean> whenGranted) {
super(context, false); super(context, false);
this.whenGranted = whenGranted; this.whenGranted = whenGranted;
@ -75,7 +75,7 @@ public class NotificationPermissionDialog extends BottomSheet implements Notific
textView.setTypeface(AndroidUtilities.bold()); textView.setTypeface(AndroidUtilities.bold());
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
textView.setGravity(Gravity.CENTER_HORIZONTAL); textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setText(LocaleController.getString("NotificationsPermissionAlertTitle")); textView.setText(LocaleController.getString(R.string.NotificationsPermissionAlertTitle));
textView.setPadding(AndroidUtilities.dp(30), 0, AndroidUtilities.dp(30), 0); textView.setPadding(AndroidUtilities.dp(30), 0, AndroidUtilities.dp(30), 0);
linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
@ -83,19 +83,19 @@ public class NotificationPermissionDialog extends BottomSheet implements Notific
textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setGravity(Gravity.CENTER_HORIZONTAL); textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setText(LocaleController.getString("NotificationsPermissionAlertSubtitle")); textView.setText(LocaleController.getString(R.string.NotificationsPermissionAlertSubtitle));
textView.setPadding(AndroidUtilities.dp(30), AndroidUtilities.dp(10), AndroidUtilities.dp(30), AndroidUtilities.dp(21)); textView.setPadding(AndroidUtilities.dp(30), AndroidUtilities.dp(10), AndroidUtilities.dp(30), AndroidUtilities.dp(21));
linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
linearLayout.addView(new SectionView(context, R.drawable.msg_message_s, LocaleController.getString("NotificationsPermissionAlert1")), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); linearLayout.addView(new SectionView(context, R.drawable.msg_message_s, LocaleController.getString(R.string.NotificationsPermissionAlert1)), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
linearLayout.addView(new SectionView(context, R.drawable.msg_members_list2, LocaleController.getString("NotificationsPermissionAlert2")), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); linearLayout.addView(new SectionView(context, R.drawable.msg_members_list2, LocaleController.getString(R.string.NotificationsPermissionAlert2)), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
linearLayout.addView(new SectionView(context, R.drawable.msg_customize_s, LocaleController.getString("NotificationsPermissionAlert3")), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); linearLayout.addView(new SectionView(context, R.drawable.msg_customize_s, LocaleController.getString(R.string.NotificationsPermissionAlert3)), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
setCustomView(linearLayout); setCustomView(linearLayout);
fixNavigationBar(getThemedColor(Theme.key_dialogBackground)); fixNavigationBar(getThemedColor(Theme.key_dialogBackground));
textView = new TextView(context); textView = new TextView(context);
textView.setText(LocaleController.getString("NotificationsPermissionContinue")); textView.setText(LocaleController.getString(settings ? R.string.NotificationsPermissionSettings : R.string.NotificationsPermissionContinue));
textView.setGravity(Gravity.CENTER); textView.setGravity(Gravity.CENTER);
textView.setTypeface(AndroidUtilities.bold()); textView.setTypeface(AndroidUtilities.bold());
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
@ -143,7 +143,6 @@ public class NotificationPermissionDialog extends BottomSheet implements Notific
} }
} }
private boolean mayBeAccidentalDismiss;
private long showTime; private long showTime;
@Override @Override
@ -152,22 +151,14 @@ public class NotificationPermissionDialog extends BottomSheet implements Notific
showTime = System.currentTimeMillis(); showTime = System.currentTimeMillis();
} }
@Override
protected void onDismissWithTouchOutside() {
mayBeAccidentalDismiss = (System.currentTimeMillis() - showTime) < 3000L;
super.onDismissWithTouchOutside();
}
@Override @Override
public void dismiss() { public void dismiss() {
super.dismiss(); super.dismiss();
if (whenGranted != null) { if (whenGranted != null) {
whenGranted.run(false); whenGranted.run(false);
whenGranted = null; whenGranted = null;
if (!mayBeAccidentalDismiss) {
askLater(); askLater();
} }
}
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; ++a) { for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; ++a) {
try { try {
NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.updateInterfaces); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.updateInterfaces);

View file

@ -11318,6 +11318,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
long ton_balance = BotStarsController.getInstance(currentAccount).getChannelBalance(did); long ton_balance = BotStarsController.getInstance(currentAccount).getChannelBalance(did);
SpannableStringBuilder ssb = new SpannableStringBuilder(); SpannableStringBuilder ssb = new SpannableStringBuilder();
if (ton_balance > 0) { if (ton_balance > 0) {
if (ton_balance / 1_000_000_000.0 > 1000.0) {
ssb.append("TON ").append(AndroidUtilities.formatWholeNumber((int) (ton_balance / 1_000_000_000.0), 0));
} else {
DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US); DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
symbols.setDecimalSeparator('.'); symbols.setDecimalSeparator('.');
DecimalFormat formatterTON = new DecimalFormat("#.##", symbols); DecimalFormat formatterTON = new DecimalFormat("#.##", symbols);
@ -11326,9 +11329,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
formatterTON.setGroupingUsed(false); formatterTON.setGroupingUsed(false);
ssb.append("TON ").append(formatterTON.format(ton_balance / 1_000_000_000.0)); ssb.append("TON ").append(formatterTON.format(ton_balance / 1_000_000_000.0));
} }
}
if (stars_balance > 0) { if (stars_balance > 0) {
if (ssb.length() > 0) ssb.append(" "); if (ssb.length() > 0) ssb.append(" ");
ssb.append("XTR ").append(LocaleController.formatNumber(stars_balance, ',')); ssb.append("XTR ").append(AndroidUtilities.formatWholeNumber((int) stars_balance, 0));
} }
textCell.setTextAndValueAndIcon(LocaleController.getString(R.string.ChannelStars), ChannelMonetizationLayout.replaceTON(StarsIntroActivity.replaceStarsWithPlain(ssb, .7f), textCell.getTextView().getPaint()), R.drawable.menu_feature_paid, true); textCell.setTextAndValueAndIcon(LocaleController.getString(R.string.ChannelStars), ChannelMonetizationLayout.replaceTON(StarsIntroActivity.replaceStarsWithPlain(ssb, .7f), textCell.getTextView().getPaint()), R.drawable.menu_feature_paid, true);
} else if (position == blockedUsersRow) { } else if (position == blockedUsersRow) {

View file

@ -1875,7 +1875,7 @@ public class StarsController {
final ConnectionsManager connectionsManager = ConnectionsManager.getInstance(currentAccount); final ConnectionsManager connectionsManager = ConnectionsManager.getInstance(currentAccount);
final long totalStars = amount; final long totalStars = amount;
if (starsController.balanceAvailable() && starsController.getBalance() < totalStars) { if (starsController.balanceAvailable() && starsController.getBalance(false) < totalStars) {
cancelled = true; cancelled = true;
messageObject.addPaidReactions((int) -amount, wasChosen, isAnonymous()); messageObject.addPaidReactions((int) -amount, wasChosen, isAnonymous());
@ -1970,7 +1970,7 @@ public class StarsController {
final long totalStars = amount; final long totalStars = amount;
final Context context = getContext(chatActivity); final Context context = getContext(chatActivity);
if (context == null) return null; if (context == null) return null;
if (checkBalance && s.balanceAvailable() && s.getBalance() <= 0) { if (checkBalance && s.balanceAvailable() && s.getBalance(false) <= 0) {
final long dialogId = chatActivity.getDialogId(); final long dialogId = chatActivity.getDialogId();
String name; String name;
if (dialogId >= 0) { if (dialogId >= 0) {

View file

@ -2087,6 +2087,8 @@ public class StarsIntroActivity extends GradientHeaderActivity implements Notifi
} }
} }
super.show(); super.show();
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.starOptionsLoaded);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.starBalanceUpdated);
} }
@Override @Override
@ -2115,8 +2117,6 @@ public class StarsIntroActivity extends GradientHeaderActivity implements Notifi
topPadding = .2f; topPadding = .2f;
this.whenPurchased = whenPurchased; this.whenPurchased = whenPurchased;
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.starOptionsLoaded);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.starBalanceUpdated);
fixNavigationBar(); fixNavigationBar();
recyclerListView.setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0); recyclerListView.setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);

View file

@ -759,7 +759,7 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N
other = menu.addItem(0, R.drawable.ic_ab_other, themeDelegate); other = menu.addItem(0, R.drawable.ic_ab_other, themeDelegate);
other.addSubItem(toggle_id, R.drawable.msg_discussion, LocaleController.getString(R.string.TopicViewAsMessages)); other.addSubItem(toggle_id, R.drawable.msg_discussion, LocaleController.getString(R.string.TopicViewAsMessages));
addMemberSubMenu = other.addSubItem(add_member_id, R.drawable.msg_addcontact, LocaleController.getString(R.string.AddMember)); addMemberSubMenu = other.addSubItem(add_member_id, R.drawable.msg_addcontact, LocaleController.getString(R.string.AddMember));
boostGroupSubmenu = other.addSubItem(boost_group_id, 0, new RLottieDrawable(R.raw.boosts, "" + R.raw.boosts, AndroidUtilities.dp(24), AndroidUtilities.dp(24)), TextCell.applyNewSpan(LocaleController.getString(R.string.BoostingBoostGroupMenu)), true, false); boostGroupSubmenu = other.addSubItem(boost_group_id, 0, new RLottieDrawable(R.raw.boosts, "" + R.raw.boosts, AndroidUtilities.dp(24), AndroidUtilities.dp(24)), LocaleController.getString(R.string.BoostingBoostGroupMenu), true, false);
createTopicSubmenu = other.addSubItem(create_topic_id, R.drawable.msg_topic_create, LocaleController.getString(R.string.CreateTopic)); createTopicSubmenu = other.addSubItem(create_topic_id, R.drawable.msg_topic_create, LocaleController.getString(R.string.CreateTopic));
deleteChatSubmenu = other.addSubItem(delete_chat_id, R.drawable.msg_leave, LocaleController.getString(R.string.LeaveMegaMenu), themeDelegate); deleteChatSubmenu = other.addSubItem(delete_chat_id, R.drawable.msg_leave, LocaleController.getString(R.string.LeaveMegaMenu), themeDelegate);

View file

@ -876,6 +876,7 @@ public class BotWebViewAttachedSheet implements NotificationCenter.NotificationC
jsonObject.put("subtitle_text_color", Theme.blendOver(backgroundColor, Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2, resourcesProvider))); jsonObject.put("subtitle_text_color", Theme.blendOver(backgroundColor, Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2, resourcesProvider)));
jsonObject.put("destructive_text_color", Theme.blendOver(backgroundColor, Theme.getColor(Theme.key_text_RedRegular, resourcesProvider))); jsonObject.put("destructive_text_color", Theme.blendOver(backgroundColor, Theme.getColor(Theme.key_text_RedRegular, resourcesProvider)));
jsonObject.put("section_separator_color", Theme.blendOver(backgroundColor, Theme.getColor(Theme.key_divider, resourcesProvider))); jsonObject.put("section_separator_color", Theme.blendOver(backgroundColor, Theme.getColor(Theme.key_divider, resourcesProvider)));
jsonObject.put("bottom_bar_bg_color", Theme.getColor(Theme.key_windowBackgroundGray, resourcesProvider));
return jsonObject; return jsonObject;
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);

View file

@ -879,6 +879,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
jsonObject.put("subtitle_text_color", Theme.blendOver(backgroundColor, Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2, resourcesProvider))); jsonObject.put("subtitle_text_color", Theme.blendOver(backgroundColor, Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2, resourcesProvider)));
jsonObject.put("destructive_text_color", Theme.blendOver(backgroundColor, Theme.getColor(Theme.key_text_RedRegular, resourcesProvider))); jsonObject.put("destructive_text_color", Theme.blendOver(backgroundColor, Theme.getColor(Theme.key_text_RedRegular, resourcesProvider)));
jsonObject.put("section_separator_color", Theme.blendOver(backgroundColor, Theme.getColor(Theme.key_divider, resourcesProvider))); jsonObject.put("section_separator_color", Theme.blendOver(backgroundColor, Theme.getColor(Theme.key_divider, resourcesProvider)));
jsonObject.put("bottom_bar_bg_color", Theme.getColor(Theme.key_windowBackgroundGray, resourcesProvider));
return jsonObject; return jsonObject;
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);

View file

@ -376,6 +376,7 @@ public class WebInstantView {
webView.setWebViewClient(new WebViewClient() { webView.setWebViewClient(new WebViewClient() {
private boolean firstLoad = true; private boolean firstLoad = true;
private boolean streamLoaded;
@androidx.annotation.Nullable @androidx.annotation.Nullable
@Override @Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) { public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
@ -387,7 +388,24 @@ public class WebInstantView {
final String html = "<script>\n" + script + "\n</script>"; final String html = "<script>\n" + script + "\n</script>";
return new WebResourceResponse("text/html", "UTF-8", new ByteArrayInputStream(html.getBytes(StandardCharsets.UTF_8))); return new WebResourceResponse("text/html", "UTF-8", new ByteArrayInputStream(html.getBytes(StandardCharsets.UTF_8)));
} else if (url != null && url.endsWith("/index.html")) { } else if (url != null && url.endsWith("/index.html")) {
mime = "application/octet-stream";
if (streamLoaded) {
MHTML.Entry entry = mhtml != null ? mhtml.entries.get(0) : null;
if (entry == null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return new WebResourceResponse(mime, "UTF-8", null);
return new WebResourceResponse("text/plain", "utf-8", 404, "Not Found", null, null);
}
try {
requestStream = entry.getInputStream();
} catch (IOException e) {
FileLog.e(e);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return new WebResourceResponse(mime, "UTF-8", null);
return new WebResourceResponse("text/plain", "utf-8", 503, "Server error", null, null);
}
} else {
requestStream = stream; requestStream = stream;
streamLoaded = true;
}
} else { } else {
MHTML.Entry entry = mhtml != null ? mhtml.entriesByLocation.get(url) : null; MHTML.Entry entry = mhtml != null ? mhtml.entriesByLocation.get(url) : null;
if (entry == null) { if (entry == null) {
@ -407,7 +425,7 @@ public class WebInstantView {
return new WebResourceResponse("text/plain", "utf-8", 503, "Server error", null, null); return new WebResourceResponse("text/plain", "utf-8", 503, "Server error", null, null);
} }
} }
return new WebResourceResponse(mime, "UTF-8", requestStream); return new WebResourceResponse(mime, null, requestStream);
} }
}); });
webView.setWebChromeClient(new WebChromeClient() { webView.setWebChromeClient(new WebChromeClient() {

View file

@ -6,9 +6,35 @@ function Readability(e,t){if(t&&t.documentElement)e=t,t=arguments[2];else if(!e|
(async function () { (async function () {
try { try {
const dirty_html = await (await fetch('index.html')).text() const getCharset = document => {
const html = DOMPurify.sanitize(dirty_html, { WHOLE_DOCUMENT: true, ADD_TAGS: ['iframe'] }) let meta = document.querySelector('meta[charset]')
const document = new DOMParser().parseFromString(html, 'text/html') if (meta) return meta.getAttribute('charset') || 'utf-8'
meta = document.querySelector('meta[http-equiv="Content-Type"]')
if (!meta) return 'utf-8'
const props = Object.fromEntries((meta.getAttribute('content') || '').split(/; */g).map(s => {
const index = s.indexOf('=')
if (index < 0) return [s, true]
return [s.substring(0, index), s.substring(index + 1)]
}))
return props.charset || 'utf-8'
}
let dirty_html = await (await fetch('/index.html')).text()
let html = DOMPurify.sanitize(dirty_html, {
WHOLE_DOCUMENT: true,
ADD_TAGS: ['iframe', 'meta'],
ADD_ATTR: ['http-equiv', 'content']
})
let document = new DOMParser().parseFromString(html, 'text/html')
const charset = getCharset(document)
if (['utf-8', 'utf8'].indexOf((charset || '').toLowerCase()) < 0) {
dirty_html = new TextDecoder(charset).decode(await (await fetch('/index.html')).arrayBuffer())
html = DOMPurify.sanitize(dirty_html, {
WHOLE_DOCUMENT: true,
ADD_TAGS: ['iframe', 'meta'],
ADD_ATTR: ['http-equiv', 'content']
})
document = new DOMParser().parseFromString(html, 'text/html')
}
if (!isProbablyReaderable(document)) { if (!isProbablyReaderable(document)) {
console.error('isProbablyReaderable = false') console.error('isProbablyReaderable = false')

View file

@ -314,6 +314,7 @@
<string name="NotificationsPermissionAlert2">Learn when you are mentioned in groups</string> <string name="NotificationsPermissionAlert2">Learn when you are mentioned in groups</string>
<string name="NotificationsPermissionAlert3">Mute specific chats and types of chats</string> <string name="NotificationsPermissionAlert3">Mute specific chats and types of chats</string>
<string name="NotificationsPermissionContinue">Continue</string> <string name="NotificationsPermissionContinue">Continue</string>
<string name="NotificationsPermissionSettings">Open Settings</string>
<string name="YourContacts">Your contacts on Telegram</string> <string name="YourContacts">Your contacts on Telegram</string>
<string name="ConnectingYourContacts">Connecting your contacts...</string> <string name="ConnectingYourContacts">Connecting your contacts...</string>
<string name="ArchiveHintHeader1">This is your Archive</string> <string name="ArchiveHintHeader1">This is your Archive</string>
@ -3784,6 +3785,7 @@
<string name="PermissionDrawAboveOtherAppsGroupCall">Overlay mode lets you use push-to-talk and see who is talking even when you are outside of Telegram.</string> <string name="PermissionDrawAboveOtherAppsGroupCall">Overlay mode lets you use push-to-talk and see who is talking even when you are outside of Telegram.</string>
<string name="PermissionOpenSettings">SETTINGS</string> <string name="PermissionOpenSettings">SETTINGS</string>
<string name="PermissionXiaomiLockscreen">Please allow Telegram to be shown on the lock screen so that calls can work properly.</string> <string name="PermissionXiaomiLockscreen">Please allow Telegram to be shown on the lock screen so that calls can work properly.</string>
<string name="PermissionFSILockscreen">Please allow Telegram to be shown on the lock screen so that calls can work properly.</string>
<string name="PermissionBackgroundLocation">To share your live location in this chat, Telegram needs access to your location all the time, including while the app is in the background.\n\nWe will access your location only for the duration you choose, and you can stop sharing it any time. We won\'t use your location for any purpose other than sharing it in this chat.</string> <string name="PermissionBackgroundLocation">To share your live location in this chat, Telegram needs access to your location all the time, including while the app is in the background.\n\nWe will access your location only for the duration you choose, and you can stop sharing it any time. We won\'t use your location for any purpose other than sharing it in this chat.</string>
<string name="PermissionDrawAboveOtherAppsTitle">Picture-in-Picture</string> <string name="PermissionDrawAboveOtherAppsTitle">Picture-in-Picture</string>
<string name="PermissionDrawAboveOtherAppsGroupCallTitle">Voice Chat Overlay</string> <string name="PermissionDrawAboveOtherAppsGroupCallTitle">Voice Chat Overlay</string>
@ -6445,7 +6447,6 @@
<string name="BoostingBoostsCountTitle_other">%d boosts</string> <string name="BoostingBoostsCountTitle_other">%d boosts</string>
<string name="BoostingSubscriptionsCountPlural_one">%2$s subscription</string> <string name="BoostingSubscriptionsCountPlural_one">%2$s subscription</string>
<string name="BoostingSubscriptionsCountPlural_other">%2$s subscriptions</string> <string name="BoostingSubscriptionsCountPlural_other">%2$s subscriptions</string>
<string name="BoostingStarsPrepaidGiveawayTitle">Prepaid giveaway</string>
<string name="BoostingStarsCountPlural_one">%1$d Star</string> <string name="BoostingStarsCountPlural_one">%1$d Star</string>
<string name="BoostingStarsCountPlural_other">%1$d Stars</string> <string name="BoostingStarsCountPlural_other">%1$d Stars</string>
<string name="BoostingTelegramPremiumCountPlural_one">%1$d Telegram Premium</string> <string name="BoostingTelegramPremiumCountPlural_one">%1$d Telegram Premium</string>

View file

@ -13,8 +13,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true # org.gradle.parallel=true
#Sat Mar 12 05:53:50 MSK 2016 #Sat Mar 12 05:53:50 MSK 2016
APP_VERSION_CODE=5235 APP_VERSION_CODE=5240
APP_VERSION_NAME=11.1.1 APP_VERSION_NAME=11.1.2
APP_PACKAGE=org.telegram.messenger APP_PACKAGE=org.telegram.messenger
IS_PRIVATE=false IS_PRIVATE=false
RELEASE_KEY_PASSWORD=android RELEASE_KEY_PASSWORD=android