diff options
author | Andrew Dolgov <[email protected]> | 2017-05-30 08:21:13 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-05-30 08:21:13 +0300 |
commit | c857f0c62733963bbbb0d609feb82b4ff484ed42 (patch) | |
tree | 3766da320c56a7d588e8db43045f1d4632d731cb /org.fox.ttrss/src/main | |
parent | 1658a915282ab08613bbb4c45f66ec171c8d7c36 (diff) |
widget: selectable background color
Diffstat (limited to 'org.fox.ttrss/src/main')
6 files changed, 33 insertions, 16 deletions
diff --git a/org.fox.ttrss/src/main/AndroidManifest.xml b/org.fox.ttrss/src/main/AndroidManifest.xml index 1d6bf725..fa5f1d9b 100755 --- a/org.fox.ttrss/src/main/AndroidManifest.xml +++ b/org.fox.ttrss/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.fox.ttrss" - android:versionCode="418" - android:versionName="1.184" > + android:versionCode="419" + android:versionName="1.185" > <uses-sdk android:minSdkVersion="16" 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 79fee1fb..fceec679 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 @@ -424,7 +424,7 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc int updateInterval = Integer.parseInt(prefs.getString("widget_update_interval", "15")) * 60 * 1000; - Log.d("setupWidgetUpdates", "setupWidgetUpdate: interval= " + updateInterval); + Log.d("setupWidgetUpdates", "interval= " + updateInterval); AlarmManager alarmManager = (AlarmManager)context.getSystemService(ALARM_SERVICE); 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 a2c23b59..dab655a2 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 @@ -21,7 +21,6 @@ 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) { @@ -34,12 +33,19 @@ public class SmallWidgetProvider extends AppWidgetProvider { views.setOnClickPendingIntent(R.id.widget_main, pendingIntent); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - boolean darkMode = prefs.getBoolean("widget_dark_mode", false); + String widgetBackground = prefs.getString("widget_background", "WB_LIGHT"); - if (darkMode) { + Log.d(TAG, "widget bg: " + widgetBackground); + + if ("WB_LIGHT".equals(widgetBackground)) { + views.setViewVisibility(R.id.widget_dark, View.INVISIBLE); + views.setViewVisibility(R.id.widget_light, View.VISIBLE); + } else if ("WB_DARK".equals(widgetBackground)) { views.setViewVisibility(R.id.widget_dark, View.VISIBLE); + views.setViewVisibility(R.id.widget_light, View.INVISIBLE); } else { views.setViewVisibility(R.id.widget_dark, View.INVISIBLE); + views.setViewVisibility(R.id.widget_light, View.INVISIBLE); } appWidgetManager.updateAppWidget(appWidgetIds, views); @@ -69,11 +75,6 @@ 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/values/arrays.xml b/org.fox.ttrss/src/main/res/values/arrays.xml index 92cbefa9..fbb16985 100644 --- a/org.fox.ttrss/src/main/res/values/arrays.xml +++ b/org.fox.ttrss/src/main/res/values/arrays.xml @@ -37,4 +37,14 @@ <item>45</item> <item>60</item> </string-array> + <string-array name="pref_widget_bgs_values" translatable="false"> + <item>WB_LIGHT</item> + <item>WB_DARK</item> + <item>WB_TRANSPARENT</item> + </string-array> + <string-array name="pref_widget_bgs"> + <item>@string/widget_background_light</item> + <item>@string/widget_background_dark</item> + <item>@string/widget_background_transparent</item> + </string-array> </resources>
\ 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 36980218..a607c720 100755 --- a/org.fox.ttrss/src/main/res/values/strings.xml +++ b/org.fox.ttrss/src/main/res/values/strings.xml @@ -248,5 +248,9 @@ <string name="pref_headlines_swipe_to_dismiss">Swipe to dismiss</string> <string name="pref_headlines_swipe_to_dismiss_long">Disables headlines context menu</string> <string name="pref_widget_update_interval">Update interval (in minutes)</string> - <string name="pref_widget_dark_background">Use dark background</string> + + <string name="widget_background_light">Light</string> + <string name="widget_background_dark">Dark</string> + <string name="widget_background_transparent">Transparent</string> + <string name="pref_widget_background">Background color</string> </resources> diff --git a/org.fox.ttrss/src/main/res/xml/preferences.xml b/org.fox.ttrss/src/main/res/xml/preferences.xml index d09d9d8e..c3114eb1 100755 --- a/org.fox.ttrss/src/main/res/xml/preferences.xml +++ b/org.fox.ttrss/src/main/res/xml/preferences.xml @@ -196,10 +196,12 @@ android:key="widget_update_interval" android:title="@string/pref_widget_update_interval" /> - <org.fox.ttrss.util.LessBrokenSwitchPreference - android:defaultValue="false" - android:key="widget_dark_mode" - android:title="@string/pref_widget_dark_background" /> + <ListPreference + android:defaultValue="WB_LIGHT" + android:entries="@array/pref_widget_bgs" + android:entryValues="@array/pref_widget_bgs_values" + android:key="widget_background" + android:title="@string/pref_widget_background" /> <org.fox.ttrss.util.LessBrokenSwitchPreference android:defaultValue="true" |