diff --git a/org.fox.ttrss/src/main/AndroidManifest.xml b/org.fox.ttrss/src/main/AndroidManifest.xml
index 75da167d..5e61e487 100755
--- a/org.fox.ttrss/src/main/AndroidManifest.xml
+++ b/org.fox.ttrss/src/main/AndroidManifest.xml
@@ -12,6 +12,7 @@
+
+
+
+
+
+
+
+
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java
index 5811a7f9..79fee1fb 100755
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java
@@ -2,6 +2,8 @@ package org.fox.ttrss;
import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.PendingIntent;
@@ -37,6 +39,7 @@ import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import org.fox.ttrss.util.DatabaseHelper;
+import org.fox.ttrss.widget.SmallWidgetProvider;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
@@ -159,6 +162,8 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc
m_prefs.registerOnSharedPreferenceChangeListener(this);
+ setupWidgetUpdates(this);
+
if (savedInstanceState != null) {
m_theme = savedInstanceState.getString("theme");
} else {
@@ -237,7 +242,7 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Log.d(TAG, "onSharedPreferenceChanged:" + key);
- String[] filter = new String[] { "theme", "enable_cats", "headline_mode" };
+ String[] filter = new String[] { "theme", "enable_cats", "headline_mode", "widget_update_interval" };
m_needRestart = Arrays.asList(filter).indexOf(key) != -1;
}
@@ -414,6 +419,29 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc
}
}
+ public static void setupWidgetUpdates(Context context) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+
+ int updateInterval = Integer.parseInt(prefs.getString("widget_update_interval", "15")) * 60 * 1000;
+
+ Log.d("setupWidgetUpdates", "setupWidgetUpdate: interval= " + updateInterval);
+
+ AlarmManager alarmManager = (AlarmManager)context.getSystemService(ALARM_SERVICE);
+
+ Intent intentUpdate = new Intent(SmallWidgetProvider.ACTION_REQUEST_UPDATE);
+
+ PendingIntent pendingIntentAlarm = PendingIntent.getBroadcast(context,
+ 0, intentUpdate, PendingIntent.FLAG_UPDATE_CURRENT);
+
+ alarmManager.cancel(pendingIntentAlarm);
+
+ alarmManager.setRepeating(AlarmManager.RTC,
+ System.currentTimeMillis() + updateInterval,
+ updateInterval,
+ pendingIntentAlarm);
+
+ }
+
public void displayImageCaption(String url, String htmlContent) {
// Android doesn't give us an easy way to access title tags;
// we'll use Jsoup on the body text to grab the title text
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/util/DeviceBootReceiver.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/util/DeviceBootReceiver.java
new file mode 100644
index 00000000..1622e72d
--- /dev/null
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/util/DeviceBootReceiver.java
@@ -0,0 +1,16 @@
+package org.fox.ttrss.util;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+import org.fox.ttrss.CommonActivity;
+
+public class DeviceBootReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
+ CommonActivity.setupWidgetUpdates(context);
+ }
+ }
+}
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/widget/SmallWidgetProvider.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/widget/SmallWidgetProvider.java
index 6c2261a8..a2c23b59 100755
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/widget/SmallWidgetProvider.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/widget/SmallWidgetProvider.java
@@ -6,7 +6,11 @@ import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
+import android.graphics.Color;
+import android.preference.PreferenceManager;
import android.util.Log;
+import android.view.View;
import android.widget.RemoteViews;
import org.fox.ttrss.OnlineActivity;
@@ -17,6 +21,7 @@ public class SmallWidgetProvider extends AppWidgetProvider {
public static final String ACTION_REQUEST_UPDATE = "org.fox.ttrss.WIDGET_FORCE_UPDATE";
public static final String ACTION_UPDATE_RESULT = "org.fox.ttrss.WIDGET_UPDATE_RESULT";
+ public static final String ACTION_SETTINGS_CHANGED = "org.fox.ttrss.WIDGET_SETTINGS_CHANGED";
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
@@ -28,11 +33,20 @@ public class SmallWidgetProvider extends AppWidgetProvider {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_small);
views.setOnClickPendingIntent(R.id.widget_main, pendingIntent);
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ boolean darkMode = prefs.getBoolean("widget_dark_mode", false);
+
+ if (darkMode) {
+ views.setViewVisibility(R.id.widget_dark, View.VISIBLE);
+ } else {
+ views.setViewVisibility(R.id.widget_dark, View.INVISIBLE);
+ }
+
appWidgetManager.updateAppWidget(appWidgetIds, views);
Intent serviceIntent = new Intent(context.getApplicationContext(), WidgetUpdateService.class);
context.startService(serviceIntent);
- }
+ }
@Override
@@ -55,6 +69,11 @@ public class SmallWidgetProvider extends AppWidgetProvider {
Log.d(TAG, "onReceive: got update result from service: " + unread + " " + resultCode);
updateWidgetsText(context, appWidgetManager, appWidgetIds, unread, resultCode);
+ } else if (ACTION_SETTINGS_CHANGED.equals(intent.getAction())) {
+ Log.d(TAG, "onReceive: got settings changed");
+
+ // TODO
+
} else {
super.onReceive(context, intent);
}
diff --git a/org.fox.ttrss/src/main/res/layout/widget_small.xml b/org.fox.ttrss/src/main/res/layout/widget_small.xml
index 99124a3c..e6ee8a88 100755
--- a/org.fox.ttrss/src/main/res/layout/widget_small.xml
+++ b/org.fox.ttrss/src/main/res/layout/widget_small.xml
@@ -4,8 +4,20 @@
android:layout_height="fill_parent"
android:padding="@dimen/widget_margin" >
+
+
+
+
diff --git a/org.fox.ttrss/src/main/res/values/arrays.xml b/org.fox.ttrss/src/main/res/values/arrays.xml
index aa14bd62..92cbefa9 100644
--- a/org.fox.ttrss/src/main/res/values/arrays.xml
+++ b/org.fox.ttrss/src/main/res/values/arrays.xml
@@ -30,5 +30,11 @@
- 1000
- 1500
- 2000
-
+
+
+ - 15
+ - 30
+ - 45
+ - 60
+
\ No newline at end of file
diff --git a/org.fox.ttrss/src/main/res/values/strings.xml b/org.fox.ttrss/src/main/res/values/strings.xml
index 3f1d44bb..36980218 100755
--- a/org.fox.ttrss/src/main/res/values/strings.xml
+++ b/org.fox.ttrss/src/main/res/values/strings.xml
@@ -247,4 +247,6 @@
Marked as read
Swipe to dismiss
Disables headlines context menu
+ Update interval (in minutes)
+ Use dark background
diff --git a/org.fox.ttrss/src/main/res/xml/preferences.xml b/org.fox.ttrss/src/main/res/xml/preferences.xml
index df3be4e9..d09d9d8e 100755
--- a/org.fox.ttrss/src/main/res/xml/preferences.xml
+++ b/org.fox.ttrss/src/main/res/xml/preferences.xml
@@ -189,6 +189,18 @@
android:title="@string/offline_image_cache_enabled" />
+
+
+
+