diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 66a09badc..b5ce30772 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -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" } diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml index b6a7aa8a3..a5fb34f8a 100644 --- a/TMessagesProj/src/main/AndroidManifest.xml +++ b/TMessagesProj/src/main/AndroidManifest.xml @@ -51,7 +51,7 @@ diff --git a/TMessagesProj/src/main/assets/fonts/rmedium.ttf b/TMessagesProj/src/main/assets/fonts/rmedium.ttf index d0f6e2b64..a3c1a1f17 100644 Binary files a/TMessagesProj/src/main/assets/fonts/rmedium.ttf and b/TMessagesProj/src/main/assets/fonts/rmedium.ttf differ diff --git a/TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java index 3b346fd00..f25d557e3 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java @@ -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); + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/android/AppStartReceiver.java b/TMessagesProj/src/main/java/org/telegram/android/AppStartReceiver.java index a52ccccc4..5368465c1 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/AppStartReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/android/AppStartReceiver.java @@ -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(); diff --git a/TMessagesProj/src/main/java/org/telegram/android/ContactsController.java b/TMessagesProj/src/main/java/org/telegram/android/ContactsController.java index d6f71a5c4..c57e9c519 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/ContactsController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/ContactsController.java @@ -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 contactsArr, final ArrayList 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 newContacts = newC; final ArrayList 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; diff --git a/TMessagesProj/src/main/java/org/telegram/android/Emoji.java b/TMessagesProj/src/main/java/org/telegram/android/Emoji.java index df744fa7b..1e55e9753 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/Emoji.java +++ b/TMessagesProj/src/main/java/org/telegram/android/Emoji.java @@ -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; diff --git a/TMessagesProj/src/main/java/org/telegram/android/GcmBroadcastReceiver.java b/TMessagesProj/src/main/java/org/telegram/android/GcmBroadcastReceiver.java index 04f282cb6..7b33e2c6c 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/GcmBroadcastReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/android/GcmBroadcastReceiver.java @@ -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(); diff --git a/TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java b/TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java index cdee9073b..4a77aed99 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java @@ -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 arr = memCache.getFilterKeys(oldKey); diff --git a/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java b/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java index 415bbc5e4..f7a28cf10 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java @@ -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 { diff --git a/TMessagesProj/src/main/java/org/telegram/android/MediaController.java b/TMessagesProj/src/main/java/org/telegram/android/MediaController.java index ad08add77..c3ced1c9a 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MediaController.java @@ -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) { diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java index e9fece9a8..76fb997ee 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java @@ -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 users = new ArrayList(); 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 ids, final ArrayList 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 dialogsToUpdate) { - AndroidUtilities.RunOnUIThread(new Runnable() { + AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { for (HashMap.Entry 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 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> 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; diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java index 9bf30b189..59319703e 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java @@ -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) { diff --git a/TMessagesProj/src/main/java/org/telegram/android/NotificationRepeat.java b/TMessagesProj/src/main/java/org/telegram/android/NotificationRepeat.java index f44a1f0c4..9732b4aa7 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/NotificationRepeat.java +++ b/TMessagesProj/src/main/java/org/telegram/android/NotificationRepeat.java @@ -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(); diff --git a/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java index fa1d9eb6e..9146bd605 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java @@ -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 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 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 messages, final ArrayList users, final ArrayList chats, final ArrayList 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); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java index 0957bd19b..995e6f2f6 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java @@ -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 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); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseContactsSearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseContactsSearchAdapter.java index 53da9988a..17903b397 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseContactsSearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseContactsSearchAdapter.java @@ -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) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsActivitySearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsActivitySearchAdapter.java index c0c16fc71..e01c1c4ce 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsActivitySearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsActivitySearchAdapter.java @@ -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 users, final ArrayList names) { - AndroidUtilities.RunOnUIThread(new Runnable() { + AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { searchResult = users; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MessagesActivitySearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MessagesActivitySearchAdapter.java index 527b85a58..c1d508d73 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MessagesActivitySearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MessagesActivitySearchAdapter.java @@ -44,9 +44,7 @@ public class MessagesActivitySearchAdapter extends BaseContactsSearchAdapter { private ArrayList searchResult = new ArrayList(); private ArrayList searchResultNames = new ArrayList(); private ArrayList searchResultMessages = new ArrayList(); - 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 result, final ArrayList names, final ArrayList 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(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/Animator10.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/Animator10.java new file mode 100644 index 000000000..32e6ccfe1 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/Animator10.java @@ -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 mListeners = null; + ArrayList 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 tmpListeners = (ArrayList) 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 tmpListeners = (ArrayList) 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(); + } + mListeners.add(listener); + } + + public void removeListener(AnimatorListener listener) { + if (mListeners == null) { + return; + } + mListeners.remove(listener); + if (mListeners.size() == 0) { + mListeners = null; + } + } + + public ArrayList getListeners() { + return mListeners; + } + + public void addPauseListener(AnimatorPauseListener listener) { + if (mPauseListeners == null) { + mPauseListeners = new ArrayList(); + } + 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 oldListeners = mListeners; + anim.mListeners = new ArrayList(); + int numListeners = oldListeners.size(); + for (AnimatorListener oldListener : oldListeners) { + anim.mListeners.add(oldListener); + } + } + if (mPauseListeners != null) { + ArrayList oldListeners = mPauseListeners; + anim.mPauseListeners = new ArrayList(); + 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); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/AnimatorListenerAdapter10.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/AnimatorListenerAdapter10.java new file mode 100644 index 000000000..42349cd13 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/AnimatorListenerAdapter10.java @@ -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) { + + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/AnimatorSet10.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/AnimatorSet10.java new file mode 100644 index 000000000..0f91b93b1 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/AnimatorSet10.java @@ -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 mPlayingSet = new ArrayList(); + private HashMap mNodeMap = new HashMap(); + private ArrayList mNodes = new ArrayList(); + private ArrayList mSortedNodes = new ArrayList(); + 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 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 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 getChildAnimations() { + ArrayList childList = new ArrayList(); + 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 tmpListeners = null; + if (mListeners != null) { + tmpListeners = (ArrayList) 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 tmpListeners = (ArrayList) 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 oldListeners = node.animation.getListeners(); + if (oldListeners != null && oldListeners.size() > 0) { + final ArrayList clonedListeners = new + ArrayList(oldListeners); + + for (AnimatorListener listener : clonedListeners) { + if (listener instanceof DependencyListener || + listener instanceof AnimatorSetListener) { + node.animation.removeListener(listener); + } + } + } + } + + final ArrayList nodesToStart = new ArrayList(); + 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) 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 tmpListeners = + (ArrayList) 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 tmpListeners = + (ArrayList) 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(); + anim.mNodeMap = new HashMap(); + anim.mNodes = new ArrayList(); + anim.mSortedNodes = new ArrayList(); + + HashMap nodeCloneMap = new HashMap(); + 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 cloneListeners = nodeClone.animation.getListeners(); + if (cloneListeners != null) { + ArrayList listenersToRemove = null; + for (AnimatorListener listener : cloneListeners) { + if (listener instanceof AnimatorSetListener) { + if (listenersToRemove == null) { + listenersToRemove = new ArrayList(); + } + 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 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 tmpListeners = + (ArrayList) 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 roots = new ArrayList(); + int numNodes = mNodes.size(); + for (Node node : mNodes) { + if (node.dependencies == null || node.dependencies.size() == 0) { + roots.add(node); + } + } + ArrayList tmpRoots = new ArrayList(); + 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(); + } + 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 dependencies = null; + public ArrayList tmpDependencies = null; + public ArrayList nodeDependencies = null; + public ArrayList nodeDependents = null; + public boolean done = false; + + public Node(Animator10 animation) { + this.animation = animation; + } + + public void addDependency(Dependency dependency) { + if (dependencies == null) { + dependencies = new ArrayList(); + nodeDependencies = new ArrayList(); + } + dependencies.add(dependency); + if (!nodeDependencies.contains(dependency.node)) { + nodeDependencies.add(dependency.node); + } + Node dependencyNode = dependency.node; + if (dependencyNode.nodeDependents == null) { + dependencyNode.nodeDependents = new ArrayList(); + } + 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; + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatEvaluator.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatEvaluator.java new file mode 100644 index 000000000..2591ebf74 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatEvaluator.java @@ -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 { + public Float evaluate(float fraction, Number startValue, Number endValue) { + float startFloat = startValue.floatValue(); + return startFloat + fraction * (endValue.floatValue() - startFloat); + } +} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatKeyframeSet.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatKeyframeSet.java new file mode 100644 index 000000000..52d0da5fe --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatKeyframeSet.java @@ -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 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(); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty.java new file mode 100755 index 000000000..870f895c6 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/FloatProperty.java @@ -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 extends Property { + + 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()); + } +} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntEvaluator.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntEvaluator.java new file mode 100644 index 000000000..cd3a19ebe --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntEvaluator.java @@ -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 { + public Integer evaluate(float fraction, Integer startValue, Integer endValue) { + int startInt = startValue; + return (int)(startInt + fraction * (endValue - startInt)); + } +} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntKeyframeSet.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntKeyframeSet.java new file mode 100644 index 000000000..9d58863c8 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntKeyframeSet.java @@ -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 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(); + } +} + diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntProperty.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntProperty.java new file mode 100755 index 000000000..07e72511a --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/IntProperty.java @@ -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 extends Property { + + 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()); + } +} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/Keyframe.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/Keyframe.java new file mode 100644 index 000000000..cb71460cd --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/Keyframe.java @@ -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; + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/KeyframeSet.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/KeyframeSet.java new file mode 100644 index 000000000..98a34ff67 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/KeyframeSet.java @@ -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 mKeyframes; + TypeEvaluator mEvaluator; + + public KeyframeSet(Keyframe... keyframes) { + mNumKeyframes = keyframes.length; + mKeyframes = new ArrayList(); + 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 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; + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/NoSuchPropertyException.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/NoSuchPropertyException.java new file mode 100755 index 000000000..a3c59a4f4 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/NoSuchPropertyException.java @@ -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); + } + +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/ObjectAnimator10.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/ObjectAnimator10.java new file mode 100644 index 000000000..6b97065ba --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/ObjectAnimator10.java @@ -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 PROXY_PROPERTIES = new HashMap(); + + static { + Property ALPHA = new FloatProperty("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 PIVOT_X = new FloatProperty("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 PIVOT_Y = new FloatProperty("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 TRANSLATION_X = new FloatProperty("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 TRANSLATION_Y = new FloatProperty("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 ROTATION = new FloatProperty("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 ROTATION_X = new FloatProperty("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 ROTATION_Y = new FloatProperty("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 SCALE_X = new FloatProperty("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 SCALE_Y = new FloatProperty("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 SCROLL_X = new IntProperty("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 SCROLL_Y = new IntProperty("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 X = new FloatProperty("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 Y = new FloatProperty("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 ObjectAnimator10(T target, Property 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 ObjectAnimator10 ofInt(T target, Property 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 ObjectAnimator10 ofFloat(T target, Property 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 ObjectAnimator10 ofObject(T target, Property property, TypeEvaluator 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(); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/Property.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/Property.java new file mode 100755 index 000000000..96beb2109 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/Property.java @@ -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 { + + private final String mName; + private final Class mType; + + public static Property of(Class hostType, Class valueType, String name) { + return new ReflectiveProperty(hostType, valueType, name); + } + + public Property(Class 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 getType() { + return mType; + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/PropertyValuesHolder.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/PropertyValuesHolder.java new file mode 100644 index 000000000..5f5c6c703 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/PropertyValuesHolder.java @@ -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> sSetterPropertyMap = new HashMap>(); + private static final HashMap> sGetterPropertyMap = new HashMap>(); + + 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 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 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 PropertyValuesHolder ofObject(Property property, + TypeEvaluator 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> propertyMapMap, String prefix, Class valueType) { + Method setterOrGetter = null; + try { + mPropertyMapLock.writeLock().lock(); + HashMap 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(); + 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> sJNISetterPropertyMap = new HashMap>(); + 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> sJNISetterPropertyMap = new HashMap>(); + 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); + } + } +} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/ReflectiveProperty.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/ReflectiveProperty.java new file mode 100755 index 000000000..ce487b4ff --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/ReflectiveProperty.java @@ -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 extends Property { + + 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 propertyHolder, Class 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 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); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/TypeEvaluator.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/TypeEvaluator.java new file mode 100644 index 000000000..33de5d619 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/TypeEvaluator.java @@ -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 { + public T evaluate(float fraction, T startValue, T endValue); +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/ValueAnimator.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/ValueAnimator.java new file mode 100644 index 000000000..b4baca6de --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/ValueAnimator.java @@ -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 sAnimationHandler = new ThreadLocal(); + 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 mUpdateListeners = null; + PropertyValuesHolder[] mValues; + HashMap 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(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 mAnimations = new ArrayList(); + private final ArrayList mTmpAnimations = new ArrayList(); + protected final ArrayList mPendingAnimations = new ArrayList(); + protected final ArrayList mDelayedAnims = new ArrayList(); + private final ArrayList mEndingAnims = new ArrayList(); + private final ArrayList mReadyAnims = new ArrayList(); + + private boolean mAnimationScheduled; + + public void start() { + scheduleAnimation(); + } + + private void doAnimationFrame(long frameTime) { + while (mPendingAnimations.size() > 0) { + ArrayList pendingCopy = (ArrayList) 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(); + } + 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 tmpListeners = (ArrayList) 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 tmpListeners = (ArrayList) 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 tmpListeners = (ArrayList) 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 oldListeners = mUpdateListeners; + anim.mUpdateListeners = new ArrayList(); + 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(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; + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Animation/View10.java b/TMessagesProj/src/main/java/org/telegram/ui/Animation/View10.java new file mode 100644 index 000000000..16ad32004 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Animation/View10.java @@ -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 PROXIES = new WeakHashMap(); + + 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 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); + } + + 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); + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorListenerAdapterProxy.java b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorListenerAdapterProxy.java new file mode 100644 index 000000000..2c416a110 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorListenerAdapterProxy.java @@ -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) { + + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorSetProxy.java b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorSetProxy.java new file mode 100644 index 000000000..49c4c8612 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/AnimatorSetProxy.java @@ -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); + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ObjectAnimatorProxy.java b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ObjectAnimatorProxy.java new file mode 100644 index 000000000..5263dcefd --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ObjectAnimatorProxy.java @@ -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(); + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ViewProxy.java b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ViewProxy.java new file mode 100644 index 000000000..478398bee --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/AnimationCompat/ViewProxy.java @@ -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; + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/ui/ApplicationLoader.java index 04612ddd7..54cc2472d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ApplicationLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ApplicationLoader.java @@ -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); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java index 02849344c..8570dc306 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java @@ -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); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java index 4569a7094..271c863ec 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java @@ -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()) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java index b3ad22bf6..615c05c70 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java @@ -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); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java index 4803d4114..f84ceb243 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java @@ -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(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java index cc6480a07..754a7e164 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java @@ -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(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index a28e59ba2..639d34a47 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -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) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatOrUserCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatOrUserCell.java index 7008878d8..a705adc9a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatOrUserCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatOrUserCell.java @@ -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); - } - } - } - } - } - } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index b1b688769..ec07f5044 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -30,6 +30,7 @@ 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 DialogCell extends BaseCell { private static TextPaint namePaint; @@ -58,8 +59,8 @@ public class DialogCell extends BaseCell { private MessageObject message; private ImageReceiver avatarImage; + private AvatarDrawable avatarDrawable; - private DialogCellLayout cellLayout; private TLRPC.User user = null; private TLRPC.Chat chat = null; private TLRPC.EncryptedChat encryptedChat = null; @@ -67,101 +68,97 @@ public class DialogCell extends BaseCell { public boolean useSeparator = false; + + private int nameLeft; + private int nameTop = AndroidUtilities.dp(13); + private StaticLayout nameLayout; + private boolean drawNameLock; + private boolean drawNameGroup; + private boolean drawNameBroadcast; + private int nameLockLeft; + private int nameLockTop; + + private int timeLeft; + private int timeTop = AndroidUtilities.dp(17); + private StaticLayout timeLayout; + + private boolean drawCheck1; + private boolean drawCheck2; + private boolean drawClock; + private int checkDrawLeft; + private int checkDrawTop = AndroidUtilities.dp(18); + private int halfCheckDrawLeft; + + private int messageTop = AndroidUtilities.dp(40); + private int messageLeft; + private StaticLayout messageLayout; + + private boolean drawError; + private int errorTop = AndroidUtilities.dp(39); + private int errorLeft; + + private boolean drawCount; + private int countTop = AndroidUtilities.dp(39); + private int countLeft; + private int countWidth; + private StaticLayout countLayout; + + private int avatarTop = AndroidUtilities.dp(10); + private void init() { if (namePaint == null) { namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); - namePaint.setTextSize(AndroidUtilities.dp(19)); + namePaint.setTextSize(AndroidUtilities.dp(17)); namePaint.setColor(0xff222222); namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - } - if (nameEncryptedPaint == null) { nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); - nameEncryptedPaint.setTextSize(AndroidUtilities.dp(19)); + nameEncryptedPaint.setTextSize(AndroidUtilities.dp(17)); nameEncryptedPaint.setColor(0xff00a60e); nameEncryptedPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - } - if (nameUnknownPaint == null) { nameUnknownPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); - nameUnknownPaint.setTextSize(AndroidUtilities.dp(19)); - nameUnknownPaint.setColor(0xff316f9f); + nameUnknownPaint.setTextSize(AndroidUtilities.dp(17)); + nameUnknownPaint.setColor(0xff548ab6); nameUnknownPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - } - if (messagePaint == null) { messagePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); messagePaint.setTextSize(AndroidUtilities.dp(16)); - messagePaint.setColor(0xff808080); - } + messagePaint.setColor(0xff8f8f8f); - if (linePaint == null) { linePaint = new Paint(); linePaint.setColor(0xffdcdcdc); - } - if (messagePrintingPaint == null) { messagePrintingPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); messagePrintingPaint.setTextSize(AndroidUtilities.dp(16)); - messagePrintingPaint.setColor(0xff316f9f); - } + messagePrintingPaint.setColor(0xff548ab6); - if (timePaint == null) { timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); - timePaint.setTextSize(AndroidUtilities.dp(14)); - timePaint.setColor(0xff9e9e9e); - } + timePaint.setTextSize(AndroidUtilities.dp(13)); + timePaint.setColor(0xff999999); - if (countPaint == null) { countPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); countPaint.setTextSize(AndroidUtilities.dp(13)); countPaint.setColor(0xffffffff); - } + countPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - if (lockDrawable == null) { lockDrawable = getResources().getDrawable(R.drawable.ic_lock_green); - } - - if (checkDrawable == null) { checkDrawable = getResources().getDrawable(R.drawable.dialogs_check); - } - - if (halfCheckDrawable == null) { halfCheckDrawable = getResources().getDrawable(R.drawable.dialogs_halfcheck); - } - - if (clockDrawable == null) { clockDrawable = getResources().getDrawable(R.drawable.msg_clock); - } - - if (errorDrawable == null) { errorDrawable = getResources().getDrawable(R.drawable.dialogs_warning); - } - - if (countDrawable == null) { countDrawable = getResources().getDrawable(R.drawable.dialogs_badge); - } - - if (groupDrawable == null) { groupDrawable = getResources().getDrawable(R.drawable.grouplist); - } - - if (broadcastDrawable == null) { broadcastDrawable = getResources().getDrawable(R.drawable.broadcast); } - - if (avatarImage == null) { - avatarImage = new ImageReceiver(this); - } - - if (cellLayout == null) { - cellLayout = new DialogCellLayout(); - } } public DialogCell(Context context) { super(context); init(); + avatarImage = new ImageReceiver(this); + avatarImage.setRoundRadius(AndroidUtilities.dp(26)); + avatarDrawable = new AvatarDrawable(); } public void setDialog(long dialog_id, MessageObject messageObject, boolean usePrintStrings, int date, int unread) { @@ -187,7 +184,7 @@ public class DialogCell extends BaseCell { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(70)); + setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(72)); } @Override @@ -202,7 +199,358 @@ public class DialogCell extends BaseCell { } public void buildLayout() { - cellLayout.build(getMeasuredWidth(), getMeasuredHeight()); + String nameString = ""; + String timeString = ""; + String countString = null; + CharSequence messageString = ""; + CharSequence printingString = null; + if (allowPrintStrings) { + printingString = MessagesController.getInstance().printingStrings.get(currentDialogId); + } + TextPaint currentNamePaint = namePaint; + TextPaint currentMessagePaint = messagePaint; + boolean checkMessage = true; + + drawNameGroup = false; + drawNameBroadcast = false; + drawNameLock = false; + + if (encryptedChat != null) { + drawNameLock = true; + nameLockTop = AndroidUtilities.dp(15); + if (!LocaleController.isRTL) { + nameLockLeft = AndroidUtilities.dp(72); + nameLeft = AndroidUtilities.dp(76) + lockDrawable.getIntrinsicWidth(); + } else { + nameLockLeft = getMeasuredWidth() - AndroidUtilities.dp(72) - lockDrawable.getIntrinsicWidth(); + nameLeft = AndroidUtilities.dp(14); + } + } else { + if (chat != null) { + if (chat.id < 0) { + drawNameBroadcast = true; + } else { + drawNameGroup = true; + } + nameLockTop = AndroidUtilities.dp(16); + if (!LocaleController.isRTL) { + nameLockLeft = AndroidUtilities.dp(72); + nameLeft = AndroidUtilities.dp(76) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth()); + } else { + nameLockLeft = getMeasuredWidth() - AndroidUtilities.dp(72) - (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth()); + nameLeft = AndroidUtilities.dp(14); + } + } else { + if (!LocaleController.isRTL) { + nameLeft = AndroidUtilities.dp(72); + } else { + nameLeft = AndroidUtilities.dp(14); + } + } + } + + if (message == null) { + if (printingString != null) { + lastPrintString = messageString = printingString; + currentMessagePaint = messagePrintingPaint; + } else { + lastPrintString = null; + if (encryptedChat != null) { + currentMessagePaint = messagePrintingPaint; + if (encryptedChat instanceof TLRPC.TL_encryptedChatRequested) { + messageString = LocaleController.getString("EncryptionProcessing", R.string.EncryptionProcessing); + } else if (encryptedChat instanceof TLRPC.TL_encryptedChatWaiting) { + if (user != null && user.first_name != null) { + messageString = LocaleController.formatString("AwaitingEncryption", R.string.AwaitingEncryption, user.first_name); + } else { + messageString = LocaleController.formatString("AwaitingEncryption", R.string.AwaitingEncryption, ""); + } + } else if (encryptedChat instanceof TLRPC.TL_encryptedChatDiscarded) { + messageString = LocaleController.getString("EncryptionRejected", R.string.EncryptionRejected); + } else if (encryptedChat instanceof TLRPC.TL_encryptedChat) { + if (encryptedChat.admin_id == UserConfig.getClientUserId()) { + if (user != null && user.first_name != null) { + messageString = LocaleController.formatString("EncryptedChatStartedOutgoing", R.string.EncryptedChatStartedOutgoing, user.first_name); + } else { + messageString = LocaleController.formatString("EncryptedChatStartedOutgoing", R.string.EncryptedChatStartedOutgoing, ""); + } + } else { + messageString = LocaleController.getString("EncryptedChatStartedIncoming", R.string.EncryptedChatStartedIncoming); + } + } + } + } + if (lastMessageDate != 0) { + timeString = LocaleController.stringForMessageListDate(lastMessageDate); + } + drawCheck1 = false; + drawCheck2 = false; + drawClock = false; + drawCount = false; + drawError = false; + } else { + TLRPC.User fromUser = MessagesController.getInstance().getUser(message.messageOwner.from_id); + + if (lastMessageDate != 0) { + timeString = LocaleController.stringForMessageListDate(lastMessageDate); + } else { + timeString = LocaleController.stringForMessageListDate(message.messageOwner.date); + } + if (printingString != null) { + lastPrintString = messageString = printingString; + currentMessagePaint = messagePrintingPaint; + } else { + lastPrintString = null; + if (message.messageOwner instanceof TLRPC.TL_messageService) { + messageString = message.messageText; + currentMessagePaint = messagePrintingPaint; + } else { + if (chat != null && chat.id > 0) { + String name = ""; + if (message.isFromMe()) { + name = LocaleController.getString("FromYou", R.string.FromYou); + } else { + if (fromUser != null) { + if (fromUser.first_name.length() > 0) { + name = fromUser.first_name; + } else { + name = fromUser.last_name; + } + } + } + checkMessage = false; + if (message.messageOwner.media != null && !(message.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) { + currentMessagePaint = messagePrintingPaint; + messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("%s: %s", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); + } else { + if (message.messageOwner.message != null) { + messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("%s: %s", name, message.messageOwner.message.replace("\n", " ").replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); + } + } + } else { + messageString = message.messageText; + if (message.messageOwner.media != null && !(message.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) { + currentMessagePaint = messagePrintingPaint; + } + } + } + } + + if (unreadCount != 0) { + drawCount = true; + countString = String.format("%d", unreadCount); + } else { + drawCount = false; + } + + if (message.isFromMe() && message.isOut()) { + if (message.isSending()) { + drawCheck1 = false; + drawCheck2 = false; + drawClock = true; + drawError = false; + } else if (message.isSendError()) { + drawCheck1 = false; + drawCheck2 = false; + drawClock = false; + drawError = true; + drawCount = false; + } else if (message.isSent()) { + if (!message.isUnread()) { + drawCheck1 = true; + drawCheck2 = true; + } else { + drawCheck1 = false; + drawCheck2 = true; + } + drawClock = false; + drawError = false; + } + } else { + drawCheck1 = false; + drawCheck2 = false; + drawClock = false; + drawError = false; + } + } + + int timeWidth = (int) Math.ceil(timePaint.measureText(timeString)); + timeLayout = new StaticLayout(timeString, timePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + if (!LocaleController.isRTL) { + timeLeft = getMeasuredWidth() - AndroidUtilities.dp(15) - timeWidth; + } else { + timeLeft = AndroidUtilities.dp(15); + } + + if (chat != null) { + nameString = chat.title; + } else if (user != null) { + if (user.id / 1000 != 777 && user.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(user.id) == null) { + if (ContactsController.getInstance().contactsDict.size() == 0 && (!ContactsController.getInstance().contactsLoaded || ContactsController.getInstance().isLoadingContacts())) { + nameString = ContactsController.formatName(user.first_name, user.last_name); + } else { + if (user.phone != null && user.phone.length() != 0) { + nameString = PhoneFormat.getInstance().format("+" + user.phone); + } else { + currentNamePaint = nameUnknownPaint; + nameString = ContactsController.formatName(user.first_name, user.last_name); + } + } + } else { + nameString = ContactsController.formatName(user.first_name, user.last_name); + } + if (encryptedChat != null) { + currentNamePaint = nameEncryptedPaint; + } + } + if (nameString.length() == 0) { + nameString = LocaleController.getString("HiddenName", R.string.HiddenName); + } + + int nameWidth; + + if (!LocaleController.isRTL) { + nameWidth = getMeasuredWidth() - nameLeft - AndroidUtilities.dp(14) - timeWidth; + } else { + nameWidth = getMeasuredWidth() - nameLeft - AndroidUtilities.dp(72) - timeWidth; + nameLeft += timeWidth; + } + if (drawNameLock) { + nameWidth -= AndroidUtilities.dp(4) + lockDrawable.getIntrinsicWidth(); + } else if (drawNameGroup) { + nameWidth -= AndroidUtilities.dp(4) + groupDrawable.getIntrinsicWidth(); + } else if (drawNameBroadcast) { + nameWidth -= AndroidUtilities.dp(4) + broadcastDrawable.getIntrinsicWidth(); + } + if (drawClock) { + int w = clockDrawable.getIntrinsicWidth() + AndroidUtilities.dp(5); + nameWidth -= w; + if (!LocaleController.isRTL) { + checkDrawLeft = timeLeft - w; + } else { + checkDrawLeft = timeLeft + timeWidth + AndroidUtilities.dp(5); + nameLeft += w; + } + } else if (drawCheck2) { + int w = checkDrawable.getIntrinsicWidth() + AndroidUtilities.dp(5); + nameWidth -= w; + if (drawCheck1) { + nameWidth -= halfCheckDrawable.getIntrinsicWidth() - AndroidUtilities.dp(8); + if (!LocaleController.isRTL) { + halfCheckDrawLeft = timeLeft - w; + checkDrawLeft = halfCheckDrawLeft - AndroidUtilities.dp(5.5f); + } else { + checkDrawLeft = timeLeft + timeWidth + AndroidUtilities.dp(5); + halfCheckDrawLeft = checkDrawLeft + AndroidUtilities.dp(5.5f); + nameLeft += w + halfCheckDrawable.getIntrinsicWidth() - AndroidUtilities.dp(8); + } + } else { + if (!LocaleController.isRTL) { + checkDrawLeft = timeLeft - w; + } else { + checkDrawLeft = timeLeft + timeWidth + AndroidUtilities.dp(5); + nameLeft += w; + } + } + } + + CharSequence nameStringFinal = TextUtils.ellipsize(nameString.replace("\n", " "), currentNamePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END); + try { + nameLayout = new StaticLayout(nameStringFinal, currentNamePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + + int messageWidth = getMeasuredWidth() - AndroidUtilities.dp(88); + int avatarLeft; + if (!LocaleController.isRTL) { + messageLeft = AndroidUtilities.dp(72); + avatarLeft = AndroidUtilities.dp(9); + } else { + messageLeft = AndroidUtilities.dp(16); + avatarLeft = getMeasuredWidth() - AndroidUtilities.dp(61); + } + avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(52), AndroidUtilities.dp(52)); + if (drawError) { + int w = errorDrawable.getIntrinsicWidth() + AndroidUtilities.dp(8); + messageWidth -= w; + if (!LocaleController.isRTL) { + errorLeft = getMeasuredWidth() - errorDrawable.getIntrinsicWidth() - AndroidUtilities.dp(11); + } else { + errorLeft = AndroidUtilities.dp(11); + messageLeft += w; + } + } else if (countString != null) { + countWidth = Math.max(AndroidUtilities.dp(12), (int)Math.ceil(countPaint.measureText(countString))); + countLayout = new StaticLayout(countString, countPaint, countWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false); + int w = countWidth + AndroidUtilities.dp(18); + messageWidth -= w; + if (!LocaleController.isRTL) { + countLeft = getMeasuredWidth() - countWidth - AndroidUtilities.dp(19); + } else { + countLeft = AndroidUtilities.dp(19); + messageLeft += w; + } + drawCount = true; + } else { + drawCount = false; + } + + if (checkMessage) { + if (messageString == null) { + messageString = ""; + } + String mess = messageString.toString().replace("\n", " "); + if (mess.length() > 150) { + mess = mess.substring(0, 150); + } + messageString = Emoji.replaceEmoji(mess, messagePaint.getFontMetricsInt(), AndroidUtilities.dp(17)); + } + + CharSequence messageStringFinal = TextUtils.ellipsize(messageString, currentMessagePaint, messageWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END); + messageLayout = new StaticLayout(messageStringFinal, currentMessagePaint, messageWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + + double widthpx = 0; + float left = 0; + if (LocaleController.isRTL) { + if (nameLayout != null && nameLayout.getLineCount() > 0) { + left = nameLayout.getLineLeft(0); + if (left == 0) { + widthpx = Math.ceil(nameLayout.getLineWidth(0)); + if (widthpx < nameWidth) { + nameLeft += (nameWidth - widthpx); + } + } + } + if (messageLayout.getLineCount() > 0) { + left = messageLayout.getLineLeft(0); + if (left == 0) { + widthpx = Math.ceil(messageLayout.getLineWidth(0)); + if (widthpx < messageWidth) { + messageLeft += (messageWidth - widthpx); + } + } + } + } else { + if (nameLayout != null && nameLayout.getLineCount() > 0) { + left = nameLayout.getLineRight(0); + if (left == nameWidth) { + widthpx = Math.ceil(nameLayout.getLineWidth(0)); + if (widthpx < nameWidth) { + nameLeft -= (nameWidth - widthpx); + } + } + } + if (messageLayout.getLineCount() > 0) { + left = messageLayout.getLineRight(0); + if (left == messageWidth) { + widthpx = Math.ceil(messageLayout.getLineWidth(0)); + if (widthpx < messageWidth) { + messageLeft -= (messageWidth - widthpx); + } + } + } + } } public void update(int mask) { @@ -265,24 +613,19 @@ public class DialogCell extends BaseCell { } } - 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); } - 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(); @@ -299,468 +642,68 @@ public class DialogCell extends BaseCell { return; } - if (cellLayout == null) { - requestLayout(); - return; - } - - 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); } - if (cellLayout.nameLayout != null) { + if (nameLayout != null) { canvas.save(); - canvas.translate(cellLayout.nameLeft, cellLayout.nameTop); - cellLayout.nameLayout.draw(canvas); + canvas.translate(nameLeft, nameTop); + nameLayout.draw(canvas); canvas.restore(); } canvas.save(); - canvas.translate(cellLayout.timeLeft, cellLayout.timeTop); - cellLayout.timeLayout.draw(canvas); + canvas.translate(timeLeft, timeTop); + timeLayout.draw(canvas); canvas.restore(); canvas.save(); - canvas.translate(cellLayout.messageLeft, cellLayout.messageTop); - cellLayout.messageLayout.draw(canvas); + canvas.translate(messageLeft, messageTop); + messageLayout.draw(canvas); canvas.restore(); - if (cellLayout.drawClock) { - setDrawableBounds(clockDrawable, cellLayout.checkDrawLeft, cellLayout.checkDrawTop); + if (drawClock) { + setDrawableBounds(clockDrawable, checkDrawLeft, checkDrawTop); clockDrawable.draw(canvas); - } else if (cellLayout.drawCheck2) { - if (cellLayout.drawCheck1) { - setDrawableBounds(halfCheckDrawable, cellLayout.halfCheckDrawLeft, cellLayout.checkDrawTop); + } else if (drawCheck2) { + if (drawCheck1) { + setDrawableBounds(halfCheckDrawable, halfCheckDrawLeft, checkDrawTop); halfCheckDrawable.draw(canvas); - setDrawableBounds(checkDrawable, cellLayout.checkDrawLeft, cellLayout.checkDrawTop); + setDrawableBounds(checkDrawable, checkDrawLeft, checkDrawTop); checkDrawable.draw(canvas); } else { - setDrawableBounds(checkDrawable, cellLayout.checkDrawLeft, cellLayout.checkDrawTop); + setDrawableBounds(checkDrawable, checkDrawLeft, checkDrawTop); checkDrawable.draw(canvas); } } - if (cellLayout.drawError) { - setDrawableBounds(errorDrawable, cellLayout.errorLeft, cellLayout.errorTop); + if (drawError) { + setDrawableBounds(errorDrawable, errorLeft, errorTop); errorDrawable.draw(canvas); - } else if (cellLayout.drawCount) { - setDrawableBounds(countDrawable, cellLayout.countLeft - AndroidUtilities.dp(5), cellLayout.countTop, cellLayout.countWidth + AndroidUtilities.dp(10), countDrawable.getIntrinsicHeight()); + } else if (drawCount) { + setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight()); countDrawable.draw(canvas); canvas.save(); - canvas.translate(cellLayout.countLeft, cellLayout.countTop + AndroidUtilities.dp(3)); - cellLayout.countLayout.draw(canvas); + canvas.translate(countLeft, countTop + AndroidUtilities.dp(4)); + countLayout.draw(canvas); canvas.restore(); } avatarImage.draw(canvas); if (useSeparator) { - int h = getMeasuredHeight(); - if (AndroidUtilities.isTablet()) { - canvas.drawLine(0, h - 1, getMeasuredWidth(), h - 1, linePaint); - } else { - canvas.drawLine(AndroidUtilities.dp(11), h - 1, getMeasuredWidth() - AndroidUtilities.dp(11), h - 1, linePaint); - } - } - } - - private class DialogCellLayout { - private int nameLeft; - private int nameTop = AndroidUtilities.dp(10); - private int nameWidth; - private StaticLayout nameLayout; - private boolean drawNameLock; - private boolean drawNameGroup; - private boolean drawNameBroadcast; - private int nameLockLeft; - private int nameLockTop; - - private int timeLeft; - private int timeTop = AndroidUtilities.dp(13); - private int timeWidth; - private StaticLayout timeLayout; - - private boolean drawCheck1; - private boolean drawCheck2; - private boolean drawClock; - private int checkDrawLeft; - private int checkDrawTop = AndroidUtilities.dp(15); - private int halfCheckDrawLeft; - - private int messageTop = AndroidUtilities.dp(40); - private int messageLeft; - private int messageWidth; - private StaticLayout messageLayout; - - private boolean drawError; - private int errorTop = AndroidUtilities.dp(37); - private int errorLeft; - - private boolean drawCount; - private int countTop = AndroidUtilities.dp(37); - private int countLeft; - private int countWidth; - private StaticLayout countLayout; - - private int avatarTop = AndroidUtilities.dp(8); - private int avatarLeft; - - public void build(int width, int height) { - String nameString = ""; - String timeString = ""; - String countString = null; - CharSequence messageString = ""; - CharSequence printingString = null; - if (allowPrintStrings) { - printingString = MessagesController.getInstance().printingStrings.get(currentDialogId); - } - TextPaint currentNamePaint = namePaint; - TextPaint currentMessagePaint = messagePaint; - boolean checkMessage = true; - - drawNameGroup = false; - drawNameBroadcast = false; - drawNameLock = false; - - if (encryptedChat != null) { - drawNameLock = true; - nameLockTop = AndroidUtilities.dp(13); - if (!LocaleController.isRTL) { - nameLockLeft = AndroidUtilities.dp(77); - nameLeft = AndroidUtilities.dp(81) + lockDrawable.getIntrinsicWidth(); - } else { - nameLockLeft = width - AndroidUtilities.dp(77) - lockDrawable.getIntrinsicWidth(); - nameLeft = AndroidUtilities.dp(14); - } - } else { - if (chat != null) { - if (chat.id < 0) { - drawNameBroadcast = true; - } else { - drawNameGroup = true; - } - nameLockTop = AndroidUtilities.dp(14); - if (!LocaleController.isRTL) { - nameLockLeft = AndroidUtilities.dp(77); - nameLeft = AndroidUtilities.dp(81) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth()); - } else { - nameLockLeft = width - AndroidUtilities.dp(77) - (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth()); - nameLeft = AndroidUtilities.dp(14); - } - } else { - if (!LocaleController.isRTL) { - nameLeft = AndroidUtilities.dp(77); - } else { - nameLeft = AndroidUtilities.dp(14); - } - } - } - - if (message == null) { - if (printingString != null) { - lastPrintString = messageString = printingString; - currentMessagePaint = messagePrintingPaint; - } else { - lastPrintString = null; - if (encryptedChat != null) { - currentMessagePaint = messagePrintingPaint; - if (encryptedChat instanceof TLRPC.TL_encryptedChatRequested) { - messageString = LocaleController.getString("EncryptionProcessing", R.string.EncryptionProcessing); - } else if (encryptedChat instanceof TLRPC.TL_encryptedChatWaiting) { - if (user != null && user.first_name != null) { - messageString = LocaleController.formatString("AwaitingEncryption", R.string.AwaitingEncryption, user.first_name); - } else { - messageString = LocaleController.formatString("AwaitingEncryption", R.string.AwaitingEncryption, ""); - } - } else if (encryptedChat instanceof TLRPC.TL_encryptedChatDiscarded) { - messageString = LocaleController.getString("EncryptionRejected", R.string.EncryptionRejected); - } else if (encryptedChat instanceof TLRPC.TL_encryptedChat) { - if (encryptedChat.admin_id == UserConfig.getClientUserId()) { - if (user != null && user.first_name != null) { - messageString = LocaleController.formatString("EncryptedChatStartedOutgoing", R.string.EncryptedChatStartedOutgoing, user.first_name); - } else { - messageString = LocaleController.formatString("EncryptedChatStartedOutgoing", R.string.EncryptedChatStartedOutgoing, ""); - } - } else { - messageString = LocaleController.getString("EncryptedChatStartedIncoming", R.string.EncryptedChatStartedIncoming); - } - } - } - } - if (lastMessageDate != 0) { - timeString = LocaleController.stringForMessageListDate(lastMessageDate); - } - drawCheck1 = false; - drawCheck2 = false; - drawClock = false; - drawCount = false; - drawError = false; - } else { - TLRPC.User fromUser = MessagesController.getInstance().getUser(message.messageOwner.from_id); - - if (lastMessageDate != 0) { - timeString = LocaleController.stringForMessageListDate(lastMessageDate); - } else { - timeString = LocaleController.stringForMessageListDate(message.messageOwner.date); - } - if (printingString != null) { - lastPrintString = messageString = printingString; - currentMessagePaint = messagePrintingPaint; - } else { - lastPrintString = null; - if (message.messageOwner instanceof TLRPC.TL_messageService) { - messageString = message.messageText; - currentMessagePaint = messagePrintingPaint; - } else { - if (chat != null && chat.id > 0) { - String name = ""; - if (message.isFromMe()) { - name = LocaleController.getString("FromYou", R.string.FromYou); - } else { - if (fromUser != null) { - if (fromUser.first_name.length() > 0) { - name = fromUser.first_name; - } else { - name = fromUser.last_name; - } - } - } - checkMessage = false; - if (message.messageOwner.media != null && !(message.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) { - currentMessagePaint = messagePrintingPaint; - messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("%s: %s", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); - } else { - if (message.messageOwner.message != null) { - messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("%s: %s", name, message.messageOwner.message.replace("\n", " ").replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); - } - } - } else { - messageString = message.messageText; - if (message.messageOwner.media != null && !(message.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) { - currentMessagePaint = messagePrintingPaint; - } - } - } - } - - if (unreadCount != 0) { - drawCount = true; - countString = String.format("%d", unreadCount); - } else { - drawCount = false; - } - - if (message.isFromMe() && message.isOut()) { - if (message.isSending()) { - drawCheck1 = false; - drawCheck2 = false; - drawClock = true; - drawError = false; - } else if (message.isSendError()) { - drawCheck1 = false; - drawCheck2 = false; - drawClock = false; - drawError = true; - drawCount = false; - } else if (message.isSent()) { - if (!message.isUnread()) { - drawCheck1 = true; - drawCheck2 = true; - } else { - drawCheck1 = false; - drawCheck2 = true; - } - drawClock = false; - drawError = false; - } - } else { - drawCheck1 = false; - drawCheck2 = false; - drawClock = false; - drawError = false; - } - } - - timeWidth = (int)Math.ceil(timePaint.measureText(timeString)); - timeLayout = new StaticLayout(timeString, timePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - if (!LocaleController.isRTL) { - timeLeft = width - AndroidUtilities.dp(11) - timeWidth; - } else { - timeLeft = AndroidUtilities.dp(11); - } - - if (chat != null) { - nameString = chat.title; - } else if (user != null) { - if (user.id / 1000 != 777 && user.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(user.id) == null) { - if (ContactsController.getInstance().contactsDict.size() == 0 && (!ContactsController.getInstance().contactsLoaded || ContactsController.getInstance().isLoadingContacts())) { - nameString = ContactsController.formatName(user.first_name, user.last_name); - } else { - if (user.phone != null && user.phone.length() != 0) { - nameString = PhoneFormat.getInstance().format("+" + user.phone); - } else { - currentNamePaint = nameUnknownPaint; - nameString = ContactsController.formatName(user.first_name, user.last_name); - } - } - } else { - nameString = ContactsController.formatName(user.first_name, user.last_name); - } - if (encryptedChat != null) { - currentNamePaint = nameEncryptedPaint; - } - } - if (nameString.length() == 0) { - nameString = LocaleController.getString("HiddenName", R.string.HiddenName); - } - - if (!LocaleController.isRTL) { - nameWidth = width - nameLeft - AndroidUtilities.dp(14) - timeWidth; - } else { - nameWidth = width - nameLeft - AndroidUtilities.dp(77) - timeWidth; - nameLeft += timeWidth; - } - if (drawNameLock) { - nameWidth -= AndroidUtilities.dp(4) + lockDrawable.getIntrinsicWidth(); - } else if (drawNameGroup) { - nameWidth -= AndroidUtilities.dp(4) + groupDrawable.getIntrinsicWidth(); - } else if (drawNameBroadcast) { - nameWidth -= AndroidUtilities.dp(4) + broadcastDrawable.getIntrinsicWidth(); - } - if (drawClock) { - int w = clockDrawable.getIntrinsicWidth() + AndroidUtilities.dp(2); - nameWidth -= w; - if (!LocaleController.isRTL) { - checkDrawLeft = timeLeft - w; - } else { - checkDrawLeft = timeLeft + timeWidth + AndroidUtilities.dp(2); - nameLeft += w; - } - } else if (drawCheck2) { - int w = checkDrawable.getIntrinsicWidth() + AndroidUtilities.dp(2); - nameWidth -= w; - if (drawCheck1) { - nameWidth -= halfCheckDrawable.getIntrinsicWidth() - AndroidUtilities.dp(5); - if (!LocaleController.isRTL) { - halfCheckDrawLeft = timeLeft - w; - checkDrawLeft = halfCheckDrawLeft - AndroidUtilities.dp(5); - } else { - checkDrawLeft = timeLeft + timeWidth + AndroidUtilities.dp(2); - halfCheckDrawLeft = checkDrawLeft + AndroidUtilities.dp(5); - nameLeft += w + halfCheckDrawable.getIntrinsicWidth() - AndroidUtilities.dp(5); - } - } else { - if (!LocaleController.isRTL) { - checkDrawLeft = timeLeft - w; - } else { - checkDrawLeft = timeLeft + timeWidth + AndroidUtilities.dp(2); - nameLeft += w; - } - } - } - - CharSequence nameStringFinal = TextUtils.ellipsize(nameString.replace("\n", " "), currentNamePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END); - try { - nameLayout = new StaticLayout(nameStringFinal, currentNamePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - - messageWidth = width - AndroidUtilities.dp(88); - if (!LocaleController.isRTL) { - messageLeft = AndroidUtilities.dp(77); - avatarLeft = AndroidUtilities.dp(11); - } else { - messageLeft = AndroidUtilities.dp(11); - avatarLeft = width - AndroidUtilities.dp(65); - } - avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(54), AndroidUtilities.dp(54)); - if (drawError) { - int w = errorDrawable.getIntrinsicWidth() + AndroidUtilities.dp(8); - messageWidth -= w; - if (!LocaleController.isRTL) { - errorLeft = width - errorDrawable.getIntrinsicWidth() - AndroidUtilities.dp(11); - } else { - errorLeft = AndroidUtilities.dp(11); - messageLeft += w; - } - } else if (countString != null) { - countWidth = Math.max(AndroidUtilities.dp(12), (int)Math.ceil(countPaint.measureText(countString))); - countLayout = new StaticLayout(countString, countPaint, countWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false); - int w = countWidth + AndroidUtilities.dp(18); - messageWidth -= w; - if (!LocaleController.isRTL) { - countLeft = width - countWidth - AndroidUtilities.dp(16); - } else { - countLeft = AndroidUtilities.dp(16); - messageLeft += w; - } - drawCount = true; - } else { - drawCount = false; - } - - if (checkMessage) { - if (messageString == null) { - messageString = ""; - } - String mess = messageString.toString().replace("\n", " "); - if (mess.length() > 150) { - mess = mess.substring(0, 150); - } - messageString = Emoji.replaceEmoji(mess, messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); - } - - CharSequence messageStringFinal = TextUtils.ellipsize(messageString, currentMessagePaint, messageWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END); - messageLayout = new StaticLayout(messageStringFinal, currentMessagePaint, messageWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - - double widthpx = 0; - float left = 0; if (LocaleController.isRTL) { - if (nameLayout != null && nameLayout.getLineCount() > 0) { - left = nameLayout.getLineLeft(0); - if (left == 0) { - widthpx = Math.ceil(nameLayout.getLineWidth(0)); - if (widthpx < nameWidth) { - nameLeft += (nameWidth - widthpx); - } - } - } - if (messageLayout.getLineCount() > 0) { - left = messageLayout.getLineLeft(0); - if (left == 0) { - widthpx = Math.ceil(messageLayout.getLineWidth(0)); - if (widthpx < messageWidth) { - messageLeft += (messageWidth - widthpx); - } - } - } + canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth() - AndroidUtilities.dp(72), getMeasuredHeight() - 1, linePaint); } else { - if (nameLayout != null && nameLayout.getLineCount() > 0) { - left = nameLayout.getLineRight(0); - if (left == nameWidth) { - widthpx = Math.ceil(nameLayout.getLineWidth(0)); - if (widthpx < nameWidth) { - nameLeft -= (nameWidth - widthpx); - } - } - } - if (messageLayout.getLineCount() > 0) { - left = messageLayout.getLineRight(0); - if (left == messageWidth) { - widthpx = Math.ceil(messageLayout.getLineWidth(0)); - if (widthpx < messageWidth) { - messageLeft -= (messageWidth - widthpx); - } - } - } + canvas.drawLine(AndroidUtilities.dp(72), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, linePaint); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 565e39dc0..e30088ce4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -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 { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java index 1dc77830f..38725543e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java @@ -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) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java index b136ba519..28a9a3c32 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java @@ -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) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java index 6097a7315..79bfe6efe 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java @@ -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; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java index 7430f2dae..4419303b7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java @@ -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 arrCounties) { - AndroidUtilities.RunOnUIThread(new Runnable() { + AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { searchResult = arrCounties; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java index 293fc3a45..d8d6cd31e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java @@ -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) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java index a8eccbdb4..2df5cc6de 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java @@ -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 contactsCopy = new ArrayList(); @@ -439,7 +440,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen } private void updateSearchResults(final ArrayList users, final ArrayList 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); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java index 82d19e28e..36dcce7de 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java @@ -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 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) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java index affe474ea..0db139257 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java @@ -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)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java index 0ab87bc8b..848bb665b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java @@ -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 arrCounties) { - AndroidUtilities.RunOnUIThread(new Runnable() { + AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { searchResult = arrCounties; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 9806c5d89..b552964f9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -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) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java index e3e065e87..0685347b9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java @@ -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)); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index 990fbc452..8b22ef211 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -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() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java index 79d0926cf..a038fba8f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java @@ -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; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityRegisterView.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityRegisterView.java index be477fe5f..fab0b4d07 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityRegisterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivityRegisterView.java @@ -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; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivitySmsView.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivitySmsView.java index d9187fba1..6c5898cd9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivitySmsView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivitySmsView.java @@ -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) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java index 0eb4b6c5b..5fae08af3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java @@ -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 { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java index b6592d9a5..bbec10b25 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java @@ -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; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java index 8b93ea57c..40b82e88b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java @@ -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); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 343b90448..92bd205b9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -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() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java index 3e7a73393..afbd48054 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java @@ -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); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java index 2a6ff7931..58c0ccc6f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java @@ -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)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java index a0164a47a..bf4d87784 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java @@ -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); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java index 1c10cb54c..2fb8fe676 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java @@ -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 users = new ArrayList(); 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; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsBlockedUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsBlockedUsersActivity.java index 49f3f8791..96ffb2676 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsBlockedUsersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsBlockedUsersActivity.java @@ -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() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeUsernameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeUsernameActivity.java index 3f893ca79..1a632b9f1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeUsernameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsChangeUsernameActivity.java @@ -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 { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java index 0e2f2c0ba..37e434f58 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java @@ -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; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java index 8731ed5d9..881d75bf2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java @@ -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)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); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java index 236ce54b8..46bdd0189 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java @@ -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) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java index b73a8b472..ebb8fbcb9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java @@ -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; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBar.java index d616b9dde..f297e29f7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBar.java @@ -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 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() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayer.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayer.java index 1dfef5f50..a2a833774 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayer.java @@ -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); } } \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayout.java index e4ce88d0c..e49828764 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayout.java @@ -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 animators = new ArrayList(); + 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); + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenu.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenu.java index ae1288bdb..cbce74e27 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenu.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenu.java @@ -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 diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenuItem.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenuItem.java index c3a3937d8..26f66390b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenuItem.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenuItem.java @@ -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); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/DrawerLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/DrawerLayout.java new file mode 100644 index 000000000..3bddf4e35 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/DrawerLayout.java @@ -0,0 +1,1213 @@ +/* + * 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.content.Context; +import android.os.Build; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowInsets; +import android.widget.FrameLayout; + +public class DrawerLayout extends FrameLayout { + + private Object mLastInsets; + + public DrawerLayout(Context context) { + super(context); + + setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); + setFocusableInTouchMode(true); + + if (Build.VERSION.SDK_INT >= 21) { + setFitsSystemWindows(true); + configureApplyInsets(this); + } + } + + static class InsetsListener implements View.OnApplyWindowInsetsListener { + @Override + public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { + final DrawerLayout drawerLayout = (DrawerLayout) v; + drawerLayout.setChildInsets(insets, insets.getSystemWindowInsetTop() > 0); + return insets.consumeSystemWindowInsets(); + } + } + + public void configureApplyInsets(View drawerLayout) { + if (Build.VERSION.SDK_INT >= 21) { + drawerLayout.setOnApplyWindowInsetsListener(new InsetsListener()); + drawerLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } + } + + public void dispatchChildInsets(View child, Object insets, int drawerGravity) { + WindowInsets wi = (WindowInsets) insets; + if (drawerGravity == Gravity.LEFT) { + wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom()); + } else if (drawerGravity == Gravity.RIGHT) { + wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom()); + } + child.dispatchApplyWindowInsets(wi); + } + + public void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity) { + WindowInsets wi = (WindowInsets) insets; + if (drawerGravity == Gravity.LEFT) { + wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom()); + } else if (drawerGravity == Gravity.RIGHT) { + wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom()); + } + lp.leftMargin = wi.getSystemWindowInsetLeft(); + lp.topMargin = wi.getSystemWindowInsetTop(); + lp.rightMargin = wi.getSystemWindowInsetRight(); + lp.bottomMargin = wi.getSystemWindowInsetBottom(); + } + + public int getTopInset(Object insets) { + if (Build.VERSION.SDK_INT >= 21) { + return insets != null ? ((WindowInsets) insets).getSystemWindowInsetTop() : 0; + } + return 0; + } + + public void setChildInsets(Object insets, boolean draw) { + mLastInsets = insets; + setWillNotDraw(!draw && getBackground() == null); + requestLayout(); + } + + + /*private static final int MIN_DRAWER_MARGIN = 64; // dp + + private static final int DEFAULT_SCRIM_COLOR = 0x99000000; + + private static final int PEEK_DELAY = 160; // ms + + private static final int MIN_FLING_VELOCITY = 400; // dips per second + + private static final boolean ALLOW_EDGE_LOCK = false; + + private static final boolean CHILDREN_DISALLOW_INTERCEPT = true; + + private static final float TOUCH_SLOP_SENSITIVITY = 1.f; + + private static final int[] LAYOUT_ATTRS = new int[] { + android.R.attr.layout_gravity + }; + + private final ChildAccessibilityDelegate mChildAccessibilityDelegate = + new ChildAccessibilityDelegate(); + + private int mMinDrawerMargin; + + private int mScrimColor = DEFAULT_SCRIM_COLOR; + private float mScrimOpacity; + private Paint mScrimPaint = new Paint(); + + private final ViewDragHelper mLeftDragger; + private final ViewDragHelper mRightDragger; + private final ViewDragCallback mLeftCallback; + private final ViewDragCallback mRightCallback; + private int mDrawerState; + private boolean mInLayout; + private boolean mFirstLayout = true; + private int mLockModeLeft; + private int mLockModeRight; + private boolean mDisallowInterceptRequested; + private boolean mChildrenCanceledTouch; + + private DrawerListener mListener; + + private float mInitialMotionX; + private float mInitialMotionY; + + private Drawable mShadowLeft; + private Drawable mShadowRight; + + + private CharSequence mTitleLeft; + private CharSequence mTitleRight; + + private Object mLastInsets; + private boolean mDrawStatusBarBackground; + + public interface DrawerListener { + public void onDrawerSlide(View drawerView, float slideOffset); + public void onDrawerOpened(View drawerView); + public void onDrawerClosed(View drawerView); + public void onDrawerStateChanged(@State int newState); + } + + public static abstract class SimpleDrawerListener implements DrawerListener { + @Override + public void onDrawerSlide(View drawerView, float slideOffset) { + } + + @Override + public void onDrawerOpened(View drawerView) { + } + + @Override + public void onDrawerClosed(View drawerView) { + } + + @Override + public void onDrawerStateChanged(int newState) { + } + } + + + static { + final int version = Build.VERSION.SDK_INT; + if (version >= 21) { + IMPL = new DrawerLayoutCompatImplApi21(); + } else { + IMPL = new DrawerLayoutCompatImplBase(); + } + } + + static final DrawerLayoutCompatImpl IMPL; + + public void setDrawerShadow(Drawable shadowDrawable, @EdgeGravity int gravity) { + + final int absGravity = GravityCompat.getAbsoluteGravity(gravity, + ViewCompat.getLayoutDirection(this)); + if ((absGravity & Gravity.LEFT) == Gravity.LEFT) { + mShadowLeft = shadowDrawable; + invalidate(); + } + if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) { + mShadowRight = shadowDrawable; + invalidate(); + } + } + + public void setDrawerShadow(@DrawableRes int resId, @EdgeGravity int gravity) { + setDrawerShadow(getResources().getDrawable(resId), gravity); + } + + public void setScrimColor(int color) { + mScrimColor = color; + invalidate(); + } + + public void setDrawerListener(DrawerListener listener) { + mListener = listener; + } + + public void setDrawerLockMode(@LockMode int lockMode) { + setDrawerLockMode(lockMode, Gravity.LEFT); + setDrawerLockMode(lockMode, Gravity.RIGHT); + } + + public void setDrawerLockMode(@LockMode int lockMode, @EdgeGravity int edgeGravity) { + final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, + ViewCompat.getLayoutDirection(this)); + if (absGravity == Gravity.LEFT) { + mLockModeLeft = lockMode; + } else if (absGravity == Gravity.RIGHT) { + mLockModeRight = lockMode; + } + if (lockMode != LOCK_MODE_UNLOCKED) { + // Cancel interaction in progress + final ViewDragHelper helper = absGravity == Gravity.LEFT ? mLeftDragger : mRightDragger; + helper.cancel(); + } + switch (lockMode) { + case LOCK_MODE_LOCKED_OPEN: + final View toOpen = findDrawerWithGravity(absGravity); + if (toOpen != null) { + openDrawer(toOpen); + } + break; + case LOCK_MODE_LOCKED_CLOSED: + final View toClose = findDrawerWithGravity(absGravity); + if (toClose != null) { + closeDrawer(toClose); + } + break; + // default: do nothing + } + } + + public void setDrawerLockMode(@LockMode int lockMode, View drawerView) { + if (!isDrawerView(drawerView)) { + throw new IllegalArgumentException("View " + drawerView + " is not a " + + "drawer with appropriate layout_gravity"); + } + final int gravity = ((LayoutParams) drawerView.getLayoutParams()).gravity; + setDrawerLockMode(lockMode, gravity); + } + + @LockMode + public int getDrawerLockMode(@EdgeGravity int edgeGravity) { + final int absGravity = GravityCompat.getAbsoluteGravity( + edgeGravity, ViewCompat.getLayoutDirection(this)); + if (absGravity == Gravity.LEFT) { + return mLockModeLeft; + } else if (absGravity == Gravity.RIGHT) { + return mLockModeRight; + } + return LOCK_MODE_UNLOCKED; + } + + @LockMode + public int getDrawerLockMode(View drawerView) { + final int absGravity = getDrawerViewAbsoluteGravity(drawerView); + if (absGravity == Gravity.LEFT) { + return mLockModeLeft; + } else if (absGravity == Gravity.RIGHT) { + return mLockModeRight; + } + return LOCK_MODE_UNLOCKED; + } + + public void setDrawerTitle(@EdgeGravity int edgeGravity, CharSequence title) { + final int absGravity = GravityCompat.getAbsoluteGravity( + edgeGravity, ViewCompat.getLayoutDirection(this)); + if (absGravity == Gravity.LEFT) { + mTitleLeft = title; + } else if (absGravity == Gravity.RIGHT) { + mTitleRight = title; + } + } + + @Nullable + public CharSequence getDrawerTitle(@EdgeGravity int edgeGravity) { + final int absGravity = GravityCompat.getAbsoluteGravity( + edgeGravity, ViewCompat.getLayoutDirection(this)); + if (absGravity == Gravity.LEFT) { + return mTitleLeft; + } else if (absGravity == Gravity.RIGHT) { + return mTitleRight; + } + return null; + } + + void updateDrawerState(int forGravity, @State int activeState, View activeDrawer) { + final int leftState = mLeftDragger.getViewDragState(); + final int rightState = mRightDragger.getViewDragState(); + + final int state; + if (leftState == STATE_DRAGGING || rightState == STATE_DRAGGING) { + state = STATE_DRAGGING; + } else if (leftState == STATE_SETTLING || rightState == STATE_SETTLING) { + state = STATE_SETTLING; + } else { + state = STATE_IDLE; + } + + if (activeDrawer != null && activeState == STATE_IDLE) { + final LayoutParams lp = (LayoutParams) activeDrawer.getLayoutParams(); + if (lp.onScreen == 0) { + dispatchOnDrawerClosed(activeDrawer); + } else if (lp.onScreen == 1) { + dispatchOnDrawerOpened(activeDrawer); + } + } + + if (state != mDrawerState) { + mDrawerState = state; + + if (mListener != null) { + mListener.onDrawerStateChanged(state); + } + } + } + + void dispatchOnDrawerClosed(View drawerView) { + final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); + if (lp.knownOpen) { + lp.knownOpen = false; + if (mListener != null) { + mListener.onDrawerClosed(drawerView); + } + + // If no drawer is opened, all drawers are not shown + // for accessibility and the content is shown. + View content = getChildAt(0); + if (content != null) { + ViewCompat.setImportantForAccessibility(content, + ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); + } + ViewCompat.setImportantForAccessibility(drawerView, + ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); + + // Only send WINDOW_STATE_CHANGE if the host has window focus. This + // may change if support for multiple foreground windows (e.g. IME) + // improves. + if (hasWindowFocus()) { + final View rootView = getRootView(); + if (rootView != null) { + rootView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); + } + } + } + } + + void dispatchOnDrawerOpened(View drawerView) { + final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); + if (!lp.knownOpen) { + lp.knownOpen = true; + if (mListener != null) { + mListener.onDrawerOpened(drawerView); + } + + // If a drawer is opened, only it is shown for + // accessibility and the content is not shown. + View content = getChildAt(0); + if (content != null) { + ViewCompat.setImportantForAccessibility(content, + ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); + } + ViewCompat.setImportantForAccessibility(drawerView, + ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); + + sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); + drawerView.requestFocus(); + } + } + + void dispatchOnDrawerSlide(View drawerView, float slideOffset) { + if (mListener != null) { + mListener.onDrawerSlide(drawerView, slideOffset); + } + } + + void setDrawerViewOffset(View drawerView, float slideOffset) { + final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); + if (slideOffset == lp.onScreen) { + return; + } + + lp.onScreen = slideOffset; + dispatchOnDrawerSlide(drawerView, slideOffset); + } + + float getDrawerViewOffset(View drawerView) { + return ((LayoutParams) drawerView.getLayoutParams()).onScreen; + } + + int getDrawerViewAbsoluteGravity(View drawerView) { + final int gravity = ((LayoutParams) drawerView.getLayoutParams()).gravity; + return GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this)); + } + + boolean checkDrawerViewAbsoluteGravity(View drawerView, int checkFor) { + final int absGravity = getDrawerViewAbsoluteGravity(drawerView); + return (absGravity & checkFor) == checkFor; + } + + View findOpenDrawer() { + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + if (((LayoutParams) child.getLayoutParams()).knownOpen) { + return child; + } + } + return null; + } + + void moveDrawerToOffset(View drawerView, float slideOffset) { + final float oldOffset = getDrawerViewOffset(drawerView); + final int width = drawerView.getWidth(); + final int oldPos = (int) (width * oldOffset); + final int newPos = (int) (width * slideOffset); + final int dx = newPos - oldPos; + + drawerView.offsetLeftAndRight( + checkDrawerViewAbsoluteGravity(drawerView, Gravity.LEFT) ? dx : -dx); + setDrawerViewOffset(drawerView, slideOffset); + } + + View findDrawerWithGravity(int gravity) { + final int absHorizGravity = GravityCompat.getAbsoluteGravity( + gravity, ViewCompat.getLayoutDirection(this)) & Gravity.HORIZONTAL_GRAVITY_MASK; + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + final int childAbsGravity = getDrawerViewAbsoluteGravity(child); + if ((childAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) == absHorizGravity) { + return child; + } + } + return null; + } + + static String gravityToString(@EdgeGravity int gravity) { + if ((gravity & Gravity.LEFT) == Gravity.LEFT) { + return "LEFT"; + } + if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) { + return "RIGHT"; + } + return Integer.toHexString(gravity); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + mFirstLayout = true; + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + mFirstLayout = true; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int widthMode = MeasureSpec.getMode(widthMeasureSpec); + int heightMode = MeasureSpec.getMode(heightMeasureSpec); + int widthSize = MeasureSpec.getSize(widthMeasureSpec); + int heightSize = MeasureSpec.getSize(heightMeasureSpec); + + setMeasuredDimension(widthSize, heightSize); + + final boolean applyInsets = mLastInsets != null && ViewCompat.getFitsSystemWindows(this); + final int layoutDirection = ViewCompat.getLayoutDirection(this); + + // Gravity value for each drawer we've seen. Only one of each permitted. + int foundDrawers = 0; + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + + if (child.getVisibility() == GONE) { + continue; + } + + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + + if (applyInsets) { + final int cgrav = GravityCompat.getAbsoluteGravity(lp.gravity, layoutDirection); + if (ViewCompat.getFitsSystemWindows(child)) { + IMPL.dispatchChildInsets(child, mLastInsets, cgrav); + } else { + IMPL.applyMarginInsets(lp, mLastInsets, cgrav); + } + } + + if (isContentView(child)) { + // Content views get measured at exactly the layout's size. + final int contentWidthSpec = MeasureSpec.makeMeasureSpec( + widthSize - lp.leftMargin - lp.rightMargin, MeasureSpec.EXACTLY); + final int contentHeightSpec = MeasureSpec.makeMeasureSpec( + heightSize - lp.topMargin - lp.bottomMargin, MeasureSpec.EXACTLY); + child.measure(contentWidthSpec, contentHeightSpec); + } else if (isDrawerView(child)) { + final int childGravity = + getDrawerViewAbsoluteGravity(child) & Gravity.HORIZONTAL_GRAVITY_MASK; + if ((foundDrawers & childGravity) != 0) { + throw new IllegalStateException("Child drawer has absolute gravity " + + gravityToString(childGravity) + " but this " + TAG + " already has a " + + "drawer view along that edge"); + } + final int drawerWidthSpec = getChildMeasureSpec(widthMeasureSpec, + mMinDrawerMargin + lp.leftMargin + lp.rightMargin, + lp.width); + final int drawerHeightSpec = getChildMeasureSpec(heightMeasureSpec, + lp.topMargin + lp.bottomMargin, + lp.height); + child.measure(drawerWidthSpec, drawerHeightSpec); + } else { + throw new IllegalStateException("Child " + child + " at index " + i + + " does not have a valid layout_gravity - must be Gravity.LEFT, " + + "Gravity.RIGHT or Gravity.NO_GRAVITY"); + } + } + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + mInLayout = true; + final int width = r - l; + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + + if (child.getVisibility() == GONE) { + continue; + } + + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + + if (isContentView(child)) { + child.layout(lp.leftMargin, lp.topMargin, + lp.leftMargin + child.getMeasuredWidth(), + lp.topMargin + child.getMeasuredHeight()); + } else { // Drawer, if it wasn't onMeasure would have thrown an exception. + final int childWidth = child.getMeasuredWidth(); + final int childHeight = child.getMeasuredHeight(); + int childLeft; + + final float newOffset; + if (checkDrawerViewAbsoluteGravity(child, Gravity.LEFT)) { + childLeft = -childWidth + (int) (childWidth * lp.onScreen); + newOffset = (float) (childWidth + childLeft) / childWidth; + } else { // Right; onMeasure checked for us. + childLeft = width - (int) (childWidth * lp.onScreen); + newOffset = (float) (width - childLeft) / childWidth; + } + + final boolean changeOffset = newOffset != lp.onScreen; + + final int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK; + + switch (vgrav) { + default: + case Gravity.TOP: { + child.layout(childLeft, lp.topMargin, childLeft + childWidth, + lp.topMargin + childHeight); + break; + } + + case Gravity.BOTTOM: { + final int height = b - t; + child.layout(childLeft, + height - lp.bottomMargin - child.getMeasuredHeight(), + childLeft + childWidth, + height - lp.bottomMargin); + break; + } + + case Gravity.CENTER_VERTICAL: { + final int height = b - t; + int childTop = (height - childHeight) / 2; + + // Offset for margins. If things don't fit right because of + // bad measurement before, oh well. + if (childTop < lp.topMargin) { + childTop = lp.topMargin; + } else if (childTop + childHeight > height - lp.bottomMargin) { + childTop = height - lp.bottomMargin - childHeight; + } + child.layout(childLeft, childTop, childLeft + childWidth, + childTop + childHeight); + break; + } + } + + if (changeOffset) { + setDrawerViewOffset(child, newOffset); + } + + final int newVisibility = lp.onScreen > 0 ? VISIBLE : INVISIBLE; + if (child.getVisibility() != newVisibility) { + child.setVisibility(newVisibility); + } + } + } + mInLayout = false; + mFirstLayout = false; + } + + @Override + public void requestLayout() { + if (!mInLayout) { + super.requestLayout(); + } + } + + @Override + public void computeScroll() { + final int childCount = getChildCount(); + float scrimOpacity = 0; + for (int i = 0; i < childCount; i++) { + final float onscreen = ((LayoutParams) getChildAt(i).getLayoutParams()).onScreen; + scrimOpacity = Math.max(scrimOpacity, onscreen); + } + mScrimOpacity = scrimOpacity; + + // "|" used on purpose; both need to run. + if (mLeftDragger.continueSettling(true) | mRightDragger.continueSettling(true)) { + ViewCompat.postInvalidateOnAnimation(this); + } + } + + private static boolean hasOpaqueBackground(View v) { + final Drawable bg = v.getBackground(); + if (bg != null) { + return bg.getOpacity() == PixelFormat.OPAQUE; + } + return false; + } + + @Override + protected boolean drawChild(Canvas canvas, View child, long drawingTime) { + final int height = getHeight(); + final boolean drawingContent = isContentView(child); + int clipLeft = 0, clipRight = getWidth(); + + final int restoreCount = canvas.save(); + if (drawingContent) { + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + final View v = getChildAt(i); + if (v == child || v.getVisibility() != VISIBLE || + !hasOpaqueBackground(v) || !isDrawerView(v) || + v.getHeight() < height) { + continue; + } + + if (checkDrawerViewAbsoluteGravity(v, Gravity.LEFT)) { + final int vright = v.getRight(); + if (vright > clipLeft) clipLeft = vright; + } else { + final int vleft = v.getLeft(); + if (vleft < clipRight) clipRight = vleft; + } + } + canvas.clipRect(clipLeft, 0, clipRight, getHeight()); + } + final boolean result = super.drawChild(canvas, child, drawingTime); + canvas.restoreToCount(restoreCount); + + if (mScrimOpacity > 0 && drawingContent) { + final int baseAlpha = (mScrimColor & 0xff000000) >>> 24; + final int imag = (int) (baseAlpha * mScrimOpacity); + final int color = imag << 24 | (mScrimColor & 0xffffff); + mScrimPaint.setColor(color); + + canvas.drawRect(clipLeft, 0, clipRight, getHeight(), mScrimPaint); + } else if (mShadowLeft != null && checkDrawerViewAbsoluteGravity(child, Gravity.LEFT)) { + final int shadowWidth = mShadowLeft.getIntrinsicWidth(); + final int childRight = child.getRight(); + final int drawerPeekDistance = mLeftDragger.getEdgeSize(); + final float alpha = + Math.max(0, Math.min((float) childRight / drawerPeekDistance, 1.f)); + mShadowLeft.setBounds(childRight, child.getTop(), + childRight + shadowWidth, child.getBottom()); + mShadowLeft.setAlpha((int) (0xff * alpha)); + mShadowLeft.draw(canvas); + } else if (mShadowRight != null && checkDrawerViewAbsoluteGravity(child, Gravity.RIGHT)) { + final int shadowWidth = mShadowRight.getIntrinsicWidth(); + final int childLeft = child.getLeft(); + final int showing = getWidth() - childLeft; + final int drawerPeekDistance = mRightDragger.getEdgeSize(); + final float alpha = + Math.max(0, Math.min((float) showing / drawerPeekDistance, 1.f)); + mShadowRight.setBounds(childLeft - shadowWidth, child.getTop(), + childLeft, child.getBottom()); + mShadowRight.setAlpha((int) (0xff * alpha)); + mShadowRight.draw(canvas); + } + return result; + } + + boolean isContentView(View child) { + return ((LayoutParams) child.getLayoutParams()).gravity == Gravity.NO_GRAVITY; + } + + boolean isDrawerView(View child) { + final int gravity = ((LayoutParams) child.getLayoutParams()).gravity; + final int absGravity = GravityCompat.getAbsoluteGravity(gravity, + ViewCompat.getLayoutDirection(child)); + return (absGravity & (Gravity.LEFT | Gravity.RIGHT)) != 0; + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + final int action = MotionEventCompat.getActionMasked(ev); + + // "|" used deliberately here; both methods should be invoked. + final boolean interceptForDrag = mLeftDragger.shouldInterceptTouchEvent(ev) | + mRightDragger.shouldInterceptTouchEvent(ev); + + boolean interceptForTap = false; + + switch (action) { + case MotionEvent.ACTION_DOWN: { + final float x = ev.getX(); + final float y = ev.getY(); + mInitialMotionX = x; + mInitialMotionY = y; + if (mScrimOpacity > 0 && + isContentView(mLeftDragger.findTopChildUnder((int) x, (int) y))) { + interceptForTap = true; + } + mDisallowInterceptRequested = false; + mChildrenCanceledTouch = false; + break; + } + + case MotionEvent.ACTION_MOVE: { + // If we cross the touch slop, don't perform the delayed peek for an edge touch. + if (mLeftDragger.checkTouchSlop(ViewDragHelper.DIRECTION_ALL)) { + mLeftCallback.removeCallbacks(); + mRightCallback.removeCallbacks(); + } + break; + } + + case MotionEvent.ACTION_CANCEL: + case MotionEvent.ACTION_UP: { + closeDrawers(true); + mDisallowInterceptRequested = false; + mChildrenCanceledTouch = false; + } + } + + return interceptForDrag || interceptForTap || hasPeekingDrawer() || mChildrenCanceledTouch; + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + mLeftDragger.processTouchEvent(ev); + mRightDragger.processTouchEvent(ev); + + final int action = ev.getAction(); + boolean wantTouchEvents = true; + + switch (action & MotionEventCompat.ACTION_MASK) { + case MotionEvent.ACTION_DOWN: { + final float x = ev.getX(); + final float y = ev.getY(); + mInitialMotionX = x; + mInitialMotionY = y; + mDisallowInterceptRequested = false; + mChildrenCanceledTouch = false; + break; + } + + case MotionEvent.ACTION_UP: { + final float x = ev.getX(); + final float y = ev.getY(); + boolean peekingOnly = true; + final View touchedView = mLeftDragger.findTopChildUnder((int) x, (int) y); + if (touchedView != null && isContentView(touchedView)) { + final float dx = x - mInitialMotionX; + final float dy = y - mInitialMotionY; + final int slop = mLeftDragger.getTouchSlop(); + if (dx * dx + dy * dy < slop * slop) { + // Taps close a dimmed open drawer but only if it isn't locked open. + final View openDrawer = findOpenDrawer(); + if (openDrawer != null) { + peekingOnly = getDrawerLockMode(openDrawer) == LOCK_MODE_LOCKED_OPEN; + } + } + } + closeDrawers(peekingOnly); + mDisallowInterceptRequested = false; + break; + } + + case MotionEvent.ACTION_CANCEL: { + closeDrawers(true); + mDisallowInterceptRequested = false; + mChildrenCanceledTouch = false; + break; + } + } + + return wantTouchEvents; + } + + public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) { + if (CHILDREN_DISALLOW_INTERCEPT || + (!mLeftDragger.isEdgeTouched(ViewDragHelper.EDGE_LEFT) && + !mRightDragger.isEdgeTouched(ViewDragHelper.EDGE_RIGHT))) { + // If we have an edge touch we want to skip this and track it for later instead. + super.requestDisallowInterceptTouchEvent(disallowIntercept); + } + mDisallowInterceptRequested = disallowIntercept; + if (disallowIntercept) { + closeDrawers(true); + } + } + + public void closeDrawers() { + closeDrawers(false); + } + + void closeDrawers(boolean peekingOnly) { + boolean needsInvalidate = false; + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + + if (!isDrawerView(child) || (peekingOnly && !lp.isPeeking)) { + continue; + } + + final int childWidth = child.getWidth(); + + if (checkDrawerViewAbsoluteGravity(child, Gravity.LEFT)) { + needsInvalidate |= mLeftDragger.smoothSlideViewTo(child, + -childWidth, child.getTop()); + } else { + needsInvalidate |= mRightDragger.smoothSlideViewTo(child, + getWidth(), child.getTop()); + } + + lp.isPeeking = false; + } + + mLeftCallback.removeCallbacks(); + mRightCallback.removeCallbacks(); + + if (needsInvalidate) { + invalidate(); + } + } + + public void openDrawer(View drawerView) { + if (!isDrawerView(drawerView)) { + throw new IllegalArgumentException("View " + drawerView + " is not a sliding drawer"); + } + + if (mFirstLayout) { + final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); + lp.onScreen = 1.f; + lp.knownOpen = true; + + View content = getChildAt(0); + if (content != null) { + ViewCompat.setImportantForAccessibility(content, + ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); + } + ViewCompat.setImportantForAccessibility(drawerView, + ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); + } else { + if (checkDrawerViewAbsoluteGravity(drawerView, Gravity.LEFT)) { + mLeftDragger.smoothSlideViewTo(drawerView, 0, drawerView.getTop()); + } else { + mRightDragger.smoothSlideViewTo(drawerView, getWidth() - drawerView.getWidth(), + drawerView.getTop()); + } + } + invalidate(); + } + + public void openDrawer(@EdgeGravity int gravity) { + final View drawerView = findDrawerWithGravity(gravity); + if (drawerView == null) { + throw new IllegalArgumentException("No drawer view found with gravity " + + gravityToString(gravity)); + } + openDrawer(drawerView); + } + + public void closeDrawer(View drawerView) { + if (!isDrawerView(drawerView)) { + throw new IllegalArgumentException("View " + drawerView + " is not a sliding drawer"); + } + + if (mFirstLayout) { + final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); + lp.onScreen = 0.f; + lp.knownOpen = false; + } else { + if (checkDrawerViewAbsoluteGravity(drawerView, Gravity.LEFT)) { + mLeftDragger.smoothSlideViewTo(drawerView, -drawerView.getWidth(), + drawerView.getTop()); + } else { + mRightDragger.smoothSlideViewTo(drawerView, getWidth(), drawerView.getTop()); + } + } + invalidate(); + } + + public void closeDrawer(@EdgeGravity int gravity) { + final View drawerView = findDrawerWithGravity(gravity); + if (drawerView == null) { + throw new IllegalArgumentException("No drawer view found with gravity " + + gravityToString(gravity)); + } + closeDrawer(drawerView); + } + + public boolean isDrawerOpen(View drawer) { + if (!isDrawerView(drawer)) { + throw new IllegalArgumentException("View " + drawer + " is not a drawer"); + } + return ((LayoutParams) drawer.getLayoutParams()).knownOpen; + } + + public boolean isDrawerOpen(@EdgeGravity int drawerGravity) { + final View drawerView = findDrawerWithGravity(drawerGravity); + if (drawerView != null) { + return isDrawerOpen(drawerView); + } + return false; + } + + public boolean isDrawerVisible(View drawer) { + if (!isDrawerView(drawer)) { + throw new IllegalArgumentException("View " + drawer + " is not a drawer"); + } + return ((LayoutParams) drawer.getLayoutParams()).onScreen > 0; + } + + public boolean isDrawerVisible(@EdgeGravity int drawerGravity) { + final View drawerView = findDrawerWithGravity(drawerGravity); + if (drawerView != null) { + return isDrawerVisible(drawerView); + } + return false; + } + + private boolean hasPeekingDrawer() { + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + final LayoutParams lp = (LayoutParams) getChildAt(i).getLayoutParams(); + if (lp.isPeeking) { + return true; + } + } + return false; + } + + @Override + protected ViewGroup.LayoutParams generateDefaultLayoutParams() { + return new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); + } + + @Override + protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) { + return p instanceof LayoutParams + ? new LayoutParams((LayoutParams) p) + : p instanceof ViewGroup.MarginLayoutParams + ? new LayoutParams((MarginLayoutParams) p) + : new LayoutParams(p); + } + + @Override + protected boolean checkLayoutParams(ViewGroup.LayoutParams p) { + return p instanceof LayoutParams && super.checkLayoutParams(p); + } + + @Override + public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { + return new LayoutParams(getContext(), attrs); + } + + private boolean hasVisibleDrawer() { + return findVisibleDrawer() != null; + } + + private View findVisibleDrawer() { + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + final View child = getChildAt(i); + if (isDrawerView(child) && isDrawerVisible(child)) { + return child; + } + } + return null; + } + + void cancelChildViewTouch() { + // Cancel child touches + if (!mChildrenCanceledTouch) { + final long now = SystemClock.uptimeMillis(); + final MotionEvent cancelEvent = MotionEvent.obtain(now, now, + MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0); + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + getChildAt(i).dispatchTouchEvent(cancelEvent); + } + cancelEvent.recycle(); + mChildrenCanceledTouch = true; + } + } + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK && hasVisibleDrawer()) { + KeyEventCompat.startTracking(event); + return true; + } + return super.onKeyDown(keyCode, event); + } + + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK) { + final View visibleDrawer = findVisibleDrawer(); + if (visibleDrawer != null && getDrawerLockMode(visibleDrawer) == LOCK_MODE_UNLOCKED) { + closeDrawers(); + } + return visibleDrawer != null; + } + return super.onKeyUp(keyCode, event); + } + + private class ViewDragCallback extends ViewDragHelper.Callback { + private final int mAbsGravity; + private ViewDragHelper mDragger; + + private final Runnable mPeekRunnable = new Runnable() { + @Override public void run() { + peekDrawer(); + } + }; + + public ViewDragCallback(int gravity) { + mAbsGravity = gravity; + } + + public void setDragger(ViewDragHelper dragger) { + mDragger = dragger; + } + + public void removeCallbacks() { + DrawerLayout.this.removeCallbacks(mPeekRunnable); + } + + @Override + public boolean tryCaptureView(View child, int pointerId) { + // Only capture views where the gravity matches what we're looking for. + // This lets us use two ViewDragHelpers, one for each side drawer. + return isDrawerView(child) && checkDrawerViewAbsoluteGravity(child, mAbsGravity) + && getDrawerLockMode(child) == LOCK_MODE_UNLOCKED; + } + + @Override + public void onViewDragStateChanged(int state) { + updateDrawerState(mAbsGravity, state, mDragger.getCapturedView()); + } + + @Override + public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) { + float offset; + final int childWidth = changedView.getWidth(); + + // This reverses the positioning shown in onLayout. + if (checkDrawerViewAbsoluteGravity(changedView, Gravity.LEFT)) { + offset = (float) (childWidth + left) / childWidth; + } else { + final int width = getWidth(); + offset = (float) (width - left) / childWidth; + } + setDrawerViewOffset(changedView, offset); + changedView.setVisibility(offset == 0 ? INVISIBLE : VISIBLE); + invalidate(); + } + + @Override + public void onViewCaptured(View capturedChild, int activePointerId) { + final LayoutParams lp = (LayoutParams) capturedChild.getLayoutParams(); + lp.isPeeking = false; + + closeOtherDrawer(); + } + + private void closeOtherDrawer() { + final int otherGrav = mAbsGravity == Gravity.LEFT ? Gravity.RIGHT : Gravity.LEFT; + final View toClose = findDrawerWithGravity(otherGrav); + if (toClose != null) { + closeDrawer(toClose); + } + } + + @Override + public void onViewReleased(View releasedChild, float xvel, float yvel) { + // Offset is how open the drawer is, therefore left/right values + // are reversed from one another. + final float offset = getDrawerViewOffset(releasedChild); + final int childWidth = releasedChild.getWidth(); + + int left; + if (checkDrawerViewAbsoluteGravity(releasedChild, Gravity.LEFT)) { + left = xvel > 0 || xvel == 0 && offset > 0.5f ? 0 : -childWidth; + } else { + final int width = getWidth(); + left = xvel < 0 || xvel == 0 && offset > 0.5f ? width - childWidth : width; + } + + mDragger.settleCapturedViewAt(left, releasedChild.getTop()); + invalidate(); + } + + @Override + public void onEdgeTouched(int edgeFlags, int pointerId) { + postDelayed(mPeekRunnable, PEEK_DELAY); + } + + private void peekDrawer() { + final View toCapture; + final int childLeft; + final int peekDistance = mDragger.getEdgeSize(); + final boolean leftEdge = mAbsGravity == Gravity.LEFT; + if (leftEdge) { + toCapture = findDrawerWithGravity(Gravity.LEFT); + childLeft = (toCapture != null ? -toCapture.getWidth() : 0) + peekDistance; + } else { + toCapture = findDrawerWithGravity(Gravity.RIGHT); + childLeft = getWidth() - peekDistance; + } + // Only peek if it would mean making the drawer more visible and the drawer isn't locked + if (toCapture != null && ((leftEdge && toCapture.getLeft() < childLeft) || + (!leftEdge && toCapture.getLeft() > childLeft)) && + getDrawerLockMode(toCapture) == LOCK_MODE_UNLOCKED) { + final LayoutParams lp = (LayoutParams) toCapture.getLayoutParams(); + mDragger.smoothSlideViewTo(toCapture, childLeft, toCapture.getTop()); + lp.isPeeking = true; + invalidate(); + + closeOtherDrawer(); + + cancelChildViewTouch(); + } + } + + @Override + public boolean onEdgeLock(int edgeFlags) { + if (ALLOW_EDGE_LOCK) { + final View drawer = findDrawerWithGravity(mAbsGravity); + if (drawer != null && !isDrawerOpen(drawer)) { + closeDrawer(drawer); + } + return true; + } + return false; + } + + @Override + public void onEdgeDragStarted(int edgeFlags, int pointerId) { + final View toCapture; + if ((edgeFlags & ViewDragHelper.EDGE_LEFT) == ViewDragHelper.EDGE_LEFT) { + toCapture = findDrawerWithGravity(Gravity.LEFT); + } else { + toCapture = findDrawerWithGravity(Gravity.RIGHT); + } + + if (toCapture != null && getDrawerLockMode(toCapture) == LOCK_MODE_UNLOCKED) { + mDragger.captureChildView(toCapture, pointerId); + } + } + + @Override + public int getViewHorizontalDragRange(View child) { + return isDrawerView(child) ? child.getWidth() : 0; + } + + @Override + public int clampViewPositionHorizontal(View child, int left, int dx) { + if (checkDrawerViewAbsoluteGravity(child, Gravity.LEFT)) { + return Math.max(-child.getWidth(), Math.min(left, 0)); + } else { + final int width = getWidth(); + return Math.max(width - child.getWidth(), Math.min(left, width)); + } + } + + @Override + public int clampViewPositionVertical(View child, int top, int dy) { + return child.getTop(); + } + } +*/ +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/MenuDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/MenuDrawable.java new file mode 100644 index 000000000..221b1fd2b --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/MenuDrawable.java @@ -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); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java new file mode 100644 index 000000000..24922c0c6 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java @@ -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; + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarUpdater.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarUpdater.java index 1fe286753..7eafab4c0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarUpdater.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarUpdater.java @@ -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); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/BackupImageView.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/BackupImageView.java index b584dcdaf..f311f94b5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/BackupImageView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/BackupImageView.java @@ -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(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java index 3959d24ce..5c174a2ad 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java @@ -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); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ClippingImageView.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ClippingImageView.java index 543272ba2..7ab955fc4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ClippingImageView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ClippingImageView.java @@ -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); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/EmojiView.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/EmojiView.java index 5664a1cc0..5c959f5ae 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/EmojiView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/EmojiView.java @@ -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) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ProgressView.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ProgressView.java index 671c858f2..6dc14ac36 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ProgressView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ProgressView.java @@ -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(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/SizeNotifierRelativeLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/SizeNotifierRelativeLayout.java index ffe96479a..b34b31170 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/SizeNotifierRelativeLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/SizeNotifierRelativeLayout.java @@ -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); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/SlidingTabView.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/SlidingTabView.java deleted file mode 100644 index c4fdbc44c..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/SlidingTabView.java +++ /dev/null @@ -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); - } -} diff --git a/TMessagesProj/src/main/res/anim/popup_in.xml b/TMessagesProj/src/main/res/anim/popup_in.xml new file mode 100644 index 000000000..42a4bb0bc --- /dev/null +++ b/TMessagesProj/src/main/res/anim/popup_in.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/anim/popup_out.xml b/TMessagesProj/src/main/res/anim/popup_out.xml new file mode 100644 index 000000000..0975248a7 --- /dev/null +++ b/TMessagesProj/src/main/res/anim/popup_out.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_aqua.png b/TMessagesProj/src/main/res/drawable-hdpi/broadcast_aqua.png deleted file mode 100755 index 69e9ee758..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_blue.png b/TMessagesProj/src/main/res/drawable-hdpi/broadcast_blue.png deleted file mode 100755 index 8a41f2a39..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_green.png b/TMessagesProj/src/main/res/drawable-hdpi/broadcast_green.png deleted file mode 100755 index 24c5329b1..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_orange.png b/TMessagesProj/src/main/res/drawable-hdpi/broadcast_orange.png deleted file mode 100755 index a942fc9ce..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_pink.png b/TMessagesProj/src/main/res/drawable-hdpi/broadcast_pink.png deleted file mode 100755 index c0a8a3d51..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_red.png b/TMessagesProj/src/main/res/drawable-hdpi/broadcast_red.png deleted file mode 100755 index b782c3ab5..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_violet.png b/TMessagesProj/src/main/res/drawable-hdpi/broadcast_violet.png deleted file mode 100755 index 905048e45..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_yellow.png b/TMessagesProj/src/main/res/drawable-hdpi/broadcast_yellow.png deleted file mode 100755 index c427ad488..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/broadcast_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge.9.png b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge.9.png index 76759b873..dbb256bc3 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_badge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_check.png b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_check.png index 2e341f051..11380095e 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_check.png and b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_check.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_halfcheck.png b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_halfcheck.png index 08f752c25..f75f9ccb2 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_halfcheck.png and b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_halfcheck.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_warning.png b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_warning.png old mode 100644 new mode 100755 index f08efbf19..c1474e23b Binary files a/TMessagesProj/src/main/res/drawable-hdpi/dialogs_warning.png and b/TMessagesProj/src/main/res/drawable-hdpi/dialogs_warning.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/floating.png b/TMessagesProj/src/main/res/drawable-hdpi/floating.png new file mode 100755 index 000000000..5b3784248 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/floating.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/floating_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/floating_pressed.png new file mode 100755 index 000000000..285040bf4 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/floating_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/gallery.png b/TMessagesProj/src/main/res/drawable-hdpi/gallery.png deleted file mode 100755 index 6bd0cda83..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/gallery.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/group_aqua.png b/TMessagesProj/src/main/res/drawable-hdpi/group_aqua.png deleted file mode 100755 index da6975c4e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/group_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/group_blue.png b/TMessagesProj/src/main/res/drawable-hdpi/group_blue.png deleted file mode 100755 index e39d84e69..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/group_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/group_green.png b/TMessagesProj/src/main/res/drawable-hdpi/group_green.png deleted file mode 100755 index a412d4b5b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/group_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/group_orange.png b/TMessagesProj/src/main/res/drawable-hdpi/group_orange.png deleted file mode 100755 index 7c6982707..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/group_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/group_pink.png b/TMessagesProj/src/main/res/drawable-hdpi/group_pink.png deleted file mode 100755 index 496a43c0e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/group_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/group_red.png b/TMessagesProj/src/main/res/drawable-hdpi/group_red.png deleted file mode 100755 index beced2b58..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/group_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/group_violet.png b/TMessagesProj/src/main/res/drawable-hdpi/group_violet.png deleted file mode 100755 index f63bc86ab..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/group_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/group_yellow.png b/TMessagesProj/src/main/res/drawable-hdpi/group_yellow.png deleted file mode 100755 index 63e1704f0..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/group_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_back.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_back.png index 2e5545fdc..5fa494878 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_back.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_back.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_back_white.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_back_white.png deleted file mode 100644 index cd1dcf6d7..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_back_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_compose.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_compose.png deleted file mode 100755 index b991582c2..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_compose.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_logo.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_logo.png deleted file mode 100755 index a9237d7b9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_logo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_other.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_other.png index f54ad9c5d..fdc4a5ad2 100755 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_other.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_other.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_other_white.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_other_white.png deleted file mode 100644 index b3a92d75e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_other_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_other_white2.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_other_white2.png deleted file mode 100755 index 936d968c3..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_other_white2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_search.png b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_search.png old mode 100644 new mode 100755 index 8d3786411..a2fc5b2e7 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_search.png and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_search.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photo_back.png b/TMessagesProj/src/main/res/drawable-hdpi/photo_back.png deleted file mode 100755 index c9eb0018d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/photo_back.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/popup_fixed.9.png b/TMessagesProj/src/main/res/drawable-hdpi/popup_fixed.9.png index 2777b18c6..385734ee4 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/popup_fixed.9.png and b/TMessagesProj/src/main/res/drawable-hdpi/popup_fixed.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/telegram_avatar.png b/TMessagesProj/src/main/res/drawable-hdpi/telegram_avatar.png deleted file mode 100644 index 254352f2e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/telegram_avatar.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/user_aqua.png b/TMessagesProj/src/main/res/drawable-hdpi/user_aqua.png deleted file mode 100755 index e90ede353..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/user_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/user_blue.png b/TMessagesProj/src/main/res/drawable-hdpi/user_blue.png deleted file mode 100755 index c538f65dd..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/user_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/user_green.png b/TMessagesProj/src/main/res/drawable-hdpi/user_green.png deleted file mode 100755 index 6a82289ba..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/user_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/user_orange.png b/TMessagesProj/src/main/res/drawable-hdpi/user_orange.png deleted file mode 100755 index 9ad5571c9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/user_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/user_pink.png b/TMessagesProj/src/main/res/drawable-hdpi/user_pink.png deleted file mode 100755 index ff199e925..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/user_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/user_red.png b/TMessagesProj/src/main/res/drawable-hdpi/user_red.png deleted file mode 100755 index b87a708d9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/user_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/user_violet.png b/TMessagesProj/src/main/res/drawable-hdpi/user_violet.png deleted file mode 100755 index eacd33232..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/user_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/user_yellow.png b/TMessagesProj/src/main/res/drawable-hdpi/user_yellow.png deleted file mode 100755 index da5bb3cc8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/user_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ab_progress.png b/TMessagesProj/src/main/res/drawable-ldpi/ab_progress.png deleted file mode 100644 index 1a7aa06ad..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ab_progress.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/addcontact_blue.png b/TMessagesProj/src/main/res/drawable-ldpi/addcontact_blue.png deleted file mode 100755 index fd1dd7433..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/addcontact_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/addcontact_green.png b/TMessagesProj/src/main/res/drawable-ldpi/addcontact_green.png deleted file mode 100755 index cfa9e2b03..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/addcontact_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/addmember.png b/TMessagesProj/src/main/res/drawable-ldpi/addmember.png deleted file mode 100755 index 28df8141f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/addmember.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/audiocancel1.png b/TMessagesProj/src/main/res/drawable-ldpi/audiocancel1.png deleted file mode 100755 index 4800fcb57..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/audiocancel1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/audiocancel1_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/audiocancel1_pressed.png deleted file mode 100755 index 4800fcb57..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/audiocancel1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/audiocancel2.png b/TMessagesProj/src/main/res/drawable-ldpi/audiocancel2.png deleted file mode 100755 index eb5f9ae5c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/audiocancel2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/audiocancel2_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/audiocancel2_pressed.png deleted file mode 100755 index c4aa51e28..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/audiocancel2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/audioload1.png b/TMessagesProj/src/main/res/drawable-ldpi/audioload1.png deleted file mode 100755 index 5eb0d5b89..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/audioload1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/audioload1_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/audioload1_pressed.png deleted file mode 100755 index c62e90c54..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/audioload1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/audioload2.png b/TMessagesProj/src/main/res/drawable-ldpi/audioload2.png deleted file mode 100755 index ad3f00e0c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/audioload2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/audioload2_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/audioload2_pressed.png deleted file mode 100755 index a285a1588..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/audioload2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/bigtimer.png b/TMessagesProj/src/main/res/drawable-ldpi/bigtimer.png deleted file mode 100755 index 69bc23298..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/bigtimer.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/boxshadow.9.png b/TMessagesProj/src/main/res/drawable-ldpi/boxshadow.9.png deleted file mode 100644 index e0c55dc12..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/boxshadow.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/broadcast.png b/TMessagesProj/src/main/res/drawable-ldpi/broadcast.png deleted file mode 100644 index cd47e3ee8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/broadcast.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/broadcast2.png b/TMessagesProj/src/main/res/drawable-ldpi/broadcast2.png deleted file mode 100644 index 6fc507a95..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/broadcast2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/broadcast3.png b/TMessagesProj/src/main/res/drawable-ldpi/broadcast3.png deleted file mode 100644 index 532a1f098..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/broadcast3.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/broadcast4.png b/TMessagesProj/src/main/res/drawable-ldpi/broadcast4.png deleted file mode 100644 index 09916a977..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/broadcast4.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_aqua.png b/TMessagesProj/src/main/res/drawable-ldpi/broadcast_aqua.png deleted file mode 100755 index 842ff62e8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_blue.png b/TMessagesProj/src/main/res/drawable-ldpi/broadcast_blue.png deleted file mode 100755 index e0a722174..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_green.png b/TMessagesProj/src/main/res/drawable-ldpi/broadcast_green.png deleted file mode 100755 index 099d3caac..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_orange.png b/TMessagesProj/src/main/res/drawable-ldpi/broadcast_orange.png deleted file mode 100755 index 84d22c9a9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_pink.png b/TMessagesProj/src/main/res/drawable-ldpi/broadcast_pink.png deleted file mode 100755 index a6ef2ff5f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_red.png b/TMessagesProj/src/main/res/drawable-ldpi/broadcast_red.png deleted file mode 100755 index 44969ccea..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_violet.png b/TMessagesProj/src/main/res/drawable-ldpi/broadcast_violet.png deleted file mode 100755 index 5b1e01588..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_yellow.png b/TMessagesProj/src/main/res/drawable-ldpi/broadcast_yellow.png deleted file mode 100755 index e81e8c8fd..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/broadcast_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/btnshadow.9.png b/TMessagesProj/src/main/res/drawable-ldpi/btnshadow.9.png deleted file mode 100644 index 862afedd3..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/btnshadow.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/burn.png b/TMessagesProj/src/main/res/drawable-ldpi/burn.png deleted file mode 100755 index 9486b66ff..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/burn.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/call.png b/TMessagesProj/src/main/res/drawable-ldpi/call.png deleted file mode 100755 index fd4919add..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/call.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/cancel_big.png b/TMessagesProj/src/main/res/drawable-ldpi/cancel_big.png deleted file mode 100755 index 64db5953e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/cancel_big.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/circle.png b/TMessagesProj/src/main/res/drawable-ldpi/circle.png deleted file mode 100755 index d1e03ff93..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/circle.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/circle1.png b/TMessagesProj/src/main/res/drawable-ldpi/circle1.png deleted file mode 100755 index 62ace1342..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/circle1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/circle_big.png b/TMessagesProj/src/main/res/drawable-ldpi/circle_big.png deleted file mode 100755 index 1ed07582b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/circle_big.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/dialogs_badge.9.png b/TMessagesProj/src/main/res/drawable-ldpi/dialogs_badge.9.png deleted file mode 100644 index 3081873eb..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/dialogs_badge.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/dialogs_check.png b/TMessagesProj/src/main/res/drawable-ldpi/dialogs_check.png deleted file mode 100755 index fc7513c24..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/dialogs_check.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/dialogs_halfcheck.png b/TMessagesProj/src/main/res/drawable-ldpi/dialogs_halfcheck.png deleted file mode 100755 index a158d1bb6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/dialogs_halfcheck.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/dialogs_warning.png b/TMessagesProj/src/main/res/drawable-ldpi/dialogs_warning.png deleted file mode 100644 index 88b06cf31..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/dialogs_warning.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/doc_actions_b.png b/TMessagesProj/src/main/res/drawable-ldpi/doc_actions_b.png deleted file mode 100755 index c9ad08121..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/doc_actions_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/doc_actions_g.png b/TMessagesProj/src/main/res/drawable-ldpi/doc_actions_g.png deleted file mode 100755 index c1a124ab9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/doc_actions_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/doc_blue.png b/TMessagesProj/src/main/res/drawable-ldpi/doc_blue.png deleted file mode 100644 index 91dffa55c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/doc_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/doc_green.png b/TMessagesProj/src/main/res/drawable-ldpi/doc_green.png deleted file mode 100644 index 4cef2bc71..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/doc_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/doccancel_b.png b/TMessagesProj/src/main/res/drawable-ldpi/doccancel_b.png deleted file mode 100644 index fbaba5983..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/doccancel_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/doccancel_g.png b/TMessagesProj/src/main/res/drawable-ldpi/doccancel_g.png deleted file mode 100644 index c700483b1..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/doccancel_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/docload_b.png b/TMessagesProj/src/main/res/drawable-ldpi/docload_b.png deleted file mode 100644 index 129a045fa..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/docload_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/docload_g.png b/TMessagesProj/src/main/res/drawable-ldpi/docload_g.png deleted file mode 100644 index 1547d6694..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/docload_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/docpause_b.png b/TMessagesProj/src/main/res/drawable-ldpi/docpause_b.png deleted file mode 100644 index d57a51a58..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/docpause_b.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/docpause_g.png b/TMessagesProj/src/main/res/drawable-ldpi/docpause_g.png deleted file mode 100644 index 41dc34fab..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/docpause_g.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/editheader.9.png b/TMessagesProj/src/main/res/drawable-ldpi/editheader.9.png deleted file mode 100644 index 20fae4b68..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/editheader.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/fastscroll_thumb_default_holo.png b/TMessagesProj/src/main/res/drawable-ldpi/fastscroll_thumb_default_holo.png deleted file mode 100644 index b2aa1e95c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/fastscroll_thumb_default_holo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/fastscroll_thumb_pressed_holo.png b/TMessagesProj/src/main/res/drawable-ldpi/fastscroll_thumb_pressed_holo.png deleted file mode 100644 index 5702423b9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/fastscroll_thumb_pressed_holo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/gallery.png b/TMessagesProj/src/main/res/drawable-ldpi/gallery.png deleted file mode 100755 index 08b2617e0..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/gallery.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/group_aqua.png b/TMessagesProj/src/main/res/drawable-ldpi/group_aqua.png deleted file mode 100755 index 951346203..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/group_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/group_blue.png b/TMessagesProj/src/main/res/drawable-ldpi/group_blue.png deleted file mode 100755 index 2abaffe2b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/group_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/group_green.png b/TMessagesProj/src/main/res/drawable-ldpi/group_green.png deleted file mode 100755 index 2b2a91c69..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/group_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/group_orange.png b/TMessagesProj/src/main/res/drawable-ldpi/group_orange.png deleted file mode 100755 index 9914c8618..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/group_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/group_pink.png b/TMessagesProj/src/main/res/drawable-ldpi/group_pink.png deleted file mode 100755 index 9de7568b9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/group_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/group_red.png b/TMessagesProj/src/main/res/drawable-ldpi/group_red.png deleted file mode 100755 index 17854ce79..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/group_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/group_violet.png b/TMessagesProj/src/main/res/drawable-ldpi/group_violet.png deleted file mode 100755 index be9b88c5f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/group_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/group_yellow.png b/TMessagesProj/src/main/res/drawable-ldpi/group_yellow.png deleted file mode 100755 index abdfd7a0b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/group_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/grouplist.png b/TMessagesProj/src/main/res/drawable-ldpi/grouplist.png deleted file mode 100755 index aff6d7ab5..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/grouplist.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/header_timer.png b/TMessagesProj/src/main/res/drawable-ldpi/header_timer.png deleted file mode 100755 index 4d386984c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/header_timer.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/header_timer2.png b/TMessagesProj/src/main/res/drawable-ldpi/header_timer2.png deleted file mode 100755 index 12b1fa8b7..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/header_timer2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_attach.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_attach.png deleted file mode 100644 index 2f4e94b05..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_attach.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_back.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_back.png deleted file mode 100755 index b96a1289f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_back.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_compose.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_compose.png deleted file mode 100755 index ce2310d06..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_compose.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_delete_white.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_delete_white.png deleted file mode 100644 index 5cc4f8f35..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_delete_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_doc.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_doc.png deleted file mode 100644 index 6f5029f42..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_doc.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_done.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_done.png deleted file mode 100644 index b24a081b2..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_done.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_done_gray.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_done_gray.png deleted file mode 100644 index 2145393a6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_done_gray.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_fwd_copy.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_fwd_copy.png deleted file mode 100644 index cc282899b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_fwd_copy.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_fwd_delete.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_fwd_delete.png deleted file mode 100644 index 25b06608c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_fwd_delete.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_fwd_forward.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_fwd_forward.png deleted file mode 100644 index 913ab080d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_fwd_forward.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_location.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_location.png deleted file mode 100755 index 1c292ec4d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_location.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_logo.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_logo.png deleted file mode 100755 index 5170ace06..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_logo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_new.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_new.png deleted file mode 100755 index a98065183..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_new.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_other.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_other.png deleted file mode 100755 index b01d9808e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_other.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_other_white2.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_other_white2.png deleted file mode 100755 index 9ff5bd3e7..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_other_white2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_search.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_search.png deleted file mode 100644 index a4930c587..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_search.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_share.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_share.png deleted file mode 100644 index 67803f8ef..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_share.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_share_white.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_share_white.png deleted file mode 100644 index 7cb39f52d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_share_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_attach_gallery.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_attach_gallery.png deleted file mode 100755 index f281584c3..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_attach_gallery.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_attach_location.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_attach_location.png deleted file mode 100755 index e9f5dd3a4..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_attach_location.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_attach_photo.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_attach_photo.png deleted file mode 100755 index 938fdc801..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_attach_photo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_attach_video.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_attach_video.png deleted file mode 100755 index a8d090f40..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_attach_video.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_auth_next.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_auth_next.png deleted file mode 100644 index 424b9eb2f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_auth_next.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_done.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_done.png deleted file mode 100644 index f680be979..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_done.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_edit.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_edit.png deleted file mode 100644 index e8bf3fb5a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_edit.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_gallery_background.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_gallery_background.png deleted file mode 100644 index db9cd6245..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_gallery_background.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_launcher.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_launcher.png deleted file mode 100644 index 5f95431f3..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_launcher.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_lock_blue.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_lock_blue.png deleted file mode 100644 index ba660e007..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_lock_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_lock_green.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_lock_green.png deleted file mode 100644 index 55dc2ba88..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_lock_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_lock_white.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_lock_white.png deleted file mode 100644 index 2b86e3eee..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_lock_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_btn_cross.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_btn_cross.png deleted file mode 100644 index efe703cee..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_btn_cross.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_btn_cross_custom.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_btn_cross_custom.png deleted file mode 100644 index 064e1e29f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_btn_cross_custom.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_panel_hide.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_panel_hide.png deleted file mode 100644 index 38baf3602..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_panel_hide.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_panel_kb.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_panel_kb.png deleted file mode 100644 index 3927a1aaf..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_panel_kb.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_panel_smiles.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_panel_smiles.png deleted file mode 100755 index e6b2f6325..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_msg_panel_smiles.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_profile_cross.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_profile_cross.png deleted file mode 100644 index 36e31a5ab..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_profile_cross.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_profile_send_message.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_profile_send_message.png deleted file mode 100755 index 1749ddd6b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_profile_send_message.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_send.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_send.png deleted file mode 100755 index 9e921724d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_send.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_send_disabled.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_send_disabled.png deleted file mode 100755 index 8a2c19b5a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_send_disabled.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_backspace.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_backspace.png deleted file mode 100644 index 2d938e8c4..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_backspace.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_backspace_active.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_backspace_active.png deleted file mode 100644 index 0f7baf0d8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_backspace_active.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_bell.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_bell.png deleted file mode 100644 index d25b1eb50..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_bell.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_bell_active.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_bell_active.png deleted file mode 100644 index 0229c9b60..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_bell_active.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_car.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_car.png deleted file mode 100644 index 10cea0ed9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_car.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_car_active.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_car_active.png deleted file mode 100644 index 2d78ad258..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_car_active.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_flower.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_flower.png deleted file mode 100644 index 4ebbd8da9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_flower.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_flower_active.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_flower_active.png deleted file mode 100644 index ff1ba79f6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_flower_active.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_grid.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_grid.png deleted file mode 100644 index 48c2f825c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_grid.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_grid_active.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_grid_active.png deleted file mode 100644 index da712734e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_grid_active.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_recent.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_recent.png deleted file mode 100644 index 9766b4906..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_recent.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_recent_active.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_recent_active.png deleted file mode 100644 index f72dc2da0..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_recent_active.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_smile.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_smile.png deleted file mode 100644 index 0b46cd28e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_smile.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_smile_active.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_smile_active.png deleted file mode 100644 index e5b848287..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_smiles_smile_active.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/ic_video.png b/TMessagesProj/src/main/res/drawable-ldpi/ic_video.png deleted file mode 100644 index 1b24900fb..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/ic_video.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/intro1.png b/TMessagesProj/src/main/res/drawable-ldpi/intro1.png deleted file mode 100755 index d065bb3c6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/intro1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/intro2.png b/TMessagesProj/src/main/res/drawable-ldpi/intro2.png deleted file mode 100755 index a318fb8bd..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/intro2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/intro3.png b/TMessagesProj/src/main/res/drawable-ldpi/intro3.png deleted file mode 100755 index f9ac0af02..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/intro3.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/intro4.png b/TMessagesProj/src/main/res/drawable-ldpi/intro4.png deleted file mode 100755 index 1c167bfdc..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/intro4.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/intro5.png b/TMessagesProj/src/main/res/drawable-ldpi/intro5.png deleted file mode 100755 index e59de2832..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/intro5.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/intro6.png b/TMessagesProj/src/main/res/drawable-ldpi/intro6.png deleted file mode 100755 index 82db2e66e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/intro6.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/intro7.png b/TMessagesProj/src/main/res/drawable-ldpi/intro7.png deleted file mode 100755 index ba759b115..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/intro7.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/load_big.png b/TMessagesProj/src/main/res/drawable-ldpi/load_big.png deleted file mode 100755 index c3f2f7791..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/load_big.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/map_pin.png b/TMessagesProj/src/main/res/drawable-ldpi/map_pin.png deleted file mode 100644 index 6132d6c4d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/map_pin.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/mic.png b/TMessagesProj/src/main/res/drawable-ldpi/mic.png deleted file mode 100755 index ae464202a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/mic.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/mic_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/mic_pressed.png deleted file mode 100755 index 761d1603e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/mic_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_check.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_check.png deleted file mode 100755 index 203d059ec..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_check.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_check_w.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_check_w.png deleted file mode 100755 index 945d09ab7..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_check_w.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_clock.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_clock.png deleted file mode 100755 index 1e505955d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_clock.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_clock_photo.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_clock_photo.png deleted file mode 100755 index 3cbc2ff8c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_clock_photo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_halfcheck.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_halfcheck.png deleted file mode 100755 index 73f290a1a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_halfcheck.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_halfcheck_w.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_halfcheck_w.png deleted file mode 100755 index 1ba678ed8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_halfcheck_w.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_in.9.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_in.9.png deleted file mode 100644 index a27f9ecd0..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_in.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_in_photo.9.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_in_photo.9.png deleted file mode 100644 index ff1d16bf4..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_in_photo.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_in_photo_selected.9.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_in_photo_selected.9.png deleted file mode 100644 index 4f0bc4829..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_in_photo_selected.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_in_selected.9.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_in_selected.9.png deleted file mode 100644 index f7f620b76..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_in_selected.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_out.9.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_out.9.png deleted file mode 100644 index c96cc68b5..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_out.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_out_photo.9.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_out_photo.9.png deleted file mode 100644 index 7291b7696..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_out_photo.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_out_photo_selected.9.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_out_photo_selected.9.png deleted file mode 100644 index b22d8be2c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_out_photo_selected.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_out_selected.9.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_out_selected.9.png deleted file mode 100644 index 4d0027c34..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_out_selected.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/msg_warning.png b/TMessagesProj/src/main/res/drawable-ldpi/msg_warning.png deleted file mode 100644 index b391d147e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/msg_warning.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/newmsg_divider.png b/TMessagesProj/src/main/res/drawable-ldpi/newmsg_divider.png deleted file mode 100755 index 12298133f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/newmsg_divider.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/nophotos.9.png b/TMessagesProj/src/main/res/drawable-ldpi/nophotos.9.png deleted file mode 100644 index 05a2c8199..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/nophotos.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/notification.png b/TMessagesProj/src/main/res/drawable-ldpi/notification.png deleted file mode 100755 index 2fe4f6b4e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/notification.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/pagedown.png b/TMessagesProj/src/main/res/drawable-ldpi/pagedown.png deleted file mode 100755 index 4689dffd1..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/pagedown.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/pause1.png b/TMessagesProj/src/main/res/drawable-ldpi/pause1.png deleted file mode 100755 index 2c7ff54b4..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/pause1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/pause1_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/pause1_pressed.png deleted file mode 100755 index 4ef1f6a72..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/pause1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/pause2.png b/TMessagesProj/src/main/res/drawable-ldpi/pause2.png deleted file mode 100755 index 812828743..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/pause2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/pause2_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/pause2_pressed.png deleted file mode 100755 index b6fbdfd5b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/pause2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/photo_back.png b/TMessagesProj/src/main/res/drawable-ldpi/photo_back.png deleted file mode 100755 index 14f9ad5e8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/photo_back.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/photobadge.9.png b/TMessagesProj/src/main/res/drawable-ldpi/photobadge.9.png deleted file mode 100644 index 0173130bd..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/photobadge.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/photoborder.9.png b/TMessagesProj/src/main/res/drawable-ldpi/photoborder.9.png deleted file mode 100644 index 2a33e9d66..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/photoborder.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/photocancel.png b/TMessagesProj/src/main/res/drawable-ldpi/photocancel.png deleted file mode 100644 index bce279ae8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/photocancel.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/photocheck.png b/TMessagesProj/src/main/res/drawable-ldpi/photocheck.png deleted file mode 100755 index 66c471720..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/photocheck.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/photogif.png b/TMessagesProj/src/main/res/drawable-ldpi/photogif.png deleted file mode 100644 index 0915f0e48..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/photogif.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/photoload.png b/TMessagesProj/src/main/res/drawable-ldpi/photoload.png deleted file mode 100644 index 5c50b3de9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/photoload.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/photopause.png b/TMessagesProj/src/main/res/drawable-ldpi/photopause.png deleted file mode 100644 index 1f95c38a7..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/photopause.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/phototime.9.png b/TMessagesProj/src/main/res/drawable-ldpi/phototime.9.png deleted file mode 100644 index 25bf2e271..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/phototime.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/play1.png b/TMessagesProj/src/main/res/drawable-ldpi/play1.png deleted file mode 100755 index df10a3ee1..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/play1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/play1_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/play1_pressed.png deleted file mode 100755 index 60aef6fbe..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/play1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/play2.png b/TMessagesProj/src/main/res/drawable-ldpi/play2.png deleted file mode 100755 index 6eca1a394..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/play2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/play2_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/play2_pressed.png deleted file mode 100755 index b3bdee286..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/play2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/play_big.png b/TMessagesProj/src/main/res/drawable-ldpi/play_big.png deleted file mode 100755 index 583153249..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/play_big.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/player1.png b/TMessagesProj/src/main/res/drawable-ldpi/player1.png deleted file mode 100755 index e49d95d94..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/player1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/player1_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/player1_pressed.png deleted file mode 100755 index 32e7dde9e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/player1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/player2.png b/TMessagesProj/src/main/res/drawable-ldpi/player2.png deleted file mode 100755 index 46551ea5e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/player2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/player2_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/player2_pressed.png deleted file mode 100755 index c16103c39..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/player2_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/playvideo.png b/TMessagesProj/src/main/res/drawable-ldpi/playvideo.png deleted file mode 100644 index d03cb384e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/playvideo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/plus.png b/TMessagesProj/src/main/res/drawable-ldpi/plus.png deleted file mode 100755 index dfc3173da..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/plus.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/rec.png b/TMessagesProj/src/main/res/drawable-ldpi/rec.png deleted file mode 100755 index 2d08c58f6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/rec.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/regbtn2.9.png b/TMessagesProj/src/main/res/drawable-ldpi/regbtn2.9.png deleted file mode 100644 index 6f9875141..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/regbtn2.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/regbtn2_pressed.9.png b/TMessagesProj/src/main/res/drawable-ldpi/regbtn2_pressed.9.png deleted file mode 100644 index 2854a90e3..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/regbtn2_pressed.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_large.png b/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_large.png deleted file mode 100755 index c0558b25f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_large.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small.png b/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small.png deleted file mode 100755 index fb868f484..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small_active.png b/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small_active.png deleted file mode 100755 index 1b18412d6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small_active.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small_grey.png b/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small_grey.png deleted file mode 100755 index c31d5db9d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small_grey.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/shadow.png b/TMessagesProj/src/main/res/drawable-ldpi/shadow.png deleted file mode 100755 index 969705413..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/shadow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/slidearrow.png b/TMessagesProj/src/main/res/drawable-ldpi/slidearrow.png deleted file mode 100755 index 12fae28d7..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/slidearrow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/spinner.9.png b/TMessagesProj/src/main/res/drawable-ldpi/spinner.9.png deleted file mode 100755 index 58326c446..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/spinner.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/spinner_pressed.9.png b/TMessagesProj/src/main/res/drawable-ldpi/spinner_pressed.9.png deleted file mode 100755 index ac4e98186..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/spinner_pressed.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/switch_off1.png b/TMessagesProj/src/main/res/drawable-ldpi/switch_off1.png deleted file mode 100755 index a7e03809b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/switch_off1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/switch_off1_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/switch_off1_pressed.png deleted file mode 100755 index 8da1ae313..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/switch_off1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/switch_on1.png b/TMessagesProj/src/main/res/drawable-ldpi/switch_on1.png deleted file mode 100755 index d0f8cde4a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/switch_on1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/switch_on1_pressed.png b/TMessagesProj/src/main/res/drawable-ldpi/switch_on1_pressed.png deleted file mode 100755 index a58b8857f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/switch_on1_pressed.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/system_black.9.png b/TMessagesProj/src/main/res/drawable-ldpi/system_black.9.png deleted file mode 100644 index a4fa2672f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/system_black.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/system_blue.9.png b/TMessagesProj/src/main/res/drawable-ldpi/system_blue.9.png deleted file mode 100644 index eb9a4c814..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/system_blue.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/system_loader1.png b/TMessagesProj/src/main/res/drawable-ldpi/system_loader1.png deleted file mode 100755 index 6823c3748..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/system_loader1.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/system_loader2.png b/TMessagesProj/src/main/res/drawable-ldpi/system_loader2.png deleted file mode 100755 index 96a5f8874..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/system_loader2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/telegram_avatar.png b/TMessagesProj/src/main/res/drawable-ldpi/telegram_avatar.png deleted file mode 100644 index e56bb3a37..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/telegram_avatar.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/tooltip.png b/TMessagesProj/src/main/res/drawable-ldpi/tooltip.png deleted file mode 100755 index 4385e07b4..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/tooltip.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/user_aqua.png b/TMessagesProj/src/main/res/drawable-ldpi/user_aqua.png deleted file mode 100755 index 1fc80871e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/user_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/user_blue.png b/TMessagesProj/src/main/res/drawable-ldpi/user_blue.png deleted file mode 100755 index 06f8c3e67..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/user_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/user_green.png b/TMessagesProj/src/main/res/drawable-ldpi/user_green.png deleted file mode 100755 index 807bf357d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/user_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/user_orange.png b/TMessagesProj/src/main/res/drawable-ldpi/user_orange.png deleted file mode 100755 index 065fa207f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/user_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/user_pink.png b/TMessagesProj/src/main/res/drawable-ldpi/user_pink.png deleted file mode 100755 index 553d52b03..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/user_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/user_placeholder.png b/TMessagesProj/src/main/res/drawable-ldpi/user_placeholder.png deleted file mode 100644 index a8d9b491c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/user_placeholder.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/user_red.png b/TMessagesProj/src/main/res/drawable-ldpi/user_red.png deleted file mode 100755 index e75da1f87..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/user_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/user_violet.png b/TMessagesProj/src/main/res/drawable-ldpi/user_violet.png deleted file mode 100755 index e85fbc933..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/user_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/user_yellow.png b/TMessagesProj/src/main/res/drawable-ldpi/user_yellow.png deleted file mode 100755 index 5356ce583..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/user_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/video_play.png b/TMessagesProj/src/main/res/drawable-ldpi/video_play.png deleted file mode 100644 index ef7a33726..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/video_play.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/videolapse.png b/TMessagesProj/src/main/res/drawable-ldpi/videolapse.png deleted file mode 100755 index 8a8a2744b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/videolapse.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/videotrimmer.png b/TMessagesProj/src/main/res/drawable-ldpi/videotrimmer.png deleted file mode 100755 index 1a6e341f0..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/videotrimmer.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/viewbtn.9.png b/TMessagesProj/src/main/res/drawable-ldpi/viewbtn.9.png deleted file mode 100644 index 222e7611a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/viewbtn.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/viewbtn_pressed.9.png b/TMessagesProj/src/main/res/drawable-ldpi/viewbtn_pressed.9.png deleted file mode 100644 index 8e12f5157..000000000 Binary files a/TMessagesProj/src/main/res/drawable-ldpi/viewbtn_pressed.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_aqua.png b/TMessagesProj/src/main/res/drawable-mdpi/broadcast_aqua.png deleted file mode 100755 index ee955dee9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_blue.png b/TMessagesProj/src/main/res/drawable-mdpi/broadcast_blue.png deleted file mode 100755 index cfe7cea90..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_green.png b/TMessagesProj/src/main/res/drawable-mdpi/broadcast_green.png deleted file mode 100755 index 322153280..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_orange.png b/TMessagesProj/src/main/res/drawable-mdpi/broadcast_orange.png deleted file mode 100755 index 2f3b81594..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_pink.png b/TMessagesProj/src/main/res/drawable-mdpi/broadcast_pink.png deleted file mode 100755 index cace0d662..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_red.png b/TMessagesProj/src/main/res/drawable-mdpi/broadcast_red.png deleted file mode 100755 index d63200980..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_violet.png b/TMessagesProj/src/main/res/drawable-mdpi/broadcast_violet.png deleted file mode 100755 index fb7135aa0..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_yellow.png b/TMessagesProj/src/main/res/drawable-mdpi/broadcast_yellow.png deleted file mode 100755 index 9ed3aa714..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/broadcast_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge.9.png b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge.9.png index 81960234d..2c32c51ef 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_badge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_check.png b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_check.png deleted file mode 100755 index a6b157a09..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_check.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_halfcheck.png b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_halfcheck.png deleted file mode 100755 index ea5a36bc1..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_halfcheck.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_warning.png b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_warning.png old mode 100644 new mode 100755 index 997da977c..0c0f3fb5f Binary files a/TMessagesProj/src/main/res/drawable-mdpi/dialogs_warning.png and b/TMessagesProj/src/main/res/drawable-mdpi/dialogs_warning.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/floating.png b/TMessagesProj/src/main/res/drawable-mdpi/floating.png new file mode 100755 index 000000000..bc566ba39 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/floating.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/floating_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/floating_pressed.png new file mode 100755 index 000000000..50dfdc652 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/floating_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/gallery.png b/TMessagesProj/src/main/res/drawable-mdpi/gallery.png deleted file mode 100755 index 4eef8a0a9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/gallery.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/group_aqua.png b/TMessagesProj/src/main/res/drawable-mdpi/group_aqua.png deleted file mode 100755 index 79acb836e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/group_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/group_blue.png b/TMessagesProj/src/main/res/drawable-mdpi/group_blue.png deleted file mode 100755 index 8afd4c0d3..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/group_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/group_green.png b/TMessagesProj/src/main/res/drawable-mdpi/group_green.png deleted file mode 100755 index 9ebf13077..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/group_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/group_orange.png b/TMessagesProj/src/main/res/drawable-mdpi/group_orange.png deleted file mode 100755 index d73b1a4fd..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/group_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/group_pink.png b/TMessagesProj/src/main/res/drawable-mdpi/group_pink.png deleted file mode 100755 index 7bad9b035..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/group_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/group_red.png b/TMessagesProj/src/main/res/drawable-mdpi/group_red.png deleted file mode 100755 index 293b63320..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/group_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/group_violet.png b/TMessagesProj/src/main/res/drawable-mdpi/group_violet.png deleted file mode 100755 index 7aa165fca..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/group_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/group_yellow.png b/TMessagesProj/src/main/res/drawable-mdpi/group_yellow.png deleted file mode 100755 index badd57403..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/group_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_back.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_back.png index 6d64f59c6..9e662f6d4 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_back.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_back.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_back_white.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_back_white.png deleted file mode 100644 index 3d44a7863..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_back_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_compose.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_compose.png deleted file mode 100755 index 0a485fc70..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_compose.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_logo.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_logo.png deleted file mode 100755 index 15024faba..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_logo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_other.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_other.png index 6159c5eba..1d8ad18a0 100755 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_other.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_other.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_other_white.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_other_white.png deleted file mode 100644 index 40c40ba5e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_other_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_other_white2.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_other_white2.png deleted file mode 100755 index 23433a4b8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_other_white2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_search.png b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_search.png old mode 100644 new mode 100755 index 20fcaaca4..dff1e3a8a Binary files a/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_search.png and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_search.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photo_back.png b/TMessagesProj/src/main/res/drawable-mdpi/photo_back.png deleted file mode 100755 index 22a1fe263..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/photo_back.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/popup_fixed.9.png b/TMessagesProj/src/main/res/drawable-mdpi/popup_fixed.9.png index 20bfba33e..e9204993d 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/popup_fixed.9.png and b/TMessagesProj/src/main/res/drawable-mdpi/popup_fixed.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/telegram_avatar.png b/TMessagesProj/src/main/res/drawable-mdpi/telegram_avatar.png deleted file mode 100644 index 04bf4ff70..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/telegram_avatar.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/user_aqua.png b/TMessagesProj/src/main/res/drawable-mdpi/user_aqua.png deleted file mode 100755 index a075f6b4e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/user_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/user_blue.png b/TMessagesProj/src/main/res/drawable-mdpi/user_blue.png deleted file mode 100755 index 234d68c7f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/user_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/user_green.png b/TMessagesProj/src/main/res/drawable-mdpi/user_green.png deleted file mode 100755 index 6faac3a35..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/user_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/user_orange.png b/TMessagesProj/src/main/res/drawable-mdpi/user_orange.png deleted file mode 100755 index be2bce768..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/user_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/user_pink.png b/TMessagesProj/src/main/res/drawable-mdpi/user_pink.png deleted file mode 100755 index ac2f29dfa..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/user_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/user_red.png b/TMessagesProj/src/main/res/drawable-mdpi/user_red.png deleted file mode 100755 index 77e95e130..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/user_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/user_violet.png b/TMessagesProj/src/main/res/drawable-mdpi/user_violet.png deleted file mode 100755 index a226a6d90..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/user_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/user_yellow.png b/TMessagesProj/src/main/res/drawable-mdpi/user_yellow.png deleted file mode 100755 index ff98ac6ad..000000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/user_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_aqua.png b/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_aqua.png deleted file mode 100755 index 70dfa6f69..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_blue.png b/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_blue.png deleted file mode 100755 index 4a30d7b6e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_green.png b/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_green.png deleted file mode 100755 index 8cabb2c33..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_orange.png b/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_orange.png deleted file mode 100755 index da46755d0..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_pink.png b/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_pink.png deleted file mode 100755 index fbc921282..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_red.png b/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_red.png deleted file mode 100755 index 1cc2c2d8d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_violet.png b/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_violet.png deleted file mode 100755 index 9f2ed8bfb..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_yellow.png b/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_yellow.png deleted file mode 100755 index 2609fca15..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/broadcast_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge.9.png index 7ce742a7b..9632851cc 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_badge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_check.png b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_check.png index 95eef6c51..83e79ba58 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_check.png and b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_check.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_halfcheck.png b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_halfcheck.png index aa4b23807..4756cbf5c 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_halfcheck.png and b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_halfcheck.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_warning.png b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_warning.png old mode 100644 new mode 100755 index 7a7c460c9..83fd07ad7 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_warning.png and b/TMessagesProj/src/main/res/drawable-xhdpi/dialogs_warning.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/floating.png b/TMessagesProj/src/main/res/drawable-xhdpi/floating.png new file mode 100755 index 000000000..c087569c8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/floating.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/floating_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/floating_pressed.png new file mode 100755 index 000000000..12374fc27 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/floating_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/gallery.png b/TMessagesProj/src/main/res/drawable-xhdpi/gallery.png deleted file mode 100755 index 3d14800a8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/gallery.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/group_aqua.png b/TMessagesProj/src/main/res/drawable-xhdpi/group_aqua.png deleted file mode 100755 index 1d1a8222d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/group_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/group_blue.png b/TMessagesProj/src/main/res/drawable-xhdpi/group_blue.png deleted file mode 100755 index 46bada8bd..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/group_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/group_green.png b/TMessagesProj/src/main/res/drawable-xhdpi/group_green.png deleted file mode 100755 index 138bcd655..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/group_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/group_orange.png b/TMessagesProj/src/main/res/drawable-xhdpi/group_orange.png deleted file mode 100755 index 22af590ce..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/group_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/group_pink.png b/TMessagesProj/src/main/res/drawable-xhdpi/group_pink.png deleted file mode 100755 index 181874de9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/group_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/group_red.png b/TMessagesProj/src/main/res/drawable-xhdpi/group_red.png deleted file mode 100755 index 1465e5d0d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/group_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/group_violet.png b/TMessagesProj/src/main/res/drawable-xhdpi/group_violet.png deleted file mode 100755 index 0699ff6a0..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/group_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/group_yellow.png b/TMessagesProj/src/main/res/drawable-xhdpi/group_yellow.png deleted file mode 100755 index 9226fe235..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/group_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_back.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_back.png index 9b612b737..addbfc886 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_back.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_back.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_back_white.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_back_white.png deleted file mode 100644 index 559f8f40b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_back_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_compose.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_compose.png deleted file mode 100755 index 5fdb45dc8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_compose.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_logo.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_logo.png deleted file mode 100755 index ee88fc628..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_logo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_other.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_other.png index 02bc89b63..1b04eda04 100755 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_other.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_other.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_other_white.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_other_white.png deleted file mode 100644 index 4031d6ef1..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_other_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_other_white2.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_other_white2.png deleted file mode 100755 index 8a5215911..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_other_white2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_search.png b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_search.png old mode 100644 new mode 100755 index 0c4f8fbd4..043759acd Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_search.png and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_search.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photo_back.png b/TMessagesProj/src/main/res/drawable-xhdpi/photo_back.png deleted file mode 100755 index 21dcdebe2..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/photo_back.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/popup_fixed.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/popup_fixed.9.png index 1b6b749f8..a081ceb95 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/popup_fixed.9.png and b/TMessagesProj/src/main/res/drawable-xhdpi/popup_fixed.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/telegram_avatar.png b/TMessagesProj/src/main/res/drawable-xhdpi/telegram_avatar.png deleted file mode 100644 index 6514bfda7..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/telegram_avatar.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/user_aqua.png b/TMessagesProj/src/main/res/drawable-xhdpi/user_aqua.png deleted file mode 100755 index 0aed5664c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/user_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/user_blue.png b/TMessagesProj/src/main/res/drawable-xhdpi/user_blue.png deleted file mode 100755 index 4366ae998..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/user_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/user_green.png b/TMessagesProj/src/main/res/drawable-xhdpi/user_green.png deleted file mode 100755 index b7916df7d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/user_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/user_orange.png b/TMessagesProj/src/main/res/drawable-xhdpi/user_orange.png deleted file mode 100755 index 60db7014e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/user_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/user_pink.png b/TMessagesProj/src/main/res/drawable-xhdpi/user_pink.png deleted file mode 100755 index ddd46de71..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/user_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/user_red.png b/TMessagesProj/src/main/res/drawable-xhdpi/user_red.png deleted file mode 100755 index ae888768e..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/user_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/user_violet.png b/TMessagesProj/src/main/res/drawable-xhdpi/user_violet.png deleted file mode 100755 index 3865d9edf..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/user_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/user_yellow.png b/TMessagesProj/src/main/res/drawable-xhdpi/user_yellow.png deleted file mode 100755 index ffb540a14..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/user_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_aqua.png b/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_aqua.png deleted file mode 100755 index 6d3d49d99..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_blue.png b/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_blue.png deleted file mode 100755 index a0b79c115..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_green.png b/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_green.png deleted file mode 100755 index 21cd9614f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_orange.png b/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_orange.png deleted file mode 100755 index 1ed205ff8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_pink.png b/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_pink.png deleted file mode 100755 index 0b65cfd00..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_red.png b/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_red.png deleted file mode 100755 index 37404ef89..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_violet.png b/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_violet.png deleted file mode 100755 index a6a22b4a0..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_yellow.png b/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_yellow.png deleted file mode 100755 index df5340e4b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/broadcast_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge.9.png index 01ce6f083..5de08904f 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_badge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_check.png b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_check.png index 2d3d5b69e..a3c0f9cec 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_check.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_check.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_halfcheck.png b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_halfcheck.png index 029081a96..5f5a7b1e1 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_halfcheck.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_halfcheck.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_warning.png b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_warning.png old mode 100644 new mode 100755 index 150fb82cc..8b1332493 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_warning.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/dialogs_warning.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/floating.png b/TMessagesProj/src/main/res/drawable-xxhdpi/floating.png new file mode 100755 index 000000000..bd6d1c2c2 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/floating.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/floating_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/floating_pressed.png new file mode 100755 index 000000000..68f657512 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/floating_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/gallery.png b/TMessagesProj/src/main/res/drawable-xxhdpi/gallery.png deleted file mode 100755 index 516f851e8..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/gallery.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/group_aqua.png b/TMessagesProj/src/main/res/drawable-xxhdpi/group_aqua.png deleted file mode 100755 index 92f07b948..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/group_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/group_blue.png b/TMessagesProj/src/main/res/drawable-xxhdpi/group_blue.png deleted file mode 100755 index 0a4b8223a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/group_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/group_green.png b/TMessagesProj/src/main/res/drawable-xxhdpi/group_green.png deleted file mode 100755 index ee04f6fa4..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/group_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/group_orange.png b/TMessagesProj/src/main/res/drawable-xxhdpi/group_orange.png deleted file mode 100755 index ec4d4c0c3..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/group_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/group_pink.png b/TMessagesProj/src/main/res/drawable-xxhdpi/group_pink.png deleted file mode 100755 index 1f95f681b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/group_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/group_red.png b/TMessagesProj/src/main/res/drawable-xxhdpi/group_red.png deleted file mode 100755 index 002d387f6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/group_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/group_violet.png b/TMessagesProj/src/main/res/drawable-xxhdpi/group_violet.png deleted file mode 100755 index 84fad91c1..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/group_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/group_yellow.png b/TMessagesProj/src/main/res/drawable-xxhdpi/group_yellow.png deleted file mode 100755 index d9e5e5442..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/group_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_back.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_back.png index 4dcf3e7d5..4057cc545 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_back.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_back.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_back_white.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_back_white.png deleted file mode 100644 index 45c92742a..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_back_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_compose.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_compose.png deleted file mode 100755 index ab4f82a4b..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_compose.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_logo.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_logo.png deleted file mode 100755 index 67a0225c7..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_logo.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_other.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_other.png index 90d0c2363..2955c02ec 100755 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_other.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_other.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_other_white.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_other_white.png deleted file mode 100644 index b70508dab..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_other_white.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_other_white2.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_other_white2.png deleted file mode 100755 index d259309d6..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_other_white2.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_search.png b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_search.png old mode 100644 new mode 100755 index 78103aaa8..0bbeab150 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_search.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_search.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photo_back.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photo_back.png deleted file mode 100755 index 83b69df05..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/photo_back.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/popup_fixed.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/popup_fixed.9.png index 3bb68a6af..fb7d715fa 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/popup_fixed.9.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/popup_fixed.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/telegram_avatar.png b/TMessagesProj/src/main/res/drawable-xxhdpi/telegram_avatar.png deleted file mode 100644 index 785dd42e9..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/telegram_avatar.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/user_aqua.png b/TMessagesProj/src/main/res/drawable-xxhdpi/user_aqua.png deleted file mode 100755 index 4de401c74..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/user_aqua.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/user_blue.png b/TMessagesProj/src/main/res/drawable-xxhdpi/user_blue.png deleted file mode 100755 index e5a3fa0be..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/user_blue.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/user_green.png b/TMessagesProj/src/main/res/drawable-xxhdpi/user_green.png deleted file mode 100755 index 9877c351f..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/user_green.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/user_orange.png b/TMessagesProj/src/main/res/drawable-xxhdpi/user_orange.png deleted file mode 100755 index 2b4e28c5c..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/user_orange.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/user_pink.png b/TMessagesProj/src/main/res/drawable-xxhdpi/user_pink.png deleted file mode 100755 index b6dcdac04..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/user_pink.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/user_red.png b/TMessagesProj/src/main/res/drawable-xxhdpi/user_red.png deleted file mode 100755 index 3f92f5f8d..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/user_red.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/user_violet.png b/TMessagesProj/src/main/res/drawable-xxhdpi/user_violet.png deleted file mode 100755 index 021666e41..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/user_violet.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/user_yellow.png b/TMessagesProj/src/main/res/drawable-xxhdpi/user_yellow.png deleted file mode 100755 index de2abbbbd..000000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/user_yellow.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable/ab_icon_up_fixed.xml b/TMessagesProj/src/main/res/drawable/ab_icon_up_fixed.xml deleted file mode 100644 index 8f48139c0..000000000 --- a/TMessagesProj/src/main/res/drawable/ab_icon_up_fixed.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/ab_icon_up_gallery.xml b/TMessagesProj/src/main/res/drawable/ab_icon_up_gallery.xml deleted file mode 100644 index 1aab7a127..000000000 --- a/TMessagesProj/src/main/res/drawable/ab_icon_up_gallery.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/ab_icon_up_messages.xml b/TMessagesProj/src/main/res/drawable/ab_icon_up_messages.xml deleted file mode 100644 index 7379f044f..000000000 --- a/TMessagesProj/src/main/res/drawable/ab_icon_up_messages.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/drawable/floating_states.xml b/TMessagesProj/src/main/res/drawable/floating_states.xml new file mode 100644 index 000000000..c2c53d129 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/floating_states.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/messages_list.xml b/TMessagesProj/src/main/res/layout/messages_list.xml index 60befc870..5309106a0 100644 --- a/TMessagesProj/src/main/res/layout/messages_list.xml +++ b/TMessagesProj/src/main/res/layout/messages_list.xml @@ -1,15 +1,9 @@ - - - - + android:layout_height="wrap_content"/> - + + + diff --git a/TMessagesProj/src/main/res/values-v21/styles.xml b/TMessagesProj/src/main/res/values-v21/styles.xml index bf6a19182..ea24d7b27 100644 --- a/TMessagesProj/src/main/res/values-v21/styles.xml +++ b/TMessagesProj/src/main/res/values-v21/styles.xml @@ -16,6 +16,8 @@ @android:color/white @android:color/white @null + #435e7e + #54759e - - diff --git a/TMessagesProj/src/main/res/values/styles.xml b/TMessagesProj/src/main/res/values/styles.xml index d3f110e3b..bf12e881b 100644 --- a/TMessagesProj/src/main/res/values/styles.xml +++ b/TMessagesProj/src/main/res/values/styles.xml @@ -32,6 +32,13 @@ true + + + + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 45c257f58..f703ec03b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Oct 06 17:04:43 MSK 2014 +#Mon Nov 03 14:19:12 MSK 2014 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip