Skip to content

Commit 5f0ddef

Browse files
Update widget - Fix #367
1 parent 7431ad4 commit 5f0ddef

File tree

4 files changed

+78
-79
lines changed

4 files changed

+78
-79
lines changed

News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/database/DatabaseConnectionOrm.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ public List<RssItem> getAllNewUnstarredRssItems() {
317317
return daoSession.getRssItemDao().queryBuilder().where(RssItemDao.Properties.Starred.eq(true), RssItemDao.Properties.Starred_temp.eq(false)).list();
318318
}
319319

320+
public LazyList<RssItem> getAllUnreadRssItemsForWidget() {
321+
return daoSession.getRssItemDao().queryBuilder().where(RssItemDao.Properties.Read_temp.eq(false)).limit(100).orderDesc(RssItemDao.Properties.PubDate).listLazy();
322+
}
323+
320324
public LazyList<RssItem> getAllItemsWithIdHigher(long id) {
321325
return daoSession.getRssItemDao().queryBuilder().where(RssItemDao.Properties.Id.ge(id)).listLazyUncached();
322326
}
@@ -412,12 +416,6 @@ public Long getLowestItemIdByFolder(Long id_folder) {
412416
return (rssItem != null) ? rssItem.getId() : 0;
413417
}
414418

415-
public List<RssItem> getListOfAllItemsForFolder(long ID_FOLDER, boolean onlyUnread, SORT_DIRECTION sortDirection, int limit) {
416-
String whereStatement = getAllItemsIdsForFolderSQL(ID_FOLDER, onlyUnread, sortDirection);
417-
whereStatement = whereStatement.replace("SELECT " + RssItemDao.Properties.Id.columnName + " FROM " + RssItemDao.TABLENAME, "");
418-
whereStatement += " LIMIT " + limit;
419-
return daoSession.getRssItemDao().queryRaw(whereStatement, (String)null);
420-
}
421419

422420
public String getAllItemsIdsForFolderSQL(long ID_FOLDER, boolean onlyUnread, SORT_DIRECTION sortDirection) {
423421
//If all starred items are requested always return them in desc. order

News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/widget/WidgetTodoViewsFactory.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
import de.luhmer.owncloudnewsreader.database.model.RssItem;
4444

4545
public class WidgetTodoViewsFactory implements RemoteViewsService.RemoteViewsFactory {
46-
private static final String TAG = "WidgetTodoViewsFactory";
46+
private static final String TAG = WidgetTodoViewsFactory.class.getCanonicalName();
4747

48-
DatabaseConnectionOrm dbConn;
49-
List<RssItem> rssItems;
48+
private DatabaseConnectionOrm dbConn;
49+
private List<RssItem> rssItems;
5050
private Context context = null;
5151

5252
private int appWidgetId;
@@ -124,7 +124,7 @@ public RemoteViews getViewAt(int position) {
124124
//Load it with whatever extra you want
125125
ei.putExtra(WidgetProvider.RSS_ITEM_ID, id);
126126
//Set it on the list remote view
127-
rv.setOnClickFillInIntent(R.id.ll_root_view_widget_row, ei);
127+
rv.setOnClickFillInIntent(R.id.cb_lv_item_read_wrapper, ei);
128128

129129
//Get a fresh new intent
130130
Intent iCheck = new Intent();
@@ -168,6 +168,8 @@ public boolean hasStableIds() {
168168
public void onDataSetChanged() {
169169
Log.v(TAG, "DataSetChanged - WidgetID: " + appWidgetId);
170170

171-
rssItems = dbConn.getListOfAllItemsForFolder(SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS.getValue(), false, SORT_DIRECTION.desc, 200);
171+
rssItems = dbConn.getAllUnreadRssItemsForWidget();
172+
173+
Log.v(TAG, "DataSetChanged finished!");
172174
}
173175
}
Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
4-
android:layout_height="wrap_content"
4+
android:layout_height="50dp"
55
android:orientation="horizontal"
66
android:background="#8a000000"
77
android:baselineAligned="false" >
@@ -12,76 +12,75 @@
1212
android:layout_width="4dip"
1313
android:layout_height="match_parent"
1414
android:orientation="horizontal" />
15-
16-
<LinearLayout
17-
android:id="@+id/ll_root_view_widget_row"
18-
android:layout_width="0dip"
19-
android:layout_weight="1"
20-
android:layout_height="wrap_content"
21-
android:layout_marginLeft="5dip"
22-
android:layout_marginTop="5dp"
23-
android:layout_marginBottom="5dp"
24-
android:orientation="vertical" >
25-
26-
<TextView
27-
android:id="@+id/feed_title"
28-
android:layout_width="wrap_content"
29-
android:layout_height="wrap_content"
30-
android:gravity="center_vertical"
31-
android:singleLine="true"
32-
android:textIsSelectable="false"
33-
android:text="Item title"
34-
android:ellipsize="end"
35-
android:textStyle="bold"
36-
android:textSize="18sp" />
37-
38-
<LinearLayout
39-
android:layout_width="match_parent"
40-
android:layout_height="match_parent"
41-
android:orientation="horizontal"
42-
android:layout_marginTop="3dp" >
43-
44-
<TextView
45-
android:id="@+id/feed_author_source"
46-
android:layout_width="0dip"
47-
android:layout_height="wrap_content"
48-
android:layout_weight="1"
49-
android:gravity="center_vertical"
50-
android:singleLine="true"
51-
android:textIsSelectable="false"
52-
android:text="Feed name"
53-
android:textSize="16sp" />
54-
55-
<TextView
56-
android:id="@+id/feed_datetime"
57-
android:layout_width="wrap_content"
58-
android:layout_height="wrap_content"
59-
android:gravity="center_vertical|right"
60-
android:singleLine="true"
61-
android:textIsSelectable="false"
62-
android:text="07.08.14 19:00"
63-
android:textSize="16sp" />
6415

65-
</LinearLayout>
6616

67-
</LinearLayout>
6817

69-
<LinearLayout
70-
android:id="@+id/cb_lv_item_read_wrapper"
71-
android:layout_width="wrap_content"
72-
android:layout_height="match_parent"
73-
android:gravity="right|center_vertical"
74-
android:clickable="true"
75-
android:paddingLeft="@dimen/listview_row_margin_left"
76-
android:paddingRight="@dimen/listview_row_margin_right">
18+
<RelativeLayout
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:layout_gravity="center_vertical"
22+
android:layout_marginLeft="8dp" >
23+
7724

78-
<ImageView
79-
android:id="@+id/cb_lv_item_read"
25+
<RelativeLayout
26+
android:id="@+id/cb_lv_item_read_wrapper"
8027
android:layout_width="35dp"
81-
android:layout_height="35dp"
82-
android:clickable="false"
83-
android:background="@drawable/abc_btn_check_to_on_mtrl_000"/>
28+
android:layout_height="50dp"
29+
android:layout_gravity="right"
30+
android:layout_alignParentRight="true">
31+
32+
<ImageView
33+
android:id="@+id/cb_lv_item_read"
34+
android:layout_width="24dp"
35+
android:layout_height="24dp"
36+
android:layout_centerVertical="true"
37+
android:clickable="false"
38+
android:background="@drawable/ic_check_box_white"/>
39+
40+
</RelativeLayout>
41+
42+
<TextView
43+
android:id="@+id/feed_title"
44+
android:layout_width="wrap_content"
45+
android:layout_height="wrap_content"
46+
android:layout_toLeftOf="@id/cb_lv_item_read_wrapper"
47+
android:layout_alignParentLeft="true"
48+
android:gravity="center_vertical"
49+
android:singleLine="true"
50+
android:textIsSelectable="false"
51+
android:text="Item title"
52+
android:ellipsize="end"
53+
android:textStyle="bold"
54+
android:textSize="16sp"
55+
android:layout_marginRight="10dp"
56+
android:layout_marginTop="5dp" />
57+
58+
<TextView
59+
android:id="@+id/feed_datetime"
60+
android:layout_width="wrap_content"
61+
android:layout_height="wrap_content"
62+
android:layout_below="@+id/feed_title"
63+
android:layout_toLeftOf="@id/cb_lv_item_read_wrapper"
64+
android:layout_marginRight="10dp"
65+
android:singleLine="true"
66+
android:textIsSelectable="false"
67+
android:text="07.08.14 19:00"
68+
android:textSize="14sp" />
69+
70+
<TextView
71+
android:id="@+id/feed_author_source"
72+
android:layout_width="wrap_content"
73+
android:layout_height="wrap_content"
74+
android:layout_below="@+id/feed_title"
75+
android:layout_toLeftOf="@id/feed_datetime"
76+
android:layout_alignParentLeft="true"
77+
android:singleLine="true"
78+
android:textIsSelectable="false"
79+
android:text="Feed name"
80+
android:textSize="14sp" />
81+
82+
8483

85-
</LinearLayout>
84+
</RelativeLayout>
8685

8786
</LinearLayout>

News-Android-App/src/main/res/layout/widget_layout.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<LinearLayout
88
android:layout_width="match_parent"
99
android:layout_height="wrap_content"
10-
android:background="#171717" >
10+
android:background="@color/owncloudBlueLight" >
1111

1212
<TextView
1313
android:id="@+id/tV_widget_header"
@@ -16,7 +16,7 @@
1616
android:layout_weight="1.0"
1717
android:padding="10dp"
1818
android:text="@string/widget_header"
19-
android:textColor="#CBCBCB"
19+
android:textColor="#FFF"
2020
android:textSize="17sp" />
2121

2222
</LinearLayout>

0 commit comments

Comments
 (0)