Merge branch 'dev'

This commit is contained in:
DrKLO 2014-08-08 14:18:21 +04:00
commit 7545dfe20a
119 changed files with 2376 additions and 1330 deletions

View File

@ -18,7 +18,7 @@ tasks.withType(JavaCompile) {
dependencies {
compile 'com.android.support:support-v4:19.0.+'
compile 'com.google.android.gms:play-services:4.1.+'
compile 'com.google.android.gms:play-services:3.2.+'
compile 'net.hockeyapp.android:HockeySDK:3.0.1'
compile 'com.googlecode.mp4parser:isoparser:1.0.+'
}
@ -83,7 +83,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 288
versionName "1.6.1"
versionCode 307
versionName "1.7.0"
}
}

View File

@ -28,7 +28,6 @@
android:largeHeap="true">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyCTNmNqbWovP9ETcAob98YlrfOQEAC0CJ4" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<activity android:name="net.hockeyapp.android.UpdateActivity" />

View File

@ -28,7 +28,6 @@
android:largeHeap="true">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<activity android:name="net.hockeyapp.android.UpdateActivity" />

View File

@ -8,6 +8,7 @@ LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT
LOCAL_CPPFLAGS := -DBSD=1 -ffast-math -O2 -funroll-loops
#LOCAL_LDLIBS := -llog
LOCAL_LDLIBS := -ljnigraphics
LOCAL_SRC_FILES := \
./opus/src/opus.c \

View File

@ -2,5 +2,5 @@
void fakeFunction() {
printf("some androids has buggy native loader, so i should check size of libs in java to know that native library is correct. So each changed native library should has diffrent size in different app versions. This function will increase lib size for few bytes :)");
printf("bla blablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablabla");
printf("bla blablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablabla");
}

View File

@ -1,4 +1,4 @@
//tanks to https://github.com/koral--/android-gif-drawable
//thanks to https://github.com/koral--/android-gif-drawable
/*
MIT License
Copyright (c)
@ -73,7 +73,7 @@ typedef struct {
typedef struct {
unsigned int duration;
short transpIndex;
int transpIndex;
unsigned char disposalMethod;
} FrameInfo;
@ -121,19 +121,20 @@ void gifOnJNIUnload(JavaVM *vm, void *reserved) {
}
static int fileReadFunc(GifFileType *gif, GifByteType *bytes, int size) {
FILE *file = (FILE *)gif->UserData;
FILE *file = (FILE *)gif->UserData;
return fread(bytes, 1, size, file);
}
static int fileRewindFun(GifInfo *info) {
return fseek(info->gifFilePtr->UserData, info->startPos, SEEK_SET);
return fseek(info->gifFilePtr->UserData, info->startPos, SEEK_SET);
}
static unsigned long getRealTime() {
struct timespec ts;
const clockid_t id = CLOCK_MONOTONIC;
if (id != (clockid_t) - 1 && clock_gettime(id, &ts) != -1)
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
if (id != (clockid_t) - 1 && clock_gettime(id, &ts) != -1) {
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
}
return -1;
}
@ -195,7 +196,7 @@ static void packARGB32(argb *pixel, GifByteType alpha, GifByteType red, GifByteT
}
static void getColorFromTable(int idx, argb *dst, const ColorMapObject *cmap) {
char colIdx = idx >= cmap->ColorCount ? 0 : idx;
int colIdx = (idx >= cmap->ColorCount) ? 0 : idx;
GifColorType *col = &cmap->Colors[colIdx];
packARGB32(dst, 0xFF, col->Red, col->Green, col->Blue);
}
@ -218,7 +219,7 @@ static inline bool setupBackupBmp(GifInfo *info, short transpIndex) {
if (transpIndex == -1) {
getColorFromTable(fGIF->SBackGroundColor, &paintingColor, fGIF->SColorMap);
} else {
packARGB32(&paintingColor,0,0,0,0);
packARGB32(&paintingColor, 0, 0, 0, 0);
}
eraseColor(info->backupPtr, fGIF->SWidth, fGIF->SHeight, paintingColor);
return true;
@ -231,14 +232,15 @@ static int readExtensions(int ExtFunction, GifByteType *ExtData, GifInfo *info)
if (ExtFunction == GRAPHICS_EXT_FUNC_CODE && ExtData[0] == 4) {
FrameInfo *fi = &info->infos[info->gifFilePtr->ImageCount];
fi->transpIndex = -1;
char *b = (char *)ExtData + 1;
char *b = (char*) ExtData + 1;
short delay = ((b[2] << 8) | b[1]);
fi->duration = delay > 1 ? delay * 10 : 100;
fi->disposalMethod = ((b[0] >> 2) & 7);
if (ExtData[1] & 1)
fi->transpIndex = (short) b[3];
if (ExtData[1] & 1) {
fi->transpIndex = 0xff & b[3];
}
if (fi->disposalMethod == 3 && info->backupPtr == NULL) {
if (!setupBackupBmp(info,fi->transpIndex)) {
if (!setupBackupBmp(info, fi->transpIndex)) {
return GIF_ERROR;
}
}
@ -260,7 +262,7 @@ static int readExtensions(int ExtFunction, GifByteType *ExtData, GifInfo *info)
return GIF_OK;
}
static int DDGifSlurp(GifFileType *GifFile, GifInfo *info, bool shouldDecode) {
static int DDGifSlurp(GifFileType *GifFile, GifInfo* info, bool shouldDecode) {
GifRecordType RecordType;
GifByteType *ExtData;
int codeSize;
@ -268,103 +270,109 @@ static int DDGifSlurp(GifFileType *GifFile, GifInfo *info, bool shouldDecode) {
size_t ImageSize;
do {
if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR) {
return GIF_ERROR;
return (GIF_ERROR);
}
switch (RecordType) {
case IMAGE_DESC_RECORD_TYPE: {
if (DGifGetImageDesc(GifFile, !shouldDecode) == GIF_ERROR) {
return GIF_ERROR;
}
int i = shouldDecode ? info->currentIndex : GifFile->ImageCount - 1;
SavedImage *sp = &GifFile->SavedImages[i];
ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height;
if (sp->ImageDesc.Width < 1 || sp->ImageDesc.Height < 1 || ImageSize > (SIZE_MAX / sizeof(GifPixelType))) {
GifFile->Error = D_GIF_ERR_INVALID_IMG_DIMS;
return GIF_ERROR;
}
if (sp->ImageDesc.Width > GifFile->SWidth || sp->ImageDesc.Height > GifFile->SHeight) {
GifFile->Error = D_GIF_ERR_IMG_NOT_CONFINED;
return GIF_ERROR;
}
if (shouldDecode) {
sp->RasterBits = info->rasterBits;
if (sp->ImageDesc.Interlace) {
int i, j;
int InterlacedOffset[] = { 0, 4, 2, 1 };
int InterlacedJumps[] = { 8, 8, 4, 2 };
for (i = 0; i < 4; i++) {
for (j = InterlacedOffset[i]; j < sp->ImageDesc.Height; j += InterlacedJumps[i]) {
if (DGifGetLine(GifFile, sp->RasterBits + j * sp->ImageDesc.Width, sp->ImageDesc.Width) == GIF_ERROR) {
return GIF_ERROR;
}
case IMAGE_DESC_RECORD_TYPE:
if (DGifGetImageDesc(GifFile, !shouldDecode) == GIF_ERROR) {
return (GIF_ERROR);
}
int i = shouldDecode ? info->currentIndex : GifFile->ImageCount - 1;
SavedImage *sp = &GifFile->SavedImages[i];
ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height;
if (sp->ImageDesc.Width < 1 || sp->ImageDesc.Height < 1 || ImageSize > (SIZE_MAX / sizeof(GifPixelType))) {
GifFile->Error = D_GIF_ERR_INVALID_IMG_DIMS;
return GIF_ERROR;
}
if (sp->ImageDesc.Width > GifFile->SWidth || sp->ImageDesc.Height > GifFile->SHeight) {
GifFile->Error = D_GIF_ERR_IMG_NOT_CONFINED;
return GIF_ERROR;
}
if (shouldDecode) {
sp->RasterBits = info->rasterBits;
if (sp->ImageDesc.Interlace) {
int i, j;
int InterlacedOffset[] = { 0, 4, 2, 1 };
int InterlacedJumps[] = { 8, 8, 4, 2 };
for (i = 0; i < 4; i++) {
for (j = InterlacedOffset[i]; j < sp->ImageDesc.Height; j += InterlacedJumps[i]) {
if (DGifGetLine(GifFile, sp->RasterBits + j * sp->ImageDesc.Width, sp->ImageDesc.Width) == GIF_ERROR) {
return GIF_ERROR;
}
}
} else {
if (DGifGetLine(GifFile, sp->RasterBits, ImageSize) == GIF_ERROR) {
return GIF_ERROR;
}
}
if (info->currentIndex >= GifFile->ImageCount - 1) {
if (info->loopCount > 0)
} else {
if (DGifGetLine(GifFile, sp->RasterBits, ImageSize) == GIF_ERROR) {
return (GIF_ERROR);
}
}
if (info->currentIndex >= GifFile->ImageCount - 1) {
if (info->loopCount > 0) {
info->currentLoop++;
if (fileRewindFun(info) != 0) {
info->gifFilePtr->Error = D_GIF_ERR_READ_FAILED;
return GIF_ERROR;
}
}
return GIF_OK;
} else {
if (DGifGetCode(GifFile, &codeSize, &ExtData) == GIF_ERROR) {
return GIF_ERROR;
}
while (ExtData) {
if (DGifGetCodeNext(GifFile, &ExtData) == GIF_ERROR) {
return GIF_ERROR;
}
}
if (fileRewindFun(info) != 0) {
info->gifFilePtr->Error = D_GIF_ERR_READ_FAILED;
return GIF_ERROR;
}
}
return GIF_OK;
} else {
if (DGifGetCode(GifFile, &codeSize, &ExtData) == GIF_ERROR) {
return (GIF_ERROR);
}
break;
while (ExtData != NULL) {
if (DGifGetCodeNext(GifFile, &ExtData) == GIF_ERROR) {
return (GIF_ERROR);
}
}
}
break;
case EXTENSION_RECORD_TYPE:
if (DGifGetExtension(GifFile, &ExtFunction, &ExtData) == GIF_ERROR) {
return (GIF_ERROR);
}
case EXTENSION_RECORD_TYPE: {
if (DGifGetExtension(GifFile, &ExtFunction, &ExtData) == GIF_ERROR) {
if (!shouldDecode) {
FrameInfo *tmpInfos = realloc(info->infos, (GifFile->ImageCount + 1) * sizeof(FrameInfo));
if (tmpInfos == NULL) {
return GIF_ERROR;
}
info->infos = tmpInfos;
if (readExtensions(ExtFunction, ExtData, info) == GIF_ERROR) {
return GIF_ERROR;
}
}
while (ExtData != NULL) {
if (DGifGetExtensionNext(GifFile, &ExtData, &ExtFunction) == GIF_ERROR) {
return (GIF_ERROR);
}
if (!shouldDecode) {
if (readExtensions(ExtFunction, ExtData, info) == GIF_ERROR) {
return GIF_ERROR;
}
}
}
break;
if (!shouldDecode) {
info->infos = realloc(info->infos, (GifFile->ImageCount + 1) * sizeof(FrameInfo));
if (readExtensions(ExtFunction, ExtData, info) == GIF_ERROR) {
return GIF_ERROR;
}
}
while (ExtData) {
if (DGifGetExtensionNext(GifFile, &ExtData, &ExtFunction) == GIF_ERROR) {
return GIF_ERROR;
}
if (!shouldDecode) {
if (readExtensions(ExtFunction, ExtData, info) == GIF_ERROR) {
return GIF_ERROR;
}
}
}
break;
}
case TERMINATE_RECORD_TYPE:
break;
default:
break;
}
} while (RecordType != TERMINATE_RECORD_TYPE);
bool ok = true;
if (shouldDecode) {
ok = (fileRewindFun(info) == 0);
}
if (ok) {
return GIF_OK;
return (GIF_OK);
} else {
info->gifFilePtr->Error = D_GIF_ERR_READ_FAILED;
return GIF_ERROR;
return (GIF_ERROR);
}
}
@ -381,7 +389,7 @@ static argb *getAddr(argb *bm, int width, int left, int top) {
}
static void blitNormal(argb *bm, int width, int height, const SavedImage *frame, const ColorMapObject *cmap, int transparent) {
const unsigned char *src = (unsigned char *)frame->RasterBits;
const unsigned char* src = (unsigned char*) frame->RasterBits;
argb *dst = getAddr(bm, width, frame->ImageDesc.Left, frame->ImageDesc.Top);
GifWord copyWidth = frame->ImageDesc.Width;
if (frame->ImageDesc.Left + copyWidth > width) {
@ -393,9 +401,6 @@ static void blitNormal(argb *bm, int width, int height, const SavedImage *frame,
copyHeight = height - frame->ImageDesc.Top;
}
int srcPad, dstPad;
dstPad = width - copyWidth;
srcPad = frame->ImageDesc.Width - copyWidth;
for (; copyHeight > 0; copyHeight--) {
copyLine(dst, src, cmap, transparent, copyWidth);
src += frame->ImageDesc.Width;
@ -404,7 +409,7 @@ static void blitNormal(argb *bm, int width, int height, const SavedImage *frame,
}
static void fillRect(argb *bm, int bmWidth, int bmHeight, GifWord left, GifWord top, GifWord width, GifWord height, argb col) {
uint32_t *dst = (uint32_t *)getAddr(bm, bmWidth, left, top);
uint32_t* dst = (uint32_t*) getAddr(bm, bmWidth, left, top);
GifWord copyWidth = width;
if (left + copyWidth > bmWidth) {
copyWidth = bmWidth - left;
@ -414,7 +419,7 @@ static void fillRect(argb *bm, int bmWidth, int bmHeight, GifWord left, GifWord
if (top + copyHeight > bmHeight) {
copyHeight = bmHeight - top;
}
uint32_t *pColor = (uint32_t *)(&col);
uint32_t* pColor = (uint32_t *) (&col);
for (; copyHeight > 0; copyHeight--) {
memset(dst, *pColor, copyWidth * sizeof(argb));
dst += bmWidth;
@ -424,12 +429,11 @@ static void fillRect(argb *bm, int bmWidth, int bmHeight, GifWord left, GifWord
static void drawFrame(argb *bm, int bmWidth, int bmHeight, const SavedImage *frame, const ColorMapObject *cmap, short transpIndex) {
if (frame->ImageDesc.ColorMap != NULL) {
cmap = frame->ImageDesc.ColorMap;
if (cmap == NULL || cmap->ColorCount != (1 << cmap->BitsPerPixel)) {
if (cmap->ColorCount != (1 << cmap->BitsPerPixel)) {
cmap = defaultCmap;
}
}
blitNormal(bm, bmWidth, bmHeight, frame, cmap, (int) transpIndex);
blitNormal(bm, bmWidth, bmHeight, frame, cmap, transpIndex);
}
static bool checkIfCover(const SavedImage *target, const SavedImage *covered) {
@ -445,30 +449,28 @@ static bool checkIfCover(const SavedImage *target, const SavedImage *covered) {
}
static inline void disposeFrameIfNeeded(argb *bm, GifInfo *info, unsigned int idx) {
argb *backup = info->backupPtr;
argb* backup = info->backupPtr;
argb color;
packARGB32(&color, 0, 0, 0, 0);
GifFileType *fGif = info->gifFilePtr;
SavedImage *cur = &fGif->SavedImages[idx - 1];
SavedImage *next = &fGif->SavedImages[idx];
SavedImage* cur = &fGif->SavedImages[idx - 1];
SavedImage* next = &fGif->SavedImages[idx];
bool curTrans = info->infos[idx - 1].transpIndex != -1;
int curDisposal = info->infos[idx - 1].disposalMethod;
bool nextTrans = info->infos[idx].transpIndex != -1;
int nextDisposal = info->infos[idx].disposalMethod;
argb *tmp;
if ((curDisposal == 2 || curDisposal == 3) && (nextTrans || !checkIfCover(next, cur))) {
switch (curDisposal) {
case 2: {
fillRect(bm, fGif->SWidth, fGif->SHeight, cur->ImageDesc.Left, cur->ImageDesc.Top, cur->ImageDesc.Width, cur->ImageDesc.Height, color);
}
case 2:
fillRect(bm, fGif->SWidth, fGif->SHeight, cur->ImageDesc.Left, cur->ImageDesc.Top, cur->ImageDesc.Width, cur->ImageDesc.Height, color);
break;
case 3: {
tmp = bm;
bm = backup;
backup = tmp;
}
case 3:
tmp = bm;
bm = backup;
backup = tmp;
break;
}
}
@ -478,27 +480,25 @@ static inline void disposeFrameIfNeeded(argb *bm, GifInfo *info, unsigned int id
}
}
static jboolean reset(GifInfo *info) {
static void reset(GifInfo *info) {
if (fileRewindFun(info) != 0) {
return JNI_FALSE;
return;
}
info->nextStartTime = 0;
info->currentLoop = -1;
info->currentIndex = -1;
return JNI_TRUE;
}
static void getBitmap(argb *bm, GifInfo *info) {
GifFileType *fGIF = info->gifFilePtr;
GifFileType* fGIF = info->gifFilePtr;
argb paintingColor;
int i = info->currentIndex;
if (DDGifSlurp(fGIF, info, true) == GIF_ERROR) {
return; //TODO add leniency support
return;
}
SavedImage *cur = &fGIF->SavedImages[i];
short transpIndex = info->infos[i].transpIndex;
SavedImage* cur = &fGIF->SavedImages[i];
int transpIndex = info->infos[i].transpIndex;
if (i == 0) {
if (transpIndex == -1) {
getColorFromTable(fGIF->SBackGroundColor, &paintingColor, fGIF->SColorMap);
@ -513,11 +513,14 @@ static void getBitmap(argb *bm, GifInfo *info) {
}
static void setMetaData(int width, int height, int ImageCount, int errorCode, JNIEnv *env, jintArray metaData) {
jint *ints = (*env)->GetIntArrayElements(env, metaData, 0);
*ints++ = width;
*ints++ = height;
*ints++ = ImageCount;
*ints = errorCode;
jint *const ints = (*env)->GetIntArrayElements(env, metaData, 0);
if (ints == NULL) {
return;
}
ints[0] = width;
ints[1] = height;
ints[2] = ImageCount;
ints[3] = errorCode;
(*env)->ReleaseIntArrayElements(env, metaData, ints, 0);
}
@ -554,9 +557,6 @@ static jint open(GifFileType *GifFileIn, int Error, int startPos, JNIEnv *env, j
info->speedFactor = 1.0;
info->rasterBits = calloc(GifFileIn->SHeight * GifFileIn->SWidth, sizeof(GifPixelType));
info->infos = malloc(sizeof(FrameInfo));
info->infos->duration = 0;
info->infos->disposalMethod = 0;
info->infos->transpIndex = -1;
info->backupPtr = NULL;
if (info->rasterBits == NULL || info->infos == NULL) {
@ -564,15 +564,18 @@ static jint open(GifFileType *GifFileIn, int Error, int startPos, JNIEnv *env, j
setMetaData(width, height, 0, D_GIF_ERR_NOT_ENOUGH_MEM, env, metaData);
return (jint) NULL;
}
if (DDGifSlurp(GifFileIn, info, false) == GIF_ERROR) {
Error = GifFileIn->Error;
}
info->infos->duration = 0;
info->infos->disposalMethod = 0;
info->infos->transpIndex = -1;
if (GifFileIn->SColorMap == NULL || GifFileIn->SColorMap->ColorCount != (1 << GifFileIn->SColorMap->BitsPerPixel)) {
GifFreeMapObject(GifFileIn->SColorMap);
GifFileIn->SColorMap = defaultCmap;
}
DDGifSlurp(GifFileIn, info, false);
int imgCount = GifFileIn->ImageCount;
if (imgCount < 1) {
Error = D_GIF_ERR_NO_FRAMES;
}
@ -583,7 +586,6 @@ static jint open(GifFileType *GifFileIn, int Error, int startPos, JNIEnv *env, j
cleanUp(info);
}
setMetaData(width, height, imgCount, Error, env, metaData);
return (jint)(Error == 0 ? info : NULL);
}
@ -600,12 +602,12 @@ JNIEXPORT jlong JNICALL Java_org_telegram_ui_Views_GifDrawable_getAllocationByte
return sum;
}
JNIEXPORT jboolean JNICALL Java_org_telegram_ui_Views_GifDrawable_reset(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_reset(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return JNI_FALSE;
return;
}
return reset(info);
reset(info);
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_setSpeedFactor(JNIEnv *env, jclass class, jobject gifInfo, jfloat factor) {
@ -618,7 +620,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_setSpeedFactor(JNI
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToTime(JNIEnv *env, jclass class, jobject gifInfo, jint desiredPos, jintArray jPixels) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
if (info == NULL || jPixels == NULL) {
return;
}
int imgCount = info->gifFilePtr->ImageCount;
@ -643,25 +645,29 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToTime(JNIEnv
if (i == imgCount - 1 && lastFrameRemainder > info->infos[i].duration) {
lastFrameRemainder = info->infos[i].duration;
}
info->lastFrameReaminder = lastFrameRemainder;
if (i > info->currentIndex) {
jint *pixels = (*env)->GetIntArrayElements(env, jPixels, 0);
jint *const pixels = (*env)->GetIntArrayElements(env, jPixels, 0);
if (pixels == NULL) {
return;
}
while (info->currentIndex <= i) {
info->currentIndex++;
getBitmap((argb *)pixels, info);
getBitmap((argb*) pixels, info);
}
(*env)->ReleaseIntArrayElements(env, jPixels, pixels, 0);
}
info->lastFrameReaminder = lastFrameRemainder;
if (info->speedFactor == 1.0) {
info->nextStartTime = getRealTime() + lastFrameRemainder;
} else {
} else {
info->nextStartTime = getRealTime() + lastFrameRemainder * info->speedFactor;
}
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToFrame(JNIEnv *env, jclass class, jobject gifInfo, jint desiredIdx, jintArray jPixels) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
if (info == NULL|| jPixels==NULL) {
return;
}
if (desiredIdx <= info->currentIndex) {
@ -673,15 +679,19 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToFrame(JNIEnv
return;
}
jint *const pixels = (*env)->GetIntArrayElements(env, jPixels, 0);
if (pixels == NULL) {
return;
}
info->lastFrameReaminder = 0;
if (desiredIdx >= imgCount) {
desiredIdx = imgCount - 1;
}
info->lastFrameReaminder = 0;
jint *pixels = (*env)->GetIntArrayElements(env, jPixels, 0);
while (info->currentIndex < desiredIdx) {
info->currentIndex++;
getBitmap((argb *)pixels, info);
getBitmap((argb *) pixels, info);
}
(*env)->ReleaseIntArrayElements(env, jPixels, pixels, 0);
if (info->speedFactor == 1.0) {
@ -689,16 +699,13 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToFrame(JNIEnv
} else {
info->nextStartTime = getRealTime() + info->infos[info->currentIndex].duration * info->speedFactor;
}
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_renderFrame(JNIEnv *env, jclass class, jintArray jPixels, jobject gifInfo, jintArray metaData) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
if (info == NULL || jPixels == NULL) {
return;
}
bool needRedraw = false;
unsigned long rt = getRealTime();
@ -708,24 +715,40 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_renderFrame(JNIEnv
}
needRedraw = true;
}
jint *rawMetaData = (*env)->GetIntArrayElements(env, metaData, 0);
jint *const rawMetaData = (*env)->GetIntArrayElements(env, metaData, 0);
if (rawMetaData == NULL) {
return;
}
if (needRedraw) {
jint *pixels = (*env)->GetIntArrayElements(env, jPixels, 0);
if (needRedraw) {
jint *const pixels = (*env)->GetIntArrayElements(env, jPixels, 0);
if (pixels == NULL) {
(*env)->ReleaseIntArrayElements(env, metaData, rawMetaData, 0);
return;
}
getBitmap((argb *)pixels, info);
rawMetaData[3] = info->gifFilePtr->Error;
(*env)->ReleaseIntArrayElements(env, jPixels, pixels, 0);
int scaledDuration = info->infos[info->currentIndex].duration;
unsigned int scaledDuration = info->infos[info->currentIndex].duration;
if (info->speedFactor != 1.0) {
scaledDuration /= info->speedFactor;
}
scaledDuration /= info->speedFactor;
if (scaledDuration<=0) {
scaledDuration=1;
} else if (scaledDuration > INT_MAX) {
scaledDuration = INT_MAX;
}
}
info->nextStartTime = rt + scaledDuration;
rawMetaData[4] = scaledDuration;
} else {
rawMetaData[4] = (int) (rt - info->nextStartTime);
}
long delay = info->nextStartTime-rt;
if (delay < 0) {
rawMetaData[4] = -1;
} else {
rawMetaData[4] = (int) delay;
}
}
(*env)->ReleaseIntArrayElements(env, metaData, rawMetaData, 0);
}
@ -794,9 +817,6 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_saveRemainder(JNIE
return;
}
info->lastFrameReaminder = getRealTime() - info->nextStartTime;
if (info->lastFrameReaminder > 0) {
info->lastFrameReaminder = 0;
}
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_restoreRemainder(JNIEnv *env, jclass class, jobject gifInfo) {
@ -814,7 +834,7 @@ JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_openFile(JNIEnv *e
return (jint) NULL;
}
const char *fname = (*env)->GetStringUTFChars(env, jfname, 0);
const char *const fname = (*env)->GetStringUTFChars(env, jfname, 0);
FILE *file = fopen(fname, "rb");
(*env)->ReleaseStringUTFChars(env, jfname, fname);
if (file == NULL) {

View File

@ -2,8 +2,101 @@
#include <stdio.h>
#include <setjmp.h>
#include <libjpeg/jpeglib.h>
#include <android/bitmap.h>
#include "utils.h"
static inline uint64_t get_colors (const uint8_t *p) {
return p[0] + (p[1] << 16) + ((uint64_t)p[2] << 32);
}
static void fastBlur(int imageWidth, int imageHeight, int imageStride, void *pixels) {
uint8_t *pix = (uint8_t *)pixels;
const int w = imageWidth;
const int h = imageHeight;
const int stride = imageStride;
const int radius = 3;
const int r1 = radius + 1;
const int div = radius * 2 + 1;
if (radius > 15 || div >= w || div >= h) {
return;
}
uint64_t rgb[imageStride * imageHeight];
int x, y, i;
int yw = 0;
const int we = w - r1;
for (y = 0; y < h; y++) {
uint64_t cur = get_colors (&pix[yw]);
uint64_t rgballsum = -radius * cur;
uint64_t rgbsum = cur * ((r1 * (r1 + 1)) >> 1);
for (i = 1; i <= radius; i++) {
uint64_t cur = get_colors (&pix[yw + i * 4]);
rgbsum += cur * (r1 - i);
rgballsum += cur;
}
x = 0;
#define update(start, middle, end) \
rgb[y * w + x] = (rgbsum >> 4) & 0x00FF00FF00FF00FFLL; \
rgballsum += get_colors (&pix[yw + (start) * 4]) - 2 * get_colors (&pix[yw + (middle) * 4]) + get_colors (&pix[yw + (end) * 4]); \
rgbsum += rgballsum; \
x++; \
while (x < r1) {
update (0, x, x + r1);
}
while (x < we) {
update (x - r1, x, x + r1);
}
while (x < w) {
update (x - r1, x, w - 1);
}
#undef update
yw += stride;
}
const int he = h - r1;
for (x = 0; x < w; x++) {
uint64_t rgballsum = -radius * rgb[x];
uint64_t rgbsum = rgb[x] * ((r1 * (r1 + 1)) >> 1);
for (i = 1; i <= radius; i++) {
rgbsum += rgb[i * w + x] * (r1 - i);
rgballsum += rgb[i * w + x];
}
y = 0;
int yi = x * 4;
#define update(start, middle, end) \
int64_t res = rgbsum >> 4; \
pix[yi] = res; \
pix[yi + 1] = res >> 16; \
pix[yi + 2] = res >> 32; \
rgballsum += rgb[x + (start) * w] - 2 * rgb[x + (middle) * w] + rgb[x + (end) * w]; \
rgbsum += rgballsum; \
y++; \
yi += stride;
while (y < r1) {
update (0, y, y + r1);
}
while (y < he) {
update (y - r1, y, y + r1);
}
while (y < h) {
update (y - r1, y, h - 1);
}
#undef update
}
}
typedef struct my_error_mgr {
struct jpeg_error_mgr pub;
jmp_buf setjmp_buffer;
@ -16,6 +109,15 @@ METHODDEF(void) my_error_exit(j_common_ptr cinfo) {
longjmp(myerr->setjmp_buffer, 1);
}
JNIEXPORT void Java_org_telegram_messenger_Utilities_blurBitmap(JNIEnv *env, jclass class, jobject bitmap, int width, int height, int stride) {
void *pixels = 0;
if (AndroidBitmap_lockPixels(env, bitmap, &pixels) < 0) {
return;
}
fastBlur(width, height, stride, pixels);
AndroidBitmap_unlockPixels(env, bitmap);
}
JNIEXPORT void Java_org_telegram_messenger_Utilities_loadBitmap(JNIEnv *env, jclass class, jstring path, jintArray bitmap, int scale, int format, int width, int height) {
int i;

View File

@ -221,4 +221,8 @@ public class AndroidUtilities {
FileLog.e("tmessages", e);
}
}
public static long makeBroadcastId(int id) {
return 0x0000000100000000L | ((long)id & 0x00000000FFFFFFFFL);
}
}

View File

@ -47,10 +47,7 @@ public class ContactsController {
private final Integer observerLock = 1;
public boolean contactsLoaded = false;
private boolean contactsBookLoaded = false;
private int lastContactsPhonesCount = -1;
private int lastContactsPhonesMaxId = -1;
private int lastContactsNamesCount = -1;
private int lastContactsNamesMaxId = -1;
private String lastContactsVersions = "";
private ArrayList<Integer> delayedContactsUpdate = new ArrayList<Integer>();
public static class Contact {
@ -119,10 +116,7 @@ public class ContactsController {
contactsSyncInProgress = false;
contactsLoaded = false;
contactsBookLoaded = false;
lastContactsPhonesCount = -1;
lastContactsPhonesMaxId = -1;
lastContactsNamesCount = -1;
lastContactsNamesMaxId = -1;
lastContactsVersions = "";
}
public void checkAppAccount() {
@ -191,70 +185,17 @@ public class ContactsController {
ContentResolver cr = ApplicationLoader.applicationContext.getContentResolver();
Cursor pCur = null;
try {
pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{ContactsContract.CommonDataKinds.Phone._ID}, null, null, ContactsContract.CommonDataKinds.Phone._ID + " desc LIMIT 1");
if (pCur != null) {
if (pCur.getCount() > 0 && pCur.moveToFirst()) {
int value = pCur.getInt(0);
if (lastContactsPhonesMaxId != -1 && value != lastContactsPhonesMaxId) {
reload = true;
}
lastContactsPhonesMaxId = value;
}
pCur = cr.query(ContactsContract.RawContacts.CONTENT_URI, new String[]{ContactsContract.RawContacts.VERSION}, null, null, null);
StringBuilder currentVersion = new StringBuilder();
while (pCur.moveToNext()) {
int col = pCur.getColumnIndex(ContactsContract.RawContacts.VERSION);
currentVersion.append(pCur.getString(col));
}
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
if (pCur != null) {
pCur.close();
}
}
try {
pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{ContactsContract.CommonDataKinds.Phone._COUNT}, null, null, null);
if (pCur != null) {
if (pCur.getCount() > 0 && pCur.moveToFirst()) {
int value = pCur.getInt(0);
if (lastContactsPhonesCount != -1 && value != lastContactsPhonesCount) {
reload = true;
}
lastContactsPhonesCount = value;
}
}
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
if (pCur != null) {
pCur.close();
}
}
try {
pCur = cr.query(ContactsContract.Data.CONTENT_URI, new String[]{ContactsContract.Data._COUNT}, ContactsContract.Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE + "'", null, null);
if (pCur != null) {
if (pCur.getCount() > 0 && pCur.moveToFirst()) {
int value = pCur.getInt(0);
if (lastContactsNamesCount != -1 && value != lastContactsNamesCount) {
reload = true;
}
lastContactsNamesCount = value;
}
}
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
if (pCur != null) {
pCur.close();
}
}
try {
pCur = cr.query(ContactsContract.Data.CONTENT_URI, new String[]{ContactsContract.Data._ID}, ContactsContract.Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE + "'", null, ContactsContract.Data._ID + " desc LIMIT 1");
if (pCur != null) {
if (pCur.getCount() > 0 && pCur.moveToFirst()) {
int value = pCur.getInt(0);
if (lastContactsNamesMaxId != -1 && value != lastContactsNamesMaxId) {
reload = true;
}
lastContactsNamesMaxId = value;
}
String newContactsVersion = currentVersion.toString();
if (lastContactsVersions.length() != 0 && !lastContactsVersions.equals(newContactsVersion)) {
reload = true;
}
lastContactsVersions = newContactsVersion;
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
@ -368,7 +309,7 @@ public class ContactsController {
String sname2 = pCur.getString(3);
String mname = pCur.getString(4);
Contact contact = contactsMap.get(id);
if (contact != null) {
if (contact != null && contact.first_name.length() == 0 && contact.last_name.length() == 0) {
contact.first_name = fname;
contact.last_name = sname;
if (contact.first_name == null) {
@ -535,7 +476,8 @@ public class ContactsController {
}
}
if (existing == null || existing != null && (!existing.first_name.equals(value.first_name) || !existing.last_name.equals(value.last_name))) {
boolean nameChanged = existing != null && (!existing.first_name.equals(value.first_name) || !existing.last_name.equals(value.last_name));
if (existing == null || nameChanged) {
for (int a = 0; a < value.phones.size(); a++) {
String sphone = value.shortPhones.get(a);
contactsBookShort.put(sphone, value);
@ -550,7 +492,7 @@ public class ContactsController {
}
}
if (request) {
if (contactsByPhone.containsKey(sphone)) {
if (!nameChanged && contactsByPhone.containsKey(sphone)) {
continue;
}

View File

@ -191,7 +191,7 @@ public class MessagesStorage {
}
}
public void cleanUp() {
public void cleanUp(final boolean isLogin) {
storageQueue.cleanupQueue();
storageQueue.postRunnable(new Runnable() {
@Override
@ -217,8 +217,15 @@ public class MessagesStorage {
cacheFile.delete();
cacheFile = null;
}
storageQueue.cleanupQueue();
openDatabase();
if (isLogin) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
MessagesController.getInstance().getDifference();
}
});
}
}
});
}
@ -358,7 +365,19 @@ public class MessagesStorage {
if (!messagesOnly) {
database.executeFast("DELETE FROM dialogs WHERE did = " + did).stepThis().dispose();
database.executeFast("DELETE FROM chat_settings WHERE uid = " + did).stepThis().dispose();
int lower_id = (int)did;
int high_id = (int)(did >> 32);
if (lower_id != 0) {
if (high_id == 1) {
database.executeFast("DELETE FROM chats WHERE uid = " + lower_id).stepThis().dispose();
} else if (lower_id < 0) {
database.executeFast("DELETE FROM chats WHERE uid = " + (-lower_id)).stepThis().dispose();
}
} else {
database.executeFast("DELETE FROM enc_chats WHERE uid = " + high_id).stepThis().dispose();
}
}
database.executeFast("UPDATE dialogs SET unread_count = 0 WHERE did = " + did).stepThis().dispose();
database.executeFast("DELETE FROM media_counts WHERE uid = " + did).stepThis().dispose();
database.executeFast("DELETE FROM messages WHERE uid = " + did).stepThis().dispose();
database.executeFast("DELETE FROM media WHERE uid = " + did).stepThis().dispose();
@ -699,6 +718,11 @@ public class MessagesStorage {
}
}
} else {
for (TLRPC.TL_chatParticipant part : info.participants) {
if (part.user_id == user_id) {
return;
}
}
TLRPC.TL_chatParticipant participant = new TLRPC.TL_chatParticipant();
participant.user_id = user_id;
participant.inviter_id = invited_id;
@ -731,7 +755,7 @@ public class MessagesStorage {
});
}
public void loadChatInfo(final int chat_id) {
public void loadChatInfo(final int chat_id, final Semaphore semaphore) {
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
@ -749,12 +773,22 @@ public class MessagesStorage {
cursor.dispose();
if (info != null) {
boolean modified = false;
ArrayList<Integer> usersArr = new ArrayList<Integer>();
String usersToLoad = "";
for (TLRPC.TL_chatParticipant c : info.participants) {
if (usersToLoad.length() != 0) {
usersToLoad += ",";
for (int a = 0; a < info.participants.size(); a++) {
TLRPC.TL_chatParticipant c = info.participants.get(a);
if (usersArr.contains(c.user_id)) {
info.participants.remove(a);
modified = true;
a--;
} else {
if (usersToLoad.length() != 0) {
usersToLoad += ",";
}
usersArr.add(c.user_id);
usersToLoad += c.user_id;
}
usersToLoad += c.user_id;
}
if (usersToLoad.length() != 0) {
cursor = database.queryFinalized(String.format(Locale.US, "SELECT data, status FROM users WHERE uid IN(%s)", usersToLoad));
@ -771,10 +805,20 @@ public class MessagesStorage {
}
cursor.dispose();
}
if (modified) {
updateChatInfo(chat_id, info, false);
}
}
if (semaphore != null) {
semaphore.release();
}
MessagesController.getInstance().processChatInfo(chat_id, info, loadedUsers, true);
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
if (semaphore != null) {
semaphore.release();
}
}
}
});
@ -900,7 +944,7 @@ public class MessagesStorage {
cursor.dispose();
}
cursor = database.queryFinalized("SELECT c.data, c.name FROM chats as c INNER JOIN dialogs as d ON c.uid = -d.did");
cursor = database.queryFinalized("SELECT data, name FROM chats");
while (cursor.next()) {
String name = cursor.stringValue(1);
String[] args = name.split(" ");
@ -909,6 +953,9 @@ public class MessagesStorage {
ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(0));
if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) {
TLRPC.Chat chat = (TLRPC.Chat) TLClassStore.Instance().TLdeserialize(data, data.readInt32());
if (!needEncrypted && chat.id < 0) {
continue;
}
resultArrayNames.add(Utilities.generateSearchName(chat.title, null, q));
resultArray.add(chat);
}
@ -918,6 +965,7 @@ public class MessagesStorage {
}
}
cursor.dispose();
NotificationCenter.getInstance().postNotificationName(MessagesController.reloadSearchResults, token, resultArray, resultArrayNames, encUsers);
} catch (Exception e) {
FileLog.e("tmessages", e);
@ -1281,14 +1329,14 @@ public class MessagesStorage {
});
}
public void getMessages(final long dialog_id, final int offset, final int count, final int max_id, final int minDate, final int classGuid, final boolean from_unread, final boolean forward) {
public void getMessages(final long dialog_id, final int count, final int max_id, final int minDate, final int classGuid, final boolean from_unread, final boolean forward) {
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
TLRPC.TL_messages_messages res = new TLRPC.TL_messages_messages();
int count_unread = 0;
int count_query = count;
int offset_query = offset;
int offset_query = 0;
int min_unread_id = 0;
int max_unread_id = 0;
int max_unread_date = 0;
@ -1447,7 +1495,7 @@ public class MessagesStorage {
res.users.clear();
FileLog.e("tmessages", e);
} finally {
MessagesController.getInstance().processLoadedMessages(res, dialog_id, offset, count_query, max_id, true, classGuid, min_unread_id, max_unread_id, count_unread, max_unread_date, forward);
MessagesController.getInstance().processLoadedMessages(res, dialog_id, count_query, max_id, true, classGuid, min_unread_id, max_unread_id, count_unread, max_unread_date, forward);
}
}
});
@ -1800,7 +1848,7 @@ public class MessagesStorage {
}
}
private void putMessagesInternal(final ArrayList<TLRPC.Message> messages, final boolean withTransaction) {
private void putMessagesInternal(final ArrayList<TLRPC.Message> messages, final boolean withTransaction, final boolean isBroadcast) {
try {
if (withTransaction) {
database.beginTransaction();
@ -1941,10 +1989,21 @@ public class MessagesStorage {
state.dispose();
state2.dispose();
state3.dispose();
state = database.executeFast("REPLACE INTO dialogs VALUES(?, ?, ifnull((SELECT unread_count FROM dialogs WHERE did = ?), 0) + ?, ?)");
state = database.executeFast("REPLACE INTO dialogs VALUES(?, ?, ?, ?)");
for (HashMap.Entry<Long, TLRPC.Message> pair : messagesMap.entrySet()) {
state.requery();
Long key = pair.getKey();
int dialog_date = 0;
int old_unread_count = 0;
SQLiteCursor cursor = database.queryFinalized("SELECT date, unread_count FROM dialogs WHERE did = " + key);
if (cursor.next()) {
dialog_date = cursor.intValue(0);
old_unread_count = cursor.intValue(1);
}
cursor.dispose();
state.requery();
TLRPC.Message value = pair.getValue();
Integer unread_count = messagesCounts.get(key);
if (unread_count == null) {
@ -1955,10 +2014,13 @@ public class MessagesStorage {
messageId = value.local_id;
}
state.bindLong(1, key);
state.bindInteger(2, value.date);
state.bindLong(3, key);
state.bindInteger(4, unread_count);
state.bindInteger(5, messageId);
if (!isBroadcast) {
state.bindInteger(2, value.date);
} else {
state.bindInteger(2, dialog_date != 0 ? dialog_date : value.date);
}
state.bindInteger(3, old_unread_count + unread_count);
state.bindInteger(4, messageId);
state.step();
}
state.dispose();
@ -1994,7 +2056,7 @@ public class MessagesStorage {
}
}
public void putMessages(final ArrayList<TLRPC.Message> messages, final boolean withTransaction, boolean useQueue) {
public void putMessages(final ArrayList<TLRPC.Message> messages, final boolean withTransaction, boolean useQueue, final boolean isBroadcast) {
if (messages.size() == 0) {
return;
}
@ -2002,11 +2064,11 @@ public class MessagesStorage {
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
putMessagesInternal(messages, withTransaction);
putMessagesInternal(messages, withTransaction, isBroadcast);
}
});
} else {
putMessagesInternal(messages, withTransaction);
putMessagesInternal(messages, withTransaction, isBroadcast);
}
}
@ -2406,20 +2468,26 @@ public class MessagesStorage {
buffersStorage.reuseFreeBuffer(data);
int lower_id = (int)dialog.id;
int high_id = (int)(dialog.id >> 32);
if (lower_id != 0) {
if (lower_id > 0) {
if (!usersToLoad.contains(lower_id)) {
usersToLoad.add(lower_id);
if (high_id == 1) {
if (!chatsToLoad.contains(lower_id)) {
chatsToLoad.add(lower_id);
}
} else {
if (!chatsToLoad.contains(-lower_id)) {
chatsToLoad.add(-lower_id);
if (lower_id > 0) {
if (!usersToLoad.contains(lower_id)) {
usersToLoad.add(lower_id);
}
} else {
if (!chatsToLoad.contains(-lower_id)) {
chatsToLoad.add(-lower_id);
}
}
}
} else {
int encryptedId = (int)(dialog.id >> 32);
if (!encryptedToLoad.contains(encryptedId)) {
encryptedToLoad.add(encryptedId);
if (!encryptedToLoad.contains(high_id)) {
encryptedToLoad.add(high_id);
}
}
}
@ -2673,20 +2741,26 @@ public class MessagesStorage {
buffersStorage.reuseFreeBuffer(data);
int lower_id = (int)dialog.id;
int high_id = (int)(dialog.id >> 32);
if (lower_id != 0) {
if (lower_id > 0) {
if (!usersToLoad.contains(lower_id)) {
usersToLoad.add(lower_id);
if (high_id == 1) {
if (!chatsToLoad.contains(lower_id)) {
chatsToLoad.add(lower_id);
}
} else {
if (!chatsToLoad.contains(-lower_id)) {
chatsToLoad.add(-lower_id);
if (lower_id > 0) {
if (!usersToLoad.contains(lower_id)) {
usersToLoad.add(lower_id);
}
} else {
if (!chatsToLoad.contains(-lower_id)) {
chatsToLoad.add(-lower_id);
}
}
}
} else {
int encryptedId = (int)(dialog.id >> 32);
if (!encryptedToLoad.contains(encryptedId)) {
encryptedToLoad.add(encryptedId);
if (!encryptedToLoad.contains(high_id)) {
encryptedToLoad.add(high_id);
}
}
}

View File

@ -24,9 +24,9 @@ import java.util.zip.ZipFile;
public class NativeLoader {
private static final long sizes[] = new long[] {
799376, //armeabi
848548, //armeabi-v7a
1246260, //x86
803472, //armeabi
856740, //armeabi-v7a
1250356, //x86
0, //mips
};

View File

@ -183,6 +183,8 @@ public class NotificationsController {
}
msg = LocaleController.formatString("NotificationGroupKickMember", R.string.NotificationGroupKickMember, Utilities.formatName(user.first_name, user.last_name), chat.title, Utilities.formatName(u2.first_name, u2.last_name));
}
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatCreate) {
msg = messageObject.messageText.toString();
}
} else {
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) {
@ -305,10 +307,12 @@ public class NotificationsController {
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
intent.setFlags(32768);
if ((int)dialog_id != 0) {
if (chat_id != 0) {
intent.putExtra("chatId", chat_id);
} else if (user_id != 0) {
intent.putExtra("userId", user_id);
if (pushDialogs.size() == 1) {
if (chat_id != 0) {
intent.putExtra("chatId", chat_id);
} else if (user_id != 0) {
intent.putExtra("userId", user_id);
}
}
if (pushDialogs.size() == 1) {
if (chat != null) {
@ -322,7 +326,9 @@ public class NotificationsController {
}
}
} else {
intent.putExtra("encId", (int)(dialog_id >> 32));
if (pushDialogs.size() == 1) {
intent.putExtra("encId", (int) (dialog_id >> 32));
}
}
PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT);
@ -350,7 +356,6 @@ public class NotificationsController {
.setContentTitle(name)
.setSmallIcon(R.drawable.notification)
.setAutoCancel(true)
.setContentText(detailText)
.setContentIntent(contentIntent);
String lastMessage = null;
@ -366,8 +371,10 @@ public class NotificationsController {
message = message.replace(name + ": ", "").replace(name + " ", "");
}
}
mBuilder.setContentText(message);
mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
} else {
mBuilder.setContentText(detailText);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.setBigContentTitle(name);
int count = Math.min(10, pushMessages.size());
@ -395,7 +402,7 @@ public class NotificationsController {
}
if (photoPath != null) {
Bitmap img = FileLoader.getInstance().getImageFromMemory(photoPath, null, null, "50_50", false);
Bitmap img = FileLoader.getInstance().getImageFromMemory(photoPath, null, null, "50_50");
if (img != null) {
mBuilder.setLargeIcon(img);
}
@ -417,6 +424,8 @@ public class NotificationsController {
}
if (needVibrate) {
mBuilder.setVibrate(new long[]{0, 100, 0, 100});
} else {
mBuilder.setVibrate(new long[]{0, 0});
}
} else {
mBuilder.setVibrate(new long[]{0, 0});
@ -485,7 +494,7 @@ public class NotificationsController {
remove = true;
}
} else {
if (messageObject.messageOwner.id <= max_id) {
if (messageObject.messageOwner.id <= max_id || max_id < 0) {
remove = true;
}
}
@ -501,9 +510,6 @@ public class NotificationsController {
if (oldCount != popupMessages.size()) {
NotificationCenter.getInstance().postNotificationName(pushMessagesUpdated);
}
// if (readMessages != null || oldCount2 != pushMessages.size() || readMessages == null && dialog_id == 0) {
// showOrUpdateNotification(notifyCheck);
// }
}
public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) {
@ -529,7 +535,7 @@ public class NotificationsController {
Boolean value = settingsCache.get(dialog_id);
boolean isChat = (int)dialog_id < 0;
popup = preferences.getInt(isChat ? "popupGroup" : "popupAll", 0);
popup = (int)dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0);
if (value == null) {
int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0);
@ -569,32 +575,41 @@ public class NotificationsController {
int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
boolean isChat = (int)dialog_id < 0;
Integer currentCount = pushDialogs.get(dialog_id);
if (!(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0)) {
Integer newCount = entry.getValue();
if (replace) {
if (currentCount != null) {
total_unread_count -= currentCount;
}
if (newCount == 0) {
pushDialogs.remove(dialog_id);
} else {
total_unread_count += newCount;
pushDialogs.put(dialog_id, newCount);
}
} else {
if (currentCount == null) {
currentCount = 0;
}
currentCount += newCount;
total_unread_count += newCount;
pushDialogs.put(dialog_id, currentCount);
boolean canAddValue = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0);
Integer newCount = entry.getValue();
if (replace) {
if (currentCount != null) {
total_unread_count -= currentCount;
}
if (newCount == 0) {
pushDialogs.remove(dialog_id);
for (int a = 0; a < pushMessages.size(); a++) {
MessageObject messageObject = pushMessages.get(a);
if (messageObject.getDialogId() == dialog_id) {
pushMessages.remove(a);
a--;
pushMessagesDict.remove(messageObject.messageOwner.id);
popupMessages.remove(messageObject);
}
}
} else if (canAddValue) {
total_unread_count += newCount;
pushDialogs.put(dialog_id, newCount);
}
} else if (canAddValue) {
if (currentCount == null) {
currentCount = 0;
}
currentCount += newCount;
total_unread_count += newCount;
pushDialogs.put(dialog_id, currentCount);
}
}
if (old_unread_count != total_unread_count) {
showOrUpdateNotification(notifyCheck);
notifyCheck = false;
}
notifyCheck = false;
if (preferences.getBoolean("badgeNumber", true)) {
setBadge(ApplicationLoader.applicationContext, total_unread_count);
}
@ -604,7 +619,6 @@ public class NotificationsController {
pushDialogs.clear();
total_unread_count = 0;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
String dialogsToLoad = "";
for (HashMap.Entry<Long, Integer> entry : dialogs.entrySet()) {
long dialog_id = entry.getKey();
int notify_override = preferences.getInt("notify2_" + dialog_id, 0);
@ -612,10 +626,6 @@ public class NotificationsController {
if (!(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0)) {
pushDialogs.put(dialog_id, entry.getValue());
total_unread_count += entry.getValue();
if (dialogsToLoad.length() != 0) {
dialogsToLoad += ",";
}
dialogsToLoad += "" + dialog_id;
}
}
if (total_unread_count == 0) {

View File

@ -781,6 +781,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
processRequestQueue(RPCRequest.RPCRequestClassTransportMask, 0);
}
MessagesController.getInstance().updateConfig(config);
}
updatingDcSettings = false;
}
@ -850,7 +851,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
}
public long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, final RPCRequest.RPCQuickAckDelegate quickAckBlock, final boolean requiresCompletion, final int requestClass, final int datacenterId, final boolean runQueue) {
if (!UserConfig.isClientActivated() && (requestClass & RPCRequest.RPCRequestClassWithoutLogin) == 0) {
if (rpc == null || !UserConfig.isClientActivated() && (requestClass & RPCRequest.RPCRequestClassWithoutLogin) == 0) {
FileLog.e("tmessages", "can't do request without login " + rpc);
return 0;
}
@ -1752,7 +1753,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
}
private void registerForPush() {
if (registeringForPush) {
if (registeringForPush || !UserConfig.isClientActivated()) {
return;
}
UserConfig.registeredForInternalPush = false;
@ -1805,6 +1806,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
UserConfig.saveConfig(false);
saveSession();
FileLog.e("tmessages", "registered for internal push");
} else {
UserConfig.registeredForInternalPush = false;
}
registeringForPush = false;
}

View File

@ -10,16 +10,17 @@ package org.telegram.messenger;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.provider.MediaStore;
import org.telegram.android.AndroidUtilities;
import org.telegram.ui.ApplicationLoader;
import java.io.RandomAccessFile;
import java.net.URL;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
@ -57,9 +58,8 @@ public class FileLoadOperation {
private String ext;
private String httpUrl;
private URLConnection httpConnection;
private DownloadImageTask httpTask = null;
public boolean needBitmapCreate = true;
private InputStream httpConnectionStream;
private RandomAccessFile fileOutputStream;
private RandomAccessFile fiv;
@ -69,6 +69,109 @@ public class FileLoadOperation {
public abstract void didChangedLoadProgress(FileLoadOperation operation, float progress);
}
private class DownloadImageTask extends AsyncTask<String, Void, Boolean> {
protected Boolean doInBackground(String... urls) {
String url = urls[0];
InputStream httpConnectionStream = null;
try {
URL downloadUrl = new URL(url);
URLConnection httpConnection = downloadUrl.openConnection();
httpConnection.setConnectTimeout(5000);
httpConnection.setReadTimeout(5000);
httpConnection.connect();
httpConnectionStream = httpConnection.getInputStream();
/*String ALLOWED_URI_CHARS = "@#&=*+-_.,:!?()/~'%";
String str = Uri.encode(url, ALLOWED_URI_CHARS);
HttpClient httpclient = new DefaultHttpClient();
HttpGet request = new HttpGet(str);
httpConnectionStream = httpclient.execute(request).getEntity().getContent();*/
} catch (Exception e) {
FileLog.e("tmessages", e);
cleanup();
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
delegate.didFailedLoadingFile(FileLoadOperation.this);
}
});
return false;
}
byte[] data = new byte[1024 * 2];
while (true) {
if (isCancelled()) {
break;
}
try {
int readed = httpConnectionStream.read(data);
if (readed > 0) {
fileOutputStream.write(data, 0, readed);
} else if (readed == -1) {
FileLoader.fileLoaderQueue.postRunnable(new Runnable() {
@Override
public void run() {
cleanup();
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
onFinishLoadingFile();
} catch (Exception e) {
delegate.didFailedLoadingFile(FileLoadOperation.this);
}
}
});
}
});
break;
} else {
FileLoader.fileLoaderQueue.postRunnable(new Runnable() {
@Override
public void run() {
cleanup();
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
delegate.didFailedLoadingFile(FileLoadOperation.this);
}
});
}
});
break;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
FileLoader.fileLoaderQueue.postRunnable(new Runnable() {
@Override
public void run() {
cleanup();
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
delegate.didFailedLoadingFile(FileLoadOperation.this);
}
});
}
});
}
}
try {
if (httpConnectionStream != null) {
httpConnectionStream.close();
}
httpConnectionStream = null;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return true;
}
}
public FileLoadOperation(TLRPC.FileLocation fileLocation) {
if (fileLocation instanceof TLRPC.TL_fileEncryptedLocation) {
location = new TLRPC.TL_inputEncryptedFileLocation();
@ -248,10 +351,14 @@ public class FileLoadOperation {
float w_filter = 0;
float h_filter = 0;
boolean blur = false;
if (filter != null) {
String args[] = filter.split("_");
w_filter = Float.parseFloat(args[0]) * AndroidUtilities.density;
h_filter = Float.parseFloat(args[1]) * AndroidUtilities.density;
if (args.length > 2) {
blur = true;
}
opts.inJustDecodeBounds = true;
if (mediaIdFinal != null) {
@ -270,7 +377,7 @@ public class FileLoadOperation {
opts.inSampleSize = (int)scaleFactor;
}
if (filter == null) {
if (filter == null || blur) {
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
} else {
opts.inPreferredConfig = Bitmap.Config.RGB_565;
@ -300,7 +407,9 @@ public class FileLoadOperation {
image = scaledBitmap;
}
}
if (image != null && blur && bitmapH < 100 && bitmapW < 100) {
Utilities.blurBitmap(image, (int)bitmapW, (int)bitmapH, image.getRowBytes());
}
}
if (FileLoader.getInstance().runtimeHack != null) {
FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
@ -400,7 +509,6 @@ public class FileLoadOperation {
}
}
});
}
}
}
@ -428,14 +536,8 @@ public class FileLoadOperation {
private void cleanup() {
if (httpUrl != null) {
try {
if (httpConnectionStream != null) {
httpConnectionStream.close();
}
httpConnection = null;
httpConnectionStream = null;
} catch (Exception e) {
FileLog.e("tmessages", e);
if (httpTask != null) {
httpTask.cancel(true);
}
} else {
try {
@ -494,10 +596,14 @@ public class FileLoadOperation {
float w_filter = 0;
float h_filter;
boolean blur = false;
if (filter != null) {
String args[] = filter.split("_");
w_filter = Float.parseFloat(args[0]) * AndroidUtilities.density;
h_filter = Float.parseFloat(args[1]) * AndroidUtilities.density;
if (args.length > 2) {
blur = true;
}
opts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(cacheFileFinal.getAbsolutePath(), opts);
@ -511,7 +617,7 @@ public class FileLoadOperation {
opts.inSampleSize = (int) scaleFactor;
}
if (filter == null) {
if (filter == null || blur) {
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
} else {
opts.inPreferredConfig = Bitmap.Config.RGB_565;
@ -540,7 +646,9 @@ public class FileLoadOperation {
image = scaledBitmap;
}
}
if (image != null && blur && bitmapH < 100 && bitmapW < 100) {
Utilities.blurBitmap(image, (int)bitmapW, (int)bitmapH, image.getRowBytes());
}
}
if (image != null && FileLoader.getInstance().runtimeHack != null) {
FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
@ -565,68 +673,11 @@ public class FileLoadOperation {
if (state != 1) {
return;
}
if (httpConnection == null) {
try {
URL downloadUrl = new URL(httpUrl);
httpConnection = downloadUrl.openConnection();
httpConnection.setConnectTimeout(5000);
httpConnection.setReadTimeout(5000);
httpConnection.connect();
httpConnectionStream = httpConnection.getInputStream();
} catch (Exception e) {
FileLog.e("tmessages", e);
cleanup();
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
delegate.didFailedLoadingFile(FileLoadOperation.this);
}
});
return;
}
}
try {
byte[] data = new byte[1024 * 2];
int readed = httpConnectionStream.read(data);
if (readed > 0) {
fileOutputStream.write(data, 0, readed);
FileLoader.fileLoaderQueue.postRunnable(new Runnable() {
@Override
public void run() {
startDownloadHTTPRequest();
}
});
} else if (readed == -1) {
cleanup();
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
onFinishLoadingFile();
} catch (Exception e) {
delegate.didFailedLoadingFile(FileLoadOperation.this);
}
}
});
} else {
cleanup();
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
delegate.didFailedLoadingFile(FileLoadOperation.this);
}
});
}
} catch (Exception e) {
cleanup();
FileLog.e("tmessages", e);
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
delegate.didFailedLoadingFile(FileLoadOperation.this);
}
});
httpTask = new DownloadImageTask();
if (android.os.Build.VERSION.SDK_INT >= 11) {
httpTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
} else {
httpTask.execute(null, null, null);
}
}

View File

@ -64,7 +64,7 @@ public class FileLoader {
private long lastProgressUpdateTime = 0;
private HashMap<String, Integer> BitmapUseCounts = new HashMap<String, Integer>();
int lastImageNum;
private int lastImageNum = 0;
public static final int FileDidUpload = 10000;
public static final int FileDidFailUpload = 10001;
@ -717,15 +717,15 @@ public class FileLoader {
});
}
public Bitmap getImageFromMemory(TLRPC.FileLocation url, ImageReceiver imageView, String filter, boolean cancel) {
return getImageFromMemory(url, null, imageView, filter, cancel);
public Bitmap getImageFromMemory(TLRPC.FileLocation url, ImageReceiver imageView, String filter) {
return getImageFromMemory(url, null, imageView, filter);
}
public Bitmap getImageFromMemory(String url, ImageReceiver imageView, String filter, boolean cancel) {
return getImageFromMemory(null, url, imageView, filter, cancel);
public Bitmap getImageFromMemory(String url, ImageReceiver imageView, String filter) {
return getImageFromMemory(null, url, imageView, filter);
}
public Bitmap getImageFromMemory(TLRPC.FileLocation url, String httpUrl, ImageReceiver imageView, String filter, boolean cancel) {
public Bitmap getImageFromMemory(TLRPC.FileLocation url, String httpUrl, ImageReceiver imageView, String filter) {
if (url == null && httpUrl == null) {
return null;
}
@ -739,11 +739,7 @@ public class FileLoader {
key += "@" + filter;
}
Bitmap img = imageFromKey(key);
if (imageView != null && img != null && cancel) {
cancelLoadingForImageView(imageView);
}
return img;
return imageFromKey(key);
}
private void performReplace(String oldKey, String newKey) {
@ -1105,8 +1101,13 @@ public class FileLoader {
return null;
}
float scaleFactor = Math.max(photoW / maxWidth, photoH / maxHeight);
int w = (int)(photoW / scaleFactor);
int h = (int)(photoH / scaleFactor);
if (h == 0 || w == 0) {
return null;
}
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, (int)(photoW / scaleFactor), (int)(photoH / scaleFactor), true);
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, w, h, true);
TLRPC.TL_fileLocation location = new TLRPC.TL_fileLocation();
location.volume_id = Integer.MIN_VALUE;

View File

@ -63,12 +63,12 @@ public class FileLog {
e.printStackTrace();
}
try {
logQueue = new DispatchQueue("logQueue");
currentFile.createNewFile();
FileOutputStream stream = new FileOutputStream(currentFile);
streamWriter = new OutputStreamWriter(stream);
streamWriter.write("-----start log " + dateFormat.format(System.currentTimeMillis()) + "-----\n");
streamWriter.flush();
logQueue = new DispatchQueue("logQueue");
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -439,6 +439,7 @@ public class TLClassStore {
classStore.put(TLRPC.TL_decryptedMessageMediaAudio_old.constructor, TLRPC.TL_decryptedMessageMediaAudio_old.class);
classStore.put(TLRPC.TL_audio_old.constructor, TLRPC.TL_audio_old.class);
classStore.put(TLRPC.TL_video_old.constructor, TLRPC.TL_video_old.class);
classStore.put(TLRPC.TL_messageActionCreatedBroadcastList.constructor, TLRPC.TL_messageActionCreatedBroadcastList.class);
}
static TLClassStore store = null;

View File

@ -8996,6 +8996,17 @@ public class TLRPC {
}
}
public static class TL_messageActionCreatedBroadcastList extends MessageAction {
public static int constructor = 0x55555557;
public void readParams(AbsSerializedData stream) {
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
}
}
public static class TL_documentEncrypted extends TL_document {
public static int constructor = 0x55555556;

View File

@ -24,6 +24,7 @@ public class UserConfig {
public static String pushString = "";
public static int lastSendMessageId = -210000;
public static int lastLocalId = -210000;
public static int lastBroadcastId = -1;
public static String contactsHash = "";
public static String importHash = "";
private final static Integer sync = 1;
@ -56,6 +57,7 @@ public class UserConfig {
editor.putString("importHash", importHash);
editor.putBoolean("saveIncomingPhotos", saveIncomingPhotos);
editor.putInt("contactsVersion", contactsVersion);
editor.putInt("lastBroadcastId", lastBroadcastId);
editor.putBoolean("registeredForInternalPush", registeredForInternalPush);
if (currentUser != null) {
if (withFile) {
@ -174,6 +176,7 @@ public class UserConfig {
importHash = preferences.getString("importHash", "");
saveIncomingPhotos = preferences.getBoolean("saveIncomingPhotos", false);
contactsVersion = preferences.getInt("contactsVersion", 0);
lastBroadcastId = preferences.getInt("lastBroadcastId", -1);
registeredForInternalPush = preferences.getBoolean("registeredForInternalPush", false);
String user = preferences.getString("user", null);
if (user != null) {
@ -196,6 +199,7 @@ public class UserConfig {
lastLocalId = -210000;
lastSendMessageId = -210000;
contactsVersion = 1;
lastBroadcastId = -1;
saveIncomingPhotos = false;
saveConfig(true);
}

View File

@ -132,6 +132,7 @@ public class Utilities {
public native static long doPQNative(long _what);
public native static void loadBitmap(String path, int[] bitmap, int scale, int format, int width, int height);
public native static void blurBitmap(Object bitmap, int width, int height, int stride);
private native static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, int offset, int length);
public static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, boolean changeIv, int offset, int length) {
@ -139,6 +140,9 @@ public class Utilities {
}
public static Integer parseInt(String value) {
if (value == null) {
return 0;
}
Integer val = 0;
try {
Matcher matcher = pattern.matcher(value);
@ -548,7 +552,7 @@ public class Utilities {
}
public static int getGroupAvatarForId(int id) {
return arrGroupsAvatars[getColorIndex(-id)];
return arrGroupsAvatars[getColorIndex(-Math.abs(id))];
}
public static String MD5(String md5) {

View File

@ -39,7 +39,6 @@ public class MessageObject {
public int contentType;
public ArrayList<PhotoObject> photoThumbs;
public Bitmap imagePreview;
public PhotoObject previewPhoto;
public String dateKey;
public boolean deleted = false;
public float audioProgress;
@ -63,6 +62,10 @@ public class MessageObject {
public ArrayList<TextLayoutBlock> textLayoutBlocks;
public MessageObject(TLRPC.Message message, AbstractMap<Integer, TLRPC.User> users) {
this(message, users, 1);
}
public MessageObject(TLRPC.Message message, AbstractMap<Integer, TLRPC.User> users, int preview) {
if (textPaint == null) {
textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
textPaint.setColor(0xff000000);
@ -134,10 +137,6 @@ public class MessageObject {
messageText = LocaleController.getString("ActionAddUser", R.string.ActionAddUser).replace("un2", "").replace("un1", "");
}
} else if (message.action instanceof TLRPC.TL_messageActionChatEditPhoto) {
photoThumbs = new ArrayList<PhotoObject>();
for (TLRPC.PhotoSize size : message.action.photo.sizes) {
photoThumbs.add(new PhotoObject(size));
}
if (isFromMe()) {
messageText = LocaleController.getString("ActionYouChangedPhoto", R.string.ActionYouChangedPhoto);
} else {
@ -232,26 +231,14 @@ public class MessageObject {
}
}
}
} else if (message.action instanceof TLRPC.TL_messageActionCreatedBroadcastList) {
messageText = LocaleController.formatString("YouCreatedBroadcastList", R.string.YouCreatedBroadcastList);
}
}
} else if (message.media != null && !(message.media instanceof TLRPC.TL_messageMediaEmpty)) {
if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
photoThumbs = new ArrayList<PhotoObject>();
for (TLRPC.PhotoSize size : message.media.photo.sizes) {
PhotoObject obj = new PhotoObject(size);
photoThumbs.add(obj);
if (imagePreview == null && obj.image != null) {
imagePreview = obj.image;
}
}
messageText = LocaleController.getString("AttachPhoto", R.string.AttachPhoto);
} else if (message.media instanceof TLRPC.TL_messageMediaVideo) {
photoThumbs = new ArrayList<PhotoObject>();
PhotoObject obj = new PhotoObject(message.media.video.thumb);
photoThumbs.add(obj);
if (imagePreview == null && obj.image != null) {
imagePreview = obj.image;
}
messageText = LocaleController.getString("AttachVideo", R.string.AttachVideo);
} else if (message.media instanceof TLRPC.TL_messageMediaGeo) {
messageText = LocaleController.getString("AttachLocation", R.string.AttachLocation);
@ -260,11 +247,6 @@ public class MessageObject {
} else if (message.media instanceof TLRPC.TL_messageMediaUnsupported) {
messageText = LocaleController.getString("UnsuppotedMedia", R.string.UnsuppotedMedia);
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
if (!(message.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty)) {
photoThumbs = new ArrayList<PhotoObject>();
PhotoObject obj = new PhotoObject(message.media.document.thumb);
photoThumbs.add(obj);
}
messageText = LocaleController.getString("AttachDocument", R.string.AttachDocument);
} else if (message.media instanceof TLRPC.TL_messageMediaAudio) {
messageText = LocaleController.getString("AttachAudio", R.string.AttachAudio);
@ -329,6 +311,80 @@ public class MessageObject {
dateKey = String.format("%d_%02d_%02d", dateYear, dateMonth, dateDay);
generateLayout();
generateThumbs(false, preview);
}
public void generateThumbs(boolean update, int preview) {
if (messageOwner instanceof TLRPC.TL_messageService) {
if (messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto) {
if (!update) {
photoThumbs = new ArrayList<PhotoObject>();
for (TLRPC.PhotoSize size : messageOwner.action.photo.sizes) {
photoThumbs.add(new PhotoObject(size, preview));
}
} else if (photoThumbs != null && !photoThumbs.isEmpty()) {
for (PhotoObject photoObject : photoThumbs) {
for (TLRPC.PhotoSize size : messageOwner.action.photo.sizes) {
if (size instanceof TLRPC.TL_photoSizeEmpty) {
continue;
}
if (size.type.equals(photoObject.photoOwner.type)) {
photoObject.photoOwner.location = size.location;
break;
}
}
}
}
}
} else if (messageOwner.media != null && !(messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
if (!update) {
photoThumbs = new ArrayList<PhotoObject>();
for (TLRPC.PhotoSize size : messageOwner.media.photo.sizes) {
PhotoObject obj = new PhotoObject(size, preview);
photoThumbs.add(obj);
if (imagePreview == null && obj.image != null) {
imagePreview = obj.image;
}
}
} else if (photoThumbs != null && !photoThumbs.isEmpty()) {
for (PhotoObject photoObject : photoThumbs) {
for (TLRPC.PhotoSize size : messageOwner.media.photo.sizes) {
if (size instanceof TLRPC.TL_photoSizeEmpty) {
continue;
}
if (size.type.equals(photoObject.photoOwner.type)) {
photoObject.photoOwner.location = size.location;
break;
}
}
}
}
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaVideo) {
if (!update) {
photoThumbs = new ArrayList<PhotoObject>();
PhotoObject obj = new PhotoObject(messageOwner.media.video.thumb, preview);
photoThumbs.add(obj);
if (imagePreview == null && obj.image != null) {
imagePreview = obj.image;
}
} else if (photoThumbs != null && !photoThumbs.isEmpty() && messageOwner.media.video.thumb != null) {
PhotoObject photoObject = photoThumbs.get(0);
photoObject.photoOwner.location = messageOwner.media.video.thumb.location;
}
} if (messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
if (!(messageOwner.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty)) {
if (!update) {
photoThumbs = new ArrayList<PhotoObject>();
PhotoObject obj = new PhotoObject(messageOwner.media.document.thumb, preview);
photoThumbs.add(obj);
} else if (photoThumbs != null && !photoThumbs.isEmpty() && messageOwner.media.document.thumb != null) {
PhotoObject photoObject = photoThumbs.get(0);
photoObject.photoOwner.location = messageOwner.media.document.thumb.location;
}
}
}
}
}
public String getFileName() {

View File

@ -13,6 +13,7 @@ import android.graphics.BitmapFactory;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.Utilities;
import java.util.ArrayList;
@ -20,18 +21,23 @@ public class PhotoObject {
public TLRPC.PhotoSize photoOwner;
public Bitmap image;
public PhotoObject(TLRPC.PhotoSize photo) {
public PhotoObject(TLRPC.PhotoSize photo, int preview) {
photoOwner = photo;
if (photo instanceof TLRPC.TL_photoCachedSize) {
if (preview != 0 && photo instanceof TLRPC.TL_photoCachedSize) {
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPreferredConfig = Bitmap.Config.RGB_565;
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
opts.inDither = false;
opts.outWidth = photo.w;
opts.outHeight = photo.h;
image = BitmapFactory.decodeByteArray(photoOwner.bytes, 0, photoOwner.bytes.length, opts);
if (image != null && FileLoader.getInstance().runtimeHack != null) {
FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
if (image != null) {
if (preview == 2) {
Utilities.blurBitmap(image, image.getWidth(), image.getHeight(), image.getRowBytes());
}
if (FileLoader.getInstance().runtimeHack != null) {
FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
}
}
}
}

View File

@ -8,7 +8,6 @@
package org.telegram.ui;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.Application;
import android.app.PendingIntent;
@ -93,34 +92,6 @@ public class ApplicationLoader extends Application {
UserConfig.loadConfig();
if (UserConfig.getCurrentUser() != null) {
boolean changed = false;
SharedPreferences preferences = applicationContext.getSharedPreferences("Notifications", MODE_PRIVATE);
int v = preferences.getInt("v", 0);
if (v != 1) {
SharedPreferences preferences2 = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences2.edit();
if (preferences.contains("view_animations")) {
editor.putBoolean("view_animations", preferences.getBoolean("view_animations", false));
}
if (preferences.contains("selectedBackground")) {
editor.putInt("selectedBackground", preferences.getInt("selectedBackground", 1000001));
}
if (preferences.contains("selectedColor")) {
editor.putInt("selectedColor", preferences.getInt("selectedColor", 0));
}
if (preferences.contains("fons_size")) {
editor.putInt("fons_size", preferences.getInt("fons_size", 16));
}
editor.commit();
editor = preferences.edit();
editor.putInt("v", 1);
editor.remove("view_animations");
editor.remove("selectedBackground");
editor.remove("selectedColor");
editor.remove("fons_size");
editor.commit();
}
MessagesController.getInstance().users.put(UserConfig.getClientUserId(), UserConfig.getCurrentUser());
ConnectionsManager.getInstance().applyCountryPortNumber(UserConfig.getCurrentUser().phone);
ConnectionsManager.getInstance().initPushConnection();

View File

@ -60,9 +60,11 @@ public class ChatBaseCell extends BaseCell {
private static Drawable checkDrawable;
private static Drawable halfCheckDrawable;
private static Drawable clockDrawable;
private static Drawable broadcastDrawable;
private static Drawable checkMediaDrawable;
private static Drawable halfCheckMediaDrawable;
private static Drawable clockMediaDrawable;
private static Drawable broadcastMediaDrawable;
private static Drawable errorDrawable;
protected static Drawable mediaBackgroundDrawable;
private static TextPaint timePaintIn;
@ -177,6 +179,8 @@ public class ChatBaseCell extends BaseCell {
clockMediaDrawable = getResources().getDrawable(R.drawable.msg_clock_photo);
errorDrawable = getResources().getDrawable(R.drawable.msg_warning);
mediaBackgroundDrawable = getResources().getDrawable(R.drawable.phototime);
broadcastDrawable = getResources().getDrawable(R.drawable.broadcast3);
broadcastMediaDrawable = getResources().getDrawable(R.drawable.broadcast4);
timePaintIn = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
timePaintIn.setTextSize(AndroidUtilities.dp(12));
@ -569,6 +573,7 @@ public class ChatBaseCell extends BaseCell {
boolean drawCheck2 = false;
boolean drawClock = false;
boolean drawError = false;
boolean isBroadcast = (int)(currentMessageObject.getDialogId() >> 32) == 1;
if (currentMessageObject.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SENDING) {
drawCheck1 = false;
@ -601,30 +606,42 @@ public class ChatBaseCell extends BaseCell {
clockMediaDrawable.draw(canvas);
}
}
if (drawCheck2) {
if (!media) {
if (drawCheck1) {
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dpf(22.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - checkDrawable.getIntrinsicHeight());
if (isBroadcast) {
if (drawCheck1 || drawCheck2) {
if (!media) {
setDrawableBounds(broadcastDrawable, layoutWidth - AndroidUtilities.dpf(20.5f) - broadcastDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.0f) - broadcastDrawable.getIntrinsicHeight());
broadcastDrawable.draw(canvas);
} else {
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dpf(18.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - checkDrawable.getIntrinsicHeight());
setDrawableBounds(broadcastMediaDrawable, layoutWidth - AndroidUtilities.dpf(24.0f) - broadcastMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - broadcastMediaDrawable.getIntrinsicHeight());
broadcastMediaDrawable.draw(canvas);
}
checkDrawable.draw(canvas);
} else {
if (drawCheck1) {
setDrawableBounds(checkMediaDrawable, layoutWidth - AndroidUtilities.dpf(26.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - checkMediaDrawable.getIntrinsicHeight());
} else {
setDrawableBounds(checkMediaDrawable, layoutWidth - AndroidUtilities.dpf(22.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - checkMediaDrawable.getIntrinsicHeight());
}
checkMediaDrawable.draw(canvas);
}
}
if (drawCheck1) {
if (!media) {
setDrawableBounds(halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - halfCheckDrawable.getIntrinsicHeight());
halfCheckDrawable.draw(canvas);
} else {
setDrawableBounds(halfCheckMediaDrawable, layoutWidth - AndroidUtilities.dpf(20.5f) - halfCheckMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - halfCheckMediaDrawable.getIntrinsicHeight());
halfCheckMediaDrawable.draw(canvas);
} else {
if (drawCheck2) {
if (!media) {
if (drawCheck1) {
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dpf(22.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - checkDrawable.getIntrinsicHeight());
} else {
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dpf(18.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - checkDrawable.getIntrinsicHeight());
}
checkDrawable.draw(canvas);
} else {
if (drawCheck1) {
setDrawableBounds(checkMediaDrawable, layoutWidth - AndroidUtilities.dpf(26.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - checkMediaDrawable.getIntrinsicHeight());
} else {
setDrawableBounds(checkMediaDrawable, layoutWidth - AndroidUtilities.dpf(22.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - checkMediaDrawable.getIntrinsicHeight());
}
checkMediaDrawable.draw(canvas);
}
}
if (drawCheck1) {
if (!media) {
setDrawableBounds(halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - halfCheckDrawable.getIntrinsicHeight());
halfCheckDrawable.draw(canvas);
} else {
setDrawableBounds(halfCheckMediaDrawable, layoutWidth - AndroidUtilities.dpf(20.5f) - halfCheckMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - halfCheckMediaDrawable.getIntrinsicHeight());
halfCheckMediaDrawable.draw(canvas);
}
}
}
if (drawError) {

View File

@ -31,7 +31,7 @@ import org.telegram.objects.PhotoObject;
import org.telegram.ui.PhotoViewer;
import org.telegram.ui.Views.GifDrawable;
import org.telegram.ui.Views.ImageReceiver;
import org.telegram.ui.Views.ProgressView;
import org.telegram.ui.Views.RoundProgressView;
import java.io.File;
import java.util.Locale;
@ -45,7 +45,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
private static Drawable placeholderInDrawable;
private static Drawable placeholderOutDrawable;
private static Drawable videoIconDrawable;
private static Drawable[][] buttonStatesDrawables = new Drawable[4][2];
private static Drawable[] buttonStatesDrawables = new Drawable[4];
private static TextPaint infoPaint;
private static MessageObject lastDownloadedGifMessage = null;
@ -57,10 +57,11 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
private String currentUrl;
private String currentPhotoFilter;
private ImageReceiver photoImage;
private ProgressView progressView;
private RoundProgressView progressView;
public int downloadPhotos = 0;
private boolean progressVisible = false;
private boolean photoNotSet = false;
private boolean cancelLoading = false;
private int TAG;
@ -83,14 +84,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
if (placeholderInDrawable == null) {
placeholderInDrawable = getResources().getDrawable(R.drawable.photo_placeholder_in);
placeholderOutDrawable = getResources().getDrawable(R.drawable.photo_placeholder_out);
buttonStatesDrawables[0][0] = getResources().getDrawable(R.drawable.photoload);
buttonStatesDrawables[0][1] = getResources().getDrawable(R.drawable.photoload_pressed);
buttonStatesDrawables[1][0] = getResources().getDrawable(R.drawable.photocancel);
buttonStatesDrawables[1][1] = getResources().getDrawable(R.drawable.photocancel_pressed);
buttonStatesDrawables[2][0] = getResources().getDrawable(R.drawable.photogif);
buttonStatesDrawables[2][1] = getResources().getDrawable(R.drawable.photogif_pressed);
buttonStatesDrawables[3][0] = getResources().getDrawable(R.drawable.playvideo);
buttonStatesDrawables[3][1] = getResources().getDrawable(R.drawable.playvideo_pressed);
buttonStatesDrawables[0] = getResources().getDrawable(R.drawable.photoload);
buttonStatesDrawables[1] = getResources().getDrawable(R.drawable.photocancel);
buttonStatesDrawables[2] = getResources().getDrawable(R.drawable.photogif);
buttonStatesDrawables[3] = getResources().getDrawable(R.drawable.playvideo);
videoIconDrawable = getResources().getDrawable(R.drawable.ic_video);
infoPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
@ -102,8 +99,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
photoImage = new ImageReceiver();
photoImage.parentView = this;
progressView = new ProgressView();
progressView.setProgressColors(0x802a2a2a, 0xffffffff);
progressView = new RoundProgressView();
}
public void clearGifImage() {
@ -225,6 +221,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
private void didPressedButton() {
if (buttonState == 0) {
cancelLoading = false;
if (currentMessageObject.type == 1) {
if (currentMessageObject.imagePreview != null) {
photoImage.setImage(currentPhotoObject.photoOwner.location, currentPhotoFilter, new BitmapDrawable(currentMessageObject.imagePreview), currentPhotoObject.photoOwner.size);
@ -246,6 +243,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
delegate.didPressedCancelSendButton(this);
}
} else {
cancelLoading = true;
if (currentMessageObject.type == 1) {
FileLoader.getInstance().cancelLoadingForImageView(photoImage);
} else if (currentMessageObject.type == 8) {
@ -304,6 +302,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
public void setMessageObject(MessageObject messageObject) {
if (currentMessageObject != messageObject || isPhotoDataChanged(messageObject) || isUserDataChanged()) {
super.setMessageObject(messageObject);
cancelLoading = false;
progressVisible = false;
buttonState = -1;
@ -395,6 +394,9 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
photoHeight = h;
backgroundWidth = w + AndroidUtilities.dp(12);
currentPhotoFilter = String.format(Locale.US, "%d_%d", (int) (w / AndroidUtilities.density), (int) (h / AndroidUtilities.density));
if (messageObject.photoThumbs.size() > 1 || messageObject.type == 3 || messageObject.type == 8) {
currentPhotoFilter += "_b";
}
if (currentPhotoObject.image != null) {
photoImage.setImageBitmap(currentPhotoObject.image);
@ -485,20 +487,16 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
if (!cacheFile.exists()) {
MediaController.getInstance().addLoadingFileObserver(fileName, this);
if (!FileLoader.getInstance().isLoadingFile(fileName)) {
if (currentMessageObject.type != 1 || downloadPhotos == 1 || downloadPhotos == 2 && !ConnectionsManager.isConnectedToWiFi()) {
if (cancelLoading || currentMessageObject.type != 1 || downloadPhotos == 1 || downloadPhotos == 2 && !ConnectionsManager.isConnectedToWiFi()) {
buttonState = 0;
progressVisible = false;
} else {
buttonState = -1;
buttonState = 1;
progressVisible = true;
}
progressView.setProgress(0);
} else {
if (currentMessageObject.type != 1 || downloadPhotos == 1 || downloadPhotos == 2 && !ConnectionsManager.isConnectedToWiFi()) {
buttonState = 1;
} else {
buttonState = -1;
}
buttonState = 1;
progressVisible = true;
Float progress = FileLoader.getInstance().fileProgresses.get(fileName);
if (progress != null) {
@ -544,13 +542,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
photoImage.imageW = photoWidth;
photoImage.imageH = photoHeight;
progressView.width = timeX - photoImage.imageX - AndroidUtilities.dpf(23.0f);
progressView.height = AndroidUtilities.dp(3);
progressView.progressHeight = AndroidUtilities.dp(3);
int size = AndroidUtilities.dp(44);
buttonX = (int)(photoImage.imageX + (photoWidth - size) / 2.0f);
buttonY = (int)(photoImage.imageY + (photoHeight - size) / 2.0f);
progressView.rect.set(buttonX + AndroidUtilities.dp(2), buttonY + AndroidUtilities.dp(2), buttonX + AndroidUtilities.dp(42), buttonY + AndroidUtilities.dp(42));
}
@Override
@ -566,22 +561,16 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
drawTime = photoImage.getVisible();
}
if (progressVisible) {
setDrawableBounds(mediaBackgroundDrawable, photoImage.imageX + AndroidUtilities.dp(4), layoutHeight - AndroidUtilities.dpf(27.5f), progressView.width + AndroidUtilities.dp(12), AndroidUtilities.dpf(16.5f));
mediaBackgroundDrawable.draw(canvas);
canvas.save();
canvas.translate(photoImage.imageX + AndroidUtilities.dp(10), layoutHeight - AndroidUtilities.dpf(21.0f));
progressView.draw(canvas);
canvas.restore();
}
if (buttonState >= 0 && buttonState < 4) {
Drawable currentButtonDrawable = buttonStatesDrawables[buttonState][buttonPressed];
Drawable currentButtonDrawable = buttonStatesDrawables[buttonState];
setDrawableBounds(currentButtonDrawable, buttonX, buttonY);
currentButtonDrawable.draw(canvas);
}
if (progressVisible) {
progressView.draw(canvas);
}
if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3)) {
setDrawableBounds(mediaBackgroundDrawable, photoImage.imageX + AndroidUtilities.dp(4), photoImage.imageY + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dpf(16.5f));
mediaBackgroundDrawable.draw(canvas);

View File

@ -35,6 +35,8 @@ public class ChatOrUserCell extends BaseCell {
private static TextPaint offlinePaint;
private static Drawable lockDrawable;
private static Drawable broadcastDrawable;
private static Drawable groupDrawable;
private static Paint linePaint;
private CharSequence currentName;
@ -93,6 +95,14 @@ public class ChatOrUserCell extends BaseCell {
linePaint.setColor(0xffdcdcdc);
}
if (broadcastDrawable == null) {
broadcastDrawable = getResources().getDrawable(R.drawable.broadcast);
}
if (groupDrawable == null) {
groupDrawable = getResources().getDrawable(R.drawable.grouplist);
}
if (avatarImage == null) {
avatarImage = new ImageReceiver();
avatarImage.parentView = this;
@ -230,6 +240,12 @@ public class ChatOrUserCell extends BaseCell {
if (cellLayout.drawNameLock) {
setDrawableBounds(lockDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
lockDrawable.draw(canvas);
} else if (cellLayout.drawNameGroup) {
setDrawableBounds(groupDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
groupDrawable.draw(canvas);
} else if (cellLayout.drawNameBroadcast) {
setDrawableBounds(broadcastDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
broadcastDrawable.draw(canvas);
}
canvas.save();
@ -262,8 +278,10 @@ public class ChatOrUserCell extends BaseCell {
private int nameWidth;
private StaticLayout nameLayout;
private boolean drawNameLock;
private boolean drawNameBroadcast;
private boolean drawNameGroup;
private int nameLockLeft;
private int nameLockTop = AndroidUtilities.dp(15);
private int nameLockTop;
private int onlineLeft;
private int onlineTop = AndroidUtilities.dp(36);
@ -277,6 +295,10 @@ public class ChatOrUserCell extends BaseCell {
CharSequence nameString = "";
TextPaint currentNamePaint;
drawNameBroadcast = false;
drawNameLock = false;
drawNameGroup = false;
if (encryptedChat != null) {
drawNameLock = true;
if (!LocaleController.isRTL) {
@ -286,12 +308,28 @@ public class ChatOrUserCell extends BaseCell {
nameLockLeft = width - AndroidUtilities.dp(63 + (usePadding ? 11 : 0)) - lockDrawable.getIntrinsicWidth();
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
}
nameLockTop = AndroidUtilities.dp(15);
} else {
drawNameLock = false;
if (!LocaleController.isRTL) {
nameLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
if (chat != null) {
nameLockTop = AndroidUtilities.dp(26);
if (chat.id < 0) {
drawNameBroadcast = true;
} else {
drawNameGroup = true;
}
if (!LocaleController.isRTL) {
nameLockLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
nameLeft = AndroidUtilities.dp(65 + (usePadding ? 11 : 0)) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
} else {
nameLockLeft = width - AndroidUtilities.dp(63 + (usePadding ? 11 : 0)) - (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
}
} else {
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
if (!LocaleController.isRTL) {
nameLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
} else {
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
}
}
}
@ -326,6 +364,8 @@ public class ChatOrUserCell extends BaseCell {
}
if (drawNameLock) {
nameWidth -= AndroidUtilities.dp(6) + lockDrawable.getIntrinsicWidth();
} else if (drawNameBroadcast) {
nameWidth -= AndroidUtilities.dp(6) + broadcastDrawable.getIntrinsicWidth();
}
CharSequence nameStringFinal = TextUtils.ellipsize(nameString, currentNamePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);

View File

@ -46,6 +46,7 @@ public class DialogCell extends BaseCell {
private static Drawable lockDrawable;
private static Drawable countDrawable;
private static Drawable groupDrawable;
private static Drawable broadcastDrawable;
private TLRPC.TL_dialog currentDialog;
private ImageReceiver avatarImage;
@ -130,6 +131,10 @@ public class DialogCell extends BaseCell {
groupDrawable = getResources().getDrawable(R.drawable.grouplist);
}
if (broadcastDrawable == null) {
broadcastDrawable = getResources().getDrawable(R.drawable.broadcast);
}
if (avatarImage == null) {
avatarImage = new ImageReceiver();
avatarImage.parentView = this;
@ -220,14 +225,19 @@ public class DialogCell extends BaseCell {
encryptedChat = null;
int lower_id = (int)currentDialog.id;
int high_id = (int)(currentDialog.id >> 32);
if (lower_id != 0) {
if (lower_id < 0) {
chat = MessagesController.getInstance().chats.get(-lower_id);
if (high_id == 1) {
chat = MessagesController.getInstance().chats.get(lower_id);
} else {
user = MessagesController.getInstance().users.get(lower_id);
if (lower_id < 0) {
chat = MessagesController.getInstance().chats.get(-lower_id);
} else {
user = MessagesController.getInstance().users.get(lower_id);
}
}
} else {
encryptedChat = MessagesController.getInstance().encryptedChats.get((int)(currentDialog.id >> 32));
encryptedChat = MessagesController.getInstance().encryptedChats.get(high_id);
if (encryptedChat != null) {
user = MessagesController.getInstance().users.get(encryptedChat.user_id);
}
@ -274,6 +284,9 @@ public class DialogCell extends BaseCell {
} else if (cellLayout.drawNameGroup) {
setDrawableBounds(groupDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
groupDrawable.draw(canvas);
} else if (cellLayout.drawNameBroadcast) {
setDrawableBounds(broadcastDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
broadcastDrawable.draw(canvas);
}
canvas.save();
@ -328,6 +341,7 @@ public class DialogCell extends BaseCell {
private StaticLayout nameLayout;
private boolean drawNameLock;
private boolean drawNameGroup;
private boolean drawNameBroadcast;
private int nameLockLeft;
private int nameLockTop;
@ -372,9 +386,12 @@ public class DialogCell extends BaseCell {
TextPaint currentMessagePaint = messagePaint;
boolean checkMessage = true;
drawNameGroup = false;
drawNameBroadcast = false;
drawNameLock = false;
if (encryptedChat != null) {
drawNameLock = true;
drawNameGroup = false;
nameLockTop = AndroidUtilities.dp(13);
if (!LocaleController.isRTL) {
nameLockLeft = AndroidUtilities.dp(77);
@ -384,19 +401,21 @@ public class DialogCell extends BaseCell {
nameLeft = AndroidUtilities.dp(14);
}
} else {
drawNameLock = false;
if (chat != null) {
drawNameGroup = true;
if (chat.id < 0) {
drawNameBroadcast = true;
} else {
drawNameGroup = true;
}
nameLockTop = AndroidUtilities.dp(14);
if (!LocaleController.isRTL) {
nameLockLeft = AndroidUtilities.dp(77);
nameLeft = AndroidUtilities.dp(81) + groupDrawable.getIntrinsicWidth();
nameLeft = AndroidUtilities.dp(81) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
} else {
nameLockLeft = width - AndroidUtilities.dp(77) - groupDrawable.getIntrinsicWidth();
nameLockLeft = width - AndroidUtilities.dp(77) - (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
nameLeft = AndroidUtilities.dp(14);
}
} else {
drawNameGroup = false;
if (!LocaleController.isRTL) {
nameLeft = AndroidUtilities.dp(77);
} else {
@ -461,7 +480,7 @@ public class DialogCell extends BaseCell {
messageString = message.messageText;
currentMessagePaint = messagePrintingPaint;
} else {
if (chat != null) {
if (chat != null && chat.id > 0) {
String name = "";
if (message.isFromMe()) {
name = LocaleController.getString("FromYou", R.string.FromYou);
@ -505,7 +524,7 @@ public class DialogCell extends BaseCell {
}
}
if (message.isFromMe()) {
if (message.isFromMe() && message.isOut()) {
if (message.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SENDING) {
drawCheck1 = false;
drawCheck2 = false;
@ -579,6 +598,8 @@ public class DialogCell extends BaseCell {
nameWidth -= AndroidUtilities.dp(4) + lockDrawable.getIntrinsicWidth();
} else if (drawNameGroup) {
nameWidth -= AndroidUtilities.dp(4) + groupDrawable.getIntrinsicWidth();
} else if (drawNameBroadcast) {
nameWidth -= AndroidUtilities.dp(4) + broadcastDrawable.getIntrinsicWidth();
}
if (drawClock) {
int w = clockDrawable.getIntrinsicWidth() + AndroidUtilities.dp(2);

View File

@ -8,6 +8,7 @@
package org.telegram.ui;
import android.animation.Animator;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
@ -129,6 +130,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private View pagedownButton;
private TextView topPanelText;
private long dialog_id;
private boolean isBraodcast = false;
private HashMap<Integer, MessageObject> selectedMessagesIds = new HashMap<Integer, MessageObject>();
private HashMap<Integer, MessageObject> selectedMessagesCanCopyIds = new HashMap<Integer, MessageObject>();
@ -141,10 +143,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean endReached = false;
private boolean loading = false;
private boolean cacheEndReaced = false;
private boolean firstLoading = true;
private int minDate = 0;
private int progressTag = 0;
boolean first = true;
private boolean first = true;
private int unread_to_load = 0;
private int first_unread_id = 0;
private int last_unread_id = 0;
@ -211,8 +214,24 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return false;
}
}
MessagesController.getInstance().loadChatInfo(currentChat.id);
dialog_id = -chatId;
if (chatId > 0) {
dialog_id = -chatId;
} else {
isBraodcast = true;
dialog_id = AndroidUtilities.makeBroadcastId(chatId);
}
Semaphore semaphore = null;
if (isBraodcast) {
semaphore = new Semaphore(0);
}
MessagesController.getInstance().loadChatInfo(currentChat.id, semaphore);
if (isBraodcast) {
try {
semaphore.acquire();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
} else if (userId != 0) {
currentUser = MessagesController.getInstance().users.get(userId);
if (currentUser == null) {
@ -331,7 +350,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
super.onFragmentCreate();
loading = true;
MessagesController.getInstance().loadMessages(dialog_id, 0, 30, 0, true, 0, classGuid, true, false);
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, true, 0, classGuid, true, false);
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
if (currentChat != null) {
@ -456,7 +475,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (info != null && info instanceof TLRPC.TL_chatParticipantsForbidden) {
return;
}
if (currentChat.participants_count == 0 || currentChat.left || currentChat instanceof TLRPC.TL_chatForbidden) {
int count = currentChat.participants_count;
if (info != null) {
count = info.participants.size();
}
if (count == 0 || currentChat.left || currentChat instanceof TLRPC.TL_chatForbidden) {
return;
}
Bundle args = new Bundle();
@ -528,6 +551,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (currentEncryptedChat != null) {
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4));
} else if (currentChat != null && currentChat.id < 0) {
actionBarLayer.setTitleIcon(R.drawable.broadcast2, AndroidUtilities.dp(4));
}
ActionBarMenu menu = actionBarLayer.createMenu();
@ -609,6 +634,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
View bottomOverlayChat = fragmentView.findViewById(R.id.bottom_overlay_chat);
progressView = fragmentView.findViewById(R.id.progressLayout);
pagedownButton = fragmentView.findViewById(R.id.pagedown_button);
pagedownButton.setVisibility(View.GONE);
View progressViewInner = progressView.findViewById(R.id.progressLayoutInner);
@ -719,24 +745,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (firstVisibleItem <= 4) {
if (!endReached && !loading) {
if (messagesByDays.size() != 0) {
MessagesController.getInstance().loadMessages(dialog_id, 0, 20, maxMessageId, !cacheEndReaced, minDate, classGuid, false, false);
MessagesController.getInstance().loadMessages(dialog_id, 20, maxMessageId, !cacheEndReaced, minDate, classGuid, false, false);
} else {
MessagesController.getInstance().loadMessages(dialog_id, 0, 20, 0, !cacheEndReaced, minDate, classGuid, false, false);
MessagesController.getInstance().loadMessages(dialog_id, 20, 0, !cacheEndReaced, minDate, classGuid, false, false);
}
loading = true;
}
}
if (firstVisibleItem + visibleItemCount >= totalItemCount - 6) {
if (!unread_end_reached && !loadingForward) {
MessagesController.getInstance().loadMessages(dialog_id, 0, 20, minMessageId, true, maxDate, classGuid, false, true);
MessagesController.getInstance().loadMessages(dialog_id, 20, minMessageId, true, maxDate, classGuid, false, true);
loadingForward = true;
}
}
if (firstVisibleItem + visibleItemCount == totalItemCount && unread_end_reached) {
showPagedownButton(false, true);
}
} else {
showPagedownButton(false, false);
}
for (int a = 0; a < visibleItemCount; a++) {
View view = absListView.getChildAt(a);
@ -853,9 +877,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
maxDate = Integer.MIN_VALUE;
minDate = 0;
unread_end_reached = true;
MessagesController.getInstance().loadMessages(dialog_id, 0, 30, 0, true, 0, classGuid, true, false);
loading = true;
chatAdapter.notifyDataSetChanged();
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, true, 0, classGuid, true, false);
}
}
@ -865,7 +889,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (show) {
if (pagedownButton.getVisibility() == View.GONE) {
if (android.os.Build.VERSION.SDK_INT >= 16 && animated) {
if (android.os.Build.VERSION.SDK_INT > 13 && animated) {
pagedownButton.setVisibility(View.VISIBLE);
pagedownButton.setAlpha(0);
pagedownButton.animate().alpha(1).setDuration(200).start();
@ -875,13 +899,28 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
} else {
if (pagedownButton.getVisibility() == View.VISIBLE) {
if (android.os.Build.VERSION.SDK_INT >= 16 && animated) {
pagedownButton.animate().alpha(0).withEndAction(new Runnable() {
if (android.os.Build.VERSION.SDK_INT > 13 && animated) {
pagedownButton.animate().alpha(0).setDuration(200).setListener(new Animator.AnimatorListener() {
@Override
public void run() {
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
pagedownButton.setVisibility(View.GONE);
}
}).setDuration(200).start();
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
}).start();
} else {
pagedownButton.setVisibility(View.GONE);
}
@ -1045,7 +1084,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private int getMessageType(MessageObject messageObject) {
if (currentEncryptedChat == null) {
if (messageObject.messageOwner.id <= 0 && messageObject.isOut()) {
boolean isBroadcastError = isBraodcast && messageObject.messageOwner.id <= 0 && messageObject.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR;
if (!isBraodcast && messageObject.messageOwner.id <= 0 && messageObject.isOut() || isBroadcastError) {
if (messageObject.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR) {
if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
return 0;
@ -1224,10 +1264,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else if (currentChat.left) {
actionBarLayer.setSubtitle(LocaleController.getString("YouLeft", R.string.YouLeft));
} else {
if (onlineCount > 0 && currentChat.participants_count != 0) {
actionBarLayer.setSubtitle(String.format("%s, %d %s", LocaleController.formatPluralString("Members", currentChat.participants_count), onlineCount, LocaleController.getString("Online", R.string.Online)));
int count = currentChat.participants_count;
if (info != null) {
count = info.participants.size();
}
if (onlineCount > 0 && count != 0) {
actionBarLayer.setSubtitle(String.format("%s, %d %s", LocaleController.formatPluralString("Members", count), onlineCount, LocaleController.getString("Online", R.string.Online)));
} else {
actionBarLayer.setSubtitle(LocaleController.formatPluralString("Members", currentChat.participants_count));
actionBarLayer.setSubtitle(LocaleController.formatPluralString("Members", count));
}
}
} else if (currentUser != null) {
@ -1447,6 +1491,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (tempPath != null) {
File temp = new File(tempPath);
originalPath += temp.length() + "_" + temp.lastModified();
} else {
originalPath = null;
}
TLRPC.TL_photo photo = (TLRPC.TL_photo)MessagesStorage.getInstance().getSentFile(originalPath, currentEncryptedChat == null ? 0 : 3);
if (photo == null && uri != null) {
@ -1664,24 +1710,42 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (id == MessagesController.messagesDidLoaded) {
long did = (Long)args[0];
if (did == dialog_id) {
int offset = (Integer)args[1];
int count = (Integer)args[2];
boolean isCache = (Boolean)args[4];
int fnid = (Integer)args[5];
int last_unread_date = (Integer)args[8];
boolean forwardLoad = (Boolean)args[9];
int count = (Integer)args[1];
boolean isCache = (Boolean)args[3];
int fnid = (Integer)args[4];
int last_unread_date = (Integer)args[7];
boolean forwardLoad = (Boolean)args[8];
boolean wasUnread = false;
boolean positionToUnread = false;
if (fnid != 0) {
first_unread_id = (Integer)args[5];
last_unread_id = (Integer)args[6];
unread_to_load = (Integer)args[7];
first_unread_id = fnid;
last_unread_id = (Integer)args[5];
unread_to_load = (Integer)args[6];
positionToUnread = true;
}
ArrayList<MessageObject> messArr = (ArrayList<MessageObject>)args[3];
ArrayList<MessageObject> messArr = (ArrayList<MessageObject>)args[2];
int newRowsCount = 0;
unread_end_reached = last_unread_id == 0;
if (firstLoading) {
if (!unread_end_reached) {
messages.clear();
messagesByDays.clear();
messagesDict.clear();
if (currentEncryptedChat == null) {
maxMessageId = Integer.MAX_VALUE;
minMessageId = Integer.MIN_VALUE;
} else {
maxMessageId = Integer.MIN_VALUE;
minMessageId = Integer.MAX_VALUE;
}
maxDate = Integer.MIN_VALUE;
minDate = 0;
}
firstLoading = false;
}
for (int a = 0; a < messArr.size(); a++) {
MessageObject obj = messArr.get(a);
if (messagesDict.containsKey(obj.messageOwner.id)) {
@ -1771,7 +1835,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (messArr.size() != count) {
if (isCache) {
cacheEndReaced = true;
if (currentEncryptedChat != null) {
if (currentEncryptedChat != null || isBraodcast) {
endReached = true;
}
} else {
@ -1849,9 +1913,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (first && messages.size() > 0) {
if (last_unread_id != 0) {
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, last_unread_id, 0, last_unread_date, wasUnread);
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, last_unread_id, 0, last_unread_date, wasUnread, false);
} else {
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, minMessageId, 0, maxDate, wasUnread);
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, minMessageId, 0, maxDate, wasUnread, false);
}
first = false;
}
@ -1932,7 +1996,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
readWithMid = currentMinMsgId;
} else {
if (messages.size() > 0) {
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, currentMinMsgId, 0, currentMaxDate, true);
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, currentMinMsgId, 0, currentMaxDate, true, false);
}
}
}
@ -2010,15 +2074,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
lastVisible++;
}
if (lastVisible == oldCount) {
if (paused) {
scrollToTopOnResume = true;
} else {
chatListView.post(new Runnable() {
@Override
public void run() {
chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop());
}
});
if (!firstLoading) {
if (paused) {
scrollToTopOnResume = true;
} else {
chatListView.post(new Runnable() {
@Override
public void run() {
chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop());
}
});
}
}
} else {
showPagedownButton(true, true);
@ -2033,7 +2099,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
readWithDate = maxDate;
readWithMid = minMessageId;
} else {
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, minMessageId, 0, maxDate, true);
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, minMessageId, 0, maxDate, true, false);
}
}
}
@ -2090,7 +2156,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
maxDate = Integer.MIN_VALUE;
minDate = 0;
MessagesController.getInstance().loadMessages(dialog_id, 0, 30, 0, !cacheEndReaced, minDate, classGuid, false, false);
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, !cacheEndReaced, minDate, classGuid, false, false);
loading = true;
}
}
@ -2106,6 +2172,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
MessageObject newMsgObj = (MessageObject)args[2];
if (newMsgObj != null) {
obj.messageOwner.media = newMsgObj.messageOwner.media;
obj.generateThumbs(true, 1);
}
messagesDict.remove(msgId);
messagesDict.put(newMsgId, obj);
@ -2388,7 +2455,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
messageObject.messageOwner.unread = false;
}
readWhenResume = false;
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, readWithMid, 0, readWithDate, true);
MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, readWithMid, 0, readWithDate, true, false);
}
fixLayout(true);
@ -2897,24 +2964,24 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private void forwardSelectedMessages(long did, boolean fromMyName) {
if (forwaringMessage != null) {
if (forwaringMessage.messageOwner.id > 0) {
if (!fromMyName) {
if (!fromMyName) {
if (forwaringMessage.messageOwner.id > 0) {
MessagesController.getInstance().sendMessage(forwaringMessage, did);
} else {
processForwardFromMe(forwaringMessage, did);
}
} else {
processForwardFromMe(forwaringMessage, did);
}
forwaringMessage = null;
} else {
ArrayList<Integer> ids = new ArrayList<Integer>(selectedMessagesIds.keySet());
Collections.sort(ids);
for (Integer id : ids) {
if (id > 0) {
if (!fromMyName) {
if (!fromMyName) {
if (id > 0) {
MessagesController.getInstance().sendMessage(selectedMessagesIds.get(id), did);
} else {
processForwardFromMe(selectedMessagesIds.get(id), did);
}
} else {
processForwardFromMe(selectedMessagesIds.get(id), did);
}
}
selectedMessagesCanCopyIds.clear();
@ -2925,7 +2992,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public void didSelectDialog(MessagesActivity activity, long did, boolean param) {
if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty())) {
if (isBraodcast) {
param = true;
}
if (did != dialog_id) {
int lower_part = (int)did;
if (lower_part != 0) {
@ -2937,8 +3006,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
args.putInt("chat_id", -lower_part);
}
presentFragment(new ChatActivity(args), true);
removeSelfFromStack();
forwardSelectedMessages(did, param);
removeSelfFromStack();
} else {
activity.finishFragment();
}

View File

@ -112,7 +112,9 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
NotificationCenter.getInstance().addObserver(this, MessagesController.closeChats);
updateOnlineCount();
MessagesController.getInstance().getMediaCount(-chat_id, classGuid, true);
if (chat_id > 0) {
MessagesController.getInstance().getMediaCount(-chat_id, classGuid, true);
}
avatarUpdater.delegate = new AvatarUpdater.AvatarUpdaterDelegate() {
@Override
public void didUploadedPhoto(TLRPC.InputFile file, TLRPC.PhotoSize small, TLRPC.PhotoSize big) {
@ -131,15 +133,18 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
private void updateRowsIds() {
rowCount = 0;
avatarRow = rowCount++;
settingsSectionRow = rowCount++;
settingsNotificationsRow = rowCount++;
sharedMediaSectionRow = rowCount++;
sharedMediaRow = rowCount++;
if (chat_id > 0) {
settingsSectionRow = rowCount++;
settingsNotificationsRow = rowCount++;
sharedMediaSectionRow = rowCount++;
sharedMediaRow = rowCount++;
}
if (info != null && !(info instanceof TLRPC.TL_chatParticipantsForbidden)) {
membersSectionRow = rowCount++;
rowCount += info.participants.size();
membersEndRow = rowCount;
if (info.participants.size() < 200) {
int maxCount = chat_id > 0 ? MessagesController.getInstance().maxGroupCount : MessagesController.getInstance().maxBroadcastCount;
if (info.participants.size() < maxCount) {
addMemberRow = rowCount++;
} else {
addMemberRow = -1;
@ -149,7 +154,9 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
addMemberRow = -1;
membersSectionRow = -1;
}
leaveGroupRow = rowCount++;
if (chat_id > 0) {
leaveGroupRow = rowCount++;
}
}
@Override
@ -166,7 +173,11 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
actionBarLayer.setTitle(LocaleController.getString("GroupInfo", R.string.GroupInfo));
if (chat_id > 0) {
actionBarLayer.setTitle(LocaleController.getString("GroupInfo", R.string.GroupInfo));
} else {
actionBarLayer.setTitle(LocaleController.getString("BroadcastList", R.string.BroadcastList));
}
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
@ -181,7 +192,11 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
View item = menu.addItemResource(done_button, R.layout.group_profile_add_member_layout);
TextView textView = (TextView)item.findViewById(R.id.done_button);
if (textView != null) {
textView.setText(LocaleController.getString("AddMember", R.string.AddMember));
if (chat_id > 0) {
textView.setText(LocaleController.getString("AddMember", R.string.AddMember));
} else {
textView.setText(LocaleController.getString("AddRecipient", R.string.AddRecipient));
}
}
fragmentView = inflater.inflate(R.layout.chat_profile_layout, container, false);
@ -206,7 +221,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
selectedUser = user;
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items = new CharSequence[] {LocaleController.getString("KickFromGroup", R.string.KickFromGroup)};
CharSequence[] items = new CharSequence[] {chat_id > 0 ? LocaleController.getString("KickFromGroup", R.string.KickFromGroup) : LocaleController.getString("KickFromBroadcast", R.string.KickFromBroadcast)};
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
@ -259,7 +274,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
@Override
public void didSelectContact(TLRPC.User user, String param) {
MessagesController.getInstance().addUserToChat(chat_id, user, info, Utilities.parseInt(param));
MessagesController.getInstance().addUserToChat(chat_id, user, info, param != null ? Utilities.parseInt(param) : 0);
}
@Override
@ -276,7 +291,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
@Override
public void restoreSelfArgs(Bundle args) {
MessagesController.getInstance().loadChatInfo(chat_id);
MessagesController.getInstance().loadChatInfo(chat_id, null);
if (avatarUpdater != null) {
avatarUpdater.currentPicturePath = args.getString("path");
}
@ -461,7 +476,9 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
args.putBoolean("destroyAfterSelect", true);
args.putBoolean("usersAsSections", true);
args.putBoolean("returnAsResult", true);
args.putString("selectAlertString", LocaleController.getString("AddToTheGroup", R.string.AddToTheGroup));
if (chat_id > 0) {
args.putString("selectAlertString", LocaleController.getString("AddToTheGroup", R.string.AddToTheGroup));
}
ContactsActivity fragment = new ContactsActivity(args);
fragment.setDelegate(this);
if (info != null) {
@ -546,52 +563,56 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
});
final ImageButton button2 = (ImageButton)view.findViewById(R.id.settings_change_avatar_button);
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items;
int type;
TLRPC.Chat chat = MessagesController.getInstance().chats.get(chat_id);
if (chat.photo == null || chat.photo.photo_big == null || chat.photo instanceof TLRPC.TL_chatPhotoEmpty) {
items = new CharSequence[] {LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)};
type = 0;
} else {
items = new CharSequence[] {LocaleController.getString("OpenPhoto", R.string.OpenPhoto), LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
type = 1;
}
final int arg0 = type;
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int action = 0;
if (arg0 == 1) {
if (i == 0) {
action = 0;
} else if (i == 1) {
action = 1;
} else if (i == 2) {
action = 2;
} else if (i == 3) {
action = 3;
}
} else if (arg0 == 0) {
if (i == 0) {
action = 1;
} else if (i == 1) {
action = 2;
}
}
processPhotoMenu(action);
if (chat_id > 0) {
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getParentActivity() == null) {
return;
}
});
showAlertDialog(builder);
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items;
int type;
TLRPC.Chat chat = MessagesController.getInstance().chats.get(chat_id);
if (chat.photo == null || chat.photo.photo_big == null || chat.photo instanceof TLRPC.TL_chatPhotoEmpty) {
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)};
type = 0;
} else {
items = new CharSequence[]{LocaleController.getString("OpenPhoto", R.string.OpenPhoto), LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
type = 1;
}
final int arg0 = type;
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int action = 0;
if (arg0 == 1) {
if (i == 0) {
action = 0;
} else if (i == 1) {
action = 1;
} else if (i == 2) {
action = 2;
} else if (i == 3) {
action = 3;
}
} else if (arg0 == 0) {
if (i == 0) {
action = 1;
} else if (i == 1) {
action = 2;
}
}
processPhotoMenu(action);
}
});
showAlertDialog(builder);
}
});
} else {
button2.setVisibility(View.GONE);
}
} else {
onlineText = (TextView)view.findViewById(R.id.settings_online);
}
@ -603,10 +624,15 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
textView.setText(chat.title);
if (chat.participants_count != 0 && onlineCount > 0) {
onlineText.setText(Html.fromHtml(String.format("%s, <font color='#357aa8'>%d %s</font>", LocaleController.formatPluralString("Members", chat.participants_count), onlineCount, LocaleController.getString("Online", R.string.Online))));
int count = chat.participants_count;
if (info != null) {
count = info.participants.size();
}
if (count != 0 && onlineCount > 0) {
onlineText.setText(Html.fromHtml(String.format("%s, <font color='#357aa8'>%d %s</font>", LocaleController.formatPluralString("Members", count), onlineCount, LocaleController.getString("Online", R.string.Online))));
} else {
onlineText.setText(LocaleController.formatPluralString("Members", chat.participants_count));
onlineText.setText(LocaleController.formatPluralString("Members", count));
}
TLRPC.FileLocation photo = null;
@ -630,7 +656,11 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
textView.setText(LocaleController.getString("SHAREDMEDIA", R.string.SHAREDMEDIA));
} else if (i == membersSectionRow) {
TLRPC.Chat chat = MessagesController.getInstance().chats.get(chat_id);
textView.setText(LocaleController.formatPluralString("Members", chat.participants_count).toUpperCase());
int count = chat.participants_count;
if (info != null) {
count = info.participants.size();
}
textView.setText(LocaleController.formatPluralString("Members", count).toUpperCase());
}
} else if (type == 2) {
if (view == null) {
@ -665,7 +695,13 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.chat_profile_add_row, viewGroup, false);
TextView textView = (TextView)view.findViewById(R.id.messages_list_row_name);
textView.setText(LocaleController.getString("AddMember", R.string.AddMember));
if (chat_id > 0) {
textView.setText(LocaleController.getString("AddMember", R.string.AddMember));
} else {
textView.setText(LocaleController.getString("AddRecipient", R.string.AddRecipient));
View divider = view.findViewById(R.id.settings_row_divider);
divider.setVisibility(View.INVISIBLE);
}
}
} else if (type == 5) {
if (view == null) {

View File

@ -76,7 +76,11 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
TLRPC.Chat currentChat = MessagesController.getInstance().chats.get(chat_id);
firstNameField = (EditText)fragmentView.findViewById(R.id.first_name_field);
firstNameField.setHint(LocaleController.getString("GroupName", R.string.GroupName));
if (chat_id > 0) {
firstNameField.setHint(LocaleController.getString("GroupName", R.string.GroupName));
} else {
firstNameField.setHint(LocaleController.getString("EnterListName", R.string.EnterListName));
}
firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
@ -91,7 +95,11 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
firstNameField.setSelection(firstNameField.length());
TextView headerLabel = (TextView)fragmentView.findViewById(R.id.settings_section_text);
headerLabel.setText(LocaleController.getString("EnterGroupNameTitle", R.string.EnterGroupNameTitle));
if (chat_id > 0) {
headerLabel.setText(LocaleController.getString("EnterGroupNameTitle", R.string.EnterGroupNameTitle));
} else {
headerLabel.setText(LocaleController.getString("EnterListName", R.string.EnterListName).toUpperCase());
}
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {

View File

@ -90,6 +90,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
private TextView emptyTextView;
private EditText userSelectEditText;
private boolean ignoreChange = false;
private boolean isBroadcast = false;
private int maxCount = 200;
private HashMap<Integer, XImageSpan> selectedContacts = new HashMap<Integer, XImageSpan>();
private ArrayList<XImageSpan> allSpans = new ArrayList<XImageSpan>();
@ -105,6 +107,16 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
private final static int done_button = 1;
public GroupCreateActivity() {
super();
}
public GroupCreateActivity(Bundle args) {
super(args);
isBroadcast = args.getBoolean("broadcast", false);
maxCount = !isBroadcast ? MessagesController.getInstance().maxGroupCount : MessagesController.getInstance().maxBroadcastCount;
}
@Override
public boolean onFragmentCreate() {
NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
@ -126,8 +138,12 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), 200));
if (isBroadcast) {
actionBarLayer.setTitle(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
} else {
actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
}
actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
@Override
@ -140,6 +156,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
result.addAll(selectedContacts.keySet());
Bundle args = new Bundle();
args.putIntegerArrayList("result", result);
args.putBoolean("broadcast", isBroadcast);
presentFragment(new GroupCreateFinalActivity(args));
}
}
@ -201,7 +218,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
selectedContacts.remove(sp.uid);
}
}
actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), 200));
actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
listView.invalidateViews();
} else {
search = true;
@ -259,7 +276,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
userSelectEditText.setSelection(text.length());
ignoreChange = false;
} else {
if (selectedContacts.size() == 200) {
if (selectedContacts.size() == maxCount) {
return;
}
ignoreChange = true;
@ -267,7 +284,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
span.uid = user.id;
ignoreChange = false;
}
actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), 200));
actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
if (searching || searchWas) {
searching = false;
searchWas = false;

View File

@ -54,11 +54,13 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
private AvatarUpdater avatarUpdater = new AvatarUpdater();
private ProgressDialog progressDialog = null;
private String nameToSet = null;
private boolean isBroadcast = false;
private final static int done_button = 1;
public GroupCreateFinalActivity(Bundle args) {
super(args);
isBroadcast = args.getBoolean("broadcast", false);
}
@SuppressWarnings("unchecked")
@ -120,7 +122,11 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
if (isBroadcast) {
actionBarLayer.setTitle(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
} else {
actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
}
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
@Override
@ -136,29 +142,33 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
}
donePressed = true;
if (avatarUpdater.uploadingAvatar != null) {
createAfterUpload = true;
if (isBroadcast) {
MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar, isBroadcast);
} else {
progressDialog = new ProgressDialog(getParentActivity());
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
if (avatarUpdater.uploadingAvatar != null) {
createAfterUpload = true;
} else {
progressDialog = new ProgressDialog(getParentActivity());
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
final long reqId = MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar);
final long reqId = MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar, isBroadcast);
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ConnectionsManager.getInstance().cancelRpc(reqId, true);
donePressed = false;
try {
dialog.dismiss();
} catch (Exception e) {
FileLog.e("tmessages", e);
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ConnectionsManager.getInstance().cancelRpc(reqId, true);
donePressed = false;
try {
dialog.dismiss();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
}
});
progressDialog.show();
});
progressDialog.show();
}
}
}
}
@ -173,45 +183,53 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
fragmentView = inflater.inflate(R.layout.group_create_final_layout, container, false);
final ImageButton button2 = (ImageButton)fragmentView.findViewById(R.id.settings_change_avatar_button);
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items;
if (avatar != null) {
items = new CharSequence[] {LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
} else {
items = new CharSequence[] {LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)};
}
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0) {
avatarUpdater.openCamera();
} else if (i == 1) {
avatarUpdater.openGallery();
} else if (i == 2) {
avatar = null;
uploadedAvatar = null;
avatarImage.setImage(avatar, "50_50", R.drawable.group_blue);
}
if (isBroadcast) {
button2.setVisibility(View.GONE);
} else {
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getParentActivity() == null) {
return;
}
});
showAlertDialog(builder);
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items;
if (avatar != null) {
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
} else {
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)};
}
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0) {
avatarUpdater.openCamera();
} else if (i == 1) {
avatarUpdater.openGallery();
} else if (i == 2) {
avatar = null;
uploadedAvatar = null;
avatarImage.setImage(avatar, "50_50", R.drawable.group_blue);
}
}
});
showAlertDialog(builder);
}
});
}
avatarImage = (BackupImageView)fragmentView.findViewById(R.id.settings_avatar_image);
avatarImage.setImageResource(R.drawable.group_blue);
nameTextView = (EditText)fragmentView.findViewById(R.id.bubble_input_text);
nameTextView.setHint(LocaleController.getString("EnterGroupNamePlaceholder", R.string.EnterGroupNamePlaceholder));
if (isBroadcast) {
nameTextView.setHint(LocaleController.getString("EnterListName", R.string.EnterListName));
} else {
nameTextView.setHint(LocaleController.getString("EnterGroupNamePlaceholder", R.string.EnterGroupNamePlaceholder));
}
if (nameToSet != null) {
nameTextView.setText(nameToSet);
nameToSet = null;
@ -237,7 +255,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
avatarImage.setImage(avatar, "50_50", R.drawable.group_blue);
if (createAfterUpload) {
FileLog.e("tmessages", "avatar did uploaded");
MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar);
MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar, false);
}
}
});

View File

@ -85,7 +85,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
currentConnectionState = ConnectionsManager.getInstance().getConnectionState();
NotificationCenter.getInstance().addObserver(this, 1234);
NotificationCenter.getInstance().addObserver(this, 658);
NotificationCenter.getInstance().addObserver(this, 701);
NotificationCenter.getInstance().addObserver(this, 702);
NotificationCenter.getInstance().addObserver(this, 703);
@ -149,6 +148,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
Integer push_chat_id = 0;
Integer push_enc_id = 0;
Integer open_settings = 0;
boolean showDialogsList = false;
photoPathsArray = null;
videoPath = null;
@ -379,6 +379,8 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
push_enc_id = encId;
}
} else {
showDialogsList = true;
}
}
}
@ -408,6 +410,11 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
if (presentFragment(fragment, false, true)) {
pushOpened = true;
}
} else if (showDialogsList) {
for (int a = 1; a < fragmentsStack.size(); a++) {
removeFragmentFromStack(fragmentsStack.get(a));
a--;
}
}
if (videoPath != null || photoPathsArray != null || sendingText != null || documentsPathsArray != null || contactsToSend != null) {
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
@ -440,18 +447,23 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
public void didSelectDialog(MessagesActivity messageFragment, long dialog_id, boolean param) {
if (dialog_id != 0) {
int lower_part = (int)dialog_id;
int high_id = (int)(dialog_id >> 32);
Bundle args = new Bundle();
args.putBoolean("scrollToTopOnResume", true);
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
if (lower_part != 0) {
if (lower_part > 0) {
args.putInt("user_id", lower_part);
} else if (lower_part < 0) {
args.putInt("chat_id", -lower_part);
if (high_id == 1) {
args.putInt("chat_id", lower_part);
} else {
if (lower_part > 0) {
args.putInt("user_id", lower_part);
} else if (lower_part < 0) {
args.putInt("chat_id", -lower_part);
}
}
} else {
args.putInt("enc_id", (int)(dialog_id >> 32));
args.putInt("enc_id", high_id);
}
ChatActivity fragment = new ChatActivity(args);
presentFragment(fragment, true);
@ -522,7 +534,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
}
finished = true;
NotificationCenter.getInstance().removeObserver(this, 1234);
NotificationCenter.getInstance().removeObserver(this, 658);
NotificationCenter.getInstance().removeObserver(this, 701);
NotificationCenter.getInstance().removeObserver(this, 702);
NotificationCenter.getInstance().removeObserver(this, 703);
@ -546,30 +557,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
startActivity(intent2);
onFinish();
finish();
} else if (id == 658) {
if (PhotoViewer.getInstance().isVisible()) {
PhotoViewer.getInstance().closePhoto(false);
}
Integer push_chat_id = (Integer)args[0];
Integer push_user_id = (Integer)args[1];
Integer push_enc_id = (Integer)args[2];
if (push_user_id != 0) {
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
Bundle args2 = new Bundle();
args2.putInt("user_id", push_user_id);
presentFragment(new ChatActivity(args2), false, true);
} else if (push_chat_id != 0) {
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
Bundle args2 = new Bundle();
args2.putInt("chat_id", push_chat_id);
presentFragment(new ChatActivity(args2), false, true);
} else if (push_enc_id != 0) {
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
Bundle args2 = new Bundle();
args2.putInt("enc_id", push_enc_id);
presentFragment(new ChatActivity(args2), false, true);
}
} else if (id == 702) {
if (args[0] != this) {
onFinish();

View File

@ -8,7 +8,9 @@
package org.telegram.ui;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -39,6 +41,8 @@ import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.ActionBar.BaseFragment;
import java.util.List;
public class LocationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
private GoogleMap googleMap;
private TextView distanceTextView;
@ -164,8 +168,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
positionMarker(location);
}
});
myLocation = googleMap.getMyLocation();
myLocation = getLastLocation();
if (sendButton != null) {
userLocation = new Location("network");
@ -249,6 +252,19 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
return fragmentView;
}
private Location getLastLocation() {
LocationManager lm = (LocationManager) ApplicationLoader.applicationContext.getSystemService(Context.LOCATION_SERVICE);
List<String> providers = lm.getProviders(true);
Location l = null;
for (int i = providers.size() - 1; i >= 0; i--) {
l = lm.getLastKnownLocation(providers.get(i));
if (l != null) {
break;
}
}
return l;
}
private void updateUserData() {
if (messageObject != null && avatarImageView != null) {
int fromId = messageObject.messageOwner.from_id;

View File

@ -150,10 +150,10 @@ public class LoginActivityRegisterView extends SlideView {
final TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization)response;
TLRPC.TL_userSelf user = (TLRPC.TL_userSelf)res.user;
UserConfig.clearConfig();
MessagesStorage.getInstance().cleanUp();
MessagesController.getInstance().cleanUp();
UserConfig.setCurrentUser(user);
UserConfig.saveConfig(true);
MessagesStorage.getInstance().cleanUp(true);
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
users.add(user);
MessagesStorage.getInstance().putUsersAndChats(users, null, true, true);

View File

@ -54,9 +54,12 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
private Bundle currentParams;
private Timer timeTimer;
private Timer codeTimer;
private static final Integer timerSync = 1;
private volatile int time = 60000;
private volatile int codeTime = 15000;
private double lastCurrentTime;
private double lastCodeTime;
private boolean waitingForSms = false;
private boolean nextPressed = false;
private String lastError = "";
@ -162,6 +165,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
codeField.requestFocus();
destroyTimer();
destroyCodeTimer();
timeText.setText(String.format("%s 1:00", LocaleController.getString("CallText", R.string.CallText)));
lastCurrentTime = System.currentTimeMillis();
problemText.setVisibility(time < 1000 ? VISIBLE : GONE);
@ -169,6 +173,46 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
createTimer();
}
private void createCodeTimer() {
if (codeTimer != null) {
return;
}
codeTime = 15000;
codeTimer = new Timer();
lastCodeTime = System.currentTimeMillis();
codeTimer.schedule(new TimerTask() {
@Override
public void run() {
double currentTime = System.currentTimeMillis();
double diff = currentTime - lastCodeTime;
codeTime -= diff;
lastCodeTime = currentTime;
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
if (codeTime <= 1000) {
problemText.setVisibility(VISIBLE);
destroyCodeTimer();
}
}
});
}
}, 0, 1000);
}
private void destroyCodeTimer() {
try {
synchronized(timerSync) {
if (codeTimer != null) {
codeTimer.cancel();
codeTimer = null;
}
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
private void createTimer() {
if (timeTimer != null) {
return;
@ -189,9 +233,9 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
int seconds = time / 1000 - minutes * 60;
timeText.setText(String.format("%s %d:%02d", LocaleController.getString("CallText", R.string.CallText), minutes, seconds));
} else {
problemText.setVisibility(VISIBLE);
timeText.setText(LocaleController.getString("Calling", R.string.Calling));
destroyTimer();
createCodeTimer();
TLRPC.TL_auth_sendCall req = new TLRPC.TL_auth_sendCall();
req.phone_number = requestPhone;
req.phone_code_hash = phoneHash;
@ -259,11 +303,12 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
if (error == null) {
TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization)response;
destroyTimer();
destroyCodeTimer();
UserConfig.clearConfig();
MessagesStorage.getInstance().cleanUp();
MessagesController.getInstance().cleanUp();
UserConfig.setCurrentUser(res.user);
UserConfig.saveConfig(true);
MessagesStorage.getInstance().cleanUp(true);
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
users.add(res.user);
MessagesStorage.getInstance().putUsersAndChats(users, null, true, true);
@ -280,6 +325,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
params.putString("code", req.phone_code);
delegate.setPage(2, true, params, false);
destroyTimer();
destroyCodeTimer();
} else {
createTimer();
if (error.text.contains("PHONE_NUMBER_INVALID")) {
@ -304,6 +350,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
@Override
public void onBackPressed() {
destroyTimer();
destroyCodeTimer();
currentParams = null;
AndroidUtilities.setWaitingForSms(false);
NotificationCenter.getInstance().removeObserver(this, 998);
@ -316,6 +363,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
AndroidUtilities.setWaitingForSms(false);
NotificationCenter.getInstance().removeObserver(this, 998);
destroyTimer();
destroyCodeTimer();
waitingForSms = false;
}

View File

@ -74,6 +74,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
private final static int messages_list_menu_new_secret_chat = 3;
private final static int messages_list_menu_contacts = 4;
private final static int messages_list_menu_settings = 5;
private final static int messages_list_menu_new_broadcast = 6;
public static interface MessagesActivityDelegate {
public abstract void didSelectDialog(MessagesActivity fragment, long dialog_id, boolean param);
@ -175,6 +176,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
item.addSubItem(messages_list_menu_new_chat, LocaleController.getString("NewGroup", R.string.NewGroup), 0);
item.addSubItem(messages_list_menu_new_secret_chat, LocaleController.getString("NewSecretChat", R.string.NewSecretChat), 0);
item.addSubItem(messages_list_menu_new_broadcast, LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), 0);
item.addSubItem(messages_list_menu_contacts, LocaleController.getString("Contacts", R.string.Contacts), 0);
item.addSubItem(messages_list_menu_settings, LocaleController.getString("Settings", R.string.Settings), 0);
}
@ -206,6 +208,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
if (onlySelect) {
finishFragment();
}
} else if (id == messages_list_menu_new_broadcast) {
Bundle args = new Bundle();
args.putBoolean("broadcast", true);
presentFragment(new GroupCreateActivity(args));
}
}
});
@ -258,7 +264,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
if (obj instanceof TLRPC.User) {
dialog_id = ((TLRPC.User) obj).id;
} else if (obj instanceof TLRPC.Chat) {
dialog_id = -((TLRPC.Chat) obj).id;
if (((TLRPC.Chat) obj).id > 0) {
dialog_id = -((TLRPC.Chat) obj).id;
} else {
dialog_id = AndroidUtilities.makeBroadcastId(((TLRPC.Chat) obj).id);
}
} else if (obj instanceof TLRPC.EncryptedChat) {
dialog_id = ((long)((TLRPC.EncryptedChat) obj).id) << 32;
}
@ -282,14 +292,19 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} else {
Bundle args = new Bundle();
int lower_part = (int)dialog_id;
int high_id = (int)(dialog_id >> 32);
if (lower_part != 0) {
if (lower_part > 0) {
args.putInt("user_id", lower_part);
} else if (lower_part < 0) {
args.putInt("chat_id", -lower_part);
if (high_id == 1) {
args.putInt("chat_id", lower_part);
} else {
if (lower_part > 0) {
args.putInt("user_id", lower_part);
} else if (lower_part < 0) {
args.putInt("chat_id", -lower_part);
}
}
} else {
args.putInt("enc_id", (int)(dialog_id >> 32));
args.putInt("enc_id", high_id);
}
presentFragment(new ChatActivity(args));
}
@ -319,7 +334,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
if ((int)selectedDialog < 0) {
int lower_id = (int)selectedDialog;
int high_id = (int)(selectedDialog >> 32);
if (lower_id < 0 && high_id != 1) {
builder.setItems(new CharSequence[]{LocaleController.getString("ClearHistory", R.string.ClearHistory), LocaleController.getString("DeleteChat", R.string.DeleteChat)}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -482,23 +500,31 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
int lower_part = (int)dialog_id;
int high_id = (int)(dialog_id >> 32);
if (lower_part != 0) {
if (lower_part > 0) {
TLRPC.User user = MessagesController.getInstance().users.get(lower_part);
if (user == null) {
return;
}
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
} else if (lower_part < 0) {
TLRPC.Chat chat = MessagesController.getInstance().chats.get(-lower_part);
if (high_id == 1) {
TLRPC.Chat chat = MessagesController.getInstance().chats.get(lower_part);
if (chat == null) {
return;
}
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, chat.title));
} else {
if (lower_part > 0) {
TLRPC.User user = MessagesController.getInstance().users.get(lower_part);
if (user == null) {
return;
}
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
} else if (lower_part < 0) {
TLRPC.Chat chat = MessagesController.getInstance().chats.get(-lower_part);
if (chat == null) {
return;
}
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, chat.title));
}
}
} else {
int chat_id = (int)(dialog_id >> 32);
TLRPC.EncryptedChat chat = MessagesController.getInstance().encryptedChats.get(chat_id);
TLRPC.EncryptedChat chat = MessagesController.getInstance().encryptedChats.get(high_id);
TLRPC.User user = MessagesController.getInstance().users.get(chat.user_id);
if (user == null) {
return;

View File

@ -413,6 +413,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
imagesByIdsTemp.clear();
needSearchImageInArr = false;
currentIndex = -1;
if (foundIndex >= imagesArr.size()) {
foundIndex = imagesArr.size() - 1;
}
setImageIndex(foundIndex, true);
} else {
if (!cacheEndReached || !arr.isEmpty() && added != 0) {
@ -1384,6 +1387,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
NotificationCenter.getInstance().addObserver(this, MessagesController.mediaDidLoaded);
NotificationCenter.getInstance().addObserver(this, MessagesController.userPhotosLoaded);
try {
if (windowView.getParent() != null) {
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm.removeView(windowView);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
placeProvider = provider;
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm.addView(windowView, windowLayoutParams);
@ -1702,8 +1714,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
return;
}
try {
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
if (windowView.getParent() != null) {
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm.removeViewImmediate(windowView);
}
windowView = null;
@ -1730,8 +1742,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
public void run() {
animatingImageView.setImageBitmap(null);
try {
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
if (windowView.getParent() != null) {
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm.removeView(windowView);
}
} catch (Exception e) {

View File

@ -161,7 +161,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
return;
}
NotificationsController.getInstance().popupMessages.remove(currentMessageNum);
MessagesController.getInstance().markDialogAsRead(currentMessageObject.getDialogId(), currentMessageObject.messageOwner.id, Math.max(0, currentMessageObject.messageOwner.id), 0, currentMessageObject.messageOwner.date, true);
MessagesController.getInstance().markDialogAsRead(currentMessageObject.getDialogId(), currentMessageObject.messageOwner.id, Math.max(0, currentMessageObject.messageOwner.id), 0, currentMessageObject.messageOwner.date, true, true);
currentMessageObject = null;
getNewMessage();
}
@ -874,9 +874,6 @@ public class PopupNotificationActivity extends Activity implements NotificationC
chatActivityEnterView.setFieldFocused(false);
}
ConnectionsManager.getInstance().setAppPaused(true, false);
if (wakeLock.isHeld()) {
wakeLock.release();
}
}
@Override

View File

@ -568,6 +568,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
} catch (Exception e) {
FileLog.e("tmessages", e);
}
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
users.add(res.user);
MessagesStorage.getInstance().putUsersAndChats(users, null, true, true);
MessagesController.getInstance().users.put(res.user.id, res.user);
Bundle args = new Bundle();
args.putInt("user_id", res.user.id);
@ -962,7 +965,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
MessagesController.getInstance().unregistedPush();
MessagesController.getInstance().logOut();
UserConfig.clearConfig();
MessagesStorage.getInstance().cleanUp();
MessagesStorage.getInstance().cleanUp(false);
MessagesController.getInstance().cleanUp();
ContactsController.getInstance().deleteAllAppAccounts();
}

View File

@ -406,7 +406,8 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
}
public void updateServerNotificationsSettings(boolean group) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
//disable global settings sync
/*SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
TLRPC.TL_account_updateNotifySettings req = new TLRPC.TL_account_updateNotifySettings();
req.settings = new TLRPC.TL_inputPeerNotifySettings();
req.settings.sound = "default";
@ -425,7 +426,7 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
public void run(TLObject response, TLRPC.TL_error error) {
}
});
});*/
}
@Override

View File

@ -467,18 +467,15 @@ public class VideoEditorActivity extends BaseFragment implements SurfaceHolder.C
List<Track> tracks = movie.getTracks();
movie.setTracks(new LinkedList<Track>());
double startTime = videoTimelineView.getLeftProgress() * videoPlayer.getDuration() / 1000.0;
double endTime = videoTimelineView.getRightProgress() * videoPlayer.getDuration() / 1000.0;
double startTime = 0;
double endTime = 0;
boolean timeCorrected = false;
for (Track track : tracks) {
if (track.getSyncSamples() != null && track.getSyncSamples().length > 0) {
if (timeCorrected) {
throw new RuntimeException("The startTime has already been corrected by another track with SyncSample. Not Supported.");
}
startTime = correctTimeToSyncSample(track, startTime, false);
endTime = correctTimeToSyncSample(track, endTime, true);
timeCorrected = true;
double duration = (double)track.getDuration() / (double)track.getTrackMetaData().getTimescale();
startTime = correctTimeToSyncSample(track, videoTimelineView.getLeftProgress() * duration, false);
endTime = videoTimelineView.getRightProgress() * duration;
break;
}
}
@ -486,7 +483,7 @@ public class VideoEditorActivity extends BaseFragment implements SurfaceHolder.C
long currentSample = 0;
double currentTime = 0;
double lastTime = 0;
long startSample = -1;
long startSample = 0;
long endSample = -1;
for (int i = 0; i < track.getSampleDurations().length; i++) {
@ -503,9 +500,7 @@ public class VideoEditorActivity extends BaseFragment implements SurfaceHolder.C
}
movie.addTrack(new CroppedTrack(track, startSample, endSample));
}
long start1 = System.currentTimeMillis();
Container out = new DefaultMp4Builder().build(movie);
long start2 = System.currentTimeMillis();
String fileName = Integer.MIN_VALUE + "_" + UserConfig.lastLocalId + ".mp4";
UserConfig.lastLocalId--;
@ -524,6 +519,11 @@ public class VideoEditorActivity extends BaseFragment implements SurfaceHolder.C
}
}
// private void startEncodeVideo() {
// MediaExtractor mediaExtractor = new MediaExtractor();
// mediaExtractor.s
// }
private static double correctTimeToSyncSample(Track track, double cutHere, boolean next) {
double[] timeOfSyncSamples = new double[track.getSyncSamples().length];
long currentSample = 0;

View File

@ -46,7 +46,7 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
private static native void renderFrame(int[] pixels, int gifFileInPtr, int[] metaData);
private static native int openFile(int[] metaData, String filePath);
private static native void free(int gifFileInPtr);
private static native boolean reset(int gifFileInPtr);
private static native void reset(int gifFileInPtr);
private static native void setSpeedFactor(int gifFileInPtr, float factor);
private static native String getComment(int gifFileInPtr);
private static native int getLoopCount(int gifFileInPtr);

View File

@ -75,17 +75,20 @@ public class ImageReceiver {
if (filter != null) {
key += "@" + filter;
}
Bitmap img;
Bitmap img = null;
if (currentPath != null) {
if (currentPath.equals(key)) {
return;
if (currentImage != null) {
return;
} else {
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter);
}
} else {
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter, true);
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter);
recycleBitmap(img);
}
} else {
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter, true);
}
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter);
currentPath = key;
last_path = path;
last_httpUrl = httpUrl;
@ -132,6 +135,9 @@ public class ImageReceiver {
last_filter = null;
currentImage = null;
last_size = 0;
if (parentView != null) {
parentView.invalidate();
}
}
public void setImageBitmap(Drawable bitmap) {
@ -145,6 +151,9 @@ public class ImageReceiver {
last_httpUrl = null;
last_filter = null;
last_size = 0;
if (parentView != null) {
parentView.invalidate();
}
}
public void clearImage() {

View File

@ -0,0 +1,43 @@
/*
* This is the source code of Telegram for Android v. 1.7.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2014.
*/
package org.telegram.ui.Views;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import org.telegram.android.AndroidUtilities;
public class RoundProgressView {
private Paint paint;
public float currentProgress = 0;
public RectF rect = new RectF();
public RoundProgressView() {
paint = new Paint();
paint.setColor(0xffffffff);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(AndroidUtilities.dp(1));
paint.setAntiAlias(true);
}
public void setProgress(float progress) {
currentProgress = progress;
if (currentProgress < 0) {
currentProgress = 0;
} else if (currentProgress > 1) {
currentProgress = 1;
}
}
public void draw(Canvas canvas) {
canvas.drawArc(rect, -90, 360 * currentProgress, false, paint);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

BIN
TMessagesProj/src/main/res/drawable-hdpi/playvideo.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 806 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 805 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 838 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 857 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 564 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 591 B

BIN
TMessagesProj/src/main/res/drawable-ldpi/playvideo.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 785 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

BIN
TMessagesProj/src/main/res/drawable-mdpi/playvideo.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

BIN
TMessagesProj/src/main/res/drawable-xhdpi/playvideo.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

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