ZenonZ / mixare

Automatically exported from code.google.com/p/mixare
0 stars 0 forks source link

Allow to start Mixare with an Intent that contains the data to be viewed #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
For example:
Intent intent = new Intent("org.mixare.VIEW");
intent.putExtra("DATA", new String[]{
"2827:46.43893:11.21706:1737:Penegal",
"2821:46.49396:11.2088:1865:Gantkofel"});

context.startActivity(intent);

Original issue reported on code.google.com by thoughtc...@googlemail.com on 10 Apr 2010 at 8:08

GoogleCodeExporter commented 8 years ago
Implementation of Issue 10 and 11:

Index: AndroidManifest.xml
===================================================================
--- AndroidManifest.xml (revision 22)
+++ AndroidManifest.xml (working copy)
@@ -23,9 +23,14 @@
                                  <data android:scheme="http"
android:mimeType="application/mixare-json"/>
                                  <data android:scheme="content"
android:mimeType="application/mixare-json"/>
             </intent-filter>
-        </activity>
+            <intent-filter>
+              <action android:name="org.mixare.VIEW"/>
+              <category android:name="android.intent.category.DEFAULT"/>
+            </intent-filter>
+
+        </activity>
 </application>
-
-<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
-
+
+<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
+
 </manifest> 
Index: src/org/mixare/Marker.java
===================================================================
--- src/org/mixare/Marker.java  (revision 22)
+++ src/org/mixare/Marker.java  (working copy)
@@ -63,6 +63,26 @@
        ScreenLine pPt = new ScreenLine();

+    /**
+     * Parses a marker from CSV.
+     * Format: id,lat,lng,elevation,title[,webpage]
+     *
+     * @param csv
+     * @return
+     */
+    public static Marker parse(String csv){
+        String[] values = csv.split(",");
+        Marker marker = new Marker();
+        marker.mId = values[0];
+        marker.mGeoLoc.setLatitude(Double.parseDouble(values[1]));
+        marker.mGeoLoc.setLongitude(Double.parseDouble(values[2]));
+        marker.mGeoLoc.setAltitude(Double.parseDouble(values[3]));
+        marker.mText = values[4];
+        if (values.length > 4) marker.mOnPress = values[5];
+        return marker;
+    }
+
+
        void cCMarker(MixVector originalPoint, Camera viewCam, float addX,
                        float addY) {
                tmpa.set(originalPoint); //1
Index: src/org/mixare/DataView.java
===================================================================
--- src/org/mixare/DataView.java        (revision 22)
+++ src/org/mixare/DataView.java        (working copy)
@@ -28,6 +28,8 @@
 import java.util.Collections;
 import java.util.Locale;

+import android.app.Activity;
+import android.content.Intent;
 import org.mixare.data.Json;
 import org.mixare.gui.PaintScreen;
 import org.mixare.gui.RadarPoints;
@@ -121,6 +123,18 @@
                // Load Layer
                if (state.nextLStatus == MixState.NOT_STARTED ) {

+            Intent intent = ((Activity) ctx.mixView).getIntent();
+            if (intent.getAction() != null &&
intent.getAction().equals("org.mixare.VIEW")) {
+                String[] data = intent.getStringArrayExtra("DATA");
+                for (int i = 0; i < data.length; i++) {
+                    Marker marker = Marker.parse(data[0]);
+                    System.out.println("marker:"+marker.mId);
+                    state.jLayer.markers.add(marker);
+                }
+
+                state.nextLStatus = MixState.DONE;
+            } else {
+
                        DownloadRequest request = new DownloadRequest();

                        if (!ctx.getStartUrl().equals(""))
@@ -134,6 +148,7 @@

                        state.nextLStatus = MixState.PROCESSING;
+            }
                } else if (state.nextLStatus == MixState.PROCESSING) {
                        if (ctx.getDownloader().isReqComplete(state.downloadId)) {
                                state.dRes =
ctx.getDownloader().getReqResult(state.downloadId);
Index: src/org/mixare/MixState.java
===================================================================
--- src/org/mixare/MixState.java        (revision 22)
+++ src/org/mixare/MixState.java        (working copy)
@@ -18,6 +18,8 @@
  */
 package org.mixare;

+import android.app.Activity;
+import android.content.Intent;
 import org.mixare.data.Json;
 import org.mixare.render.Matrix;
 import org.mixare.render.MixVector;
@@ -47,13 +49,20 @@

        boolean handleEvent(MixContext ctx, String xmlId, String onPress) {

-               if (onPress != null && onPress.startsWith("webpage")) {
+               if (onPress != null){
+            if (onPress.startsWith("webpage")) {
                        try {
                                String webpage = MixUtils.parseAction(onPress);
                                this.detailsView = true;
                                ctx.loadWebPage(webpage);
                        } catch (Exception ex) {
                        }
+            } else if (onPress.startsWith("return")){
+                Intent intent = new Intent();
+                intent.putExtra("RESULT", xmlId);
+                ctx.mixView.setResult(Activity.RESULT_OK, intent);
+                ctx.mixView.finish();
+            }
                } 
                return true;
        }

Original comment by thoughtc...@googlemail.com on 14 Apr 2010 at 9:33

GoogleCodeExporter commented 8 years ago
Please see the dev-extras branch on https://github.com/mixare/mixare 

This is planned for release with the upcoming 0.8 version of mixare

Original comment by daniele.gobbetti on 28 Feb 2012 at 12:43

GoogleCodeExporter commented 8 years ago

Original comment by mixare.org on 23 Apr 2012 at 7:50