[Android] remove uneeded SleepAlarmReceiver

Sébastien Toque git at videolan.org
Sun Dec 30 19:30:24 CET 2012


vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Fri Dec 28 20:54:53 2012 +0100| [31122d57f7822ff8c20918b871c5c189a135ff3d] | committer: Sébastien Toque

remove uneeded SleepAlarmReceiver

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=31122d57f7822ff8c20918b871c5c189a135ff3d
---

 vlc-android/AndroidManifest.xml                    |    3 --
 .../src/org/videolan/vlc/SleepAlarmReceiver.java   |   41 --------------------
 .../src/org/videolan/vlc/VLCApplication.java       |    2 +
 .../src/org/videolan/vlc/gui/TimeSleepDialog.java  |    6 +--
 .../vlc/gui/video/VideoOverflowDialog.java         |    6 +--
 5 files changed, 8 insertions(+), 50 deletions(-)

diff --git a/vlc-android/AndroidManifest.xml b/vlc-android/AndroidManifest.xml
index ad998d4..a4c9630 100644
--- a/vlc-android/AndroidManifest.xml
+++ b/vlc-android/AndroidManifest.xml
@@ -412,9 +412,6 @@
                 <action android:name="android.intent.action.MEDIA_BUTTON" />
             </intent-filter>
         </receiver>
-        <receiver
-            android:name="org.videolan.vlc.SleepAlarmReceiver" >
-        </receiver>
     </application>
 
 </manifest>
diff --git a/vlc-android/src/org/videolan/vlc/SleepAlarmReceiver.java b/vlc-android/src/org/videolan/vlc/SleepAlarmReceiver.java
deleted file mode 100644
index eede4c3..0000000
--- a/vlc-android/src/org/videolan/vlc/SleepAlarmReceiver.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*****************************************************************************
- * SleepAlarmReceiver.java
- *****************************************************************************
- * Copyright © 2012 VLC authors and VideoLAN
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-package org.videolan.vlc;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.util.Log;
-
-public class SleepAlarmReceiver extends BroadcastReceiver {
-    public final static String TAG = "VLC/SleepAlarmReceiver";
-
-    public final static String SLEEP_INTENT = "org.videolan.vlc.SleepIntent";
-
-    @Override
-    public void onReceive(Context context, Intent intent) {
-        if(context == null)
-            return;
-        Log.i(TAG,"VLC is about to sleep");
-        Intent intentSleep = new Intent();
-        intentSleep.setAction(SLEEP_INTENT);
-        context.getApplicationContext().sendBroadcast(intentSleep);
-    }
-}
diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index 250badb..bf7bd8e 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -33,6 +33,8 @@ public class VLCApplication extends Application {
     public final static String TAG = "VLC/VLCApplication";
     private static VLCApplication instance;
 
+    public final static String SLEEP_INTENT = "org.videolan.vlc.SleepIntent";
+
     @Override
     public void onCreate() {
         super.onCreate();
diff --git a/vlc-android/src/org/videolan/vlc/gui/TimeSleepDialog.java b/vlc-android/src/org/videolan/vlc/gui/TimeSleepDialog.java
index d43ad04..c927378 100644
--- a/vlc-android/src/org/videolan/vlc/gui/TimeSleepDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/TimeSleepDialog.java
@@ -22,8 +22,8 @@ package org.videolan.vlc.gui;
 import java.util.Calendar;
 
 import org.videolan.vlc.R;
-import org.videolan.vlc.SleepAlarmReceiver;
 import org.videolan.vlc.VLCApplication;
+
 import android.app.AlarmManager;
 import android.app.AlertDialog;
 import android.app.PendingIntent;
@@ -61,8 +61,8 @@ public class TimeSleepDialog extends TimePickerDialog {
             @Override
             public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                 AlarmManager alarmMgr = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
-                Intent intent = new Intent(VLCApplication.getAppContext(), SleepAlarmReceiver.class);
-                mSleepPendingIntent = PendingIntent.getBroadcast(VLCApplication.getAppContext(), 0, intent, 0);
+                Intent intent = new Intent(VLCApplication.SLEEP_INTENT);
+                mSleepPendingIntent = PendingIntent.getBroadcast(VLCApplication.getAppContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
 
                 Calendar currentTime = Calendar.getInstance();
                 currentTime.setTimeInMillis(System.currentTimeMillis());
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoOverflowDialog.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoOverflowDialog.java
index 095bffd..94e5288 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoOverflowDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoOverflowDialog.java
@@ -22,7 +22,7 @@ package org.videolan.vlc.gui.video;
 import java.util.Calendar;
 
 import org.videolan.vlc.R;
-import org.videolan.vlc.SleepAlarmReceiver;
+import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.gui.SpeedSelectorDialog;
 import org.videolan.vlc.gui.TimeSleepDialog;
 
@@ -69,7 +69,7 @@ public class VideoOverflowDialog extends Dialog {
         mSleep = (ImageButton) mAdvFuncView.findViewById(R.id.adv_func_sleep);
         mSleep.setOnClickListener(mSleepListener);
         IntentFilter filter = new IntentFilter();
-        filter.addAction(SleepAlarmReceiver.SLEEP_INTENT);
+        filter.addAction(VLCApplication.SLEEP_INTENT);
         getOwnerActivity().registerReceiver(mSleepReceiver, filter);
 
         // Init Speed function
@@ -84,7 +84,7 @@ public class VideoOverflowDialog extends Dialog {
         public void onReceive(Context context, Intent intent)
         {
             String action = intent.getAction();
-            if (action.equalsIgnoreCase(SleepAlarmReceiver.SLEEP_INTENT))
+            if (action.equalsIgnoreCase(VLCApplication.SLEEP_INTENT))
                 getOwnerActivity().finish();
         }
     };



More information about the Android mailing list