diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 73b4abe33..aac3f3014 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -81,7 +81,7 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 19 - versionCode 244 - versionName "1.4.15" + versionCode 245 + versionName "1.5.0" } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index e93cef0f6..3cdcc0253 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -79,6 +79,48 @@ public class MediaController implements NotificationCenter.NotificationCenterDel long pcmOffset; } + private static final String[] projectionPhotos = { + MediaStore.Images.Media._ID, + MediaStore.Images.Media.BUCKET_ID, + MediaStore.Images.Media.BUCKET_DISPLAY_NAME, + MediaStore.Images.Media.DATA, + MediaStore.Images.Media.DATE_TAKEN, + MediaStore.Images.Media.ORIENTATION + }; + + public static class AlbumEntry { + public int bucketId; + public String bucketName; + public PhotoEntry coverPhoto; + public ArrayList photos = new ArrayList(); + + public AlbumEntry(int bucketId, String bucketName, PhotoEntry coverPhoto) { + this.bucketId = bucketId; + this.bucketName = bucketName; + this.coverPhoto = coverPhoto; + } + + public void addPhoto(PhotoEntry photoEntry) { + photos.add(photoEntry); + } + } + + public static class PhotoEntry { + public int bucketId; + public int imageId; + public long dateTaken; + public String path; + public int orientation; + + public PhotoEntry(int bucketId, int imageId, long dateTaken, String path, int orientation) { + this.bucketId = bucketId; + this.imageId = imageId; + this.dateTaken = dateTaken; + this.path = path; + this.orientation = orientation; + } + } + public final static int audioProgressDidChanged = 50001; public final static int audioDidReset = 50002; public final static int recordProgressChanged = 50003; @@ -86,6 +128,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel public final static int recordStartError = 50005; public final static int recordStopped = 50006; public final static int screenshotTook = 50007; + public final static int albumsDidLoaded = 50008; private HashMap>> loadingFileObservers = new HashMap>>(); private HashMap observersByTag = new HashMap(); @@ -412,7 +455,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel } public void stopMediaObserver() { - if (android.os.Build.VERSION.SDK_INT < 10) { //disable while it's not perferct + if (android.os.Build.VERSION.SDK_INT > 0) { //disable while it's not perferct return; } if (stopMediaObserverRunnable == null) { @@ -1533,4 +1576,80 @@ public class MediaController implements NotificationCenter.NotificationCenterDel } return null; } + + public static void loadGalleryPhotosAlbums(final int guid) { + Utilities.globalQueue.postRunnable(new Runnable() { + @Override + public void run() { + final ArrayList albumsSorted = new ArrayList(); + HashMap albums = new HashMap(); + AlbumEntry allPhotosAlbum = null; + String cameraFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath() + "/" + "Camera/"; + Integer cameraAlbumId = null; + + Cursor cursor = null; + try { + cursor = MediaStore.Images.Media.query(ApplicationLoader.applicationContext.getContentResolver(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projectionPhotos, "", null, MediaStore.Images.Media.DATE_TAKEN + " DESC"); + if (cursor != null) { + int imageIdColumn = cursor.getColumnIndex(MediaStore.Images.Media._ID); + int bucketIdColumn = cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_ID); + int bucketNameColumn = cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME); + int dataColumn = cursor.getColumnIndex(MediaStore.Images.Media.DATA); + int dateColumn = cursor.getColumnIndex(MediaStore.Images.Media.DATE_TAKEN); + int orientationColumn = cursor.getColumnIndex(MediaStore.Images.Media.ORIENTATION); + + while (cursor.moveToNext()) { + int imageId = cursor.getInt(imageIdColumn); + int bucketId = cursor.getInt(bucketIdColumn); + String bucketName = cursor.getString(bucketNameColumn); + String path = cursor.getString(dataColumn); + long dateTaken = cursor.getLong(dateColumn); + int orientation = cursor.getInt(orientationColumn); + + PhotoEntry photoEntry = new PhotoEntry(bucketId, imageId, dateTaken, path, orientation); + + if (allPhotosAlbum == null) { + allPhotosAlbum = new AlbumEntry(0, LocaleController.getString("AllPhotos", R.string.AllPhotos), photoEntry); + albumsSorted.add(0, allPhotosAlbum); + } + if (allPhotosAlbum != null) { + allPhotosAlbum.addPhoto(photoEntry); + } + + AlbumEntry albumEntry = albums.get(bucketId); + if (albumEntry == null) { + albumEntry = new AlbumEntry(bucketId, bucketName, photoEntry); + albums.put(bucketId, albumEntry); + if (cameraAlbumId == null && cameraFolder != null && path != null && path.startsWith(cameraFolder)) { + albumsSorted.add(0, albumEntry); + cameraAlbumId = bucketId; + } else { + albumsSorted.add(albumEntry); + } + } + + albumEntry.addPhoto(photoEntry); + } + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } finally { + if (cursor != null) { + try { + cursor.close(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + } + final Integer cameraAlbumIdFinal = cameraAlbumId; + Utilities.RunOnUIThread(new Runnable() { + @Override + public void run() { + NotificationCenter.getInstance().postNotificationName(albumsDidLoaded, guid, albumsSorted, cameraAlbumIdFinal); + } + }); + } + }); + } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index 0c472b085..56e2bb0b4 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -4516,9 +4516,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (choosenSoundPath != null && !choosenSoundPath.equals("NoSound")) { if (choosenSoundPath.equals(defaultPath)) { - mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI); + mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, AudioManager.STREAM_NOTIFICATION); } else { - mBuilder.setSound(Uri.parse(choosenSoundPath)); + mBuilder.setSound(Uri.parse(choosenSoundPath), AudioManager.STREAM_NOTIFICATION); } } 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 abe78fb79..552f17f96 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java @@ -387,6 +387,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD w = (int) (currentPhotoObject.photoOwner.w / hScale); } } + int timeWidthTotal = timeWidth + Utilities.dp(14 + (currentMessageObject.isOut() ? 20 : 0)); + if (w < timeWidthTotal) { + w = timeWidthTotal; + } photoWidth = w; photoHeight = h; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index c2eeac5ad..8d0f4aa10 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -101,7 +101,10 @@ import java.util.Comparator; import java.util.HashMap; import java.util.concurrent.Semaphore; -public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate, NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, DocumentSelectActivity.DocumentSelectActivityDelegate, PhotoViewer.PhotoViewerProvider { +public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate, + NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, + DocumentSelectActivity.DocumentSelectActivityDelegate, PhotoViewer.PhotoViewerProvider, + PhotoPickerActivity.PhotoPickerActivityDelegate { private View timeItem; private View menuItem; @@ -414,7 +417,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { @@ -438,13 +441,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa FileLog.e("tmessages", e); } } else if (id == attach_gallery) { - try { - Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); - photoPickerIntent.setType("image/*"); - getParentActivity().startActivityForResult(photoPickerIntent, 1); - } catch (Exception e) { - FileLog.e("tmessages", e); - } + PhotoPickerActivity fragment = new PhotoPickerActivity(); + fragment.setDelegate(ChatActivity.this); + presentFragment(fragment); } else if (id == attach_video) { try { Intent pickIntent = new Intent(); @@ -1987,7 +1986,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa View firstVisView = chatListView.getChildAt(chatListView.getChildCount() - 1); int top = ((firstVisView == null) ? 0 : firstVisView.getTop()) - chatListView.getPaddingTop(); chatAdapter.notifyDataSetChanged(); - chatListView.setSelectionFromTop(firstVisPos + newRowsCount, top); + chatListView.setSelectionFromTop(firstVisPos + newRowsCount - (endReached ? 1 : 0), top); } if (paused) { @@ -2676,6 +2675,24 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa } } + @Override + public void didSelectPhotos(ArrayList photos) { + for (String path : photos) { + processSendingPhoto(path, null); + } + } + + @Override + public void startPhotoSelectActivity() { + try { + Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); + photoPickerIntent.setType("image/*"); + getParentActivity().startActivityForResult(photoPickerIntent, 1); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + @Override public void onBeginSlide() { super.onBeginSlide(); @@ -3327,7 +3344,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa } @Override - public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) { + public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { if (messageObject == null) { return null; } @@ -3372,9 +3389,25 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa } @Override - public void willHidePhotoViewer() { - updateVisibleRows(); - } + public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { } + + @Override + public void willHidePhotoViewer() { } + + @Override + public boolean isPhotoChecked(int index) { return false; } + + @Override + public void setPhotoChecked(int index) { } + + @Override + public void cancelButtonPressed() { } + + @Override + public void sendButtonPressed(int index) { } + + @Override + public int getSelectedCount() { return 0; } private class ChatAdapter extends BaseAdapter { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java index 76e5d9bb5..767afa2a8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java @@ -144,7 +144,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("GroupInfo", R.string.GroupInfo)); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { @Override @@ -337,7 +337,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen } @Override - public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) { + public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { if (fileLocation == null) { return null; } @@ -368,9 +368,25 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen } @Override - public void willHidePhotoViewer() { + public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { } - } + @Override + public void willHidePhotoViewer() { } + + @Override + public boolean isPhotoChecked(int index) { return false; } + + @Override + public void setPhotoChecked(int index) { } + + @Override + public void cancelButtonPressed() { } + + @Override + public void sendButtonPressed(int index) { } + + @Override + public int getSelectedCount() { return 0; } public void didReceivedNotification(int id, Object... args) { if (id == MessagesController.updateInterfaces) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java index 3b778713c..7234524ab 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java @@ -115,7 +115,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); if (destroyAfterSelect) { actionBarLayer.setTitle(LocaleController.getString("SelectContact", R.string.SelectContact)); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java index 372326e42..ed7cd03d5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java @@ -118,7 +118,7 @@ public class CountrySelectActivity extends BaseFragment { @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java index 4c7c0edb2..508b98ba7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java @@ -126,7 +126,7 @@ public class DocumentSelectActivity extends BaseFragment { } if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile)); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java index 0dc953a84..183be989e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java @@ -123,7 +123,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup)); actionBarLayer.setSubtitle(String.format("%d/200 %s", selectedContacts.size(), LocaleController.getString("Members", R.string.Members))); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java index 2262bc953..3a4f6500d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java @@ -118,7 +118,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup)); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java index a8bfda4af..2222804cc 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); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey)); actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, Utilities.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 6475797ec..4bc7578ca 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java @@ -48,7 +48,7 @@ public class LanguageSelectActivity extends BaseFragment { @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("Language", R.string.Language)); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java index d246d92f3..3fcd31c35 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java @@ -80,7 +80,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); if (messageObject != null) { actionBarLayer.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation)); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index e779d8ab9..0bb5d68a3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -56,7 +56,7 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayUseLogoEnabled(true); + actionBarLayer.setDisplayUseLogoEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("AppName", R.string.AppName)); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java index 22323f834..bcd226a0e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java @@ -46,7 +46,6 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No private HashMap messagesDict = new HashMap(); private long dialog_id; private int totalCount = 0; - private int orientation = 0; private int itemWidth = 100; private boolean loading = false; private boolean endReached = false; @@ -87,7 +86,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("SharedMedia", R.string.SharedMedia)); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { @Override @@ -264,7 +263,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No } @Override - public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) { + public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { if (messageObject == null) { return null; } @@ -296,9 +295,25 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No } @Override - public void willHidePhotoViewer() { + public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { } - } + @Override + public void willHidePhotoViewer() { } + + @Override + public boolean isPhotoChecked(int index) { return false; } + + @Override + public void setPhotoChecked(int index) { } + + @Override + public void cancelButtonPressed() { } + + @Override + public void sendButtonPressed(int index) { } + + @Override + public int getSelectedCount() { return 0; } private void fixLayout() { if (listView != null) { @@ -310,12 +325,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No int rotation = manager.getDefaultDisplay().getRotation(); if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { - orientation = 1; listView.setNumColumns(6); itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 6 - Utilities.dp(2) * 5; listView.setColumnWidth(itemWidth); } else { - orientation = 0; listView.setNumColumns(4); itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 4 - Utilities.dp(2) * 3; listView.setColumnWidth(itemWidth); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java index cfe02edf0..a41925070 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java @@ -164,10 +164,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter } }); if (onlySelect) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat)); } else { - actionBarLayer.setDisplayUseLogoEnabled(true); + actionBarLayer.setDisplayUseLogoEnabled(true, R.drawable.ic_ab_logo); 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); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java new file mode 100644 index 000000000..3b06142e3 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java @@ -0,0 +1,573 @@ +/* + * This is the source code of Telegram for Android v. 1.4.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; + +import android.app.Activity; +import android.content.Context; +import android.os.Build; +import android.view.LayoutInflater; +import android.view.Surface; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.view.WindowManager; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.Button; +import android.widget.GridView; +import android.widget.ImageView; +import android.widget.TextView; + +import org.telegram.messenger.LocaleController; +import org.telegram.messenger.MediaController; +import org.telegram.messenger.MessagesController; +import org.telegram.messenger.NotificationCenter; +import org.telegram.messenger.R; +import org.telegram.messenger.TLRPC; +import org.telegram.messenger.Utilities; +import org.telegram.objects.MessageObject; +import org.telegram.ui.Views.ActionBar.ActionBarLayer; +import org.telegram.ui.Views.ActionBar.ActionBarMenu; +import org.telegram.ui.Views.ActionBar.BaseFragment; +import org.telegram.ui.Views.BackupImageView; + +import java.util.ArrayList; +import java.util.HashMap; + +public class PhotoPickerActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, PhotoViewer.PhotoViewerProvider { + + public static interface PhotoPickerActivityDelegate { + public abstract void didSelectPhotos(ArrayList photos); + public abstract void startPhotoSelectActivity(); + } + + private ArrayList albumsSorted = null; + private HashMap selectedPhotos = new HashMap(); + private Integer cameraAlbumId = null; + private boolean loading = false; + private MediaController.AlbumEntry selectedAlbum = null; + + private GridView listView; + private ListAdapter listAdapter; + private View progressView; + private TextView emptyView; + private View doneButton; + private TextView doneButtonTextView; + private TextView doneButtonBadgeTextView; + private int itemWidth = 100; + + private PhotoPickerActivityDelegate delegate; + + @Override + public boolean onFragmentCreate() { + loading = true; + MediaController.loadGalleryPhotosAlbums(classGuid); + NotificationCenter.getInstance().addObserver(this, MediaController.albumsDidLoaded); + NotificationCenter.getInstance().addObserver(this, MessagesController.closeChats); + return super.onFragmentCreate(); + } + + @Override + public void onFragmentDestroy() { + NotificationCenter.getInstance().removeObserver(this, MediaController.albumsDidLoaded); + NotificationCenter.getInstance().removeObserver(this, MessagesController.closeChats); + super.onFragmentDestroy(); + } + + @Override + public View createView(LayoutInflater inflater, ViewGroup container) { + 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.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); + actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { + @Override + public void onItemClick(int id) { + if (id == -1) { + if (selectedAlbum != null) { + selectedAlbum = null; + actionBarLayer.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); + fixLayoutInternal(); + } else { + if (Build.VERSION.SDK_INT < 11) { + listView.setAdapter(null); + listView = null; + listAdapter = null; + } + finishFragment(); + } + } else if (id == 1) { + if (delegate != null) { + finishFragment(); + delegate.startPhotoSelectActivity(); + } + } + } + }); + + ActionBarMenu menu = actionBarLayer.createMenu(); + menu.addItem(1, R.drawable.ic_ab_other_white2); + + fragmentView = inflater.inflate(R.layout.photo_picker_layout, container, false); + + emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView); + emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos)); + listView = (GridView)fragmentView.findViewById(R.id.media_grid); + progressView = fragmentView.findViewById(R.id.progressLayout); + + Button cancelButton = (Button)fragmentView.findViewById(R.id.cancel_button); + cancelButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finishFragment(); + } + }); + doneButton = fragmentView.findViewById(R.id.done_button); + doneButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + sendSelectedPhotos(); + } + }); + + cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase()); + doneButtonTextView = (TextView)doneButton.findViewById(R.id.done_button_text); + doneButtonTextView.setText(LocaleController.getString("Send", R.string.Send).toUpperCase()); + doneButtonBadgeTextView = (TextView)doneButton.findViewById(R.id.done_button_badge); + + listView.setAdapter(listAdapter = new ListAdapter(getParentActivity())); + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + if (selectedAlbum == null) { + if (i < 0 || i >= albumsSorted.size()) { + return; + } + selectedAlbum = albumsSorted.get(i); + actionBarLayer.setTitle(selectedAlbum.bucketName); + fixLayoutInternal(); + } else { + if (i < 0 || i >= selectedAlbum.photos.size()) { + return; + } + PhotoViewer.getInstance().openPhotoForSelect(selectedAlbum.photos, i, PhotoPickerActivity.this); + } + } + }); + if (loading && albumsSorted != null && albumsSorted.isEmpty()) { + progressView.setVisibility(View.VISIBLE); + listView.setEmptyView(null); + } else { + progressView.setVisibility(View.GONE); + listView.setEmptyView(emptyView); + } + updateSelectedCount(); + } else { + ViewGroup parent = (ViewGroup)fragmentView.getParent(); + if (parent != null) { + parent.removeView(fragmentView); + } + } + return fragmentView; + } + + @Override + public void onResume() { + super.onResume(); + if (listAdapter != null) { + listAdapter.notifyDataSetChanged(); + } + fixLayout(); + } + + @Override + public void onConfigurationChanged(android.content.res.Configuration newConfig) { + super.onConfigurationChanged(newConfig); + fixLayout(); + } + + @SuppressWarnings("unchecked") + @Override + public void didReceivedNotification(int id, Object... args) { + if (id == MediaController.albumsDidLoaded) { + int guid = (Integer)args[0]; + if (classGuid == guid) { + albumsSorted = (ArrayList)args[1]; + if (args[2] != null) { + cameraAlbumId = (Integer) args[2]; + } + if (progressView != null) { + progressView.setVisibility(View.GONE); + } + if (listView != null && listView.getEmptyView() == null) { + listView.setEmptyView(emptyView); + } + if (listAdapter != null) { + listAdapter.notifyDataSetChanged(); + } + } + } else if (id == MessagesController.closeChats) { + removeSelfFromStack(); + } + } + + @Override + public boolean onBackPressed() { + if (selectedAlbum != null) { + selectedAlbum = null; + actionBarLayer.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); + fixLayoutInternal(); + return false; + } + return super.onBackPressed(); + } + + @Override + public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { + if (selectedAlbum == null) { + return null; + } + int count = listView.getChildCount(); + + for (int a = 0; a < count; a++) { + View view = listView.getChildAt(a); + BackupImageView imageView = (BackupImageView)view.findViewById(R.id.media_photo_image); + if (imageView != null) { + int num = (Integer)imageView.getTag(); + if (num < 0 || num >= selectedAlbum.photos.size()) { + continue; + } + if (num == index) { + int coords[] = new int[2]; + imageView.getLocationInWindow(coords); + PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject(); + object.viewX = coords[0]; + object.viewY = coords[1] - Utilities.statusBarHeight; + object.parentView = listView; + object.imageReceiver = imageView.imageReceiver; + object.thumb = object.imageReceiver.getBitmap(); + View frameView = view.findViewById(R.id.photo_frame); + frameView.setVisibility(View.GONE); + ImageView checkImageView = (ImageView)view.findViewById(R.id.photo_check); + checkImageView.setVisibility(View.GONE); + return object; + } + } + } + return null; + } + + @Override + public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { + int count = listView.getChildCount(); + for (int a = 0; a < count; a++) { + View view = listView.getChildAt(a); + int num = (Integer)view.getTag(); + if (num < 0 || num >= selectedAlbum.photos.size()) { + continue; + } + if (num == index) { + View frameView = view.findViewById(R.id.photo_frame); + frameView.setVisibility(View.VISIBLE); + ImageView checkImageView = (ImageView)view.findViewById(R.id.photo_check); + checkImageView.setVisibility(View.VISIBLE); + break; + } + } + } + + @Override + public void willHidePhotoViewer() { + if (listAdapter != null) { + listAdapter.notifyDataSetChanged(); + } + } + + @Override + public boolean isPhotoChecked(int index) { + if (selectedAlbum == null || index < 0 || index >= selectedAlbum.photos.size()) { + return false; + } + MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index); + return selectedPhotos.containsKey(photoEntry.imageId); + } + + @Override + public void setPhotoChecked(int index) { + if (selectedAlbum == null || index < 0 || index >= selectedAlbum.photos.size()) { + return; + } + MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index); + if (selectedPhotos.containsKey(photoEntry.imageId)) { + selectedPhotos.remove(photoEntry.imageId); + } else { + selectedPhotos.put(photoEntry.imageId, photoEntry); + } + int count = listView.getChildCount(); + + for (int a = 0; a < count; a++) { + View view = listView.getChildAt(a); + int num = (Integer)view.getTag(); + if (num == index) { + updateSelectedPhoto(view, photoEntry); + break; + } + } + updateSelectedCount(); + } + + @Override + public void cancelButtonPressed() { + finishFragment(); + } + + @Override + public void sendButtonPressed(int index) { + if (selectedPhotos.isEmpty()) { + if (index < 0 || index >= selectedAlbum.photos.size()) { + return; + } + MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index); + selectedPhotos.put(photoEntry.imageId, photoEntry); + } + sendSelectedPhotos(); + } + + @Override + public int getSelectedCount() { + return selectedPhotos.size(); + } + + public void setDelegate(PhotoPickerActivityDelegate delegate) { + this.delegate = delegate; + } + + private void sendSelectedPhotos() { + if (selectedPhotos.isEmpty() || delegate == null) { + return; + } + ArrayList photos = new ArrayList(); + for (HashMap.Entry entry : selectedPhotos.entrySet()) { + MediaController.PhotoEntry photoEntry = entry.getValue(); + if (photoEntry.path != null) { + photos.add(photoEntry.path); + } + } + delegate.didSelectPhotos(photos); + finishFragment(); + } + + private void fixLayout() { + if (listView != null) { + ViewTreeObserver obs = listView.getViewTreeObserver(); + obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + fixLayoutInternal(); + if (listView != null) { + listView.getViewTreeObserver().removeOnPreDrawListener(this); + } + return false; + } + }); + } + } + + private void fixLayoutInternal() { + if (getParentActivity() == null) { + return; + } + WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); + int rotation = manager.getDefaultDisplay().getRotation(); + + int columnsCount = 2; + if (selectedAlbum != null) { + if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { + columnsCount = 5; + } else { + columnsCount = 3; + } + } else { + if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { + columnsCount = 4; + } + } + listView.setNumColumns(columnsCount); + itemWidth = (getParentActivity().getResources().getDisplayMetrics().widthPixels - ((columnsCount + 1) * Utilities.dp(4))) / columnsCount; + listView.setColumnWidth(itemWidth); + + listAdapter.notifyDataSetChanged(); + } + + private void updateSelectedCount() { + if (selectedPhotos.isEmpty()) { + doneButtonTextView.setTextColor(0xff999999); + doneButtonTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.selectphoto_small_grey, 0, 0, 0); + doneButtonBadgeTextView.setVisibility(View.GONE); + doneButton.setEnabled(false); + } else { + doneButtonTextView.setTextColor(0xffffffff); + doneButtonTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + doneButtonBadgeTextView.setVisibility(View.VISIBLE); + doneButtonBadgeTextView.setText("" + selectedPhotos.size()); + doneButton.setEnabled(true); + } + } + + private void updateSelectedPhoto(View view, MediaController.PhotoEntry photoEntry) { + View frameView = view.findViewById(R.id.photo_frame); + ImageView checkImageView = (ImageView)view.findViewById(R.id.photo_check); + if (selectedPhotos.containsKey(photoEntry.imageId)) { + frameView.setBackgroundResource(R.drawable.photoborder); + checkImageView.setImageResource(R.drawable.selectphoto_small_active); + checkImageView.setBackgroundColor(0xff42d1f6); + } else { + frameView.setBackgroundDrawable(null); + checkImageView.setImageResource(R.drawable.selectphoto_small); + checkImageView.setBackgroundColor(0x501c1c1c); + } + } + + private class ListAdapter extends BaseAdapter { + private Context mContext; + + public ListAdapter(Context context) { + mContext = context; + } + + @Override + public boolean areAllItemsEnabled() { + return true; + } + + @Override + public boolean isEnabled(int i) { + return true; + } + + @Override + public int getCount() { + if (selectedAlbum != null) { + return selectedAlbum.photos.size(); + } + return albumsSorted != null ? albumsSorted.size() : 0; + } + + @Override + public Object getItem(int i) { + return null; + } + + @Override + public long getItemId(int i) { + return i; + } + + @Override + public boolean hasStableIds() { + return true; + } + + @Override + public View getView(int i, View view, ViewGroup viewGroup) { + int type = getItemViewType(i); + if (type == 0) { + if (view == null) { + LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + view = li.inflate(R.layout.photo_picker_album_layout, viewGroup, false); + } + ViewGroup.LayoutParams params = view.getLayoutParams(); + params.width = itemWidth; + params.height = itemWidth; + view.setLayoutParams(params); + + 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(albumEntry.coverPhoto.path, "150_150", R.drawable.nophotos); + } else { + imageView.setImageResource(R.drawable.nophotos); + } + TextView textView = (TextView)view.findViewById(R.id.album_name); + textView.setText(albumEntry.bucketName); + if (cameraAlbumId != null && albumEntry.bucketId == cameraAlbumId) { + + } else { + + } + textView = (TextView)view.findViewById(R.id.album_count); + textView.setText("" + albumEntry.photos.size()); + } else if (type == 1) { + if (view == null) { + LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + view = li.inflate(R.layout.photo_picker_photo_layout, viewGroup, false); + ImageView checkImageView = (ImageView)view.findViewById(R.id.photo_check); + checkImageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get((Integer)((View)v.getParent()).getTag()); + if (selectedPhotos.containsKey(photoEntry.imageId)) { + selectedPhotos.remove(photoEntry.imageId); + } else { + selectedPhotos.put(photoEntry.imageId, photoEntry); + } + updateSelectedPhoto((View)v.getParent(), photoEntry); + updateSelectedCount(); + } + }); + } + ViewGroup.LayoutParams params = view.getLayoutParams(); + params.width = itemWidth; + params.height = itemWidth; + view.setLayoutParams(params); + + MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(i); + BackupImageView imageView = (BackupImageView)view.findViewById(R.id.media_photo_image); + imageView.setTag(i); + view.setTag(i); + if (photoEntry.path != null) { + imageView.setImage(photoEntry.path, "100_100", R.drawable.nophotos); + } else { + imageView.setImageResource(R.drawable.nophotos); + } + updateSelectedPhoto(view, photoEntry); + boolean showing = PhotoViewer.getInstance().isShowingImage(photoEntry.path); + imageView.imageReceiver.setVisible(!showing, false); + View frameView = view.findViewById(R.id.photo_frame); + frameView.setVisibility(showing ? View.GONE : View.VISIBLE); + ImageView checkImageView = (ImageView)view.findViewById(R.id.photo_check); + checkImageView.setVisibility(showing ? View.GONE : View.VISIBLE); + } + return view; + } + + @Override + public int getItemViewType(int i) { + if (selectedAlbum != null) { + return 1; + } + return 0; + } + + @Override + public int getViewTypeCount() { + return 2; + } + + @Override + public boolean isEmpty() { + if (selectedAlbum != null) { + return selectedAlbum.photos.isEmpty(); + } + return albumsSorted == null || albumsSorted.isEmpty(); + } + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 8e7646c8f..493cacd99 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -12,6 +12,7 @@ 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; import android.content.Intent; @@ -26,6 +27,7 @@ import android.text.TextUtils; import android.view.GestureDetector; import android.view.Gravity; import android.view.MotionEvent; +import android.view.Surface; import android.view.VelocityTracker; import android.view.View; import android.view.ViewGroup; @@ -33,6 +35,7 @@ import android.view.ViewTreeObserver; import android.view.WindowManager; import android.view.animation.AlphaAnimation; import android.view.animation.DecelerateInterpolator; +import android.widget.Button; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ProgressBar; @@ -64,6 +67,7 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.Locale; public class PhotoViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener { private int classGuid; @@ -86,6 +90,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private ActionBarMenuItem menuItem; private ColorDrawable backgroundDrawable = new ColorDrawable(0xff000000); private OverlayView currentOverlay; + private ImageView checkImageView; + private View pickerView; + private TextView doneButtonTextView; + private TextView doneButtonBadgeTextView; private boolean canShowBottom = true; private boolean overlayViewVisible = true; @@ -100,6 +108,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private TLRPC.FileLocation currentFileLocation; private String currentFileName; private PlaceProviderObject currentPlaceObject; + private String currentPathObject; private Bitmap currentThumb = null; private int avatarsUserId; @@ -152,6 +161,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private HashMap imagesByIds = new HashMap(); private ArrayList imagesArrLocations = new ArrayList(); private ArrayList imagesArrLocationsSizes = new ArrayList(); + private ArrayList imagesArrLocals = new ArrayList(); private final static int gallery_menu_save = 1; private final static int gallery_menu_showall = 2; @@ -199,8 +209,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } public static interface PhotoViewerProvider { - public PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation); + public PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index); + public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index); public void willHidePhotoViewer(); + public boolean isPhotoChecked(int index); + public void setPhotoChecked(int index); + public void cancelButtonPressed(); + public void sendButtonPressed(int index); + public int getSelectedCount(); } private static class FrameLayoutTouchListener extends FrameLayout { @@ -406,13 +422,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat actionBar = new ActionBar(activity); containerView.addView(actionBar); actionBar.setBackgroundColor(0xdd000000); - actionBar.setItemsBackground(R.drawable.bar_selector_white); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)actionBar.getLayoutParams(); layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; actionBar.setLayoutParams(layoutParams); actionBarLayer = actionBar.createLayer(); - actionBarLayer.setDisplayHomeAsUpEnabled(true); - actionBarLayer.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); + actionBarLayer.setItemsBackground(R.drawable.bar_selector_white); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.photo_back); + actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1)); actionBar.setCurrentActionBarLayer(actionBarLayer); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { @@ -593,6 +609,34 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat layoutParams.topMargin = Utilities.dp(26); dateTextView.setLayoutParams(layoutParams); + pickerView = parentActivity.getLayoutInflater().inflate(R.layout.photo_picker_bottom_layout, null); + bottomLayout.addView(pickerView); + Button cancelButton = (Button)pickerView.findViewById(R.id.cancel_button); + cancelButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (placeProvider != null) { + placeProvider.cancelButtonPressed(); + closePhoto(false); + } + } + }); + View doneButton = pickerView.findViewById(R.id.done_button); + doneButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (placeProvider != null) { + placeProvider.sendButtonPressed(currentIndex); + closePhoto(false); + } + } + }); + + cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase()); + doneButtonTextView = (TextView)doneButton.findViewById(R.id.done_button_text); + doneButtonTextView.setText(LocaleController.getString("Send", R.string.Send).toUpperCase()); + doneButtonBadgeTextView = (TextView)doneButton.findViewById(R.id.done_button_badge); + progressBar = new ProgressBar(containerView.getContext(), null, android.R.attr.progressBarStyleHorizontal); progressBar.setVisibility(View.GONE); progressBar.setMax(100); @@ -617,6 +661,39 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat currentOverlay = new OverlayView(containerView.getContext()); containerView.addView(currentOverlay); currentOverlay.setVisibility(View.GONE); + + checkImageView = new ImageView(containerView.getContext()); + containerView.addView(checkImageView); + checkImageView.setVisibility(View.GONE); + checkImageView.setScaleType(ImageView.ScaleType.CENTER); + checkImageView.setImageResource(R.drawable.selectphoto_large); + layoutParams = (FrameLayout.LayoutParams)checkImageView.getLayoutParams(); + layoutParams.width = Utilities.dp(46); + layoutParams.height = Utilities.dp(46); + layoutParams.gravity = Gravity.RIGHT; + layoutParams.rightMargin = Utilities.dp(10); + WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); + int rotation = manager.getDefaultDisplay().getRotation(); + if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { + layoutParams.topMargin = Utilities.dp(48); + } else { + layoutParams.topMargin = Utilities.dp(58); + } + checkImageView.setLayoutParams(layoutParams); + checkImageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (placeProvider != null) { + placeProvider.setPhotoChecked(currentIndex); + if (placeProvider.isPhotoChecked(currentIndex)) { + checkImageView.setBackgroundColor(0xff42d1f6); + } else { + checkImageView.setBackgroundColor(0x801c1c1c); + } + updateSelectedCount(); + } + } + }); } private void toggleOverlayView(boolean show) { @@ -828,8 +905,25 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat return null; } + private void updateSelectedCount() { + if (placeProvider == null) { + return; + } + int count = placeProvider.getSelectedCount(); + if (count == 0) { + doneButtonTextView.setTextColor(0xffffffff); + doneButtonTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.selectphoto_small, 0, 0, 0); + doneButtonBadgeTextView.setVisibility(View.GONE); + } else { + doneButtonTextView.setTextColor(0xffffffff); + doneButtonTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + doneButtonBadgeTextView.setVisibility(View.VISIBLE); + doneButtonBadgeTextView.setText("" + count); + } + } + private void updateActionOverlays() { - if (currentMessageObject == null) { + if (currentMessageObject == null || currentFileName == null) { currentOverlay.setVisibility(View.GONE); return; } @@ -868,10 +962,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } } - private void onPhotoShow(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList messages, int index, final PlaceProviderObject object) { + private void onPhotoShow(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList messages, final ArrayList photos, int index, final PlaceProviderObject object) { classGuid = ConnectionsManager.getInstance().generateClassGuid(); currentMessageObject = null; currentFileLocation = null; + currentPathObject = null; currentIndex = -1; currentFileName = null; avatarsUserId = 0; @@ -882,13 +977,19 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat loadingMoreImages = false; cacheEndReached = false; opennedFromMedia = false; + canShowBottom = true; imagesArr.clear(); imagesArrLocations.clear(); imagesArrLocationsSizes.clear(); + imagesArrLocals.clear(); imagesByIds.clear(); imagesArrTemp.clear(); imagesByIdsTemp.clear(); currentThumb = object.thumb; + menuItem.setVisibility(View.VISIBLE); + bottomLayout.setVisibility(View.VISIBLE); + checkImageView.setVisibility(View.GONE); + pickerView.setVisibility(View.GONE); if (messageObject != null && messages == null) { imagesArr.add(messageObject); @@ -912,17 +1013,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } else { menuItem.hideSubItem(gallery_menu_showall); } - bottomLayout.setVisibility(View.VISIBLE); - canShowBottom = true; setImageIndex(0, true); } else if (fileLocation != null) { avatarsUserId = object.user_id; imagesArrLocations.add(fileLocation); imagesArrLocationsSizes.add(object.size); bottomLayout.setVisibility(View.GONE); + canShowBottom = false; menuItem.hideSubItem(gallery_menu_showall); setImageIndex(0, true); - canShowBottom = false; } else if (messages != null) { imagesArr.addAll(messages); Collections.reverse(imagesArr); @@ -950,6 +1049,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } opennedFromMedia = true; setImageIndex(index, true); + } else if (photos != null) { + checkImageView.setVisibility(View.VISIBLE); + menuItem.setVisibility(View.GONE); + imagesArrLocals.addAll(photos); + setImageIndex(index, true); + pickerView.setVisibility(View.VISIBLE); + updateSelectedCount(); } if (currentDialogId != 0 && totalImagesCount == 0) { @@ -966,6 +1072,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (!init) { currentThumb = null; } + placeProvider.willSwitchFromPhoto(currentMessageObject, currentFileLocation, currentIndex); int prevIndex = currentIndex; currentIndex = index; currentFileName = getFileName(index, null); @@ -991,8 +1098,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat updateActionOverlays(); } else if (!imagesArrLocations.isEmpty()) { currentFileLocation = imagesArrLocations.get(index); - if (imagesArrLocations.size() > 1) { - actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, currentIndex + 1, imagesArrLocations.size())); + actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, currentIndex + 1, imagesArrLocations.size())); + } else if (!imagesArrLocals.isEmpty()) { + currentPathObject = imagesArrLocals.get(index).path; + actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, currentIndex + 1, imagesArrLocals.size())); + + if (placeProvider.isPhotoChecked(currentIndex)) { + checkImageView.setBackgroundColor(0xff42d1f6); + } else { + checkImageView.setBackgroundColor(0x801c1c1c); } } @@ -1001,7 +1115,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat currentPlaceObject.imageReceiver.setVisible(true, true); } } - currentPlaceObject = placeProvider.getPlaceForPhoto(currentMessageObject, currentFileLocation); + currentPlaceObject = placeProvider.getPlaceForPhoto(currentMessageObject, currentFileLocation, currentIndex); if (!init) { if (currentPlaceObject != null) { currentPlaceObject.imageReceiver.setVisible(false, true); @@ -1033,7 +1147,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat canDragDown = true; changingPage = false; switchImageAfterAnimation = 0; - canZoom = !currentFileName.endsWith("mp4"); + canZoom = currentFileName == null || !currentFileName.endsWith("mp4"); updateMinMax(scale); if (prevIndex == -1) { @@ -1080,45 +1194,60 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } else { progressBar.setVisibility(View.GONE); } + updateActionOverlays(); } private void setIndexToImage(ImageReceiver imageReceiver, int index) { - int size[] = new int[1]; - TLRPC.FileLocation fileLocation = getFileLocation(index, size); - - if (fileLocation != null) { - MessageObject messageObject = null; - if (!imagesArr.isEmpty()) { - messageObject = imagesArr.get(index); + if (!imagesArrLocals.isEmpty()) { + if (index >= 0 && index < imagesArrLocals.size()) { + MediaController.PhotoEntry photoEntry = imagesArrLocals.get(index); + Bitmap placeHolder = null; + if (currentThumb != null && imageReceiver == centerImage) { + placeHolder = currentThumb; + } + int size = (int)(800 / Utilities.density); + imageReceiver.setImage(photoEntry.path, String.format(Locale.US, "%d_%d", size, size), placeHolder != null ? new BitmapDrawable(null, placeHolder) : null); + } else { + imageReceiver.setImageBitmap((Bitmap) null); } + } else { + int size[] = new int[1]; + TLRPC.FileLocation fileLocation = getFileLocation(index, size); - if (messageObject != null && messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVideo) { - if (messageObject.imagePreview != null) { - imageReceiver.setImageBitmap(messageObject.imagePreview); - } else if (messageObject.messageOwner.media.video.thumb != null) { + if (fileLocation != null) { + MessageObject messageObject = null; + if (!imagesArr.isEmpty()) { + messageObject = imagesArr.get(index); + } + + if (messageObject != null && messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVideo) { + if (messageObject.imagePreview != null) { + imageReceiver.setImageBitmap(messageObject.imagePreview); + } else if (messageObject.messageOwner.media.video.thumb != null) { + Bitmap placeHolder = null; + if (currentThumb != null && imageReceiver == centerImage) { + placeHolder = currentThumb; + } + imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, size[0]); + } else { + imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder)); + } + } else { Bitmap placeHolder = null; + if (messageObject != null) { + placeHolder = messageObject.imagePreview; + } if (currentThumb != null && imageReceiver == centerImage) { placeHolder = currentThumb; } imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, size[0]); + } + } else { + if (size[0] == 0) { + imageReceiver.setImageBitmap((Bitmap) null); } else { imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder)); } - } else { - Bitmap placeHolder = null; - if (messageObject != null) { - placeHolder = messageObject.imagePreview; - } - if (currentThumb != null && imageReceiver == centerImage) { - placeHolder = currentThumb; - } - imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, size[0]); - } - } else { - if (size[0] == 0) { - imageReceiver.setImageBitmap((Bitmap) null); - } else { - imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder)); } } } @@ -1131,28 +1260,36 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat return !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 !disableShowCheck && object != null && currentPathObject != null && object.equals(currentPathObject); + } + public void openPhoto(final MessageObject messageObject, final PhotoViewerProvider provider) { - openPhoto(messageObject, null, null, 0, provider); + openPhoto(messageObject, null, null, null, 0, provider); } public void openPhoto(final TLRPC.FileLocation fileLocation, final PhotoViewerProvider provider) { - openPhoto(null, fileLocation, null, 0, provider); + openPhoto(null, fileLocation, null, null, 0, provider); } public void openPhoto(final ArrayList messages, final int index, final PhotoViewerProvider provider) { - openPhoto(messages.get(index), null, messages, index, provider); + openPhoto(messages.get(index), null, messages, null, index, provider); } - public void openPhoto(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList messages, final int index, final PhotoViewerProvider provider) { - if (parentActivity == null || isVisible || provider == null || animationInProgress || messageObject == null && fileLocation == null && messages == null) { + public void openPhotoForSelect(final ArrayList photos, final int index, final PhotoViewerProvider provider) { + openPhoto(null, null, null, photos, index, provider); + } + + public void openPhoto(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList messages, final ArrayList photos, final int index, final PhotoViewerProvider provider) { + if (parentActivity == null || isVisible || provider == null || animationInProgress || messageObject == null && fileLocation == null && messages == null && photos == null) { return; } - final PlaceProviderObject object = provider.getPlaceForPhoto(messageObject, fileLocation); + final PlaceProviderObject object = provider.getPlaceForPhoto(messageObject, fileLocation, index); if (object == null) { return; } - actionBarLayer.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); + actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1)); NotificationCenter.getInstance().addObserver(this, FileLoader.FileDidFailedLoad); NotificationCenter.getInstance().addObserver(this, FileLoader.FileDidLoaded); NotificationCenter.getInstance().addObserver(this, FileLoader.FileLoadProgressChanged); @@ -1169,7 +1306,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } disableShowCheck = true; - onPhotoShow(messageObject, fileLocation, messages, index, object); + onPhotoShow(messageObject, fileLocation, messages, photos, index, object); isVisible = true; backgroundDrawable.setAlpha(255); toggleActionBar(true, false); @@ -1208,6 +1345,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat float xPos = (Utilities.displaySize.x - width) / 2.0f; float yPos = (Utilities.displaySize.y - Utilities.statusBarHeight - height) / 2.0f; int clipHorizontal = Math.abs(object.imageReceiver.drawRegion.left - object.imageReceiver.imageX); + int clipVertical = Math.abs(object.imageReceiver.drawRegion.top - object.imageReceiver.imageY); int coords2[] = new int[2]; object.parentView.getLocationInWindow(coords2); @@ -1219,6 +1357,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (clipBottom < 0) { clipBottom = 0; } + clipTop = Math.max(clipTop, clipVertical); + clipBottom = Math.max(clipBottom, clipVertical); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( @@ -1233,7 +1373,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ObjectAnimator.ofFloat(actionBar, "alpha", 0.0f, 1.0f), ObjectAnimator.ofFloat(bottomLayout, "alpha", 0.0f, 1.0f), ObjectAnimator.ofFloat(progressBar, "alpha", 0.0f, 1.0f), - ObjectAnimator.ofFloat(currentOverlay, "alpha", 0.0f, 1.0f) + ObjectAnimator.ofFloat(currentOverlay, "alpha", 0.0f, 1.0f), + ObjectAnimator.ofFloat(checkImageView, "alpha", 0.0f, 1.0f) ); animatorSet.setDuration(250); @@ -1284,7 +1425,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat velocityTracker = null; } - final PlaceProviderObject object = placeProvider.getPlaceForPhoto(currentMessageObject, currentFileLocation); + final PlaceProviderObject object = placeProvider.getPlaceForPhoto(currentMessageObject, currentFileLocation, currentIndex); if(android.os.Build.VERSION.SDK_INT >= 11 && animated) { Utilities.lockOrientation(parentActivity); @@ -1321,6 +1462,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (object != null) { object.imageReceiver.setVisible(false, true); int clipHorizontal = Math.abs(object.imageReceiver.drawRegion.left - object.imageReceiver.imageX); + int clipVertical = Math.abs(object.imageReceiver.drawRegion.top - object.imageReceiver.imageY); int coords2[] = new int[2]; object.parentView.getLocationInWindow(coords2); @@ -1333,6 +1475,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat clipBottom = 0; } + clipTop = Math.max(clipTop, clipVertical); + clipBottom = Math.max(clipBottom, clipVertical); + animatorSet.playTogether( ObjectAnimator.ofFloat(animatingImageView, "scaleX", 1), ObjectAnimator.ofFloat(animatingImageView, "scaleY", 1), @@ -1345,7 +1490,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ObjectAnimator.ofFloat(actionBar, "alpha", 0.0f), ObjectAnimator.ofFloat(bottomLayout, "alpha", 0.0f), ObjectAnimator.ofFloat(progressBar, "alpha", 0.0f), - ObjectAnimator.ofFloat(currentOverlay, "alpha", 0.0f) + ObjectAnimator.ofFloat(currentOverlay, "alpha", 0.0f), + ObjectAnimator.ofFloat(checkImageView, "alpha", 0.0f) ); } else { animatorSet.playTogether( @@ -1355,7 +1501,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ObjectAnimator.ofFloat(bottomLayout, "alpha", 0.0f), ObjectAnimator.ofFloat(progressBar, "alpha", 0.0f), ObjectAnimator.ofFloat(animatingImageView, "translationY", translationY >= 0 ? Utilities.displaySize.y : -Utilities.displaySize.y), - ObjectAnimator.ofFloat(currentOverlay, "alpha", 0.0f) + ObjectAnimator.ofFloat(currentOverlay, "alpha", 0.0f), + ObjectAnimator.ofFloat(checkImageView, "alpha", 0.0f) ); } @@ -1378,6 +1525,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat disableShowCheck = true; currentMessageObject = null; currentFileLocation = null; + currentPathObject = null; currentThumb = null; centerImage.setImageBitmap((Bitmap)null); leftImage.setImageBitmap((Bitmap) null); @@ -1777,17 +1925,37 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat canvas.restore(); } + @SuppressLint("DrawAllocation") private void onLayout(boolean changed, int left, int top, int right, int bottom) { if(changed) { scale = 1; translationX = 0; translationY = 0; updateMinMax(scale); + + if (checkImageView != null) { + checkImageView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + checkImageView.getViewTreeObserver().removeOnPreDrawListener(this); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)checkImageView.getLayoutParams(); + WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); + int rotation = manager.getDefaultDisplay().getRotation(); + if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { + layoutParams.topMargin = Utilities.dp(48); + } else { + layoutParams.topMargin = Utilities.dp(58); + } + checkImageView.setLayoutParams(layoutParams); + return false; + } + }); + } } } private void onActionClick(View view) { - if (currentMessageObject == null) { + if (currentMessageObject == null || currentFileName == null) { return; } boolean loadFile = false; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java index 65959ac6d..185b896e0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java @@ -220,7 +220,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("Settings", R.string.Settings)); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { @Override @@ -413,7 +413,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } @Override - public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) { + public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { if (fileLocation == null) { return null; } @@ -445,9 +445,25 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } @Override - public void willHidePhotoViewer() { + public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { } - } + @Override + public void willHidePhotoViewer() { } + + @Override + public boolean isPhotoChecked(int index) { return false; } + + @Override + public void setPhotoChecked(int index) { } + + @Override + public void cancelButtonPressed() { } + + @Override + public void sendButtonPressed(int index) { } + + @Override + public int getSelectedCount() { return 0; } public void performAskAQuestion() { final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsBlockedUsers.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsBlockedUsers.java index ced697f97..88912f31f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsBlockedUsers.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsBlockedUsers.java @@ -67,7 +67,7 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers)); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java index 4acc174e6..8b3165c57 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java @@ -97,7 +97,7 @@ public class SettingsNotificationsActivity extends BaseFragment { @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds)); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java index 597f3e487..33322a47f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java @@ -134,7 +134,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen @Override public View createView(LayoutInflater inflater, ViewGroup container) { if (fragmentView == null) { - actionBarLayer.setDisplayHomeAsUpEnabled(true); + actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); if (dialog_id != 0) { actionBarLayer.setTitle(LocaleController.getString("SecretTitle", R.string.SecretTitle)); actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, Utilities.dp(4)); @@ -454,7 +454,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen } @Override - public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) { + public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { if (fileLocation == null) { return null; } @@ -486,9 +486,25 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen } @Override - public void willHidePhotoViewer() { + public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { } - } + @Override + public void willHidePhotoViewer() { } + + @Override + public boolean isPhotoChecked(int index) { return false; } + + @Override + public void setPhotoChecked(int index) { } + + @Override + public void cancelButtonPressed() { } + + @Override + public void sendButtonPressed(int index) { } + + @Override + public int getSelectedCount() { return 0; } private void createActionBarMenu() { ActionBarMenu menu = actionBarLayer.createMenu(); 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 13dc763ce..9be684dae 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 @@ -32,7 +32,6 @@ public class ActionBar extends FrameLayout { private View currentBackOverlay; private View shadowView = null; private int currentBackOverlayWidth; - protected int itemsBackgroundResourceId; public ActionBar(Context context) { super(context); @@ -206,8 +205,4 @@ public class ActionBar extends FrameLayout { currentLayer.onMenuButtonPressed(); } } - - public void setItemsBackground(int resourceId) { - itemsBackgroundResourceId = resourceId; - } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarActivity.java index 7ba3eccf6..183903aba 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarActivity.java @@ -56,6 +56,7 @@ public class ActionBarActivity extends Activity { private long transitionAnimationStartTime; private boolean inActionMode = false; private int startedTrackingPointerId; + private Animation.AnimationListener listener; private class FrameLayoutTouch extends FrameLayout { public FrameLayoutTouch(Context context) { @@ -126,7 +127,6 @@ public class ActionBarActivity extends Activity { shadowView.setVisibility(View.INVISIBLE); actionBar = new ActionBar(this); - actionBar.setItemsBackground(R.drawable.bar_selector); contentView.addView(actionBar); layoutParams = actionBar.getLayoutParams(); layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; @@ -153,6 +153,11 @@ public class ActionBarActivity extends Activity { protected void onResume() { super.onResume(); fixLayout(); + if (transitionAnimationInProgress && listener != null) { + openAnimation.cancel(); + closeAnimation.cancel(); + listener.onAnimationEnd(null); + } if (!fragmentsStack.isEmpty()) { BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1); lastFragment.onResume(); @@ -493,7 +498,7 @@ public class ActionBarActivity extends Activity { transitionAnimationStartTime = System.currentTimeMillis(); transitionAnimationInProgress = true; openAnimation.reset(); - openAnimation.setAnimationListener(new Animation.AnimationListener() { + openAnimation.setAnimationListener(listener = new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { @@ -501,10 +506,12 @@ public class ActionBarActivity extends Activity { @Override public void onAnimationEnd(Animation animation) { - transitionAnimationInProgress = false; - transitionAnimationStartTime = 0; - fragment.onOpenAnimationEnd(); - presentFragmentInternalRemoveOld(removeLast, currentFragment); + if (transitionAnimationInProgress) { + transitionAnimationInProgress = false; + transitionAnimationStartTime = 0; + fragment.onOpenAnimationEnd(); + presentFragmentInternalRemoveOld(removeLast, currentFragment); + } } @Override @@ -566,7 +573,7 @@ public class ActionBarActivity extends Activity { transitionAnimationStartTime = System.currentTimeMillis(); transitionAnimationInProgress = true; closeAnimation.reset(); - closeAnimation.setAnimationListener(new Animation.AnimationListener() { + closeAnimation.setAnimationListener(listener = new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { @@ -574,9 +581,11 @@ public class ActionBarActivity extends Activity { @Override public void onAnimationEnd(Animation animation) { - transitionAnimationInProgress = false; - transitionAnimationStartTime = 0; - closeLastFragmentInternalRemoveOld(currentFragment); + if (transitionAnimationInProgress) { + transitionAnimationInProgress = false; + transitionAnimationStartTime = 0; + closeLastFragmentInternalRemoveOld(currentFragment); + } } @Override 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 7f22c6c7b..4ccde6a1e 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 @@ -43,11 +43,14 @@ public class ActionBarLayer extends FrameLayout { 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 boolean isBackLayoutHidden = false; protected boolean isSearchFieldVisible; + protected int itemsBackgroundResourceId; public ActionBarMenuOnItemClick actionBarMenuOnItemClick; public ActionBarLayer(Context context, ActionBar actionBar) { @@ -60,7 +63,6 @@ public class ActionBarLayer extends FrameLayout { layoutParams.height = LayoutParams.FILL_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; backButtonFrameLayout.setLayoutParams(layoutParams); - backButtonFrameLayout.setBackgroundResource(actionBar.itemsBackgroundResourceId); backButtonFrameLayout.setPadding(0, 0, Utilities.dp(4), 0); backButtonFrameLayout.setOnClickListener(new OnClickListener() { @Override @@ -207,28 +209,31 @@ public class ActionBarLayer extends FrameLayout { menu.measure(width, height); } - public void setDisplayUseLogoEnabled(boolean value) { + public void setDisplayUseLogoEnabled(boolean value, int resource) { if (value && logoImageView == null) { + logoResourceId = resource; logoImageView = new ImageView(getContext()); logoImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); - logoImageView.setImageResource(R.drawable.ic_ab_logo); backButtonFrameLayout.addView(logoImageView); - positionLogoImage(getMeasuredHeight()); - } else if (logoImageView != null) { + } + if (logoImageView != null) { logoImageView.setVisibility(value ? VISIBLE : GONE); + logoImageView.setImageResource(resource); + positionLogoImage(getMeasuredHeight()); } } - public void setDisplayHomeAsUpEnabled(boolean value) { + public void setDisplayHomeAsUpEnabled(boolean value, int resource) { if (value && backButtonImageView == null) { + backResourceId = resource; backButtonImageView = new ImageView(getContext()); - backButtonImageView.setImageResource(R.drawable.ic_ab_back); backButtonFrameLayout.addView(backButtonImageView); - positionBackImage(getMeasuredHeight()); } if (backButtonImageView != null) { backButtonImageView.setVisibility(value ? VISIBLE : GONE); backButtonFrameLayout.setEnabled(value); + backButtonImageView.setImageResource(resource); + positionBackImage(getMeasuredHeight()); } } @@ -404,22 +409,21 @@ public class ActionBarLayer extends FrameLayout { backButtonFrameLayout.setPadding(0, 0, visible ? 0 : Utilities.dp(4), 0); if (visible) { oldUseLogo = logoImageView != null && logoImageView.getVisibility() == VISIBLE; - setDisplayUseLogoEnabled(true); + setDisplayUseLogoEnabled(true, R.drawable.ic_ab_search); } else { - setDisplayUseLogoEnabled(oldUseLogo); + setDisplayUseLogoEnabled(oldUseLogo, logoResourceId); } if (visible) { oldUseBack = backButtonImageView != null && backButtonImageView.getVisibility() == VISIBLE; - setDisplayHomeAsUpEnabled(true); + setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); } else { - setDisplayHomeAsUpEnabled(oldUseBack); + setDisplayHomeAsUpEnabled(oldUseBack, backResourceId); } if (visible) { backButtonFrameLayout.setVisibility(VISIBLE); } else { backButtonFrameLayout.setVisibility(isBackLayoutHidden ? INVISIBLE : VISIBLE); } - logoImageView.setImageResource(visible ? R.drawable.ic_ab_search : R.drawable.ic_ab_logo); } public void closeSearchField() { @@ -459,4 +463,9 @@ public class ActionBarLayer extends FrameLayout { menu.hideAllPopupMenus(); } } + + public void setItemsBackground(int resourceId) { + itemsBackgroundResourceId = resourceId; + backButtonFrameLayout.setBackgroundResource(itemsBackgroundResourceId); + } } \ No newline at end of file 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 87abb9c2d..823eb704b 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 @@ -49,7 +49,7 @@ public class ActionBarMenu extends LinearLayout { addView(view); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)view.getLayoutParams(); layoutParams.height = FrameLayout.LayoutParams.FILL_PARENT; - view.setBackgroundResource(parentActionBar.itemsBackgroundResourceId); + view.setBackgroundResource(parentActionBarLayer.itemsBackgroundResourceId); view.setLayoutParams(layoutParams); view.setOnClickListener(new OnClickListener() { @Override @@ -61,7 +61,7 @@ public class ActionBarMenu extends LinearLayout { } public ActionBarMenuItem addItem(int id, int icon) { - ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, parentActionBar); + ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, parentActionBar, parentActionBarLayer.itemsBackgroundResourceId); menuItem.setTag(id); menuItem.setScaleType(ImageView.ScaleType.CENTER); menuItem.setImageResource(icon); 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 5d244836a..90b4e8051 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 @@ -46,9 +46,9 @@ public class ActionBarMenuItem extends ImageView { private boolean isSearchField = false; private ActionBarMenuItemSearchListener listener; - public ActionBarMenuItem(Context context, ActionBarMenu menu, ActionBar actionBar) { + public ActionBarMenuItem(Context context, ActionBarMenu menu, ActionBar actionBar, int background) { super(context); - setBackgroundResource(actionBar.itemsBackgroundResourceId); + setBackgroundResource(background); parentMenu = menu; parentActionBar = actionBar; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/BaseFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/BaseFragment.java index 456e5dba6..a30354e39 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/BaseFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/BaseFragment.java @@ -62,6 +62,7 @@ public class BaseFragment { } actionBarLayer = parentActivity.getInternalActionBar().createLayer(); actionBarLayer.setBackgroundResource(R.color.header); + actionBarLayer.setItemsBackground(R.drawable.bar_selector); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ImageReceiver.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ImageReceiver.java index 625466633..1cc3f8218 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ImageReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ImageReceiver.java @@ -259,6 +259,6 @@ public class ImageReceiver { } public boolean hasImage() { - return currentImage != null || last_placeholder != null || currentPath != null; + return currentImage != null || last_placeholder != null || currentPath != null || last_httpUrl != null; } } diff --git a/TMessagesProj/src/main/res/drawable-hdpi/gallery.png b/TMessagesProj/src/main/res/drawable-hdpi/gallery.png new file mode 100755 index 000000000..6bd0cda83 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/gallery.png 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 new file mode 100755 index 000000000..936d968c3 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/ic_ab_other_white2.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/nophotos.9.png b/TMessagesProj/src/main/res/drawable-hdpi/nophotos.9.png new file mode 100644 index 000000000..27c40f747 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/nophotos.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photo_back.png b/TMessagesProj/src/main/res/drawable-hdpi/photo_back.png new file mode 100755 index 000000000..c9eb0018d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photo_back.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photobadge.9.png b/TMessagesProj/src/main/res/drawable-hdpi/photobadge.9.png new file mode 100644 index 000000000..e6d9b2289 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photobadge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/photoborder.9.png b/TMessagesProj/src/main/res/drawable-hdpi/photoborder.9.png new file mode 100644 index 000000000..3eb03a164 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/photoborder.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/selectphoto_large.png b/TMessagesProj/src/main/res/drawable-hdpi/selectphoto_large.png new file mode 100755 index 000000000..e718ed06b Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/selectphoto_large.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/selectphoto_small.png b/TMessagesProj/src/main/res/drawable-hdpi/selectphoto_small.png new file mode 100755 index 000000000..7a023ec07 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/selectphoto_small.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/selectphoto_small_active.png b/TMessagesProj/src/main/res/drawable-hdpi/selectphoto_small_active.png new file mode 100755 index 000000000..7a023ec07 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/selectphoto_small_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/selectphoto_small_grey.png b/TMessagesProj/src/main/res/drawable-hdpi/selectphoto_small_grey.png new file mode 100755 index 000000000..6cf4bcda9 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-hdpi/selectphoto_small_grey.png differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/gallery.png b/TMessagesProj/src/main/res/drawable-ldpi/gallery.png new file mode 100755 index 000000000..08b2617e0 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/gallery.png 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 new file mode 100755 index 000000000..9ff5bd3e7 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/ic_ab_other_white2.png differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/nophotos.9.png b/TMessagesProj/src/main/res/drawable-ldpi/nophotos.9.png new file mode 100644 index 000000000..05a2c8199 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/nophotos.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/photo_back.png b/TMessagesProj/src/main/res/drawable-ldpi/photo_back.png new file mode 100755 index 000000000..14f9ad5e8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/photo_back.png differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/photobadge.9.png b/TMessagesProj/src/main/res/drawable-ldpi/photobadge.9.png new file mode 100644 index 000000000..0173130bd Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/photobadge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/photoborder.9.png b/TMessagesProj/src/main/res/drawable-ldpi/photoborder.9.png new file mode 100644 index 000000000..2a33e9d66 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/photoborder.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_large.png b/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_large.png new file mode 100755 index 000000000..c0558b25f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_large.png differ diff --git a/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small.png b/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small.png new file mode 100755 index 000000000..fb868f484 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small.png 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 new file mode 100755 index 000000000..1b18412d6 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small_active.png 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 new file mode 100755 index 000000000..c31d5db9d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-ldpi/selectphoto_small_grey.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/gallery.png b/TMessagesProj/src/main/res/drawable-mdpi/gallery.png new file mode 100755 index 000000000..4eef8a0a9 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/gallery.png 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 new file mode 100755 index 000000000..23433a4b8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/ic_ab_other_white2.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/nophotos.9.png b/TMessagesProj/src/main/res/drawable-mdpi/nophotos.9.png new file mode 100644 index 000000000..30f05e378 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/nophotos.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photo_back.png b/TMessagesProj/src/main/res/drawable-mdpi/photo_back.png new file mode 100755 index 000000000..22a1fe263 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photo_back.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photobadge.9.png b/TMessagesProj/src/main/res/drawable-mdpi/photobadge.9.png new file mode 100644 index 000000000..9a2e146fb Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photobadge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/photoborder.9.png b/TMessagesProj/src/main/res/drawable-mdpi/photoborder.9.png new file mode 100644 index 000000000..75b581198 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/photoborder.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/selectphoto_large.png b/TMessagesProj/src/main/res/drawable-mdpi/selectphoto_large.png new file mode 100755 index 000000000..f8799c402 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/selectphoto_large.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/selectphoto_small.png b/TMessagesProj/src/main/res/drawable-mdpi/selectphoto_small.png new file mode 100755 index 000000000..051f23a6f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/selectphoto_small.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/selectphoto_small_active.png b/TMessagesProj/src/main/res/drawable-mdpi/selectphoto_small_active.png new file mode 100755 index 000000000..051f23a6f Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/selectphoto_small_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/selectphoto_small_grey.png b/TMessagesProj/src/main/res/drawable-mdpi/selectphoto_small_grey.png new file mode 100755 index 000000000..0dcf76705 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-mdpi/selectphoto_small_grey.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/gallery.png b/TMessagesProj/src/main/res/drawable-xhdpi/gallery.png new file mode 100755 index 000000000..3d14800a8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/gallery.png 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 new file mode 100755 index 000000000..8a5215911 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/ic_ab_other_white2.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/nophotos.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/nophotos.9.png new file mode 100644 index 000000000..3d70646b3 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/nophotos.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photo_back.png b/TMessagesProj/src/main/res/drawable-xhdpi/photo_back.png new file mode 100755 index 000000000..21dcdebe2 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photo_back.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photobadge.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/photobadge.9.png new file mode 100644 index 000000000..7d778da73 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photobadge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/photoborder.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/photoborder.9.png new file mode 100644 index 000000000..77ba09d40 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/photoborder.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/selectphoto_large.png b/TMessagesProj/src/main/res/drawable-xhdpi/selectphoto_large.png new file mode 100755 index 000000000..090543233 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/selectphoto_large.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/selectphoto_small.png b/TMessagesProj/src/main/res/drawable-xhdpi/selectphoto_small.png new file mode 100755 index 000000000..5b817801c Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/selectphoto_small.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/selectphoto_small_active.png b/TMessagesProj/src/main/res/drawable-xhdpi/selectphoto_small_active.png new file mode 100755 index 000000000..95d818a44 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/selectphoto_small_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/selectphoto_small_grey.png b/TMessagesProj/src/main/res/drawable-xhdpi/selectphoto_small_grey.png new file mode 100755 index 000000000..598676b91 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xhdpi/selectphoto_small_grey.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/gallery.png b/TMessagesProj/src/main/res/drawable-xxhdpi/gallery.png new file mode 100755 index 000000000..516f851e8 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/gallery.png 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 new file mode 100755 index 000000000..d259309d6 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/ic_ab_other_white2.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/nophotos.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/nophotos.9.png new file mode 100644 index 000000000..123b71b56 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/nophotos.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photo_back.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photo_back.png new file mode 100755 index 000000000..83b69df05 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photo_back.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photobadge.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photobadge.9.png new file mode 100644 index 000000000..3e4f234a2 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photobadge.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/photoborder.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/photoborder.9.png new file mode 100644 index 000000000..b46d44547 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/photoborder.9.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/selectphoto_large.png b/TMessagesProj/src/main/res/drawable-xxhdpi/selectphoto_large.png new file mode 100755 index 000000000..d22cfb8ff Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/selectphoto_large.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/selectphoto_small.png b/TMessagesProj/src/main/res/drawable-xxhdpi/selectphoto_small.png new file mode 100755 index 000000000..7620f457e Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/selectphoto_small.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/selectphoto_small_active.png b/TMessagesProj/src/main/res/drawable-xxhdpi/selectphoto_small_active.png new file mode 100755 index 000000000..11ac540b6 Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/selectphoto_small_active.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/selectphoto_small_grey.png b/TMessagesProj/src/main/res/drawable-xxhdpi/selectphoto_small_grey.png new file mode 100755 index 000000000..935604b4d Binary files /dev/null and b/TMessagesProj/src/main/res/drawable-xxhdpi/selectphoto_small_grey.png differ diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_picker.xml b/TMessagesProj/src/main/res/drawable/bar_selector_picker.xml new file mode 100644 index 000000000..3a705f195 --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/bar_selector_picker.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/media_photo_layout.xml b/TMessagesProj/src/main/res/layout/media_photo_layout.xml index b60a04d28..c3a16aae9 100644 --- a/TMessagesProj/src/main/res/layout/media_photo_layout.xml +++ b/TMessagesProj/src/main/res/layout/media_photo_layout.xml @@ -1,10 +1,11 @@ - - + + + android:layout_height="fill_parent"/> + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/media_video_layout.xml b/TMessagesProj/src/main/res/layout/media_video_layout.xml index 6bcdc3293..810f77f3b 100644 --- a/TMessagesProj/src/main/res/layout/media_video_layout.xml +++ b/TMessagesProj/src/main/res/layout/media_video_layout.xml @@ -6,8 +6,7 @@ + android:layout_height="fill_parent"/> + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/photo_picker_bottom_layout.xml b/TMessagesProj/src/main/res/layout/photo_picker_bottom_layout.xml new file mode 100644 index 000000000..07777cb07 --- /dev/null +++ b/TMessagesProj/src/main/res/layout/photo_picker_bottom_layout.xml @@ -0,0 +1,69 @@ + + +