various contextmenu related fixes
This commit is contained in:
parent
a7106ca240
commit
d5f8effc6d
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.fox.ttrss"
|
||||
android:versionCode="395"
|
||||
android:versionName="1.163" >
|
||||
android:versionCode="396"
|
||||
android:versionName="1.164" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="16"
|
||||
|
@ -371,7 +371,10 @@ public class ArticleImagesPagerActivity extends CommonActivity implements Gestur
|
||||
int position = m_pager.getCurrentItem();
|
||||
String url = m_checkedUrls.get(position);
|
||||
|
||||
return onImageMenuItemSelected(item, url);
|
||||
if (!onImageMenuItemSelected(item, url))
|
||||
return super.onContextItemSelected(item);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onImageMenuItemSelected(MenuItem item, String url) {
|
||||
|
@ -69,6 +69,7 @@ import com.shamanland.fab.ShowHideOnScroll;
|
||||
import org.fox.ttrss.types.Article;
|
||||
import org.fox.ttrss.types.ArticleList;
|
||||
import org.fox.ttrss.types.Feed;
|
||||
import org.fox.ttrss.util.EnlargingImageView;
|
||||
import org.fox.ttrss.util.HeadlinesRequest;
|
||||
import org.jsoup.Jsoup;
|
||||
|
||||
@ -202,6 +203,18 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
|
||||
.getMenuInfo();
|
||||
|
||||
Article article = getArticleAtPosition(info.position);
|
||||
|
||||
if (!onArticleMenuItemSelected(item, article))
|
||||
return super.onContextItemSelected(item);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
|
||||
@ -364,29 +377,17 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/*@Override
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
|
||||
getActivity().getMenuInflater().inflate(R.menu.context_headlines, menu);
|
||||
|
||||
if (getSelectedArticles().size() > 0) {
|
||||
menu.setHeaderTitle(R.string.headline_context_multiple);
|
||||
menu.setGroupVisible(R.id.menu_group_single_article, false);
|
||||
} else {
|
||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
||||
Article article = getArticleAtPosition(info.position);
|
||||
|
||||
menu.setHeaderTitle(Html.fromHtml(article.title));
|
||||
menu.setGroupVisible(R.id.menu_group_single_article, true);
|
||||
}
|
||||
|
||||
menu.findItem(R.id.set_labels).setEnabled(m_activity.getApiLevel() >= 1);
|
||||
menu.findItem(R.id.article_set_note).setEnabled(m_activity.getApiLevel() >= 1);
|
||||
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
@ -469,7 +470,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
|
||||
m_list.setOnItemClickListener(this);
|
||||
m_list.setOnScrollListener(this);
|
||||
//registerForContextMenu(m_list);
|
||||
registerForContextMenu(m_list);
|
||||
|
||||
if (m_activity.isSmallScreen()) {
|
||||
m_activity.setTitle(m_feed.title);
|
||||
@ -901,7 +902,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
public View getView(final int position, final View convertView, ViewGroup parent) {
|
||||
|
||||
View v = convertView;
|
||||
|
||||
@ -1131,6 +1132,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
holder.flavorImageOverflow.setVisibility(View.GONE);
|
||||
holder.headlineHeader.setBackgroundDrawable(null);
|
||||
|
||||
// this is needed if our flavor image goes behind base listview element
|
||||
holder.headlineHeader.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -1138,6 +1140,15 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
}
|
||||
});
|
||||
|
||||
holder.headlineHeader.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
m_activity.openContextMenu(v);
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (showFlavorImage && article.flavorImageUri != null && holder.flavorImageView != null) {
|
||||
if (holder.flavorImageOverflow != null) {
|
||||
holder.flavorImageOverflow.setOnClickListener(new View.OnClickListener() {
|
||||
@ -1172,6 +1183,16 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
popup.show();
|
||||
}
|
||||
});
|
||||
|
||||
holder.flavorImageView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
|
||||
m_activity.openContextMenu(v);
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!article.flavorImageUri.equals(holder.flavorImageView.getTag())) {
|
||||
|
@ -279,7 +279,10 @@ public class VideoPlayerActivity extends CommonActivity {
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
return onVideoMenuItemSelected(item);
|
||||
if (!onVideoMenuItemSelected(item))
|
||||
return super.onContextItemSelected(item);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onVideoMenuItemSelected(android.view.MenuItem item) {
|
||||
|
@ -103,6 +103,32 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
return selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
|
||||
getActivity().getMenuInflater().inflate(R.menu.context_headlines, menu);
|
||||
|
||||
menu.findItem(R.id.set_labels).setVisible(false);
|
||||
menu.findItem(R.id.article_set_note).setVisible(false);
|
||||
menu.findItem(R.id.headlines_article_unread).setVisible(false); // TODO: implement
|
||||
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
|
||||
.getMenuInfo();
|
||||
|
||||
int articleId = getArticleIdAtPosition(info.position);
|
||||
|
||||
if (!onArticleMenuItemSelected(item, articleId))
|
||||
return super.onContextItemSelected(item);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean onArticleMenuItemSelected(MenuItem item, int articleId) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.headlines_article_link_copy:
|
||||
@ -158,7 +184,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
return true;
|
||||
default:
|
||||
Log.d(TAG, "onArticleMenuItemSelected, unhandled id=" + item.getItemId());
|
||||
return super.onContextItemSelected(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -271,6 +297,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
|
||||
m_list.setOnItemClickListener(this);
|
||||
m_list.setOnScrollListener(this);
|
||||
registerForContextMenu(m_list);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -57,6 +57,7 @@
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/headline_header"
|
||||
android:clickable="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?headlineHeaderBackground"
|
||||
@ -64,6 +65,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:background="@drawable/ripple"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_span="2"
|
||||
|
@ -58,6 +58,7 @@
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/headline_header"
|
||||
android:clickable="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?headlineHeaderBackground"
|
||||
@ -65,6 +66,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:background="@drawable/ripple"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_span="2"
|
||||
|
Loading…
Reference in New Issue
Block a user