From 1fe01350a51152f0f596f3e2c6eaadb36f940b57 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 24 Nov 2011 14:51:23 +0300 Subject: [PATCH] more interface stuff, allow marking headlines as checked --- res/anim/slide_in_left.xml | 2 +- res/anim/slide_out_right.xml | 16 ++--- res/drawable-hdpi/mark_set.png | Bin 1530 -> 0 bytes res/drawable-hdpi/mark_unset.png | Bin 1433 -> 0 bytes res/drawable/mark_set.svg | 77 ---------------------- res/drawable/mark_unset.svg | 79 ----------------------- res/layout/article_fragment.xml | 2 +- res/layout/headlines_row.xml | 2 +- res/layout/headlines_row_selected.xml | 6 +- res/layout/headlines_row_unread.xml | 6 +- res/layout/main.xml | 16 ++--- res/values/attrs.xml | 6 +- res/values/style.xml | 13 +++- src/org/fox/ttrss/Article.java | 1 + src/org/fox/ttrss/HeadlinesFragment.java | 43 +++++++++++- src/org/fox/ttrss/MainActivity.java | 13 +--- 16 files changed, 85 insertions(+), 197 deletions(-) delete mode 100644 res/drawable-hdpi/mark_set.png delete mode 100644 res/drawable-hdpi/mark_unset.png delete mode 100644 res/drawable/mark_set.svg delete mode 100644 res/drawable/mark_unset.svg diff --git a/res/anim/slide_in_left.xml b/res/anim/slide_in_left.xml index 11991019..b51d378c 100644 --- a/res/anim/slide_in_left.xml +++ b/res/anim/slide_in_left.xml @@ -3,7 +3,7 @@ \ No newline at end of file diff --git a/res/anim/slide_out_right.xml b/res/anim/slide_out_right.xml index cc43178e..d7854d63 100644 --- a/res/anim/slide_out_right.xml +++ b/res/anim/slide_out_right.xml @@ -1,11 +1,9 @@ - - - - + + \ No newline at end of file diff --git a/res/drawable-hdpi/mark_set.png b/res/drawable-hdpi/mark_set.png deleted file mode 100644 index bd7c3755fe3e6ed22a8953319aff1d023c86ad4f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1530 zcmV*su@x*WNHBU(Ahac# zCShlh3{6~$O2?+C1Y0<7>4?k$ z5tU$7H(vsJfFr7Ic1NWrG6#Tjj^~e~Qldn$22|aA9=MiAK5S^BKWtr5Mc}*#?VJbg zp%HonRNXuP{OQyDf}x4u!_*f=1ahNaCFJGR78XK{fU28az#yOi?Aa>m!;?9dEO5}! z#6Va&!;Zj5SjGzl_C78zq2$^XizhUM=76f3&j4@Q?`_Rc7n4_8vy1f&RX6vBr8mq7 zoVDc%1v*n34V@`h6a*ngAruEx-E0Hiw%>PchD3a$JrS2Q2i{V3^XV{jhZTXdSb3F_ zH~Ka@Q?kuM6>ugD#SiU(s++CAyY_o)6Esv8@-Sjxxf%d%}@EF?->}-NV zyNWC9zXjtnCGA=PMksXbx}k}?E(cCt$h;36br@P-QoIjd?SLkq(YG;^hVO?e)d0W( z8xCDjPF~3D2Ks>QK_v(U>f>@=+gGv{wkCr0pIn65Wtd;txE5ByEH5dT0D6^dHfwK# zeSm9G)x{uL0}VCMU>jTmiI{6g2?g0KEUv+P+Hz`DKF_9MX{~^L4Cpm9F`8Qg){bx) zc*^G5nt-G25R0>~e#9QpfR zeSDXv)u9_%pa4>E-wmlKY^r%w=F%`!bZmlQXtKcgYrwG}#zPtDw4sR^;DnRbSTwZ@1`io0EM0+6?l-o@ z`O;KdW^WI8$Y}9k^F_H1bU9!A^8Rv=ER@mZ!RCvK9Z1B($&oe*cl}Jn4(ziZJVvf! zgE@oDq$PG`H&hwM*bx>9W%BhL#fjO*`w-;Lrj!FPo@7|h%!GBUvN^No%OMw@1Ig9u<#ZN94fiHnC z3{A}X$VdVo0v`ay&M+nnP3#C_SI}%U3HaqFYrxmQXT|dNJb5YP-9E0s94l_0R0Ms+&iU8^9q#b|3@1ZfN4W%1jIfYhVtm gx_KOUB}kwD0YV7D5f6&>CIA2c07*qoM6N<$f?Tw>Q~&?~ diff --git a/res/drawable-hdpi/mark_unset.png b/res/drawable-hdpi/mark_unset.png deleted file mode 100644 index cb29576cad1f7b7f45d779fd3f2978441677bcdf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1433 zcm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9mX>~<$R7EWgT+AXzl7j0{N)5=_fmY`^i{TTctF>aS2&DbN z;r33f14?rj@V0&ZLW-rsttdLZkyqQ>QfBf!~17>@}q{Z`gfx z6kJ_vELS3=8A8njw}F%43Q9AG`GS58Jn9++d38JkA+WLB}eLBkuwC#ONwY!NW=HO5}hgu9TlF0AB(h#pUfG zef5~XHE&V*C}nk}j&PB52t|d|0}caCQm`Yb@nAMfQm_MPvO1!AG0`we>OfoQ{TSv~ z(KacVO{k*`QZOq8+ko{}XB=lF(mF5#bVgQQDzOM`k%I4+ nVP9fM!B0S^(hLAECTa6O4l#&vl&W(Y00000NkvXXu0mjfr16D# diff --git a/res/drawable/mark_set.svg b/res/drawable/mark_set.svg deleted file mode 100644 index 5f55e61a..00000000 --- a/res/drawable/mark_set.svg +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/res/drawable/mark_unset.svg b/res/drawable/mark_unset.svg deleted file mode 100644 index 0d46aeb0..00000000 --- a/res/drawable/mark_unset.svg +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/res/layout/article_fragment.xml b/res/layout/article_fragment.xml index 4610d207..de8caed0 100644 --- a/res/layout/article_fragment.xml +++ b/res/layout/article_fragment.xml @@ -1,6 +1,6 @@ - + - + diff --git a/res/layout/headlines_row_selected.xml b/res/layout/headlines_row_selected.xml index 81760bc4..ff755483 100644 --- a/res/layout/headlines_row_selected.xml +++ b/res/layout/headlines_row_selected.xml @@ -2,9 +2,9 @@ - + android:background="?headlineSelectedBackground" + android:id="@+id/headlines_row" android:orientation="horizontal" android:layout_height="wrap_content"> + diff --git a/res/layout/headlines_row_unread.xml b/res/layout/headlines_row_unread.xml index e139cfad..f6fef283 100644 --- a/res/layout/headlines_row_unread.xml +++ b/res/layout/headlines_row_unread.xml @@ -2,9 +2,9 @@ - + android:background="?headlineUnreadBackground" + android:id="@+id/headlines_row" android:orientation="horizontal" android:layout_height="wrap_content"> + diff --git a/res/layout/main.xml b/res/layout/main.xml index ee05766b..1509b309 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -1,16 +1,16 @@ - - - - + + + + - - - - + + + + diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 9a6bbea0..6ed260dd 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -6,6 +6,10 @@ - + + + + + \ No newline at end of file diff --git a/res/values/style.xml b/res/values/style.xml index 69c2e1d6..ba524ccc 100644 --- a/res/values/style.xml +++ b/res/values/style.xml @@ -6,8 +6,12 @@ #ffffff #96c5ff #ffffff - #fff7d5 + #fff7d5 + #ffffff #96C5FF + #96C5FF + #909090 + #DBC981 \ No newline at end of file diff --git a/src/org/fox/ttrss/Article.java b/src/org/fox/ttrss/Article.java index 0e156af8..c4989d7a 100644 --- a/src/org/fox/ttrss/Article.java +++ b/src/org/fox/ttrss/Article.java @@ -14,4 +14,5 @@ public class Article { int feed_id; List tags; String content; + boolean _selected; } diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index 00e1448e..953bed54 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -16,12 +16,16 @@ import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.ListView; import android.widget.TextView; @@ -210,7 +214,20 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener { public static final int VIEW_SELECTED = 2; public static final int VIEW_COUNT = VIEW_SELECTED+1; + + private ArrayList
m_selectedArticles = new ArrayList
(); + /* private class ArticleCheckListener implements OnCheckedChangeListener { + + @Override + public void onCheckedChanged(CompoundButton buttonView, + boolean isChecked) { + + Log.d(TAG, "onCheckedChanged: " + buttonView + "/" + getContext()); + } + + } */ + public ArticleListAdapter(Context context, int textViewResourceId, ArrayList
items) { super(context, textViewResourceId, items); this.items = items; @@ -238,8 +255,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener { View v = convertView; - Article article = items.get(position); - + final Article article = items.get(position); + if (v == null) { int layoutId = R.layout.headlines_row; @@ -281,6 +298,28 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener { dv.setText(df.format(d)); } + CheckBox cb = (CheckBox) v.findViewById(R.id.selected); + + if (cb != null) { + cb.setChecked(m_selectedArticles.contains(article)); + + cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, + boolean isChecked) { + + if (isChecked) { + m_selectedArticles.add(article); + } else { + m_selectedArticles.remove(article); + } + + Log.d(TAG, "num selected: " + m_selectedArticles.size()); + + } + }); + } + return v; } } diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index 35309338..44625ad4 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -103,12 +103,9 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect ft.replace(R.id.feeds_fragment, new FeedsFragment()); ft.replace(R.id.headlines_fragment, hf); ft.replace(R.id.article_fragment, af); - //ft.hide(hf); - //ft.hide(af); ft.commit(); findViewById(R.id.article_fragment).setVisibility(View.GONE); - //findViewById(R.id.headlines_fragment).setVisibility(View.GONE); LoginRequest ar = new LoginRequest(); ar.setApi(m_prefs.getString("ttrss_url", null)); @@ -232,9 +229,6 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect setLoadingStatus(R.string.loading_message, true); - //FragmentManager fm = getFragmentManager(); - //FeedsFragment ff = (FeedsFragment) fm.findFragmentById(R.id.feeds_fragment); - ViewFlipper vf = (ViewFlipper) findViewById(R.id.main_flipper); if (vf != null) { @@ -245,6 +239,7 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.feeds_fragment, frag); + ft.show(frag); ft.commit(); if (m_refreshTask != null) { @@ -293,7 +288,6 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect m_activeFeed = feed; HeadlinesFragment hf = new HeadlinesFragment(); - //hf.initialize(m_sessionId, feed.id, m_prefs); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); @@ -301,8 +295,6 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect ft.replace(R.id.headlines_fragment, hf); ft.addToBackStack(null); ft.commit(); - - findViewById(R.id.headlines_fragment).setVisibility(View.VISIBLE); } public Article getSelectedArticle() { @@ -319,13 +311,14 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out); + //ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right); ft.show(getFragmentManager().findFragmentById(R.id.article_fragment)); - //ft.hide(getFragmentManager().findFragmentById(R.id.feeds_fragment)); ft.replace(R.id.article_fragment, frag); ft.addToBackStack(null); ft.commit(); findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); + } public Feed getActiveFeed() {