aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-10-11 16:28:50 -0700
committerdaneren2005 <daneren2005@gmail.com>2013-10-11 16:28:50 -0700
commit7ca56013ee36e32c011728faf7bd778ad9745c70 (patch)
treeddb541a32b46daa51a6b4cad3b862f84c789ee20 /src
parentbb78a71c413677b9a33cbd29d4b89e62a70e021b (diff)
downloaddsub-7ca56013ee36e32c011728faf7bd778ad9745c70.tar.gz
dsub-7ca56013ee36e32c011728faf7bd778ad9745c70.tar.bz2
dsub-7ca56013ee36e32c011728faf7bd778ad9745c70.zip
#130 Add support to hide widget while inactive
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/provider/DSubWidgetProvider.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java b/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java
index 7215040c..f8023712 100644
--- a/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java
+++ b/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java
@@ -25,6 +25,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
+import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
@@ -61,6 +62,7 @@ public class DSubWidgetProvider extends AppWidgetProvider {
private static DSubWidget4x2 instance4x2;
private static DSubWidget4x3 instance4x3;
private static DSubWidget4x4 instance4x4;
+ private boolean hidden = false;
public static synchronized void notifyInstances(Context context, DownloadService service, boolean playing) {
if(instance4x1 == null) {
@@ -103,6 +105,13 @@ public class DSubWidgetProvider extends AppWidgetProvider {
if(getLayout() == R.layout.appwidget4x2) {
views.setTextViewText(R.id.album, "");
}
+
+ // Hide widget
+ SharedPreferences prefs = Util.getPreferences(context);
+ if(prefs.getBoolean(Constants.PREFERENCES_KEY_HIDE_WIDGET, false)) {
+ views.setViewVisibility(0, View.GONE);
+ hidden = true;
+ }
linkButtons(context, views, false);
pushUpdate(context, appWidgetIds, views);
@@ -142,6 +151,12 @@ public class DSubWidgetProvider extends AppWidgetProvider {
private void performUpdate(Context context, DownloadService service, int[] appWidgetIds, boolean playing) {
final Resources res = context.getResources();
final RemoteViews views = new RemoteViews(context.getPackageName(), getLayout());
+
+ // Make sure widget is visible
+ if(hidden) {
+ views.setViewVisibility(0, View.VISIBLE);
+ hidden = false;
+ }
MusicDirectory.Entry currentPlaying = service.getCurrentPlaying() == null ? null : service.getCurrentPlaying().getSong();
String title = currentPlaying == null ? null : currentPlaying.getTitle();