aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-10-11 19:10:47 -0700
committerScott Jackson <daneren2005@gmail.com>2013-10-11 19:10:47 -0700
commite1cf77e0ee66701dc979f4c3f5e38ce0508f5645 (patch)
tree6323434434bd84386938069e5d8b444bcede5645 /src/github/daneren2005
parent7ca56013ee36e32c011728faf7bd778ad9745c70 (diff)
downloaddsub-e1cf77e0ee66701dc979f4c3f5e38ce0508f5645.tar.gz
dsub-e1cf77e0ee66701dc979f4c3f5e38ce0508f5645.tar.bz2
dsub-e1cf77e0ee66701dc979f4c3f5e38ce0508f5645.zip
Closes #130 Add option to hide widget while inactive
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/provider/DSubWidgetProvider.java27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java b/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java
index f8023712..f0c7f9fb 100644
--- a/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java
+++ b/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java
@@ -37,6 +37,7 @@ import android.graphics.RectF;
import android.os.Environment;
import android.util.Log;
import android.view.KeyEvent;
+import android.view.View;
import android.widget.RemoteViews;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.activity.DownloadActivity;
@@ -46,6 +47,8 @@ import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.DownloadServiceImpl;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.FileUtil;
+import github.daneren2005.dsub.util.Util;
+
import java.util.HashMap;
/**
@@ -62,7 +65,6 @@ 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) {
@@ -105,13 +107,6 @@ 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);
@@ -151,12 +146,16 @@ 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;
- }
+
+ if(playing) {
+ views.setViewVisibility(R.id.widget_root, View.VISIBLE);
+ } else {
+ // Hide widget
+ SharedPreferences prefs = Util.getPreferences(context);
+ if(prefs.getBoolean(Constants.PREFERENCES_KEY_HIDE_WIDGET, false)) {
+ views.setViewVisibility(R.id.widget_root, View.GONE);
+ }
+ }
MusicDirectory.Entry currentPlaying = service.getCurrentPlaying() == null ? null : service.getCurrentPlaying().getSong();
String title = currentPlaying == null ? null : currentPlaying.getTitle();