Browse Source

Vibration basic support

master
Igor Zhukov 10 years ago
parent
commit
4d4d08710a
  1. 15
      app/js/controllers.js
  2. 17
      app/js/services.js
  3. 7
      app/partials/mobile/settings_modal.html

15
app/js/controllers.js

@ -1963,7 +1963,7 @@ angular.module('myApp.controllers', []) @@ -1963,7 +1963,7 @@ angular.module('myApp.controllers', [])
});
};
Storage.get('notify_nodesktop', 'notify_nosound', 'send_ctrlenter', 'notify_volume').then(function (settings) {
Storage.get('notify_nodesktop', 'notify_nosound', 'send_ctrlenter', 'notify_volume', 'notify_novibrate').then(function (settings) {
$scope.notify.desktop = !settings[0];
$scope.send.enter = settings[2] ? '' : '1';
@ -1975,6 +1975,9 @@ angular.module('myApp.controllers', []) @@ -1975,6 +1975,9 @@ angular.module('myApp.controllers', [])
$scope.notify.volume = 5;
}
$scope.notify.canVibrate = NotificationsManager.getVibrateSupport();
$scope.notify.vibrate = !settings[4];
$scope.notify.volumeOf4 = function () {
return 1 + Math.ceil(($scope.notify.volume - 1) / 3.3);
};
@ -2014,6 +2017,16 @@ angular.module('myApp.controllers', []) @@ -2014,6 +2017,16 @@ angular.module('myApp.controllers', [])
}
}
$scope.toggleVibrate = function () {
$scope.notify.vibrate = !$scope.notify.vibrate;
if ($scope.notify.vibrate) {
Storage.remove('notify_novibrate');
} else {
Storage.set({notify_novibrate: true});
}
}
$scope.toggleCtrlEnter = function (newValue) {
$scope.send.enter = newValue;

17
app/js/services.js

@ -3400,10 +3400,13 @@ angular.module('myApp.services', []) @@ -3400,10 +3400,13 @@ angular.module('myApp.services', [])
.service('NotificationsManager', function ($rootScope, $window, $timeout, $interval, $q, MtpApiManager, AppPeersManager, IdleManager, Storage) {
navigator.vibrate = navigator.vibrate || navigator.mozVibrate || navigator.webkitVibrate;
var notificationsUiSupport = ('Notification' in window) || ('mozNotification' in navigator);
var notificationsShown = {};
var notificationIndex = 0;
var notificationsCount = 0;
var vibrateSupport = !!navigator.vibrate;
var peerSettings = {};
var faviconBackupEl = $('link[rel="icon"]'),
faviconNewEl = $('<link rel="icon" href="favicon_unread.ico" type="image/x-icon" />');
@ -3476,6 +3479,7 @@ angular.module('myApp.services', []) @@ -3476,6 +3479,7 @@ angular.module('myApp.services', [])
getPeerMuted: getPeerMuted,
savePeerSettings: savePeerSettings,
updatePeerSettings: updatePeerSettings,
getVibrateSupport: getVibrateSupport,
testSound: playSound
};
@ -3561,8 +3565,13 @@ angular.module('myApp.services', []) @@ -3561,8 +3565,13 @@ angular.module('myApp.services', [])
}
})
Storage.get('notify_nodesktop').then(function (noShow) {
if (noShow) {
Storage.get('notify_nodesktop', 'notify_novibrate').then(function (settings) {
if (settings[0]) {
if (vibrateSupport && !settings[1]) {
navigator.vibrate([200, 100, 200]);
return;
}
return;
}
var idx = ++notificationIndex,
@ -3694,6 +3703,10 @@ angular.module('myApp.services', []) @@ -3694,6 +3703,10 @@ angular.module('myApp.services', [])
})
}
function getVibrateSupport () {
return vibrateSupport;
}
})

7
app/partials/mobile/settings_modal.html

@ -79,6 +79,13 @@ @@ -79,6 +79,13 @@
</a>
</div>
<div class="mobile_modal_action_wrap" ng-if="!notify.desktop &amp;&amp; notify.canVibrate">
<a class="mobile_modal_action tg_checkbox clearfix" ng-click="toggleVibrate()" ng-class="notify.vibrate ? 'tg_checkbox_on' : ''">
<span class="icon icon-checkbox-outer"><i class="icon-checkbox-inner"></i></span>
<span class="tg_checkbox_label">Vibrate</span>
</a>
</div>
<div class="mobile_modal_action_wrap">
<a class="mobile_modal_action tg_checkbox clearfix" ng-click="toggleSound()" ng-class="notify.volume ? 'tg_checkbox_on' : ''">
<span class="icon icon-checkbox-outer"><i class="icon-checkbox-inner"></i></span>

Loading…
Cancel
Save