Vibrate on widget touch

Fixes #443
This commit is contained in:
M66B 2016-06-23 17:20:13 +02:00
parent 7983b03c6c
commit 8c1cbad26e
3 changed files with 8 additions and 0 deletions

View File

@ -191,6 +191,7 @@ Permissions
* RECEIVE_BOOT_COMPLETED ('*Run at startup*'): to start the firewall when booting the device
* WAKE_LOCK ('*Prevent device from sleeping*'): to reliably reload rules in the background on connectivity changes
* READ/WRITE_EXTERNAL_STORAGE ('*Photos/Media/Files*'): to export/import settings on Android versions before 5.0 (Lollipop) (there is no need to grant this permission on later Android versions)
* VIBRATE: to give feedback on widget tap
* com.android.vending.BILLING: to use in-app billing
Support

View File

@ -10,6 +10,7 @@
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<!-- http://developer.android.com/guide/topics/security/permissions.html#normal-dangerous -->
<uses-feature

View File

@ -29,6 +29,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.net.VpnService;
import android.os.Build;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.RemoteViews;
@ -60,6 +61,11 @@ public class Widget extends AppWidgetProvider {
PendingIntent pi = PendingIntent.getBroadcast(context, 0, new Intent(INTENT_ON), PendingIntent.FLAG_UPDATE_CURRENT);
am.cancel(pi);
// Vibrate
Vibrator vs = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
if (vs.hasVibrator())
vs.vibrate(50);
if (INTENT_OFF.equals(intent.getAction())) {
prefs.edit().putBoolean("enabled", false).apply();
ServiceSinkhole.stop("widget", context);