From c1b41d9de8559240fa6c0b8f6cae8b4266830270 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 18 May 2013 13:19:16 +0400 Subject: [PATCH 1/8] add holo triangle back --- .../ic_mailbox_collapsed_holo_dark.png | Bin 0 -> 274 bytes .../ic_mailbox_collapsed_holo_light.png | Bin 0 -> 350 bytes res/layout/headlines_row.xml | 9 +++++++++ res/layout/headlines_row_selected.xml | 10 ++++++++++ res/layout/headlines_row_selected_unread.xml | 9 +++++++++ res/layout/headlines_row_unread.xml | 12 +++++++++++- src/org/fox/ttrss/CommonActivity.java | 7 +++++++ src/org/fox/ttrss/HeadlinesFragment.java | 9 ++++++--- .../ttrss/offline/OfflineHeadlinesFragment.java | 11 +++++++---- 9 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 res/drawable-hdpi/ic_mailbox_collapsed_holo_dark.png create mode 100644 res/drawable-hdpi/ic_mailbox_collapsed_holo_light.png diff --git a/res/drawable-hdpi/ic_mailbox_collapsed_holo_dark.png b/res/drawable-hdpi/ic_mailbox_collapsed_holo_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..eb1a7bd8c4b37b17937b82c949c5c56ff8f2f382 GIT binary patch literal 274 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!pj3%#L`iUdT1k0gQ7S_~VrE{6o}X)oLYc9i zsh**M!Iz?iKvj*NE{-7<{%bEg@--;%xCDOjl8LM8$@BPPVs**Q++m^5r|?JIdOVA} z4YOv8%=kIs__n_STeK$ySv~crH+^!`)g`iTYq)cPu!7o&rV>T%OD%2_v`o4bD!<<5 zX?pT?QzQ%LL+1-ZEV_b0QdMtbAv%36$bn}k6X5c=?+eU`7535<70y>7l M)78&qol`;+0J@x9N&o-= literal 0 HcmV?d00001 diff --git a/res/drawable-hdpi/ic_mailbox_collapsed_holo_light.png b/res/drawable-hdpi/ic_mailbox_collapsed_holo_light.png new file mode 100644 index 0000000000000000000000000000000000000000..2c395b800c887cbb2d7399f95ee2530754bcc40a GIT binary patch literal 350 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+0wn(&ce?|mn3BBRT^Rni_n+Ah2>S z4={E+nQaFWEGuwK2hw1@49XUHUO-Nor;B5V#`)H>hJ1${1eg!p6t#aOeckoR|NRb& z9%u+DI^0>OEv{^>Q`CCEWRpTm=8a7XFEel0E>blA{&=gRQq`x;U*^{=6#eOt{Yg*M zGTXOfo`9`l^&!`eSu)A1TSs4+9F=JSWhQv!Nl!A8&ykOBT7;dOH!?pi&B9U zgOP!up{{|Yu7P2Qp`n$bxs`#5t^trVI9On^4@E<6eoAIqCAtPvD`PW=hP5ZWz5+E! vf@}!RPb(=;EJ|f?Ovz75Rq)JBOiv9;O-!jQJeg_(RK(!v>gTe~DWM4f(w1$T literal 0 HcmV?d00001 diff --git a/res/layout/headlines_row.xml b/res/layout/headlines_row.xml index 94d5f856..d339e281 100644 --- a/res/layout/headlines_row.xml +++ b/res/layout/headlines_row.xml @@ -120,6 +120,15 @@ android:clickable="true" android:src="@drawable/ic_rss_bw" /> + \ No newline at end of file diff --git a/res/layout/headlines_row_selected.xml b/res/layout/headlines_row_selected.xml index e1788ad5..be2239d9 100644 --- a/res/layout/headlines_row_selected.xml +++ b/res/layout/headlines_row_selected.xml @@ -120,6 +120,16 @@ android:layout_weight="0" android:clickable="true" android:src="@drawable/ic_rss_bw" /> + + diff --git a/res/layout/headlines_row_selected_unread.xml b/res/layout/headlines_row_selected_unread.xml index a91d5407..0367199e 100644 --- a/res/layout/headlines_row_selected_unread.xml +++ b/res/layout/headlines_row_selected_unread.xml @@ -121,6 +121,15 @@ android:clickable="true" android:src="@drawable/ic_rss_bw" /> + \ No newline at end of file diff --git a/res/layout/headlines_row_unread.xml b/res/layout/headlines_row_unread.xml index df794891..a4cbae11 100644 --- a/res/layout/headlines_row_unread.xml +++ b/res/layout/headlines_row_unread.xml @@ -119,9 +119,19 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" - android:clickable="true" + android:clickable="true" android:src="@drawable/ic_rss_bw" /> + + \ No newline at end of file diff --git a/src/org/fox/ttrss/CommonActivity.java b/src/org/fox/ttrss/CommonActivity.java index e1cacb02..78d1937c 100644 --- a/src/org/fox/ttrss/CommonActivity.java +++ b/src/org/fox/ttrss/CommonActivity.java @@ -166,6 +166,13 @@ public class CommonActivity extends SherlockFragmentActivity { toast.show(); } + public boolean isDarkTheme() { + String defaultTheme = "THEME_DARK"; + + return (m_prefs.getString("theme", defaultTheme).equals("THEME_DARK")) || + m_prefs.getString("theme", defaultTheme).equals("THEME_DARK_GRAY"); + } + protected void setAppTheme(SharedPreferences prefs) { String defaultTheme = "THEME_DARK"; diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index f9cc51d8..0c5b09ec 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -41,6 +41,7 @@ import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.CheckBox; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -721,17 +722,19 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, }); } - /* ImageButton ib = (ImageButton) v.findViewById(R.id.article_menu_button); + ImageButton ib = (ImageButton) v.findViewById(R.id.article_menu_button); if (ib != null) { - ib.setVisibility(android.os.Build.VERSION.SDK_INT >= 10 ? View.VISIBLE : View.GONE); + if (m_activity.isDarkTheme()) + ib.setImageResource(R.drawable.ic_mailbox_collapsed_holo_dark); + ib.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getActivity().openContextMenu(v); } }); - } */ + } return v; } diff --git a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index e7e848d2..85588195 100644 --- a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -38,6 +38,7 @@ import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; import android.widget.CheckBox; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -576,18 +577,20 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis }); } - /* ImageButton ib = (ImageButton) v.findViewById(R.id.article_menu_button); + ImageButton ib = (ImageButton) v.findViewById(R.id.article_menu_button); if (ib != null) { - ib.setVisibility(android.os.Build.VERSION.SDK_INT >= 10 ? View.VISIBLE : View.GONE); + if (m_activity.isDarkTheme()) + ib.setImageResource(R.drawable.ic_mailbox_collapsed_holo_dark); + ib.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getActivity().openContextMenu(v); } }); - } */ - + } + return v; } From 709b3838bbe00f873ec7e1d18dde52b72517240f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 18 May 2013 13:28:10 +0400 Subject: [PATCH 2/8] add preference to confirm marking headlines as read --- res/values/strings.xml | 1 + res/xml/preferences.xml | 6 ++ src/org/fox/ttrss/OnlineActivity.java | 107 +++++++++++++++----------- 3 files changed, 67 insertions(+), 47 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 9212a1e6..05df6e0c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -196,4 +196,5 @@ Mark read on scroll Headlines will be marked read when scrolling past them Mark %1$d article(s) as read? + Confirm marking articles as read diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index e05fc5b6..6bfa0e29 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -129,6 +129,12 @@ android:defaultValue="false" android:key="full_screen_mode" android:title="@string/prefs_fullscreen_mode" /> + + + 0) { - AlertDialog.Builder builder = new AlertDialog.Builder( - OnlineActivity.this) - .setMessage(getString(R.string.mark_num_headlines_as_read, count)) - .setPositiveButton(R.string.catchup, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { + if (confirm) { + AlertDialog.Builder builder = new AlertDialog.Builder( + OnlineActivity.this) + .setMessage(getString(R.string.mark_num_headlines_as_read, count)) + .setPositiveButton(R.string.catchup, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { - ArticleList articles = hf.getUnreadArticles(); - - for (Article a : articles) - a.unread = false; - - ApiRequest req = new ApiRequest(getApplicationContext()) { - protected void onPostExecute(JsonElement result) { - if (hf.isAdded()) { - hf.refresh(false); - } - } - }; - - final String articleIds = articlesToIdString(articles); - - @SuppressWarnings("serial") - HashMap map = new HashMap() { - { - put("sid", getSessionId()); - put("op", "updateArticle"); - put("article_ids", articleIds); - put("mode", "0"); - put("field", "2"); - } - }; - req.execute(map); - - - } - }) - .setNegativeButton(R.string.dialog_cancel, - new Dialog.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - - } - }); - - AlertDialog dlg = builder.create(); - dlg.show(); + catchupVisibleArticles(); + + } + }) + .setNegativeButton(R.string.dialog_cancel, + new Dialog.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + + } + }); + + AlertDialog dlg = builder.create(); + dlg.show(); + } else { + catchupVisibleArticles(); + } } } return true; @@ -1020,6 +1000,39 @@ public class OnlineActivity extends CommonActivity { } } + protected void catchupVisibleArticles() { + final HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES); + + if (hf != null) { + ArticleList articles = hf.getUnreadArticles(); + + for (Article a : articles) + a.unread = false; + + ApiRequest req = new ApiRequest(getApplicationContext()) { + protected void onPostExecute(JsonElement result) { + if (hf.isAdded()) { + hf.refresh(false); + } + } + }; + + final String articleIds = articlesToIdString(articles); + + @SuppressWarnings("serial") + HashMap map = new HashMap() { + { + put("sid", getSessionId()); + put("op", "updateArticle"); + put("article_ids", articleIds); + put("mode", "0"); + put("field", "2"); + } + }; + req.execute(map); + } + } + public void editArticleNote(final Article article) { String note = ""; From ad6b01cb469b41b27056e81a44760f6d2559cda8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 18 May 2013 13:35:12 +0400 Subject: [PATCH 3/8] dark theme minor style fix --- res/drawable/headline_row_selected_dark.xml | 2 ++ res/values-v11/style.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/res/drawable/headline_row_selected_dark.xml b/res/drawable/headline_row_selected_dark.xml index b8ddb446..75c79a11 100644 --- a/res/drawable/headline_row_selected_dark.xml +++ b/res/drawable/headline_row_selected_dark.xml @@ -3,6 +3,8 @@ + + @android:color/transparent @android:drawable/divider_horizontal_dark - @drawable/ics_divider_vertical + @android:color/transparent @color/ics_cyan @drawable/headlines_dark @drawable/headlines_dark From 47a2f150abbbe45a17df212d44cecd2416dee24a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 18 May 2013 13:41:44 +0400 Subject: [PATCH 4/8] bump version, update light theme --- AndroidManifest.xml | 4 ++-- res/drawable-hdpi/arrowhead_light.png | Bin 1283 -> 287 bytes res/drawable/shadow_headlines.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index d2baf5cf..3d6ebe8b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="169" + android:versionName="1.7.6" > 9J%+`|F-mx2%nADz9i==Y}jD@`L~zX z%Lg&aY<9g*8lO%qO2}LyS7DpPtoYtA?3~ccF}G0YmV2c2!^! z;4JWnEM{QfI}E~%$MaXD00kvWTq8KjgkGC~-%{;+2jafxJK*oV-p2`%F zB{m$41&%wM3R)h{|9R)INblC~39F)V|5s^d?E5-dGiv$QH=2 - + \ No newline at end of file From 8d85dc931fb1184a12f573cc7507e4406ccd9ba9 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 18 May 2013 13:57:25 +0400 Subject: [PATCH 5/8] add (invisible) context triangle icon to feed rows --- res/layout-sw600dp/feeds_row_selected.xml | 12 ++++++++++++ res/layout/feeds_row.xml | 12 ++++++++++++ res/layout/feeds_row_selected.xml | 12 ++++++++++++ src/org/fox/ttrss/FeedCategoriesFragment.java | 19 +++++++++++++++++++ src/org/fox/ttrss/FeedsFragment.java | 16 ++++++++++++++++ .../OfflineFeedCategoriesFragment.java | 17 +++++++++++++++++ .../ttrss/offline/OfflineFeedsFragment.java | 16 ++++++++++++++++ 7 files changed, 104 insertions(+) diff --git a/res/layout-sw600dp/feeds_row_selected.xml b/res/layout-sw600dp/feeds_row_selected.xml index 12336d71..f6217520 100644 --- a/res/layout-sw600dp/feeds_row_selected.xml +++ b/res/layout-sw600dp/feeds_row_selected.xml @@ -4,6 +4,7 @@ android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:background="?feedsSelectedBackground" + android:descendantFocusability="blocksDescendants" android:gravity="center_vertical" android:orientation="horizontal" android:paddingBottom="10dip" @@ -43,4 +44,15 @@ android:textSize="13sp" android:textStyle="bold" /> + + \ No newline at end of file diff --git a/res/layout/feeds_row.xml b/res/layout/feeds_row.xml index bd033b25..ffea8cf6 100644 --- a/res/layout/feeds_row.xml +++ b/res/layout/feeds_row.xml @@ -3,6 +3,7 @@ android:id="@+id/feeds_row" android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeight" + android:descendantFocusability="blocksDescendants" android:gravity="center_vertical" android:orientation="horizontal" android:paddingBottom="10dip" @@ -42,4 +43,15 @@ android:textSize="13sp" android:textStyle="bold" /> + + \ No newline at end of file diff --git a/res/layout/feeds_row_selected.xml b/res/layout/feeds_row_selected.xml index cb95a819..b1d53549 100644 --- a/res/layout/feeds_row_selected.xml +++ b/res/layout/feeds_row_selected.xml @@ -4,6 +4,7 @@ android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:background="?feedsSelectedBackgroundSolid" + android:descendantFocusability="blocksDescendants" android:gravity="center_vertical" android:orientation="horizontal" android:paddingBottom="10dip" @@ -43,4 +44,15 @@ android:textSize="13sp" android:textStyle="bold" /> + + \ No newline at end of file diff --git a/src/org/fox/ttrss/FeedCategoriesFragment.java b/src/org/fox/ttrss/FeedCategoriesFragment.java index 90889255..fdd44f9e 100644 --- a/src/org/fox/ttrss/FeedCategoriesFragment.java +++ b/src/org/fox/ttrss/FeedCategoriesFragment.java @@ -21,6 +21,7 @@ import android.support.v4.app.Fragment; import android.util.Log; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; +import android.view.View.OnClickListener; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -29,6 +30,7 @@ import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -406,6 +408,21 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe icon.setImageResource(cat.unread > 0 ? R.drawable.ic_rss : R.drawable.ic_rss_bw); } + ImageButton ib = (ImageButton) v.findViewById(R.id.feed_menu_button); + + if (ib != null) { + if (m_activity.isDarkTheme()) + ib.setImageResource(R.drawable.ic_mailbox_collapsed_holo_dark); + + ib.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + getActivity().openContextMenu(v); + } + }); + } + + return v; } } @@ -422,6 +439,8 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe public void onItemClick(AdapterView av, View view, int position, long id) { ListView list = (ListView)av; + Log.d(TAG, "onItemClick=" + position); + if (list != null) { FeedCategory cat = (FeedCategory)list.getItemAtPosition(position); diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index da428823..181d4418 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -34,6 +34,7 @@ import android.util.Base64; import android.util.Log; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; +import android.view.View.OnClickListener; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -42,6 +43,7 @@ import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -529,6 +531,20 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh } } + + ImageButton ib = (ImageButton) v.findViewById(R.id.feed_menu_button); + + if (ib != null) { + if (m_activity.isDarkTheme()) + ib.setImageResource(R.drawable.ic_mailbox_collapsed_holo_dark); + + ib.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + getActivity().openContextMenu(v); + } + }); + } return v; } diff --git a/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java b/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java index 85f49d6b..31cfcb03 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java +++ b/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java @@ -15,6 +15,7 @@ import android.support.v4.widget.SimpleCursorAdapter; import android.util.Log; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; +import android.view.View.OnClickListener; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -22,6 +23,7 @@ import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -282,6 +284,21 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli if (icon != null) { icon.setImageResource(cursor.getInt(cursor.getColumnIndex("unread")) > 0 ? R.drawable.ic_rss : R.drawable.ic_rss_bw); } + + ImageButton ib = (ImageButton) v.findViewById(R.id.feed_menu_button); + + if (ib != null) { + if (m_activity.isDarkTheme()) + ib.setImageResource(R.drawable.ic_mailbox_collapsed_holo_dark); + + ib.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + getActivity().openContextMenu(v); + } + }); + } + return v; } diff --git a/src/org/fox/ttrss/offline/OfflineFeedsFragment.java b/src/org/fox/ttrss/offline/OfflineFeedsFragment.java index 50e13afb..a2231485 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedsFragment.java +++ b/src/org/fox/ttrss/offline/OfflineFeedsFragment.java @@ -20,6 +20,7 @@ import android.support.v4.widget.SimpleCursorAdapter; import android.util.Log; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; +import android.view.View.OnClickListener; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -27,6 +28,7 @@ import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -307,6 +309,20 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene } + ImageButton ib = (ImageButton) v.findViewById(R.id.feed_menu_button); + + if (ib != null) { + if (m_activity.isDarkTheme()) + ib.setImageResource(R.drawable.ic_mailbox_collapsed_holo_dark); + + ib.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + getActivity().openContextMenu(v); + } + }); + } + return v; } } From c59613fe05efd051c0980af71e4b14bdad4c0d35 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 18 May 2013 14:01:47 +0400 Subject: [PATCH 6/8] remove compat check for actionbar up enabled --- src/org/fox/ttrss/FeedsActivity.java | 8 +++----- src/org/fox/ttrss/HeadlinesActivity.java | 4 +--- src/org/fox/ttrss/offline/OfflineFeedsActivity.java | 8 +++----- src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java | 4 +--- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/org/fox/ttrss/FeedsActivity.java b/src/org/fox/ttrss/FeedsActivity.java index 43ae5152..3682ba08 100644 --- a/src/org/fox/ttrss/FeedsActivity.java +++ b/src/org/fox/ttrss/FeedsActivity.java @@ -58,10 +58,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe if (intent.getParcelableExtra("feed") != null || intent.getParcelableExtra("category") != null || intent.getParcelableExtra("article") != null) { - if (!isCompatMode()) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - m_actionbarUpEnabled = true; - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + m_actionbarUpEnabled = true; Feed feed = (Feed) intent.getParcelableExtra("feed"); FeedCategory cat = (FeedCategory) intent.getParcelableExtra("category"); @@ -127,7 +125,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe container.setWeightSum(3f); } - if (!isCompatMode() && m_actionbarUpEnabled) { + if (m_actionbarUpEnabled) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); } } diff --git a/src/org/fox/ttrss/HeadlinesActivity.java b/src/org/fox/ttrss/HeadlinesActivity.java index 505f3344..b44b4388 100644 --- a/src/org/fox/ttrss/HeadlinesActivity.java +++ b/src/org/fox/ttrss/HeadlinesActivity.java @@ -33,9 +33,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL setContentView(R.layout.headlines); - if (!isCompatMode()) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); setSmallScreen(findViewById(R.id.headlines_fragment) == null); diff --git a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java index dea8d336..30a08213 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java +++ b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java @@ -45,7 +45,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled"); - if (!isCompatMode() && m_actionbarUpEnabled) { + if (m_actionbarUpEnabled) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @@ -55,10 +55,8 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead if (intent.getIntExtra("feed", -10000) != -10000 || intent.getIntExtra("category", -10000) != -10000 || intent.getIntExtra("article", -10000) != -10000) { - if (!isCompatMode()) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - m_actionbarUpEnabled = true; - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + m_actionbarUpEnabled = true; FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); diff --git a/src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java b/src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java index 9aabfc9d..3ae56bdb 100644 --- a/src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java +++ b/src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java @@ -33,9 +33,7 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline setContentView(R.layout.headlines); - if (!isCompatMode()) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + getSupportActionBar().setDisplayHomeAsUpEnabled(true); setSmallScreen(findViewById(R.id.headlines_fragment) == null); From 858e2c93c9b587d31eff69a8441c008f08947a21 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 18 May 2013 14:27:04 +0400 Subject: [PATCH 7/8] better handle moving back from nested feeds --- src/org/fox/ttrss/FeedCategoriesFragment.java | 4 +-- src/org/fox/ttrss/FeedsActivity.java | 31 ++++++++++++++++- src/org/fox/ttrss/OnlineActivity.java | 4 +-- .../fox/ttrss/offline/OfflineActivity.java | 4 +-- .../OfflineFeedCategoriesFragment.java | 4 +-- .../ttrss/offline/OfflineFeedsActivity.java | 33 ++++++++++++++++++- .../offline/OfflineHeadlinesActivity.java | 22 +++++++++++++ 7 files changed, 92 insertions(+), 10 deletions(-) diff --git a/src/org/fox/ttrss/FeedCategoriesFragment.java b/src/org/fox/ttrss/FeedCategoriesFragment.java index fdd44f9e..144ea7c8 100644 --- a/src/org/fox/ttrss/FeedCategoriesFragment.java +++ b/src/org/fox/ttrss/FeedCategoriesFragment.java @@ -457,8 +457,8 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe } } - if (!m_activity.isSmallScreen()) - m_selectedCat = cat; + //if (!m_activity.isSmallScreen()) + // m_selectedCat = cat; m_adapter.notifyDataSetChanged(); } diff --git a/src/org/fox/ttrss/FeedsActivity.java b/src/org/fox/ttrss/FeedsActivity.java index 3682ba08..914d5461 100644 --- a/src/org/fox/ttrss/FeedsActivity.java +++ b/src/org/fox/ttrss/FeedsActivity.java @@ -34,6 +34,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe protected long m_lastRefresh = 0; private boolean m_actionbarUpEnabled = false; + private int m_actionbarRevertDepth = 0; @SuppressLint("NewApi") @Override @@ -118,6 +119,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe } } else { // savedInstanceState != null m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled"); + m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth"); if (!isSmallScreen()) { // temporary hack because FeedsActivity doesn't track whether active feed is open @@ -235,7 +237,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe } public void onCatSelected(FeedCategory cat, boolean openAsFeed) { - + FeedCategoriesFragment fc = (FeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS); + if (!openAsFeed) { if (isSmallScreen()) { @@ -246,6 +249,10 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe startActivityForResult(intent, 0); } else { + if (fc != null) { + fc.setSelectedCategory(null); + } + FragmentTransaction ft = getSupportFragmentManager() .beginTransaction(); @@ -255,8 +262,17 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe ft.addToBackStack(null); ft.commit(); + + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + m_actionbarUpEnabled = true; + m_actionbarRevertDepth = m_actionbarRevertDepth + 1; } } else { + + if (fc != null) { + fc.setSelectedCategory(cat); + } + Feed feed = new Feed(cat.id, cat.title, true); onFeedSelected(feed); } @@ -269,6 +285,18 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { + case android.R.id.home: + if (m_actionbarRevertDepth > 0) { + + m_actionbarRevertDepth = m_actionbarRevertDepth - 1; + m_actionbarUpEnabled = m_actionbarRevertDepth > 0; + getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled); + + onBackPressed(); + } else { + finish(); + } + return true; case R.id.show_feeds: setUnreadOnly(!getUnreadOnly()); initMenu(); @@ -297,6 +325,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe super.onSaveInstanceState(out); out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled); + out.putInt("actionbarRevertDepth", m_actionbarRevertDepth); GlobalState.getInstance().save(out); } diff --git a/src/org/fox/ttrss/OnlineActivity.java b/src/org/fox/ttrss/OnlineActivity.java index 1606c728..c3696d02 100644 --- a/src/org/fox/ttrss/OnlineActivity.java +++ b/src/org/fox/ttrss/OnlineActivity.java @@ -621,9 +621,9 @@ public class OnlineActivity extends CommonActivity { final ArticlePager ap = (ArticlePager)getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE); switch (item.getItemId()) { - case android.R.id.home: + /* case android.R.id.home: finish(); - return true; + return true; */ case R.id.subscribe_to_feed: Intent subscribe = new Intent(OnlineActivity.this, SubscribeActivity.class); startActivityForResult(subscribe, 0); diff --git a/src/org/fox/ttrss/offline/OfflineActivity.java b/src/org/fox/ttrss/offline/OfflineActivity.java index 319b76c8..de437fcf 100644 --- a/src/org/fox/ttrss/offline/OfflineActivity.java +++ b/src/org/fox/ttrss/offline/OfflineActivity.java @@ -169,9 +169,9 @@ public class OfflineActivity extends CommonActivity { .findFragmentByTag(FRAG_ARTICLE); switch (item.getItemId()) { - case android.R.id.home: + /* case android.R.id.home: finish(); - return true; + return true; */ case R.id.go_online: switchOnline(); return true; diff --git a/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java b/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java index 31cfcb03..426cda0d 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java +++ b/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java @@ -197,8 +197,8 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli m_activity.onCatSelected(feedId); } - if (!m_activity.isSmallScreen()) - m_selectedCatId = feedId; + /* if (!m_activity.isSmallScreen()) + m_selectedCatId = feedId; */ m_adapter.notifyDataSetChanged(); } diff --git a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java index 30a08213..fc0f521f 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java +++ b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java @@ -24,6 +24,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead private final String TAG = this.getClass().getSimpleName(); private boolean m_actionbarUpEnabled = false; + private int m_actionbarRevertDepth = 0; @SuppressLint("NewApi") @Override @@ -44,6 +45,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead if (savedInstanceState != null) { m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled"); + m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth"); if (m_actionbarUpEnabled) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); @@ -127,6 +129,18 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { + case android.R.id.home: + if (m_actionbarRevertDepth > 0) { + + m_actionbarRevertDepth = m_actionbarRevertDepth - 1; + m_actionbarUpEnabled = m_actionbarRevertDepth > 0; + getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled); + + onBackPressed(); + } else { + finish(); + } + return true; case R.id.show_feeds: setUnreadOnly(!getUnreadOnly()); initMenu(); @@ -143,6 +157,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead super.onSaveInstanceState(out); out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled); + out.putInt("actionbarRevertDepth", m_actionbarRevertDepth); GlobalState.getInstance().save(out); } @@ -179,7 +194,13 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead } public void onCatSelected(int catId, boolean openAsFeed) { + OfflineFeedCategoriesFragment fc = (OfflineFeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS); + if (openAsFeed) { + if (fc != null) { + fc.setSelectedFeedId(catId); + } + onFeedSelected(catId, true, true); } else { if (isSmallScreen()) { @@ -188,6 +209,10 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead startActivityForResult(intent, 0); } else { + if (fc != null) { + fc.setSelectedFeedId(-1); + } + FragmentTransaction ft = getSupportFragmentManager() .beginTransaction(); @@ -196,6 +221,10 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS); ft.addToBackStack(null); + + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + m_actionbarUpEnabled = true; + m_actionbarRevertDepth = m_actionbarRevertDepth + 1; ft.commit(); } @@ -303,7 +332,9 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead intent.putExtra("isCat", hf.getFeedIsCat()); intent.putExtra("article", articleId); - startActivityForResult(intent, 0); + startActivityForResult(intent, 0); + + overridePendingTransition(R.anim.right_slide_in, 0); } } else { refresh(); diff --git a/src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java b/src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java index 3ae56bdb..cfd1e19e 100644 --- a/src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java +++ b/src/org/fox/ttrss/offline/OfflineHeadlinesActivity.java @@ -3,6 +3,8 @@ package org.fox.ttrss.offline; import org.fox.ttrss.GlobalState; import org.fox.ttrss.R; +import com.actionbarsherlock.view.MenuItem; + import android.annotation.SuppressLint; import android.content.Intent; import android.content.SharedPreferences; @@ -13,6 +15,7 @@ import android.preference.PreferenceManager; import android.provider.BaseColumns; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; +import android.util.Log; import android.view.View; public class OfflineHeadlinesActivity extends OfflineActivity implements OfflineHeadlinesEventListener { @@ -90,6 +93,19 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline initMenu(); } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + overridePendingTransition(0, R.anim.right_slide_out); + return true; + default: + Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId()); + return super.onOptionsItemSelected(item); + } + } + @Override public void onArticleSelected(int articleId, boolean open) { SQLiteStatement stmt = getWritableDb().compileStatement( @@ -142,4 +158,10 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline public void onArticleSelected(int articleId) { onArticleSelected(articleId, true); } + + @Override + public void onBackPressed() { + super.onBackPressed(); + overridePendingTransition(0, R.anim.right_slide_out); + } } From 48f2680916df329bbe34365ee58ceed67dc082ba Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 18 May 2013 14:38:47 +0400 Subject: [PATCH 8/8] fix padding on headlinesfragment removed needlessly in portrait mode on sw600dp --- src/org/fox/ttrss/HeadlinesFragment.java | 2 +- src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index 0c5b09ec..c8a791b0 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -273,7 +273,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, //list.setEmptyView(view.findViewById(R.id.no_headlines)); registerForContextMenu(list); - if (m_activity.isSmallScreen() || m_activity.isPortrait()) + if (m_activity.isSmallScreen()) view.findViewById(R.id.headlines_fragment).setPadding(0, 0, 0, 0); Log.d(TAG, "onCreateView, feed=" + m_feed); diff --git a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index 85588195..b8ac6023 100644 --- a/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/src/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -284,7 +284,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis list.setEmptyView(view.findViewById(R.id.no_headlines)); registerForContextMenu(list); - if (m_activity.isSmallScreen() || m_activity.isPortrait()) + if (m_activity.isSmallScreen()) view.findViewById(R.id.headlines_fragment).setPadding(0, 0, 0, 0); getActivity().setProgressBarIndeterminateVisibility(false);