mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 06:25:14 +01:00
Different improvements (not finished, not usable yet)
This commit is contained in:
parent
1add11177d
commit
ab0ae72560
480 changed files with 7609 additions and 1882 deletions
|
@ -3,7 +3,7 @@ buildscript {
|
|||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:0.13.+'
|
||||
classpath 'com.android.tools.build:gradle:0.14.0'
|
||||
}
|
||||
}
|
||||
apply plugin: 'com.android.application'
|
||||
|
@ -25,7 +25,7 @@ dependencies {
|
|||
|
||||
android {
|
||||
compileSdkVersion 21
|
||||
buildToolsVersion '21.0.2'
|
||||
buildToolsVersion '21.1.0'
|
||||
|
||||
signingConfigs {
|
||||
debug {
|
||||
|
@ -79,7 +79,7 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
targetSdkVersion 21
|
||||
versionCode 379
|
||||
versionName "1.9.7"
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
<activity
|
||||
android:name="org.telegram.ui.LaunchActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleTask"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
|
|
Binary file not shown.
|
@ -15,6 +15,7 @@ import android.content.DialogInterface;
|
|||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
|
@ -29,14 +30,12 @@ import android.widget.TextView;
|
|||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
import org.telegram.ui.Views.NumberPicker;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AndroidUtilities {
|
||||
|
||||
|
@ -51,37 +50,6 @@ public class AndroidUtilities {
|
|||
public static Integer photoSize = null;
|
||||
private static Boolean isTablet = null;
|
||||
|
||||
public static int[] arrColors = {0xffee4928, 0xff41a903, 0xffe09602, 0xff0f94ed, 0xff8f3bf7, 0xfffc4380, 0xff00a1c4, 0xffeb7002};
|
||||
public static int[] arrUsersAvatars = {
|
||||
R.drawable.user_red,
|
||||
R.drawable.user_green,
|
||||
R.drawable.user_yellow,
|
||||
R.drawable.user_blue,
|
||||
R.drawable.user_violet,
|
||||
R.drawable.user_pink,
|
||||
R.drawable.user_aqua,
|
||||
R.drawable.user_orange};
|
||||
|
||||
public static int[] arrGroupsAvatars = {
|
||||
R.drawable.group_red,
|
||||
R.drawable.group_green,
|
||||
R.drawable.group_yellow,
|
||||
R.drawable.group_blue,
|
||||
R.drawable.group_violet,
|
||||
R.drawable.group_pink,
|
||||
R.drawable.group_aqua,
|
||||
R.drawable.group_orange};
|
||||
|
||||
public static int[] arrBroadcastAvatars = {
|
||||
R.drawable.broadcast_red,
|
||||
R.drawable.broadcast_green,
|
||||
R.drawable.broadcast_yellow,
|
||||
R.drawable.broadcast_blue,
|
||||
R.drawable.broadcast_violet,
|
||||
R.drawable.broadcast_pink,
|
||||
R.drawable.broadcast_aqua,
|
||||
R.drawable.broadcast_orange};
|
||||
|
||||
static {
|
||||
density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
|
||||
checkDisplaySize();
|
||||
|
@ -239,11 +207,7 @@ public class AndroidUtilities {
|
|||
return new File("");
|
||||
}
|
||||
|
||||
public static int dp(int value) {
|
||||
return (int)(Math.max(1, density * value));
|
||||
}
|
||||
|
||||
public static int dpf(float value) {
|
||||
public static int dp(float value) {
|
||||
return (int)Math.ceil(density * value);
|
||||
}
|
||||
|
||||
|
@ -290,11 +254,11 @@ public class AndroidUtilities {
|
|||
return layer & 0x0000ffff | (version << 16);
|
||||
}
|
||||
|
||||
public static void RunOnUIThread(Runnable runnable) {
|
||||
RunOnUIThread(runnable, 0);
|
||||
public static void runOnUIThread(Runnable runnable) {
|
||||
runOnUIThread(runnable, 0);
|
||||
}
|
||||
|
||||
public static void RunOnUIThread(Runnable runnable, long delay) {
|
||||
public static void runOnUIThread(Runnable runnable, long delay) {
|
||||
if (delay == 0) {
|
||||
ApplicationLoader.applicationHandler.post(runnable);
|
||||
} else {
|
||||
|
@ -302,7 +266,7 @@ public class AndroidUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public static void CancelRunOnUIThread(Runnable runnable) {
|
||||
public static void cancelRunOnUIThread(Runnable runnable) {
|
||||
ApplicationLoader.applicationHandler.removeCallbacks(runnable);
|
||||
}
|
||||
|
||||
|
@ -337,58 +301,6 @@ public class AndroidUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public static int getColorIndex(int id) {
|
||||
int[] arr;
|
||||
if (id >= 0) {
|
||||
arr = arrUsersAvatars;
|
||||
} else {
|
||||
arr = arrGroupsAvatars;
|
||||
}
|
||||
try {
|
||||
String str;
|
||||
if (id >= 0) {
|
||||
str = String.format(Locale.US, "%d%d", id, UserConfig.getClientUserId());
|
||||
} else {
|
||||
str = String.format(Locale.US, "%d", id);
|
||||
}
|
||||
if (str.length() > 15) {
|
||||
str = str.substring(0, 15);
|
||||
}
|
||||
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
|
||||
byte[] digest = md.digest(str.getBytes());
|
||||
int b = digest[Math.abs(id % 16)];
|
||||
if (b < 0) {
|
||||
b += 256;
|
||||
}
|
||||
return Math.abs(b) % arr.length;
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
return id % arr.length;
|
||||
}
|
||||
|
||||
public static int getColorForId(int id) {
|
||||
if (id / 1000 == 333) {
|
||||
return 0xff0f94ed;
|
||||
}
|
||||
return arrColors[getColorIndex(id)];
|
||||
}
|
||||
|
||||
public static int getUserAvatarForId(int id) {
|
||||
if (id / 1000 == 333 || id / 1000 == 777) {
|
||||
return R.drawable.telegram_avatar;
|
||||
}
|
||||
return arrUsersAvatars[getColorIndex(id)];
|
||||
}
|
||||
|
||||
public static int getGroupAvatarForId(int id) {
|
||||
return arrGroupsAvatars[getColorIndex(-Math.abs(id))];
|
||||
}
|
||||
|
||||
public static int getBroadcastAvatarForId(int id) {
|
||||
return arrBroadcastAvatars[getColorIndex(-Math.abs(id))];
|
||||
}
|
||||
|
||||
public static int getPhotoSize() {
|
||||
if (photoSize == null) {
|
||||
if (Build.VERSION.SDK_INT >= 16) {
|
||||
|
@ -501,4 +413,34 @@ public class AndroidUtilities {
|
|||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getViewInset(View view) {
|
||||
if (view == null || Build.VERSION.SDK_INT < 21) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
Field mAttachInfoField = View.class.getDeclaredField("mAttachInfo");
|
||||
mAttachInfoField.setAccessible(true);
|
||||
Object mAttachInfo = mAttachInfoField.get(view);
|
||||
if (mAttachInfo != null) {
|
||||
Field mStableInsetsField = mAttachInfo.getClass().getDeclaredField("mStableInsets");
|
||||
mStableInsetsField.setAccessible(true);
|
||||
Rect insets = (Rect)mStableInsetsField.get(mAttachInfo);
|
||||
return insets.bottom;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getCurrentActionBarHeight() {
|
||||
if (isTablet()) {
|
||||
return dp(64);
|
||||
} else if (ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
return dp(48);
|
||||
} else {
|
||||
return dp(56);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.telegram.ui.ApplicationLoader;
|
|||
|
||||
public class AppStartReceiver extends BroadcastReceiver {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationLoader.startPushService();
|
||||
|
|
|
@ -419,7 +419,7 @@ public class ContactsController {
|
|||
FileLog.e("tmessages", "detected account deletion!");
|
||||
currentAccount = new Account(UserConfig.getCurrentUser().phone, "org.telegram.account");
|
||||
am.addAccountExplicitly(currentAccount, "", null);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
performWriteContactsToPhoneBook();
|
||||
|
@ -546,7 +546,7 @@ public class ContactsController {
|
|||
MessagesStorage.getInstance().putCachedPhoneBook(contactsMap);
|
||||
}
|
||||
if (!disableDeletion && !contactHashMap.isEmpty()) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (BuildVars.DEBUG_VERSION) {
|
||||
|
@ -702,7 +702,7 @@ public class ContactsController {
|
|||
}
|
||||
}
|
||||
});
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateUnregisteredContacts(contacts);
|
||||
|
@ -763,7 +763,7 @@ public class ContactsController {
|
|||
applyContactsUpdates(delayedContactsUpdate, null, null, null);
|
||||
delayedContactsUpdate.clear();
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (loadContactsSync) {
|
||||
|
@ -784,7 +784,7 @@ public class ContactsController {
|
|||
|
||||
public void processLoadedContacts(final ArrayList<TLRPC.TL_contact> contactsArr, final ArrayList<TLRPC.User> usersArr, final int from) {
|
||||
//from: 0 - from server, 1 - from db, 2 - from imported contacts
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesController.getInstance().putUsers(usersArr, from == 1);
|
||||
|
@ -928,7 +928,7 @@ public class ContactsController {
|
|||
}
|
||||
});
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
contacts = contactsArr;
|
||||
|
@ -953,7 +953,7 @@ public class ContactsController {
|
|||
}
|
||||
|
||||
if (contactsByPhonesDictFinal != null) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.globalQueue.postRunnable(new Runnable() {
|
||||
|
@ -1272,7 +1272,7 @@ public class ContactsController {
|
|||
} else {
|
||||
final ArrayList<TLRPC.TL_contact> newContacts = newC;
|
||||
final ArrayList<Integer> contactsToDelete = contactsTD;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (TLRPC.TL_contact contact : newContacts) {
|
||||
|
@ -1477,7 +1477,7 @@ public class ContactsController {
|
|||
}
|
||||
}
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (TLRPC.User u : res.users) {
|
||||
|
@ -1541,7 +1541,7 @@ public class ContactsController {
|
|||
}
|
||||
}
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean remove = false;
|
||||
|
|
|
@ -259,7 +259,7 @@ public class Emoji {
|
|||
|
||||
Utilities.loadBitmap(imageFile.getAbsolutePath(), bitmap, imageResize);
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
emojiBmp[page] = bitmap;
|
||||
|
|
|
@ -27,7 +27,7 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
|
|||
FileLog.d("tmessages", "GCM received intent: " + intent);
|
||||
|
||||
if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationLoader.postInitApplication();
|
||||
|
|
|
@ -307,7 +307,7 @@ public class ImageLoader {
|
|||
}
|
||||
|
||||
private void onPostExecute(final BitmapDrawable bitmapDrawable) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (bitmapDrawable != null && memCache.get(cacheImage.key) == null) {
|
||||
|
@ -518,7 +518,7 @@ public class ImageLoader {
|
|||
if (lastProgressUpdateTime == 0 || lastProgressUpdateTime < currentTime - 500) {
|
||||
lastProgressUpdateTime = currentTime;
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.FileUploadProgressChanged, location, progress, isEncrypted);
|
||||
|
@ -549,7 +549,7 @@ public class ImageLoader {
|
|||
|
||||
@Override
|
||||
public void fileDidLoaded(final String location, final File finalFile, final File tempFile) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (location != null) {
|
||||
|
@ -567,7 +567,7 @@ public class ImageLoader {
|
|||
|
||||
@Override
|
||||
public void fileDidFailedLoad(final String location, final int state) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImageLoader.this.fileDidFailedLoad(location);
|
||||
|
@ -581,7 +581,7 @@ public class ImageLoader {
|
|||
long currentTime = System.currentTimeMillis();
|
||||
if (lastProgressUpdateTime == 0 || lastProgressUpdateTime < currentTime - 500) {
|
||||
lastProgressUpdateTime = currentTime;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.FileLoadProgressChanged, location, progress);
|
||||
|
@ -601,7 +601,7 @@ public class ImageLoader {
|
|||
}
|
||||
};
|
||||
if (Intent.ACTION_MEDIA_UNMOUNTED.equals(intent.getAction())) {
|
||||
AndroidUtilities.RunOnUIThread(r, 1000);
|
||||
AndroidUtilities.runOnUIThread(r, 1000);
|
||||
} else {
|
||||
r.run();
|
||||
}
|
||||
|
@ -816,7 +816,7 @@ public class ImageLoader {
|
|||
}
|
||||
|
||||
public void replaceImageInCache(final String oldKey, final String newKey) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ArrayList<String> arr = memCache.getFilterKeys(oldKey);
|
||||
|
|
|
@ -139,7 +139,7 @@ public class ImageReceiver {
|
|||
if (roundRadius != 0) {
|
||||
bitmapShader = new BitmapShader(bitmap.getBitmap(), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
|
||||
roundPaint.setShader(bitmapShader);
|
||||
bitmapRect.set(0, 0, bitmap.getIntrinsicWidth(), bitmap.getIntrinsicHeight());
|
||||
bitmapRect.set(0, 0, bitmap.getBitmap().getWidth(), bitmap.getBitmap().getHeight());
|
||||
}
|
||||
if (parentView != null) {
|
||||
parentView.invalidate();
|
||||
|
@ -225,9 +225,9 @@ public class ImageReceiver {
|
|||
if (bitmapDrawable != null) {
|
||||
if (bitmapShader != null) {
|
||||
drawRegion.set(imageX, imageY, imageX + imageW, imageY + imageH);
|
||||
roundRect.set(imageX, imageY, imageX + imageW, imageY + imageH);
|
||||
roundRect.set(drawRegion);
|
||||
shaderMatrix.reset();
|
||||
shaderMatrix.setScale(1.5f, 1.5f);
|
||||
shaderMatrix.setRectToRect(bitmapRect, roundRect, Matrix.ScaleToFit.FILL);
|
||||
bitmapShader.setLocalMatrix(shaderMatrix);
|
||||
canvas.drawRoundRect(roundRect, roundRadius, roundRadius, roundPaint);
|
||||
} else {
|
||||
|
|
|
@ -273,7 +273,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
});
|
||||
}
|
||||
recordQueue.postRunnable(recordRunnable);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.recordProgressChanged, System.currentTimeMillis() - recordStartTime);
|
||||
|
@ -451,7 +451,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
@Override
|
||||
public void run() {
|
||||
synchronized (sync) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (playingMessageObject != null && (audioPlayer != null || audioTrackPlayer != null) && !isPaused) {
|
||||
|
@ -802,7 +802,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
cursor.close();
|
||||
}
|
||||
if (!screenshotDates.isEmpty()) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.screenshotTook);
|
||||
|
@ -1060,7 +1060,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
if (count > 0) {
|
||||
final long pcm = buffer.pcmOffset;
|
||||
final int marker = buffer.finished == 1 ? buffer.size : -1;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
lastPlayPcm = pcm;
|
||||
|
@ -1149,7 +1149,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
freePlayerBuffers.addAll(usedPlayerBuffers);
|
||||
usedPlayerBuffers.clear();
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isPaused) {
|
||||
|
@ -1404,7 +1404,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
@Override
|
||||
public void run() {
|
||||
if (audioRecorder != null) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.recordStartError);
|
||||
|
@ -1425,7 +1425,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
|
||||
try {
|
||||
if (startRecord(recordingAudioFile.getAbsolutePath()) == 0) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.recordStartError);
|
||||
|
@ -1453,7 +1453,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
FileLog.e("tmessages", e2);
|
||||
}
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.recordStartError);
|
||||
|
@ -1463,7 +1463,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
}
|
||||
|
||||
recordQueue.postRunnable(recordRunnable);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.recordStarted);
|
||||
|
@ -1481,7 +1481,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
@Override
|
||||
public void run() {
|
||||
stopRecord();
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
audioToSend.date = ConnectionsManager.getInstance().getCurrentTime();
|
||||
|
@ -1536,7 +1536,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.recordStopped);
|
||||
|
@ -1609,7 +1609,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
if (lastProgress <= System.currentTimeMillis() - 500) {
|
||||
lastProgress = System.currentTimeMillis();
|
||||
final int progress = (int) ((float) a / (float) size * 100);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
@ -1641,7 +1641,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
FileLog.e("tmessages", e);
|
||||
}
|
||||
if (finalProgress != null) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
@ -1915,7 +1915,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
}
|
||||
}
|
||||
final Integer cameraAlbumIdFinal = cameraAlbumId;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.albumsDidLoaded, guid, albumsSorted, cameraAlbumIdFinal);
|
||||
|
@ -2037,7 +2037,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
if (firstWrite) {
|
||||
videoConvertFirstWrite = false;
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (error) {
|
||||
|
|
|
@ -150,7 +150,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
|
||||
public void updateConfig(final TLRPC.TL_config config) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
maxBroadcastCount = config.broadcast_size_max;
|
||||
|
@ -247,7 +247,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
||||
users.add(user);
|
||||
MessagesStorage.getInstance().putUsersAndChats(users, null, false, true);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_AVATAR);
|
||||
|
@ -418,7 +418,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
}
|
||||
if (updateStatus) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_STATUS);
|
||||
|
@ -482,7 +482,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
@Override
|
||||
public void run(final TLObject response, TLRPC.TL_error error) {
|
||||
if (error == null) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadingFullUsers.remove((Integer)user.id);
|
||||
|
@ -499,7 +499,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
});
|
||||
} else {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadingFullUsers.remove((Integer)user.id);
|
||||
|
@ -546,7 +546,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
}
|
||||
});
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didCreatedNewDeleteTask, mids);
|
||||
|
@ -573,7 +573,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
Utilities.stageQueue.cancelRunnable(currentDeleteTaskRunnable);
|
||||
}
|
||||
currentDeleteTaskRunnable = null;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
deleteMessages(currentDeletingTaskMids, null, null);
|
||||
|
@ -721,7 +721,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
|
||||
public void processLoadedBlockedUsers(final ArrayList<Integer> ids, final ArrayList<TLRPC.User> users, final boolean cache) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (users != null) {
|
||||
|
@ -777,7 +777,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
users.add(user);
|
||||
MessagesStorage.getInstance().putUsersAndChats(users, null, false, true);
|
||||
user.photo = (TLRPC.UserProfilePhoto)response;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_ALL);
|
||||
|
@ -807,7 +807,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
loadUserPhotos(uid, offset, count, max_id, false, classGuid);
|
||||
return;
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(res.users, fromCache);
|
||||
|
@ -835,7 +835,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
objects.add(new MessageObject(message, usersLocal));
|
||||
}
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int totalCount;
|
||||
|
@ -892,7 +892,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
|
||||
public void processLoadedMediaCount(final int count, final long uid, final int classGuid, final boolean fromCache) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int lower_part = (int)uid;
|
||||
|
@ -939,7 +939,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
final TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
|
||||
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(res.users, false);
|
||||
|
@ -1024,7 +1024,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationsController.getInstance().processReadMessages(null, did, 0, Integer.MAX_VALUE, false);
|
||||
|
@ -1099,7 +1099,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
final TLRPC.TL_messages_chatFull res = (TLRPC.TL_messages_chatFull) response;
|
||||
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
|
||||
MessagesStorage.getInstance().updateChatInfo(chat_id, res.full_chat.participants, false);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(res.users, false);
|
||||
|
@ -1110,7 +1110,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
});
|
||||
} else {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(usersArr, fromCache);
|
||||
|
@ -1203,7 +1203,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
updatePrintingStrings();
|
||||
|
||||
if (updated) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_USER_PRINT);
|
||||
|
@ -1253,7 +1253,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
|
||||
lastPrintingStringCount = newPrintingStrings.size();
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
printingStrings = newPrintingStrings;
|
||||
|
@ -1303,7 +1303,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
long reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendingTypings.remove(dialog_id);
|
||||
|
@ -1377,7 +1377,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().putMessages(messagesRes, dialog_id);
|
||||
}
|
||||
if (lower_id != 0 && isCache && messagesRes.messages.size() == 0 && (load_type == 0 || load_type == 3)) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadMessages(dialog_id, count, max_id, false, 0, classGuid, load_type);
|
||||
|
@ -1394,7 +1394,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
message.dialog_id = dialog_id;
|
||||
objects.add(new MessageObject(message, usersLocal, 2));
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(messagesRes.users, isCache);
|
||||
|
@ -1453,7 +1453,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
|
||||
public void processDialogsUpdateRead(final HashMap<Long, Integer> dialogsToUpdate) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (HashMap.Entry<Long, Integer> entry : dialogsToUpdate.entrySet()) {
|
||||
|
@ -1502,7 +1502,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
dialogsToUpdate.put(d.id, d.unread_count);
|
||||
}
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(dialogsRes.users, true);
|
||||
|
@ -1571,7 +1571,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
@Override
|
||||
public void run() {
|
||||
if (isCache && dialogsRes.dialogs.size() == 0) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(dialogsRes.users, isCache);
|
||||
|
@ -1626,7 +1626,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
|
||||
final int arg1 = new_totalDialogsCount;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isCache) {
|
||||
|
@ -1754,7 +1754,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TLRPC.TL_dialog dialog = dialogs_dict.get(dialog_id);
|
||||
|
@ -1817,7 +1817,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationsController.getInstance().processReadMessages(null, dialog_id, max_date, 0, popup);
|
||||
|
@ -1915,7 +1915,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
if (error != null) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatDidFailCreate);
|
||||
|
@ -1926,7 +1926,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
|
||||
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(res.users, false);
|
||||
|
@ -1973,7 +1973,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
|
||||
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(res.users, false);
|
||||
|
@ -2051,7 +2051,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
|
||||
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(res.users, false);
|
||||
|
@ -2136,7 +2136,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
|
||||
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(res.users, false);
|
||||
|
@ -2186,7 +2186,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
|
||||
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(res.users, false);
|
||||
|
@ -2288,7 +2288,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
UserConfig.pushString = regid;
|
||||
UserConfig.saveConfig(false);
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
registeringForPush = false;
|
||||
|
@ -2386,7 +2386,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
updatesStartWaitTime = 0;
|
||||
if (state == 1) {
|
||||
final int stateCopy = ConnectionsManager.getInstance().getConnectionState();
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didUpdatedConnectionState, stateCopy);
|
||||
|
@ -2396,7 +2396,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
} else {
|
||||
if (state == 1) {
|
||||
final int stateCopy = ConnectionsManager.getInstance().getConnectionState();
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didUpdatedConnectionState, stateCopy);
|
||||
|
@ -2430,7 +2430,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
if (ConnectionsManager.getInstance().getConnectionState() == 0) {
|
||||
ConnectionsManager.getInstance().setConnectionState(3);
|
||||
final int stateCopy = ConnectionsManager.getInstance().getConnectionState();
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didUpdatedConnectionState, stateCopy);
|
||||
|
@ -2462,7 +2462,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
}
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(res.users, false);
|
||||
|
@ -2483,7 +2483,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
|
||||
if (!corrected.isEmpty()) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (HashMap.Entry<Integer, Integer> entry : corrected.entrySet()) {
|
||||
|
@ -2551,7 +2551,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
|
||||
processPendingEncMessages();
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (HashMap.Entry<Long, ArrayList<MessageObject>> pair : messages.entrySet()) {
|
||||
|
@ -2566,7 +2566,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
@Override
|
||||
public void run() {
|
||||
if (!pushMessages.isEmpty()) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationsController.getInstance().processNewMessages(pushMessages, !(res instanceof TLRPC.TL_updates_differenceSlice));
|
||||
|
@ -2616,7 +2616,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
gettingDifference = false;
|
||||
ConnectionsManager.getInstance().setConnectionState(0);
|
||||
final int stateCopy = ConnectionsManager.getInstance().getConnectionState();
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didUpdatedConnectionState, stateCopy);
|
||||
|
@ -2661,7 +2661,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
if (printUpdate) {
|
||||
updatePrintingStrings();
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (printUpdate) {
|
||||
|
@ -2675,7 +2675,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!obj.isFromMe() && obj.isUnread()) {
|
||||
|
@ -2727,7 +2727,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
if (printUpdate) {
|
||||
updatePrintingStrings();
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (printUpdate) {
|
||||
|
@ -2740,7 +2740,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!obj.isFromMe() && obj.isUnread()) {
|
||||
|
@ -2892,7 +2892,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
|
||||
if (usersArr != null || chatsArr != null) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putUsers(usersArr, false);
|
||||
|
@ -3127,7 +3127,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
dialog.top_message = 0;
|
||||
dialog.last_message_date = update.date;
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
dialogs_dict.put(dialog.id, dialog);
|
||||
|
@ -3174,7 +3174,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
newChat.seq_in = exist.seq_in;
|
||||
newChat.seq_out = exist.seq_out;
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (exist != null) {
|
||||
|
@ -3197,7 +3197,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (finalUpdate.blocked) {
|
||||
|
@ -3264,7 +3264,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!pushMessages.isEmpty()) {
|
||||
|
@ -3279,7 +3279,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().putMessages(messagesArr, true, true, false, MediaController.getInstance().getAutodownloadMask());
|
||||
}
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int updateMask = interfaceUpdateMaskFinal;
|
||||
|
@ -3387,7 +3387,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int updateMask = 0;
|
||||
|
@ -3764,7 +3764,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
return newMessage;
|
||||
} else if (serviceMessage.action instanceof TLRPC.TL_decryptedMessageActionFlushHistory) {
|
||||
final long did = ((long)chat.id) << 32;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TLRPC.TL_dialog dialog = dialogs_dict.get(did);
|
||||
|
@ -3775,7 +3775,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationsController.getInstance().processReadMessages(null, did, 0, Integer.MAX_VALUE, false);
|
||||
|
@ -3909,7 +3909,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
newChat.auth_key = chat.auth_key;
|
||||
newChat.seq_in = chat.seq_in;
|
||||
newChat.seq_out = chat.seq_out;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putEncryptedChat(newChat, false);
|
||||
|
@ -3980,7 +3980,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
encryptedChat.seq_in = 0;
|
||||
encryptedChat.seq_out = 1;
|
||||
MessagesStorage.getInstance().updateEncryptedChat(encryptedChat);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putEncryptedChat(encryptedChat, false);
|
||||
|
@ -3996,7 +3996,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
newChat.seq_in = encryptedChat.seq_in;
|
||||
newChat.seq_out = encryptedChat.seq_out;
|
||||
MessagesStorage.getInstance().updateEncryptedChat(newChat);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putEncryptedChat(newChat, false);
|
||||
|
@ -4105,7 +4105,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
newChat.seq_in = encryptedChat.seq_in;
|
||||
newChat.seq_out = encryptedChat.seq_out;
|
||||
MessagesStorage.getInstance().updateEncryptedChat(newChat);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
putEncryptedChat(newChat, false);
|
||||
|
@ -4142,7 +4142,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig) response;
|
||||
if (response instanceof TLRPC.TL_messages_dhConfig) {
|
||||
if (!Utilities.isGoodPrime(res.p, res.g)) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
@ -4183,7 +4183,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
@Override
|
||||
public void run(final TLObject response, TLRPC.TL_error error) {
|
||||
if (error == null) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startingSecretChat = false;
|
||||
|
@ -4242,7 +4242,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
});
|
||||
} else {
|
||||
delayedEncryptedChatUpdates.clear();
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!((Activity) context).isFinishing()) {
|
||||
|
@ -4265,7 +4265,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
||||
} else {
|
||||
delayedEncryptedChatUpdates.clear();
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startingSecretChat = false;
|
||||
|
|
|
@ -528,7 +528,7 @@ public class MessagesStorage {
|
|||
}
|
||||
}
|
||||
Collections.reverse(messages);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationsController.getInstance().processLoadedUnreadMessages(pushDialogs, messages, users, chats, encryptedChats);
|
||||
|
@ -1034,7 +1034,7 @@ public class MessagesStorage {
|
|||
info.version = version;
|
||||
|
||||
final TLRPC.ChatParticipants finalInfo = info;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatInfoDidLoaded, finalInfo.chat_id, finalInfo);
|
||||
|
@ -2385,7 +2385,7 @@ public class MessagesStorage {
|
|||
}
|
||||
cursor.dispose();
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MediaController.getInstance().processDownloadObjects(type, objects);
|
||||
|
@ -2675,7 +2675,7 @@ public class MessagesStorage {
|
|||
|
||||
if (downloadMediaMask != 0) {
|
||||
final int downloadMediaMaskFinal = downloadMediaMask;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MediaController.getInstance().newDownloadObjectsAvailable(downloadMediaMaskFinal);
|
||||
|
@ -3030,7 +3030,7 @@ public class MessagesStorage {
|
|||
}
|
||||
cursor.dispose();
|
||||
if (!mids.isEmpty()) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Integer id : mids) {
|
||||
|
|
|
@ -21,7 +21,7 @@ public class NotificationRepeat extends IntentService {
|
|||
|
||||
@Override
|
||||
protected void onHandleIntent(Intent intent) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationsController.getInstance().repeatNotificationMaybe();
|
||||
|
|
|
@ -96,7 +96,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
final TLRPC.InputFile file = (TLRPC.InputFile)args[1];
|
||||
final TLRPC.InputEncryptedFile encryptedFile = (TLRPC.InputEncryptedFile)args[2];
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ArrayList<DelayedMessage> arr = delayedMessages.get(location);
|
||||
|
@ -162,7 +162,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
final String location = (String) args[0];
|
||||
final boolean enc = (Boolean) args[1];
|
||||
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ArrayList<DelayedMessage> arr = delayedMessages.get(location);
|
||||
|
@ -1067,7 +1067,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.stopEncodingService, path);
|
||||
|
@ -1121,7 +1121,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
|
||||
MessagesStorage.getInstance().putMessages(currentMessage, true, false, false, 0);
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
|
||||
|
@ -1145,7 +1145,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
});
|
||||
} else {
|
||||
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.id);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||
|
@ -1162,7 +1162,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
@Override
|
||||
public void quickAck() {
|
||||
final int msg_id = newMsgObj.id;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
|
||||
|
@ -1310,7 +1310,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
}
|
||||
MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, newMsgObj.id, newMsgObj.id, res.date, false);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
|
||||
|
@ -1325,7 +1325,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
});
|
||||
} else {
|
||||
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.id);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||
|
@ -1810,7 +1810,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
|
||||
protected void processUnsentMessages(final ArrayList<TLRPC.Message> messages, final ArrayList<TLRPC.User> users, final ArrayList<TLRPC.Chat> chats, final ArrayList<TLRPC.EncryptedChat> encryptedChats) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesController.getInstance().putUsers(users, true);
|
||||
|
@ -1921,7 +1921,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
|
||||
final TLRPC.TL_document documentFinal = document;
|
||||
final String originalPathFinal = originalPath;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, path, dialog_id);
|
||||
|
@ -2039,7 +2039,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
if (photo != null) {
|
||||
final String originalPathFinal = originalPath;
|
||||
final TLRPC.TL_photo photoFinal = photo;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SendMessagesHelper.getInstance().sendMessage(photoFinal, originalPathFinal, dialog_id);
|
||||
|
@ -2161,7 +2161,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
final TLRPC.TL_video videoFinal = video;
|
||||
final String originalPathFinal = originalPath;
|
||||
final String finalPath = path;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SendMessagesHelper.getInstance().sendMessage(videoFinal, originalPathFinal, finalPath, dialog_id);
|
||||
|
|
|
@ -639,7 +639,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
}
|
||||
|
||||
public void bindRequestToGuid(final Long request, final int guid) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ArrayList<Long> requests = requestsByGuids.get(guid);
|
||||
|
@ -652,7 +652,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
}
|
||||
|
||||
public void removeRequestInClass(final Long request) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Integer guid = requestsByClass.get(request);
|
||||
|
@ -2143,7 +2143,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0) {
|
||||
if (UserConfig.isClientActivated()) {
|
||||
UserConfig.clearConfig();
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.appDidLogout);
|
||||
|
@ -2402,7 +2402,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
}
|
||||
}
|
||||
final int stateCopy = connectionState;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didUpdatedConnectionState, stateCopy);
|
||||
|
@ -2452,7 +2452,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
if (ConnectionsManager.getInstance().connectionState == 3 && !MessagesController.getInstance().gettingDifference && !MessagesController.getInstance().gettingDifferenceAgain) {
|
||||
ConnectionsManager.getInstance().connectionState = 0;
|
||||
final int stateCopy = ConnectionsManager.getInstance().connectionState;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didUpdatedConnectionState, stateCopy);
|
||||
|
@ -2468,7 +2468,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
if (connectionState == 1 || connectionState == 2) {
|
||||
connectionState = 3;
|
||||
final int stateCopy = connectionState;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didUpdatedConnectionState, stateCopy);
|
||||
|
|
|
@ -41,7 +41,7 @@ public class BaseContactsSearchAdapter extends BaseFragmentAdapter {
|
|||
reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(final TLObject response, final TLRPC.TL_error error) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (currentReqId == lastReqId) {
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
}
|
||||
|
||||
private void processSearch(final String query) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (allowUsernameSearch) {
|
||||
|
@ -130,7 +130,7 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
}
|
||||
|
||||
private void updateSearchResults(final ArrayList<TLRPC.User> users, final ArrayList<CharSequence> names) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
searchResult = users;
|
||||
|
|
|
@ -44,9 +44,7 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
private ArrayList<TLObject> searchResult = new ArrayList<TLObject>();
|
||||
private ArrayList<CharSequence> searchResultNames = new ArrayList<CharSequence>();
|
||||
private ArrayList<MessageObject> searchResultMessages = new ArrayList<MessageObject>();
|
||||
private String lastSearchTextDialogs;
|
||||
private String lastSearchTextMessages;
|
||||
private int currentSearchType;
|
||||
private String lastSearchText;
|
||||
private long reqId = 0;
|
||||
private int lastReqId;
|
||||
private MessagesActivitySearchAdapterDelegate delegate;
|
||||
|
@ -89,7 +87,7 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
reqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(final TLObject response, final TLRPC.TL_error error) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (currentReqId == lastReqId) {
|
||||
|
@ -240,7 +238,7 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
}
|
||||
|
||||
private void updateSearchResults(final ArrayList<TLObject> result, final ArrayList<CharSequence> names, final ArrayList<TLRPC.User> encUsers) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (TLObject obj : result) {
|
||||
|
@ -266,46 +264,17 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
}
|
||||
|
||||
public String getLastSearchText() {
|
||||
if (currentSearchType == 2) {
|
||||
return lastSearchTextMessages;
|
||||
} else {
|
||||
return lastSearchTextDialogs;
|
||||
}
|
||||
return lastSearchText;
|
||||
}
|
||||
|
||||
public boolean isGlobalSearch(int i) {
|
||||
if (currentSearchType != 2) {
|
||||
int localCount = searchResult.size();
|
||||
int globalCount = globalSearch.size();
|
||||
if (i >= 0 && i < localCount) {
|
||||
return false;
|
||||
} else if (i > localCount && i <= globalCount + localCount) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return i > searchResult.size() && i <= globalSearch.size() + searchResult.size();
|
||||
}
|
||||
|
||||
public void searchDialogs(final String query, final int type) {
|
||||
String lastSearchText;
|
||||
if (type == 2) {
|
||||
lastSearchText = lastSearchTextMessages;
|
||||
} else {
|
||||
lastSearchText = lastSearchTextDialogs;
|
||||
}
|
||||
boolean typeChanged = currentSearchType != type;
|
||||
currentSearchType = type;
|
||||
public void searchDialogs(final String query, final boolean serverOnly) {
|
||||
if (query == null && lastSearchText == null || query != null && lastSearchText != null && query.equals(lastSearchText)) {
|
||||
if (typeChanged) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (type == 2) {
|
||||
lastSearchTextMessages = query;
|
||||
} else {
|
||||
lastSearchTextDialogs = query;
|
||||
}
|
||||
try {
|
||||
if (searchTimer != null) {
|
||||
searchTimer.cancel();
|
||||
|
@ -314,13 +283,10 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
FileLog.e("tmessages", e);
|
||||
}
|
||||
if (query == null || query.length() == 0) {
|
||||
if (currentSearchType == 2) {
|
||||
searchMessagesInternal(null);
|
||||
} else {
|
||||
searchResult.clear();
|
||||
searchResultNames.clear();
|
||||
queryServerSearch(null);
|
||||
}
|
||||
searchResult.clear();
|
||||
searchResultNames.clear();
|
||||
searchMessagesInternal(null);
|
||||
queryServerSearch(null);
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
searchTimer = new Timer();
|
||||
|
@ -333,22 +299,14 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
if (type != 2) {
|
||||
searchDialogsInternal(query, type == 0);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
queryServerSearch(query);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
searchMessagesInternal(query);
|
||||
}
|
||||
});
|
||||
}
|
||||
searchDialogsInternal(query, serverOnly);
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
queryServerSearch(query);
|
||||
searchMessagesInternal(query);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 200, 300);
|
||||
}
|
||||
|
@ -361,38 +319,34 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int i) {
|
||||
return currentSearchType == 2 || i != searchResult.size();
|
||||
return i != searchResult.size() && i != searchResult.size() + (globalSearch.isEmpty() ? 0 : globalSearch.size() + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if (currentSearchType == 2) {
|
||||
return searchResultMessages.size();
|
||||
} else {
|
||||
int count = searchResult.size();
|
||||
int globalCount = globalSearch.size();
|
||||
if (globalCount != 0) {
|
||||
count += globalCount + 1;
|
||||
}
|
||||
return count;
|
||||
int count = searchResult.size();
|
||||
int globalCount = globalSearch.size();
|
||||
int messagesCount = searchResultMessages.size();
|
||||
if (globalCount != 0) {
|
||||
count += globalCount + 1;
|
||||
}
|
||||
if (messagesCount != 0) {
|
||||
count += messagesCount + 1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
if (currentSearchType == 2) {
|
||||
if (i < 0 || i >= searchResultMessages.size()) {
|
||||
return null;
|
||||
}
|
||||
return searchResultMessages.get(i);
|
||||
} else {
|
||||
int localCount = searchResult.size();
|
||||
int globalCount = globalSearch.size();
|
||||
if (i >= 0 && i < localCount) {
|
||||
return searchResult.get(i);
|
||||
} else if (i > localCount && i <= globalCount + localCount) {
|
||||
return globalSearch.get(i - localCount - 1);
|
||||
}
|
||||
int localCount = searchResult.size();
|
||||
int globalCount = globalSearch.isEmpty() ? 0 : globalSearch.size() + 1;
|
||||
int messagesCount = searchResultMessages.isEmpty() ? 0 : searchResultMessages.size() + 1;
|
||||
if (i >= 0 && i < localCount) {
|
||||
return searchResult.get(i);
|
||||
} else if (i > localCount && i < globalCount + localCount) {
|
||||
return globalSearch.get(i - localCount - 1);
|
||||
} else if (i > globalCount + localCount && i < globalCount + localCount + messagesCount) {
|
||||
return searchResultMessages.get(i - localCount - globalCount - 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -414,9 +368,13 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
if (type == 1) {
|
||||
if (view == null) {
|
||||
view = new SettingsSectionLayout(mContext);
|
||||
((SettingsSectionLayout) view).setText(LocaleController.getString("GlobalSearch", R.string.GlobalSearch));
|
||||
view.setPadding(AndroidUtilities.dp(11), 0, AndroidUtilities.dp(11), 0);
|
||||
}
|
||||
if (!globalSearch.isEmpty() && i == searchResult.size()) {
|
||||
((SettingsSectionLayout) view).setText(LocaleController.getString("GlobalSearch", R.string.GlobalSearch));
|
||||
} else {
|
||||
((SettingsSectionLayout) view).setText(LocaleController.getString("SearchMessages", R.string.SearchMessages));
|
||||
}
|
||||
} else if (type == 0) {
|
||||
if (view == null) {
|
||||
view = new ChatOrUserCell(mContext);
|
||||
|
@ -426,7 +384,10 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
TLRPC.Chat chat = null;
|
||||
TLRPC.EncryptedChat encryptedChat = null;
|
||||
|
||||
((ChatOrUserCell) view).useSeparator = (i != getCount() - 1 && i != searchResult.size() - 1);
|
||||
int localCount = searchResult.size();
|
||||
int globalCount = globalSearch.isEmpty() ? -1 : globalSearch.size() + 1;
|
||||
|
||||
((ChatOrUserCell) view).useSeparator = (i != getCount() - 1 && i != localCount - 1 && i != localCount + globalCount - 1);
|
||||
Object obj = getItem(i);
|
||||
if (obj instanceof TLRPC.User) {
|
||||
user = MessagesController.getInstance().getUser(((TLRPC.User) obj).id);
|
||||
|
@ -465,7 +426,7 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
view = new DialogCell(mContext);
|
||||
}
|
||||
((DialogCell) view).useSeparator = (i != getCount() - 1);
|
||||
MessageObject messageObject = searchResultMessages.get(i);
|
||||
MessageObject messageObject = (MessageObject)getItem(i);
|
||||
((DialogCell) view).setDialog(messageObject.getDialogId(), messageObject, false, messageObject.messageOwner.date, 0);
|
||||
}
|
||||
|
||||
|
@ -474,14 +435,15 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
if (currentSearchType == 2) {
|
||||
return 2;
|
||||
} else {
|
||||
if (i == searchResult.size()) {
|
||||
return 1;
|
||||
}
|
||||
int localCount = searchResult.size();
|
||||
int globalCount = globalSearch.isEmpty() ? 0 : globalSearch.size() + 1;
|
||||
int messagesCount = searchResultMessages.isEmpty() ? 0 : searchResultMessages.size() + 1;
|
||||
if (i >= 0 && i < localCount || i > localCount && i < globalCount + localCount) {
|
||||
return 0;
|
||||
} else if (i > globalCount + localCount && i < globalCount + localCount + messagesCount) {
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -491,9 +453,6 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
if (currentSearchType == 2) {
|
||||
return searchResultMessages.isEmpty();
|
||||
}
|
||||
return searchResult.isEmpty() && globalSearch.isEmpty();
|
||||
return searchResult.isEmpty() && globalSearch.isEmpty() && searchResultMessages.isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,191 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class Animator10 implements Cloneable {
|
||||
|
||||
ArrayList<AnimatorListener> mListeners = null;
|
||||
ArrayList<AnimatorPauseListener> mPauseListeners = null;
|
||||
boolean mPaused = false;
|
||||
|
||||
public abstract long getStartDelay();
|
||||
|
||||
public abstract void setStartDelay(long startDelay);
|
||||
|
||||
public abstract Animator10 setDuration(long duration);
|
||||
|
||||
public abstract long getDuration();
|
||||
|
||||
public abstract void setInterpolator(Interpolator value);
|
||||
|
||||
public abstract boolean isRunning();
|
||||
|
||||
public void start() {
|
||||
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
|
||||
}
|
||||
|
||||
public void end() {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void pause() {
|
||||
if (isStarted() && !mPaused) {
|
||||
mPaused = true;
|
||||
if (mPauseListeners != null) {
|
||||
ArrayList<AnimatorPauseListener> tmpListeners = (ArrayList<AnimatorPauseListener>) mPauseListeners.clone();
|
||||
int numListeners = tmpListeners.size();
|
||||
for (AnimatorPauseListener tmpListener : tmpListeners) {
|
||||
tmpListener.onAnimationPause(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void resume() {
|
||||
if (mPaused) {
|
||||
mPaused = false;
|
||||
if (mPauseListeners != null) {
|
||||
ArrayList<AnimatorPauseListener> tmpListeners = (ArrayList<AnimatorPauseListener>) mPauseListeners.clone();
|
||||
int numListeners = tmpListeners.size();
|
||||
for (AnimatorPauseListener tmpListener : tmpListeners) {
|
||||
tmpListener.onAnimationResume(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPaused() {
|
||||
return mPaused;
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
return isRunning();
|
||||
}
|
||||
|
||||
public Interpolator getInterpolator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addListener(AnimatorListener listener) {
|
||||
if (mListeners == null) {
|
||||
mListeners = new ArrayList<AnimatorListener>();
|
||||
}
|
||||
mListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(AnimatorListener listener) {
|
||||
if (mListeners == null) {
|
||||
return;
|
||||
}
|
||||
mListeners.remove(listener);
|
||||
if (mListeners.size() == 0) {
|
||||
mListeners = null;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<AnimatorListener> getListeners() {
|
||||
return mListeners;
|
||||
}
|
||||
|
||||
public void addPauseListener(AnimatorPauseListener listener) {
|
||||
if (mPauseListeners == null) {
|
||||
mPauseListeners = new ArrayList<AnimatorPauseListener>();
|
||||
}
|
||||
mPauseListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removePauseListener(AnimatorPauseListener listener) {
|
||||
if (mPauseListeners == null) {
|
||||
return;
|
||||
}
|
||||
mPauseListeners.remove(listener);
|
||||
if (mPauseListeners.size() == 0) {
|
||||
mPauseListeners = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAllListeners() {
|
||||
if (mListeners != null) {
|
||||
mListeners.clear();
|
||||
mListeners = null;
|
||||
}
|
||||
if (mPauseListeners != null) {
|
||||
mPauseListeners.clear();
|
||||
mPauseListeners = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animator10 clone() {
|
||||
try {
|
||||
final Animator10 anim = (Animator10) super.clone();
|
||||
if (mListeners != null) {
|
||||
ArrayList<AnimatorListener> oldListeners = mListeners;
|
||||
anim.mListeners = new ArrayList<AnimatorListener>();
|
||||
int numListeners = oldListeners.size();
|
||||
for (AnimatorListener oldListener : oldListeners) {
|
||||
anim.mListeners.add(oldListener);
|
||||
}
|
||||
}
|
||||
if (mPauseListeners != null) {
|
||||
ArrayList<AnimatorPauseListener> oldListeners = mPauseListeners;
|
||||
anim.mPauseListeners = new ArrayList<AnimatorPauseListener>();
|
||||
int numListeners = oldListeners.size();
|
||||
for (AnimatorPauseListener oldListener : oldListeners) {
|
||||
anim.mPauseListeners.add(oldListener);
|
||||
}
|
||||
}
|
||||
return anim;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
public void setupStartValues() {
|
||||
|
||||
}
|
||||
|
||||
public void setupEndValues() {
|
||||
|
||||
}
|
||||
|
||||
public void setTarget(Object target) {
|
||||
|
||||
}
|
||||
|
||||
public static interface AnimatorListener {
|
||||
void onAnimationStart(Animator10 animation);
|
||||
void onAnimationEnd(Animator10 animation);
|
||||
void onAnimationCancel(Animator10 animation);
|
||||
void onAnimationRepeat(Animator10 animation);
|
||||
}
|
||||
|
||||
public static interface AnimatorPauseListener {
|
||||
void onAnimationPause(Animator10 animation);
|
||||
void onAnimationResume(Animator10 animation);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
public abstract class AnimatorListenerAdapter10 implements Animator10.AnimatorListener, Animator10.AnimatorPauseListener {
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator10 animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator10 animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator10 animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator10 animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationPause(Animator10 animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationResume(Animator10 animation) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,705 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public final class AnimatorSet10 extends Animator10 {
|
||||
|
||||
private ArrayList<Animator10> mPlayingSet = new ArrayList<Animator10>();
|
||||
private HashMap<Animator10, Node> mNodeMap = new HashMap<Animator10, Node>();
|
||||
private ArrayList<Node> mNodes = new ArrayList<Node>();
|
||||
private ArrayList<Node> mSortedNodes = new ArrayList<Node>();
|
||||
private boolean mNeedsSort = true;
|
||||
private AnimatorSetListener mSetListener = null;
|
||||
boolean mTerminated = false;
|
||||
private boolean mStarted = false;
|
||||
private long mStartDelay = 0;
|
||||
private ValueAnimator mDelayAnim = null;
|
||||
private long mDuration = -1;
|
||||
private Interpolator mInterpolator = null;
|
||||
|
||||
public void playTogether(Animator10... items) {
|
||||
if (items != null) {
|
||||
mNeedsSort = true;
|
||||
Builder builder = play(items[0]);
|
||||
for (int i = 1; i < items.length; ++i) {
|
||||
builder.with(items[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void playTogether(Collection<Animator10> items) {
|
||||
if (items != null && items.size() > 0) {
|
||||
mNeedsSort = true;
|
||||
Builder builder = null;
|
||||
for (Animator10 anim : items) {
|
||||
if (builder == null) {
|
||||
builder = play(anim);
|
||||
} else {
|
||||
builder.with(anim);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void playSequentially(Animator10... items) {
|
||||
if (items != null) {
|
||||
mNeedsSort = true;
|
||||
if (items.length == 1) {
|
||||
play(items[0]);
|
||||
} else {
|
||||
for (int i = 0; i < items.length - 1; ++i) {
|
||||
play(items[i]).before(items[i+1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void playSequentially(List<Animator10> items) {
|
||||
if (items != null && items.size() > 0) {
|
||||
mNeedsSort = true;
|
||||
if (items.size() == 1) {
|
||||
play(items.get(0));
|
||||
} else {
|
||||
for (int i = 0; i < items.size() - 1; ++i) {
|
||||
play(items.get(i)).before(items.get(i+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Animator10> getChildAnimations() {
|
||||
ArrayList<Animator10> childList = new ArrayList<Animator10>();
|
||||
for (Node node : mNodes) {
|
||||
childList.add(node.animation);
|
||||
}
|
||||
return childList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTarget(Object target) {
|
||||
for (Node node : mNodes) {
|
||||
Animator10 animation = node.animation;
|
||||
if (animation instanceof AnimatorSet10) {
|
||||
animation.setTarget(target);
|
||||
} else if (animation instanceof ObjectAnimator10) {
|
||||
animation.setTarget(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInterpolator(Interpolator interpolator) {
|
||||
mInterpolator = interpolator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interpolator getInterpolator() {
|
||||
return mInterpolator;
|
||||
}
|
||||
|
||||
public Builder play(Animator10 anim) {
|
||||
if (anim != null) {
|
||||
mNeedsSort = true;
|
||||
return new Builder(anim);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void cancel() {
|
||||
mTerminated = true;
|
||||
if (isStarted()) {
|
||||
ArrayList<AnimatorListener> tmpListeners = null;
|
||||
if (mListeners != null) {
|
||||
tmpListeners = (ArrayList<AnimatorListener>) mListeners.clone();
|
||||
for (AnimatorListener listener : tmpListeners) {
|
||||
listener.onAnimationCancel(this);
|
||||
}
|
||||
}
|
||||
if (mDelayAnim != null && mDelayAnim.isRunning()) {
|
||||
mDelayAnim.cancel();
|
||||
} else if (mSortedNodes.size() > 0) {
|
||||
for (Node node : mSortedNodes) {
|
||||
node.animation.cancel();
|
||||
}
|
||||
}
|
||||
if (tmpListeners != null) {
|
||||
for (AnimatorListener listener : tmpListeners) {
|
||||
listener.onAnimationEnd(this);
|
||||
}
|
||||
}
|
||||
mStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void end() {
|
||||
mTerminated = true;
|
||||
if (isStarted()) {
|
||||
if (mSortedNodes.size() != mNodes.size()) {
|
||||
// hasn't been started yet - sort the nodes now, then end them
|
||||
sortNodes();
|
||||
for (Node node : mSortedNodes) {
|
||||
if (mSetListener == null) {
|
||||
mSetListener = new AnimatorSetListener(this);
|
||||
}
|
||||
node.animation.addListener(mSetListener);
|
||||
}
|
||||
}
|
||||
if (mDelayAnim != null) {
|
||||
mDelayAnim.cancel();
|
||||
}
|
||||
if (mSortedNodes.size() > 0) {
|
||||
for (Node node : mSortedNodes) {
|
||||
node.animation.end();
|
||||
}
|
||||
}
|
||||
if (mListeners != null) {
|
||||
ArrayList<AnimatorListener> tmpListeners = (ArrayList<AnimatorListener>) mListeners.clone();
|
||||
for (AnimatorListener listener : tmpListeners) {
|
||||
listener.onAnimationEnd(this);
|
||||
}
|
||||
}
|
||||
mStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
for (Node node : mNodes) {
|
||||
if (node.animation.isRunning()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return mStarted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStartDelay() {
|
||||
return mStartDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelay(long startDelay) {
|
||||
mStartDelay = startDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDuration() {
|
||||
return mDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimatorSet10 setDuration(long duration) {
|
||||
if (duration < 0) {
|
||||
throw new IllegalArgumentException("duration must be a value of zero or greater");
|
||||
}
|
||||
mDuration = duration;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupStartValues() {
|
||||
for (Node node : mNodes) {
|
||||
node.animation.setupStartValues();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupEndValues() {
|
||||
for (Node node : mNodes) {
|
||||
node.animation.setupEndValues();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
boolean previouslyPaused = mPaused;
|
||||
super.pause();
|
||||
if (!previouslyPaused && mPaused) {
|
||||
if (mDelayAnim != null) {
|
||||
mDelayAnim.pause();
|
||||
} else {
|
||||
for (Node node : mNodes) {
|
||||
node.animation.pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
boolean previouslyPaused = mPaused;
|
||||
super.resume();
|
||||
if (previouslyPaused && !mPaused) {
|
||||
if (mDelayAnim != null) {
|
||||
mDelayAnim.resume();
|
||||
} else {
|
||||
for (Node node : mNodes) {
|
||||
node.animation.resume();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void start() {
|
||||
mTerminated = false;
|
||||
mStarted = true;
|
||||
mPaused = false;
|
||||
|
||||
if (mDuration >= 0) {
|
||||
for (Node node : mNodes) {
|
||||
node.animation.setDuration(mDuration);
|
||||
}
|
||||
}
|
||||
if (mInterpolator != null) {
|
||||
for (Node node : mNodes) {
|
||||
node.animation.setInterpolator(mInterpolator);
|
||||
}
|
||||
}
|
||||
|
||||
sortNodes();
|
||||
|
||||
int numSortedNodes = mSortedNodes.size();
|
||||
for (Node node : mSortedNodes) {
|
||||
ArrayList<AnimatorListener> oldListeners = node.animation.getListeners();
|
||||
if (oldListeners != null && oldListeners.size() > 0) {
|
||||
final ArrayList<AnimatorListener> clonedListeners = new
|
||||
ArrayList<AnimatorListener>(oldListeners);
|
||||
|
||||
for (AnimatorListener listener : clonedListeners) {
|
||||
if (listener instanceof DependencyListener ||
|
||||
listener instanceof AnimatorSetListener) {
|
||||
node.animation.removeListener(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final ArrayList<Node> nodesToStart = new ArrayList<Node>();
|
||||
for (Node node : mSortedNodes) {
|
||||
if (mSetListener == null) {
|
||||
mSetListener = new AnimatorSetListener(this);
|
||||
}
|
||||
if (node.dependencies == null || node.dependencies.size() == 0) {
|
||||
nodesToStart.add(node);
|
||||
} else {
|
||||
int numDependencies = node.dependencies.size();
|
||||
for (int j = 0; j < numDependencies; ++j) {
|
||||
Dependency dependency = node.dependencies.get(j);
|
||||
dependency.node.animation.addListener(
|
||||
new DependencyListener(this, node, dependency.rule));
|
||||
}
|
||||
node.tmpDependencies = (ArrayList<Dependency>) node.dependencies.clone();
|
||||
}
|
||||
node.animation.addListener(mSetListener);
|
||||
}
|
||||
|
||||
if (mStartDelay <= 0) {
|
||||
for (Node node : nodesToStart) {
|
||||
node.animation.start();
|
||||
mPlayingSet.add(node.animation);
|
||||
}
|
||||
} else {
|
||||
mDelayAnim = ValueAnimator.ofFloat(0f, 1f);
|
||||
mDelayAnim.setDuration(mStartDelay);
|
||||
mDelayAnim.addListener(new AnimatorListenerAdapter10() {
|
||||
boolean canceled = false;
|
||||
public void onAnimationCancel(Animator10 anim) {
|
||||
canceled = true;
|
||||
}
|
||||
public void onAnimationEnd(Animator10 anim) {
|
||||
if (!canceled) {
|
||||
int numNodes = nodesToStart.size();
|
||||
for (Node node : nodesToStart) {
|
||||
node.animation.start();
|
||||
mPlayingSet.add(node.animation);
|
||||
}
|
||||
}
|
||||
mDelayAnim = null;
|
||||
}
|
||||
});
|
||||
mDelayAnim.start();
|
||||
}
|
||||
if (mListeners != null) {
|
||||
ArrayList<AnimatorListener> tmpListeners =
|
||||
(ArrayList<AnimatorListener>) mListeners.clone();
|
||||
int numListeners = tmpListeners.size();
|
||||
for (AnimatorListener tmpListener : tmpListeners) {
|
||||
tmpListener.onAnimationStart(this);
|
||||
}
|
||||
}
|
||||
if (mNodes.size() == 0 && mStartDelay == 0) {
|
||||
mStarted = false;
|
||||
if (mListeners != null) {
|
||||
ArrayList<AnimatorListener> tmpListeners =
|
||||
(ArrayList<AnimatorListener>) mListeners.clone();
|
||||
int numListeners = tmpListeners.size();
|
||||
for (AnimatorListener tmpListener : tmpListeners) {
|
||||
tmpListener.onAnimationEnd(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimatorSet10 clone() {
|
||||
final AnimatorSet10 anim = (AnimatorSet10) super.clone();
|
||||
|
||||
anim.mNeedsSort = true;
|
||||
anim.mTerminated = false;
|
||||
anim.mStarted = false;
|
||||
anim.mPlayingSet = new ArrayList<Animator10>();
|
||||
anim.mNodeMap = new HashMap<Animator10, Node>();
|
||||
anim.mNodes = new ArrayList<Node>();
|
||||
anim.mSortedNodes = new ArrayList<Node>();
|
||||
|
||||
HashMap<Node, Node> nodeCloneMap = new HashMap<Node, Node>();
|
||||
for (Node node : mNodes) {
|
||||
Node nodeClone = node.clone();
|
||||
nodeCloneMap.put(node, nodeClone);
|
||||
anim.mNodes.add(nodeClone);
|
||||
anim.mNodeMap.put(nodeClone.animation, nodeClone);
|
||||
nodeClone.dependencies = null;
|
||||
nodeClone.tmpDependencies = null;
|
||||
nodeClone.nodeDependents = null;
|
||||
nodeClone.nodeDependencies = null;
|
||||
ArrayList<AnimatorListener> cloneListeners = nodeClone.animation.getListeners();
|
||||
if (cloneListeners != null) {
|
||||
ArrayList<AnimatorListener> listenersToRemove = null;
|
||||
for (AnimatorListener listener : cloneListeners) {
|
||||
if (listener instanceof AnimatorSetListener) {
|
||||
if (listenersToRemove == null) {
|
||||
listenersToRemove = new ArrayList<AnimatorListener>();
|
||||
}
|
||||
listenersToRemove.add(listener);
|
||||
}
|
||||
}
|
||||
if (listenersToRemove != null) {
|
||||
for (AnimatorListener listener : listenersToRemove) {
|
||||
cloneListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Node node : mNodes) {
|
||||
Node nodeClone = nodeCloneMap.get(node);
|
||||
if (node.dependencies != null) {
|
||||
for (Dependency dependency : node.dependencies) {
|
||||
Node clonedDependencyNode = nodeCloneMap.get(dependency.node);
|
||||
Dependency cloneDependency = new Dependency(clonedDependencyNode, dependency.rule);
|
||||
nodeClone.addDependency(cloneDependency);
|
||||
}
|
||||
}
|
||||
}
|
||||
return anim;
|
||||
}
|
||||
|
||||
private static class DependencyListener implements AnimatorListener {
|
||||
|
||||
private AnimatorSet10 mAnimatorSet;
|
||||
private Node mNode;
|
||||
private int mRule;
|
||||
|
||||
public DependencyListener(AnimatorSet10 animatorSet, Node node, int rule) {
|
||||
this.mAnimatorSet = animatorSet;
|
||||
this.mNode = node;
|
||||
this.mRule = rule;
|
||||
}
|
||||
|
||||
public void onAnimationCancel(Animator10 animation) {
|
||||
|
||||
}
|
||||
|
||||
public void onAnimationEnd(Animator10 animation) {
|
||||
if (mRule == Dependency.AFTER) {
|
||||
startIfReady(animation);
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimationRepeat(Animator10 animation) {
|
||||
|
||||
}
|
||||
|
||||
public void onAnimationStart(Animator10 animation) {
|
||||
if (mRule == Dependency.WITH) {
|
||||
startIfReady(animation);
|
||||
}
|
||||
}
|
||||
|
||||
private void startIfReady(Animator10 dependencyAnimation) {
|
||||
if (mAnimatorSet.mTerminated) {
|
||||
return;
|
||||
}
|
||||
Dependency dependencyToRemove = null;
|
||||
int numDependencies = mNode.tmpDependencies.size();
|
||||
for (int i = 0; i < numDependencies; ++i) {
|
||||
Dependency dependency = mNode.tmpDependencies.get(i);
|
||||
if (dependency.rule == mRule && dependency.node.animation == dependencyAnimation) {
|
||||
dependencyToRemove = dependency;
|
||||
dependencyAnimation.removeListener(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
mNode.tmpDependencies.remove(dependencyToRemove);
|
||||
if (mNode.tmpDependencies.size() == 0) {
|
||||
mNode.animation.start();
|
||||
mAnimatorSet.mPlayingSet.add(mNode.animation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class AnimatorSetListener implements AnimatorListener {
|
||||
|
||||
private AnimatorSet10 mAnimatorSet;
|
||||
|
||||
AnimatorSetListener(AnimatorSet10 animatorSet) {
|
||||
mAnimatorSet = animatorSet;
|
||||
}
|
||||
|
||||
public void onAnimationCancel(Animator10 animation) {
|
||||
if (!mTerminated) {
|
||||
if (mPlayingSet.size() == 0) {
|
||||
if (mListeners != null) {
|
||||
int numListeners = mListeners.size();
|
||||
for (AnimatorListener mListener : mListeners) {
|
||||
mListener.onAnimationCancel(mAnimatorSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void onAnimationEnd(Animator10 animation) {
|
||||
animation.removeListener(this);
|
||||
mPlayingSet.remove(animation);
|
||||
Node animNode = mAnimatorSet.mNodeMap.get(animation);
|
||||
animNode.done = true;
|
||||
if (!mTerminated) {
|
||||
ArrayList<Node> sortedNodes = mAnimatorSet.mSortedNodes;
|
||||
boolean allDone = true;
|
||||
int numSortedNodes = sortedNodes.size();
|
||||
for (Node sortedNode : sortedNodes) {
|
||||
if (!sortedNode.done) {
|
||||
allDone = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allDone) {
|
||||
if (mListeners != null) {
|
||||
ArrayList<AnimatorListener> tmpListeners =
|
||||
(ArrayList<AnimatorListener>) mListeners.clone();
|
||||
int numListeners = tmpListeners.size();
|
||||
for (AnimatorListener tmpListener : tmpListeners) {
|
||||
tmpListener.onAnimationEnd(mAnimatorSet);
|
||||
}
|
||||
}
|
||||
mAnimatorSet.mStarted = false;
|
||||
mAnimatorSet.mPaused = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimationRepeat(Animator10 animation) {
|
||||
|
||||
}
|
||||
|
||||
public void onAnimationStart(Animator10 animation) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void sortNodes() {
|
||||
if (mNeedsSort) {
|
||||
mSortedNodes.clear();
|
||||
ArrayList<Node> roots = new ArrayList<Node>();
|
||||
int numNodes = mNodes.size();
|
||||
for (Node node : mNodes) {
|
||||
if (node.dependencies == null || node.dependencies.size() == 0) {
|
||||
roots.add(node);
|
||||
}
|
||||
}
|
||||
ArrayList<Node> tmpRoots = new ArrayList<Node>();
|
||||
while (roots.size() > 0) {
|
||||
int numRoots = roots.size();
|
||||
for (Node root : roots) {
|
||||
mSortedNodes.add(root);
|
||||
if (root.nodeDependents != null) {
|
||||
int numDependents = root.nodeDependents.size();
|
||||
for (int j = 0; j < numDependents; ++j) {
|
||||
Node node = root.nodeDependents.get(j);
|
||||
node.nodeDependencies.remove(root);
|
||||
if (node.nodeDependencies.size() == 0) {
|
||||
tmpRoots.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
roots.clear();
|
||||
roots.addAll(tmpRoots);
|
||||
tmpRoots.clear();
|
||||
}
|
||||
mNeedsSort = false;
|
||||
if (mSortedNodes.size() != mNodes.size()) {
|
||||
throw new IllegalStateException("Circular dependencies cannot exist in AnimatorSet");
|
||||
}
|
||||
} else {
|
||||
int numNodes = mNodes.size();
|
||||
for (Node node : mNodes) {
|
||||
if (node.dependencies != null && node.dependencies.size() > 0) {
|
||||
int numDependencies = node.dependencies.size();
|
||||
for (int j = 0; j < numDependencies; ++j) {
|
||||
Dependency dependency = node.dependencies.get(j);
|
||||
if (node.nodeDependencies == null) {
|
||||
node.nodeDependencies = new ArrayList<Node>();
|
||||
}
|
||||
if (!node.nodeDependencies.contains(dependency.node)) {
|
||||
node.nodeDependencies.add(dependency.node);
|
||||
}
|
||||
}
|
||||
}
|
||||
node.done = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class Dependency {
|
||||
static final int WITH = 0;
|
||||
static final int AFTER = 1;
|
||||
public Node node;
|
||||
public int rule;
|
||||
|
||||
public Dependency(Node node, int rule) {
|
||||
this.node = node;
|
||||
this.rule = rule;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Node implements Cloneable {
|
||||
public Animator10 animation;
|
||||
public ArrayList<Dependency> dependencies = null;
|
||||
public ArrayList<Dependency> tmpDependencies = null;
|
||||
public ArrayList<Node> nodeDependencies = null;
|
||||
public ArrayList<Node> nodeDependents = null;
|
||||
public boolean done = false;
|
||||
|
||||
public Node(Animator10 animation) {
|
||||
this.animation = animation;
|
||||
}
|
||||
|
||||
public void addDependency(Dependency dependency) {
|
||||
if (dependencies == null) {
|
||||
dependencies = new ArrayList<Dependency>();
|
||||
nodeDependencies = new ArrayList<Node>();
|
||||
}
|
||||
dependencies.add(dependency);
|
||||
if (!nodeDependencies.contains(dependency.node)) {
|
||||
nodeDependencies.add(dependency.node);
|
||||
}
|
||||
Node dependencyNode = dependency.node;
|
||||
if (dependencyNode.nodeDependents == null) {
|
||||
dependencyNode.nodeDependents = new ArrayList<Node>();
|
||||
}
|
||||
dependencyNode.nodeDependents.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node clone() {
|
||||
try {
|
||||
Node node = (Node) super.clone();
|
||||
node.animation = animation.clone();
|
||||
return node;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Builder {
|
||||
|
||||
private Node mCurrentNode;
|
||||
|
||||
Builder(Animator10 anim) {
|
||||
mCurrentNode = mNodeMap.get(anim);
|
||||
if (mCurrentNode == null) {
|
||||
mCurrentNode = new Node(anim);
|
||||
mNodeMap.put(anim, mCurrentNode);
|
||||
mNodes.add(mCurrentNode);
|
||||
}
|
||||
}
|
||||
|
||||
public Builder with(Animator10 anim) {
|
||||
Node node = mNodeMap.get(anim);
|
||||
if (node == null) {
|
||||
node = new Node(anim);
|
||||
mNodeMap.put(anim, node);
|
||||
mNodes.add(node);
|
||||
}
|
||||
Dependency dependency = new Dependency(mCurrentNode, Dependency.WITH);
|
||||
node.addDependency(dependency);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder before(Animator10 anim) {
|
||||
Node node = mNodeMap.get(anim);
|
||||
if (node == null) {
|
||||
node = new Node(anim);
|
||||
mNodeMap.put(anim, node);
|
||||
mNodes.add(node);
|
||||
}
|
||||
Dependency dependency = new Dependency(mCurrentNode, Dependency.AFTER);
|
||||
node.addDependency(dependency);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder after(Animator10 anim) {
|
||||
Node node = mNodeMap.get(anim);
|
||||
if (node == null) {
|
||||
node = new Node(anim);
|
||||
mNodeMap.put(anim, node);
|
||||
mNodes.add(node);
|
||||
}
|
||||
Dependency dependency = new Dependency(node, Dependency.AFTER);
|
||||
mCurrentNode.addDependency(dependency);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder after(long delay) {
|
||||
ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
|
||||
anim.setDuration(delay);
|
||||
after(anim);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
public class FloatEvaluator implements TypeEvaluator<Number> {
|
||||
public Float evaluate(float fraction, Number startValue, Number endValue) {
|
||||
float startFloat = startValue.floatValue();
|
||||
return startFloat + fraction * (endValue.floatValue() - startFloat);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import org.telegram.ui.Animation.Keyframe.FloatKeyframe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
class FloatKeyframeSet extends KeyframeSet {
|
||||
private float firstValue;
|
||||
private float lastValue;
|
||||
private float deltaValue;
|
||||
private boolean firstTime = true;
|
||||
|
||||
public FloatKeyframeSet(FloatKeyframe... keyframes) {
|
||||
super(keyframes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(float fraction) {
|
||||
return getFloatValue(fraction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatKeyframeSet clone() {
|
||||
ArrayList<Keyframe> keyframes = mKeyframes;
|
||||
int numKeyframes = mKeyframes.size();
|
||||
FloatKeyframe[] newKeyframes = new FloatKeyframe[numKeyframes];
|
||||
for (int i = 0; i < numKeyframes; ++i) {
|
||||
newKeyframes[i] = (FloatKeyframe) keyframes.get(i).clone();
|
||||
}
|
||||
return new FloatKeyframeSet(newKeyframes);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public float getFloatValue(float fraction) {
|
||||
if (mNumKeyframes == 2) {
|
||||
if (firstTime) {
|
||||
firstTime = false;
|
||||
firstValue = ((FloatKeyframe) mKeyframes.get(0)).getFloatValue();
|
||||
lastValue = ((FloatKeyframe) mKeyframes.get(1)).getFloatValue();
|
||||
deltaValue = lastValue - firstValue;
|
||||
}
|
||||
if (mInterpolator != null) {
|
||||
fraction = mInterpolator.getInterpolation(fraction);
|
||||
}
|
||||
if (mEvaluator == null) {
|
||||
return firstValue + fraction * deltaValue;
|
||||
} else {
|
||||
return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).floatValue();
|
||||
}
|
||||
}
|
||||
if (fraction <= 0f) {
|
||||
final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0);
|
||||
final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(1);
|
||||
float prevValue = prevKeyframe.getFloatValue();
|
||||
float nextValue = nextKeyframe.getFloatValue();
|
||||
float prevFraction = prevKeyframe.getFraction();
|
||||
float nextFraction = nextKeyframe.getFraction();
|
||||
final Interpolator interpolator = nextKeyframe.getInterpolator();
|
||||
if (interpolator != null) {
|
||||
fraction = interpolator.getInterpolation(fraction);
|
||||
}
|
||||
float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction);
|
||||
return mEvaluator == null ? prevValue + intervalFraction * (nextValue - prevValue) : ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).floatValue();
|
||||
} else if (fraction >= 1f) {
|
||||
final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 2);
|
||||
final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 1);
|
||||
float prevValue = prevKeyframe.getFloatValue();
|
||||
float nextValue = nextKeyframe.getFloatValue();
|
||||
float prevFraction = prevKeyframe.getFraction();
|
||||
float nextFraction = nextKeyframe.getFraction();
|
||||
final Interpolator interpolator = nextKeyframe.getInterpolator();
|
||||
if (interpolator != null) {
|
||||
fraction = interpolator.getInterpolation(fraction);
|
||||
}
|
||||
float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction);
|
||||
return mEvaluator == null ? prevValue + intervalFraction * (nextValue - prevValue) : ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).floatValue();
|
||||
}
|
||||
FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0);
|
||||
for (int i = 1; i < mNumKeyframes; ++i) {
|
||||
FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(i);
|
||||
if (fraction < nextKeyframe.getFraction()) {
|
||||
final Interpolator interpolator = nextKeyframe.getInterpolator();
|
||||
if (interpolator != null) {
|
||||
fraction = interpolator.getInterpolation(fraction);
|
||||
}
|
||||
float intervalFraction = (fraction - prevKeyframe.getFraction()) /
|
||||
(nextKeyframe.getFraction() - prevKeyframe.getFraction());
|
||||
float prevValue = prevKeyframe.getFloatValue();
|
||||
float nextValue = nextKeyframe.getFloatValue();
|
||||
return mEvaluator == null ? prevValue + intervalFraction * (nextValue - prevValue) : ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).floatValue();
|
||||
}
|
||||
prevKeyframe = nextKeyframe;
|
||||
}
|
||||
return ((Number)mKeyframes.get(mNumKeyframes - 1).getValue()).floatValue();
|
||||
}
|
||||
}
|
30
TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty.java
Executable file
30
TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty.java
Executable file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
public abstract class FloatProperty<T> extends Property<T, Float> {
|
||||
|
||||
public FloatProperty(String name) {
|
||||
super(Float.class, name);
|
||||
}
|
||||
|
||||
public abstract void setValue(T object, float value);
|
||||
|
||||
@Override
|
||||
final public void set(T object, Float value) {
|
||||
setValue(object, value.floatValue());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
public class IntEvaluator implements TypeEvaluator<Integer> {
|
||||
public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
|
||||
int startInt = startValue;
|
||||
return (int)(startInt + fraction * (endValue - startInt));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import org.telegram.ui.Animation.Keyframe.IntKeyframe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
class IntKeyframeSet extends KeyframeSet {
|
||||
private int firstValue;
|
||||
private int lastValue;
|
||||
private int deltaValue;
|
||||
private boolean firstTime = true;
|
||||
|
||||
public IntKeyframeSet(IntKeyframe... keyframes) {
|
||||
super(keyframes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(float fraction) {
|
||||
return getIntValue(fraction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntKeyframeSet clone() {
|
||||
ArrayList<Keyframe> keyframes = mKeyframes;
|
||||
int numKeyframes = mKeyframes.size();
|
||||
IntKeyframe[] newKeyframes = new IntKeyframe[numKeyframes];
|
||||
for (int i = 0; i < numKeyframes; ++i) {
|
||||
newKeyframes[i] = (IntKeyframe) keyframes.get(i).clone();
|
||||
}
|
||||
return new IntKeyframeSet(newKeyframes);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public int getIntValue(float fraction) {
|
||||
if (mNumKeyframes == 2) {
|
||||
if (firstTime) {
|
||||
firstTime = false;
|
||||
firstValue = ((IntKeyframe) mKeyframes.get(0)).getIntValue();
|
||||
lastValue = ((IntKeyframe) mKeyframes.get(1)).getIntValue();
|
||||
deltaValue = lastValue - firstValue;
|
||||
}
|
||||
if (mInterpolator != null) {
|
||||
fraction = mInterpolator.getInterpolation(fraction);
|
||||
}
|
||||
if (mEvaluator == null) {
|
||||
return firstValue + (int)(fraction * deltaValue);
|
||||
} else {
|
||||
return ((Number)mEvaluator.evaluate(fraction, firstValue, lastValue)).intValue();
|
||||
}
|
||||
}
|
||||
if (fraction <= 0f) {
|
||||
final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0);
|
||||
final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(1);
|
||||
int prevValue = prevKeyframe.getIntValue();
|
||||
int nextValue = nextKeyframe.getIntValue();
|
||||
float prevFraction = prevKeyframe.getFraction();
|
||||
float nextFraction = nextKeyframe.getFraction();
|
||||
final Interpolator interpolator = nextKeyframe.getInterpolator();
|
||||
if (interpolator != null) {
|
||||
fraction = interpolator.getInterpolation(fraction);
|
||||
}
|
||||
float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction);
|
||||
return mEvaluator == null ? prevValue + (int)(intervalFraction * (nextValue - prevValue)) : ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).intValue();
|
||||
} else if (fraction >= 1f) {
|
||||
final IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 2);
|
||||
final IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(mNumKeyframes - 1);
|
||||
int prevValue = prevKeyframe.getIntValue();
|
||||
int nextValue = nextKeyframe.getIntValue();
|
||||
float prevFraction = prevKeyframe.getFraction();
|
||||
float nextFraction = nextKeyframe.getFraction();
|
||||
final Interpolator interpolator = nextKeyframe.getInterpolator();
|
||||
if (interpolator != null) {
|
||||
fraction = interpolator.getInterpolation(fraction);
|
||||
}
|
||||
float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction);
|
||||
return mEvaluator == null ? prevValue + (int)(intervalFraction * (nextValue - prevValue)) : ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).intValue();
|
||||
}
|
||||
IntKeyframe prevKeyframe = (IntKeyframe) mKeyframes.get(0);
|
||||
for (int i = 1; i < mNumKeyframes; ++i) {
|
||||
IntKeyframe nextKeyframe = (IntKeyframe) mKeyframes.get(i);
|
||||
if (fraction < nextKeyframe.getFraction()) {
|
||||
final Interpolator interpolator = nextKeyframe.getInterpolator();
|
||||
if (interpolator != null) {
|
||||
fraction = interpolator.getInterpolation(fraction);
|
||||
}
|
||||
float intervalFraction = (fraction - prevKeyframe.getFraction()) / (nextKeyframe.getFraction() - prevKeyframe.getFraction());
|
||||
int prevValue = prevKeyframe.getIntValue();
|
||||
int nextValue = nextKeyframe.getIntValue();
|
||||
return mEvaluator == null ? prevValue + (int)(intervalFraction * (nextValue - prevValue)) : ((Number)mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).intValue();
|
||||
}
|
||||
prevKeyframe = nextKeyframe;
|
||||
}
|
||||
return ((Number)mKeyframes.get(mNumKeyframes - 1).getValue()).intValue();
|
||||
}
|
||||
}
|
||||
|
30
TMessagesProj/src/main/java/org/telegram/ui/Animation/IntProperty.java
Executable file
30
TMessagesProj/src/main/java/org/telegram/ui/Animation/IntProperty.java
Executable file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
public abstract class IntProperty<T> extends Property<T, Integer> {
|
||||
|
||||
public IntProperty(String name) {
|
||||
super(Integer.class, name);
|
||||
}
|
||||
|
||||
public abstract void setValue(T object, int value);
|
||||
|
||||
@Override
|
||||
final public void set(T object, Integer value) {
|
||||
setValue(object, value.intValue());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
public abstract class Keyframe implements Cloneable {
|
||||
|
||||
float mFraction;
|
||||
Class mValueType;
|
||||
private Interpolator mInterpolator = null;
|
||||
boolean mHasValue = false;
|
||||
|
||||
public static Keyframe ofInt(float fraction, int value) {
|
||||
return new IntKeyframe(fraction, value);
|
||||
}
|
||||
|
||||
public static Keyframe ofInt(float fraction) {
|
||||
return new IntKeyframe(fraction);
|
||||
}
|
||||
|
||||
public static Keyframe ofFloat(float fraction, float value) {
|
||||
return new FloatKeyframe(fraction, value);
|
||||
}
|
||||
|
||||
public static Keyframe ofFloat(float fraction) {
|
||||
return new FloatKeyframe(fraction);
|
||||
}
|
||||
|
||||
public static Keyframe ofObject(float fraction, Object value) {
|
||||
return new ObjectKeyframe(fraction, value);
|
||||
}
|
||||
|
||||
public static Keyframe ofObject(float fraction) {
|
||||
return new ObjectKeyframe(fraction, null);
|
||||
}
|
||||
|
||||
public boolean hasValue() {
|
||||
return mHasValue;
|
||||
}
|
||||
|
||||
public abstract Object getValue();
|
||||
public abstract void setValue(Object value);
|
||||
|
||||
public float getFraction() {
|
||||
return mFraction;
|
||||
}
|
||||
|
||||
public void setFraction(float fraction) {
|
||||
mFraction = fraction;
|
||||
}
|
||||
|
||||
public Interpolator getInterpolator() {
|
||||
return mInterpolator;
|
||||
}
|
||||
|
||||
public void setInterpolator(Interpolator interpolator) {
|
||||
mInterpolator = interpolator;
|
||||
}
|
||||
|
||||
public Class getType() {
|
||||
return mValueType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract Keyframe clone();
|
||||
|
||||
static class ObjectKeyframe extends Keyframe {
|
||||
|
||||
Object mValue;
|
||||
|
||||
ObjectKeyframe(float fraction, Object value) {
|
||||
mFraction = fraction;
|
||||
mValue = value;
|
||||
mHasValue = (value != null);
|
||||
mValueType = mHasValue ? value.getClass() : Object.class;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
mValue = value;
|
||||
mHasValue = (value != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectKeyframe clone() {
|
||||
ObjectKeyframe kfClone = new ObjectKeyframe(getFraction(), mHasValue ? mValue : null);
|
||||
kfClone.setInterpolator(getInterpolator());
|
||||
return kfClone;
|
||||
}
|
||||
}
|
||||
|
||||
static class IntKeyframe extends Keyframe {
|
||||
|
||||
int mValue;
|
||||
|
||||
IntKeyframe(float fraction, int value) {
|
||||
mFraction = fraction;
|
||||
mValue = value;
|
||||
mValueType = int.class;
|
||||
mHasValue = true;
|
||||
}
|
||||
|
||||
IntKeyframe(float fraction) {
|
||||
mFraction = fraction;
|
||||
mValueType = int.class;
|
||||
}
|
||||
|
||||
public int getIntValue() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
if (value != null && value.getClass() == Integer.class) {
|
||||
mValue = (Integer) value;
|
||||
mHasValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntKeyframe clone() {
|
||||
IntKeyframe kfClone = mHasValue ? new IntKeyframe(getFraction(), mValue) : new IntKeyframe(getFraction());
|
||||
kfClone.setInterpolator(getInterpolator());
|
||||
return kfClone;
|
||||
}
|
||||
}
|
||||
|
||||
static class FloatKeyframe extends Keyframe {
|
||||
|
||||
float mValue;
|
||||
|
||||
FloatKeyframe(float fraction, float value) {
|
||||
mFraction = fraction;
|
||||
mValue = value;
|
||||
mValueType = float.class;
|
||||
mHasValue = true;
|
||||
}
|
||||
|
||||
FloatKeyframe(float fraction) {
|
||||
mFraction = fraction;
|
||||
mValueType = float.class;
|
||||
}
|
||||
|
||||
public float getFloatValue() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
if (value != null && value.getClass() == Float.class) {
|
||||
mValue = (Float) value;
|
||||
mHasValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatKeyframe clone() {
|
||||
FloatKeyframe kfClone = mHasValue ? new FloatKeyframe(getFraction(), mValue) : new FloatKeyframe(getFraction());
|
||||
kfClone.setInterpolator(getInterpolator());
|
||||
return kfClone;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import android.util.Log;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import org.telegram.ui.Animation.Keyframe.IntKeyframe;
|
||||
import org.telegram.ui.Animation.Keyframe.FloatKeyframe;
|
||||
import org.telegram.ui.Animation.Keyframe.ObjectKeyframe;
|
||||
|
||||
class KeyframeSet {
|
||||
|
||||
int mNumKeyframes;
|
||||
|
||||
Keyframe mFirstKeyframe;
|
||||
Keyframe mLastKeyframe;
|
||||
Interpolator mInterpolator;
|
||||
ArrayList<Keyframe> mKeyframes;
|
||||
TypeEvaluator mEvaluator;
|
||||
|
||||
public KeyframeSet(Keyframe... keyframes) {
|
||||
mNumKeyframes = keyframes.length;
|
||||
mKeyframes = new ArrayList<Keyframe>();
|
||||
mKeyframes.addAll(Arrays.asList(keyframes));
|
||||
mFirstKeyframe = mKeyframes.get(0);
|
||||
mLastKeyframe = mKeyframes.get(mNumKeyframes - 1);
|
||||
mInterpolator = mLastKeyframe.getInterpolator();
|
||||
}
|
||||
|
||||
public static KeyframeSet ofInt(int... values) {
|
||||
int numKeyframes = values.length;
|
||||
IntKeyframe keyframes[] = new IntKeyframe[Math.max(numKeyframes,2)];
|
||||
if (numKeyframes == 1) {
|
||||
keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f);
|
||||
keyframes[1] = (IntKeyframe) Keyframe.ofInt(1f, values[0]);
|
||||
} else {
|
||||
keyframes[0] = (IntKeyframe) Keyframe.ofInt(0f, values[0]);
|
||||
for (int i = 1; i < numKeyframes; ++i) {
|
||||
keyframes[i] = (IntKeyframe) Keyframe.ofInt((float) i / (numKeyframes - 1), values[i]);
|
||||
}
|
||||
}
|
||||
return new IntKeyframeSet(keyframes);
|
||||
}
|
||||
|
||||
public static KeyframeSet ofFloat(float... values) {
|
||||
boolean badValue = false;
|
||||
int numKeyframes = values.length;
|
||||
FloatKeyframe keyframes[] = new FloatKeyframe[Math.max(numKeyframes,2)];
|
||||
if (numKeyframes == 1) {
|
||||
keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f);
|
||||
keyframes[1] = (FloatKeyframe) Keyframe.ofFloat(1f, values[0]);
|
||||
if (Float.isNaN(values[0])) {
|
||||
badValue = true;
|
||||
}
|
||||
} else {
|
||||
keyframes[0] = (FloatKeyframe) Keyframe.ofFloat(0f, values[0]);
|
||||
for (int i = 1; i < numKeyframes; ++i) {
|
||||
keyframes[i] = (FloatKeyframe) Keyframe.ofFloat((float) i / (numKeyframes - 1), values[i]);
|
||||
if (Float.isNaN(values[i])) {
|
||||
badValue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (badValue) {
|
||||
Log.w("Animator", "Bad value (NaN) in float animator");
|
||||
}
|
||||
return new FloatKeyframeSet(keyframes);
|
||||
}
|
||||
|
||||
public static KeyframeSet ofKeyframe(Keyframe... keyframes) {
|
||||
int numKeyframes = keyframes.length;
|
||||
boolean hasFloat = false;
|
||||
boolean hasInt = false;
|
||||
boolean hasOther = false;
|
||||
for (Keyframe keyframe : keyframes) {
|
||||
if (keyframe instanceof FloatKeyframe) {
|
||||
hasFloat = true;
|
||||
} else if (keyframe instanceof IntKeyframe) {
|
||||
hasInt = true;
|
||||
} else {
|
||||
hasOther = true;
|
||||
}
|
||||
}
|
||||
if (hasFloat && !hasInt && !hasOther) {
|
||||
FloatKeyframe floatKeyframes[] = new FloatKeyframe[numKeyframes];
|
||||
for (int i = 0; i < numKeyframes; ++i) {
|
||||
floatKeyframes[i] = (FloatKeyframe) keyframes[i];
|
||||
}
|
||||
return new FloatKeyframeSet(floatKeyframes);
|
||||
} else if (hasInt && !hasFloat && !hasOther) {
|
||||
IntKeyframe intKeyframes[] = new IntKeyframe[numKeyframes];
|
||||
for (int i = 0; i < numKeyframes; ++i) {
|
||||
intKeyframes[i] = (IntKeyframe) keyframes[i];
|
||||
}
|
||||
return new IntKeyframeSet(intKeyframes);
|
||||
} else {
|
||||
return new KeyframeSet(keyframes);
|
||||
}
|
||||
}
|
||||
|
||||
public static KeyframeSet ofObject(Object... values) {
|
||||
int numKeyframes = values.length;
|
||||
ObjectKeyframe keyframes[] = new ObjectKeyframe[Math.max(numKeyframes,2)];
|
||||
if (numKeyframes == 1) {
|
||||
keyframes[0] = (ObjectKeyframe) Keyframe.ofObject(0f);
|
||||
keyframes[1] = (ObjectKeyframe) Keyframe.ofObject(1f, values[0]);
|
||||
} else {
|
||||
keyframes[0] = (ObjectKeyframe) Keyframe.ofObject(0f, values[0]);
|
||||
for (int i = 1; i < numKeyframes; ++i) {
|
||||
keyframes[i] = (ObjectKeyframe) Keyframe.ofObject((float) i / (numKeyframes - 1), values[i]);
|
||||
}
|
||||
}
|
||||
return new KeyframeSet(keyframes);
|
||||
}
|
||||
|
||||
public void setEvaluator(TypeEvaluator evaluator) {
|
||||
mEvaluator = evaluator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyframeSet clone() {
|
||||
ArrayList<Keyframe> keyframes = mKeyframes;
|
||||
int numKeyframes = mKeyframes.size();
|
||||
Keyframe[] newKeyframes = new Keyframe[numKeyframes];
|
||||
for (int i = 0; i < numKeyframes; ++i) {
|
||||
newKeyframes[i] = keyframes.get(i).clone();
|
||||
}
|
||||
return new KeyframeSet(newKeyframes);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getValue(float fraction) {
|
||||
if (mNumKeyframes == 2) {
|
||||
if (mInterpolator != null) {
|
||||
fraction = mInterpolator.getInterpolation(fraction);
|
||||
}
|
||||
return mEvaluator.evaluate(fraction, mFirstKeyframe.getValue(), mLastKeyframe.getValue());
|
||||
}
|
||||
if (fraction <= 0f) {
|
||||
final Keyframe nextKeyframe = mKeyframes.get(1);
|
||||
final Interpolator interpolator = nextKeyframe.getInterpolator();
|
||||
if (interpolator != null) {
|
||||
fraction = interpolator.getInterpolation(fraction);
|
||||
}
|
||||
final float prevFraction = mFirstKeyframe.getFraction();
|
||||
float intervalFraction = (fraction - prevFraction) / (nextKeyframe.getFraction() - prevFraction);
|
||||
return mEvaluator.evaluate(intervalFraction, mFirstKeyframe.getValue(), nextKeyframe.getValue());
|
||||
} else if (fraction >= 1f) {
|
||||
final Keyframe prevKeyframe = mKeyframes.get(mNumKeyframes - 2);
|
||||
final Interpolator interpolator = mLastKeyframe.getInterpolator();
|
||||
if (interpolator != null) {
|
||||
fraction = interpolator.getInterpolation(fraction);
|
||||
}
|
||||
final float prevFraction = prevKeyframe.getFraction();
|
||||
float intervalFraction = (fraction - prevFraction) / (mLastKeyframe.getFraction() - prevFraction);
|
||||
return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), mLastKeyframe.getValue());
|
||||
}
|
||||
Keyframe prevKeyframe = mFirstKeyframe;
|
||||
for (int i = 1; i < mNumKeyframes; ++i) {
|
||||
Keyframe nextKeyframe = mKeyframes.get(i);
|
||||
if (fraction < nextKeyframe.getFraction()) {
|
||||
final Interpolator interpolator = nextKeyframe.getInterpolator();
|
||||
if (interpolator != null) {
|
||||
fraction = interpolator.getInterpolation(fraction);
|
||||
}
|
||||
final float prevFraction = prevKeyframe.getFraction();
|
||||
float intervalFraction = (fraction - prevFraction) / (nextKeyframe.getFraction() - prevFraction);
|
||||
return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), nextKeyframe.getValue());
|
||||
}
|
||||
prevKeyframe = nextKeyframe;
|
||||
}
|
||||
return mLastKeyframe.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String returnVal = " ";
|
||||
for (int i = 0; i < mNumKeyframes; ++i) {
|
||||
returnVal += mKeyframes.get(i).getValue() + " ";
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
public class NoSuchPropertyException extends RuntimeException {
|
||||
|
||||
public NoSuchPropertyException(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,488 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public final class ObjectAnimator10 extends ValueAnimator {
|
||||
|
||||
private static final HashMap<String, Property> PROXY_PROPERTIES = new HashMap<String, Property>();
|
||||
|
||||
static {
|
||||
Property<View, Float> ALPHA = new FloatProperty<View>("alpha") {
|
||||
@Override
|
||||
public void setValue(View object, float value) {
|
||||
View10.wrap(object).setAlpha(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(View object) {
|
||||
return View10.wrap(object).getAlpha();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Float> PIVOT_X = new FloatProperty<View>("pivotX") {
|
||||
@Override
|
||||
public void setValue(View object, float value) {
|
||||
View10.wrap(object).setPivotX(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(View object) {
|
||||
return View10.wrap(object).getPivotX();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Float> PIVOT_Y = new FloatProperty<View>("pivotY") {
|
||||
@Override
|
||||
public void setValue(View object, float value) {
|
||||
View10.wrap(object).setPivotY(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(View object) {
|
||||
return View10.wrap(object).getPivotY();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Float> TRANSLATION_X = new FloatProperty<View>("translationX") {
|
||||
@Override
|
||||
public void setValue(View object, float value) {
|
||||
View10.wrap(object).setTranslationX(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(View object) {
|
||||
return View10.wrap(object).getTranslationX();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Float> TRANSLATION_Y = new FloatProperty<View>("translationY") {
|
||||
@Override
|
||||
public void setValue(View object, float value) {
|
||||
View10.wrap(object).setTranslationY(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(View object) {
|
||||
return View10.wrap(object).getTranslationY();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Float> ROTATION = new FloatProperty<View>("rotation") {
|
||||
@Override
|
||||
public void setValue(View object, float value) {
|
||||
View10.wrap(object).setRotation(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(View object) {
|
||||
return View10.wrap(object).getRotation();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Float> ROTATION_X = new FloatProperty<View>("rotationX") {
|
||||
@Override
|
||||
public void setValue(View object, float value) {
|
||||
View10.wrap(object).setRotationX(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(View object) {
|
||||
return View10.wrap(object).getRotationX();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Float> ROTATION_Y = new FloatProperty<View>("rotationY") {
|
||||
@Override
|
||||
public void setValue(View object, float value) {
|
||||
View10.wrap(object).setRotationY(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(View object) {
|
||||
return View10.wrap(object).getRotationY();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Float> SCALE_X = new FloatProperty<View>("scaleX") {
|
||||
@Override
|
||||
public void setValue(View object, float value) {
|
||||
View10.wrap(object).setScaleX(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(View object) {
|
||||
return View10.wrap(object).getScaleX();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Float> SCALE_Y = new FloatProperty<View>("scaleY") {
|
||||
@Override
|
||||
public void setValue(View object, float value) {
|
||||
View10.wrap(object).setScaleY(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(View object) {
|
||||
return View10.wrap(object).getScaleY();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Integer> SCROLL_X = new IntProperty<View>("scrollX") {
|
||||
@Override
|
||||
public void setValue(View object, int value) {
|
||||
View10.wrap(object).setScrollX(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer get(View object) {
|
||||
return View10.wrap(object).getScrollX();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Integer> SCROLL_Y = new IntProperty<View>("scrollY") {
|
||||
@Override
|
||||
public void setValue(View object, int value) {
|
||||
View10.wrap(object).setScrollY(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer get(View object) {
|
||||
return View10.wrap(object).getScrollY();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Float> X = new FloatProperty<View>("x") {
|
||||
@Override
|
||||
public void setValue(View object, float value) {
|
||||
View10.wrap(object).setX(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(View object) {
|
||||
return View10.wrap(object).getX();
|
||||
}
|
||||
};
|
||||
|
||||
Property<View, Float> Y = new FloatProperty<View>("y") {
|
||||
@Override
|
||||
public void setValue(View object, float value) {
|
||||
View10.wrap(object).setY(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(View object) {
|
||||
return View10.wrap(object).getY();
|
||||
}
|
||||
};
|
||||
|
||||
PROXY_PROPERTIES.put("alpha", ALPHA);
|
||||
PROXY_PROPERTIES.put("pivotX", PIVOT_X);
|
||||
PROXY_PROPERTIES.put("pivotY", PIVOT_Y);
|
||||
PROXY_PROPERTIES.put("translationX", TRANSLATION_X);
|
||||
PROXY_PROPERTIES.put("translationY", TRANSLATION_Y);
|
||||
PROXY_PROPERTIES.put("rotation", ROTATION);
|
||||
PROXY_PROPERTIES.put("rotationX", ROTATION_X);
|
||||
PROXY_PROPERTIES.put("rotationY", ROTATION_Y);
|
||||
PROXY_PROPERTIES.put("scaleX", SCALE_X);
|
||||
PROXY_PROPERTIES.put("scaleY", SCALE_Y);
|
||||
PROXY_PROPERTIES.put("scrollX", SCROLL_X);
|
||||
PROXY_PROPERTIES.put("scrollY", SCROLL_Y);
|
||||
PROXY_PROPERTIES.put("x", X);
|
||||
PROXY_PROPERTIES.put("y", Y);
|
||||
}
|
||||
|
||||
private Object mTarget;
|
||||
private String mPropertyName;
|
||||
private Property mProperty;
|
||||
private boolean mAutoCancel = false;
|
||||
|
||||
public void setPropertyName(String propertyName) {
|
||||
if (mValues != null) {
|
||||
PropertyValuesHolder valuesHolder = mValues[0];
|
||||
String oldName = valuesHolder.getPropertyName();
|
||||
valuesHolder.setPropertyName(propertyName);
|
||||
mValuesMap.remove(oldName);
|
||||
mValuesMap.put(propertyName, valuesHolder);
|
||||
}
|
||||
mPropertyName = propertyName;
|
||||
mInitialized = false;
|
||||
}
|
||||
|
||||
public void setProperty(Property property) {
|
||||
if (mValues != null) {
|
||||
PropertyValuesHolder valuesHolder = mValues[0];
|
||||
String oldName = valuesHolder.getPropertyName();
|
||||
valuesHolder.setProperty(property);
|
||||
mValuesMap.remove(oldName);
|
||||
mValuesMap.put(mPropertyName, valuesHolder);
|
||||
}
|
||||
if (mProperty != null) {
|
||||
mPropertyName = property.getName();
|
||||
}
|
||||
mProperty = property;
|
||||
mInitialized = false;
|
||||
}
|
||||
|
||||
public String getPropertyName() {
|
||||
String propertyName = null;
|
||||
if (mPropertyName != null) {
|
||||
propertyName = mPropertyName;
|
||||
} else if (mProperty != null) {
|
||||
propertyName = mProperty.getName();
|
||||
} else if (mValues != null && mValues.length > 0) {
|
||||
for (int i = 0; i < mValues.length; ++i) {
|
||||
if (i == 0) {
|
||||
propertyName = "";
|
||||
} else {
|
||||
propertyName += ",";
|
||||
}
|
||||
propertyName += mValues[i].getPropertyName();
|
||||
}
|
||||
}
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
public ObjectAnimator10() {
|
||||
|
||||
}
|
||||
|
||||
private ObjectAnimator10(Object target, String propertyName) {
|
||||
mTarget = target;
|
||||
setPropertyName(propertyName);
|
||||
}
|
||||
|
||||
private <T> ObjectAnimator10(T target, Property<T, ?> property) {
|
||||
mTarget = target;
|
||||
setProperty(property);
|
||||
}
|
||||
|
||||
public static ObjectAnimator10 ofInt(Object target, String propertyName, int... values) {
|
||||
ObjectAnimator10 anim = new ObjectAnimator10(target, propertyName);
|
||||
anim.setIntValues(values);
|
||||
return anim;
|
||||
}
|
||||
|
||||
public static <T> ObjectAnimator10 ofInt(T target, Property<T, Integer> property, int... values) {
|
||||
ObjectAnimator10 anim = new ObjectAnimator10(target, property);
|
||||
anim.setIntValues(values);
|
||||
return anim;
|
||||
}
|
||||
|
||||
public static ObjectAnimator10 ofFloat(Object target, String propertyName, float... values) {
|
||||
ObjectAnimator10 anim = new ObjectAnimator10(target, propertyName);
|
||||
anim.setFloatValues(values);
|
||||
return anim;
|
||||
}
|
||||
|
||||
public static <T> ObjectAnimator10 ofFloat(T target, Property<T, Float> property, float... values) {
|
||||
ObjectAnimator10 anim = new ObjectAnimator10(target, property);
|
||||
anim.setFloatValues(values);
|
||||
return anim;
|
||||
}
|
||||
|
||||
public static ObjectAnimator10 ofObject(Object target, String propertyName, TypeEvaluator evaluator, Object... values) {
|
||||
ObjectAnimator10 anim = new ObjectAnimator10(target, propertyName);
|
||||
anim.setObjectValues(values);
|
||||
anim.setEvaluator(evaluator);
|
||||
return anim;
|
||||
}
|
||||
|
||||
public static <T, V> ObjectAnimator10 ofObject(T target, Property<T, V> property, TypeEvaluator<V> evaluator, V... values) {
|
||||
ObjectAnimator10 anim = new ObjectAnimator10(target, property);
|
||||
anim.setObjectValues(values);
|
||||
anim.setEvaluator(evaluator);
|
||||
return anim;
|
||||
}
|
||||
|
||||
public static ObjectAnimator10 ofPropertyValuesHolder(Object target, PropertyValuesHolder... values) {
|
||||
ObjectAnimator10 anim = new ObjectAnimator10();
|
||||
anim.mTarget = target;
|
||||
anim.setValues(values);
|
||||
return anim;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void setIntValues(int... values) {
|
||||
if (mValues == null || mValues.length == 0) {
|
||||
if (mProperty != null) {
|
||||
setValues(PropertyValuesHolder.ofInt(mProperty, values));
|
||||
} else {
|
||||
setValues(PropertyValuesHolder.ofInt(mPropertyName, values));
|
||||
}
|
||||
} else {
|
||||
super.setIntValues(values);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void setFloatValues(float... values) {
|
||||
if (mValues == null || mValues.length == 0) {
|
||||
if (mProperty != null) {
|
||||
setValues(PropertyValuesHolder.ofFloat(mProperty, values));
|
||||
} else {
|
||||
setValues(PropertyValuesHolder.ofFloat(mPropertyName, values));
|
||||
}
|
||||
} else {
|
||||
super.setFloatValues(values);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObjectValues(Object... values) {
|
||||
if (mValues == null || mValues.length == 0) {
|
||||
if (mProperty != null) {
|
||||
setValues(PropertyValuesHolder.ofObject(mProperty, null, values));
|
||||
} else {
|
||||
setValues(PropertyValuesHolder.ofObject(mPropertyName, null, values));
|
||||
}
|
||||
} else {
|
||||
super.setObjectValues(values);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoCancel(boolean cancel) {
|
||||
mAutoCancel = cancel;
|
||||
}
|
||||
|
||||
private boolean hasSameTargetAndProperties(Animator10 anim) {
|
||||
if (anim instanceof ObjectAnimator10) {
|
||||
PropertyValuesHolder[] theirValues = ((ObjectAnimator10) anim).getValues();
|
||||
if (((ObjectAnimator10) anim).getTarget() == mTarget &&
|
||||
mValues.length == theirValues.length) {
|
||||
for (int i = 0; i < mValues.length; ++i) {
|
||||
PropertyValuesHolder pvhMine = mValues[i];
|
||||
PropertyValuesHolder pvhTheirs = theirValues[i];
|
||||
if (pvhMine.getPropertyName() == null ||
|
||||
!pvhMine.getPropertyName().equals(pvhTheirs.getPropertyName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
AnimationHandler handler = sAnimationHandler.get();
|
||||
if (handler != null) {
|
||||
int numAnims = handler.mAnimations.size();
|
||||
for (int i = numAnims - 1; i >= 0; i--) {
|
||||
if (handler.mAnimations.get(i) instanceof ObjectAnimator10) {
|
||||
ObjectAnimator10 anim = (ObjectAnimator10) handler.mAnimations.get(i);
|
||||
if (anim.mAutoCancel && hasSameTargetAndProperties(anim)) {
|
||||
anim.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
numAnims = handler.mPendingAnimations.size();
|
||||
for (int i = numAnims - 1; i >= 0; i--) {
|
||||
if (handler.mPendingAnimations.get(i) instanceof ObjectAnimator10) {
|
||||
ObjectAnimator10 anim = (ObjectAnimator10) handler.mPendingAnimations.get(i);
|
||||
if (anim.mAutoCancel && hasSameTargetAndProperties(anim)) {
|
||||
anim.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
numAnims = handler.mDelayedAnims.size();
|
||||
for (int i = numAnims - 1; i >= 0; i--) {
|
||||
if (handler.mDelayedAnims.get(i) instanceof ObjectAnimator10) {
|
||||
ObjectAnimator10 anim = (ObjectAnimator10) handler.mDelayedAnims.get(i);
|
||||
if (anim.mAutoCancel && hasSameTargetAndProperties(anim)) {
|
||||
anim.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
super.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
void initAnimation() {
|
||||
if (!mInitialized) {
|
||||
if ((mProperty == null) && (mTarget instanceof View) && PROXY_PROPERTIES.containsKey(mPropertyName)) {
|
||||
setProperty(PROXY_PROPERTIES.get(mPropertyName));
|
||||
}
|
||||
int numValues = mValues.length;
|
||||
for (PropertyValuesHolder mValue : mValues) {
|
||||
mValue.setupSetterAndGetter(mTarget);
|
||||
}
|
||||
super.initAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectAnimator10 setDuration(long duration) {
|
||||
super.setDuration(duration);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object getTarget() {
|
||||
return mTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTarget(Object target) {
|
||||
if (mTarget != target) {
|
||||
final Object oldTarget = mTarget;
|
||||
mTarget = target;
|
||||
if (oldTarget != null && target != null && oldTarget.getClass() == target.getClass()) {
|
||||
return;
|
||||
}
|
||||
mInitialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupStartValues() {
|
||||
initAnimation();
|
||||
int numValues = mValues.length;
|
||||
for (PropertyValuesHolder mValue : mValues) {
|
||||
mValue.setupStartValue(mTarget);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupEndValues() {
|
||||
initAnimation();
|
||||
int numValues = mValues.length;
|
||||
for (PropertyValuesHolder mValue : mValues) {
|
||||
mValue.setupEndValue(mTarget);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void animateValue(float fraction) {
|
||||
super.animateValue(fraction);
|
||||
int numValues = mValues.length;
|
||||
for (PropertyValuesHolder mValue : mValues) {
|
||||
mValue.setAnimatedValue(mTarget);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectAnimator10 clone() {
|
||||
return (ObjectAnimator10) super.clone();
|
||||
}
|
||||
}
|
49
TMessagesProj/src/main/java/org/telegram/ui/Animation/Property.java
Executable file
49
TMessagesProj/src/main/java/org/telegram/ui/Animation/Property.java
Executable file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
public abstract class Property<T, V> {
|
||||
|
||||
private final String mName;
|
||||
private final Class<V> mType;
|
||||
|
||||
public static <T, V> Property<T, V> of(Class<T> hostType, Class<V> valueType, String name) {
|
||||
return new ReflectiveProperty<T, V>(hostType, valueType, name);
|
||||
}
|
||||
|
||||
public Property(Class<V> type, String name) {
|
||||
mName = name;
|
||||
mType = type;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void set(T object, V value) {
|
||||
throw new UnsupportedOperationException("Property " + getName() +" is read-only");
|
||||
}
|
||||
|
||||
public abstract V get(T object);
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public Class<V> getType() {
|
||||
return mType;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,556 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
public class PropertyValuesHolder implements Cloneable {
|
||||
|
||||
String mPropertyName;
|
||||
protected Property mProperty;
|
||||
Method mSetter = null;
|
||||
private Method mGetter = null;
|
||||
Class mValueType;
|
||||
KeyframeSet mKeyframeSet = null;
|
||||
|
||||
private static final TypeEvaluator sIntEvaluator = new IntEvaluator();
|
||||
private static final TypeEvaluator sFloatEvaluator = new FloatEvaluator();
|
||||
|
||||
private static Class[] FLOAT_VARIANTS = {float.class, Float.class, double.class, int.class, Double.class, Integer.class};
|
||||
private static Class[] INTEGER_VARIANTS = {int.class, Integer.class, float.class, double.class, Float.class, Double.class};
|
||||
private static Class[] DOUBLE_VARIANTS = {double.class, Double.class, float.class, int.class, Float.class, Integer.class};
|
||||
|
||||
private static final HashMap<Class, HashMap<String, Method>> sSetterPropertyMap = new HashMap<Class, HashMap<String, Method>>();
|
||||
private static final HashMap<Class, HashMap<String, Method>> sGetterPropertyMap = new HashMap<Class, HashMap<String, Method>>();
|
||||
|
||||
final ReentrantReadWriteLock mPropertyMapLock = new ReentrantReadWriteLock();
|
||||
final Object[] mTmpValueArray = new Object[1];
|
||||
|
||||
private TypeEvaluator mEvaluator;
|
||||
|
||||
private Object mAnimatedValue;
|
||||
|
||||
private PropertyValuesHolder(String propertyName) {
|
||||
mPropertyName = propertyName;
|
||||
}
|
||||
|
||||
private PropertyValuesHolder(Property property) {
|
||||
mProperty = property;
|
||||
if (property != null) {
|
||||
mPropertyName = property.getName();
|
||||
}
|
||||
}
|
||||
|
||||
public static PropertyValuesHolder ofInt(String propertyName, int... values) {
|
||||
return new IntPropertyValuesHolder(propertyName, values);
|
||||
}
|
||||
|
||||
public static PropertyValuesHolder ofInt(Property<?, Integer> property, int... values) {
|
||||
return new IntPropertyValuesHolder(property, values);
|
||||
}
|
||||
|
||||
public static PropertyValuesHolder ofFloat(String propertyName, float... values) {
|
||||
return new FloatPropertyValuesHolder(propertyName, values);
|
||||
}
|
||||
|
||||
public static PropertyValuesHolder ofFloat(Property<?, Float> property, float... values) {
|
||||
return new FloatPropertyValuesHolder(property, values);
|
||||
}
|
||||
|
||||
public static PropertyValuesHolder ofObject(String propertyName, TypeEvaluator evaluator,
|
||||
Object... values) {
|
||||
PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName);
|
||||
pvh.setObjectValues(values);
|
||||
pvh.setEvaluator(evaluator);
|
||||
return pvh;
|
||||
}
|
||||
|
||||
public static <V> PropertyValuesHolder ofObject(Property property,
|
||||
TypeEvaluator<V> evaluator, V... values) {
|
||||
PropertyValuesHolder pvh = new PropertyValuesHolder(property);
|
||||
pvh.setObjectValues(values);
|
||||
pvh.setEvaluator(evaluator);
|
||||
return pvh;
|
||||
}
|
||||
|
||||
public static PropertyValuesHolder ofKeyframe(String propertyName, Keyframe... values) {
|
||||
KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values);
|
||||
if (keyframeSet instanceof IntKeyframeSet) {
|
||||
return new IntPropertyValuesHolder(propertyName, (IntKeyframeSet) keyframeSet);
|
||||
} else if (keyframeSet instanceof FloatKeyframeSet) {
|
||||
return new FloatPropertyValuesHolder(propertyName, (FloatKeyframeSet) keyframeSet);
|
||||
} else {
|
||||
PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName);
|
||||
pvh.mKeyframeSet = keyframeSet;
|
||||
pvh.mValueType = values[0].getType();
|
||||
return pvh;
|
||||
}
|
||||
}
|
||||
|
||||
public static PropertyValuesHolder ofKeyframe(Property property, Keyframe... values) {
|
||||
KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values);
|
||||
if (keyframeSet instanceof IntKeyframeSet) {
|
||||
return new IntPropertyValuesHolder(property, (IntKeyframeSet) keyframeSet);
|
||||
} else if (keyframeSet instanceof FloatKeyframeSet) {
|
||||
return new FloatPropertyValuesHolder(property, (FloatKeyframeSet) keyframeSet);
|
||||
} else {
|
||||
PropertyValuesHolder pvh = new PropertyValuesHolder(property);
|
||||
pvh.mKeyframeSet = keyframeSet;
|
||||
pvh.mValueType = values[0].getType();
|
||||
return pvh;
|
||||
}
|
||||
}
|
||||
|
||||
public void setIntValues(int... values) {
|
||||
mValueType = int.class;
|
||||
mKeyframeSet = KeyframeSet.ofInt(values);
|
||||
}
|
||||
|
||||
public void setFloatValues(float... values) {
|
||||
mValueType = float.class;
|
||||
mKeyframeSet = KeyframeSet.ofFloat(values);
|
||||
}
|
||||
|
||||
public void setKeyframes(Keyframe... values) {
|
||||
int numKeyframes = values.length;
|
||||
Keyframe keyframes[] = new Keyframe[Math.max(numKeyframes, 2)];
|
||||
mValueType = values[0].getType();
|
||||
System.arraycopy(values, 0, keyframes, 0, numKeyframes);
|
||||
mKeyframeSet = new KeyframeSet(keyframes);
|
||||
}
|
||||
|
||||
public void setObjectValues(Object... values) {
|
||||
mValueType = values[0].getClass();
|
||||
mKeyframeSet = KeyframeSet.ofObject(values);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Method getPropertyFunction(Class targetClass, String prefix, Class valueType) {
|
||||
Method returnVal = null;
|
||||
String methodName = getMethodName(prefix, mPropertyName);
|
||||
Class args[] = null;
|
||||
if (valueType == null) {
|
||||
try {
|
||||
returnVal = targetClass.getMethod(methodName, args);
|
||||
} catch (NoSuchMethodException e) {
|
||||
try {
|
||||
returnVal = targetClass.getDeclaredMethod(methodName, args);
|
||||
returnVal.setAccessible(true);
|
||||
} catch (NoSuchMethodException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
args = new Class[1];
|
||||
Class typeVariants[];
|
||||
if (mValueType.equals(Float.class)) {
|
||||
typeVariants = FLOAT_VARIANTS;
|
||||
} else if (mValueType.equals(Integer.class)) {
|
||||
typeVariants = INTEGER_VARIANTS;
|
||||
} else if (mValueType.equals(Double.class)) {
|
||||
typeVariants = DOUBLE_VARIANTS;
|
||||
} else {
|
||||
typeVariants = new Class[1];
|
||||
typeVariants[0] = mValueType;
|
||||
}
|
||||
for (Class typeVariant : typeVariants) {
|
||||
args[0] = typeVariant;
|
||||
try {
|
||||
returnVal = targetClass.getMethod(methodName, args);
|
||||
mValueType = typeVariant;
|
||||
return returnVal;
|
||||
} catch (NoSuchMethodException e) {
|
||||
try {
|
||||
returnVal = targetClass.getDeclaredMethod(methodName, args);
|
||||
returnVal.setAccessible(true);
|
||||
mValueType = typeVariant;
|
||||
return returnVal;
|
||||
} catch (NoSuchMethodException e2) {
|
||||
// Swallow the error and keep trying other variants
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
private Method setupSetterOrGetter(Class targetClass, HashMap<Class, HashMap<String, Method>> propertyMapMap, String prefix, Class valueType) {
|
||||
Method setterOrGetter = null;
|
||||
try {
|
||||
mPropertyMapLock.writeLock().lock();
|
||||
HashMap<String, Method> propertyMap = propertyMapMap.get(targetClass);
|
||||
if (propertyMap != null) {
|
||||
setterOrGetter = propertyMap.get(mPropertyName);
|
||||
}
|
||||
if (setterOrGetter == null) {
|
||||
setterOrGetter = getPropertyFunction(targetClass, prefix, valueType);
|
||||
if (propertyMap == null) {
|
||||
propertyMap = new HashMap<String, Method>();
|
||||
propertyMapMap.put(targetClass, propertyMap);
|
||||
}
|
||||
propertyMap.put(mPropertyName, setterOrGetter);
|
||||
}
|
||||
} finally {
|
||||
mPropertyMapLock.writeLock().unlock();
|
||||
}
|
||||
return setterOrGetter;
|
||||
}
|
||||
|
||||
void setupSetter(Class targetClass) {
|
||||
mSetter = setupSetterOrGetter(targetClass, sSetterPropertyMap, "set", mValueType);
|
||||
}
|
||||
|
||||
private void setupGetter(Class targetClass) {
|
||||
mGetter = setupSetterOrGetter(targetClass, sGetterPropertyMap, "get", null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
void setupSetterAndGetter(Object target) {
|
||||
if (mProperty != null) {
|
||||
try {
|
||||
Object testValue = mProperty.get(target);
|
||||
for (Keyframe kf : mKeyframeSet.mKeyframes) {
|
||||
if (!kf.hasValue()) {
|
||||
kf.setValue(mProperty.get(target));
|
||||
}
|
||||
}
|
||||
return;
|
||||
} catch (ClassCastException e) {
|
||||
mProperty = null;
|
||||
}
|
||||
}
|
||||
Class targetClass = target.getClass();
|
||||
if (mSetter == null) {
|
||||
setupSetter(targetClass);
|
||||
}
|
||||
for (Keyframe kf : mKeyframeSet.mKeyframes) {
|
||||
if (!kf.hasValue()) {
|
||||
if (mGetter == null) {
|
||||
setupGetter(targetClass);
|
||||
if (mGetter == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
kf.setValue(mGetter.invoke(target));
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void setupValue(Object target, Keyframe kf) {
|
||||
if (mProperty != null) {
|
||||
kf.setValue(mProperty.get(target));
|
||||
}
|
||||
try {
|
||||
if (mGetter == null) {
|
||||
Class targetClass = target.getClass();
|
||||
setupGetter(targetClass);
|
||||
if (mGetter == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
kf.setValue(mGetter.invoke(target));
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
void setupStartValue(Object target) {
|
||||
setupValue(target, mKeyframeSet.mKeyframes.get(0));
|
||||
}
|
||||
|
||||
void setupEndValue(Object target) {
|
||||
setupValue(target, mKeyframeSet.mKeyframes.get(mKeyframeSet.mKeyframes.size() - 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyValuesHolder clone() {
|
||||
try {
|
||||
PropertyValuesHolder newPVH = (PropertyValuesHolder) super.clone();
|
||||
newPVH.mPropertyName = mPropertyName;
|
||||
newPVH.mProperty = mProperty;
|
||||
newPVH.mKeyframeSet = mKeyframeSet.clone();
|
||||
newPVH.mEvaluator = mEvaluator;
|
||||
return newPVH;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
void setAnimatedValue(Object target) {
|
||||
if (mProperty != null) {
|
||||
mProperty.set(target, getAnimatedValue());
|
||||
}
|
||||
if (mSetter != null) {
|
||||
try {
|
||||
mTmpValueArray[0] = getAnimatedValue();
|
||||
mSetter.invoke(target, mTmpValueArray);
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init() {
|
||||
if (mEvaluator == null) {
|
||||
mEvaluator = (mValueType == Integer.class) ? sIntEvaluator : (mValueType == Float.class) ? sFloatEvaluator : null;
|
||||
}
|
||||
if (mEvaluator != null) {
|
||||
mKeyframeSet.setEvaluator(mEvaluator);
|
||||
}
|
||||
}
|
||||
|
||||
public void setEvaluator(TypeEvaluator evaluator) {
|
||||
mEvaluator = evaluator;
|
||||
mKeyframeSet.setEvaluator(evaluator);
|
||||
}
|
||||
|
||||
void calculateValue(float fraction) {
|
||||
mAnimatedValue = mKeyframeSet.getValue(fraction);
|
||||
}
|
||||
|
||||
public void setPropertyName(String propertyName) {
|
||||
mPropertyName = propertyName;
|
||||
}
|
||||
|
||||
public void setProperty(Property property) {
|
||||
mProperty = property;
|
||||
}
|
||||
|
||||
public String getPropertyName() {
|
||||
return mPropertyName;
|
||||
}
|
||||
|
||||
Object getAnimatedValue() {
|
||||
return mAnimatedValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return mPropertyName + ": " + mKeyframeSet.toString();
|
||||
}
|
||||
|
||||
static String getMethodName(String prefix, String propertyName) {
|
||||
if (propertyName == null || propertyName.length() == 0) {
|
||||
return prefix;
|
||||
}
|
||||
char firstLetter = Character.toUpperCase(propertyName.charAt(0));
|
||||
String theRest = propertyName.substring(1);
|
||||
return prefix + firstLetter + theRest;
|
||||
}
|
||||
|
||||
static class IntPropertyValuesHolder extends PropertyValuesHolder {
|
||||
private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap = new HashMap<Class, HashMap<String, Integer>>();
|
||||
private IntProperty mIntProperty;
|
||||
|
||||
IntKeyframeSet mIntKeyframeSet;
|
||||
int mIntAnimatedValue;
|
||||
|
||||
public IntPropertyValuesHolder(String propertyName, IntKeyframeSet keyframeSet) {
|
||||
super(propertyName);
|
||||
mValueType = int.class;
|
||||
mKeyframeSet = keyframeSet;
|
||||
mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet;
|
||||
}
|
||||
|
||||
public IntPropertyValuesHolder(Property property, IntKeyframeSet keyframeSet) {
|
||||
super(property);
|
||||
mValueType = int.class;
|
||||
mKeyframeSet = keyframeSet;
|
||||
mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet;
|
||||
if (property instanceof IntProperty) {
|
||||
mIntProperty = (IntProperty) mProperty;
|
||||
}
|
||||
}
|
||||
|
||||
public IntPropertyValuesHolder(String propertyName, int... values) {
|
||||
super(propertyName);
|
||||
setIntValues(values);
|
||||
}
|
||||
|
||||
public IntPropertyValuesHolder(Property property, int... values) {
|
||||
super(property);
|
||||
setIntValues(values);
|
||||
if (property instanceof IntProperty) {
|
||||
mIntProperty = (IntProperty) mProperty;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntValues(int... values) {
|
||||
super.setIntValues(values);
|
||||
mIntKeyframeSet = (IntKeyframeSet) mKeyframeSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
void calculateValue(float fraction) {
|
||||
mIntAnimatedValue = mIntKeyframeSet.getIntValue(fraction);
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getAnimatedValue() {
|
||||
return mIntAnimatedValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntPropertyValuesHolder clone() {
|
||||
IntPropertyValuesHolder newPVH = (IntPropertyValuesHolder) super.clone();
|
||||
newPVH.mIntKeyframeSet = (IntKeyframeSet) newPVH.mKeyframeSet;
|
||||
return newPVH;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
void setAnimatedValue(Object target) {
|
||||
if (mIntProperty != null) {
|
||||
mIntProperty.setValue(target, mIntAnimatedValue);
|
||||
return;
|
||||
}
|
||||
if (mProperty != null) {
|
||||
mProperty.set(target, mIntAnimatedValue);
|
||||
return;
|
||||
}
|
||||
if (mSetter != null) {
|
||||
try {
|
||||
mTmpValueArray[0] = mIntAnimatedValue;
|
||||
mSetter.invoke(target, mTmpValueArray);
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void setupSetter(Class targetClass) {
|
||||
if (mProperty != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.setupSetter(targetClass);
|
||||
}
|
||||
}
|
||||
|
||||
static class FloatPropertyValuesHolder extends PropertyValuesHolder {
|
||||
|
||||
private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap = new HashMap<Class, HashMap<String, Integer>>();
|
||||
private FloatProperty mFloatProperty;
|
||||
|
||||
FloatKeyframeSet mFloatKeyframeSet;
|
||||
float mFloatAnimatedValue;
|
||||
|
||||
public FloatPropertyValuesHolder(String propertyName, FloatKeyframeSet keyframeSet) {
|
||||
super(propertyName);
|
||||
mValueType = float.class;
|
||||
mKeyframeSet = keyframeSet;
|
||||
mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet;
|
||||
}
|
||||
|
||||
public FloatPropertyValuesHolder(Property property, FloatKeyframeSet keyframeSet) {
|
||||
super(property);
|
||||
mValueType = float.class;
|
||||
mKeyframeSet = keyframeSet;
|
||||
mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet;
|
||||
if (property instanceof FloatProperty) {
|
||||
mFloatProperty = (FloatProperty) mProperty;
|
||||
}
|
||||
}
|
||||
|
||||
public FloatPropertyValuesHolder(String propertyName, float... values) {
|
||||
super(propertyName);
|
||||
setFloatValues(values);
|
||||
}
|
||||
|
||||
public FloatPropertyValuesHolder(Property property, float... values) {
|
||||
super(property);
|
||||
setFloatValues(values);
|
||||
if (property instanceof FloatProperty) {
|
||||
mFloatProperty = (FloatProperty) mProperty;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFloatValues(float... values) {
|
||||
super.setFloatValues(values);
|
||||
mFloatKeyframeSet = (FloatKeyframeSet) mKeyframeSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
void calculateValue(float fraction) {
|
||||
mFloatAnimatedValue = mFloatKeyframeSet.getFloatValue(fraction);
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getAnimatedValue() {
|
||||
return mFloatAnimatedValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatPropertyValuesHolder clone() {
|
||||
FloatPropertyValuesHolder newPVH = (FloatPropertyValuesHolder) super.clone();
|
||||
newPVH.mFloatKeyframeSet = (FloatKeyframeSet) newPVH.mKeyframeSet;
|
||||
return newPVH;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
void setAnimatedValue(Object target) {
|
||||
if (mFloatProperty != null) {
|
||||
mFloatProperty.setValue(target, mFloatAnimatedValue);
|
||||
return;
|
||||
}
|
||||
if (mProperty != null) {
|
||||
mProperty.set(target, mFloatAnimatedValue);
|
||||
return;
|
||||
}
|
||||
if (mSetter != null) {
|
||||
try {
|
||||
mTmpValueArray[0] = mFloatAnimatedValue;
|
||||
mSetter.invoke(target, mTmpValueArray);
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void setupSetter(Class targetClass) {
|
||||
if (mProperty != null) {
|
||||
return;
|
||||
}
|
||||
super.setupSetter(targetClass);
|
||||
}
|
||||
}
|
||||
}
|
182
TMessagesProj/src/main/java/org/telegram/ui/Animation/ReflectiveProperty.java
Executable file
182
TMessagesProj/src/main/java/org/telegram/ui/Animation/ReflectiveProperty.java
Executable file
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Internal class to automatically generate a Property for a given class/name pair, given the
|
||||
* specification of {@link Property#of(java.lang.Class, java.lang.Class, java.lang.String)}
|
||||
*/
|
||||
class ReflectiveProperty<T, V> extends Property<T, V> {
|
||||
|
||||
private static final String PREFIX_GET = "get";
|
||||
private static final String PREFIX_IS = "is";
|
||||
private static final String PREFIX_SET = "set";
|
||||
private Method mSetter;
|
||||
private Method mGetter;
|
||||
private Field mField;
|
||||
|
||||
/**
|
||||
* For given property name 'name', look for getName/isName method or 'name' field.
|
||||
* Also look for setName method (optional - could be readonly). Failing method getters and
|
||||
* field results in throwing NoSuchPropertyException.
|
||||
*
|
||||
* @param propertyHolder The class on which the methods or field are found
|
||||
* @param name The name of the property, where this name is capitalized and appended to
|
||||
* "get" and "is to search for the appropriate methods. If the get/is methods are not found,
|
||||
* the constructor will search for a field with that exact name.
|
||||
*/
|
||||
public ReflectiveProperty(Class<T> propertyHolder, Class<V> valueType, String name) {
|
||||
// TODO: cache reflection info for each new class/name pair
|
||||
super(valueType, name);
|
||||
char firstLetter = Character.toUpperCase(name.charAt(0));
|
||||
String theRest = name.substring(1);
|
||||
String capitalizedName = firstLetter + theRest;
|
||||
String getterName = PREFIX_GET + capitalizedName;
|
||||
try {
|
||||
mGetter = propertyHolder.getMethod(getterName, (Class<?>[]) null);
|
||||
} catch (NoSuchMethodException e) {
|
||||
try {
|
||||
/* The native implementation uses JNI to do reflection, which allows access to private methods.
|
||||
* getDeclaredMethod(..) does not find superclass methods, so it's implemented as a fallback.
|
||||
*/
|
||||
mGetter = propertyHolder.getDeclaredMethod(getterName, (Class<?>[]) null);
|
||||
mGetter.setAccessible(true);
|
||||
} catch (NoSuchMethodException e2) {
|
||||
// getName() not available - try isName() instead
|
||||
getterName = PREFIX_IS + capitalizedName;
|
||||
try {
|
||||
mGetter = propertyHolder.getMethod(getterName, (Class<?>[]) null);
|
||||
} catch (NoSuchMethodException e3) {
|
||||
try {
|
||||
/* The native implementation uses JNI to do reflection, which allows access to private methods.
|
||||
* getDeclaredMethod(..) does not find superclass methods, so it's implemented as a fallback.
|
||||
*/
|
||||
mGetter = propertyHolder.getDeclaredMethod(getterName, (Class<?>[]) null);
|
||||
mGetter.setAccessible(true);
|
||||
} catch (NoSuchMethodException e4) {
|
||||
// Try public field instead
|
||||
try {
|
||||
mField = propertyHolder.getField(name);
|
||||
Class fieldType = mField.getType();
|
||||
if (!typesMatch(valueType, fieldType)) {
|
||||
throw new NoSuchPropertyException("Underlying type (" + fieldType + ") " +
|
||||
"does not match Property type (" + valueType + ")");
|
||||
}
|
||||
return;
|
||||
} catch (NoSuchFieldException e5) {
|
||||
// no way to access property - throw appropriate exception
|
||||
throw new NoSuchPropertyException("No accessor method or field found for"
|
||||
+ " property with name " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Class getterType = mGetter.getReturnType();
|
||||
// Check to make sure our getter type matches our valueType
|
||||
if (!typesMatch(valueType, getterType)) {
|
||||
throw new NoSuchPropertyException("Underlying type (" + getterType + ") " +
|
||||
"does not match Property type (" + valueType + ")");
|
||||
}
|
||||
String setterName = PREFIX_SET + capitalizedName;
|
||||
try {
|
||||
// mSetter = propertyHolder.getMethod(setterName, getterType);
|
||||
// The native implementation uses JNI to do reflection, which allows access to private methods.
|
||||
mSetter = propertyHolder.getDeclaredMethod(setterName, getterType);
|
||||
mSetter.setAccessible(true);
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
// Okay to not have a setter - just a readonly property
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to check whether the type of the underlying field/method on the target
|
||||
* object matches the type of the Property. The extra checks for primitive types are because
|
||||
* generics will force the Property type to be a class, whereas the type of the underlying
|
||||
* method/field will probably be a primitive type instead. Accept float as matching Float,
|
||||
* etc.
|
||||
*/
|
||||
private boolean typesMatch(Class<V> valueType, Class getterType) {
|
||||
if (getterType != valueType) {
|
||||
if (getterType.isPrimitive()) {
|
||||
return (getterType == float.class && valueType == Float.class) ||
|
||||
(getterType == int.class && valueType == Integer.class) ||
|
||||
(getterType == boolean.class && valueType == Boolean.class) ||
|
||||
(getterType == long.class && valueType == Long.class) ||
|
||||
(getterType == double.class && valueType == Double.class) ||
|
||||
(getterType == short.class && valueType == Short.class) ||
|
||||
(getterType == byte.class && valueType == Byte.class) ||
|
||||
(getterType == char.class && valueType == Character.class);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(T object, V value) {
|
||||
if (mSetter != null) {
|
||||
try {
|
||||
mSetter.invoke(object, value);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError();
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
} else if (mField != null) {
|
||||
try {
|
||||
mField.set(object, value);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Property " + getName() +" is read-only");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(T object) {
|
||||
if (mGetter != null) {
|
||||
try {
|
||||
return (V) mGetter.invoke(object, (Object[])null);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError();
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
} else if (mField != null) {
|
||||
try {
|
||||
return (V) mField.get(object);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
// Should not get here: there should always be a non-null getter or field
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns false if there is no setter or public field underlying this Property.
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return (mSetter == null && mField == null);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
public interface TypeEvaluator<T> {
|
||||
public T evaluate(float fraction, T startValue, T endValue);
|
||||
}
|
|
@ -0,0 +1,675 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
import android.os.Looper;
|
||||
import android.util.AndroidRuntimeException;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ValueAnimator extends Animator10 {
|
||||
|
||||
private static float sDurationScale = 1.0f;
|
||||
static final int STOPPED = 0;
|
||||
static final int RUNNING = 1;
|
||||
static final int SEEKED = 2;
|
||||
|
||||
long mStartTime;
|
||||
long mSeekTime = -1;
|
||||
private long mPauseTime;
|
||||
private boolean mResumed = false;
|
||||
protected static ThreadLocal<AnimationHandler> sAnimationHandler = new ThreadLocal<AnimationHandler>();
|
||||
private static final Interpolator sDefaultInterpolator = new AccelerateDecelerateInterpolator();
|
||||
private boolean mPlayingBackwards = false;
|
||||
private int mCurrentIteration = 0;
|
||||
private float mCurrentFraction = 0f;
|
||||
private boolean mStartedDelay = false;
|
||||
private long mDelayStartTime;
|
||||
int mPlayingState = STOPPED;
|
||||
private boolean mRunning = false;
|
||||
private boolean mStarted = false;
|
||||
private boolean mStartListenersCalled = false;
|
||||
boolean mInitialized = false;
|
||||
|
||||
private long mDuration = (long)(300 * sDurationScale);
|
||||
private long mUnscaledDuration = 300;
|
||||
private long mStartDelay = 0;
|
||||
private long mUnscaledStartDelay = 0;
|
||||
private int mRepeatCount = 0;
|
||||
private int mRepeatMode = RESTART;
|
||||
private Interpolator mInterpolator = sDefaultInterpolator;
|
||||
private ArrayList<AnimatorUpdateListener> mUpdateListeners = null;
|
||||
PropertyValuesHolder[] mValues;
|
||||
HashMap<String, PropertyValuesHolder> mValuesMap;
|
||||
|
||||
public static final int RESTART = 1;
|
||||
public static final int REVERSE = 2;
|
||||
public static final int INFINITE = -1;
|
||||
|
||||
public static void setDurationScale(float durationScale) {
|
||||
sDurationScale = durationScale;
|
||||
}
|
||||
|
||||
public static float getDurationScale() {
|
||||
return sDurationScale;
|
||||
}
|
||||
|
||||
public ValueAnimator() {
|
||||
|
||||
}
|
||||
|
||||
public static ValueAnimator ofInt(int... values) {
|
||||
ValueAnimator anim = new ValueAnimator();
|
||||
anim.setIntValues(values);
|
||||
return anim;
|
||||
}
|
||||
|
||||
public static ValueAnimator ofFloat(float... values) {
|
||||
ValueAnimator anim = new ValueAnimator();
|
||||
anim.setFloatValues(values);
|
||||
return anim;
|
||||
}
|
||||
|
||||
public static ValueAnimator ofPropertyValuesHolder(PropertyValuesHolder... values) {
|
||||
ValueAnimator anim = new ValueAnimator();
|
||||
anim.setValues(values);
|
||||
return anim;
|
||||
}
|
||||
|
||||
public static ValueAnimator ofObject(TypeEvaluator evaluator, Object... values) {
|
||||
ValueAnimator anim = new ValueAnimator();
|
||||
anim.setObjectValues(values);
|
||||
anim.setEvaluator(evaluator);
|
||||
return anim;
|
||||
}
|
||||
|
||||
public void setIntValues(int... values) {
|
||||
if (values == null || values.length == 0) {
|
||||
return;
|
||||
}
|
||||
if (mValues == null || mValues.length == 0) {
|
||||
setValues(PropertyValuesHolder.ofInt("", values));
|
||||
} else {
|
||||
PropertyValuesHolder valuesHolder = mValues[0];
|
||||
valuesHolder.setIntValues(values);
|
||||
}
|
||||
mInitialized = false;
|
||||
}
|
||||
|
||||
public void setFloatValues(float... values) {
|
||||
if (values == null || values.length == 0) {
|
||||
return;
|
||||
}
|
||||
if (mValues == null || mValues.length == 0) {
|
||||
setValues(PropertyValuesHolder.ofFloat("", values));
|
||||
} else {
|
||||
PropertyValuesHolder valuesHolder = mValues[0];
|
||||
valuesHolder.setFloatValues(values);
|
||||
}
|
||||
mInitialized = false;
|
||||
}
|
||||
|
||||
public void setObjectValues(Object... values) {
|
||||
if (values == null || values.length == 0) {
|
||||
return;
|
||||
}
|
||||
if (mValues == null || mValues.length == 0) {
|
||||
setValues(PropertyValuesHolder.ofObject("", null, values));
|
||||
} else {
|
||||
PropertyValuesHolder valuesHolder = mValues[0];
|
||||
valuesHolder.setObjectValues(values);
|
||||
}
|
||||
mInitialized = false;
|
||||
}
|
||||
|
||||
public void setValues(PropertyValuesHolder... values) {
|
||||
int numValues = values.length;
|
||||
mValues = values;
|
||||
mValuesMap = new HashMap<String, PropertyValuesHolder>(numValues);
|
||||
for (PropertyValuesHolder valuesHolder : values) {
|
||||
mValuesMap.put(valuesHolder.getPropertyName(), valuesHolder);
|
||||
}
|
||||
mInitialized = false;
|
||||
}
|
||||
|
||||
public PropertyValuesHolder[] getValues() {
|
||||
return mValues;
|
||||
}
|
||||
|
||||
void initAnimation() {
|
||||
if (!mInitialized) {
|
||||
int numValues = mValues.length;
|
||||
for (PropertyValuesHolder mValue : mValues) {
|
||||
mValue.init();
|
||||
}
|
||||
mInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public ValueAnimator setDuration(long duration) {
|
||||
if (duration < 0) {
|
||||
throw new IllegalArgumentException("Animators cannot have negative duration: " + duration);
|
||||
}
|
||||
mUnscaledDuration = duration;
|
||||
mDuration = (long)(duration * sDurationScale);
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return mUnscaledDuration;
|
||||
}
|
||||
|
||||
public void setCurrentPlayTime(long playTime) {
|
||||
initAnimation();
|
||||
long currentTime = AnimationUtils.currentAnimationTimeMillis();
|
||||
if (mPlayingState != RUNNING) {
|
||||
mSeekTime = playTime;
|
||||
mPlayingState = SEEKED;
|
||||
}
|
||||
mStartTime = currentTime - playTime;
|
||||
doAnimationFrame(currentTime);
|
||||
}
|
||||
|
||||
public long getCurrentPlayTime() {
|
||||
if (!mInitialized || mPlayingState == STOPPED) {
|
||||
return 0;
|
||||
}
|
||||
return AnimationUtils.currentAnimationTimeMillis() - mStartTime;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected static class AnimationHandler implements Runnable {
|
||||
|
||||
protected final ArrayList<ValueAnimator> mAnimations = new ArrayList<ValueAnimator>();
|
||||
private final ArrayList<ValueAnimator> mTmpAnimations = new ArrayList<ValueAnimator>();
|
||||
protected final ArrayList<ValueAnimator> mPendingAnimations = new ArrayList<ValueAnimator>();
|
||||
protected final ArrayList<ValueAnimator> mDelayedAnims = new ArrayList<ValueAnimator>();
|
||||
private final ArrayList<ValueAnimator> mEndingAnims = new ArrayList<ValueAnimator>();
|
||||
private final ArrayList<ValueAnimator> mReadyAnims = new ArrayList<ValueAnimator>();
|
||||
|
||||
private boolean mAnimationScheduled;
|
||||
|
||||
public void start() {
|
||||
scheduleAnimation();
|
||||
}
|
||||
|
||||
private void doAnimationFrame(long frameTime) {
|
||||
while (mPendingAnimations.size() > 0) {
|
||||
ArrayList<ValueAnimator> pendingCopy = (ArrayList<ValueAnimator>) mPendingAnimations.clone();
|
||||
mPendingAnimations.clear();
|
||||
int count = pendingCopy.size();
|
||||
for (ValueAnimator anim : pendingCopy) {
|
||||
if (anim.mStartDelay == 0) {
|
||||
anim.startAnimation(this);
|
||||
} else {
|
||||
mDelayedAnims.add(anim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int numDelayedAnims = mDelayedAnims.size();
|
||||
for (ValueAnimator anim : mDelayedAnims) {
|
||||
if (anim.delayedAnimationFrame(frameTime)) {
|
||||
mReadyAnims.add(anim);
|
||||
}
|
||||
}
|
||||
int numReadyAnims = mReadyAnims.size();
|
||||
if (numReadyAnims > 0) {
|
||||
for (ValueAnimator anim : mReadyAnims) {
|
||||
anim.startAnimation(this);
|
||||
anim.mRunning = true;
|
||||
mDelayedAnims.remove(anim);
|
||||
}
|
||||
mReadyAnims.clear();
|
||||
}
|
||||
|
||||
int numAnims = mAnimations.size();
|
||||
for (ValueAnimator mAnimation : mAnimations) {
|
||||
mTmpAnimations.add(mAnimation);
|
||||
}
|
||||
for (int i = 0; i < numAnims; ++i) {
|
||||
ValueAnimator anim = mTmpAnimations.get(i);
|
||||
if (mAnimations.contains(anim) && anim.doAnimationFrame(frameTime)) {
|
||||
mEndingAnims.add(anim);
|
||||
}
|
||||
}
|
||||
mTmpAnimations.clear();
|
||||
if (mEndingAnims.size() > 0) {
|
||||
for (ValueAnimator mEndingAnim : mEndingAnims) {
|
||||
mEndingAnim.endAnimation(this);
|
||||
}
|
||||
mEndingAnims.clear();
|
||||
}
|
||||
|
||||
if (!mAnimations.isEmpty() || !mDelayedAnims.isEmpty()) {
|
||||
scheduleAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
mAnimationScheduled = false;
|
||||
doAnimationFrame(System.nanoTime() / 1000000);
|
||||
}
|
||||
|
||||
private void scheduleAnimation() {
|
||||
if (!mAnimationScheduled) {
|
||||
AndroidUtilities.runOnUIThread(this);
|
||||
mAnimationScheduled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long getStartDelay() {
|
||||
return mUnscaledStartDelay;
|
||||
}
|
||||
|
||||
public void setStartDelay(long startDelay) {
|
||||
this.mStartDelay = (long)(startDelay * sDurationScale);
|
||||
mUnscaledStartDelay = startDelay;
|
||||
}
|
||||
|
||||
public Object getAnimatedValue() {
|
||||
if (mValues != null && mValues.length > 0) {
|
||||
return mValues[0].getAnimatedValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getAnimatedValue(String propertyName) {
|
||||
PropertyValuesHolder valuesHolder = mValuesMap.get(propertyName);
|
||||
if (valuesHolder != null) {
|
||||
return valuesHolder.getAnimatedValue();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setRepeatCount(int value) {
|
||||
mRepeatCount = value;
|
||||
}
|
||||
|
||||
public int getRepeatCount() {
|
||||
return mRepeatCount;
|
||||
}
|
||||
|
||||
public void setRepeatMode(int value) {
|
||||
mRepeatMode = value;
|
||||
}
|
||||
|
||||
public int getRepeatMode() {
|
||||
return mRepeatMode;
|
||||
}
|
||||
|
||||
public void addUpdateListener(AnimatorUpdateListener listener) {
|
||||
if (mUpdateListeners == null) {
|
||||
mUpdateListeners = new ArrayList<AnimatorUpdateListener>();
|
||||
}
|
||||
mUpdateListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeAllUpdateListeners() {
|
||||
if (mUpdateListeners == null) {
|
||||
return;
|
||||
}
|
||||
mUpdateListeners.clear();
|
||||
mUpdateListeners = null;
|
||||
}
|
||||
|
||||
public void removeUpdateListener(AnimatorUpdateListener listener) {
|
||||
if (mUpdateListeners == null) {
|
||||
return;
|
||||
}
|
||||
mUpdateListeners.remove(listener);
|
||||
if (mUpdateListeners.size() == 0) {
|
||||
mUpdateListeners = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInterpolator(Interpolator value) {
|
||||
if (value != null) {
|
||||
mInterpolator = value;
|
||||
} else {
|
||||
mInterpolator = new LinearInterpolator();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interpolator getInterpolator() {
|
||||
return mInterpolator;
|
||||
}
|
||||
|
||||
public void setEvaluator(TypeEvaluator value) {
|
||||
if (value != null && mValues != null && mValues.length > 0) {
|
||||
mValues[0].setEvaluator(value);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void notifyStartListeners() {
|
||||
if (mListeners != null && !mStartListenersCalled) {
|
||||
ArrayList<AnimatorListener> tmpListeners = (ArrayList<AnimatorListener>) mListeners.clone();
|
||||
int numListeners = tmpListeners.size();
|
||||
for (AnimatorListener tmpListener : tmpListeners) {
|
||||
tmpListener.onAnimationStart(this);
|
||||
}
|
||||
}
|
||||
mStartListenersCalled = true;
|
||||
}
|
||||
|
||||
private void start(boolean playBackwards) {
|
||||
if (Looper.myLooper() == null) {
|
||||
throw new AndroidRuntimeException("Animators may only be run on Looper threads");
|
||||
}
|
||||
mPlayingBackwards = playBackwards;
|
||||
mCurrentIteration = 0;
|
||||
mPlayingState = STOPPED;
|
||||
mStarted = true;
|
||||
mStartedDelay = false;
|
||||
mPaused = false;
|
||||
AnimationHandler animationHandler = getOrCreateAnimationHandler();
|
||||
animationHandler.mPendingAnimations.add(this);
|
||||
if (mStartDelay == 0) {
|
||||
setCurrentPlayTime(0);
|
||||
mPlayingState = STOPPED;
|
||||
mRunning = true;
|
||||
notifyStartListeners();
|
||||
}
|
||||
animationHandler.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
start(false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void cancel() {
|
||||
AnimationHandler handler = getOrCreateAnimationHandler();
|
||||
if (mPlayingState != STOPPED || handler.mPendingAnimations.contains(this) || handler.mDelayedAnims.contains(this)) {
|
||||
if ((mStarted || mRunning) && mListeners != null) {
|
||||
if (!mRunning) {
|
||||
notifyStartListeners();
|
||||
}
|
||||
ArrayList<AnimatorListener> tmpListeners = (ArrayList<AnimatorListener>) mListeners.clone();
|
||||
for (AnimatorListener listener : tmpListeners) {
|
||||
listener.onAnimationCancel(this);
|
||||
}
|
||||
}
|
||||
endAnimation(handler);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
AnimationHandler handler = getOrCreateAnimationHandler();
|
||||
if (!handler.mAnimations.contains(this) && !handler.mPendingAnimations.contains(this)) {
|
||||
mStartedDelay = false;
|
||||
startAnimation(handler);
|
||||
mStarted = true;
|
||||
} else if (!mInitialized) {
|
||||
initAnimation();
|
||||
}
|
||||
animateValue(mPlayingBackwards ? 0f : 1f);
|
||||
endAnimation(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
if (mPaused) {
|
||||
mResumed = true;
|
||||
}
|
||||
super.resume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
boolean previouslyPaused = mPaused;
|
||||
super.pause();
|
||||
if (!previouslyPaused && mPaused) {
|
||||
mPauseTime = -1;
|
||||
mResumed = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return (mPlayingState == RUNNING || mRunning);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return mStarted;
|
||||
}
|
||||
|
||||
public void reverse() {
|
||||
mPlayingBackwards = !mPlayingBackwards;
|
||||
if (mPlayingState == RUNNING) {
|
||||
long currentTime = AnimationUtils.currentAnimationTimeMillis();
|
||||
long currentPlayTime = currentTime - mStartTime;
|
||||
long timeLeft = mDuration - currentPlayTime;
|
||||
mStartTime = currentTime - timeLeft;
|
||||
} else if (mStarted) {
|
||||
end();
|
||||
} else {
|
||||
start(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void endAnimation(AnimationHandler handler) {
|
||||
handler.mAnimations.remove(this);
|
||||
handler.mPendingAnimations.remove(this);
|
||||
handler.mDelayedAnims.remove(this);
|
||||
mPlayingState = STOPPED;
|
||||
mPaused = false;
|
||||
if ((mStarted || mRunning) && mListeners != null) {
|
||||
if (!mRunning) {
|
||||
notifyStartListeners();
|
||||
}
|
||||
ArrayList<AnimatorListener> tmpListeners = (ArrayList<AnimatorListener>) mListeners.clone();
|
||||
int numListeners = tmpListeners.size();
|
||||
for (AnimatorListener tmpListener : tmpListeners) {
|
||||
tmpListener.onAnimationEnd(this);
|
||||
}
|
||||
}
|
||||
mRunning = false;
|
||||
mStarted = false;
|
||||
mStartListenersCalled = false;
|
||||
mPlayingBackwards = false;
|
||||
}
|
||||
|
||||
private void startAnimation(AnimationHandler handler) {
|
||||
initAnimation();
|
||||
handler.mAnimations.add(this);
|
||||
if (mStartDelay > 0 && mListeners != null) {
|
||||
notifyStartListeners();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean delayedAnimationFrame(long currentTime) {
|
||||
if (!mStartedDelay) {
|
||||
mStartedDelay = true;
|
||||
mDelayStartTime = currentTime;
|
||||
} else {
|
||||
if (mPaused) {
|
||||
if (mPauseTime < 0) {
|
||||
mPauseTime = currentTime;
|
||||
}
|
||||
return false;
|
||||
} else if (mResumed) {
|
||||
mResumed = false;
|
||||
if (mPauseTime > 0) {
|
||||
mDelayStartTime += (currentTime - mPauseTime);
|
||||
}
|
||||
}
|
||||
long deltaTime = currentTime - mDelayStartTime;
|
||||
if (deltaTime > mStartDelay) {
|
||||
mStartTime = currentTime - (deltaTime - mStartDelay);
|
||||
mPlayingState = RUNNING;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean animationFrame(long currentTime) {
|
||||
boolean done = false;
|
||||
switch (mPlayingState) {
|
||||
case RUNNING:
|
||||
case SEEKED:
|
||||
float fraction = mDuration > 0 ? (float)(currentTime - mStartTime) / mDuration : 1f;
|
||||
if (fraction >= 1f) {
|
||||
if (mCurrentIteration < mRepeatCount || mRepeatCount == INFINITE) {
|
||||
if (mListeners != null) {
|
||||
int numListeners = mListeners.size();
|
||||
for (AnimatorListener mListener : mListeners) {
|
||||
mListener.onAnimationRepeat(this);
|
||||
}
|
||||
}
|
||||
if (mRepeatMode == REVERSE) {
|
||||
mPlayingBackwards = !mPlayingBackwards;
|
||||
}
|
||||
mCurrentIteration += (int)fraction;
|
||||
fraction = fraction % 1f;
|
||||
mStartTime += mDuration;
|
||||
} else {
|
||||
done = true;
|
||||
fraction = Math.min(fraction, 1.0f);
|
||||
}
|
||||
}
|
||||
if (mPlayingBackwards) {
|
||||
fraction = 1f - fraction;
|
||||
}
|
||||
animateValue(fraction);
|
||||
break;
|
||||
}
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
final boolean doAnimationFrame(long frameTime) {
|
||||
if (mPlayingState == STOPPED) {
|
||||
mPlayingState = RUNNING;
|
||||
if (mSeekTime < 0) {
|
||||
mStartTime = frameTime;
|
||||
} else {
|
||||
mStartTime = frameTime - mSeekTime;
|
||||
mSeekTime = -1;
|
||||
}
|
||||
}
|
||||
if (mPaused) {
|
||||
if (mPauseTime < 0) {
|
||||
mPauseTime = frameTime;
|
||||
}
|
||||
return false;
|
||||
} else if (mResumed) {
|
||||
mResumed = false;
|
||||
if (mPauseTime > 0) {
|
||||
mStartTime += (frameTime - mPauseTime);
|
||||
}
|
||||
}
|
||||
final long currentTime = Math.max(frameTime, mStartTime);
|
||||
return animationFrame(currentTime);
|
||||
}
|
||||
|
||||
public float getAnimatedFraction() {
|
||||
return mCurrentFraction;
|
||||
}
|
||||
|
||||
void animateValue(float fraction) {
|
||||
fraction = mInterpolator.getInterpolation(fraction);
|
||||
mCurrentFraction = fraction;
|
||||
int numValues = mValues.length;
|
||||
for (PropertyValuesHolder mValue : mValues) {
|
||||
mValue.calculateValue(fraction);
|
||||
}
|
||||
if (mUpdateListeners != null) {
|
||||
int numListeners = mUpdateListeners.size();
|
||||
for (AnimatorUpdateListener mUpdateListener : mUpdateListeners) {
|
||||
mUpdateListener.onAnimationUpdate(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueAnimator clone() {
|
||||
final ValueAnimator anim = (ValueAnimator) super.clone();
|
||||
if (mUpdateListeners != null) {
|
||||
ArrayList<AnimatorUpdateListener> oldListeners = mUpdateListeners;
|
||||
anim.mUpdateListeners = new ArrayList<AnimatorUpdateListener>();
|
||||
int numListeners = oldListeners.size();
|
||||
for (AnimatorUpdateListener oldListener : oldListeners) {
|
||||
anim.mUpdateListeners.add(oldListener);
|
||||
}
|
||||
}
|
||||
anim.mSeekTime = -1;
|
||||
anim.mPlayingBackwards = false;
|
||||
anim.mCurrentIteration = 0;
|
||||
anim.mInitialized = false;
|
||||
anim.mPlayingState = STOPPED;
|
||||
anim.mStartedDelay = false;
|
||||
PropertyValuesHolder[] oldValues = mValues;
|
||||
if (oldValues != null) {
|
||||
int numValues = oldValues.length;
|
||||
anim.mValues = new PropertyValuesHolder[numValues];
|
||||
anim.mValuesMap = new HashMap<String, PropertyValuesHolder>(numValues);
|
||||
for (int i = 0; i < numValues; ++i) {
|
||||
PropertyValuesHolder newValuesHolder = oldValues[i].clone();
|
||||
anim.mValues[i] = newValuesHolder;
|
||||
anim.mValuesMap.put(newValuesHolder.getPropertyName(), newValuesHolder);
|
||||
}
|
||||
}
|
||||
return anim;
|
||||
}
|
||||
|
||||
public static interface AnimatorUpdateListener {
|
||||
void onAnimationUpdate(ValueAnimator animation);
|
||||
}
|
||||
|
||||
public static int getCurrentAnimationsCount() {
|
||||
AnimationHandler handler = sAnimationHandler.get();
|
||||
return handler != null ? handler.mAnimations.size() : 0;
|
||||
}
|
||||
|
||||
public static void clearAllAnimations() {
|
||||
AnimationHandler handler = sAnimationHandler.get();
|
||||
if (handler != null) {
|
||||
handler.mAnimations.clear();
|
||||
handler.mPendingAnimations.clear();
|
||||
handler.mDelayedAnims.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private static AnimationHandler getOrCreateAnimationHandler() {
|
||||
AnimationHandler handler = sAnimationHandler.get();
|
||||
if (handler == null) {
|
||||
handler = new AnimationHandler();
|
||||
sAnimationHandler.set(handler);
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,346 @@
|
|||
/*
|
||||
Copyright 2012 Jake Wharton
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Animation;
|
||||
|
||||
import android.graphics.Camera;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class View10 extends Animation {
|
||||
|
||||
public static boolean NEED_PROXY = Build.VERSION.SDK_INT < 11;
|
||||
|
||||
private static final WeakHashMap<View, View10> PROXIES = new WeakHashMap<View, View10>();
|
||||
|
||||
public static View10 wrap(View view) {
|
||||
View10 proxy = PROXIES.get(view);
|
||||
if (proxy == null || proxy != view.getAnimation()) {
|
||||
proxy = new View10(view);
|
||||
PROXIES.put(view, proxy);
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
private final WeakReference<View> mView;
|
||||
private final Camera mCamera = new Camera();
|
||||
private boolean mHasPivot;
|
||||
|
||||
private float mAlpha = 1;
|
||||
private float mPivotX;
|
||||
private float mPivotY;
|
||||
private float mRotationX;
|
||||
private float mRotationY;
|
||||
private float mRotationZ;
|
||||
private float mScaleX = 1;
|
||||
private float mScaleY = 1;
|
||||
private float mTranslationX;
|
||||
private float mTranslationY;
|
||||
|
||||
private final RectF mBefore = new RectF();
|
||||
private final RectF mAfter = new RectF();
|
||||
private final Matrix mTempMatrix = new Matrix();
|
||||
|
||||
private View10(View view) {
|
||||
setDuration(0);
|
||||
setFillAfter(true);
|
||||
view.setAnimation(this);
|
||||
mView = new WeakReference<View>(view);
|
||||
}
|
||||
|
||||
public float getAlpha() {
|
||||
return mAlpha;
|
||||
}
|
||||
|
||||
public void setAlpha(float alpha) {
|
||||
if (mAlpha != alpha) {
|
||||
mAlpha = alpha;
|
||||
View view = mView.get();
|
||||
if (view != null) {
|
||||
view.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float getPivotX() {
|
||||
return mPivotX;
|
||||
}
|
||||
|
||||
public void setPivotX(float pivotX) {
|
||||
if (!mHasPivot || mPivotX != pivotX) {
|
||||
prepareForUpdate();
|
||||
mHasPivot = true;
|
||||
mPivotX = pivotX;
|
||||
invalidateAfterUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public float getPivotY() {
|
||||
return mPivotY;
|
||||
}
|
||||
|
||||
public void setPivotY(float pivotY) {
|
||||
if (!mHasPivot || mPivotY != pivotY) {
|
||||
prepareForUpdate();
|
||||
mHasPivot = true;
|
||||
mPivotY = pivotY;
|
||||
invalidateAfterUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public float getRotation() {
|
||||
return mRotationZ;
|
||||
}
|
||||
|
||||
public void setRotation(float rotation) {
|
||||
if (mRotationZ != rotation) {
|
||||
prepareForUpdate();
|
||||
mRotationZ = rotation;
|
||||
invalidateAfterUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public float getRotationX() {
|
||||
return mRotationX;
|
||||
}
|
||||
|
||||
public void setRotationX(float rotationX) {
|
||||
if (mRotationX != rotationX) {
|
||||
prepareForUpdate();
|
||||
mRotationX = rotationX;
|
||||
invalidateAfterUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public float getRotationY() {
|
||||
return mRotationY;
|
||||
}
|
||||
|
||||
public void setRotationY(float rotationY) {
|
||||
if (mRotationY != rotationY) {
|
||||
prepareForUpdate();
|
||||
mRotationY = rotationY;
|
||||
invalidateAfterUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public float getScaleX() {
|
||||
return mScaleX;
|
||||
}
|
||||
|
||||
public void setScaleX(float scaleX) {
|
||||
if (mScaleX != scaleX) {
|
||||
prepareForUpdate();
|
||||
mScaleX = scaleX;
|
||||
invalidateAfterUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public float getScaleY() {
|
||||
return mScaleY;
|
||||
}
|
||||
|
||||
public void setScaleY(float scaleY) {
|
||||
if (mScaleY != scaleY) {
|
||||
prepareForUpdate();
|
||||
mScaleY = scaleY;
|
||||
invalidateAfterUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public int getScrollX() {
|
||||
View view = mView.get();
|
||||
if (view == null) {
|
||||
return 0;
|
||||
}
|
||||
return view.getScrollX();
|
||||
}
|
||||
|
||||
public void setScrollX(int value) {
|
||||
View view = mView.get();
|
||||
if (view != null) {
|
||||
view.scrollTo(value, view.getScrollY());
|
||||
}
|
||||
}
|
||||
|
||||
public int getScrollY() {
|
||||
View view = mView.get();
|
||||
if (view == null) {
|
||||
return 0;
|
||||
}
|
||||
return view.getScrollY();
|
||||
}
|
||||
|
||||
public void setScrollY(int value) {
|
||||
View view = mView.get();
|
||||
if (view != null) {
|
||||
view.scrollTo(view.getScrollX(), value);
|
||||
}
|
||||
}
|
||||
|
||||
public float getTranslationX() {
|
||||
return mTranslationX;
|
||||
}
|
||||
|
||||
public void setTranslationX(float translationX) {
|
||||
if (mTranslationX != translationX) {
|
||||
prepareForUpdate();
|
||||
mTranslationX = translationX;
|
||||
invalidateAfterUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public float getTranslationY() {
|
||||
return mTranslationY;
|
||||
}
|
||||
|
||||
public void setTranslationY(float translationY) {
|
||||
if (mTranslationY != translationY) {
|
||||
prepareForUpdate();
|
||||
mTranslationY = translationY;
|
||||
invalidateAfterUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
View view = mView.get();
|
||||
if (view == null) {
|
||||
return 0;
|
||||
}
|
||||
return view.getLeft() + mTranslationX;
|
||||
}
|
||||
|
||||
public void setX(float x) {
|
||||
View view = mView.get();
|
||||
if (view != null) {
|
||||
setTranslationX(x - view.getLeft());
|
||||
}
|
||||
}
|
||||
|
||||
public float getY() {
|
||||
View view = mView.get();
|
||||
if (view == null) {
|
||||
return 0;
|
||||
}
|
||||
return view.getTop() + mTranslationY;
|
||||
}
|
||||
|
||||
public void setY(float y) {
|
||||
View view = mView.get();
|
||||
if (view != null) {
|
||||
setTranslationY(y - view.getTop());
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareForUpdate() {
|
||||
View view = mView.get();
|
||||
if (view != null) {
|
||||
computeRect(mBefore, view);
|
||||
}
|
||||
}
|
||||
|
||||
private void invalidateAfterUpdate() {
|
||||
View view = mView.get();
|
||||
if (view == null || view.getParent() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final RectF after = mAfter;
|
||||
computeRect(after, view);
|
||||
after.union(mBefore);
|
||||
|
||||
((View) view.getParent()).invalidate(
|
||||
(int) Math.floor(after.left),
|
||||
(int) Math.floor(after.top),
|
||||
(int) Math.ceil(after.right),
|
||||
(int) Math.ceil(after.bottom));
|
||||
}
|
||||
|
||||
private void computeRect(final RectF r, View view) {
|
||||
final float w = view.getWidth();
|
||||
final float h = view.getHeight();
|
||||
|
||||
r.set(0, 0, w, h);
|
||||
|
||||
final Matrix m = mTempMatrix;
|
||||
m.reset();
|
||||
transformMatrix(m, view);
|
||||
mTempMatrix.mapRect(r);
|
||||
|
||||
r.offset(view.getLeft(), view.getTop());
|
||||
|
||||
if (r.right < r.left) {
|
||||
final float f = r.right;
|
||||
r.right = r.left;
|
||||
r.left = f;
|
||||
}
|
||||
if (r.bottom < r.top) {
|
||||
final float f = r.top;
|
||||
r.top = r.bottom;
|
||||
r.bottom = f;
|
||||
}
|
||||
}
|
||||
|
||||
private void transformMatrix(Matrix m, View view) {
|
||||
final float w = view.getWidth();
|
||||
final float h = view.getHeight();
|
||||
final boolean hasPivot = mHasPivot;
|
||||
final float pX = hasPivot ? mPivotX : w / 2f;
|
||||
final float pY = hasPivot ? mPivotY : h / 2f;
|
||||
|
||||
final float rX = mRotationX;
|
||||
final float rY = mRotationY;
|
||||
final float rZ = mRotationZ;
|
||||
if ((rX != 0) || (rY != 0) || (rZ != 0)) {
|
||||
final Camera camera = mCamera;
|
||||
camera.save();
|
||||
camera.rotateX(rX);
|
||||
camera.rotateY(rY);
|
||||
camera.rotateZ(-rZ);
|
||||
camera.getMatrix(m);
|
||||
camera.restore();
|
||||
m.preTranslate(-pX, -pY);
|
||||
m.postTranslate(pX, pY);
|
||||
}
|
||||
|
||||
final float sX = mScaleX;
|
||||
final float sY = mScaleY;
|
||||
if ((sX != 1.0f) || (sY != 1.0f)) {
|
||||
m.postScale(sX, sY);
|
||||
final float sPX = -(pX / w) * ((sX * w) - w);
|
||||
final float sPY = -(pY / h) * ((sY * h) - h);
|
||||
m.postTranslate(sPX, sPY);
|
||||
}
|
||||
|
||||
m.postTranslate(mTranslationX, mTranslationY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
View view = mView.get();
|
||||
if (view != null) {
|
||||
t.setAlpha(mAlpha);
|
||||
transformMatrix(t.getMatrix(), view);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* 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.AnimationCompat;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
|
||||
import org.telegram.ui.Animation.Animator10;
|
||||
import org.telegram.ui.Animation.AnimatorListenerAdapter10;
|
||||
import org.telegram.ui.Animation.View10;
|
||||
|
||||
public class AnimatorListenerAdapterProxy {
|
||||
protected Object animatorListenerAdapter;
|
||||
|
||||
public AnimatorListenerAdapterProxy() {
|
||||
if (View10.NEED_PROXY) {
|
||||
animatorListenerAdapter = new AnimatorListenerAdapter10() {
|
||||
@Override
|
||||
public void onAnimationCancel(Animator10 animation) {
|
||||
AnimatorListenerAdapterProxy.this.onAnimationCancel(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator10 animation) {
|
||||
AnimatorListenerAdapterProxy.this.onAnimationEnd(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator10 animation) {
|
||||
AnimatorListenerAdapterProxy.this.onAnimationRepeat(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator10 animation) {
|
||||
AnimatorListenerAdapterProxy.this.onAnimationStart(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationPause(Animator10 animation) {
|
||||
AnimatorListenerAdapterProxy.this.onAnimationPause(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationResume(Animator10 animation) {
|
||||
AnimatorListenerAdapterProxy.this.onAnimationResume(animation);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
animatorListenerAdapter = new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
AnimatorListenerAdapterProxy.this.onAnimationCancel(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
AnimatorListenerAdapterProxy.this.onAnimationEnd(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
AnimatorListenerAdapterProxy.this.onAnimationRepeat(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
AnimatorListenerAdapterProxy.this.onAnimationStart(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationPause(Animator animation) {
|
||||
AnimatorListenerAdapterProxy.this.onAnimationPause(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationResume(Animator animation) {
|
||||
AnimatorListenerAdapterProxy.this.onAnimationResume(animation);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void onAnimationCancel(Object animation) {
|
||||
|
||||
}
|
||||
|
||||
public void onAnimationEnd(Object animation) {
|
||||
|
||||
}
|
||||
|
||||
public void onAnimationRepeat(Object animation) {
|
||||
|
||||
}
|
||||
|
||||
public void onAnimationStart(Object animation) {
|
||||
|
||||
}
|
||||
|
||||
public void onAnimationPause(Object animation) {
|
||||
|
||||
}
|
||||
|
||||
public void onAnimationResume(Object animation) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* 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.AnimationCompat;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
|
||||
import org.telegram.ui.Animation.Animator10;
|
||||
import org.telegram.ui.Animation.AnimatorListenerAdapter10;
|
||||
import org.telegram.ui.Animation.AnimatorSet10;
|
||||
import org.telegram.ui.Animation.ObjectAnimator10;
|
||||
import org.telegram.ui.Animation.View10;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class AnimatorSetProxy {
|
||||
private Object animatorSet;
|
||||
|
||||
public AnimatorSetProxy() {
|
||||
if (View10.NEED_PROXY) {
|
||||
animatorSet = new AnimatorSet10();
|
||||
} else {
|
||||
animatorSet = new AnimatorSet();
|
||||
}
|
||||
}
|
||||
|
||||
public void playTogether(Object... items) {
|
||||
if (View10.NEED_PROXY) {
|
||||
Animator10[] animators = Arrays.copyOf(items, items.length, Animator10[].class);
|
||||
((AnimatorSet10) animatorSet).playTogether(animators);
|
||||
} else {
|
||||
Animator[] animators = Arrays.copyOf(items, items.length, Animator[].class);
|
||||
((AnimatorSet) animatorSet).playTogether(animators);
|
||||
}
|
||||
}
|
||||
|
||||
public AnimatorSetProxy setDuration(long duration) {
|
||||
if (View10.NEED_PROXY) {
|
||||
((AnimatorSet10) animatorSet).setDuration(duration);
|
||||
} else {
|
||||
((AnimatorSet) animatorSet).setDuration(duration);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (View10.NEED_PROXY) {
|
||||
((AnimatorSet10) animatorSet).start();
|
||||
} else {
|
||||
((AnimatorSet) animatorSet).start();
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener(AnimatorListenerAdapterProxy listener) {
|
||||
if (View10.NEED_PROXY) {
|
||||
((AnimatorSet10) animatorSet).addListener((AnimatorListenerAdapter10)listener.animatorListenerAdapter);
|
||||
} else {
|
||||
((AnimatorSet) animatorSet).addListener((AnimatorListenerAdapter) listener.animatorListenerAdapter);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* 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.AnimationCompat;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import org.telegram.ui.Animation.ObjectAnimator10;
|
||||
import org.telegram.ui.Animation.View10;
|
||||
|
||||
public class ObjectAnimatorProxy {
|
||||
|
||||
private Object objectAnimator;
|
||||
|
||||
public ObjectAnimatorProxy(Object animator) {
|
||||
objectAnimator = animator;
|
||||
}
|
||||
|
||||
public static Object ofFloat(Object target, String propertyName, float... values) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return ObjectAnimator10.ofFloat(target, propertyName, values);
|
||||
} else {
|
||||
return ObjectAnimator.ofFloat(target, propertyName, values);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object ofInt(Object target, String propertyName, int... values) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return ObjectAnimator10.ofInt(target, propertyName, values);
|
||||
} else {
|
||||
return ObjectAnimator.ofInt(target, propertyName, values);
|
||||
}
|
||||
}
|
||||
|
||||
public static ObjectAnimatorProxy ofFloatProxy(Object target, String propertyName, float... values) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return new ObjectAnimatorProxy(ObjectAnimator10.ofFloat(target, propertyName, values));
|
||||
} else {
|
||||
return new ObjectAnimatorProxy(ObjectAnimator.ofFloat(target, propertyName, values));
|
||||
}
|
||||
}
|
||||
|
||||
public static ObjectAnimatorProxy ofIntProxy(Object target, String propertyName, int... values) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return new ObjectAnimatorProxy(ObjectAnimator10.ofInt(target, propertyName, values));
|
||||
} else {
|
||||
return new ObjectAnimatorProxy(ObjectAnimator.ofInt(target, propertyName, values));
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectAnimatorProxy setDuration(long duration) {
|
||||
if (View10.NEED_PROXY) {
|
||||
((ObjectAnimator10) objectAnimator).setDuration(duration);
|
||||
} else {
|
||||
((ObjectAnimator) objectAnimator).setDuration(duration);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setInterpolator(Interpolator value) {
|
||||
if (View10.NEED_PROXY) {
|
||||
((ObjectAnimator10) objectAnimator).setInterpolator(value);
|
||||
} else {
|
||||
((ObjectAnimator) objectAnimator).setInterpolator(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (View10.NEED_PROXY) {
|
||||
((ObjectAnimator10) objectAnimator).start();
|
||||
} else {
|
||||
((ObjectAnimator) objectAnimator).start();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,248 @@
|
|||
/*
|
||||
* 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.AnimationCompat;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.ui.Animation.View10;
|
||||
|
||||
public class ViewProxy {
|
||||
|
||||
public static float getAlpha(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getAlpha();
|
||||
} else {
|
||||
return view.getAlpha();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setAlpha(View view, float alpha) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setAlpha(alpha);
|
||||
} else {
|
||||
view.setAlpha(alpha);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getPivotX(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getPivotX();
|
||||
} else {
|
||||
return view.getPivotX();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPivotX(View view, float pivotX) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setPivotX(pivotX);
|
||||
} else {
|
||||
view.setPivotX(pivotX);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getPivotY(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getPivotY();
|
||||
} else {
|
||||
return view.getPivotY();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPivotY(View view, float pivotY) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setPivotY(pivotY);
|
||||
} else {
|
||||
view.setPivotY(pivotY);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getRotation(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getRotation();
|
||||
} else {
|
||||
return view.getRotation();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setRotation(View view, float rotation) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setRotation(rotation);
|
||||
} else {
|
||||
view.setRotation(rotation);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getRotationX(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getRotationX();
|
||||
} else {
|
||||
return view.getRotationX();
|
||||
}
|
||||
}
|
||||
|
||||
public void setRotationX(View view, float rotationX) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setRotationX(rotationX);
|
||||
} else {
|
||||
view.setRotationX(rotationX);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getRotationY(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getRotationY();
|
||||
} else {
|
||||
return view.getRotationY();
|
||||
}
|
||||
}
|
||||
|
||||
public void setRotationY(View view, float rotationY) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setRotationY(rotationY);
|
||||
} else {
|
||||
view.setRotationY(rotationY);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getScaleX(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getScaleX();
|
||||
} else {
|
||||
return view.getScaleX();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setScaleX(View view, float scaleX) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setScaleX(scaleX);
|
||||
} else {
|
||||
view.setScaleX(scaleX);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getScaleY(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getScaleY();
|
||||
} else {
|
||||
return view.getScaleY();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setScaleY(View view, float scaleY) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setScaleY(scaleY);
|
||||
} else {
|
||||
view.setScaleY(scaleY);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getScrollX(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getScrollX();
|
||||
} else {
|
||||
return view.getScrollX();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setScrollX(View view, int value) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setScrollX(value);
|
||||
} else {
|
||||
view.setScrollX(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getScrollY(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getScrollY();
|
||||
} else {
|
||||
return view.getScrollY();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setScrollY(View view, int value) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setScrollY(value);
|
||||
} else {
|
||||
view.setScrollY(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getTranslationX(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getTranslationX();
|
||||
} else {
|
||||
return view.getTranslationX();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTranslationX(View view, float translationX) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setTranslationX(translationX);
|
||||
} else {
|
||||
view.setTranslationX(translationX);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getTranslationY(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getTranslationY();
|
||||
} else {
|
||||
return view.getTranslationY();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTranslationY(View view, float translationY) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setTranslationY(translationY);
|
||||
} else {
|
||||
view.setTranslationY(translationY);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getX(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getX();
|
||||
} else {
|
||||
return view.getX();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setX(View view, float x) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setX(x);
|
||||
} else {
|
||||
view.setX(x);
|
||||
}
|
||||
}
|
||||
|
||||
public static float getY(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view).getY();
|
||||
} else {
|
||||
return view.getY();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setY(View view, float y) {
|
||||
if (View10.NEED_PROXY) {
|
||||
View10.wrap(view).setY(y);
|
||||
} else {
|
||||
view.setY(y);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object wrap(View view) {
|
||||
if (View10.NEED_PROXY) {
|
||||
return View10.wrap(view);
|
||||
} else {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -272,7 +272,7 @@ public class ApplicationLoader extends Application {
|
|||
UserConfig.registeredForPush = !isNew;
|
||||
UserConfig.saveConfig(false);
|
||||
if (UserConfig.getClientUserId() != 0) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesController.getInstance().registerForPush(regid);
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.telegram.messenger.R;
|
|||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.ui.PhotoViewer;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
|
||||
public class ChatActionCell extends BaseCell {
|
||||
|
||||
|
@ -47,6 +48,7 @@ public class ChatActionCell extends BaseCell {
|
|||
private URLSpan pressedLink;
|
||||
|
||||
private ImageReceiver imageReceiver;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private StaticLayout textLayout;
|
||||
private int textWidth = 0;
|
||||
private int textHeight = 0;
|
||||
|
@ -72,6 +74,7 @@ public class ChatActionCell extends BaseCell {
|
|||
textPaint.linkColor = 0xffffffff;
|
||||
}
|
||||
imageReceiver = new ImageReceiver(this);
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
|
||||
}
|
||||
|
||||
|
@ -97,18 +100,19 @@ public class ChatActionCell extends BaseCell {
|
|||
}
|
||||
}
|
||||
}
|
||||
avatarDrawable.setInfo(id, null, null, false);
|
||||
if (currentMessageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
|
||||
imageReceiver.setImage(currentMessageObject.messageOwner.action.newUserPhoto.photo_small, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(id)), false);
|
||||
imageReceiver.setImage(currentMessageObject.messageOwner.action.newUserPhoto.photo_small, "50_50", avatarDrawable, false);
|
||||
} else {
|
||||
PhotoObject photo = PhotoObject.getClosestImageWithSize(currentMessageObject.photoThumbs, AndroidUtilities.dp(64));
|
||||
if (photo != null) {
|
||||
if (photo.image != null) {
|
||||
imageReceiver.setImageBitmap(photo.image);
|
||||
} else {
|
||||
imageReceiver.setImage(photo.photoOwner.location, "50_50", getResources().getDrawable(AndroidUtilities.getGroupAvatarForId(id)), false);
|
||||
imageReceiver.setImage(photo.photoOwner.location, "50_50", avatarDrawable, false);
|
||||
}
|
||||
} else {
|
||||
imageReceiver.setImageBitmap(getResources().getDrawable(AndroidUtilities.getGroupAvatarForId(id)));
|
||||
imageReceiver.setImageBitmap(avatarDrawable);
|
||||
}
|
||||
}
|
||||
imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(currentMessageObject), false);
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.telegram.android.MessagesController;
|
|||
import org.telegram.messenger.R;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.ImageReceiver;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.ProgressView;
|
||||
import org.telegram.ui.Views.SeekBar;
|
||||
|
||||
|
@ -36,6 +37,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
|||
private static TextPaint timePaint;
|
||||
|
||||
private ImageReceiver avatarImage;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private boolean needAvatarImage = false;
|
||||
private SeekBar seekBar;
|
||||
private ProgressView progressView;
|
||||
|
@ -66,6 +68,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
|||
seekBar = new SeekBar(context);
|
||||
seekBar.delegate = this;
|
||||
progressView = new ProgressView();
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
|
||||
if (timePaint == null) {
|
||||
statesDrawable[0][0] = getResources().getDrawable(R.drawable.play1);
|
||||
|
@ -364,11 +367,15 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
|||
if (audioUser != null) {
|
||||
if (audioUser.photo != null) {
|
||||
currentPhoto = audioUser.photo.photo_small;
|
||||
} else {
|
||||
currentPhoto = null;
|
||||
}
|
||||
avatarImage.setImage(currentPhoto, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid)), false);
|
||||
avatarDrawable.setInfo(audioUser);
|
||||
} else {
|
||||
avatarImage.setImage(null, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid)), false);
|
||||
avatarDrawable.setInfo(uid, null, null, false);
|
||||
currentPhoto = null;
|
||||
}
|
||||
avatarImage.setImage(currentPhoto, "50_50", avatarDrawable, false);
|
||||
}
|
||||
|
||||
if (messageObject.isOut()) {
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.telegram.android.MessagesController;
|
|||
import org.telegram.messenger.R;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.ImageReceiver;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
|
||||
public class ChatBaseCell extends BaseCell {
|
||||
|
||||
|
@ -77,6 +78,7 @@ public class ChatBaseCell extends BaseCell {
|
|||
protected int layoutHeight;
|
||||
|
||||
private ImageReceiver avatarImage;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private boolean avatarPressed = false;
|
||||
private boolean forwardNamePressed = false;
|
||||
|
||||
|
@ -154,6 +156,7 @@ public class ChatBaseCell extends BaseCell {
|
|||
forwardNamePaint.setTextSize(AndroidUtilities.dp(14));
|
||||
}
|
||||
avatarImage = new ImageReceiver(this);
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -236,10 +239,12 @@ public class ChatBaseCell extends BaseCell {
|
|||
} else {
|
||||
currentPhoto = null;
|
||||
}
|
||||
avatarImage.setImage(currentPhoto, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(currentUser.id)), false);
|
||||
avatarDrawable.setInfo(currentUser);
|
||||
} else {
|
||||
avatarImage.setImage(null, "50_50", null, false);
|
||||
currentPhoto = null;
|
||||
avatarDrawable.setInfo(messageObject.messageOwner.from_id, null, null, false);
|
||||
}
|
||||
avatarImage.setImage(currentPhoto, "50_50", avatarDrawable, false);
|
||||
}
|
||||
|
||||
if (!media) {
|
||||
|
@ -389,13 +394,13 @@ public class ChatBaseCell extends BaseCell {
|
|||
if (!currentMessageObject.isOut()) {
|
||||
timeX = backgroundWidth - AndroidUtilities.dp(9) - timeWidth + (isChat ? AndroidUtilities.dp(52) : 0);
|
||||
} else {
|
||||
timeX = layoutWidth - timeWidth - AndroidUtilities.dpf(38.5f);
|
||||
timeX = layoutWidth - timeWidth - AndroidUtilities.dp(38.5f);
|
||||
}
|
||||
} else {
|
||||
if (!currentMessageObject.isOut()) {
|
||||
timeX = backgroundWidth - AndroidUtilities.dp(4) - timeWidth + (isChat ? AndroidUtilities.dp(52) : 0);
|
||||
} else {
|
||||
timeX = layoutWidth - timeWidth - AndroidUtilities.dpf(42.0f);
|
||||
timeX = layoutWidth - timeWidth - AndroidUtilities.dp(42.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,7 +481,7 @@ public class ChatBaseCell extends BaseCell {
|
|||
if (drawName && nameLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19) - nameOffsetX, AndroidUtilities.dp(10));
|
||||
namePaint.setColor(AndroidUtilities.getColorForId(currentUser.id));
|
||||
namePaint.setColor(AvatarDrawable.getColorForId(currentUser.id));
|
||||
nameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
@ -499,16 +504,16 @@ public class ChatBaseCell extends BaseCell {
|
|||
|
||||
if (drawTime) {
|
||||
if (media) {
|
||||
setDrawableBounds(mediaBackgroundDrawable, timeX - AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dpf(27.5f), timeWidth + AndroidUtilities.dp(6 + (currentMessageObject.isOut() ? 20 : 0)), AndroidUtilities.dpf(16.5f));
|
||||
setDrawableBounds(mediaBackgroundDrawable, timeX - AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(27.5f), timeWidth + AndroidUtilities.dp(6 + (currentMessageObject.isOut() ? 20 : 0)), AndroidUtilities.dp(16.5f));
|
||||
mediaBackgroundDrawable.draw(canvas);
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(timeX, layoutHeight - AndroidUtilities.dpf(12.0f) - timeLayout.getHeight());
|
||||
canvas.translate(timeX, layoutHeight - AndroidUtilities.dp(12.0f) - timeLayout.getHeight());
|
||||
timeLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
} else {
|
||||
canvas.save();
|
||||
canvas.translate(timeX, layoutHeight - AndroidUtilities.dpf(6.5f) - timeLayout.getHeight());
|
||||
canvas.translate(timeX, layoutHeight - AndroidUtilities.dp(6.5f) - timeLayout.getHeight());
|
||||
timeLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
@ -544,20 +549,20 @@ public class ChatBaseCell extends BaseCell {
|
|||
|
||||
if (drawClock) {
|
||||
if (!media) {
|
||||
setDrawableBounds(clockDrawable, layoutWidth - AndroidUtilities.dpf(18.5f) - clockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - clockDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(clockDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - clockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - clockDrawable.getIntrinsicHeight());
|
||||
clockDrawable.draw(canvas);
|
||||
} else {
|
||||
setDrawableBounds(clockMediaDrawable, layoutWidth - AndroidUtilities.dpf(22.0f) - clockMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - clockMediaDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(clockMediaDrawable, layoutWidth - AndroidUtilities.dp(22.0f) - clockMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - clockMediaDrawable.getIntrinsicHeight());
|
||||
clockMediaDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
if (isBroadcast) {
|
||||
if (drawCheck1 || drawCheck2) {
|
||||
if (!media) {
|
||||
setDrawableBounds(broadcastDrawable, layoutWidth - AndroidUtilities.dpf(20.5f) - broadcastDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.0f) - broadcastDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(broadcastDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - broadcastDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - broadcastDrawable.getIntrinsicHeight());
|
||||
broadcastDrawable.draw(canvas);
|
||||
} else {
|
||||
setDrawableBounds(broadcastMediaDrawable, layoutWidth - AndroidUtilities.dpf(24.0f) - broadcastMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - broadcastMediaDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(broadcastMediaDrawable, layoutWidth - AndroidUtilities.dp(24.0f) - broadcastMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - broadcastMediaDrawable.getIntrinsicHeight());
|
||||
broadcastMediaDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
@ -565,36 +570,36 @@ public class ChatBaseCell extends BaseCell {
|
|||
if (drawCheck2) {
|
||||
if (!media) {
|
||||
if (drawCheck1) {
|
||||
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dpf(22.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - checkDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dp(22.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - checkDrawable.getIntrinsicHeight());
|
||||
} else {
|
||||
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dpf(18.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - checkDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(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());
|
||||
setDrawableBounds(checkMediaDrawable, layoutWidth - AndroidUtilities.dp(26.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - checkMediaDrawable.getIntrinsicHeight());
|
||||
} else {
|
||||
setDrawableBounds(checkMediaDrawable, layoutWidth - AndroidUtilities.dpf(22.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - checkMediaDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(checkMediaDrawable, layoutWidth - AndroidUtilities.dp(22.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(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());
|
||||
setDrawableBounds(halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - halfCheckDrawable.getIntrinsicHeight());
|
||||
halfCheckDrawable.draw(canvas);
|
||||
} else {
|
||||
setDrawableBounds(halfCheckMediaDrawable, layoutWidth - AndroidUtilities.dpf(20.5f) - halfCheckMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - halfCheckMediaDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(halfCheckMediaDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - halfCheckMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(13.0f) - halfCheckMediaDrawable.getIntrinsicHeight());
|
||||
halfCheckMediaDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (drawError) {
|
||||
if (!media) {
|
||||
setDrawableBounds(errorDrawable, layoutWidth - AndroidUtilities.dp(18) - errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(6.5f) - errorDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(errorDrawable, layoutWidth - AndroidUtilities.dp(18) - errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(6.5f) - errorDrawable.getIntrinsicHeight());
|
||||
errorDrawable.draw(canvas);
|
||||
} else {
|
||||
setDrawableBounds(errorDrawable, layoutWidth - AndroidUtilities.dpf(20.5f) - errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(12.5f) - errorDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(errorDrawable, layoutWidth - AndroidUtilities.dp(20.5f) - errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(12.5f) - errorDrawable.getIntrinsicHeight());
|
||||
errorDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.telegram.android.MessagesController;
|
|||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
|
||||
public class ChatContactCell extends ChatBaseCell {
|
||||
|
||||
|
@ -42,6 +43,7 @@ public class ChatContactCell extends ChatBaseCell {
|
|||
private static Drawable addContactDrawableOut;
|
||||
|
||||
private ImageReceiver avatarImage;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
|
||||
private StaticLayout nameLayout;
|
||||
private StaticLayout phoneLayout;
|
||||
|
@ -183,11 +185,15 @@ public class ChatContactCell extends ChatBaseCell {
|
|||
if (contactUser != null) {
|
||||
if (contactUser.photo != null) {
|
||||
currentPhoto = contactUser.photo.photo_small;
|
||||
} else {
|
||||
currentPhoto = null;
|
||||
}
|
||||
avatarImage.setImage(currentPhoto, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid)), false);
|
||||
avatarDrawable.setInfo(contactUser);
|
||||
} else {
|
||||
avatarImage.setImage(null, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(uid)), false);
|
||||
currentPhoto = null;
|
||||
avatarDrawable.setInfo(uid, null, null, false);
|
||||
}
|
||||
avatarImage.setImage(currentPhoto, "50_50", avatarDrawable, false);
|
||||
|
||||
String currentNameString = ContactsController.formatName(messageObject.messageOwner.media.first_name, messageObject.messageOwner.media.last_name);
|
||||
int nameWidth = Math.min((int) Math.ceil(namePaint.measureText(currentNameString)), maxWidth);
|
||||
|
@ -265,7 +271,7 @@ public class ChatContactCell extends ChatBaseCell {
|
|||
if (nameLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(avatarImage.getImageX() + avatarImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(10));
|
||||
namePaint.setColor(AndroidUtilities.getColorForId(currentMessageObject.messageOwner.media.user_id));
|
||||
namePaint.setColor(AvatarDrawable.getColorForId(currentMessageObject.messageOwner.media.user_id));
|
||||
nameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
|
|
@ -911,16 +911,16 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
}
|
||||
} else if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3 || currentMessageObject.isSecretPhoto())) {
|
||||
infoPaint.setColor(0xffffffff);
|
||||
setDrawableBounds(mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dpf(16.5f));
|
||||
setDrawableBounds(mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dp(16.5f));
|
||||
mediaBackgroundDrawable.draw(canvas);
|
||||
|
||||
if (currentMessageObject.type == 3) {
|
||||
setDrawableBounds(videoIconDrawable, photoImage.getImageX() + AndroidUtilities.dp(8), photoImage.getImageY() + AndroidUtilities.dpf(7.5f));
|
||||
setDrawableBounds(videoIconDrawable, photoImage.getImageX() + AndroidUtilities.dp(8), photoImage.getImageY() + AndroidUtilities.dp(7.5f));
|
||||
videoIconDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(photoImage.getImageX() + AndroidUtilities.dp(8) + infoOffset, photoImage.getImageY() + AndroidUtilities.dpf(5.5f));
|
||||
canvas.translate(photoImage.getImageX() + AndroidUtilities.dp(8) + infoOffset, photoImage.getImageY() + AndroidUtilities.dp(5.5f));
|
||||
infoLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
|
|
@ -160,14 +160,14 @@ public class ChatMessageCell extends ChatBaseCell {
|
|||
super.setMessageObject(messageObject);
|
||||
|
||||
backgroundWidth = messageObject.textWidth;
|
||||
totalHeight = messageObject.textHeight + AndroidUtilities.dpf(19.5f) + namesOffset;
|
||||
totalHeight = messageObject.textHeight + AndroidUtilities.dp(19.5f) + namesOffset;
|
||||
|
||||
int maxChildWidth = Math.max(backgroundWidth, nameWidth);
|
||||
maxChildWidth = Math.max(maxChildWidth, forwardedNameWidth);
|
||||
|
||||
int timeMore = timeWidth + AndroidUtilities.dp(6);
|
||||
if (messageObject.isOut()) {
|
||||
timeMore += AndroidUtilities.dpf(20.5f);
|
||||
timeMore += AndroidUtilities.dp(20.5f);
|
||||
}
|
||||
|
||||
if (maxWidth - messageObject.lastLineWidth < timeMore) {
|
||||
|
|
|
@ -27,13 +27,13 @@ import org.telegram.android.MessagesController;
|
|||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.android.ImageReceiver;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
|
||||
public class ChatOrUserCell extends BaseCell {
|
||||
private static TextPaint namePaint;
|
||||
private static TextPaint nameEncryptedPaint;
|
||||
private static TextPaint onlinePaint;
|
||||
private static TextPaint offlinePaint;
|
||||
|
||||
private static Drawable lockDrawable;
|
||||
private static Drawable broadcastDrawable;
|
||||
private static Drawable groupDrawable;
|
||||
|
@ -41,9 +41,9 @@ public class ChatOrUserCell extends BaseCell {
|
|||
|
||||
private CharSequence currentName;
|
||||
private ImageReceiver avatarImage;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private CharSequence subLabel;
|
||||
|
||||
private ChatOrUserCellLayout cellLayout;
|
||||
private TLRPC.User user = null;
|
||||
private TLRPC.Chat chat = null;
|
||||
private TLRPC.EncryptedChat encryptedChat = null;
|
||||
|
@ -56,9 +56,26 @@ public class ChatOrUserCell extends BaseCell {
|
|||
public boolean useSeparator = false;
|
||||
public float drawAlpha = 1;
|
||||
|
||||
private int nameLeft;
|
||||
private int nameTop;
|
||||
private StaticLayout nameLayout;
|
||||
private boolean drawNameLock;
|
||||
private boolean drawNameBroadcast;
|
||||
private boolean drawNameGroup;
|
||||
private int nameLockLeft;
|
||||
private int nameLockTop;
|
||||
|
||||
private int onlineLeft;
|
||||
private int onlineTop = AndroidUtilities.dp(36);
|
||||
private StaticLayout onlineLayout;
|
||||
|
||||
private int avatarTop = AndroidUtilities.dp(7);
|
||||
|
||||
public ChatOrUserCell(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
avatarImage = new ImageReceiver(this);
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
@ -66,50 +83,28 @@ public class ChatOrUserCell extends BaseCell {
|
|||
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
namePaint.setTextSize(AndroidUtilities.dp(18));
|
||||
namePaint.setColor(0xff222222);
|
||||
}
|
||||
|
||||
if (nameEncryptedPaint == null) {
|
||||
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
nameEncryptedPaint.setTextSize(AndroidUtilities.dp(18));
|
||||
nameEncryptedPaint.setColor(0xff00a60e);
|
||||
}
|
||||
|
||||
if (onlinePaint == null) {
|
||||
onlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
onlinePaint.setTextSize(AndroidUtilities.dp(15));
|
||||
onlinePaint.setColor(0xff316f9f);
|
||||
}
|
||||
|
||||
if (offlinePaint == null) {
|
||||
offlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
offlinePaint.setTextSize(AndroidUtilities.dp(15));
|
||||
offlinePaint.setColor(0xff999999);
|
||||
}
|
||||
|
||||
if (lockDrawable == null) {
|
||||
lockDrawable = getResources().getDrawable(R.drawable.ic_lock_green);
|
||||
}
|
||||
|
||||
if (linePaint == null) {
|
||||
linePaint = new Paint();
|
||||
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(this);
|
||||
}
|
||||
|
||||
if (cellLayout == null) {
|
||||
cellLayout = new ChatOrUserCellLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public void setData(TLRPC.User u, TLRPC.Chat c, TLRPC.EncryptedChat ec, CharSequence n, CharSequence s) {
|
||||
|
@ -147,26 +142,181 @@ public class ChatOrUserCell extends BaseCell {
|
|||
}
|
||||
|
||||
public void buildLayout() {
|
||||
cellLayout.build(getMeasuredWidth(), getMeasuredHeight());
|
||||
CharSequence nameString = "";
|
||||
TextPaint currentNamePaint;
|
||||
|
||||
drawNameBroadcast = false;
|
||||
drawNameLock = false;
|
||||
drawNameGroup = false;
|
||||
|
||||
if (encryptedChat != null) {
|
||||
drawNameLock = true;
|
||||
if (!LocaleController.isRTL) {
|
||||
nameLockLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
||||
nameLeft = AndroidUtilities.dp(65 + (usePadding ? 11 : 0)) + lockDrawable.getIntrinsicWidth();
|
||||
} else {
|
||||
nameLockLeft = getMeasuredWidth() - AndroidUtilities.dp(63 + (usePadding ? 11 : 0)) - lockDrawable.getIntrinsicWidth();
|
||||
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
}
|
||||
nameLockTop = AndroidUtilities.dp(15);
|
||||
} else {
|
||||
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 = getMeasuredWidth() - AndroidUtilities.dp(63 + (usePadding ? 11 : 0)) - (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
|
||||
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
}
|
||||
} else {
|
||||
if (!LocaleController.isRTL) {
|
||||
nameLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
||||
} else {
|
||||
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentName != null) {
|
||||
nameString = currentName;
|
||||
} else {
|
||||
String nameString2 = "";
|
||||
if (chat != null) {
|
||||
nameString2 = chat.title;
|
||||
} else if (user != null) {
|
||||
nameString2 = ContactsController.formatName(user.first_name, user.last_name);
|
||||
}
|
||||
nameString = nameString2.replace("\n", " ");
|
||||
}
|
||||
if (nameString.length() == 0) {
|
||||
if (user != null && user.phone != null && user.phone.length() != 0) {
|
||||
nameString = PhoneFormat.getInstance().format("+" + user.phone);
|
||||
} else {
|
||||
nameString = LocaleController.getString("HiddenName", R.string.HiddenName);
|
||||
}
|
||||
}
|
||||
if (encryptedChat != null) {
|
||||
currentNamePaint = nameEncryptedPaint;
|
||||
} else {
|
||||
currentNamePaint = namePaint;
|
||||
}
|
||||
|
||||
int onlineWidth;
|
||||
int nameWidth;
|
||||
if (!LocaleController.isRTL) {
|
||||
onlineWidth = nameWidth = getMeasuredWidth() - nameLeft - AndroidUtilities.dp(3 + (usePadding ? 11 : 0));
|
||||
} else {
|
||||
onlineWidth = nameWidth = getMeasuredWidth() - nameLeft - AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
||||
}
|
||||
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);
|
||||
nameLayout = new StaticLayout(nameStringFinal, currentNamePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
|
||||
if (chat == null) {
|
||||
if (!LocaleController.isRTL) {
|
||||
onlineLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
||||
} else {
|
||||
onlineLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
}
|
||||
|
||||
CharSequence onlineString = "";
|
||||
TextPaint currentOnlinePaint = offlinePaint;
|
||||
|
||||
if (subLabel != null) {
|
||||
onlineString = subLabel;
|
||||
} else {
|
||||
onlineString = LocaleController.formatUserStatus(user);
|
||||
if (user != null && (user.id == UserConfig.getClientUserId() || user.status != null && user.status.expires > ConnectionsManager.getInstance().getCurrentTime())) {
|
||||
currentOnlinePaint = onlinePaint;
|
||||
onlineString = LocaleController.getString("Online", R.string.Online);
|
||||
}
|
||||
}
|
||||
|
||||
CharSequence onlineStringFinal = TextUtils.ellipsize(onlineString, currentOnlinePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
||||
onlineLayout = new StaticLayout(onlineStringFinal, currentOnlinePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
nameTop = AndroidUtilities.dp(12);
|
||||
} else {
|
||||
onlineLayout = null;
|
||||
nameTop = AndroidUtilities.dp(22);
|
||||
}
|
||||
|
||||
int avatarLeft;
|
||||
if (!LocaleController.isRTL) {
|
||||
avatarLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
} else {
|
||||
avatarLeft = getMeasuredWidth() - AndroidUtilities.dp(50 + (usePadding ? 11 : 0));
|
||||
}
|
||||
avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(50), AndroidUtilities.dp(50));
|
||||
|
||||
|
||||
double widthpx = 0;
|
||||
float left = 0;
|
||||
if (LocaleController.isRTL) {
|
||||
if (nameLayout.getLineCount() > 0) {
|
||||
left = nameLayout.getLineLeft(0);
|
||||
if (left == 0) {
|
||||
widthpx = Math.ceil(nameLayout.getLineWidth(0));
|
||||
if (widthpx < nameWidth) {
|
||||
nameLeft += (nameWidth - widthpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (onlineLayout != null && onlineLayout.getLineCount() > 0) {
|
||||
left = onlineLayout.getLineLeft(0);
|
||||
if (left == 0) {
|
||||
widthpx = Math.ceil(onlineLayout.getLineWidth(0));
|
||||
if (widthpx < onlineWidth) {
|
||||
onlineLeft += (onlineWidth - widthpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (nameLayout.getLineCount() > 0) {
|
||||
left = nameLayout.getLineRight(0);
|
||||
if (left == nameWidth) {
|
||||
widthpx = Math.ceil(nameLayout.getLineWidth(0));
|
||||
if (widthpx < nameWidth) {
|
||||
nameLeft -= (nameWidth - widthpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (onlineLayout != null && onlineLayout.getLineCount() > 0) {
|
||||
left = onlineLayout.getLineRight(0);
|
||||
if (left == onlineWidth) {
|
||||
widthpx = Math.ceil(onlineLayout.getLineWidth(0));
|
||||
if (widthpx < onlineWidth) {
|
||||
onlineLeft -= (onlineWidth - widthpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void update(int mask) {
|
||||
int placeHolderId = 0;
|
||||
TLRPC.FileLocation photo = null;
|
||||
if (user != null) {
|
||||
if (user.photo != null) {
|
||||
photo = user.photo.photo_small;
|
||||
}
|
||||
placeHolderId = AndroidUtilities.getUserAvatarForId(user.id);
|
||||
avatarDrawable.setInfo(user);
|
||||
} else if (chat != null) {
|
||||
if (chat.photo != null) {
|
||||
photo = chat.photo.photo_small;
|
||||
}
|
||||
if (chat.id > 0) {
|
||||
placeHolderId = AndroidUtilities.getGroupAvatarForId(chat.id);
|
||||
} else {
|
||||
placeHolderId = AndroidUtilities.getBroadcastAvatarForId(chat.id);
|
||||
}
|
||||
avatarDrawable.setInfo(chat);
|
||||
} else {
|
||||
avatarDrawable.setInfo(0, null, null, false);
|
||||
}
|
||||
|
||||
if (mask != 0) {
|
||||
|
@ -215,7 +365,7 @@ public class ChatOrUserCell extends BaseCell {
|
|||
|
||||
|
||||
lastAvatar = photo;
|
||||
avatarImage.setImage(photo, "50_50", placeHolderId == 0 ? null : getResources().getDrawable(placeHolderId), false);
|
||||
avatarImage.setImage(photo, "50_50", avatarDrawable, false);
|
||||
|
||||
if (getMeasuredWidth() != 0 || getMeasuredHeight() != 0) {
|
||||
buildLayout();
|
||||
|
@ -231,11 +381,6 @@ public class ChatOrUserCell extends BaseCell {
|
|||
return;
|
||||
}
|
||||
|
||||
if (cellLayout == null) {
|
||||
requestLayout();
|
||||
return;
|
||||
}
|
||||
|
||||
if (useSeparator) {
|
||||
int h = getMeasuredHeight();
|
||||
if (!usePadding) {
|
||||
|
@ -249,208 +394,29 @@ public class ChatOrUserCell extends BaseCell {
|
|||
canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(), (int)(255 * drawAlpha), Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
|
||||
}
|
||||
|
||||
if (cellLayout.drawNameLock) {
|
||||
setDrawableBounds(lockDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
|
||||
if (drawNameLock) {
|
||||
setDrawableBounds(lockDrawable, nameLockLeft, nameLockTop);
|
||||
lockDrawable.draw(canvas);
|
||||
} else if (cellLayout.drawNameGroup) {
|
||||
setDrawableBounds(groupDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
|
||||
} else if (drawNameGroup) {
|
||||
setDrawableBounds(groupDrawable, nameLockLeft, nameLockTop);
|
||||
groupDrawable.draw(canvas);
|
||||
} else if (cellLayout.drawNameBroadcast) {
|
||||
setDrawableBounds(broadcastDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
|
||||
} else if (drawNameBroadcast) {
|
||||
setDrawableBounds(broadcastDrawable, nameLockLeft, nameLockTop);
|
||||
broadcastDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(cellLayout.nameLeft, cellLayout.nameTop);
|
||||
cellLayout.nameLayout.draw(canvas);
|
||||
canvas.translate(nameLeft, nameTop);
|
||||
nameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
if (cellLayout.onlineLayout != null) {
|
||||
if (onlineLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(cellLayout.onlineLeft, cellLayout.onlineTop);
|
||||
cellLayout.onlineLayout.draw(canvas);
|
||||
canvas.translate(onlineLeft, onlineTop);
|
||||
onlineLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
avatarImage.draw(canvas);
|
||||
}
|
||||
|
||||
private class ChatOrUserCellLayout {
|
||||
private int nameLeft;
|
||||
private int nameTop;
|
||||
private int nameWidth;
|
||||
private StaticLayout nameLayout;
|
||||
private boolean drawNameLock;
|
||||
private boolean drawNameBroadcast;
|
||||
private boolean drawNameGroup;
|
||||
private int nameLockLeft;
|
||||
private int nameLockTop;
|
||||
|
||||
private int onlineLeft;
|
||||
private int onlineTop = AndroidUtilities.dp(36);
|
||||
private int onlineWidth;
|
||||
private StaticLayout onlineLayout;
|
||||
|
||||
private int avatarTop = AndroidUtilities.dp(7);
|
||||
private int avatarLeft;
|
||||
|
||||
public void build(int width, int height) {
|
||||
CharSequence nameString = "";
|
||||
TextPaint currentNamePaint;
|
||||
|
||||
drawNameBroadcast = false;
|
||||
drawNameLock = false;
|
||||
drawNameGroup = false;
|
||||
|
||||
if (encryptedChat != null) {
|
||||
drawNameLock = true;
|
||||
if (!LocaleController.isRTL) {
|
||||
nameLockLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
||||
nameLeft = AndroidUtilities.dp(65 + (usePadding ? 11 : 0)) + lockDrawable.getIntrinsicWidth();
|
||||
} else {
|
||||
nameLockLeft = width - AndroidUtilities.dp(63 + (usePadding ? 11 : 0)) - lockDrawable.getIntrinsicWidth();
|
||||
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
}
|
||||
nameLockTop = AndroidUtilities.dp(15);
|
||||
} else {
|
||||
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 {
|
||||
if (!LocaleController.isRTL) {
|
||||
nameLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
||||
} else {
|
||||
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentName != null) {
|
||||
nameString = currentName;
|
||||
} else {
|
||||
String nameString2 = "";
|
||||
if (chat != null) {
|
||||
nameString2 = chat.title;
|
||||
} else if (user != null) {
|
||||
nameString2 = ContactsController.formatName(user.first_name, user.last_name);
|
||||
}
|
||||
nameString = nameString2.replace("\n", " ");
|
||||
}
|
||||
if (nameString.length() == 0) {
|
||||
if (user != null && user.phone != null && user.phone.length() != 0) {
|
||||
nameString = PhoneFormat.getInstance().format("+" + user.phone);
|
||||
} else {
|
||||
nameString = LocaleController.getString("HiddenName", R.string.HiddenName);
|
||||
}
|
||||
}
|
||||
if (encryptedChat != null) {
|
||||
currentNamePaint = nameEncryptedPaint;
|
||||
} else {
|
||||
currentNamePaint = namePaint;
|
||||
}
|
||||
|
||||
if (!LocaleController.isRTL) {
|
||||
onlineWidth = nameWidth = width - nameLeft - AndroidUtilities.dp(3 + (usePadding ? 11 : 0));
|
||||
} else {
|
||||
onlineWidth = nameWidth = width - nameLeft - AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
||||
}
|
||||
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);
|
||||
nameLayout = new StaticLayout(nameStringFinal, currentNamePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
|
||||
if (chat == null) {
|
||||
if (!LocaleController.isRTL) {
|
||||
onlineLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
||||
} else {
|
||||
onlineLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
}
|
||||
|
||||
CharSequence onlineString = "";
|
||||
TextPaint currentOnlinePaint = offlinePaint;
|
||||
|
||||
if (subLabel != null) {
|
||||
onlineString = subLabel;
|
||||
} else {
|
||||
onlineString = LocaleController.formatUserStatus(user);
|
||||
if (user != null && (user.id == UserConfig.getClientUserId() || user.status != null && user.status.expires > ConnectionsManager.getInstance().getCurrentTime())) {
|
||||
currentOnlinePaint = onlinePaint;
|
||||
onlineString = LocaleController.getString("Online", R.string.Online);
|
||||
}
|
||||
}
|
||||
|
||||
CharSequence onlineStringFinal = TextUtils.ellipsize(onlineString, currentOnlinePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
||||
onlineLayout = new StaticLayout(onlineStringFinal, currentOnlinePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
nameTop = AndroidUtilities.dp(12);
|
||||
} else {
|
||||
onlineLayout = null;
|
||||
nameTop = AndroidUtilities.dp(22);
|
||||
}
|
||||
|
||||
if (!LocaleController.isRTL) {
|
||||
avatarLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
} else {
|
||||
avatarLeft = width - AndroidUtilities.dp(50 + (usePadding ? 11 : 0));
|
||||
}
|
||||
avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(50), AndroidUtilities.dp(50));
|
||||
|
||||
|
||||
double widthpx = 0;
|
||||
float left = 0;
|
||||
if (LocaleController.isRTL) {
|
||||
if (nameLayout.getLineCount() > 0) {
|
||||
left = nameLayout.getLineLeft(0);
|
||||
if (left == 0) {
|
||||
widthpx = Math.ceil(nameLayout.getLineWidth(0));
|
||||
if (widthpx < nameWidth) {
|
||||
nameLeft += (nameWidth - widthpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (onlineLayout != null && onlineLayout.getLineCount() > 0) {
|
||||
left = onlineLayout.getLineLeft(0);
|
||||
if (left == 0) {
|
||||
widthpx = Math.ceil(onlineLayout.getLineWidth(0));
|
||||
if (widthpx < onlineWidth) {
|
||||
onlineLeft += (onlineWidth - widthpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (nameLayout.getLineCount() > 0) {
|
||||
left = nameLayout.getLineRight(0);
|
||||
if (left == nameWidth) {
|
||||
widthpx = Math.ceil(nameLayout.getLineWidth(0));
|
||||
if (widthpx < nameWidth) {
|
||||
nameLeft -= (nameWidth - widthpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (onlineLayout != null && onlineLayout.getLineCount() > 0) {
|
||||
left = onlineLayout.getLineRight(0);
|
||||
if (left == onlineWidth) {
|
||||
widthpx = Math.ceil(onlineLayout.getLineWidth(0));
|
||||
if (widthpx < onlineWidth) {
|
||||
onlineLeft -= (onlineWidth - widthpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -35,6 +35,7 @@ import android.view.MotionEvent;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
|
@ -73,6 +74,7 @@ import org.telegram.ui.Cells.ChatMessageCell;
|
|||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.ChatActivityEnterView;
|
||||
|
@ -441,10 +443,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
actionBarLayer.setExtraLeftMargin(4);
|
||||
}
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
|
@ -877,7 +876,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
SecretPhotoViewer.getInstance().openPhoto(messageObject);
|
||||
}
|
||||
};
|
||||
AndroidUtilities.RunOnUIThread(openSecretPhotoRunnable, 100);
|
||||
AndroidUtilities.runOnUIThread(openSecretPhotoRunnable, 100);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -890,14 +889,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (openSecretPhotoRunnable != null || SecretPhotoViewer.getInstance().isVisible()) {
|
||||
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_POINTER_UP) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chatListView.setOnItemClickListener(onItemClickListener);
|
||||
}
|
||||
}, 150);
|
||||
if (openSecretPhotoRunnable != null) {
|
||||
AndroidUtilities.CancelRunOnUIThread(openSecretPhotoRunnable);
|
||||
AndroidUtilities.cancelRunOnUIThread(openSecretPhotoRunnable);
|
||||
openSecretPhotoRunnable = null;
|
||||
try {
|
||||
Toast.makeText(v.getContext(), LocaleController.getString("PhotoTip", R.string.PhotoTip), Toast.LENGTH_SHORT).show();
|
||||
|
@ -906,7 +905,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
} else {
|
||||
if (SecretPhotoViewer.getInstance().isVisible()) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chatListView.setOnItemLongClickListener(onItemLongClickListener);
|
||||
|
@ -922,11 +921,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
} else if (openSecretPhotoRunnable != null) {
|
||||
if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
if (Math.hypot(startX - event.getX(), startY - event.getY()) > AndroidUtilities.dp(5)) {
|
||||
AndroidUtilities.CancelRunOnUIThread(openSecretPhotoRunnable);
|
||||
AndroidUtilities.cancelRunOnUIThread(openSecretPhotoRunnable);
|
||||
openSecretPhotoRunnable = null;
|
||||
}
|
||||
} else {
|
||||
AndroidUtilities.CancelRunOnUIThread(openSecretPhotoRunnable);
|
||||
AndroidUtilities.cancelRunOnUIThread(openSecretPhotoRunnable);
|
||||
openSecretPhotoRunnable = null;
|
||||
}
|
||||
}
|
||||
|
@ -1192,26 +1191,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
timerButton.setTime(currentEncryptedChat.ttl);
|
||||
}
|
||||
|
||||
if (avatarImageView != null) {
|
||||
TLRPC.FileLocation photo = null;
|
||||
int placeHolderId = 0;
|
||||
if (currentUser != null) {
|
||||
if (currentUser.photo != null) {
|
||||
photo = currentUser.photo.photo_small;
|
||||
}
|
||||
placeHolderId = AndroidUtilities.getUserAvatarForId(currentUser.id);
|
||||
} else if (currentChat != null) {
|
||||
if (currentChat.photo != null) {
|
||||
photo = currentChat.photo.photo_small;
|
||||
}
|
||||
if (isBroadcast) {
|
||||
placeHolderId = AndroidUtilities.getBroadcastAvatarForId(currentChat.id);
|
||||
} else {
|
||||
placeHolderId = AndroidUtilities.getGroupAvatarForId(currentChat.id);
|
||||
}
|
||||
}
|
||||
avatarImageView.setImage(photo, "50_50", placeHolderId);
|
||||
}
|
||||
checkAndUpdateAvatar();
|
||||
}
|
||||
|
||||
private void updateOnlineCount() {
|
||||
|
@ -1461,7 +1441,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
private void checkAndUpdateAvatar() {
|
||||
TLRPC.FileLocation newPhoto = null;
|
||||
int placeHolderId = 0;
|
||||
AvatarDrawable avatarDrawable = null;
|
||||
if (currentUser != null) {
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(currentUser.id);
|
||||
if (user == null) {
|
||||
|
@ -1471,7 +1451,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (currentUser.photo != null) {
|
||||
newPhoto = currentUser.photo.photo_small;
|
||||
}
|
||||
placeHolderId = AndroidUtilities.getUserAvatarForId(currentUser.id);
|
||||
avatarDrawable = new AvatarDrawable(currentUser);
|
||||
} else if (currentChat != null) {
|
||||
TLRPC.Chat chat = MessagesController.getInstance().getChat(currentChat.id);
|
||||
if (chat == null) {
|
||||
|
@ -1481,14 +1461,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (currentChat.photo != null) {
|
||||
newPhoto = currentChat.photo.photo_small;
|
||||
}
|
||||
if (isBroadcast) {
|
||||
placeHolderId = AndroidUtilities.getBroadcastAvatarForId(currentChat.id);
|
||||
} else {
|
||||
placeHolderId = AndroidUtilities.getGroupAvatarForId(currentChat.id);
|
||||
}
|
||||
avatarDrawable = new AvatarDrawable(currentChat);
|
||||
}
|
||||
if (avatarImageView != null) {
|
||||
avatarImageView.setImage(newPhoto, "50_50", placeHolderId);
|
||||
avatarImageView.setImage(newPhoto, "50_50", avatarDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2407,6 +2383,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
|
||||
checkActionBarMenu();
|
||||
if (chatAdapter != null) {
|
||||
chatAdapter.notifyDataSetChanged();
|
||||
|
@ -2458,7 +2436,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
if (startVideoEdit != null) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
openVideoEditor(startVideoEdit, false);
|
||||
|
@ -2481,6 +2459,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
||||
actionBarLayer.hideActionMode();
|
||||
chatActivityEnterView.hideEmojiPopup();
|
||||
paused = true;
|
||||
|
@ -2537,9 +2516,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (getParentActivity() == null) {
|
||||
return true;
|
||||
}
|
||||
int height = AndroidUtilities.dp(48);
|
||||
int height = AndroidUtilities.getCurrentActionBarHeight();
|
||||
if (!AndroidUtilities.isTablet() && getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
height = AndroidUtilities.dp(40);
|
||||
selectedMessagesCountTextView.setTextSize(16);
|
||||
} else {
|
||||
selectedMessagesCountTextView.setTextSize(18);
|
||||
|
@ -3227,6 +3205,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (idx != -1) {
|
||||
String ext = fileName.substring(idx + 1);
|
||||
realMimeType = myMime.getMimeTypeFromExtension(ext.toLowerCase());
|
||||
if (realMimeType == null) {
|
||||
realMimeType = message.messageOwner.media.document.mime_type;
|
||||
if (realMimeType == null || realMimeType.length() == 0) {
|
||||
realMimeType = null;
|
||||
}
|
||||
}
|
||||
if (realMimeType != null) {
|
||||
intent.setDataAndType(Uri.fromFile(f), realMimeType);
|
||||
} else {
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
|||
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.AvatarUpdater;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
|
@ -172,7 +173,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
if (chat_id > 0) {
|
||||
actionBarLayer.setTitle(LocaleController.getString("GroupInfo", R.string.GroupInfo));
|
||||
|
@ -643,7 +644,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||
photo = chat.photo.photo_small;
|
||||
photoBig = chat.photo.photo_big;
|
||||
}
|
||||
avatarImage.setImage(photo, "50_50", chat_id > 0 ? AndroidUtilities.getGroupAvatarForId(chat.id) : AndroidUtilities.getBroadcastAvatarForId(chat.id));
|
||||
avatarImage.setImage(photo, "50_50", new AvatarDrawable(chat));
|
||||
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
||||
return view;
|
||||
} else if (type == 1) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.telegram.messenger.TLRPC;
|
|||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
|
||||
|
@ -164,7 +165,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
|||
if (user.photo != null) {
|
||||
photo = user.photo.photo_small;
|
||||
}
|
||||
avatarImage.setImage(photo, "50_50", AndroidUtilities.getUserAvatarForId(user.id));
|
||||
avatarImage.setImage(photo, "50_50", new AvatarDrawable(user));
|
||||
}
|
||||
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
|
|
|
@ -125,7 +125,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
if (destroyAfterSelect) {
|
||||
actionBarLayer.setTitle(LocaleController.getString("SelectContact", R.string.SelectContact));
|
||||
|
@ -446,7 +446,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
if (error == null) {
|
||||
final TLRPC.TL_help_inviteText res = (TLRPC.TL_help_inviteText)response;
|
||||
if (res.message.length() != 0) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updatingInviteText = false;
|
||||
|
|
|
@ -122,7 +122,7 @@ public class CountrySelectActivity extends BaseFragment {
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBarLayer.setTitle(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
|
||||
|
||||
|
@ -325,7 +325,7 @@ public class CountrySelectActivity extends BaseFragment {
|
|||
}
|
||||
|
||||
private void updateSearchResults(final ArrayList<Country> arrCounties) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
searchResult = arrCounties;
|
||||
|
|
|
@ -130,7 +130,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||
}
|
||||
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBarLayer.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile));
|
||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||
|
@ -481,7 +481,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||
if (item.thumb != null) {
|
||||
imageView.setImageBitmap(null);
|
||||
typeTextView.setText(item.ext.toUpperCase().substring(0, Math.min(item.ext.length(), 4)));
|
||||
imageView.setImage(item.thumb, "55_42", 0);
|
||||
imageView.setImage(item.thumb, "55_42", null);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
typeTextView.setVisibility(View.VISIBLE);
|
||||
} else if (item.icon != 0) {
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.telegram.messenger.UserConfig;
|
|||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.PinnedHeaderListView;
|
||||
|
@ -138,7 +139,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
if (isBroadcast) {
|
||||
actionBarLayer.setTitle(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
|
||||
|
@ -403,7 +404,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
}
|
||||
|
||||
private void processSearch(final String query) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final ArrayList<TLRPC.TL_contact> contactsCopy = new ArrayList<TLRPC.TL_contact>();
|
||||
|
@ -439,7 +440,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
}
|
||||
|
||||
private void updateSearchResults(final ArrayList<TLRPC.User> users, final ArrayList<CharSequence> names) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
searchResult = users;
|
||||
|
@ -463,7 +464,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
}
|
||||
}
|
||||
} else if (id == NotificationCenter.chatDidCreated) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
removeSelfFromStack();
|
||||
|
@ -562,8 +563,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
if (user.photo != null) {
|
||||
photo = user.photo.photo_small;
|
||||
}
|
||||
int placeHolderId = AndroidUtilities.getUserAvatarForId(user.id);
|
||||
holder.avatarImage.setImage(photo, "50_50", placeHolderId);
|
||||
holder.avatarDrawable.setInfo(user.id, user.first_name, user.last_name, false);
|
||||
holder.avatarImage.setImage(photo, "50_50", holder.avatarDrawable);
|
||||
|
||||
holder.messageTextView.setText(LocaleController.formatUserStatus(user));
|
||||
if (user.status != null && user.status.expires > ConnectionsManager.getInstance().getCurrentTime()) {
|
||||
|
@ -614,6 +615,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
public BackupImageView avatarImage;
|
||||
public TextView messageTextView;
|
||||
public TextView nameTextView;
|
||||
public AvatarDrawable avatarDrawable = new AvatarDrawable();
|
||||
|
||||
public ContactListRowHolder(View view) {
|
||||
messageTextView = (TextView)view.findViewById(R.id.messages_list_row_message);
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.telegram.messenger.R;
|
|||
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.AvatarUpdater;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
|
@ -50,6 +51,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||
private TLRPC.InputFile uploadedAvatar;
|
||||
private ArrayList<Integer> selectedContacts;
|
||||
private BackupImageView avatarImage;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private boolean createAfterUpload;
|
||||
private boolean donePressed;
|
||||
private AvatarUpdater avatarUpdater = new AvatarUpdater();
|
||||
|
@ -120,7 +122,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
if (isBroadcast) {
|
||||
actionBarLayer.setTitle(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
|
||||
|
@ -212,7 +214,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||
} else if (i == 2) {
|
||||
avatar = null;
|
||||
uploadedAvatar = null;
|
||||
avatarImage.setImage(avatar, "50_50", R.drawable.group_blue);
|
||||
avatarImage.setImage(avatar, "50_50", avatarDrawable);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -222,7 +224,8 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||
}
|
||||
|
||||
avatarImage = (BackupImageView)fragmentView.findViewById(R.id.settings_avatar_image);
|
||||
avatarImage.setImageResource(R.drawable.group_blue);
|
||||
avatarDrawable.setInfo(3, null, null, isBroadcast);
|
||||
avatarImage.setImageDrawable(avatarDrawable);
|
||||
|
||||
nameTextView = (EditText)fragmentView.findViewById(R.id.bubble_input_text);
|
||||
if (isBroadcast) {
|
||||
|
@ -247,12 +250,12 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||
|
||||
@Override
|
||||
public void didUploadedPhoto(final TLRPC.InputFile file, final TLRPC.PhotoSize small, final TLRPC.PhotoSize big) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
uploadedAvatar = file;
|
||||
avatar = small.location;
|
||||
avatarImage.setImage(avatar, "50_50", R.drawable.group_blue);
|
||||
avatarImage.setImage(avatar, "50_50", avatarDrawable);
|
||||
if (createAfterUpload) {
|
||||
FileLog.e("tmessages", "avatar did uploaded");
|
||||
MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar, false);
|
||||
|
@ -311,7 +314,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
|||
}
|
||||
donePressed = false;
|
||||
} else if (id == NotificationCenter.chatDidCreated) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (progressDialog != null) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class IdenticonActivity extends BaseFragment {
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBarLayer.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
|
||||
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4));
|
||||
|
|
|
@ -50,7 +50,7 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBarLayer.setTitle(LocaleController.getString("Language", R.string.Language));
|
||||
|
||||
|
@ -264,7 +264,7 @@ public class LanguageSelectActivity extends BaseFragment {
|
|||
}
|
||||
|
||||
private void updateSearchResults(final ArrayList<LocaleController.LocaleInfo> arrCounties) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
searchResult = arrCounties;
|
||||
|
|
|
@ -235,6 +235,11 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||
}
|
||||
actionBarLayout.init(mainFragmentsStack);
|
||||
actionBarLayout.setDelegate(this);
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
actionBarLayout.setNeedStatusBar(true);
|
||||
actionBarLayout.setStatusBarColor(0xff54759e);
|
||||
}
|
||||
actionBarLayout.createDrawerLayout();
|
||||
|
||||
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
|
|
|
@ -27,7 +27,6 @@ import com.google.android.gms.maps.model.LatLng;
|
|||
import com.google.android.gms.maps.model.Marker;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.LocaleController;
|
||||
|
@ -39,6 +38,7 @@ import org.telegram.messenger.R;
|
|||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
if (messageObject != null) {
|
||||
actionBarLayer.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation));
|
||||
|
@ -226,19 +226,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
|
||||
if (messageObject != null) {
|
||||
int fromId = messageObject.messageOwner.from_id;
|
||||
if (messageObject.messageOwner instanceof TLRPC.TL_messageForwarded) {
|
||||
fromId = messageObject.messageOwner.fwd_from_id;
|
||||
}
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(fromId);
|
||||
if (user != null) {
|
||||
TLRPC.FileLocation photo = null;
|
||||
if (user.photo != null) {
|
||||
photo = user.photo.photo_small;
|
||||
}
|
||||
avatarImageView.setImage(photo, "50_50", AndroidUtilities.getUserAvatarForId(user.id));
|
||||
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||
}
|
||||
updateUserData();
|
||||
userLocation = new Location("network");
|
||||
userLocation.setLatitude(messageObject.messageOwner.media.geo.lat);
|
||||
userLocation.setLongitude(messageObject.messageOwner.media.geo._long);
|
||||
|
@ -285,7 +273,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
if (user.photo != null) {
|
||||
photo = user.photo.photo_small;
|
||||
}
|
||||
avatarImageView.setImage(photo, null, AndroidUtilities.getUserAvatarForId(user.id));
|
||||
avatarImageView.setImage(photo, null, new AvatarDrawable(user));
|
||||
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,6 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayUseLogoEnabled(true, R.drawable.ic_ab_logo);
|
||||
actionBarLayer.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||
|
||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||
|
|
|
@ -359,7 +359,7 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI
|
|||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(final TLObject response, final TLRPC.TL_error error) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
nextPressed = false;
|
||||
|
|
|
@ -139,7 +139,7 @@ public class LoginActivityRegisterView extends SlideView {
|
|||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(final TLObject response, final TLRPC.TL_error error) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
nextPressed = false;
|
||||
|
|
|
@ -186,7 +186,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
|||
double diff = currentTime - lastCodeTime;
|
||||
codeTime -= diff;
|
||||
lastCodeTime = currentTime;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (codeTime <= 1000) {
|
||||
|
@ -224,7 +224,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
|||
double diff = currentTime - lastCurrentTime;
|
||||
time -= diff;
|
||||
lastCurrentTime = currentTime;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (time >= 1000) {
|
||||
|
@ -242,7 +242,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
|||
@Override
|
||||
public void run(TLObject response, final TLRPC.TL_error error) {
|
||||
if (error != null && error.text != null) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
lastError = error.text;
|
||||
|
@ -291,7 +291,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
|||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(final TLObject response, final TLRPC.TL_error error) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (delegate == null) {
|
||||
|
@ -379,7 +379,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
|||
@Override
|
||||
public void didReceivedNotification(int id, final Object... args) {
|
||||
if (id == 998) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!waitingForSms) {
|
||||
|
|
|
@ -87,7 +87,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBarLayer.setTitle(LocaleController.getString("SharedMedia", R.string.SharedMedia));
|
||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||
|
@ -421,7 +421,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||
imageView.setImageBitmap(message.imagePreview);
|
||||
} else {
|
||||
TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, 80);
|
||||
imageView.setImage(photoSize.location, null, R.drawable.photo_placeholder_in);
|
||||
imageView.setImage(photoSize.location, null, mContext.getResources().getDrawable(R.drawable.photo_placeholder_in));
|
||||
}
|
||||
} else {
|
||||
imageView.setImageResource(R.drawable.photo_placeholder_in);
|
||||
|
@ -450,7 +450,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||
if (message.imagePreview != null) {
|
||||
imageView.setImageBitmap(message.imagePreview);
|
||||
} else {
|
||||
imageView.setImage(message.messageOwner.media.video.thumb.location, null, R.drawable.photo_placeholder_in);
|
||||
imageView.setImage(message.messageOwner.media.video.thumb.location, null, mContext.getResources().getDrawable(R.drawable.photo_placeholder_in));
|
||||
}
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
|
|
@ -10,16 +10,22 @@ package org.telegram.ui;
|
|||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -36,13 +42,15 @@ import org.telegram.messenger.UserConfig;
|
|||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Adapters.MessagesActivityAdapter;
|
||||
import org.telegram.ui.Adapters.MessagesActivitySearchAdapter;
|
||||
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.ui.AnimationCompat.ViewProxy;
|
||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||
import org.telegram.ui.Cells.DialogCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.SlidingTabView;
|
||||
import org.telegram.ui.Views.ActionBar.MenuDrawable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -53,7 +61,12 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
private TextView searchEmptyView;
|
||||
private View progressView;
|
||||
private View emptyView;
|
||||
private SlidingTabView searchPanelView;
|
||||
private ImageView floatingButton;
|
||||
private int prevPosition;
|
||||
private int prevTop;
|
||||
private boolean scrollUpdated;
|
||||
private boolean floatingHidden;
|
||||
private final AccelerateDecelerateInterpolator floatingInterpolator = new AccelerateDecelerateInterpolator();
|
||||
|
||||
private String selectAlertString;
|
||||
private String selectAlertStringGroup;
|
||||
|
@ -69,9 +82,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
|
||||
private long openedDialogId = 0;
|
||||
|
||||
private final static int messages_list_menu_new_messages = 1;
|
||||
private final static int messages_list_menu_other = 1;
|
||||
private final static int messages_list_menu_new_chat = 2;
|
||||
private final static int messages_list_menu_other = 6;
|
||||
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;
|
||||
|
@ -131,9 +143,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
searching = true;
|
||||
if (messagesListView != null) {
|
||||
messagesListView.setEmptyView(searchEmptyView);
|
||||
searchPanelView.setVisibility(View.VISIBLE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
progressView.setVisibility(View.GONE);
|
||||
if (!onlySelect) {
|
||||
floatingButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,14 +157,21 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
searchWas = false;
|
||||
if (messagesListView != null) {
|
||||
messagesListView.setEmptyView(emptyView);
|
||||
searchPanelView.setVisibility(View.GONE);
|
||||
searchEmptyView.setVisibility(View.GONE);
|
||||
progressView.setVisibility(View.GONE);
|
||||
messagesListView.setAdapter(messagesActivityAdapter);
|
||||
messagesActivityAdapter.notifyDataSetChanged();
|
||||
if (!onlySelect) {
|
||||
floatingButton.setVisibility(View.VISIBLE);
|
||||
floatingHidden = true;
|
||||
ViewProxy.setTranslationY(floatingButton, AndroidUtilities.dp(100));
|
||||
hideFloatingButton(false);
|
||||
}
|
||||
if (messagesListView.getAdapter() != messagesActivityAdapter) {
|
||||
messagesListView.setAdapter(messagesActivityAdapter);
|
||||
messagesActivityAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
if (messagesActivitySearchAdapter != null) {
|
||||
messagesActivitySearchAdapter.searchDialogs(null, 0);
|
||||
messagesActivitySearchAdapter.searchDialogs(null, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,21 +191,16 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
}
|
||||
if (messagesActivitySearchAdapter != null) {
|
||||
if (searchPanelView.getSeletedTab() == 0) {
|
||||
messagesActivitySearchAdapter.searchDialogs(text, serverOnly ? 1 : 0);
|
||||
} else {
|
||||
messagesActivitySearchAdapter.searchDialogs(text, 2);
|
||||
}
|
||||
messagesActivitySearchAdapter.searchDialogs(text, serverOnly);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (onlySelect) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
|
||||
} else {
|
||||
actionBarLayer.setDisplayUseLogoEnabled(true, R.drawable.ic_ab_logo);
|
||||
actionBarLayer.setBackButtonDrawable(new MenuDrawable());
|
||||
actionBarLayer.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||
menu.addItem(messages_list_menu_new_messages, R.drawable.ic_ab_compose);
|
||||
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);
|
||||
|
@ -201,12 +217,6 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
presentFragment(new SettingsActivity());
|
||||
} else if (id == messages_list_menu_contacts) {
|
||||
presentFragment(new ContactsActivity(null));
|
||||
} else if (id == messages_list_menu_new_messages) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("onlyUsers", true);
|
||||
args.putBoolean("destroyAfterSelect", true);
|
||||
args.putBoolean("usersAsSections", true);
|
||||
presentFragment(new ContactsActivity(args));
|
||||
} else if (id == messages_list_menu_new_secret_chat) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("onlyUsers", true);
|
||||
|
@ -245,22 +255,6 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
}
|
||||
});
|
||||
searchPanelView = (SlidingTabView)fragmentView.findViewById(R.id.searchPanelView);
|
||||
searchPanelView.addTextTab(0, LocaleController.getString("SearchConversations", R.string.SearchConversations));
|
||||
searchPanelView.addTextTab(1, LocaleController.getString("SearchMessages", R.string.SearchMessages));
|
||||
searchPanelView.setDelegate(new SlidingTabView.SlidingTabViewDelegate() {
|
||||
@Override
|
||||
public void didSelectTab(int tab) {
|
||||
if (searching && searchWas) {
|
||||
if (tab == 0) {
|
||||
messagesActivitySearchAdapter.searchDialogs(messagesActivitySearchAdapter.getLastSearchText(), serverOnly ? 1 : 0);
|
||||
} else {
|
||||
messagesActivitySearchAdapter.searchDialogs(messagesActivitySearchAdapter.getLastSearchText(), 2);
|
||||
}
|
||||
messagesActivitySearchAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
messagesListView = (ListView)fragmentView.findViewById(R.id.messages_list_view);
|
||||
messagesListView.setAdapter(messagesActivityAdapter);
|
||||
|
@ -290,6 +284,23 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text2);
|
||||
textView.setText(LocaleController.getString("NoChats", R.string.NoChatsHelp));
|
||||
|
||||
floatingButton = (ImageView)fragmentView.findViewById(R.id.floating_button);
|
||||
floatingButton.setVisibility(onlySelect ? View.GONE : View.VISIBLE);
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)floatingButton.getLayoutParams();
|
||||
layoutParams.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(14) : 0;
|
||||
layoutParams.rightMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(14);
|
||||
layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM;
|
||||
floatingButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("onlyUsers", true);
|
||||
args.putBoolean("destroyAfterSelect", true);
|
||||
args.putBoolean("usersAsSections", true);
|
||||
presentFragment(new ContactsActivity(args));
|
||||
}
|
||||
});
|
||||
|
||||
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
|
||||
searchEmptyView.setVisibility(View.GONE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
|
@ -483,6 +494,29 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
MessagesController.getInstance().loadDialogs(MessagesController.getInstance().dialogs.size(), MessagesController.getInstance().dialogsServerOnly.size(), 100, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (floatingButton.getVisibility() != View.GONE) {
|
||||
final View topChild = absListView.getChildAt(0);
|
||||
int firstViewTop = 0;
|
||||
if (topChild != null) {
|
||||
firstViewTop = topChild.getTop();
|
||||
}
|
||||
boolean goingDown;
|
||||
boolean changed = true;
|
||||
if (prevPosition == firstVisibleItem) {
|
||||
final int topDelta = prevTop - firstViewTop;
|
||||
goingDown = firstViewTop < prevTop;
|
||||
changed = Math.abs(topDelta) > 1;
|
||||
} else {
|
||||
goingDown = firstVisibleItem > prevPosition;
|
||||
}
|
||||
if (changed && scrollUpdated) {
|
||||
hideFloatingButton(goingDown);
|
||||
}
|
||||
prevPosition = firstVisibleItem;
|
||||
prevTop = firstViewTop;
|
||||
scrollUpdated = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -506,6 +540,26 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
if (!onlySelect && floatingButton != null) {
|
||||
floatingButton.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
ViewProxy.setTranslationY(floatingButton, floatingHidden ? AndroidUtilities.dp(100) : 0);
|
||||
if (floatingButton != null) {
|
||||
if (Build.VERSION.SDK_INT < 16) {
|
||||
floatingButton.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
} else {
|
||||
floatingButton.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
|
@ -560,6 +614,16 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
}
|
||||
|
||||
private void hideFloatingButton(boolean hide) {
|
||||
if (floatingHidden == hide) {
|
||||
return;
|
||||
}
|
||||
floatingHidden = hide;
|
||||
ObjectAnimatorProxy animator = ObjectAnimatorProxy.ofFloatProxy(floatingButton, "translationY", floatingHidden ? AndroidUtilities.dp(100) : 0).setDuration(300);
|
||||
animator.setInterpolator(floatingInterpolator);
|
||||
animator.start();
|
||||
}
|
||||
|
||||
private void updateVisibleRows(int mask) {
|
||||
if (messagesListView == null) {
|
||||
return;
|
||||
|
|
|
@ -86,8 +86,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
|||
if (fragmentView == null) {
|
||||
actionBarLayer.setBackgroundColor(0xff333333);
|
||||
actionBarLayer.setItemsBackground(R.drawable.bar_selector_picker);
|
||||
actionBarLayer.setDisplayUseLogoEnabled(true, R.drawable.gallery);
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.photo_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setTitle(LocaleController.getString("Gallery", R.string.Gallery));
|
||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
|
@ -115,7 +114,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
|||
});
|
||||
|
||||
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||
menu.addItem(1, R.drawable.ic_ab_other_white2);
|
||||
menu.addItem(1, R.drawable.ic_ab_other);
|
||||
|
||||
fragmentView = inflater.inflate(R.layout.photo_picker_layout, container, false);
|
||||
|
||||
|
@ -515,7 +514,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
|||
MediaController.AlbumEntry albumEntry = albumsSorted.get(i);
|
||||
BackupImageView imageView = (BackupImageView)view.findViewById(R.id.media_photo_image);
|
||||
if (albumEntry.coverPhoto != null && albumEntry.coverPhoto.path != null) {
|
||||
imageView.setImage("thumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, R.drawable.nophotos);
|
||||
imageView.setImage("thumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, mContext.getResources().getDrawable(R.drawable.nophotos));
|
||||
} else {
|
||||
imageView.setImageResource(R.drawable.nophotos);
|
||||
}
|
||||
|
@ -557,7 +556,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
|||
imageView.setTag(i);
|
||||
view.setTag(i);
|
||||
if (photoEntry.path != null) {
|
||||
imageView.setImage("thumb://" + photoEntry.imageId + ":" + photoEntry.path, null, R.drawable.nophotos);
|
||||
imageView.setImage("thumb://" + photoEntry.imageId + ":" + photoEntry.path, null, mContext.getResources().getDrawable(R.drawable.nophotos));
|
||||
} else {
|
||||
imageView.setImageResource(R.drawable.nophotos);
|
||||
}
|
||||
|
|
|
@ -8,10 +8,6 @@
|
|||
|
||||
package org.telegram.ui;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
@ -63,6 +59,10 @@ import org.telegram.messenger.TLRPC;
|
|||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.ui.AnimationCompat.ViewProxy;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
|
@ -610,7 +610,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
actionBar.setLayoutParams(layoutParams);
|
||||
actionBarLayer = actionBar.createLayer();
|
||||
actionBarLayer.setItemsBackground(R.drawable.bar_selector_white);
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.photo_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1));
|
||||
actionBar.setCurrentActionBarLayer(actionBarLayer);
|
||||
|
||||
|
@ -693,7 +693,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
});
|
||||
|
||||
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||
menuItem = menu.addItem(0, R.drawable.ic_ab_other_white);
|
||||
menuItem = menu.addItem(0, R.drawable.ic_ab_other);
|
||||
menuItem.addSubItem(gallery_menu_save, LocaleController.getString("SaveToGallery", R.string.SaveToGallery), 0);
|
||||
menuItem.addSubItem(gallery_menu_showall, LocaleController.getString("ShowAllMedia", R.string.ShowAllMedia), 0);
|
||||
|
||||
|
@ -955,38 +955,30 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
actionBar.setEnabled(show);
|
||||
actionBarLayer.setEnabled(show);
|
||||
bottomLayout.setEnabled(show);
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
if (animated) {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimator.ofFloat(actionBar, "alpha", show ? 1.0f : 0.0f),
|
||||
ObjectAnimator.ofFloat(bottomLayout, "alpha", show ? 1.0f : 0.0f)
|
||||
);
|
||||
if (!show) {
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
actionBar.setVisibility(View.GONE);
|
||||
if (canShowBottom) {
|
||||
bottomLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
animatorSet.setDuration(250);
|
||||
animatorSet.start();
|
||||
} else {
|
||||
actionBar.setAlpha(show ? 1.0f : 0.0f);
|
||||
bottomLayout.setAlpha(show ? 1.0f : 0.0f);
|
||||
if (!show) {
|
||||
actionBar.setVisibility(View.GONE);
|
||||
if (canShowBottom) {
|
||||
bottomLayout.setVisibility(View.GONE);
|
||||
if (animated) {
|
||||
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimatorProxy.ofFloat(actionBar, "alpha", show ? 1.0f : 0.0f),
|
||||
ObjectAnimatorProxy.ofFloat(bottomLayout, "alpha", show ? 1.0f : 0.0f)
|
||||
);
|
||||
if (!show) {
|
||||
animatorSet.addListener(new AnimatorListenerAdapterProxy() {
|
||||
@Override
|
||||
public void onAnimationEnd(Object animation) {
|
||||
actionBar.setVisibility(View.GONE);
|
||||
if (canShowBottom) {
|
||||
bottomLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
animatorSet.setDuration(200);
|
||||
animatorSet.start();
|
||||
} else {
|
||||
ViewProxy.setAlpha(actionBar, show ? 1.0f : 0.0f);
|
||||
ViewProxy.setAlpha(bottomLayout, show ? 1.0f : 0.0f);
|
||||
if (!show) {
|
||||
actionBar.setVisibility(View.GONE);
|
||||
if (canShowBottom) {
|
||||
|
@ -1340,7 +1332,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
}
|
||||
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11 && currentPlaceObject != null) {
|
||||
if (currentPlaceObject != null) {
|
||||
if (animationInProgress == 0) {
|
||||
currentPlaceObject.imageReceiver.setVisible(true, true);
|
||||
} else {
|
||||
|
@ -1348,7 +1340,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
}
|
||||
}
|
||||
currentPlaceObject = placeProvider.getPlaceForPhoto(currentMessageObject, currentFileLocation, currentIndex);
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11 && currentPlaceObject != null) {
|
||||
if (currentPlaceObject != null) {
|
||||
if (animationInProgress == 0) {
|
||||
currentPlaceObject.imageReceiver.setVisible(false, true);
|
||||
} else {
|
||||
|
@ -1518,15 +1510,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
}
|
||||
|
||||
public boolean isShowingImage(MessageObject object) {
|
||||
return android.os.Build.VERSION.SDK_INT >= 11 && isVisible && !disableShowCheck && object != null && currentMessageObject != null && currentMessageObject.messageOwner.id == object.messageOwner.id;
|
||||
return isVisible && !disableShowCheck && object != null && currentMessageObject != null && currentMessageObject.messageOwner.id == object.messageOwner.id;
|
||||
}
|
||||
|
||||
public boolean isShowingImage(TLRPC.FileLocation object) {
|
||||
return android.os.Build.VERSION.SDK_INT >= 11 && isVisible && !disableShowCheck && object != null && currentFileLocation != null && object.local_id == currentFileLocation.local_id && object.volume_id == currentFileLocation.volume_id && object.dc_id == currentFileLocation.dc_id;
|
||||
return isVisible && !disableShowCheck && object != null && currentFileLocation != null && object.local_id == currentFileLocation.local_id && object.volume_id == currentFileLocation.volume_id && object.dc_id == currentFileLocation.dc_id;
|
||||
}
|
||||
|
||||
public boolean isShowingImage(String object) {
|
||||
return android.os.Build.VERSION.SDK_INT >= 11 && isVisible && !disableShowCheck && object != null && currentPathObject != null && object.equals(currentPathObject);
|
||||
return isVisible && !disableShowCheck && object != null && currentPathObject != null && object.equals(currentPathObject);
|
||||
}
|
||||
|
||||
public void openPhoto(final MessageObject messageObject, final PhotoViewerProvider provider) {
|
||||
|
@ -1599,132 +1591,112 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
backgroundDrawable.setAlpha(255);
|
||||
toggleActionBar(true, false);
|
||||
|
||||
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
AndroidUtilities.lockOrientation(parentActivity);
|
||||
AndroidUtilities.lockOrientation(parentActivity);
|
||||
|
||||
final Rect drawRegion = object.imageReceiver.getDrawRegion();
|
||||
final Rect drawRegion = object.imageReceiver.getDrawRegion();
|
||||
|
||||
animatingImageView.setVisibility(View.VISIBLE);
|
||||
animatingImageView.setImageBitmap(object.thumb);
|
||||
animatingImageView.setVisibility(View.VISIBLE);
|
||||
animatingImageView.setImageBitmap(object.thumb);
|
||||
|
||||
animatingImageView.setAlpha(1.0f);
|
||||
animatingImageView.setPivotX(0);
|
||||
animatingImageView.setPivotY(0);
|
||||
animatingImageView.setScaleX(1);
|
||||
animatingImageView.setScaleY(1);
|
||||
animatingImageView.setTranslationX(object.viewX + drawRegion.left);
|
||||
animatingImageView.setTranslationY(object.viewY + drawRegion.top);
|
||||
final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams();
|
||||
layoutParams.width = drawRegion.right - drawRegion.left;
|
||||
layoutParams.height = drawRegion.bottom - drawRegion.top;
|
||||
animatingImageView.setLayoutParams(layoutParams);
|
||||
ViewProxy.setAlpha(animatingImageView, 1.0f);
|
||||
ViewProxy.setPivotX(animatingImageView, 0.0f);
|
||||
ViewProxy.setPivotY(animatingImageView, 0.0f);
|
||||
ViewProxy.setScaleX(animatingImageView, 1.0f);
|
||||
ViewProxy.setScaleY(animatingImageView, 1.0f);
|
||||
ViewProxy.setTranslationX(animatingImageView, object.viewX + drawRegion.left);
|
||||
ViewProxy.setTranslationY(animatingImageView, object.viewY + drawRegion.top);
|
||||
final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams();
|
||||
layoutParams.width = drawRegion.right - drawRegion.left;
|
||||
layoutParams.height = drawRegion.bottom - drawRegion.top;
|
||||
animatingImageView.setLayoutParams(layoutParams);
|
||||
|
||||
containerView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
containerView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
containerView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
containerView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
|
||||
float scaleX = (float) AndroidUtilities.displaySize.x / layoutParams.width;
|
||||
float scaleY = (float) (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight) / layoutParams.height;
|
||||
float scale = scaleX > scaleY ? scaleY : scaleX;
|
||||
float width = layoutParams.width * scale;
|
||||
float height = layoutParams.height * scale;
|
||||
float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f;
|
||||
float yPos = (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight - height) / 2.0f;
|
||||
int clipHorizontal = Math.abs(drawRegion.left - object.imageReceiver.getImageX());
|
||||
int clipVertical = Math.abs(drawRegion.top - object.imageReceiver.getImageY());
|
||||
float scaleX = (float) AndroidUtilities.displaySize.x / layoutParams.width;
|
||||
float scaleY = (float) (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight) / layoutParams.height;
|
||||
float scale = scaleX > scaleY ? scaleY : scaleX;
|
||||
float width = layoutParams.width * scale;
|
||||
float height = layoutParams.height * scale;
|
||||
float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f;
|
||||
float yPos = (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight - height) / 2.0f;
|
||||
int clipHorizontal = Math.abs(drawRegion.left - object.imageReceiver.getImageX());
|
||||
int clipVertical = Math.abs(drawRegion.top - object.imageReceiver.getImageY());
|
||||
|
||||
int coords2[] = new int[2];
|
||||
object.parentView.getLocationInWindow(coords2);
|
||||
int clipTop = coords2[1] - AndroidUtilities.statusBarHeight - (object.viewY + drawRegion.top);
|
||||
if (clipTop < 0) {
|
||||
clipTop = 0;
|
||||
}
|
||||
int clipBottom = (object.viewY + drawRegion.top + layoutParams.height) - (coords2[1] + object.parentView.getHeight() - AndroidUtilities.statusBarHeight);
|
||||
if (clipBottom < 0) {
|
||||
clipBottom = 0;
|
||||
}
|
||||
clipTop = Math.max(clipTop, clipVertical);
|
||||
clipBottom = Math.max(clipBottom, clipVertical);
|
||||
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimator.ofFloat(animatingImageView, "scaleX", scale),
|
||||
ObjectAnimator.ofFloat(animatingImageView, "scaleY", scale),
|
||||
ObjectAnimator.ofFloat(animatingImageView, "translationX", xPos),
|
||||
ObjectAnimator.ofFloat(animatingImageView, "translationY", yPos),
|
||||
ObjectAnimator.ofInt(backgroundDrawable, "alpha", 0, 255),
|
||||
ObjectAnimator.ofInt(animatingImageView, "clipHorizontal", clipHorizontal, 0),
|
||||
ObjectAnimator.ofInt(animatingImageView, "clipTop", clipTop, 0),
|
||||
ObjectAnimator.ofInt(animatingImageView, "clipBottom", clipBottom, 0),
|
||||
ObjectAnimator.ofFloat(containerView, "alpha", 0.0f, 1.0f)
|
||||
);
|
||||
|
||||
animationEndRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
animationInProgress = 0;
|
||||
transitionAnimationStartTime = 0;
|
||||
containerView.invalidate();
|
||||
animatingImageView.setVisibility(View.GONE);
|
||||
AndroidUtilities.unlockOrientation(parentActivity);
|
||||
if (showAfterAnimation != null) {
|
||||
showAfterAnimation.imageReceiver.setVisible(true, true);
|
||||
}
|
||||
if (hideAfterAnimation != null) {
|
||||
hideAfterAnimation.imageReceiver.setVisible(false, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
animatorSet.setDuration(250);
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (animationEndRunnable != null) {
|
||||
animationEndRunnable.run();
|
||||
animationEndRunnable = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
onAnimationEnd(animation);
|
||||
}
|
||||
});
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
animatorSet.start();
|
||||
|
||||
animatingImageView.setOnDrawListener(new ClippingImageView.onDrawListener() {
|
||||
@Override
|
||||
public void onDraw() {
|
||||
disableShowCheck = false;
|
||||
animatingImageView.setOnDrawListener(null);
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
object.imageReceiver.setVisible(false, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
int coords2[] = new int[2];
|
||||
object.parentView.getLocationInWindow(coords2);
|
||||
int clipTop = coords2[1] - AndroidUtilities.statusBarHeight - (object.viewY + drawRegion.top);
|
||||
if (clipTop < 0) {
|
||||
clipTop = 0;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
animationInProgress = 0;
|
||||
transitionAnimationStartTime = 0;
|
||||
containerView.invalidate();
|
||||
AnimationSet animationSet = new AnimationSet(true);
|
||||
AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
|
||||
animation.setDuration(150);
|
||||
animation.setFillAfter(false);
|
||||
animationSet.addAnimation(animation);
|
||||
ScaleAnimation scaleAnimation = new ScaleAnimation(0.9f, 1.0f, 0.9f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
scaleAnimation.setDuration(150);
|
||||
scaleAnimation.setFillAfter(false);
|
||||
animationSet.addAnimation(scaleAnimation);
|
||||
animationSet.setDuration(150);
|
||||
containerView.startAnimation(animationSet);
|
||||
disableShowCheck = false;
|
||||
}
|
||||
int clipBottom = (object.viewY + drawRegion.top + layoutParams.height) - (coords2[1] + object.parentView.getHeight() - AndroidUtilities.statusBarHeight);
|
||||
if (clipBottom < 0) {
|
||||
clipBottom = 0;
|
||||
}
|
||||
clipTop = Math.max(clipTop, clipVertical);
|
||||
clipBottom = Math.max(clipBottom, clipVertical);
|
||||
|
||||
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimatorProxy.ofFloat(animatingImageView, "scaleX", scale),
|
||||
ObjectAnimatorProxy.ofFloat(animatingImageView, "scaleY", scale),
|
||||
ObjectAnimatorProxy.ofFloat(animatingImageView, "translationX", xPos),
|
||||
ObjectAnimatorProxy.ofFloat(animatingImageView, "translationY", yPos),
|
||||
ObjectAnimatorProxy.ofInt(backgroundDrawable, "alpha", 0, 255),
|
||||
ObjectAnimatorProxy.ofInt(animatingImageView, "clipHorizontal", clipHorizontal, 0),
|
||||
ObjectAnimatorProxy.ofInt(animatingImageView, "clipTop", clipTop, 0),
|
||||
ObjectAnimatorProxy.ofInt(animatingImageView, "clipBottom", clipBottom, 0),
|
||||
ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f)
|
||||
);
|
||||
|
||||
animationEndRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
animationInProgress = 0;
|
||||
transitionAnimationStartTime = 0;
|
||||
containerView.invalidate();
|
||||
animatingImageView.setVisibility(View.GONE);
|
||||
AndroidUtilities.unlockOrientation(parentActivity);
|
||||
if (showAfterAnimation != null) {
|
||||
showAfterAnimation.imageReceiver.setVisible(true, true);
|
||||
}
|
||||
if (hideAfterAnimation != null) {
|
||||
hideAfterAnimation.imageReceiver.setVisible(false, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
animatorSet.setDuration(200);
|
||||
animatorSet.addListener(new AnimatorListenerAdapterProxy() {
|
||||
@Override
|
||||
public void onAnimationEnd(Object animation) {
|
||||
if (animationEndRunnable != null) {
|
||||
animationEndRunnable.run();
|
||||
animationEndRunnable = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Object animation) {
|
||||
onAnimationEnd(animation);
|
||||
}
|
||||
});
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
animatorSet.start();
|
||||
|
||||
animatingImageView.setOnDrawListener(new ClippingImageView.onDrawListener() {
|
||||
@Override
|
||||
public void onDraw() {
|
||||
disableShowCheck = false;
|
||||
animatingImageView.setOnDrawListener(null);
|
||||
object.imageReceiver.setVisible(false, true);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void closePhoto(boolean animated) {
|
||||
|
@ -1751,14 +1723,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
|
||||
final PlaceProviderObject object = placeProvider.getPlaceForPhoto(currentMessageObject, currentFileLocation, currentIndex);
|
||||
|
||||
if(android.os.Build.VERSION.SDK_INT >= 11 && animated) {
|
||||
if(animated) {
|
||||
AndroidUtilities.lockOrientation(parentActivity);
|
||||
|
||||
animationInProgress = 1;
|
||||
int visibility = animatingImageView.getVisibility();
|
||||
animatingImageView.setVisibility(View.VISIBLE);
|
||||
containerView.invalidate();
|
||||
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
|
||||
|
||||
final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams();
|
||||
Rect drawRegion = null;
|
||||
|
@ -1781,15 +1754,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
float height = layoutParams.height * scale * scale2;
|
||||
float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f;
|
||||
float yPos = (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight - height) / 2.0f;
|
||||
animatingImageView.setTranslationX(xPos + translationX);
|
||||
animatingImageView.setTranslationY(yPos + translationY);
|
||||
animatingImageView.setScaleX(scale * scale2);
|
||||
animatingImageView.setScaleY(scale * scale2);
|
||||
ViewProxy.setTranslationX(animatingImageView, xPos + translationX);
|
||||
ViewProxy.setTranslationY(animatingImageView, yPos + translationY);
|
||||
ViewProxy.setScaleX(animatingImageView, scale * scale2);
|
||||
ViewProxy.setScaleY(animatingImageView, scale * scale2);
|
||||
|
||||
if (object != null) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
object.imageReceiver.setVisible(false, true);
|
||||
}
|
||||
object.imageReceiver.setVisible(false, true);
|
||||
int clipHorizontal = Math.abs(drawRegion.left - object.imageReceiver.getImageX());
|
||||
int clipVertical = Math.abs(drawRegion.top - object.imageReceiver.getImageY());
|
||||
|
||||
|
@ -1808,22 +1779,22 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
clipBottom = Math.max(clipBottom, clipVertical);
|
||||
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimator.ofFloat(animatingImageView, "scaleX", 1),
|
||||
ObjectAnimator.ofFloat(animatingImageView, "scaleY", 1),
|
||||
ObjectAnimator.ofFloat(animatingImageView, "translationX", object.viewX + drawRegion.left),
|
||||
ObjectAnimator.ofFloat(animatingImageView, "translationY", object.viewY + drawRegion.top),
|
||||
ObjectAnimator.ofInt(backgroundDrawable, "alpha", 0),
|
||||
ObjectAnimator.ofInt(animatingImageView, "clipHorizontal", clipHorizontal),
|
||||
ObjectAnimator.ofInt(animatingImageView, "clipTop", clipTop),
|
||||
ObjectAnimator.ofInt(animatingImageView, "clipBottom", clipBottom),
|
||||
ObjectAnimator.ofFloat(containerView, "alpha", 0.0f)
|
||||
ObjectAnimatorProxy.ofFloat(animatingImageView, "scaleX", 1),
|
||||
ObjectAnimatorProxy.ofFloat(animatingImageView, "scaleY", 1),
|
||||
ObjectAnimatorProxy.ofFloat(animatingImageView, "translationX", object.viewX + drawRegion.left),
|
||||
ObjectAnimatorProxy.ofFloat(animatingImageView, "translationY", object.viewY + drawRegion.top),
|
||||
ObjectAnimatorProxy.ofInt(backgroundDrawable, "alpha", 0),
|
||||
ObjectAnimatorProxy.ofInt(animatingImageView, "clipHorizontal", clipHorizontal),
|
||||
ObjectAnimatorProxy.ofInt(animatingImageView, "clipTop", clipTop),
|
||||
ObjectAnimatorProxy.ofInt(animatingImageView, "clipBottom", clipBottom),
|
||||
ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f)
|
||||
);
|
||||
} else {
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimator.ofInt(backgroundDrawable, "alpha", 0),
|
||||
ObjectAnimator.ofFloat(animatingImageView, "alpha", 0.0f),
|
||||
ObjectAnimator.ofFloat(animatingImageView, "translationY", translationY >= 0 ? AndroidUtilities.displaySize.y : -AndroidUtilities.displaySize.y),
|
||||
ObjectAnimator.ofFloat(containerView, "alpha", 0.0f)
|
||||
ObjectAnimatorProxy.ofInt(backgroundDrawable, "alpha", 0),
|
||||
ObjectAnimatorProxy.ofFloat(animatingImageView, "alpha", 0.0f),
|
||||
ObjectAnimatorProxy.ofFloat(animatingImageView, "translationY", translationY >= 0 ? AndroidUtilities.displaySize.y : -AndroidUtilities.displaySize.y),
|
||||
ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1836,10 +1807,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
}
|
||||
};
|
||||
|
||||
animatorSet.setDuration(250);
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() {
|
||||
animatorSet.setDuration(200);
|
||||
animatorSet.addListener(new AnimatorListenerAdapterProxy() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
public void onAnimationEnd(Object animation) {
|
||||
if (animationEndRunnable != null) {
|
||||
animationEndRunnable.run();
|
||||
animationEndRunnable = null;
|
||||
|
@ -1847,7 +1818,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
public void onAnimationCancel(Object animation) {
|
||||
onAnimationEnd(animation);
|
||||
}
|
||||
});
|
||||
|
@ -1929,7 +1900,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
centerImage.setImageBitmap((Bitmap)null);
|
||||
leftImage.setImageBitmap((Bitmap)null);
|
||||
rightImage.setImageBitmap((Bitmap)null);
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11 && object != null) {
|
||||
if (object != null) {
|
||||
object.imageReceiver.setVisible(true, true);
|
||||
}
|
||||
containerView.post(new Runnable() {
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.telegram.android.PhotoObject;
|
|||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ChatActivityEnterView;
|
||||
import org.telegram.ui.Views.FrameLayoutFixed;
|
||||
|
@ -188,7 +189,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
|||
actionBar.setLayoutParams(layoutParams);
|
||||
|
||||
actionBarLayer = actionBar.createLayer();
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackgroundResource(R.color.header);
|
||||
actionBarLayer.setItemsBackground(R.drawable.bar_selector);
|
||||
actionBar.setCurrentActionBarLayer(actionBarLayer);
|
||||
|
@ -625,11 +626,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
|||
messageContainer.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
if (!checkTransitionAnimation() && !startedMoving) {
|
||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)messageContainer.getLayoutParams();
|
||||
if (!AndroidUtilities.isTablet() && PopupNotificationActivity.this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
layoutParams.topMargin = AndroidUtilities.dp(40);
|
||||
} else {
|
||||
layoutParams.topMargin = AndroidUtilities.dp(48);
|
||||
}
|
||||
layoutParams.topMargin = AndroidUtilities.getCurrentActionBarHeight();
|
||||
layoutParams.bottomMargin = AndroidUtilities.dp(48);
|
||||
layoutParams.width = ViewGroup.MarginLayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = ViewGroup.MarginLayoutParams.MATCH_PARENT;
|
||||
|
@ -791,7 +788,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
|||
|
||||
private void checkAndUpdateAvatar() {
|
||||
TLRPC.FileLocation newPhoto = null;
|
||||
int placeHolderId = 0;
|
||||
AvatarDrawable avatarDrawable = null;
|
||||
if (currentChat != null) {
|
||||
TLRPC.Chat chat = MessagesController.getInstance().getChat(currentChat.id);
|
||||
if (chat == null) {
|
||||
|
@ -801,7 +798,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
|||
if (currentChat.photo != null) {
|
||||
newPhoto = currentChat.photo.photo_small;
|
||||
}
|
||||
placeHolderId = AndroidUtilities.getGroupAvatarForId(currentChat.id);
|
||||
avatarDrawable = new AvatarDrawable(currentChat);
|
||||
} else if (currentUser != null) {
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(currentUser.id);
|
||||
if (user == null) {
|
||||
|
@ -811,10 +808,10 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
|||
if (currentUser.photo != null) {
|
||||
newPhoto = currentUser.photo.photo_small;
|
||||
}
|
||||
placeHolderId = AndroidUtilities.getUserAvatarForId(currentUser.id);
|
||||
avatarDrawable = new AvatarDrawable(currentUser);
|
||||
}
|
||||
if (avatarImageView != null) {
|
||||
avatarImageView.setImage(newPhoto, "50_50", placeHolderId);
|
||||
avatarImageView.setImage(newPhoto, "50_50", avatarDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
|
||||
actionBarLayer.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
|
||||
|
|
|
@ -314,7 +314,7 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
|||
currentMessageObject = null;
|
||||
isVisible = false;
|
||||
AndroidUtilities.unlockOrientation(parentActivity);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
centerImage.setImageBitmap((Bitmap)null);
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.telegram.messenger.UserConfig;
|
|||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.AvatarUpdater;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
|
@ -162,7 +163,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
||||
users.add(user);
|
||||
MessagesStorage.getInstance().putUsersAndChats(users, null, false, true);
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_ALL);
|
||||
|
@ -227,7 +228,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBarLayer.setTitle(LocaleController.getString("Settings", R.string.Settings));
|
||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||
|
@ -338,7 +339,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(final TLObject response, final TLRPC.TL_error error) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (getParentActivity() == null) {
|
||||
|
@ -593,7 +594,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
if (error == null) {
|
||||
|
||||
final TLRPC.TL_help_support res = (TLRPC.TL_help_support)response;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
|
@ -617,7 +618,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
});
|
||||
} else {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
@ -826,7 +827,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
photo = user.photo.photo_small;
|
||||
photoBig = user.photo.photo_big;
|
||||
}
|
||||
avatarImage.setImage(photo, "50_50", AndroidUtilities.getUserAvatarForId(user.id));
|
||||
avatarImage.setImage(photo, "50_50", new AvatarDrawable(user));
|
||||
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
||||
}
|
||||
return view;
|
||||
|
|
|
@ -60,7 +60,7 @@ public class SettingsBlockedUsersActivity extends BaseFragment implements Notifi
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBarLayer.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers));
|
||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||
|
|
|
@ -222,7 +222,7 @@ public class SettingsChangeUsernameActivity extends BaseFragment {
|
|||
return true;
|
||||
}
|
||||
if (checkRunnable != null) {
|
||||
AndroidUtilities.CancelRunOnUIThread(checkRunnable);
|
||||
AndroidUtilities.cancelRunOnUIThread(checkRunnable);
|
||||
checkRunnable = null;
|
||||
lastCheckName = null;
|
||||
if (checkReqId != 0) {
|
||||
|
@ -294,7 +294,7 @@ public class SettingsChangeUsernameActivity extends BaseFragment {
|
|||
checkReqId = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(final TLObject response, final TLRPC.TL_error error) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkReqId = 0;
|
||||
|
@ -315,7 +315,7 @@ public class SettingsChangeUsernameActivity extends BaseFragment {
|
|||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
||||
}
|
||||
};
|
||||
AndroidUtilities.RunOnUIThread(checkRunnable, 300);
|
||||
AndroidUtilities.runOnUIThread(checkRunnable, 300);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ public class SettingsChangeUsernameActivity extends BaseFragment {
|
|||
public void run(TLObject response, final TLRPC.TL_error error) {
|
||||
if (error == null) {
|
||||
final TLRPC.User user = (TLRPC.User)response;
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
@ -369,7 +369,7 @@ public class SettingsChangeUsernameActivity extends BaseFragment {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
|
|
@ -119,7 +119,7 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBarLayer.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
|
||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||
|
@ -214,7 +214,7 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
|
|||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesController.getInstance().enableJoined = true;
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
|
@ -366,7 +367,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||
progressBar.setProgress((int)(progress * 100));
|
||||
}
|
||||
} else if (id == NotificationCenter.wallpapersDidLoaded) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
wallPapers = (ArrayList<TLRPC.WallPaper>)args[0];
|
||||
|
@ -400,7 +401,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||
if (error != null) {
|
||||
return;
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
wallPapers.clear();
|
||||
|
@ -534,7 +535,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||
TLRPC.WallPaper wallPaper = wallPapers.get(i - 1);
|
||||
TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes, AndroidUtilities.dp(100));
|
||||
if (size != null && size.location != null) {
|
||||
image.setImage(size.location, "100_100", 0);
|
||||
image.setImage(size.location, "100_100", (Drawable)null);
|
||||
}
|
||||
if (wallPaper.id == selectedBackground) {
|
||||
selection.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
|||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Views.AvatarDrawable;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.IdenticonView;
|
||||
|
@ -141,7 +142,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
if (dialog_id != 0) {
|
||||
actionBarLayer.setTitle(LocaleController.getString("SecretTitle", R.string.SecretTitle));
|
||||
|
@ -311,11 +312,11 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||
}
|
||||
} else if (id == NotificationCenter.encryptedChatCreated) {
|
||||
if (creatingChat) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
||||
TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat)args[0];
|
||||
TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat) args[0];
|
||||
Bundle args2 = new Bundle();
|
||||
args2.putInt("enc_id", encryptedChat.id);
|
||||
presentFragment(new ChatActivity(args2), true);
|
||||
|
@ -535,7 +536,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||
photo = user.photo.photo_small;
|
||||
photoBig = user.photo.photo_big;
|
||||
}
|
||||
avatarImage.setImage(photo, "50_50", AndroidUtilities.getUserAvatarForId(user.id));
|
||||
avatarImage.setImage(photo, "50_50", new AvatarDrawable(user));
|
||||
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
||||
return view;
|
||||
} else if (type == 1) {
|
||||
|
|
|
@ -116,7 +116,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
|
|||
if (!playerCheck) {
|
||||
break;
|
||||
}
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (videoPlayer != null && videoPlayer.isPlaying()) {
|
||||
|
@ -172,7 +172,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
|
|||
videoPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mp) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onPlayComplete();
|
||||
|
@ -222,7 +222,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
|
|||
if (fragmentView == null) {
|
||||
actionBarLayer.setBackgroundColor(0xff333333);
|
||||
actionBarLayer.setItemsBackground(R.drawable.bar_selector_white);
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.photo_back);
|
||||
actionBarLayer.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBarLayer.setTitle(LocaleController.getString("EditVideo", R.string.EditVideo));
|
||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
|
@ -535,11 +535,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
|
|||
if (AndroidUtilities.isTablet()) {
|
||||
viewHeight = AndroidUtilities.dp(472);
|
||||
} else {
|
||||
if (!AndroidUtilities.isTablet() && getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
viewHeight = AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight - AndroidUtilities.dp(40);
|
||||
} else {
|
||||
viewHeight = AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight - AndroidUtilities.dp(48);
|
||||
}
|
||||
viewHeight = AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight - AndroidUtilities.getCurrentActionBarHeight();
|
||||
}
|
||||
|
||||
int width = 0;
|
||||
|
|
|
@ -8,11 +8,7 @@
|
|||
|
||||
package org.telegram.ui.Views.ActionBar;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
|
@ -21,15 +17,13 @@ import android.widget.FrameLayout;
|
|||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.telegram.ui.AnimationCompat.ViewProxy;
|
||||
|
||||
public class ActionBar extends FrameLayout {
|
||||
|
||||
private static Drawable logoDrawable;
|
||||
protected ActionBarLayer currentLayer = null;
|
||||
private ActionBarLayer previousLayer = null;
|
||||
private View shadowView = null;
|
||||
protected ActionBarLayer previousLayer = null;
|
||||
protected View shadowView = null;
|
||||
private boolean isBackOverlayVisible;
|
||||
|
||||
public ActionBar(Context context) {
|
||||
|
@ -87,9 +81,7 @@ public class ActionBar extends FrameLayout {
|
|||
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||
layer.setLayoutParams(layoutParams);
|
||||
currentLayer.setBackOverlayVisible(isBackOverlayVisible);
|
||||
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
layer.setAlpha(1);
|
||||
}
|
||||
layer.setAlphaEx(1);
|
||||
}
|
||||
|
||||
public void setBackOverlayVisible(boolean visible) {
|
||||
|
@ -116,7 +108,7 @@ public class ActionBar extends FrameLayout {
|
|||
layoutParams.width = LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||
layer.setLayoutParams(layoutParams);
|
||||
shadowView.setX(-AndroidUtilities.dp(2));
|
||||
ViewProxy.setX(shadowView, -AndroidUtilities.dp(2));
|
||||
shadowView.setVisibility(VISIBLE);
|
||||
previousLayer.setBackOverlayVisible(isBackOverlayVisible);
|
||||
}
|
||||
|
@ -125,56 +117,41 @@ public class ActionBar extends FrameLayout {
|
|||
if (currentLayer == null) {
|
||||
return;
|
||||
}
|
||||
currentLayer.setX(0);
|
||||
|
||||
if (!backAnimation) {
|
||||
removeView(currentLayer);
|
||||
currentLayer = previousLayer;
|
||||
currentLayer.setAlpha(1);
|
||||
currentLayer.setAlphaEx(1);
|
||||
previousLayer = null;
|
||||
} else {
|
||||
removeView(previousLayer);
|
||||
previousLayer = null;
|
||||
}
|
||||
shadowView.setVisibility(INVISIBLE);
|
||||
ViewProxy.setX(currentLayer, 0);
|
||||
}
|
||||
|
||||
public void moveActionBarByX(int dx) {
|
||||
if (currentLayer == null) {
|
||||
return;
|
||||
}
|
||||
currentLayer.setX(dx);
|
||||
shadowView.setX(dx - AndroidUtilities.dp(2));
|
||||
ViewProxy.setX(currentLayer, dx);
|
||||
ViewProxy.setX(shadowView, dx - AndroidUtilities.dp(2));
|
||||
if (dx != 0) {
|
||||
if (previousLayer != null) {
|
||||
previousLayer.setAlpha(Math.min(1, (float) dx / (float) currentLayer.getMeasuredWidth()));
|
||||
previousLayer.setAlphaEx(Math.min(1, (float) dx / (float) currentLayer.getMeasuredWidth()));
|
||||
}
|
||||
} else {
|
||||
if (previousLayer != null) {
|
||||
previousLayer.setAlpha(0);
|
||||
previousLayer.setAlphaEx(0);
|
||||
}
|
||||
currentLayer.setAlpha(1);
|
||||
}
|
||||
}
|
||||
|
||||
public void setupAnimations(ArrayList<Animator> animators, boolean back) {
|
||||
if (back) {
|
||||
animators.add(ObjectAnimator.ofFloat(currentLayer, "x", 0));
|
||||
animators.add(ObjectAnimator.ofFloat(shadowView, "x", -AndroidUtilities.dp(2)));
|
||||
animators.add(ObjectAnimator.ofFloat(previousLayer, "alpha", 0));
|
||||
} else {
|
||||
animators.add(ObjectAnimator.ofFloat(currentLayer, "x", getMeasuredWidth()));
|
||||
animators.add(ObjectAnimator.ofFloat(shadowView, "x", getMeasuredWidth() - AndroidUtilities.dp(2)));
|
||||
animators.add(ObjectAnimator.ofFloat(previousLayer, "alpha", 1.0f));
|
||||
currentLayer.setAlphaEx(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(40), MeasureSpec.EXACTLY));
|
||||
} else {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY));
|
||||
}
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.getCurrentActionBarHeight(), MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
public void onMenuButtonPressed() {
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.widget.TextView;
|
|||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.AnimationCompat.ViewProxy;
|
||||
|
||||
public class ActionBarLayer extends FrameLayout {
|
||||
|
||||
|
@ -36,40 +37,41 @@ public class ActionBarLayer extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
private FrameLayout backButtonFrameLayout;
|
||||
private ImageView logoImageView;
|
||||
private FrameLayout titleFrameLayout;
|
||||
private ImageView backButtonImageView;
|
||||
private TextView titleTextView;
|
||||
private TextView subTitleTextView;
|
||||
private ActionBarMenu menu;
|
||||
private ActionBarMenu actionMode;
|
||||
private int logoResourceId;
|
||||
private int backResourceId;
|
||||
protected ActionBar parentActionBar;
|
||||
private boolean oldUseLogo;
|
||||
private boolean oldUseBack;
|
||||
private View actionOverlay;
|
||||
protected boolean isSearchFieldVisible;
|
||||
protected int itemsBackgroundResourceId;
|
||||
private boolean isBackOverlayVisible;
|
||||
protected BaseFragment parentFragment;
|
||||
public ActionBarMenuOnItemClick actionBarMenuOnItemClick;
|
||||
private int leftMargin = 0;
|
||||
private float alphaEx = 1;
|
||||
|
||||
public ActionBarLayer(Context context, ActionBar actionBar) {
|
||||
super(context);
|
||||
parentActionBar = actionBar;
|
||||
backButtonFrameLayout = new FrameLayout(context);
|
||||
addView(backButtonFrameLayout);
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)backButtonFrameLayout.getLayoutParams();
|
||||
titleFrameLayout = new FrameLayout(context);
|
||||
addView(titleFrameLayout);
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)titleFrameLayout.getLayoutParams();
|
||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.height = LayoutParams.FILL_PARENT;
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||
backButtonFrameLayout.setLayoutParams(layoutParams);
|
||||
backButtonFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0);
|
||||
backButtonFrameLayout.setOnClickListener(new OnClickListener() {
|
||||
titleFrameLayout.setLayoutParams(layoutParams);
|
||||
titleFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0);
|
||||
titleFrameLayout.setEnabled(false);
|
||||
|
||||
backButtonImageView = new ImageView(getContext());
|
||||
titleFrameLayout.addView(backButtonImageView);
|
||||
backButtonImageView.setVisibility(VISIBLE);
|
||||
backButtonImageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
backButtonImageView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
public void onClick(View v) {
|
||||
if (isSearchFieldVisible) {
|
||||
closeSearchField();
|
||||
return;
|
||||
|
@ -79,7 +81,6 @@ public class ActionBarLayer extends FrameLayout {
|
|||
}
|
||||
}
|
||||
});
|
||||
backButtonFrameLayout.setEnabled(false);
|
||||
}
|
||||
|
||||
public ActionBarLayer(Context context) {
|
||||
|
@ -94,38 +95,16 @@ public class ActionBarLayer extends FrameLayout {
|
|||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public void setExtraLeftMargin(int margin) {
|
||||
leftMargin = margin;
|
||||
}
|
||||
|
||||
private void positionBackImage(int height) {
|
||||
if (backButtonImageView != null) {
|
||||
LayoutParams layoutParams = (LayoutParams)backButtonImageView.getLayoutParams();
|
||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.width = AndroidUtilities.dp(54);
|
||||
layoutParams.height = height;
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||
layoutParams.setMargins(AndroidUtilities.dp(3 + leftMargin), (height - backButtonImageView.getDrawable().getIntrinsicHeight()) / 2, 0, 0);
|
||||
backButtonImageView.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
private void positionLogoImage(int height) {
|
||||
if (logoImageView != null && logoImageView.getDrawable() != null) {
|
||||
LayoutParams layoutParams = (LayoutParams) logoImageView.getLayoutParams();
|
||||
if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
layoutParams.width = (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
|
||||
layoutParams.height = (int)(logoImageView.getDrawable().getIntrinsicHeight() / 1.3f);
|
||||
layoutParams.setMargins(AndroidUtilities.dp(12), (height - layoutParams.height) / 2, 0, 0);
|
||||
} else {
|
||||
layoutParams.width = logoImageView.getDrawable().getIntrinsicWidth();
|
||||
layoutParams.height = logoImageView.getDrawable().getIntrinsicHeight();
|
||||
layoutParams.setMargins(AndroidUtilities.dp(12), (height - layoutParams.width) / 2, 0, 0);
|
||||
}
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||
logoImageView.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
private void positionTitle(int width, int height) {
|
||||
int offset = AndroidUtilities.dp(2);
|
||||
if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
|
@ -137,9 +116,9 @@ public class ActionBarLayer extends FrameLayout {
|
|||
|
||||
if (titleTextView != null && titleTextView.getVisibility() == VISIBLE) {
|
||||
if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
titleTextView.setTextSize(16);
|
||||
} else {
|
||||
titleTextView.setTextSize(18);
|
||||
} else {
|
||||
titleTextView.setTextSize(20);
|
||||
}
|
||||
|
||||
layoutParams = (LayoutParams) titleTextView.getLayoutParams();
|
||||
|
@ -152,9 +131,9 @@ public class ActionBarLayer extends FrameLayout {
|
|||
}
|
||||
if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) {
|
||||
if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
subTitleTextView.setTextSize(12);
|
||||
} else {
|
||||
subTitleTextView.setTextSize(14);
|
||||
} else {
|
||||
subTitleTextView.setTextSize(16);
|
||||
}
|
||||
|
||||
layoutParams = (LayoutParams) subTitleTextView.getLayoutParams();
|
||||
|
@ -167,16 +146,13 @@ public class ActionBarLayer extends FrameLayout {
|
|||
}
|
||||
|
||||
int x = 0;
|
||||
if (logoImageView == null || logoImageView.getVisibility() == GONE) {
|
||||
x = AndroidUtilities.dp(16 + leftMargin);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
x = AndroidUtilities.dp(80);
|
||||
} else {
|
||||
if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
x = AndroidUtilities.dp(22 + leftMargin) + (logoImageView.getDrawable() != null ? (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f) : 0);
|
||||
} else {
|
||||
x = AndroidUtilities.dp(22 + leftMargin) + (logoImageView.getDrawable() != null ? logoImageView.getDrawable().getIntrinsicWidth() : 0);
|
||||
}
|
||||
x = AndroidUtilities.dp(72);
|
||||
}
|
||||
|
||||
|
||||
if (menu != null) {
|
||||
maxTextWidth = Math.min(maxTextWidth, width - menu.getMeasuredWidth() - AndroidUtilities.dp(16));
|
||||
}
|
||||
|
@ -185,9 +161,11 @@ public class ActionBarLayer extends FrameLayout {
|
|||
layoutParams = (LayoutParams) titleTextView.getLayoutParams();
|
||||
layoutParams.width = LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = titleTextView.getMeasuredHeight();
|
||||
int y = (height - titleTextView.getMeasuredHeight()) / 2;
|
||||
int y;
|
||||
if (subTitleTextView != null && subTitleTextView.getVisibility() == VISIBLE) {
|
||||
y = (height / 2 - titleTextView.getMeasuredHeight()) / 2 + offset;
|
||||
} else {
|
||||
y = (height - titleTextView.getMeasuredHeight()) / 2 - AndroidUtilities.dp(1);
|
||||
}
|
||||
layoutParams.setMargins(x, y, 0, 0);
|
||||
titleTextView.setLayoutParams(layoutParams);
|
||||
|
@ -200,9 +178,9 @@ public class ActionBarLayer extends FrameLayout {
|
|||
subTitleTextView.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
ViewGroup.LayoutParams layoutParams1 = backButtonFrameLayout.getLayoutParams();
|
||||
ViewGroup.LayoutParams layoutParams1 = titleFrameLayout.getLayoutParams();
|
||||
layoutParams1.width = x + maxTextWidth + (isSearchFieldVisible ? 0 : AndroidUtilities.dp(6));
|
||||
backButtonFrameLayout.setLayoutParams(layoutParams1);
|
||||
titleFrameLayout.setLayoutParams(layoutParams1);
|
||||
}
|
||||
|
||||
public void positionMenu(int width, int height) {
|
||||
|
@ -211,49 +189,36 @@ public class ActionBarLayer extends FrameLayout {
|
|||
}
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)menu.getLayoutParams();
|
||||
layoutParams.width = isSearchFieldVisible ? LayoutParams.MATCH_PARENT : LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.leftMargin = isSearchFieldVisible ? AndroidUtilities.dp(26) + logoImageView.getDrawable().getIntrinsicWidth() : 0;
|
||||
layoutParams.leftMargin = isSearchFieldVisible ? AndroidUtilities.dp(54) : 0;
|
||||
menu.setLayoutParams(layoutParams);
|
||||
menu.measure(width, height);
|
||||
}
|
||||
|
||||
public void setDisplayUseLogoEnabled(boolean value, int resource) {
|
||||
if (value && logoImageView == null) {
|
||||
logoResourceId = resource;
|
||||
logoImageView = new ImageView(getContext());
|
||||
logoImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
backButtonFrameLayout.addView(logoImageView);
|
||||
}
|
||||
if (logoImageView != null) {
|
||||
logoImageView.setVisibility(value ? VISIBLE : GONE);
|
||||
logoImageView.setImageResource(resource);
|
||||
positionLogoImage(getMeasuredHeight());
|
||||
}
|
||||
public void setBackButtonDrawable(Drawable drawable) {
|
||||
backButtonImageView.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
public void setDisplayHomeAsUpEnabled(boolean value, int resource) {
|
||||
if (value && backButtonImageView == null) {
|
||||
backResourceId = resource;
|
||||
backButtonImageView = new ImageView(getContext());
|
||||
backButtonFrameLayout.addView(backButtonImageView);
|
||||
}
|
||||
if (backButtonImageView != null) {
|
||||
backButtonImageView.setVisibility(value ? VISIBLE : GONE);
|
||||
backButtonFrameLayout.setEnabled(value);
|
||||
backButtonImageView.setImageResource(resource);
|
||||
positionBackImage(getMeasuredHeight());
|
||||
public void setBackButtonImage(int resource) {
|
||||
backButtonImageView.setImageResource(resource);
|
||||
}
|
||||
|
||||
private void createSubtitleTextView() {
|
||||
if (subTitleTextView != null) {
|
||||
return;
|
||||
}
|
||||
subTitleTextView = new TextView(getContext());
|
||||
titleFrameLayout.addView(subTitleTextView);
|
||||
subTitleTextView.setGravity(Gravity.LEFT);
|
||||
subTitleTextView.setTextColor(0xffd7e8f7);
|
||||
subTitleTextView.setSingleLine(true);
|
||||
subTitleTextView.setLines(1);
|
||||
subTitleTextView.setMaxLines(1);
|
||||
subTitleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
}
|
||||
|
||||
public void setSubtitle(CharSequence value) {
|
||||
if (value != null && subTitleTextView == null) {
|
||||
subTitleTextView = new TextView(getContext());
|
||||
backButtonFrameLayout.addView(subTitleTextView);
|
||||
subTitleTextView.setGravity(Gravity.LEFT);
|
||||
subTitleTextView.setTextColor(0xffd7e8f7);
|
||||
subTitleTextView.setSingleLine(true);
|
||||
subTitleTextView.setLines(1);
|
||||
subTitleTextView.setMaxLines(1);
|
||||
subTitleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
createSubtitleTextView();
|
||||
}
|
||||
if (subTitleTextView != null) {
|
||||
subTitleTextView.setVisibility(value != null ? VISIBLE : GONE);
|
||||
|
@ -264,14 +229,7 @@ public class ActionBarLayer extends FrameLayout {
|
|||
|
||||
public void setSubTitleIcon(int resourceId, Drawable drawable, int padding) {
|
||||
if ((resourceId != 0 || drawable != null) && subTitleTextView == null) {
|
||||
subTitleTextView = new TextView(getContext());
|
||||
backButtonFrameLayout.addView(subTitleTextView);
|
||||
subTitleTextView.setGravity(Gravity.LEFT);
|
||||
subTitleTextView.setTextColor(0xffd7e8f7);
|
||||
subTitleTextView.setSingleLine(true);
|
||||
subTitleTextView.setLines(1);
|
||||
subTitleTextView.setMaxLines(1);
|
||||
subTitleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
createSubtitleTextView();
|
||||
positionTitle(getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
if (subTitleTextView != null) {
|
||||
|
@ -284,16 +242,24 @@ public class ActionBarLayer extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
private void createTitleTextView() {
|
||||
if (titleTextView != null) {
|
||||
return;
|
||||
}
|
||||
titleTextView = new TextView(getContext());
|
||||
titleTextView.setGravity(Gravity.LEFT);
|
||||
titleTextView.setSingleLine(true);
|
||||
titleTextView.setLines(1);
|
||||
titleTextView.setMaxLines(1);
|
||||
titleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
titleFrameLayout.addView(titleTextView);
|
||||
titleTextView.setTextColor(0xffffffff);
|
||||
titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
}
|
||||
|
||||
public void setTitle(CharSequence value) {
|
||||
if (value != null && titleTextView == null) {
|
||||
titleTextView = new TextView(getContext());
|
||||
titleTextView.setGravity(Gravity.LEFT);
|
||||
titleTextView.setSingleLine(true);
|
||||
titleTextView.setLines(1);
|
||||
titleTextView.setMaxLines(1);
|
||||
titleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
backButtonFrameLayout.addView(titleTextView);
|
||||
titleTextView.setTextColor(0xffffffff);
|
||||
createTitleTextView();
|
||||
}
|
||||
if (titleTextView != null) {
|
||||
titleTextView.setVisibility(value != null ? VISIBLE : GONE);
|
||||
|
@ -304,14 +270,7 @@ public class ActionBarLayer extends FrameLayout {
|
|||
|
||||
public void setTitleIcon(int resourceId, int padding) {
|
||||
if (resourceId != 0 && titleTextView == null) {
|
||||
titleTextView = new TextView(getContext());
|
||||
titleTextView.setGravity(Gravity.LEFT);
|
||||
backButtonFrameLayout.addView(titleTextView);
|
||||
titleTextView.setTextColor(0xffffffff);
|
||||
titleTextView.setSingleLine(true);
|
||||
titleTextView.setLines(1);
|
||||
titleTextView.setMaxLines(1);
|
||||
titleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
createTitleTextView();
|
||||
positionTitle(getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
titleTextView.setCompoundDrawablesWithIntrinsicBounds(resourceId, 0, 0, 0);
|
||||
|
@ -378,8 +337,8 @@ public class ActionBarLayer extends FrameLayout {
|
|||
return;
|
||||
}
|
||||
actionMode.setVisibility(VISIBLE);
|
||||
if (backButtonFrameLayout != null) {
|
||||
backButtonFrameLayout.setVisibility(INVISIBLE);
|
||||
if (titleFrameLayout != null) {
|
||||
titleFrameLayout.setVisibility(INVISIBLE);
|
||||
}
|
||||
if (menu != null) {
|
||||
menu.setVisibility(INVISIBLE);
|
||||
|
@ -391,8 +350,8 @@ public class ActionBarLayer extends FrameLayout {
|
|||
return;
|
||||
}
|
||||
actionMode.setVisibility(GONE);
|
||||
if (backButtonFrameLayout != null) {
|
||||
backButtonFrameLayout.setVisibility(isSearchFieldVisible || actionOverlay == null || actionOverlay.getVisibility() == GONE ? VISIBLE : INVISIBLE);
|
||||
if (titleFrameLayout != null) {
|
||||
titleFrameLayout.setVisibility(isSearchFieldVisible || actionOverlay == null || actionOverlay.getVisibility() == GONE ? VISIBLE : INVISIBLE);
|
||||
}
|
||||
if (menu != null) {
|
||||
menu.setVisibility(VISIBLE);
|
||||
|
@ -411,18 +370,9 @@ public class ActionBarLayer extends FrameLayout {
|
|||
if (subTitleTextView != null) {
|
||||
subTitleTextView.setVisibility(visible ? GONE : VISIBLE);
|
||||
}
|
||||
backButtonFrameLayout.setPadding(0, 0, visible ? 0 : AndroidUtilities.dp(4), 0);
|
||||
if (visible) {
|
||||
oldUseLogo = logoImageView != null && logoImageView.getVisibility() == VISIBLE;
|
||||
setDisplayUseLogoEnabled(true, R.drawable.ic_ab_search);
|
||||
} else {
|
||||
setDisplayUseLogoEnabled(oldUseLogo, logoResourceId);
|
||||
}
|
||||
if (visible) {
|
||||
oldUseBack = backButtonImageView != null && backButtonImageView.getVisibility() == VISIBLE;
|
||||
setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
} else {
|
||||
setDisplayHomeAsUpEnabled(oldUseBack, backResourceId);
|
||||
Drawable drawable = backButtonImageView.getDrawable();
|
||||
if (drawable != null && drawable instanceof MenuDrawable) {
|
||||
((MenuDrawable)drawable).setRotation(visible ? 1 : 0, true);
|
||||
}
|
||||
positionBackOverlay(getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
|
@ -436,7 +386,6 @@ public class ActionBarLayer extends FrameLayout {
|
|||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
positionLogoImage(MeasureSpec.getSize(heightMeasureSpec));
|
||||
positionBackImage(MeasureSpec.getSize(heightMeasureSpec));
|
||||
positionMenu(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec));
|
||||
positionTitle(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec));
|
||||
|
@ -444,16 +393,20 @@ public class ActionBarLayer extends FrameLayout {
|
|||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(float alpha) {
|
||||
public void setAlphaEx(float alpha) {
|
||||
alphaEx = alpha;
|
||||
if (menu != null) {
|
||||
menu.setAlpha(alpha);
|
||||
ViewProxy.setAlpha(menu, alphaEx);
|
||||
}
|
||||
if (backButtonFrameLayout != null) {
|
||||
backButtonFrameLayout.setAlpha(alpha);
|
||||
if (titleFrameLayout != null) {
|
||||
ViewProxy.setAlpha(titleFrameLayout, alphaEx);
|
||||
}
|
||||
}
|
||||
|
||||
public float getAlphaEx() {
|
||||
return alphaEx;
|
||||
}
|
||||
|
||||
public void onMenuButtonPressed() {
|
||||
if (menu != null) {
|
||||
menu.onMenuButtonPressed();
|
||||
|
@ -496,7 +449,7 @@ public class ActionBarLayer extends FrameLayout {
|
|||
if (actionOverlay == null) {
|
||||
return;
|
||||
}
|
||||
backButtonFrameLayout.setVisibility(isSearchFieldVisible || actionOverlay == null || actionOverlay.getVisibility() == GONE ? VISIBLE : INVISIBLE);
|
||||
titleFrameLayout.setVisibility(isSearchFieldVisible || actionOverlay == null || actionOverlay.getVisibility() == GONE ? VISIBLE : INVISIBLE);
|
||||
actionOverlay.setVisibility(!isSearchFieldVisible && isBackOverlayVisible ? VISIBLE : GONE);
|
||||
if (actionOverlay.getVisibility() == VISIBLE) {
|
||||
ViewGroup.LayoutParams layoutParams = actionOverlay.getLayoutParams();
|
||||
|
@ -511,6 +464,6 @@ public class ActionBarLayer extends FrameLayout {
|
|||
|
||||
public void setItemsBackground(int resourceId) {
|
||||
itemsBackgroundResourceId = resourceId;
|
||||
backButtonFrameLayout.setBackgroundResource(itemsBackgroundResourceId);
|
||||
backButtonImageView.setBackgroundResource(resourceId);
|
||||
}
|
||||
}
|
|
@ -8,13 +8,11 @@
|
|||
|
||||
package org.telegram.ui.Views.ActionBar;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.view.ActionMode;
|
||||
|
@ -34,6 +32,10 @@ import org.telegram.android.AndroidUtilities;
|
|||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.ui.AnimationCompat.ViewProxy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -64,6 +66,10 @@ public class ActionBarLayout extends FrameLayout {
|
|||
private FrameLayoutAnimationListener containerView;
|
||||
private FrameLayoutAnimationListener containerViewBack;
|
||||
private View shadowView;
|
||||
private DrawerLayout drawerLayout;
|
||||
|
||||
private boolean needStatusBar;
|
||||
private Paint statusBarPaint = new Paint();
|
||||
|
||||
private Animation openAnimation;
|
||||
private Animation closeAnimation;
|
||||
|
@ -131,6 +137,10 @@ public class ActionBarLayout extends FrameLayout {
|
|||
fragment.setParentLayout(this);
|
||||
}
|
||||
|
||||
if (drawerLayout != null) {
|
||||
bringChildToFront(drawerLayout);
|
||||
}
|
||||
|
||||
needLayout();
|
||||
}
|
||||
|
||||
|
@ -144,6 +154,14 @@ public class ActionBarLayout extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (needStatusBar) {
|
||||
canvas.drawRect(0, 0, getWidth(), AndroidUtilities.statusBarHeight, statusBarPaint);
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
fixLayout();
|
||||
if (transitionAnimationInProgress) {
|
||||
|
@ -199,12 +217,7 @@ public class ActionBarLayout extends FrameLayout {
|
|||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
private void onSlideAnimationEnd(boolean backAnimation) {
|
||||
containerView.setTranslationX(0);
|
||||
containerViewBack.setTranslationX(0);
|
||||
actionBar.stopMoving(backAnimation);
|
||||
shadowView.setVisibility(View.INVISIBLE);
|
||||
shadowView.setTranslationX(-AndroidUtilities.dp(2));
|
||||
private void onSlideAnimationEnd(final boolean backAnimation) {
|
||||
if (!backAnimation) {
|
||||
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||
lastFragment.onPause();
|
||||
|
@ -216,8 +229,14 @@ public class ActionBarLayout extends FrameLayout {
|
|||
containerView = containerViewBack;
|
||||
containerViewBack = temp;
|
||||
ViewGroup parent = (ViewGroup)containerView.getParent();
|
||||
parent.removeView(containerView);
|
||||
parent.addView(containerView, 1);
|
||||
parent.bringChildToFront(containerView);
|
||||
parent.bringChildToFront(shadowView);
|
||||
parent.bringChildToFront(actionBar);
|
||||
if (drawerLayout != null) {
|
||||
parent.bringChildToFront(drawerLayout);
|
||||
}
|
||||
//parent.removeViewInLayout(containerView);
|
||||
//parent.addView(containerView, 1);
|
||||
lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||
lastFragment.onResume();
|
||||
} else {
|
||||
|
@ -234,6 +253,12 @@ public class ActionBarLayout extends FrameLayout {
|
|||
AndroidUtilities.unlockOrientation(parentActivity);
|
||||
startedTracking = false;
|
||||
animationInProgress = false;
|
||||
|
||||
ViewProxy.setTranslationX(containerView, 0);
|
||||
ViewProxy.setTranslationX(containerViewBack, 0);
|
||||
actionBar.stopMoving(backAnimation);
|
||||
shadowView.setVisibility(View.INVISIBLE);
|
||||
ViewProxy.setTranslationX(shadowView, -AndroidUtilities.dp(2));
|
||||
}
|
||||
|
||||
private void prepareForMoving(MotionEvent ev) {
|
||||
|
@ -241,7 +266,7 @@ public class ActionBarLayout extends FrameLayout {
|
|||
startedTracking = true;
|
||||
startedTrackingX = (int) ev.getX();
|
||||
shadowView.setVisibility(View.VISIBLE);
|
||||
shadowView.setTranslationX(-AndroidUtilities.dp(2));
|
||||
ViewProxy.setTranslationX(shadowView, -AndroidUtilities.dp(2));
|
||||
containerViewBack.setVisibility(View.VISIBLE);
|
||||
beginTrackingSent = false;
|
||||
|
||||
|
@ -266,7 +291,7 @@ public class ActionBarLayout extends FrameLayout {
|
|||
}
|
||||
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if(android.os.Build.VERSION.SDK_INT >= 11 && !checkTransitionAnimation() && !inActionMode && fragmentsStack.size() > 1 && !animationInProgress) {
|
||||
if(!checkTransitionAnimation() && !inActionMode && fragmentsStack.size() > 1 && !animationInProgress) {
|
||||
if (ev != null && ev.getAction() == MotionEvent.ACTION_DOWN && !startedTracking && !maybeStartTracking) {
|
||||
BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||
if (!currentFragment.swipeBackEnabled) {
|
||||
|
@ -298,8 +323,8 @@ public class ActionBarLayout extends FrameLayout {
|
|||
beginTrackingSent = true;
|
||||
}
|
||||
actionBar.moveActionBarByX(dx);
|
||||
containerView.setTranslationX(dx);
|
||||
shadowView.setTranslationX(dx - AndroidUtilities.dp(2));
|
||||
ViewProxy.setTranslationX(containerView, dx);
|
||||
ViewProxy.setTranslationX(shadowView, dx - AndroidUtilities.dp(2));
|
||||
}
|
||||
} else if (ev != null && ev.getPointerId(0) == startedTrackingPointerId && (ev.getAction() == MotionEvent.ACTION_CANCEL || ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_POINTER_UP)) {
|
||||
if (velocityTracker == null) {
|
||||
|
@ -314,49 +339,46 @@ public class ActionBarLayout extends FrameLayout {
|
|||
}
|
||||
}
|
||||
if (startedTracking) {
|
||||
float x = containerView.getX();
|
||||
ArrayList<Animator> animators = new ArrayList<Animator>();
|
||||
float x = ViewProxy.getX(containerView);
|
||||
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
|
||||
float velX = velocityTracker.getXVelocity();
|
||||
float velY = velocityTracker.getYVelocity();
|
||||
final boolean backAnimation = x < containerView.getMeasuredWidth() / 3.0f && (velX < 3500 || velX < velY);
|
||||
float distToMove = 0;
|
||||
if (!backAnimation) {
|
||||
distToMove = containerView.getMeasuredWidth() - x;
|
||||
animators.add(ObjectAnimator.ofFloat(containerView, "x", containerView.getMeasuredWidth()));
|
||||
animators.add(ObjectAnimator.ofFloat(shadowView, "x", containerView.getMeasuredWidth() - AndroidUtilities.dp(2)));
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimatorProxy.ofFloat(containerView, "x", containerView.getMeasuredWidth()),
|
||||
ObjectAnimatorProxy.ofFloat(shadowView, "x", containerView.getMeasuredWidth() - AndroidUtilities.dp(2)),
|
||||
ObjectAnimatorProxy.ofFloat(actionBar.currentLayer, "x", actionBar.getMeasuredWidth()),
|
||||
ObjectAnimatorProxy.ofFloat(actionBar.shadowView, "x", actionBar.getMeasuredWidth() - AndroidUtilities.dp(2)),
|
||||
ObjectAnimatorProxy.ofFloat(actionBar.previousLayer, "alphaEx", 1.0f)
|
||||
);
|
||||
} else {
|
||||
distToMove = x;
|
||||
animators.add(ObjectAnimator.ofFloat(containerView, "x", 0));
|
||||
animators.add(ObjectAnimator.ofFloat(shadowView, "x", -AndroidUtilities.dp(2)));
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimatorProxy.ofFloat(containerView, "x", 0),
|
||||
ObjectAnimatorProxy.ofFloat(shadowView, "x", -AndroidUtilities.dp(2)),
|
||||
ObjectAnimatorProxy.ofFloat(actionBar.currentLayer, "x", 0),
|
||||
ObjectAnimatorProxy.ofFloat(actionBar.shadowView, "x", -AndroidUtilities.dp(2)),
|
||||
ObjectAnimatorProxy.ofFloat(actionBar.previousLayer, "alphaEx", 0)
|
||||
);
|
||||
}
|
||||
actionBar.setupAnimations(animators, backAnimation);
|
||||
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(animators);
|
||||
animatorSet.setDuration(Math.max((int) (200.0f / containerView.getMeasuredWidth() * distToMove), 50));
|
||||
animatorSet.start();
|
||||
animationInProgress = true;
|
||||
animatorSet.addListener(new Animator.AnimatorListener() {
|
||||
animatorSet.addListener(new AnimatorListenerAdapterProxy() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
public void onAnimationEnd(Object animator) {
|
||||
onSlideAnimationEnd(backAnimation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animator) {
|
||||
public void onAnimationCancel(Object animator) {
|
||||
onSlideAnimationEnd(backAnimation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animator) {
|
||||
|
||||
}
|
||||
});
|
||||
animatorSet.start();
|
||||
animationInProgress = true;
|
||||
} else {
|
||||
maybeStartTracking = false;
|
||||
startedTracking = false;
|
||||
|
@ -438,13 +460,17 @@ public class ActionBarLayout extends FrameLayout {
|
|||
|
||||
int height = 0;
|
||||
if (actionBar.getVisibility() == View.VISIBLE) {
|
||||
if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
height = AndroidUtilities.dp(40);
|
||||
} else {
|
||||
height = AndroidUtilities.dp(48);
|
||||
}
|
||||
height = AndroidUtilities.getCurrentActionBarHeight();
|
||||
}
|
||||
if (needStatusBar) {
|
||||
height += AndroidUtilities.statusBarHeight;
|
||||
}
|
||||
|
||||
if (actionBar != null) {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) actionBar.getLayoutParams();
|
||||
layoutParams.topMargin = needStatusBar ? AndroidUtilities.statusBarHeight : 0;
|
||||
actionBar.setLayoutParams(layoutParams);
|
||||
}
|
||||
if (containerView != null) {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) containerView.getLayoutParams();
|
||||
if (layoutParams.topMargin != height) {
|
||||
|
@ -529,8 +555,14 @@ public class ActionBarLayout extends FrameLayout {
|
|||
containerViewBack = temp;
|
||||
containerView.setVisibility(View.VISIBLE);
|
||||
ViewGroup parent = (ViewGroup)containerView.getParent();
|
||||
parent.removeView(containerView);
|
||||
parent.addView(containerView, 1);
|
||||
//parent.removeView(containerView);
|
||||
//parent.addView(containerView, 1);
|
||||
parent.bringChildToFront(containerView);
|
||||
parent.bringChildToFront(shadowView);
|
||||
parent.bringChildToFront(actionBar);
|
||||
if (drawerLayout != null) {
|
||||
parent.bringChildToFront(drawerLayout);
|
||||
}
|
||||
|
||||
if (!needAnimation) {
|
||||
presentFragmentInternalRemoveOld(removeLast, currentFragment);
|
||||
|
@ -824,4 +856,23 @@ public class ActionBarLayout extends FrameLayout {
|
|||
public void setBackgroundView(View view) {
|
||||
backgroundView = view;
|
||||
}
|
||||
|
||||
public void setNeedStatusBar(boolean value) {
|
||||
needStatusBar = value;
|
||||
setWillNotDraw(!needStatusBar);
|
||||
}
|
||||
|
||||
public void setStatusBarColor(int color) {
|
||||
statusBarPaint.setColor(color);
|
||||
}
|
||||
|
||||
public void createDrawerLayout() {
|
||||
drawerLayout = new DrawerLayout(getContext());
|
||||
addView(drawerLayout);
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)drawerLayout.getLayoutParams();
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||
layoutParams.width = AndroidUtilities.dp(100);
|
||||
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
drawerLayout.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class ActionBarMenu extends LinearLayout {
|
|||
addView(menuItem);
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)menuItem.getLayoutParams();
|
||||
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.width = AndroidUtilities.dp(56);
|
||||
layoutParams.width = AndroidUtilities.dp(48);
|
||||
menuItem.setLayoutParams(layoutParams);
|
||||
menuItem.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -32,6 +32,7 @@ import android.widget.TextView;
|
|||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -51,9 +52,10 @@ public class ActionBarMenuItem extends ImageView {
|
|||
private EditText searchField;
|
||||
private boolean isSearchField = false;
|
||||
private ActionBarMenuItemSearchListener listener;
|
||||
private Rect rect = null;
|
||||
private int[] location = null;
|
||||
private View selectedMenuView = null;
|
||||
private Rect rect;
|
||||
private int[] location;
|
||||
private View selectedMenuView;
|
||||
private Runnable showMenuRunnable;
|
||||
|
||||
public ActionBarMenuItem(Context context, ActionBarMenu menu, ActionBar actionBar, int background) {
|
||||
super(context);
|
||||
|
@ -76,7 +78,20 @@ public class ActionBarMenuItem extends ImageView {
|
|||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
|
||||
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||
if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) {
|
||||
showMenuRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (getParent() != null) {
|
||||
getParent().requestDisallowInterceptTouchEvent(true);
|
||||
}
|
||||
toggleSubMenu();
|
||||
}
|
||||
};
|
||||
AndroidUtilities.runOnUIThread(showMenuRunnable, 200);
|
||||
}
|
||||
} else if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
|
||||
if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) {
|
||||
if (event.getY() > getHeight()) {
|
||||
if (getParent() != null) {
|
||||
|
@ -98,9 +113,18 @@ public class ActionBarMenuItem extends ImageView {
|
|||
child.getHitRect(rect);
|
||||
if ((Integer)child.getTag() < 100) {
|
||||
if (!rect.contains((int)x, (int)y)) {
|
||||
child.setPressed(false);
|
||||
child.setSelected(false);
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
child.getBackground().setVisible(false, false);
|
||||
}
|
||||
} else {
|
||||
child.setPressed(true);
|
||||
child.setSelected(true);
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
child.getBackground().setVisible(true, false);
|
||||
child.drawableHotspotChanged(x, y - child.getTop());
|
||||
}
|
||||
selectedMenuView = child;
|
||||
}
|
||||
}
|
||||
|
@ -151,16 +175,6 @@ public class ActionBarMenuItem extends ImageView {
|
|||
}
|
||||
});
|
||||
}
|
||||
if (popupLayout.getChildCount() != 0) {
|
||||
View delimeter = new View(getContext());
|
||||
delimeter.setBackgroundColor(0xffdcdcdc);
|
||||
popupLayout.addView(delimeter);
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)delimeter.getLayoutParams();
|
||||
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = AndroidUtilities.density >= 3 ? 2 : 1;
|
||||
delimeter.setLayoutParams(layoutParams);
|
||||
delimeter.setTag(100 + id);
|
||||
}
|
||||
TextView textView = new TextView(getContext());
|
||||
textView.setTextColor(0xff000000);
|
||||
textView.setBackgroundResource(R.drawable.list_selector);
|
||||
|
@ -206,6 +220,13 @@ public class ActionBarMenuItem extends ImageView {
|
|||
}
|
||||
|
||||
public void toggleSubMenu() {
|
||||
if (popupLayout == null) {
|
||||
return;
|
||||
}
|
||||
if (showMenuRunnable != null) {
|
||||
AndroidUtilities.cancelRunOnUIThread(showMenuRunnable);
|
||||
showMenuRunnable = null;
|
||||
}
|
||||
if (popupWindow != null && popupWindow.isShowing()) {
|
||||
popupWindow.dismiss();
|
||||
return;
|
||||
|
@ -213,6 +234,7 @@ public class ActionBarMenuItem extends ImageView {
|
|||
if (popupWindow == null) {
|
||||
popupWindow = new ActionBarPopupWindow(popupLayout, FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
//popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
||||
popupWindow.setAnimationStyle(R.style.PopupAnimation);
|
||||
popupWindow.setOutsideTouchable(true);
|
||||
popupWindow.setClippingEnabled(true);
|
||||
popupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||
|
@ -232,10 +254,10 @@ public class ActionBarMenuItem extends ImageView {
|
|||
}
|
||||
popupWindow.setFocusable(true);
|
||||
if (popupLayout.getMeasuredWidth() == 0) {
|
||||
popupWindow.showAsDropDown(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), 0);
|
||||
popupWindow.update(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), 0, -1, -1);
|
||||
popupWindow.showAsDropDown(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight());
|
||||
popupWindow.update(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1);
|
||||
} else {
|
||||
popupWindow.showAsDropDown(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), 0);
|
||||
popupWindow.showAsDropDown(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,10 +399,13 @@ public class ActionBarMenuItem extends ImageView {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
if (popupWindow != null && popupWindow.isShowing()) {
|
||||
popupWindow.update(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), 0, -1, -1);
|
||||
int x = parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft();
|
||||
int y = -getMeasuredHeight();
|
||||
FileLog.e("tmessages", "x = " + x + " y = " + y);
|
||||
popupWindow.update(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* 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.ActionBar;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
|
||||
public class MenuDrawable extends Drawable {
|
||||
|
||||
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private boolean reverseAngle = false;
|
||||
private long lastFrameTime;
|
||||
private boolean animationInProgress;
|
||||
private float finalRotation;
|
||||
private float currentRotation;
|
||||
private int currentAnimationTime;
|
||||
private DecelerateInterpolator interpolator = new DecelerateInterpolator();
|
||||
|
||||
public MenuDrawable() {
|
||||
super();
|
||||
paint.setColor(0xffffffff);
|
||||
paint.setStrokeWidth(AndroidUtilities.dp(2));
|
||||
}
|
||||
|
||||
public void setRotation(float rotation, boolean animated) {
|
||||
lastFrameTime = 0;
|
||||
if (currentRotation == 1) {
|
||||
reverseAngle = true;
|
||||
} else if (currentRotation == 0) {
|
||||
reverseAngle = false;
|
||||
}
|
||||
lastFrameTime = 0;
|
||||
if (animated) {
|
||||
if (currentRotation < rotation) {
|
||||
currentAnimationTime = (int) (currentRotation * 300);
|
||||
} else {
|
||||
currentAnimationTime = (int) ((1.0f - currentRotation) * 300);
|
||||
}
|
||||
lastFrameTime = System.currentTimeMillis();
|
||||
finalRotation = rotation;
|
||||
} else {
|
||||
finalRotation = currentRotation = rotation;
|
||||
}
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
if (currentRotation != finalRotation) {
|
||||
if (lastFrameTime != 0) {
|
||||
long dt = System.currentTimeMillis() - lastFrameTime;
|
||||
|
||||
currentAnimationTime += dt;
|
||||
if (currentAnimationTime >= 300) {
|
||||
currentRotation = finalRotation;
|
||||
} else {
|
||||
if (currentRotation < finalRotation) {
|
||||
currentRotation = interpolator.getInterpolation(currentAnimationTime / 300.0f) * finalRotation;
|
||||
} else {
|
||||
currentRotation = 1.0f - interpolator.getInterpolation(currentAnimationTime / 300.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
lastFrameTime = System.currentTimeMillis();
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(getIntrinsicWidth() / 2, getIntrinsicHeight() / 2);
|
||||
canvas.rotate(currentRotation * (reverseAngle ? -180 : 180));
|
||||
canvas.drawLine(-AndroidUtilities.dp(9), 0, AndroidUtilities.dp(9) - AndroidUtilities.dp(1) * currentRotation, 0, paint);
|
||||
float endYDiff = AndroidUtilities.dp(5) * (1 - Math.abs(currentRotation)) - AndroidUtilities.dp(0.5f) * Math.abs(currentRotation);
|
||||
float endXDiff = AndroidUtilities.dp(9) - AndroidUtilities.dp(0.5f) * Math.abs(currentRotation);
|
||||
float startYDiff = AndroidUtilities.dp(5) + AndroidUtilities.dp(3.5f) * Math.abs(currentRotation);
|
||||
float startXDiff = -AndroidUtilities.dp(9) + AndroidUtilities.dp(8.5f) * Math.abs(currentRotation);
|
||||
canvas.drawLine(startXDiff, -startYDiff, endXDiff, -endYDiff, paint);
|
||||
canvas.drawLine(startXDiff, startYDiff, endXDiff, endYDiff, paint);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return AndroidUtilities.dp(24);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return AndroidUtilities.dp(24);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* 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.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Layout;
|
||||
import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
|
||||
public class AvatarDrawable extends Drawable {
|
||||
|
||||
private static Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private static TextPaint namePaint;
|
||||
private static int[] arrColors = {0xffe56555, 0xfff28c48, 0xffeec764, 0xff76c84d, 0xff5fbed5, 0xff549cdd, 0xff8e85ee, 0xfff2749a};
|
||||
|
||||
private int color;
|
||||
private StaticLayout textLayout;
|
||||
private float textWidth;
|
||||
private float textHeight;
|
||||
|
||||
public AvatarDrawable() {
|
||||
super();
|
||||
|
||||
if (namePaint == null) {
|
||||
namePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
namePaint.setColor(0xffffffff);
|
||||
namePaint.setTextSize(AndroidUtilities.dp(20));
|
||||
}
|
||||
}
|
||||
|
||||
public AvatarDrawable(TLRPC.User user) {
|
||||
this();
|
||||
if (user != null) {
|
||||
setInfo(user.id, user.first_name, user.last_name, false);
|
||||
}
|
||||
}
|
||||
|
||||
public AvatarDrawable(TLRPC.Chat chat) {
|
||||
this();
|
||||
if (chat != null) {
|
||||
setInfo(chat.id, chat.title, null, chat.id < 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getColorForId(int id) {
|
||||
return arrColors[Math.abs(id) % arrColors.length];
|
||||
}
|
||||
|
||||
public void setInfo(TLRPC.User user) {
|
||||
if (user != null) {
|
||||
setInfo(user.id, user.first_name, user.last_name, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setInfo(TLRPC.Chat chat) {
|
||||
if (chat != null) {
|
||||
setInfo(chat.id, chat.title, null, chat.id < 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void setInfo(int id, String firstName, String lastName, boolean isBroadcast) {
|
||||
color = arrColors[Math.abs(id) % arrColors.length];
|
||||
|
||||
String text = "";
|
||||
if (firstName != null && firstName.length() > 0) {
|
||||
text += firstName.substring(0, 1);
|
||||
}
|
||||
if (lastName != null && lastName.length() > 0) {
|
||||
text += lastName.substring(0, 1);
|
||||
}
|
||||
if (text.length() > 0) {
|
||||
text = text.toUpperCase();
|
||||
try {
|
||||
textLayout = new StaticLayout(text, namePaint, AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
if (textLayout.getLineCount() > 0) {
|
||||
textWidth = textLayout.getLineWidth(0);
|
||||
textHeight = textLayout.getLineBottom(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} else {
|
||||
textLayout = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
Rect bounds = getBounds();
|
||||
if (bounds == null) {
|
||||
return;
|
||||
}
|
||||
int size = bounds.right - bounds.left;
|
||||
paint.setColor(color);
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(bounds.left, bounds.top);
|
||||
canvas.drawCircle(size / 2, size / 2, size / 2, paint);
|
||||
|
||||
if (textLayout != null) {
|
||||
canvas.translate((size - textWidth) / 2, (size - textHeight) / 2);
|
||||
textLayout.draw(canvas);
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -146,7 +146,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
|||
if (id == NotificationCenter.FileDidUpload) {
|
||||
String location = (String)args[0];
|
||||
if (uploadingAvatar != null && location.equals(uploadingAvatar)) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().removeObserver(AvatarUpdater.this, NotificationCenter.FileDidUpload);
|
||||
|
@ -165,7 +165,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
|||
} else if (id == NotificationCenter.FileDidFailUpload) {
|
||||
String location = (String)args[0];
|
||||
if (uploadingAvatar != null && location.equals(uploadingAvatar)) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().removeObserver(AvatarUpdater.this, NotificationCenter.FileDidUpload);
|
||||
|
|
|
@ -42,32 +42,32 @@ public class BackupImageView extends View {
|
|||
imageReceiver = new ImageReceiver(this);
|
||||
}
|
||||
|
||||
public void setImage(TLRPC.FileLocation path, String filter, int placeholder) {
|
||||
public void setImage(TLRPC.FileLocation path, String filter, Drawable placeholder) {
|
||||
setImage(path, null, filter, placeholder, null, 0);
|
||||
}
|
||||
|
||||
public void setImage(TLRPC.FileLocation path, String filter, Bitmap placeholderBitmap) {
|
||||
setImage(path, null, filter, 0, placeholderBitmap, 0);
|
||||
setImage(path, null, filter, null, placeholderBitmap, 0);
|
||||
}
|
||||
|
||||
public void setImage(TLRPC.FileLocation path, String filter, int placeholder, int size) {
|
||||
public void setImage(TLRPC.FileLocation path, String filter, Drawable placeholder, int size) {
|
||||
setImage(path, null, filter, placeholder, null, size);
|
||||
}
|
||||
|
||||
public void setImage(TLRPC.FileLocation path, String filter, Bitmap placeholderBitmap, int size) {
|
||||
setImage(path, null, filter, 0, placeholderBitmap, size);
|
||||
setImage(path, null, filter, null, placeholderBitmap, size);
|
||||
}
|
||||
|
||||
public void setImage(String path, String filter, int placeholder) {
|
||||
public void setImage(String path, String filter, Drawable placeholder) {
|
||||
setImage(null, path, filter, placeholder, null, 0);
|
||||
}
|
||||
|
||||
public void setImage(TLRPC.FileLocation path, String httpUrl, String filter, int placeholder, Bitmap placeholderBitmap, int size) {
|
||||
public void setImage(TLRPC.FileLocation path, String httpUrl, String filter, Drawable placeholder, Bitmap placeholderBitmap, int size) {
|
||||
Drawable placeholderDrawable = null;
|
||||
if (placeholderBitmap != null) {
|
||||
placeholderDrawable = new BitmapDrawable(null, placeholderBitmap);
|
||||
} else if (placeholder != 0) {
|
||||
placeholderDrawable = getResources().getDrawable(placeholder);
|
||||
} else if (placeholder != null) {
|
||||
placeholderDrawable = placeholder;
|
||||
}
|
||||
imageReceiver.setImage(path, httpUrl, filter, placeholderDrawable, size, false);
|
||||
}
|
||||
|
@ -80,6 +80,10 @@ public class BackupImageView extends View {
|
|||
imageReceiver.setImageBitmap(getResources().getDrawable(resId));
|
||||
}
|
||||
|
||||
public void setImageDrawable(Drawable drawable) {
|
||||
imageReceiver.setImageBitmap(drawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.os.PowerManager;
|
|||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
|
@ -28,7 +29,6 @@ import android.view.View;
|
|||
import android.view.WindowManager;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
|
@ -529,7 +529,6 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
|
|||
}
|
||||
|
||||
private void showEmojiPopup(boolean show) {
|
||||
InputMethodManager localInputMethodManager = (InputMethodManager)ApplicationLoader.applicationContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (show) {
|
||||
if (emojiPopup == null) {
|
||||
createEmojiPopup();
|
||||
|
@ -553,7 +552,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
|
|||
emojiPopup.setWidth(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, View.MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), 83, 0, 0);
|
||||
emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), Gravity.BOTTOM | Gravity.LEFT, 0, 0);
|
||||
if (!keyboardVisible) {
|
||||
if (sizeNotifierRelativeLayout != null) {
|
||||
sizeNotifierRelativeLayout.setPadding(0, 0, 0, currentHeight);
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.graphics.Rect;
|
|||
import android.view.View;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.ui.AnimationCompat.ViewProxy;
|
||||
|
||||
public class ClippingImageView extends View {
|
||||
private int clipBottom;
|
||||
|
@ -59,12 +60,16 @@ public class ClippingImageView extends View {
|
|||
}
|
||||
|
||||
public void onDraw(Canvas canvas) {
|
||||
if (getVisibility() == GONE || getVisibility() == INVISIBLE) {
|
||||
return;
|
||||
}
|
||||
if (bmp != null) {
|
||||
if (drawListener != null && getScaleY() != 1) {
|
||||
float scaleY = ViewProxy.getScaleY(this);
|
||||
if (drawListener != null && scaleY != 1) {
|
||||
drawListener.onDraw();
|
||||
}
|
||||
canvas.save();
|
||||
canvas.clipRect(clipLeft / getScaleY(), clipTop / getScaleY(), getWidth() - clipRight / getScaleY(), getHeight() - clipBottom / getScaleY());
|
||||
canvas.clipRect(clipLeft / scaleY, clipTop / scaleY, getWidth() - clipRight / scaleY, getHeight() - clipBottom / scaleY);
|
||||
drawRect.set(0, 0, getWidth(), getHeight());
|
||||
try {
|
||||
canvas.drawBitmap(this.bmp, null, drawRect, this.paint);
|
||||
|
|
|
@ -124,8 +124,8 @@ public class EmojiView extends LinearLayout {
|
|||
tabs.setViewPager(pager);
|
||||
tabs.setShouldExpand(true);
|
||||
tabs.setIndicatorColor(0xff33b5e5);
|
||||
tabs.setIndicatorHeight(AndroidUtilities.dpf(2.0f));
|
||||
tabs.setUnderlineHeight(AndroidUtilities.dpf(2.0f));
|
||||
tabs.setIndicatorHeight(AndroidUtilities.dp(2.0f));
|
||||
tabs.setUnderlineHeight(AndroidUtilities.dp(2.0f));
|
||||
tabs.setUnderlineColor(0x66000000);
|
||||
tabs.setTabBackground(0);
|
||||
LinearLayout localLinearLayout = new LinearLayout(getContext());
|
||||
|
@ -152,7 +152,7 @@ public class EmojiView extends LinearLayout {
|
|||
localTextView.setGravity(17);
|
||||
recentsWrap.addView(localTextView);
|
||||
views.get(0).setEmptyView(localTextView);
|
||||
addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dpf(48.0f)));
|
||||
addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dp(48.0f)));
|
||||
addView(pager);
|
||||
loadRecents();
|
||||
if (Emoji.data[0] == null || Emoji.data[0].length == 0) {
|
||||
|
|
|
@ -20,7 +20,7 @@ public class ProgressView {
|
|||
public float currentProgress = 0;
|
||||
public int width;
|
||||
public int height;
|
||||
public float progressHeight = AndroidUtilities.dpf(2.0f);
|
||||
public float progressHeight = AndroidUtilities.dp(2.0f);
|
||||
|
||||
public ProgressView() {
|
||||
innerPaint = new Paint();
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.content.Context;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
|
@ -55,7 +56,8 @@ public class SizeNotifierRelativeLayout extends RelativeLayout {
|
|||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
if (delegate != null) {
|
||||
int usableViewHeight = this.getRootView().getHeight() - AndroidUtilities.statusBarHeight;
|
||||
View rootView = this.getRootView();
|
||||
int usableViewHeight = rootView.getHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.getViewInset(rootView);
|
||||
this.getWindowVisibleDisplayFrame(rect);
|
||||
int keyboardHeight = usableViewHeight - (rect.bottom - rect.top);
|
||||
delegate.onSizeChanged(keyboardHeight);
|
||||
|
|
|
@ -1,153 +0,0 @@
|
|||
/*
|
||||
* 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.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.R;
|
||||
|
||||
public class SlidingTabView extends LinearLayout {
|
||||
|
||||
public static interface SlidingTabViewDelegate {
|
||||
public abstract void didSelectTab(int tab);
|
||||
}
|
||||
|
||||
private SlidingTabViewDelegate delegate;
|
||||
private int selectedTab = 0;
|
||||
private int tabCount = 0;
|
||||
private float tabWidth = 0;
|
||||
private float tabX = 0;
|
||||
private float animateTabXTo = 0;
|
||||
private Paint paint = new Paint();
|
||||
private long startAnimationTime = 0;
|
||||
private long totalAnimationDiff = 0;
|
||||
private float startAnimationX = 0;
|
||||
private DecelerateInterpolator interpolator;
|
||||
|
||||
private void init() {
|
||||
setBackgroundResource(R.color.header);
|
||||
setOrientation(HORIZONTAL);
|
||||
setWeightSum(100);
|
||||
interpolator = new DecelerateInterpolator();
|
||||
}
|
||||
|
||||
public SlidingTabView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public SlidingTabView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public SlidingTabView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public SlidingTabView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
public void addTextTab(final int position, String title) {
|
||||
TextView tab = new TextView(getContext());
|
||||
tab.setText(title);
|
||||
tab.setFocusable(true);
|
||||
tab.setGravity(Gravity.CENTER);
|
||||
tab.setSingleLine();
|
||||
tab.setTextColor(0xffffffff);
|
||||
tab.setTextSize(12);
|
||||
tab.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
tab.setBackgroundResource(R.drawable.bar_selector);
|
||||
|
||||
tab.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
didSelectTab(position);
|
||||
}
|
||||
});
|
||||
addView(tab);
|
||||
LayoutParams layoutParams = (LayoutParams)tab.getLayoutParams();
|
||||
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||
layoutParams.width = 0;
|
||||
layoutParams.weight = 50;
|
||||
tab.setLayoutParams(layoutParams);
|
||||
|
||||
tabCount++;
|
||||
}
|
||||
|
||||
public void setDelegate(SlidingTabViewDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public int getSeletedTab() {
|
||||
return selectedTab;
|
||||
}
|
||||
|
||||
private void didSelectTab(int tab) {
|
||||
if (selectedTab == tab) {
|
||||
return;
|
||||
}
|
||||
selectedTab = tab;
|
||||
animateToTab(tab);
|
||||
if (delegate != null) {
|
||||
delegate.didSelectTab(tab);
|
||||
}
|
||||
}
|
||||
|
||||
private void animateToTab(int tab) {
|
||||
animateTabXTo = tab * tabWidth;
|
||||
startAnimationX = tabX;
|
||||
totalAnimationDiff = 0;
|
||||
startAnimationTime = System.currentTimeMillis();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
tabWidth = (r - l) / (float)tabCount;
|
||||
animateTabXTo = tabX = tabWidth * selectedTab;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
paint.setColor(0xaaffffff);
|
||||
for (int a = 0; a < tabCount - 1; a++) {
|
||||
canvas.drawRect(tabWidth + a * tabWidth - 1, AndroidUtilities.dp(12), tabWidth + a * tabWidth + 1, getHeight() - AndroidUtilities.dp(12), paint);
|
||||
}
|
||||
|
||||
if (tabX != animateTabXTo) {
|
||||
long dt = System.currentTimeMillis() - startAnimationTime;
|
||||
startAnimationTime = System.currentTimeMillis();
|
||||
totalAnimationDiff += dt;
|
||||
if (totalAnimationDiff > 200) {
|
||||
totalAnimationDiff = 200;
|
||||
tabX = animateTabXTo;
|
||||
} else {
|
||||
tabX = startAnimationX + interpolator.getInterpolation(totalAnimationDiff / 200.0f) * (animateTabXTo - startAnimationX);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
canvas.drawRect(tabX, getHeight() - AndroidUtilities.dp(4), (tabX + tabWidth), getHeight(), paint);
|
||||
}
|
||||
}
|
8
TMessagesProj/src/main/res/anim/popup_in.xml
Normal file
8
TMessagesProj/src/main/res/anim/popup_in.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<alpha android:fromAlpha="0.0"
|
||||
android:toAlpha="1.0"
|
||||
android:duration="150"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"/>
|
||||
</set>
|
8
TMessagesProj/src/main/res/anim/popup_out.xml
Normal file
8
TMessagesProj/src/main/res/anim/popup_out.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<alpha android:fromAlpha="1.0"
|
||||
android:toAlpha="0.0"
|
||||
android:duration="150"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"/>
|
||||
</set>
|
Binary file not shown.
Before Width: | Height: | Size: 3.5 KiB |
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue