diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java index da150a8b..170b0f8e 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java @@ -135,7 +135,7 @@ public class ArticleFragment extends Fragment { if (result != null && (result.getType() == HitTestResult.IMAGE_TYPE || result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE)) { menu.setHeaderTitle(result.getExtra()); - getActivity().getMenuInflater().inflate(R.menu.context_article_content_img, menu); + getActivity().getMenuInflater().inflate(R.menu.content_gallery_entry, menu); /* FIXME I have no idea how to do this correctly ;( */ diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryActivity.java index e83e27db..32dedd1b 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryActivity.java @@ -1,5 +1,6 @@ package org.fox.ttrss; +import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.ActivityCompat; @@ -8,8 +9,11 @@ import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.widget.Toolbar; -import android.view.ContextMenu; +import android.util.Log; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; +import android.widget.PopupMenu; import android.widget.ProgressBar; import com.ToxicBakery.viewpager.transforms.DepthPageTransformer; @@ -239,6 +243,28 @@ public class GalleryActivity extends CommonActivity { m_content = savedInstanceState.getString("content"); } + findViewById(R.id.gallery_overflow).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + PopupMenu popup = new PopupMenu(GalleryActivity.this, v); + MenuInflater inflater = popup.getMenuInflater(); + inflater.inflate(R.menu.content_gallery_entry, popup.getMenu()); + + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + String url = m_items.get(m_pager.getCurrentItem()).url; + + return onImageMenuItemSelected(item, url); + } + }); + + popup.show(); + + } + }); + + /*if (m_items.size() > 1) { m_progress.setProgress(0); m_progress.setMax(m_items.size()); @@ -260,20 +286,12 @@ public class GalleryActivity extends CommonActivity { m_adapter = new ArticleImagesPagerAdapter(getSupportFragmentManager(), m_items); - m_pager = (ViewPager) findViewById(R.id.article_images_pager); + m_pager = (ViewPager) findViewById(R.id.gallery_pager); m_pager.setAdapter(m_adapter); m_pager.setPageTransformer(true, new DepthPageTransformer()); } - @Override - public void onCreateContextMenu(ContextMenu menu, View v, - ContextMenu.ContextMenuInfo menuInfo) { - - getMenuInflater().inflate(R.menu.context_article_content_img, menu); - - super.onCreateContextMenu(menu, v, menuInfo); - } @Override public void onSaveInstanceState(Bundle out) { @@ -284,5 +302,48 @@ public class GalleryActivity extends CommonActivity { out.putString("content", m_content); } + @Override + public boolean onContextItemSelected(MenuItem item) { + int position = m_pager.getCurrentItem(); + String url = m_items.get(position).url; + + if (onImageMenuItemSelected(item, url)) + return true; + + return super.onContextItemSelected(item); + } + + public boolean onImageMenuItemSelected(MenuItem item, String url) { + switch (item.getItemId()) { + case R.id.article_img_open: + if (url != null) { + try { + openUri(Uri.parse(url)); + } catch (Exception e) { + e.printStackTrace(); + toast(R.string.error_other_error); + } + } + return true; + case R.id.article_img_copy: + if (url != null) { + copyToClipboard(url); + } + return true; + case R.id.article_img_share: + if (url != null) { + shareText(url); + } + return true; + case R.id.article_img_view_caption: + if (url != null) { + displayImageCaption(url, m_content); + } + return true; + default: + Log.d(TAG, "onImageMenuItemSelected, unhandled id=" + item.getItemId()); + return false; + } + } } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryBaseFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryBaseFragment.java index 9dc65311..1b2cbed3 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryBaseFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryBaseFragment.java @@ -5,7 +5,9 @@ import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.Log; +import android.view.ContextMenu; import android.view.MenuItem; +import android.view.View; public class GalleryBaseFragment extends Fragment { private final String TAG = this.getClass().getSimpleName(); @@ -18,39 +20,6 @@ public class GalleryBaseFragment extends Fragment { setRetainInstance(true); } - public boolean onImageMenuItemSelected(MenuItem item, String url) { - switch (item.getItemId()) { - case R.id.article_img_open: - if (url != null) { - try { - m_activity.openUri(Uri.parse(url)); - } catch (Exception e) { - e.printStackTrace(); - m_activity.toast(R.string.error_other_error); - } - } - return true; - case R.id.article_img_copy: - if (url != null) { - m_activity.copyToClipboard(url); - } - return true; - case R.id.article_img_share: - if (url != null) { - m_activity.shareText(url); - } - return true; - case R.id.article_img_view_caption: - if (url != null) { - m_activity.displayImageCaption(url, m_activity.m_content); - } - return true; - default: - Log.d(TAG, "onImageMenuItemSelected, unhandled id=" + item.getItemId()); - return false; - } - } - @Override public void onAttach(Activity activity) { super.onAttach(activity); @@ -60,5 +29,12 @@ public class GalleryBaseFragment extends Fragment { } + @Override + public void onCreateContextMenu(ContextMenu menu, View v, + ContextMenu.ContextMenuInfo menuInfo) { + m_activity.getMenuInflater().inflate(R.menu.content_gallery_entry, menu); + + super.onCreateContextMenu(menu, v, menuInfo); + } } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryImageFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryImageFragment.java index ca7dfbb3..109bf92d 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryImageFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryImageFragment.java @@ -40,33 +40,14 @@ public class GalleryImageFragment extends GalleryBaseFragment { ImageMatrixTouchHandler touchHandler = new ImageMatrixTouchHandler(view.getContext()); - imgView.setOnTouchListener(touchHandler); + //imgView.setOnTouchListener(touchHandler); // shared element transitions stop GIFs from playing if (m_url.toLowerCase().indexOf(".gif") == -1) { ViewCompat.setTransitionName(imgView, "gallery:" + m_url); } - //registerForContextMenu(imgView); - - view.findViewById(R.id.flavor_image_overflow).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - PopupMenu popup = new PopupMenu(getContext(), v); - MenuInflater inflater = popup.getMenuInflater(); - inflater.inflate(R.menu.context_article_content_img, popup.getMenu()); - - popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - return onImageMenuItemSelected(item, m_url); - } - }); - - popup.show(); - - } - }); + registerForContextMenu(imgView); final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.flavor_image_progress); final View errorMessage = view.findViewById(R.id.flavor_image_error); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryVideoFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryVideoFragment.java index aba56e39..387781f5 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryVideoFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/GalleryVideoFragment.java @@ -52,26 +52,7 @@ public class GalleryVideoFragment extends GalleryBaseFragment { ViewCompat.setTransitionName(imgView, "gallery:" + m_url); - //registerForContextMenu(imgView); - - view.findViewById(R.id.flavor_image_overflow).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - PopupMenu popup = new PopupMenu(getContext(), v); - MenuInflater inflater = popup.getMenuInflater(); - inflater.inflate(R.menu.context_article_content_img, popup.getMenu()); - - popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - return onImageMenuItemSelected(item, m_url); - } - }); - - popup.show(); - - } - }); + registerForContextMenu(imgView); final GlideDrawableImageViewTarget glideImage = new GlideDrawableImageViewTarget(imgView); @@ -133,9 +114,12 @@ public class GalleryVideoFragment extends GalleryBaseFragment { //Log.d(TAG, "initializeVideoPlayer: " + m_activity + " " + view); + final MediaController m_mediaController = new MediaController(m_activity); final TextureView textureView = (TextureView) view.findViewById(R.id.flavor_video); + registerForContextMenu(textureView); + textureView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -271,17 +255,6 @@ public class GalleryVideoFragment extends GalleryBaseFragment { m_coverUrl = coverUrl; } - /*@Override - public boolean onContextItemSelected(MenuItem item) { - int position = m_pager.getCurrentItem(); - String url = m_checkedUrls.get(position); - - if (!onImageMenuItemSelected(item, url)) - return super.onContextItemSelected(item); - else - return true; - }*/ - @Override public void onSaveInstanceState (Bundle out) { super.onSaveInstanceState(out); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index eb9295c5..60054b6e 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -791,7 +791,7 @@ public class HeadlinesFragment extends Fragment { textChecked = (ImageView) v.findViewById(R.id.text_checked); headlineHeader = v.findViewById(R.id.headline_header); topChangedMessage = v.findViewById(R.id.headlines_row_top_changed); - flavorImageOverflow = v.findViewById(R.id.flavor_image_overflow); + flavorImageOverflow = v.findViewById(R.id.gallery_overflow); flavorVideoView = (TextureView) v.findViewById(R.id.flavor_video); } @@ -1086,7 +1086,7 @@ public class HeadlinesFragment extends Fragment { public void onClick(View v) { PopupMenu popup = new PopupMenu(getActivity(), holder.flavorImageOverflow); MenuInflater inflater = popup.getMenuInflater(); - inflater.inflate(R.menu.context_article_content_img, popup.getMenu()); + inflater.inflate(R.menu.content_gallery_entry, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java index 9c7974ea..1ab89c21 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java @@ -98,7 +98,7 @@ public class OfflineArticleFragment extends Fragment { if (result != null && (result.getType() == HitTestResult.IMAGE_TYPE || result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE)) { menu.setHeaderTitle(result.getExtra()); - getActivity().getMenuInflater().inflate(R.menu.context_article_content_img, menu); + getActivity().getMenuInflater().inflate(R.menu.content_gallery_entry, menu); /* FIXME I have no idea how to do this correctly ;( */ diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index 4921a0fa..f9708dda 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -572,7 +572,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis holder.textChecked = (ImageView) v.findViewById(R.id.text_checked); holder.flavorVideoKindView = (ImageView) v.findViewById(R.id.flavor_video_kind); holder.headlineHeader = v.findViewById(R.id.headline_header); - holder.flavorImageOverflow = v.findViewById(R.id.flavor_image_overflow); + holder.flavorImageOverflow = v.findViewById(R.id.gallery_overflow); v.setTag(holder); diff --git a/org.fox.ttrss/src/main/res/layout/activity_gallery.xml b/org.fox.ttrss/src/main/res/layout/activity_gallery.xml index de99eedb..8ae3d971 100644 --- a/org.fox.ttrss/src/main/res/layout/activity_gallery.xml +++ b/org.fox.ttrss/src/main/res/layout/activity_gallery.xml @@ -7,11 +7,23 @@ android:layout_height="fill_parent"> + + - diff --git a/org.fox.ttrss/src/main/res/layout/fragment_gallery_entry.xml b/org.fox.ttrss/src/main/res/layout/fragment_gallery_entry.xml index e5fe47f4..5bde3166 100644 --- a/org.fox.ttrss/src/main/res/layout/fragment_gallery_entry.xml +++ b/org.fox.ttrss/src/main/res/layout/fragment_gallery_entry.xml @@ -34,16 +34,4 @@ android:layout_gravity="center" android:id="@+id/flavor_image_progress" /> - - \ No newline at end of file diff --git a/org.fox.ttrss/src/main/res/layout/headlines_row.xml b/org.fox.ttrss/src/main/res/layout/headlines_row.xml index 6ffec2dd..e434c497 100755 --- a/org.fox.ttrss/src/main/res/layout/headlines_row.xml +++ b/org.fox.ttrss/src/main/res/layout/headlines_row.xml @@ -151,7 +151,7 @@ android:layout_marginLeft="8dp" />