Browse Source

Add skeleton activity and receiver to locale plugin

master
Chris Smith 14 years ago
parent
commit
16c71af5b4

+ 14
- 1
code/LocalePlugin/AndroidManifest.xml View File

@@ -7,8 +7,21 @@
7 7
             android:theme="@android:style/Theme.Translucent.NoTitleBar">
8 8
             <intent-filter>
9 9
                 <action android:name="android.intent.action.MAIN"/>
10
-                <category android:name="android.intent.category.LAUNCHER"/>
10
+                <category android:name="android.intent.category.INFO"/>
11 11
             </intent-filter>
12 12
         </activity>
13
+
14
+        <activity android:name=".EditActivity" android:label="Activity"
15
+            android:icon="@drawable/icon" android:exported="true">
16
+            <intent-filter>
17
+                <action android:name="com.twofortyfouram.locale.intent.action.EDIT_CONDITION"/>
18
+            </intent-filter>
19
+        </activity>
20
+
21
+         <receiver android:name=".Receiver" >
22
+             <intent-filter>
23
+                 <action android:name="com.twofortyfouram.locale.intent.action.QUERY_CONDITION" />
24
+             </intent-filter>
25
+         </receiver>
13 26
     </application>
14 27
 </manifest>

+ 34
- 0
code/LocalePlugin/src/uk/co/md87/android/contextanalyser/locale/EditActivity.java View File

@@ -0,0 +1,34 @@
1
+/*
2
+ * Copyright (c) 2009-2010 Chris Smith
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package uk.co.md87.android.contextanalyser.locale;
24
+
25
+import android.app.Activity;
26
+
27
+/**
28
+ * Activity which allows editing of the Locale trigger.
29
+ *
30
+ * @author chris
31
+ */
32
+public class EditActivity extends Activity {
33
+
34
+}

+ 52
- 0
code/LocalePlugin/src/uk/co/md87/android/contextanalyser/locale/Receiver.java View File

@@ -0,0 +1,52 @@
1
+/*
2
+ * Copyright (c) 2009-2010 Chris Smith
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package uk.co.md87.android.contextanalyser.locale;
24
+
25
+import android.content.BroadcastReceiver;
26
+import android.content.Context;
27
+import android.content.Intent;
28
+import android.database.Cursor;
29
+import android.net.Uri;
30
+
31
+/**
32
+ * Receives broadcast intents from Locale and the Context Analyser.
33
+ *
34
+ * @author chris
35
+ */
36
+public class Receiver extends BroadcastReceiver {
37
+
38
+    @Override
39
+    public void onReceive(Context context, Intent intent) {
40
+        final Cursor cursor = context.getContentResolver().query(
41
+                Uri.parse("content://uk.co.md87.android.contextanalyser."
42
+                + "activitiescontentprovider/current"),
43
+                new String[] { "activity" }, null, null, null);
44
+
45
+        if (cursor.moveToFirst()) {
46
+            cursor.getString(cursor.getColumnIndex("activity"));
47
+        } else {
48
+            setResultCode(com.twofortyfouram.Intent.RESULT_CONDITION_UNKNOWN);
49
+        }
50
+    }
51
+
52
+}

Loading…
Cancel
Save