mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Added favicons as part of the initial feed / folder download.
This commit is contained in:
parent
d3187f749a
commit
5d362f3b55
11 changed files with 70 additions and 22 deletions
|
@ -2,18 +2,29 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:background="@color/white" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/row_feedname"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16dp"
|
||||
android:paddingBottom="10dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/row_feedname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/black"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginLeft="50dp"/>
|
||||
|
||||
android:textSize="16dp"
|
||||
android:layout_marginLeft="70dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/row_feedfavicon"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginLeft="40dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:contentDescription="@string/description_favicon" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -3,7 +3,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:background="@color/lightgray">
|
||||
|
||||
<TextView
|
||||
|
@ -13,7 +14,7 @@
|
|||
android:textSize="18dp"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginLeft="40dp"
|
||||
android:textColor="@color/darkgray" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -3,7 +3,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:background="@color/lightgray">
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<string name="description_login_button">Press to log in.</string>
|
||||
<string name="description_login_logo">NewsBlur Logo</string>
|
||||
<string name="description_signup_button">Press to sign up</string>
|
||||
<string name="description_favicon">The feed\'s favicon</string>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ public class BlurDatabase extends SQLiteOpenHelper {
|
|||
DatabaseConstants.FEED_ACTIVE + TEXT + ", " +
|
||||
DatabaseConstants.FEED_ADDRESS + TEXT + ", " +
|
||||
DatabaseConstants.FEED_FAVICON_COLOUR + TEXT + ", " +
|
||||
DatabaseConstants.FEED_FAVICON + TEXT + ", " +
|
||||
DatabaseConstants.FEED_FAVICON_FADE + TEXT + ", " +
|
||||
DatabaseConstants.FEED_LINK + TEXT + ", " +
|
||||
DatabaseConstants.FEED_SUBSCRIBERS + TEXT + ", " +
|
||||
|
|
|
@ -18,6 +18,7 @@ public class DatabaseConstants {
|
|||
public static final String FEED_FAVICON_FADE = "favicon_fade";
|
||||
public static final String FEED_FAVICON_COLOUR = "favicon_colour";
|
||||
public static final String FEED_ACTIVE = "active";
|
||||
public static final String FEED_FAVICON = "favicon";
|
||||
|
||||
public static final String FEED_FOLDER_MAP_TABLE = "feed_folder_map";
|
||||
public static final String FEED_FOLDER_FEED_ID = "feed_id";
|
||||
|
@ -42,5 +43,6 @@ public class DatabaseConstants {
|
|||
public static final String STORY_INTELLIGENCE_TITLE = "intelligence_title";
|
||||
public static final String STORY_READ = "read";
|
||||
public static final String STORY_FEED_ID = "feed_id";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,5 +23,5 @@ public class FolderTreeAdapter extends SimpleCursorTreeAdapter {
|
|||
final Uri uri = FeedProvider.FEED_FOLDER_MAP_URI.buildUpon().appendPath(parentFolder.getName()).build();
|
||||
return resolver.query(uri, null, null, null, null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ public class Feed {
|
|||
@SerializedName("favicon_color")
|
||||
public String faviconColour;
|
||||
|
||||
@SerializedName("favicon")
|
||||
public String favicon;
|
||||
|
||||
@SerializedName("favicon_fade")
|
||||
public String faviconFade;
|
||||
|
||||
|
@ -41,6 +44,7 @@ public class Feed {
|
|||
values.put(DatabaseConstants.FEED_ADDRESS, address);
|
||||
values.put(DatabaseConstants.FEED_FAVICON_COLOUR, faviconColour);
|
||||
values.put(DatabaseConstants.FEED_FAVICON_FADE, faviconFade);
|
||||
values.put(DatabaseConstants.FEED_FAVICON, favicon);
|
||||
values.put(DatabaseConstants.FEED_LINK, feedLink);
|
||||
values.put(DatabaseConstants.FEED_SUBSCRIBERS, subscribers);
|
||||
values.put(DatabaseConstants.FEED_TITLE, title);
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.newsblur.R;
|
|||
import com.newsblur.database.DatabaseConstants;
|
||||
import com.newsblur.database.FeedProvider;
|
||||
import com.newsblur.database.FolderTreeAdapter;
|
||||
import com.newsblur.view.FolderTreeViewBinder;
|
||||
|
||||
public class FolderFeedListFragment extends Fragment {
|
||||
|
||||
|
@ -29,12 +30,11 @@ public class FolderFeedListFragment extends Fragment {
|
|||
|
||||
final String[] groupFrom = new String[] { DatabaseConstants.FOLDER_NAME };
|
||||
final int[] groupTo = new int[] { R.id.row_foldername };
|
||||
final String[] childFrom = new String[] { DatabaseConstants.FEED_TITLE };
|
||||
final int[] childTo = new int[] { R.id.row_feedname };
|
||||
final String[] childFrom = new String[] { DatabaseConstants.FEED_TITLE, DatabaseConstants.FEED_FAVICON };
|
||||
final int[] childTo = new int[] { R.id.row_feedname, R.id.row_feedfavicon };
|
||||
|
||||
folderAdapter = new FolderTreeAdapter(getActivity(), cursor, R.layout.row_folder_collapsed, R.layout.row_folder_expanded, groupFrom, groupTo, R.layout.row_feed, childFrom, childTo);
|
||||
|
||||
|
||||
folderAdapter.setViewBinder(new FolderTreeViewBinder());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +42,7 @@ public class FolderFeedListFragment extends Fragment {
|
|||
View v = inflater.inflate(R.layout.fragment_folderfeedlist, container);
|
||||
list = (ExpandableListView) v.findViewById(R.id.folderfeed_list);
|
||||
list.setAdapter(folderAdapter);
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package com.newsblur.network;
|
|||
public class APIConstants {
|
||||
|
||||
public static final String URL_LOGIN = "http://newsblur.com/api/login";
|
||||
public static final String URL_FEEDS = "http://newsblur.com/reader/feeds/";
|
||||
public static final String URL_FEEDS = "http://newsblur.com/reader/feeds/?include_favicons=true";
|
||||
|
||||
public static final String USERNAME = "username";
|
||||
public static final String PASSWORD = "password";
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package com.newsblur.view;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SimpleCursorTreeAdapter.ViewBinder;
|
||||
|
||||
import com.newsblur.database.DatabaseConstants;
|
||||
|
||||
public class FolderTreeViewBinder implements ViewBinder {
|
||||
|
||||
@Override
|
||||
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
|
||||
if (TextUtils.equals(cursor.getColumnName(columnIndex), DatabaseConstants.FEED_FAVICON) && cursor.getBlob(columnIndex) != null) {
|
||||
final byte[] data = Base64.decode(cursor.getBlob(columnIndex), Base64.DEFAULT);
|
||||
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
|
||||
((ImageView) view).setImageBitmap(bitmap);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue