Last active
February 17, 2017 15:01
Revisions
-
degliwe revised this gist
Jan 9, 2015 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changesFile renamed without changes. -
degliwe revised this gist
Dec 22, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -82,7 +82,7 @@ public void onDraw(Canvas canvas, Rect bounds) { ``` ##Conclusion I can already see many use for this, like realistic lightning to make "classic" wtach face even more realistic and shiny, but also more abstract or experimental animated faces, like a spaceship hud... This is it, you are all set. I can't wait to see the great interactive watch faces you will make and the creative unexpected uses for this. -
degliwe revised this gist
Dec 22, 2014 . 3 changed files with 0 additions and 2 deletions.There are no files selected for viewing
File renamed without changesThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,8 +3,6 @@ Since the early days of Android wear, I wanted to try to make more interactive faces. I think the various sensors offer a great opportunity to implement realistic light, giving more depth to your watch face. In case you don't know what this is about, you can give it a try here from the sample I've uploaded to the playstore: https://play.google.com/store/apps/details?id=com.deglise.sensorface Binary file not shown. -
degliwe revised this gist
Dec 22, 2014 . 3 changed files with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ Since the early days of Android wear, I wanted to try to make more interactive faces. I think the various sensors offer a great opportunity to implement realistic light, giving more depth to your watch face.  In case you don't know what this is about, you can give it a try here from the sample I've uploaded to the playstore: https://play.google.com/store/apps/details?id=com.deglise.sensorface File renamed without changesFile renamed without changes -
degliwe revised this gist
Dec 22, 2014 . 3 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changesFile renamed without changesFile renamed without changes. -
degliwe revised this gist
Dec 22, 2014 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed.LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
degliwe revised this gist
Dec 22, 2014 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
-
degliwe revised this gist
Dec 22, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
degliwe created this gist
Dec 22, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,92 @@ #Add some depth to your WatchFace Since the early days of Android wear, I wanted to try to make more interactive faces. I think the various sensors offer a great opportunity to implement realistic light, giving more depth to your watch face. In case you don't know what this is about, you can give it a try here from the sample I've uploaded to the playstore: https://play.google.com/store/apps/details?id=com.deglise.sensorface ## Implement SensorEventListener The very first thing to do is to implement SensorEventListener, and then declare a SensorManager, sensorX and sensorY as described below. ```java private class Engine extends CanvasWatchFaceService.Engine implements SensorEventListener{ SensorManager sensorMgr; float sensorX; float sensorY; ... } ``` ## @Override Implementing SensorEventListener, requires you to provide onSensorChanged and onAccuracyChanged method as shown below. ```java @Override public void onSensorChanged(SensorEvent event) { // Reading raw value // todo smoothen things sensorX=event.values[0]; sensorY=event.values[1]; } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { //You can keep it empty } ``` ##Register & unregister sensor You want the sensor to be on as soon as your watchface is shown but you also don't want your face to lock the sensor when the screen is off or when another app may need the sensor... Then onVisibilityChanged seems the best place to achieve that. ```java @Override public void onVisibilityChanged(boolean visible) { super.onVisibilityChanged(visible); if (visible) { registerSensor(); } else { unregisterSensor(); } } private void unregisterSensor() { sensorMgr.unregisterListener(this); } private void registerSensor() { sensorMgr = (SensorManager) getSystemService(getBaseContext().SENSOR_SERVICE); sensorMgr.registerListener(this, sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); } ``` ##Time to draw! From the onDraw method, you can now, access the sensorX,sensorY to alter position of the element on the canvas. ```java @Override public void onDraw(Canvas canvas, Rect bounds) { // Draw digital minutes. canvas.drawText(minuteString, x+sensorX, mYOffset+sensorY, mShadowPaint); canvas.drawText(minuteString, x, mYOffset, mTimePaint); } ``` ##Conclusion I can already see many sues for this, like realistic lightning to make "classic" wtach face even more realistic and shiny, but also more abstract or experimental animated faces, like a spaceship hud... This is it, you are all set. I can't wait to see the great interactive watch faces you will make and the creative unexpected uses for this. Feel free to share the result of your experiments with me.