use of android.os.Vibrator in project Signal-Android by signalapp.
the class ConversationActivity method onRecorderCanceled.
@Override
public void onRecorderCanceled() {
Vibrator vibrator = ServiceUtil.getVibrator(this);
vibrator.vibrate(50);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording();
future.addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() {
@Override
public void onSuccess(final Pair<Uri, Long> result) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
PersistentBlobProvider.getInstance(ConversationActivity.this).delete(ConversationActivity.this, result.first);
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
@Override
public void onFailure(ExecutionException e) {
}
});
}
use of android.os.Vibrator in project Signal-Android by signalapp.
the class ConversationActivity method onRecorderFinished.
@Override
public void onRecorderFinished() {
Vibrator vibrator = ServiceUtil.getVibrator(this);
vibrator.vibrate(20);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording();
future.addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() {
@Override
public void onSuccess(@NonNull final Pair<Uri, Long> result) {
boolean forceSms = sendButton.isManualSelection() && sendButton.getSelectedTransport().isSms();
int subscriptionId = sendButton.getSelectedTransport().getSimSubscriptionId().or(-1);
long expiresIn = recipient.getExpireMessages() * 1000L;
boolean initiating = threadId == -1;
AudioSlide audioSlide = new AudioSlide(ConversationActivity.this, result.first, result.second, MediaUtil.AUDIO_AAC, true);
SlideDeck slideDeck = new SlideDeck();
slideDeck.addSlide(audioSlide);
sendMediaMessage(forceSms, "", slideDeck, expiresIn, subscriptionId, initiating).addListener(new AssertedSuccessListener<Void>() {
@Override
public void onSuccess(Void nothing) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
PersistentBlobProvider.getInstance(ConversationActivity.this).delete(ConversationActivity.this, result.first);
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
}
@Override
public void onFailure(ExecutionException e) {
Toast.makeText(ConversationActivity.this, R.string.ConversationActivity_unable_to_record_audio, Toast.LENGTH_LONG).show();
}
});
}
use of android.os.Vibrator in project xDrip-plus by jamorham.
the class NFCReaderX method vibrate.
public static void vibrate(Context context, int pattern) {
// 0 = scanning
// 1 = scan ok
// 2 = warning
// 3 = lesser error
final long[][] patterns = { { 0, 150 }, { 0, 150, 70, 150 }, { 0, 2000 }, { 0, 1000 }, { 0, 100 } };
if (Pref.getBooleanDefaultFalse("nfc_scan_vibrate")) {
final Vibrator vibrate = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
if ((vibrate == null) || (!vibrate.hasVibrator()))
return;
vibrate.cancel();
if (d)
Log.d(TAG, "About to vibrate, pattern: " + pattern);
try {
vibrate.vibrate(patterns[pattern], -1);
} catch (Exception e) {
Log.d(TAG, "Exception in vibrate: " + e);
}
}
}
use of android.os.Vibrator in project AndroidChromium by JackyAndroid.
the class FindToolbar method onFindResult.
@Override
public void onFindResult(FindNotificationDetails result) {
if (mResultBar != null)
mResultBar.mWaitingForActivateAck = false;
assert mFindInPageBridge != null;
if ((result.activeMatchOrdinal == -1 || result.numberOfMatches == 1) && !result.finalUpdate) {
// at the start (see below for why we can't filter them out).
return;
}
if (result.finalUpdate) {
if (result.numberOfMatches > 0) {
// TODO(johnme): Don't wait till end of find, stream rects live!
mFindInPageBridge.requestFindMatchRects(mResultBar != null ? mResultBar.mRectsVersion : -1);
} else {
clearResults();
}
findResultSelected(result.rendererSelectionRect);
}
// Even though we wait above until activeMatchOrdinal is no longer -1,
// it's possible for it to still be -1 (unknown) in the final find
// notification. This happens very rarely, e.g. if the m_activeMatch
// found by WebFrameImpl::find has been removed from the DOM by the time
// WebFrameImpl::scopeStringMatches tries to find the ordinal of the
// active match (while counting the matches), as in b/4147049. In such
// cases it looks less broken to show 0 instead of -1 (as desktop does).
Context context = getContext();
String text = context.getResources().getString(R.string.find_in_page_count, Math.max(result.activeMatchOrdinal, 0), result.numberOfMatches);
setStatus(text, result.numberOfMatches == 0);
// The accessible version will be something like "Result 1 of 9".
String accessibleText = getAccessibleStatusText(Math.max(result.activeMatchOrdinal, 0), result.numberOfMatches);
mFindStatus.setContentDescription(accessibleText);
announceStatusForAccessibility(accessibleText);
// Vibrate when no results are found, unless you're just deleting chars.
if (result.numberOfMatches == 0 && result.finalUpdate && !mFindInPageBridge.getPreviousFindText().startsWith(mFindQuery.getText().toString())) {
final boolean hapticFeedbackEnabled = Settings.System.getInt(context.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1) == 1;
if (hapticFeedbackEnabled) {
Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
final long noResultsVibrateDurationMs = 50;
v.vibrate(noResultsVibrateDurationMs);
}
}
}
use of android.os.Vibrator in project SmartMesh_Android by SmartMeshFoundation.
the class BeepManager method playBeepSoundAndVibrate.
public void playBeepSoundAndVibrate() {
if (playBeep && mediaPlayer != null) {
mediaPlayer.start();
}
if (vibrate) {
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_DURATION);
}
}
Aggregations