Commit 55ccb7c9 authored by DrKLO's avatar DrKLO

New photo picker in chats

parent db64b2f6
...@@ -81,7 +81,7 @@ android { ...@@ -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"
} }
} }
...@@ -79,6 +79,48 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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);
}
});
}
});
}
} }
...@@ -4516,9 +4516,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -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);
} }
} }
......
...@@ -387,6 +387,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD ...@@ -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;
......
...@@ -101,7 +101,10 @@ import java.util.Comparator; ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 {
......
...@@ -144,7 +144,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -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 ...@@ -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 ...@@ -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) {
......
...@@ -115,7 +115,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter ...@@ -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 {
......
...@@ -118,7 +118,7 @@ public class CountrySelectActivity extends BaseFragment { ...@@ -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() {
......
...@@ -126,7 +126,7 @@ public class DocumentSelectActivity extends BaseFragment { ...@@ -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
......
...@@ -123,7 +123,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen ...@@ -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)));
......
...@@ -118,7 +118,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati ...@@ -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() {
......
...@@ -45,7 +45,7 @@ public class IdenticonActivity extends BaseFragment { ...@@ -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));
......
...@@ -48,7 +48,7 @@ public class LanguageSelectActivity extends BaseFragment { ...@@ -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() {
......
...@@ -80,7 +80,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter ...@@ -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 {
......
...@@ -56,7 +56,7 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe ...@@ -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() {
......
...@@ -46,7 +46,6 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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);
......
...@@ -164,10 +164,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter ...@@ -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);
......
...@@ -220,7 +220,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter ...@@ -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 ...@@ -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 ...@@ -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);
......
...@@ -67,7 +67,7 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe ...@@ -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
......
...@@ -97,7 +97,7 @@ public class SettingsNotificationsActivity extends BaseFragment { ...@@ -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
......
...@@ -134,7 +134,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen ...@@ -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 ...@@ -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 ...@@ -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();
......
...@@ -32,7 +32,6 @@ public class ActionBar extends FrameLayout { ...@@ -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 { ...@@ -206,8 +205,4 @@ public class ActionBar extends FrameLayout {
currentLayer.onMenuButtonPressed(); currentLayer.onMenuButtonPressed();
} }
} }
public void setItemsBackground(int resourceId) {
itemsBackgroundResourceId = resourceId;
}
} }
...@@ -56,6 +56,7 @@ public class ActionBarActivity extends Activity { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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,11 +506,13 @@ public class ActionBarActivity extends Activity { ...@@ -501,11 +506,13 @@ public class ActionBarActivity extends Activity {
@Override @Override
public void onAnimationEnd(Animation animation) { public void onAnimationEnd(Animation animation) {
if (transitionAnimationInProgress) {
transitionAnimationInProgress = false; transitionAnimationInProgress = false;
transitionAnimationStartTime = 0; transitionAnimationStartTime = 0;
fragment.onOpenAnimationEnd(); fragment.onOpenAnimationEnd();
presentFragmentInternalRemoveOld(removeLast, currentFragment); presentFragmentInternalRemoveOld(removeLast, currentFragment);
} }
}
@Override @Override
public void onAnimationRepeat(Animation animation) { public void onAnimationRepeat(Animation animation) {
...@@ -566,7 +573,7 @@ public class ActionBarActivity extends Activity { ...@@ -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,10 +581,12 @@ public class ActionBarActivity extends Activity { ...@@ -574,10 +581,12 @@ public class ActionBarActivity extends Activity {
@Override @Override
public void onAnimationEnd(Animation animation) { public void onAnimationEnd(Animation animation) {
if (transitionAnimationInProgress) {
transitionAnimationInProgress = false; transitionAnimationInProgress = false;
transitionAnimationStartTime = 0; transitionAnimationStartTime = 0;
closeLastFragmentInternalRemoveOld(currentFragment); closeLastFragmentInternalRemoveOld(currentFragment);
} }
}
@Override @Override
public void onAnimationRepeat(Animation animation) { public void onAnimationRepeat(Animation animation) {
......
...@@ -43,11 +43,14 @@ public class ActionBarLayer extends FrameLayout { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -459,4 +463,9 @@ public class ActionBarLayer extends FrameLayout {
menu.hideAllPopupMenus(); menu.hideAllPopupMenus();
} }
} }
public void setItemsBackground(int resourceId) {
itemsBackgroundResourceId = resourceId;
backButtonFrameLayout.setBackgroundResource(itemsBackgroundResourceId);
}
} }
\ No newline at end of file
...@@ -49,7 +49,7 @@ public class ActionBarMenu extends LinearLayout { ...@@ -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 { ...@@ -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);
......
...@@ -46,9 +46,9 @@ public class ActionBarMenuItem extends ImageView { ...@@ -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;
} }
......
...@@ -62,6 +62,7 @@ public class BaseFragment { ...@@ -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);
} }
} }
} }
......
...@@ -259,6 +259,6 @@ public class ImageReceiver { ...@@ -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;
} }
} }
<!--
~ 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>
\ No newline at end of file
<?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>
\ No newline at end of file
...@@ -6,8 +6,7 @@ ...@@ -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"
......
<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>
\ No newline at end of file
<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>
\ No newline at end of file
<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>
\ No newline at end of file
<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>
\ No newline at end of file
...@@ -290,6 +290,8 @@ ...@@ -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>
......
...@@ -290,6 +290,8 @@ ...@@ -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>
......
...@@ -290,6 +290,8 @@ ...@@ -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>
......
...@@ -290,6 +290,8 @@ ...@@ -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>
......
...@@ -290,6 +290,8 @@ ...@@ -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>
......
...@@ -292,6 +292,8 @@ ...@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment