Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 73: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 74: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 75: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 76: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 77: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 78: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
/** * ShakeController: provide a vibration when the user shake the device * Copyright (C) 2010 Ivomania * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ package com.ivomania.controller; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Vibrator; /** * Controls the shaking movement. Calibration made on Google Nexus One */ public class ShakeController { /** Gravity threshold module set to 1,33 G */ public static final float GRAVITY_MODULE = SensorManager.GRAVITY_EARTH + SensorManager.GRAVITY_EARTH/3; //Application context Context context; Vibrator vibrator; SensorManager sm; Sensor accelerometer; IvomaniaSensorListener accelerometerListener; private static ShakeController instance; /** * Singleton Implementation for this class (private constructor) * @param context the application context */ private ShakeController(Context context) { this.context = context; //init the listener accelerometerListener = new IvomaniaSensorListener(); //init the accelerometer initAccelerometer(); //init the vibrator initVibrator(); } /** * Singleton Implementation for this class * @param context the application context * @return ShakeController this class unique instance */ public static ShakeController getInstance(Context context) { if (instance == null) { instance = new ShakeController(context); } return instance; } /** * System call to initialize the vibrator service * needs "android.permission.VIBRATION" on the AndroidManifest.xml */ private void initVibrator() { vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); } /** * System call to initialize the accelerometer service */ private void initAccelerometer() { sm = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); this.accelerometer = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); } /** * External call to start sensor the service */ public void startService() { sm.registerListener(accelerometerListener, accelerometer, SensorManager.SENSOR_DELAY_GAME); } /** * External call to stop sensor the service */ public void stopService() { sm.unregisterListener(accelerometerListener, accelerometer); } /** * The accelerometer listener implementation */ class IvomaniaSensorListener implements SensorEventListener { private static final int SCROLL_TO_VIBE = 2; //Counter for the left shake int rightCounter = 0; //Counter for the right shake int leftCounter = 0; protected IvomaniaSensorListener() { } /** * Use the x value to understand how much the scroll took place * After 4 intense scrolls left and right this method produces a vibration * @param sensorEvent */ public void onSensorChanged(SensorEvent sensorEvent) { float[] coord = sensorEvent.values; if (coord[0] > GRAVITY_MODULE) { leftCounter++; } else if (coord[0] < - GRAVITY_MODULE) { rightCounter++; } if (rightCounter > SCROLL_TO_VIBE || leftCounter > 4) { leftCounter = 0; rightCounter = 0; } if (leftCounter == SCROLL_TO_VIBE && rightCounter == SCROLL_TO_VIBE) { vibrator.vibrate(500); leftCounter = 0; rightCounter = 0; } } /** * Not implemented * @param se * @param accuracy */ public void onAccuracyChanged(Sensor se, int accuracy) { //Log.error("Accuracy = " + accuracy); } } }