mirror of
https://github.com/vanitasvitae/Spherical
synced 2024-11-22 04:12:07 +01:00
Add more logic and metadata object.
This commit is contained in:
parent
68d2695fae
commit
c74c40dc7c
3 changed files with 98 additions and 18 deletions
|
@ -8,7 +8,6 @@ import android.util.Log;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -18,7 +17,9 @@ import de.trac.spherical.parser.SphereParser;
|
|||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
public static final String TAG = "Spherical";
|
||||
public static final String INTENT_SPHERE = "application/vnd.google.panorama360+jpg";
|
||||
|
||||
public static final String MIME_PHOTO_SPHERE = "application/vnd.google.panorama360+jpg";
|
||||
public static final String MIME_IMAGE = "image/*";
|
||||
|
||||
private TextView text;
|
||||
|
||||
|
@ -26,41 +27,81 @@ public class MainActivity extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
//TODO: Remove later
|
||||
text = (TextView) findViewById(R.id.hello_world);
|
||||
|
||||
Log.d(TAG, "STARTING");
|
||||
Intent intent = getIntent();
|
||||
Log.d(TAG, "Intent: " + intent.getAction() + " " + intent.getType());
|
||||
|
||||
switch (intent.getAction()) {
|
||||
//Image was sent into the app
|
||||
case Intent.ACTION_SEND:
|
||||
handleSentImage(intent);
|
||||
break;
|
||||
handleSentImageIntent(intent);
|
||||
break;
|
||||
|
||||
//App was launched via launcher icon
|
||||
//TODO: Remove later together with launcher intent filter
|
||||
default:
|
||||
Toast.makeText(this, R.string.prompt_share_image, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSentImage(Intent intent) {
|
||||
/**
|
||||
* Distinguish type of sent image. Images with the MIME type of a photosphere will be directly
|
||||
* displayed, while images with MIME type image/* are being manually tested using {@link SphereParser}.
|
||||
* @param intent incoming intent.
|
||||
*/
|
||||
private void handleSentImageIntent(Intent intent) {
|
||||
String type = intent.getType();
|
||||
if (type != null) {
|
||||
switch (type) {
|
||||
case INTENT_SPHERE:
|
||||
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if (imageUri != null) {
|
||||
showImage(imageUri);
|
||||
}
|
||||
|
||||
Toast.makeText(this, R.string.wow, Toast.LENGTH_LONG).show();
|
||||
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if (imageUri == null) {
|
||||
Toast.makeText(this, R.string.file_not_found, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case MIME_PHOTO_SPHERE:
|
||||
displayPhotoSphere(imageUri);
|
||||
break;
|
||||
|
||||
case MIME_IMAGE:
|
||||
displayMaybePhotoSphere(imageUri);
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
Toast.makeText(this, "LOL", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(this, "TODO: Figure out what to do :D", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void showImage(Uri uri) {
|
||||
/**
|
||||
* Check, whether the sent photo is a photo sphere and display either a sphere, or a plain image.
|
||||
* @param uri
|
||||
*/
|
||||
private void displayMaybePhotoSphere(Uri uri) {
|
||||
try {
|
||||
InputStream inputStream = getContentResolver().openInputStream(uri);
|
||||
String xml = SphereParser.getXMLContent(inputStream);
|
||||
|
||||
boolean sphere = true; //TODO: parser.
|
||||
|
||||
if (sphere) {
|
||||
displayPhotoSphere(uri);
|
||||
} else {
|
||||
displayFlatImage(uri);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a photo sphere.
|
||||
* @param uri
|
||||
*/
|
||||
private void displayPhotoSphere(Uri uri) {
|
||||
try {
|
||||
InputStream inputStream = getContentResolver().openInputStream(uri);
|
||||
String xml = SphereParser.getXMLContent(inputStream);
|
||||
|
@ -79,4 +120,12 @@ public class MainActivity extends AppCompatActivity {
|
|||
Toast.makeText(this, R.string.ioerror, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a flat image.
|
||||
* @param uri
|
||||
*/
|
||||
private void displayFlatImage(Uri uri) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package de.trac.spherical.parser;
|
||||
|
||||
/**
|
||||
* Created by vanitas on 12.09.17.
|
||||
*/
|
||||
|
||||
public class PhotoSphereMetadata {
|
||||
|
||||
public static final String USE_PANORAMA_VIEWER = "GPano:UsePanoramaViewer";
|
||||
public static final String CAPTURE_SOFTWARE = "GPano:CaptureSoftware";
|
||||
public static final String STITCHING_SOFTWARE = "GPano:StitchingSoftware";
|
||||
public static final String PROJECTION_TYPE = "GPano:ProjectionType";
|
||||
public static final String POSE_HEADING_DEGREES = "GPano:PoseHeadingDegrees";
|
||||
public static final String POSE_PITCH_DEGREES = "GPano:PosePitchDegrees";
|
||||
public static final String POSE_ROLL_DEGREES = "GPano:PoseRollDegrees";
|
||||
public static final String INITIAL_VIEW_HEADING_DEGREES = "GPano:InitialViewHeadingDegrees";
|
||||
public static final String INITIAL_VIEW_PITCH_DEGREES = "GPano:InitialViewPitchDegrees";
|
||||
public static final String INITIAL_VIEW_ROLL_DEGREES = "GPano:InitialViewRollDegrees";
|
||||
public static final String INITIAL_HORIZONTAL_POV_DEGREES = "GPano:InitialHorizontalFOVDegrees";
|
||||
public static final String FIRST_PHOTO_DATE = "GPano:FirstPhotoDate";
|
||||
public static final String LAST_PHOTO_DATE = "GPano:LastPhotoDate";
|
||||
public static final String SOURCE_PHOTOS_COUNT = "GPano:SourcePhotosCount";
|
||||
public static final String EXPOSURE_LOCK_USED = "GPano:ExposureLockUsed";
|
||||
public static final String CROPPED_AREA_IMAGE_WIDTH_PIXELS = "GPano:CroppedAreaImageWidthPixels";
|
||||
public static final String CROPPED_AREA_IMAGE_HEIGHT_PIXELS = "GPano:CroppedAreaImageHeightPixels";
|
||||
public static final String FULL_PANO_WIDTH_PIXELS = "GPano:FullPanoWidthPixels";
|
||||
public static final String FULL_PANO_HEIGHT_PIXELS = "GPano:FullPanoHeightPixels";
|
||||
public static final String CROPPED_AREA_LEFT_PIXELS = "GPano:CroppedAreaLeftPixels";
|
||||
public static final String CROPPED_AREA_TOP_PIXELS = "GPano:CroppedAreaTopPixels";
|
||||
public static final String INITIAL_CAMERA_DOLLY = "GPano:InitialCameraDolly";
|
||||
}
|
|
@ -108,7 +108,7 @@ public class SphereParser {
|
|||
}
|
||||
}
|
||||
|
||||
public static void append(ArrayList<Byte> list, byte[] array, int r) {
|
||||
private static void append(ArrayList<Byte> list, byte[] array, int r) {
|
||||
for (int i = 0; i < r; i++) {
|
||||
list.add(array[i]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue