Loading libs/rs/java/ModelViewer/AndroidManifest.xml +8 −3 Original line number Diff line number Diff line Loading @@ -3,14 +3,19 @@ package="com.android.modelviewer"> <application android:label="ModelViewer"> <activity android:name="SimpleModel" android:label="SimpleModel" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar"> android:label="SimpleModel"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="A3DSelector" android:label="A3DSelector" android:hardwareAccelerated="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name="SceneGraph" android:label="SceneGraph" android:theme="@android:style/Theme.Black.NoTitleBar"> Loading libs/rs/java/ModelViewer/res/menu/loader_menu.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ --> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/load_model" android:title="@string/load_model" /> <item android:id="@+id/display_options" android:title="@string/display_options" /> </menu> libs/rs/java/ModelViewer/res/values/strings.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <skip /> <string name="load_model">Load Model</string> <string name="display_options">Display Options</string> </resources> libs/rs/java/ModelViewer/src/com/android/modelviewer/A3DSelector.java 0 → 100644 +110 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.modelviewer; import java.io.File; import java.io.FileFilter; import java.util.ArrayList; import java.util.List; import android.app.ListActivity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; /** * A list view where the last item the user clicked is placed in * the "activated" state, causing its background to highlight. */ public class A3DSelector extends ListActivity { File[] mCurrentSubList; File mCurrentFile; class A3DFilter implements FileFilter { public boolean accept(File file) { if (file.isDirectory()) { return true; } return file.getName().endsWith(".a3d"); } } private void populateList(File file) { mCurrentFile = file; setTitle(mCurrentFile.getAbsolutePath() + "/*.a3d"); List<String> names = new ArrayList<String>(); names.add(".."); mCurrentSubList = mCurrentFile.listFiles(new A3DFilter()); if (mCurrentSubList != null) { for (int i = 0; i < mCurrentSubList.length; i ++) { String fileName = mCurrentSubList[i].getName(); if (mCurrentSubList[i].isDirectory()) { fileName = "/" + fileName; } names.add(fileName); } } // Use the built-in layout for showing a list item with a single // line of text whose background is changes when activated. setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, names)); getListView().setTextFilterEnabled(true); // Tell the list view to show one checked/activated item at a time. getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); populateList(new File("/sdcard/")); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { if (position == 0) { File parent = mCurrentFile.getParentFile(); if (parent == null) { return; } populateList(parent); return; } // the first thing in list is parent directory File selectedFile = mCurrentSubList[position - 1]; if (selectedFile.isDirectory()) { populateList(selectedFile); return; } Intent resultIntent = new Intent(); resultIntent.setData(Uri.fromFile(selectedFile)); setResult(RESULT_OK, resultIntent); finish(); } } libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModel.java +43 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.renderscript.RenderScript; import android.app.Activity; import android.content.res.Configuration; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Looper; Loading @@ -31,9 +32,11 @@ import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.MenuInflater; import android.view.Window; import android.widget.Button; import android.widget.ListView; import android.net.Uri; import java.lang.Runtime; Loading Loading @@ -67,5 +70,45 @@ public class SimpleModel extends Activity { mView.pause(); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.loader_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.load_model: loadModel(); return true; case R.id.display_options: return true; default: return super.onOptionsItemSelected(item); } } private static final int FIND_A3D_MODEL = 10; public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { if (requestCode == FIND_A3D_MODEL) { Uri selectedImageUri = data.getData(); Log.e("Selected Path: ", selectedImageUri.getPath()); mView.loadA3DFile(selectedImageUri.getPath()); } } } public void loadModel() { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setClassName("com.android.modelviewer", "com.android.modelviewer.A3DSelector"); startActivityForResult(intent, FIND_A3D_MODEL); } } Loading
libs/rs/java/ModelViewer/AndroidManifest.xml +8 −3 Original line number Diff line number Diff line Loading @@ -3,14 +3,19 @@ package="com.android.modelviewer"> <application android:label="ModelViewer"> <activity android:name="SimpleModel" android:label="SimpleModel" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar"> android:label="SimpleModel"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="A3DSelector" android:label="A3DSelector" android:hardwareAccelerated="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name="SceneGraph" android:label="SceneGraph" android:theme="@android:style/Theme.Black.NoTitleBar"> Loading
libs/rs/java/ModelViewer/res/menu/loader_menu.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ --> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/load_model" android:title="@string/load_model" /> <item android:id="@+id/display_options" android:title="@string/display_options" /> </menu>
libs/rs/java/ModelViewer/res/values/strings.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <skip /> <string name="load_model">Load Model</string> <string name="display_options">Display Options</string> </resources>
libs/rs/java/ModelViewer/src/com/android/modelviewer/A3DSelector.java 0 → 100644 +110 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.modelviewer; import java.io.File; import java.io.FileFilter; import java.util.ArrayList; import java.util.List; import android.app.ListActivity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; /** * A list view where the last item the user clicked is placed in * the "activated" state, causing its background to highlight. */ public class A3DSelector extends ListActivity { File[] mCurrentSubList; File mCurrentFile; class A3DFilter implements FileFilter { public boolean accept(File file) { if (file.isDirectory()) { return true; } return file.getName().endsWith(".a3d"); } } private void populateList(File file) { mCurrentFile = file; setTitle(mCurrentFile.getAbsolutePath() + "/*.a3d"); List<String> names = new ArrayList<String>(); names.add(".."); mCurrentSubList = mCurrentFile.listFiles(new A3DFilter()); if (mCurrentSubList != null) { for (int i = 0; i < mCurrentSubList.length; i ++) { String fileName = mCurrentSubList[i].getName(); if (mCurrentSubList[i].isDirectory()) { fileName = "/" + fileName; } names.add(fileName); } } // Use the built-in layout for showing a list item with a single // line of text whose background is changes when activated. setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, names)); getListView().setTextFilterEnabled(true); // Tell the list view to show one checked/activated item at a time. getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); populateList(new File("/sdcard/")); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { if (position == 0) { File parent = mCurrentFile.getParentFile(); if (parent == null) { return; } populateList(parent); return; } // the first thing in list is parent directory File selectedFile = mCurrentSubList[position - 1]; if (selectedFile.isDirectory()) { populateList(selectedFile); return; } Intent resultIntent = new Intent(); resultIntent.setData(Uri.fromFile(selectedFile)); setResult(RESULT_OK, resultIntent); finish(); } }
libs/rs/java/ModelViewer/src/com/android/modelviewer/SimpleModel.java +43 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.renderscript.RenderScript; import android.app.Activity; import android.content.res.Configuration; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Looper; Loading @@ -31,9 +32,11 @@ import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.MenuInflater; import android.view.Window; import android.widget.Button; import android.widget.ListView; import android.net.Uri; import java.lang.Runtime; Loading Loading @@ -67,5 +70,45 @@ public class SimpleModel extends Activity { mView.pause(); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.loader_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.load_model: loadModel(); return true; case R.id.display_options: return true; default: return super.onOptionsItemSelected(item); } } private static final int FIND_A3D_MODEL = 10; public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { if (requestCode == FIND_A3D_MODEL) { Uri selectedImageUri = data.getData(); Log.e("Selected Path: ", selectedImageUri.getPath()); mView.loadA3DFile(selectedImageUri.getPath()); } } } public void loadModel() { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setClassName("com.android.modelviewer", "com.android.modelviewer.A3DSelector"); startActivityForResult(intent, FIND_A3D_MODEL); } }