remove separate list for selected articles
This commit is contained in:
parent
f2b4da5089
commit
15aebd8d3a
@ -447,7 +447,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
intent.putExtra("searchQuery", hf.getSearchQuery());
|
||||
//intent.putParcelableArrayListExtra("articles", hf.getArticles());
|
||||
intent.putExtra("articles", (Parcelable)hf.getAllArticles());
|
||||
intent.putExtra("selectedArticles", (Parcelable)hf.getSelectedArticles());
|
||||
|
||||
/* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
startActivityForResult(intent, HEADLINES_REQUEST, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
|
||||
@ -500,14 +499,12 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
||||
//ArrayList<Article> tmp = data.getParcelableArrayListExtra("articles");
|
||||
Article article = data.getParcelableExtra("activeArticle");
|
||||
ArticleList articles = data.getParcelableExtra("articles");
|
||||
ArticleList selectedArticles = data.getParcelableExtra("selectedArticles");
|
||||
|
||||
if (articles != null) {
|
||||
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||
|
||||
if (hf != null) {
|
||||
hf.setArticles(articles);
|
||||
hf.setSelectedArticles(selectedArticles);
|
||||
hf.setActiveArticle(article);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import org.fox.ttrss.types.Feed;
|
||||
public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventListener {
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
protected ArticleList m_articles = new ArticleList();
|
||||
protected ArticleList m_selectedArticles = new ArticleList();
|
||||
|
||||
protected SharedPreferences m_prefs;
|
||||
private Article m_activeArticle;
|
||||
@ -38,6 +37,8 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
|
||||
|
||||
setContentView(R.layout.headlines_articles);
|
||||
|
||||
m_forceDisableActionMode = isPortrait() || isSmallScreen();
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
|
||||
@ -51,7 +52,6 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
m_articles = savedInstanceState.getParcelable("articles");
|
||||
m_selectedArticles = savedInstanceState.getParcelable("selectedArticles");
|
||||
} else {
|
||||
Intent i = getIntent();
|
||||
|
||||
@ -85,22 +85,12 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
|
||||
m_articles.addAll(tmp);
|
||||
}
|
||||
|
||||
tmp = i.getParcelableExtra("selectedArticles");
|
||||
|
||||
if (tmp != null) {
|
||||
m_selectedArticles.addAll(tmp);
|
||||
}
|
||||
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
|
||||
final HeadlinesFragment hf = new HeadlinesFragment();
|
||||
hf.initialize(feed, article, true, m_articles);
|
||||
hf.setSearchQuery(searchQuery);
|
||||
|
||||
if (!isPortrait() && !isSmallScreen()) {
|
||||
hf.setSelectedArticles(m_selectedArticles);
|
||||
}
|
||||
|
||||
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
|
||||
ft.replace(R.id.article_fragment, new LoadingFragment(), null);
|
||||
|
||||
@ -133,6 +123,9 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
|
||||
if (!isSmallScreen()) {
|
||||
findViewById(R.id.headlines_fragment).setVisibility(isPortrait() ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
m_forceDisableActionMode = isPortrait() || isSmallScreen();
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -156,7 +149,6 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
|
||||
super.onSaveInstanceState(out);
|
||||
|
||||
out.putParcelable("articles", m_articles);
|
||||
out.putParcelable("selectedArticles", m_selectedArticles);
|
||||
|
||||
GlobalState.getInstance().save(out);
|
||||
}
|
||||
@ -317,17 +309,9 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
|
||||
public void onBackPressed() {
|
||||
Intent resultIntent = new Intent();
|
||||
|
||||
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||
|
||||
resultIntent.putExtra("articles", (Parcelable) m_articles);
|
||||
resultIntent.putExtra("activeArticle", m_activeArticle);
|
||||
|
||||
if (hf != null && !isPortrait() && !isSmallScreen()) {
|
||||
resultIntent.putExtra("selectedArticles", (Parcelable) hf.getSelectedArticles());
|
||||
} else {
|
||||
resultIntent.putExtra("selectedArticles", (Parcelable) m_selectedArticles);
|
||||
}
|
||||
|
||||
setResult(Activity.RESULT_OK, resultIntent);
|
||||
|
||||
super.onBackPressed();
|
||||
|
@ -93,7 +93,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
|
||||
private ArticleListAdapter m_adapter;
|
||||
private ArticleList m_articles = new ArticleList(); //GlobalState.getInstance().m_loadedArticles;
|
||||
private ArticleList m_selectedArticles = new ArticleList();
|
||||
//private ArticleList m_selectedArticles = new ArticleList();
|
||||
private ArticleList m_readArticles = new ArticleList();
|
||||
private HeadlinesEventListener m_listener;
|
||||
private OnlineActivity m_activity;
|
||||
@ -102,7 +102,13 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
private boolean m_compactLayoutMode = false;
|
||||
|
||||
public ArticleList getSelectedArticles() {
|
||||
return m_selectedArticles;
|
||||
ArticleList tmp = new ArticleList();
|
||||
|
||||
for (Article a : m_articles) {
|
||||
if (a.selected) tmp.add(a);
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public void initialize(Feed feed) {
|
||||
@ -291,7 +297,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
|
||||
getActivity().getMenuInflater().inflate(R.menu.headlines_context_menu, menu);
|
||||
|
||||
if (m_selectedArticles.size() > 0) {
|
||||
if (getSelectedArticles().size() > 0) {
|
||||
menu.setHeaderTitle(R.string.headline_context_multiple);
|
||||
menu.setGroupVisible(R.id.menu_group_single_article, false);
|
||||
} else {
|
||||
@ -322,7 +328,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
}
|
||||
|
||||
m_activeArticle = savedInstanceState.getParcelable("activeArticle");
|
||||
m_selectedArticles = savedInstanceState.getParcelable("selectedArticles");
|
||||
//m_selectedArticles = savedInstanceState.getParcelable("selectedArticles");
|
||||
m_searchQuery = (String) savedInstanceState.getCharSequence("searchQuery");
|
||||
m_compactLayoutMode = savedInstanceState.getBoolean("compactLayoutMode");
|
||||
}
|
||||
@ -610,7 +616,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
out.putParcelable("feed", m_feed);
|
||||
out.putParcelable("articles", m_articles);
|
||||
out.putParcelable("activeArticle", m_activeArticle);
|
||||
out.putParcelable("selectedArticles", m_selectedArticles);
|
||||
//out.putParcelable("selectedArticles", m_selectedArticles);
|
||||
out.putCharSequence("searchQuery", m_searchQuery);
|
||||
out.putBoolean("compactLayoutMode", m_compactLayoutMode);
|
||||
}
|
||||
@ -685,7 +691,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
private void updateTextCheckedState(HeadlineViewHolder holder, Article item) {
|
||||
String tmp = item.title.length() > 0 ? item.title.substring(0, 1) : "?";
|
||||
|
||||
if (m_selectedArticles.containsId(item.id)) {
|
||||
if (item.selected) {
|
||||
holder.textImage.setImageDrawable(m_drawableBuilder.build(" ", 0xff616161));
|
||||
|
||||
holder.textChecked.setVisibility(View.VISIBLE);
|
||||
@ -773,17 +779,13 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
public void onClick(View view) {
|
||||
Log.d(TAG, "textImage : onclicked");
|
||||
|
||||
if (!m_selectedArticles.containsId(article.id)) {
|
||||
m_selectedArticles.add(article);
|
||||
} else {
|
||||
m_selectedArticles.remove(m_selectedArticles.findById(article.id));
|
||||
}
|
||||
article.selected = !article.selected;
|
||||
|
||||
updateTextCheckedState(holder, article);
|
||||
|
||||
m_listener.onArticleListSelectionChange(m_selectedArticles);
|
||||
m_listener.onArticleListSelectionChange(getSelectedArticles());
|
||||
|
||||
Log.d(TAG, "num selected: " + m_selectedArticles.size());
|
||||
Log.d(TAG, "num selected: " + getSelectedArticles().size());
|
||||
}
|
||||
});
|
||||
|
||||
@ -1053,7 +1055,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
|
||||
|
||||
if (holder.selectionBoxView != null) {
|
||||
holder.selectionBoxView.setChecked(m_selectedArticles.containsId(article.id));
|
||||
holder.selectionBoxView.setChecked(article.selected);
|
||||
holder.selectionBoxView.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
@ -1061,15 +1063,14 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
CheckBox cb = (CheckBox)view;
|
||||
|
||||
if (cb.isChecked()) {
|
||||
if (!m_selectedArticles.containsId(article.id))
|
||||
m_selectedArticles.add(article);
|
||||
article.selected = true;
|
||||
} else {
|
||||
m_selectedArticles.remove(m_selectedArticles.findById(article.id));
|
||||
article.selected = false;
|
||||
}
|
||||
|
||||
m_listener.onArticleListSelectionChange(m_selectedArticles);
|
||||
m_listener.onArticleListSelectionChange(getSelectedArticles());
|
||||
|
||||
Log.d(TAG, "num selected: " + m_selectedArticles.size());
|
||||
Log.d(TAG, "num selected: " + getSelectedArticles().size());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1140,12 +1141,13 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
}
|
||||
|
||||
public void setSelection(ArticlesSelection select) {
|
||||
m_selectedArticles.clear();
|
||||
for (Article a : m_articles)
|
||||
a.selected = false;
|
||||
|
||||
if (select != ArticlesSelection.NONE) {
|
||||
for (Article a : m_articles) {
|
||||
if (select == ArticlesSelection.ALL || select == ArticlesSelection.UNREAD && a.unread) {
|
||||
m_selectedArticles.add(a);
|
||||
a.selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1155,19 +1157,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedArticles(ArticleList selectedArticles) {
|
||||
if (selectedArticles != null) {
|
||||
m_selectedArticles.clear();
|
||||
m_selectedArticles.addAll(selectedArticles);
|
||||
|
||||
if (m_adapter != null) {
|
||||
m_adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Article getArticleAtPosition(int position) {
|
||||
try {
|
||||
return m_adapter.getItem(position);
|
||||
|
@ -64,6 +64,7 @@ public class OnlineActivity extends CommonActivity {
|
||||
protected Menu m_menu;
|
||||
|
||||
protected int m_offlineModeStatus = 0;
|
||||
protected boolean m_forceDisableActionMode = false;
|
||||
|
||||
private ActionMode m_headlinesActionMode;
|
||||
private HeadlinesActionModeCallback m_headlinesActionModeCallback;
|
||||
@ -107,16 +108,15 @@ public class OnlineActivity extends CommonActivity {
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
m_headlinesActionMode = null;
|
||||
|
||||
if (!m_forceDisableActionMode) {
|
||||
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||
|
||||
if (hf != null) {
|
||||
ArticleList selected = hf.getSelectedArticles();
|
||||
if (selected.size() > 0) {
|
||||
selected.clear();
|
||||
hf.setSelection(HeadlinesFragment.ArticlesSelection.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
invalidateOptionsMenu();
|
||||
hf.notifyUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1569,12 +1569,14 @@ public class OnlineActivity extends CommonActivity {
|
||||
|
||||
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||
|
||||
if (hf != null) {
|
||||
if (hf != null && !m_forceDisableActionMode) {
|
||||
if (hf.getSelectedArticles().size() > 0 && m_headlinesActionMode == null) {
|
||||
m_headlinesActionMode = startSupportActionMode(m_headlinesActionModeCallback);
|
||||
} else if (hf.getSelectedArticles().size() == 0 && m_headlinesActionMode != null) {
|
||||
m_headlinesActionMode.finish();
|
||||
}
|
||||
} else if (m_forceDisableActionMode && m_headlinesActionMode != null) {
|
||||
m_headlinesActionMode.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
3
org.fox.ttrss/src/main/java/org/fox/ttrss/types/Article.java
Normal file → Executable file
3
org.fox.ttrss/src/main/java/org/fox/ttrss/types/Article.java
Normal file → Executable file
@ -29,6 +29,7 @@ public class Article implements Parcelable {
|
||||
public boolean always_display_attachments;
|
||||
public String author;
|
||||
public String note;
|
||||
public boolean selected;
|
||||
|
||||
public Article(Parcel in) {
|
||||
readFromParcel(in);
|
||||
@ -72,6 +73,7 @@ public class Article implements Parcelable {
|
||||
out.writeInt(always_display_attachments ? 1 : 0);
|
||||
out.writeString(author);
|
||||
out.writeString(note);
|
||||
out.writeInt(selected ? 1 : 0);
|
||||
}
|
||||
|
||||
public void readFromParcel(Parcel in) {
|
||||
@ -102,6 +104,7 @@ public class Article implements Parcelable {
|
||||
always_display_attachments = in.readInt() == 1;
|
||||
author = in.readString();
|
||||
note = in.readString();
|
||||
selected = in.readInt() == 1;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
@ -35,7 +35,7 @@
|
||||
<string name="article_toggle_published">(Un)Publish</string>
|
||||
<string name="headlines_select">Select articles</string>
|
||||
<string name="headlines_select_dialog">Select articles</string>
|
||||
<string name="headlines_select_all">Everything</string>
|
||||
<string name="headlines_select_all">Select all</string>
|
||||
<string name="headlines_select_unread">Unread</string>
|
||||
<string name="headlines_select_none">Deselect all</string>
|
||||
<string name="selection_toggle_marked">(Un)Star</string>
|
||||
|
Loading…
Reference in New Issue
Block a user