com.google.android.glass.media.Sounds Java Examples
The following examples show how to use
com.google.android.glass.media.Sounds.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseGameActivity.java From gdk-charades-sample with Apache License 2.0 | 6 votes |
/** * Marks the currently visible phrase as correctly guessed. This method changes the phrase's * color to green, flings it off the screen, advances the game model to the next phrase, and * flings the new phrase into view. */ protected void score() { // Disable gesture handling so that the user can't tap or swipe during the animation. setGesturesEnabled(false); mModel.markGuessed(); playSoundEffect(Sounds.SUCCESS); getCurrentTextView().setTextColor(SCORED_PHRASE_COLOR); mHandler.postDelayed(new Runnable() { @Override public void run() { if (!mModel.areAllPhrasesGuessedCorrectly()) { mPhraseFlipper.showNext(); updateDisplay(); // Re-enable gesture handling after the delay has passed. setGesturesEnabled(true); } } }, SCORED_PHRASE_DELAY_MILLIS); }
Example #2
Source File: SelectValueActivityTest.java From PTVGlass with MIT License | 6 votes |
@UiThreadTest public void testOnGestureTapSupported() { MockSelectValueActivity activity = startActivity(mActivityIntent, null, null); int expectedSelectedValue = 35; activity.onResume(); activity.getView().setSelection(expectedSelectedValue); assertTrue(activity.onGesture(Gesture.TAP)); assertEquals(1, activity.mPlayedSoundEffects.size()); assertEquals(Sounds.TAP, activity.mPlayedSoundEffects.get(0).intValue()); assertTrue(isFinishCalled()); assertEquals(Activity.RESULT_OK, activity.mResultCode); assertNotNull(activity.mResultIntent); assertEquals( expectedSelectedValue, activity.mResultIntent.getIntExtra(SelectValueActivity.EXTRA_SELECTED_VALUE, 0)); }
Example #3
Source File: SetTimerActivityTest.java From PTVGlass with MIT License | 6 votes |
@UiThreadTest public void testOnGestureSwipeDownSupported() { MockSetTimerActivity activity = startActivity(mActivityIntent, null, null); SetTimerScrollAdapter adapter = (SetTimerScrollAdapter) activity.getView().getAdapter(); long expectedDuration = TimeUnit.SECONDS.toMillis(45); adapter.setDurationMillis(expectedDuration); assertTrue(activity.onGesture(Gesture.SWIPE_DOWN)); assertEquals(1, activity.mPlayedSoundEffects.size()); assertEquals(Sounds.DISMISSED, activity.mPlayedSoundEffects.get(0).intValue()); assertTrue(isFinishCalled()); assertEquals(Activity.RESULT_OK, activity.mResultCode); assertNotNull(activity.mResultIntent); assertEquals( expectedDuration, activity.mResultIntent.getLongExtra(SetTimerActivity.EXTRA_DURATION_MILLIS, 0)); }
Example #4
Source File: SetTimerActivityTest.java From PTVGlass with MIT License | 6 votes |
@UiThreadTest public void testOnGestureTapSupportedSelectValueForMinutes() { MockSetTimerActivity activity = startActivity(mActivityIntent, null, null); activity.onResume(); activity.getView().setSelection(1); assertTrue(activity.onGesture(Gesture.TAP)); assertEquals(1, activity.mPlayedSoundEffects.size()); assertEquals(Sounds.TAP, activity.mPlayedSoundEffects.get(0).intValue()); Intent startedIntent = getStartedActivityIntent(); assertNotNull(startedIntent); assertEquals( SelectValueActivity.class.getName(), startedIntent.getComponent().getClassName()); assertEquals( SetTimerScrollAdapter.TimeComponents.MINUTES.getMaxValue(), startedIntent.getIntExtra(SelectValueActivity.EXTRA_COUNT, 0)); assertEquals( 5, startedIntent.getIntExtra(SelectValueActivity.EXTRA_INITIAL_VALUE, 0)); assertEquals(SetTimerActivity.SELECT_VALUE, getStartedActivityRequest()); assertFalse(isFinishCalled()); }
Example #5
Source File: SetTimerActivityTest.java From PTVGlass with MIT License | 6 votes |
@UiThreadTest public void testOnGestureTapSupported() { MockSetTimerActivity activity = startActivity(mActivityIntent, null, null); activity.onResume(); activity.getView().setSelection(0); assertTrue(activity.onGesture(Gesture.TAP)); assertEquals(1, activity.mPlayedSoundEffects.size()); assertEquals(Sounds.TAP, activity.mPlayedSoundEffects.get(0).intValue()); Intent startedIntent = getStartedActivityIntent(); assertNotNull(startedIntent); assertEquals( SelectValueActivity.class.getName(), startedIntent.getComponent().getClassName()); assertEquals( SetTimerScrollAdapter.TimeComponents.HOURS.getMaxValue(), startedIntent.getIntExtra(SelectValueActivity.EXTRA_COUNT, 0)); assertEquals( 0, startedIntent.getIntExtra(SelectValueActivity.EXTRA_INITIAL_VALUE, 0)); assertEquals(SetTimerActivity.SELECT_VALUE, getStartedActivityRequest()); assertFalse(isFinishCalled()); }
Example #6
Source File: MainActivity.java From Bluetooth-Manager-for-Glass with MIT License | 6 votes |
private GestureDetector createGestureDetector(Context context) { GestureDetector gestureDetector = new GestureDetector(context); //Create a base listener for generic gestures gestureDetector.setBaseListener( new GestureDetector.BaseListener() { @Override public boolean onGesture(Gesture gesture) { if (gesture == Gesture.TAP) { AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audio.playSoundEffect(Sounds.TAP); openOptionsMenu(); return true; } return false; } }); return gestureDetector; }
Example #7
Source File: SelectValueActivity.java From PTVGlass with MIT License | 6 votes |
@Override public boolean onGesture(Gesture gesture) { switch (gesture) { case TAP: Intent resultIntent = new Intent(); resultIntent.putExtra(EXTRA_SELECTED_VALUE, getView().getSelectedItemPosition()); setResultInternal(RESULT_OK, resultIntent); playSoundEffect(Sounds.TAP); finish(); return true; case SWIPE_DOWN: setResultInternal(RESULT_CANCELED, null); playSoundEffect(Sounds.DISMISSED); finish(); return true; default: return false; } }
Example #8
Source File: BleDevicesActivity.java From Bluetooth-Manager-for-Glass with MIT License | 6 votes |
@Override public void onLeScan(BluetoothDevice device, int rssi, byte[] bytes) { if (device.getName() != null) { BleDevice bleDevice = new BleDevice(device, rssi); if (!mDevices.contains(bleDevice)) { mDevices.add(bleDevice); AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audio.playSoundEffect(Sounds.SUCCESS); } else { int index = mDevices.indexOf(bleDevice); mDevices.get(index).setRssi(rssi); } runOnUiThread(new Runnable() { @Override public void run() { adapter = new BleDeviceCardScrollAdapter(BleDevicesActivity.this, mDevices); mCardScrollView.setAdapter(adapter); } }); } }
Example #9
Source File: SliderActivity.java From gdk-apidemo-sample with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); // Ensure screen stays on during demo. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mCardScroller = new CardScrollView(this); mCardScroller.setAdapter(new CardAdapter(createCards(this))); mCardScroller.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Plays sound. AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); am.playSoundEffect(Sounds.TAP); processSliderRequest(position); } }); setContentView(mCardScroller); mSlider = Slider.from(mCardScroller); }
Example #10
Source File: SetTimerActivity.java From gdk-timer-sample with Apache License 2.0 | 6 votes |
@Override public boolean onGesture(Gesture gesture) { switch (gesture) { case TAP: long timeMinutes = TimeUnit.SECONDS.toMinutes((long) mTimeSeconds); if (timeMinutes > 0) { playSoundEffect(Sounds.TAP); openOptionsMenu(); mOptionMenuOpen = true; } else { playSoundEffect(Sounds.DISALLOWED); } return true; case SWIPE_DOWN: setResultInternal(RESULT_CANCELED, null); playSoundEffect(Sounds.DISMISSED); finish(); return true; default: return false; } }
Example #11
Source File: HelloWorld.java From arcgis-runtime-demos-android with Apache License 2.0 | 6 votes |
/** * Different type of activities can be shown, when tapped on a card. */ private void setCardScrollerListener() { mCardScroller.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Log.d(TAG, "Clicked view at position " + position + ", row-id " + id); int soundEffect = Sounds.TAP; switch (position) { case 0: startService(new Intent(HelloWorld.this, MapService.class)); break; default: soundEffect = Sounds.ERROR; Log.d(TAG, "Don't show anything"); } // Play sound. AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); am.playSoundEffect(soundEffect); } }); }
Example #12
Source File: BleDevicesActivity.java From Bluetooth-Manager-for-Glass with MIT License | 5 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audio.playSoundEffect(Sounds.TAP); mSelectedDevice = adapter.getItem(position); openOptionsMenu(); }
Example #13
Source File: PairDevicesActivity.java From Bluetooth-Manager-for-Glass with MIT License | 5 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audio.playSoundEffect(Sounds.TAP); mSelectedDevice = adapter.getItem(position); openOptionsMenu(); }
Example #14
Source File: PairedDevicesListActivity.java From Bluetooth-Manager-for-Glass with MIT License | 5 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mSelectedDevice = (BluetoothDevice) mCardScrollView.getItemAtPosition(position); AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audio.playSoundEffect(Sounds.TAP); openOptionsMenu(); }
Example #15
Source File: SetTimerActivity.java From gdk-timer-sample with Apache License 2.0 | 5 votes |
/** Sets the Timer value. */ private void setTimeSeconds(float timeSeconds) { float previousTimeSeconds = mTimeSeconds; mTimeSeconds = confineTimeSeconds(timeSeconds); if (TimeUnit.SECONDS.toMinutes((int) previousTimeSeconds) != TimeUnit.SECONDS.toMinutes((int) mTimeSeconds)) { playSoundEffect(Sounds.TAP); updateText(); } }
Example #16
Source File: SetTimerActivityTest.java From gdk-timer-sample with Apache License 2.0 | 5 votes |
@UiThreadTest public void testOnGestureTapSupported() { MockSetTimerActivity activity = startActivity(mActivityIntent, null, null); assertTrue(activity.onGesture(Gesture.TAP)); assertEquals(1, activity.mPlayedSoundEffects.size()); assertEquals(Sounds.TAP, activity.mPlayedSoundEffects.get(0).intValue()); assertTrue(activity.mOptionsMenuOpen); }
Example #17
Source File: SetTimerActivityTest.java From gdk-timer-sample with Apache License 2.0 | 5 votes |
@UiThreadTest public void testOnGestureTapDisallowed() { mActivityIntent.removeExtra(SetTimerActivity.EXTRA_DURATION_MILLIS); MockSetTimerActivity activity = startActivity(mActivityIntent, null, null); assertTrue(activity.onGesture(Gesture.TAP)); assertEquals(1, activity.mPlayedSoundEffects.size()); assertEquals(Sounds.DISALLOWED, activity.mPlayedSoundEffects.get(0).intValue()); assertFalse(activity.mOptionsMenuOpen); }
Example #18
Source File: SetTimerActivityTest.java From gdk-timer-sample with Apache License 2.0 | 5 votes |
@UiThreadTest public void testOnGestureSwipeDownSupported() { MockSetTimerActivity activity = startActivity(mActivityIntent, null, null); assertTrue(activity.onGesture(Gesture.SWIPE_DOWN)); assertEquals(1, activity.mPlayedSoundEffects.size()); assertEquals(Sounds.DISMISSED, activity.mPlayedSoundEffects.get(0).intValue()); assertTrue(isFinishCalled()); assertEquals(Activity.RESULT_CANCELED, activity.mResultCode); assertNull(activity.mResultIntent); }
Example #19
Source File: SelectValueActivityTest.java From PTVGlass with MIT License | 5 votes |
@UiThreadTest public void testOnGestureSwipeDownSupported() { MockSelectValueActivity activity = startActivity(mActivityIntent, null, null); assertTrue(activity.onGesture(Gesture.SWIPE_DOWN)); assertEquals(1, activity.mPlayedSoundEffects.size()); assertEquals(Sounds.DISMISSED, activity.mPlayedSoundEffects.get(0).intValue()); assertTrue(isFinishCalled()); assertEquals(Activity.RESULT_CANCELED, activity.mResultCode); assertNull(activity.mResultIntent); }
Example #20
Source File: SetTimerActivity.java From PTVGlass with MIT License | 5 votes |
@Override public boolean onGesture(Gesture gesture) { switch (gesture) { case TAP: int position = getView().getSelectedItemPosition(); SetTimerScrollAdapter.TimeComponents component = (SetTimerScrollAdapter.TimeComponents) mAdapter.getItem(position); Intent selectValueIntent = new Intent(this, SelectValueActivity.class); selectValueIntent.putExtra( SelectValueActivity.EXTRA_COUNT, component.getMaxValue()); selectValueIntent.putExtra( SelectValueActivity.EXTRA_INITIAL_VALUE, (int) mAdapter.getTimeComponent(component)); startActivityForResult(selectValueIntent, SELECT_VALUE); playSoundEffect(Sounds.TAP); return true; case SWIPE_DOWN: Intent resultIntent = new Intent(); resultIntent.putExtra(EXTRA_DURATION_MILLIS, mAdapter.getDurationMillis()); setResultInternal(RESULT_OK, resultIntent); playSoundEffect(Sounds.DISMISSED); finish(); return true; default: return false; } }
Example #21
Source File: ApiDemoActivity.java From PTVGlass with MIT License | 5 votes |
/** * Different type of activities can be shown, when tapped on a card. */ private void setCardScrollerListener() { mCardScroller.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Log.d(TAG, "Clicked view at position " + position + ", row-id " + id); int soundEffect = Sounds.TAP; switch (position) { case CARDS: startActivity(new Intent(ApiDemoActivity.this, CardsActivity.class)); break; case GESTURE_DETECTOR: startActivity(new Intent(ApiDemoActivity.this, SelectGestureDemoActivity.class)); break; case THEMING: startActivity(new Intent(ApiDemoActivity.this, ThemingActivity.class)); break; case OPENGL: startService(new Intent(ApiDemoActivity.this, OpenGlService.class)); break; default: soundEffect = Sounds.ERROR; Log.d(TAG, "Don't show anything"); } // Play sound. AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); am.playSoundEffect(soundEffect); } }); }
Example #22
Source File: VoiceMenuActivity.java From gdk-apidemo-sample with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); // Requests a voice menu on this activity. As for any other window feature, // be sure to request this before setContentView() is called getWindow().requestFeature(WindowUtils.FEATURE_VOICE_COMMANDS); // Ensure screen stays on during demo. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // Sets up a singleton card scroller as content of this activity. Clicking // on the card toggles the voice menu on and off. mCardScroller = new CardScrollView(this); mCardScroller.setAdapter(new CardAdapter(createCards(this))); mCardScroller.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Plays sound. AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); am.playSoundEffect(Sounds.TAP); // Toggles voice menu. Invalidates menu to flag change. mVoiceMenuEnabled = !mVoiceMenuEnabled; getWindow().invalidatePanelMenu(WindowUtils.FEATURE_VOICE_COMMANDS); } }); setContentView(mCardScroller); }
Example #23
Source File: SliderActivity.java From gdk-apidemo-sample with Apache License 2.0 | 5 votes |
@Override public void onGracePeriodCancel() { // Play a DIMISS sound to indicate the cancellation of the grace period. AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); am.playSoundEffect(Sounds.DISMISSED); mGracePeriod = null; }
Example #24
Source File: SliderActivity.java From gdk-apidemo-sample with Apache License 2.0 | 5 votes |
@Override public void onGracePeriodEnd() { // Play a SUCCESS sound to indicate the end of the grace period. AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); am.playSoundEffect(Sounds.SUCCESS); mGracePeriod = null; }
Example #25
Source File: StartGameActivity.java From gdk-charades-sample with Apache License 2.0 | 5 votes |
@Override public boolean onGesture(Gesture gesture) { if (gesture == Gesture.TAP) { mAudioManager.playSoundEffect(Sounds.TAP); openOptionsMenu(); return true; } else { return false; } }
Example #26
Source File: BaseGameActivity.java From gdk-charades-sample with Apache License 2.0 | 5 votes |
/** Passes on the current phrase and advances to the next one. */ protected void pass() { mModel.pass(); playSoundEffect(Sounds.SELECTED); mPhraseFlipper.showNext(); updateDisplay(); }
Example #27
Source File: ApiDemoActivity.java From gdk-apidemo-sample with Apache License 2.0 | 4 votes |
/** * Different type of activities can be shown, when tapped on a card. */ private void setCardScrollerListener() { mCardScroller.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Log.d(TAG, "Clicked view at position " + position + ", row-id " + id); int soundEffect = Sounds.TAP; switch (position) { case CARD_BUILDER: startActivity(new Intent(ApiDemoActivity.this, CardBuilderActivity.class)); break; case CARD_BUILDER_EMBEDDED_LAYOUT: startActivity(new Intent( ApiDemoActivity.this, EmbeddedCardLayoutActivity.class)); break; case CARD_SCROLL_VIEW: startActivity(new Intent(ApiDemoActivity.this, CardScrollViewActivity.class)); break; case GESTURE_DETECTOR: startActivity(new Intent(ApiDemoActivity.this, SelectGestureDemoActivity.class)); break; case TEXT_APPEARANCE: startActivity(new Intent(ApiDemoActivity.this, TextAppearanceActivity.class)); break; case OPENGL: startService(new Intent(ApiDemoActivity.this, OpenGlService.class)); break; case VOICE_MENU: startActivity(new Intent(ApiDemoActivity.this, VoiceMenuActivity.class)); break; case SLIDER: startActivity(new Intent(ApiDemoActivity.this, SliderActivity.class)); break; default: soundEffect = Sounds.ERROR; Log.d(TAG, "Don't show anything"); } // Play sound. AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); am.playSoundEffect(soundEffect); } }); }
Example #28
Source File: CardScrollViewActivity.java From gdk-apidemo-sample with Apache License 2.0 | 4 votes |
/** * Sets up click listener. */ private void setupClickListener() { mCardScroller.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); switch (mAdapter.getActionAt(position)) { case DELETION_HERE: am.playSoundEffect(Sounds.TAP); deleteCard(position); break; case NAVIGATION_TO_BEGIN: am.playSoundEffect(Sounds.TAP); navigateToCard(0); break; case NAVIGATION_TO_END: am.playSoundEffect(Sounds.TAP); navigateToCard(mAdapter.getCount() - 1); break; case INSERTION_AT_BEGIN: am.playSoundEffect(Sounds.TAP); insertNewCard(0); break; case INSERTION_BEFORE: am.playSoundEffect(Sounds.TAP); insertNewCard(position); break; case INSERTION_AFTER: am.playSoundEffect(Sounds.TAP); insertNewCard(position + 1); break; case INSERTION_AT_END: am.playSoundEffect(Sounds.TAP); insertNewCard(mAdapter.getCount()); break; default: am.playSoundEffect(Sounds.DISALLOWED); break; } } }); }
Example #29
Source File: BleServicesActivity.java From Bluetooth-Manager-for-Glass with MIT License | 4 votes |
private void onServiceClick(int position) { AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audio.playSoundEffect(Sounds.TAP); mSelectedService = adapter.getItem(position); openOptionsMenu(); }
Example #30
Source File: BleServicesActivity.java From Bluetooth-Manager-for-Glass with MIT License | 4 votes |
private void onCharacteristicClick(int position) { AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audio.playSoundEffect(Sounds.TAP); mSelectedCharacteristic = charAdapter.getItem(position); openOptionsMenu(); }