diff options
Diffstat (limited to 'testapps/testSensors')
-rw-r--r-- | testapps/testSensors/.classpath | 8 | ||||
-rw-r--r-- | testapps/testSensors/.project | 33 | ||||
-rw-r--r-- | testapps/testSensors/AndroidManifest.xml | 41 | ||||
-rw-r--r-- | testapps/testSensors/project.properties | 11 | ||||
-rw-r--r-- | testapps/testSensors/res/drawable-hdpi/ic_launcher.png | bin | 4147 -> 0 bytes | |||
-rw-r--r-- | testapps/testSensors/res/drawable-ldpi/ic_launcher.png | bin | 1723 -> 0 bytes | |||
-rw-r--r-- | testapps/testSensors/res/drawable-mdpi/ic_launcher.png | bin | 2574 -> 0 bytes | |||
-rw-r--r-- | testapps/testSensors/res/layout/main.xml | 15 | ||||
-rw-r--r-- | testapps/testSensors/res/layout/one_row.xml | 20 | ||||
-rw-r--r-- | testapps/testSensors/res/values/strings.xml | 7 | ||||
-rw-r--r-- | testapps/testSensors/src/com/android/tests/testsensors/TestSensorsActivity.java | 246 |
11 files changed, 0 insertions, 381 deletions
diff --git a/testapps/testSensors/.classpath b/testapps/testSensors/.classpath deleted file mode 100644 index a4763d1ee..000000000 --- a/testapps/testSensors/.classpath +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="gen"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> - <classpathentry kind="output" path="bin/classes"/> -</classpath> diff --git a/testapps/testSensors/.project b/testapps/testSensors/.project deleted file mode 100644 index de0da91e0..000000000 --- a/testapps/testSensors/.project +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>TestSensorsActivity</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>com.android.ide.eclipse.adt.ApkBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>com.android.ide.eclipse.adt.AndroidNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/testapps/testSensors/AndroidManifest.xml b/testapps/testSensors/AndroidManifest.xml deleted file mode 100644 index 375717436..000000000 --- a/testapps/testSensors/AndroidManifest.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* - * Copyright 2010 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. - */ ---> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.android.tests.testsensors" - android:versionCode="1" - android:versionName="1.0" > - - <uses-sdk android:minSdkVersion="8" /> - <uses-permission android:name="android.permission.INTERNET" /> - - <application - android:icon="@drawable/ic_launcher" - android:label="@string/app_name" > - <activity - android:label="@string/app_name" - android:name=".TestSensorsActivity" > - <intent-filter > - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest>
\ No newline at end of file diff --git a/testapps/testSensors/project.properties b/testapps/testSensors/project.properties deleted file mode 100644 index ea89160e0..000000000 --- a/testapps/testSensors/project.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-8 diff --git a/testapps/testSensors/res/drawable-hdpi/ic_launcher.png b/testapps/testSensors/res/drawable-hdpi/ic_launcher.png Binary files differdeleted file mode 100644 index 8074c4c57..000000000 --- a/testapps/testSensors/res/drawable-hdpi/ic_launcher.png +++ /dev/null diff --git a/testapps/testSensors/res/drawable-ldpi/ic_launcher.png b/testapps/testSensors/res/drawable-ldpi/ic_launcher.png Binary files differdeleted file mode 100644 index 1095584ec..000000000 --- a/testapps/testSensors/res/drawable-ldpi/ic_launcher.png +++ /dev/null diff --git a/testapps/testSensors/res/drawable-mdpi/ic_launcher.png b/testapps/testSensors/res/drawable-mdpi/ic_launcher.png Binary files differdeleted file mode 100644 index a07c69fa5..000000000 --- a/testapps/testSensors/res/drawable-mdpi/ic_launcher.png +++ /dev/null diff --git a/testapps/testSensors/res/layout/main.xml b/testapps/testSensors/res/layout/main.xml deleted file mode 100644 index 1f73c9c40..000000000 --- a/testapps/testSensors/res/layout/main.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/scrollView1" - android:layout_width="fill_parent" - android:layout_height="fill_parent" > - - <TableLayout - android:id="@+id/tableLayout" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:saveEnabled="false" /> - -</ScrollView> - diff --git a/testapps/testSensors/res/layout/one_row.xml b/testapps/testSensors/res/layout/one_row.xml deleted file mode 100644 index e3c54b890..000000000 --- a/testapps/testSensors/res/layout/one_row.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" > -
<TextView
- android:id="@+id/row_textview_name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:saveEnabled="false"
- android:layout_marginRight="10dp"
- android:textAppearance="?android:attr/textAppearanceSmall" />
-
- <TextView
- android:id="@+id/row_textview_value"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:textAppearance="?android:attr/textAppearanceSmall" />
-
-</TableRow>
\ No newline at end of file diff --git a/testapps/testSensors/res/values/strings.xml b/testapps/testSensors/res/values/strings.xml deleted file mode 100644 index bc7d7c8c8..000000000 --- a/testapps/testSensors/res/values/strings.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - - <string name="hello">Hello World, TestSensorsActivity!</string> - <string name="app_name">TestSensors</string> - -</resources>
\ No newline at end of file diff --git a/testapps/testSensors/src/com/android/tests/testsensors/TestSensorsActivity.java b/testapps/testSensors/src/com/android/tests/testsensors/TestSensorsActivity.java deleted file mode 100644 index c30e05fd5..000000000 --- a/testapps/testSensors/src/com/android/tests/testsensors/TestSensorsActivity.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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.tests.testsensors; - -import java.util.ArrayList; -import java.util.List; - -import android.app.Activity; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.widget.TableLayout; -import android.widget.TableRow; -import android.widget.TextView; - -public class TestSensorsActivity extends Activity { - private static final String TAG = "testSensors"; - /** Array containing monitored sensors. */ - private List<MonitoredSensor> mSensors; - /** Controls displayed list of sensors. */ - private TableLayout mTableLayout; - - /** - * Encapsulates a sensor. - */ - private class MonitoredSensor implements SensorEventListener { - /** Sensor to monitor. */ - private final Sensor mSensor; - /** Check box representing the sensor on the screen. */ - private final TextView mName; - /** Text view displaying the value of the sensor. */ - private final TextView mVal; - /** Formats string to show in the TextView. */ - private String mTextFmt; - - /** - * Constructs MonitoredSensor instance, and register the listeners. - * - * @param sensor Sensor to monitor. - */ - MonitoredSensor(Sensor sensor) { - mSensor = sensor; - - // Add a row representing this sensor on the display - final LayoutInflater inflater = getLayoutInflater(); - final TableRow row = (TableRow) inflater.inflate(R.layout.one_row, mTableLayout, false); - mTableLayout.addView(row); - - // Initialize displayed checkbox for this sensor, and register - // checked state listener for it. - mName = (TextView) row.findViewById(R.id.row_textview_name); - - // Initialize displayed text box for this sensor. - mVal = (TextView) row.findViewById(R.id.row_textview_value); - mVal.setText(""); - - // Set appropriate sensor name depending on the type. Unfortunately, - // we can't really use sensor.getName() here, since the value it - // returns (although resembles the purpose) is a bit vaguer than it - // should be. Also choose an appropriate format for the strings that - // display sensor's value, and strings that are sent to the - // emulator. - switch (sensor.getType()) { - case Sensor.TYPE_ACCELEROMETER: - mName.setText("Accelerometer"); - // 3 floats. - mTextFmt = "%+.2f %+.2f %+.2f"; - break; - case 9: // Sensor.TYPE_GRAVITY is missing in API 7 - // 3 floats. - mName.setText("Gravity"); - mTextFmt = "%+.2f %+.2f %+.2f"; - break; - case Sensor.TYPE_GYROSCOPE: - mName.setText("Gyroscope"); - // 3 floats. - mTextFmt = "%+.2f %+.2f %+.2f"; - break; - case Sensor.TYPE_LIGHT: - mName.setText("Light"); - // 1 integer. - mTextFmt = "%.0f"; - break; - case 10: // Sensor.TYPE_LINEAR_ACCELERATION is missing in API 7 - mName.setText("Linear acceleration"); - // 3 floats. - mTextFmt = "%+.2f %+.2f %+.2f"; - break; - case Sensor.TYPE_MAGNETIC_FIELD: - mName.setText("Magnetic field"); - // 3 floats. - mTextFmt = "%+.2f %+.2f %+.2f"; - break; - case Sensor.TYPE_ORIENTATION: - mName.setText("Orientation"); - // 3 integers. - mTextFmt = "%+03.0f %+03.0f %+03.0f"; - break; - case Sensor.TYPE_PRESSURE: - mName.setText("Pressure"); - // 1 integer. - mTextFmt = "%.0f"; - break; - case Sensor.TYPE_PROXIMITY: - mName.setText("Proximity"); - // 1 integer. - mTextFmt = "%.0f"; - break; - case 11: // Sensor.TYPE_ROTATION_VECTOR is missing in API 7 - mName.setText("Rotation"); - // 3 floats. - mTextFmt = "%+.2f %+.2f %+.2f"; - break; - case Sensor.TYPE_TEMPERATURE: - mName.setText("Temperature"); - // 1 integer. - mTextFmt = "%.0f"; - break; - default: - mName.setText("<Unknown>"); - mTextFmt = "N/A"; - break; - } - } - - /** - * Gets sensor type. - * - * @return Sensor type as one of the Sensor.TYPE_XXX constants. - */ - private int getType() { - return mSensor.getType(); - } - - /** - * Starts monitoring the sensor. NOTE: This method is called from - * outside of the UI thread. - */ - private void startListening() { - SensorManager sm = (SensorManager) getSystemService(SENSOR_SERVICE); - sm.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_UI); - } - - /** - * Stops monitoring the sensor. NOTE: This method is called from outside - * of the UI thread. - */ - private void stopListening() { - SensorManager sm = (SensorManager) getSystemService(SENSOR_SERVICE); - sm.unregisterListener(this); - } - - /** - * Handles "sensor changed" event. This is an implementation of the - * SensorEventListener interface. - */ - @Override - public void onSensorChanged(SensorEvent event) { - // Display current sensor value, and format message that will be - // sent to the emulator. - final int nArgs = event.values.length; - String val; - if (nArgs == 3) { - val = String.format(mTextFmt, event.values[0], event.values[1], event.values[2]); - } else if (nArgs == 2) { - val = String.format(mTextFmt, event.values[0], event.values[1]); - } else if (nArgs == 1) { - val = String.format(mTextFmt, event.values[0]); - } else { - return; - } - mVal.setText(val); - } - - /** - * Handles "sensor accuracy changed" event. This is an implementation of - * the SensorEventListener interface. - */ - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - } // MonitoredSensor - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - mTableLayout = (TableLayout) findViewById(R.id.tableLayout); - - // Iterate through the available sensors, adding them to the array. - mSensors = new ArrayList<MonitoredSensor>(); - SensorManager sm = (SensorManager) getSystemService(SENSOR_SERVICE); - List<Sensor> sensors = sm.getSensorList(Sensor.TYPE_ALL); - int cur_index = 0; - for (int n = 0; n < sensors.size(); n++) { - Sensor avail_sensor = sensors.get(n); - - // There can be multiple sensors of the same type. We need only one. - if (!isSensorTypeAlreadyMonitored(avail_sensor.getType())) { - // The first sensor we've got for the given type is not - // necessarily the right one. So, use the default sensor - // for the given type. - Sensor def_sens = sm.getDefaultSensor(avail_sensor.getType()); - MonitoredSensor to_add = new MonitoredSensor(def_sens); - cur_index++; - mSensors.add(to_add); - to_add.startListening(); - } - } - } - - /** - * Checks if a sensor for the given type is already monitored. - * - * @param type Sensor type (one of the Sensor.TYPE_XXX constants) - * @return true if a sensor for the given type is already monitored, or - * false if the sensor is not monitored. - */ - private boolean isSensorTypeAlreadyMonitored(int type) { - for (int n = 0; n < mSensors.size(); n++) { - if (mSensors.get(n).getType() == type) { - return true; - } - } - return false; - } -} |