Repository
The app provides users with various features from choosing the correct destination to making all the bookings and to easily organising the trip. The app provides solutions for every possible problem a traveller might face during the course of his or her entire journey.
New Features
What feature(s) did you add?
App has some cool features for travellers like weather info, checklist etc. There was a open issue on adding compass utility. Have implemented the compass in utilities section of the App.
How did you implement it/them?
-The smartphones have a small magnetometer built in, which can measure the Earth’s magnetic field. This information is combined with an accelerator that acquires information regarding the phone’s position in space.
- Created compass utility class expending SensorEventListener to read accelerator sensor data.
@Overridepublic void onSensorChanged(SensorEvent event) {final float alpha = 0.97f;
synchronized (this) {if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
mGravity[0] = alpha * mGravity[0] + (1 - alpha)* event.values[0];mGravity[1] = alpha * mGravity[1] + (1 - alpha)* event.values[1];mGravity[2] = alpha * mGravity[2] + (1 - alpha)* event.values[2];}
if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {// mGeomagnetic = event.values;
mGeomagnetic[0] = alpha * mGeomagnetic[0] + (1 - alpha)* event.values[0];mGeomagnetic[1] = alpha * mGeomagnetic[1] + (1 - alpha)* event.values[1];mGeomagnetic[2] = alpha * mGeomagnetic[2] + (1 - alpha)* event.values[2];// Log.e(TAG, Float.toString(event.values[0]));
}
boolean success = SensorManager.getRotationMatrix(mR, mI, mGravity,mGeomagnetic);if (success) {float[] orientation = new float[3];SensorManager.getOrientation(mR, orientation);// Log.d(TAG, "azimuth (rad): " + azimuth);mAzimuth = (float) Math.toDegrees(orientation[0]); // orientationmAzimuth = (mAzimuth + mAzimuthFix + 360) % 360;// Log.d(TAG, "azimuth (deg): " + azimuth);if (mListener != null) {mListener.onNewAzimuth(mAzimuth);}}}
- Created a activity CompassActivity to create and setup compass.
/*** setup compass*/private void setupCompass() {mCompass = new Compass(this);Compass.CompassListener cl = new Compass.CompassListener() {@Overridepublic void onNewAzimuth(float azimuth) {adjustArrow(azimuth);}};mCompass.setListener(cl);}/*** adjuts arrow** @param azimuth azimuth*/private void adjustArrow(float azimuth) {Log.d(TAG, "will set rotation from " + mCurrentAzimuth + " to "+ azimuth);Animation an = new RotateAnimation(-mCurrentAzimuth, -azimuth,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);mCurrentAzimuth = azimuth;an.setDuration(500);an.setRepeatCount(0);an.setFillAfter(true);mArrowView.startAnimation(an);}
Drawables used Compass_dial and compass_hand