SmartTorch widget (com.greenlog.smarttorch) on Google Play
SmartTorch can turns off automatically by a timer, and remain on until you put the gadget on the table (ie, as long as you keep the gadget in your hands: uses accelerometer). You will not need to turn off the flashlight: you just put the phone and it switches itself off!Widget is able to work on home screen and lock screen (widget on a lock screen feature is supported in Android 4.2+).SmartTorch supports modes that you can switch by flipping through them in the widget. The mode defines:• timeout after which the flashlight is turned off (∞ means that will work until you turn it off) • determines whether a accelerometer (shake sensor) enabled, which allows to keep the flashlight on until you don't put the gadget on the tableThe list of modes can be changed in the configuration window that appears when you put the widget on the home screen or lock screen. The configuration window can also be called by double-clicking on an existing widget (on your home screen, not on a lock screen).In addition to the list of modes it is possible to set the threshold of sensitivity of the accelerometer (acceleration at which SmartTorch will assume that the gadget is stationary). You can choose one of three pre-defined levels of sensitivity, or calibrate the threshold for your gadget (at the time of calibration your gadget should remain motionless, since the application measures the noise level of the accelerometer and automatically sets the threshold). Calibration allows to maximize the sensitivity to motions limited by accelerometer's noises.Knock control feature. Now you can switch between modes by knocking your phone. Turn on this feature in the settings and specify how many knocks need to do to select the mode.New permission: vibrate. The widget confirms the selected mode by vibration.Pocket detector. You can just put your gadget into a pocket and SmartTorch will be turned off automatically. Just turn this feature on in the settings (double-click on existing widget or place a new widget on your home screen). This feature requires a proximity sensor. When the sensor reports than something is very close to it, SmartTorch starts waiting for defined by you timeout and turns off when it has expired.Auto lock. SmartTorch will lock your gadget right after you turn the light on if you enable this feature. WARNING! To uninstall SmartTorch, you will have to turn this feature off (or disable SmartTorch in "Device administrators").SmartTorch doesn't eats battery when turned off, contains no advertising and other not related to a flashlight garbage.You can grab sources here: https://github.com/nesquikm/SmartTorch