1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-02 10:33:36 +00:00

New photo picker in chats

This commit is contained in:
DrKLO 2014-06-12 05:13:15 +04:00
parent db64b2f698
commit 55ccb7c9e2
93 changed files with 1349 additions and 144 deletions

View File

@ -81,7 +81,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 244 versionCode 245
versionName "1.4.15" versionName "1.5.0"
} }
} }

View File

@ -79,6 +79,48 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
long pcmOffset; 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<PhotoEntry> photos = new ArrayList<PhotoEntry>();
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 audioProgressDidChanged = 50001;
public final static int audioDidReset = 50002; public final static int audioDidReset = 50002;
public final static int recordProgressChanged = 50003; 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 recordStartError = 50005;
public final static int recordStopped = 50006; public final static int recordStopped = 50006;
public final static int screenshotTook = 50007; public final static int screenshotTook = 50007;
public final static int albumsDidLoaded = 50008;
private HashMap<String, ArrayList<WeakReference<FileDownloadProgressListener>>> loadingFileObservers = new HashMap<String, ArrayList<WeakReference<FileDownloadProgressListener>>>(); private HashMap<String, ArrayList<WeakReference<FileDownloadProgressListener>>> loadingFileObservers = new HashMap<String, ArrayList<WeakReference<FileDownloadProgressListener>>>();
private HashMap<Integer, String> observersByTag = new HashMap<Integer, String>(); private HashMap<Integer, String> observersByTag = new HashMap<Integer, String>();
@ -412,7 +455,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
} }
public void stopMediaObserver() { 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; return;
} }
if (stopMediaObserverRunnable == null) { if (stopMediaObserverRunnable == null) {
@ -1533,4 +1576,80 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
} }
return null; return null;
} }
public static void loadGalleryPhotosAlbums(final int guid) {
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public void run() {
final ArrayList<AlbumEntry> albumsSorted = new ArrayList<AlbumEntry>();
HashMap<Integer, AlbumEntry> albums = new HashMap<Integer, AlbumEntry>();
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);
}
});
}
});
}
} }

View File

@ -4516,9 +4516,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (choosenSoundPath != null && !choosenSoundPath.equals("NoSound")) { if (choosenSoundPath != null && !choosenSoundPath.equals("NoSound")) {
if (choosenSoundPath.equals(defaultPath)) { if (choosenSoundPath.equals(defaultPath)) {
mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI); mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, AudioManager.STREAM_NOTIFICATION);
} else { } else {
mBuilder.setSound(Uri.parse(choosenSoundPath)); mBuilder.setSound(Uri.parse(choosenSoundPath), AudioManager.STREAM_NOTIFICATION);
} }
} }

View File

@ -387,6 +387,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
w = (int) (currentPhotoObject.photoOwner.w / hScale); w = (int) (currentPhotoObject.photoOwner.w / hScale);
} }
} }
int timeWidthTotal = timeWidth + Utilities.dp(14 + (currentMessageObject.isOut() ? 20 : 0));
if (w < timeWidthTotal) {
w = timeWidthTotal;
}
photoWidth = w; photoWidth = w;
photoHeight = h; photoHeight = h;

View File

@ -101,7 +101,10 @@ import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.Semaphore; 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 timeItem;
private View menuItem; private View menuItem;
@ -414,7 +417,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
@Override @Override
public void onItemClick(int id) { public void onItemClick(int id) {
@ -438,13 +441,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} else if (id == attach_gallery) { } else if (id == attach_gallery) {
try { PhotoPickerActivity fragment = new PhotoPickerActivity();
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); fragment.setDelegate(ChatActivity.this);
photoPickerIntent.setType("image/*"); presentFragment(fragment);
getParentActivity().startActivityForResult(photoPickerIntent, 1);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else if (id == attach_video) { } else if (id == attach_video) {
try { try {
Intent pickIntent = new Intent(); Intent pickIntent = new Intent();
@ -1987,7 +1986,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
View firstVisView = chatListView.getChildAt(chatListView.getChildCount() - 1); View firstVisView = chatListView.getChildAt(chatListView.getChildCount() - 1);
int top = ((firstVisView == null) ? 0 : firstVisView.getTop()) - chatListView.getPaddingTop(); int top = ((firstVisView == null) ? 0 : firstVisView.getTop()) - chatListView.getPaddingTop();
chatAdapter.notifyDataSetChanged(); chatAdapter.notifyDataSetChanged();
chatListView.setSelectionFromTop(firstVisPos + newRowsCount, top); chatListView.setSelectionFromTop(firstVisPos + newRowsCount - (endReached ? 1 : 0), top);
} }
if (paused) { if (paused) {
@ -2676,6 +2675,24 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} }
} }
@Override
public void didSelectPhotos(ArrayList<String> 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 @Override
public void onBeginSlide() { public void onBeginSlide() {
super.onBeginSlide(); super.onBeginSlide();
@ -3327,7 +3344,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} }
@Override @Override
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) { public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
if (messageObject == null) { if (messageObject == null) {
return null; return null;
} }
@ -3372,9 +3389,25 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
} }
@Override @Override
public void willHidePhotoViewer() { public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { }
updateVisibleRows();
} @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 { private class ChatAdapter extends BaseAdapter {

View File

@ -144,7 +144,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("GroupInfo", R.string.GroupInfo)); actionBarLayer.setTitle(LocaleController.getString("GroupInfo", R.string.GroupInfo));
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
@Override @Override
@ -337,7 +337,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
} }
@Override @Override
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) { public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
if (fileLocation == null) { if (fileLocation == null) {
return null; return null;
} }
@ -368,9 +368,25 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
} }
@Override @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) { public void didReceivedNotification(int id, Object... args) {
if (id == MessagesController.updateInterfaces) { if (id == MessagesController.updateInterfaces) {

View File

@ -115,7 +115,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
if (destroyAfterSelect) { if (destroyAfterSelect) {
actionBarLayer.setTitle(LocaleController.getString("SelectContact", R.string.SelectContact)); actionBarLayer.setTitle(LocaleController.getString("SelectContact", R.string.SelectContact));
} else { } else {

View File

@ -118,7 +118,7 @@ public class CountrySelectActivity extends BaseFragment {
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); actionBarLayer.setTitle(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {

View File

@ -126,7 +126,7 @@ public class DocumentSelectActivity extends BaseFragment {
} }
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile)); actionBarLayer.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile));
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
@Override @Override

View File

@ -123,7 +123,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup)); actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
actionBarLayer.setSubtitle(String.format("%d/200 %s", selectedContacts.size(), LocaleController.getString("Members", R.string.Members))); actionBarLayer.setSubtitle(String.format("%d/200 %s", selectedContacts.size(), LocaleController.getString("Members", R.string.Members)));

View File

@ -118,7 +118,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup)); actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {

View File

@ -45,7 +45,7 @@ public class IdenticonActivity extends BaseFragment {
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey)); actionBarLayer.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, Utilities.dp(4)); actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, Utilities.dp(4));

View File

@ -48,7 +48,7 @@ public class LanguageSelectActivity extends BaseFragment {
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("Language", R.string.Language)); actionBarLayer.setTitle(LocaleController.getString("Language", R.string.Language));
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {

View File

@ -80,7 +80,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
if (messageObject != null) { if (messageObject != null) {
actionBarLayer.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation)); actionBarLayer.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation));
} else { } else {

View File

@ -56,7 +56,7 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayUseLogoEnabled(true); actionBarLayer.setDisplayUseLogoEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("AppName", R.string.AppName)); actionBarLayer.setTitle(LocaleController.getString("AppName", R.string.AppName));
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {

View File

@ -46,7 +46,6 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
private HashMap<Integer, MessageObject> messagesDict = new HashMap<Integer, MessageObject>(); private HashMap<Integer, MessageObject> messagesDict = new HashMap<Integer, MessageObject>();
private long dialog_id; private long dialog_id;
private int totalCount = 0; private int totalCount = 0;
private int orientation = 0;
private int itemWidth = 100; private int itemWidth = 100;
private boolean loading = false; private boolean loading = false;
private boolean endReached = false; private boolean endReached = false;
@ -87,7 +86,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("SharedMedia", R.string.SharedMedia)); actionBarLayer.setTitle(LocaleController.getString("SharedMedia", R.string.SharedMedia));
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
@Override @Override
@ -264,7 +263,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
} }
@Override @Override
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) { public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
if (messageObject == null) { if (messageObject == null) {
return null; return null;
} }
@ -296,9 +295,25 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
} }
@Override @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() { private void fixLayout() {
if (listView != null) { if (listView != null) {
@ -310,12 +325,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
int rotation = manager.getDefaultDisplay().getRotation(); int rotation = manager.getDefaultDisplay().getRotation();
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
orientation = 1;
listView.setNumColumns(6); listView.setNumColumns(6);
itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 6 - Utilities.dp(2) * 5; itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 6 - Utilities.dp(2) * 5;
listView.setColumnWidth(itemWidth); listView.setColumnWidth(itemWidth);
} else { } else {
orientation = 0;
listView.setNumColumns(4); listView.setNumColumns(4);
itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 4 - Utilities.dp(2) * 3; itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 4 - Utilities.dp(2) * 3;
listView.setColumnWidth(itemWidth); listView.setColumnWidth(itemWidth);

View File

@ -164,10 +164,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} }
}); });
if (onlySelect) { if (onlySelect) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat)); actionBarLayer.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
} else { } else {
actionBarLayer.setDisplayUseLogoEnabled(true); actionBarLayer.setDisplayUseLogoEnabled(true, R.drawable.ic_ab_logo);
actionBarLayer.setTitle(LocaleController.getString("AppName", R.string.AppName)); actionBarLayer.setTitle(LocaleController.getString("AppName", R.string.AppName));
menu.addItem(messages_list_menu_new_messages, R.drawable.ic_ab_compose); menu.addItem(messages_list_menu_new_messages, R.drawable.ic_ab_compose);
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other); ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);

View File

@ -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<String> photos);
public abstract void startPhotoSelectActivity();
}
private ArrayList<MediaController.AlbumEntry> albumsSorted = null;
private HashMap<Integer, MediaController.PhotoEntry> selectedPhotos = new HashMap<Integer, MediaController.PhotoEntry>();
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<MediaController.AlbumEntry>)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<String> photos = new ArrayList<String>();
for (HashMap.Entry<Integer, MediaController.PhotoEntry> 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();
}
}
}

View File

@ -12,6 +12,7 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -26,6 +27,7 @@ import android.text.TextUtils;
import android.view.GestureDetector; import android.view.GestureDetector;
import android.view.Gravity; import android.view.Gravity;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.Surface;
import android.view.VelocityTracker; import android.view.VelocityTracker;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -33,6 +35,7 @@ import android.view.ViewTreeObserver;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.AlphaAnimation; import android.view.animation.AlphaAnimation;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import android.widget.Button;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
@ -64,6 +67,7 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
public class PhotoViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener { public class PhotoViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
private int classGuid; private int classGuid;
@ -86,6 +90,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private ActionBarMenuItem menuItem; private ActionBarMenuItem menuItem;
private ColorDrawable backgroundDrawable = new ColorDrawable(0xff000000); private ColorDrawable backgroundDrawable = new ColorDrawable(0xff000000);
private OverlayView currentOverlay; private OverlayView currentOverlay;
private ImageView checkImageView;
private View pickerView;
private TextView doneButtonTextView;
private TextView doneButtonBadgeTextView;
private boolean canShowBottom = true; private boolean canShowBottom = true;
private boolean overlayViewVisible = true; private boolean overlayViewVisible = true;
@ -100,6 +108,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private TLRPC.FileLocation currentFileLocation; private TLRPC.FileLocation currentFileLocation;
private String currentFileName; private String currentFileName;
private PlaceProviderObject currentPlaceObject; private PlaceProviderObject currentPlaceObject;
private String currentPathObject;
private Bitmap currentThumb = null; private Bitmap currentThumb = null;
private int avatarsUserId; private int avatarsUserId;
@ -152,6 +161,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private HashMap<Integer, MessageObject> imagesByIds = new HashMap<Integer, MessageObject>(); private HashMap<Integer, MessageObject> imagesByIds = new HashMap<Integer, MessageObject>();
private ArrayList<TLRPC.FileLocation> imagesArrLocations = new ArrayList<TLRPC.FileLocation>(); private ArrayList<TLRPC.FileLocation> imagesArrLocations = new ArrayList<TLRPC.FileLocation>();
private ArrayList<Integer> imagesArrLocationsSizes = new ArrayList<Integer>(); private ArrayList<Integer> imagesArrLocationsSizes = new ArrayList<Integer>();
private ArrayList<MediaController.PhotoEntry> imagesArrLocals = new ArrayList<MediaController.PhotoEntry>();
private final static int gallery_menu_save = 1; private final static int gallery_menu_save = 1;
private final static int gallery_menu_showall = 2; private final static int gallery_menu_showall = 2;
@ -199,8 +209,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
public static interface PhotoViewerProvider { 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 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 { private static class FrameLayoutTouchListener extends FrameLayout {
@ -406,13 +422,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
actionBar = new ActionBar(activity); actionBar = new ActionBar(activity);
containerView.addView(actionBar); containerView.addView(actionBar);
actionBar.setBackgroundColor(0xdd000000); actionBar.setBackgroundColor(0xdd000000);
actionBar.setItemsBackground(R.drawable.bar_selector_white);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)actionBar.getLayoutParams(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)actionBar.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
actionBar.setLayoutParams(layoutParams); actionBar.setLayoutParams(layoutParams);
actionBarLayer = actionBar.createLayer(); actionBarLayer = actionBar.createLayer();
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setItemsBackground(R.drawable.bar_selector_white);
actionBarLayer.setTitle(LocaleController.getString("Gallery", R.string.Gallery)); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.photo_back);
actionBarLayer.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1));
actionBar.setCurrentActionBarLayer(actionBarLayer); actionBar.setCurrentActionBarLayer(actionBarLayer);
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
@ -593,6 +609,34 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
layoutParams.topMargin = Utilities.dp(26); layoutParams.topMargin = Utilities.dp(26);
dateTextView.setLayoutParams(layoutParams); 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 = new ProgressBar(containerView.getContext(), null, android.R.attr.progressBarStyleHorizontal);
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
progressBar.setMax(100); progressBar.setMax(100);
@ -617,6 +661,39 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
currentOverlay = new OverlayView(containerView.getContext()); currentOverlay = new OverlayView(containerView.getContext());
containerView.addView(currentOverlay); containerView.addView(currentOverlay);
currentOverlay.setVisibility(View.GONE); 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) { private void toggleOverlayView(boolean show) {
@ -828,8 +905,25 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
return null; 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() { private void updateActionOverlays() {
if (currentMessageObject == null) { if (currentMessageObject == null || currentFileName == null) {
currentOverlay.setVisibility(View.GONE); currentOverlay.setVisibility(View.GONE);
return; return;
} }
@ -868,10 +962,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
} }
private void onPhotoShow(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList<MessageObject> messages, int index, final PlaceProviderObject object) { private void onPhotoShow(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList<MessageObject> messages, final ArrayList<MediaController.PhotoEntry> photos, int index, final PlaceProviderObject object) {
classGuid = ConnectionsManager.getInstance().generateClassGuid(); classGuid = ConnectionsManager.getInstance().generateClassGuid();
currentMessageObject = null; currentMessageObject = null;
currentFileLocation = null; currentFileLocation = null;
currentPathObject = null;
currentIndex = -1; currentIndex = -1;
currentFileName = null; currentFileName = null;
avatarsUserId = 0; avatarsUserId = 0;
@ -882,13 +977,19 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
loadingMoreImages = false; loadingMoreImages = false;
cacheEndReached = false; cacheEndReached = false;
opennedFromMedia = false; opennedFromMedia = false;
canShowBottom = true;
imagesArr.clear(); imagesArr.clear();
imagesArrLocations.clear(); imagesArrLocations.clear();
imagesArrLocationsSizes.clear(); imagesArrLocationsSizes.clear();
imagesArrLocals.clear();
imagesByIds.clear(); imagesByIds.clear();
imagesArrTemp.clear(); imagesArrTemp.clear();
imagesByIdsTemp.clear(); imagesByIdsTemp.clear();
currentThumb = object.thumb; currentThumb = object.thumb;
menuItem.setVisibility(View.VISIBLE);
bottomLayout.setVisibility(View.VISIBLE);
checkImageView.setVisibility(View.GONE);
pickerView.setVisibility(View.GONE);
if (messageObject != null && messages == null) { if (messageObject != null && messages == null) {
imagesArr.add(messageObject); imagesArr.add(messageObject);
@ -912,17 +1013,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else { } else {
menuItem.hideSubItem(gallery_menu_showall); menuItem.hideSubItem(gallery_menu_showall);
} }
bottomLayout.setVisibility(View.VISIBLE);
canShowBottom = true;
setImageIndex(0, true); setImageIndex(0, true);
} else if (fileLocation != null) { } else if (fileLocation != null) {
avatarsUserId = object.user_id; avatarsUserId = object.user_id;
imagesArrLocations.add(fileLocation); imagesArrLocations.add(fileLocation);
imagesArrLocationsSizes.add(object.size); imagesArrLocationsSizes.add(object.size);
bottomLayout.setVisibility(View.GONE); bottomLayout.setVisibility(View.GONE);
canShowBottom = false;
menuItem.hideSubItem(gallery_menu_showall); menuItem.hideSubItem(gallery_menu_showall);
setImageIndex(0, true); setImageIndex(0, true);
canShowBottom = false;
} else if (messages != null) { } else if (messages != null) {
imagesArr.addAll(messages); imagesArr.addAll(messages);
Collections.reverse(imagesArr); Collections.reverse(imagesArr);
@ -950,6 +1049,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
opennedFromMedia = true; opennedFromMedia = true;
setImageIndex(index, 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) { if (currentDialogId != 0 && totalImagesCount == 0) {
@ -966,6 +1072,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (!init) { if (!init) {
currentThumb = null; currentThumb = null;
} }
placeProvider.willSwitchFromPhoto(currentMessageObject, currentFileLocation, currentIndex);
int prevIndex = currentIndex; int prevIndex = currentIndex;
currentIndex = index; currentIndex = index;
currentFileName = getFileName(index, null); currentFileName = getFileName(index, null);
@ -991,8 +1098,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
updateActionOverlays(); updateActionOverlays();
} else if (!imagesArrLocations.isEmpty()) { } else if (!imagesArrLocations.isEmpty()) {
currentFileLocation = imagesArrLocations.get(index); 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.imageReceiver.setVisible(true, true);
} }
} }
currentPlaceObject = placeProvider.getPlaceForPhoto(currentMessageObject, currentFileLocation); currentPlaceObject = placeProvider.getPlaceForPhoto(currentMessageObject, currentFileLocation, currentIndex);
if (!init) { if (!init) {
if (currentPlaceObject != null) { if (currentPlaceObject != null) {
currentPlaceObject.imageReceiver.setVisible(false, true); currentPlaceObject.imageReceiver.setVisible(false, true);
@ -1033,7 +1147,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
canDragDown = true; canDragDown = true;
changingPage = false; changingPage = false;
switchImageAfterAnimation = 0; switchImageAfterAnimation = 0;
canZoom = !currentFileName.endsWith("mp4"); canZoom = currentFileName == null || !currentFileName.endsWith("mp4");
updateMinMax(scale); updateMinMax(scale);
if (prevIndex == -1) { if (prevIndex == -1) {
@ -1080,45 +1194,60 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else { } else {
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
} }
updateActionOverlays();
} }
private void setIndexToImage(ImageReceiver imageReceiver, int index) { private void setIndexToImage(ImageReceiver imageReceiver, int index) {
int size[] = new int[1]; if (!imagesArrLocals.isEmpty()) {
TLRPC.FileLocation fileLocation = getFileLocation(index, size); if (index >= 0 && index < imagesArrLocals.size()) {
MediaController.PhotoEntry photoEntry = imagesArrLocals.get(index);
if (fileLocation != null) { Bitmap placeHolder = null;
MessageObject messageObject = null; if (currentThumb != null && imageReceiver == centerImage) {
if (!imagesArr.isEmpty()) { placeHolder = currentThumb;
messageObject = imagesArr.get(index); }
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 (fileLocation != null) {
if (messageObject.imagePreview != null) { MessageObject messageObject = null;
imageReceiver.setImageBitmap(messageObject.imagePreview); if (!imagesArr.isEmpty()) {
} else if (messageObject.messageOwner.media.video.thumb != null) { 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; Bitmap placeHolder = null;
if (messageObject != null) {
placeHolder = messageObject.imagePreview;
}
if (currentThumb != null && imageReceiver == centerImage) { if (currentThumb != null && imageReceiver == centerImage) {
placeHolder = currentThumb; placeHolder = currentThumb;
} }
imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, size[0]); imageReceiver.setImage(fileLocation, null, placeHolder != null ? new BitmapDrawable(null, placeHolder) : null, size[0]);
}
} else {
if (size[0] == 0) {
imageReceiver.setImageBitmap((Bitmap) null);
} else { } else {
imageReceiver.setImageBitmap(parentActivity.getResources().getDrawable(R.drawable.photoview_placeholder)); 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; 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) { 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) { 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<MessageObject> messages, final int index, final PhotoViewerProvider provider) { public void openPhoto(final ArrayList<MessageObject> 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<MessageObject> messages, final int index, final PhotoViewerProvider provider) { public void openPhotoForSelect(final ArrayList<MediaController.PhotoEntry> photos, final int index, final PhotoViewerProvider provider) {
if (parentActivity == null || isVisible || provider == null || animationInProgress || messageObject == null && fileLocation == null && messages == null) { openPhoto(null, null, null, photos, index, provider);
}
public void openPhoto(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList<MessageObject> messages, final ArrayList<MediaController.PhotoEntry> photos, final int index, final PhotoViewerProvider provider) {
if (parentActivity == null || isVisible || provider == null || animationInProgress || messageObject == null && fileLocation == null && messages == null && photos == null) {
return; return;
} }
final PlaceProviderObject object = provider.getPlaceForPhoto(messageObject, fileLocation); final PlaceProviderObject object = provider.getPlaceForPhoto(messageObject, fileLocation, index);
if (object == null) { if (object == null) {
return; 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.FileDidFailedLoad);
NotificationCenter.getInstance().addObserver(this, FileLoader.FileDidLoaded); NotificationCenter.getInstance().addObserver(this, FileLoader.FileDidLoaded);
NotificationCenter.getInstance().addObserver(this, FileLoader.FileLoadProgressChanged); NotificationCenter.getInstance().addObserver(this, FileLoader.FileLoadProgressChanged);
@ -1169,7 +1306,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
disableShowCheck = true; disableShowCheck = true;
onPhotoShow(messageObject, fileLocation, messages, index, object); onPhotoShow(messageObject, fileLocation, messages, photos, index, object);
isVisible = true; isVisible = true;
backgroundDrawable.setAlpha(255); backgroundDrawable.setAlpha(255);
toggleActionBar(true, false); toggleActionBar(true, false);
@ -1208,6 +1345,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
float xPos = (Utilities.displaySize.x - width) / 2.0f; float xPos = (Utilities.displaySize.x - width) / 2.0f;
float yPos = (Utilities.displaySize.y - Utilities.statusBarHeight - height) / 2.0f; float yPos = (Utilities.displaySize.y - Utilities.statusBarHeight - height) / 2.0f;
int clipHorizontal = Math.abs(object.imageReceiver.drawRegion.left - object.imageReceiver.imageX); 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]; int coords2[] = new int[2];
object.parentView.getLocationInWindow(coords2); object.parentView.getLocationInWindow(coords2);
@ -1219,6 +1357,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (clipBottom < 0) { if (clipBottom < 0) {
clipBottom = 0; clipBottom = 0;
} }
clipTop = Math.max(clipTop, clipVertical);
clipBottom = Math.max(clipBottom, clipVertical);
AnimatorSet animatorSet = new AnimatorSet(); AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether( animatorSet.playTogether(
@ -1233,7 +1373,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
ObjectAnimator.ofFloat(actionBar, "alpha", 0.0f, 1.0f), ObjectAnimator.ofFloat(actionBar, "alpha", 0.0f, 1.0f),
ObjectAnimator.ofFloat(bottomLayout, "alpha", 0.0f, 1.0f), ObjectAnimator.ofFloat(bottomLayout, "alpha", 0.0f, 1.0f),
ObjectAnimator.ofFloat(progressBar, "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); animatorSet.setDuration(250);
@ -1284,7 +1425,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
velocityTracker = null; 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) { if(android.os.Build.VERSION.SDK_INT >= 11 && animated) {
Utilities.lockOrientation(parentActivity); Utilities.lockOrientation(parentActivity);
@ -1321,6 +1462,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (object != null) { if (object != null) {
object.imageReceiver.setVisible(false, true); object.imageReceiver.setVisible(false, true);
int clipHorizontal = Math.abs(object.imageReceiver.drawRegion.left - object.imageReceiver.imageX); 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]; int coords2[] = new int[2];
object.parentView.getLocationInWindow(coords2); object.parentView.getLocationInWindow(coords2);
@ -1333,6 +1475,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
clipBottom = 0; clipBottom = 0;
} }
clipTop = Math.max(clipTop, clipVertical);
clipBottom = Math.max(clipBottom, clipVertical);
animatorSet.playTogether( animatorSet.playTogether(
ObjectAnimator.ofFloat(animatingImageView, "scaleX", 1), ObjectAnimator.ofFloat(animatingImageView, "scaleX", 1),
ObjectAnimator.ofFloat(animatingImageView, "scaleY", 1), ObjectAnimator.ofFloat(animatingImageView, "scaleY", 1),
@ -1345,7 +1490,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
ObjectAnimator.ofFloat(actionBar, "alpha", 0.0f), ObjectAnimator.ofFloat(actionBar, "alpha", 0.0f),
ObjectAnimator.ofFloat(bottomLayout, "alpha", 0.0f), ObjectAnimator.ofFloat(bottomLayout, "alpha", 0.0f),
ObjectAnimator.ofFloat(progressBar, "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 { } else {
animatorSet.playTogether( animatorSet.playTogether(
@ -1355,7 +1501,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
ObjectAnimator.ofFloat(bottomLayout, "alpha", 0.0f), ObjectAnimator.ofFloat(bottomLayout, "alpha", 0.0f),
ObjectAnimator.ofFloat(progressBar, "alpha", 0.0f), ObjectAnimator.ofFloat(progressBar, "alpha", 0.0f),
ObjectAnimator.ofFloat(animatingImageView, "translationY", translationY >= 0 ? Utilities.displaySize.y : -Utilities.displaySize.y), 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; disableShowCheck = true;
currentMessageObject = null; currentMessageObject = null;
currentFileLocation = null; currentFileLocation = null;
currentPathObject = null;
currentThumb = null; currentThumb = null;
centerImage.setImageBitmap((Bitmap)null); centerImage.setImageBitmap((Bitmap)null);
leftImage.setImageBitmap((Bitmap) null); leftImage.setImageBitmap((Bitmap) null);
@ -1777,17 +1925,37 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
canvas.restore(); canvas.restore();
} }
@SuppressLint("DrawAllocation")
private void onLayout(boolean changed, int left, int top, int right, int bottom) { private void onLayout(boolean changed, int left, int top, int right, int bottom) {
if(changed) { if(changed) {
scale = 1; scale = 1;
translationX = 0; translationX = 0;
translationY = 0; translationY = 0;
updateMinMax(scale); 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) { private void onActionClick(View view) {
if (currentMessageObject == null) { if (currentMessageObject == null || currentFileName == null) {
return; return;
} }
boolean loadFile = false; boolean loadFile = false;

View File

@ -220,7 +220,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("Settings", R.string.Settings)); actionBarLayer.setTitle(LocaleController.getString("Settings", R.string.Settings));
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
@Override @Override
@ -413,7 +413,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
} }
@Override @Override
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) { public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
if (fileLocation == null) { if (fileLocation == null) {
return null; return null;
} }
@ -445,9 +445,25 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
} }
@Override @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() { public void performAskAQuestion() {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);

View File

@ -67,7 +67,7 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers)); actionBarLayer.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers));
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
@Override @Override

View File

@ -97,7 +97,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
actionBarLayer.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds)); actionBarLayer.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
@Override @Override

View File

@ -134,7 +134,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
@Override @Override
public View createView(LayoutInflater inflater, ViewGroup container) { public View createView(LayoutInflater inflater, ViewGroup container) {
if (fragmentView == null) { if (fragmentView == null) {
actionBarLayer.setDisplayHomeAsUpEnabled(true); actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
if (dialog_id != 0) { if (dialog_id != 0) {
actionBarLayer.setTitle(LocaleController.getString("SecretTitle", R.string.SecretTitle)); actionBarLayer.setTitle(LocaleController.getString("SecretTitle", R.string.SecretTitle));
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, Utilities.dp(4)); actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, Utilities.dp(4));
@ -454,7 +454,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
} }
@Override @Override
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) { public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
if (fileLocation == null) { if (fileLocation == null) {
return null; return null;
} }
@ -486,9 +486,25 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
} }
@Override @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() { private void createActionBarMenu() {
ActionBarMenu menu = actionBarLayer.createMenu(); ActionBarMenu menu = actionBarLayer.createMenu();

View File

@ -32,7 +32,6 @@ public class ActionBar extends FrameLayout {
private View currentBackOverlay; private View currentBackOverlay;
private View shadowView = null; private View shadowView = null;
private int currentBackOverlayWidth; private int currentBackOverlayWidth;
protected int itemsBackgroundResourceId;
public ActionBar(Context context) { public ActionBar(Context context) {
super(context); super(context);
@ -206,8 +205,4 @@ public class ActionBar extends FrameLayout {
currentLayer.onMenuButtonPressed(); currentLayer.onMenuButtonPressed();
} }
} }
public void setItemsBackground(int resourceId) {
itemsBackgroundResourceId = resourceId;
}
} }

View File

@ -56,6 +56,7 @@ public class ActionBarActivity extends Activity {
private long transitionAnimationStartTime; private long transitionAnimationStartTime;
private boolean inActionMode = false; private boolean inActionMode = false;
private int startedTrackingPointerId; private int startedTrackingPointerId;
private Animation.AnimationListener listener;
private class FrameLayoutTouch extends FrameLayout { private class FrameLayoutTouch extends FrameLayout {
public FrameLayoutTouch(Context context) { public FrameLayoutTouch(Context context) {
@ -126,7 +127,6 @@ public class ActionBarActivity extends Activity {
shadowView.setVisibility(View.INVISIBLE); shadowView.setVisibility(View.INVISIBLE);
actionBar = new ActionBar(this); actionBar = new ActionBar(this);
actionBar.setItemsBackground(R.drawable.bar_selector);
contentView.addView(actionBar); contentView.addView(actionBar);
layoutParams = actionBar.getLayoutParams(); layoutParams = actionBar.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
@ -153,6 +153,11 @@ public class ActionBarActivity extends Activity {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
fixLayout(); fixLayout();
if (transitionAnimationInProgress && listener != null) {
openAnimation.cancel();
closeAnimation.cancel();
listener.onAnimationEnd(null);
}
if (!fragmentsStack.isEmpty()) { if (!fragmentsStack.isEmpty()) {
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1); BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
lastFragment.onResume(); lastFragment.onResume();
@ -493,7 +498,7 @@ public class ActionBarActivity extends Activity {
transitionAnimationStartTime = System.currentTimeMillis(); transitionAnimationStartTime = System.currentTimeMillis();
transitionAnimationInProgress = true; transitionAnimationInProgress = true;
openAnimation.reset(); openAnimation.reset();
openAnimation.setAnimationListener(new Animation.AnimationListener() { openAnimation.setAnimationListener(listener = new Animation.AnimationListener() {
@Override @Override
public void onAnimationStart(Animation animation) { public void onAnimationStart(Animation animation) {
@ -501,10 +506,12 @@ public class ActionBarActivity extends Activity {
@Override @Override
public void onAnimationEnd(Animation animation) { public void onAnimationEnd(Animation animation) {
transitionAnimationInProgress = false; if (transitionAnimationInProgress) {
transitionAnimationStartTime = 0; transitionAnimationInProgress = false;
fragment.onOpenAnimationEnd(); transitionAnimationStartTime = 0;
presentFragmentInternalRemoveOld(removeLast, currentFragment); fragment.onOpenAnimationEnd();
presentFragmentInternalRemoveOld(removeLast, currentFragment);
}
} }
@Override @Override
@ -566,7 +573,7 @@ public class ActionBarActivity extends Activity {
transitionAnimationStartTime = System.currentTimeMillis(); transitionAnimationStartTime = System.currentTimeMillis();
transitionAnimationInProgress = true; transitionAnimationInProgress = true;
closeAnimation.reset(); closeAnimation.reset();
closeAnimation.setAnimationListener(new Animation.AnimationListener() { closeAnimation.setAnimationListener(listener = new Animation.AnimationListener() {
@Override @Override
public void onAnimationStart(Animation animation) { public void onAnimationStart(Animation animation) {
@ -574,9 +581,11 @@ public class ActionBarActivity extends Activity {
@Override @Override
public void onAnimationEnd(Animation animation) { public void onAnimationEnd(Animation animation) {
transitionAnimationInProgress = false; if (transitionAnimationInProgress) {
transitionAnimationStartTime = 0; transitionAnimationInProgress = false;
closeLastFragmentInternalRemoveOld(currentFragment); transitionAnimationStartTime = 0;
closeLastFragmentInternalRemoveOld(currentFragment);
}
} }
@Override @Override

View File

@ -43,11 +43,14 @@ public class ActionBarLayer extends FrameLayout {
private TextView subTitleTextView; private TextView subTitleTextView;
private ActionBarMenu menu; private ActionBarMenu menu;
private ActionBarMenu actionMode; private ActionBarMenu actionMode;
private int logoResourceId;
private int backResourceId;
protected ActionBar parentActionBar; protected ActionBar parentActionBar;
private boolean oldUseLogo; private boolean oldUseLogo;
private boolean oldUseBack; private boolean oldUseBack;
private boolean isBackLayoutHidden = false; private boolean isBackLayoutHidden = false;
protected boolean isSearchFieldVisible; protected boolean isSearchFieldVisible;
protected int itemsBackgroundResourceId;
public ActionBarMenuOnItemClick actionBarMenuOnItemClick; public ActionBarMenuOnItemClick actionBarMenuOnItemClick;
public ActionBarLayer(Context context, ActionBar actionBar) { public ActionBarLayer(Context context, ActionBar actionBar) {
@ -60,7 +63,6 @@ public class ActionBarLayer extends FrameLayout {
layoutParams.height = LayoutParams.FILL_PARENT; layoutParams.height = LayoutParams.FILL_PARENT;
layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
backButtonFrameLayout.setLayoutParams(layoutParams); backButtonFrameLayout.setLayoutParams(layoutParams);
backButtonFrameLayout.setBackgroundResource(actionBar.itemsBackgroundResourceId);
backButtonFrameLayout.setPadding(0, 0, Utilities.dp(4), 0); backButtonFrameLayout.setPadding(0, 0, Utilities.dp(4), 0);
backButtonFrameLayout.setOnClickListener(new OnClickListener() { backButtonFrameLayout.setOnClickListener(new OnClickListener() {
@Override @Override
@ -207,28 +209,31 @@ public class ActionBarLayer extends FrameLayout {
menu.measure(width, height); menu.measure(width, height);
} }
public void setDisplayUseLogoEnabled(boolean value) { public void setDisplayUseLogoEnabled(boolean value, int resource) {
if (value && logoImageView == null) { if (value && logoImageView == null) {
logoResourceId = resource;
logoImageView = new ImageView(getContext()); logoImageView = new ImageView(getContext());
logoImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); logoImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
logoImageView.setImageResource(R.drawable.ic_ab_logo);
backButtonFrameLayout.addView(logoImageView); backButtonFrameLayout.addView(logoImageView);
positionLogoImage(getMeasuredHeight()); }
} else if (logoImageView != null) { if (logoImageView != null) {
logoImageView.setVisibility(value ? VISIBLE : GONE); 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) { if (value && backButtonImageView == null) {
backResourceId = resource;
backButtonImageView = new ImageView(getContext()); backButtonImageView = new ImageView(getContext());
backButtonImageView.setImageResource(R.drawable.ic_ab_back);
backButtonFrameLayout.addView(backButtonImageView); backButtonFrameLayout.addView(backButtonImageView);
positionBackImage(getMeasuredHeight());
} }
if (backButtonImageView != null) { if (backButtonImageView != null) {
backButtonImageView.setVisibility(value ? VISIBLE : GONE); backButtonImageView.setVisibility(value ? VISIBLE : GONE);
backButtonFrameLayout.setEnabled(value); 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); backButtonFrameLayout.setPadding(0, 0, visible ? 0 : Utilities.dp(4), 0);
if (visible) { if (visible) {
oldUseLogo = logoImageView != null && logoImageView.getVisibility() == VISIBLE; oldUseLogo = logoImageView != null && logoImageView.getVisibility() == VISIBLE;
setDisplayUseLogoEnabled(true); setDisplayUseLogoEnabled(true, R.drawable.ic_ab_search);
} else { } else {
setDisplayUseLogoEnabled(oldUseLogo); setDisplayUseLogoEnabled(oldUseLogo, logoResourceId);
} }
if (visible) { if (visible) {
oldUseBack = backButtonImageView != null && backButtonImageView.getVisibility() == VISIBLE; oldUseBack = backButtonImageView != null && backButtonImageView.getVisibility() == VISIBLE;
setDisplayHomeAsUpEnabled(true); setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
} else { } else {
setDisplayHomeAsUpEnabled(oldUseBack); setDisplayHomeAsUpEnabled(oldUseBack, backResourceId);
} }
if (visible) { if (visible) {
backButtonFrameLayout.setVisibility(VISIBLE); backButtonFrameLayout.setVisibility(VISIBLE);
} else { } else {
backButtonFrameLayout.setVisibility(isBackLayoutHidden ? INVISIBLE : VISIBLE); backButtonFrameLayout.setVisibility(isBackLayoutHidden ? INVISIBLE : VISIBLE);
} }
logoImageView.setImageResource(visible ? R.drawable.ic_ab_search : R.drawable.ic_ab_logo);
} }
public void closeSearchField() { public void closeSearchField() {
@ -459,4 +463,9 @@ public class ActionBarLayer extends FrameLayout {
menu.hideAllPopupMenus(); menu.hideAllPopupMenus();
} }
} }
public void setItemsBackground(int resourceId) {
itemsBackgroundResourceId = resourceId;
backButtonFrameLayout.setBackgroundResource(itemsBackgroundResourceId);
}
} }

View File

@ -49,7 +49,7 @@ public class ActionBarMenu extends LinearLayout {
addView(view); addView(view);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)view.getLayoutParams(); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)view.getLayoutParams();
layoutParams.height = FrameLayout.LayoutParams.FILL_PARENT; layoutParams.height = FrameLayout.LayoutParams.FILL_PARENT;
view.setBackgroundResource(parentActionBar.itemsBackgroundResourceId); view.setBackgroundResource(parentActionBarLayer.itemsBackgroundResourceId);
view.setLayoutParams(layoutParams); view.setLayoutParams(layoutParams);
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -61,7 +61,7 @@ public class ActionBarMenu extends LinearLayout {
} }
public ActionBarMenuItem addItem(int id, int icon) { 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.setTag(id);
menuItem.setScaleType(ImageView.ScaleType.CENTER); menuItem.setScaleType(ImageView.ScaleType.CENTER);
menuItem.setImageResource(icon); menuItem.setImageResource(icon);

View File

@ -46,9 +46,9 @@ public class ActionBarMenuItem extends ImageView {
private boolean isSearchField = false; private boolean isSearchField = false;
private ActionBarMenuItemSearchListener listener; private ActionBarMenuItemSearchListener listener;
public ActionBarMenuItem(Context context, ActionBarMenu menu, ActionBar actionBar) { public ActionBarMenuItem(Context context, ActionBarMenu menu, ActionBar actionBar, int background) {
super(context); super(context);
setBackgroundResource(actionBar.itemsBackgroundResourceId); setBackgroundResource(background);
parentMenu = menu; parentMenu = menu;
parentActionBar = actionBar; parentActionBar = actionBar;
} }

View File

@ -62,6 +62,7 @@ public class BaseFragment {
} }
actionBarLayer = parentActivity.getInternalActionBar().createLayer(); actionBarLayer = parentActivity.getInternalActionBar().createLayer();
actionBarLayer.setBackgroundResource(R.color.header); actionBarLayer.setBackgroundResource(R.color.header);
actionBarLayer.setItemsBackground(R.drawable.bar_selector);
} }
} }
} }

View File

@ -259,6 +259,6 @@ public class ImageReceiver {
} }
public boolean hasImage() { public boolean hasImage() {
return currentImage != null || last_placeholder != null || currentPath != null; return currentImage != null || last_placeholder != null || currentPath != null || last_httpUrl != null;
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 991 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

View File

@ -0,0 +1,27 @@
<!--
~ 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.
-->
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="#ff3d3d3d" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle">
<solid android:color="#ff3d3d3d" />
</shape>
</item>
<item android:state_selected="true">
<shape android:shape="rectangle">
<solid android:color="#ff3d3d3d" />
</shape>
</item>
<item android:drawable="@drawable/transparent" />
</selector>

View File

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <FrameLayout
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="100dp"> android:layout_height="100dp">
<org.telegram.ui.Views.BackupImageView <org.telegram.ui.Views.BackupImageView
android:id="@+id/media_photo_image" android:id="@+id/media_photo_image"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"/>
android:scaleType="centerCrop"/>
</FrameLayout> </FrameLayout>

View File

@ -6,8 +6,7 @@
<org.telegram.ui.Views.BackupImageView <org.telegram.ui.Views.BackupImageView
android:id="@+id/media_photo_image" android:id="@+id/media_photo_image"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"/>
android:scaleType="centerCrop"/>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -0,0 +1,45 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="top">
<org.telegram.ui.Views.BackupImageView
android:id="@+id/media_photo_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="28dp"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:background="#7f000000">
<TextView
android:layout_height="fill_parent"
android:layout_width="0dp"
android:id="@+id/album_name"
android:textSize="13dp"
android:gravity="center_vertical"
android:textColor="#ffffffff"
android:layout_weight="1"
android:singleLine="true"
android:maxLines="1"
android:layout_marginLeft="8dp"/>
<TextView
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:id="@+id/album_count"
android:textSize="13dp"
android:gravity="center_vertical"
android:textColor="#ffaaaaaa"
android:singleLine="true"
android:maxLines="1"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"/>
</LinearLayout>
</FrameLayout>

View File

@ -0,0 +1,69 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:background="#ff333333">
<Button
android:textSize="14dp"
android:textColor="#ffffff"
android:id="@+id/cancel_button"
android:background="@drawable/bar_selector_picker"
android:paddingLeft="3dp"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:textStyle="bold"/>
<View
android:layout_gravity="center_vertical"
android:background="#5c5c5c"
android:layout_width="1px"
android:layout_height="28dp" />
<FrameLayout
android:id="@+id/done_button"
android:background="@drawable/bar_selector_picker"
android:paddingRight="3dp"
android:clickable="true"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:layout_weight="1.0">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center">
<TextView
android:textSize="13dp"
android:textColor="#ffffff"
android:gravity="center"
android:background="@drawable/photobadge"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="19dp"
android:id="@+id/done_button_badge"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:textStyle="bold"
android:layout_marginRight="10dp"/>
<TextView
android:textSize="14dp"
android:textColor="#ffffff"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/done_button_text"
android:drawablePadding="8dp"
android:textStyle="bold"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>

View File

@ -0,0 +1,54 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#ff000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top">
<GridView
android:id="@+id/media_grid"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:layout_marginBottom="48dp"
android:clipToPadding="false"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="true"
android:verticalSpacing="4dp"
android:horizontalSpacing="4dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:gravity="center"
android:layout_gravity="top"
android:scrollbars="none"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#808080"
android:gravity="center"
android:textSize="24dp"
android:id="@+id/searchEmptyView"
android:visibility="gone"
android:layout_marginBottom="48dp"/>
<LinearLayout
android:id="@+id/progressLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
android:layout_marginBottom="48dp">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<include layout="@layout/photo_picker_bottom_layout"/>
</FrameLayout>

View File

@ -0,0 +1,26 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="top">
<org.telegram.ui.Views.BackupImageView
android:id="@+id/media_photo_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<FrameLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/photo_frame"/>
<ImageView
android:layout_height="30dp"
android:layout_width="30dp"
android:id="@+id/photo_check"
android:layout_gravity="right"
android:layout_marginTop="2dp"
android:scaleType="center"
android:layout_marginRight="2dp"/>
</FrameLayout>

View File

@ -290,6 +290,8 @@
<string name="SaveToGallery">حفظ في الجهاز</string> <string name="SaveToGallery">حفظ في الجهاز</string>
<string name="Of">%1$d من %2$d</string> <string name="Of">%1$d من %2$d</string>
<string name="Gallery">الألبوم</string> <string name="Gallery">الألبوم</string>
<string name="AllPhotos">All Photos</string>
<string name="NoPhotos">No photos yet</string>
<!--button titles--> <!--button titles-->
<string name="Next">التالي</string> <string name="Next">التالي</string>

View File

@ -290,6 +290,8 @@
<string name="SaveToGallery">In der Galerie speichern</string> <string name="SaveToGallery">In der Galerie speichern</string>
<string name="Of">%1$d von %2$d</string> <string name="Of">%1$d von %2$d</string>
<string name="Gallery">Galerie</string> <string name="Gallery">Galerie</string>
<string name="AllPhotos">All Photos</string>
<string name="NoPhotos">No photos yet</string>
<!--button titles--> <!--button titles-->
<string name="Next">Weiter</string> <string name="Next">Weiter</string>

View File

@ -290,6 +290,8 @@
<string name="SaveToGallery">Guardar en galería</string> <string name="SaveToGallery">Guardar en galería</string>
<string name="Of">%1$d de %2$d</string> <string name="Of">%1$d de %2$d</string>
<string name="Gallery">Galería</string> <string name="Gallery">Galería</string>
<string name="AllPhotos">All Photos</string>
<string name="NoPhotos">No photos yet</string>
<!--button titles--> <!--button titles-->
<string name="Next">Siguiente</string> <string name="Next">Siguiente</string>

View File

@ -290,6 +290,8 @@
<string name="SaveToGallery">Salva nella galleria</string> <string name="SaveToGallery">Salva nella galleria</string>
<string name="Of">%1$d di %2$d</string> <string name="Of">%1$d di %2$d</string>
<string name="Gallery">Galleria</string> <string name="Gallery">Galleria</string>
<string name="AllPhotos">All Photos</string>
<string name="NoPhotos">No photos yet</string>
<!--button titles--> <!--button titles-->
<string name="Next">Avanti</string> <string name="Next">Avanti</string>

View File

@ -290,6 +290,8 @@
<string name="SaveToGallery">Opslaan in galerij</string> <string name="SaveToGallery">Opslaan in galerij</string>
<string name="Of">%1$d van %2$d</string> <string name="Of">%1$d van %2$d</string>
<string name="Gallery">Galerij</string> <string name="Gallery">Galerij</string>
<string name="AllPhotos">All Photos</string>
<string name="NoPhotos">No photos yet</string>
<!--button titles--> <!--button titles-->
<string name="Next">Volgende</string> <string name="Next">Volgende</string>

View File

@ -292,6 +292,8 @@
<string name="SaveToGallery">Save to gallery</string> <string name="SaveToGallery">Save to gallery</string>
<string name="Of">%1$d of %2$d</string> <string name="Of">%1$d of %2$d</string>
<string name="Gallery">Gallery</string> <string name="Gallery">Gallery</string>
<string name="AllPhotos">All Photos</string>
<string name="NoPhotos">No photos yet</string>
<!--button titles--> <!--button titles-->
<string name="Next">Next</string> <string name="Next">Next</string>