Skip to content

Commit 7769eb2

Browse files
Initial release (v1.0)
1 parent bbc6d8d commit 7769eb2

File tree

133 files changed

+4847
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+4847
-0
lines changed

source/MobileUtils_gml/MobileUtils.yyp

Lines changed: 102 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
YoYoGames x Opera
167 KB
Loading
20.9 KB
Loading
47.5 KB
Binary file not shown.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
2+
package ${YYAndroidPackageName};
3+
import ${YYAndroidPackageName}.R;
4+
import com.yoyogames.runner.RunnerJNILib;
5+
6+
import android.app.Activity;
7+
import android.content.Intent;
8+
import android.net.Uri;
9+
import android.os.Environment;
10+
import android.provider.MediaStore;
11+
import android.os.Build;
12+
import android.os.StrictMode;
13+
import android.util.Log;
14+
15+
import java.io.File;
16+
import java.lang.SecurityException;
17+
18+
import java.lang.Exception;
19+
20+
import java.util.Date;
21+
import java.text.SimpleDateFormat;
22+
23+
import androidx.core.content.FileProvider;
24+
25+
public class MobileUtils_Camera extends RunnerSocial
26+
{
27+
int MY_PERMISSIONS = 9;
28+
int EVENT_OTHER_SOCIAL = 70;
29+
int CAMERA_REQUEST_CODE = 17;
30+
31+
String currentPhotoPath;
32+
33+
Activity activity = RunnerActivity.CurrentActivity;
34+
35+
private File createImageFile() throws Exception {
36+
// Create an image file name
37+
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
38+
String imageFileName = "JPEG_" + timeStamp + "_";
39+
File storageDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
40+
File image = File.createTempFile(
41+
imageFileName, /* prefix */
42+
".jpg", /* suffix */
43+
storageDir /* directory */
44+
);
45+
46+
currentPhotoPath = image.getAbsolutePath();
47+
48+
return image;
49+
}
50+
51+
public double MobileUtils_Camera_Open()
52+
{
53+
try
54+
{
55+
StrictMode.VmPolicy.Builder newbuilder = new StrictMode.VmPolicy.Builder();
56+
StrictMode.setVmPolicy(newbuilder.build());
57+
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
58+
//if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null)
59+
{
60+
File photoFile = null;
61+
try
62+
{
63+
photoFile = createImageFile();
64+
}
65+
catch (Exception ex)
66+
{
67+
Log.i("yoyo","Camera_Start error");
68+
// Error occurred while creating the File
69+
}
70+
// Continue only if the File was successfully created
71+
if (photoFile != null)
72+
{
73+
Uri photoURI = FileProvider.getUriForFile(activity, activity.getPackageName() + ".camera",photoFile);
74+
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
75+
activity.startActivityForResult(takePictureIntent, CAMERA_REQUEST_CODE);
76+
}
77+
}
78+
return 1;
79+
}
80+
catch (SecurityException e)
81+
{
82+
return -1.0;
83+
}
84+
}
85+
86+
@Override
87+
public void onActivityResult(int requestCode, int resultCode, Intent data)
88+
{
89+
if (resultCode == Activity.RESULT_OK)
90+
if (requestCode == CAMERA_REQUEST_CODE)
91+
{
92+
int dsMapIndex = RunnerJNILib.jCreateDsMap(null, null, null);
93+
RunnerJNILib.DsMapAddString( dsMapIndex,"type","MobileUtils_Camera_Open" );
94+
RunnerJNILib.DsMapAddString( dsMapIndex,"path",currentPhotoPath);
95+
RunnerJNILib.CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
96+
}
97+
}
98+
}
99+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<paths xmlns:android="http://schemas.android.com/apk/res/android">
3+
<external-path name="provider" path="/"/>
4+
</paths>

source/MobileUtils_gml/extensions/MobileUtils_Camera/CameraClass.ext

Whitespace-only changes.

source/MobileUtils_gml/extensions/MobileUtils_Camera/MobileUtils_Camera.yy

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
#import <UIKit/UIKit.h>
3+
4+
5+
@interface MobileUtils_Camera : UIViewController<UIImagePickerControllerDelegate,UINavigationControllerDelegate>
6+
{
7+
8+
}
9+
10+
@property (nonatomic, retain) NSString* ImagePath;
11+
12+
-(NSString*)iOS_GetPath;
13+
14+
@end
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
#import <Foundation/Foundation.h>
3+
#import "MobileUtils_Camera.h"
4+
5+
const int EVENT_OTHER_SOCIAL = 70;
6+
extern int CreateDsMap( int _num, ... );
7+
extern void CreateAsynEventWithDSMap(int dsmapindex, int event_index);
8+
extern UIViewController *g_controller;
9+
extern UIView *g_glView;
10+
extern int g_DeviceWidth;
11+
extern int g_DeviceHeight;
12+
13+
14+
@implementation MobileUtils_Camera
15+
{
16+
}
17+
18+
-(void) MobileUtils_Camera_Open
19+
{
20+
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
21+
picker.delegate = self;
22+
picker.allowsEditing = YES;
23+
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
24+
[g_controller presentViewController:picker animated:YES completion:NULL];
25+
}
26+
27+
28+
-(NSString*)iOS_GetPath
29+
{
30+
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
31+
return([paths objectAtIndex:0]);
32+
}
33+
34+
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
35+
{
36+
//UIImageWriteToSavedPhotosAlbum(chosenImage,nil,nil,nil);
37+
38+
NSString* path = [[self iOS_GetPath] stringByAppendingString: @"/temp.jpg"];
39+
UIImage *chosenImage = info[UIImagePickerControllerOriginalImage];
40+
41+
[UIImageJPEGRepresentation(chosenImage, 1.0) writeToFile:path atomically:YES];
42+
43+
[picker dismissViewControllerAnimated:YES completion:NULL];
44+
45+
int dsMapIndex;
46+
dsMapIndex = CreateDsMap(2,"type",0.0 ,"MobileUtils_Camera_Open","path", 0.0,[path UTF8String]);
47+
CreateAsynEventWithDSMap(dsMapIndex,EVENT_OTHER_SOCIAL);
48+
}
49+
50+
51+
@end

0 commit comments

Comments
 (0)