1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-04 11:13:36 +00:00

Update to 8.3.1

This commit is contained in:
xaxtix 2021-12-09 19:28:33 +03:00
parent 3477d72367
commit 4a43f809b3
35 changed files with 1206 additions and 870 deletions

View File

@ -299,7 +299,7 @@ android {
} }
} }
defaultConfig.versionCode = 2493 defaultConfig.versionCode = 2495
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.all { output -> variant.outputs.all { output ->
@ -318,7 +318,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 30 targetSdkVersion 30
versionName "8.3.0" versionName "8.3.1"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

View File

@ -10,12 +10,12 @@
<uses-feature android:name="android.hardware.LOCATION" android:required="false" /> <uses-feature android:name="android.hardware.LOCATION" android:required="false" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE"/> <uses-permission android:name="${applicationId}.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<application <application
android:allowBackup="false" android:allowBackup="false"

View File

@ -10,7 +10,7 @@
<uses-feature android:name="android.hardware.LOCATION" android:required="false" /> <uses-feature android:name="android.hardware.LOCATION" android:required="false" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE"/> <uses-permission android:name="${applicationId}.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

View File

@ -10,12 +10,12 @@
<uses-feature android:name="android.hardware.LOCATION" android:required="false" /> <uses-feature android:name="android.hardware.LOCATION" android:required="false" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE"/> <uses-permission android:name="${applicationId}.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<application <application
android:allowBackup="false" android:allowBackup="false"

View File

@ -10,7 +10,7 @@
<uses-feature android:name="android.hardware.LOCATION" android:required="false" /> <uses-feature android:name="android.hardware.LOCATION" android:required="false" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE"/> <uses-permission android:name="${applicationId}.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
@ -18,7 +18,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" /> <uses-permission android:name="android.permission.READ_CALL_LOG" />
<permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<application <application
android:allowBackup="false" android:allowBackup="false"

View File

@ -10,7 +10,7 @@
<uses-feature android:name="android.hardware.LOCATION" android:required="false" /> <uses-feature android:name="android.hardware.LOCATION" android:required="false" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE"/> <uses-permission android:name="${applicationId}.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
@ -18,7 +18,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" /> <uses-permission android:name="android.permission.READ_CALL_LOG" />
<permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<application <application
android:allowBackup="false" android:allowBackup="false"

View File

@ -67,7 +67,7 @@
<uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS"/> <uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS"/>
<uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_READ"/> <uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_READ"/>
<uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_WRITE"/> <uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_WRITE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
@ -80,6 +80,7 @@
android:manageSpaceActivity="org.telegram.ui.ExternalActionActivity" android:manageSpaceActivity="org.telegram.ui.ExternalActionActivity"
android:supportsRtl="false" android:supportsRtl="false"
android:requestLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"
android:preserveLegacyExternalStorage="true"
android:allowAudioPlaybackCapture="true" android:allowAudioPlaybackCapture="true"
tools:replace="android:supportsRtl"> tools:replace="android:supportsRtl">
@ -448,6 +449,7 @@
<!-- <service android:name=".FeedWidgetService"--> <!-- <service android:name=".FeedWidgetService"-->
<!-- android:permission="android.permission.BIND_REMOTEVIEWS"--> <!-- android:permission="android.permission.BIND_REMOTEVIEWS"-->
<!-- android:exported="false" />--> <!-- android:exported="false" />-->
<service android:name=".FilesMigrationService" android:exported="false"/>
<uses-library android:name="com.sec.android.app.multiwindow" android:required="false" /> <uses-library android:name="com.sec.android.app.multiwindow" android:required="false" />
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true" /> <meta-data android:name="com.sec.android.support.multiwindow" android:value="true" />

View File

@ -19,18 +19,14 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true; public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true; public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29; public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 2493; public static int BUILD_VERSION = 2495;
public static String BUILD_VERSION_STRING = "8.3.0"; public static String BUILD_VERSION_STRING = "8.3.1";
public static int APP_ID = 4; public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
public static String APPCENTER_HASH = "a5b5c4f5-51da-dedc-9918-d9766a22ca7c"; public static String APPCENTER_HASH = "a5b5c4f5-51da-dedc-9918-d9766a22ca7c";
// PUBLIC
public static boolean DEBUG_PRIVATE_VERSION = false; public static boolean DEBUG_PRIVATE_VERSION = false;
// public static String APPCENTER_HASH_DEBUG = "f9726602-67c9-48d2-b5d0-4761f1c1a8f3";
// PRIVATE
//public static boolean DEBUG_PRIVATE_VERSION = true;
//public static String APPCENTER_HASH_DEBUG = DEBUG_PRIVATE_VERSION ? "29d0a6f1-b92f-493a-9fce-445681d767ec" : "f9726602-67c9-48d2-b5d0-4761f1c1a8f3";
//
public static String SMS_HASH = isStandaloneApp() ? "w0lkcmTZkKh" : (DEBUG_VERSION ? "O2P2z+/jBpJ" : "oLeq9AcOZkT"); public static String SMS_HASH = isStandaloneApp() ? "w0lkcmTZkKh" : (DEBUG_VERSION ? "O2P2z+/jBpJ" : "oLeq9AcOZkT");
public static String PLAYSTORE_APP_URL = "https://play.google.com/store/apps/details?id=org.telegram.messenger"; public static String PLAYSTORE_APP_URL = "https://play.google.com/store/apps/details?id=org.telegram.messenger";

View File

@ -166,7 +166,7 @@ public class FileLog {
if (!BuildVars.LOGS_ENABLED) { if (!BuildVars.LOGS_ENABLED) {
return; return;
} }
if (BuildVars.DEBUG_VERSION && needSent(e)) { if (BuildVars.DEBUG_VERSION && needSent(e) && logToAppCenter) {
AndroidUtilities.appCenterLog(e); AndroidUtilities.appCenterLog(e);
} }
ensureInitied(); ensureInitied();

View File

@ -0,0 +1,315 @@
package org.telegram.messenger;
import android.Manifest;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Environment;
import android.os.IBinder;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.graphics.ColorUtils;
import com.google.android.exoplayer2.util.Log;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.BottomSheet;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.StickerImageView;
import org.telegram.ui.DialogsActivity;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.stream.Stream;
@RequiresApi(api = Build.VERSION_CODES.R)
public class FilesMigrationService extends Service {
public static boolean hasOldFolder;
public static boolean isRunning;
public static FilesMigrationBottomSheet filesMigrationBottomSheet;
private int totalFilesCount;
private int movedFilesCount;
private static boolean wasShown = false;
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
public static void start() {
Intent intent = new Intent(ApplicationLoader.applicationContext, FilesMigrationService.class);
ApplicationLoader.applicationContext.startService(intent);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
NotificationsController.checkOtherNotificationsChannel();
Notification notification = new Notification.Builder(this, NotificationsController.OTHER_NOTIFICATIONS_CHANNEL)
.setContentTitle(getText(R.string.MigratingFiles))
.setAutoCancel(false)
.setSmallIcon(R.drawable.notification)
.build();
isRunning = true;
new Thread() {
@Override
public void run() {
migrateOldFolder();
AndroidUtilities.runOnUIThread(() -> {
isRunning = false;
stopForeground(true);
stopSelf();
});
}
}.start();
startForeground(301, notification);
return super.onStartCommand(intent, flags, startId);
}
public void migrateOldFolder() {
File path = Environment.getExternalStorageDirectory();
if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
ArrayList<File> dirs = AndroidUtilities.getRootDirs();
if (dirs != null) {
for (int a = 0, N = dirs.size(); a < N; a++) {
File dir = dirs.get(a);
if (dir.getAbsolutePath().startsWith(SharedConfig.storageCacheDir)) {
path = dir;
break;
}
}
}
}
File newPath = ApplicationLoader.applicationContext.getExternalFilesDir(null);
File telegramPath = new File(newPath, "Telegram");
File oldPath = new File(path, "Telegram");
totalFilesCount = getFilesCount(oldPath);
long moveStart = System.currentTimeMillis();
if (oldPath.canRead() && oldPath.canWrite()) {
moveDirectory(oldPath, telegramPath);
}
long dt = System.currentTimeMillis() - moveStart;
FileLog.d("move time = " + dt);
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE);
sharedPreferences.edit().putBoolean("migration_to_scoped_storage_finished", true).apply();
}
private int getFilesCount(File source) {
if (!source.exists()) {
return 0;
}
int count = 0;
File[] fileList = source.listFiles();
if (fileList != null) {
for (int i = 0; i < fileList.length; i++) {
if (fileList[i].isDirectory()) {
count += getFilesCount(fileList[i]);
} else {
count++;
}
}
}
return count;
}
private void moveDirectory(File source, File target) {
if (!source.exists() || (!target.exists() && !target.mkdir())) {
return;
}
try (Stream<Path> files = Files.list(source.toPath())) {
files.forEach(path -> {
File dest = new File(target, path.getFileName().toString());
if (Files.isDirectory(path)) {
moveDirectory(path.toFile(), dest);
} else {
try {
Files.move(path, dest.toPath());
} catch (Exception e) {
FileLog.e(e, false);
try {
path.toFile().delete();
} catch (Exception e1) {
FileLog.e(e1);
}
}
movedFilesCount++;
updateProgress();
}
});
} catch (Exception e) {
FileLog.e(e);
}
try {
source.delete();
} catch (Exception e) {
FileLog.e(e);
}
}
long lastUpdateTime;
private void updateProgress() {
long time = System.currentTimeMillis();
if (time - lastUpdateTime > 20 || movedFilesCount >= totalFilesCount - 1) {
int currentCount = movedFilesCount;
AndroidUtilities.runOnUIThread(() -> {
Notification notification = new Notification.Builder(FilesMigrationService.this, NotificationsController.OTHER_NOTIFICATIONS_CHANNEL)
.setContentTitle(getText(R.string.MigratingFiles))
.setContentText(String.format("%s/%s", currentCount, totalFilesCount))
.setSmallIcon(R.drawable.notification)
.setAutoCancel(false)
.setProgress(totalFilesCount, currentCount, false)
.build();
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(301, notification);
});
}
}
public static void checkBottomSheet(BaseFragment fragment) {
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE);
if (!Environment.isExternalStorageLegacy() || sharedPreferences.getBoolean("migration_to_scoped_storage_finished", false) || sharedPreferences.getInt("migration_to_scoped_storage_count", 0) >= 5 || wasShown || filesMigrationBottomSheet != null || isRunning) {
return;
}
if (Build.VERSION.SDK_INT >= 30) {
File path = Environment.getExternalStorageDirectory();
if (!TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
ArrayList<File> dirs = AndroidUtilities.getRootDirs();
if (dirs != null) {
for (int a = 0, N = dirs.size(); a < N; a++) {
File dir = dirs.get(a);
if (dir.getAbsolutePath().startsWith(SharedConfig.storageCacheDir)) {
path = dir;
break;
}
}
}
}
File oldDirectory = new File(path, "Telegram");
hasOldFolder = oldDirectory.exists();
}
if (hasOldFolder) {
filesMigrationBottomSheet = new FilesMigrationBottomSheet(fragment);
filesMigrationBottomSheet.show();
wasShown = true;
sharedPreferences.edit().putInt("migration_to_scoped_storage_count", sharedPreferences.getInt("migration_to_scoped_storage_count", 0) + 1).apply();
} else {
sharedPreferences.edit().putBoolean("migration_to_scoped_storage_finished", true).apply();
}
}
public static class FilesMigrationBottomSheet extends BottomSheet {
BaseFragment fragment;
@Override
protected boolean canDismissWithSwipe() {
return false;
}
@Override
protected boolean canDismissWithTouchOutside() {
return false;
}
public FilesMigrationBottomSheet(BaseFragment fragment) {
super(fragment.getParentActivity(), false);
this.fragment = fragment;
setCanceledOnTouchOutside(false);
Context context = fragment.getParentActivity();
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
StickerImageView imageView = new StickerImageView(context, currentAccount);
imageView.setStickerNum(7);
imageView.getImageReceiver().setAutoRepeat(1);
linearLayout.addView(imageView, LayoutHelper.createLinear(144, 144, Gravity.CENTER_HORIZONTAL, 0, 16, 0, 0));
TextView title = new TextView(context);
title.setGravity(Gravity.START);
title.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
title.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
title.setText(LocaleController.getString("MigrateOldFolderTitle", R.string.MigrateOldFolderTitle));
linearLayout.addView(title, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 21, 30, 21, 0));
TextView description = new TextView(context);
description.setGravity(Gravity.START);
description.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
description.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
description.setText(AndroidUtilities.replaceTags(LocaleController.getString("MigrateOldFolderDescription", R.string.MigrateOldFolderDescription)));
linearLayout.addView(description, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 21, 15, 21, 16));
TextView buttonTextView = new TextView(context);
buttonTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0);
buttonTextView.setGravity(Gravity.CENTER);
buttonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
buttonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
buttonTextView.setText(LocaleController.getString("MigrateOldFolderButton", R.string.MigrateOldFolderButton));
buttonTextView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
buttonTextView.setBackgroundDrawable(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_featuredStickers_addButton), ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_windowBackgroundWhite), 120)));
linearLayout.addView(buttonTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, 0, 16, 15, 16, 16));
buttonTextView.setOnClickListener(view -> {
migrateOldFolder();
});
ScrollView scrollView = new ScrollView(context);
scrollView.addView(linearLayout);
setCustomView(scrollView);
}
public void migrateOldFolder() {
Activity activity = fragment.getParentActivity();
boolean canWrite = activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
boolean canRead = activity.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
if (!canRead || !canWrite) {
ArrayList<String> permissions = new ArrayList<>();
if (!canRead) {
permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE);
}
if (!canWrite) {
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
String[] string = new String[permissions.size()];
activity.requestPermissions(permissions.toArray(string), 4);
return;
}
start();
dismiss();
}
@Override
public void dismiss() {
super.dismiss();
filesMigrationBottomSheet = null;
}
}
}

View File

@ -4722,20 +4722,26 @@ public class MessagesController extends BaseController implements NotificationCe
}); });
} }
public void deleteUserChannelHistory(TLRPC.Chat chat, TLRPC.User user, int offset) { public void deleteUserChannelHistory(TLRPC.Chat currentChat, TLRPC.User fromUser, TLRPC.Chat fromChat, int offset) {
long fromId = 0;
if (fromUser != null) {
fromId = fromUser.id;
} else if (fromChat != null){
fromId = fromChat.id;
}
if (offset == 0) { if (offset == 0) {
getMessagesStorage().deleteUserChatHistory(-chat.id, user.id); getMessagesStorage().deleteUserChatHistory(-currentChat.id, fromId);
} }
TLRPC.TL_channels_deleteParticipantHistory req = new TLRPC.TL_channels_deleteParticipantHistory(); TLRPC.TL_channels_deleteParticipantHistory req = new TLRPC.TL_channels_deleteParticipantHistory();
req.channel = getInputChannel(chat); req.channel = getInputChannel(currentChat);
req.participant = getInputPeer(user); req.participant = fromUser != null ? getInputPeer(fromUser) : getInputPeer(fromChat);
getConnectionsManager().sendRequest(req, (response, error) -> { getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) { if (error == null) {
TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response; TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response;
if (res.offset > 0) { if (res.offset > 0) {
deleteUserChannelHistory(chat, user, res.offset); deleteUserChannelHistory(currentChat, fromUser, fromChat, res.offset);
} }
processNewChannelDifferenceParams(res.pts, res.pts_count, chat.id); processNewChannelDifferenceParams(res.pts, res.pts_count, currentChat.id);
} }
}); });
} }
@ -14810,10 +14816,7 @@ public class MessagesController extends BaseController implements NotificationCe
} }
public void markSponsoredAsRead(long dialog_id, MessageObject object) { public void markSponsoredAsRead(long dialog_id, MessageObject object) {
ArrayList<MessageObject> messages = getSponsoredMessages(dialog_id); sponsoredMessages.remove(dialog_id);
if (messages != null) {
messages.remove(object);
}
} }
public void deleteMessagesRange(long dialogId, long channelId, int minDate, int maxDate, boolean forAll, Runnable callback) { public void deleteMessagesRange(long dialogId, long channelId, int minDate, int maxDate, boolean forAll, Runnable callback) {

View File

@ -292,7 +292,7 @@ public class MessagesStorage extends BaseController {
shmCacheFile = new File(filesDir, "cache4.db-shm"); shmCacheFile = new File(filesDir, "cache4.db-shm");
boolean createTable = false; boolean createTable = false;
//cacheFile.delete();
if (!cacheFile.exists()) { if (!cacheFile.exists()) {
createTable = true; createTable = true;
} }
@ -452,6 +452,9 @@ public class MessagesStorage extends BaseController {
} }
cursor.dispose(); cursor.dispose();
} catch (Exception e) { } catch (Exception e) {
if (e.getMessage() != null && e.getMessage().contains("malformed")) {
throw new RuntimeException("malformed");
}
FileLog.e(e); FileLog.e(e);
try { try {
database.executeFast("CREATE TABLE IF NOT EXISTS params(id INTEGER PRIMARY KEY, seq INTEGER, pts INTEGER, date INTEGER, qts INTEGER, lsv INTEGER, sg INTEGER, pbytes BLOB)").stepThis().dispose(); database.executeFast("CREATE TABLE IF NOT EXISTS params(id INTEGER PRIMARY KEY, seq INTEGER, pts INTEGER, date INTEGER, qts INTEGER, lsv INTEGER, sg INTEGER, pbytes BLOB)").stepThis().dispose();
@ -6015,6 +6018,9 @@ public class MessagesStorage extends BaseController {
participant = TLRPC.ChannelParticipant.TLdeserialize(data, data.readInt32(false), false); participant = TLRPC.ChannelParticipant.TLdeserialize(data, data.readInt32(false), false);
data.reuse(); data.reuse();
} }
if (participant != null && participant.user_id == getUserConfig().clientUserId) {
user = getUserConfig().getCurrentUser();
}
if (user != null && participant != null) { if (user != null && participant != null) {
if (user.status != null) { if (user.status != null) {
user.status.expires = cursor.intValue(1); user.status.expires = cursor.intValue(1);
@ -8748,7 +8754,7 @@ public class MessagesStorage extends BaseController {
try { try {
SQLitePreparedStatement state = database.executeFast("UPDATE messages_v2 SET replies_data = ? WHERE mid = ? AND uid = ?"); SQLitePreparedStatement state = database.executeFast("UPDATE messages_v2 SET replies_data = ? WHERE mid = ? AND uid = ?");
TLRPC.MessageReplies currentReplies = null; TLRPC.MessageReplies currentReplies = null;
SQLiteCursor cursor = database.queryFinalized(String.format("SELECT replies_data FROM messages_v2 WHERE mid = %d AND uid = %d", mid, -chatId)); SQLiteCursor cursor = database.queryFinalized(String.format(Locale.ENGLISH, "SELECT replies_data FROM messages_v2 WHERE mid = %d AND uid = %d", mid, -chatId));
if (cursor.next()) { if (cursor.next()) {
NativeByteBuffer data = cursor.byteBufferValue(0); NativeByteBuffer data = cursor.byteBufferValue(0);
if (data != null) { if (data != null) {

View File

@ -13,6 +13,8 @@ import androidx.annotation.UiThread;
import android.os.SystemClock; import android.os.SystemClock;
import android.util.SparseArray; import android.util.SparseArray;
import com.google.android.exoplayer2.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;

View File

@ -1025,7 +1025,7 @@ public class ConnectionsManager extends BaseController {
httpConnectionStream.close(); httpConnectionStream.close();
} }
} catch (Throwable e) { } catch (Throwable e) {
FileLog.e(e); FileLog.e(e, false);
} }
try { try {
if (outbuf != null) { if (outbuf != null) {

View File

@ -49905,29 +49905,29 @@ public class TLRPC {
} }
} }
public static class TL_channels_reportSpam extends TLObject { public static class TL_channels_reportSpam extends TLObject {
public static int constructor = 0xfe087810; public static int constructor = 0xf44a8315;
public InputChannel channel; public InputChannel channel;
public InputUser user_id; public InputPeer participant;
public ArrayList<Integer> id = new ArrayList<>(); public ArrayList<Integer> id = new ArrayList<>();
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Bool.TLdeserialize(stream, constructor, exception); return Bool.TLdeserialize(stream, constructor, exception);
} }
public void serializeToStream(AbstractSerializedData stream) { public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor); stream.writeInt32(constructor);
channel.serializeToStream(stream); channel.serializeToStream(stream);
user_id.serializeToStream(stream); participant.serializeToStream(stream);
stream.writeInt32(0x1cb5c415); stream.writeInt32(0x1cb5c415);
int count = id.size(); int count = id.size();
stream.writeInt32(count); stream.writeInt32(count);
for (int a = 0; a < count; a++) { for (int a = 0; a < count; a++) {
stream.writeInt32(id.get(a)); stream.writeInt32(id.get(a));
} }
} }
} }
public static class TL_channels_getMessages extends TLObject { public static class TL_channels_getMessages extends TLObject {
public static int constructor = 0x93d7b347; public static int constructor = 0x93d7b347;

View File

@ -1590,6 +1590,7 @@ public class ActionBarMenuItem extends FrameLayout {
if (view != null && view.getVisibility() != GONE) { if (view != null && view.getVisibility() != GONE) {
view.setVisibility(GONE); view.setVisibility(GONE);
measurePopup = true; measurePopup = true;
checkHideMenuItem();
} }
} }
@ -1618,6 +1619,7 @@ public class ActionBarMenuItem extends FrameLayout {
popupLayout.getItemAt(a).setVisibility(GONE); popupLayout.getItemAt(a).setVisibility(GONE);
} }
measurePopup = true; measurePopup = true;
checkHideMenuItem();
} }
public boolean isSubItemVisible(int id) { public boolean isSubItemVisible(int id) {
@ -1636,6 +1638,7 @@ public class ActionBarMenuItem extends FrameLayout {
if (view != null && view.getVisibility() != VISIBLE) { if (view != null && view.getVisibility() != VISIBLE) {
view.setVisibility(VISIBLE); view.setVisibility(VISIBLE);
measurePopup = true; measurePopup = true;
checkHideMenuItem();
} }
} }

View File

@ -10,13 +10,11 @@ package org.telegram.ui;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri; import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.os.Environment; import android.os.Environment;
import android.os.StatFs; import android.os.StatFs;
import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.transition.ChangeBounds; import android.transition.ChangeBounds;
import android.transition.Fade; import android.transition.Fade;
@ -25,7 +23,6 @@ import android.transition.TransitionSet;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
@ -35,18 +32,14 @@ import androidx.core.widget.NestedScrollView;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.google.android.exoplayer2.util.Log;
import org.telegram.SQLite.SQLiteCursor; import org.telegram.SQLite.SQLiteCursor;
import org.telegram.SQLite.SQLiteDatabase; import org.telegram.SQLite.SQLiteDatabase;
import org.telegram.SQLite.SQLitePreparedStatement; import org.telegram.SQLite.SQLitePreparedStatement;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.DialogObject; import org.telegram.messenger.DialogObject;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.FilesMigrationService;
import org.telegram.messenger.ImageLoader; import org.telegram.messenger.ImageLoader;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MediaDataController;
@ -79,11 +72,7 @@ import org.telegram.ui.Components.StroageUsageView;
import org.telegram.ui.Components.UndoView; import org.telegram.ui.Components.UndoView;
import java.io.File; import java.io.File;
import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.stream.Stream;
public class CacheControlActivity extends BaseFragment { public class CacheControlActivity extends BaseFragment {
@ -118,7 +107,6 @@ public class CacheControlActivity extends BaseFragment {
private boolean calculating = true; private boolean calculating = true;
private volatile boolean canceled = false; private volatile boolean canceled = false;
private boolean hasOldFolder;
private View bottomSheetView; private View bottomSheetView;
private BottomSheet bottomSheet; private BottomSheet bottomSheet;
@ -213,24 +201,6 @@ public class CacheControlActivity extends BaseFragment {
}); });
fragmentCreateTime = System.currentTimeMillis(); fragmentCreateTime = System.currentTimeMillis();
if (Build.VERSION.SDK_INT >= 30) {
File path = Environment.getExternalStorageDirectory();
if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
ArrayList<File> dirs = AndroidUtilities.getRootDirs();
if (dirs != null) {
for (int a = 0, N = dirs.size(); a < N; a++) {
File dir = dirs.get(a);
if (dir.getAbsolutePath().startsWith(SharedConfig.storageCacheDir)) {
path = dir;
break;
}
}
}
}
File oldDirectory = new File(path, "Telegram");
hasOldFolder = oldDirectory.exists();
}
updateRows(); updateRows();
return true; return true;
} }
@ -247,21 +217,18 @@ public class CacheControlActivity extends BaseFragment {
cacheInfoRow = rowCount++; cacheInfoRow = rowCount++;
databaseRow = rowCount++; databaseRow = rowCount++;
databaseInfoRow = rowCount++; databaseInfoRow = rowCount++;
// if (hasOldFolder) {
// migrateOldFolderRow = rowCount++;
// }
} }
private void updateStorageUsageRow() { private void updateStorageUsageRow() {
View view = layoutManager.findViewByPosition(storageUsageRow); View view = layoutManager.findViewByPosition(storageUsageRow);
if (view instanceof StroageUsageView) { if (view instanceof StroageUsageView) {
StroageUsageView stroageUsageView = ((StroageUsageView) view); StroageUsageView stroageUsageView = ((StroageUsageView) view);
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && currentTime - fragmentCreateTime > 250) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && currentTime - fragmentCreateTime > 250) {
TransitionSet transition = new TransitionSet(); TransitionSet transition = new TransitionSet();
ChangeBounds changeBounds = new ChangeBounds(); ChangeBounds changeBounds = new ChangeBounds();
changeBounds.setDuration(250); changeBounds.setDuration(250);
changeBounds.excludeTarget(stroageUsageView.legendLayout,true); changeBounds.excludeTarget(stroageUsageView.legendLayout, true);
Fade in = new Fade(Fade.IN); Fade in = new Fade(Fade.IN);
in.setDuration(290); in.setDuration(290);
transition transition
@ -569,111 +536,7 @@ public class CacheControlActivity extends BaseFragment {
@RequiresApi(api = Build.VERSION_CODES.R) @RequiresApi(api = Build.VERSION_CODES.R)
private void migrateOldFolder() { private void migrateOldFolder() {
boolean isExternalStorageManager = Environment.isExternalStorageManager(); FilesMigrationService.checkBottomSheet(this);
if (!BuildVars.NO_SCOPED_STORAGE && !isExternalStorageManager) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("MigrateOldFolder", R.string.MigrateOldFolder));
builder.setMessage(LocaleController.getString("ManageAllFilesRational2", R.string.ManageAllFilesRational2));
builder.setPositiveButton(LocaleController.getString("Allow", R.string.Allow), (i1, i2) -> {
Uri uri = Uri.parse("package:" + BuildConfig.APPLICATION_ID);
getParentActivity().startActivity(new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, uri));
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), (i1, i2) -> {
});
builder.show();
return;
}
Thread thread = new Thread() {
int totalFilesCount;
int movedFilesCount;
@Override
public void run() {
super.run();
File path = Environment.getExternalStorageDirectory();
if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
ArrayList<File> dirs = AndroidUtilities.getRootDirs();
if (dirs != null) {
for (int a = 0, N = dirs.size(); a < N; a++) {
File dir = dirs.get(a);
if (dir.getAbsolutePath().startsWith(SharedConfig.storageCacheDir)) {
path = dir;
break;
}
}
}
}
File newPath = ApplicationLoader.applicationContext.getExternalFilesDir(null);
File telegramPath = new File(newPath, "Telegram");
File oldPath = new File(path, "Telegram");
totalFilesCount = getFilesCount(oldPath);
long moveStart = System.currentTimeMillis();
moveDirectory(oldPath, telegramPath);
long dt = System.currentTimeMillis() - moveStart;
FileLog.d("move time = " + dt);
}
private int getFilesCount(File source) {
if (!source.exists()) {
return 0;
}
int count = 0;
File[] fileList = source.listFiles();
for (int i = 0; i < fileList.length; i++) {
if (fileList[i].isDirectory()) {
count += getFilesCount(fileList[i]);
} else {
count++;
}
}
return count;
}
private void moveDirectory(File source, File target) {
if (!source.exists() || (!target.exists() && !target.mkdir())) {
return;
}
try (Stream<Path> files = Files.list(source.toPath())) {
files.forEach(path -> {
File dest = new File(target, path.getFileName().toString());
if (Files.isDirectory(path)) {
moveDirectory(path.toFile(), dest);
} else {
try {
Files.move(path, dest.toPath());
} catch (Exception e) {
FileLog.e(e);
try {
path.toFile().delete();
} catch (Exception e1) {
FileLog.e(e1);
}
}
movedFilesCount++;
updateProgress();
}
});
} catch (Exception e) {
FileLog.e(e);
}
try {
source.delete();
} catch (Exception e) {
FileLog.e(e);
}
}
private void updateProgress() {
float p = movedFilesCount / (float) totalFilesCount;
}
};
thread.start();
} }
private void clearDatabase() { private void clearDatabase() {
@ -982,4 +845,21 @@ public class CacheControlActivity extends BaseFragment {
arrayList.add(new ThemeDescription(bottomSheetView, 0, null, null, null, null, Theme.key_statisticChartLine_indigo)); arrayList.add(new ThemeDescription(bottomSheetView, 0, null, null, null, null, Theme.key_statisticChartLine_indigo));
return arrayList; return arrayList;
} }
@Override
public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == 4) {
boolean allGranted = true;
for (int a = 0; a < grantResults.length; a++) {
if (grantResults[a] != PackageManager.PERMISSION_GRANTED) {
allGranted = false;
break;
}
}
if (allGranted && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && FilesMigrationService.filesMigrationBottomSheet != null) {
FilesMigrationService.filesMigrationBottomSheet.migrateOldFolder();
}
}
}
} }

View File

@ -378,7 +378,7 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
} else if (url.startsWith("http")) { } else if (url.startsWith("http")) {
Browser.openUrl(getContext(), url); Browser.openUrl(getContext(), url);
} else { } else {
delegate.needOpenUserProfile(Integer.parseInt(url)); delegate.needOpenUserProfile(Long.parseLong(url));
} }
} }
result = true; result = true;

View File

@ -105,6 +105,16 @@ public class SessionCell extends FrameLayout {
linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 2, 0, 0)); linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 2, 0, 0));
} }
int leftMargin;
int rightMargin;
if (LocaleController.isRTL) {
rightMargin = type == 0 ? 72 : 21;
leftMargin = 21;
} else {
leftMargin = type == 0 ? 72 : 21;
rightMargin = 21;
}
detailTextView = new TextView(context); detailTextView = new TextView(context);
detailTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); detailTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
detailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); detailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
@ -113,7 +123,7 @@ public class SessionCell extends FrameLayout {
detailTextView.setSingleLine(true); detailTextView.setSingleLine(true);
detailTextView.setEllipsize(TextUtils.TruncateAt.END); detailTextView.setEllipsize(TextUtils.TruncateAt.END);
detailTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); detailTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, type == 0 ? 72 : 21, 36, 21, 0)); addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, leftMargin, 36, rightMargin, 0));
detailExTextView = new TextView(context); detailExTextView = new TextView(context);
detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3)); detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
@ -123,7 +133,7 @@ public class SessionCell extends FrameLayout {
detailExTextView.setSingleLine(true); detailExTextView.setSingleLine(true);
detailExTextView.setEllipsize(TextUtils.TruncateAt.END); detailExTextView.setEllipsize(TextUtils.TruncateAt.END);
detailExTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); detailExTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, type == 0 ? 72 : 21, 59, 21, 0)); addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, leftMargin, 59, rightMargin, 0));
} }
@Override @Override
@ -136,11 +146,7 @@ public class SessionCell extends FrameLayout {
if (object instanceof TLRPC.TL_authorization) { if (object instanceof TLRPC.TL_authorization) {
TLRPC.TL_authorization session = (TLRPC.TL_authorization) object; TLRPC.TL_authorization session = (TLRPC.TL_authorization) object;
imageView.setImageDrawable(createDrawable(session)); imageView.setImageDrawable(createDrawable(session));
// nameTextView.setText(String.format(Locale.US, "%s %s", session.app_name, session.app_version));
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
if (session.device_model.length() != 0) { if (session.device_model.length() != 0) {

File diff suppressed because it is too large Load Diff

View File

@ -142,7 +142,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
} }
isPrivate = !isForcePublic && TextUtils.isEmpty(currentChat.username); isPrivate = !isForcePublic && TextUtils.isEmpty(currentChat.username);
isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup; isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
isSaveRestricted = isPrivate && currentChat.noforwards; isSaveRestricted = currentChat.noforwards;
if (isForcePublic && TextUtils.isEmpty(currentChat.username) || isPrivate && currentChat.creator) { if (isForcePublic && TextUtils.isEmpty(currentChat.username) || isPrivate && currentChat.creator) {
TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername(); TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername();
req.username = "1"; req.username = "1";
@ -470,7 +470,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
} }
private void processDone() { private void processDone() {
if (isPrivate && currentChat.noforwards != isSaveRestricted) { if (currentChat.noforwards != isSaveRestricted) {
getMessagesController().toggleChatNoForwards(chatId, currentChat.noforwards = isSaveRestricted); getMessagesController().toggleChatNoForwards(chatId, currentChat.noforwards = isSaveRestricted);
} }
if (trySetUsername()) { if (trySetUsername()) {
@ -616,7 +616,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
} }
publicContainer.setVisibility(isPrivate ? View.GONE : View.VISIBLE); publicContainer.setVisibility(isPrivate ? View.GONE : View.VISIBLE);
privateContainer.setVisibility(isPrivate ? View.VISIBLE : View.GONE); privateContainer.setVisibility(isPrivate ? View.VISIBLE : View.GONE);
saveContainer.setVisibility(isPrivate ? View.VISIBLE : View.GONE); saveContainer.setVisibility(View.VISIBLE);
manageLinksTextView.setVisibility(View.VISIBLE); manageLinksTextView.setVisibility(View.VISIBLE);
manageLinksInfoCell.setVisibility(View.VISIBLE); manageLinksInfoCell.setVisibility(View.VISIBLE);
linkContainer.setPadding(0, 0, 0, isPrivate ? 0 : AndroidUtilities.dp(7)); linkContainer.setPadding(0, 0, 0, isPrivate ? 0 : AndroidUtilities.dp(7));

View File

@ -4130,6 +4130,7 @@ public class AlertsCreator {
final boolean[] checks = new boolean[3]; final boolean[] checks = new boolean[3];
final boolean[] deleteForAll = new boolean[1]; final boolean[] deleteForAll = new boolean[1];
TLRPC.User actionUser = null; TLRPC.User actionUser = null;
TLRPC.Chat actionChat = null;
boolean canRevokeInbox = user != null && MessagesController.getInstance(currentAccount).canRevokePmInbox; boolean canRevokeInbox = user != null && MessagesController.getInstance(currentAccount).canRevokePmInbox;
int revokeTimeLimit; int revokeTimeLimit;
if (user != null) { if (user != null) {
@ -4148,7 +4149,13 @@ public class AlertsCreator {
selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionChatDeleteUser || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionChatDeleteUser ||
selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByLink || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByLink ||
selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionChatAddUser) { selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionChatAddUser) {
actionUser = MessagesController.getInstance(currentAccount).getUser(selectedMessage.messageOwner.from_id.user_id); if (selectedMessage.messageOwner.from_id.user_id != 0) {
actionUser = MessagesController.getInstance(currentAccount).getUser(selectedMessage.messageOwner.from_id.user_id);
} else if (selectedMessage.messageOwner.from_id.channel_id != 0) {
actionChat = MessagesController.getInstance(currentAccount).getChat(selectedMessage.messageOwner.from_id.channel_id);
} else if (selectedMessage.messageOwner.from_id.chat_id != 0) {
actionChat = MessagesController.getInstance(currentAccount).getChat(selectedMessage.messageOwner.from_id.chat_id);
}
} }
boolean hasOutgoing = !selectedMessage.isSendError() && selectedMessage.getDialogId() == mergeDialogId && (selectedMessage.messageOwner.action == null || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionEmpty) && selectedMessage.isOut() && (currentDate - selectedMessage.messageOwner.date) <= revokeTimeLimit; boolean hasOutgoing = !selectedMessage.isSendError() && selectedMessage.getDialogId() == mergeDialogId && (selectedMessage.messageOwner.action == null || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionEmpty) && selectedMessage.isOut() && (currentDate - selectedMessage.messageOwner.date) <= revokeTimeLimit;
if (hasOutgoing) { if (hasOutgoing) {
@ -4188,8 +4195,8 @@ public class AlertsCreator {
actionUser = MessagesController.getInstance(currentAccount).getUser(from_id); actionUser = MessagesController.getInstance(currentAccount).getUser(from_id);
} }
} }
if (actionUser != null && actionUser.id != UserConfig.getInstance(currentAccount).getClientUserId()) { if ((actionUser != null && actionUser.id != UserConfig.getInstance(currentAccount).getClientUserId()) || (actionChat != null && !ChatObject.hasAdminRights(actionChat))) {
if (loadParticipant == 1 && !chat.creator) { if (loadParticipant == 1 && !chat.creator && actionUser != null) {
final AlertDialog[] progressDialog = new AlertDialog[]{new AlertDialog(activity, 3)}; final AlertDialog[] progressDialog = new AlertDialog[]{new AlertDialog(activity, 3)};
TLRPC.TL_channels_getParticipant req = new TLRPC.TL_channels_getParticipant(); TLRPC.TL_channels_getParticipant req = new TLRPC.TL_channels_getParticipant();
@ -4224,6 +4231,7 @@ public class AlertsCreator {
} }
FrameLayout frameLayout = new FrameLayout(activity); FrameLayout frameLayout = new FrameLayout(activity);
int num = 0; int num = 0;
String name = actionUser != null ? ContactsController.formatName(actionUser.first_name, actionUser.last_name) : actionChat.title;
for (int a = 0; a < 3; a++) { for (int a = 0; a < 3; a++) {
if ((loadParticipant == 2 || !canBan) && a == 0) { if ((loadParticipant == 2 || !canBan) && a == 0) {
continue; continue;
@ -4236,7 +4244,7 @@ public class AlertsCreator {
} else if (a == 1) { } else if (a == 1) {
cell.setText(LocaleController.getString("DeleteReportSpam", R.string.DeleteReportSpam), "", false, false); cell.setText(LocaleController.getString("DeleteReportSpam", R.string.DeleteReportSpam), "", false, false);
} else { } else {
cell.setText(LocaleController.formatString("DeleteAllFrom", R.string.DeleteAllFrom, ContactsController.formatName(actionUser.first_name, actionUser.last_name)), "", false, false); cell.setText(LocaleController.formatString("DeleteAllFrom", R.string.DeleteAllFrom, name), "", false, false);
} }
cell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0); cell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0);
frameLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.TOP | Gravity.LEFT, 0, 48 * num, 0, 0)); frameLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.TOP | Gravity.LEFT, 0, 48 * num, 0, 0));
@ -4335,6 +4343,7 @@ public class AlertsCreator {
} }
} }
final TLRPC.User userFinal = actionUser; final TLRPC.User userFinal = actionUser;
final TLRPC.Chat chatFinal = actionChat;
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> { builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> {
ArrayList<Integer> ids = null; ArrayList<Integer> ids = null;
if (selectedMessage != null) { if (selectedMessage != null) {
@ -4386,21 +4395,25 @@ public class AlertsCreator {
selectedMessages[a].clear(); selectedMessages[a].clear();
} }
} }
if (userFinal != null) { if (userFinal != null || chatFinal != null) {
if (checks[0]) { if (checks[0]) {
MessagesController.getInstance(currentAccount).deleteParticipantFromChat(chat.id, userFinal, chatInfo); MessagesController.getInstance(currentAccount).deleteParticipantFromChat(chat.id, userFinal, chatFinal, chatInfo, false, false);
} }
if (checks[1]) { if (checks[1]) {
TLRPC.TL_channels_reportSpam req = new TLRPC.TL_channels_reportSpam(); TLRPC.TL_channels_reportSpam req = new TLRPC.TL_channels_reportSpam();
req.channel = MessagesController.getInputChannel(chat); req.channel = MessagesController.getInputChannel(chat);
req.user_id = MessagesController.getInstance(currentAccount).getInputUser(userFinal); if (userFinal != null) {
req.participant = MessagesController.getInputPeer(userFinal);
} else {
req.participant = MessagesController.getInputPeer(chatFinal);
}
req.id = ids; req.id = ids;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
}); });
} }
if (checks[2]) { if (checks[2]) {
MessagesController.getInstance(currentAccount).deleteUserChannelHistory(chat, userFinal, 0); MessagesController.getInstance(currentAccount).deleteUserChannelHistory(chat, userFinal, chatFinal, 0);
} }
} }
if (onDelete != null) { if (onDelete != null) {

View File

@ -4659,7 +4659,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
messageEditText.setAlpha(1f); messageEditText.setAlpha(1f);
messageEditText.setTranslationX(0); messageEditText.setTranslationX(0);
messageEditText.requestFocus(); messageEditText.requestFocus();
updateSendAsButton();
} }
}); });
@ -6816,7 +6815,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
} }
} }
boolean wasVisible = senderSelectView.getVisibility() == View.VISIBLE; boolean wasVisible = senderSelectView.getVisibility() == View.VISIBLE;
boolean isVisible = delegate.getSendAsPeers() != null && defPeer != null && delegate.getSendAsPeers().peers.size() > 1 && !isEditingMessage() && !isRecordingAudioVideo() && (recordedAudioPanel == null || recordedAudioPanel.getVisibility() == View.GONE); boolean isVisible = delegate.getSendAsPeers() != null && defPeer != null && delegate.getSendAsPeers().peers.size() > 1 && !isEditingMessage() && !isRecordingAudioVideo();
int pad = AndroidUtilities.dp(2); int pad = AndroidUtilities.dp(2);
MarginLayoutParams params = (MarginLayoutParams) senderSelectView.getLayoutParams(); MarginLayoutParams params = (MarginLayoutParams) senderSelectView.getLayoutParams();
float sA = isVisible ? 0 : 1; float sA = isVisible ? 0 : 1;
@ -6832,8 +6831,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
} }
if (parentFragment.getOtherSameChatsDiff() == 0 && parentFragment.fragmentOpened) { if (parentFragment.getOtherSameChatsDiff() == 0 && parentFragment.fragmentOpened) {
ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(220); ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(150);
anim.setInterpolator(CubicBezierInterpolator.DEFAULT);
anim.addUpdateListener(animation -> { anim.addUpdateListener(animation -> {
float val = (float) animation.getAnimatedValue(); float val = (float) animation.getAnimatedValue();

View File

@ -336,13 +336,13 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
ListItem item = (ListItem) object; ListItem item = (ListItem) object;
File file = item.file; File file = item.file;
boolean isExternalStorageManager = false; boolean isExternalStorageManager = false;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// isExternalStorageManager = Environment.isExternalStorageManager(); isExternalStorageManager = Environment.isExternalStorageManager();
// } }
if (!BuildVars.NO_SCOPED_STORAGE && (item.icon == R.drawable.files_storage || item.icon == R.drawable.files_internal)) { if (!BuildVars.NO_SCOPED_STORAGE && (item.icon == R.drawable.files_storage || item.icon == R.drawable.files_internal) && !isExternalStorageManager) {
//if (SharedConfig.dontAskManageStorage) { if (SharedConfig.dontAskManageStorage) {
delegate.startDocumentSelectActivity(); delegate.startDocumentSelectActivity();
/*} else { } else {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTopImage(R.drawable.doc_big, Theme.getColor(Theme.key_dialogTopBackground)); builder.setTopImage(R.drawable.doc_big, Theme.getColor(Theme.key_dialogTopBackground));
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("ManageAllFilesRational", R.string.ManageAllFilesRational))); builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("ManageAllFilesRational", R.string.ManageAllFilesRational)));
@ -368,7 +368,7 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
delegate.startDocumentSelectActivity(); delegate.startDocumentSelectActivity();
}); });
builder.show(); builder.show();
}*/ }
} else if (file == null) { } else if (file == null) {
if (item.icon == R.drawable.files_gallery) { if (item.icon == R.drawable.files_gallery) {
HashMap<Object, Object> selectedPhotos = new HashMap<>(); HashMap<Object, Object> selectedPhotos = new HashMap<>();

View File

@ -104,7 +104,7 @@ public class MediaActivity extends BaseFragment implements SharedMediaLayout.Sha
@Override @Override
public boolean dispatchTouchEvent(MotionEvent ev) { public boolean dispatchTouchEvent(MotionEvent ev) {
if (sharedMediaLayout != null && sharedMediaLayout.isInFastScroll() && sharedMediaLayout.getY() == 0) { if (sharedMediaLayout != null && sharedMediaLayout.isInFastScroll()) {
return sharedMediaLayout.dispatchFastScrollEvent(ev); return sharedMediaLayout.dispatchFastScrollEvent(ev);
} }
if (sharedMediaLayout != null && sharedMediaLayout.checkPinchToZoom(ev)) { if (sharedMediaLayout != null && sharedMediaLayout.checkPinchToZoom(ev)) {

View File

@ -440,7 +440,6 @@ public class MotionBackgroundDrawable extends Drawable {
legacyBitmap2 = null; legacyBitmap2 = null;
} }
try { try {
legacyBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); legacyBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
legacyCanvas = new Canvas(legacyBitmap); legacyCanvas = new Canvas(legacyBitmap);
invalidateLegacy = true; invalidateLegacy = true;

View File

@ -385,6 +385,7 @@ public class RecyclerListView extends RecyclerView {
float touchSlop; float touchSlop;
Drawable fastScrollShadowDrawable; Drawable fastScrollShadowDrawable;
Drawable fastScrollBackgroundDrawable; Drawable fastScrollBackgroundDrawable;
boolean isRtl;
Runnable hideFloatingDateRunnable = new Runnable() { Runnable hideFloatingDateRunnable = new Runnable() {
@Override @Override
@ -404,7 +405,9 @@ public class RecyclerListView extends RecyclerView {
this.type = type; this.type = type;
if (type == LETTER_TYPE) { if (type == LETTER_TYPE) {
letterPaint.setTextSize(AndroidUtilities.dp(45)); letterPaint.setTextSize(AndroidUtilities.dp(45));
isRtl = LocaleController.isRTL;
} else { } else {
isRtl = false;
letterPaint.setTextSize(AndroidUtilities.dp(13)); letterPaint.setTextSize(AndroidUtilities.dp(13));
letterPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); letterPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
paint2.setColor(Theme.getColor(Theme.key_windowBackgroundWhite)); paint2.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
@ -415,7 +418,7 @@ public class RecyclerListView extends RecyclerView {
radii[a] = AndroidUtilities.dp(44); radii[a] = AndroidUtilities.dp(44);
} }
scrollX = LocaleController.isRTL ? AndroidUtilities.dp(10) : AndroidUtilities.dp((type == LETTER_TYPE ? 132 : 240) - 15); scrollX = isRtl ? AndroidUtilities.dp(10) : AndroidUtilities.dp((type == LETTER_TYPE ? 132 : 240) - 15);
updateColors(); updateColors();
setFocusableInTouchMode(true); setFocusableInTouchMode(true);
ViewConfiguration vc = ViewConfiguration.get(context); ViewConfiguration vc = ViewConfiguration.get(context);
@ -453,11 +456,11 @@ public class RecyclerListView extends RecyclerView {
float x = event.getX(); float x = event.getX();
startY = lastY = event.getY(); startY = lastY = event.getY();
float currentY = (float) Math.ceil((getMeasuredHeight() - AndroidUtilities.dp(24 + 30)) * progress) + AndroidUtilities.dp(12); float currentY = (float) Math.ceil((getMeasuredHeight() - AndroidUtilities.dp(24 + 30)) * progress) + AndroidUtilities.dp(12);
if (LocaleController.isRTL && x > AndroidUtilities.dp(25) || !LocaleController.isRTL && x < AndroidUtilities.dp(107) || lastY < currentY || lastY > currentY + AndroidUtilities.dp(30)) { if (isRtl && x > AndroidUtilities.dp(25) || !isRtl && x < AndroidUtilities.dp(107) || lastY < currentY || lastY > currentY + AndroidUtilities.dp(30)) {
return false; return false;
} }
if (type == DATE_TYPE && !floatingDateVisible) { if (type == DATE_TYPE && !floatingDateVisible) {
if (LocaleController.isRTL && x > AndroidUtilities.dp(25) || !LocaleController.isRTL && x < (getMeasuredWidth() - AndroidUtilities.dp(25)) || lastY < currentY || lastY > currentY + AndroidUtilities.dp(30)) { if (isRtl && x > AndroidUtilities.dp(25) || !isRtl && x < (getMeasuredWidth() - AndroidUtilities.dp(25)) || lastY < currentY || lastY > currentY + AndroidUtilities.dp(30)) {
return false; return false;
} }
} }
@ -552,7 +555,7 @@ public class RecyclerListView extends RecyclerView {
if (letterLayout.getLineCount() > 0) { if (letterLayout.getLineCount() > 0) {
float lWidth = letterLayout.getLineWidth(0); float lWidth = letterLayout.getLineWidth(0);
float lleft = letterLayout.getLineLeft(0); float lleft = letterLayout.getLineLeft(0);
if (LocaleController.isRTL) { if (isRtl) {
textX = AndroidUtilities.dp(10) + (AndroidUtilities.dp(88) - letterLayout.getLineWidth(0)) / 2 - letterLayout.getLineLeft(0); textX = AndroidUtilities.dp(10) + (AndroidUtilities.dp(88) - letterLayout.getLineWidth(0)) / 2 - letterLayout.getLineLeft(0);
} else { } else {
textX = (AndroidUtilities.dp(88) - letterLayout.getLineWidth(0)) / 2 - letterLayout.getLineLeft(0); textX = (AndroidUtilities.dp(88) - letterLayout.getLineWidth(0)) / 2 - letterLayout.getLineLeft(0);
@ -625,8 +628,8 @@ public class RecyclerListView extends RecyclerView {
raduisBottom = AndroidUtilities.dp(44); raduisBottom = AndroidUtilities.dp(44);
raduisTop = AndroidUtilities.dp(4) + (1.0f - diff / AndroidUtilities.dp(29)) * AndroidUtilities.dp(40); raduisTop = AndroidUtilities.dp(4) + (1.0f - diff / AndroidUtilities.dp(29)) * AndroidUtilities.dp(40);
} }
if (LocaleController.isRTL && (radii[0] != raduisTop || radii[6] != raduisBottom) || !LocaleController.isRTL && (radii[2] != raduisTop || radii[4] != raduisBottom)) { if (isRtl && (radii[0] != raduisTop || radii[6] != raduisBottom) || !isRtl && (radii[2] != raduisTop || radii[4] != raduisBottom)) {
if (LocaleController.isRTL) { if (isRtl) {
radii[0] = radii[1] = raduisTop; radii[0] = radii[1] = raduisTop;
radii[6] = radii[7] = raduisBottom; radii[6] = radii[7] = raduisBottom;
} else { } else {
@ -634,7 +637,7 @@ public class RecyclerListView extends RecyclerView {
radii[4] = radii[5] = raduisBottom; radii[4] = radii[5] = raduisBottom;
} }
path.reset(); path.reset();
rect.set(LocaleController.isRTL ? AndroidUtilities.dp(10) : 0, 0, AndroidUtilities.dp(LocaleController.isRTL ? 98 : 88), AndroidUtilities.dp(88)); rect.set(isRtl ? AndroidUtilities.dp(10) : 0, 0, AndroidUtilities.dp(isRtl ? 98 : 88), AndroidUtilities.dp(88));
path.addRoundRect(rect, radii, Path.Direction.CW); path.addRoundRect(rect, radii, Path.Direction.CW);
path.close(); path.close();
} }
@ -1225,7 +1228,7 @@ public class RecyclerListView extends RecyclerView {
if (fastScroll != null) { if (fastScroll != null) {
selfOnLayout = true; selfOnLayout = true;
t += getPaddingTop(); t += getPaddingTop();
if (LocaleController.isRTL) { if (fastScroll.isRtl) {
fastScroll.layout(0, t, fastScroll.getMeasuredWidth(), t + fastScroll.getMeasuredHeight()); fastScroll.layout(0, t, fastScroll.getMeasuredWidth(), t + fastScroll.getMeasuredHeight());
} else { } else {
int x = getMeasuredWidth() - fastScroll.getMeasuredWidth(); int x = getMeasuredWidth() - fastScroll.getMeasuredWidth();

View File

@ -0,0 +1,85 @@
package org.telegram.ui.Components;
import android.content.Context;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.DocumentObject;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.SvgHelper;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme;
public class StickerImageView extends BackupImageView implements NotificationCenter.NotificationCenterDelegate {
int currentAccount;
int stickerNum;
String stickerPackName = AndroidUtilities.STICKERS_PLACEHOLDER_PACK_NAME;
public StickerImageView(Context context, int currentAccount) {
super(context);
this.currentAccount = currentAccount;
}
public void setStickerNum(int stickerNum) {
this.stickerNum = stickerNum;
}
public void setStickerPackName(String stickerPackName) {
this.stickerPackName = stickerPackName;
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
setSticker();
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.diceStickersDidLoad);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.diceStickersDidLoad);
}
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.diceStickersDidLoad) {
String name = (String) args[0];
if (stickerPackName.equals(name)) {
setSticker();
}
}
}
private void setSticker() {
String imageFilter = null;
TLRPC.Document document = null;
TLRPC.TL_messages_stickerSet set = null;
set = MediaDataController.getInstance(currentAccount).getStickerSetByName(stickerPackName);
if (set == null) {
set = MediaDataController.getInstance(currentAccount).getStickerSetByEmojiOrName(stickerPackName);
}
if (set != null && set.documents.size() > stickerNum) {
document = set.documents.get(stickerNum);
}
imageFilter = "130_130";
SvgHelper.SvgDrawable svgThumb = null;
if (document != null) {
svgThumb = DocumentObject.getSvgThumb(document.thumbs, Theme.key_emptyListPlaceholder, 0.2f);
}
if (svgThumb != null) {
svgThumb.overrideWidthAndHeight(512, 512);
}
if (document != null) {
ImageLocation imageLocation = ImageLocation.getForDocument(document);
setImage(imageLocation, imageFilter, "tgs", svgThumb, set);
} else {
MediaDataController.getInstance(currentAccount).loadStickersByEmojiOrName(stickerPackName, false, set == null);
}
}
}

View File

@ -248,7 +248,7 @@ public class DefaultThemesPreviewCell extends LinearLayout {
if (!Theme.isCurrentThemeDay()) { if (!Theme.isCurrentThemeDay()) {
darkThemeDrawable.setCurrentFrame(darkThemeDrawable.getFramesCount() - 1); darkThemeDrawable.setCurrentFrame(darkThemeDrawable.getFramesCount() - 1);
dayNightCell.setTextAndIcon(LocaleController.getString("SettingsSwitchToDaytMode", R.string.SettingsSwitchToDayMode), darkThemeDrawable, true); dayNightCell.setTextAndIcon(LocaleController.getString("SettingsSwitchToDayMode", R.string.SettingsSwitchToDayMode), darkThemeDrawable, true);
} else { } else {
dayNightCell.setTextAndIcon(LocaleController.getString("SettingsSwitchToNightMode", R.string.SettingsSwitchToNightMode), darkThemeDrawable, true); dayNightCell.setTextAndIcon(LocaleController.getString("SettingsSwitchToNightMode", R.string.SettingsSwitchToNightMode), darkThemeDrawable, true);
} }

View File

@ -88,6 +88,7 @@ import org.telegram.messenger.ContactsController;
import org.telegram.messenger.DialogObject; import org.telegram.messenger.DialogObject;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.FilesMigrationService;
import org.telegram.messenger.ImageLoader; import org.telegram.messenger.ImageLoader;
import org.telegram.messenger.ImageLocation; import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
@ -3534,6 +3535,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
showSearch(false, false); showSearch(false, false);
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
FilesMigrationService.checkBottomSheet(this);
}
updateMenuButton(false); updateMenuButton(false);
return fragmentView; return fragmentView;
} }
@ -6347,6 +6351,18 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
askingForPermissions = false; askingForPermissions = false;
showFiltersHint(); showFiltersHint();
} }
} else if (requestCode == 4) {
boolean allGranted = true;
for (int a = 0; a < grantResults.length; a++) {
if (grantResults[a] != PackageManager.PERMISSION_GRANTED) {
allGranted = false;
break;
}
}
if (allGranted && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && FilesMigrationService.filesMigrationBottomSheet != null) {
FilesMigrationService.filesMigrationBottomSheet.migrateOldFolder();
}
} }
} }

View File

@ -1942,12 +1942,12 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
String msgID = data.getQueryParameter("message_id"); String msgID = data.getQueryParameter("message_id");
if (userID != null) { if (userID != null) {
try { try {
push_user_id = Integer.parseInt(userID); push_user_id = Long.parseLong(userID);
} catch (NumberFormatException ignore) { } catch (NumberFormatException ignore) {
} }
} else if (chatID != null) { } else if (chatID != null) {
try { try {
push_chat_id = Integer.parseInt(chatID); push_chat_id = Long.parseLong(chatID);
} catch (NumberFormatException ignore) { } catch (NumberFormatException ignore) {
} }
} }

View File

@ -9648,7 +9648,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
isEvent = object != null && object.isEvent; isEvent = object != null && object.isEvent;
sharedMediaType = MediaDataController.MEDIA_PHOTOVIDEO; sharedMediaType = MediaDataController.MEDIA_PHOTOVIDEO;
allMediaItem.setText(LocaleController.getString("ShowAllMedia", R.string.ShowAllMedia)); allMediaItem.setText(LocaleController.getString("ShowAllMedia", R.string.ShowAllMedia));
menuItem.setVisibility(View.VISIBLE);
setItemVisible(sendItem, false, false); setItemVisible(sendItem, false, false);
setItemVisible(pipItem, false, true); setItemVisible(pipItem, false, true);
cameraItem.setVisibility(View.GONE); cameraItem.setVisibility(View.GONE);
@ -9894,7 +9893,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
cameraItem.setVisibility(View.VISIBLE); cameraItem.setVisibility(View.VISIBLE);
cameraItem.setTag(1); cameraItem.setTag(1);
} }
menuItem.setVisibility(View.GONE);
imagesArrLocals.addAll(photos); imagesArrLocals.addAll(photos);
Object obj = imagesArrLocals.get(index); Object obj = imagesArrLocals.get(index);
boolean allowCaption; boolean allowCaption;
@ -10553,7 +10551,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
actionBar.setTitle(LocaleController.getString("AttachGif", R.string.AttachGif)); actionBar.setTitle(LocaleController.getString("AttachGif", R.string.AttachGif));
} else { } else {
menuItem.setVisibility(View.VISIBLE);
if (size == 1) { if (size == 1) {
if (isVideo) { if (isVideo) {
actionBar.setTitle(LocaleController.getString("AttachVideo", R.string.AttachVideo)); actionBar.setTitle(LocaleController.getString("AttachVideo", R.string.AttachVideo));
@ -12350,7 +12347,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
disableShowCheck = false; disableShowCheck = false;
object.imageReceiver.setVisible(false, true); object.imageReceiver.setVisible(false, true);
}; };
if (parentChatActivity != null) { if (parentChatActivity != null && parentChatActivity.getFragmentView() != null) {
parentChatActivity.getUndoView().hide(false, 1); parentChatActivity.getUndoView().hide(false, 1);
parentChatActivity.getFragmentView().invalidate(); parentChatActivity.getFragmentView().invalidate();
} }

View File

@ -3886,7 +3886,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
participant.inviter_id = participant.channelParticipant.inviter_id; participant.inviter_id = participant.channelParticipant.inviter_id;
participant.user_id = MessageObject.getPeerId(participant.channelParticipant.peer); participant.user_id = MessageObject.getPeerId(participant.channelParticipant.peer);
participant.date = participant.channelParticipant.date; participant.date = participant.channelParticipant.date;
if (participant.user_id != 0 && participantsMap.indexOfKey(participant.user_id) < 0) { if (participantsMap.indexOfKey(participant.user_id) < 0) {
if (chatInfo.participants == null) { if (chatInfo.participants == null) {
chatInfo.participants = new TLRPC.TL_chatParticipants(); chatInfo.participants = new TLRPC.TL_chatParticipants();
} }

View File

@ -378,15 +378,17 @@ public class SessionBottomSheet extends BottomSheet {
LinearLayout linearLayout = new LinearLayout(context); LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setOrientation(LinearLayout.VERTICAL);
addView(linearLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 64, 4, 0, 4)); addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 64, 4, 0, 4));
valueText = new TextView(context); valueText = new TextView(context);
valueText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); valueText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
valueText.setGravity(Gravity.LEFT);
valueText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); valueText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
linearLayout.addView(valueText, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 0, 0)); linearLayout.addView(valueText, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 0, 0));
descriptionText = new TextView(context); descriptionText = new TextView(context);
descriptionText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); descriptionText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
descriptionText.setGravity(Gravity.LEFT);
descriptionText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText)); descriptionText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
linearLayout.addView(descriptionText, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 4, 0, 0)); linearLayout.addView(descriptionText, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 4, 0, 0));
setPadding(0, AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4)); setPadding(0, AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4));

View File

@ -4889,4 +4889,9 @@
<string name="ChatWithAdminMessage">You received this message because you requested to join **%1$s** on %2$s</string> <string name="ChatWithAdminMessage">You received this message because you requested to join **%1$s** on %2$s</string>
<string name="EventLogSendMessages">un1 sent this message:</string> <string name="EventLogSendMessages">un1 sent this message:</string>
<string name="DidNotGetTheCodePhone">Get code on this phone</string> <string name="DidNotGetTheCodePhone">Get code on this phone</string>
<string name="MigrationNotification">Migration</string>
<string name="MigrateOldFolderButton">Move Files Now</string>
<string name="MigrateOldFolderTitle">Migrate Files to Scoped Storage</string>
<string name="MigrateOldFolderDescription">Due to a change made by **Google**, we need to move the files you downloaded using **Telegram** to a new folder.\n\nThis may take a few moments. You can continue using the app while the files are moved.</string>
<string name="MigratingFiles">Migrating files</string>
</resources> </resources>