From 45de2b8f245a767a368c6af60a193474285c8ebe Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 11 Feb 2015 15:54:04 +0300 Subject: [PATCH] more drawer-y sidebar with header and adjusted row styles --- .../org/fox/ttrss/FeedCategoriesFragment.java | 23 +++++- .../java/org/fox/ttrss/FeedsFragment.java | 82 +++++++++++-------- .../src/main/res/layout/drawer_header.xml | 46 +++++++++++ .../src/main/res/layout/feeds_goback.xml | 6 +- .../src/main/res/layout/feeds_row.xml | 12 +-- .../main/res/layout/feeds_row_selected.xml | 12 +-- .../src/main/res/layout/headlines.xml | 2 +- org.fox.ttrss/src/main/res/values/style.xml | 0 .../src/main/res/xml/preferences.xml | 4 +- 9 files changed, 134 insertions(+), 53 deletions(-) mode change 100644 => 100755 org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java mode change 100644 => 100755 org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java create mode 100755 org.fox.ttrss/src/main/res/layout/drawer_header.xml mode change 100644 => 100755 org.fox.ttrss/src/main/res/layout/feeds_goback.xml mode change 100644 => 100755 org.fox.ttrss/src/main/res/layout/feeds_row.xml mode change 100644 => 100755 org.fox.ttrss/src/main/res/layout/feeds_row_selected.xml mode change 100644 => 100755 org.fox.ttrss/src/main/res/layout/headlines.xml mode change 100644 => 100755 org.fox.ttrss/src/main/res/values/style.xml mode change 100644 => 100755 org.fox.ttrss/src/main/res/xml/preferences.xml diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java old mode 100644 new mode 100755 index 0c77f54e..17f1db05 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java @@ -39,6 +39,8 @@ import org.fox.ttrss.types.FeedCategory; import org.fox.ttrss.types.FeedCategoryList; import java.lang.reflect.Type; +import java.net.MalformedURLException; +import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -214,6 +216,19 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe list.setOnItemClickListener(this); registerForContextMenu(list); + View layout = inflater.inflate(R.layout.drawer_header, container, false); + list.addHeaderView(layout, null, false); + + TextView login = (TextView) view.findViewById(R.id.drawer_header_login); + TextView server = (TextView) view.findViewById(R.id.drawer_header_server); + + login.setText(m_prefs.getString("login", "")); + try { + server.setText(new URL(m_prefs.getString("ttrss_url", "")).getHost()); + } catch (MalformedURLException e) { + server.setText(""); + } + View loadingBar = (View) view.findViewById(R.id.feeds_loading_bar); loadingBar.setVisibility(View.VISIBLE); @@ -473,7 +488,13 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe ImageView icon = (ImageView)v.findViewById(R.id.icon); if (icon != null) { - icon.setImageResource(cat.unread > 0 ? R.drawable.ic_published : R.drawable.ic_unpublished); + if (m_activity.isDarkTheme()) { + icon.setImageResource(R.drawable.ic_published); + } else { + icon.setImageResource(R.drawable.ic_menu_published_dark); + } + + //icon.setImageResource(cat.unread > 0 ? R.drawable.ic_published : R.drawable.ic_unpublished); } ImageButton ib = (ImageButton) v.findViewById(R.id.feed_menu_button); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java old mode 100644 new mode 100755 index 1ccbb05c..63605765 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsFragment.java @@ -8,18 +8,11 @@ import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Typeface; -import android.net.http.AndroidHttpClient; -import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; -import android.os.Environment; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.support.v4.widget.SwipeRefreshLayout; -import android.util.Base64; import android.util.Log; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; @@ -46,12 +39,8 @@ import org.fox.ttrss.types.Feed; import org.fox.ttrss.types.FeedCategory; import org.fox.ttrss.types.FeedList; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; import java.lang.reflect.Type; -import java.net.HttpURLConnection; +import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collections; @@ -68,7 +57,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh private Feed m_selectedFeed; private FeedCategory m_activeCategory; private static final String ICON_PATH = "/icons/"; - private boolean m_enableFeedIcons; + //private boolean m_enableFeedIcons; private boolean m_feedIconsChecked = false; private SwipeRefreshLayout m_swipeLayout; private boolean m_enableParentBtn = false; @@ -310,6 +299,19 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh }); list.addHeaderView(layout, null, false); + } else { + View layout = inflater.inflate(R.layout.drawer_header, container, false); + list.addHeaderView(layout, null, false); + + TextView login = (TextView) view.findViewById(R.id.drawer_header_login); + TextView server = (TextView) view.findViewById(R.id.drawer_header_server); + + login.setText(m_prefs.getString("login", "")); + try { + server.setText(new URL(m_prefs.getString("ttrss_url", "")).getHost()); + } catch (MalformedURLException e) { + server.setText(""); + } } m_adapter = new FeedListAdapter(getActivity(), R.layout.feeds_row, (ArrayList)m_feeds); @@ -318,8 +320,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh list.setOnItemClickListener(this); registerForContextMenu(list); - - m_enableFeedIcons = m_prefs.getBoolean("download_feed_icons", false); + + //m_enableFeedIcons = m_prefs.getBoolean("download_feed_icons", false); View loadingBar = (View) view.findViewById(R.id.feeds_loading_bar); loadingBar.setVisibility(View.VISIBLE); @@ -438,7 +440,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh } */ @SuppressWarnings({ "serial" }) - public void getFeedIcons() { + /* public void getFeedIcons() { ApiRequest req = new ApiRequest(getActivity().getApplicationContext()) { protected void onPostExecute(JsonElement result) { @@ -487,7 +489,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh }; req.execute(map); - } + } */ private class FeedsRequest extends ApiRequest { private int m_catId; @@ -570,8 +572,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh //m_activity.setLoadingStatus(R.string.blank, false); //m_adapter.notifyDataSetChanged(); (done by sortFeeds) - if (m_enableFeedIcons && !m_feedIconsChecked && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) - getFeedIcons(); + /* if (m_enableFeedIcons && !m_feedIconsChecked && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) + getFeedIcons(); */ return; } @@ -670,7 +672,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh if ((feed.is_cat && feed.always_display_as_feed) || (!feed.is_cat && feed.id == -4)) { icon.setImageResource(R.drawable.ic_published_special); - } else if (m_enableFeedIcons) { + /* } else if (m_enableFeedIcons) { try { File storage = m_activity.getExternalCacheDir(); @@ -682,14 +684,31 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh icon.setImageBitmap(bmpOrig); } } else { - icon.setImageResource(feed.unread > 0 ? R.drawable.ic_published : R.drawable.ic_unpublished); + if (m_activity.isDarkTheme()) { + icon.setImageResource(R.drawable.ic_published); + } else { + icon.setImageResource(R.drawable.ic_menu_published_dark); + } + + //icon.setImageResource(feed.unread > 0 ? R.drawable.ic_published : R.drawable.ic_unpublished); } } catch (NullPointerException e) { - icon.setImageResource(feed.unread > 0 ? R.drawable.ic_published : R.drawable.ic_unpublished); - } + //icon.setImageResource(feed.unread > 0 ? R.drawable.ic_published : R.drawable.ic_unpublished); + if (m_activity.isDarkTheme()) { + icon.setImageResource(R.drawable.ic_published); + } else { + icon.setImageResource(R.drawable.ic_menu_published_dark); + } + } */ } else { - icon.setImageResource(feed.unread > 0 ? R.drawable.ic_published : R.drawable.ic_unpublished); + //icon.setImageResource(feed.unread > 0 ? R.drawable.ic_published : R.drawable.ic_unpublished); + + if (m_activity.isDarkTheme()) { + icon.setImageResource(R.drawable.ic_published); + } else { + icon.setImageResource(R.drawable.ic_menu_published_dark); + } } } @@ -736,7 +755,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh } } - public class GetIconsTask extends AsyncTask { + /* public class GetIconsTask extends AsyncTask { private String m_baseUrl; @@ -779,11 +798,6 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh protected void downloadFile(String fetchUrl, String outputFile) { AndroidHttpClient client = AndroidHttpClient.newInstance("Tiny Tiny RSS"); - /* ApiRequest.disableConnectionReuseIfNecessary(); */ - - /* ApiRequest.trustAllHosts(m_prefs.getBoolean("ssl_trust_any", false), - m_prefs.getBoolean("ssl_trust_any_host", false)); */ - try { URL url = new URL(fetchUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); @@ -828,14 +842,14 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh m_adapter.notifyDataSetChanged(); } - } + } */ @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { sortFeeds(); - m_enableFeedIcons = m_prefs.getBoolean("download_feed_icons", false); + //m_enableFeedIcons = m_prefs.getBoolean("download_feed_icons", false); } @@ -851,7 +865,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh } } - public Feed getSelectedFeed() { + /* public Feed getSelectedFeed() { return m_selectedFeed; } @@ -861,7 +875,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh if (m_adapter != null) { m_adapter.notifyDataSetChanged(); } - } + } */ /* @Override public void onRefreshStarted(View view) { diff --git a/org.fox.ttrss/src/main/res/layout/drawer_header.xml b/org.fox.ttrss/src/main/res/layout/drawer_header.xml new file mode 100755 index 00000000..f60cd3ea --- /dev/null +++ b/org.fox.ttrss/src/main/res/layout/drawer_header.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/org.fox.ttrss/src/main/res/layout/feeds_goback.xml b/org.fox.ttrss/src/main/res/layout/feeds_goback.xml old mode 100644 new mode 100755 index bace3d5f..39525829 --- a/org.fox.ttrss/src/main/res/layout/feeds_goback.xml +++ b/org.fox.ttrss/src/main/res/layout/feeds_goback.xml @@ -23,17 +23,17 @@ android:src="@drawable/ic_unpublished" /> + android:textSize="14sp" /> \ No newline at end of file diff --git a/org.fox.ttrss/src/main/res/layout/feeds_row.xml b/org.fox.ttrss/src/main/res/layout/feeds_row.xml old mode 100644 new mode 100755 index 362dffa9..3cb5433f --- a/org.fox.ttrss/src/main/res/layout/feeds_row.xml +++ b/org.fox.ttrss/src/main/res/layout/feeds_row.xml @@ -19,25 +19,26 @@ android:layout_height="16dp" android:layout_weight="0" android:scaleType="fitXY" - android:src="@drawable/ic_unpublished" /> + android:src="@drawable/ic_menu_published_dark" /> + android:textSize="14sp" /> + android:textSize="14sp" /> + android:src="@drawable/ic_menu_published_dark" /> + android:textSize="14sp" /> + android:textSize="14sp" /> diff --git a/org.fox.ttrss/src/main/res/values/style.xml b/org.fox.ttrss/src/main/res/values/style.xml old mode 100644 new mode 100755 diff --git a/org.fox.ttrss/src/main/res/xml/preferences.xml b/org.fox.ttrss/src/main/res/xml/preferences.xml old mode 100644 new mode 100755 index 682224c1..a97c2566 --- a/org.fox.ttrss/src/main/res/xml/preferences.xml +++ b/org.fox.ttrss/src/main/res/xml/preferences.xml @@ -64,10 +64,10 @@ android:defaultValue="false" android:key="sort_feeds_by_unread" android:title="@string/sort_feeds_by_unread" /> - + android:title="@string/download_feed_icons" /> -->