Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Atte Sillanpaeae
VR-demos
Commits
69e39ef4
Commit
69e39ef4
authored
Oct 18, 2017
by
Ruben Jesus Garcia Hernandez
Browse files
Android Cardboard: Support new phones/systems intents (for loading config
file), add analytics json support, fix app name
parent
2029a2d0
Changes
4
Hide whitespace changes
Inline
Side-by-side
GoogleCardboardAndroid/NOMADgvrT/src/main/java/com/google/vr/ndk/samples/treasurehunt/Filepath.java
0 → 100644
View file @
69e39ef4
package
com.google.vr.ndk.samples.treasurehunt
;
//https://stackoverflow.com/questions/3401579/get-filename-and-path-from-uri-from-mediastore/7265235#7265235
class
Filepath
{
//@SuppressLint("NewApi")
public
static
String
getFilePath
(
android
.
content
.
Context
context
,
android
.
net
.
Uri
uri
)
throws
java
.
net
.
URISyntaxException
{
String
selection
=
null
;
String
[]
selectionArgs
=
null
;
// Uri is different in versions after KITKAT (Android 4.4), we need to
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
19
&&
android
.
provider
.
DocumentsContract
.
isDocumentUri
(
context
.
getApplicationContext
(),
uri
))
{
if
(
isExternalStorageDocument
(
uri
))
{
final
String
docId
=
android
.
provider
.
DocumentsContract
.
getDocumentId
(
uri
);
final
String
[]
split
=
docId
.
split
(
":"
);
return
android
.
os
.
Environment
.
getExternalStorageDirectory
()
+
"/"
+
split
[
1
];
}
else
if
(
isDownloadsDocument
(
uri
))
{
final
String
id
=
android
.
provider
.
DocumentsContract
.
getDocumentId
(
uri
);
uri
=
android
.
content
.
ContentUris
.
withAppendedId
(
android
.
net
.
Uri
.
parse
(
"content://downloads/public_downloads"
),
Long
.
valueOf
(
id
));
}
else
if
(
isMediaDocument
(
uri
))
{
final
String
docId
=
android
.
provider
.
DocumentsContract
.
getDocumentId
(
uri
);
final
String
[]
split
=
docId
.
split
(
":"
);
final
String
type
=
split
[
0
];
if
(
"image"
.
equals
(
type
))
{
uri
=
android
.
provider
.
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
;
}
else
if
(
"video"
.
equals
(
type
))
{
uri
=
android
.
provider
.
MediaStore
.
Video
.
Media
.
EXTERNAL_CONTENT_URI
;
}
else
if
(
"audio"
.
equals
(
type
))
{
uri
=
android
.
provider
.
MediaStore
.
Audio
.
Media
.
EXTERNAL_CONTENT_URI
;
}
selection
=
"_id=?"
;
selectionArgs
=
new
String
[]{
split
[
1
]
};
}
}
if
(
"content"
.
equalsIgnoreCase
(
uri
.
getScheme
()))
{
String
[]
projection
=
{
android
.
provider
.
MediaStore
.
Images
.
Media
.
DATA
};
android
.
database
.
Cursor
cursor
=
null
;
try
{
cursor
=
context
.
getContentResolver
()
.
query
(
uri
,
projection
,
selection
,
selectionArgs
,
null
);
int
column_index
=
cursor
.
getColumnIndexOrThrow
(
android
.
provider
.
MediaStore
.
Images
.
Media
.
DATA
);
if
(
cursor
.
moveToFirst
())
{
return
cursor
.
getString
(
column_index
);
}
}
catch
(
Exception
e
)
{
}
}
else
if
(
"file"
.
equalsIgnoreCase
(
uri
.
getScheme
()))
{
return
uri
.
getPath
();
}
return
null
;
}
public
static
boolean
isExternalStorageDocument
(
android
.
net
.
Uri
uri
)
{
return
"com.android.externalstorage.documents"
.
equals
(
uri
.
getAuthority
());
}
public
static
boolean
isDownloadsDocument
(
android
.
net
.
Uri
uri
)
{
return
"com.android.providers.downloads.documents"
.
equals
(
uri
.
getAuthority
());
}
public
static
boolean
isMediaDocument
(
android
.
net
.
Uri
uri
)
{
return
"com.android.providers.media.documents"
.
equals
(
uri
.
getAuthority
());
}
}
GoogleCardboardAndroid/NOMADgvrT/src/main/java/com/google/vr/ndk/samples/treasurehunt/MainActivity.java
View file @
69e39ef4
...
...
@@ -91,7 +91,13 @@ public static void verifyStoragePermissions(Activity activity) {
}
else
if
(
s
.
startsWith
(
"content://com.asus.filemanager.OpenFileProvider/file"
))
{
uriString
=
s
.
substring
(
52
);
}
else
{
uriString
=
s
;
android
.
net
.
Uri
u
=
android
.
net
.
Uri
.
parse
(
s
);
try
{
uriString
=
Filepath
.
getFilePath
(
this
.
getApplicationContext
(),
u
);
}
catch
(
java
.
net
.
URISyntaxException
e
)
{
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"URISyntaxException, e="
+
e
);
uriString
=
null
;
}
}
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"OnActivityResult, uri="
+
uriString
);
nativeSetConfigFile
(
uriString
,
android
.
os
.
Environment
.
getExternalStorageDirectory
().
getPath
()
+
"/"
);
...
...
GoogleCardboardAndroid/NOMADgvrT/src/main/jni/treasure_hunt_renderer.cc
View file @
69e39ef4
...
...
@@ -658,14 +658,16 @@ if (animateTimesteps) {
frame
.
BindBuffer
(
0
);
if
(
error
<
0
)
{
//rgh: FIXME, add textures with messages here
if
(
-
100
<
error
)
{
if
(
-
100
<
error
)
{
//error with ncfg file
glClearColor
(
1.
f
,
0.
f
,
0.
f
,
1.
f
);
}
else
if
(
-
200
<
error
){
}
else
if
(
-
200
<
error
){
//error loading xyz
glClearColor
(
0.
f
,
1.
f
,
0.
f
,
1.
f
);
}
else
if
(
-
300
<
error
)
{
}
else
if
(
-
300
<
error
)
{
//error loading gaussian
glClearColor
(
0.
f
,
0.
f
,
1.
f
,
1.
f
);
}
else
if
(
-
400
<
error
)
{
glClearColor
(
0.
f
,
1.
f
,
1.
f
,
1.
f
);
}
else
if
(
-
400
<
error
)
{
//error loading encyclopedia json
glClearColor
(
0.
f
,
1.
f
,
1.
f
,
1.
f
);
}
else
if
(
-
500
<
error
)
{
//error loading analytics json
glClearColor
(
1.
f
,
1.
f
,
0.
f
,
1.
f
);
}
else
{
glClearColor
(
1.
f
,
0.
f
,
1.
f
,
1.
f
);
}
...
...
@@ -853,7 +855,7 @@ if ((e = glGetError()) != GL_NO_ERROR)
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"5 Gl error RenderIsos timestep =%d: %d
\n
"
,
currentSet
,
e
);
eprintf
(
"Drawing %d vertices, isos"
,
numISOIndices
[
currentSet
*
ISOS
+
i
]);
glDrawElements
(
GL_TRIANGLES
,
numISOIndices
[
currentSet
*
ISOS
+
i
]
,
GL_UNSIGNED_INT
,
0
);
glDrawElements
(
GL_TRIANGLES
,
numISOIndices
[
currentSet
*
ISOS
+
i
]
,
GL_UNSIGNED_INT
,
0
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"6 Gl error RenderIsos timestep =%d: %d
\n
"
,
currentSet
,
e
);
}
...
...
GoogleCardboardAndroid/NOMADgvrT/src/main/res/values/strings.xml
View file @
69e39ef4
<resources>
<string
name=
"app_name"
>
NOMAD
gvrT
</string>
<string
name=
"app_name"
>
NOMAD
VR
</string>
</resources>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment