diff --git a/MessengerProj/src/main/java/com/b44t/messenger/SendMessagesHelper.java b/MessengerProj/src/main/java/com/b44t/messenger/SendMessagesHelper.java index ab2865b75..320325400 100644 --- a/MessengerProj/src/main/java/com/b44t/messenger/SendMessagesHelper.java +++ b/MessengerProj/src/main/java/com/b44t/messenger/SendMessagesHelper.java @@ -815,162 +815,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter prepareSendingPhotos(paths, uris, dialog_id, captions); } - public static void prepareSendingPhotosSearch(final ArrayList photos, final long dialog_id) { - if (photos == null || photos.isEmpty()) { - return; - } - new Thread(new Runnable() { - @Override - public void run() { - final boolean isEncrypted = false;//(int) dialog_id == 0; - for (int a = 0; a < photos.size(); a++) { - final MediaController.SearchImage searchImage = photos.get(a); - if (searchImage.type == 1) { - final HashMap params = new HashMap<>(); - TLRPC.TL_document document = null; - File cacheFile; - if (searchImage.document instanceof TLRPC.TL_document) { - document = (TLRPC.TL_document) searchImage.document; - cacheFile = FileLoader.getPathToAttach(document, true); - } else { - /*if (!isEncrypted)*/ { - TLRPC.Document doc = null;//(TLRPC.Document) MessagesStorage.getInstance().getSentFile(searchImage.imageUrl, !isEncrypted ? 1 : 4); - if (doc instanceof TLRPC.TL_document) { - document = (TLRPC.TL_document) doc; - } - } - String md5 = Utilities.MD5(searchImage.imageUrl) + "." + ImageLoader.getHttpUrlExtension(searchImage.imageUrl, "jpg"); - cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), md5); - } - if (document == null) { - if (searchImage.localUrl != null) { - params.put("url", searchImage.localUrl); - } - File thumbFile = null; - document = new TLRPC.TL_document(); - document.id = 0; - document.date = ConnectionsManager.getInstance().getCurrentTime(); - TLRPC.TL_documentAttributeFilename fileName = new TLRPC.TL_documentAttributeFilename(); - fileName.file_name = "animation.gif"; - document.attributes.add(fileName); - document.size = searchImage.size; - document.dc_id = 0; - if (cacheFile.toString().endsWith("mp4")) { - document.mime_type = "video/mp4"; - document.attributes.add(new TLRPC.TL_documentAttributeAnimated()); - } else { - document.mime_type = "image/gif"; - } - if (cacheFile.exists()) { - thumbFile = cacheFile; - } else { - cacheFile = null; - } - if (thumbFile == null) { - String thumb = Utilities.MD5(searchImage.thumbUrl) + "." + ImageLoader.getHttpUrlExtension(searchImage.thumbUrl, "jpg"); - thumbFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), thumb); - if (!thumbFile.exists()) { - thumbFile = null; - } - } - if (thumbFile != null) { - try { - Bitmap bitmap; - if (thumbFile.getAbsolutePath().endsWith("mp4")) { - bitmap = ThumbnailUtils.createVideoThumbnail(thumbFile.getAbsolutePath(), MediaStore.Video.Thumbnails.MINI_KIND); - } else { - bitmap = ImageLoader.loadBitmap(thumbFile.getAbsolutePath(), null, 90, 90, true); - } - if (bitmap != null) { - document.thumb = ImageLoader.scaleAndSaveImage(bitmap, 90, 90, 55, isEncrypted); - bitmap.recycle(); - } - } catch (Exception e) { - FileLog.e("messenger", e); - } - } - if (document.thumb == null) { - document.thumb = new TLRPC.TL_photoSize(); - document.thumb.w = searchImage.width; - document.thumb.h = searchImage.height; - document.thumb.size = 0; - document.thumb.location = new TLRPC.TL_fileLocationUnavailable(); - document.thumb.type = "x"; - } - } - - if (searchImage.caption != null) { - document.caption = searchImage.caption.toString(); - } - final TLRPC.TL_document documentFinal = document; - final String originalPathFinal = searchImage.imageUrl; - final String pathFinal = cacheFile == null ? searchImage.imageUrl : cacheFile.toString(); - if (params != null && searchImage.imageUrl != null) { - params.put("originalPath", searchImage.imageUrl); - } - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - SendMessagesHelper.getInstance().sendMessageDocument(documentFinal, null, pathFinal, dialog_id, params); - } - }); - } else { - boolean needDownloadHttp = true; - TLRPC.TL_photo photo = null; - /*if (!isEncrypted)*/ { - photo = null;//MessagesStorage.getInstance().getSentFile(searchImage.imageUrl, !isEncrypted ? 0 : 3); - } - if (photo == null) { - String md5 = Utilities.MD5(searchImage.imageUrl) + "." + ImageLoader.getHttpUrlExtension(searchImage.imageUrl, "jpg"); - File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), md5); - if (cacheFile.exists() && cacheFile.length() != 0) { - photo = SendMessagesHelper.getInstance().generatePhotoSizes(cacheFile.toString(), null); - if (photo != null) { - needDownloadHttp = false; - } - } - if (photo == null) { - md5 = Utilities.MD5(searchImage.thumbUrl) + "." + ImageLoader.getHttpUrlExtension(searchImage.thumbUrl, "jpg"); - cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), md5); - if (cacheFile.exists()) { - photo = SendMessagesHelper.getInstance().generatePhotoSizes(cacheFile.toString(), null); - } - if (photo == null) { - photo = new TLRPC.TL_photo(); - photo.date = ConnectionsManager.getInstance().getCurrentTime(); - TLRPC.TL_photoSize photoSize = new TLRPC.TL_photoSize(); - photoSize.w = searchImage.width; - photoSize.h = searchImage.height; - photoSize.size = 0; - photoSize.location = new TLRPC.TL_fileLocationUnavailable(); - photoSize.type = "x"; - photo.sizes.add(photoSize); - } - } - } - if (photo != null) { - if (searchImage.caption != null) { - photo.caption = searchImage.caption.toString(); - } - final TLRPC.TL_photo photoFinal = photo; - final boolean needDownloadHttpFinal = needDownloadHttp; - final HashMap params = new HashMap<>(); - if (searchImage.imageUrl != null) { - params.put("originalPath", searchImage.imageUrl); - } - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - SendMessagesHelper.getInstance().sendMessagePhoto(photoFinal, needDownloadHttpFinal ? searchImage.imageUrl : null, dialog_id, params); - } - }); - } - } - } - } - }).start(); - } - private static String getTrimmedString(String src) { String result = src.trim(); if (result.length() == 0) { diff --git a/MessengerProj/src/main/java/com/b44t/ui/Cells/PhotoPickerAlbumsCell.java b/MessengerProj/src/main/java/com/b44t/ui/Cells/PhotoPickerAlbumsCell.java index c35463dc4..cf8596cd5 100644 --- a/MessengerProj/src/main/java/com/b44t/ui/Cells/PhotoPickerAlbumsCell.java +++ b/MessengerProj/src/main/java/com/b44t/ui/Cells/PhotoPickerAlbumsCell.java @@ -70,7 +70,7 @@ public class PhotoPickerAlbumsCell extends FrameLayout { addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 28, Gravity.LEFT | Gravity.BOTTOM)); nameTextView = new TextView(context); - nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); + nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); nameTextView.setTextColor(0xffffffff); nameTextView.setSingleLine(true); nameTextView.setEllipsize(TextUtils.TruncateAt.END); diff --git a/MessengerProj/src/main/java/com/b44t/ui/Cells/PhotoPickerSearchCell.java b/MessengerProj/src/main/java/com/b44t/ui/Cells/PhotoPickerSearchCell.java deleted file mode 100644 index 2d4ab99a1..000000000 --- a/MessengerProj/src/main/java/com/b44t/ui/Cells/PhotoPickerSearchCell.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * - * Messenger Android Frontend - * (C) 2013-2016 Nikolai Kudashov - * (C) 2017 Björn Petersen - * Contact: r10s@b44t.com, http://b44t.com - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see http://www.gnu.org/licenses/ . - * - ******************************************************************************/ - - -package com.b44t.ui.Cells; - -import android.content.Context; -import android.os.Build; -import android.text.TextUtils; -import android.util.TypedValue; -import android.view.Gravity; -import android.view.MotionEvent; -import android.view.View; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -import com.b44t.messenger.AndroidUtilities; -import com.b44t.messenger.LocaleController; -import com.b44t.messenger.R; -import com.b44t.ui.Components.LayoutHelper; - -public class PhotoPickerSearchCell extends LinearLayout { - - public interface PhotoPickerSearchCellDelegate { - void didPressedSearchButton(int index); - } - - private class SearchButton extends FrameLayout { - - private TextView textView1; - private TextView textView2; - private ImageView imageView; - private View selector; - - public SearchButton(Context context) { - super(context); - - setBackgroundColor(0xff1a1a1a); - - selector = new View(context); - selector.setBackgroundResource(R.drawable.list_selector); - addView(selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); - - imageView = new ImageView(context); - imageView.setScaleType(ImageView.ScaleType.CENTER); - addView(imageView, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP)); - - textView1 = new TextView(context); - textView1.setGravity(Gravity.CENTER_VERTICAL); - textView1.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - textView1.setTextColor(0xffffffff); - textView1.setSingleLine(true); - textView1.setEllipsize(TextUtils.TruncateAt.END); - addView(textView1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 51, 8, 4, 0)); - - textView2 = new TextView(context); - textView2.setGravity(Gravity.CENTER_VERTICAL); - textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10); - textView2.setTextColor(0xff666666); - textView2.setSingleLine(true); - textView2.setEllipsize(TextUtils.TruncateAt.END); - addView(textView2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 51, 26, 4, 0)); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - if (Build.VERSION.SDK_INT >= 21) { - selector.drawableHotspotChanged(event.getX(), event.getY()); - } - return super.onTouchEvent(event); - } - } - - private PhotoPickerSearchCellDelegate delegate; - - public PhotoPickerSearchCell(Context context, boolean allowGifs) { - super(context); - setOrientation(HORIZONTAL); - - SearchButton searchButton = new SearchButton(context); - searchButton.textView1.setText(LocaleController.getString("SearchImages", R.string.SearchImages)); - searchButton.textView2.setText(LocaleController.getString("SearchImagesInfo", R.string.SearchImagesInfo)); - searchButton.imageView.setImageResource(R.drawable.search_web); - addView(searchButton); - LayoutParams layoutParams = (LayoutParams) searchButton.getLayoutParams(); - layoutParams.weight = 0.5f; - layoutParams.topMargin = AndroidUtilities.dp(4); - layoutParams.height = AndroidUtilities.dp(48); - layoutParams.width = 0; - searchButton.setLayoutParams(layoutParams); - searchButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (delegate != null) { - delegate.didPressedSearchButton(0); - } - } - }); - - FrameLayout frameLayout = new FrameLayout(context); - frameLayout.setBackgroundColor(0); - addView(frameLayout); - layoutParams = (LayoutParams) frameLayout.getLayoutParams(); - layoutParams.topMargin = AndroidUtilities.dp(4); - layoutParams.height = AndroidUtilities.dp(48); - layoutParams.width = AndroidUtilities.dp(4); - frameLayout.setLayoutParams(layoutParams); - - searchButton = new SearchButton(context); - searchButton.textView1.setText(LocaleController.getString("SearchGifs", R.string.SearchGifs)); - searchButton.textView2.setText("GIPHY"); - searchButton.imageView.setImageResource(R.drawable.search_gif); - addView(searchButton); - layoutParams = (LayoutParams) searchButton.getLayoutParams(); - layoutParams.weight = 0.5f; - layoutParams.topMargin = AndroidUtilities.dp(4); - layoutParams.height = AndroidUtilities.dp(48); - layoutParams.width = 0; - searchButton.setLayoutParams(layoutParams); - if (allowGifs) { - searchButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (delegate != null) { - delegate.didPressedSearchButton(1); - } - } - }); - } else { - searchButton.setAlpha(0.5f); - } - } - - public void setDelegate(PhotoPickerSearchCellDelegate delegate) { - this.delegate = delegate; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(52), MeasureSpec.EXACTLY)); - } -} diff --git a/MessengerProj/src/main/java/com/b44t/ui/ChatActivity.java b/MessengerProj/src/main/java/com/b44t/ui/ChatActivity.java index 1df676911..9e007b082 100644 --- a/MessengerProj/src/main/java/com/b44t/ui/ChatActivity.java +++ b/MessengerProj/src/main/java/com/b44t/ui/ChatActivity.java @@ -1205,17 +1205,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4); return; } - PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(false, true, ChatActivity.this); + PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(false, ChatActivity.this); fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() { @Override - public void didSelectPhotos(ArrayList photos, ArrayList captions, ArrayList webPhotos) { + public void didSelectPhotos(ArrayList photos, ArrayList captions) { SendMessagesHelper.prepareSendingPhotos(photos, null, dialog_id, captions); - SendMessagesHelper.prepareSendingPhotosSearch(webPhotos, dialog_id); m_mrChat.cleanDraft(); } @Override public void startPhotoSelectActivity() { + /* -- this is the fallback implementation of the gallery selection, see ID_OPEN_SYSTEM_SELECTOR try { Intent videoPickerIntent = new Intent(); videoPickerIntent.setType("video/*"); @@ -1230,7 +1230,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not startActivityForResult(chooserIntent, RC1_CHAT_PICK); } catch (Exception e) { FileLog.e("messenger", e); - } + } */ } @Override @@ -1717,6 +1717,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not AndroidUtilities.addMediaToGallery(currentPicturePath); currentPicturePath = null; } else if (requestCode == RC1_CHAT_PICK) { + /* -- this is the fallback implementation of the gallery selection, see ID_OPEN_SYSTEM_SELECTOR if (data == null || data.getData() == null) { showAttachmentError(); return; @@ -1744,7 +1745,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else { SendMessagesHelper.prepareSendingPhoto(null, uri, dialog_id, null); } - m_mrChat.cleanDraft(); + m_mrChat.cleanDraft(); */ } else if (requestCode == RC2_CHAT_VIDEO_CAPTURE) { String videoPath = null; FileLog.d("messenger", "pic path " + currentPicturePath); diff --git a/MessengerProj/src/main/java/com/b44t/ui/Components/AvatarUpdater.java b/MessengerProj/src/main/java/com/b44t/ui/Components/AvatarUpdater.java index 826857ff0..ba5360a61 100644 --- a/MessengerProj/src/main/java/com/b44t/ui/Components/AvatarUpdater.java +++ b/MessengerProj/src/main/java/com/b44t/ui/Components/AvatarUpdater.java @@ -97,10 +97,10 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg return; } } - PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(true, false, null); + PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(true, null); fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() { @Override - public void didSelectPhotos(ArrayList photos, ArrayList captions, ArrayList webPhotos) { + public void didSelectPhotos(ArrayList photos, ArrayList captions) { if (!photos.isEmpty()) { Bitmap bitmap = ImageLoader.loadBitmap(photos.get(0), null, 800, 800, true); processBitmap(bitmap); @@ -109,13 +109,14 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg @Override public void startPhotoSelectActivity() { + /* -- this is the fallback implementation of the gallery selection, see ID_OPEN_SYSTEM_SELECTOR try { Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT); photoPickerIntent.setType("image/*"); parentFragment.startActivityForResult(photoPickerIntent, BaseFragment.RC14_AVATAR_GET_CONTENT); } catch (Exception e) { FileLog.e("messenger", e); - } + } */ } @Override @@ -189,10 +190,11 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg AndroidUtilities.addMediaToGallery(currentPicturePath); currentPicturePath = null; } else if (requestCode == BaseFragment.RC14_AVATAR_GET_CONTENT) { + /* -- this is the fallback implementation of the gallery selection, see ID_OPEN_SYSTEM_SELECTOR if (data == null || data.getData() == null) { return; } - startCrop(null, data.getData()); + startCrop(null, data.getData()); */ } } } diff --git a/MessengerProj/src/main/java/com/b44t/ui/PhotoAlbumPickerActivity.java b/MessengerProj/src/main/java/com/b44t/ui/PhotoAlbumPickerActivity.java index 36105ab6b..e7a791e47 100644 --- a/MessengerProj/src/main/java/com/b44t/ui/PhotoAlbumPickerActivity.java +++ b/MessengerProj/src/main/java/com/b44t/ui/PhotoAlbumPickerActivity.java @@ -54,7 +54,6 @@ import com.b44t.ui.ActionBar.BaseFragment; import com.b44t.ui.ActionBar.Theme; import com.b44t.ui.Adapters.BaseFragmentAdapter; import com.b44t.ui.Cells.PhotoPickerAlbumsCell; -import com.b44t.ui.Cells.PhotoPickerSearchCell; import com.b44t.ui.Components.LayoutHelper; import com.b44t.ui.Components.PickerBottomLayout; @@ -64,7 +63,7 @@ import java.util.HashMap; public class PhotoAlbumPickerActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { public interface PhotoAlbumPickerActivityDelegate { - void didSelectPhotos(ArrayList photos, ArrayList captions, ArrayList webPhotos); + void didSelectPhotos(ArrayList photos, ArrayList captions); boolean didSelectVideo(String path); void startPhotoSelectActivity(); } @@ -72,11 +71,6 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati private ArrayList albumsSorted = null; private ArrayList videoAlbumsSorted = null; private HashMap selectedPhotos = new HashMap<>(); - private HashMap selectedWebPhotos = new HashMap<>(); - private HashMap recentImagesWebKeys = new HashMap<>(); - private HashMap recentImagesGifKeys = new HashMap<>(); - private ArrayList recentWebImages = new ArrayList<>(); - private ArrayList recentGifImages = new ArrayList<>(); private boolean loading = false; private int columnsCount = 2; @@ -89,7 +83,6 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati private PickerBottomLayout pickerBottomLayout; private boolean sendPressed; private boolean singlePhoto; - private boolean allowGifs; private final static int SELECTMODE0_PHOTOS = 0; private final static int SELECTMODE1_VIDEOS = 1; @@ -99,14 +92,14 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati private PhotoAlbumPickerActivityDelegate delegate; - private final static int item_photos = 2; - private final static int item_video = 3; + private final static int ID_OPEN_SYSTEM_SELECTOR = 1; + private final static int ID_ITEM_PHOTOS = 2; + private final static int ID_ITEM_VIDEO = 3; - public PhotoAlbumPickerActivity(boolean singlePhoto, boolean allowGifs, ChatActivity chatActivity) { + public PhotoAlbumPickerActivity(boolean singlePhoto, ChatActivity chatActivity) { super(); this.chatActivity = chatActivity; this.singlePhoto = singlePhoto; - this.allowGifs = allowGifs; } @Override @@ -114,7 +107,6 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati loading = true; MediaController.loadGalleryPhotosAlbums(classGuid); NotificationCenter.getInstance().addObserver(this, NotificationCenter.albumsDidLoaded); - NotificationCenter.getInstance().addObserver(this, NotificationCenter.recentImagesDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeChats); return super.onFragmentCreate(); } @@ -122,7 +114,6 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati @Override public void onFragmentDestroy() { NotificationCenter.getInstance().removeObserver(this, NotificationCenter.albumsDidLoaded); - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.recentImagesDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats); super.onFragmentDestroy(); } @@ -136,12 +127,12 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati public void onItemClick(int id) { if (id == -1) { finishFragment(); - } else if (id == 1) { + } else if (id == ID_OPEN_SYSTEM_SELECTOR) { if (delegate != null) { finishFragment(false); delegate.startPhotoSelectActivity(); } - } else if (id == item_photos) { + } else if (id == ID_ITEM_PHOTOS) { if (selectedMode == SELECTMODE0_PHOTOS) { return; } @@ -149,7 +140,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati dropDown.setText(LocaleController.getString("PickerPhotos", R.string.PickerPhotos)); emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos)); listAdapter.notifyDataSetChanged(); - } else if (id == item_video) { + } else if (id == ID_ITEM_VIDEO) { if (selectedMode == SELECTMODE1_VIDEOS) { return; } @@ -162,7 +153,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati }); ActionBarMenu menu = actionBar.createMenu(); - menu.addItem(1, R.drawable.ic_ab_other); + //menu.addItem(ID_OPEN_SYSTEM_SELECTOR, R.drawable.ic_ab_other); -- fallback-selector not needed fragmentView = new FrameLayout(context); @@ -174,8 +165,8 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati dropDownContainer = new ActionBarMenuItem(context, menu, 0); dropDownContainer.setSubMenuOpenSide(1); - dropDownContainer.addSubItem(item_photos, LocaleController.getString("PickerPhotos", R.string.PickerPhotos), 0); - dropDownContainer.addSubItem(item_video, LocaleController.getString("PickerVideo", R.string.PickerVideo), 0); + dropDownContainer.addSubItem(ID_ITEM_PHOTOS, LocaleController.getString("PickerPhotos", R.string.PickerPhotos), 0); + dropDownContainer.addSubItem(ID_ITEM_VIDEO, LocaleController.getString("PickerVideo", R.string.PickerVideo), 0); actionBar.addView(dropDownContainer); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams(); layoutParams.height = LayoutHelper.MATCH_PARENT; @@ -296,7 +287,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati progressView.setVisibility(View.GONE); listView.setEmptyView(emptyView); } - pickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true); + pickerBottomLayout.updateSelectedCount(selectedPhotos.size(), true); View shadow = new View(context); shadow.setBackgroundResource(R.drawable.header_shadow_reverse); @@ -349,21 +340,6 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati } } else if (id == NotificationCenter.closeChats) { removeSelfFromStack(); - } else if (id == NotificationCenter.recentImagesDidLoaded) { - int type = (Integer) args[0]; - if (type == 0) { - recentWebImages = (ArrayList) args[1]; - recentImagesWebKeys.clear(); - for (MediaController.SearchImage searchImage : recentWebImages) { - recentImagesWebKeys.put(searchImage.id, searchImage); - } - } else if (type == 1) { - recentGifImages = (ArrayList) args[1]; - recentImagesGifKeys.clear(); - for (MediaController.SearchImage searchImage : recentGifImages) { - recentImagesGifKeys.put(searchImage.id, searchImage); - } - } } } @@ -372,7 +348,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati } private void sendSelectedPhotos() { - if (selectedPhotos.isEmpty() && selectedWebPhotos.isEmpty() || delegate == null || sendPressed) { + if (selectedPhotos.isEmpty() || delegate == null || sendPressed) { return; } sendPressed = true; @@ -388,47 +364,8 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati captions.add(photoEntry.caption != null ? photoEntry.caption.toString() : null); } } - ArrayList webPhotos = new ArrayList<>(); - boolean gifChanged = false; - boolean webChange = false; - for (HashMap.Entry entry : selectedWebPhotos.entrySet()) { - MediaController.SearchImage searchImage = entry.getValue(); - if (searchImage.imagePath != null) { - photos.add(searchImage.imagePath); - captions.add(searchImage.caption != null ? searchImage.caption.toString() : null); - } else { - webPhotos.add(searchImage); - } - searchImage.date = (int) (System.currentTimeMillis() / 1000); - if (searchImage.type == 0) { - webChange = true; - MediaController.SearchImage recentImage = recentImagesWebKeys.get(searchImage.id); - if (recentImage != null) { - recentWebImages.remove(recentImage); - recentWebImages.add(0, recentImage); - } else { - recentWebImages.add(0, searchImage); - } - } else if (searchImage.type == 1) { - gifChanged = true; - MediaController.SearchImage recentImage = recentImagesGifKeys.get(searchImage.id); - if (recentImage != null) { - recentGifImages.remove(recentImage); - recentGifImages.add(0, recentImage); - } else { - recentGifImages.add(0, searchImage); - } - } - } - if (webChange) { - //MessagesStorage.getInstance().putWebRecent(recentWebImages); - } - if (gifChanged) { - //MessagesStorage.getInstance().putWebRecent(recentGifImages); - } - - delegate.didSelectPhotos(photos, captions, webPhotos); + delegate.didSelectPhotos(photos, captions); } private void fixLayout() { @@ -475,21 +412,16 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati } } - private void openPhotoPicker(MediaController.AlbumEntry albumEntry, int type) { - ArrayList recentImages = null; - if (albumEntry == null) { - if (type == PhotoPickerActivity.TYPE0_SEARCH_IMAGES) { - recentImages = recentWebImages; - } else if (type == PhotoPickerActivity.TYPE1_SEARCH_GIF) { - recentImages = recentGifImages; - } + private void openPhotoPicker(MediaController.AlbumEntry albumEntry) { + if( albumEntry == null ) { + return; } - PhotoPickerActivity fragment = new PhotoPickerActivity(type, albumEntry, selectedPhotos, selectedWebPhotos, recentImages, singlePhoto, chatActivity); + PhotoPickerActivity fragment = new PhotoPickerActivity(albumEntry, selectedPhotos, singlePhoto, chatActivity); fragment.setDelegate(new PhotoPickerActivity.PhotoPickerActivityDelegate() { @Override public void selectedPhotosChanged() { if (pickerBottomLayout != null) { - pickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true); + pickerBottomLayout.updateSelectedCount(selectedPhotos.size(), true); } } @@ -530,10 +462,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati @Override public int getCount() { if (singlePhoto || selectedMode == SELECTMODE0_PHOTOS) { - if (singlePhoto) { - return albumsSorted != null ? (int) Math.ceil(albumsSorted.size() / (float) columnsCount) : 0; - } - return 1 + (albumsSorted != null ? (int) Math.ceil(albumsSorted.size() / (float) columnsCount) : 0); + return (albumsSorted != null ? (int) Math.ceil(albumsSorted.size() / (float) columnsCount) : 0); } else { return (videoAlbumsSorted != null ? (int) Math.ceil(videoAlbumsSorted.size() / (float) columnsCount) : 0); } @@ -565,7 +494,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati photoPickerAlbumsCell.setDelegate(new PhotoPickerAlbumsCell.PhotoPickerAlbumsCellDelegate() { @Override public void didSelectAlbum(MediaController.AlbumEntry albumEntry) { - openPhotoPicker(albumEntry, PhotoPickerActivity.TYPE0_SEARCH_IMAGES); + openPhotoPicker(albumEntry); } }); } else { @@ -573,12 +502,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati } photoPickerAlbumsCell.setAlbumsCount(columnsCount); for (int a = 0; a < columnsCount; a++) { - int index; - if (singlePhoto || selectedMode == SELECTMODE1_VIDEOS) { - index = i * columnsCount + a; - } else { - index = (i - 1) * columnsCount + a; - } + int index = i * columnsCount + a; if (singlePhoto || selectedMode == SELECTMODE0_PHOTOS) { if (index < albumsSorted.size()) { MediaController.AlbumEntry albumEntry = albumsSorted.get(index); @@ -596,37 +520,18 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati } } photoPickerAlbumsCell.requestLayout(); - } else if (type == 1) { - if (view == null) { - view = new PhotoPickerSearchCell(mContext, allowGifs); - ((PhotoPickerSearchCell) view).setDelegate(new PhotoPickerSearchCell.PhotoPickerSearchCellDelegate() { - @Override - public void didPressedSearchButton(int index) { - openPhotoPicker(null, index); - } - }); - } } return view; } @Override public int getItemViewType(int i) { - if (singlePhoto || selectedMode == SELECTMODE1_VIDEOS) { - return 0; - } - if (i == 0) { - return 1; - } return 0; } @Override public int getViewTypeCount() { - if (singlePhoto || selectedMode == SELECTMODE1_VIDEOS) { - return 1; - } - return 2; + return 1; } @Override diff --git a/MessengerProj/src/main/java/com/b44t/ui/PhotoPickerActivity.java b/MessengerProj/src/main/java/com/b44t/ui/PhotoPickerActivity.java index 1d52c7daf..a8ef9fef1 100644 --- a/MessengerProj/src/main/java/com/b44t/ui/PhotoPickerActivity.java +++ b/MessengerProj/src/main/java/com/b44t/ui/PhotoPickerActivity.java @@ -27,34 +27,25 @@ import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.view.Gravity; -import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.WindowManager; -import android.widget.AbsListView; import android.widget.AdapterView; -import android.widget.EditText; import android.widget.FrameLayout; import android.widget.GridView; -import android.widget.ProgressBar; import android.widget.TextView; import com.b44t.messenger.AndroidUtilities; -import com.b44t.messenger.FileLoader; import com.b44t.messenger.LocaleController; import com.b44t.messenger.MediaController; import com.b44t.messenger.NotificationCenter; -import com.b44t.messenger.volley.RequestQueue; -import com.b44t.messenger.volley.toolbox.Volley; import com.b44t.messenger.ApplicationLoader; import com.b44t.messenger.R; import com.b44t.messenger.TLRPC; import com.b44t.messenger.MessageObject; -import com.b44t.ui.ActionBar.ActionBarMenu; -import com.b44t.ui.ActionBar.ActionBarMenuItem; import com.b44t.ui.ActionBar.Theme; import com.b44t.ui.Adapters.BaseFragmentAdapter; import com.b44t.ui.ActionBar.ActionBar; @@ -77,37 +68,13 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen boolean didSelectVideo(String path); } - private RequestQueue requestQueue; - - public final static int TYPE0_SEARCH_IMAGES = 0; - public final static int TYPE1_SEARCH_GIF = 1; - private int type; - - private HashMap selectedWebPhotos; private HashMap selectedPhotos; - private ArrayList recentImages; - - private ArrayList searchResult = new ArrayList<>(); - private HashMap searchResultKeys = new HashMap<>(); - private HashMap searchResultUrls = new HashMap<>(); - - private boolean searching; - private String nextSearchBingString; - private boolean giphySearchEndReached = true; - private String lastSearchString; - private boolean loadingRecent; - private int nextGiphySearchOffset; - private int giphyReqId; - private int lastSearchToken; private MediaController.AlbumEntry selectedAlbum; private GridView listView; private ListAdapter listAdapter; private PickerBottomLayout pickerBottomLayout; - private FrameLayout progressView; - private TextView emptyView; - private ActionBarMenuItem searchItem; private int itemWidth = 100; private boolean sendPressed; private boolean singlePhoto; @@ -115,16 +82,13 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen private PhotoPickerActivityDelegate delegate; - public PhotoPickerActivity(int type, MediaController.AlbumEntry selectedAlbum, HashMap selectedPhotos, HashMap selectedWebPhotos, ArrayList recentImages, boolean onlyOnePhoto, ChatActivity chatActivity) { + public PhotoPickerActivity(MediaController.AlbumEntry selectedAlbum, HashMap selectedPhotos, boolean onlyOnePhoto, ChatActivity chatActivity) { super(); - this.selectedAlbum = selectedAlbum; + this.selectedAlbum = selectedAlbum; // must never be null this.selectedPhotos = selectedPhotos; - this.selectedWebPhotos = selectedWebPhotos; - this.type = type; - this.recentImages = recentImages; this.singlePhoto = onlyOnePhoto; this.chatActivity = chatActivity; - if (selectedAlbum != null && selectedAlbum.isVideo) { + if (selectedAlbum.isVideo) { singlePhoto = true; } } @@ -132,25 +96,12 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen @Override public boolean onFragmentCreate() { NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeChats); - NotificationCenter.getInstance().addObserver(this, NotificationCenter.recentImagesDidLoaded); - if (selectedAlbum == null) { - requestQueue = Volley.newRequestQueue(ApplicationLoader.applicationContext); - if (recentImages.isEmpty()) { - //MessagesStorage.getInstance().loadWebRecent(type); - loadingRecent = true; - } - } return super.onFragmentCreate(); } @Override public void onFragmentDestroy() { NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats); - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.recentImagesDidLoaded); - if (requestQueue != null) { - requestQueue.cancelAll("search"); - requestQueue.stop(); - } super.onFragmentDestroy(); } @@ -158,13 +109,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen @Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); - if (selectedAlbum != null) { - actionBar.setTitle(selectedAlbum.bucketName); - } else if (type == TYPE0_SEARCH_IMAGES) { - actionBar.setTitle(LocaleController.getString("SearchImagesTitle", R.string.SearchImagesTitle)); - } else if (type == TYPE1_SEARCH_GIF) { - actionBar.setTitle(LocaleController.getString("SearchGifsTitle", R.string.SearchGifsTitle)); - } + actionBar.setTitle(selectedAlbum.bucketName); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { @@ -174,36 +119,6 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } }); - if (selectedAlbum == null) { - ActionBarMenu menu = actionBar.createMenu(); - searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true, false).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { - @Override - public void onSearchExpand() { - - } - - @Override - public boolean canCollapseSearch() { - finishFragment(); - return false; - } - - @Override - public void onSearchPressed(EditText editText) { - // Telegram-FOSS doesn't support searching with external engines (privacy issues) - return; - } - }); - } - - if (selectedAlbum == null) { - if (type == TYPE0_SEARCH_IMAGES) { - searchItem.getSearchField().setHint(LocaleController.getString("SearchImagesTitle", R.string.SearchImagesTitle)); - } else if (type == TYPE1_SEARCH_GIF) { - searchItem.getSearchField().setHint(LocaleController.getString("SearchGifsTitle", R.string.SearchGifsTitle)); - } - } - fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; @@ -231,7 +146,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { - if (selectedAlbum != null && selectedAlbum.isVideo) { + if (selectedAlbum.isVideo) { if (i < 0 || i >= selectedAlbum.photos.size()) { return; } @@ -239,52 +154,23 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen finishFragment(); } } else { - ArrayList arrayList; - if (selectedAlbum != null) { - arrayList = (ArrayList) selectedAlbum.photos; - } else { - if (searchResult.isEmpty() && lastSearchString == null) { - arrayList = (ArrayList) recentImages; - } else { - arrayList = (ArrayList) searchResult; - } - } + ArrayList arrayList = (ArrayList) selectedAlbum.photos; if (i < 0 || i >= arrayList.size()) { return; } - if (searchItem != null) { - AndroidUtilities.hideKeyboard(searchItem.getSearchField()); - } PhotoViewer.getInstance().setParentActivity(getParentActivity()); PhotoViewer.getInstance().openPhotoForSelect(arrayList, i, singlePhoto ? 1 : 0, PhotoPickerActivity.this, chatActivity); } } }); - if (selectedAlbum == null) { - listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { - @Override - public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { - // Telegram-FOSS doesn't support searching with external engines (privacy issues) - return false; - } - }); - } - - emptyView = new TextView(context); + TextView emptyView = new TextView(context); emptyView.setTextColor(0xff808080); emptyView.setTextSize(20); emptyView.setGravity(Gravity.CENTER); emptyView.setVisibility(View.GONE); - if (selectedAlbum != null) { - emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos)); - } else { - if (type == TYPE0_SEARCH_IMAGES) { - emptyView.setText(LocaleController.getString("NoRecentPhotos", R.string.NoRecentPhotos)); - } else if (type == TYPE1_SEARCH_GIF) { - emptyView.setText(LocaleController.getString("NoRecentGIFs", R.string.NoRecentGIFs)); - } - } + emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos)); + frameLayout.addView(emptyView); layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; @@ -298,42 +184,6 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } }); - if (selectedAlbum == null) { - listView.setOnScrollListener(new AbsListView.OnScrollListener() { - @Override - public void onScrollStateChanged(AbsListView absListView, int i) { - if (i == SCROLL_STATE_TOUCH_SCROLL) { - AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus()); - } - } - - @Override - public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { - // Telegram-FOSS doesn't support searching with external engines (privacy issues) - return; - } - }); - - progressView = new FrameLayout(context); - progressView.setVisibility(View.GONE); - frameLayout.addView(progressView); - layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); - layoutParams.width = LayoutHelper.MATCH_PARENT; - layoutParams.height = LayoutHelper.MATCH_PARENT; - layoutParams.bottomMargin = singlePhoto ? 0 : AndroidUtilities.dp(48); - progressView.setLayoutParams(layoutParams); - - ProgressBar progressBar = new ProgressBar(context); - progressView.addView(progressBar); - layoutParams = (FrameLayout.LayoutParams) progressBar.getLayoutParams(); - layoutParams.width = LayoutHelper.WRAP_CONTENT; - layoutParams.height = LayoutHelper.WRAP_CONTENT; - layoutParams.gravity = Gravity.CENTER; - progressBar.setLayoutParams(layoutParams); - - updateSearchInterface(); - } - pickerBottomLayout = new PickerBottomLayout(context, false); frameLayout.addView(pickerBottomLayout); layoutParams = (FrameLayout.LayoutParams) pickerBottomLayout.getLayoutParams(); @@ -359,7 +209,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } listView.setEmptyView(emptyView); - pickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true); + pickerBottomLayout.updateSelectedCount(selectedPhotos.size(), true); View shadow = new View(context); shadow.setBackgroundResource(R.drawable.header_shadow_reverse); @@ -374,10 +224,6 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } - if (searchItem != null) { - searchItem.openSearch(true); - getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); - } fixLayout(); } @@ -392,12 +238,6 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen public void didReceivedNotification(int id, Object... args) { if (id == NotificationCenter.closeChats) { removeSelfFromStack(); - } else if (id == NotificationCenter.recentImagesDidLoaded) { - if (selectedAlbum == null && type == (Integer) args[0]) { - recentImages = (ArrayList) args[1]; - loadingRecent = false; - updateSearchInterface(); - } } } @@ -409,21 +249,10 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen if (view instanceof PhotoPickerPhotoCell) { PhotoPickerPhotoCell cell = (PhotoPickerPhotoCell) view; int num = (Integer) cell.photoImage.getTag(); - if (selectedAlbum != null) { - if (num < 0 || num >= selectedAlbum.photos.size()) { - continue; - } - } else { - ArrayList array; - if (searchResult.isEmpty() && lastSearchString == null) { - array = recentImages; - } else { - array = searchResult; - } - if (num < 0 || num >= array.size()) { - continue; - } + if (num < 0 || num >= selectedAlbum.photos.size()) { + continue; } + if (num == index) { return cell; } @@ -455,7 +284,6 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen public void updatePhotoAtIndex(int index) { PhotoPickerPhotoCell cell = getCellForIndex(index); if (cell != null) { - if (selectedAlbum != null) { cell.photoImage.setOrientation(0, true); MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index); if (photoEntry.thumbPath != null) { @@ -470,24 +298,6 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } else { cell.photoImage.setImageResource(R.drawable.nophotos); } - } else { - ArrayList array; - if (searchResult.isEmpty() && lastSearchString == null) { - array = recentImages; - } else { - array = searchResult; - } - MediaController.SearchImage photoEntry = array.get(index); - if (photoEntry.document != null && photoEntry.document.thumb != null) { - cell.photoImage.setImage(photoEntry.document.thumb.location, null, cell.getContext().getResources().getDrawable(R.drawable.nophotos)); - } else if (photoEntry.thumbPath != null) { - cell.photoImage.setImage(photoEntry.thumbPath, null, cell.getContext().getResources().getDrawable(R.drawable.nophotos)); - } else if (photoEntry.thumbUrl != null && photoEntry.thumbUrl.length() > 0) { - cell.photoImage.setImage(photoEntry.thumbUrl, null, cell.getContext().getResources().getDrawable(R.drawable.nophotos)); - } else { - cell.photoImage.setImageResource(R.drawable.nophotos); - } - } } } @@ -510,21 +320,9 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } PhotoPickerPhotoCell cell = (PhotoPickerPhotoCell) view; int num = (Integer) view.getTag(); - if (selectedAlbum != null) { if (num < 0 || num >= selectedAlbum.photos.size()) { continue; } - } else { - ArrayList array; - if (searchResult.isEmpty() && lastSearchString == null) { - array = recentImages; - } else { - array = searchResult; - } - if (num < 0 || num >= array.size()) { - continue; - } - } if (num == index) { cell.checkBox.setVisibility(View.VISIBLE); break; @@ -541,23 +339,12 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen @Override public boolean isPhotoChecked(int index) { - if (selectedAlbum != null) { return !(index < 0 || index >= selectedAlbum.photos.size()) && selectedPhotos.containsKey(selectedAlbum.photos.get(index).imageId); - } else { - ArrayList array; - if (searchResult.isEmpty() && lastSearchString == null) { - array = recentImages; - } else { - array = searchResult; - } - return !(index < 0 || index >= array.size()) && selectedWebPhotos.containsKey(array.get(index).id); - } } @Override public void setPhotoChecked(int index) { boolean add = true; - if (selectedAlbum != null) { if (index < 0 || index >= selectedAlbum.photos.size()) { return; } @@ -568,25 +355,6 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } else { selectedPhotos.put(photoEntry.imageId, photoEntry); } - } else { - MediaController.SearchImage photoEntry; - ArrayList array; - if (searchResult.isEmpty() && lastSearchString == null) { - array = recentImages; - } else { - array = searchResult; - } - if (index < 0 || index >= array.size()) { - return; - } - photoEntry = array.get(index); - if (selectedWebPhotos.containsKey(photoEntry.id)) { - selectedWebPhotos.remove(photoEntry.id); - add = false; - } else { - selectedWebPhotos.put(photoEntry.id, photoEntry); - } - } int count = listView.getChildCount(); for (int a = 0; a < count; a++) { View view = listView.getChildAt(a); @@ -596,7 +364,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen break; } } - pickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true); + pickerBottomLayout.updateSelectedCount(selectedPhotos.size(), true); delegate.selectedPhotosChanged(); } @@ -609,7 +377,6 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen @Override public void sendButtonPressed(int index) { - if (selectedAlbum != null) { if (selectedPhotos.isEmpty()) { if (index < 0 || index >= selectedAlbum.photos.size()) { return; @@ -617,47 +384,12 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index); selectedPhotos.put(photoEntry.imageId, photoEntry); } - } else if (selectedPhotos.isEmpty()) { - ArrayList array; - if (searchResult.isEmpty() && lastSearchString == null) { - array = recentImages; - } else { - array = searchResult; - } - if (index < 0 || index >= array.size()) { - return; - } - MediaController.SearchImage photoEntry = array.get(index); - selectedWebPhotos.put(photoEntry.id, photoEntry); - } sendSelectedPhotos(); } @Override public int getSelectedCount() { - return selectedPhotos.size() + selectedWebPhotos.size(); - } - - @Override - public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { - if (isOpen && searchItem != null) { - AndroidUtilities.showKeyboard(searchItem.getSearchField()); - } - } - - private void updateSearchInterface() { - if (listAdapter != null) { - listAdapter.notifyDataSetChanged(); - } - if (searching && searchResult.isEmpty() || loadingRecent && lastSearchString == null) { - progressView.setVisibility(View.VISIBLE); - listView.setEmptyView(null); - emptyView.setVisibility(View.GONE); - } else { - progressView.setVisibility(View.GONE); - emptyView.setVisibility(View.VISIBLE); - listView.setEmptyView(emptyView); - } + return selectedPhotos.size(); } public void setDelegate(PhotoPickerActivityDelegate delegate) { @@ -665,7 +397,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } private void sendSelectedPhotos() { - if (selectedPhotos.isEmpty() && selectedWebPhotos.isEmpty() || delegate == null || sendPressed) { + if (selectedPhotos.isEmpty() || delegate == null || sendPressed) { return; } sendPressed = true; @@ -717,10 +449,6 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen listAdapter.notifyDataSetChanged(); listView.setSelection(position); - - if (selectedAlbum == null) { - emptyView.setPadding(0, 0, 0, (int) ((AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight()) * 0.4f)); - } } private class ListAdapter extends BaseFragmentAdapter { @@ -732,32 +460,16 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen @Override public boolean areAllItemsEnabled() { - return selectedAlbum != null; + return true; } @Override public boolean isEnabled(int i) { - if (selectedAlbum == null) { - if (searchResult.isEmpty() && lastSearchString == null) { - return i < recentImages.size(); - } else { - return i < searchResult.size(); - } - } return true; } @Override public int getCount() { - if (selectedAlbum == null) { - if (searchResult.isEmpty() && lastSearchString == null) { - return recentImages.size(); - } else if (type == TYPE0_SEARCH_IMAGES) { - return searchResult.size() + (nextSearchBingString == null ? 0 : 1); - } else if (type == TYPE1_SEARCH_GIF) { - return searchResult.size() + (giphySearchEndReached ? 0 : 1); - } - } return selectedAlbum.photos.size(); } @@ -778,8 +490,6 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen @Override public View getView(int i, View view, ViewGroup viewGroup) { - int viewType = getItemViewType(i); - if (viewType == 0) { PhotoPickerPhotoCell cell = (PhotoPickerPhotoCell) view; if (view == null) { view = new PhotoPickerPhotoCell(mContext); @@ -788,7 +498,6 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen @Override public void onClick(View v) { int index = (Integer) ((View) v.getParent()).getTag(); - if (selectedAlbum != null) { MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index); if (selectedPhotos.containsKey(photoEntry.imageId)) { selectedPhotos.remove(photoEntry.imageId); @@ -799,25 +508,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen selectedPhotos.put(photoEntry.imageId, photoEntry); } ((PhotoPickerPhotoCell) v.getParent()).setChecked(selectedPhotos.containsKey(photoEntry.imageId), true); - } else { - AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus()); - MediaController.SearchImage photoEntry; - if (searchResult.isEmpty() && lastSearchString == null) { - photoEntry = recentImages.get((Integer) ((View) v.getParent()).getTag()); - } else { - photoEntry = searchResult.get((Integer) ((View) v.getParent()).getTag()); - } - if (selectedWebPhotos.containsKey(photoEntry.id)) { - selectedWebPhotos.remove(photoEntry.id); - photoEntry.imagePath = null; - photoEntry.thumbPath = null; - updatePhotoAtIndex(index); - } else { - selectedWebPhotos.put(photoEntry.id, photoEntry); - } - ((PhotoPickerPhotoCell) v.getParent()).setChecked(selectedWebPhotos.containsKey(photoEntry.id), true); - } - pickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true); + pickerBottomLayout.updateSelectedCount(selectedPhotos.size(), true); delegate.selectedPhotosChanged(); } }); @@ -830,7 +521,6 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen boolean showing; imageView.setOrientation(0, true); - if (selectedAlbum != null) { MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(i); if (photoEntry.thumbPath != null) { imageView.setImage(photoEntry.thumbPath, null, mContext.getResources().getDrawable(R.drawable.nophotos)); @@ -846,68 +536,24 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } cell.setChecked(selectedPhotos.containsKey(photoEntry.imageId), false); showing = PhotoViewer.getInstance().isShowingImage(photoEntry.path); - } else { - MediaController.SearchImage photoEntry; - if (searchResult.isEmpty() && lastSearchString == null) { - photoEntry = recentImages.get(i); - } else { - photoEntry = searchResult.get(i); - } - if (photoEntry.thumbPath != null) { - imageView.setImage(photoEntry.thumbPath, null, mContext.getResources().getDrawable(R.drawable.nophotos)); - } else if (photoEntry.thumbUrl != null && photoEntry.thumbUrl.length() > 0) { - imageView.setImage(photoEntry.thumbUrl, null, mContext.getResources().getDrawable(R.drawable.nophotos)); - } else if (photoEntry.document != null && photoEntry.document.thumb != null) { - imageView.setImage(photoEntry.document.thumb.location, null, mContext.getResources().getDrawable(R.drawable.nophotos)); - } else { - imageView.setImageResource(R.drawable.nophotos); - } - cell.setChecked(selectedWebPhotos.containsKey(photoEntry.id), false); - if (photoEntry.document != null) { - showing = PhotoViewer.getInstance().isShowingImage(FileLoader.getPathToAttach(photoEntry.document, true).getAbsolutePath()); - } else { - showing = PhotoViewer.getInstance().isShowingImage(photoEntry.imageUrl); - } - } imageView.getImageReceiver().setVisible(!showing, true); cell.checkBox.setVisibility(singlePhoto || showing ? View.GONE : View.VISIBLE); - } else if (viewType == 1) { - if (view == null) { - LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = li.inflate(R.layout.media_loading_layout, viewGroup, false); - } - ViewGroup.LayoutParams params = view.getLayoutParams(); - params.width = itemWidth; - params.height = itemWidth; - view.setLayoutParams(params); - } return view; } @Override public int getItemViewType(int i) { - if (selectedAlbum != null || searchResult.isEmpty() && lastSearchString == null && i < recentImages.size() || i < searchResult.size()) { - return 0; - } - return 1; + return 0; } @Override public int getViewTypeCount() { - return 2; + return 1; } @Override public boolean isEmpty() { - if (selectedAlbum != null) { - return selectedAlbum.photos.isEmpty(); - } else { - if (searchResult.isEmpty() && lastSearchString == null) { - return recentImages.isEmpty(); - } else { - return searchResult.isEmpty(); - } - } + return selectedAlbum.photos.isEmpty(); } } } diff --git a/MessengerProj/src/main/res/drawable-hdpi/search_gif.png b/MessengerProj/src/main/res/drawable-hdpi/search_gif.png deleted file mode 100755 index 3be94584a..000000000 Binary files a/MessengerProj/src/main/res/drawable-hdpi/search_gif.png and /dev/null differ diff --git a/MessengerProj/src/main/res/drawable-hdpi/search_web.png b/MessengerProj/src/main/res/drawable-hdpi/search_web.png deleted file mode 100755 index 900a5303b..000000000 Binary files a/MessengerProj/src/main/res/drawable-hdpi/search_web.png and /dev/null differ diff --git a/MessengerProj/src/main/res/drawable-mdpi/search_gif.png b/MessengerProj/src/main/res/drawable-mdpi/search_gif.png deleted file mode 100755 index 5e8873fa7..000000000 Binary files a/MessengerProj/src/main/res/drawable-mdpi/search_gif.png and /dev/null differ diff --git a/MessengerProj/src/main/res/drawable-mdpi/search_web.png b/MessengerProj/src/main/res/drawable-mdpi/search_web.png deleted file mode 100755 index bab8acf03..000000000 Binary files a/MessengerProj/src/main/res/drawable-mdpi/search_web.png and /dev/null differ diff --git a/MessengerProj/src/main/res/drawable-xhdpi/search_gif.png b/MessengerProj/src/main/res/drawable-xhdpi/search_gif.png deleted file mode 100755 index 5cd150ba3..000000000 Binary files a/MessengerProj/src/main/res/drawable-xhdpi/search_gif.png and /dev/null differ diff --git a/MessengerProj/src/main/res/drawable-xhdpi/search_web.png b/MessengerProj/src/main/res/drawable-xhdpi/search_web.png deleted file mode 100755 index 44532e089..000000000 Binary files a/MessengerProj/src/main/res/drawable-xhdpi/search_web.png and /dev/null differ diff --git a/MessengerProj/src/main/res/drawable-xxhdpi/search_gif.png b/MessengerProj/src/main/res/drawable-xxhdpi/search_gif.png deleted file mode 100755 index d9e7195be..000000000 Binary files a/MessengerProj/src/main/res/drawable-xxhdpi/search_gif.png and /dev/null differ diff --git a/MessengerProj/src/main/res/drawable-xxhdpi/search_web.png b/MessengerProj/src/main/res/drawable-xxhdpi/search_web.png deleted file mode 100755 index 193208c52..000000000 Binary files a/MessengerProj/src/main/res/drawable-xxhdpi/search_web.png and /dev/null differ diff --git a/MessengerProj/src/main/res/values-de/strings.xml b/MessengerProj/src/main/res/values-de/strings.xml index d50563cc0..9bdb92c34 100644 --- a/MessengerProj/src/main/res/values-de/strings.xml +++ b/MessengerProj/src/main/res/values-de/strings.xml @@ -177,13 +177,6 @@ Alle Videos Noch keine Bilder Noch keine Videos - Suchverlauf - Suchverlauf - BILDERSUCHE - BILDERSUCHE - GIF-SUCHE - Suche Bilder - Suche GIFs Bild zuschneiden Bild bearbeiten Verbessern diff --git a/MessengerProj/src/main/res/values-es/strings.xml b/MessengerProj/src/main/res/values-es/strings.xml index 8bf162499..15ca8f185 100644 --- a/MessengerProj/src/main/res/values-es/strings.xml +++ b/MessengerProj/src/main/res/values-es/strings.xml @@ -174,13 +174,6 @@ Todos los vídeos Aún sin fotos Sin vídeos aún - No hay fotos recientes - No hay GIF recientes - BUSCA FOTOS - BÚSQUEDA WEB - BUSCA GIF - Buscar foto - Buscar GIF Recortar imagen Editar imagen Realzar diff --git a/MessengerProj/src/main/res/values-fr/strings.xml b/MessengerProj/src/main/res/values-fr/strings.xml index ea10212a0..62dd783c7 100644 --- a/MessengerProj/src/main/res/values-fr/strings.xml +++ b/MessengerProj/src/main/res/values-fr/strings.xml @@ -172,13 +172,6 @@ Toutes les vidéos Aucune photo pour le moment Aucune vidéo pour le moement - Aucune photo récente - Aucun GIF récent - TROUVER LES IMAGES - RECHERCHER SUR LE WEB - TROUVER DES GIFS - Recherche sur le web - Rechercher des GIF Couper les images Modifier les images Améliorer diff --git a/MessengerProj/src/main/res/values-it/strings.xml b/MessengerProj/src/main/res/values-it/strings.xml index 5bfc30e6f..e2a54a0e9 100644 --- a/MessengerProj/src/main/res/values-it/strings.xml +++ b/MessengerProj/src/main/res/values-it/strings.xml @@ -174,13 +174,6 @@ Tutti i video Ancora nessuna foto Ancora nessun video - Nessuna foto recente - Nessuna GIF recente - CERCA IMMAGINI - RICERCA WEB - CERCA GIF - Cerca su web - Cerca GIF Ritaglia immagine Modifica immagine Migliora diff --git a/MessengerProj/src/main/res/values-nl/strings.xml b/MessengerProj/src/main/res/values-nl/strings.xml index 21d6536d8..2c95f22f1 100644 --- a/MessengerProj/src/main/res/values-nl/strings.xml +++ b/MessengerProj/src/main/res/values-nl/strings.xml @@ -174,13 +174,6 @@ Alle video\'s Nog geen foto\'s Nog geen video\'s - Niets recents - Niets recents - ONLINE ZOEKEN - ZOEK OP HET WEB - GIF\'S ZOEKEN - Online zoeken - GIF\'s zoeken Foto bijsnijden Foto bewerken Verbeteren diff --git a/MessengerProj/src/main/res/values-pl/strings.xml b/MessengerProj/src/main/res/values-pl/strings.xml index 3637cbd00..4ac1aa87a 100644 --- a/MessengerProj/src/main/res/values-pl/strings.xml +++ b/MessengerProj/src/main/res/values-pl/strings.xml @@ -177,13 +177,6 @@ Wszystkie wideo Nie ma zdjęć Nie ma jeszcze wideo - Nie ma wcześniejszych zdjęć - Nie ma wcześniejszych GIFów - SZUKAJ OBRAZY - W INTERNECIE - SZUKAJ GIFY - Przeszukaj internet - Szukaj GIFy Przytnij zdjęcie Edytuj zdjęcie Ulepszenie diff --git a/MessengerProj/src/main/res/values-pt/strings.xml b/MessengerProj/src/main/res/values-pt/strings.xml index ed3f35a85..64c159b8d 100644 --- a/MessengerProj/src/main/res/values-pt/strings.xml +++ b/MessengerProj/src/main/res/values-pt/strings.xml @@ -173,13 +173,6 @@ Todos os Vídeos Ainda não há fotos Nenhum vídeo ainda - Nenhuma foto recente - Nenhum GIF recente - BUSCAR IMAGENS - BUSCA GLOBAL - BUSCAR GIFS - Procurar na web - Procurar GIFs Recortar imagem Editar imagem Realçar diff --git a/MessengerProj/src/main/res/values/strings.xml b/MessengerProj/src/main/res/values/strings.xml index 44d1f2c69..baa31de5e 100644 --- a/MessengerProj/src/main/res/values/strings.xml +++ b/MessengerProj/src/main/res/values/strings.xml @@ -177,13 +177,6 @@ All Videos No photos yet No videos yet - No recent photos - No recent GIFs - FIND IMAGES - WEB SEARCH - FIND GIFS - Search web - Search GIFs Crop image Edit image Enhance