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_MEDIA_LOCATION" />
<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"/>

View file

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

View file

@ -15,6 +15,7 @@
<uses-permission android:name="android.permission.ACCESS_FINE_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.USE_FULL_SCREEN_INTENT"/>
<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_MICROPHONE" />
<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"/>

View file

@ -25,6 +25,7 @@
<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.READ_CALL_LOG" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<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);
MessageObject obj = new MessageObject(currentAccount, message, usersDict, true, false);
pushMessages.add(obj);
getMessagesStorage().getStorageQueue().postRunnable(() -> AndroidUtilities.runOnUIThread(() -> getNotificationsController().processNewMessages(pushMessages, true, false, null)));
if (message.from_id.user_id != getUserConfig().getClientUserId()) {
getMessagesStorage().getStorageQueue().postRunnable(() -> AndroidUtilities.runOnUIThread(() -> getNotificationsController().processNewMessages(pushMessages, true, false, null)));
}
getMessagesStorage().putMessages(messagesArr, true, true, false, 0, 0, 0);
} else {
pushMessages = null;

View file

@ -78501,18 +78501,6 @@ public class TLRPC {
public static class TL_messageMediaGiveawayResults_layer186 extends TL_messageMediaGiveawayResults {
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) {
flags = stream.readInt32(exception);
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);
} else if (prepaidGiveaway instanceof TL_stories.TL_prepaidStarsGiveaway) {
TL_stories.TL_prepaidStarsGiveaway starsGiveaway = (TL_stories.TL_prepaidStarsGiveaway) prepaidGiveaway;
String name = LocaleController.getString(R.string.BoostingStarsPrepaidGiveawayTitle);
String info = LocaleController.formatPluralStringComma("BoostingStarsCountPlural", (int) starsGiveaway.stars);
String name = LocaleController.formatPluralStringComma("BoostingStarsCountPlural", (int) starsGiveaway.stars);
String info = LocaleController.formatPluralString("AmongWinners", starsGiveaway.quantity);
giveawayCell.setData(prepaidGiveaway, name, info, 0, !item.isLast);
}
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.FilterCreateActivity;
import org.telegram.ui.PeerColorActivity;
import org.telegram.ui.Stories.recorder.HintView2;
public class TextCell extends FrameLayout {
@ -534,11 +535,16 @@ public class TextCell extends FrameLayout {
offsetFromImage = getOffsetFromImage(false);
textView.setText(text);
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);
valueSpoilersTextView.setVisibility(GONE);
valueImageView.setVisibility(GONE);
imageView.setVisibility(VISIBLE);
imageView.setTranslationX(0);
imageView.setTranslationY(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);
} else if (prepaidGiveaway instanceof TL_stories.TL_prepaidStarsGiveaway) {
TL_stories.TL_prepaidStarsGiveaway starsGiveaway = (TL_stories.TL_prepaidStarsGiveaway) prepaidGiveaway;
String name = LocaleController.getString(R.string.BoostingStarsPrepaidGiveawayTitle);
String info = LocaleController.formatPluralStringComma("BoostingStarsCountPlural", (int) starsGiveaway.stars);
String name = LocaleController.formatPluralStringComma("BoostingStarsCountPlural", (int) starsGiveaway.stars);
String info = LocaleController.formatPluralString("AmongWinners", starsGiveaway.quantity);
giveawayCell.setData(prepaidGiveaway, name, info, 0, !item.isLast);
}
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))) {
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));
updateTranslateItemVisibility();

View file

@ -164,9 +164,9 @@ public class MentionsContainerView extends BlurredFrameLayout implements Notific
@Override
protected int getFlowItemCount() {
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() {
@ -726,7 +726,6 @@ public class MentionsContainerView extends BlurredFrameLayout implements Notific
if (position == 0) {
return;
}
position--;
if (adapter.isStickers()) {
return;
} 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.net.Uri;
import android.os.Build;
import android.provider.Settings;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
@ -115,10 +116,10 @@ public class PermissionRequest {
if (whenDone != null) whenDone.run(true);
return;
}
boolean needsPermissionRationale = true;
boolean needsPermissionRationale = false;
for (String permission : checkPermissions) {
if (!activity.shouldShowRequestPermissionRationale(permission)) {
needsPermissionRationale = false;
if (activity.shouldShowRequestPermissionRationale(permission)) {
needsPermissionRationale = true;
break;
}
}
@ -156,32 +157,46 @@ 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) {
Activity _activity = LaunchActivity.instance;
if (_activity == null) _activity = AndroidUtilities.findActivity(ApplicationLoader.applicationContext);
if (_activity == null) return;
final Activity activity = _activity;
final int code = lastId++;
NotificationCenter.NotificationCenterDelegate[] observer = new NotificationCenter.NotificationCenterDelegate[1];
observer[0] = new NotificationCenter.NotificationCenterDelegate() {
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.activityPermissionsGranted) {
int requestCode = (int) args[0];
String[] permissions = (String[]) args[1];
int[] grantResults = (int[]) args[2];
if (requestCode == code) {
if (whenDone != null) {
whenDone.run(grantResults);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
final int code = lastId++;
NotificationCenter.NotificationCenterDelegate[] observer = new NotificationCenter.NotificationCenterDelegate[1];
observer[0] = new NotificationCenter.NotificationCenterDelegate() {
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.activityPermissionsGranted) {
int requestCode = (int) args[0];
String[] permissions = (String[]) args[1];
int[] grantResults = (int[]) args[2];
if (requestCode == code) {
if (whenDone != null) {
whenDone.run(grantResults);
}
NotificationCenter.getGlobalInstance().removeObserver(observer[0], NotificationCenter.activityPermissionsGranted);
}
NotificationCenter.getGlobalInstance().removeObserver(observer[0], NotificationCenter.activityPermissionsGranted);
}
}
};
NotificationCenter.getGlobalInstance().addObserver(observer[0], NotificationCenter.activityPermissionsGranted);
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;
}
};
NotificationCenter.getGlobalInstance().addObserver(observer[0], NotificationCenter.activityPermissionsGranted);
activity.requestPermissions(permissions, code);
whenDone.run(res);
}
}
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.replaceTags;
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.getString;
import static org.telegram.ui.Components.Premium.boosts.SelectorBottomSheet.TYPE_CHANNEL;
@ -514,7 +515,7 @@ public class BoostDialogs {
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
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 {
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.only_new_subscribers = giveawayResults.only_new_subscribers;
giveaway.until_date = giveawayResults.until_date;
if ((giveawayResults.flags & 32) != 0) {
giveaway.flags |= 32;
giveaway.stars = giveawayResults.stars;
}
} else {
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));
} else {
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, () -> {
PremiumPreviewBottomSheet previewBottomSheet = new PremiumPreviewBottomSheet(getBaseFragment(), currentAccount, null, resourcesProvider);
previewBottomSheet.setOnDismissListener(dialog -> adapter.setPausedStars(false));

View file

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

View file

@ -23,6 +23,7 @@ import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Dialog;
import android.app.NotificationManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -48,6 +49,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
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.BackupImageView;
import org.telegram.ui.Components.BlurredRecyclerView;
import org.telegram.ui.Components.PermissionRequest;
import org.telegram.ui.Stars.StarsController;
import org.telegram.ui.Stars.StarsIntroActivity;
import org.telegram.ui.Stories.StealthModeAlert;
@ -6897,6 +6900,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} else {
tosAccepted = true;
}
final NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
if (tosAccepted && folderId == 0 && checkPermission && !onlySelect && Build.VERSION.SDK_INT >= 23) {
Activity activity = getParentActivity();
if (activity != null) {
@ -6912,18 +6916,18 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (hasNotNotificationsPermission || hasNotContactsPermission || hasNotStoragePermission) {
askingForPermissions = true;
if (hasNotNotificationsPermission && NotificationPermissionDialog.shouldAsk(activity)) {
NotificationPermissionDialog sheet = new NotificationPermissionDialog(activity, granted -> {
if (granted) {
activity.requestPermissions(new String[] { Manifest.permission.POST_NOTIFICATIONS }, 1);
PermissionRequest.requestPermission(Manifest.permission.POST_NOTIFICATIONS, 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);
}
}));
}
});
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)) {
AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> {
askAboutContacts = param != 0;
@ -6934,7 +6938,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} else if (hasNotStoragePermission && activity.shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
if (activity instanceof BasePermissionsActivity) {
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 {
askForPermissons(true);
@ -6942,7 +6946,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
}, 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) {
return;
}
@ -6951,15 +6955,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
showDialog(new AlertDialog.Builder(getParentActivity())
.setTopAnimation(R.raw.permission_request_apk, AlertsCreator.PERMISSIONS_REQUEST_TOP_ICON_SIZE, false, Theme.getColor(Theme.key_dialogTopBackground))
.setMessage(LocaleController.getString(R.string.PermissionXiaomiLockscreen))
.setPositiveButton(LocaleController.getString(R.string.PermissionOpenSettings), (dialog, which) -> {
.setMessage(getString(R.string.PermissionXiaomiLockscreen))
.setPositiveButton(getString(R.string.PermissionOpenSettings), (dialog, which) -> {
Intent intent = XiaomiUtilities.getPermissionManagerIntent();
if (intent != null) {
try {
getParentActivity().startActivity(intent);
} catch (Exception x) {
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()));
getParentActivity().startActivity(intent);
} catch (Exception xx) {
@ -6968,8 +6972,31 @@ 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());
}
showFiltersHint();
if (viewPages != null) {
@ -7026,6 +7053,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
updateProxyButton(false, true);
updateStoriesVisibility(false);
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
@ -7863,7 +7899,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
int dialogsType = dialogsAdapter.getDialogsType();
if (dialogsType == DIALOGS_TYPE_FOLDER1 || dialogsType == DIALOGS_TYPE_FOLDER2) {
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);
if (object instanceof TLRPC.User) {
@ -10214,10 +10250,13 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
return;
}
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) {
showDialog(new NotificationPermissionDialog(activity, 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);
}
}));
@ -10270,7 +10309,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
@Override
protected void onDialogDismiss(Dialog dialog) {
super.onDialogDismiss(dialog);
if (permissionDialog != null && dialog == permissionDialog && getParentActivity() != null) {
if (folderId == 0 && permissionDialog != null && dialog == permissionDialog && getParentActivity() != null) {
askForPermissons(false);
}
}

View file

@ -46,7 +46,7 @@ public class NotificationPermissionDialog extends BottomSheet implements Notific
private RLottieImageView rLottieImageView;
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);
this.whenGranted = whenGranted;
@ -75,7 +75,7 @@ public class NotificationPermissionDialog extends BottomSheet implements Notific
textView.setTypeface(AndroidUtilities.bold());
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
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);
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.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
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));
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_members_list2, LocaleController.getString("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_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(R.string.NotificationsPermissionAlert2)), 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);
fixNavigationBar(getThemedColor(Theme.key_dialogBackground));
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.setTypeface(AndroidUtilities.bold());
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
@ -143,7 +143,6 @@ public class NotificationPermissionDialog extends BottomSheet implements Notific
}
}
private boolean mayBeAccidentalDismiss;
private long showTime;
@Override
@ -152,21 +151,13 @@ public class NotificationPermissionDialog extends BottomSheet implements Notific
showTime = System.currentTimeMillis();
}
@Override
protected void onDismissWithTouchOutside() {
mayBeAccidentalDismiss = (System.currentTimeMillis() - showTime) < 3000L;
super.onDismissWithTouchOutside();
}
@Override
public void dismiss() {
super.dismiss();
if (whenGranted != null) {
whenGranted.run(false);
whenGranted = null;
if (!mayBeAccidentalDismiss) {
askLater();
}
askLater();
}
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; ++a) {
try {

View file

@ -11318,17 +11318,21 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
long ton_balance = BotStarsController.getInstance(currentAccount).getChannelBalance(did);
SpannableStringBuilder ssb = new SpannableStringBuilder();
if (ton_balance > 0) {
DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
symbols.setDecimalSeparator('.');
DecimalFormat formatterTON = new DecimalFormat("#.##", symbols);
formatterTON.setMinimumFractionDigits(2);
formatterTON.setMaximumFractionDigits(3);
formatterTON.setGroupingUsed(false);
ssb.append("TON ").append(formatterTON.format(ton_balance / 1_000_000_000.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);
symbols.setDecimalSeparator('.');
DecimalFormat formatterTON = new DecimalFormat("#.##", symbols);
formatterTON.setMinimumFractionDigits(2);
formatterTON.setMaximumFractionDigits(3);
formatterTON.setGroupingUsed(false);
ssb.append("TON ").append(formatterTON.format(ton_balance / 1_000_000_000.0));
}
}
if (stars_balance > 0) {
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);
} else if (position == blockedUsersRow) {

View file

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

View file

@ -2087,6 +2087,8 @@ public class StarsIntroActivity extends GradientHeaderActivity implements Notifi
}
}
super.show();
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.starOptionsLoaded);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.starBalanceUpdated);
}
@Override
@ -2115,8 +2117,6 @@ public class StarsIntroActivity extends GradientHeaderActivity implements Notifi
topPadding = .2f;
this.whenPurchased = whenPurchased;
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.starOptionsLoaded);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.starBalanceUpdated);
fixNavigationBar();
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.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));
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));
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("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("bottom_bar_bg_color", Theme.getColor(Theme.key_windowBackgroundGray, resourcesProvider));
return jsonObject;
} catch (Exception 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("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("bottom_bar_bg_color", Theme.getColor(Theme.key_windowBackgroundGray, resourcesProvider));
return jsonObject;
} catch (Exception e) {
FileLog.e(e);

View file

@ -376,6 +376,7 @@ public class WebInstantView {
webView.setWebViewClient(new WebViewClient() {
private boolean firstLoad = true;
private boolean streamLoaded;
@androidx.annotation.Nullable
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
@ -387,7 +388,24 @@ public class WebInstantView {
final String html = "<script>\n" + script + "\n</script>";
return new WebResourceResponse("text/html", "UTF-8", new ByteArrayInputStream(html.getBytes(StandardCharsets.UTF_8)));
} else if (url != null && url.endsWith("/index.html")) {
requestStream = stream;
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;
streamLoaded = true;
}
} else {
MHTML.Entry entry = mhtml != null ? mhtml.entriesByLocation.get(url) : 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(mime, "UTF-8", requestStream);
return new WebResourceResponse(mime, null, requestStream);
}
});
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 () {
try {
const dirty_html = await (await fetch('index.html')).text()
const html = DOMPurify.sanitize(dirty_html, { WHOLE_DOCUMENT: true, ADD_TAGS: ['iframe'] })
const document = new DOMParser().parseFromString(html, 'text/html')
const getCharset = document => {
let meta = document.querySelector('meta[charset]')
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)) {
console.error('isProbablyReaderable = false')

View file

@ -314,6 +314,7 @@
<string name="NotificationsPermissionAlert2">Learn when you are mentioned in groups</string>
<string name="NotificationsPermissionAlert3">Mute specific chats and types of chats</string>
<string name="NotificationsPermissionContinue">Continue</string>
<string name="NotificationsPermissionSettings">Open Settings</string>
<string name="YourContacts">Your contacts on Telegram</string>
<string name="ConnectingYourContacts">Connecting your contacts...</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="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="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="PermissionDrawAboveOtherAppsTitle">Picture-in-Picture</string>
<string name="PermissionDrawAboveOtherAppsGroupCallTitle">Voice Chat Overlay</string>
@ -6445,7 +6447,6 @@
<string name="BoostingBoostsCountTitle_other">%d boosts</string>
<string name="BoostingSubscriptionsCountPlural_one">%2$s subscription</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_other">%1$d Stars</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
# org.gradle.parallel=true
#Sat Mar 12 05:53:50 MSK 2016
APP_VERSION_CODE=5235
APP_VERSION_NAME=11.1.1
APP_VERSION_CODE=5240
APP_VERSION_NAME=11.1.2
APP_PACKAGE=org.telegram.messenger
IS_PRIVATE=false
RELEASE_KEY_PASSWORD=android