1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.testapp; 18 19import android.renderscript.RSSurfaceView; 20import android.renderscript.RenderScript; 21 22import android.app.Activity; 23import android.content.res.Configuration; 24import android.content.Intent; 25import android.os.Bundle; 26import android.os.Handler; 27import android.os.Looper; 28import android.os.Message; 29import android.provider.Settings.System; 30import android.util.Log; 31import android.view.Menu; 32import android.view.MenuItem; 33import android.view.View; 34import android.view.Window; 35import android.widget.Button; 36import android.widget.ListView; 37import android.view.MenuInflater; 38import android.view.Window; 39import android.net.Uri; 40 41import java.lang.Runtime; 42 43public class TestApp extends Activity { 44 45 private TestAppView mView; 46 47 @Override 48 public void onCreate(Bundle icicle) { 49 super.onCreate(icicle); 50 51 // Create our Preview view and set it as the content of our 52 // Activity 53 mView = new TestAppView(this); 54 setContentView(mView); 55 } 56 57 @Override 58 protected void onResume() { 59 // Ideally a game should implement onResume() and onPause() 60 // to take appropriate action when the activity looses focus 61 super.onResume(); 62 mView.resume(); 63 } 64 65 @Override 66 protected void onPause() { 67 // Ideally a game should implement onResume() and onPause() 68 // to take appropriate action when the activity looses focus 69 super.onPause(); 70 mView.pause(); 71 } 72 73 @Override 74 public boolean onCreateOptionsMenu(Menu menu) { 75 MenuInflater inflater = getMenuInflater(); 76 inflater.inflate(R.menu.loader_menu, menu); 77 return true; 78 } 79 80 @Override 81 public boolean onOptionsItemSelected(MenuItem item) { 82 // Handle item selection 83 switch (item.getItemId()) { 84 case R.id.load_model: 85 loadModel(); 86 return true; 87 case R.id.use_blur: 88 mView.mRender.toggleBlur(); 89 return true; 90 default: 91 return super.onOptionsItemSelected(item); 92 } 93 } 94 95 private static final int FIND_DAE_MODEL = 10; 96 public void onActivityResult(int requestCode, int resultCode, Intent data) { 97 if (resultCode == RESULT_OK) { 98 if (requestCode == FIND_DAE_MODEL) { 99 Uri selectedImageUri = data.getData(); 100 Log.e("Selected Path: ", selectedImageUri.getPath()); 101 mView.mRender.loadModel(selectedImageUri.getPath()); 102 } 103 } 104 } 105 106 public void loadModel() { 107 Intent intent = new Intent(); 108 intent.setAction(Intent.ACTION_PICK); 109 intent.setClassName("com.android.testapp", 110 "com.android.testapp.FileSelector"); 111 startActivityForResult(intent, FIND_DAE_MODEL); 112 } 113 114} 115 116