Skip to content

Commit

Permalink
Added a permission for receiving the broadcast intent to close issue #8
Browse files Browse the repository at this point in the history
- Changed the broadcast intent name
- PortalStateChangedReceiver: all it was doing was updating the
notification, but the service does this itself
- Translated permission strings for issue #6
  • Loading branch information
Zachary Klippenstein committed Apr 26, 2012
1 parent 4abaa2b commit 2d9281b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 47 deletions.
12 changes: 7 additions & 5 deletions src/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.zachklipp.captivate.permission.ACCESS_PORTAL_STATE"/>
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<permission
android:name="com.zachklipp.captivate.permission.ACCESS_PORTAL_STATE"
android:label="@string/portal_state_perm_label"
android:description="@string/portal_state_perm_desc"
android:permissionGroup="android.permission-group.NETWORK"
android:protectionLevel="normal" />

<application
android:name="Application"
Expand All @@ -30,11 +37,6 @@
<action android:name="android.net.wifi.STATE_CHANGE"/>
</intent-filter>
</receiver>
<receiver android:name=".service.PortalStateChangedReceiver">
<intent-filter>
<action android:name="com.zachklipp.captivate.ACTION_PORTAL_STATE_CHANGED"/>
</intent-filter>
</receiver>
<activity android:name="AboutActivity" android:label="@string/about_title"></activity>
<service android:name=".service.PortalDetectorService">
</service>
Expand Down
4 changes: 4 additions & 0 deletions src/res/values-es/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="portal_state_perm_label">acceder estado de portal cautivo</string>
<string name="portal_state_perm_desc">Permite que la aplicación para determinar si el dispositivo está detrás de un portal cautivo.</string>

<string name="ok">Aceptar</string>

<string name="notification_title">Hotspot Captive Detectado</string>
Expand Down
4 changes: 4 additions & 0 deletions src/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="portal_state_perm_label">accéder à l\'état de portail captif</string>
<string name="portal_state_perm_desc">Permet à l\'application afin de déterminer si l\'appareil se trouve derrière un portail captif.</string>

<string name="ok">OK</string>

<string name="notification_title">Hotspot détecté en captivité</string>
Expand Down
4 changes: 4 additions & 0 deletions src/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="portal_state_perm_label">esir portalı durumuna erişmek</string>
<string name="portal_state_perm_desc">Cihaz bir esir portalı arkasında olup olmadığını belirlemek için uygulama sağlar.</string>

<string name="ok">Tamam</string>

<string name="notification_title">Esir Hotspot Tespit</string>
Expand Down
3 changes: 3 additions & 0 deletions src/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

<!-- Localizable strings -->

<string name="portal_state_perm_label">access captive portal state</string>
<string name="portal_state_perm_desc">Allows the application to determine if the device is behind a captive portal.</string>

<string name="ok">OK</string>

<string name="notification_title">Captive Hotspot Detected</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public static interface StorageBackendFactory
public StateMachineStorage.StorageBackend create(Context context, PortalDetector detector);
}

private static final String INTENT_NAMESPACE = "com.zachklipp.captivate.";
private static final String INTENT_NAMESPACE = "com.zachklipp.captivate.intent.";

// For broadcast intent
public static final String ACCESS_PORTAL_STATE_PERMISSION = "com.zachklipp.captivate.permission.ACCESS_PORTAL_STATE";
public static final String ACTION_PORTAL_STATE_CHANGED = INTENT_NAMESPACE + "ACTION_PORTAL_STATE_CHANGED";
public static final String EXTRA_CAPTIVE_PORTAL_STATE = INTENT_NAMESPACE + "EXTRA_CAPTIVE_PORTAL_STATE";
public static final String EXTRA_CAPTIVE_PORTAL_INFO = INTENT_NAMESPACE + "EXTRA_CAPTIVE_PORTAL_INFO";
Expand Down Expand Up @@ -143,7 +144,7 @@ private void sendStateChangedBroadcast()
Log.i(String.format("Broadcasting portal state change. new state=%s, portal=%s",
state, portal));

sendBroadcast(intent);
sendBroadcast(intent, ACCESS_PORTAL_STATE_PERMISSION);
}

private static Intent createStateChangedBroadcastIntent(State state, PortalInfo portal)
Expand Down

This file was deleted.

0 comments on commit 2d9281b

Please sign in to comment.