From 079ea30606f31a88786a70feacff3184336a96b8 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Mon, 29 Jul 2013 11:40:31 +0300 Subject: [PATCH] Let user disable showing ongoing events --- res/xml/prefs.xml | 1 + src/ro/ieval/fonbot/FonBotMainService.java | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/res/xml/prefs.xml b/res/xml/prefs.xml index cc881fe..6d90c6a 100644 --- a/res/xml/prefs.xml +++ b/res/xml/prefs.xml @@ -3,6 +3,7 @@ + diff --git a/src/ro/ieval/fonbot/FonBotMainService.java b/src/ro/ieval/fonbot/FonBotMainService.java index e0bc6c0..38e0a29 100644 --- a/src/ro/ieval/fonbot/FonBotMainService.java +++ b/src/ro/ieval/fonbot/FonBotMainService.java @@ -160,13 +160,14 @@ public final class FonBotMainService extends Service { @Override public int onStartCommand(final @Nullable Intent intent, final int flags, final int startId) { + final boolean showOngoing=PreferenceManager.getDefaultSharedPreferences(this).getBoolean("ongoing", false); boolean updateNotification = false; - if(intent!=null && intent.getAction()==ACTION_PUT_ONGOING && intent.hasExtra(EXTRA_ONGOING_ID)){ + if(intent!=null && intent.getAction()==ACTION_PUT_ONGOING && intent.hasExtra(EXTRA_ONGOING_ID) && showOngoing){ ongoing.add(OngoingEvent.values()[intent.getIntExtra(EXTRA_ONGOING_ID, 0)]); LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(ACTION_ONGOING_UPDATE)); updateNotification=true; } - if(intent!=null && intent.getAction()==ACTION_DELETE_ONGOING && intent.hasExtra(EXTRA_ONGOING_ID)){ + if(intent!=null && intent.getAction()==ACTION_DELETE_ONGOING && intent.hasExtra(EXTRA_ONGOING_ID) && showOngoing){ ongoing.remove(OngoingEvent.values()[intent.getIntExtra(EXTRA_ONGOING_ID, 0)]); LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(ACTION_ONGOING_UPDATE)); updateNotification=true; @@ -194,7 +195,7 @@ public final class FonBotMainService extends Service { setContentIntent(PendingIntent.getActivity(this, 0, mainIntent, 0)). setOngoing(true); - if(!ongoing.isEmpty()) { + if(showOngoing && !ongoing.isEmpty()) { final NotificationCompat.InboxStyle inboxBuilder=new NotificationCompat.InboxStyle(builder); for(final OngoingEvent event : ongoing) -- 2.30.2