Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
5ad1af8e
Commit
5ad1af8e
authored
11 years ago
by
Maxime Graulich
Browse files
Options
Downloads
Patches
Plain Diff
Android: open file browser
parent
8243ae6e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java
+2
-2
2 additions, 2 deletions
contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java
contrib/mobile/Android/src/org/geuz/onelab/ModelList.java
+25
-126
25 additions, 126 deletions
contrib/mobile/Android/src/org/geuz/onelab/ModelList.java
with
27 additions
and
128 deletions
contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java
+
2
−
2
View file @
5ad1af8e
...
@@ -56,10 +56,10 @@ public class MainActivity extends Activity{
...
@@ -56,10 +56,10 @@ public class MainActivity extends Activity{
Intent
intent
=
getIntent
();
Intent
intent
=
getIntent
();
Bundle
extras
=
intent
.
getExtras
();
Bundle
extras
=
intent
.
getExtras
();
if
(
savedInstanceState
!=
null
);
if
(
savedInstanceState
!=
null
);
else
if
(
intent
!=
null
&&
intent
.
getAction
()
!=
null
&&
intent
.
getAction
().
equals
(
Intent
.
ACTION_VIEW
))
{
else
if
(
intent
.
getAction
()
!=
null
&&
intent
.
getAction
().
equals
(
Intent
.
ACTION_VIEW
))
{
String
tmp
=
intent
.
getData
().
getPath
();
String
tmp
=
intent
.
getData
().
getPath
();
_gmsh
.
load
(
tmp
);
_gmsh
.
load
(
tmp
);
}
}
else
if
(
extras
!=
null
)
{
else
if
(
extras
!=
null
)
{
//extras.getString("name");
//extras.getString("name");
String
tmp
=
extras
.
getString
(
"file"
);
String
tmp
=
extras
.
getString
(
"file"
);
...
...
This diff is collapsed.
Click to expand it.
contrib/mobile/Android/src/org/geuz/onelab/ModelList.java
+
25
−
126
View file @
5ad1af8e
...
@@ -15,10 +15,12 @@ import android.app.Dialog;
...
@@ -15,10 +15,12 @@ import android.app.Dialog;
import
android.app.DialogFragment
;
import
android.app.DialogFragment
;
import
android.content.DialogInterface
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.os.Environment
;
import
android.provider.MediaStore
;
import
android.util.Xml
;
import
android.util.Xml
;
import
android.view.Menu
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.view.MenuItem
;
...
@@ -48,17 +50,6 @@ public class ModelList extends Activity {
...
@@ -48,17 +50,6 @@ public class ModelList extends Activity {
LinearLayout
layout
=
new
LinearLayout
(
this
);
LinearLayout
layout
=
new
LinearLayout
(
this
);
layout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
layout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
ListView
list
=
new
ListView
(
this
);
ListView
list
=
new
ListView
(
this
);
Button
loadSD
=
new
Button
(
this
);
loadSD
.
setText
(
R
.
string
.
button_open_external_file
);
loadSD
.
setLayoutParams
(
new
ListView
.
LayoutParams
(
LayoutParams
.
MATCH_PARENT
,
ListView
.
LayoutParams
.
WRAP_CONTENT
));
loadSD
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
public
void
onClick
(
View
v
)
{
@SuppressWarnings
(
"unused"
)
SDFileChooser
f
=
new
SDFileChooser
();
}
});
//TODO list.addFooterView(loadSD);
list
.
setAdapter
(
_modelArrayAdapter
);
list
.
setAdapter
(
_modelArrayAdapter
);
list
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
list
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
...
@@ -125,12 +116,33 @@ public class ModelList extends Activity {
...
@@ -125,12 +116,33 @@ public class ModelList extends Activity {
@Override
@Override
public
boolean
onMenuItemSelected
(
int
featureId
,
MenuItem
item
)
{
public
boolean
onMenuItemSelected
(
int
featureId
,
MenuItem
item
)
{
if
(
item
.
getTitle
().
equals
(
getString
(
R
.
string
.
button_open_external_file
)))
{
if
(
item
.
getTitle
().
equals
(
getString
(
R
.
string
.
button_open_external_file
)))
{
Intent
browserIntent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
fromFile
(
this
.
getFilesDir
()));
Intent
fileBrowserIntent
=
new
Intent
();
startActivity
(
browserIntent
);
fileBrowserIntent
.
setAction
(
Intent
.
ACTION_GET_CONTENT
);
fileBrowserIntent
.
setType
(
"file/*"
);
startActivityForResult
(
fileBrowserIntent
,
1
);
}
}
return
super
.
onMenuItemSelected
(
featureId
,
item
);
return
super
.
onMenuItemSelected
(
featureId
,
item
);
}
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
switch
(
requestCode
)
{
case
1
:
Uri
uri
=
data
.
getData
();
String
[]
projection
=
{
MediaStore
.
Images
.
Media
.
DATA
};
Cursor
cursor
=
managedQuery
(
uri
,
projection
,
null
,
null
,
null
);
int
column_index
=
cursor
.
getColumnIndexOrThrow
(
MediaStore
.
Images
.
Media
.
DATA
);
cursor
.
moveToFirst
();
Intent
intent
=
new
Intent
(
ModelList
.
this
,
MainActivity
.
class
);
intent
.
putExtra
(
"file"
,
cursor
.
getString
(
column_index
));
intent
.
putExtra
(
"name"
,
"None"
);
startActivity
(
intent
);
break
;
}
}
private
void
getModels
()
throws
XmlPullParserException
,
IOException
private
void
getModels
()
throws
XmlPullParserException
,
IOException
{
{
File
document
=
this
.
getFilesDir
();
File
document
=
this
.
getFilesDir
();
...
@@ -228,117 +240,4 @@ public class ModelList extends Activity {
...
@@ -228,117 +240,4 @@ public class ModelList extends Activity {
}
}
}
}
}
}
private
class
SDFileChooser
{
File
curentPath
;
FileDialog
dialog
;
public
SDFileChooser
()
{
String
state
=
Environment
.
getExternalStorageState
();
if
(
Environment
.
MEDIA_MOUNTED
.
equals
(
state
)
||
Environment
.
MEDIA_MOUNTED_READ_ONLY
.
equals
(
state
))
{
curentPath
=
Environment
.
getExternalStorageDirectory
();
showList
(
getFile
(
curentPath
));
}
else
showMessage
(
R
.
string
.
error_nosdcard
);
}
public
void
setPath
(
String
newPath
)
{
curentPath
=
new
File
(
newPath
);
showList
(
getFile
(
curentPath
));
}
public
String
getPath
()
{
return
curentPath
.
toString
();
}
private
void
showList
(
String
[]
list
)
{
if
(!
curentPath
.
toString
().
equals
(
Environment
.
getExternalStorageDirectory
().
toString
())){
String
[]
newList
=
new
String
[
list
.
length
+
1
];
for
(
int
i
=
0
;
i
<
list
.
length
;
i
++)
newList
[
i
+
1
]
=
list
[
i
];
newList
[
0
]
=
".."
;
list
=
newList
;
}
if
(
list
.
length
<
1
){
showMessage
(
R
.
string
.
error_nomshfile
);
return
;
}
if
(
dialog
!=
null
)
dialog
.
dismiss
();
dialog
=
new
FileDialog
(
this
,
list
);
dialog
.
show
(
getFragmentManager
(),
"files"
);
}
private
void
showMessage
(
int
msg
)
{
dialog
=
new
FileDialog
(
this
,
msg
);
dialog
.
show
(
getFragmentManager
(),
"msg"
);
}
private
String
[]
getFile
(
File
path
)
{
return
path
.
list
(
new
FilenameFilter
()
{
public
boolean
accept
(
File
dir
,
String
filename
)
{
String
ext
=
filename
.
substring
(
filename
.
lastIndexOf
(
"."
)
+
1
,
filename
.
length
());
File
curent
=
new
File
(
dir
.
toString
()+
"/"
+
filename
);
if
(
curent
.
isHidden
())
return
false
;
else
if
(
curent
.
isDirectory
())
return
true
;
else
if
(
ext
.
equals
(
"MSH"
)
||
ext
.
equals
(
"msh"
)
||
ext
.
equals
(
"geo"
)
||
ext
.
equals
(
"GEO"
)
||
ext
.
equals
(
"pro"
)
||
ext
.
equals
(
"PRO"
))
return
true
;
else
return
false
;
}
});
}
private
class
FileDialog
extends
DialogFragment
{
String
[]
list
;
int
msg
=
-
1
;
SDFileChooser
parent
;
public
FileDialog
(
SDFileChooser
p
,
String
[]
l
)
{
list
=
l
;
parent
=
p
;
}
public
FileDialog
(
SDFileChooser
p
,
int
m
)
{
msg
=
m
;
parent
=
p
;
}
@Override
public
Dialog
onCreateDialog
(
Bundle
savedInstanceState
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
getActivity
());
if
(
msg
>
0
)
{
builder
.
setMessage
(
R
.
string
.
error_nomshfile
)
.
setPositiveButton
(
R
.
string
.
button_ok
,
null
);
}
else
{
builder
.
setTitle
(
R
.
string
.
dialog_title_choosefile
);
builder
.
setItems
(
list
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
if
(
list
[
which
].
equals
(
".."
))
parent
.
setPath
(
curentPath
.
getParentFile
().
toString
());
else
if
(
new
File
(
parent
.
getPath
()
+
"/"
+
list
[
which
]).
isDirectory
())
parent
.
setPath
(
parent
.
getPath
()
+
"/"
+
list
[
which
]);
else
{
String
ext
=
list
[
which
].
substring
(
list
[
which
].
lastIndexOf
(
"."
)
+
1
,
list
[
which
].
length
());
if
(
ext
.
equals
(
"MSH"
)
||
ext
.
equals
(
"msh"
)
||
ext
.
equals
(
"geo"
)
||
ext
.
equals
(
"GEO"
)
||
ext
.
equals
(
"pro"
)
||
ext
.
equals
(
"PRO"
))
{
Intent
intent
=
new
Intent
(
ModelList
.
this
,
MainActivity
.
class
);
intent
.
putExtra
(
"file"
,
curentPath
+
"/"
+
getFile
(
curentPath
)[
which
]);
startActivity
(
intent
);
}
}
}
});
}
return
builder
.
create
();
};
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment