more drawer-y sidebar with header and adjusted row styles

This commit is contained in:
Andrew Dolgov 2015-02-11 15:54:04 +03:00
parent 0264b2d30f
commit 45de2b8f24
9 changed files with 134 additions and 53 deletions

View File

@ -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);

View File

@ -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<Feed>)m_feeds);
@ -319,7 +321,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
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<FeedList, Integer, Integer> {
/* public class GetIconsTask extends AsyncTask<FeedList, Integer, Integer> {
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) {

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="96dp"
android:orientation="vertical"
android:background="?articleHeader"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TextView
android:id="@+id/drawer_header_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:textColor="?articleHeaderTextColor"
android:text="test"
android:textSize="14sp"
android:textStyle="bold"
/>
<TextView
android:id="@+id/drawer_header_server"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?articleHeaderTextColor"
android:layout_marginLeft="16dp"
android:layout_marginTop="5dp"
android:text="example.org"
android:textSize="14sp"
android:textStyle="normal"
/>
</LinearLayout>
</RelativeLayout>

6
org.fox.ttrss/src/main/res/layout/feeds_goback.xml Normal file → Executable file
View File

@ -23,17 +23,17 @@
android:src="@drawable/ic_unpublished" />
<TextView
android:fontFamily="sans-serif-light"
android:fontFamily="sans-serif-medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:paddingLeft="16dp"
android:paddingLeft="40dp"
android:singleLine="true"
android:text=".."
android:paddingBottom="2dp"
android:textColor="?feedlistTextColor"
android:textSize="18sp" />
android:textSize="14sp" />
</LinearLayout>

12
org.fox.ttrss/src/main/res/layout/feeds_row.xml Normal file → Executable file
View File

@ -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" />
<TextView
android:id="@+id/title"
android:fontFamily="sans-serif-light"
android:fontFamily="sans-serif-medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:paddingLeft="16dp"
android:paddingLeft="40dp"
android:singleLine="true"
android:text="Feed"
android:paddingBottom="2dp"
android:textColor="?feedlistTextColor"
android:textSize="18sp" />
android:textSize="14sp" />
<TextView
android:id="@+id/unread_counter"
android:fontFamily="sans-serif-medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
@ -45,8 +46,7 @@
android:text="3200"
android:layout_marginLeft="16dp"
android:textColor="?unreadCounterColor"
android:textSize="14sp"
android:textStyle="bold" />
android:textSize="14sp" />
<ImageButton
android:id="@+id/feed_menu_button"

View File

@ -20,25 +20,26 @@
android:layout_height="16dp"
android:layout_weight="0"
android:scaleType="fitXY"
android:src="@drawable/ic_unpublished" />
android:src="@drawable/ic_menu_published_dark" />
<TextView
android:id="@+id/title"
android:fontFamily="sans-serif-light"
android:fontFamily="sans-serif-medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:paddingLeft="16dp"
android:paddingLeft="40dp"
android:singleLine="true"
android:text="Feed"
android:paddingBottom="2dp"
android:textColor="?feedlistSelectedTextColor"
android:textSize="18sp" />
android:textSize="14sp" />
<TextView
android:id="@+id/unread_counter"
android:fontFamily="sans-serif-medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
@ -46,8 +47,7 @@
android:text="3200"
android:layout_marginLeft="16dp"
android:textColor="?unreadCounterColor"
android:textSize="14sp"
android:textStyle="bold" />
android:textSize="14sp" />
<ImageButton
android:id="@+id/feed_menu_button"

2
org.fox.ttrss/src/main/res/layout/headlines.xml Normal file → Executable file
View File

@ -16,7 +16,7 @@
<FrameLayout
android:id="@+id/feeds_fragment"
android:layout_width="240dp"
android:layout_width="match_parent"
android:layout_gravity="start"
android:background="?feedlistBackground"
android:layout_height="match_parent" >

0
org.fox.ttrss/src/main/res/values/style.xml Normal file → Executable file
View File

4
org.fox.ttrss/src/main/res/xml/preferences.xml Normal file → Executable file
View File

@ -64,10 +64,10 @@
android:defaultValue="false"
android:key="sort_feeds_by_unread"
android:title="@string/sort_feeds_by_unread" />
<CheckBoxPreference
<!-- <CheckBoxPreference
android:defaultValue="false"
android:key="download_feed_icons"
android:title="@string/download_feed_icons" />
android:title="@string/download_feed_icons" /> -->
<CheckBoxPreference
android:defaultValue="false"
android:key="enable_cats"