From 3cc0cb84104bb3d69ab276fe81a1ce42ec31cc4e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 24 Nov 2011 17:57:44 +0300 Subject: [PATCH] various layout tweaks fix logout action --- res/layout/article_fragment.xml | 6 +++--- res/layout/feeds_fragment.xml | 2 +- res/layout/feeds_row.xml | 4 ++-- res/layout/feeds_row_selected.xml | 4 ++-- res/layout/headlines_row.xml | 6 +++--- res/layout/headlines_row_selected.xml | 6 +++--- res/layout/headlines_row_unread.xml | 6 +++--- res/menu/login_menu.xml | 15 --------------- res/menu/main_menu.xml | 19 ++++++++++++++----- res/values/strings.xml | 2 +- res/values/style.xml | 4 ++-- src/org/fox/ttrss/ApiRequest.java | 1 - src/org/fox/ttrss/ArticleFragment.java | 23 ++++++----------------- src/org/fox/ttrss/FeedsFragment.java | 2 -- src/org/fox/ttrss/HeadlinesFragment.java | 22 ++++++++++++++++++++-- src/org/fox/ttrss/MainActivity.java | 18 ++++++++++++++++++ 16 files changed, 78 insertions(+), 62 deletions(-) delete mode 100644 res/menu/login_menu.xml diff --git a/res/layout/article_fragment.xml b/res/layout/article_fragment.xml index de8caed0..48b597de 100644 --- a/res/layout/article_fragment.xml +++ b/res/layout/article_fragment.xml @@ -7,10 +7,10 @@ android:layout_weight="1" android:layout_height="match_parent" android:orientation="vertical"> - - + + - + diff --git a/res/layout/feeds_fragment.xml b/res/layout/feeds_fragment.xml index 0dcbc1c4..32f2d229 100644 --- a/res/layout/feeds_fragment.xml +++ b/res/layout/feeds_fragment.xml @@ -6,6 +6,6 @@ - + diff --git a/res/layout/feeds_row.xml b/res/layout/feeds_row.xml index 08eafd32..8ef8bbac 100644 --- a/res/layout/feeds_row.xml +++ b/res/layout/feeds_row.xml @@ -10,7 +10,7 @@ android:layout_weight="1" android:layout_gravity="center_vertical" android:paddingLeft="6dip" - android:text="{FEED}" android:layout_width="wrap_content" android:textSize="21dp"/> + android:text="{FEED}" android:layout_width="wrap_content" android:textSize="18dip"/> + android:text="{123}" android:textSize="13dip"/> \ No newline at end of file diff --git a/res/layout/feeds_row_selected.xml b/res/layout/feeds_row_selected.xml index 7ee526f7..a694119b 100644 --- a/res/layout/feeds_row_selected.xml +++ b/res/layout/feeds_row_selected.xml @@ -11,7 +11,7 @@ android:layout_weight="1" android:layout_gravity="center_vertical" android:paddingLeft="6dip" - android:text="{FEED}" android:layout_width="wrap_content" android:textSize="21dp"/> + android:text="{FEED}" android:layout_width="wrap_content" android:textSize="18dip"/> + android:text="{123}" android:textSize="13dip"/> \ No newline at end of file diff --git a/res/layout/headlines_row.xml b/res/layout/headlines_row.xml index 69a94a04..79de6413 100644 --- a/res/layout/headlines_row.xml +++ b/res/layout/headlines_row.xml @@ -12,10 +12,10 @@ - - + + \ No newline at end of file diff --git a/res/layout/headlines_row_selected.xml b/res/layout/headlines_row_selected.xml index ff755483..92740519 100644 --- a/res/layout/headlines_row_selected.xml +++ b/res/layout/headlines_row_selected.xml @@ -14,11 +14,11 @@ - - + + \ No newline at end of file diff --git a/res/layout/headlines_row_unread.xml b/res/layout/headlines_row_unread.xml index f6fef283..12d089eb 100644 --- a/res/layout/headlines_row_unread.xml +++ b/res/layout/headlines_row_unread.xml @@ -15,10 +15,10 @@ - - + + \ No newline at end of file diff --git a/res/menu/login_menu.xml b/res/menu/login_menu.xml deleted file mode 100644 index 0c244247..00000000 --- a/res/menu/login_menu.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - diff --git a/res/menu/main_menu.xml b/res/menu/main_menu.xml index a4dcb9f3..57b6a65d 100644 --- a/res/menu/main_menu.xml +++ b/res/menu/main_menu.xml @@ -7,17 +7,20 @@ android:title="@string/login" android:showAsAction="ifRoom|withText"/> - - + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 5947deb9..ca217315 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -29,5 +29,5 @@ Show unread feeds Show all feeds Update - + Close article diff --git a/res/values/style.xml b/res/values/style.xml index ba524ccc..f931d5cb 100644 --- a/res/values/style.xml +++ b/res/values/style.xml @@ -5,7 +5,7 @@ #0000ff #ffffff #96c5ff - #ffffff + @android:color/transparent #fff7d5 #ffffff #96C5FF @@ -20,7 +20,7 @@ #0000ff #000000 #303030 - #101010 + @android:color/transparent #303060 #303030 #303060 diff --git a/src/org/fox/ttrss/ApiRequest.java b/src/org/fox/ttrss/ApiRequest.java index 5e06d682..5678b1fc 100644 --- a/src/org/fox/ttrss/ApiRequest.java +++ b/src/org/fox/ttrss/ApiRequest.java @@ -15,7 +15,6 @@ import android.util.Log; import com.google.gson.Gson; import com.google.gson.JsonElement; -import com.google.gson.JsonObject; import com.google.gson.JsonParser; public class ApiRequest extends AsyncTask, Integer, JsonElement> { diff --git a/src/org/fox/ttrss/ArticleFragment.java b/src/org/fox/ttrss/ArticleFragment.java index ed90041b..7e1d528f 100644 --- a/src/org/fox/ttrss/ArticleFragment.java +++ b/src/org/fox/ttrss/ArticleFragment.java @@ -4,22 +4,21 @@ import java.net.URLEncoder; import android.app.Activity; import android.app.Fragment; -import android.app.FragmentTransaction; import android.content.SharedPreferences; import android.os.Bundle; +import android.text.Html; +import android.text.method.LinkMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; -import android.widget.Button; import android.widget.TextView; -public class ArticleFragment extends Fragment implements View.OnClickListener { +public class ArticleFragment extends Fragment { private final String TAG = this.getClass().getSimpleName(); protected SharedPreferences m_prefs; - //private int m_articleId; private String m_sessionId; private Article m_article; @@ -38,7 +37,8 @@ public class ArticleFragment extends Fragment implements View.OnClickListener { TextView title = (TextView)view.findViewById(R.id.title); if (title != null) { - title.setText(m_article.title); + title.setText(Html.fromHtml("" + m_article.title + "")); + title.setMovementMethod(LinkMovementMethod.getInstance()); } WebView web = (WebView)view.findViewById(R.id.content); @@ -46,6 +46,7 @@ public class ArticleFragment extends Fragment implements View.OnClickListener { if (web != null) { // this is ridiculous + // TODO white on black style for dark theme String content = URLEncoder.encode("" + "" + "" + m_article.content + "").replace('+', ' '); @@ -53,11 +54,6 @@ public class ArticleFragment extends Fragment implements View.OnClickListener { web.loadData(content, "text/html", "utf-8"); } - Button btn = (Button)view.findViewById(R.id.close_button); - - if (btn != null) { - btn.setOnClickListener(this); - } } return view; @@ -86,11 +82,4 @@ public class ArticleFragment extends Fragment implements View.OnClickListener { //m_prefs = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()); } - - @Override - public void onClick(View v) { - getActivity().findViewById(R.id.article_fragment).setVisibility(View.GONE); - getActivity().findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE); - } - } diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index 35c5a490..7d7863f3 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -12,11 +12,9 @@ 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.AbsListView; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index e1928d52..65cf2c6f 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -19,6 +19,7 @@ import android.preference.PreferenceManager; import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; @@ -26,6 +27,7 @@ import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; +import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -279,13 +281,29 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener { v = vi.inflate(layoutId, null); } - TextView tt = (TextView) v.findViewById(R.id.title); + TextView tt = (TextView)v.findViewById(R.id.title); if (tt != null) { tt.setText(article.title); } - TextView te = (TextView) v.findViewById(R.id.excerpt); + ImageView marked = (ImageView)v.findViewById(R.id.marked); + + if (marked != null) { + marked.setImageResource(article.marked ? android.R.drawable.star_on : android.R.drawable.star_off); + + marked.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + Log.d(TAG, "Marked image clicked " + v + " / " + article.id + "/" + article.marked); + article.marked = !article.marked; + m_adapter.notifyDataSetChanged(); + } + }); + } + + TextView te = (TextView)v.findViewById(R.id.excerpt); if (te != null) { String excerpt = Jsoup.parse(article.content).text(); diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index 9c0e789b..8ef91d39 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -191,6 +191,9 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect case R.id.login: login(); return true; + case R.id.close_article: + closeArticle(); + return true; case R.id.show_feeds: if (getUnreadOnly()) { item.setTitle(R.string.menu_unread_feeds); @@ -205,6 +208,16 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect } } + public void closeArticle() { + findViewById(R.id.article_fragment).setVisibility(View.GONE); + findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE); + + if (m_menu != null) + m_menu.findItem(R.id.close_article).setVisible(false); + + m_selectedArticle = null; + } + private class LoginRequest extends ApiRequest { protected void onPostExecute(JsonElement result) { @@ -316,6 +329,9 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect findViewById(R.id.feeds_fragment).setVisibility(View.GONE); findViewById(R.id.article_fragment).setVisibility(View.VISIBLE); + if (m_menu != null) + m_menu.findItem(R.id.close_article).setVisible(true); + } public Feed getActiveFeed() { @@ -327,9 +343,11 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect findViewById(R.id.main).setVisibility(View.INVISIBLE); if (m_menu != null) { + m_menu.findItem(R.id.login).setVisible(true); m_menu.findItem(R.id.logout).setVisible(false); m_menu.findItem(R.id.update).setVisible(false); m_menu.findItem(R.id.show_feeds).setVisible(false); + m_menu.findItem(R.id.close_article).setVisible(false); } if (m_refreshTask != null) {