Read checkbox in widget - #182
This commit is contained in:
parent
4bfe27932f
commit
fa6b0c8a1f
5 changed files with 113 additions and 31 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 6c90cb7ea5272cfd509270059125ca38ea01cf01
|
||||
Subproject commit 7a99ea2008e44d53ae1bef5cc7769054b5b69451
|
|
@ -55,7 +55,25 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
|
||||
|
@ -66,13 +84,13 @@
|
|||
<orderEntry type="library" exported="" name="gson-2.2.4" level="project" />
|
||||
<orderEntry type="library" exported="" name="greendao-generator-1.3.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-20.0.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="butterknife-5.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="jsoup-1.7.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-20.0.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-20.0.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="freemarker-2.3.18" level="project" />
|
||||
<orderEntry type="library" exported="" name="picasso-2.3.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="butterknife-5.1.2" level="project" />
|
||||
<orderEntry type="module" module-name="library" exported="" />
|
||||
<orderEntry type="module" module-name="ownCloud-Account-Importer" exported="" />
|
||||
<orderEntry type="module" module-name="MessageBar" exported="" />
|
||||
|
|
|
@ -38,6 +38,8 @@ import de.luhmer.owncloudnewsreader.Constants;
|
|||
import de.luhmer.owncloudnewsreader.NewsDetailActivity;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm;
|
||||
import de.luhmer.owncloudnewsreader.database.model.RssItem;
|
||||
|
||||
public class WidgetProvider extends AppWidgetProvider {
|
||||
|
||||
|
@ -46,6 +48,7 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||
public static final String ACTION_WIDGET_CONFIGURE = "ConfigureWidget";
|
||||
public static final String ACTION_WIDGET_RECEIVER = "ActionReceiverWidget";
|
||||
public static final String ACTION_LIST_CLICK = "ACTION_LIST_CLICK";
|
||||
public static final String ACTION_CHECKED_CLICK = "ACTION_CHECKED_CLICK";
|
||||
public static final String RSS_ITEM_ID = "RSS_ITEM_ID";
|
||||
|
||||
public static final String EXTRA_ITEM = null;
|
||||
|
@ -60,11 +63,11 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||
appWidgetId = new int[] { intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID) };
|
||||
else
|
||||
appWidgetId = new int[] { AppWidgetManager.INVALID_APPWIDGET_ID };
|
||||
|
||||
if(Constants.debugModeWidget)
|
||||
Log.d(TAG, "onRecieve - WidgetID: " + appWidgetId);
|
||||
|
||||
String action = intent.getAction();
|
||||
|
||||
Log.v(TAG, "onRecieve - WidgetID: " + appWidgetId + " - " + action);
|
||||
|
||||
for(int i = 0; i < appWidgetId.length; i++) {
|
||||
if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) {
|
||||
if (appWidgetId[i] != AppWidgetManager.INVALID_APPWIDGET_ID) {
|
||||
|
@ -83,14 +86,29 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||
try
|
||||
{
|
||||
Long rssItemId = intent.getExtras().getLong(RSS_ITEM_ID);
|
||||
//Intent intentToDoListAct = new Intent(context, TodoListActivity.class);
|
||||
Intent intentToDoListAct = new Intent(context, NewsDetailActivity.class);
|
||||
intentToDoListAct.putExtra(RSS_ITEM_ID, rssItemId);
|
||||
intentToDoListAct.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intentToDoListAct);
|
||||
|
||||
if(Constants.debugModeWidget)
|
||||
Log.d(TAG, "ListItem Clicked Starting Activity for Item: " + rssItemId);
|
||||
|
||||
if(intent.hasExtra(ACTION_CHECKED_CLICK)) {
|
||||
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(context);
|
||||
RssItem rssItem = dbConn.getRssItemById(rssItemId);
|
||||
rssItem.setRead_temp(!rssItem.getRead_temp());
|
||||
//rssItem.setRead_temp(true);
|
||||
|
||||
|
||||
|
||||
AppWidgetManager.getInstance(context)
|
||||
.notifyAppWidgetViewDataChanged(appWidgetId[i], R.id.list_view);
|
||||
|
||||
Log.v(TAG, "I'm here!!! It fucking works!");
|
||||
} else {
|
||||
//Intent intentToDoListAct = new Intent(context, TodoListActivity.class);
|
||||
Intent intentToDoListAct = new Intent(context, NewsDetailActivity.class);
|
||||
intentToDoListAct.putExtra(RSS_ITEM_ID, rssItemId);
|
||||
intentToDoListAct.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intentToDoListAct);
|
||||
}
|
||||
|
||||
Log.v(TAG, "ListItem Clicked Starting Activity for Item: " + rssItemId);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
@ -170,7 +188,15 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||
onListClickIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
rv.setPendingIntentTemplate(R.id.list_view, onListClickPendingIntent);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Intent intentWidget = new Intent(context, WidgetProvider.class);
|
||||
PendingIntent pendingWidgetIntent = PendingIntent.getBroadcast(context, 0, intentWidget, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
rv.setOnClickPendingIntent(R.id.cb_lv_item_read_wrapper, pendingWidgetIntent);
|
||||
*/
|
||||
|
||||
|
||||
Intent intentToDoListAct = new Intent(context, NewsReaderListActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intentToDoListAct, 0);
|
||||
rv.setOnClickPendingIntent(R.id.tV_widget_header, pendingIntent);
|
||||
|
|
|
@ -85,13 +85,21 @@ public class WidgetTodoViewsFactory implements RemoteViewsService.RemoteViewsFac
|
|||
// combination with the app widget item XML file to construct a RemoteViews object.
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
public RemoteViews getViewAt(int position) {
|
||||
RssItem rssItem = rssItems.get(position);
|
||||
|
||||
//RemoteViews rv = new RemoteViews(context.getPackageName(), android.R.layout.simple_list_item_2);
|
||||
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_item);
|
||||
RssItem rssItem = rssItems.get(position);
|
||||
|
||||
/*
|
||||
if(rssItem.getRead_temp())
|
||||
rv = new RemoteViews(context.getPackageName(), R.layout.widget_item);
|
||||
else
|
||||
rv = new RemoteViews(context.getPackageName(), R.layout.widget_item_unread);
|
||||
*/
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
String header = rssItem.getFeed().getFeedTitle();
|
||||
String colorString = rssItem.getFeed().getAvgColour();
|
||||
|
||||
|
@ -99,8 +107,6 @@ public class WidgetTodoViewsFactory implements RemoteViewsService.RemoteViewsFac
|
|||
header += authorOfArticle == null ? "" : " - " + authorOfArticle.trim();
|
||||
String title = Html.fromHtml(rssItem.getTitle()).toString();
|
||||
long id = rssItem.getId();
|
||||
//rv.setTextViewText(android.R.id.text1, header);
|
||||
//rv.setTextViewText(android.R.id.text2, title);
|
||||
|
||||
Date date = rssItem.getPubDate();
|
||||
String dateString = "";
|
||||
|
@ -115,10 +121,20 @@ public class WidgetTodoViewsFactory implements RemoteViewsService.RemoteViewsFac
|
|||
rv.setTextViewText(R.id.feed_title, title);
|
||||
|
||||
|
||||
|
||||
if(rssItem.getRead_temp()) {
|
||||
rv.setInt(R.id.cb_lv_item_read, "setBackgroundResource", R.drawable.btn_check_on_holo_dark);
|
||||
}
|
||||
else {
|
||||
rv.setInt(R.id.cb_lv_item_read, "setBackgroundResource", R.drawable.btn_check_off_holo_dark);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//View viewColor = view.findViewById(R.id.color_line_feed);
|
||||
if(colorString != null)
|
||||
rv.setInt(R.id.color_line_feed, "setBackgroundColor", Integer.parseInt(colorString));
|
||||
//rv.set(R.id.color_line_feed, Integer.parseInt(colorString));
|
||||
|
||||
|
||||
|
||||
//Get a fresh new intent
|
||||
|
@ -127,6 +143,16 @@ public class WidgetTodoViewsFactory implements RemoteViewsService.RemoteViewsFac
|
|||
ei.putExtra(WidgetProvider.RSS_ITEM_ID, id);
|
||||
//Set it on the list remote view
|
||||
rv.setOnClickFillInIntent(R.id.ll_root_view_widget_row, ei);
|
||||
|
||||
//Get a fresh new intent
|
||||
Intent iCheck = new Intent();
|
||||
//Load it with whatever extra you want
|
||||
iCheck.putExtra(WidgetProvider.RSS_ITEM_ID, id);
|
||||
iCheck.putExtra(WidgetProvider.ACTION_CHECKED_CLICK, true);
|
||||
rv.setOnClickFillInIntent(R.id.cb_lv_item_read, iCheck);
|
||||
|
||||
|
||||
|
||||
} catch(Exception ex) {
|
||||
Log.d(TAG, ex.getLocalizedMessage());
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/ll_root_view_widget_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="@dimen/listview_row_margin_right"
|
||||
android:orientation="horizontal"
|
||||
android:background="@drawable/row_divider_line"
|
||||
android:baselineAligned="false" >
|
||||
|
@ -16,6 +14,7 @@
|
|||
android:orientation="horizontal" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_root_view_widget_row"
|
||||
android:layout_width="0dip"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -31,7 +30,7 @@
|
|||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:textIsSelectable="false"
|
||||
android:text="dsjkafd"
|
||||
android:text="Item title"
|
||||
android:ellipsize="end"
|
||||
android:textStyle="bold"
|
||||
android:textSize="18sp" />
|
||||
|
@ -50,7 +49,7 @@
|
|||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:textIsSelectable="false"
|
||||
android:text="cdskfjds"
|
||||
android:text="Feed name"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
|
@ -60,16 +59,29 @@
|
|||
android:gravity="center_vertical|right"
|
||||
android:singleLine="true"
|
||||
android:textIsSelectable="false"
|
||||
android:text="dsjkfldsjalf"
|
||||
android:text="07.08.14 19:00"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<!--
|
||||
<CheckBox
|
||||
android:id="@+id/cb_lv_item_read"
|
||||
android:layout_gravity="right"
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/cb_lv_item_read_wrapper"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent" />
|
||||
-->
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="right|center_vertical"
|
||||
android:clickable="true"
|
||||
android:paddingLeft="@dimen/listview_row_margin_left"
|
||||
android:paddingRight="@dimen/listview_row_margin_right">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cb_lv_item_read"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:clickable="false"
|
||||
android:background="@drawable/btn_check_on_holo_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in a new issue