]> iEval git - fonbot.git/commitdiff
Let user disable showing ongoing events
authorMarius Gavrilescu <marius@ieval.ro>
Mon, 29 Jul 2013 08:40:31 +0000 (11:40 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Mon, 29 Jul 2013 08:40:31 +0000 (11:40 +0300)
res/xml/prefs.xml
src/ro/ieval/fonbot/FonBotMainService.java

index cc881fe5617010c943854d69ea71dd0f2ecd59df..6d90c6aca888de51b649e1f69a39d0e9c3df03a9 100644 (file)
@@ -3,6 +3,7 @@
     <EditTextPreference android:title="Username" android:key="username" android:dialogTitle="Username" android:dialogMessage="Enter your username"/>
     <EditTextPreference android:dialogTitle="Password" android:dialogMessage="Enter your password" android:inputType="textPassword" android:title="Password" android:key="password"/>
     <EditTextPreference android:dialogTitle="SMS Password" android:dialogMessage="Enter the password required to send SMS commands. Leave empty to disable SMS commands" android:title="SMS Password" android:key="smspassword"/>
+       <CheckBoxPreference android:title="Show ongoing events" android:summaryOn="Ongoing events are shown" android:summaryOff="Ongoing events are not shown" android:key="ongoing"/>
     <CheckBoxPreference android:title="Device administration" android:summaryOn="Device administration is enabled." android:key="admin" android:summaryOff="Device administration is disabled. Some commands require device administration."/>
        <CheckBoxPreference android:key="foreground" android:title="Run service in foreground" android:summaryOn="The FonBot service is kept in foreground. " android:summaryOff="The FonBot service is not kept in foreground."/>
     <CheckBoxPreference android:key="system" android:summaryOff="FonBot is not a system app. Changing this requires root and busybox" android:title="System App" android:summaryOn="FonBot is a system app. Changing this requires root and busybox"/>
index e0bc6c0cf5452b7a76868843a167be08a9d372b6..38e0a29d0cbb8b4fd8a850ba28474b3e5ea54ccb 100644 (file)
@@ -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)
This page took 0.0222 seconds and 4 git commands to generate.