Update to 7.7.0 (2284)

This commit is contained in:
DrKLO 2021-04-14 04:44:46 +03:00
parent 7ba9838a2d
commit 8bf056e27b
209 changed files with 7639 additions and 2243 deletions

View File

@ -24,4 +24,4 @@ RUN $ANDROID_HOME/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSIO
ENV PATH ${ANDROID_NDK_HOME}:$PATH ENV PATH ${ANDROID_NDK_HOME}:$PATH
ENV PATH ${ANDROID_NDK_HOME}/prebuilt/linux-x86_64/bin/:$PATH ENV PATH ${ANDROID_NDK_HOME}/prebuilt/linux-x86_64/bin/:$PATH
CMD mkdir -p /home/source/TMessagesProj/build/outputs/apk && mkdir -p /home/source/TMessagesProj/build/outputs/native-debug-symbols && cp -R /home/source/. /home/gradle && cd /home/gradle && gradle assembleRelease && cp -R /home/gradle/TMessagesProj/build/outputs/apk/. /home/source/TMessagesProj/build/outputs/apk && cp -R /home/gradle/TMessagesProj/build/outputs/native-debug-symbols/. /home/source/TMessagesProj/build/outputs/native-debug-symbols CMD mkdir -p /home/source/TMessagesProj/build/outputs/apk && mkdir -p /home/source/TMessagesProj/build/outputs/native-debug-symbols && cp -R /home/source/. /home/gradle && cd /home/gradle && gradle assembleRelease && gradle assembleStandalone && cp -R /home/gradle/TMessagesProj/build/outputs/apk/. /home/source/TMessagesProj/build/outputs/apk && cp -R /home/gradle/TMessagesProj/build/outputs/native-debug-symbols/. /home/source/TMessagesProj/build/outputs/native-debug-symbols

View File

@ -143,6 +143,17 @@ android {
ndk.debugSymbolLevel = 'FULL' ndk.debugSymbolLevel = 'FULL'
} }
standalone {
debuggable false
jniDebuggable false
signingConfig signingConfigs.release
applicationIdSuffix ".web"
minifyEnabled true
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ndk.debugSymbolLevel = 'FULL'
}
release { release {
debuggable false debuggable false
jniDebuggable false jniDebuggable false
@ -167,6 +178,10 @@ android {
manifest.srcFile 'config/debug/AndroidManifest.xml' manifest.srcFile 'config/debug/AndroidManifest.xml'
} }
sourceSets.standalone {
manifest.srcFile 'config/release/AndroidManifest.xml'
}
sourceSets.release { sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest.xml' manifest.srcFile 'config/release/AndroidManifest.xml'
} }
@ -243,9 +258,6 @@ android {
sourceSets.debug { sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
} }
/*sourceSets.debugAsan {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}*/
sourceSets.release { sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml' manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
} }
@ -276,19 +288,19 @@ android {
sourceSets.debug { sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
} }
/*sourceSets.debugAsan {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}*/
sourceSets.release { sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml' manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
} }
sourceSets.standalone {
manifest.srcFile 'config/release/AndroidManifest_standalone.xml'
}
ext { ext {
abiVersionCode = 9 abiVersionCode = 9
} }
} }
} }
defaultConfig.versionCode = 2274 defaultConfig.versionCode = 2284
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.all { output -> variant.outputs.all { output ->
@ -307,7 +319,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 29 targetSdkVersion 29
versionName "7.6.1" versionName "7.7.0"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.telegram.messenger"
android:installLocation="auto">
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
<uses-feature android:name="android.hardware.location.network" android:required="false" />
<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="org.telegram.messenger.permission.MAPS_RECEIVE"/>
<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_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher_sa"
android:roundIcon="@mipmap/ic_launcher_sa"
android:label="@string/AppName"
android:theme="@style/Theme.TMessages.Start"
android:name=".ApplicationLoader"
android:hardwareAccelerated="@bool/useHardwareAcceleration"
android:largeHeap="true"
android:supportsRtl="false"
android:requestLegacyExternalStorage="true"
tools:replace="android:supportsRtl">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k" />
<service
android:name=".GcmPushListenerService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<uses-library android:name="com.google.android.maps" android:required="false"/>
<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />
<meta-data android:name="google_analytics_adid_collection_enabled" android:value="false" />
<receiver
tools:replace="android:enabled"
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="false">
<intent-filter>
<action android:name="com.google.android.gms.measurement.UPLOAD" />
</intent-filter>
</receiver>
<service
tools:replace="android:enabled"
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="false"
android:exported="false" />
</application>
</manifest>

View File

@ -6,35 +6,6 @@
"storage_bucket": "tmessages2.appspot.com" "storage_bucket": "tmessages2.appspot.com"
}, },
"client": [ "client": [
{
"client_info": {
"mobilesdk_app_id": "1:760348033671:android:dc022572c167a16c",
"android_client_info": {
"package_name": "org.telegram.messenger.beta"
}
},
"oauth_client": [
{
"client_id": "760348033671-2hh8ebmuflsnjoc0kldkfells9rhtfni.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "760348033671-jiv412evc1r36rl4k7vhl1ba83atdmot.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{ {
"client_info": { "client_info": {
"mobilesdk_app_id": "1:760348033671:android:f6afd7b67eae3860", "mobilesdk_app_id": "1:760348033671:android:f6afd7b67eae3860",
@ -57,7 +28,65 @@
"appinvite_service": { "appinvite_service": {
"other_platform_oauth_client": [ "other_platform_oauth_client": [
{ {
"client_id": "760348033671-jiv412evc1r36rl4k7vhl1ba83atdmot.apps.googleusercontent.com", "client_id": "760348033671-2hh8ebmuflsnjoc0kldkfells9rhtfni.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:760348033671:android:dc022572c167a16c",
"android_client_info": {
"package_name": "org.telegram.messenger.beta"
}
},
"oauth_client": [
{
"client_id": "760348033671-2hh8ebmuflsnjoc0kldkfells9rhtfni.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "760348033671-2hh8ebmuflsnjoc0kldkfells9rhtfni.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:760348033671:android:7396e651423888c3f66e22",
"android_client_info": {
"package_name": "org.telegram.messenger.web"
}
},
"oauth_client": [
{
"client_id": "760348033671-2hh8ebmuflsnjoc0kldkfells9rhtfni.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "760348033671-2hh8ebmuflsnjoc0kldkfells9rhtfni.apps.googleusercontent.com",
"client_type": 3 "client_type": 3
} }
] ]

View File

@ -399,7 +399,7 @@ target_compile_definitions(sqlite PUBLIC
#voip #voip
include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt) include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt)
set(NATIVE_LIB "tmessages.37") set(NATIVE_LIB "tmessages.38")
#tmessages #tmessages
add_library(${NATIVE_LIB} SHARED add_library(${NATIVE_LIB} SHARED

View File

@ -371,7 +371,7 @@ void setSystemLangCode(JNIEnv *env, jclass c, jint instanceNum, jstring langCode
} }
} }
void init(JNIEnv *env, jclass c, jint instanceNum, jint version, jint layer, jint apiId, jstring deviceModel, jstring systemVersion, jstring appVersion, jstring langCode, jstring systemLangCode, jstring configPath, jstring logPath, jstring regId, jstring cFingerprint, jstring installerId, jint timezoneOffset, jint userId, jboolean enablePushConnection, jboolean hasNetwork, jint networkType) { void init(JNIEnv *env, jclass c, jint instanceNum, jint version, jint layer, jint apiId, jstring deviceModel, jstring systemVersion, jstring appVersion, jstring langCode, jstring systemLangCode, jstring configPath, jstring logPath, jstring regId, jstring cFingerprint, jstring installerId, jstring packageId, jint timezoneOffset, jint userId, jboolean enablePushConnection, jboolean hasNetwork, jint networkType) {
const char *deviceModelStr = env->GetStringUTFChars(deviceModel, 0); const char *deviceModelStr = env->GetStringUTFChars(deviceModel, 0);
const char *systemVersionStr = env->GetStringUTFChars(systemVersion, 0); const char *systemVersionStr = env->GetStringUTFChars(systemVersion, 0);
const char *appVersionStr = env->GetStringUTFChars(appVersion, 0); const char *appVersionStr = env->GetStringUTFChars(appVersion, 0);
@ -382,8 +382,9 @@ void init(JNIEnv *env, jclass c, jint instanceNum, jint version, jint layer, jin
const char *regIdStr = env->GetStringUTFChars(regId, 0); const char *regIdStr = env->GetStringUTFChars(regId, 0);
const char *cFingerprintStr = env->GetStringUTFChars(cFingerprint, 0); const char *cFingerprintStr = env->GetStringUTFChars(cFingerprint, 0);
const char *installerIdStr = env->GetStringUTFChars(installerId, 0); const char *installerIdStr = env->GetStringUTFChars(installerId, 0);
const char *packageIdStr = env->GetStringUTFChars(packageId, 0);
ConnectionsManager::getInstance(instanceNum).init((uint32_t) version, layer, apiId, std::string(deviceModelStr), std::string(systemVersionStr), std::string(appVersionStr), std::string(langCodeStr), std::string(systemLangCodeStr), std::string(configPathStr), std::string(logPathStr), std::string(regIdStr), std::string(cFingerprintStr), std::string(installerIdStr), timezoneOffset, userId, true, enablePushConnection, hasNetwork, networkType); ConnectionsManager::getInstance(instanceNum).init((uint32_t) version, layer, apiId, std::string(deviceModelStr), std::string(systemVersionStr), std::string(appVersionStr), std::string(langCodeStr), std::string(systemLangCodeStr), std::string(configPathStr), std::string(logPathStr), std::string(regIdStr), std::string(cFingerprintStr), std::string(installerIdStr), std::string(packageIdStr), timezoneOffset, userId, true, enablePushConnection, hasNetwork, networkType);
if (deviceModelStr != 0) { if (deviceModelStr != 0) {
env->ReleaseStringUTFChars(deviceModel, deviceModelStr); env->ReleaseStringUTFChars(deviceModel, deviceModelStr);
@ -415,6 +416,9 @@ void init(JNIEnv *env, jclass c, jint instanceNum, jint version, jint layer, jin
if (installerIdStr != 0) { if (installerIdStr != 0) {
env->ReleaseStringUTFChars(installerId, installerIdStr); env->ReleaseStringUTFChars(installerId, installerIdStr);
} }
if (packageIdStr != 0) {
env->ReleaseStringUTFChars(packageId, packageIdStr);
}
} }
void setJava(JNIEnv *env, jclass c, jboolean useJavaByteBuffers) { void setJava(JNIEnv *env, jclass c, jboolean useJavaByteBuffers) {
@ -440,7 +444,7 @@ static JNINativeMethod ConnectionsManagerMethods[] = {
{"native_setProxySettings", "(ILjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", (void *) setProxySettings}, {"native_setProxySettings", "(ILjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", (void *) setProxySettings},
{"native_getConnectionState", "(I)I", (void *) getConnectionState}, {"native_getConnectionState", "(I)I", (void *) getConnectionState},
{"native_setUserId", "(II)V", (void *) setUserId}, {"native_setUserId", "(II)V", (void *) setUserId},
{"native_init", "(IIIILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIZZI)V", (void *) init}, {"native_init", "(IIIILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIZZI)V", (void *) init},
{"native_setLangCode", "(ILjava/lang/String;)V", (void *) setLangCode}, {"native_setLangCode", "(ILjava/lang/String;)V", (void *) setLangCode},
{"native_setRegId", "(ILjava/lang/String;)V", (void *) setRegId}, {"native_setRegId", "(ILjava/lang/String;)V", (void *) setRegId},
{"native_setSystemLangCode", "(ILjava/lang/String;)V", (void *) setSystemLangCode}, {"native_setSystemLangCode", "(ILjava/lang/String;)V", (void *) setSystemLangCode},

View File

@ -1172,7 +1172,7 @@ UserProfilePhoto *UserProfilePhoto::TLdeserialize(NativeByteBuffer *stream, uint
case 0x4f11bae1: case 0x4f11bae1:
result = new TL_userProfilePhotoEmpty(); result = new TL_userProfilePhotoEmpty();
break; break;
case 0x69d3ab26: case 0xcc656077:
result = new TL_userProfilePhoto(); result = new TL_userProfilePhoto();
break; break;
default: default:
@ -1194,6 +1194,9 @@ void TL_userProfilePhoto::readParams(NativeByteBuffer *stream, int32_t instanceN
photo_id = stream->readInt64(&error); photo_id = stream->readInt64(&error);
photo_small = std::unique_ptr<FileLocation>(FileLocation::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); photo_small = std::unique_ptr<FileLocation>(FileLocation::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
photo_big = std::unique_ptr<FileLocation>(FileLocation::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error)); photo_big = std::unique_ptr<FileLocation>(FileLocation::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
if ((flags & 2) != 0) {
stripped_thumb = std::unique_ptr<ByteArray>(stream->readByteArray(&error));
}
dc_id = stream->readInt32(&error); dc_id = stream->readInt32(&error);
} }
@ -1204,6 +1207,9 @@ void TL_userProfilePhoto::serializeToStream(NativeByteBuffer *stream) {
stream->writeInt64(photo_id); stream->writeInt64(photo_id);
photo_small->serializeToStream(stream); photo_small->serializeToStream(stream);
photo_big->serializeToStream(stream); photo_big->serializeToStream(stream);
if ((flags & 2) != 0) {
stream->writeByteArray(stripped_thumb.get());
}
stream->writeInt32(dc_id); stream->writeInt32(dc_id);
} }

View File

@ -257,6 +257,7 @@ public:
int64_t photo_id; int64_t photo_id;
std::unique_ptr<FileLocation> photo_small; std::unique_ptr<FileLocation> photo_small;
std::unique_ptr<FileLocation> photo_big; std::unique_ptr<FileLocation> photo_big;
std::unique_ptr<ByteArray> stripped_thumb;
int32_t dc_id; int32_t dc_id;
static UserProfilePhoto *TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error); static UserProfilePhoto *TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error);
@ -273,7 +274,7 @@ public:
class TL_userProfilePhoto : public UserProfilePhoto { class TL_userProfilePhoto : public UserProfilePhoto {
public: public:
static const uint32_t constructor = 0x69d3ab26; static const uint32_t constructor = 0xcc656077;
void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error); void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
void serializeToStream(NativeByteBuffer *stream); void serializeToStream(NativeByteBuffer *stream);

View File

@ -2494,6 +2494,7 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t
if (request->rawRequest->initFunc != nullptr) { if (request->rawRequest->initFunc != nullptr) {
request->rawRequest->initFunc(request->messageId); request->rawRequest->initFunc(request->messageId);
} }
if (LOGS_ENABLED) DEBUG_D("messageId for token = %d, 0x%" PRIx64, request->requestToken, request->messageId);
uint32_t requestLength = request->rpcRequest->getObjectSize(); uint32_t requestLength = request->rpcRequest->getObjectSize();
if (request->requestFlags & RequestFlagCanCompress) { if (request->requestFlags & RequestFlagCanCompress) {
@ -2593,8 +2594,8 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t
Datacenter *datacenter = getDatacenterWithId(iter->first); Datacenter *datacenter = getDatacenterWithId(iter->first);
if (datacenter != nullptr) { if (datacenter != nullptr) {
bool scannedPreviousRequests = false; bool scannedPreviousRequests = false;
int64_t lastSentMessageRpcId = 0;
bool needQuickAck = false; bool needQuickAck = false;
int64_t lastSentMessageRpcId = 0;
std::vector<std::unique_ptr<NetworkMessage>> &array = iter->second; std::vector<std::unique_ptr<NetworkMessage>> &array = iter->second;
size_t count = array.size(); size_t count = array.size();
for (uint32_t b = 0; b < count; b++) { for (uint32_t b = 0; b < count; b++) {
@ -2609,13 +2610,18 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t
std::vector<int64_t> currentRequests; std::vector<int64_t> currentRequests;
for (uint32_t a = 0; a < count; a++) { for (uint32_t a = 0; a < count; a++) {
NetworkMessage *currentNetworkMessage = array[a].get(); NetworkMessage *currentNetworkMessage = array[a].get();
TL_message *currentMessage = currentNetworkMessage->message.get();
if (currentNetworkMessage->invokeAfter) { if (currentNetworkMessage->invokeAfter) {
currentRequests.push_back(currentMessage->msg_id); currentRequests.push_back(currentNetworkMessage->message->msg_id);
} }
} }
int64_t maxRequestId = 0; int64_t maxRequestId = 0;
if (lastInvokeAfterMessageId != 0) {
int64_t timeMessage = (int64_t) (lastInvokeAfterMessageId / 4294967296.0);
if (getCurrentTime() - timeMessage <= 30) {
maxRequestId = lastInvokeAfterMessageId;
}
}
for (requestsIter iter2 = runningRequests.begin(); iter2 != runningRequests.end(); iter2++) { for (requestsIter iter2 = runningRequests.begin(); iter2 != runningRequests.end(); iter2++) {
Request *request = iter2->get(); Request *request = iter2->get();
if (request->requestFlags & RequestFlagInvokeAfter) { if (request->requestFlags & RequestFlagInvokeAfter) {
@ -2634,11 +2640,11 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t
TL_invokeAfterMsg *request = new TL_invokeAfterMsg(); TL_invokeAfterMsg *request = new TL_invokeAfterMsg();
request->msg_id = lastSentMessageRpcId; request->msg_id = lastSentMessageRpcId;
if (message->outgoingBody != nullptr) { if (message->outgoingBody != nullptr) {
if (LOGS_ENABLED) DEBUG_D("wrap outgoingBody(%p, %s) to TL_invokeAfterMsg", message->outgoingBody, typeid(*message->outgoingBody).name()); if (LOGS_ENABLED) DEBUG_D("wrap outgoingBody(%p, %s) to TL_invokeAfterMsg, token = %d, after 0x%" PRIx64, message->outgoingBody, typeid(*message->outgoingBody).name(), networkMessage->requestId, request->msg_id);
request->outgoingQuery = message->outgoingBody; request->outgoingQuery = message->outgoingBody;
message->outgoingBody = nullptr; message->outgoingBody = nullptr;
} else { } else {
if (LOGS_ENABLED) DEBUG_D("wrap body(%p, %s) to TL_invokeAfterMsg", message->body.get(), typeid(*(message->body.get())).name()); if (LOGS_ENABLED) DEBUG_D("wrap body(%p, %s) to TL_invokeAfterMsg, token = %d, after 0x%" PRIx64, message->body.get(), typeid(*(message->body.get())).name(), networkMessage->requestId, request->msg_id);
request->query = std::move(message->body); request->query = std::move(message->body);
} }
message->body = std::unique_ptr<TLObject>(request); message->body = std::unique_ptr<TLObject>(request);
@ -2646,6 +2652,7 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t
} }
lastSentMessageRpcId = message->msg_id; lastSentMessageRpcId = message->msg_id;
lastInvokeAfterMessageId = message->msg_id;
} }
} }
@ -2764,6 +2771,13 @@ std::unique_ptr<TLObject> ConnectionsManager::wrapInLayer(TLObject *object, Data
objectValue->key = "installer"; objectValue->key = "installer";
objectValue->value = std::unique_ptr<JSONValue>(jsonString); objectValue->value = std::unique_ptr<JSONValue>(jsonString);
objectValue = new TL_jsonObjectValue();
jsonObject->value.push_back(std::unique_ptr<TL_jsonObjectValue>(objectValue));
jsonString = new TL_jsonString();
jsonString->value = package;
objectValue->key = "package_id";
objectValue->value = std::unique_ptr<JSONValue>(jsonString);
objectValue = new TL_jsonObjectValue(); objectValue = new TL_jsonObjectValue();
jsonObject->value.push_back(std::unique_ptr<TL_jsonObjectValue>(objectValue)); jsonObject->value.push_back(std::unique_ptr<TL_jsonObjectValue>(objectValue));
@ -3212,7 +3226,7 @@ void ConnectionsManager::applyDnsConfig(NativeByteBuffer *buffer, std::string ph
}); });
} }
void ConnectionsManager::init(uint32_t version, int32_t layer, int32_t apiId, std::string deviceModel, std::string systemVersion, std::string appVersion, std::string langCode, std::string systemLangCode, std::string configPath, std::string logPath, std::string regId, std::string cFingerpting, std::string installerId, int32_t timezoneOffset, int32_t userId, bool isPaused, bool enablePushConnection, bool hasNetwork, int32_t networkType) { void ConnectionsManager::init(uint32_t version, int32_t layer, int32_t apiId, std::string deviceModel, std::string systemVersion, std::string appVersion, std::string langCode, std::string systemLangCode, std::string configPath, std::string logPath, std::string regId, std::string cFingerpting, std::string installerId, std::string packageId, int32_t timezoneOffset, int32_t userId, bool isPaused, bool enablePushConnection, bool hasNetwork, int32_t networkType) {
currentVersion = version; currentVersion = version;
currentLayer = layer; currentLayer = layer;
currentApiId = apiId; currentApiId = apiId;
@ -3224,6 +3238,7 @@ void ConnectionsManager::init(uint32_t version, int32_t layer, int32_t apiId, st
currentRegId = regId; currentRegId = regId;
certFingerprint = cFingerpting; certFingerprint = cFingerpting;
installer = installerId; installer = installerId;
package = packageId;
currentDeviceTimezone = timezoneOffset; currentDeviceTimezone = timezoneOffset;
currentSystemLangCode = systemLangCode; currentSystemLangCode = systemLangCode;
currentUserId = userId; currentUserId = userId;

View File

@ -63,7 +63,7 @@ public:
void pauseNetwork(); void pauseNetwork();
void setNetworkAvailable(bool value, int32_t type, bool slow); void setNetworkAvailable(bool value, int32_t type, bool slow);
void setIpStrategy(uint8_t value); void setIpStrategy(uint8_t value);
void init(uint32_t version, int32_t layer, int32_t apiId, std::string deviceModel, std::string systemVersion, std::string appVersion, std::string langCode, std::string systemLangCode, std::string configPath, std::string logPath, std::string regId, std::string cFingerprint, std::string installerId, int32_t timezoneOffset, int32_t userId, bool isPaused, bool enablePushConnection, bool hasNetwork, int32_t networkType); void init(uint32_t version, int32_t layer, int32_t apiId, std::string deviceModel, std::string systemVersion, std::string appVersion, std::string langCode, std::string systemLangCode, std::string configPath, std::string logPath, std::string regId, std::string cFingerprint, std::string installerId, std::string packageId, int32_t timezoneOffset, int32_t userId, bool isPaused, bool enablePushConnection, bool hasNetwork, int32_t networkType);
void setProxySettings(std::string address, uint16_t port, std::string username, std::string password, std::string secret); void setProxySettings(std::string address, uint16_t port, std::string username, std::string password, std::string secret);
void setLangCode(std::string langCode); void setLangCode(std::string langCode);
void setRegId(std::string regId); void setRegId(std::string regId);
@ -206,6 +206,7 @@ private:
requestsList runningRequests; requestsList runningRequests;
std::vector<uint32_t> requestingSaltsForDc; std::vector<uint32_t> requestingSaltsForDc;
int32_t lastPingId = 0; int32_t lastPingId = 0;
int64_t lastInvokeAfterMessageId = 0;
int32_t currentNetworkType = NETWORK_TYPE_WIFI; int32_t currentNetworkType = NETWORK_TYPE_WIFI;
uint32_t currentVersion = 1; uint32_t currentVersion = 1;
@ -218,6 +219,7 @@ private:
std::string currentRegId; std::string currentRegId;
std::string certFingerprint; std::string certFingerprint;
std::string installer; std::string installer;
std::string package;
int32_t currentDeviceTimezone = 0; int32_t currentDeviceTimezone = 0;
std::string currentSystemLangCode; std::string currentSystemLangCode;
std::string currentConfigPath; std::string currentConfigPath;

View File

@ -75,8 +75,6 @@
android:name="org.telegram.messenger.ApplicationLoader" android:name="org.telegram.messenger.ApplicationLoader"
android:allowBackup="false" android:allowBackup="false"
android:hardwareAccelerated="@bool/useHardwareAcceleration" android:hardwareAccelerated="@bool/useHardwareAcceleration"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:largeHeap="true" android:largeHeap="true"
android:theme="@style/Theme.TMessages.Start" android:theme="@style/Theme.TMessages.Start"
android:manageSpaceActivity="org.telegram.ui.ExternalActionActivity" android:manageSpaceActivity="org.telegram.ui.ExternalActionActivity"

View File

@ -49,6 +49,7 @@ import android.provider.MediaStore;
import android.provider.Settings; import android.provider.Settings;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import androidx.core.graphics.ColorUtils;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
@ -185,6 +186,8 @@ public class AndroidUtilities {
private static Paint roundPaint; private static Paint roundPaint;
private static RectF bitmapRect; private static RectF bitmapRect;
public static final RectF rectTmp = new RectF();
public static Pattern WEB_URL = null; public static Pattern WEB_URL = null;
static { static {
@ -365,6 +368,22 @@ public class AndroidUtilities {
int end; int end;
} }
private static Boolean standaloneApp;
public static boolean isStandaloneApp() {
if (standaloneApp == null) {
standaloneApp = "org.telegram.messenger.web".equals(ApplicationLoader.applicationContext.getPackageName());
}
return standaloneApp;
}
private static Boolean betaApp;
public static boolean isBetaApp() {
if (betaApp == null) {
betaApp = "org.telegram.messenger.beta".equals(ApplicationLoader.applicationContext.getPackageName());
}
return betaApp;
}
private static String makeUrl(String url, String[] prefixes, Matcher matcher) { private static String makeUrl(String url, String[] prefixes, Matcher matcher) {
boolean hasPrefix = false; boolean hasPrefix = false;
for (int i = 0; i < prefixes.length; i++) { for (int i = 0; i < prefixes.length; i++) {
@ -2477,6 +2496,17 @@ public class AndroidUtilities {
} }
} }
public static String formatFullDuration(int duration) {
int h = duration / 3600;
int m = duration / 60 % 60;
int s = duration % 60;
if (duration < 0) {
return String.format(Locale.US, "-%02d:%02d:%02d", Math.abs(h), Math.abs(m), Math.abs(s));
} else {
return String.format(Locale.US, "%02d:%02d:%02d", h, m, s);
}
}
public static String formatDurationNoHours(int duration, boolean isLong) { public static String formatDurationNoHours(int duration, boolean isLong) {
int m = duration / 60; int m = duration / 60;
int s = duration % 60; int s = duration % 60;
@ -3666,10 +3696,9 @@ public class AndroidUtilities {
view.setScaleY(1f); view.setScaleY(1f);
} }
view.setTag(1); view.setTag(1);
} else { } else if (!show && view.getTag() != null){
view.animate().setListener(null).cancel(); view.animate().setListener(null).cancel();
if (animated) { if (animated) {
view.animate().alpha(1f).scaleY(1f).scaleX(1f).setDuration(150).start();
view.animate().alpha(0).scaleY(scaleFactor).scaleX(scaleFactor).setListener(new AnimatorListenerAdapter() { view.animate().alpha(0).scaleY(scaleFactor).scaleX(scaleFactor).setListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
@ -3680,6 +3709,13 @@ public class AndroidUtilities {
view.setVisibility(View.GONE); view.setVisibility(View.GONE);
} }
view.setTag(null); view.setTag(null);
} else if (!animated) {
view.animate().setListener(null).cancel();
view.setVisibility(show ? View.VISIBLE : View.GONE);
view.setTag(show ? 1 : null);
view.setAlpha(1f);
view.setScaleX(1f);
view.setScaleY(1f);
} }
} }
} }

View File

@ -18,8 +18,8 @@ public class BuildVars {
public static boolean LOGS_ENABLED = false; public static boolean LOGS_ENABLED = false;
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 int BUILD_VERSION = 2274; public static int BUILD_VERSION = 2284;
public static String BUILD_VERSION_STRING = "7.6.0"; public static String BUILD_VERSION_STRING = "7.7.0";
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";

View File

@ -100,7 +100,7 @@ public class ChatObject {
loadMembers(true); loadMembers(true);
} }
public void addSelfDummyParticipant() { public void addSelfDummyParticipant(boolean notify) {
int selfId = getSelfId(); int selfId = getSelfId();
if (participants.indexOfKey(selfId) >= 0) { if (participants.indexOfKey(selfId) >= 0) {
return; return;
@ -109,17 +109,30 @@ public class ChatObject {
selfDummyParticipant.peer = selfPeer; selfDummyParticipant.peer = selfPeer;
selfDummyParticipant.muted = true; selfDummyParticipant.muted = true;
selfDummyParticipant.self = true; selfDummyParticipant.self = true;
selfDummyParticipant.can_self_unmute = !call.join_muted;
selfDummyParticipant.date = currentAccount.getConnectionsManager().getCurrentTime();
TLRPC.Chat chat = currentAccount.getMessagesController().getChat(chatId); TLRPC.Chat chat = currentAccount.getMessagesController().getChat(chatId);
selfDummyParticipant.can_self_unmute = !call.join_muted || ChatObject.canManageCalls(chat);
selfDummyParticipant.date = currentAccount.getConnectionsManager().getCurrentTime();
if (ChatObject.canManageCalls(chat) || !ChatObject.isChannel(chat) || chat.megagroup || selfDummyParticipant.can_self_unmute) { if (ChatObject.canManageCalls(chat) || !ChatObject.isChannel(chat) || chat.megagroup || selfDummyParticipant.can_self_unmute) {
selfDummyParticipant.active_date = currentAccount.getConnectionsManager().getCurrentTime(); selfDummyParticipant.active_date = currentAccount.getConnectionsManager().getCurrentTime();
} }
if (selfId > 0) {
TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount.getCurrentAccount()).getUserFull(selfId);
if (userFull != null) {
selfDummyParticipant.about = userFull.about;
}
} else {
TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount.getCurrentAccount()).getChatFull(-selfId);
if (chatFull != null) {
selfDummyParticipant.about = chatFull.about;
}
}
participants.put(selfId, selfDummyParticipant); participants.put(selfId, selfDummyParticipant);
sortedParticipants.add(selfDummyParticipant); sortedParticipants.add(selfDummyParticipant);
sortParticipants(); sortParticipants();
if (notify) {
currentAccount.getNotificationCenter().postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, false); currentAccount.getNotificationCenter().postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, false);
} }
}
public void migrateToChat(TLRPC.Chat chat) { public void migrateToChat(TLRPC.Chat chat) {
chatId = chat.id; chatId = chat.id;
@ -129,6 +142,14 @@ public class ChatObject {
} }
} }
public boolean shouldShowPanel() {
return call.participants_count > 0 || isScheduled();
}
public boolean isScheduled() {
return (call.flags & 128) != 0;
}
private int getSelfId() { private int getSelfId() {
int selfId; int selfId;
if (selfPeer != null) { if (selfPeer != null) {

View File

@ -400,7 +400,7 @@ public class DownloadController extends BaseController implements NotificationCe
if (type == AUTODOWNLOAD_TYPE_PHOTO) { if (type == AUTODOWNLOAD_TYPE_PHOTO) {
return PRESET_SIZE_NUM_PHOTO; return PRESET_SIZE_NUM_PHOTO;
} else if (type == AUTODOWNLOAD_TYPE_AUDIO) { } else if (type == AUTODOWNLOAD_TYPE_AUDIO) {
return PRESET_SIZE_NUM_AUDIO; return PRESET_SIZE_NUM_DOCUMENT;
} else if (type == AUTODOWNLOAD_TYPE_VIDEO) { } else if (type == AUTODOWNLOAD_TYPE_VIDEO) {
return PRESET_SIZE_NUM_VIDEO; return PRESET_SIZE_NUM_VIDEO;
} else if (type == AUTODOWNLOAD_TYPE_DOCUMENT) { } else if (type == AUTODOWNLOAD_TYPE_DOCUMENT) {
@ -663,7 +663,12 @@ public class DownloadController extends BaseController implements NotificationCe
preset = getCurrentMobilePreset(); preset = getCurrentMobilePreset();
} }
int mask = preset.mask[index]; int mask = preset.mask[index];
int maxSize = preset.sizes[typeToIndex(type)]; int maxSize;
if (type == AUTODOWNLOAD_TYPE_AUDIO) {
maxSize = Math.max(512 * 1024, preset.sizes[typeToIndex(type)]);
} else {
maxSize = preset.sizes[typeToIndex(type)];
}
int size = MessageObject.getMessageSize(message); int size = MessageObject.getMessageSize(message);
if (isVideo && preset.preloadVideo && size > maxSize && maxSize > 2 * 1024 * 1024) { if (isVideo && preset.preloadVideo && size > maxSize && maxSize > 2 * 1024 * 1024) {
return (mask & type) != 0 ? 2 : 0; return (mask & type) != 0 ? 2 : 0;

View File

@ -196,7 +196,7 @@ public class FileLoadOperation {
location.id = imageLocation.location.volume_id; location.id = imageLocation.location.volume_id;
location.volume_id = imageLocation.location.volume_id; location.volume_id = imageLocation.location.volume_id;
location.local_id = imageLocation.location.local_id; location.local_id = imageLocation.location.local_id;
location.big = imageLocation.photoPeerBig; location.big = imageLocation.photoPeerType == ImageLocation.TYPE_BIG;
location.peer = imageLocation.photoPeer; location.peer = imageLocation.photoPeer;
} else if (imageLocation.stickerSet != null) { } else if (imageLocation.stickerSet != null) {
location = new TLRPC.TL_inputStickerSetThumb(); location = new TLRPC.TL_inputStickerSetThumb();

View File

@ -23,7 +23,7 @@ public class ImageLocation {
public TLRPC.PhotoSize photoSize; public TLRPC.PhotoSize photoSize;
public TLRPC.Photo photo; public TLRPC.Photo photo;
public boolean photoPeerBig; public int photoPeerType;
public TLRPC.InputPeer photoPeer; public TLRPC.InputPeer photoPeer;
public TLRPC.InputStickerSet stickerSet; public TLRPC.InputStickerSet stickerSet;
public int imageType; public int imageType;
@ -99,14 +99,37 @@ public class ImageLocation {
} else { } else {
dc_id = photoSize.location.dc_id; dc_id = photoSize.location.dc_id;
} }
return getForPhoto(photoSize.location, photoSize.size, photo, null, null, false, dc_id, null, photoSize.type); return getForPhoto(photoSize.location, photoSize.size, photo, null, null, TYPE_SMALL, dc_id, null, photoSize.type);
} }
public static ImageLocation getForUser(TLRPC.User user, boolean big) { public static final int TYPE_BIG = 0;
public static final int TYPE_SMALL = 1;
public static final int TYPE_STRIPPED = 2;
public static ImageLocation getForUserOrChat(TLObject object, int type) {
if (object instanceof TLRPC.User) {
return getForUser((TLRPC.User) object, type);
} else if (object instanceof TLRPC.Chat) {
return getForChat((TLRPC.Chat) object, type);
}
return null;
}
public static ImageLocation getForUser(TLRPC.User user, int type) {
if (user == null || user.access_hash == 0 || user.photo == null) { if (user == null || user.access_hash == 0 || user.photo == null) {
return null; return null;
} }
TLRPC.FileLocation fileLocation = big ? user.photo.photo_big : user.photo.photo_small; if (type == TYPE_STRIPPED) {
if (user.photo.stripped_thumb == null) {
return null;
}
ImageLocation imageLocation = new ImageLocation();
imageLocation.photoSize = new TLRPC.TL_photoStrippedSize();
imageLocation.photoSize.type = "s";
imageLocation.photoSize.bytes = user.photo.stripped_thumb;
return imageLocation;
}
TLRPC.FileLocation fileLocation = type == TYPE_BIG ? user.photo.photo_big : user.photo.photo_small;
if (fileLocation == null) { if (fileLocation == null) {
return null; return null;
} }
@ -119,14 +142,24 @@ public class ImageLocation {
} else { } else {
dc_id = fileLocation.dc_id; dc_id = fileLocation.dc_id;
} }
return getForPhoto(fileLocation, 0, null, null, inputPeer, big, dc_id, null, null); return getForPhoto(fileLocation, 0, null, null, inputPeer, type, dc_id, null, null);
} }
public static ImageLocation getForChat(TLRPC.Chat chat, boolean big) { public static ImageLocation getForChat(TLRPC.Chat chat, int type) {
if (chat == null || chat.photo == null) { if (chat == null || chat.photo == null) {
return null; return null;
} }
TLRPC.FileLocation fileLocation = big ? chat.photo.photo_big : chat.photo.photo_small; if (type == TYPE_STRIPPED) {
if (chat.photo.stripped_thumb == null) {
return null;
}
ImageLocation imageLocation = new ImageLocation();
imageLocation.photoSize = new TLRPC.TL_photoStrippedSize();
imageLocation.photoSize.type = "s";
imageLocation.photoSize.bytes = chat.photo.stripped_thumb;
return imageLocation;
}
TLRPC.FileLocation fileLocation = type == TYPE_BIG ? chat.photo.photo_big : chat.photo.photo_small;
if (fileLocation == null) { if (fileLocation == null) {
return null; return null;
} }
@ -148,7 +181,7 @@ public class ImageLocation {
} else { } else {
dc_id = fileLocation.dc_id; dc_id = fileLocation.dc_id;
} }
return getForPhoto(fileLocation, 0, null, null, inputPeer, big, dc_id, null, null); return getForPhoto(fileLocation, 0, null, null, inputPeer, type, dc_id, null, null);
} }
public static ImageLocation getForSticker(TLRPC.PhotoSize photoSize, TLRPC.Document sticker) { public static ImageLocation getForSticker(TLRPC.PhotoSize photoSize, TLRPC.Document sticker) {
@ -163,7 +196,7 @@ public class ImageLocation {
if (stickerSet == null) { if (stickerSet == null) {
return null; return null;
} }
ImageLocation imageLocation = getForPhoto(photoSize.location, photoSize.size, null, null, null, false, sticker.dc_id, stickerSet, photoSize.type); ImageLocation imageLocation = getForPhoto(photoSize.location, photoSize.size, null, null, null, TYPE_SMALL, sticker.dc_id, stickerSet, photoSize.type);
if (MessageObject.isAnimatedStickerDocument(sticker, true)) { if (MessageObject.isAnimatedStickerDocument(sticker, true)) {
imageLocation.imageType = FileLoader.IMAGE_TYPE_LOTTIE; imageLocation.imageType = FileLoader.IMAGE_TYPE_LOTTIE;
} }
@ -174,7 +207,7 @@ public class ImageLocation {
if (videoSize == null || document == null) { if (videoSize == null || document == null) {
return null; return null;
} }
ImageLocation location = getForPhoto(videoSize.location, videoSize.size, null, document, null, false, document.dc_id, null, videoSize.type); ImageLocation location = getForPhoto(videoSize.location, videoSize.size, null, document, null, TYPE_SMALL, document.dc_id, null, videoSize.type);
location.imageType = FileLoader.IMAGE_TYPE_ANIMATION; location.imageType = FileLoader.IMAGE_TYPE_ANIMATION;
return location; return location;
} }
@ -183,7 +216,7 @@ public class ImageLocation {
if (videoSize == null || photo == null) { if (videoSize == null || photo == null) {
return null; return null;
} }
ImageLocation location = getForPhoto(videoSize.location, videoSize.size, photo, null, null, false, photo.dc_id, null, videoSize.type); ImageLocation location = getForPhoto(videoSize.location, videoSize.size, photo, null, null, TYPE_SMALL, photo.dc_id, null, videoSize.type);
location.imageType = FileLoader.IMAGE_TYPE_ANIMATION; location.imageType = FileLoader.IMAGE_TYPE_ANIMATION;
if ((videoSize.flags & 1) != 0) { if ((videoSize.flags & 1) != 0) {
location.videoSeekTo = (int) (videoSize.video_start_ts * 1000); location.videoSeekTo = (int) (videoSize.video_start_ts * 1000);
@ -199,7 +232,7 @@ public class ImageLocation {
} else if (photoSize == null || document == null) { } else if (photoSize == null || document == null) {
return null; return null;
} }
return getForPhoto(photoSize.location, photoSize.size, null, document, null, false, document.dc_id, null, photoSize.type); return getForPhoto(photoSize.location, photoSize.size, null, document, null, TYPE_SMALL, document.dc_id, null, photoSize.type);
} }
public static ImageLocation getForLocal(TLRPC.FileLocation location) { public static ImageLocation getForLocal(TLRPC.FileLocation location) {
@ -215,7 +248,7 @@ public class ImageLocation {
return imageLocation; return imageLocation;
} }
private static ImageLocation getForPhoto(TLRPC.FileLocation location, int size, TLRPC.Photo photo, TLRPC.Document document, TLRPC.InputPeer photoPeer, boolean photoPeerBig, int dc_id, TLRPC.InputStickerSet stickerSet, String thumbSize) { private static ImageLocation getForPhoto(TLRPC.FileLocation location, int size, TLRPC.Photo photo, TLRPC.Document document, TLRPC.InputPeer photoPeer, int photoPeerType, int dc_id, TLRPC.InputStickerSet stickerSet, String thumbSize) {
if (location == null || photo == null && photoPeer == null && stickerSet == null && document == null) { if (location == null || photo == null && photoPeer == null && stickerSet == null && document == null) {
return null; return null;
} }
@ -224,7 +257,7 @@ public class ImageLocation {
imageLocation.photo = photo; imageLocation.photo = photo;
imageLocation.currentSize = size; imageLocation.currentSize = size;
imageLocation.photoPeer = photoPeer; imageLocation.photoPeer = photoPeer;
imageLocation.photoPeerBig = photoPeerBig; imageLocation.photoPeerType = photoPeerType;
imageLocation.stickerSet = stickerSet; imageLocation.stickerSet = stickerSet;
if (location instanceof TLRPC.TL_fileLocationToBeDeprecated) { if (location instanceof TLRPC.TL_fileLocationToBeDeprecated) {
imageLocation.location = (TLRPC.TL_fileLocationToBeDeprecated) location; imageLocation.location = (TLRPC.TL_fileLocationToBeDeprecated) location;

View File

@ -313,6 +313,10 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
setImage(imageLocation, imageFilter, thumbLocation, thumbFilter, null, size, ext, parentObject, cacheType); setImage(imageLocation, imageFilter, thumbLocation, thumbFilter, null, size, ext, parentObject, cacheType);
} }
public void setImage(ImageLocation fileLocation, String fileFilter, ImageLocation thumbLocation, String thumbFilter, Drawable thumb, Object parentObject, int cacheType) {
setImage(null, null, fileLocation, fileFilter, thumbLocation, thumbFilter, thumb, 0, null, parentObject, cacheType);
}
public void setImage(ImageLocation fileLocation, String fileFilter, ImageLocation thumbLocation, String thumbFilter, Drawable thumb, int size, String ext, Object parentObject, int cacheType) { public void setImage(ImageLocation fileLocation, String fileFilter, ImageLocation thumbLocation, String thumbFilter, Drawable thumb, int size, String ext, Object parentObject, int cacheType) {
setImage(null, null, fileLocation, fileFilter, thumbLocation, thumbFilter, thumb, size, ext, parentObject, cacheType); setImage(null, null, fileLocation, fileFilter, thumbLocation, thumbFilter, thumb, size, ext, parentObject, cacheType);
} }

View File

@ -65,7 +65,7 @@ public class LocaleController {
public FastDateFormat formatterScheduleDay; public FastDateFormat formatterScheduleDay;
public FastDateFormat formatterScheduleYear; public FastDateFormat formatterScheduleYear;
public FastDateFormat formatterMonthYear; public FastDateFormat formatterMonthYear;
public FastDateFormat[] formatterScheduleSend = new FastDateFormat[6]; public FastDateFormat[] formatterScheduleSend = new FastDateFormat[15];
private HashMap<String, PluralRules> allRules = new HashMap<>(); private HashMap<String, PluralRules> allRules = new HashMap<>();
@ -1087,7 +1087,53 @@ public class LocaleController {
} }
} }
private static char[] defaultNumbers = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
private static char[][] otherNumbers = new char[][]{
{'٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'},
{'۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'},
{'', '१', '२', '३', '४', '५', '६', '७', '८', '९'},
{'', '૧', '૨', '૩', '૪', '૫', '૬', '૭', '૮', '૯'},
{'', '', '੨', '੩', '', '੫', '੬', '੭', '੮', '੯'},
{'', '১', '২', '৩', '', '৫', '৬', '', '৮', '৯'},
{'', '೧', '೨', '೩', '೪', '೫', '೬', '೭', '೮', '೯'},
{'', '୧', '', '୩', '୪', '୫', '୬', '୭', '୮', '୯'},
{'', '൧', '൨', '൩', '൪', '൫', '൬', '', '൮', '൯'},
{'', '௧', '௨', '௩', '௪', '௫', '௬', '௭', '௮', '௯'},
{'', '౧', '౨', '౩', '౪', '౫', '౬', '౭', '౮', '౯'},
{'', '၁', '၂', '၃', '၄', '၅', '၆', '၇', '၈', '၉'},
{'༠', '༡', '༢', '༣', '༤', '༥', '༦', '༧', '༨', '༩'},
{'᠐', '᠑', '᠒', '᠓', '᠔', '᠕', '᠖', '᠗', '᠘', '᠙'},
{'០', '១', '២', '៣', '៤', '៥', '៦', '៧', '៨', '៩'},
{'', '๑', '๒', '๓', '๔', '๕', '๖', '๗', '๘', '๙'},
{'', '໑', '໒', '໓', '໔', '໕', '໖', '໗', '໘', '໙'},
{'꧐', '꧑', '꧒', '꧓', '꧔', '꧕', '꧖', '꧗', '꧘', '꧙'}
};
public static String fixNumbers(CharSequence numbers) {
StringBuilder builder = new StringBuilder(numbers);
for (int c = 0, N = builder.length(); c < N; c++) {
char ch = builder.charAt(c);
if (ch >= '0' && ch <= '9' || ch == '.' || ch == ',') {
continue;
}
for (int a = 0; a < otherNumbers.length; a++) {
for (int b = 0; b < otherNumbers[a].length; b++) {
if (ch == otherNumbers[a][b]) {
builder.setCharAt(c, defaultNumbers[b]);
a = otherNumbers.length;
break;
}
}
}
}
return builder.toString();
}
public String formatCurrencyString(long amount, String type) { public String formatCurrencyString(long amount, String type) {
return formatCurrencyString(amount, true, type);
}
public String formatCurrencyString(long amount, boolean fixAnything, String type) {
type = type.toUpperCase(); type = type.toUpperCase();
String customFormat; String customFormat;
double doubleAmount; double doubleAmount;
@ -1102,7 +1148,7 @@ public class LocaleController {
case "IRR": case "IRR":
doubleAmount = amount / 100.0f; doubleAmount = amount / 100.0f;
if (amount % 100 == 0) { if (fixAnything && amount % 100 == 0) {
customFormat = " %.0f"; customFormat = " %.0f";
} else { } else {
customFormat = " %.2f"; customFormat = " %.2f";
@ -1158,7 +1204,7 @@ public class LocaleController {
if (currency != null) { if (currency != null) {
NumberFormat format = NumberFormat.getCurrencyInstance(currentLocale != null ? currentLocale : systemDefaultLocale); NumberFormat format = NumberFormat.getCurrencyInstance(currentLocale != null ? currentLocale : systemDefaultLocale);
format.setCurrency(currency); format.setCurrency(currency);
if (type.equals("IRR")) { if (fixAnything && type.equals("IRR")) {
format.setMaximumFractionDigits(0); format.setMaximumFractionDigits(0);
} }
return (discount ? "-" : "") + format.format(doubleAmount); return (discount ? "-" : "") + format.format(doubleAmount);
@ -1166,6 +1212,46 @@ public class LocaleController {
return (discount ? "-" : "") + String.format(Locale.US, type + customFormat, doubleAmount); return (discount ? "-" : "") + String.format(Locale.US, type + customFormat, doubleAmount);
} }
public static int getCurrencyExpDivider(String type) {
switch (type) {
case "CLF":
return 10000;
case "BHD":
case "IQD":
case "JOD":
case "KWD":
case "LYD":
case "OMR":
case "TND":
return 1000;
case "BIF":
case "BYR":
case "CLP":
case "CVE":
case "DJF":
case "GNF":
case "ISK":
case "JPY":
case "KMF":
case "KRW":
case "MGA":
case "PYG":
case "RWF":
case "UGX":
case "UYI":
case "VND":
case "VUV":
case "XAF":
case "XOF":
case "XPF":
return 1;
case "MRO":
return 10;
default:
return 100;
}
}
public String formatCurrencyDecimalString(long amount, String type, boolean inludeType) { public String formatCurrencyDecimalString(long amount, String type, boolean inludeType) {
type = type.toUpperCase(); type = type.toUpperCase();
String customFormat; String customFormat;
@ -1559,12 +1645,57 @@ public class LocaleController {
formatterScheduleSend[3] = createFormatter(locale, getStringInternal("RemindTodayAt", R.string.RemindTodayAt), "'Remind today at' HH:mm"); formatterScheduleSend[3] = createFormatter(locale, getStringInternal("RemindTodayAt", R.string.RemindTodayAt), "'Remind today at' HH:mm");
formatterScheduleSend[4] = createFormatter(locale, getStringInternal("RemindDayAt", R.string.RemindDayAt), "'Remind on' MMM d 'at' HH:mm"); formatterScheduleSend[4] = createFormatter(locale, getStringInternal("RemindDayAt", R.string.RemindDayAt), "'Remind on' MMM d 'at' HH:mm");
formatterScheduleSend[5] = createFormatter(locale, getStringInternal("RemindDayYearAt", R.string.RemindDayYearAt), "'Remind on' MMM d yyyy 'at' HH:mm"); formatterScheduleSend[5] = createFormatter(locale, getStringInternal("RemindDayYearAt", R.string.RemindDayYearAt), "'Remind on' MMM d yyyy 'at' HH:mm");
formatterScheduleSend[6] = createFormatter(locale, getStringInternal("StartTodayAt", R.string.StartTodayAt), "'Start today at' HH:mm");
formatterScheduleSend[7] = createFormatter(locale, getStringInternal("StartDayAt", R.string.StartDayAt), "'Start on' MMM d 'at' HH:mm");
formatterScheduleSend[8] = createFormatter(locale, getStringInternal("StartDayYearAt", R.string.StartDayYearAt), "'Start on' MMM d yyyy 'at' HH:mm");
formatterScheduleSend[9] = createFormatter(locale, getStringInternal("StartShortTodayAt", R.string.StartShortTodayAt), "'Today,' HH:mm");
formatterScheduleSend[10] = createFormatter(locale, getStringInternal("StartShortDayAt", R.string.StartShortDayAt), "MMM d',' HH:mm");
formatterScheduleSend[11] = createFormatter(locale, getStringInternal("StartShortDayYearAt", R.string.StartShortDayYearAt), "MMM d yyyy, HH:mm");
formatterScheduleSend[12] = createFormatter(locale, getStringInternal("StartsTodayAt", R.string.StartsTodayAt), "'Starts today at' HH:mm");
formatterScheduleSend[13] = createFormatter(locale, getStringInternal("StartsDayAt", R.string.StartsDayAt), "'Starts on' MMM d 'at' HH:mm");
formatterScheduleSend[14] = createFormatter(locale, getStringInternal("StartsDayYearAt", R.string.StartsDayYearAt), "'Starts on' MMM d yyyy 'at' HH:mm");
} }
public static boolean isRTLCharacter(char ch) { public static boolean isRTLCharacter(char ch) {
return Character.getDirectionality(ch) == Character.DIRECTIONALITY_RIGHT_TO_LEFT || Character.getDirectionality(ch) == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC || Character.getDirectionality(ch) == Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING || Character.getDirectionality(ch) == Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE; return Character.getDirectionality(ch) == Character.DIRECTIONALITY_RIGHT_TO_LEFT || Character.getDirectionality(ch) == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC || Character.getDirectionality(ch) == Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING || Character.getDirectionality(ch) == Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE;
} }
public static String formatStartsTime(long date, int type) {
return formatStartsTime(date, type, true);
}
public static String formatStartsTime(long date, int type, boolean needToday) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
int currentYear = calendar.get(Calendar.YEAR);
int currentDay = calendar.get(Calendar.DAY_OF_YEAR);
calendar.setTimeInMillis(date * 1000);
int selectedYear = calendar.get(Calendar.YEAR);
int selectedDay = calendar.get(Calendar.DAY_OF_YEAR);
int num;
if (currentYear == selectedYear) {
if (needToday && selectedDay == currentDay) {
num = 0;
} else {
num = 1;
}
} else {
num = 2;
}
if (type == 1) {
num += 3;
} else if (type == 2) {
num += 6;
} else if (type == 3) {
num += 9;
} else if (type == 4) {
num += 12;
}
return LocaleController.getInstance().formatterScheduleSend[num].format(calendar.getTimeInMillis());
}
public static String formatSectionDate(long date) { public static String formatSectionDate(long date) {
try { try {
date *= 1000; date *= 1000;

View File

@ -883,7 +883,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
} }
proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
PowerManager powerManager = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE); PowerManager powerManager = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
proximityWakeLock = powerManager.newWakeLock(0x00000020, "proximity"); proximityWakeLock = powerManager.newWakeLock(0x00000020, "telegram:proximity_lock");
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
} }

View File

@ -144,6 +144,8 @@ public class MediaDataController extends BaseController {
public static final int TYPE_FEATURED = 3; public static final int TYPE_FEATURED = 3;
public static final int TYPE_EMOJI = 4; public static final int TYPE_EMOJI = 4;
public static final int TYPE_GREETINGS = 3;
private ArrayList<TLRPC.TL_messages_stickerSet>[] stickerSets = new ArrayList[]{new ArrayList<>(), new ArrayList<>(), new ArrayList<>(0), new ArrayList<>(), new ArrayList<>()}; private ArrayList<TLRPC.TL_messages_stickerSet>[] stickerSets = new ArrayList[]{new ArrayList<>(), new ArrayList<>(), new ArrayList<>(0), new ArrayList<>(), new ArrayList<>()};
private LongSparseArray<TLRPC.Document>[] stickersByIds = new LongSparseArray[]{new LongSparseArray<>(), new LongSparseArray<>(), new LongSparseArray<>(), new LongSparseArray<>(), new LongSparseArray<>()}; private LongSparseArray<TLRPC.Document>[] stickersByIds = new LongSparseArray[]{new LongSparseArray<>(), new LongSparseArray<>(), new LongSparseArray<>(), new LongSparseArray<>(), new LongSparseArray<>()};
private LongSparseArray<TLRPC.TL_messages_stickerSet> stickerSetsById = new LongSparseArray<>(); private LongSparseArray<TLRPC.TL_messages_stickerSet> stickerSetsById = new LongSparseArray<>();
@ -168,9 +170,9 @@ public class MediaDataController extends BaseController {
private HashMap<String, ArrayList<TLRPC.Document>> allStickers = new HashMap<>(); private HashMap<String, ArrayList<TLRPC.Document>> allStickers = new HashMap<>();
private HashMap<String, ArrayList<TLRPC.Document>> allStickersFeatured = new HashMap<>(); private HashMap<String, ArrayList<TLRPC.Document>> allStickersFeatured = new HashMap<>();
private ArrayList<TLRPC.Document>[] recentStickers = new ArrayList[]{new ArrayList<>(), new ArrayList<>(), new ArrayList<>()}; private ArrayList<TLRPC.Document>[] recentStickers = new ArrayList[]{new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()};
private boolean[] loadingRecentStickers = new boolean[3]; private boolean[] loadingRecentStickers = new boolean[4];
private boolean[] recentStickersLoaded = new boolean[3]; private boolean[] recentStickersLoaded = new boolean[4];
private ArrayList<TLRPC.Document> recentGifs = new ArrayList<>(); private ArrayList<TLRPC.Document> recentGifs = new ArrayList<>();
private boolean loadingRecentGifs; private boolean loadingRecentGifs;
@ -185,8 +187,10 @@ public class MediaDataController extends BaseController {
private boolean loadingFeaturedStickers; private boolean loadingFeaturedStickers;
private boolean featuredStickersLoaded; private boolean featuredStickersLoaded;
private TLRPC.Document greetingsSticker;
public void cleanup() { public void cleanup() {
for (int a = 0; a < 3; a++) { for (int a = 0; a < recentStickers.length; a++) {
recentStickers[a].clear(); recentStickers[a].clear();
loadingRecentStickers[a] = false; loadingRecentStickers[a] = false;
recentStickersLoaded[a] = false; recentStickersLoaded[a] = false;
@ -283,7 +287,7 @@ public class MediaDataController extends BaseController {
} }
public void addRecentSticker(final int type, Object parentObject, TLRPC.Document document, int date, boolean remove) { public void addRecentSticker(final int type, Object parentObject, TLRPC.Document document, int date, boolean remove) {
if (!MessageObject.isStickerDocument(document) && !MessageObject.isAnimatedStickerDocument(document, true)) { if (type == TYPE_GREETINGS || !MessageObject.isStickerDocument(document) && !MessageObject.isAnimatedStickerDocument(document, true)) {
return; return;
} }
boolean found = false; boolean found = false;
@ -749,6 +753,8 @@ public class MediaDataController extends BaseController {
cacheType = 3; cacheType = 3;
} else if (type == TYPE_MASK) { } else if (type == TYPE_MASK) {
cacheType = 4; cacheType = 4;
} else if (type == TYPE_GREETINGS) {
cacheType = 6;
} else { } else {
cacheType = 5; cacheType = 5;
} }
@ -777,6 +783,9 @@ public class MediaDataController extends BaseController {
loadingRecentStickers[type] = false; loadingRecentStickers[type] = false;
recentStickersLoaded[type] = true; recentStickersLoaded[type] = true;
} }
if (type == TYPE_GREETINGS) {
preloadNextGreetingsSticker();
}
getNotificationCenter().postNotificationName(NotificationCenter.recentDocumentsDidLoad, gif, type); getNotificationCenter().postNotificationName(NotificationCenter.recentDocumentsDidLoad, gif, type);
loadRecents(type, gif, false, false); loadRecents(type, gif, false, false);
}); });
@ -794,6 +803,8 @@ public class MediaDataController extends BaseController {
lastLoadTime = preferences.getLong("lastStickersLoadTime", 0); lastLoadTime = preferences.getLong("lastStickersLoadTime", 0);
} else if (type == TYPE_MASK) { } else if (type == TYPE_MASK) {
lastLoadTime = preferences.getLong("lastStickersLoadTimeMask", 0); lastLoadTime = preferences.getLong("lastStickersLoadTimeMask", 0);
} else if (type == TYPE_GREETINGS) {
lastLoadTime = preferences.getLong("lastStickersLoadTimeGreet", 0);
} else { } else {
lastLoadTime = preferences.getLong("lastStickersLoadTimeFavs", 0); lastLoadTime = preferences.getLong("lastStickersLoadTimeFavs", 0);
} }
@ -823,6 +834,11 @@ public class MediaDataController extends BaseController {
TLRPC.TL_messages_getFavedStickers req = new TLRPC.TL_messages_getFavedStickers(); TLRPC.TL_messages_getFavedStickers req = new TLRPC.TL_messages_getFavedStickers();
req.hash = calcDocumentsHash(recentStickers[type]); req.hash = calcDocumentsHash(recentStickers[type]);
request = req; request = req;
} else if (type == TYPE_GREETINGS) {
TLRPC.TL_messages_getStickers req = new TLRPC.TL_messages_getStickers();
req.emoticon = "\uD83D\uDC4B" + Emoji.fixEmoji("");
req.hash = calcDocumentsHash(recentStickers[type]);
request = req;
} else { } else {
TLRPC.TL_messages_getRecentStickers req = new TLRPC.TL_messages_getRecentStickers(); TLRPC.TL_messages_getRecentStickers req = new TLRPC.TL_messages_getRecentStickers();
req.hash = calcDocumentsHash(recentStickers[type]); req.hash = calcDocumentsHash(recentStickers[type]);
@ -831,7 +847,12 @@ public class MediaDataController extends BaseController {
} }
getConnectionsManager().sendRequest(request, (response, error) -> { getConnectionsManager().sendRequest(request, (response, error) -> {
ArrayList<TLRPC.Document> arrayList = null; ArrayList<TLRPC.Document> arrayList = null;
if (type == TYPE_FAVE) { if (type == TYPE_GREETINGS) {
if (response instanceof TLRPC.TL_messages_stickers) {
TLRPC.TL_messages_stickers res = (TLRPC.TL_messages_stickers) response;
arrayList = res.stickers;
}
} else if (type == TYPE_FAVE) {
if (response instanceof TLRPC.TL_messages_favedStickers) { if (response instanceof TLRPC.TL_messages_favedStickers) {
TLRPC.TL_messages_favedStickers res = (TLRPC.TL_messages_favedStickers) response; TLRPC.TL_messages_favedStickers res = (TLRPC.TL_messages_favedStickers) response;
arrayList = res.stickers; arrayList = res.stickers;
@ -842,12 +863,26 @@ public class MediaDataController extends BaseController {
arrayList = res.stickers; arrayList = res.stickers;
} }
} }
processLoadedRecentDocuments(type, arrayList, gif, 0, true); processLoadedRecentDocuments(type, arrayList, false, 0, true);
}); });
} }
} }
} }
private void preloadNextGreetingsSticker() {
if (recentStickers[TYPE_GREETINGS].isEmpty()) {
return;
}
greetingsSticker = recentStickers[TYPE_GREETINGS].get(Utilities.random.nextInt(recentStickers[TYPE_GREETINGS].size()));
getFileLoader().loadFile(ImageLocation.getForDocument(greetingsSticker), greetingsSticker, null, 0, 1);
}
public TLRPC.Document getGreetingsSticker() {
TLRPC.Document result = greetingsSticker;
preloadNextGreetingsSticker();
return result;
}
protected void processLoadedRecentDocuments(final int type, final ArrayList<TLRPC.Document> documents, final boolean gif, final int date, boolean replace) { protected void processLoadedRecentDocuments(final int type, final ArrayList<TLRPC.Document> documents, final boolean gif, final int date, boolean replace) {
if (documents != null) { if (documents != null) {
getMessagesStorage().getStorageQueue().postRunnable(() -> { getMessagesStorage().getStorageQueue().postRunnable(() -> {
@ -857,7 +892,9 @@ public class MediaDataController extends BaseController {
if (gif) { if (gif) {
maxCount = getMessagesController().maxRecentGifsCount; maxCount = getMessagesController().maxRecentGifsCount;
} else { } else {
if (type == TYPE_FAVE) { if (type == TYPE_GREETINGS) {
maxCount = 200;
} else if (type == TYPE_FAVE) {
maxCount = getMessagesController().maxFaveStickersCount; maxCount = getMessagesController().maxFaveStickersCount;
} else { } else {
maxCount = getMessagesController().maxRecentStickersCount; maxCount = getMessagesController().maxRecentStickersCount;
@ -874,6 +911,8 @@ public class MediaDataController extends BaseController {
cacheType = 3; cacheType = 3;
} else if (type == TYPE_MASK) { } else if (type == TYPE_MASK) {
cacheType = 4; cacheType = 4;
} else if (type == TYPE_GREETINGS) {
cacheType = 6;
} else { } else {
cacheType = 5; cacheType = 5;
} }
@ -899,10 +938,8 @@ public class MediaDataController extends BaseController {
document.serializeToStream(data); document.serializeToStream(data);
state.bindByteBuffer(10, data); state.bindByteBuffer(10, data);
state.step(); state.step();
if (data != null) {
data.reuse(); data.reuse();
} }
}
state.dispose(); state.dispose();
database.commitTransaction(); database.commitTransaction();
if (documents.size() >= maxCount) { if (documents.size() >= maxCount) {
@ -931,6 +968,8 @@ public class MediaDataController extends BaseController {
editor.putLong("lastStickersLoadTime", System.currentTimeMillis()).commit(); editor.putLong("lastStickersLoadTime", System.currentTimeMillis()).commit();
} else if (type == TYPE_MASK) { } else if (type == TYPE_MASK) {
editor.putLong("lastStickersLoadTimeMask", System.currentTimeMillis()).commit(); editor.putLong("lastStickersLoadTimeMask", System.currentTimeMillis()).commit();
} else if (type == TYPE_GREETINGS) {
editor.putLong("lastStickersLoadTimeGreet", System.currentTimeMillis()).commit();
} else { } else {
editor.putLong("lastStickersLoadTimeFavs", System.currentTimeMillis()).commit(); editor.putLong("lastStickersLoadTimeFavs", System.currentTimeMillis()).commit();
} }
@ -941,6 +980,9 @@ public class MediaDataController extends BaseController {
} else { } else {
recentStickers[type] = documents; recentStickers[type] = documents;
} }
if (type == TYPE_GREETINGS) {
preloadNextGreetingsSticker();
}
getNotificationCenter().postNotificationName(NotificationCenter.recentDocumentsDidLoad, gif, type); getNotificationCenter().postNotificationName(NotificationCenter.recentDocumentsDidLoad, gif, type);
} else { } else {

View File

@ -2424,7 +2424,10 @@ public class MessageObject {
if (messageOwner instanceof TLRPC.TL_messageService) { if (messageOwner instanceof TLRPC.TL_messageService) {
if (messageOwner.action != null) { if (messageOwner.action != null) {
if (messageOwner.action instanceof TLRPC.TL_messageActionGroupCall) { if (messageOwner.action instanceof TLRPC.TL_messageActionGroupCallScheduled) {
TLRPC.TL_messageActionGroupCallScheduled action = (TLRPC.TL_messageActionGroupCallScheduled) messageOwner.action;
messageText = LocaleController.formatString("ActionGroupCallScheduled", R.string.ActionGroupCallScheduled, LocaleController.formatStartsTime(action.schedule_date, 3, false));
} else if (messageOwner.action instanceof TLRPC.TL_messageActionGroupCall) {
if (messageOwner.action.duration != 0) { if (messageOwner.action.duration != 0) {
String time; String time;
int days = messageOwner.action.duration / (3600 * 24); int days = messageOwner.action.duration / (3600 * 24);

View File

@ -313,9 +313,6 @@ public class MessagesController extends BaseController implements NotificationCe
public volatile boolean ignoreSetOnline; public volatile boolean ignoreSetOnline;
private ArrayList<TLRPC.Document> preloadedStickers = new ArrayList<>();
private boolean preloadingSticker;
public static class FaqSearchResult { public static class FaqSearchResult {
public String title; public String title;
@ -2390,7 +2387,7 @@ public class MessagesController extends BaseController implements NotificationCe
editor = emojiPreferences.edit(); editor = emojiPreferences.edit();
editor.putLong("lastGifLoadTime", 0).putLong("lastStickersLoadTime", 0).putLong("lastStickersLoadTimeMask", 0).putLong("lastStickersLoadTimeFavs", 0).commit(); editor.putLong("lastGifLoadTime", 0).putLong("lastStickersLoadTime", 0).putLong("lastStickersLoadTimeMask", 0).putLong("lastStickersLoadTimeFavs", 0).commit();
editor = mainPreferences.edit(); editor = mainPreferences.edit();
editor.remove("archivehint").remove("proximityhint").remove("archivehint_l").remove("gifhint").remove("soundHint").remove("dcDomainName2").remove("webFileDatacenterId").remove("themehint").remove("showFiltersTooltip").commit(); editor.remove("archivehint").remove("proximityhint").remove("archivehint_l").remove("gifhint").remove("reminderhint").remove("soundHint").remove("dcDomainName2").remove("webFileDatacenterId").remove("themehint").remove("showFiltersTooltip").commit();
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
SharedPreferences.Editor widgetEditor = null; SharedPreferences.Editor widgetEditor = null;
@ -3006,6 +3003,9 @@ public class MessagesController extends BaseController implements NotificationCe
})); }));
} }
} }
if (result != null && result.call instanceof TLRPC.TL_groupCallDiscarded) {
return null;
}
return result; return result;
} }
@ -8885,14 +8885,11 @@ public class MessagesController extends BaseController implements NotificationCe
} }
public void updateChatAbout(int chat_id, final String about, final TLRPC.ChatFull info) { public void updateChatAbout(int chat_id, final String about, final TLRPC.ChatFull info) {
if (info == null) {
return;
}
TLRPC.TL_messages_editChatAbout req = new TLRPC.TL_messages_editChatAbout(); TLRPC.TL_messages_editChatAbout req = new TLRPC.TL_messages_editChatAbout();
req.peer = getInputPeer(-chat_id); req.peer = getInputPeer(-chat_id);
req.about = about; req.about = about;
getConnectionsManager().sendRequest(req, (response, error) -> { getConnectionsManager().sendRequest(req, (response, error) -> {
if (response instanceof TLRPC.TL_boolTrue) { if (response instanceof TLRPC.TL_boolTrue && info != null) {
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
info.about = about; info.about = about;
getMessagesStorage().updateChatInfo(info, false); getMessagesStorage().updateChatInfo(info, false);
@ -9141,7 +9138,7 @@ public class MessagesController extends BaseController implements NotificationCe
} }
} }
public void changeChatAvatar(int chat_id, TLRPC.TL_inputChatPhoto oldPhoto, TLRPC.InputFile inputPhoto, final TLRPC.InputFile inputVideo, double videoStartTimestamp, String videoPath, TLRPC.FileLocation smallSize, TLRPC.FileLocation bigSize) { public void changeChatAvatar(int chat_id, TLRPC.TL_inputChatPhoto oldPhoto, TLRPC.InputFile inputPhoto, final TLRPC.InputFile inputVideo, double videoStartTimestamp, String videoPath, TLRPC.FileLocation smallSize, TLRPC.FileLocation bigSize, Runnable callback) {
TLObject request; TLObject request;
TLRPC.InputChatPhoto inputChatPhoto; TLRPC.InputChatPhoto inputChatPhoto;
if (oldPhoto != null) { if (oldPhoto != null) {
@ -9221,7 +9218,12 @@ public class MessagesController extends BaseController implements NotificationCe
} }
} }
processUpdates(updates, false); processUpdates(updates, false);
AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_AVATAR)); AndroidUtilities.runOnUIThread(() -> {
if (callback != null) {
callback.run();
}
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_AVATAR);
});
}, ConnectionsManager.RequestFlagInvokeAfter); }, ConnectionsManager.RequestFlagInvokeAfter);
} }
@ -13977,7 +13979,7 @@ public class MessagesController extends BaseController implements NotificationCe
} }
for (int a = 0, N = reasons.size(); a < N; a++) { for (int a = 0, N = reasons.size(); a < N; a++) {
TLRPC.TL_restrictionReason reason = reasons.get(a); TLRPC.TL_restrictionReason reason = reasons.get(a);
if ("all".equals(reason.platform) || "android".equals(reason.platform)) { if ("all".equals(reason.platform) || !AndroidUtilities.isStandaloneApp() && !AndroidUtilities.isBetaApp() && "android".equals(reason.platform)) {
return reason.text; return reason.text;
} }
} }
@ -14238,9 +14240,6 @@ public class MessagesController extends BaseController implements NotificationCe
if (callback != null) { if (callback != null) {
callback.onMessagesLoaded(isCache); callback.onMessagesLoaded(isCache);
} }
if (lower_part > 0 && size == 0) {
preloadGreetingsSticker();
}
} }
} else if (id == NotificationCenter.loadingMessagesFailed && (Integer) args[0] == classGuid) { } else if (id == NotificationCenter.loadingMessagesFailed && (Integer) args[0] == classGuid) {
getNotificationCenter().removeObserver(this, NotificationCenter.messagesDidLoadWithoutProcess); getNotificationCenter().removeObserver(this, NotificationCenter.messagesDidLoadWithoutProcess);
@ -14263,34 +14262,6 @@ public class MessagesController extends BaseController implements NotificationCe
} }
} }
public void preloadGreetingsSticker() {
if (preloadingSticker) {
return;
}
preloadingSticker = true;
TLRPC.TL_messages_getStickers req = new TLRPC.TL_messages_getStickers();
req.emoticon = "\uD83D\uDC4B" + Emoji.fixEmoji("");
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
if (response instanceof TLRPC.TL_messages_stickers) {
ArrayList<TLRPC.Document> list = ((TLRPC.TL_messages_stickers) response).stickers;
if (!list.isEmpty()) {
AndroidUtilities.runOnUIThread(() -> {
for (int i = 0; i < list.size(); i++) {
TLRPC.Document sticker = list.get(i);
FileLoader.getInstance(currentAccount).loadFile(ImageLocation.getForDocument(sticker), sticker, null, 0, 1);
preloadedStickers.add(sticker);
}
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.greetingsStickerLoaded);
});
}
}
});
}
public TLRPC.Document getPreloadedSticker() {
return !preloadedStickers.isEmpty() ? preloadedStickers.get(Utilities.random.nextInt(preloadedStickers.size())) : null;
}
public interface MessagesLoadedCallback { public interface MessagesLoadedCallback {
void onMessagesLoaded(boolean fromCache); void onMessagesLoaded(boolean fromCache);
void onError(); void onError();

View File

@ -6562,6 +6562,7 @@ public class MessagesStorage extends BaseController {
} }
int minId = Integer.MAX_VALUE; int minId = Integer.MAX_VALUE;
int maxId = Integer.MIN_VALUE; int maxId = Integer.MIN_VALUE;
ArrayList<Long> messageIdsToFix = null;
if (cursor != null) { if (cursor != null) {
while (cursor.next()) { while (cursor.next()) {
messagesCount++; messagesCount++;
@ -6572,7 +6573,14 @@ public class MessagesStorage extends BaseController {
if (data != null) { if (data != null) {
TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false);
message.send_state = cursor.intValue(2); message.send_state = cursor.intValue(2);
message.id = cursor.intValue(3); long fullMid = cursor.longValue(3);
message.id = (int) fullMid;
if ((fullMid & 0xffffffff00000000L) == 0xffffffff00000000L && message.id > 0) {
if (messageIdsToFix == null) {
messageIdsToFix = new ArrayList<>();
}
messageIdsToFix.add(fullMid);
}
if (message.id > 0 && message.send_state != 0 && message.send_state != 3) { if (message.id > 0 && message.send_state != 0 && message.send_state != 3) {
message.send_state = 0; message.send_state = 0;
} }
@ -6678,6 +6686,18 @@ public class MessagesStorage extends BaseController {
} }
cursor.dispose(); cursor.dispose();
} }
if (messageIdsToFix != null) { //TODO remove later
SQLitePreparedStatement state = database.executeFast("UPDATE messages SET mid = ? WHERE mid = ?");
for (int a = 0, N = messageIdsToFix.size(); a < N; a++) {
long id = messageIdsToFix.get(a);
state.requery();
state.bindLong(1, (int) id);
state.bindLong(2, id);
state.step();
}
state.dispose();
}
Collections.sort(res.messages, (lhs, rhs) -> { Collections.sort(res.messages, (lhs, rhs) -> {
if (lhs.id > 0 && rhs.id > 0) { if (lhs.id > 0 && rhs.id > 0) {

View File

@ -22,7 +22,7 @@ import java.util.zip.ZipFile;
public class NativeLoader { public class NativeLoader {
private final static int LIB_VERSION = 37; private final static int LIB_VERSION = 38;
private final static String LIB_NAME = "tmessages." + LIB_VERSION; private final static String LIB_NAME = "tmessages." + LIB_VERSION;
private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so"; private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so"; private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";

View File

@ -213,7 +213,6 @@ public class NotificationCenter {
public static final int webRtcMicAmplitudeEvent = totalEvents++; public static final int webRtcMicAmplitudeEvent = totalEvents++;
public static final int webRtcSpeakerAmplitudeEvent = totalEvents++; public static final int webRtcSpeakerAmplitudeEvent = totalEvents++;
public static final int showBulletin = totalEvents++; public static final int showBulletin = totalEvents++;
public static final int greetingsStickerLoaded = totalEvents++;
private SparseArray<ArrayList<NotificationCenterDelegate>> observers = new SparseArray<>(); private SparseArray<ArrayList<NotificationCenterDelegate>> observers = new SparseArray<>();
private SparseArray<ArrayList<NotificationCenterDelegate>> removeAfterBroadcast = new SparseArray<>(); private SparseArray<ArrayList<NotificationCenterDelegate>> removeAfterBroadcast = new SparseArray<>();

View File

@ -1404,6 +1404,8 @@ public class NotificationsController extends BaseController {
} }
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGroupCall) { } else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGroupCall) {
return LocaleController.formatString("NotificationGroupCreatedCall", R.string.NotificationGroupCreatedCall, name, chat.title); return LocaleController.formatString("NotificationGroupCreatedCall", R.string.NotificationGroupCreatedCall, name, chat.title);
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGroupCallScheduled) {
return messageObject.messageText.toString();
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionInviteToGroupCall) { } else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionInviteToGroupCall) {
int singleUserId = messageObject.messageOwner.action.user_id; int singleUserId = messageObject.messageOwner.action.user_id;
if (singleUserId == 0 && messageObject.messageOwner.action.users.size() == 1) { if (singleUserId == 0 && messageObject.messageOwner.action.users.size() == 1) {
@ -2023,6 +2025,8 @@ public class NotificationsController extends BaseController {
} }
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGroupCall) { } else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGroupCall) {
msg = LocaleController.formatString("NotificationGroupCreatedCall", R.string.NotificationGroupCreatedCall, name, chat.title); msg = LocaleController.formatString("NotificationGroupCreatedCall", R.string.NotificationGroupCreatedCall, name, chat.title);
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGroupCallScheduled) {
msg = messageObject.messageText.toString();
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionInviteToGroupCall) { } else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionInviteToGroupCall) {
int singleUserId = messageObject.messageOwner.action.user_id; int singleUserId = messageObject.messageOwner.action.user_id;
if (singleUserId == 0 && messageObject.messageOwner.action.users.size() == 1) { if (singleUserId == 0 && messageObject.messageOwner.action.users.size() == 1) {

View File

@ -42,6 +42,7 @@ import android.widget.Toast;
import androidx.annotation.UiThread; import androidx.annotation.UiThread;
import androidx.core.view.inputmethod.InputContentInfoCompat; import androidx.core.view.inputmethod.InputContentInfoCompat;
import org.json.JSONObject;
import org.telegram.messenger.audioinfo.AudioInfo; import org.telegram.messenger.audioinfo.AudioInfo;
import org.telegram.messenger.support.SparseLongArray; import org.telegram.messenger.support.SparseLongArray;
import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.ConnectionsManager;
@ -1616,7 +1617,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
TLRPC.TL_keyboardButtonRow newRow = null; TLRPC.TL_keyboardButtonRow newRow = null;
for (int c = 0, N2 = oldRow.buttons.size(); c < N2; c++) { for (int c = 0, N2 = oldRow.buttons.size(); c < N2; c++) {
TLRPC.KeyboardButton button = oldRow.buttons.get(c); TLRPC.KeyboardButton button = oldRow.buttons.get(c);
if (button instanceof TLRPC.TL_keyboardButtonUrlAuth || button instanceof TLRPC.TL_keyboardButtonUrl || button instanceof TLRPC.TL_keyboardButtonSwitchInline) { if (button instanceof TLRPC.TL_keyboardButtonUrlAuth || button instanceof TLRPC.TL_keyboardButtonUrl || button instanceof TLRPC.TL_keyboardButtonSwitchInline || button instanceof TLRPC.TL_keyboardButtonBuy) {
if (button instanceof TLRPC.TL_keyboardButtonUrlAuth) { if (button instanceof TLRPC.TL_keyboardButtonUrlAuth) {
TLRPC.TL_keyboardButtonUrlAuth auth = new TLRPC.TL_keyboardButtonUrlAuth(); TLRPC.TL_keyboardButtonUrlAuth auth = new TLRPC.TL_keyboardButtonUrlAuth();
auth.flags = button.flags; auth.flags = button.flags;
@ -2541,9 +2542,9 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
if (response instanceof TLRPC.TL_payments_paymentForm) { if (response instanceof TLRPC.TL_payments_paymentForm) {
final TLRPC.TL_payments_paymentForm form = (TLRPC.TL_payments_paymentForm) response; final TLRPC.TL_payments_paymentForm form = (TLRPC.TL_payments_paymentForm) response;
getMessagesController().putUsers(form.users, false); getMessagesController().putUsers(form.users, false);
parentFragment.presentFragment(new PaymentFormActivity(form, messageObject)); parentFragment.presentFragment(new PaymentFormActivity(form, messageObject, parentFragment));
} else if (response instanceof TLRPC.TL_payments_paymentReceipt) { } else if (response instanceof TLRPC.TL_payments_paymentReceipt) {
parentFragment.presentFragment(new PaymentFormActivity(messageObject, (TLRPC.TL_payments_paymentReceipt) response)); parentFragment.presentFragment(new PaymentFormActivity((TLRPC.TL_payments_paymentReceipt) response));
} }
} else { } else {
TLRPC.TL_messages_botCallbackAnswer res = (TLRPC.TL_messages_botCallbackAnswer) response; TLRPC.TL_messages_botCallbackAnswer res = (TLRPC.TL_messages_botCallbackAnswer) response;
@ -2730,10 +2731,26 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
if ((messageObject.messageOwner.media.flags & 4) == 0) { if ((messageObject.messageOwner.media.flags & 4) == 0) {
TLRPC.TL_payments_getPaymentForm req = new TLRPC.TL_payments_getPaymentForm(); TLRPC.TL_payments_getPaymentForm req = new TLRPC.TL_payments_getPaymentForm();
req.msg_id = messageObject.getId(); req.msg_id = messageObject.getId();
req.peer = getMessagesController().getInputPeer(messageObject.messageOwner.peer_id);
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put("bg_color", Theme.getColor(Theme.key_windowBackgroundWhite));
jsonObject.put("text_color", Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
jsonObject.put("hint_color", Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
jsonObject.put("link_color", Theme.getColor(Theme.key_windowBackgroundWhiteLinkText));
jsonObject.put("button_color", Theme.getColor(Theme.key_featuredStickers_addButton));
jsonObject.put("button_text_color", Theme.getColor(Theme.key_featuredStickers_buttonText));
req.theme_params = new TLRPC.TL_dataJSON();
req.theme_params.data = jsonObject.toString();
req.flags |= 1;
} catch (Exception e) {
FileLog.e(e);
}
getConnectionsManager().sendRequest(req, requestDelegate, ConnectionsManager.RequestFlagFailOnServerErrors); getConnectionsManager().sendRequest(req, requestDelegate, ConnectionsManager.RequestFlagFailOnServerErrors);
} else { } else {
TLRPC.TL_payments_getPaymentReceipt req = new TLRPC.TL_payments_getPaymentReceipt(); TLRPC.TL_payments_getPaymentReceipt req = new TLRPC.TL_payments_getPaymentReceipt();
req.msg_id = messageObject.messageOwner.media.receipt_msg_id; req.msg_id = messageObject.messageOwner.media.receipt_msg_id;
req.peer = getMessagesController().getInputPeer(messageObject.messageOwner.peer_id);
getConnectionsManager().sendRequest(req, requestDelegate, ConnectionsManager.RequestFlagFailOnServerErrors); getConnectionsManager().sendRequest(req, requestDelegate, ConnectionsManager.RequestFlagFailOnServerErrors);
} }
} else { } else {
@ -2815,38 +2832,42 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
} }
public void sendMessage(MessageObject retryMessageObject) { public void sendMessage(MessageObject retryMessageObject) {
sendMessage(null, null, null, null, null, null, null, null, null, retryMessageObject.getDialogId(), retryMessageObject.messageOwner.attachPath, null, null, null, true, retryMessageObject, null, retryMessageObject.messageOwner.reply_markup, retryMessageObject.messageOwner.params, !retryMessageObject.messageOwner.silent, retryMessageObject.scheduled ? retryMessageObject.messageOwner.date : 0, 0, null); sendMessage(null, null, null, null, null, null, null, null, null, null, retryMessageObject.getDialogId(), retryMessageObject.messageOwner.attachPath, null, null, null, true, retryMessageObject, null, retryMessageObject.messageOwner.reply_markup, retryMessageObject.messageOwner.params, !retryMessageObject.messageOwner.silent, retryMessageObject.scheduled ? retryMessageObject.messageOwner.date : 0, 0, null);
} }
public void sendMessage(TLRPC.User user, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate) { public void sendMessage(TLRPC.User user, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate) {
sendMessage(null, null, null, null, null, user, null, null, null, peer, null, replyToMsg, replyToTopMsg, null, true, null, null, replyMarkup, params, notify, scheduleDate, 0, null); sendMessage(null, null, null, null, null, user, null, null, null, null, peer, null, replyToMsg, replyToTopMsg, null, true, null, null, replyMarkup, params, notify, scheduleDate, 0, null);
}
public void sendMessage(TLRPC.TL_messageMediaInvoice invoice, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate) {
sendMessage(null, null, null, null, null, null, null, null, null, invoice, peer, null, replyToMsg, replyToTopMsg, null, true, null, null, replyMarkup, params, notify, scheduleDate, 0, null);
} }
public void sendMessage(TLRPC.TL_document document, VideoEditedInfo videoEditedInfo, String path, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, String caption, ArrayList<TLRPC.MessageEntity> entities, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate, int ttl, Object parentObject) { public void sendMessage(TLRPC.TL_document document, VideoEditedInfo videoEditedInfo, String path, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, String caption, ArrayList<TLRPC.MessageEntity> entities, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate, int ttl, Object parentObject) {
sendMessage(null, caption, null, null, videoEditedInfo, null, document, null, null, peer, path, replyToMsg, replyToTopMsg, null, true, null, entities, replyMarkup, params, notify, scheduleDate, ttl, parentObject); sendMessage(null, caption, null, null, videoEditedInfo, null, document, null, null, null, peer, path, replyToMsg, replyToTopMsg, null, true, null, entities, replyMarkup, params, notify, scheduleDate, ttl, parentObject);
} }
public void sendMessage(String message, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, TLRPC.WebPage webPage, boolean searchLinks, ArrayList<TLRPC.MessageEntity> entities, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate) { public void sendMessage(String message, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, TLRPC.WebPage webPage, boolean searchLinks, ArrayList<TLRPC.MessageEntity> entities, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate) {
sendMessage(message, null, null, null, null, null, null, null, null, peer, null, replyToMsg, replyToTopMsg, webPage, searchLinks, null, entities, replyMarkup, params, notify, scheduleDate, 0, null); sendMessage(message, null, null, null, null, null, null, null, null, null, peer, null, replyToMsg, replyToTopMsg, webPage, searchLinks, null, entities, replyMarkup, params, notify, scheduleDate, 0, null);
} }
public void sendMessage(TLRPC.MessageMedia location, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate) { public void sendMessage(TLRPC.MessageMedia location, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate) {
sendMessage(null, null, location, null, null, null, null, null, null, peer, null, replyToMsg, replyToTopMsg, null, true, null, null, replyMarkup, params, notify, scheduleDate, 0, null); sendMessage(null, null, location, null, null, null, null, null, null, null, peer, null, replyToMsg, replyToTopMsg, null, true, null, null, replyMarkup, params, notify, scheduleDate, 0, null);
} }
public void sendMessage(TLRPC.TL_messageMediaPoll poll, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate) { public void sendMessage(TLRPC.TL_messageMediaPoll poll, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate) {
sendMessage(null, null, null, null, null, null, null, null, poll, peer, null, replyToMsg, replyToTopMsg, null, true, null, null, replyMarkup, params, notify, scheduleDate, 0, null); sendMessage(null, null, null, null, null, null, null, null, poll, null, peer, null, replyToMsg, replyToTopMsg, null, true, null, null, replyMarkup, params, notify, scheduleDate, 0, null);
} }
public void sendMessage(TLRPC.TL_game game, long peer, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate) { public void sendMessage(TLRPC.TL_game game, long peer, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate) {
sendMessage(null, null, null, null, null, null, null, game, null, peer, null, null, null, null, true, null, null, replyMarkup, params, notify, scheduleDate, 0, null); sendMessage(null, null, null, null, null, null, null, game, null, null, peer, null, null, null, null, true, null, null, replyMarkup, params, notify, scheduleDate, 0, null);
} }
public void sendMessage(TLRPC.TL_photo photo, String path, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, String caption, ArrayList<TLRPC.MessageEntity> entities, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate, int ttl, Object parentObject) { public void sendMessage(TLRPC.TL_photo photo, String path, long peer, MessageObject replyToMsg, MessageObject replyToTopMsg, String caption, ArrayList<TLRPC.MessageEntity> entities, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate, int ttl, Object parentObject) {
sendMessage(null, caption, null, photo, null, null, null, null, null, peer, path, replyToMsg, replyToTopMsg, null, true, null, entities, replyMarkup, params, notify, scheduleDate, ttl, parentObject); sendMessage(null, caption, null, photo, null, null, null, null, null, null, peer, path, replyToMsg, replyToTopMsg, null, true, null, entities, replyMarkup, params, notify, scheduleDate, ttl, parentObject);
} }
private void sendMessage(String message, String caption, TLRPC.MessageMedia location, TLRPC.TL_photo photo, VideoEditedInfo videoEditedInfo, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_game game, TLRPC.TL_messageMediaPoll poll, long peer, String path, MessageObject replyToMsg, MessageObject replyToTopMsg, TLRPC.WebPage webPage, boolean searchLinks, MessageObject retryMessageObject, ArrayList<TLRPC.MessageEntity> entities, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate, int ttl, Object parentObject) { private void sendMessage(String message, String caption, TLRPC.MessageMedia location, TLRPC.TL_photo photo, VideoEditedInfo videoEditedInfo, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_game game, TLRPC.TL_messageMediaPoll poll, TLRPC.TL_messageMediaInvoice invoice, long peer, String path, MessageObject replyToMsg, MessageObject replyToTopMsg, TLRPC.WebPage webPage, boolean searchLinks, MessageObject retryMessageObject, ArrayList<TLRPC.MessageEntity> entities, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params, boolean notify, int scheduleDate, int ttl, Object parentObject) {
if (user != null && user.phone == null) { if (user != null && user.phone == null) {
return; return;
} }
@ -3053,6 +3074,12 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
if (params != null && params.containsKey("query_id")) { if (params != null && params.containsKey("query_id")) {
type = 9; type = 9;
} }
} else if (invoice != null) {
newMsg = new TLRPC.TL_message();
newMsg.media = invoice;
if (params != null && params.containsKey("query_id")) {
type = 9;
}
} else if (user != null) { } else if (user != null) {
if (encryptedChat != null) { if (encryptedChat != null) {
newMsg = new TLRPC.TL_message_secret(); newMsg = new TLRPC.TL_message_secret();
@ -5040,7 +5067,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
newMsgObj.flags |= TLRPC.MESSAGE_FLAG_HAS_MEDIA; newMsgObj.flags |= TLRPC.MESSAGE_FLAG_HAS_MEDIA;
ImageLoader.saveMessageThumbs(newMsgObj); ImageLoader.saveMessageThumbs(newMsgObj);
} }
if (res.media instanceof TLRPC.TL_messageMediaGame && !TextUtils.isEmpty(res.message)) { if ((res.media instanceof TLRPC.TL_messageMediaGame || res.media instanceof TLRPC.TL_messageMediaInvoice) && !TextUtils.isEmpty(res.message)) {
newMsgObj.message = res.message; newMsgObj.message = res.message;
} }
if (!newMsgObj.entities.isEmpty()) { if (!newMsgObj.entities.isEmpty()) {
@ -5207,7 +5234,6 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByAck, msg_id); getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByAck, msg_id);
}); });
}, ConnectionsManager.RequestFlagCanCompress | ConnectionsManager.RequestFlagInvokeAfter | (req instanceof TLRPC.TL_messages_sendMessage ? ConnectionsManager.RequestFlagNeedQuickAck : 0)); }, ConnectionsManager.RequestFlagCanCompress | ConnectionsManager.RequestFlagInvokeAfter | (req instanceof TLRPC.TL_messages_sendMessage ? ConnectionsManager.RequestFlagNeedQuickAck : 0));
if (parentMessage != null) { if (parentMessage != null) {
parentMessage.sendDelayedRequests(); parentMessage.sendDelayedRequests();
} }
@ -5435,12 +5461,16 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
} else if (sentMessage.media instanceof TLRPC.TL_messageMediaGeo) { } else if (sentMessage.media instanceof TLRPC.TL_messageMediaGeo) {
sentMessage.media.geo.lat = newMsg.media.geo.lat; sentMessage.media.geo.lat = newMsg.media.geo.lat;
sentMessage.media.geo._long = newMsg.media.geo._long; sentMessage.media.geo._long = newMsg.media.geo._long;
} else if (sentMessage.media instanceof TLRPC.TL_messageMediaGame) { } else if (sentMessage.media instanceof TLRPC.TL_messageMediaGame || sentMessage.media instanceof TLRPC.TL_messageMediaInvoice) {
newMsg.media = sentMessage.media; newMsg.media = sentMessage.media;
if (newMsg.media instanceof TLRPC.TL_messageMediaGame && !TextUtils.isEmpty(sentMessage.message)) { if (!TextUtils.isEmpty(sentMessage.message)) {
newMsg.entities = sentMessage.entities; newMsg.entities = sentMessage.entities;
newMsg.message = sentMessage.message; newMsg.message = sentMessage.message;
} }
if (sentMessage.reply_markup != null) {
newMsg.reply_markup = sentMessage.reply_markup;
newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_MARKUP;
}
} else if (sentMessage.media instanceof TLRPC.TL_messageMediaPoll) { } else if (sentMessage.media instanceof TLRPC.TL_messageMediaPoll) {
newMsg.media = sentMessage.media; newMsg.media = sentMessage.media;
} }
@ -6438,6 +6468,24 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
reason.reason = ""; reason.reason = "";
user.restriction_reason.add(reason); user.restriction_reason.add(reason);
accountInstance.getSendMessagesHelper().sendMessage(user, dialogId, replyToMsg, replyToTopMsg, result.send_message.reply_markup, params, notify, scheduleDate); accountInstance.getSendMessagesHelper().sendMessage(user, dialogId, replyToMsg, replyToTopMsg, result.send_message.reply_markup, params, notify, scheduleDate);
} else if (result.send_message instanceof TLRPC.TL_botInlineMessageMediaInvoice) {
if (DialogObject.isSecretDialogId(dialogId)) {
return; //doesn't work in secret chats for now
}
TLRPC.TL_botInlineMessageMediaInvoice invoice = (TLRPC.TL_botInlineMessageMediaInvoice) result.send_message;
TLRPC.TL_messageMediaInvoice messageMediaInvoice = new TLRPC.TL_messageMediaInvoice();
messageMediaInvoice.shipping_address_requested = invoice.shipping_address_requested;
messageMediaInvoice.test = invoice.test;
messageMediaInvoice.title = invoice.title;
messageMediaInvoice.description = invoice.description;
if (invoice.photo != null) {
messageMediaInvoice.photo = invoice.photo;
messageMediaInvoice.flags |= 1;
}
messageMediaInvoice.currency = invoice.currency;
messageMediaInvoice.total_amount = invoice.total_amount;
messageMediaInvoice.start_param = "";
accountInstance.getSendMessagesHelper().sendMessage(messageMediaInvoice, dialogId, replyToMsg, replyToTopMsg, result.send_message.reply_markup, params, notify, scheduleDate);
} }
} }
@ -7360,6 +7408,9 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
orientation[0] = fileDrawable.getOrientation(); orientation[0] = fileDrawable.getOrientation();
} }
fileDrawable.recycle(); fileDrawable.recycle();
if (bitmap == null) {
return createVideoThumbnailAtTime(filePath, time, orientation, false);
}
} else { } else {
MediaMetadataRetriever retriever = new MediaMetadataRetriever(); MediaMetadataRetriever retriever = new MediaMetadataRetriever();
try { try {

View File

@ -260,11 +260,15 @@ public class SvgHelper {
placeholderMatrix = new Matrix(); placeholderMatrix = new Matrix();
placeholderGradient.setLocalMatrix(placeholderMatrix); placeholderGradient.setLocalMatrix(placeholderMatrix);
for (Paint paint : paints.values()) { for (Paint paint : paints.values()) {
if (Build.VERSION.SDK_INT <= 22) {
paint.setShader(backgroundGradient);
} else {
paint.setShader(new ComposeShader(placeholderGradient, backgroundGradient, PorterDuff.Mode.ADD)); paint.setShader(new ComposeShader(placeholderGradient, backgroundGradient, PorterDuff.Mode.ADD));
} }
} }
} }
} }
}
public static Bitmap getBitmap(File file, int width, int height, boolean white) { public static Bitmap getBitmap(File file, int width, int height, boolean white) {
try (FileInputStream stream = new FileInputStream(file)) { try (FileInputStream stream = new FileInputStream(file)) {

View File

@ -96,7 +96,7 @@ public class WearDataLayerListenerService extends WearableListenerService {
}; };
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
NotificationCenter.getInstance(currentAccount).addObserver(listener, NotificationCenter.fileDidLoad); NotificationCenter.getInstance(currentAccount).addObserver(listener, NotificationCenter.fileDidLoad);
FileLoader.getInstance(currentAccount).loadFile(ImageLocation.getForUser(user, false), user, null, 1, 1); FileLoader.getInstance(currentAccount).loadFile(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), user, null, 1, 1);
}); });
try { try {
barrier.await(10, TimeUnit.SECONDS); barrier.await(10, TimeUnit.SECONDS);

View File

@ -195,6 +195,7 @@ public abstract class VoIPBaseService extends Service implements SensorEventList
protected int mySource; protected int mySource;
protected String myJson; protected String myJson;
protected boolean createGroupCall; protected boolean createGroupCall;
protected int scheduleDate;
protected TLRPC.InputPeer groupCallPeer; protected TLRPC.InputPeer groupCallPeer;
public boolean hasFewPeers; public boolean hasFewPeers;
protected String joinHash; protected String joinHash;
@ -1281,6 +1282,7 @@ public abstract class VoIPBaseService extends Service implements SensorEventList
protected Bitmap getRoundAvatarBitmap(TLObject userOrChat) { protected Bitmap getRoundAvatarBitmap(TLObject userOrChat) {
Bitmap bitmap = null; Bitmap bitmap = null;
try {
if (userOrChat instanceof TLRPC.User) { if (userOrChat instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) userOrChat; TLRPC.User user = (TLRPC.User) userOrChat;
if (user.photo != null && user.photo.photo_small != null) { if (user.photo != null && user.photo.photo_small != null) {
@ -1314,6 +1316,9 @@ public abstract class VoIPBaseService extends Service implements SensorEventList
} }
} }
} }
} catch (Throwable e) {
FileLog.e(e);
}
if (bitmap == null) { if (bitmap == null) {
Theme.createDialogsResources(this); Theme.createDialogsResources(this);
AvatarDrawable placeholder; AvatarDrawable placeholder;

View File

@ -237,6 +237,7 @@ public class VoIPService extends VoIPBaseService {
groupCallPeer.user_id = peerUserId; groupCallPeer.user_id = peerUserId;
groupCallPeer.access_hash = intent.getLongExtra("peerAccessHash", 0); groupCallPeer.access_hash = intent.getLongExtra("peerAccessHash", 0);
} }
scheduleDate = intent.getIntExtra("scheduleDate", 0);
isOutgoing = intent.getBooleanExtra("is_outgoing", false); isOutgoing = intent.getBooleanExtra("is_outgoing", false);
videoCall = intent.getBooleanExtra("video_call", false); videoCall = intent.getBooleanExtra("video_call", false);
@ -1328,6 +1329,10 @@ public class VoIPService extends VoIPBaseService {
TLRPC.TL_phone_createGroupCall req = new TLRPC.TL_phone_createGroupCall(); TLRPC.TL_phone_createGroupCall req = new TLRPC.TL_phone_createGroupCall();
req.peer = MessagesController.getInputPeer(chat); req.peer = MessagesController.getInputPeer(chat);
req.random_id = Utilities.random.nextInt(); req.random_id = Utilities.random.nextInt();
if (scheduleDate != 0) {
req.schedule_date = scheduleDate;
req.flags |= 2;
}
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
if (response != null) { if (response != null) {
TLRPC.Updates updates = (TLRPC.Updates) response; TLRPC.Updates updates = (TLRPC.Updates) response;
@ -1673,8 +1678,7 @@ public class VoIPService extends VoIPBaseService {
connectingSoundRunnable = null; connectingSoundRunnable = null;
} }
} else { } else {
Utilities.globalQueue.postRunnable(() -> soundPool.play(spVoiceChatStartId, 1.0f, 1.0f, 0, 0, 1)); playConnectedSound();
playedConnectedSound = true;
} }
if (!wasConnected) { if (!wasConnected) {
wasConnected = true; wasConnected = true;
@ -1866,6 +1870,11 @@ public class VoIPService extends VoIPBaseService {
} }
} }
public void playConnectedSound() {
Utilities.globalQueue.postRunnable(() -> soundPool.play(spVoiceChatStartId, 1.0f, 1.0f, 0, 0, 1));
playedConnectedSound = true;
}
private void startConnectingSound() { private void startConnectingSound() {
Utilities.globalQueue.postRunnable(() -> { Utilities.globalQueue.postRunnable(() -> {
if (spPlayId != 0) { if (spPlayId != 0) {

View File

@ -376,8 +376,17 @@ public class ConnectionsManager extends BaseController {
if (installer == null) { if (installer == null) {
installer = ""; installer = "";
} }
String packageId = "";
try {
packageId = ApplicationLoader.applicationContext.getPackageName();
} catch (Throwable ignore) {
native_init(currentAccount, version, layer, apiId, deviceModel, systemVersion, appVersion, langCode, systemLangCode, configPath, logPath, regId, cFingerprint, installer, timezoneOffset, userId, enablePushConnection, ApplicationLoader.isNetworkOnline(), ApplicationLoader.getCurrentNetworkType()); }
if (packageId == null) {
packageId = "";
}
native_init(currentAccount, version, layer, apiId, deviceModel, systemVersion, appVersion, langCode, systemLangCode, configPath, logPath, regId, cFingerprint, installer, packageId, timezoneOffset, userId, enablePushConnection, ApplicationLoader.isNetworkOnline(), ApplicationLoader.getCurrentNetworkType());
checkConnection(); checkConnection();
} }
@ -688,7 +697,7 @@ public class ConnectionsManager extends BaseController {
public static native void native_applyDatacenterAddress(int currentAccount, int datacenterId, String ipAddress, int port); public static native void native_applyDatacenterAddress(int currentAccount, int datacenterId, String ipAddress, int port);
public static native int native_getConnectionState(int currentAccount); public static native int native_getConnectionState(int currentAccount);
public static native void native_setUserId(int currentAccount, int id); public static native void native_setUserId(int currentAccount, int id);
public static native void native_init(int currentAccount, int version, int layer, int apiId, String deviceModel, String systemVersion, String appVersion, String langCode, String systemLangCode, String configPath, String logPath, String regId, String cFingerprint, String installer, int timezoneOffset, int userId, boolean enablePushConnection, boolean hasNetwork, int networkType); public static native void native_init(int currentAccount, int version, int layer, int apiId, String deviceModel, String systemVersion, String appVersion, String langCode, String systemLangCode, String configPath, String logPath, String regId, String cFingerprint, String installer, String packageId, int timezoneOffset, int userId, boolean enablePushConnection, boolean hasNetwork, int networkType);
public static native void native_setProxySettings(int currentAccount, String address, int port, String username, String password, String secret); public static native void native_setProxySettings(int currentAccount, String address, int port, String username, String password, String secret);
public static native void native_setLangCode(int currentAccount, String langCode); public static native void native_setLangCode(int currentAccount, String langCode);
public static native void native_setRegId(int currentAccount, String regId); public static native void native_setRegId(int currentAccount, String regId);

View File

@ -62,7 +62,7 @@ public class TLRPC {
public static final int MESSAGE_FLAG_HAS_BOT_ID = 0x00000800; public static final int MESSAGE_FLAG_HAS_BOT_ID = 0x00000800;
public static final int MESSAGE_FLAG_EDITED = 0x00008000; public static final int MESSAGE_FLAG_EDITED = 0x00008000;
public static final int LAYER = 126; public static final int LAYER = 127;
public static class TL_stats_megagroupStats extends TLObject { public static class TL_stats_megagroupStats extends TLObject {
public static int constructor = 0xef7ff916; public static int constructor = 0xef7ff916;
@ -400,6 +400,7 @@ public class TLRPC {
public boolean has_video; public boolean has_video;
public FileLocation photo_small; public FileLocation photo_small;
public FileLocation photo_big; public FileLocation photo_big;
public byte[] stripped_thumb;
public int dc_id; public int dc_id;
public static ChatPhoto TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { public static ChatPhoto TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
@ -415,6 +416,9 @@ public class TLRPC {
result = new TL_chatPhoto_layer97(); result = new TL_chatPhoto_layer97();
break; break;
case 0xd20b9f3c: case 0xd20b9f3c:
result = new TL_chatPhoto_layer126();
break;
case 0x4790ee05:
result = new TL_chatPhoto(); result = new TL_chatPhoto();
break; break;
} }
@ -471,7 +475,7 @@ public class TLRPC {
} }
} }
public static class TL_chatPhoto extends ChatPhoto { public static class TL_chatPhoto_layer126 extends TL_chatPhoto {
public static int constructor = 0xd20b9f3c; public static int constructor = 0xd20b9f3c;
@ -493,6 +497,34 @@ public class TLRPC {
} }
} }
public static class TL_chatPhoto extends ChatPhoto {
public static int constructor = 0x4790ee05;
public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception);
has_video = (flags & 1) != 0;
photo_small = FileLocation.TLdeserialize(stream, stream.readInt32(exception), exception);
photo_big = FileLocation.TLdeserialize(stream, stream.readInt32(exception), exception);
if ((flags & 2) != 0) {
stripped_thumb = stream.readByteArray(exception);
}
dc_id = stream.readInt32(exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
flags = has_video ? (flags | 1) : (flags &~ 1);
stream.writeInt32(flags);
photo_small.serializeToStream(stream);
photo_big.serializeToStream(stream);
if ((flags & 2) != 0) {
stream.writeByteArray(stripped_thumb);
}
stream.writeInt32(dc_id);
}
}
public static class TL_help_termsOfService extends TLObject { public static class TL_help_termsOfService extends TLObject {
public static int constructor = 0x780a0310; public static int constructor = 0x780a0310;
@ -560,15 +592,19 @@ public class TLRPC {
} }
public static class TL_payments_paymentReceipt extends TLObject { public static class TL_payments_paymentReceipt extends TLObject {
public static int constructor = 0x500911e1; public static int constructor = 0x10b555d0;
public int flags; public int flags;
public int date; public int date;
public int bot_id; public int bot_id;
public TL_invoice invoice;
public int provider_id; public int provider_id;
public String title;
public String description;
public WebDocument photo;
public TL_invoice invoice;
public TL_paymentRequestedInfo info; public TL_paymentRequestedInfo info;
public TL_shippingOption shipping; public TL_shippingOption shipping;
public long tip_amount;
public String currency; public String currency;
public long total_amount; public long total_amount;
public String credentials_title; public String credentials_title;
@ -591,14 +627,22 @@ public class TLRPC {
flags = stream.readInt32(exception); flags = stream.readInt32(exception);
date = stream.readInt32(exception); date = stream.readInt32(exception);
bot_id = stream.readInt32(exception); bot_id = stream.readInt32(exception);
invoice = TL_invoice.TLdeserialize(stream, stream.readInt32(exception), exception);
provider_id = stream.readInt32(exception); provider_id = stream.readInt32(exception);
title = stream.readString(exception);
description = stream.readString(exception);
if ((flags & 4) != 0) {
photo = WebDocument.TLdeserialize(stream, stream.readInt32(exception), exception);
}
invoice = TL_invoice.TLdeserialize(stream, stream.readInt32(exception), exception);
if ((flags & 1) != 0) { if ((flags & 1) != 0) {
info = TL_paymentRequestedInfo.TLdeserialize(stream, stream.readInt32(exception), exception); info = TL_paymentRequestedInfo.TLdeserialize(stream, stream.readInt32(exception), exception);
} }
if ((flags & 2) != 0) { if ((flags & 2) != 0) {
shipping = TL_shippingOption.TLdeserialize(stream, stream.readInt32(exception), exception); shipping = TL_shippingOption.TLdeserialize(stream, stream.readInt32(exception), exception);
} }
if ((flags & 8) != 0) {
tip_amount = stream.readInt64(exception);
}
currency = stream.readString(exception); currency = stream.readString(exception);
total_amount = stream.readInt64(exception); total_amount = stream.readInt64(exception);
credentials_title = stream.readString(exception); credentials_title = stream.readString(exception);
@ -624,14 +668,22 @@ public class TLRPC {
stream.writeInt32(flags); stream.writeInt32(flags);
stream.writeInt32(date); stream.writeInt32(date);
stream.writeInt32(bot_id); stream.writeInt32(bot_id);
invoice.serializeToStream(stream);
stream.writeInt32(provider_id); stream.writeInt32(provider_id);
stream.writeString(title);
stream.writeString(description);
if ((flags & 4) != 0) {
photo.serializeToStream(stream);
}
invoice.serializeToStream(stream);
if ((flags & 1) != 0) { if ((flags & 1) != 0) {
info.serializeToStream(stream); info.serializeToStream(stream);
} }
if ((flags & 2) != 0) { if ((flags & 2) != 0) {
shipping.serializeToStream(stream); shipping.serializeToStream(stream);
} }
if ((flags & 8) != 0) {
stream.writeInt64(tip_amount);
}
stream.writeString(currency); stream.writeString(currency);
stream.writeInt64(total_amount); stream.writeInt64(total_amount);
stream.writeString(credentials_title); stream.writeString(credentials_title);
@ -1876,15 +1928,17 @@ public class TLRPC {
public boolean join_muted; public boolean join_muted;
public boolean can_change_join_muted; public boolean can_change_join_muted;
public boolean join_date_asc; public boolean join_date_asc;
public boolean schedule_start_subscribed;
public long id; public long id;
public long access_hash; public long access_hash;
public int duration;
public int participants_count; public int participants_count;
public TL_dataJSON params; public TL_dataJSON params;
public String title; public String title;
public int stream_dc_id; public int stream_dc_id;
public int record_start_date; public int record_start_date;
public int schedule_date;
public int version; public int version;
public int duration;
public static GroupCall TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { public static GroupCall TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
GroupCall result = null; GroupCall result = null;
@ -1892,7 +1946,7 @@ public class TLRPC {
case 0x7780bcb4: case 0x7780bcb4:
result = new TL_groupCallDiscarded(); result = new TL_groupCallDiscarded();
break; break;
case 0xc0c2052e: case 0xc95c6654:
result = new TL_groupCall(); result = new TL_groupCall();
break; break;
} }
@ -1925,7 +1979,7 @@ public class TLRPC {
} }
public static class TL_groupCall extends GroupCall { public static class TL_groupCall extends GroupCall {
public static int constructor = 0xc0c2052e; public static int constructor = 0xc95c6654;
public void readParams(AbstractSerializedData stream, boolean exception) { public void readParams(AbstractSerializedData stream, boolean exception) {
@ -1933,6 +1987,7 @@ public class TLRPC {
join_muted = (flags & 2) != 0; join_muted = (flags & 2) != 0;
can_change_join_muted = (flags & 4) != 0; can_change_join_muted = (flags & 4) != 0;
join_date_asc = (flags & 64) != 0; join_date_asc = (flags & 64) != 0;
schedule_start_subscribed = (flags & 256) != 0;
id = stream.readInt64(exception); id = stream.readInt64(exception);
access_hash = stream.readInt64(exception); access_hash = stream.readInt64(exception);
participants_count = stream.readInt32(exception); participants_count = stream.readInt32(exception);
@ -1948,6 +2003,9 @@ public class TLRPC {
if ((flags & 32) != 0) { if ((flags & 32) != 0) {
record_start_date = stream.readInt32(exception); record_start_date = stream.readInt32(exception);
} }
if ((flags & 128) != 0) {
schedule_date = stream.readInt32(exception);
}
version = stream.readInt32(exception); version = stream.readInt32(exception);
} }
@ -1956,6 +2014,7 @@ public class TLRPC {
flags = join_muted ? (flags | 2) : (flags &~ 2); flags = join_muted ? (flags | 2) : (flags &~ 2);
flags = can_change_join_muted ? (flags | 4) : (flags &~ 4); flags = can_change_join_muted ? (flags | 4) : (flags &~ 4);
flags = join_date_asc ? (flags | 64) : (flags &~ 64); flags = join_date_asc ? (flags | 64) : (flags &~ 64);
flags = schedule_start_subscribed ? (flags | 256) : (flags &~ 256);
stream.writeInt32(flags); stream.writeInt32(flags);
stream.writeInt64(id); stream.writeInt64(id);
stream.writeInt64(access_hash); stream.writeInt64(access_hash);
@ -1972,6 +2031,9 @@ public class TLRPC {
if ((flags & 32) != 0) { if ((flags & 32) != 0) {
stream.writeInt32(record_start_date); stream.writeInt32(record_start_date);
} }
if ((flags & 128) != 0) {
stream.writeInt32(schedule_date);
}
stream.writeInt32(version); stream.writeInt32(version);
} }
} }
@ -2874,11 +2936,12 @@ public class TLRPC {
} }
public static class TL_payments_paymentForm extends TLObject { public static class TL_payments_paymentForm extends TLObject {
public static int constructor = 0x3f56aea3; public static int constructor = 0x8d0b2415;
public int flags; public int flags;
public boolean can_save_credentials; public boolean can_save_credentials;
public boolean password_missing; public boolean password_missing;
public long form_id;
public int bot_id; public int bot_id;
public TL_invoice invoice; public TL_invoice invoice;
public int provider_id; public int provider_id;
@ -2906,6 +2969,7 @@ public class TLRPC {
flags = stream.readInt32(exception); flags = stream.readInt32(exception);
can_save_credentials = (flags & 4) != 0; can_save_credentials = (flags & 4) != 0;
password_missing = (flags & 8) != 0; password_missing = (flags & 8) != 0;
form_id = stream.readInt64(exception);
bot_id = stream.readInt32(exception); bot_id = stream.readInt32(exception);
invoice = TL_invoice.TLdeserialize(stream, stream.readInt32(exception), exception); invoice = TL_invoice.TLdeserialize(stream, stream.readInt32(exception), exception);
provider_id = stream.readInt32(exception); provider_id = stream.readInt32(exception);
@ -2944,6 +3008,7 @@ public class TLRPC {
flags = can_save_credentials ? (flags | 4) : (flags &~ 4); flags = can_save_credentials ? (flags | 4) : (flags &~ 4);
flags = password_missing ? (flags | 8) : (flags &~ 8); flags = password_missing ? (flags | 8) : (flags &~ 8);
stream.writeInt32(flags); stream.writeInt32(flags);
stream.writeInt64(form_id);
stream.writeInt32(bot_id); stream.writeInt32(bot_id);
invoice.serializeToStream(stream); invoice.serializeToStream(stream);
stream.writeInt32(provider_id); stream.writeInt32(provider_id);
@ -14034,6 +14099,9 @@ public class TLRPC {
case 0x51846fd: case 0x51846fd:
result = new TL_botInlineMessageMediaGeo(); result = new TL_botInlineMessageMediaGeo();
break; break;
case 0x354a9b09:
result = new TL_botInlineMessageMediaInvoice();
break;
} }
if (result == null && exception) { if (result == null && exception) {
throw new RuntimeException(String.format("can't parse magic %x in BotInlineMessage", constructor)); throw new RuntimeException(String.format("can't parse magic %x in BotInlineMessage", constructor));
@ -14363,6 +14431,50 @@ public class TLRPC {
} }
} }
public static class TL_botInlineMessageMediaInvoice extends BotInlineMessage {
public static int constructor = 0x354a9b09;
public boolean shipping_address_requested;
public boolean test;
public String description;
public WebDocument photo;
public String currency;
public long total_amount;
public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception);
shipping_address_requested = (flags & 2) != 0;
test = (flags & 8) != 0;
title = stream.readString(exception);
description = stream.readString(exception);
if ((flags & 1) != 0) {
photo = WebDocument.TLdeserialize(stream, stream.readInt32(exception), exception);
}
currency = stream.readString(exception);
total_amount = stream.readInt64(exception);
if ((flags & 4) != 0) {
reply_markup = ReplyMarkup.TLdeserialize(stream, stream.readInt32(exception), exception);
}
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
flags = shipping_address_requested ? (flags | 2) : (flags &~ 2);
flags = test ? (flags | 8) : (flags &~ 8);
stream.writeInt32(flags);
stream.writeString(title);
stream.writeString(description);
if ((flags & 1) != 0) {
photo.serializeToStream(stream);
}
stream.writeString(currency);
stream.writeInt64(total_amount);
if ((flags & 4) != 0) {
reply_markup.serializeToStream(stream);
}
}
}
public static class TL_keyboardButtonRow extends TLObject { public static class TL_keyboardButtonRow extends TLObject {
public static int constructor = 0x77608b83; public static int constructor = 0x77608b83;
@ -18367,6 +18479,9 @@ public class TLRPC {
case 0x92a72876: case 0x92a72876:
result = new TL_messageActionGameScore(); result = new TL_messageActionGameScore();
break; break;
case 0xb3a07661:
result = new TL_messageActionGroupCallScheduled();
break;
} }
if (result == null && exception) { if (result == null && exception) {
throw new RuntimeException(String.format("can't parse magic %x in MessageAction", constructor)); throw new RuntimeException(String.format("can't parse magic %x in MessageAction", constructor));
@ -18896,6 +19011,23 @@ public class TLRPC {
} }
} }
public static class TL_messageActionGroupCallScheduled extends MessageAction {
public static int constructor = 0xb3a07661;
public int schedule_date;
public void readParams(AbstractSerializedData stream, boolean exception) {
call = TL_inputGroupCall.TLdeserialize(stream, stream.readInt32(exception), exception);
schedule_date = stream.readInt32(exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
call.serializeToStream(stream);
stream.writeInt32(schedule_date);
}
}
public static abstract class ReportReason extends TLObject { public static abstract class ReportReason extends TLObject {
public static ReportReason TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { public static ReportReason TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
@ -19412,7 +19544,7 @@ public class TLRPC {
} }
public static class TL_invoice extends TLObject { public static class TL_invoice extends TLObject {
public static int constructor = 0xc30aa358; public static int constructor = 0xcd886e0;
public int flags; public int flags;
public boolean test; public boolean test;
@ -19425,6 +19557,8 @@ public class TLRPC {
public boolean email_to_provider; public boolean email_to_provider;
public String currency; public String currency;
public ArrayList<TL_labeledPrice> prices = new ArrayList<>(); public ArrayList<TL_labeledPrice> prices = new ArrayList<>();
public long max_tip_amount;
public ArrayList<Long> suggested_tip_amounts = new ArrayList<>();
public static TL_invoice TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { public static TL_invoice TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
if (TL_invoice.constructor != constructor) { if (TL_invoice.constructor != constructor) {
@ -19465,6 +19599,22 @@ public class TLRPC {
} }
prices.add(object); prices.add(object);
} }
if ((flags & 256) != 0) {
max_tip_amount = stream.readInt64(exception);
}
if ((flags & 256) != 0) {
magic = stream.readInt32(exception);
if (magic != 0x1cb5c415) {
if (exception) {
throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
}
return;
}
count = stream.readInt32(exception);
for (int a = 0; a < count; a++) {
suggested_tip_amounts.add(stream.readInt64(exception));
}
}
} }
public void serializeToStream(AbstractSerializedData stream) { public void serializeToStream(AbstractSerializedData stream) {
@ -19485,6 +19635,17 @@ public class TLRPC {
for (int a = 0; a < count; a++) { for (int a = 0; a < count; a++) {
prices.get(a).serializeToStream(stream); prices.get(a).serializeToStream(stream);
} }
if ((flags & 256) != 0) {
stream.writeInt64(max_tip_amount);
}
if ((flags & 256) != 0) {
stream.writeInt32(0x1cb5c415);
count = suggested_tip_amounts.size();
stream.writeInt32(count);
for (int a = 0; a < count; a++) {
stream.writeInt64(suggested_tip_amounts.get(a));
}
}
} }
} }
@ -26695,13 +26856,14 @@ public class TLRPC {
public long photo_id; public long photo_id;
public FileLocation photo_small; public FileLocation photo_small;
public FileLocation photo_big; public FileLocation photo_big;
public byte[] stripped_thumb;
public int dc_id; public int dc_id;
public static UserProfilePhoto TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { public static UserProfilePhoto TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
UserProfilePhoto result = null; UserProfilePhoto result = null;
switch (constructor) { switch (constructor) {
case 0x69d3ab26: case 0x69d3ab26:
result = new TL_userProfilePhoto(); result = new TL_userProfilePhoto_layer126();
break; break;
case 0xecd75d8c: case 0xecd75d8c:
result = new TL_userProfilePhoto_layer115(); result = new TL_userProfilePhoto_layer115();
@ -26715,6 +26877,9 @@ public class TLRPC {
case 0x990d1493: case 0x990d1493:
result = new TL_userProfilePhoto_old(); result = new TL_userProfilePhoto_old();
break; break;
case 0xcc656077:
result = new TL_userProfilePhoto();
break;
} }
if (result == null && exception) { if (result == null && exception) {
throw new RuntimeException(String.format("can't parse magic %x in UserProfilePhoto", constructor)); throw new RuntimeException(String.format("can't parse magic %x in UserProfilePhoto", constructor));
@ -26726,7 +26891,7 @@ public class TLRPC {
} }
} }
public static class TL_userProfilePhoto extends UserProfilePhoto { public static class TL_userProfilePhoto_layer126 extends TL_userProfilePhoto {
public static int constructor = 0x69d3ab26; public static int constructor = 0x69d3ab26;
@ -26750,6 +26915,36 @@ public class TLRPC {
} }
} }
public static class TL_userProfilePhoto extends UserProfilePhoto {
public static int constructor = 0xcc656077;
public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception);
has_video = (flags & 1) != 0;
photo_id = stream.readInt64(exception);
photo_small = FileLocation.TLdeserialize(stream, stream.readInt32(exception), exception);
photo_big = FileLocation.TLdeserialize(stream, stream.readInt32(exception), exception);
if ((flags & 2) != 0) {
stripped_thumb = stream.readByteArray(exception);
}
dc_id = stream.readInt32(exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
flags = has_video ? (flags | 1) : (flags &~ 1);
stream.writeInt32(flags);
stream.writeInt64(photo_id);
photo_small.serializeToStream(stream);
photo_big.serializeToStream(stream);
if ((flags & 2) != 0) {
stream.writeByteArray(stripped_thumb);
}
stream.writeInt32(dc_id);
}
}
public static class TL_userProfilePhoto_layer115 extends TL_userProfilePhoto { public static class TL_userProfilePhoto_layer115 extends TL_userProfilePhoto {
public static int constructor = 0xecd75d8c; public static int constructor = 0xecd75d8c;
@ -34359,6 +34554,7 @@ public class TLRPC {
public int installed_date; public int installed_date;
public ArrayList<PhotoSize> thumbs = new ArrayList<>(); public ArrayList<PhotoSize> thumbs = new ArrayList<>();
public int thumb_dc_id; public int thumb_dc_id;
public int thumb_version;
public static StickerSet TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { public static StickerSet TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
StickerSet result = null; StickerSet result = null;
@ -34376,11 +34572,14 @@ public class TLRPC {
result = new TL_stickerSet_layer121(); result = new TL_stickerSet_layer121();
break; break;
case 0x40e237a8: case 0x40e237a8:
result = new TL_stickerSet(); result = new TL_stickerSet_layer126();
break; break;
case 0xcd303b41: case 0xcd303b41:
result = new TL_stickerSet_layer75(); result = new TL_stickerSet_layer75();
break; break;
case 0xd7df217a:
result = new TL_stickerSet();
break;
} }
if (result == null && exception) { if (result == null && exception) {
throw new RuntimeException(String.format("can't parse magic %x in StickerSet", constructor)); throw new RuntimeException(String.format("can't parse magic %x in StickerSet", constructor));
@ -34412,6 +34611,83 @@ public class TLRPC {
} }
} }
public static class TL_stickerSet extends StickerSet {
public static int constructor = 0xd7df217a;
public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception);
archived = (flags & 2) != 0;
official = (flags & 4) != 0;
masks = (flags & 8) != 0;
animated = (flags & 32) != 0;
if ((flags & 1) != 0) {
installed_date = stream.readInt32(exception);
}
id = stream.readInt64(exception);
access_hash = stream.readInt64(exception);
title = stream.readString(exception);
short_name = stream.readString(exception);
if ((flags & 16) != 0) {
int magic = stream.readInt32(exception);
if (magic != 0x1cb5c415) {
if (exception) {
throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
}
return;
}
int count = stream.readInt32(exception);
for (int a = 0; a < count; a++) {
PhotoSize object = PhotoSize.TLdeserialize(stream, stream.readInt32(exception), exception);
if (object == null) {
return;
}
thumbs.add(object);
}
}
if ((flags & 16) != 0) {
thumb_dc_id = stream.readInt32(exception);
}
if ((flags & 16) != 0) {
thumb_version = stream.readInt32(exception);
}
count = stream.readInt32(exception);
hash = stream.readInt32(exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
flags = archived ? (flags | 2) : (flags &~ 2);
flags = official ? (flags | 4) : (flags &~ 4);
flags = masks ? (flags | 8) : (flags &~ 8);
flags = animated ? (flags | 32) : (flags &~ 32);
stream.writeInt32(flags);
if ((flags & 1) != 0) {
stream.writeInt32(installed_date);
}
stream.writeInt64(id);
stream.writeInt64(access_hash);
stream.writeString(title);
stream.writeString(short_name);
if ((flags & 16) != 0) {
stream.writeInt32(0x1cb5c415);
int count = thumbs.size();
stream.writeInt32(count);
for (int a = 0; a < count; a++) {
thumbs.get(a).serializeToStream(stream);
}
}
if ((flags & 16) != 0) {
stream.writeInt32(thumb_dc_id);
}
if ((flags & 16) != 0) {
stream.writeInt32(thumb_version);
}
stream.writeInt32(count);
stream.writeInt32(hash);
}
}
public static class TL_stickerSet_layer96 extends TL_stickerSet { public static class TL_stickerSet_layer96 extends TL_stickerSet {
public static int constructor = 0x5585a139; public static int constructor = 0x5585a139;
@ -34497,7 +34773,7 @@ public class TLRPC {
} }
} }
public static class TL_stickerSet extends StickerSet { public static class TL_stickerSet_layer126 extends TL_stickerSet {
public static int constructor = 0x40e237a8; public static int constructor = 0x40e237a8;
@ -38310,7 +38586,7 @@ public class TLRPC {
} }
public static class TL_groupCallParticipant extends TLObject { public static class TL_groupCallParticipant extends TLObject {
public static int constructor = 0x19adba89; public static int constructor = 0xb96b25ee;
public int flags; public int flags;
public boolean muted; public boolean muted;
@ -38329,6 +38605,7 @@ public class TLRPC {
public int volume; public int volume;
public String about; public String about;
public long raise_hand_rating; public long raise_hand_rating;
public TL_dataJSON params;
public long lastSpeakTime; //custom; public long lastSpeakTime; //custom;
public float amplitude; //custom; public float amplitude; //custom;
public boolean hasVoice; //custom; public boolean hasVoice; //custom;
@ -38378,6 +38655,9 @@ public class TLRPC {
if ((flags & 8192) != 0) { if ((flags & 8192) != 0) {
raise_hand_rating = stream.readInt64(exception); raise_hand_rating = stream.readInt64(exception);
} }
if ((flags & 64) != 0) {
params = TL_dataJSON.TLdeserialize(stream, stream.readInt32(exception), exception);
}
} }
public void serializeToStream(AbstractSerializedData stream) { public void serializeToStream(AbstractSerializedData stream) {
@ -38407,6 +38687,9 @@ public class TLRPC {
if ((flags & 8192) != 0) { if ((flags & 8192) != 0) {
stream.writeInt64(raise_hand_rating); stream.writeInt64(raise_hand_rating);
} }
if ((flags & 64) != 0) {
params.serializeToStream(stream);
}
} }
} }
@ -45165,10 +45448,13 @@ public class TLRPC {
} }
public static class TL_phone_createGroupCall extends TLObject { public static class TL_phone_createGroupCall extends TLObject {
public static int constructor = 0xbd3dabe0; public static int constructor = 0x48cdc6d8;
public int flags;
public InputPeer peer; public InputPeer peer;
public int random_id; public int random_id;
public String title;
public int schedule_date;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Updates.TLdeserialize(stream, constructor, exception); return Updates.TLdeserialize(stream, constructor, exception);
@ -45176,8 +45462,15 @@ public class TLRPC {
public void serializeToStream(AbstractSerializedData stream) { public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor); stream.writeInt32(constructor);
stream.writeInt32(flags);
peer.serializeToStream(stream); peer.serializeToStream(stream);
stream.writeInt32(random_id); stream.writeInt32(random_id);
if ((flags & 1) != 0) {
stream.writeString(title);
}
if ((flags & 2) != 0) {
stream.writeInt32(schedule_date);
}
} }
} }
@ -45453,10 +45746,62 @@ public class TLRPC {
} }
} }
public static class TL_payments_getPaymentForm extends TLObject { public static class TL_phone_toggleGroupCallStartSubscription extends TLObject {
public static int constructor = 0x99f09745; public static int constructor = 0x219c34e6;
public TL_inputGroupCall call;
public boolean subscribed;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Updates.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
call.serializeToStream(stream);
stream.writeBool(subscribed);
}
}
public static class TL_phone_startScheduledGroupCall extends TLObject {
public static int constructor = 0x5680e342;
public TL_inputGroupCall call;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Updates.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
call.serializeToStream(stream);
}
}
public static class TL_phone_saveDefaultGroupCallJoinAs extends TLObject {
public static int constructor = 0x575e1f8c;
public InputPeer peer;
public InputPeer join_as;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Bool.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
peer.serializeToStream(stream);
join_as.serializeToStream(stream);
}
}
public static class TL_payments_getPaymentForm extends TLObject {
public static int constructor = 0x8a333c8d;
public int flags;
public InputPeer peer;
public int msg_id; public int msg_id;
public TL_dataJSON theme_params;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return TL_payments_paymentForm.TLdeserialize(stream, constructor, exception); return TL_payments_paymentForm.TLdeserialize(stream, constructor, exception);
@ -45464,13 +45809,19 @@ public class TLRPC {
public void serializeToStream(AbstractSerializedData stream) { public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor); stream.writeInt32(constructor);
stream.writeInt32(flags);
peer.serializeToStream(stream);
stream.writeInt32(msg_id); stream.writeInt32(msg_id);
if ((flags & 1) != 0) {
theme_params.serializeToStream(stream);
}
} }
} }
public static class TL_payments_getPaymentReceipt extends TLObject { public static class TL_payments_getPaymentReceipt extends TLObject {
public static int constructor = 0xa092a980; public static int constructor = 0x2478d1cc;
public InputPeer peer;
public int msg_id; public int msg_id;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
@ -45479,10 +45830,69 @@ public class TLRPC {
public void serializeToStream(AbstractSerializedData stream) { public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor); stream.writeInt32(constructor);
peer.serializeToStream(stream);
stream.writeInt32(msg_id); stream.writeInt32(msg_id);
} }
} }
public static class TL_payments_validateRequestedInfo extends TLObject {
public static int constructor = 0xdb103170;
public int flags;
public boolean save;
public InputPeer peer;
public int msg_id;
public TL_paymentRequestedInfo info;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return TL_payments_validatedRequestedInfo.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
flags = save ? (flags | 1) : (flags &~ 1);
stream.writeInt32(flags);
peer.serializeToStream(stream);
stream.writeInt32(msg_id);
info.serializeToStream(stream);
}
}
public static class TL_payments_sendPaymentForm extends TLObject {
public static int constructor = 0x30c3bc9d;
public int flags;
public long form_id;
public InputPeer peer;
public int msg_id;
public String requested_info_id;
public String shipping_option_id;
public InputPaymentCredentials credentials;
public long tip_amount;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return payments_PaymentResult.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(flags);
stream.writeInt64(form_id);
peer.serializeToStream(stream);
stream.writeInt32(msg_id);
if ((flags & 1) != 0) {
stream.writeString(requested_info_id);
}
if ((flags & 2) != 0) {
stream.writeString(shipping_option_id);
}
credentials.serializeToStream(stream);
if ((flags & 4) != 0) {
stream.writeInt64(tip_amount);
}
}
}
public static class TL_help_supportName extends TLObject { public static class TL_help_supportName extends TLObject {
public static int constructor = 0x8c05f1c9; public static int constructor = 0x8c05f1c9;
@ -45573,54 +45983,6 @@ public class TLRPC {
} }
} }
public static class TL_payments_validateRequestedInfo extends TLObject {
public static int constructor = 0x770a8e74;
public int flags;
public boolean save;
public int msg_id;
public TL_paymentRequestedInfo info;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return TL_payments_validatedRequestedInfo.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
flags = save ? (flags | 1) : (flags &~ 1);
stream.writeInt32(flags);
stream.writeInt32(msg_id);
info.serializeToStream(stream);
}
}
public static class TL_payments_sendPaymentForm extends TLObject {
public static int constructor = 0x2b8879b3;
public int flags;
public int msg_id;
public String requested_info_id;
public String shipping_option_id;
public InputPaymentCredentials credentials;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return payments_PaymentResult.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(flags);
stream.writeInt32(msg_id);
if ((flags & 1) != 0) {
stream.writeString(requested_info_id);
}
if ((flags & 2) != 0) {
stream.writeString(shipping_option_id);
}
credentials.serializeToStream(stream);
}
}
public static class TL_payments_getSavedInfo extends TLObject { public static class TL_payments_getSavedInfo extends TLObject {
public static int constructor = 0x227d824b; public static int constructor = 0x227d824b;

View File

@ -353,6 +353,11 @@ public class ActionBarLayout extends FrameLayout {
public void setInnerTranslationX(float value) { public void setInnerTranslationX(float value) {
innerTranslationX = value; innerTranslationX = value;
invalidate(); invalidate();
if (fragmentsStack.size() >= 2) {
BaseFragment prevFragment = fragmentsStack.get(fragmentsStack.size() - 2);
prevFragment.onSlideProgress(false, value / containerView.getMeasuredWidth());
}
} }
@Keep @Keep
@ -528,9 +533,11 @@ public class ActionBarLayout extends FrameLayout {
return; return;
} }
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1); BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
lastFragment.prepareFragmentToSlide(true, false);
lastFragment.onPause(); lastFragment.onPause();
lastFragment.onFragmentDestroy(); lastFragment.onFragmentDestroy();
lastFragment.setParentLayout(null); lastFragment.setParentLayout(null);
fragmentsStack.remove(fragmentsStack.size() - 1); fragmentsStack.remove(fragmentsStack.size() - 1);
LayoutContainer temp = containerView; LayoutContainer temp = containerView;
@ -542,11 +549,16 @@ public class ActionBarLayout extends FrameLayout {
currentActionBar = lastFragment.actionBar; currentActionBar = lastFragment.actionBar;
lastFragment.onResume(); lastFragment.onResume();
lastFragment.onBecomeFullyVisible(); lastFragment.onBecomeFullyVisible();
lastFragment.prepareFragmentToSlide(false, false);
layoutToIgnore = containerView; layoutToIgnore = containerView;
} else { } else {
if (fragmentsStack.size() >= 2) { if (fragmentsStack.size() >= 2) {
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 2); BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
lastFragment.prepareFragmentToSlide(true, false);
lastFragment = fragmentsStack.get(fragmentsStack.size() - 2);
lastFragment.prepareFragmentToSlide(false, false);
lastFragment.onPause(); lastFragment.onPause();
if (lastFragment.fragmentView != null) { if (lastFragment.fragmentView != null) {
ViewGroup parent = (ViewGroup) lastFragment.fragmentView.getParent(); ViewGroup parent = (ViewGroup) lastFragment.fragmentView.getParent();
@ -614,6 +626,10 @@ public class ActionBarLayout extends FrameLayout {
if (themeAnimatorSet != null) { if (themeAnimatorSet != null) {
presentingFragmentDescriptions = lastFragment.getThemeDescriptions(); presentingFragmentDescriptions = lastFragment.getThemeDescriptions();
} }
BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
currentFragment.prepareFragmentToSlide(true, true);
lastFragment.prepareFragmentToSlide(false, true);
} }
public boolean onTouchEvent(MotionEvent ev) { public boolean onTouchEvent(MotionEvent ev) {
@ -685,19 +701,33 @@ public class ActionBarLayout extends FrameLayout {
float distToMove; float distToMove;
if (!backAnimation) { if (!backAnimation) {
distToMove = containerView.getMeasuredWidth() - x; distToMove = containerView.getMeasuredWidth() - x;
int duration = Math.max((int) (200.0f / containerView.getMeasuredWidth() * distToMove), 50);
animatorSet.playTogether( animatorSet.playTogether(
ObjectAnimator.ofFloat(containerView, View.TRANSLATION_X, containerView.getMeasuredWidth()), ObjectAnimator.ofFloat(containerView, View.TRANSLATION_X, containerView.getMeasuredWidth()).setDuration(duration),
ObjectAnimator.ofFloat(this, "innerTranslationX", (float) containerView.getMeasuredWidth()) ObjectAnimator.ofFloat(this, "innerTranslationX", (float) containerView.getMeasuredWidth()).setDuration(duration)
); );
} else { } else {
distToMove = x; distToMove = x;
int duration = Math.max((int) (200.0f / containerView.getMeasuredWidth() * distToMove), 50);
animatorSet.playTogether( animatorSet.playTogether(
ObjectAnimator.ofFloat(containerView, View.TRANSLATION_X, 0), ObjectAnimator.ofFloat(containerView, View.TRANSLATION_X, 0).setDuration(duration),
ObjectAnimator.ofFloat(this, "innerTranslationX", 0.0f) ObjectAnimator.ofFloat(this, "innerTranslationX", 0.0f).setDuration(duration)
); );
} }
animatorSet.setDuration(Math.max((int) (200.0f / containerView.getMeasuredWidth() * distToMove), 50)); Animator customTransition = currentFragment.getCustomSlideTransition(false, backAnimation, distToMove);
if (customTransition != null) {
animatorSet.playTogether(customTransition);
}
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 2);
if (lastFragment != null) {
customTransition = lastFragment.getCustomSlideTransition(false, backAnimation, distToMove);
if (customTransition != null) {
animatorSet.playTogether(customTransition);
}
}
animatorSet.addListener(new AnimatorListenerAdapter() { animatorSet.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animator) { public void onAnimationEnd(Animator animator) {

View File

@ -17,7 +17,6 @@ import android.widget.LinearLayout;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.ui.Adapters.FiltersView; import org.telegram.ui.Adapters.FiltersView;
import org.telegram.ui.Components.RLottieDrawable; import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RLottieImageView;
public class ActionBarMenu extends LinearLayout { public class ActionBarMenu extends LinearLayout {

View File

@ -1685,12 +1685,12 @@ public class ActionBarMenuItem extends FrameLayout {
avatarImageView.setImageDrawable(combinedDrawable); avatarImageView.setImageDrawable(combinedDrawable);
} else { } else {
avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(16)); avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(16));
avatarImageView.getImageReceiver().setImage(ImageLocation.getForUser(user, false), "50_50", thumbDrawable, null, user, 0); avatarImageView.getImageReceiver().setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", thumbDrawable, user, 0);
} }
} else if (data.chat instanceof TLRPC.Chat) { } else if (data.chat instanceof TLRPC.Chat) {
TLRPC.Chat chat = (TLRPC.Chat) data.chat; TLRPC.Chat chat = (TLRPC.Chat) data.chat;
avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(16)); avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(16));
avatarImageView.getImageReceiver().setImage(ImageLocation.getForChat(chat, false), "50_50",thumbDrawable, null, chat, 0); avatarImageView.getImageReceiver().setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", thumbDrawable, chat, 0);
} }
} else if (data.filterType == FiltersView.FILTER_TYPE_ARCHIVE) { } else if (data.filterType == FiltersView.FILTER_TYPE_ARCHIVE) {
CombinedDrawable combinedDrawable = Theme.createCircleDrawableWithIcon(AndroidUtilities.dp(32), R.drawable.chats_archive); CombinedDrawable combinedDrawable = Theme.createCircleDrawableWithIcon(AndroidUtilities.dp(32), R.drawable.chats_archive);

View File

@ -68,6 +68,8 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
private AnimatorSet[] shadowAnimation = new AnimatorSet[2]; private AnimatorSet[] shadowAnimation = new AnimatorSet[2];
private int customViewOffset = 20; private int customViewOffset = 20;
private String dialogButtonColorKey = Theme.key_dialogButton;
private OnCancelListener onCancelListener; private OnCancelListener onCancelListener;
private AlertDialog cancelDialog; private AlertDialog cancelDialog;
@ -728,13 +730,13 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
textView.setMinWidth(AndroidUtilities.dp(64)); textView.setMinWidth(AndroidUtilities.dp(64));
textView.setTag(Dialog.BUTTON_POSITIVE); textView.setTag(Dialog.BUTTON_POSITIVE);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setTextColor(getThemeColor(Theme.key_dialogButton)); textView.setTextColor(getThemeColor(dialogButtonColorKey));
textView.setGravity(Gravity.CENTER); textView.setGravity(Gravity.CENTER);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
// textView.setLines(1); // textView.setLines(1);
// textView.setSingleLine(true); //TODO // textView.setSingleLine(true); //TODO
textView.setText(positiveButtonText.toString().toUpperCase()); textView.setText(positiveButtonText.toString().toUpperCase());
textView.setBackgroundDrawable(Theme.getRoundRectSelectorDrawable(getThemeColor(Theme.key_dialogButton))); textView.setBackgroundDrawable(Theme.getRoundRectSelectorDrawable(getThemeColor(dialogButtonColorKey)));
textView.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), 0); textView.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), 0);
if (verticalButtons) { if (verticalButtons) {
buttonsLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36, LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT)); buttonsLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36, LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT));
@ -768,13 +770,13 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
textView.setMinWidth(AndroidUtilities.dp(64)); textView.setMinWidth(AndroidUtilities.dp(64));
textView.setTag(Dialog.BUTTON_NEGATIVE); textView.setTag(Dialog.BUTTON_NEGATIVE);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setTextColor(getThemeColor(Theme.key_dialogButton)); textView.setTextColor(getThemeColor(dialogButtonColorKey));
textView.setGravity(Gravity.CENTER); textView.setGravity(Gravity.CENTER);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setEllipsize(TextUtils.TruncateAt.END); textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setSingleLine(true); textView.setSingleLine(true);
textView.setText(negativeButtonText.toString().toUpperCase()); textView.setText(negativeButtonText.toString().toUpperCase());
textView.setBackgroundDrawable(Theme.getRoundRectSelectorDrawable(getThemeColor(Theme.key_dialogButton))); textView.setBackgroundDrawable(Theme.getRoundRectSelectorDrawable(getThemeColor(dialogButtonColorKey)));
textView.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), 0); textView.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), 0);
if (verticalButtons) { if (verticalButtons) {
buttonsLayout.addView(textView, 0, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36, LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT)); buttonsLayout.addView(textView, 0, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36, LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT));
@ -808,13 +810,13 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
textView.setMinWidth(AndroidUtilities.dp(64)); textView.setMinWidth(AndroidUtilities.dp(64));
textView.setTag(Dialog.BUTTON_NEUTRAL); textView.setTag(Dialog.BUTTON_NEUTRAL);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setTextColor(getThemeColor(Theme.key_dialogButton)); textView.setTextColor(getThemeColor(dialogButtonColorKey));
textView.setGravity(Gravity.CENTER); textView.setGravity(Gravity.CENTER);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setEllipsize(TextUtils.TruncateAt.END); textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setSingleLine(true); textView.setSingleLine(true);
textView.setText(neutralButtonText.toString().toUpperCase()); textView.setText(neutralButtonText.toString().toUpperCase());
textView.setBackgroundDrawable(Theme.getRoundRectSelectorDrawable(getThemeColor(Theme.key_dialogButton))); textView.setBackgroundDrawable(Theme.getRoundRectSelectorDrawable(getThemeColor(dialogButtonColorKey)));
textView.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), 0); textView.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), 0);
if (verticalButtons) { if (verticalButtons) {
buttonsLayout.addView(textView, 1, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36, LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT)); buttonsLayout.addView(textView, 1, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36, LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT));
@ -1015,6 +1017,9 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
@Override @Override
public void dismiss() { public void dismiss() {
if (onDismissListener != null) {
onDismissListener.onDismiss(this);
}
if (cancelDialog != null) { if (cancelDialog != null) {
cancelDialog.dismiss(); cancelDialog.dismiss();
} }
@ -1176,8 +1181,8 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
private AlertDialog alertDialog; private AlertDialog alertDialog;
protected Builder(AlertDialog alert){ protected Builder(AlertDialog alert) {
alertDialog=alert; alertDialog = alert;
} }
public Builder(Context context) { public Builder(Context context) {
@ -1241,6 +1246,11 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
return this; return this;
} }
public Builder setDialogButtonColorKey(String key) {
alertDialog.dialogButtonColorKey = key;
return this;
}
public Builder setTopAnimation(int resId, int backgroundColor) { public Builder setTopAnimation(int resId, int backgroundColor) {
alertDialog.topAnimationId = resId; alertDialog.topAnimationId = resId;
alertDialog.topBackgroundColor = backgroundColor; alertDialog.topBackgroundColor = backgroundColor;
@ -1329,5 +1339,10 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
public void setButtonsVertical(boolean vertical) { public void setButtonsVertical(boolean vertical) {
alertDialog.verticalButtons = vertical; alertDialog.verticalButtons = vertical;
} }
public Builder setOnPreDismissListener(OnDismissListener onDismissListener) {
alertDialog.onDismissListener = onDismissListener;
return this;
}
} }
} }

View File

@ -8,6 +8,7 @@
package org.telegram.ui.ActionBar; package org.telegram.ui.ActionBar;
import android.animation.Animator;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
@ -46,7 +47,7 @@ import org.telegram.ui.Components.LayoutHelper;
import java.util.ArrayList; import java.util.ArrayList;
public class BaseFragment { public abstract class BaseFragment {
private boolean isFinished; private boolean isFinished;
private boolean finishing; private boolean finishing;
@ -327,6 +328,10 @@ public class BaseFragment {
} }
public boolean isLastFragment() {
return parentLayout != null && !parentLayout.fragmentsStack.isEmpty() && parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 1) == this;
}
public ActionBarLayout getParentLayout() { public ActionBarLayout getParentLayout() {
return parentLayout; return parentLayout;
} }
@ -411,6 +416,10 @@ public class BaseFragment {
} }
} }
protected void onSlideProgress(boolean isOpen, float progress) {
}
protected void onTransitionAnimationProgress(boolean isOpen, float progress) { protected void onTransitionAnimationProgress(boolean isOpen, float progress) {
} }
@ -597,4 +606,16 @@ public class BaseFragment {
public void saveKeyboardPositionBeforeTransition() { public void saveKeyboardPositionBeforeTransition() {
} }
protected Animator getCustomSlideTransition(boolean topFragment, boolean backAnimation, float distanceToMove) {
return null;
}
protected void prepareFragmentToSlide(boolean topFragment, boolean beginSlide) {
}
public void setProgressToDrawerOpened(float v) {
}
} }

View File

@ -58,6 +58,7 @@ import org.telegram.ui.Components.AnimationProperties;
import org.telegram.ui.Components.Bulletin; import org.telegram.ui.Components.Bulletin;
import org.telegram.ui.Components.CubicBezierInterpolator; import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.LaunchActivity;
import java.util.ArrayList; import java.util.ArrayList;
@ -107,6 +108,8 @@ public class BottomSheet extends Dialog {
private boolean allowCustomAnimation = true; private boolean allowCustomAnimation = true;
private boolean showWithoutAnimation; private boolean showWithoutAnimation;
protected int statusBarHeight = AndroidUtilities.statusBarHeight;
protected boolean calcMandatoryInsets; protected boolean calcMandatoryInsets;
private int touchSlop; private int touchSlop;
@ -766,6 +769,10 @@ public class BottomSheet extends Dialog {
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
container.setFitsSystemWindows(true); container.setFitsSystemWindows(true);
container.setOnApplyWindowInsetsListener((v, insets) -> { container.setOnApplyWindowInsetsListener((v, insets) -> {
int newTopInset = insets.getSystemWindowInsetTop();
if ((newTopInset != 0 || AndroidUtilities.isInMultiwindow) && statusBarHeight != 0 && statusBarHeight != newTopInset) {
statusBarHeight = newTopInset;
}
lastInsets = insets; lastInsets = insets;
v.requestLayout(); v.requestLayout();
if (Build.VERSION.SDK_INT >= 30) { if (Build.VERSION.SDK_INT >= 30) {

View File

@ -193,6 +193,14 @@ public class DrawerLayoutContainer extends FrameLayout {
if (drawerLayout.getVisibility() != newVisibility) { if (drawerLayout.getVisibility() != newVisibility) {
drawerLayout.setVisibility(newVisibility); drawerLayout.setVisibility(newVisibility);
} }
BaseFragment currentFragment = parentActionBarLayout.fragmentsStack.get(0);
if (drawerPosition == drawerLayout.getMeasuredWidth()) {
currentFragment.setProgressToDrawerOpened(1f);
} else if (drawerPosition == 0){
currentFragment.setProgressToDrawerOpened(0);
} else {
currentFragment.setProgressToDrawerOpened(drawerPosition / drawerLayout.getMeasuredWidth());
}
setScrimOpacity(drawerPosition / (float) drawerLayout.getMeasuredWidth()); setScrimOpacity(drawerPosition / (float) drawerLayout.getMeasuredWidth());
} }

View File

@ -27,6 +27,8 @@ import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo;
import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.ui.Components.EmptyStubSpan; import org.telegram.ui.Components.EmptyStubSpan;
@ -79,7 +81,7 @@ public class SimpleTextView extends View implements Drawable.Callback {
private static final int SCROLL_SLOWDOWN_PX = 100; private static final int SCROLL_SLOWDOWN_PX = 100;
private int fullLayoutAdditionalWidth; private int fullLayoutAdditionalWidth;
private int fullLayoutLeftOffset; private int fullLayoutLeftOffset;
private boolean crosfadeFullLayout; private float fullLayoutLeftCharactersOffset;
public SimpleTextView(Context context) { public SimpleTextView(Context context) {
super(context); super(context);
@ -186,19 +188,15 @@ public class SimpleTextView extends View implements Drawable.Callback {
} }
if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.CENTER_HORIZONTAL) { if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.CENTER_HORIZONTAL) {
offsetX = (width - textWidth) / 2; offsetX = (width - textWidth) / 2 - (int) layout.getLineLeft(0);
} else if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.LEFT) { } else if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.LEFT) {
if (crosfadeFullLayout) { if (firstLineLayout != null) {
offsetX = 0;
} else if (firstLineLayout != null) {
offsetX = -(int) firstLineLayout.getLineLeft(0); offsetX = -(int) firstLineLayout.getLineLeft(0);
} else { } else {
offsetX = -(int) layout.getLineLeft(0); offsetX = -(int) layout.getLineLeft(0);
} }
} else if (layout.getLineLeft(0) == 0) { } else if (layout.getLineLeft(0) == 0) {
if (crosfadeFullLayout) { if (firstLineLayout != null) {
offsetX = 0;
} else if (firstLineLayout != null) {
offsetX = (int) (width - firstLineLayout.getLineWidth(0)); offsetX = (int) (width - firstLineLayout.getLineWidth(0));
} else { } else {
offsetX = width - textWidth; offsetX = width - textWidth;
@ -208,6 +206,10 @@ public class SimpleTextView extends View implements Drawable.Callback {
} }
offsetX += getPaddingLeft(); offsetX += getPaddingLeft();
textDoesNotFit = textWidth > width; textDoesNotFit = textWidth > width;
if (fullLayout != null && fullLayoutAdditionalWidth > 0) {
fullLayoutLeftCharactersOffset = fullLayout.getPrimaryHorizontal(0) - firstLineLayout.getPrimaryHorizontal(0);
}
} }
} }
@ -223,19 +225,12 @@ public class SimpleTextView extends View implements Drawable.Callback {
width -= dw; width -= dw;
width -= drawablePadding; width -= drawablePadding;
} }
crosfadeFullLayout = false;
if (buildFullLayout) { if (buildFullLayout) {
CharSequence string = TextUtils.ellipsize(text, textPaint, width, TextUtils.TruncateAt.END); CharSequence string = TextUtils.ellipsize(text, textPaint, width, TextUtils.TruncateAt.END);
if (!string.equals(text)) { if (!string.equals(text)) {
fullLayout = StaticLayoutEx.createStaticLayout(text, 0, text.length(), textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, width, 3, false); fullLayout = StaticLayoutEx.createStaticLayout(text, 0, text.length(), textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, width, 3, false);
if (fullLayout != null) { if (fullLayout != null) {
if (LocaleController.isRTL || fullLayout.isRtlCharAt(0) && fullLayoutAdditionalWidth != 0) {
layout = StaticLayoutEx.createStaticLayout(text, 0, text.length(), textPaint, width + AndroidUtilities.dp(8), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, width, maxLines, false);
fullLayout = StaticLayoutEx.createStaticLayout(text, 0, text.length(), textPaint, width + fullLayoutAdditionalWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, width + fullLayoutAdditionalWidth, 3, false);
partLayout = null;
firstLineLayout = null;
crosfadeFullLayout = true;
} else {
int end = fullLayout.getLineEnd(0); int end = fullLayout.getLineEnd(0);
int start = fullLayout.getLineStart(1); int start = fullLayout.getLineStart(1);
CharSequence substr = text.subSequence(0, end); CharSequence substr = text.subSequence(0, end);
@ -253,8 +248,7 @@ public class SimpleTextView extends View implements Drawable.Callback {
part = "\u200F" + part; part = "\u200F" + part;
} }
partLayout = new StaticLayout(part, 0, part.length(), textPaint, scrollNonFitText ? AndroidUtilities.dp(2000) : width + AndroidUtilities.dp(8), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); partLayout = new StaticLayout(part, 0, part.length(), textPaint, scrollNonFitText ? AndroidUtilities.dp(2000) : width + AndroidUtilities.dp(8), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
fullLayout = StaticLayoutEx.createStaticLayout(full, 0, full.length(), textPaint, width + fullLayoutAdditionalWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, width + fullLayoutAdditionalWidth, 3, false); fullLayout = StaticLayoutEx.createStaticLayout(full, 0, full.length(), textPaint, width + AndroidUtilities.dp(8) + fullLayoutAdditionalWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, width + fullLayoutAdditionalWidth, 3, false);
}
} }
} else { } else {
layout = new StaticLayout(string, 0, string.length(), textPaint, scrollNonFitText ? AndroidUtilities.dp(2000) : width + AndroidUtilities.dp(8), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); layout = new StaticLayout(string, 0, string.length(), textPaint, scrollNonFitText ? AndroidUtilities.dp(2000) : width + AndroidUtilities.dp(8), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
@ -579,7 +573,7 @@ public class SimpleTextView extends View implements Drawable.Callback {
} else { } else {
canvas.translate(layout.getLineWidth(0) - (partLayout.getText().length() == 1 ? AndroidUtilities.dp(4) : 0), 0); canvas.translate(layout.getLineWidth(0) - (partLayout.getText().length() == 1 ? AndroidUtilities.dp(4) : 0), 0);
} }
canvas.translate(-fullLayoutLeftOffset * fullAlpha, 0); canvas.translate(-fullLayoutLeftOffset * fullAlpha + fullLayoutLeftCharactersOffset * fullAlpha, 0);
partLayout.draw(canvas); partLayout.draw(canvas);
canvas.restore(); canvas.restore();
textPaint.setAlpha(prevAlpha); textPaint.setAlpha(prevAlpha);
@ -588,10 +582,7 @@ public class SimpleTextView extends View implements Drawable.Callback {
int prevAlpha = textPaint.getAlpha(); int prevAlpha = textPaint.getAlpha();
textPaint.setAlpha((int) (255 * fullAlpha)); textPaint.setAlpha((int) (255 * fullAlpha));
if (layout.getLineLeft(0) != 0) { canvas.translate(-fullLayoutLeftOffset * fullAlpha + fullLayoutLeftCharactersOffset * fullAlpha - fullLayoutLeftCharactersOffset, 0);
canvas.translate(-offsetX, 0);
}
canvas.translate(-fullLayoutLeftOffset * fullAlpha, 0);
fullLayout.draw(canvas); fullLayout.draw(canvas);
textPaint.setAlpha(prevAlpha); textPaint.setAlpha(prevAlpha);
} }
@ -625,17 +616,9 @@ public class SimpleTextView extends View implements Drawable.Callback {
} }
private void drawLayout(Canvas canvas) { private void drawLayout(Canvas canvas) {
if (crosfadeFullLayout && fullAlpha > 0) { if (fullAlpha > 0 && fullLayoutLeftOffset != 0) {
int prevAlpha = textPaint.getAlpha();
textPaint.setAlpha((int) (255 * (1f - fullAlpha)));
canvas.save(); canvas.save();
canvas.translate(-fullLayoutLeftOffset * fullAlpha, 0); canvas.translate(-fullLayoutLeftOffset * fullAlpha + fullLayoutLeftCharactersOffset * fullAlpha, 0);
layout.draw(canvas);
textPaint.setAlpha(prevAlpha);
canvas.restore();
} else if (fullAlpha > 0 && fullLayoutLeftOffset != 0) {
canvas.save();
canvas.translate(-fullLayoutLeftOffset * fullAlpha, 0);
layout.draw(canvas); layout.draw(canvas);
canvas.restore(); canvas.restore();
} else { } else {
@ -703,6 +686,9 @@ public class SimpleTextView extends View implements Drawable.Callback {
this.fullLayoutLeftOffset = fullLayoutLeftOffset; this.fullLayoutLeftOffset = fullLayoutLeftOffset;
createLayout(getMeasuredWidth()); createLayout(getMeasuredWidth());
} }
}
public int getTextColor() {
return textPaint.getColor();
} }
} }

View File

@ -2172,6 +2172,7 @@ public class Theme {
public static Drawable chat_replyIconDrawable; public static Drawable chat_replyIconDrawable;
public static Drawable chat_goIconDrawable; public static Drawable chat_goIconDrawable;
public static Drawable chat_botLinkDrawalbe; public static Drawable chat_botLinkDrawalbe;
public static Drawable chat_botCardDrawalbe;
public static Drawable chat_botInlineDrawable; public static Drawable chat_botInlineDrawable;
public static Drawable chat_systemDrawable; public static Drawable chat_systemDrawable;
public static Drawable chat_commentDrawable; public static Drawable chat_commentDrawable;
@ -7202,6 +7203,7 @@ public class Theme {
chat_botLinkDrawalbe = resources.getDrawable(R.drawable.bot_link); chat_botLinkDrawalbe = resources.getDrawable(R.drawable.bot_link);
chat_botInlineDrawable = resources.getDrawable(R.drawable.bot_lines); chat_botInlineDrawable = resources.getDrawable(R.drawable.bot_lines);
chat_botCardDrawalbe = resources.getDrawable(R.drawable.bot_card);
chat_commentDrawable = resources.getDrawable(R.drawable.msg_msgbubble); chat_commentDrawable = resources.getDrawable(R.drawable.msg_msgbubble);
chat_commentStickerDrawable = resources.getDrawable(R.drawable.msg_msgbubble2); chat_commentStickerDrawable = resources.getDrawable(R.drawable.msg_msgbubble2);

View File

@ -204,8 +204,6 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter {
if (folderId == 0 && onlineContacts != null) { if (folderId == 0 && onlineContacts != null) {
if (!hasContacts) { if (!hasContacts) {
onlineContacts = null; onlineContacts = null;
} else {
MessagesController.getInstance(currentAccount).preloadGreetingsSticker();
} }
} }
if (folderId == 1 && showArchiveHint) { if (folderId == 1 && showArchiveHint) {
@ -508,12 +506,6 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter {
} }
cell.setChecked(selectedDialogs.contains(dialog.id), false); cell.setChecked(selectedDialogs.contains(dialog.id), false);
cell.setDialog(dialog, dialogsType, folderId); cell.setDialog(dialog, dialogsType, folderId);
if ((int) dialog.id > 0) {
MessageObject message = MessagesController.getInstance(currentAccount).dialogMessage.get(dialog.id);
if (MessageObject.isSystemSignUp(message)) {
MessagesController.getInstance(currentAccount).preloadGreetingsSticker();
}
}
if (preloader != null && i < 10) { if (preloader != null && i < 10) {
preloader.add(dialog.id); preloader.add(dialog.id);
} }

View File

@ -304,7 +304,7 @@ public class DrawerLayoutAdapter extends RecyclerListView.SelectionAdapter {
items.add(new Item(8, LocaleController.getString("Settings", R.string.Settings), settingsIcon)); items.add(new Item(8, LocaleController.getString("Settings", R.string.Settings), settingsIcon));
items.add(null); // divider items.add(null); // divider
items.add(new Item(7, LocaleController.getString("InviteFriends", R.string.InviteFriends), inviteIcon)); items.add(new Item(7, LocaleController.getString("InviteFriends", R.string.InviteFriends), inviteIcon));
items.add(new Item(9, LocaleController.getString("TelegramFAQ", R.string.TelegramFAQ), helpIcon)); items.add(new Item(13, LocaleController.getString("TelegramFeatures", R.string.TelegramFeatures), helpIcon));
} }
public int getId(int position) { public int getId(int position) {

View File

@ -40,7 +40,6 @@ import org.telegram.ui.Components.CombinedDrawable;
import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.RecyclerListView; import org.telegram.ui.Components.RecyclerListView;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -49,7 +48,6 @@ import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException; import java.time.format.DateTimeParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -730,12 +728,12 @@ public class FiltersView extends RecyclerListView {
avatarImageView.setImageDrawable(combinedDrawable); avatarImageView.setImageDrawable(combinedDrawable);
} else { } else {
avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(16)); avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(16));
avatarImageView.getImageReceiver().setImage(ImageLocation.getForUser(user, false), "50_50", thumbDrawable, null, user, 0); avatarImageView.getImageReceiver().setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", thumbDrawable, user, 0);
} }
} else if (data.chat instanceof TLRPC.Chat) { } else if (data.chat instanceof TLRPC.Chat) {
TLRPC.Chat chat = (TLRPC.Chat) data.chat; TLRPC.Chat chat = (TLRPC.Chat) data.chat;
avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(16)); avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(16));
avatarImageView.getImageReceiver().setImage(ImageLocation.getForChat(chat, false), "50_50", thumbDrawable, null, chat, 0); avatarImageView.getImageReceiver().setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", thumbDrawable, chat, 0);
} }
} else { } else {
avatarImageView.setImageDrawable(thumbDrawable); avatarImageView.setImageDrawable(thumbDrawable);

View File

@ -290,6 +290,8 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
TextSelectionHelper.ArticleTextSelectionHelper textSelectionHelper; TextSelectionHelper.ArticleTextSelectionHelper textSelectionHelper;
TextSelectionHelper.ArticleTextSelectionHelper textSelectionHelperBottomSheet; TextSelectionHelper.ArticleTextSelectionHelper textSelectionHelperBottomSheet;
PinchToZoomHelper pinchToZoomHelper;
private int allowAnimationIndex = -1; private int allowAnimationIndex = -1;
private final String BOTTOM_SHEET_VIEW_TAG = "bottomSheet"; private final String BOTTOM_SHEET_VIEW_TAG = "bottomSheet";
@ -707,6 +709,10 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
@Override @Override
public boolean dispatchTouchEvent(MotionEvent ev) { public boolean dispatchTouchEvent(MotionEvent ev) {
if (pinchToZoomHelper.isInOverlayMode()) {
ev.offsetLocation(-containerView.getX(), -containerView.getY());
return pinchToZoomHelper.onTouchEvent(ev);
}
TextSelectionHelper.TextSelectionOverlay selectionOverlay = textSelectionHelper.getOverlayView(getContext()); TextSelectionHelper.TextSelectionOverlay selectionOverlay = textSelectionHelper.getOverlayView(getContext());
MotionEvent textSelectionEv = MotionEvent.obtain(ev); MotionEvent textSelectionEv = MotionEvent.obtain(ev);
textSelectionEv.offsetLocation(-containerView.getX(), -containerView.getY()); textSelectionEv.offsetLocation(-containerView.getX(), -containerView.getY());
@ -3657,6 +3663,22 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
}); });
containerView.addView(textSelectionHelper.getOverlayView(activity)); containerView.addView(textSelectionHelper.getOverlayView(activity));
pinchToZoomHelper = new PinchToZoomHelper(containerView);
pinchToZoomHelper.setClipBoundsListener(new PinchToZoomHelper.ClipBoundsListener() {
@Override
public void getClipTopBottom(float[] topBottom) {
topBottom[0] = currentHeaderHeight;
topBottom[1] = listView[0].getMeasuredHeight();
}
});
pinchToZoomHelper.setCallback(new PinchToZoomHelper.Callback() {
@Override
public void onZoomStarted(MessageObject messageObject) {
if (listView[0] != null) {
listView[0].cancelClickRunnables(true);
}
}
});
updatePaintColors(); updatePaintColors();
} }
@ -5952,6 +5974,9 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if (pinchToZoomHelper.checkPinchToZoom(event, this, imageView, null)) {
return true;
}
float x = event.getX(); float x = event.getX();
float y = event.getY(); float y = event.getY();
if (channelCell.getVisibility() == VISIBLE && y > channelCell.getTranslationY() && y < channelCell.getTranslationY() + AndroidUtilities.dp(39)) { if (channelCell.getVisibility() == VISIBLE && y > channelCell.getTranslationY() && y < channelCell.getTranslationY() + AndroidUtilities.dp(39)) {
@ -6118,10 +6143,12 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
if (!imageView.hasBitmapImage() || imageView.getCurrentAlpha() != 1.0f) { if (!imageView.hasBitmapImage() || imageView.getCurrentAlpha() != 1.0f) {
canvas.drawRect(imageView.getDrawRegion(), photoBackgroundPaint); canvas.drawRect(imageView.getDrawRegion(), photoBackgroundPaint);
} }
if (!pinchToZoomHelper.isInOverlayModeFor(this)) {
imageView.draw(canvas); imageView.draw(canvas);
if (imageView.getVisible()) { if (imageView.getVisible()) {
radialProgress.draw(canvas); radialProgress.draw(canvas);
} }
}
int count = 0; int count = 0;
if (captionLayout != null) { if (captionLayout != null) {
canvas.save(); canvas.save();
@ -9831,6 +9858,9 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if (pinchToZoomHelper.checkPinchToZoom(event, this, imageView, null)) {
return true;
}
float x = event.getX(); float x = event.getX();
float y = event.getY(); float y = event.getY();
if (channelCell.getVisibility() == VISIBLE && y > channelCell.getTranslationY() && y < channelCell.getTranslationY() + AndroidUtilities.dp(39)) { if (channelCell.getVisibility() == VISIBLE && y > channelCell.getTranslationY() && y < channelCell.getTranslationY() + AndroidUtilities.dp(39)) {
@ -9992,10 +10022,12 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
if (!imageView.hasBitmapImage() || imageView.getCurrentAlpha() != 1.0f) { if (!imageView.hasBitmapImage() || imageView.getCurrentAlpha() != 1.0f) {
canvas.drawRect(imageView.getImageX(), imageView.getImageY(), imageView.getImageX2(), imageView.getImageY2(), photoBackgroundPaint); canvas.drawRect(imageView.getImageX(), imageView.getImageY(), imageView.getImageX2(), imageView.getImageY2(), photoBackgroundPaint);
} }
if (!pinchToZoomHelper.isInOverlayModeFor(this)) {
imageView.draw(canvas); imageView.draw(canvas);
if (imageView.getVisible()) { if (imageView.getVisible()) {
radialProgress.draw(canvas); radialProgress.draw(canvas);
} }
}
if (!TextUtils.isEmpty(currentBlock.url)) { if (!TextUtils.isEmpty(currentBlock.url)) {
int x = getMeasuredWidth() - AndroidUtilities.dp(11 + 24); int x = getMeasuredWidth() - AndroidUtilities.dp(11 + 24);
int y = (int) (imageView.getImageY() + AndroidUtilities.dp(11)); int y = (int) (imageView.getImageY() + AndroidUtilities.dp(11));

View File

@ -163,15 +163,15 @@ public class AvatarPreviewer {
public static class Data { public static class Data {
public static Data of(TLRPC.User user, int classGuid, MenuItem... menuItems) { public static Data of(TLRPC.User user, int classGuid, MenuItem... menuItems) {
final ImageLocation imageLocation = ImageLocation.getForUser(user, true); final ImageLocation imageLocation = ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_BIG);
final ImageLocation thumbImageLocation = ImageLocation.getForUser(user, false); final ImageLocation thumbImageLocation = ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL);
final String thumbFilter = thumbImageLocation != null && thumbImageLocation.photoSize instanceof TLRPC.TL_photoStrippedSize ? "b" : null; final String thumbFilter = thumbImageLocation != null && thumbImageLocation.photoSize instanceof TLRPC.TL_photoStrippedSize ? "b" : null;
return new Data(imageLocation, thumbImageLocation, null, null, thumbFilter, null, null, user, menuItems, new UserInfoLoadTask(user, classGuid)); return new Data(imageLocation, thumbImageLocation, null, null, thumbFilter, null, null, user, menuItems, new UserInfoLoadTask(user, classGuid));
} }
public static Data of(TLRPC.UserFull userFull, MenuItem... menuItems) { public static Data of(TLRPC.UserFull userFull, MenuItem... menuItems) {
final ImageLocation imageLocation = ImageLocation.getForUser(userFull.user, true); final ImageLocation imageLocation = ImageLocation.getForUserOrChat(userFull.user, ImageLocation.TYPE_BIG);
final ImageLocation thumbImageLocation = ImageLocation.getForUser(userFull.user, false); final ImageLocation thumbImageLocation = ImageLocation.getForUserOrChat(userFull.user, ImageLocation.TYPE_SMALL);
final String thumbFilter = thumbImageLocation != null && thumbImageLocation.photoSize instanceof TLRPC.TL_photoStrippedSize ? "b" : null; final String thumbFilter = thumbImageLocation != null && thumbImageLocation.photoSize instanceof TLRPC.TL_photoStrippedSize ? "b" : null;
final ImageLocation videoLocation; final ImageLocation videoLocation;
final String videoFileName; final String videoFileName;
@ -188,15 +188,15 @@ public class AvatarPreviewer {
} }
public static Data of(TLRPC.Chat chat, int classGuid, MenuItem... menuItems) { public static Data of(TLRPC.Chat chat, int classGuid, MenuItem... menuItems) {
final ImageLocation imageLocation = ImageLocation.getForChat(chat, true); final ImageLocation imageLocation = ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_BIG);
final ImageLocation thumbImageLocation = ImageLocation.getForChat(chat, false); final ImageLocation thumbImageLocation = ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL);
final String thumbFilter = thumbImageLocation != null && thumbImageLocation.photoSize instanceof TLRPC.TL_photoStrippedSize ? "b" : null; final String thumbFilter = thumbImageLocation != null && thumbImageLocation.photoSize instanceof TLRPC.TL_photoStrippedSize ? "b" : null;
return new Data(imageLocation, thumbImageLocation, null, null, thumbFilter, null, null, chat, menuItems, new ChatInfoLoadTask(chat, classGuid)); return new Data(imageLocation, thumbImageLocation, null, null, thumbFilter, null, null, chat, menuItems, new ChatInfoLoadTask(chat, classGuid));
} }
public static Data of(TLRPC.Chat chat, TLRPC.ChatFull chatFull, MenuItem... menuItems) { public static Data of(TLRPC.Chat chat, TLRPC.ChatFull chatFull, MenuItem... menuItems) {
final ImageLocation imageLocation = ImageLocation.getForChat(chat, true); final ImageLocation imageLocation = ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_BIG);
final ImageLocation thumbImageLocation = ImageLocation.getForChat(chat, false); final ImageLocation thumbImageLocation = ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL);
final String thumbFilter = thumbImageLocation != null && thumbImageLocation.photoSize instanceof TLRPC.TL_photoStrippedSize ? "b" : null; final String thumbFilter = thumbImageLocation != null && thumbImageLocation.photoSize instanceof TLRPC.TL_photoStrippedSize ? "b" : null;
final ImageLocation videoLocation; final ImageLocation videoLocation;
final String videoFileName; final String videoFileName;

View File

@ -25,6 +25,7 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils;
@ -553,8 +554,8 @@ public class CancelAccountDeletionActivity extends BaseFragment {
PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0); PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
String version = String.format(Locale.US, "%s (%d)", pInfo.versionName, pInfo.versionCode); String version = String.format(Locale.US, "%s (%d)", pInfo.versionName, pInfo.versionCode);
Intent mailer = new Intent(Intent.ACTION_SEND); Intent mailer = new Intent(Intent.ACTION_SENDTO);
mailer.setType("message/rfc822"); mailer.setData(Uri.parse("mailto:"));
mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"sms@stel.com"}); mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"sms@stel.com"});
mailer.putExtra(Intent.EXTRA_SUBJECT, "Android cancel account deletion issue " + version + " " + phone); mailer.putExtra(Intent.EXTRA_SUBJECT, "Android cancel account deletion issue " + version + " " + phone);
mailer.putExtra(Intent.EXTRA_TEXT, "Phone: " + phone + "\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault() + "\nError: " + lastError); mailer.putExtra(Intent.EXTRA_TEXT, "Phone: " + phone + "\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault() + "\nError: " + lastError);

View File

@ -110,12 +110,12 @@ public class AccountSelectCell extends FrameLayout {
TLRPC.User user = (TLRPC.User) object; TLRPC.User user = (TLRPC.User) object;
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
infoTextView.setText(ContactsController.formatName(user.first_name, user.last_name)); infoTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} else { } else {
TLRPC.Chat chat = (TLRPC.Chat) object; TLRPC.Chat chat = (TLRPC.Chat) object;
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
infoTextView.setText(chat.title); infoTextView.setText(chat.title);
imageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); imageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
} }
} }
@ -125,7 +125,7 @@ public class AccountSelectCell extends FrameLayout {
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
textView.setText(ContactsController.formatName(user.first_name, user.last_name)); textView.setText(ContactsController.formatName(user.first_name, user.last_name));
imageView.getImageReceiver().setCurrentAccount(account); imageView.getImageReceiver().setCurrentAccount(account);
imageView.setImage(ImageLocation.getForUser(user,false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user,ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
checkImageView.setVisibility(check && account == UserConfig.selectedAccount ? VISIBLE : INVISIBLE); checkImageView.setVisibility(check && account == UserConfig.selectedAccount ? VISIBLE : INVISIBLE);
} }

View File

@ -81,7 +81,7 @@ public class AdminedChannelCell extends FrameLayout {
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(url + channel.username); SpannableStringBuilder stringBuilder = new SpannableStringBuilder(url + channel.username);
stringBuilder.setSpan(new URLSpanNoUnderline(""), url.length(), stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); stringBuilder.setSpan(new URLSpanNoUnderline(""), url.length(), stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
statusTextView.setText(stringBuilder); statusTextView.setText(stringBuilder);
avatarImageView.setImage(ImageLocation.getForChat(channel, false), "50_50", avatarDrawable, currentChannel); avatarImageView.setImage(ImageLocation.getForUserOrChat(channel, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(channel, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentChannel);
isLast = last; isLast = last;
} }

View File

@ -126,6 +126,7 @@ import org.telegram.ui.Components.URLSpanBrowser;
import org.telegram.ui.Components.URLSpanMono; import org.telegram.ui.Components.URLSpanMono;
import org.telegram.ui.Components.URLSpanNoUnderline; import org.telegram.ui.Components.URLSpanNoUnderline;
import org.telegram.ui.PhotoViewer; import org.telegram.ui.PhotoViewer;
import org.telegram.ui.PinchToZoomHelper;
import org.telegram.ui.SecretMediaViewer; import org.telegram.ui.SecretMediaViewer;
import java.io.File; import java.io.File;
@ -257,6 +258,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
default boolean shouldDrawThreadProgress(ChatMessageCell cell) { default boolean shouldDrawThreadProgress(ChatMessageCell cell) {
return false; return false;
} }
default PinchToZoomHelper getPinchToZoomHelper() {
return null;
}
} }
private final static int DOCUMENT_ATTACH_TYPE_NONE = 0; private final static int DOCUMENT_ATTACH_TYPE_NONE = 0;
@ -775,6 +781,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}; };
private SparseArray<Rect> accessibilityVirtualViewBounds = new SparseArray<>(); private SparseArray<Rect> accessibilityVirtualViewBounds = new SparseArray<>();
private int currentFocusedVirtualView = -1; private int currentFocusedVirtualView = -1;
public boolean drawFromPinchToZoom;
public ChatMessageCell(Context context) { public ChatMessageCell(Context context) {
super(context); super(context);
@ -1930,6 +1937,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
boolean result = checkTextBlockMotionEvent(event); boolean result = checkTextBlockMotionEvent(event);
if (!result) {
result = checkPinchToZoom(event);
}
if (!result) { if (!result) {
result = checkDateMotionEvent(event); result = checkDateMotionEvent(event);
} }
@ -2196,6 +2206,17 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
return result; return result;
} }
private boolean checkPinchToZoom(MotionEvent ev) {
PinchToZoomHelper pinchToZoomHelper = delegate == null ? null : delegate.getPinchToZoomHelper();
if (currentMessageObject == null || !photoImage.hasNotThumb() || pinchToZoomHelper == null || currentMessageObject.isSticker() ||
currentMessageObject.isAnimatedEmoji() || (currentMessageObject.isVideo() && !autoPlayingMedia) ||
currentMessageObject.isRoundVideo() || currentMessageObject.isAnimatedSticker() || (currentMessageObject.isDocument() && !currentMessageObject.isGif()) || currentMessageObject.needDrawBluredPreview()) {
return false;
}
return pinchToZoomHelper.checkPinchToZoom(ev, this, photoImage, currentMessageObject);
}
private boolean checkTextSelection(MotionEvent event) { private boolean checkTextSelection(MotionEvent event) {
TextSelectionHelper.ChatListTextSelectionHelper textSelectionHelper = delegate.getTextSelectionHelper(); TextSelectionHelper.ChatListTextSelectionHelper textSelectionHelper = delegate.getTextSelectionHelper();
if (textSelectionHelper == null) { if (textSelectionHelper == null) {
@ -3144,10 +3165,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} }
if (user != null) { if (user != null) {
commentAvatarDrawables[a].setInfo(user); commentAvatarDrawables[a].setInfo(user);
commentAvatarImages[a].setImage(ImageLocation.getForUser(user, false), "50_50", commentAvatarDrawables[a], null, user, 0); commentAvatarImages[a].setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", commentAvatarDrawables[a], user, 0);
} else if (chat != null) { } else if (chat != null) {
commentAvatarDrawables[a].setInfo(chat); commentAvatarDrawables[a].setInfo(chat);
commentAvatarImages[a].setImage(ImageLocation.getForChat(chat, false), "50_50", commentAvatarDrawables[a], null, chat, 0); commentAvatarImages[a].setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", commentAvatarDrawables[a], chat, 0);
} else { } else {
commentAvatarDrawables[a].setInfo(id, "", ""); commentAvatarDrawables[a].setInfo(id, "", "");
} }
@ -3236,9 +3257,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
hasInvoicePreview = messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice; hasInvoicePreview = messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice;
hasLinkPreview = !messageObject.isRestrictedMessage && messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && messageObject.messageOwner.media.webpage instanceof TLRPC.TL_webPage; hasLinkPreview = !messageObject.isRestrictedMessage && messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && messageObject.messageOwner.media.webpage instanceof TLRPC.TL_webPage;
drawInstantView = hasLinkPreview && messageObject.messageOwner.media.webpage.cached_page != null; drawInstantView = hasLinkPreview && messageObject.messageOwner.media.webpage.cached_page != null;
hasEmbed = hasLinkPreview && !TextUtils.isEmpty(messageObject.messageOwner.media.webpage.embed_url) && !messageObject.isGif();
boolean slideshow = false;
String siteName = hasLinkPreview ? messageObject.messageOwner.media.webpage.site_name : null; String siteName = hasLinkPreview ? messageObject.messageOwner.media.webpage.site_name : null;
hasEmbed = hasLinkPreview && !TextUtils.isEmpty(messageObject.messageOwner.media.webpage.embed_url) && !messageObject.isGif() && !"instangram".equalsIgnoreCase(siteName);
boolean slideshow = false;
String webpageType = hasLinkPreview ? messageObject.messageOwner.media.webpage.type : null; String webpageType = hasLinkPreview ? messageObject.messageOwner.media.webpage.type : null;
TLRPC.Document androidThemeDocument = null; TLRPC.Document androidThemeDocument = null;
TLRPC.TL_themeSettings androidThemeSettings = null; TLRPC.TL_themeSettings androidThemeSettings = null;
@ -3908,8 +3929,21 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
width = height = maxPhotoWidth; width = height = maxPhotoWidth;
} else { } else {
if (hasGamePreview || hasInvoicePreview) { if (hasGamePreview || hasInvoicePreview) {
if (hasInvoicePreview) {
width = 640; width = 640;
height = 360; height = 360;
for (int a = 0, N = webDocument.attributes.size(); a < N; a++) {
TLRPC.DocumentAttribute attribute = webDocument.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeImageSize) {
width = attribute.w;
height = attribute.h;
break;
}
}
} else {
width = 640;
height = 360;
}
float scale = width / (float) (maxPhotoWidth - AndroidUtilities.dp(2)); float scale = width / (float) (maxPhotoWidth - AndroidUtilities.dp(2));
width /= scale; width /= scale;
height /= scale; height /= scale;
@ -4202,7 +4236,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else { } else {
hasName = false; hasName = false;
} }
photoImage.setImage(ImageLocation.getForUser(user, false), "50_50", hasName ? contactAvatarDrawable : Theme.chat_contactDrawable[messageObject.isOutOwner() ? 1 : 0], null, messageObject, 0); photoImage.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", hasName ? contactAvatarDrawable : Theme.chat_contactDrawable[messageObject.isOutOwner() ? 1 : 0], messageObject, 0);
CharSequence phone; CharSequence phone;
if (!TextUtils.isEmpty(messageObject.vCardData)) { if (!TextUtils.isEmpty(messageObject.vCardData)) {
@ -4394,7 +4428,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(id); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(id);
if (user != null) { if (user != null) {
pollAvatarDrawables[a].setInfo(user); pollAvatarDrawables[a].setInfo(user);
pollAvatarImages[a].setImage(ImageLocation.getForUser(user, false), "50_50", pollAvatarDrawables[a], null, user, 0); pollAvatarImages[a].setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", pollAvatarDrawables[a], user, 0);
} else { } else {
pollAvatarDrawables[a].setInfo(id, "", ""); pollAvatarDrawables[a].setInfo(id, "", "");
} }
@ -4728,13 +4762,13 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
updateCurrentUserAndChat(); updateCurrentUserAndChat();
if (currentUser != null) { if (currentUser != null) {
contactAvatarDrawable.setInfo(currentUser); contactAvatarDrawable.setInfo(currentUser);
locationImageReceiver.setImage(ImageLocation.getForUser(currentUser, false), "50_50", contactAvatarDrawable, null, currentUser, 0); locationImageReceiver.setImage(ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_STRIPPED), "50_50", contactAvatarDrawable, currentUser, 0);
} else if (currentChat != null) { } else if (currentChat != null) {
if (currentChat.photo != null) { if (currentChat.photo != null) {
currentPhoto = currentChat.photo.photo_small; currentPhoto = currentChat.photo.photo_small;
} }
contactAvatarDrawable.setInfo(currentChat); contactAvatarDrawable.setInfo(currentChat);
locationImageReceiver.setImage(ImageLocation.getForChat(currentChat, false), "50_50", contactAvatarDrawable, null, currentChat, 0); locationImageReceiver.setImage(ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_STRIPPED), "50_50", contactAvatarDrawable, currentChat, 0);
} else { } else {
locationImageReceiver.setImage(null, null, contactAvatarDrawable, null, null, 0); locationImageReceiver.setImage(null, null, contactAvatarDrawable, null, null, 0);
} }
@ -4809,7 +4843,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else if (currentMapProvider == 2) { } else if (currentMapProvider == 2) {
if (currentWebFile != null) { if (currentWebFile != null) {
ImageLocation lastLocation = lastWebFile == null ? null : ImageLocation.getForWebFile(lastWebFile); ImageLocation lastLocation = lastWebFile == null ? null : ImageLocation.getForWebFile(lastWebFile);
photoImage.setImage(ImageLocation.getForWebFile(currentWebFile), null, lastLocation, null, null, messageObject, 0); photoImage.setImage(ImageLocation.getForWebFile(currentWebFile), null, lastLocation, null, (Drawable) null, messageObject, 0);
} }
} else { } else {
if (currentMapProvider == 3 || currentMapProvider == 4) { if (currentMapProvider == 3 || currentMapProvider == 4) {
@ -7097,8 +7131,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
buttonY = this.buttonY = (int) (photoImage.getImageY() + (photoImage.getImageHeight() - size) / 2.0f); buttonY = this.buttonY = (int) (photoImage.getImageY() + (photoImage.getImageHeight() - size) / 2.0f);
radialProgress.setProgressRect((int) buttonX, (int ) buttonY, (int) buttonX + size, (int) buttonY + size); radialProgress.setProgressRect((int) buttonX, (int ) buttonY, (int) buttonX + size, (int) buttonY + size);
} }
if (delegate == null || delegate.getPinchToZoomHelper() == null || !delegate.getPinchToZoomHelper().isInOverlayModeFor(this)) {
imageDrawn = photoImage.draw(canvas); imageDrawn = photoImage.draw(canvas);
} }
}
linkPreviewY += photoImage.getImageHeight() + AndroidUtilities.dp(6); linkPreviewY += photoImage.getImageHeight() + AndroidUtilities.dp(6);
} }
@ -7180,9 +7216,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
imageDrawn = true; imageDrawn = true;
drawTime = true; drawTime = true;
} else { } else {
if (delegate == null || delegate.getPinchToZoomHelper() == null || !delegate.getPinchToZoomHelper().isInOverlayModeFor(this)) {
imageDrawn = photoImage.draw(canvas); imageDrawn = photoImage.draw(canvas);
} }
} }
}
if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) { if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) {
videoButtonX = (int) (photoImage.getImageX() + AndroidUtilities.dp(8)); videoButtonX = (int) (photoImage.getImageX() + AndroidUtilities.dp(8));
videoButtonY = (int) (photoImage.getImageY() + AndroidUtilities.dp(8)); videoButtonY = (int) (photoImage.getImageY() + AndroidUtilities.dp(8));
@ -7330,7 +7368,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else { } else {
photoImage.setSideClip(0); photoImage.setSideClip(0);
} }
if (delegate == null || delegate.getPinchToZoomHelper() == null || !delegate.getPinchToZoomHelper().isInOverlayModeFor(this)) {
imageDrawn = photoImage.draw(canvas); imageDrawn = photoImage.draw(canvas);
}
boolean drawTimeOld = drawTime; boolean drawTimeOld = drawTime;
drawTime = photoImage.getVisible(); drawTime = photoImage.getVisible();
if (currentPosition != null && drawTimeOld != drawTime) { if (currentPosition != null && drawTimeOld != drawTime) {
@ -7796,11 +7836,19 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
setDrawableBounds(Theme.chat_botInlineDrawable, x, y + AndroidUtilities.dp(3)); setDrawableBounds(Theme.chat_botInlineDrawable, x, y + AndroidUtilities.dp(3));
Theme.chat_botInlineDrawable.draw(canvas); Theme.chat_botInlineDrawable.draw(canvas);
} else if (button.button instanceof TLRPC.TL_keyboardButtonCallback || button.button instanceof TLRPC.TL_keyboardButtonRequestGeoLocation || button.button instanceof TLRPC.TL_keyboardButtonGame || button.button instanceof TLRPC.TL_keyboardButtonBuy || button.button instanceof TLRPC.TL_keyboardButtonUrlAuth) { } else if (button.button instanceof TLRPC.TL_keyboardButtonCallback || button.button instanceof TLRPC.TL_keyboardButtonRequestGeoLocation || button.button instanceof TLRPC.TL_keyboardButtonGame || button.button instanceof TLRPC.TL_keyboardButtonBuy || button.button instanceof TLRPC.TL_keyboardButtonUrlAuth) {
if (button.button instanceof TLRPC.TL_keyboardButtonBuy) {
int x = button.x + button.width - AndroidUtilities.dp(5) - Theme.chat_botCardDrawalbe.getIntrinsicWidth() + addX;
setDrawableBounds(Theme.chat_botCardDrawalbe, x, y + AndroidUtilities.dp(4));
Theme.chat_botCardDrawalbe.draw(canvas);
}
boolean drawProgress = (button.button instanceof TLRPC.TL_keyboardButtonCallback || button.button instanceof TLRPC.TL_keyboardButtonGame || button.button instanceof TLRPC.TL_keyboardButtonBuy || button.button instanceof TLRPC.TL_keyboardButtonUrlAuth) && SendMessagesHelper.getInstance(currentAccount).isSendingCallback(currentMessageObject, button.button) || boolean drawProgress = (button.button instanceof TLRPC.TL_keyboardButtonCallback || button.button instanceof TLRPC.TL_keyboardButtonGame || button.button instanceof TLRPC.TL_keyboardButtonBuy || button.button instanceof TLRPC.TL_keyboardButtonUrlAuth) && SendMessagesHelper.getInstance(currentAccount).isSendingCallback(currentMessageObject, button.button) ||
button.button instanceof TLRPC.TL_keyboardButtonRequestGeoLocation && SendMessagesHelper.getInstance(currentAccount).isSendingCurrentLocation(currentMessageObject, button.button); button.button instanceof TLRPC.TL_keyboardButtonRequestGeoLocation && SendMessagesHelper.getInstance(currentAccount).isSendingCurrentLocation(currentMessageObject, button.button);
if (drawProgress || button.progressAlpha != 0) { if (drawProgress || button.progressAlpha != 0) {
Theme.chat_botProgressPaint.setAlpha(Math.min(255, (int) (button.progressAlpha * 255))); Theme.chat_botProgressPaint.setAlpha(Math.min(255, (int) (button.progressAlpha * 255)));
int x = button.x + button.width - AndroidUtilities.dp(9 + 3) + addX; int x = button.x + button.width - AndroidUtilities.dp(9 + 3) + addX;
if (button.button instanceof TLRPC.TL_keyboardButtonBuy) {
y += AndroidUtilities.dp(26);
}
rect.set(x, y + AndroidUtilities.dp(4), x + AndroidUtilities.dp(8), y + AndroidUtilities.dp(8 + 4)); rect.set(x, y + AndroidUtilities.dp(4), x + AndroidUtilities.dp(8), y + AndroidUtilities.dp(8 + 4));
canvas.drawArc(rect, button.angle, 220, false, Theme.chat_botProgressPaint); canvas.drawArc(rect, button.angle, 220, false, Theme.chat_botProgressPaint);
invalidate(); invalidate();
@ -9150,7 +9198,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
currentPhoto = null; currentPhoto = null;
} }
avatarDrawable.setInfo(currentUser); avatarDrawable.setInfo(currentUser);
avatarImage.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, null, currentUser, 0); avatarImage.setImage(ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentUser, 0);
} else if (currentChat != null) { } else if (currentChat != null) {
if (currentChat.photo != null) { if (currentChat.photo != null) {
currentPhoto = currentChat.photo.photo_small; currentPhoto = currentChat.photo.photo_small;
@ -9158,7 +9206,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
currentPhoto = null; currentPhoto = null;
} }
avatarDrawable.setInfo(currentChat); avatarDrawable.setInfo(currentChat);
avatarImage.setImage(ImageLocation.getForChat(currentChat, false), "50_50", avatarDrawable, null, currentChat, 0); avatarImage.setImage(ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentChat, 0);
} else { } else {
currentPhoto = null; currentPhoto = null;
avatarDrawable.setInfo(messageObject.getFromChatId(), null, null); avatarDrawable.setInfo(messageObject.getFromChatId(), null, null);
@ -11020,7 +11068,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
return !forceNotDrawTime; return !forceNotDrawTime;
} }
private boolean shouldDrawTimeOnMedia() { public boolean shouldDrawTimeOnMedia() {
if (overideShouldDrawTimeOnMedia != 0) { if (overideShouldDrawTimeOnMedia != 0) {
return overideShouldDrawTimeOnMedia == 1; return overideShouldDrawTimeOnMedia == 1;
} }
@ -11028,6 +11076,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} }
public void drawTime(Canvas canvas, float alpha, boolean fromParent) { public void drawTime(Canvas canvas, float alpha, boolean fromParent) {
if (!drawFromPinchToZoom && delegate != null && delegate.getPinchToZoomHelper() != null && delegate.getPinchToZoomHelper().isInOverlayModeFor(this) && shouldDrawTimeOnMedia()) {
return;
}
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
float curentAplha = alpha; float curentAplha = alpha;
if (i == 0 && isDrawSelectionBackground() && currentSelectedBackgroundAlpha == 1f && !shouldDrawTimeOnMedia()) { if (i == 0 && isDrawSelectionBackground() && currentSelectedBackgroundAlpha == 1f && !shouldDrawTimeOnMedia()) {
@ -11828,6 +11879,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} }
public void drawOverlays(Canvas canvas) { public void drawOverlays(Canvas canvas) {
if (!drawFromPinchToZoom && delegate != null && delegate.getPinchToZoomHelper() != null && delegate.getPinchToZoomHelper().isInOverlayModeFor(this)) {
return;
}
long newAnimationTime = SystemClock.elapsedRealtime(); long newAnimationTime = SystemClock.elapsedRealtime();
long animationDt = newAnimationTime - lastAnimationTime; long animationDt = newAnimationTime - lastAnimationTime;
if (animationDt > 17) { if (animationDt > 17) {
@ -13127,6 +13181,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
info.setParent(ChatMessageCell.this); info.setParent(ChatMessageCell.this);
info.setPackageName(getContext().getPackageName()); info.setPackageName(getContext().getPackageName());
if (virtualViewId >= LINK_IDS_START) { if (virtualViewId >= LINK_IDS_START) {
if (!(currentMessageObject.messageText instanceof Spannable)) {
return null;
}
Spannable buffer = (Spannable) currentMessageObject.messageText; Spannable buffer = (Spannable) currentMessageObject.messageText;
ClickableSpan link = getLinkById(virtualViewId); ClickableSpan link = getLinkById(virtualViewId);
if (link == null) { if (link == null) {

View File

@ -77,7 +77,7 @@ public class CheckBoxUserCell extends FrameLayout {
textView.setText(ContactsController.formatName(user.first_name, user.last_name)); textView.setText(ContactsController.formatName(user.first_name, user.last_name));
checkBox.setChecked(checked, false); checkBox.setChecked(checked, false);
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
needDivider = divider; needDivider = divider;
setWillNotDraw(!divider); setWillNotDraw(!divider);
} }

View File

@ -981,7 +981,7 @@ public class DialogCell extends BaseCell {
} }
thumbImage.setImage(ImageLocation.getForObject(bigThumb, message.photoThumbsObject), "20_20", ImageLocation.getForObject(smallThumb, message.photoThumbsObject), "20_20", size, null, message, 0); thumbImage.setImage(ImageLocation.getForObject(bigThumb, message.photoThumbsObject), "20_20", ImageLocation.getForObject(smallThumb, message.photoThumbsObject), "20_20", size, null, message, 0);
} else { } else {
thumbImage.setImage(null, null, ImageLocation.getForObject(smallThumb, message.photoThumbsObject), "20_20", null, message, 0); thumbImage.setImage(null, null, ImageLocation.getForObject(smallThumb, message.photoThumbsObject), "20_20", (Drawable) null, message, 0);
} }
needEmoji = false; needEmoji = false;
} }
@ -2113,11 +2113,11 @@ public class DialogCell extends BaseCell {
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED); avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
avatarImage.setImage(null, null, avatarDrawable, null, user, 0); avatarImage.setImage(null, null, avatarDrawable, null, user, 0);
} else { } else {
avatarImage.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, null, user, 0); avatarImage.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user, 0);
} }
} else if (chat != null) { } else if (chat != null) {
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
avatarImage.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, null, chat, 0); avatarImage.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat, 0);
} }
} }
@ -2236,7 +2236,10 @@ public class DialogCell extends BaseCell {
boolean needInvalidate = false; boolean needInvalidate = false;
if (currentDialogFolderId != 0 && archivedChatsDrawable != null && archivedChatsDrawable.outProgress == 0.0f && translationX == 0.0f) { if (currentDialogFolderId != 0 && archivedChatsDrawable != null && archivedChatsDrawable.outProgress == 0.0f && translationX == 0.0f) {
canvas.save();
canvas.clipRect(0, 0, getMeasuredWidth(), getMeasuredHeight());
archivedChatsDrawable.draw(canvas); archivedChatsDrawable.draw(canvas);
canvas.restore();
return; return;
} }
@ -2892,7 +2895,10 @@ public class DialogCell extends BaseCell {
canvas.restore(); canvas.restore();
} }
if (currentDialogFolderId != 0 && translationX == 0 && archivedChatsDrawable != null) { if (currentDialogFolderId != 0 && translationX == 0 && archivedChatsDrawable != null) {
canvas.save();
canvas.clipRect(0, 0, getMeasuredWidth(), getMeasuredHeight());
archivedChatsDrawable.draw(canvas); archivedChatsDrawable.draw(canvas);
canvas.restore();
} }
if (useSeparator) { if (useSeparator) {

View File

@ -129,7 +129,7 @@ public class DialogMeUrlCell extends BaseCell {
} }
nameString = chat.title; nameString = chat.title;
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
avatarImage.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, null, recentMeUrl, 0); avatarImage.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, recentMeUrl, 0);
} else if (recentMeUrl instanceof TLRPC.TL_recentMeUrlUser) { } else if (recentMeUrl instanceof TLRPC.TL_recentMeUrlUser) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(recentMeUrl.user_id); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(recentMeUrl.user_id);
if (!LocaleController.isRTL) { if (!LocaleController.isRTL) {
@ -153,7 +153,7 @@ public class DialogMeUrlCell extends BaseCell {
} }
nameString = UserObject.getUserName(user); nameString = UserObject.getUserName(user);
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
avatarImage.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, null, recentMeUrl, 0); avatarImage.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, recentMeUrl, 0);
} else if (recentMeUrl instanceof TLRPC.TL_recentMeUrlStickerSet) { } else if (recentMeUrl instanceof TLRPC.TL_recentMeUrlStickerSet) {
if (!LocaleController.isRTL) { if (!LocaleController.isRTL) {
nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline); nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
@ -180,7 +180,7 @@ public class DialogMeUrlCell extends BaseCell {
nameLockTop = AndroidUtilities.dp(17.5f); nameLockTop = AndroidUtilities.dp(17.5f);
} }
drawVerified = recentMeUrl.chat_invite.chat.verified; drawVerified = recentMeUrl.chat_invite.chat.verified;
avatarImage.setImage(ImageLocation.getForChat(recentMeUrl.chat_invite.chat, false), "50_50", avatarDrawable, null, recentMeUrl, 0); avatarImage.setImage(ImageLocation.getForUserOrChat(recentMeUrl.chat_invite.chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(recentMeUrl.chat_invite.chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, recentMeUrl, 0);
} else { } else {
nameString = recentMeUrl.chat_invite.title; nameString = recentMeUrl.chat_invite.title;
avatarDrawable.setInfo(5, recentMeUrl.chat_invite.title, null); avatarDrawable.setInfo(5, recentMeUrl.chat_invite.title, null);

View File

@ -351,7 +351,7 @@ public class DrawerProfileCell extends FrameLayout {
phoneTextView.setText(PhoneFormat.getInstance().format("+" + user.phone)); phoneTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
AvatarDrawable avatarDrawable = new AvatarDrawable(user); AvatarDrawable avatarDrawable = new AvatarDrawable(user);
avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue)); avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); avatarImageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
applyBackground(true); applyBackground(true);
} }

View File

@ -91,7 +91,7 @@ public class DrawerUserCell extends FrameLayout {
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
textView.setText(ContactsController.formatName(user.first_name, user.last_name)); textView.setText(ContactsController.formatName(user.first_name, user.last_name));
imageView.getImageReceiver().setCurrentAccount(account); imageView.getImageReceiver().setCurrentAccount(account);
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
checkBox.setVisibility(account == UserConfig.selectedAccount ? VISIBLE : INVISIBLE); checkBox.setVisibility(account == UserConfig.selectedAccount ? VISIBLE : INVISIBLE);
} }

View File

@ -91,7 +91,7 @@ public class GroupCallInvitedCell extends FrameLayout {
nameTextView.setText(lastName); nameTextView.setText(lastName);
avatarImageView.getImageReceiver().setCurrentAccount(account); avatarImageView.getImageReceiver().setCurrentAccount(account);
avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser); avatarImageView.setImage(ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentUser);
} }
public void setDrawDivider(boolean draw) { public void setDrawDivider(boolean draw) {

View File

@ -45,8 +45,8 @@ import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.RLottieDrawable; import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RLottieImageView; import org.telegram.ui.Components.RLottieImageView;
import org.telegram.ui.Components.RadialProgressView;
import org.telegram.ui.Components.WaveDrawable; import org.telegram.ui.Components.WaveDrawable;
import org.telegram.ui.ProfileActivity;
import java.util.ArrayList; import java.util.ArrayList;
@ -57,10 +57,13 @@ public class GroupCallUserCell extends FrameLayout {
private BackupImageView avatarImageView; private BackupImageView avatarImageView;
private SimpleTextView nameTextView; private SimpleTextView nameTextView;
private SimpleTextView[] statusTextView = new SimpleTextView[5]; private SimpleTextView[] statusTextView = new SimpleTextView[5];
private SimpleTextView fullAboutTextView;
private RLottieImageView muteButton; private RLottieImageView muteButton;
private RLottieDrawable muteDrawable; private RLottieDrawable muteDrawable;
private RLottieDrawable shakeHandDrawable; private RLottieDrawable shakeHandDrawable;
private RadialProgressView avatarProgressView;
private AvatarDrawable avatarDrawable; private AvatarDrawable avatarDrawable;
private ChatObject.Call currentCall; private ChatObject.Call currentCall;
@ -81,7 +84,6 @@ public class GroupCallUserCell extends FrameLayout {
private int currentStatus; private int currentStatus;
private int selfId; private int selfId;
private Runnable shakeHandCallback = () -> { private Runnable shakeHandCallback = () -> {
shakeHandDrawable.setOnFinishCallback(null, 0); shakeHandDrawable.setOnFinishCallback(null, 0);
muteDrawable.setOnFinishCallback(null, 0); muteDrawable.setOnFinishCallback(null, 0);
@ -132,6 +134,7 @@ public class GroupCallUserCell extends FrameLayout {
private boolean updateRunnableScheduled; private boolean updateRunnableScheduled;
private boolean updateVoiceRunnableScheduled; private boolean updateVoiceRunnableScheduled;
private boolean isSpeaking; private boolean isSpeaking;
private boolean hasAvatar;
private Drawable speakingDrawable; private Drawable speakingDrawable;
@ -142,6 +145,16 @@ public class GroupCallUserCell extends FrameLayout {
public void setProgressToAvatarPreview(float progressToAvatarPreview) { public void setProgressToAvatarPreview(float progressToAvatarPreview) {
this.progressToAvatarPreview = progressToAvatarPreview; this.progressToAvatarPreview = progressToAvatarPreview;
nameTextView.setTranslationX((LocaleController.isRTL ? AndroidUtilities.dp(53) : -AndroidUtilities.dp(53)) * progressToAvatarPreview); nameTextView.setTranslationX((LocaleController.isRTL ? AndroidUtilities.dp(53) : -AndroidUtilities.dp(53)) * progressToAvatarPreview);
if (isSelfUser() && progressToAvatarPreview > 0) {
fullAboutTextView.setTranslationX((LocaleController.isRTL ? -AndroidUtilities.dp(53) : AndroidUtilities.dp(53)) * (1f - progressToAvatarPreview));
fullAboutTextView.setVisibility(View.VISIBLE);
fullAboutTextView.setAlpha(progressToAvatarPreview);
statusTextView[4].setAlpha(1f - progressToAvatarPreview);
statusTextView[4].setTranslationX((LocaleController.isRTL ? AndroidUtilities.dp(53) : -AndroidUtilities.dp(53)) * progressToAvatarPreview);
} else {
fullAboutTextView.setVisibility(View.GONE);
for (int i = 0; i < statusTextView.length; i++) { for (int i = 0; i < statusTextView.length; i++) {
if (!TextUtils.isEmpty(statusTextView[4].getText()) && statusTextView[4].getLineCount() > 1) { if (!TextUtils.isEmpty(statusTextView[4].getText()) && statusTextView[4].getLineCount() > 1) {
statusTextView[i].setFullLayoutAdditionalWidth(AndroidUtilities.dp(92), LocaleController.isRTL ? AndroidUtilities.dp(48) : AndroidUtilities.dp(53)); statusTextView[i].setFullLayoutAdditionalWidth(AndroidUtilities.dp(92), LocaleController.isRTL ? AndroidUtilities.dp(48) : AndroidUtilities.dp(53));
@ -153,6 +166,8 @@ public class GroupCallUserCell extends FrameLayout {
statusTextView[i].setFullLayoutAdditionalWidth(0, 0); statusTextView[i].setFullLayoutAdditionalWidth(0, 0);
} }
} }
}
avatarImageView.setAlpha(progressToAvatarPreview == 0 ? 1f : 0); avatarImageView.setAlpha(progressToAvatarPreview == 0 ? 1f : 0);
avatarWavesDrawable.setShowWaves(isSpeaking && progressToAvatarPreview == 0, this); avatarWavesDrawable.setShowWaves(isSpeaking && progressToAvatarPreview == 0, this);
@ -160,6 +175,8 @@ public class GroupCallUserCell extends FrameLayout {
muteButton.setAlpha(1f - progressToAvatarPreview); muteButton.setAlpha(1f - progressToAvatarPreview);
muteButton.setScaleX(0.6f + 0.4f * (1f - progressToAvatarPreview)); muteButton.setScaleX(0.6f + 0.4f * (1f - progressToAvatarPreview));
muteButton.setScaleY(0.6f + 0.4f * (1f - progressToAvatarPreview)); muteButton.setScaleY(0.6f + 0.4f * (1f - progressToAvatarPreview));
invalidate(); invalidate();
} }
@ -167,6 +184,15 @@ public class GroupCallUserCell extends FrameLayout {
return avatarWavesDrawable; return avatarWavesDrawable;
} }
public void setUploadProgress(float progress, boolean animated) {
avatarProgressView.setProgress(progress);
if (progress < 1f) {
AndroidUtilities.updateViewVisibilityAnimated(avatarProgressView, true, 1f, animated);
} else {
AndroidUtilities.updateViewVisibilityAnimated(avatarProgressView, false, 1f, animated);
}
}
private static class VerifiedDrawable extends Drawable { private static class VerifiedDrawable extends Drawable {
private Drawable[] drawables = new Drawable[2]; private Drawable[] drawables = new Drawable[2];
@ -227,6 +253,28 @@ public class GroupCallUserCell extends FrameLayout {
avatarImageView.setRoundRadius(AndroidUtilities.dp(24)); avatarImageView.setRoundRadius(AndroidUtilities.dp(24));
addView(avatarImageView, LayoutHelper.createFrame(46, 46, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 11, 6, LocaleController.isRTL ? 11 : 0, 0)); addView(avatarImageView, LayoutHelper.createFrame(46, 46, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 11, 6, LocaleController.isRTL ? 11 : 0, 0));
avatarProgressView = new RadialProgressView(context) {
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
{
paint.setColor(0x55000000);
}
@Override
protected void onDraw(Canvas canvas) {
if (avatarImageView.getImageReceiver().hasNotThumb() && avatarImageView.getAlpha() > 0) {
paint.setAlpha((int) (0x55 * avatarImageView.getImageReceiver().getCurrentAlpha() * avatarImageView.getAlpha()));
canvas.drawCircle(getMeasuredWidth() / 2.0f, getMeasuredHeight() / 2.0f, getMeasuredWidth() / 2.0f, paint);
}
avatarProgressView.setProgressColor(ColorUtils.setAlphaComponent(0xffffffff, (int) (255 * avatarImageView.getImageReceiver().getCurrentAlpha() * avatarImageView.getAlpha())));
super.onDraw(canvas);
}
};
avatarProgressView.setSize(AndroidUtilities.dp(26));
avatarProgressView.setProgressColor(0xffffffff);
avatarProgressView.setNoProgress(false);
addView(avatarProgressView, LayoutHelper.createFrame(46, 46, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 11, 6, LocaleController.isRTL ? 11 : 0, 0));
AndroidUtilities.updateViewVisibilityAnimated(avatarProgressView, false, 1f, false);
nameTextView = new SimpleTextView(context); nameTextView = new SimpleTextView(context);
nameTextView.setTextColor(Theme.getColor(Theme.key_voipgroup_nameText)); nameTextView.setTextColor(Theme.getColor(Theme.key_voipgroup_nameText));
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
@ -247,15 +295,18 @@ public class GroupCallUserCell extends FrameLayout {
@Override @Override
public void setAlpha(float alpha) { public void setAlpha(float alpha) {
originalAlpha = alpha; originalAlpha = alpha;
float alphaOverride;
if (num == 4) { if (num == 4) {
float alphaOverride = statusTextView[4].getFullAlpha(); alphaOverride = statusTextView[4].getFullAlpha();
if (alphaOverride > 0) { if (isSelfUser() && progressToAvatarPreview > 0) {
super.setAlpha(1f - progressToAvatarPreview);
} else if (alphaOverride > 0) {
super.setAlpha(Math.max(alpha, alphaOverride)); super.setAlpha(Math.max(alpha, alphaOverride));
} else { } else {
super.setAlpha(alpha); super.setAlpha(alpha);
} }
} else { } else {
float alphaOverride = 1.0f - statusTextView[4].getFullAlpha(); alphaOverride = 1.0f - statusTextView[4].getFullAlpha();
super.setAlpha(alpha * alphaOverride); super.setAlpha(alpha * alphaOverride);
} }
} }
@ -306,6 +357,13 @@ public class GroupCallUserCell extends FrameLayout {
} }
} }
fullAboutTextView = new SimpleTextView(context);
fullAboutTextView.setMaxLines(3);
fullAboutTextView.setTextSize(15);
fullAboutTextView.setTextColor(Theme.getColor(Theme.key_voipgroup_mutedIcon));
fullAboutTextView.setVisibility(View.GONE);
addView(fullAboutTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20 * 3, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 14, 32, 14, 0));
muteDrawable = new RLottieDrawable(R.raw.voice_outlined2, "" + R.raw.voice_outlined2, AndroidUtilities.dp(34), AndroidUtilities.dp(32), true, null); muteDrawable = new RLottieDrawable(R.raw.voice_outlined2, "" + R.raw.voice_outlined2, AndroidUtilities.dp(34), AndroidUtilities.dp(32), true, null);
shakeHandDrawable = new RLottieDrawable(R.raw.hand_1, "" + R.raw.hand_1, AndroidUtilities.dp(34), AndroidUtilities.dp(32), true, null); shakeHandDrawable = new RLottieDrawable(R.raw.hand_1, "" + R.raw.hand_1, AndroidUtilities.dp(34), AndroidUtilities.dp(32), true, null);
@ -333,10 +391,16 @@ public class GroupCallUserCell extends FrameLayout {
} }
public int getClipHeight() { public int getClipHeight() {
int lineCount = statusTextView[4].getLineCount(); SimpleTextView aboutTextView;
if (!TextUtils.isEmpty(fullAboutTextView.getText()) && hasAvatar) {
aboutTextView = fullAboutTextView;
} else {
aboutTextView = statusTextView[4];
}
int lineCount = aboutTextView.getLineCount();
if (lineCount > 1) { if (lineCount > 1) {
int h = statusTextView[4].getTextHeight(); int h = aboutTextView.getTextHeight();
return statusTextView[4].getTop() + h + AndroidUtilities.dp(8); return aboutTextView.getTop() + h + AndroidUtilities.dp(8);
} }
return getMeasuredHeight(); return getMeasuredHeight();
} }
@ -377,7 +441,7 @@ public class GroupCallUserCell extends FrameLayout {
return avatarImageView.getImageReceiver().hasNotThumb(); return avatarImageView.getImageReceiver().hasNotThumb();
} }
public void setData(AccountInstance account, TLRPC.TL_groupCallParticipant groupCallParticipant, ChatObject.Call call, int self) { public void setData(AccountInstance account, TLRPC.TL_groupCallParticipant groupCallParticipant, ChatObject.Call call, int self, TLRPC.FileLocation uploadingAvatar) {
currentCall = call; currentCall = call;
accountInstance = account; accountInstance = account;
selfId = self; selfId = self;
@ -393,7 +457,14 @@ public class GroupCallUserCell extends FrameLayout {
nameTextView.setText(UserObject.getUserName(currentUser)); nameTextView.setText(UserObject.getUserName(currentUser));
nameTextView.setRightDrawable(currentUser != null && currentUser.verified ? new VerifiedDrawable(getContext()) : null); nameTextView.setRightDrawable(currentUser != null && currentUser.verified ? new VerifiedDrawable(getContext()) : null);
avatarImageView.getImageReceiver().setCurrentAccount(account.getCurrentAccount()); avatarImageView.getImageReceiver().setCurrentAccount(account.getCurrentAccount());
avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser); if (uploadingAvatar != null) {
hasAvatar = true;
avatarImageView.setImage(ImageLocation.getForLocal(uploadingAvatar), "50_50", avatarDrawable, null);
} else {
ImageLocation imageLocation = ImageLocation.getForUser(currentUser, ImageLocation.TYPE_SMALL);
hasAvatar = imageLocation != null;
avatarImageView.setImage(imageLocation, "50_50", avatarDrawable, currentUser);
}
} else { } else {
currentChat = accountInstance.getMessagesController().getChat(-id); currentChat = accountInstance.getMessagesController().getChat(-id);
currentUser = null; currentUser = null;
@ -403,10 +474,18 @@ public class GroupCallUserCell extends FrameLayout {
nameTextView.setText(currentChat.title); nameTextView.setText(currentChat.title);
nameTextView.setRightDrawable(currentChat.verified ? new VerifiedDrawable(getContext()) : null); nameTextView.setRightDrawable(currentChat.verified ? new VerifiedDrawable(getContext()) : null);
avatarImageView.getImageReceiver().setCurrentAccount(account.getCurrentAccount()); avatarImageView.getImageReceiver().setCurrentAccount(account.getCurrentAccount());
avatarImageView.setImage(ImageLocation.getForChat(currentChat, false), "50_50", avatarDrawable, currentChat); if (uploadingAvatar != null) {
hasAvatar = true;
avatarImageView.setImage(ImageLocation.getForLocal(uploadingAvatar), "50_50", avatarDrawable, null);
} else {
ImageLocation imageLocation = ImageLocation.getForChat(currentChat, ImageLocation.TYPE_SMALL);
hasAvatar = imageLocation != null;
avatarImageView.setImage(imageLocation, "50_50", avatarDrawable, currentChat);
} }
} }
} }
applyParticipantChanges(false);
}
public void setDrawDivider(boolean draw) { public void setDrawDivider(boolean draw) {
needDivider = draw; needDivider = draw;
@ -578,18 +657,45 @@ public class GroupCallUserCell extends FrameLayout {
} }
} }
if (isSelfUser()) { if (!isSelfUser()) {
statusTextView[4].setTextColor(Theme.getColor(Theme.key_voipgroup_listeningText));
} else {
statusTextView[4].setTextColor(Theme.getColor(grayIconColor)); statusTextView[4].setTextColor(Theme.getColor(grayIconColor));
} }
if (isSelfUser()) { if (isSelfUser()) {
if (!hasAbout && !hasAvatar) {
if (currentUser != null) {
statusTextView[4].setText(LocaleController.getString("TapToAddPhotoOrBio", R.string.TapToAddPhotoOrBio));
} else {
statusTextView[4].setText(LocaleController.getString("TapToAddPhotoOrDescription", R.string.TapToAddPhotoOrDescription));
}
statusTextView[4].setTextColor(Theme.getColor(grayIconColor));
} else if (!hasAbout ){
if (currentUser != null) {
statusTextView[4].setText(LocaleController.getString("TapToAddBio", R.string.TapToAddBio));
} else {
statusTextView[4].setText(LocaleController.getString("TapToAddDescription", R.string.TapToAddDescription));
}
statusTextView[4].setTextColor(Theme.getColor(grayIconColor));
} else if (!hasAvatar) {
statusTextView[4].setText(LocaleController.getString("TapToAddPhoto", R.string.TapToAddPhoto));
statusTextView[4].setTextColor(Theme.getColor(grayIconColor));
} else {
statusTextView[4].setText(LocaleController.getString("ThisIsYou", R.string.ThisIsYou)); statusTextView[4].setText(LocaleController.getString("ThisIsYou", R.string.ThisIsYou));
statusTextView[4].setTextColor(Theme.getColor(Theme.key_voipgroup_listeningText));
}
if (hasAbout) {
fullAboutTextView.setText(AndroidUtilities.replaceNewLines(participant.about));
fullAboutTextView.setTextColor(Theme.getColor(Theme.key_voipgroup_mutedIcon));
} else {
fullAboutTextView.setText(statusTextView[newStatus].getText());
fullAboutTextView.setTextColor(statusTextView[newStatus].getTextColor());
}
} else if (hasAbout) { } else if (hasAbout) {
statusTextView[4].setText(AndroidUtilities.replaceNewLines(participant.about)); statusTextView[4].setText(AndroidUtilities.replaceNewLines(participant.about));
fullAboutTextView.setText("");
} else { } else {
statusTextView[4].setText(""); statusTextView[4].setText("");
fullAboutTextView.setText("");
} }
boolean somethingChanged = false; boolean somethingChanged = false;
if (animatorSet != null) { if (animatorSet != null) {
@ -626,7 +732,7 @@ public class GroupCallUserCell extends FrameLayout {
int volume = vol / 100; int volume = vol / 100;
if (volume != 100) { if (volume != 100) {
statusTextView[1].setLeftDrawable(speakingDrawable); statusTextView[1].setLeftDrawable(speakingDrawable);
statusTextView[1].setText((vol < 100 ? 1 : volume) + "% " + LocaleController.getString("Speaking", R.string.Speaking)); statusTextView[1].setText(LocaleController.formatString("SpeakingWithVolume", R.string.SpeakingWithVolume, vol < 100 ? 1 : volume));
} else { } else {
statusTextView[1].setLeftDrawable(null); statusTextView[1].setLeftDrawable(null);
statusTextView[1].setText(LocaleController.getString("Speaking", R.string.Speaking)); statusTextView[1].setText(LocaleController.getString("Speaking", R.string.Speaking));
@ -766,6 +872,8 @@ public class GroupCallUserCell extends FrameLayout {
avatarImageView.setScaleX(avatarWavesDrawable.getAvatarScale()); avatarImageView.setScaleX(avatarWavesDrawable.getAvatarScale());
avatarImageView.setScaleY(avatarWavesDrawable.getAvatarScale()); avatarImageView.setScaleY(avatarWavesDrawable.getAvatarScale());
avatarProgressView.setScaleX(avatarWavesDrawable.getAvatarScale());
avatarProgressView.setScaleY(avatarWavesDrawable.getAvatarScale());
super.dispatchDraw(canvas); super.dispatchDraw(canvas);
} }
@ -913,6 +1021,7 @@ public class GroupCallUserCell extends FrameLayout {
return avatarImageView; return avatarImageView;
} }
@Override @Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info); super.onInitializeAccessibilityNodeInfo(info);

View File

@ -330,7 +330,7 @@ public class GroupCreateUserCell extends FrameLayout {
} }
} }
avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser); avatarImageView.setImage(ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentUser);
} else { } else {
TLRPC.Chat currentChat = (TLRPC.Chat) currentObject; TLRPC.Chat currentChat = (TLRPC.Chat) currentObject;
if (currentChat.photo != null) { if (currentChat.photo != null) {
@ -390,7 +390,7 @@ public class GroupCreateUserCell extends FrameLayout {
} }
} }
avatarImageView.setImage(ImageLocation.getForChat(currentChat, false), "50_50", avatarDrawable, currentChat); avatarImageView.setImage(ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentChat);
} }
} }

View File

@ -11,8 +11,6 @@ package org.telegram.ui.Cells;
import android.content.Context; import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.RectF; import android.graphics.RectF;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
@ -130,7 +128,7 @@ public class HintDialogCell extends FrameLayout {
nameTextView.setText(""); nameTextView.setText("");
} }
avatarDrawable.setInfo(currentUser); avatarDrawable.setInfo(currentUser);
imageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser); imageView.setImage(ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentUser);
} else { } else {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-uid); TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-uid);
if (name != null) { if (name != null) {
@ -142,7 +140,7 @@ public class HintDialogCell extends FrameLayout {
} }
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
currentUser = null; currentUser = null;
imageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); imageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
} }
if (counter) { if (counter) {
update(0); update(0);

View File

@ -58,7 +58,7 @@ public class JoinSheetUserCell extends FrameLayout {
public void setUser(TLRPC.User user) { public void setUser(TLRPC.User user) {
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name)); nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} }
public void setCount(int count) { public void setCount(int count) {

View File

@ -260,7 +260,7 @@ public class ManageChatUserCell extends FrameLayout {
} }
} }
lastAvatar = photo; lastAvatar = photo;
avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser); avatarImageView.setImage(ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentUser);
} else if (currentObject instanceof TLRPC.Chat) { } else if (currentObject instanceof TLRPC.Chat) {
TLRPC.Chat currentChat = (TLRPC.Chat) currentObject; TLRPC.Chat currentChat = (TLRPC.Chat) currentObject;
@ -317,7 +317,7 @@ public class ManageChatUserCell extends FrameLayout {
} }
} }
lastAvatar = photo; lastAvatar = photo;
avatarImageView.setImage(ImageLocation.getForChat(currentChat, false), "50_50", avatarDrawable, currentChat); avatarImageView.setImage(ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentChat);
} else if (currentObject instanceof Integer) { } else if (currentObject instanceof Integer) {
nameTextView.setText(currentName); nameTextView.setText(currentName);
statusTextView.setTextColor(statusColor); statusTextView.setTextColor(statusColor);

View File

@ -76,7 +76,7 @@ public class MentionCell extends LinearLayout {
} }
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
if (user.photo != null && user.photo.photo_small != null) { if (user.photo != null && user.photo.photo_small != null) {
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} else { } else {
imageView.setImageDrawable(avatarDrawable); imageView.setImageDrawable(avatarDrawable);
} }
@ -99,7 +99,7 @@ public class MentionCell extends LinearLayout {
} }
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
if (chat.photo != null && chat.photo.photo_small != null) { if (chat.photo != null && chat.photo.photo_small != null) {
imageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); imageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
} else { } else {
imageView.setImageDrawable(avatarDrawable); imageView.setImageDrawable(avatarDrawable);
} }
@ -140,7 +140,7 @@ public class MentionCell extends LinearLayout {
imageView.setVisibility(VISIBLE); imageView.setVisibility(VISIBLE);
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
if (user.photo != null && user.photo.photo_small != null) { if (user.photo != null && user.photo.photo_small != null) {
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} else { } else {
imageView.setImageDrawable(avatarDrawable); imageView.setImageDrawable(avatarDrawable);
} }

View File

@ -60,25 +60,27 @@ public class PaymentInfoCell extends FrameLayout {
detailExTextView = new TextView(context); detailExTextView = new TextView(context);
detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2)); detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
detailExTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); detailExTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
detailExTextView.setLines(1); detailExTextView.setLines(1);
detailExTextView.setMaxLines(1); detailExTextView.setMaxLines(1);
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, LocaleController.isRTL ? 10 : 123, 90, LocaleController.isRTL ? 123 : 10, 0)); addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 90, LocaleController.isRTL ? 123 : 10, 9));
} }
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(120), MeasureSpec.EXACTLY)); int h;
if (imageView.getVisibility() != GONE) {
h = MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(120), MeasureSpec.EXACTLY);
} else {
h = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
measureChildWithMargins(detailTextView, widthMeasureSpec, 0, heightMeasureSpec, 0);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) detailExTextView.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(33) + detailTextView.getMeasuredHeight() + AndroidUtilities.dp(3);
} }
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), h);
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
top = detailTextView.getBottom() + AndroidUtilities.dp(3);
detailExTextView.layout(detailExTextView.getLeft(), top, detailExTextView.getRight(), top + detailExTextView.getMeasuredHeight());
} }
public void setInvoice(TLRPC.TL_messageMediaInvoice invoice, String botname) { public void setInvoice(TLRPC.TL_messageMediaInvoice invoice, String botname) {
@ -107,7 +109,38 @@ public class PaymentInfoCell extends FrameLayout {
} else { } else {
nameTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 9, 17, 0)); nameTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 9, 17, 0));
detailTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 33, 17, 0)); detailTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 33, 17, 0));
detailExTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 90, 17, 0)); detailExTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 90, 17, 9));
imageView.setVisibility(GONE);
}
}
public void setReceipt(TLRPC.TL_payments_paymentReceipt receipt, String botname) {
nameTextView.setText(receipt.title);
detailTextView.setText(receipt.description);
detailExTextView.setText(botname);
int maxPhotoWidth;
if (AndroidUtilities.isTablet()) {
maxPhotoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
} else {
maxPhotoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f);
}
int width = 640;
int height = 360;
float scale = width / (float) (maxPhotoWidth - AndroidUtilities.dp(2));
width /= scale;
height /= scale;
if (receipt.photo != null && receipt.photo.mime_type.startsWith("image/")) {
nameTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 9, LocaleController.isRTL ? 123 : 10, 0));
detailTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 33, LocaleController.isRTL ? 123 : 10, 0));
detailExTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 90, LocaleController.isRTL ? 123 : 10, 0));
imageView.setVisibility(VISIBLE);
String filter = String.format(Locale.US, "%d_%d", width, height);
imageView.getImageReceiver().setImage(ImageLocation.getForWebFile(WebFile.createWithWebDocument(receipt.photo)), filter, null, null, -1, null, receipt, 1);
} else {
nameTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 9, 17, 0));
detailTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 33, 17, 0));
detailExTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 90, 17, 9));
imageView.setVisibility(GONE); imageView.setVisibility(GONE);
} }
} }

View File

@ -501,14 +501,14 @@ public class ProfileSearchCell extends BaseCell {
if (user.photo != null) { if (user.photo != null) {
photo = user.photo.photo_small; photo = user.photo.photo_small;
} }
avatarImage.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, null, user, 0); avatarImage.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user, 0);
} }
} else if (chat != null) { } else if (chat != null) {
if (chat.photo != null) { if (chat.photo != null) {
photo = chat.photo.photo_small; photo = chat.photo.photo_small;
} }
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
avatarImage.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, null, chat, 0); avatarImage.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat, 0);
} else { } else {
avatarDrawable.setInfo(0, null, null); avatarDrawable.setInfo(0, null, null);
avatarImage.setImage(null, null, avatarDrawable, null, null, 0); avatarImage.setImage(null, null, avatarDrawable, null, null, 0);

View File

@ -183,7 +183,7 @@ public class SessionCell extends FrameLayout {
if (user != null) { if (user != null) {
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
name = UserObject.getFirstName(user); name = UserObject.getFirstName(user);
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} else { } else {
name = ""; name = "";
} }

View File

@ -41,58 +41,68 @@ public class ShareDialogCell extends FrameLayout {
private CheckBox2 checkBox; private CheckBox2 checkBox;
private AvatarDrawable avatarDrawable = new AvatarDrawable(); private AvatarDrawable avatarDrawable = new AvatarDrawable();
private TLRPC.User user; private TLRPC.User user;
private boolean darkTheme; private int currentType;
private float onlineProgress; private float onlineProgress;
private long lastUpdateTime; private long lastUpdateTime;
private long currentDialog;
private int currentAccount = UserConfig.selectedAccount; private int currentAccount = UserConfig.selectedAccount;
public ShareDialogCell(Context context, boolean forCall) { public static final int TYPE_SHARE = 0;
public static final int TYPE_CALL = 1;
public static final int TYPE_CREATE = 2;
public ShareDialogCell(Context context, int type) {
super(context); super(context);
setWillNotDraw(false); setWillNotDraw(false);
darkTheme = forCall; currentType = type;
imageView = new BackupImageView(context); imageView = new BackupImageView(context);
imageView.setRoundRadius(AndroidUtilities.dp(28)); imageView.setRoundRadius(AndroidUtilities.dp(28));
if (type == TYPE_CREATE) {
addView(imageView, LayoutHelper.createFrame(48, 48, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0));
} else {
addView(imageView, LayoutHelper.createFrame(56, 56, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0)); addView(imageView, LayoutHelper.createFrame(56, 56, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0));
}
nameTextView = new TextView(context); nameTextView = new TextView(context);
nameTextView.setTextColor(Theme.getColor(forCall ? Theme.key_voipgroup_nameText : Theme.key_dialogTextBlack)); nameTextView.setTextColor(Theme.getColor(type == TYPE_CALL ? Theme.key_voipgroup_nameText : Theme.key_dialogTextBlack));
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
nameTextView.setMaxLines(2); nameTextView.setMaxLines(2);
nameTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL); nameTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
nameTextView.setLines(2); nameTextView.setLines(2);
nameTextView.setEllipsize(TextUtils.TruncateAt.END); nameTextView.setEllipsize(TextUtils.TruncateAt.END);
addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 6, 66, 6, 0)); addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 6, currentType == TYPE_CREATE ? 58 : 66, 6, 0));
checkBox = new CheckBox2(context, 21); checkBox = new CheckBox2(context, 21);
checkBox.setColor(Theme.key_dialogRoundCheckBox, forCall ? Theme.key_voipgroup_inviteMembersBackground : Theme.key_dialogBackground, Theme.key_dialogRoundCheckBoxCheck); checkBox.setColor(Theme.key_dialogRoundCheckBox, type == TYPE_CALL ? Theme.key_voipgroup_inviteMembersBackground : Theme.key_dialogBackground, Theme.key_dialogRoundCheckBoxCheck);
checkBox.setDrawUnchecked(false); checkBox.setDrawUnchecked(false);
checkBox.setDrawBackgroundAsArc(4); checkBox.setDrawBackgroundAsArc(4);
checkBox.setProgressDelegate(progress -> { checkBox.setProgressDelegate(progress -> {
float scale = 1.0f - (1.0f - 0.857f) * checkBox.getProgress(); float scale = 1.0f - (1.0f - 0.857f) * checkBox.getProgress();
imageView.setScaleX(scale); imageView.setScaleX(scale);
imageView.setScaleY(scale); imageView.setScaleY(scale);
invalidate();
}); });
addView(checkBox, LayoutHelper.createFrame(24, 24, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 19, 42, 0, 0)); addView(checkBox, LayoutHelper.createFrame(24, 24, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 19, currentType == TYPE_CREATE ? -40 : 42, 0, 0));
} }
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(103), MeasureSpec.EXACTLY)); super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(currentType == TYPE_CREATE ? 95 : 103), MeasureSpec.EXACTLY));
} }
public void setDialog(int uid, boolean checked, CharSequence name) { public void setDialog(int uid, boolean checked, CharSequence name) {
if (uid > 0) { if (uid > 0) {
user = MessagesController.getInstance(currentAccount).getUser(uid); user = MessagesController.getInstance(currentAccount).getUser(uid);
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
if (UserObject.isReplyUser(user)) { if (currentType != TYPE_CREATE && UserObject.isReplyUser(user)) {
nameTextView.setText(LocaleController.getString("RepliesTitle", R.string.RepliesTitle)); nameTextView.setText(LocaleController.getString("RepliesTitle", R.string.RepliesTitle));
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_REPLIES); avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_REPLIES);
imageView.setImage(null, null, avatarDrawable, user); imageView.setImage(null, null, avatarDrawable, user);
} else if (UserObject.isUserSelf(user)) { } else if (currentType != TYPE_CREATE && UserObject.isUserSelf(user)) {
nameTextView.setText(LocaleController.getString("SavedMessages", R.string.SavedMessages)); nameTextView.setText(LocaleController.getString("SavedMessages", R.string.SavedMessages));
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED); avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
imageView.setImage(null, null, avatarDrawable, user); imageView.setImage(null, null, avatarDrawable, user);
@ -104,7 +114,7 @@ public class ShareDialogCell extends FrameLayout {
} else { } else {
nameTextView.setText(""); nameTextView.setText("");
} }
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} }
} else { } else {
user = null; user = null;
@ -117,11 +127,16 @@ public class ShareDialogCell extends FrameLayout {
nameTextView.setText(""); nameTextView.setText("");
} }
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
imageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); imageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
} }
currentDialog = uid;
checkBox.setChecked(checked, false); checkBox.setChecked(checked, false);
} }
public long getCurrentDialog() {
return currentDialog;
}
public void setChecked(boolean checked, boolean animated) { public void setChecked(boolean checked, boolean animated) {
checkBox.setChecked(checked, animated); checkBox.setChecked(checked, animated);
} }
@ -129,7 +144,7 @@ public class ShareDialogCell extends FrameLayout {
@Override @Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) { protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
boolean result = super.drawChild(canvas, child, drawingTime); boolean result = super.drawChild(canvas, child, drawingTime);
if (child == imageView) { if (child == imageView && currentType != TYPE_CREATE) {
if (user != null && !MessagesController.isSupportUser(user)) { if (user != null && !MessagesController.isSupportUser(user)) {
long newTime = SystemClock.elapsedRealtime(); long newTime = SystemClock.elapsedRealtime();
long dt = newTime - lastUpdateTime; long dt = newTime - lastUpdateTime;
@ -142,7 +157,7 @@ public class ShareDialogCell extends FrameLayout {
if (isOnline || onlineProgress != 0) { if (isOnline || onlineProgress != 0) {
int top = imageView.getBottom() - AndroidUtilities.dp(6); int top = imageView.getBottom() - AndroidUtilities.dp(6);
int left = imageView.getRight() - AndroidUtilities.dp(10); int left = imageView.getRight() - AndroidUtilities.dp(10);
Theme.dialogs_onlineCirclePaint.setColor(Theme.getColor(darkTheme ? Theme.key_voipgroup_inviteMembersBackground : Theme.key_windowBackgroundWhite)); Theme.dialogs_onlineCirclePaint.setColor(Theme.getColor(currentType == TYPE_CALL ? Theme.key_voipgroup_inviteMembersBackground : Theme.key_windowBackgroundWhite));
canvas.drawCircle(left, top, AndroidUtilities.dp(7) * onlineProgress, Theme.dialogs_onlineCirclePaint); canvas.drawCircle(left, top, AndroidUtilities.dp(7) * onlineProgress, Theme.dialogs_onlineCirclePaint);
Theme.dialogs_onlineCirclePaint.setColor(Theme.getColor(Theme.key_chats_onlineCircle)); Theme.dialogs_onlineCirclePaint.setColor(Theme.getColor(Theme.key_chats_onlineCircle));
canvas.drawCircle(left, top, AndroidUtilities.dp(5) * onlineProgress, Theme.dialogs_onlineCirclePaint); canvas.drawCircle(left, top, AndroidUtilities.dp(5) * onlineProgress, Theme.dialogs_onlineCirclePaint);
@ -177,6 +192,6 @@ public class ShareDialogCell extends FrameLayout {
int cy = imageView.getTop() + imageView.getMeasuredHeight() / 2; int cy = imageView.getTop() + imageView.getMeasuredHeight() / 2;
Theme.checkboxSquare_checkPaint.setColor(Theme.getColor(Theme.key_dialogRoundCheckBox)); Theme.checkboxSquare_checkPaint.setColor(Theme.getColor(Theme.key_dialogRoundCheckBox));
Theme.checkboxSquare_checkPaint.setAlpha((int) (checkBox.getProgress() * 255)); Theme.checkboxSquare_checkPaint.setAlpha((int) (checkBox.getProgress() * 255));
canvas.drawCircle(cx, cy, AndroidUtilities.dp(28), Theme.checkboxSquare_checkPaint); canvas.drawCircle(cx, cy, AndroidUtilities.dp(24), Theme.checkboxSquare_checkPaint);
} }
} }

View File

@ -124,14 +124,14 @@ public class SharingLiveLocationCell extends FrameLayout {
if (user != null) { if (user != null) {
avatarDrawable = new AvatarDrawable(user); avatarDrawable = new AvatarDrawable(user);
name = UserObject.getUserName(user); name = UserObject.getUserName(user);
avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); avatarImageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} }
} else { } else {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lowerId); TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lowerId);
if (chat != null) { if (chat != null) {
avatarDrawable = new AvatarDrawable(chat); avatarDrawable = new AvatarDrawable(chat);
name = chat.title; name = chat.title;
avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); avatarImageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
} }
} }
nameTextView.setText(name); nameTextView.setText(name);
@ -177,14 +177,14 @@ public class SharingLiveLocationCell extends FrameLayout {
if (user != null) { if (user != null) {
avatarDrawable = new AvatarDrawable(user); avatarDrawable = new AvatarDrawable(user);
name = UserObject.getUserName(user); name = UserObject.getUserName(user);
avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); avatarImageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} }
} else { } else {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-fromId); TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-fromId);
if (chat != null) { if (chat != null) {
avatarDrawable = new AvatarDrawable(chat); avatarDrawable = new AvatarDrawable(chat);
name = chat.title; name = chat.title;
avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); avatarImageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
} }
} }
} }
@ -216,14 +216,14 @@ public class SharingLiveLocationCell extends FrameLayout {
if (user != null) { if (user != null) {
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name)); nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); avatarImageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} }
} else { } else {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id); TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id);
if (chat != null) { if (chat != null) {
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
nameTextView.setText(chat.title); nameTextView.setText(chat.title);
avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); avatarImageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
} }
} }
@ -249,14 +249,14 @@ public class SharingLiveLocationCell extends FrameLayout {
if (user != null) { if (user != null) {
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name)); nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); avatarImageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} }
} else { } else {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id); TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id);
if (chat != null) { if (chat != null) {
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
nameTextView.setText(chat.title); nameTextView.setText(chat.title);
avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); avatarImageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
} }
} }
} }

View File

@ -113,7 +113,7 @@ public class StatisticPostInfoCell extends FrameLayout {
public void setData(StatisticActivity.MemberData memberData) { public void setData(StatisticActivity.MemberData memberData) {
avatarDrawable.setInfo(memberData.user); avatarDrawable.setInfo(memberData.user);
imageView.setImage(ImageLocation.getForUser(memberData.user, false), "50_50", avatarDrawable, memberData.user); imageView.setImage(ImageLocation.getForUserOrChat(memberData.user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(memberData.user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, memberData.user);
imageView.setRoundRadius(AndroidUtilities.dp(46) >> 1); imageView.setRoundRadius(AndroidUtilities.dp(46) >> 1);
message.setText(memberData.user.first_name); message.setText(memberData.user.first_name);
date.setText(memberData.description); date.setText(memberData.description);

View File

@ -493,9 +493,9 @@ public class UserCell extends FrameLayout {
lastAvatar = photo; lastAvatar = photo;
if (currentUser != null) { if (currentUser != null) {
avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser); avatarImageView.setImage(ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentUser);
} else if (currentChat != null) { } else if (currentChat != null) {
avatarImageView.setImage(ImageLocation.getForChat(currentChat, false), "50_50", avatarDrawable, currentChat); avatarImageView.setImage(ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentChat);
} else { } else {
avatarImageView.setImageDrawable(avatarDrawable); avatarImageView.setImageDrawable(avatarDrawable);
} }

View File

@ -260,7 +260,7 @@ public class UserCell2 extends FrameLayout {
statusTextView.setText(LocaleController.formatUserStatus(currentAccount, currentUser)); statusTextView.setText(LocaleController.formatUserStatus(currentAccount, currentUser));
} }
} }
avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser); avatarImageView.setImage(ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentUser);
} else if (currentChat != null) { } else if (currentChat != null) {
statusTextView.setTextColor(statusColor); statusTextView.setTextColor(statusColor);
if (ChatObject.isChannel(currentChat) && !currentChat.megagroup) { if (ChatObject.isChannel(currentChat) && !currentChat.megagroup) {
@ -282,7 +282,7 @@ public class UserCell2 extends FrameLayout {
statusTextView.setText(LocaleController.getString("MegaPublic", R.string.MegaPublic)); statusTextView.setText(LocaleController.getString("MegaPublic", R.string.MegaPublic));
} }
} }
avatarImageView.setImage(ImageLocation.getForChat(currentChat, false), "50_50", avatarDrawable, currentObject); avatarImageView.setImage(ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentObject);
} else { } else {
avatarImageView.setImageDrawable(avatarDrawable); avatarImageView.setImageDrawable(avatarDrawable);
} }

View File

@ -27,6 +27,7 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils;
@ -981,8 +982,8 @@ public class ChangePhoneActivity extends BaseFragment {
PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0); PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
String version = String.format(Locale.US, "%s (%d)", pInfo.versionName, pInfo.versionCode); String version = String.format(Locale.US, "%s (%d)", pInfo.versionName, pInfo.versionCode);
Intent mailer = new Intent(Intent.ACTION_SEND); Intent mailer = new Intent(Intent.ACTION_SENDTO);
mailer.setType("message/rfc822"); mailer.setData(Uri.parse("mailto:"));
mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"sms@stel.com"}); mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"sms@stel.com"});
mailer.putExtra(Intent.EXTRA_SUBJECT, "Android registration/login issue " + version + " " + emailPhone); mailer.putExtra(Intent.EXTRA_SUBJECT, "Android registration/login issue " + version + " " + emailPhone);
mailer.putExtra(Intent.EXTRA_TEXT, "Phone: " + requestPhone + "\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault() + "\nError: " + lastError); mailer.putExtra(Intent.EXTRA_TEXT, "Phone: " + requestPhone + "\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault() + "\nError: " + lastError);

View File

@ -2754,7 +2754,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatActionCell.class}, Theme.chat_actionTextPaint, null, null, Theme.key_chat_serviceText)); themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatActionCell.class}, Theme.chat_actionTextPaint, null, null, Theme.key_chat_serviceText));
themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_LINKCOLOR, new Class[]{ChatActionCell.class}, Theme.chat_actionTextPaint, null, null, Theme.key_chat_serviceLink)); themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_LINKCOLOR, new Class[]{ChatActionCell.class}, Theme.chat_actionTextPaint, null, null, Theme.key_chat_serviceLink));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_shareIconDrawable, Theme.chat_botInlineDrawable, Theme.chat_botLinkDrawalbe, Theme.chat_goIconDrawable, Theme.chat_commentStickerDrawable}, null, Theme.key_chat_serviceIcon)); themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_botCardDrawalbe, Theme.chat_shareIconDrawable, Theme.chat_botInlineDrawable, Theme.chat_botLinkDrawalbe, Theme.chat_goIconDrawable, Theme.chat_commentStickerDrawable}, null, Theme.key_chat_serviceIcon));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class, ChatActionCell.class}, null, null, null, Theme.key_chat_serviceBackground)); themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class, ChatActionCell.class}, null, null, null, Theme.key_chat_serviceBackground));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class, ChatActionCell.class}, null, null, null, Theme.key_chat_serviceBackgroundSelected)); themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class, ChatActionCell.class}, null, null, null, Theme.key_chat_serviceBackgroundSelected));

View File

@ -1003,7 +1003,7 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
bundle.putInt("chat_id", chat_id); bundle.putInt("chat_id", chat_id);
bundle.putBoolean("canCreatePublic", canCreatePublic); bundle.putBoolean("canCreatePublic", canCreatePublic);
if (inputPhoto != null || inputVideo != null) { if (inputPhoto != null || inputVideo != null) {
MessagesController.getInstance(currentAccount).changeChatAvatar(chat_id, null, inputPhoto, inputVideo, videoTimestamp, inputVideoPath, avatar, avatarBig); MessagesController.getInstance(currentAccount).changeChatAvatar(chat_id, null, inputPhoto, inputVideo, videoTimestamp, inputVideoPath, avatar, avatarBig, null);
} }
presentFragment(new ChannelCreateActivity(bundle), true); presentFragment(new ChannelCreateActivity(bundle), true);
} }

View File

@ -737,6 +737,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean invalidateMessagesVisiblePart; private boolean invalidateMessagesVisiblePart;
private boolean scrollByTouch; private boolean scrollByTouch;
private PinchToZoomHelper pinchToZoomHelper;
public float getChatListViewPadding() { public float getChatListViewPadding() {
return chatListViewPaddingTop; return chatListViewPaddingTop;
} }
@ -1666,6 +1668,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (chatListItemAnimator != null) { if (chatListItemAnimator != null) {
chatListItemAnimator.onDestroy(); chatListItemAnimator.onDestroy();
} }
if (pinchToZoomHelper != null) {
pinchToZoomHelper.clear();
}
} }
@Override @Override
@ -1824,8 +1829,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
alert.setDelegate(new ClearHistoryAlert.ClearHistoryAlertDelegate() { alert.setDelegate(new ClearHistoryAlert.ClearHistoryAlertDelegate() {
@Override @Override
public void onClearHistory(boolean revoke) { public void onClearHistory(boolean revoke) {
if (revoke && currentUser != null) {
getMessagesStorage().getMessagesCount(currentUser.id, (count) -> {
if (count >= 50) {
AlertsCreator.createClearOrDeleteDialogAlert(ChatActivity.this, true, false, true, null, currentUser, false, false, (param) -> {
performHistoryClear(true);
});
} else {
performHistoryClear(true);
}
});
} else {
performHistoryClear(revoke); performHistoryClear(revoke);
} }
}
@Override @Override
public void onAutoDeleteHistory(int ttl, int action) { public void onAutoDeleteHistory(int ttl, int action) {
@ -1960,6 +1977,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
avatarContainer.onDestroy(); avatarContainer.onDestroy();
} }
avatarContainer = new ChatAvatarContainer(context, this, currentEncryptedChat != null); avatarContainer = new ChatAvatarContainer(context, this, currentEncryptedChat != null);
AndroidUtilities.updateViewVisibilityAnimated(avatarContainer, true, 1f, false);
if (inPreviewMode || inBubbleMode) { if (inPreviewMode || inBubbleMode) {
avatarContainer.setOccupyStatusBar(false); avatarContainer.setOccupyStatusBar(false);
} }
@ -2401,6 +2419,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
} }
if (pinchToZoomHelper.isInOverlayMode()) {
return pinchToZoomHelper.onTouchEvent(ev);
}
if (AvatarPreviewer.hasVisibleInstance()) { if (AvatarPreviewer.hasVisibleInstance()) {
AvatarPreviewer.getInstance().onTouchEvent(ev); AvatarPreviewer.getInstance().onTouchEvent(ev);
return true; return true;
@ -5566,6 +5588,26 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return; return;
} }
TLRPC.BotInlineResult result = (TLRPC.BotInlineResult) object; TLRPC.BotInlineResult result = (TLRPC.BotInlineResult) object;
if (currentEncryptedChat != null) {
int error = 0;
if (result.send_message instanceof TLRPC.TL_botInlineMessageMediaAuto && "game".equals(result.type)) {
error = 1;
} else if (result.send_message instanceof TLRPC.TL_botInlineMessageMediaInvoice) {
error = 2;
}
if (error != 0) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle));
if (error == 1) {
builder.setMessage(LocaleController.getString("GameCantSendSecretChat", R.string.GameCantSendSecretChat));
} else {
builder.setMessage(LocaleController.getString("InvoiceCantSendSecretChat", R.string.InvoiceCantSendSecretChat));
}
builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), null);
showDialog(builder.create());
return;
}
}
if ((result.type.equals("photo") && (result.photo != null || result.content != null) || if ((result.type.equals("photo") && (result.photo != null || result.content != null) ||
result.type.equals("gif") && (result.document != null || result.content != null) || result.type.equals("gif") && (result.document != null || result.content != null) ||
result.type.equals("video") && (result.document != null/* || result.content_url != null*/))) { result.type.equals("video") && (result.document != null/* || result.content_url != null*/))) {
@ -5743,7 +5785,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
}); });
topUndoView = new UndoView(context, true) { topUndoView = new UndoView(context, this, true) {
@Override @Override
public void didPressUrl(CharacterStyle span) { public void didPressUrl(CharacterStyle span) {
didPressMessageUrl(span, false, null, null); didPressMessageUrl(span, false, null, null);
@ -6362,17 +6404,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
replyLayout.setOnClickListener(v -> { replyLayout.setOnClickListener(v -> {
if (forwardingMessages != null && !forwardingMessages.isEmpty()) { if (forwardingMessages != null && !forwardingMessages.isEmpty()) {
int hasPoll = 0; int hasPoll = 0;
boolean hasInvoice = false;
for (int a = 0, N = forwardingMessages.size(); a < N; a++) { for (int a = 0, N = forwardingMessages.size(); a < N; a++) {
MessageObject messageObject = forwardingMessages.get(a); MessageObject messageObject = forwardingMessages.get(a);
if (hasPoll != 2 && messageObject.isPoll()) { if (messageObject.isPoll()) {
if (hasPoll != 2) {
hasPoll = messageObject.isPublicPoll() ? 2 : 1; hasPoll = messageObject.isPublicPoll() ? 2 : 1;
} }
} else if (messageObject.isInvoice()) {
hasInvoice = true;
}
selectedMessagesIds[0].put(messageObject.getId(), messageObject); selectedMessagesIds[0].put(messageObject.getId(), messageObject);
} }
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putBoolean("onlySelect", true); args.putBoolean("onlySelect", true);
args.putInt("dialogsType", 3); args.putInt("dialogsType", 3);
args.putInt("hasPoll", hasPoll); args.putInt("hasPoll", hasPoll);
args.putBoolean("hasInvoice", hasInvoice);
args.putInt("messagesCount", forwardingMessages.size()); args.putInt("messagesCount", forwardingMessages.size());
DialogsActivity fragment = new DialogsActivity(args); DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate(ChatActivity.this); fragment.setDelegate(ChatActivity.this);
@ -6422,17 +6470,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
builder.setNegativeButton(LocaleController.getString("SelectOtherChat", R.string.SelectOtherChat), (dialogInterface, i) -> { builder.setNegativeButton(LocaleController.getString("SelectOtherChat", R.string.SelectOtherChat), (dialogInterface, i) -> {
if (forwardingMessages != null && !forwardingMessages.isEmpty()) { if (forwardingMessages != null && !forwardingMessages.isEmpty()) {
int hasPoll = 0; int hasPoll = 0;
boolean hasInvoice = false;
for (int a = 0, N = forwardingMessages.size(); a < N; a++) { for (int a = 0, N = forwardingMessages.size(); a < N; a++) {
MessageObject messageObject = forwardingMessages.get(a); MessageObject messageObject = forwardingMessages.get(a);
if (hasPoll != 2 && messageObject.isPoll()) { if (messageObject.isPoll()) {
if (hasPoll != 2) {
hasPoll = messageObject.isPublicPoll() ? 2 : 1; hasPoll = messageObject.isPublicPoll() ? 2 : 1;
} }
} else if (messageObject.isInvoice()) {
hasInvoice = true;
}
selectedMessagesIds[0].put(messageObject.getId(), messageObject); selectedMessagesIds[0].put(messageObject.getId(), messageObject);
} }
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putBoolean("onlySelect", true); args.putBoolean("onlySelect", true);
args.putInt("dialogsType", 3); args.putInt("dialogsType", 3);
args.putInt("hasPoll", hasPoll); args.putInt("hasPoll", hasPoll);
args.putBoolean("hasInvoice", hasInvoice);
args.putInt("messagesCount", forwardingMessages.size()); args.putInt("messagesCount", forwardingMessages.size());
DialogsActivity fragment = new DialogsActivity(args); DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate(ChatActivity.this); fragment.setDelegate(ChatActivity.this);
@ -6911,7 +6965,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
contentView.addView(searchContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 51, Gravity.BOTTOM)); contentView.addView(searchContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 51, Gravity.BOTTOM));
undoView = new UndoView(context); undoView = new UndoView(context, this);
undoView.setAdditionalTranslationY(AndroidUtilities.dp(51)); undoView.setAdditionalTranslationY(AndroidUtilities.dp(51));
contentView.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8)); contentView.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
@ -7006,6 +7060,109 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (replyingMessageObject != null) { if (replyingMessageObject != null) {
chatActivityEnterView.setReplyingMessageObject(replyingMessageObject); chatActivityEnterView.setReplyingMessageObject(replyingMessageObject);
} }
ViewGroup decorView;
if (Build.VERSION.SDK_INT >= 21) {
decorView = (ViewGroup) getParentActivity().getWindow().getDecorView();
} else {
decorView = contentView;
}
pinchToZoomHelper = new PinchToZoomHelper(decorView) {
@Override
protected void drawOverlays(Canvas canvas, float alpha, float parentOffsetX, float parentOffsetY, float clipTop, float clipBottom) {
if (alpha > 0) {
View view = getChild();
if (view instanceof ChatMessageCell) {
ChatMessageCell cell = (ChatMessageCell) view;
int top = (int) Math.max(clipTop, parentOffsetY);
int bottom = (int) Math.min(clipBottom, parentOffsetY + cell.getMeasuredHeight());
AndroidUtilities.rectTmp.set(parentOffsetX, top, parentOffsetX + cell.getMeasuredWidth(), bottom);
canvas.saveLayerAlpha(AndroidUtilities.rectTmp, (int) (255 * alpha), Canvas.ALL_SAVE_FLAG);
canvas.translate(parentOffsetX, parentOffsetY);
cell.drawFromPinchToZoom = true;
cell.drawOverlays(canvas);
if (cell.shouldDrawTimeOnMedia() && cell.getCurrentMessagesGroup() == null) {
cell.drawTime(canvas, 1f, false);
}
cell.drawFromPinchToZoom = false;
canvas.restore();
}
}
}
};
pinchToZoomHelper.setCallback(new PinchToZoomHelper.Callback() {
@Override
public TextureView getCurrentTextureView() {
return videoTextureView;
}
@Override
public void onZoomStarted(MessageObject messageObject) {
chatListView.cancelClickRunnables(true);
chatListView.stopScroll();
if (MediaController.getInstance().isPlayingMessage(messageObject)) {
contentView.removeView(videoPlayerContainer);
videoPlayerContainer = null;
videoTextureView = null;
aspectRatioFrameLayout = null;
}
for (int i = 0; i < chatListView.getChildCount(); i++) {
if (chatListView.getChildAt(i) instanceof ChatMessageCell) {
ChatMessageCell cell = (ChatMessageCell) chatListView.getChildAt(i);
if (cell.getMessageObject().getId() == messageObject.getId()) {
cell.getPhotoImage().setVisible(false, true);
}
}
}
}
@Override
public void onZoomFinished(MessageObject messageObject) {
if (messageObject == null) {
return;
}
if (MediaController.getInstance().isPlayingMessage(messageObject)) {
for (int i = 0; i < chatListView.getChildCount(); i++) {
if (chatListView.getChildAt(i) instanceof ChatMessageCell) {
ChatMessageCell cell = (ChatMessageCell) chatListView.getChildAt(i);
if (cell.getMessageObject().getId() == messageObject.getId()) {
AnimatedFileDrawable animation = cell.getPhotoImage().getAnimation();
if (animation.isRunning()) {
animation.stop();
}
if (animation != null) {
Bitmap bitmap = animation.getAnimatedBitmap();
if (bitmap != null) {
try {
Bitmap src = pinchToZoomHelper.getVideoBitmap(bitmap.getWidth(), bitmap.getHeight());
Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(src, 0, 0, null);
src.recycle();
} catch (Throwable e) {
FileLog.e(e);
}
}
}
}
}
}
createTextureView(true);
MediaController.getInstance().setTextureView(videoTextureView, aspectRatioFrameLayout, videoPlayerContainer, true);
}
chatListView.invalidate();
}
});
pinchToZoomHelper.setClipBoundsListener(new PinchToZoomHelper.ClipBoundsListener() {
@Override
public void getClipTopBottom(float[] topBottom) {
topBottom[1] = chatListView.getBottom();
topBottom[0] = chatListView.getTop() + chatListViewPaddingTop - AndroidUtilities.dp(4);
}
});
return fragmentView; return fragmentView;
} }
@ -7597,6 +7754,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private void openForward() { private void openForward() {
int hasPoll = 0; int hasPoll = 0;
boolean hasInvoice = false;
for (int a = 0; a < 2; a++) { for (int a = 0; a < 2; a++) {
for (int b = 0; b < selectedMessagesIds[a].size(); b++) { for (int b = 0; b < selectedMessagesIds[a].size(); b++) {
MessageObject messageObject = selectedMessagesIds[a].valueAt(b); MessageObject messageObject = selectedMessagesIds[a].valueAt(b);
@ -7605,6 +7763,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (hasPoll == 2) { if (hasPoll == 2) {
break; break;
} }
} else if (messageObject.isInvoice()) {
hasInvoice = true;
} }
} }
if (hasPoll == 2) { if (hasPoll == 2) {
@ -7616,6 +7776,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
args.putInt("dialogsType", 3); args.putInt("dialogsType", 3);
args.putInt("messagesCount", canForwardMessagesCount); args.putInt("messagesCount", canForwardMessagesCount);
args.putInt("hasPoll", hasPoll); args.putInt("hasPoll", hasPoll);
args.putBoolean("hasInvoice", hasInvoice);
DialogsActivity fragment = new DialogsActivity(args); DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate(ChatActivity.this); fragment.setDelegate(ChatActivity.this);
presentFragment(fragment); presentFragment(fragment);
@ -7851,7 +8012,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return; return;
} }
if (chatAttachAlert == null) { if (chatAttachAlert == null) {
chatAttachAlert = new ChatAttachAlert(getParentActivity(), this) { chatAttachAlert = new ChatAttachAlert(getParentActivity(), this, false) {
@Override @Override
public void dismissInternal() { public void dismissInternal() {
if (chatAttachAlert.isShowing()) { if (chatAttachAlert.isShowing()) {
@ -9805,7 +9966,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
private void moveScrollToLastMessage() { private void moveScrollToLastMessage() {
if (chatListView != null && !messages.isEmpty()) { if (chatListView != null && !messages.isEmpty() && !pinchToZoomHelper.isInOverlayMode()) {
chatLayoutManager.scrollToPositionWithOffset(0, 0); chatLayoutManager.scrollToPositionWithOffset(0, 0);
chatListView.stopScroll(); chatListView.stopScroll();
} }
@ -18050,11 +18211,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return; return;
} }
MessageObject message = null; MessageObject message;
if (v instanceof ChatMessageCell) { if (v instanceof ChatMessageCell) {
message = ((ChatMessageCell) v).getMessageObject(); message = ((ChatMessageCell) v).getMessageObject();
} else if (v instanceof ChatActionCell) { } else if (v instanceof ChatActionCell) {
message = ((ChatActionCell) v).getMessageObject(); message = ((ChatActionCell) v).getMessageObject();
} else {
message = null;
} }
if (message == null) { if (message == null) {
return; return;
@ -18072,7 +18235,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (avatarContainer.openSetTimer()) { if (avatarContainer.openSetTimer()) {
return; return;
} }
} else if (message.messageOwner.action instanceof TLRPC.TL_messageActionGroupCall || message.messageOwner.action instanceof TLRPC.TL_messageActionInviteToGroupCall) { } else if (message.messageOwner.action instanceof TLRPC.TL_messageActionPaymentSent && message.replyMessageObject != null && message.replyMessageObject.isInvoice()) {
TLRPC.TL_payments_getPaymentReceipt req = new TLRPC.TL_payments_getPaymentReceipt();
req.msg_id = message.getId();
req.peer = getMessagesController().getInputPeer(message.messageOwner.peer_id);
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response instanceof TLRPC.TL_payments_paymentReceipt) {
presentFragment(new PaymentFormActivity((TLRPC.TL_payments_paymentReceipt) response));
}
}), ConnectionsManager.RequestFlagFailOnServerErrors);
return;
} else if (message.messageOwner.action instanceof TLRPC.TL_messageActionGroupCall || message.messageOwner.action instanceof TLRPC.TL_messageActionInviteToGroupCall || message.messageOwner.action instanceof TLRPC.TL_messageActionGroupCallScheduled) {
if (getParentActivity() == null) { if (getParentActivity() == null) {
return; return;
} }
@ -18080,7 +18253,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (sharedInstance != null) { if (sharedInstance != null) {
if (sharedInstance.groupCall != null && message.messageOwner.action.call.id == sharedInstance.groupCall.call.id) { if (sharedInstance.groupCall != null && message.messageOwner.action.call.id == sharedInstance.groupCall.call.id) {
if (getParentActivity() instanceof LaunchActivity) { if (getParentActivity() instanceof LaunchActivity) {
GroupCallActivity.create((LaunchActivity) getParentActivity(), AccountInstance.getInstance(currentAccount)); GroupCallActivity.create((LaunchActivity) getParentActivity(), AccountInstance.getInstance(currentAccount), null, null, false, null);
} else { } else {
Intent intent = new Intent(getParentActivity(), LaunchActivity.class).setAction("voip_chat"); Intent intent = new Intent(getParentActivity(), LaunchActivity.class).setAction("voip_chat");
intent.putExtra("currentAccount", VoIPService.getSharedInstance().getAccount()); intent.putExtra("currentAccount", VoIPService.getSharedInstance().getAccount());
@ -18093,7 +18266,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return; return;
} else if (fragmentContextView != null && getGroupCall() != null) { } else if (fragmentContextView != null && getGroupCall() != null) {
if (VoIPService.getSharedInstance() != null) { if (VoIPService.getSharedInstance() != null) {
GroupCallActivity.create((LaunchActivity) getParentActivity(), AccountInstance.getInstance(VoIPService.getSharedInstance().getAccount())); GroupCallActivity.create((LaunchActivity) getParentActivity(), AccountInstance.getInstance(VoIPService.getSharedInstance().getAccount()), null, null, false, null);
} else { } else {
ChatObject.Call call = getGroupCall(); ChatObject.Call call = getGroupCall();
if (call == null) { if (call == null) {
@ -19077,6 +19250,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
args.putInt("dialogsType", 3); args.putInt("dialogsType", 3);
args.putInt("messagesCount", forwardingMessageGroup == null ? 1 : forwardingMessageGroup.messages.size()); args.putInt("messagesCount", forwardingMessageGroup == null ? 1 : forwardingMessageGroup.messages.size());
args.putInt("hasPoll", forwardingMessage.isPoll() ? (forwardingMessage.isPublicPoll() ? 2 : 1) : 0); args.putInt("hasPoll", forwardingMessage.isPoll() ? (forwardingMessage.isPublicPoll() ? 2 : 1) : 0);
args.putBoolean("hasInvoice", forwardingMessage.isInvoice());
DialogsActivity fragment = new DialogsActivity(args); DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate(this); fragment.setDelegate(this);
presentFragment(fragment); presentFragment(fragment);
@ -21550,6 +21724,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
fireworksOverlay.start(); fireworksOverlay.start();
fireworksOverlay.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); fireworksOverlay.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} }
@Override
public PinchToZoomHelper getPinchToZoomHelper() {
return pinchToZoomHelper;
}
}); });
if (currentEncryptedChat == null) { if (currentEncryptedChat == null) {
chatMessageCell.setAllowAssistant(true); chatMessageCell.setAllowAssistant(true);
@ -22406,6 +22585,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void onStartAnimation() { public void onStartAnimation() {
super.onStartAnimation(); super.onStartAnimation();
scrollCallbackAnimationIndex = getNotificationCenter().setAnimationInProgress(scrollCallbackAnimationIndex, allowedNotificationsDuringChatListAnimations); scrollCallbackAnimationIndex = getNotificationCenter().setAnimationInProgress(scrollCallbackAnimationIndex, allowedNotificationsDuringChatListAnimations);
if (pinchToZoomHelper.isInOverlayMode()) {
pinchToZoomHelper.finishZoom();
}
} }
@Override @Override
@ -22562,7 +22744,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatActionCell.class}, Theme.chat_actionTextPaint, null, null, Theme.key_chat_serviceText)); themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatActionCell.class}, Theme.chat_actionTextPaint, null, null, Theme.key_chat_serviceText));
themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_LINKCOLOR, new Class[]{ChatActionCell.class}, Theme.chat_actionTextPaint, null, null, Theme.key_chat_serviceLink)); themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_LINKCOLOR, new Class[]{ChatActionCell.class}, Theme.chat_actionTextPaint, null, null, Theme.key_chat_serviceLink));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_shareIconDrawable, Theme.chat_replyIconDrawable, Theme.chat_botInlineDrawable, Theme.chat_botLinkDrawalbe, Theme.chat_goIconDrawable, Theme.chat_commentStickerDrawable}, null, Theme.key_chat_serviceIcon)); themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_botCardDrawalbe, Theme.chat_shareIconDrawable, Theme.chat_replyIconDrawable, Theme.chat_botInlineDrawable, Theme.chat_botLinkDrawalbe, Theme.chat_goIconDrawable, Theme.chat_commentStickerDrawable}, null, Theme.key_chat_serviceIcon));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class, ChatActionCell.class}, null, null, null, Theme.key_chat_serviceBackground)); themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class, ChatActionCell.class}, null, null, null, Theme.key_chat_serviceBackground));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class, ChatActionCell.class}, null, null, null, Theme.key_chat_serviceBackgroundSelected)); themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class, ChatActionCell.class}, null, null, null, Theme.key_chat_serviceBackgroundSelected));

View File

@ -584,7 +584,7 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
setAvatarCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton); setAvatarCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
setAvatarCell.setOnClickListener(v -> imageUpdater.openMenu(avatar != null, () -> { setAvatarCell.setOnClickListener(v -> imageUpdater.openMenu(avatar != null, () -> {
avatar = null; avatar = null;
MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, null, null, null, 0, null, null, null); MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, null, null, null, 0, null, null, null, null);
showAvatarProgress(false, true); showAvatarProgress(false, true);
avatarImage.setImage(null, null, avatarDrawable, currentChat); avatarImage.setImage(null, null, avatarDrawable, currentChat);
}, null)); }, null));
@ -775,7 +775,7 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
blockCell = new TextCell(context); blockCell = new TextCell(context);
blockCell.setBackgroundDrawable(Theme.getSelectorDrawable(false)); blockCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
blockCell.setVisibility(ChatObject.isChannel(currentChat) || currentChat.creator ? View.VISIBLE : View.GONE); blockCell.setVisibility(ChatObject.isChannel(currentChat) || currentChat.creator || ChatObject.hasAdminRights(currentChat) && ChatObject.canChangeChatInfo(currentChat) ? View.VISIBLE : View.GONE);
blockCell.setOnClickListener(v -> { blockCell.setOnClickListener(v -> {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt("chat_id", chatId); args.putInt("chat_id", chatId);
@ -937,8 +937,8 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
boolean hasPhoto; boolean hasPhoto;
if (currentChat.photo != null) { if (currentChat.photo != null) {
avatar = currentChat.photo.photo_small; avatar = currentChat.photo.photo_small;
ImageLocation location = ImageLocation.getForChat(currentChat, false); ImageLocation location = ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_SMALL);
avatarImage.setImage(location, "50_50", avatarDrawable, currentChat); avatarImage.setImage(location, "50_50", ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentChat);
hasPhoto = location != null; hasPhoto = location != null;
} else { } else {
avatarImage.setImageDrawable(avatarDrawable); avatarImage.setImageDrawable(avatarDrawable);
@ -1001,7 +1001,7 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
avatar = smallSize.location; avatar = smallSize.location;
if (photo != null || video != null) { if (photo != null || video != null) {
MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, null, photo, video, videoStartTimestamp, videoPath, smallSize.location, bigSize.location); MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, null, photo, video, videoStartTimestamp, videoPath, smallSize.location, bigSize.location, null);
if (createAfterUpload) { if (createAfterUpload) {
try { try {
if (progressDialog != null && progressDialog.isShowing()) { if (progressDialog != null && progressDialog.isShowing()) {

View File

@ -499,7 +499,7 @@ public class ChatLinkActivity extends BaseFragment implements NotificationCenter
frameLayout2.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 21 : 76), 11, (LocaleController.isRTL ? 76 : 21), 0)); frameLayout2.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 21 : 76), 11, (LocaleController.isRTL ? 76 : 21), 0));
frameLayout2.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 57, 24, 9)); frameLayout2.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 57, 24, 9));
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
imageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); imageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
builder.setPositiveButton(LocaleController.getString("DiscussionLinkGroup", R.string.DiscussionLinkGroup), (dialogInterface, i) -> { builder.setPositiveButton(LocaleController.getString("DiscussionLinkGroup", R.string.DiscussionLinkGroup), (dialogInterface, i) -> {
if (chatFull.hidden_prehistory) { if (chatFull.hidden_prehistory) {
MessagesController.getInstance(currentAccount).toogleChannelInvitesHistory(chat.id, false); MessagesController.getInstance(currentAccount).toogleChannelInvitesHistory(chat.id, false);

View File

@ -514,7 +514,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
if (slowmodeInfoRow == -1 && gigaHeaderRow == -1 || removedUsersRow != -1) { if (slowmodeInfoRow == -1 && gigaHeaderRow == -1 || removedUsersRow != -1) {
participantsDividerRow = rowCount++; participantsDividerRow = rowCount++;
} }
if (ChatObject.canBlockUsers(currentChat)) { if (ChatObject.canBlockUsers(currentChat) && (ChatObject.isChannel(currentChat) || currentChat.creator)) {
addNewRow = rowCount++; addNewRow = rowCount++;
} }
@ -726,6 +726,9 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
} else { } else {
searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search)); searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
} }
if (!(ChatObject.isChannel(currentChat) || currentChat.creator)) {
searchItem.setVisibility(View.GONE);
}
if (type == TYPE_KICKED) { if (type == TYPE_KICKED) {
doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56), LocaleController.getString("Done", R.string.Done)); doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56), LocaleController.getString("Done", R.string.Done));
@ -2109,7 +2112,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
if (type != TYPE_KICKED) { if (type != TYPE_KICKED) {
return; return;
} }
if (!ChatObject.isChannel(currentChat) && selectedSlowmode != initialSlowmode && info != null) { if (currentChat.creator && !ChatObject.isChannel(currentChat) && selectedSlowmode != initialSlowmode && info != null) {
MessagesController.getInstance(currentAccount).convertToMegaGroup(getParentActivity(), chatId, this, param -> { MessagesController.getInstance(currentAccount).convertToMegaGroup(getParentActivity(), chatId, this, param -> {
if (param != 0) { if (param != 0) {
chatId = param; chatId = param;

View File

@ -28,22 +28,28 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Vibrator; import android.os.Vibrator;
import android.provider.Settings; import android.provider.Settings;
import android.text.Editable;
import android.text.Html; import android.text.Html;
import android.text.InputFilter;
import android.text.InputType; import android.text.InputType;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.URLSpan; import android.text.style.URLSpan;
import android.util.Base64; import android.util.Base64;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.HapticFeedbackConstants; import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.ViewOutlineProvider; import android.view.ViewOutlineProvider;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
@ -89,6 +95,7 @@ import org.telegram.ui.ChatActivity;
import org.telegram.ui.Components.voip.VoIPHelper; import org.telegram.ui.Components.voip.VoIPHelper;
import org.telegram.ui.LanguageSelectActivity; import org.telegram.ui.LanguageSelectActivity;
import org.telegram.ui.LaunchActivity; import org.telegram.ui.LaunchActivity;
import org.telegram.ui.LoginActivity;
import org.telegram.ui.NotificationsCustomSettingsActivity; import org.telegram.ui.NotificationsCustomSettingsActivity;
import org.telegram.ui.NotificationsSettingsActivity; import org.telegram.ui.NotificationsSettingsActivity;
import org.telegram.ui.ProfileNotificationsActivity; import org.telegram.ui.ProfileNotificationsActivity;
@ -285,7 +292,7 @@ public class AlertsCreator {
} }
} else if (request instanceof TLRPC.TL_account_sendChangePhoneCode) { } else if (request instanceof TLRPC.TL_account_sendChangePhoneCode) {
if (error.text.contains("PHONE_NUMBER_INVALID")) { if (error.text.contains("PHONE_NUMBER_INVALID")) {
showSimpleAlert(fragment, LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber)); LoginActivity.needShowInvalidAlert(fragment, (String) args[0], false);
} else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
showSimpleAlert(fragment, LocaleController.getString("InvalidCode", R.string.InvalidCode)); showSimpleAlert(fragment, LocaleController.getString("InvalidCode", R.string.InvalidCode));
} else if (error.text.contains("PHONE_CODE_EXPIRED")) { } else if (error.text.contains("PHONE_CODE_EXPIRED")) {
@ -294,6 +301,8 @@ public class AlertsCreator {
showSimpleAlert(fragment, LocaleController.getString("FloodWait", R.string.FloodWait)); showSimpleAlert(fragment, LocaleController.getString("FloodWait", R.string.FloodWait));
} else if (error.text.startsWith("PHONE_NUMBER_OCCUPIED")) { } else if (error.text.startsWith("PHONE_NUMBER_OCCUPIED")) {
showSimpleAlert(fragment, LocaleController.formatString("ChangePhoneNumberOccupied", R.string.ChangePhoneNumberOccupied, args[0])); showSimpleAlert(fragment, LocaleController.formatString("ChangePhoneNumberOccupied", R.string.ChangePhoneNumberOccupied, args[0]));
} else if (error.text.startsWith("PHONE_NUMBER_BANNED")) {
LoginActivity.needShowInvalidAlert(fragment, (String) args[0], true);
} else { } else {
showSimpleAlert(fragment, LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred)); showSimpleAlert(fragment, LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred));
} }
@ -837,10 +846,26 @@ public class AlertsCreator {
} }
} }
} }
if (callback != null) { if (callback != null) {
callback.run(i); callback.run(i);
} }
builder.getDismissRunnable().run(); builder.getDismissRunnable().run();
int setting = -1;
if (i == 0) {
setting = NotificationsController.SETTING_MUTE_UNMUTE;
} else if (i == 1) {
setting = NotificationsController.SETTING_MUTE_HOUR;
} else if (i == 2) {
setting = NotificationsController.SETTING_MUTE_2_DAYS;
} else if (i == 4){
setting = NotificationsController.SETTING_MUTE_FOREVER;
}
if (setting >= 0) {
if (BulletinFactory.canShowBulletin(parentFragment)) {
BulletinFactory.createMuteBulletin(parentFragment, setting).show();
}
}
}); });
} }
builder.setTitle(LocaleController.getString("Notifications", R.string.Notifications)); builder.setTitle(LocaleController.getString("Notifications", R.string.Notifications));
@ -1136,11 +1161,11 @@ public class AlertsCreator {
} else { } else {
avatarDrawable.setSmallSize(false); avatarDrawable.setSmallSize(false);
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} }
} else { } else {
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
imageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); imageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
} }
messageTextView.setText(AndroidUtilities.replaceTags(message)); messageTextView.setText(AndroidUtilities.replaceTags(message));
@ -1304,11 +1329,11 @@ public class AlertsCreator {
} else { } else {
avatarDrawable.setSmallSize(false); avatarDrawable.setSmallSize(false);
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} }
} else { } else {
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
imageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); imageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
} }
if (second) { if (second) {
@ -1474,7 +1499,7 @@ public class AlertsCreator {
BackupImageView imageView = new BackupImageView(context); BackupImageView imageView = new BackupImageView(context);
imageView.setRoundRadius(AndroidUtilities.dp(20)); imageView.setRoundRadius(AndroidUtilities.dp(20));
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
frameLayout.addView(imageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 22, 5, 22, 0)); frameLayout.addView(imageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 22, 5, 22, 0));
TextView textView = new TextView(context); TextView textView = new TextView(context);
@ -1500,6 +1525,292 @@ public class AlertsCreator {
fragment.showDialog(dialog); fragment.showDialog(dialog);
} }
public static void createChangeBioAlert(String currentBio, int peerId, Context context, int currentAccount) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(peerId > 0 ? LocaleController.getString("UserBio", R.string.UserBio) : LocaleController.getString("DescriptionPlaceholder", R.string.DescriptionPlaceholder));
builder.setMessage(peerId > 0 ? LocaleController.getString("VoipGroupBioEditAlertText", R.string.VoipGroupBioEditAlertText) : LocaleController.getString("DescriptionInfo", R.string.DescriptionInfo));
FrameLayout dialogView = new FrameLayout(context);
dialogView.setClipChildren(false);
if (peerId < 0) {
TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(-peerId);
if (chatFull == null) {
MessagesController.getInstance(currentAccount).loadFullChat(-peerId, ConnectionsManager.generateClassGuid(), true);
}
}
NumberTextView checkTextView = new NumberTextView(context);
EditText editTextView = new EditText(context);
editTextView.setTextColor(Theme.getColor(Theme.key_voipgroup_actionBarItems));
editTextView.setHint(peerId > 0 ? LocaleController.getString("UserBio", R.string.UserBio) : LocaleController.getString("DescriptionPlaceholder", R.string.DescriptionPlaceholder));
editTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
editTextView.setBackground(Theme.createEditTextDrawable(context, true));
editTextView.setMaxLines(4);
editTextView.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
editTextView.setImeOptions(EditorInfo.IME_ACTION_DONE);
InputFilter[] inputFilters = new InputFilter[1];
int maxSymbolsCount = peerId > 0 ? 70 : 255;
inputFilters[0] = new CodepointsLengthInputFilter(maxSymbolsCount) {
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
CharSequence result = super.filter(source, start, end, dest, dstart, dend);
if (result != null && source != null && result.length() != source.length()) {
Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
if (v != null) {
v.vibrate(200);
}
AndroidUtilities.shakeView(checkTextView, 2, 0);
}
return result;
}
};
editTextView.setFilters(inputFilters);
checkTextView.setCenterAlign(true);
checkTextView.setTextSize(15);
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText4));
checkTextView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
dialogView.addView(checkTextView, LayoutHelper.createFrame(20, 20, LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT, 0, 14, 21, 0));
editTextView.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(24) : 0, AndroidUtilities.dp(8), LocaleController.isRTL ? 0 : AndroidUtilities.dp(24), AndroidUtilities.dp(8));
editTextView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable s) {
int count = maxSymbolsCount - Character.codePointCount(s, 0, s.length());
if (count < 30) {
checkTextView.setNumber(count, checkTextView.getVisibility() == View.VISIBLE);
AndroidUtilities.updateViewVisibilityAnimated(checkTextView, true);
} else {
AndroidUtilities.updateViewVisibilityAnimated(checkTextView, false);
}
}
});
AndroidUtilities.updateViewVisibilityAnimated(checkTextView, false, 0, false);
editTextView.setText(currentBio);
editTextView.setSelection(editTextView.getText().toString().length());
builder.setView(dialogView);
DialogInterface.OnClickListener onDoneListener = (dialogInterface, i) -> {
if (peerId > 0) {
final TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(UserConfig.getInstance(currentAccount).getClientUserId());
final String newName = editTextView.getText().toString().replace("\n", " ").replaceAll(" +", " ").trim();
if (userFull != null) {
String currentName = userFull.about;
if (currentName == null) {
currentName = "";
}
if (currentName.equals(newName)) {
AndroidUtilities.hideKeyboard(editTextView);
dialogInterface.dismiss();
return;
}
userFull.about = newName;
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.userInfoDidLoad, peerId, userFull);
}
final TLRPC.TL_account_updateProfile req = new TLRPC.TL_account_updateProfile();
req.about = newName;
req.flags |= 4;
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_BIO_CHANGED, peerId);
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
}, ConnectionsManager.RequestFlagFailOnServerErrors);
} else {
TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(-peerId);
final String newAbout = editTextView.getText().toString();
if (chatFull != null) {
String currentName = chatFull.about;
if (currentName == null) {
currentName = "";
}
if (currentName.equals(newAbout)) {
AndroidUtilities.hideKeyboard(editTextView);
dialogInterface.dismiss();
return;
}
chatFull.about = newAbout;
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.chatInfoDidLoad, chatFull, 0, false, false);
}
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_BIO_CHANGED, peerId);
MessagesController.getInstance(currentAccount).updateChatAbout(-peerId, newAbout, chatFull);
}
dialogInterface.dismiss();
};
builder.setPositiveButton(LocaleController.getString("Save", R.string.Save), onDoneListener);
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
builder.setOnPreDismissListener(dialogInterface -> AndroidUtilities.hideKeyboard(editTextView));
dialogView.addView(editTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 23, 12, 23, 21));
editTextView.requestFocus();
AndroidUtilities.showKeyboard(editTextView);
AlertDialog dialog = builder.create();
editTextView.setOnEditorActionListener((textView, i, keyEvent) -> {
if ((i == EditorInfo.IME_ACTION_DONE || (peerId > 0 && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER)) && dialog.isShowing()) {
onDoneListener.onClick(dialog, 0);
return true;
}
return false;
});
dialog.setBackgroundColor(Theme.getColor(Theme.key_voipgroup_dialogBackground));
dialog.show();
dialog.setTextColor(Theme.getColor(Theme.key_voipgroup_actionBarItems));
}
public static void createChangeNameAlert(int peerId, Context context, int currentAccount) {
String currentName;
String currentLastName = null;
if (peerId > 0) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(peerId);
currentName = user.first_name;
currentLastName = user.last_name;
} else {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-peerId);
currentName = chat.title;
}
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(peerId > 0 ? LocaleController.getString("VoipEditName", R.string.VoipEditName) : LocaleController.getString("VoipEditTitle", R.string.VoipEditTitle));
LinearLayout dialogView = new LinearLayout(context);
dialogView.setOrientation(LinearLayout.VERTICAL);
EditText firstNameEditTextView = new EditText(context);
firstNameEditTextView.setTextColor(Theme.getColor(Theme.key_voipgroup_actionBarItems));
firstNameEditTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
firstNameEditTextView.setMaxLines(1);
firstNameEditTextView.setLines(1);
firstNameEditTextView.setSingleLine(true);
firstNameEditTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
firstNameEditTextView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
firstNameEditTextView.setImeOptions(peerId > 0 ? EditorInfo.IME_ACTION_NEXT : EditorInfo.IME_ACTION_DONE);
firstNameEditTextView.setHint(peerId > 0 ? LocaleController.getString("FirstName", R.string.FirstName) : LocaleController.getString("VoipEditTitleHint", R.string.VoipEditTitleHint));
firstNameEditTextView.setBackground(Theme.createEditTextDrawable(context, true));
firstNameEditTextView.setPadding(0, AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8));
firstNameEditTextView.requestFocus();
EditText lastNameEditTextView = null;
if (peerId > 0) {
lastNameEditTextView = new EditText(context);
lastNameEditTextView.setTextColor(Theme.getColor(Theme.key_voipgroup_actionBarItems));
lastNameEditTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
lastNameEditTextView.setMaxLines(1);
lastNameEditTextView.setLines(1);
lastNameEditTextView.setSingleLine(true);
lastNameEditTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
lastNameEditTextView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
lastNameEditTextView.setImeOptions(EditorInfo.IME_ACTION_DONE);
lastNameEditTextView.setHint(LocaleController.getString("LastName", R.string.LastName));
lastNameEditTextView.setBackground(Theme.createEditTextDrawable(context, true));
lastNameEditTextView.setPadding(0, AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8));
}
AndroidUtilities.showKeyboard(firstNameEditTextView);
dialogView.addView(firstNameEditTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 23, 12, 23, 21));
if (lastNameEditTextView != null) {
dialogView.addView(lastNameEditTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 23, 12, 23, 21));
}
firstNameEditTextView.setText(currentName);
firstNameEditTextView.setSelection(firstNameEditTextView.getText().toString().length());
if (lastNameEditTextView != null) {
lastNameEditTextView.setText(currentLastName);
lastNameEditTextView.setSelection(lastNameEditTextView.getText().toString().length());
}
builder.setView(dialogView);
EditText finalLastNameEditTextView = lastNameEditTextView;
DialogInterface.OnClickListener onDoneListener = (dialogInterface, i) -> {
if (firstNameEditTextView.getText() == null) {
return;
}
if (peerId > 0) {
TLRPC.User currentUser = MessagesController.getInstance(currentAccount).getUser(peerId);
String newFirst = firstNameEditTextView.getText().toString();
String newLast = finalLastNameEditTextView.getText().toString();
String oldFirst = currentUser.first_name;
String oldLast = currentUser.last_name;
if (oldFirst == null) {
oldFirst = "";
}
if (oldLast == null) {
oldLast = "";
}
if (oldFirst.equals(newFirst) && oldLast.equals(newLast)) {
dialogInterface.dismiss();
return;
}
TLRPC.TL_account_updateProfile req = new TLRPC.TL_account_updateProfile();
req.flags = 3;
currentUser.first_name = req.first_name = newFirst;
currentUser.last_name = req.last_name = newLast;
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
if (user != null) {
user.first_name = req.first_name;
user.last_name = req.last_name;
}
UserConfig.getInstance(currentAccount).saveConfig(true);
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
});
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_NAME_CHANGED, peerId);
} else {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-peerId);
String newFirst = firstNameEditTextView.getText().toString();
if (chat.title != null && chat.title.equals(newFirst)) {
dialogInterface.dismiss();
return;
}
chat.title = newFirst;
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_CHAT_NAME);
MessagesController.getInstance(currentAccount).changeChatTitle(-peerId, newFirst);
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_NAME_CHANGED, peerId);
}
dialogInterface.dismiss();
};
builder.setPositiveButton(LocaleController.getString("Save", R.string.Save), onDoneListener);
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
builder.setOnPreDismissListener(dialogInterface -> {
AndroidUtilities.hideKeyboard(firstNameEditTextView);
AndroidUtilities.hideKeyboard(finalLastNameEditTextView);
});
AlertDialog dialog = builder.create();
dialog.setBackgroundColor(Theme.getColor(Theme.key_voipgroup_dialogBackground));
dialog.show();
dialog.setTextColor(Theme.getColor(Theme.key_voipgroup_actionBarItems));
TextView.OnEditorActionListener actionListener = (textView, i, keyEvent) -> {
if ((i == EditorInfo.IME_ACTION_DONE || keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) && dialog.isShowing()) {
onDoneListener.onClick(dialog, 0);
return true;
}
return false;
};
if (lastNameEditTextView != null) {
lastNameEditTextView.setOnEditorActionListener(actionListener);
} else {
firstNameEditTextView.setOnEditorActionListener(actionListener);
}
}
public interface BlockDialogCallback { public interface BlockDialogCallback {
void run(boolean report, boolean delete); void run(boolean report, boolean delete);
} }
@ -1640,16 +1951,28 @@ public class AlertsCreator {
return builder; return builder;
} }
private static boolean checkScheduleDate(TextView button, boolean reminder, NumberPicker dayPicker, NumberPicker hourPicker, NumberPicker minutePicker) { public static boolean checkScheduleDate(TextView button, TextView infoText, int type, NumberPicker dayPicker, NumberPicker hourPicker, NumberPicker minutePicker) {
return checkScheduleDate(button, infoText, 0, type, dayPicker, hourPicker, minutePicker);
}
public static boolean checkScheduleDate(TextView button, TextView infoText, long maxDate, int type, NumberPicker dayPicker, NumberPicker hourPicker, NumberPicker minutePicker) {
int day = dayPicker.getValue(); int day = dayPicker.getValue();
int hour = hourPicker.getValue(); int hour = hourPicker.getValue();
int minute = minutePicker.getValue(); int minute = minutePicker.getValue();
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
long systemTime = System.currentTimeMillis(); long systemTime = System.currentTimeMillis();
calendar.setTimeInMillis(systemTime); calendar.setTimeInMillis(systemTime);
int currentYear = calendar.get(Calendar.YEAR); int currentYear = calendar.get(Calendar.YEAR);
int currentDay = calendar.get(Calendar.DAY_OF_YEAR); int currentDay = calendar.get(Calendar.DAY_OF_YEAR);
if (maxDate > 0) {
maxDate *= 1000;
calendar.setTimeInMillis(systemTime + maxDate);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
maxDate = calendar.getTimeInMillis();
}
calendar.setTimeInMillis(System.currentTimeMillis() + (long) day * 24 * 3600 * 1000); calendar.setTimeInMillis(System.currentTimeMillis() + (long) day * 24 * 3600 * 1000);
calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.HOUR_OF_DAY, hour);
@ -1658,11 +1981,18 @@ public class AlertsCreator {
if (currentTime <= systemTime + 60000L) { if (currentTime <= systemTime + 60000L) {
calendar.setTimeInMillis(systemTime + 60000L); calendar.setTimeInMillis(systemTime + 60000L);
if (currentDay != calendar.get(Calendar.DAY_OF_YEAR)) { if (currentDay != calendar.get(Calendar.DAY_OF_YEAR)) {
dayPicker.setValue(day = 1); dayPicker.setValue(day = 1);
} }
hourPicker.setValue(hour = calendar.get(Calendar.HOUR_OF_DAY)); hourPicker.setValue(hour = calendar.get(Calendar.HOUR_OF_DAY));
minutePicker.setValue(minute = calendar.get(Calendar.MINUTE)); minutePicker.setValue(minute = calendar.get(Calendar.MINUTE));
} else if (maxDate > 0 && currentTime > maxDate) {
calendar.setTimeInMillis(maxDate);
dayPicker.setValue(day = 7);
hourPicker.setValue(hour = calendar.get(Calendar.HOUR_OF_DAY));
minutePicker.setValue(minute = calendar.get(Calendar.MINUTE));
} }
int selectedYear = calendar.get(Calendar.YEAR); int selectedYear = calendar.get(Calendar.YEAR);
@ -1670,8 +2000,8 @@ public class AlertsCreator {
calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.MINUTE, minute);
if (button != null) {
long time = calendar.getTimeInMillis(); long time = calendar.getTimeInMillis();
if (button != null) {
int num; int num;
if (day == 0) { if (day == 0) {
num = 0; num = 0;
@ -1680,11 +2010,33 @@ public class AlertsCreator {
} else { } else {
num = 2; num = 2;
} }
if (reminder) { if (type == 1) {
num += 3; num += 3;
} else if (type == 2) {
num += 6;
} else if (type == 3) {
num += 9;
} }
button.setText(LocaleController.getInstance().formatterScheduleSend[num].format(time)); button.setText(LocaleController.getInstance().formatterScheduleSend[num].format(time));
} }
if (infoText != null) {
int diff = (int) ((time - systemTime) / 1000);
String t;
if (diff > 24 * 60 * 60) {
t = LocaleController.formatPluralString("DaysSchedule", diff / (24 * 60 * 60));
} else if (diff >= 60 * 60) {
t = LocaleController.formatPluralString("HoursSchedule", diff / (60 * 60));
} else if (diff >= 60) {
t = LocaleController.formatPluralString("MinutesSchedule", diff / 60);
} else {
t = LocaleController.formatPluralString("SecondsSchedule", diff);
}
if (infoText.getTag() != null) {
infoText.setText(LocaleController.formatString("VoipGroupScheduleInfo", R.string.VoipGroupScheduleInfo, t));
} else {
infoText.setText(LocaleController.formatString("VoipChannelScheduleInfo", R.string.VoipChannelScheduleInfo, t));
}
}
return currentTime - systemTime > 60000L; return currentTime - systemTime > 60000L;
} }
@ -1892,7 +2244,7 @@ public class AlertsCreator {
} catch (Exception ignore) { } catch (Exception ignore) {
} }
checkScheduleDate(buttonTextView, selfUserId == dialogId, dayPicker, hourPicker, minutePicker); checkScheduleDate(buttonTextView, null, selfUserId == dialogId ? 1 : 0, dayPicker, hourPicker, minutePicker);
}; };
dayPicker.setOnValueChangedListener(onValueChangeListener); dayPicker.setOnValueChangedListener(onValueChangeListener);
@ -1926,7 +2278,7 @@ public class AlertsCreator {
} }
final boolean[] canceled = {true}; final boolean[] canceled = {true};
checkScheduleDate(buttonTextView, selfUserId == dialogId, dayPicker, hourPicker, minutePicker); checkScheduleDate(buttonTextView, null, selfUserId == dialogId ? 1 : 0, dayPicker, hourPicker, minutePicker);
buttonTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0); buttonTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0);
buttonTextView.setGravity(Gravity.CENTER); buttonTextView.setGravity(Gravity.CENTER);
@ -1937,7 +2289,7 @@ public class AlertsCreator {
container.addView(buttonTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM, 16, 15, 16, 16)); container.addView(buttonTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM, 16, 15, 16, 16));
buttonTextView.setOnClickListener(v -> { buttonTextView.setOnClickListener(v -> {
canceled[0] = false; canceled[0] = false;
boolean setSeconds = checkScheduleDate(null, selfUserId == dialogId, dayPicker, hourPicker, minutePicker); boolean setSeconds = checkScheduleDate(null, null, selfUserId == dialogId ? 1 : 0, dayPicker, hourPicker, minutePicker);
calendar.setTimeInMillis(System.currentTimeMillis() + (long) dayPicker.getValue() * 24 * 3600 * 1000); calendar.setTimeInMillis(System.currentTimeMillis() + (long) dayPicker.getValue() * 24 * 3600 * 1000);
calendar.set(Calendar.HOUR_OF_DAY, hourPicker.getValue()); calendar.set(Calendar.HOUR_OF_DAY, hourPicker.getValue());
calendar.set(Calendar.MINUTE, minutePicker.getValue()); calendar.set(Calendar.MINUTE, minutePicker.getValue());
@ -2078,7 +2430,7 @@ public class AlertsCreator {
} catch (Exception ignore) { } catch (Exception ignore) {
} }
checkScheduleDate(null, false, dayPicker, hourPicker, minutePicker); checkScheduleDate(null, null, 0, dayPicker, hourPicker, minutePicker);
}; };
dayPicker.setOnValueChangedListener(onValueChangeListener); dayPicker.setOnValueChangedListener(onValueChangeListener);
@ -2110,9 +2462,8 @@ public class AlertsCreator {
dayPicker.setValue(days); dayPicker.setValue(days);
} }
} }
final boolean[] canceled = {true};
checkScheduleDate(null, false, dayPicker, hourPicker, minutePicker); checkScheduleDate(null, null, 0, dayPicker, hourPicker, minutePicker);
buttonTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0); buttonTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0);
buttonTextView.setGravity(Gravity.CENTER); buttonTextView.setGravity(Gravity.CENTER);
@ -2123,8 +2474,7 @@ public class AlertsCreator {
buttonTextView.setText(LocaleController.getString("SetTimeLimit", R.string.SetTimeLimit)); buttonTextView.setText(LocaleController.getString("SetTimeLimit", R.string.SetTimeLimit));
container.addView(buttonTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM, 16, 15, 16, 16)); container.addView(buttonTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM, 16, 15, 16, 16));
buttonTextView.setOnClickListener(v -> { buttonTextView.setOnClickListener(v -> {
canceled[0] = false; boolean setSeconds = checkScheduleDate(null, null, 0, dayPicker, hourPicker, minutePicker);
boolean setSeconds = checkScheduleDate(null, false, dayPicker, hourPicker, minutePicker);
calendar.setTimeInMillis(System.currentTimeMillis() + (long) dayPicker.getValue() * 24 * 3600 * 1000); calendar.setTimeInMillis(System.currentTimeMillis() + (long) dayPicker.getValue() * 24 * 3600 * 1000);
calendar.set(Calendar.HOUR_OF_DAY, hourPicker.getValue()); calendar.set(Calendar.HOUR_OF_DAY, hourPicker.getValue());
calendar.set(Calendar.MINUTE, minutePicker.getValue()); calendar.set(Calendar.MINUTE, minutePicker.getValue());
@ -3011,7 +3361,7 @@ public class AlertsCreator {
BackupImageView imageView = new BackupImageView(activity); BackupImageView imageView = new BackupImageView(activity);
imageView.setRoundRadius(AndroidUtilities.dp(26)); imageView.setRoundRadius(AndroidUtilities.dp(26));
imageView.setImage(ImageLocation.getForUser(selfUser, false), "50_50", (Drawable) null, selfUser); imageView.setImage(ImageLocation.getForUserOrChat(selfUser, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(selfUser, ImageLocation.TYPE_STRIPPED), "50_50", (Drawable) null, selfUser);
frameLayout.addView(imageView, LayoutHelper.createFrame(52, 52, Gravity.CENTER, 0, 0, 0, 11)); frameLayout.addView(imageView, LayoutHelper.createFrame(52, 52, Gravity.CENTER, 0, 0, 0, 11));
builder.setTopView(frameLayout); builder.setTopView(frameLayout);

View File

@ -234,9 +234,9 @@ public class AvatarsImageView extends FrameLayout {
animatingStates[index].id = -currentChat.id; animatingStates[index].id = -currentChat.id;
} }
if (currentUser != null) { if (currentUser != null) {
animatingStates[index].imageReceiver.setImage(ImageLocation.getForUser(currentUser, false), "50_50", animatingStates[index].avatarDrawable, null, currentUser, 0); animatingStates[index].imageReceiver.setImage(ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_STRIPPED), "50_50", animatingStates[index].avatarDrawable, currentUser, 0);
} else { } else {
animatingStates[index].imageReceiver.setImage(ImageLocation.getForChat(currentChat, false), "50_50", animatingStates[index].avatarDrawable, null, currentChat, 0); animatingStates[index].imageReceiver.setImage(ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentChat, ImageLocation.TYPE_STRIPPED), "50_50", animatingStates[index].avatarDrawable, currentChat, 0);
} }
animatingStates[index].imageReceiver.setRoundRadius(AndroidUtilities.dp(currentStyle == 4 ? 16 : 12)); animatingStates[index].imageReceiver.setRoundRadius(AndroidUtilities.dp(currentStyle == 4 ? 16 : 12));
int size = AndroidUtilities.dp(currentStyle == 4 ? 32 : 24); int size = AndroidUtilities.dp(currentStyle == 4 ? 32 : 24);

View File

@ -61,6 +61,8 @@ public final class Bulletin {
public static final int TYPE_STICKER = 0; public static final int TYPE_STICKER = 0;
public static final int TYPE_ERROR = 1; public static final int TYPE_ERROR = 1;
public static final int TYPE_BIO_CHANGED = 2;
public static final int TYPE_NAME_CHANGED = 3;
public static Bulletin make(@NonNull FrameLayout containerLayout, @NonNull Layout contentLayout, int duration) { public static Bulletin make(@NonNull FrameLayout containerLayout, @NonNull Layout contentLayout, int duration) {
return new Bulletin(containerLayout, contentLayout, duration); return new Bulletin(containerLayout, contentLayout, duration);
@ -1031,6 +1033,7 @@ public final class Bulletin {
textView.setTypeface(Typeface.SANS_SERIF); textView.setTypeface(Typeface.SANS_SERIF);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
textView.setEllipsize(TextUtils.TruncateAt.END); textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setPadding(0, AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8));
addView(textView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 56, 0, 16, 0)); addView(textView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 56, 0, 16, 0));
} }

View File

@ -116,6 +116,8 @@ public final class BulletinFactory {
final Bulletin.LottieLayout layout = new Bulletin.LottieLayout(getContext()); final Bulletin.LottieLayout layout = new Bulletin.LottieLayout(getContext());
layout.setAnimation(iconRawId, 36, 36); layout.setAnimation(iconRawId, 36, 36);
layout.textView.setText(text); layout.textView.setText(text);
layout.textView.setSingleLine(false);
layout.textView.setMaxLines(2);
return create(layout, Bulletin.DURATION_SHORT); return create(layout, Bulletin.DURATION_SHORT);
} }

View File

@ -49,6 +49,7 @@ import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.text.style.ImageSpan; import android.text.style.ImageSpan;
import android.util.Log;
import android.util.Property; import android.util.Property;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.ActionMode; import android.view.ActionMode;
@ -3457,7 +3458,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
showKeyboardOnResume = true; showKeyboardOnResume = true;
} }
AndroidUtilities.runOnUIThread(hideKeyboardRunnable = () -> { AndroidUtilities.runOnUIThread(hideKeyboardRunnable = () -> {
if (parentFragment == null || parentFragment.isLastFragment()) {
closeKeyboard(); closeKeyboard();
}
hideKeyboardRunnable = null; hideKeyboardRunnable = null;
}, 500); }, 500);
} }
@ -4819,7 +4822,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
slideText.setTranslationX(0); slideText.setTranslationX(0);
recordCircle.showTooltipIfNeed(); recordCircle.showTooltipIfNeed();
messageEditText.setVisibility(View.GONE); messageEditText.setAlpha(0f);
} }
}); });
runningAnimationAudio.setInterpolator(new DecelerateInterpolator()); runningAnimationAudio.setInterpolator(new DecelerateInterpolator());

View File

@ -391,6 +391,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
private Paint attachButtonPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private Paint attachButtonPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private float bottomPannelTranslation; private float bottomPannelTranslation;
private boolean forceDarkTheme;
private class AttachButton extends FrameLayout { private class AttachButton extends FrameLayout {
@ -552,7 +553,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
currentUser = user; currentUser = user;
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name)); nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); imageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
requestLayout(); requestLayout();
} }
} }
@ -563,8 +564,9 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
float currentPanTranslationY; float currentPanTranslationY;
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
public ChatAttachAlert(Context context, final BaseFragment parentFragment) { public ChatAttachAlert(Context context, final BaseFragment parentFragment, boolean forceDarkTheme) {
super(context, false); super(context, false);
this.forceDarkTheme = forceDarkTheme;
drawNavigationBar = true; drawNavigationBar = true;
inBubbleMode = parentFragment instanceof ChatActivity && parentFragment.isInBubbleMode(); inBubbleMode = parentFragment instanceof ChatActivity && parentFragment.isInBubbleMode();
openInterpolator = new OvershootInterpolator(0.7f); openInterpolator = new OvershootInterpolator(0.7f);
@ -896,8 +898,9 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
shadowDrawable.setAlpha(viewAlpha); shadowDrawable.setAlpha(viewAlpha);
shadowDrawable.setBounds(0, top, getMeasuredWidth(), height); shadowDrawable.setBounds(0, top, getMeasuredWidth(), height);
shadowDrawable.draw(canvas); shadowDrawable.draw(canvas);
int backgroundColor = Theme.getColor(forceDarkTheme ? Theme.key_voipgroup_listViewBackground : Theme.key_dialogBackground);
if (actionBarType == 2) { if (actionBarType == 2) {
Theme.dialogs_onlineCirclePaint.setColor(Theme.getColor(Theme.key_dialogBackground)); Theme.dialogs_onlineCirclePaint.setColor(backgroundColor);
Theme.dialogs_onlineCirclePaint.setAlpha(viewAlpha); Theme.dialogs_onlineCirclePaint.setAlpha(viewAlpha);
rect.set(backgroundPaddingLeft, backgroundPaddingTop + top, getMeasuredWidth() - backgroundPaddingLeft, backgroundPaddingTop + top + AndroidUtilities.dp(24)); rect.set(backgroundPaddingLeft, backgroundPaddingTop + top, getMeasuredWidth() - backgroundPaddingLeft, backgroundPaddingTop + top + AndroidUtilities.dp(24));
canvas.save(); canvas.save();
@ -909,7 +912,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
boolean result = super.drawChild(canvas, child, drawingTime); boolean result = super.drawChild(canvas, child, drawingTime);
if (rad != 1.0f && actionBarType != 2) { if (rad != 1.0f && actionBarType != 2) {
Theme.dialogs_onlineCirclePaint.setColor(Theme.getColor(Theme.key_dialogBackground)); Theme.dialogs_onlineCirclePaint.setColor(backgroundColor);
Theme.dialogs_onlineCirclePaint.setAlpha(viewAlpha); Theme.dialogs_onlineCirclePaint.setAlpha(viewAlpha);
rect.set(backgroundPaddingLeft, backgroundPaddingTop + top, getMeasuredWidth() - backgroundPaddingLeft, backgroundPaddingTop + top + AndroidUtilities.dp(24)); rect.set(backgroundPaddingLeft, backgroundPaddingTop + top, getMeasuredWidth() - backgroundPaddingLeft, backgroundPaddingTop + top + AndroidUtilities.dp(24));
canvas.save(); canvas.save();
@ -946,7 +949,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
if (inBubbleMode) { if (inBubbleMode) {
return; return;
} }
int color1 = Theme.getColor(Theme.key_dialogBackground); int color1 = Theme.getColor(forceDarkTheme ? Theme.key_voipgroup_listViewBackground : Theme.key_dialogBackground);
int finalColor = Color.argb((int) (255 * actionBar.getAlpha()), (int) (Color.red(color1) * 0.8f), (int) (Color.green(color1) * 0.8f), (int) (Color.blue(color1) * 0.8f)); int finalColor = Color.argb((int) (255 * actionBar.getAlpha()), (int) (Color.red(color1) * 0.8f), (int) (Color.green(color1) * 0.8f), (int) (Color.blue(color1) * 0.8f));
Theme.dialogs_onlineCirclePaint.setColor(finalColor); Theme.dialogs_onlineCirclePaint.setColor(finalColor);
canvas.drawRect(backgroundPaddingLeft, currentPanTranslationY, getMeasuredWidth() - backgroundPaddingLeft, AndroidUtilities.statusBarHeight + currentPanTranslationY, Theme.dialogs_onlineCirclePaint); canvas.drawRect(backgroundPaddingLeft, currentPanTranslationY, getMeasuredWidth() - backgroundPaddingLeft, AndroidUtilities.statusBarHeight + currentPanTranslationY, Theme.dialogs_onlineCirclePaint);
@ -1162,7 +1165,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
selectedTextView.setVisibility(View.INVISIBLE); selectedTextView.setVisibility(View.INVISIBLE);
selectedTextView.setAlpha(0.0f); selectedTextView.setAlpha(0.0f);
layouts[0] = photoLayout = new ChatAttachAlertPhotoLayout(this, context); layouts[0] = photoLayout = new ChatAttachAlertPhotoLayout(this, context, forceDarkTheme);
currentAttachLayout = photoLayout; currentAttachLayout = photoLayout;
selectedId = 1; selectedId = 1;
containerView.addView(photoLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); containerView.addView(photoLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
@ -1309,7 +1312,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
float alphaOffset = (frameLayout2.getMeasuredHeight() - AndroidUtilities.dp(84)) * (1f - getAlpha()); float alphaOffset = (frameLayout2.getMeasuredHeight() - AndroidUtilities.dp(84)) * (1f - getAlpha());
shadow.setTranslationY(-(frameLayout2.getMeasuredHeight() - AndroidUtilities.dp(84)) + captionEditTextTopOffset + currentPanTranslationY + bottomPannelTranslation + alphaOffset); shadow.setTranslationY(-(frameLayout2.getMeasuredHeight() - AndroidUtilities.dp(84)) + captionEditTextTopOffset + currentPanTranslationY + bottomPannelTranslation + alphaOffset);
int newColor = Theme.getColor(Theme.key_dialogBackground); int newColor = Theme.getColor(forceDarkTheme ? Theme.key_voipgroup_listViewBackground : Theme.key_dialogBackground);
if (color != newColor) { if (color != newColor) {
color = newColor; color = newColor;
p.setColor(color); p.setColor(color);
@ -1688,6 +1691,11 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
selectedCountView.setScaleX(0.2f); selectedCountView.setScaleX(0.2f);
selectedCountView.setScaleY(0.2f); selectedCountView.setScaleY(0.2f);
containerView.addView(selectedCountView, LayoutHelper.createFrame(42, 24, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, -8, 9)); containerView.addView(selectedCountView, LayoutHelper.createFrame(42, 24, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, -8, 9));
if (forceDarkTheme) {
checkColors();
navBarColorKey = null;
}
} }
@Override @Override
@ -2130,18 +2138,18 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
for (int a = 0; a < count; a++) { for (int a = 0; a < count; a++) {
applyAttachButtonColors(buttonsRecyclerView.getChildAt(a)); applyAttachButtonColors(buttonsRecyclerView.getChildAt(a));
} }
selectedTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); selectedTextView.setTextColor(forceDarkTheme ? Theme.getColor(Theme.key_voipgroup_actionBarItems) : Theme.getColor(Theme.key_dialogTextBlack));
doneItem.getTextView().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader)); doneItem.getTextView().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader));
selectedMenuItem.setIconColor(Theme.getColor(Theme.key_dialogTextBlack)); selectedMenuItem.setIconColor(forceDarkTheme ? Theme.getColor(Theme.key_voipgroup_actionBarItems) : Theme.getColor(Theme.key_dialogTextBlack));
Theme.setDrawableColor(selectedMenuItem.getBackground(), Theme.getColor(Theme.key_dialogButtonSelector)); Theme.setDrawableColor(selectedMenuItem.getBackground(), forceDarkTheme ? Theme.getColor(Theme.key_voipgroup_actionBarItemsSelector) : Theme.getColor(Theme.key_dialogButtonSelector));
selectedMenuItem.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), false); selectedMenuItem.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), false);
selectedMenuItem.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), true); selectedMenuItem.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), true);
selectedMenuItem.redrawPopup(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground)); selectedMenuItem.redrawPopup(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));
searchItem.setIconColor(Theme.getColor(Theme.key_dialogTextBlack)); searchItem.setIconColor(forceDarkTheme ? Theme.getColor(Theme.key_voipgroup_actionBarItems) : Theme.getColor(Theme.key_dialogTextBlack));
Theme.setDrawableColor(searchItem.getBackground(), Theme.getColor(Theme.key_dialogButtonSelector)); Theme.setDrawableColor(searchItem.getBackground(), forceDarkTheme ? Theme.getColor(Theme.key_voipgroup_actionBarItemsSelector) : Theme.getColor(Theme.key_dialogButtonSelector));
commentTextView.updateColors(); commentTextView.updateColors();
@ -2149,7 +2157,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
for (int a = 0; a < itemCells.length; a++) { for (int a = 0; a < itemCells.length; a++) {
if (itemCells[a] != null) { if (itemCells[a] != null) {
itemCells[a].setColors(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), Theme.getColor(Theme.key_actionBarDefaultSubmenuItemIcon)); itemCells[a].setColors(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), Theme.getColor(Theme.key_actionBarDefaultSubmenuItemIcon));
itemCells[a].setSelectorColor(Theme.getColor(Theme.key_dialogButtonSelector)); itemCells[a].setSelectorColor(forceDarkTheme ? Theme.getColor(Theme.key_voipgroup_actionBarItemsSelector) : Theme.getColor(Theme.key_dialogButtonSelector));
} }
} }
sendPopupLayout.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground)); sendPopupLayout.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));
@ -2165,18 +2173,18 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
actionBarShadow.setBackgroundColor(Theme.getColor(Theme.key_dialogShadowLine)); actionBarShadow.setBackgroundColor(Theme.getColor(Theme.key_dialogShadowLine));
buttonsRecyclerView.setGlowColor(Theme.getColor(Theme.key_dialogScrollGlow)); buttonsRecyclerView.setGlowColor(Theme.getColor(Theme.key_dialogScrollGlow));
buttonsRecyclerView.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground)); buttonsRecyclerView.setBackgroundColor(Theme.getColor(forceDarkTheme ? Theme.key_voipgroup_listViewBackground : Theme.key_dialogBackground));
frameLayout2.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground)); frameLayout2.setBackgroundColor(Theme.getColor(forceDarkTheme ? Theme.key_voipgroup_listViewBackground : Theme.key_dialogBackground));
selectedCountView.invalidate(); selectedCountView.invalidate();
actionBar.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground)); actionBar.setBackgroundColor(forceDarkTheme ? Theme.getColor(Theme.key_voipgroup_actionBar) : Theme.getColor(Theme.key_dialogBackground));
actionBar.setItemsColor(Theme.getColor(Theme.key_dialogTextBlack), false); actionBar.setItemsColor(forceDarkTheme ? Theme.getColor(Theme.key_voipgroup_actionBarItems) : Theme.getColor(Theme.key_dialogTextBlack), false);
actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_dialogButtonSelector), false); actionBar.setItemsBackgroundColor(forceDarkTheme ? Theme.getColor(Theme.key_voipgroup_actionBarItemsSelector) : Theme.getColor(Theme.key_dialogButtonSelector), false);
actionBar.setTitleColor(Theme.getColor(Theme.key_dialogTextBlack)); actionBar.setTitleColor(forceDarkTheme ? Theme.getColor(Theme.key_voipgroup_actionBarItems) : Theme.getColor(Theme.key_dialogTextBlack));
Theme.setDrawableColor(shadowDrawable, Theme.getColor(Theme.key_dialogBackground)); Theme.setDrawableColor(shadowDrawable, Theme.getColor(forceDarkTheme ? Theme.key_voipgroup_listViewBackground : Theme.key_dialogBackground));
containerView.invalidate(); containerView.invalidate();
@ -2489,7 +2497,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
if (baseFragment == null) { if (baseFragment == null) {
return; return;
} }
if (baseFragment instanceof ChatActivity) { if (baseFragment instanceof ChatActivity && avatarPicker != 2) {
TLRPC.Chat chat = ((ChatActivity) baseFragment).getCurrentChat(); TLRPC.Chat chat = ((ChatActivity) baseFragment).getCurrentChat();
TLRPC.User user = ((ChatActivity) baseFragment).getCurrentUser(); TLRPC.User user = ((ChatActivity) baseFragment).getCurrentUser();
if (chat != null) { if (chat != null) {

View File

@ -208,7 +208,7 @@ public class ChatAttachAlertContactsLayout extends ChatAttachAlert.AttachAlertLa
lastAvatar = photo; lastAvatar = photo;
if (currentUser != null) { if (currentUser != null) {
avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser); avatarImageView.setImage(ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, currentUser);
} else { } else {
avatarImageView.setImageDrawable(avatarDrawable); avatarImageView.setImageDrawable(avatarDrawable);
} }

View File

@ -190,6 +190,8 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
private final static int compress = 1; private final static int compress = 1;
private final static int open_in = 2; private final static int open_in = 2;
boolean forceDarkTheme;
private class BasePhotoProvider extends PhotoViewer.EmptyPhotoViewerProvider { private class BasePhotoProvider extends PhotoViewer.EmptyPhotoViewerProvider {
@Override @Override
public boolean isPhotoChecked(int index) { public boolean isPhotoChecked(int index) {
@ -433,8 +435,9 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
return arrayList; return arrayList;
} }
public ChatAttachAlertPhotoLayout(ChatAttachAlert alert, Context context) { public ChatAttachAlertPhotoLayout(ChatAttachAlert alert, Context context, boolean forceDarkTheme) {
super(alert, context); super(alert, context);
this.forceDarkTheme = forceDarkTheme;
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.albumsDidLoad); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.albumsDidLoad);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.cameraInitied); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.cameraInitied);
FrameLayout container = alert.getContainer(); FrameLayout container = alert.getContainer();
@ -596,17 +599,16 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
PhotoViewer.getInstance().setMaxSelectedPhotos(parentAlert.maxSelectedPhotos, parentAlert.allowOrder); PhotoViewer.getInstance().setMaxSelectedPhotos(parentAlert.maxSelectedPhotos, parentAlert.allowOrder);
ChatActivity chatActivity; ChatActivity chatActivity;
int type; int type;
if (parentAlert.baseFragment instanceof ChatActivity) { if (parentAlert.avatarPicker != 0) {
chatActivity = null;
type = PhotoViewer.SELECT_TYPE_AVATAR;
} else if (parentAlert.baseFragment instanceof ChatActivity) {
chatActivity = (ChatActivity) parentAlert.baseFragment; chatActivity = (ChatActivity) parentAlert.baseFragment;
type = 0; type = 0;
} else { } else {
chatActivity = null; chatActivity = null;
if (parentAlert.avatarPicker != 0) {
type = PhotoViewer.SELECT_TYPE_AVATAR;
} else {
type = 4; type = 4;
} }
}
AndroidUtilities.hideKeyboard(parentAlert.baseFragment.getFragmentView().findFocus()); AndroidUtilities.hideKeyboard(parentAlert.baseFragment.getFragmentView().findFocus());
AndroidUtilities.hideKeyboard(parentAlert.getContainer().findFocus()); AndroidUtilities.hideKeyboard(parentAlert.getContainer().findFocus());
PhotoViewer.getInstance().openPhotoForSelect(arrayList, position, type, false, photoViewerProvider, chatActivity); PhotoViewer.getInstance().openPhotoForSelect(arrayList, position, type, false, photoViewerProvider, chatActivity);
@ -1247,17 +1249,16 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
ChatActivity chatActivity; ChatActivity chatActivity;
int type; int type;
if (parentAlert.baseFragment instanceof ChatActivity) { if (parentAlert.avatarPicker != 0) {
type = PhotoViewer.SELECT_TYPE_AVATAR;
chatActivity = null;
} else if (parentAlert.baseFragment instanceof ChatActivity) {
chatActivity = (ChatActivity) parentAlert.baseFragment; chatActivity = (ChatActivity) parentAlert.baseFragment;
type = 2; type = 2;
} else { } else {
chatActivity = null; chatActivity = null;
if (parentAlert.avatarPicker != 0) {
type = PhotoViewer.SELECT_TYPE_AVATAR;
} else {
type = 5; type = 5;
} }
}
ArrayList<Object> arrayList; ArrayList<Object> arrayList;
int index; int index;
if (parentAlert.avatarPicker != 0) { if (parentAlert.avatarPicker != 0) {
@ -1490,7 +1491,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
} }
public void checkCamera(boolean request) { public void checkCamera(boolean request) {
if (parentAlert.baseFragment == null) { if (parentAlert.baseFragment == null || parentAlert.baseFragment.getParentActivity() == null) {
return; return;
} }
boolean old = deviceHasGoodCamera; boolean old = deviceHasGoodCamera;
@ -2363,6 +2364,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
if (cameraIcon != null) { if (cameraIcon != null) {
cameraIcon.invalidate(); cameraIcon.invalidate();
} }
String textColor = forceDarkTheme ? Theme.key_voipgroup_actionBarItems : Theme.key_dialogTextBlack;
Theme.setDrawableColor(cameraDrawable, Theme.getColor(Theme.key_dialogCameraIcon)); Theme.setDrawableColor(cameraDrawable, Theme.getColor(Theme.key_dialogCameraIcon));
progressView.setTextColor(Theme.getColor(Theme.key_emptyListPlaceholder)); progressView.setTextColor(Theme.getColor(Theme.key_emptyListPlaceholder));
gridView.setGlowColor(Theme.getColor(Theme.key_dialogScrollGlow)); gridView.setGlowColor(Theme.getColor(Theme.key_dialogScrollGlow));
@ -2371,11 +2373,11 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
((PhotoAttachCameraCell) holder.itemView).getImageView().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogCameraIcon), PorterDuff.Mode.MULTIPLY)); ((PhotoAttachCameraCell) holder.itemView).getImageView().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogCameraIcon), PorterDuff.Mode.MULTIPLY));
} }
dropDown.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); dropDown.setTextColor(Theme.getColor(textColor));
dropDownContainer.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), false); dropDownContainer.setPopupItemsColor(Theme.getColor(forceDarkTheme ? Theme.key_voipgroup_actionBarItems : Theme.key_actionBarDefaultSubmenuItem), false);
dropDownContainer.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), true); dropDownContainer.setPopupItemsColor(Theme.getColor(forceDarkTheme ? Theme.key_voipgroup_actionBarItems :Theme.key_actionBarDefaultSubmenuItem), true);
dropDownContainer.redrawPopup(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground)); dropDownContainer.redrawPopup(Theme.getColor(forceDarkTheme ? Theme.key_voipgroup_actionBarUnscrolled : Theme.key_actionBarDefaultSubmenuBackground));
Theme.setDrawableColor(dropDownDrawable, Theme.getColor(Theme.key_dialogTextBlack)); Theme.setDrawableColor(dropDownDrawable, Theme.getColor(textColor));
} }
@Override @Override
@ -2389,7 +2391,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
cameraIcon.setAlpha(mediaEnabled ? 1.0f : 0.2f); cameraIcon.setAlpha(mediaEnabled ? 1.0f : 0.2f);
cameraIcon.setEnabled(mediaEnabled); cameraIcon.setEnabled(mediaEnabled);
} }
if (parentAlert.baseFragment instanceof ChatActivity) { if (parentAlert.baseFragment instanceof ChatActivity && parentAlert.avatarPicker == 0) {
galleryAlbumEntry = MediaController.allMediaAlbumEntry; galleryAlbumEntry = MediaController.allMediaAlbumEntry;
if (mediaEnabled) { if (mediaEnabled) {
progressView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos)); progressView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));

View File

@ -589,7 +589,7 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
public void setChatAvatar(TLRPC.Chat chat) { public void setChatAvatar(TLRPC.Chat chat) {
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
if (avatarImageView != null) { if (avatarImageView != null) {
avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); avatarImageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
} }
} }
@ -615,7 +615,7 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
} else { } else {
avatarDrawable.setSmallSize(false); avatarDrawable.setSmallSize(false);
if (avatarImageView != null) { if (avatarImageView != null) {
avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); avatarImageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} }
} }
} }
@ -643,13 +643,13 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
} else { } else {
avatarDrawable.setSmallSize(false); avatarDrawable.setSmallSize(false);
if (avatarImageView != null) { if (avatarImageView != null) {
avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user); avatarImageView.setImage(ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, user);
} }
} }
} else if (chat != null) { } else if (chat != null) {
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
if (avatarImageView != null) { if (avatarImageView != null) {
avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); avatarImageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
} }
} }
} }

View File

@ -9,25 +9,20 @@ import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.DocumentObject; import org.telegram.messenger.DocumentObject;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.ImageLocation; import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.SvgHelper; import org.telegram.messenger.SvgHelper;
import org.telegram.messenger.UserConfig;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ActionBar.Theme;
import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
import java.util.Random;
public class ChatGreetingsView extends LinearLayout implements NotificationCenter.NotificationCenterDelegate { public class ChatGreetingsView extends LinearLayout {
private TLRPC.Document preloadedGreetingsSticker; private TLRPC.Document preloadedGreetingsSticker;
private TextView titleView; private TextView titleView;
@ -39,7 +34,7 @@ public class ChatGreetingsView extends LinearLayout implements NotificationCente
public BackupImageView stickerToSendView; public BackupImageView stickerToSendView;
public ChatGreetingsView(Context context, TLRPC.User user, int distance, int currentAccount, TLRPC.Document preloadedGreetingsSticker) { public ChatGreetingsView(Context context, TLRPC.User user, int distance, int currentAccount, TLRPC.Document sticker) {
super(context); super(context);
setOrientation(VERTICAL); setOrientation(VERTICAL);
this.currentAccount = currentAccount; this.currentAccount = currentAccount;
@ -70,16 +65,17 @@ public class ChatGreetingsView extends LinearLayout implements NotificationCente
descriptionView.setText(LocaleController.getString("NearbyPeopleGreetingsDescription", R.string.NearbyPeopleGreetingsDescription)); descriptionView.setText(LocaleController.getString("NearbyPeopleGreetingsDescription", R.string.NearbyPeopleGreetingsDescription));
} }
this.preloadedGreetingsSticker = preloadedGreetingsSticker; preloadedGreetingsSticker = sticker;
if (preloadedGreetingsSticker == null) { if (preloadedGreetingsSticker == null) {
MessagesController.getInstance(currentAccount).preloadGreetingsSticker(); preloadedGreetingsSticker = MediaDataController.getInstance(currentAccount).getGreetingsSticker();
} else {
setSticker(preloadedGreetingsSticker);
} }
setSticker(preloadedGreetingsSticker);
} }
private void setSticker(TLRPC.Document sticker) { private void setSticker(TLRPC.Document sticker) {
if (sticker == null) {
return;
}
SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(sticker, Theme.key_chat_serviceBackground, 1.0f); SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(sticker, Theme.key_chat_serviceBackground, 1.0f);
if (svgThumb != null) { if (svgThumb != null) {
stickerToSendView.setImage(ImageLocation.getForDocument(sticker), createFilter(sticker), svgThumb, 0, sticker); stickerToSendView.setImage(ImageLocation.getForDocument(sticker), createFilter(sticker), svgThumb, 0, sticker);
@ -177,26 +173,17 @@ public class ChatGreetingsView extends LinearLayout implements NotificationCente
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
super.onAttachedToWindow(); super.onAttachedToWindow();
fetchSticker(); fetchSticker();
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.greetingsStickerLoaded);
} }
@Override @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.greetingsStickerLoaded);
} }
private void fetchSticker() { private void fetchSticker() {
if (preloadedGreetingsSticker == null) { if (preloadedGreetingsSticker == null) {
preloadedGreetingsSticker = MessagesController.getInstance(currentAccount).getPreloadedSticker(); preloadedGreetingsSticker = MediaDataController.getInstance(currentAccount).getGreetingsSticker();
if (preloadedGreetingsSticker != null) {
setSticker(preloadedGreetingsSticker); setSticker(preloadedGreetingsSticker);
} }
} }
}
@Override
public void didReceivedNotification(int id, int account, Object... args) {
fetchSticker();
}
} }

View File

@ -27,6 +27,8 @@ public class ContextProgressView extends View {
private int currentColorType; private int currentColorType;
private String innerKey; private String innerKey;
private String outerKey; private String outerKey;
private int innerColor;
private int outerColor;
public ContextProgressView(Context context, int colorType) { public ContextProgressView(Context context, int colorType) {
super(context); super(context);
@ -51,9 +53,25 @@ public class ContextProgressView extends View {
updateColors(); updateColors();
} }
public void setColors(int innerColor, int outerColor) {
innerKey = null;
outerKey = null;
this.innerColor = innerColor;
this.outerColor = outerColor;
updateColors();
}
public void updateColors() { public void updateColors() {
if (innerKey != null) {
innerPaint.setColor(Theme.getColor(innerKey)); innerPaint.setColor(Theme.getColor(innerKey));
} else {
innerPaint.setColor(innerColor);
}
if (outerKey != null) {
outerPaint.setColor(Theme.getColor(outerKey)); outerPaint.setColor(Theme.getColor(outerKey));
} else {
outerPaint.setColor(outerColor);
}
invalidate(); invalidate();
} }

View File

@ -1134,8 +1134,12 @@ public class FilterTabsView extends FrameLayout {
} }
} }
if (indicatorWidth != 0) { if (indicatorWidth != 0) {
canvas.save();
canvas.translate(listView.getTranslationX(), 0);
canvas.scale(listView.getScaleX(), 1f, listView.getPivotX() + listView.getX(), listView.getPivotY());
selectorDrawable.setBounds((int) indicatorX, height - AndroidUtilities.dpr(4), (int) (indicatorX + indicatorWidth), height); selectorDrawable.setBounds((int) indicatorX, height - AndroidUtilities.dpr(4), (int) (indicatorX + indicatorWidth), height);
selectorDrawable.draw(canvas); selectorDrawable.draw(canvas);
canvas.restore();
} }
} }
long newTime = SystemClock.elapsedRealtime(); long newTime = SystemClock.elapsedRealtime();
@ -1525,4 +1529,8 @@ public class FilterTabsView extends FrameLayout {
viewHolder.itemView.setBackground(null); viewHolder.itemView.setBackground(null);
} }
} }
public RecyclerListView getListView() {
return listView;
}
} }

View File

@ -17,8 +17,13 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -26,8 +31,11 @@ import android.os.Bundle;
import androidx.annotation.Keep; import androidx.annotation.Keep;
import android.os.SystemClock; import android.os.SystemClock;
import android.text.Layout;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.Spanned; import android.text.Spanned;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
@ -104,6 +112,42 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
private boolean supportsCalls = true; private boolean supportsCalls = true;
private AvatarsImageView avatars; private AvatarsImageView avatars;
private Paint gradientPaint;
private LinearGradient linearGradient;
private Matrix matrix;
private int gradientWidth;
private TextPaint gradientTextPaint;
private StaticLayout timeLayout;
private RectF rect = new RectF();
private boolean scheduleRunnableScheduled;
private Runnable updateScheduleTimeRunnable = new Runnable() {
@Override
public void run() {
if (gradientTextPaint == null || !(fragment instanceof ChatActivity)) {
scheduleRunnableScheduled = false;
return;
}
ChatObject.Call call = ((ChatActivity) fragment).getGroupCall();
if (call == null || !call.isScheduled()) {
timeLayout = null;
scheduleRunnableScheduled = false;
return;
}
int currentTime = fragment.getConnectionsManager().getCurrentTime();
int diff = call.call.schedule_date - currentTime;
String str;
if (diff >= 24 * 60 * 60) {
str = LocaleController.formatPluralString("Days", Math.round(diff / (24 * 60 * 60.0f)));
} else {
str = AndroidUtilities.formatFullDuration(call.call.schedule_date - currentTime);
}
int width = (int) Math.ceil(gradientTextPaint.measureText(str));
timeLayout = new StaticLayout(str, gradientTextPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
AndroidUtilities.runOnUIThread(updateScheduleTimeRunnable, 1000);
frameLayout.invalidate();
}
};
private final int account = UserConfig.selectedAccount; private final int account = UserConfig.selectedAccount;
private boolean isLocation; private boolean isLocation;
@ -173,6 +217,44 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
avatars.invalidate(); avatars.invalidate();
} }
} }
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (currentStyle == 4 && timeLayout != null) {
int width = (int) Math.ceil(timeLayout.getLineWidth(0)) + AndroidUtilities.dp(24);
if (width != gradientWidth) {
linearGradient = new LinearGradient(0, 0, width * 1.7f, 0, new int[]{0xff648CF4, 0xff8C69CF, 0xffD45979, 0xffD45979}, new float[]{0.0f, 0.294f, 0.588f, 1.0f}, Shader.TileMode.CLAMP);
gradientPaint.setShader(linearGradient);
gradientWidth = width;
}
ChatObject.Call call = ((ChatActivity) fragment).getGroupCall();
float moveProgress = 0.0f;
if (fragment != null && call != null && call.isScheduled()) {
long diff = ((long) call.call.schedule_date) * 1000 - fragment.getConnectionsManager().getCurrentTimeMillis();
if (diff < 0) {
moveProgress = 1.0f;
} else if (diff < 5000) {
moveProgress = 1.0f - diff / 5000.0f;
}
if (diff < 6000) {
invalidate();
}
}
matrix.reset();
matrix.postTranslate(-gradientWidth * 0.7f * moveProgress, 0);
linearGradient.setLocalMatrix(matrix);
int x = getMeasuredWidth() - width - AndroidUtilities.dp(10);
int y = AndroidUtilities.dp(12);
rect.set(0, 0, width, AndroidUtilities.dp(24));
canvas.save();
canvas.translate(x, y);
canvas.drawRoundRect(rect, AndroidUtilities.dp(12), AndroidUtilities.dp(12), gradientPaint);
canvas.translate(AndroidUtilities.dp(12), AndroidUtilities.dp(4));
timeLayout.draw(canvas);
canvas.restore();
}
}
}; };
addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 0)); addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 0));
@ -528,7 +610,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
} }
} else if (currentStyle == 3) { } else if (currentStyle == 3) {
if (VoIPService.getSharedInstance() != null && getContext() instanceof LaunchActivity) { if (VoIPService.getSharedInstance() != null && getContext() instanceof LaunchActivity) {
GroupCallActivity.create((LaunchActivity) getContext(), AccountInstance.getInstance(VoIPService.getSharedInstance().getAccount())); GroupCallActivity.create((LaunchActivity) getContext(), AccountInstance.getInstance(VoIPService.getSharedInstance().getAccount()), null, null, false, null);
} }
} else if (currentStyle == 4) { } else if (currentStyle == 4) {
if (fragment.getParentActivity() == null) { if (fragment.getParentActivity() == null) {
@ -614,7 +696,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
show = true; show = true;
} else if (fragment instanceof ChatActivity && fragment.getSendMessagesHelper().getImportingHistory(((ChatActivity) fragment).getDialogId()) != null && !isPlayingVoice()) { } else if (fragment instanceof ChatActivity && fragment.getSendMessagesHelper().getImportingHistory(((ChatActivity) fragment).getDialogId()) != null && !isPlayingVoice()) {
show = true; show = true;
} else if (fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && ((ChatActivity) fragment).getGroupCall().call.participants_count > 0 && !GroupCallPip.isShowing() && !isPlayingVoice()) { } else if (fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && ((ChatActivity) fragment).getGroupCall().shouldShowPanel() && !GroupCallPip.isShowing() && !isPlayingVoice()) {
show = true; show = true;
} else { } else {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
@ -656,6 +738,10 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
} }
} }
currentStyle = style; currentStyle = style;
frameLayout.setWillNotDraw(currentStyle != 4);
if (style != 4) {
timeLayout = null;
}
if (avatars != null) { if (avatars != null) {
avatars.setStyle(currentStyle); avatars.setStyle(currentStyle);
@ -738,9 +824,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
frameLayout.setBackgroundColor(Theme.getColor(Theme.key_inappPlayerBackground)); frameLayout.setBackgroundColor(Theme.getColor(Theme.key_inappPlayerBackground));
frameLayout.setTag(Theme.key_inappPlayerBackground); frameLayout.setTag(Theme.key_inappPlayerBackground);
muteButton.setVisibility(GONE); muteButton.setVisibility(GONE);
subtitleTextView.setVisibility(VISIBLE); subtitleTextView.setVisibility(VISIBLE);
joinButton.setVisibility(VISIBLE);
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
TextView textView = i == 0 ? titleTextView.getTextView() : titleTextView.getNextTextView(); TextView textView = i == 0 ? titleTextView.getTextView() : titleTextView.getNextTextView();
@ -754,7 +838,6 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
} }
titleTextView.setTag(Theme.key_inappPlayerPerformer); titleTextView.setTag(Theme.key_inappPlayerPerformer);
titleTextView.setPadding(0, 0, 0, 0); titleTextView.setPadding(0, 0, 0, 0);
titleTextView.setText(LocaleController.getString("VoipGroupVoiceChat", R.string.VoipGroupVoiceChat), false);
importingImageView.setVisibility(GONE); importingImageView.setVisibility(GONE);
importingImageView.stopAnimation(); importingImageView.stopAnimation();
@ -820,6 +903,10 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
animatorSet.cancel(); animatorSet.cancel();
animatorSet = null; animatorSet = null;
} }
if (scheduleRunnableScheduled) {
AndroidUtilities.cancelRunOnUIThread(updateScheduleTimeRunnable);
scheduleRunnableScheduled = false;
}
visible = false; visible = false;
NotificationCenter.getInstance(account).onAnimationFinish(animationIndex); NotificationCenter.getInstance(account).onAnimationFinish(animationIndex);
topPadding = 0; topPadding = 0;
@ -885,7 +972,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
checkCall(true); checkCall(true);
} else if (fragment instanceof ChatActivity && fragment.getSendMessagesHelper().getImportingHistory(((ChatActivity) fragment).getDialogId()) != null && !isPlayingVoice()) { } else if (fragment instanceof ChatActivity && fragment.getSendMessagesHelper().getImportingHistory(((ChatActivity) fragment).getDialogId()) != null && !isPlayingVoice()) {
checkImport(true); checkImport(true);
} else if (fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && ((ChatActivity) fragment).getGroupCall().call.participants_count > 0 && !GroupCallPip.isShowing() && !isPlayingVoice()) { } else if (fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && ((ChatActivity) fragment).getGroupCall().shouldShowPanel() && !GroupCallPip.isShowing() && !isPlayingVoice()) {
checkCall(true); checkCall(true);
} else { } else {
checkPlayer(true); checkPlayer(true);
@ -905,6 +992,11 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
muteDrawable.setCurrentFrame(muteDrawable.getCustomEndFrame() - 1, false, true); muteDrawable.setCurrentFrame(muteDrawable.getCustomEndFrame() - 1, false, true);
muteButton.invalidate(); muteButton.invalidate();
} }
} else if (currentStyle == 4) {
if (!scheduleRunnableScheduled) {
scheduleRunnableScheduled = true;
updateScheduleTimeRunnable.run();
}
} }
if (visible && topPadding == 0) { if (visible && topPadding == 0) {
@ -963,7 +1055,9 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
if (visible && currentStyle == 4) { if (visible && currentStyle == 4) {
ChatObject.Call call = ((ChatActivity) fragment).getGroupCall(); ChatObject.Call call = ((ChatActivity) fragment).getGroupCall();
if (call != null) { if (call != null) {
if (call.call.participants_count == 0) { if (call.isScheduled()) {
subtitleTextView.setText(LocaleController.formatStartsTime(call.call.schedule_date, 4), false);
} else if (call.call.participants_count == 0) {
subtitleTextView.setText(LocaleController.getString("MembersTalkingNobody", R.string.MembersTalkingNobody), false); subtitleTextView.setText(LocaleController.getString("MembersTalkingNobody", R.string.MembersTalkingNobody), false);
} else { } else {
subtitleTextView.setText(LocaleController.formatPluralString("Participants", call.call.participants_count), false); subtitleTextView.setText(LocaleController.formatPluralString("Participants", call.call.participants_count), false);
@ -1226,7 +1320,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
boolean callAvailable = supportsCalls && VoIPService.getSharedInstance() != null && !VoIPService.getSharedInstance().isHangingUp() && VoIPService.getSharedInstance().getCallState() != VoIPService.STATE_WAITING_INCOMING && !GroupCallPip.isShowing(); boolean callAvailable = supportsCalls && VoIPService.getSharedInstance() != null && !VoIPService.getSharedInstance().isHangingUp() && VoIPService.getSharedInstance().getCallState() != VoIPService.STATE_WAITING_INCOMING && !GroupCallPip.isShowing();
if (!isPlayingVoice() && !callAvailable && fragment instanceof ChatActivity && !GroupCallPip.isShowing()) { if (!isPlayingVoice() && !callAvailable && fragment instanceof ChatActivity && !GroupCallPip.isShowing()) {
ChatObject.Call call = ((ChatActivity) fragment).getGroupCall(); ChatObject.Call call = ((ChatActivity) fragment).getGroupCall();
callAvailable = call != null && call.call.participants_count > 0; callAvailable = call != null && call.shouldShowPanel();
} }
if (callAvailable) { if (callAvailable) {
checkCall(false); checkCall(false);
@ -1558,7 +1652,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
groupActive = false; groupActive = false;
if (!isPlayingVoice() && !GroupCallActivity.groupCallUiVisible && supportsCalls && !callAvailable && fragment instanceof ChatActivity) { if (!isPlayingVoice() && !GroupCallActivity.groupCallUiVisible && supportsCalls && !callAvailable && fragment instanceof ChatActivity) {
ChatObject.Call call = ((ChatActivity) fragment).getGroupCall(); ChatObject.Call call = ((ChatActivity) fragment).getGroupCall();
if (call != null && call.call.participants_count > 0) { if (call != null && call.shouldShowPanel()) {
callAvailable = true; callAvailable = true;
groupActive = true; groupActive = true;
} }
@ -1614,7 +1708,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
int newStyle; int newStyle;
if (groupActive) { if (groupActive) {
newStyle = 4; newStyle = 4;
} else if (voIPService != null && voIPService.groupCall != null) { } else if (voIPService.groupCall != null) {
newStyle = 3; newStyle = 3;
} else { } else {
newStyle = 1; newStyle = 1;
@ -1653,12 +1747,38 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
updateStyle(4); updateStyle(4);
ChatObject.Call call = ((ChatActivity) fragment).getGroupCall(); ChatObject.Call call = ((ChatActivity) fragment).getGroupCall();
if (call.isScheduled()) {
if (gradientPaint == null) {
gradientTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
gradientTextPaint.setColor(0xffffffff);
gradientTextPaint.setTextSize(AndroidUtilities.dp(14));
gradientTextPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
gradientPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
gradientPaint.setColor(0xffffffff);
matrix = new Matrix();
}
joinButton.setVisibility(GONE);
if (!TextUtils.isEmpty(call.call.title)) {
titleTextView.setText(call.call.title, false);
} else {
titleTextView.setText(LocaleController.getString("VoipGroupScheduledVoiceChat", R.string.VoipGroupScheduledVoiceChat), false);
}
subtitleTextView.setText(LocaleController.formatStartsTime(call.call.schedule_date, 2), false);
if (!scheduleRunnableScheduled) {
scheduleRunnableScheduled = true;
updateScheduleTimeRunnable.run();
}
} else {
joinButton.setVisibility(VISIBLE);
titleTextView.setText(LocaleController.getString("VoipGroupVoiceChat", R.string.VoipGroupVoiceChat), false);
if (call.call.participants_count == 0) { if (call.call.participants_count == 0) {
subtitleTextView.setText(LocaleController.getString("MembersTalkingNobody", R.string.MembersTalkingNobody), false); subtitleTextView.setText(LocaleController.getString("MembersTalkingNobody", R.string.MembersTalkingNobody), false);
} else { } else {
subtitleTextView.setText(LocaleController.formatPluralString("Participants", call.call.participants_count), false); subtitleTextView.setText(LocaleController.formatPluralString("Participants", call.call.participants_count), false);
} }
}
updateAvatars(avatars.wasDraw && updateAnimated); updateAvatars(avatars.wasDraw && updateAnimated);
} else { } else {

View File

@ -10,6 +10,8 @@ import android.graphics.Shader;
import android.os.SystemClock; import android.os.SystemClock;
import android.view.View; import android.view.View;
import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ChatObject; import org.telegram.messenger.ChatObject;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
@ -78,7 +80,11 @@ public class FragmentContextViewWavesDrawable {
if (dt > 20) { if (dt > 20) {
dt = 17; dt = 17;
} }
if (dt < 3) {
update = false;
}
}
if (update) {
if (animateToAmplitude != amplitude) { if (animateToAmplitude != amplitude) {
amplitude += animateAmplitudeDiff * dt; amplitude += animateAmplitudeDiff * dt;
if (animateAmplitudeDiff > 0) { if (animateAmplitudeDiff > 0) {
@ -145,7 +151,7 @@ public class FragmentContextViewWavesDrawable {
lineBlobDrawable2.minRadius = AndroidUtilities.dp(0); lineBlobDrawable2.minRadius = AndroidUtilities.dp(0);
lineBlobDrawable2.maxRadius = AndroidUtilities.dp(3) + AndroidUtilities.dp(9) * amplitude; lineBlobDrawable2.maxRadius = AndroidUtilities.dp(3) + AndroidUtilities.dp(9) * amplitude;
if (i == 1) { if (i == 1 && update) {
lineBlobDrawable.update(amplitude, 0.3f); lineBlobDrawable.update(amplitude, 0.3f);
lineBlobDrawable1.update(amplitude, 0.7f); lineBlobDrawable1.update(amplitude, 0.7f);
lineBlobDrawable2.update(amplitude, 0.7f); lineBlobDrawable2.update(amplitude, 0.7f);

View File

@ -143,7 +143,7 @@ public class GroupCreateSpan extends View {
} else { } else {
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
firstName = UserObject.getFirstName(user); firstName = UserObject.getFirstName(user);
imageLocation = ImageLocation.getForUser(user, false); imageLocation = ImageLocation.getForUserOrChat(user, ImageLocation.TYPE_SMALL);
imageParent = user; imageParent = user;
} }
} else if (object instanceof TLRPC.Chat) { } else if (object instanceof TLRPC.Chat) {
@ -151,7 +151,7 @@ public class GroupCreateSpan extends View {
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
uid = -chat.id; uid = -chat.id;
firstName = chat.title; firstName = chat.title;
imageLocation = ImageLocation.getForChat(chat, false); imageLocation = ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL);
imageParent = chat; imageParent = chat;
} else { } else {
avatarDrawable.setInfo(0, contact.first_name, contact.last_name); avatarDrawable.setInfo(0, contact.first_name, contact.last_name);

View File

@ -331,12 +331,14 @@ public class HintView extends FrameLayout {
top += AndroidUtilities.dp(4); top += AndroidUtilities.dp(4);
} else if (currentType == 6) { } else if (currentType == 6) {
top += view.getMeasuredHeight() + getMeasuredHeight() + AndroidUtilities.dp(10); top += view.getMeasuredHeight() + getMeasuredHeight() + AndroidUtilities.dp(10);
} else if (currentType == 7 || currentType == 8) { } else if (currentType == 7 || currentType == 8 && isTopArrow) {
top += view.getMeasuredHeight() + getMeasuredHeight() + AndroidUtilities.dp(8); top += view.getMeasuredHeight() + getMeasuredHeight() + AndroidUtilities.dp(8);
} else if (currentType == 8) {
top -= AndroidUtilities.dp(10);
} }
int centerX; int centerX;
if (currentType == 8) { if (currentType == 8 && isTopArrow) {
if (view instanceof SimpleTextView) { if (view instanceof SimpleTextView) {
SimpleTextView textView = (SimpleTextView) view; SimpleTextView textView = (SimpleTextView) view;
Drawable drawable = textView.getRightDrawable(); Drawable drawable = textView.getRightDrawable();
@ -374,7 +376,9 @@ public class HintView extends FrameLayout {
leftMargin = ((MarginLayoutParams) getLayoutParams()).leftMargin; leftMargin = ((MarginLayoutParams) getLayoutParams()).leftMargin;
rightMargin = ((MarginLayoutParams) getLayoutParams()).rightMargin; rightMargin = ((MarginLayoutParams) getLayoutParams()).rightMargin;
} }
if (centerX > parentView.getMeasuredWidth() / 2) { if (currentType == 8 && !isTopArrow) {
offset = (parentWidth - leftMargin - rightMargin - getMeasuredWidth()) / 2;
} else if (centerX > parentView.getMeasuredWidth() / 2) {
if (currentType == TYPE_SEARCH_AS_LIST) { if (currentType == TYPE_SEARCH_AS_LIST) {
offset = (int) (parentWidth - getMeasuredWidth() * 1.5f); offset = (int) (parentWidth - getMeasuredWidth() * 1.5f);
} else { } else {

View File

@ -88,6 +88,7 @@ public class ImageUpdater implements NotificationCenter.NotificationCenterDelega
private double videoTimestamp; private double videoTimestamp;
private boolean canSelectVideo; private boolean canSelectVideo;
private boolean forceDarkTheme;
private final static int attach_photo = 0; private final static int attach_photo = 0;
@ -208,6 +209,11 @@ public class ImageUpdater implements NotificationCenter.NotificationCenterDelega
useAttachMenu = searchAvailable = value; useAttachMenu = searchAvailable = value;
} }
public void setSearchAvailable(boolean value, boolean useAttachMenu) {
this.useAttachMenu = useAttachMenu;
searchAvailable = value;
}
public void setUploadAfterSelect(boolean value) { public void setUploadAfterSelect(boolean value) {
uploadAfterSelect = value; uploadAfterSelect = value;
} }
@ -319,7 +325,7 @@ public class ImageUpdater implements NotificationCenter.NotificationCenterDelega
return; return;
} }
if (chatAttachAlert == null) { if (chatAttachAlert == null) {
chatAttachAlert = new ChatAttachAlert(parentFragment.getParentActivity(), parentFragment); chatAttachAlert = new ChatAttachAlert(parentFragment.getParentActivity(), parentFragment, forceDarkTheme);
chatAttachAlert.setAvatarPicker(canSelectVideo ? 2 : 1, searchAvailable); chatAttachAlert.setAvatarPicker(canSelectVideo ? 2 : 1, searchAvailable);
chatAttachAlert.setDelegate(new ChatAttachAlert.ChatAttachViewDelegate() { chatAttachAlert.setDelegate(new ChatAttachAlert.ChatAttachViewDelegate() {
@ -882,4 +888,8 @@ public class ImageUpdater implements NotificationCenter.NotificationCenterDelega
parentFragment.getFileLoader().uploadFile(uploadingVideo, false, false, (int) convertingVideo.videoEditedInfo.estimatedSize, ConnectionsManager.FileTypeVideo, false); parentFragment.getFileLoader().uploadFile(uploadingVideo, false, false, (int) convertingVideo.videoEditedInfo.estimatedSize, ConnectionsManager.FileTypeVideo, false);
} }
} }
public void setForceDarkTheme(boolean forceDarkTheme) {
this.forceDarkTheme = forceDarkTheme;
}
} }

View File

@ -39,7 +39,7 @@ import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.BottomSheet; import org.telegram.ui.ActionBar.BottomSheet;
import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Cells.GroupCreateUserCell; import org.telegram.ui.Cells.GroupCreateUserCell;
import org.telegram.ui.ContentPreviewViewer; import org.telegram.ui.Cells.ShareDialogCell;
import java.util.ArrayList; import java.util.ArrayList;
@ -67,6 +67,7 @@ public class JoinCallAlert extends BottomSheet {
private TLRPC.Peer selectedPeer; private TLRPC.Peer selectedPeer;
private TLRPC.Peer currentPeer; private TLRPC.Peer currentPeer;
private TLRPC.InputPeer selectAfterDismiss; private TLRPC.InputPeer selectAfterDismiss;
private boolean schedule;
private boolean animationInProgress; private boolean animationInProgress;
@ -101,21 +102,26 @@ public class JoinCallAlert extends BottomSheet {
} }
public interface JoinCallAlertDelegate { public interface JoinCallAlertDelegate {
void didSelectChat(TLRPC.InputPeer peer, boolean hasFewPeers); void didSelectChat(TLRPC.InputPeer peer, boolean hasFewPeers, boolean schedule);
} }
public class BottomSheetCell extends FrameLayout { public class BottomSheetCell extends FrameLayout {
private View background; private View background;
private TextView[] textView = new TextView[2]; private TextView[] textView = new TextView[2];
private LinearLayout linearLayout; private boolean hasBackground;
public BottomSheetCell(Context context) { public BottomSheetCell(Context context, boolean withoutBackground) {
super(context); super(context);
hasBackground = !withoutBackground;
setBackground(null);
background = new View(context); background = new View(context);
if (hasBackground) {
background.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed))); background.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
addView(background, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 16, 16, 16, 16)); }
addView(background, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 16, withoutBackground ? 0 : 16, 16, 16));
for (int a = 0; a < 2; a++) { for (int a = 0; a < 2; a++) {
textView[a] = new TextView(context); textView[a] = new TextView(context);
@ -124,9 +130,14 @@ public class JoinCallAlert extends BottomSheet {
textView[a].setGravity(Gravity.CENTER_HORIZONTAL); textView[a].setGravity(Gravity.CENTER_HORIZONTAL);
textView[a].setEllipsize(TextUtils.TruncateAt.END); textView[a].setEllipsize(TextUtils.TruncateAt.END);
textView[a].setGravity(Gravity.CENTER); textView[a].setGravity(Gravity.CENTER);
if (hasBackground) {
textView[a].setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText)); textView[a].setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
textView[a].setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView[a].setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView[a].setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
} else {
textView[a].setTextColor(Theme.getColor(Theme.key_featuredStickers_addButton));
}
textView[a].setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView[a].setPadding(0, 0, 0, hasBackground ? 0 : AndroidUtilities.dp(13));
addView(textView[a], LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); addView(textView[a], LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
if (a == 1) { if (a == 1) {
textView[a].setAlpha(0.0f); textView[a].setAlpha(0.0f);
@ -136,7 +147,7 @@ public class JoinCallAlert extends BottomSheet {
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(80), MeasureSpec.EXACTLY)); super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(hasBackground ? 80 : 50), MeasureSpec.EXACTLY));
} }
public void setText(CharSequence text, boolean animated) { public void setText(CharSequence text, boolean animated) {
@ -201,16 +212,16 @@ public class JoinCallAlert extends BottomSheet {
} }
} }
public static void open(Context context, int did, AccountInstance accountInstance, BaseFragment fragment, int type, JoinCallAlertDelegate delegate) { public static void open(Context context, int did, AccountInstance accountInstance, BaseFragment fragment, int type, TLRPC.Peer scheduledPeer, JoinCallAlertDelegate delegate) {
if (context == null || delegate == null) { if (context == null || delegate == null) {
return; return;
} }
if (lastCachedAccount == accountInstance.getCurrentAccount() && lastCacheDid == did && cachedChats != null && SystemClock.elapsedRealtime() - lastCacheTime < 5 * 60 * 1000) { if (lastCachedAccount == accountInstance.getCurrentAccount() && lastCacheDid == did && cachedChats != null && SystemClock.elapsedRealtime() - lastCacheTime < 5 * 60 * 1000) {
if (cachedChats.size() == 1) { if (cachedChats.size() == 1 && type != TYPE_CREATE) {
TLRPC.InputPeer peer = accountInstance.getMessagesController().getInputPeer(MessageObject.getPeerId(cachedChats.get(0))); TLRPC.InputPeer peer = accountInstance.getMessagesController().getInputPeer(MessageObject.getPeerId(cachedChats.get(0)));
delegate.didSelectChat(peer, false); delegate.didSelectChat(peer, false, false);
} else { } else {
showAlert(context, cachedChats, fragment, type, delegate); showAlert(context, did, cachedChats, fragment, type, scheduledPeer, delegate);
} }
} else { } else {
final AlertDialog progressDialog = new AlertDialog(context, 3); final AlertDialog progressDialog = new AlertDialog(context, 3);
@ -226,7 +237,7 @@ public class JoinCallAlert extends BottomSheet {
TLRPC.TL_phone_joinAsPeers res = (TLRPC.TL_phone_joinAsPeers) response; TLRPC.TL_phone_joinAsPeers res = (TLRPC.TL_phone_joinAsPeers) response;
if (res.peers.size() == 1) { if (res.peers.size() == 1) {
TLRPC.InputPeer peer = accountInstance.getMessagesController().getInputPeer(MessageObject.getPeerId(res.peers.get(0))); TLRPC.InputPeer peer = accountInstance.getMessagesController().getInputPeer(MessageObject.getPeerId(res.peers.get(0)));
delegate.didSelectChat(peer, false); delegate.didSelectChat(peer, false, false);
return; return;
} }
cachedChats = res.peers; cachedChats = res.peers;
@ -235,7 +246,7 @@ public class JoinCallAlert extends BottomSheet {
lastCachedAccount = accountInstance.getCurrentAccount(); lastCachedAccount = accountInstance.getCurrentAccount();
accountInstance.getMessagesController().putChats(res.chats, false); accountInstance.getMessagesController().putChats(res.chats, false);
accountInstance.getMessagesController().putUsers(res.users, false); accountInstance.getMessagesController().putUsers(res.users, false);
showAlert(context, res.peers, fragment, type, delegate); showAlert(context, did, res.peers, fragment, type, scheduledPeer, delegate);
} }
})); }));
progressDialog.setOnCancelListener(dialog -> accountInstance.getConnectionsManager().cancelRequest(reqId, true)); progressDialog.setOnCancelListener(dialog -> accountInstance.getConnectionsManager().cancelRequest(reqId, true));
@ -247,8 +258,8 @@ public class JoinCallAlert extends BottomSheet {
} }
} }
private static void showAlert(Context context, ArrayList<TLRPC.Peer> peers, BaseFragment fragment, int type, JoinCallAlertDelegate delegate) { private static void showAlert(Context context, long dialogId, ArrayList<TLRPC.Peer> peers, BaseFragment fragment, int type, TLRPC.Peer scheduledPeer, JoinCallAlertDelegate delegate) {
JoinCallAlert alert = new JoinCallAlert(context, peers, type, delegate); JoinCallAlert alert = new JoinCallAlert(context, dialogId, peers, type, scheduledPeer, delegate);
if (fragment != null) { if (fragment != null) {
if (fragment.getParentActivity() != null) { if (fragment.getParentActivity() != null) {
fragment.showDialog(alert); fragment.showDialog(alert);
@ -258,14 +269,13 @@ public class JoinCallAlert extends BottomSheet {
} }
} }
private JoinCallAlert(Context context, ArrayList<TLRPC.Peer> chats, int type, JoinCallAlertDelegate delegate) { private JoinCallAlert(Context context, long dialogId, ArrayList<TLRPC.Peer> arrayList, int type, TLRPC.Peer scheduledPeer, JoinCallAlertDelegate delegate) {
super(context, false); super(context, false);
setApplyBottomPadding(false); setApplyBottomPadding(false);
this.chats = chats; chats = new ArrayList<>(arrayList);
this.delegate = delegate; this.delegate = delegate;
currentType = type; currentType = type;
shadowDrawable = context.getResources().getDrawable(R.drawable.sheet_shadow_round).mutate(); shadowDrawable = context.getResources().getDrawable(R.drawable.sheet_shadow_round).mutate();
if (type == TYPE_DISPLAY) { if (type == TYPE_DISPLAY) {
if (VoIPService.getSharedInstance() != null) { if (VoIPService.getSharedInstance() != null) {
@ -277,6 +287,15 @@ public class JoinCallAlert extends BottomSheet {
break; break;
} }
} }
} else if (scheduledPeer != null) {
long did = MessageObject.getPeerId(scheduledPeer);
for (int a = 0, N = chats.size(); a < N; a++) {
TLRPC.Peer p = chats.get(a);
if (MessageObject.getPeerId(p) == did) {
selectedPeer = currentPeer = p;
break;
}
}
} else { } else {
selectedPeer = chats.get(0); selectedPeer = chats.get(0);
} }
@ -286,6 +305,52 @@ public class JoinCallAlert extends BottomSheet {
selectedPeer = chats.get(0); selectedPeer = chats.get(0);
} }
ViewGroup internalLayout;
if (currentType == TYPE_CREATE) {
LinearLayout linearLayout = new LinearLayout(context) {
boolean sorted;
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (currentType == TYPE_CREATE) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int totalWidth = chats.size() * AndroidUtilities.dp(95);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams();
if (totalWidth > width) {
layoutParams.width = LayoutHelper.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
if (!sorted) {
if (selectedPeer != null) {
chats.remove(selectedPeer);
chats.add(0, selectedPeer);
}
sorted = true;
}
} else {
layoutParams.width = LayoutHelper.WRAP_CONTENT;
layoutParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
if (!sorted) {
if (selectedPeer != null) {
int idx;
if (chats.size() % 2 == 0) {
idx = Math.max(0, chats.size() / 2 - 1);
} else {
idx = chats.size() / 2;
}
chats.remove(selectedPeer);
chats.add(idx, selectedPeer);
}
sorted = true;
}
}
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
};
linearLayout.setOrientation(LinearLayout.VERTICAL);
setCustomView(internalLayout = linearLayout);
} else {
containerView = new FrameLayout(context) { containerView = new FrameLayout(context) {
@Override @Override
@ -347,16 +412,12 @@ public class JoinCallAlert extends BottomSheet {
shadowDrawable.draw(canvas); shadowDrawable.draw(canvas);
} }
}; };
internalLayout = containerView;
containerView.setWillNotDraw(false); containerView.setWillNotDraw(false);
containerView.setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0); containerView.setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);
listView = new RecyclerListView(context) {
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
boolean result = ContentPreviewViewer.getInstance().onInterceptTouchEvent(event, listView, 0, null);
return super.onInterceptTouchEvent(event) || result;
} }
listView = new RecyclerListView(context) {
@Override @Override
public void requestLayout() { public void requestLayout() {
if (ignoreLayout) { if (ignoreLayout) {
@ -365,7 +426,7 @@ public class JoinCallAlert extends BottomSheet {
super.requestLayout(); super.requestLayout();
} }
}; };
listView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); listView.setLayoutManager(new LinearLayoutManager(getContext(), currentType == TYPE_CREATE ? LinearLayoutManager.HORIZONTAL : LinearLayoutManager.VERTICAL, false));
listView.setAdapter(new ListAdapter(context)); listView.setAdapter(new ListAdapter(context));
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setClipToPadding(false); listView.setClipToPadding(false);
@ -381,18 +442,41 @@ public class JoinCallAlert extends BottomSheet {
if (animationInProgress || chats.get(position) == selectedPeer) { if (animationInProgress || chats.get(position) == selectedPeer) {
return; return;
} }
GroupCreateUserCell cell = (GroupCreateUserCell) view;
selectedPeer = chats.get(position); selectedPeer = chats.get(position);
cell.setChecked(true, true); if (view instanceof GroupCreateUserCell) {
((GroupCreateUserCell) view).setChecked(true, true);
} else if (view instanceof ShareDialogCell) {
((ShareDialogCell) view).setChecked(true, true);
view.invalidate();
}
for (int a = 0, N = listView.getChildCount(); a < N; a++) { for (int a = 0, N = listView.getChildCount(); a < N; a++) {
GroupCreateUserCell child = (GroupCreateUserCell) listView.getChildAt(a); View child = listView.getChildAt(a);
if (child != cell) { if (child != view) {
child.setChecked(false, true); if (view instanceof GroupCreateUserCell) {
((GroupCreateUserCell) child).setChecked(false, true);
} else if (view instanceof ShareDialogCell) {
((ShareDialogCell) child).setChecked(false, true);
} }
} }
}
if (currentType != TYPE_CREATE) {
updateDoneButton(true); updateDoneButton(true);
}
}); });
containerView.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 100, 0, 80)); if (type != TYPE_CREATE) {
internalLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 100, 0, 80));
} else {
listView.setSelectorDrawableColor(0);
listView.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), 0);
}
if (type == TYPE_CREATE) {
RLottieImageView imageView = new RLottieImageView(context);
imageView.setAutoRepeat(true);
imageView.setAnimation(R.raw.utyan_schedule, 120, 120);
imageView.playAnimation();
internalLayout.addView(imageView, LayoutHelper.createLinear(160, 160, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 17, 8, 17, 0));
}
textView = new TextView(context); textView = new TextView(context);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
@ -402,16 +486,19 @@ public class JoinCallAlert extends BottomSheet {
} else { } else {
textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
} }
textView.setSingleLine(true);
textView.setEllipsize(TextUtils.TruncateAt.END);
if (type == TYPE_CREATE) {
textView.setText(LocaleController.getString("StartVoipChatTitle", R.string.StartVoipChatTitle));
internalLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 23, 16, 23, 0));
} else {
if (type == TYPE_DISPLAY) { if (type == TYPE_DISPLAY) {
textView.setText(LocaleController.getString("VoipGroupDisplayAs", R.string.VoipGroupDisplayAs)); textView.setText(LocaleController.getString("VoipGroupDisplayAs", R.string.VoipGroupDisplayAs));
} else if (type == TYPE_CREATE) {
textView.setText(LocaleController.getString("VoipGroupStartAs", R.string.VoipGroupStartAs));
} else { } else {
textView.setText(LocaleController.getString("VoipGroupJoinAs", R.string.VoipGroupJoinAs)); textView.setText(LocaleController.getString("VoipGroupJoinAs", R.string.VoipGroupJoinAs));
} }
textView.setSingleLine(true); internalLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 23, 8, 23, 0));
textView.setEllipsize(TextUtils.TruncateAt.END); }
containerView.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 23, 0, 23, 0));
messageTextView = new TextView(getContext()); messageTextView = new TextView(getContext());
if (type == TYPE_DISPLAY) { if (type == TYPE_DISPLAY) {
@ -431,34 +518,71 @@ public class JoinCallAlert extends BottomSheet {
} }
} }
} }
messageTextView.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy());
messageTextView.setLinkTextColor(Theme.getColor(Theme.key_dialogTextLink));
if (type == TYPE_CREATE) {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat((int) -dialogId);
StringBuilder builder = new StringBuilder();
if (ChatObject.isChannel(chat) && !chat.megagroup) {
builder.append(LocaleController.getString("VoipChannelStart2", R.string.VoipChannelStart2));
} else {
builder.append(LocaleController.getString("VoipGroupStart2", R.string.VoipGroupStart2));
}
if (chats.size() > 1) {
builder.append("\n\n").append(LocaleController.getString("VoipChatDisplayedAs", R.string.VoipChatDisplayedAs));
} else {
listView.setVisibility(View.GONE);
}
messageTextView.setText(builder);
messageTextView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);
internalLayout.addView(messageTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 23, 0, 23, 5));
} else {
if (hasGroup) { if (hasGroup) {
messageTextView.setText(LocaleController.getString("VoipGroupStartAsInfoGroup", R.string.VoipGroupStartAsInfoGroup)); messageTextView.setText(LocaleController.getString("VoipGroupStartAsInfoGroup", R.string.VoipGroupStartAsInfoGroup));
} else { } else {
messageTextView.setText(LocaleController.getString("VoipGroupStartAsInfo", R.string.VoipGroupStartAsInfo)); messageTextView.setText(LocaleController.getString("VoipGroupStartAsInfo", R.string.VoipGroupStartAsInfo));
} }
messageTextView.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy());
messageTextView.setLinkTextColor(Theme.getColor(Theme.key_dialogTextLink));
messageTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); messageTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
containerView.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 23, 0, 23, 5)); internalLayout.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 23, 0, 23, 5));
}
doneButton = new BottomSheetCell(context); if (type == TYPE_CREATE) {
doneButton.setBackground(null); internalLayout.addView(listView, LayoutHelper.createLinear(chats.size() < 5 ? LayoutHelper.WRAP_CONTENT : LayoutHelper.MATCH_PARENT, 95, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 6, 0, 0));
}
doneButton = new BottomSheetCell(context, false);
doneButton.background.setOnClickListener(v -> { doneButton.background.setOnClickListener(v -> {
TLRPC.InputPeer peer = MessagesController.getInstance(currentAccount).getInputPeer(MessageObject.getPeerId(selectedPeer)); TLRPC.InputPeer peer = MessagesController.getInstance(currentAccount).getInputPeer(MessageObject.getPeerId(selectedPeer));
if (currentType == TYPE_DISPLAY) { if (currentType == TYPE_DISPLAY) {
if (selectedPeer != currentPeer) { if (selectedPeer != currentPeer) {
delegate.didSelectChat(peer, chats.size() > 1); delegate.didSelectChat(peer, chats.size() > 1, false);
} }
} else { } else {
selectAfterDismiss = peer; selectAfterDismiss = peer;
} }
dismiss(); dismiss();
}); });
containerView.addView(doneButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50, Gravity.LEFT | Gravity.BOTTOM, 0, 0, 0, 0)); if (currentType == TYPE_CREATE) {
internalLayout.addView(doneButton, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
BottomSheetCell scheduleButton = new BottomSheetCell(context, true);
scheduleButton.setText(LocaleController.getString("VoipGroupScheduleVoiceChat", R.string.VoipGroupScheduleVoiceChat), false);
scheduleButton.background.setOnClickListener(v -> {
selectAfterDismiss = MessagesController.getInstance(currentAccount).getInputPeer(MessageObject.getPeerId(selectedPeer));
schedule = true;
dismiss();
});
internalLayout.addView(scheduleButton, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
} else {
internalLayout.addView(doneButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50, Gravity.LEFT | Gravity.BOTTOM, 0, 0, 0, 0));
}
updateDoneButton(false); updateDoneButton(false);
} }
private void updateDoneButton(boolean animated) { private void updateDoneButton(boolean animated) {
if (currentType == TYPE_CREATE) {
doneButton.setText(LocaleController.formatString("VoipGroupStartVoiceChat", R.string.VoipGroupStartVoiceChat), animated);
} else {
int did = MessageObject.getPeerId(selectedPeer); int did = MessageObject.getPeerId(selectedPeer);
if (did > 0) { if (did > 0) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(did); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(did);
@ -468,8 +592,12 @@ public class JoinCallAlert extends BottomSheet {
doneButton.setText(LocaleController.formatString("VoipGroupContinueAs", R.string.VoipGroupContinueAs, chat != null ? chat.title : ""), animated); doneButton.setText(LocaleController.formatString("VoipGroupContinueAs", R.string.VoipGroupContinueAs, chat != null ? chat.title : ""), animated);
} }
} }
}
private void updateLayout() { private void updateLayout() {
if (currentType == TYPE_CREATE) {
return;
}
if (listView.getChildCount() <= 0) { if (listView.getChildCount() <= 0) {
listView.setTopGlowOffset(scrollOffsetY = listView.getPaddingTop()); listView.setTopGlowOffset(scrollOffsetY = listView.getPaddingTop());
containerView.invalidate(); containerView.invalidate();
@ -491,7 +619,7 @@ public class JoinCallAlert extends BottomSheet {
public void dismissInternal() { public void dismissInternal() {
super.dismissInternal(); super.dismissInternal();
if (selectAfterDismiss != null) { if (selectAfterDismiss != null) {
delegate.didSelectChat(selectAfterDismiss, chats.size() > 1); delegate.didSelectChat(selectAfterDismiss, chats.size() > 1, schedule);
} }
} }
@ -525,30 +653,41 @@ public class JoinCallAlert extends BottomSheet {
@Override @Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = new GroupCreateUserCell(context, 2, 0, false, currentType == TYPE_DISPLAY); View view;
if (currentType == TYPE_CREATE) {
view = new ShareDialogCell(context, ShareDialogCell.TYPE_CREATE);
view.setLayoutParams(new RecyclerView.LayoutParams(AndroidUtilities.dp(80), AndroidUtilities.dp(100)));
} else {
view = new GroupCreateUserCell(context, 2, 0, false, currentType == TYPE_DISPLAY);
}
return new RecyclerListView.Holder(view); return new RecyclerListView.Holder(view);
} }
@Override @Override
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) { public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
int position = holder.getAdapterPosition(); int position = holder.getAdapterPosition();
long did = MessageObject.getPeerId(selectedPeer);
if (holder.itemView instanceof GroupCreateUserCell) {
GroupCreateUserCell cell = (GroupCreateUserCell) holder.itemView; GroupCreateUserCell cell = (GroupCreateUserCell) holder.itemView;
Object object = cell.getObject(); Object object = cell.getObject();
long id = 0;
if (object != null) { if (object != null) {
int did = MessageObject.getPeerId(selectedPeer);
int id;
if (object instanceof TLRPC.Chat) { if (object instanceof TLRPC.Chat) {
id = -((TLRPC.Chat) object).id; id = -((TLRPC.Chat) object).id;
} else { } else {
id = ((TLRPC.User) object).id; id = ((TLRPC.User) object).id;
} }
}
cell.setChecked(did == id, false);
} else {
ShareDialogCell cell = (ShareDialogCell) holder.itemView;
long id = cell.getCurrentDialog();
cell.setChecked(did == id, false); cell.setChecked(did == id, false);
} }
} }
@Override @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
GroupCreateUserCell cell = (GroupCreateUserCell) holder.itemView;
int did = MessageObject.getPeerId(chats.get(position)); int did = MessageObject.getPeerId(chats.get(position));
TLObject object; TLObject object;
String status; String status;
@ -559,7 +698,13 @@ public class JoinCallAlert extends BottomSheet {
object = MessagesController.getInstance(currentAccount).getChat(-did); object = MessagesController.getInstance(currentAccount).getChat(-did);
status = null; status = null;
} }
if (currentType == TYPE_CREATE) {
ShareDialogCell cell = (ShareDialogCell) holder.itemView;
cell.setDialog(did, did == MessageObject.getPeerId(selectedPeer), null);
} else {
GroupCreateUserCell cell = (GroupCreateUserCell) holder.itemView;
cell.setObject(object, null, status, position != getItemCount() - 1); cell.setObject(object, null, status, position != getItemCount() - 1);
} }
} }
}
} }

View File

@ -80,7 +80,7 @@ public class JoinCallByUrlAlert extends BottomSheet {
linearLayout.addView(avatarImageView, LayoutHelper.createLinear(90, 90, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 29, 0, 0)); linearLayout.addView(avatarImageView, LayoutHelper.createLinear(90, 90, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 29, 0, 0));
AvatarDrawable avatarDrawable = new AvatarDrawable(chat); AvatarDrawable avatarDrawable = new AvatarDrawable(chat);
avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat); avatarImageView.setImage(ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, chat);
TextView percentTextView = new TextView(context); TextView percentTextView = new TextView(context);
percentTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); percentTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));

View File

@ -68,7 +68,7 @@ public class JoinGroupAlert extends BottomSheet {
avatarDrawable = new AvatarDrawable(invite.chat); avatarDrawable = new AvatarDrawable(invite.chat);
title = invite.chat.title; title = invite.chat.title;
participants_count = invite.chat.participants_count; participants_count = invite.chat.participants_count;
avatarImageView.setImage(ImageLocation.getForChat(invite.chat, false), "50_50", avatarDrawable, invite); avatarImageView.setImage(ImageLocation.getForUserOrChat(invite.chat, ImageLocation.TYPE_SMALL), "50_50", ImageLocation.getForUserOrChat(invite.chat, ImageLocation.TYPE_STRIPPED), "50_50", avatarDrawable, invite);
} else { } else {
avatarDrawable = new AvatarDrawable(); avatarDrawable = new AvatarDrawable();
avatarDrawable.setInfo(0, invite.title, null); avatarDrawable.setInfo(0, invite.title, null);

View File

@ -232,6 +232,7 @@ public class NumberPicker extends LinearLayout {
public NumberPicker(Context context) { public NumberPicker(Context context) {
this(context, 18); this(context, 18);
} }
public NumberPicker(Context context, int textSize) { public NumberPicker(Context context, int textSize) {
super(context); super(context);
mTextSize = AndroidUtilities.dp(textSize); mTextSize = AndroidUtilities.dp(textSize);

Some files were not shown because too many files have changed in this diff Show More