/** * Handles activity initialization when the Service has connected. * * <p>Should be called when there is a reason to believe that the connection might have became * valid. The connection MUST be established but other validity criteria may still be unfilled * such as server synchronization being complete. * * <p>The method implements the logic required for making sure that the Connected service is in * such a state that it fills all the connection criteria for ChannelList. * * <p>The method also takes care of making sure that its initialization code is executed only once * so calling it several times doesn't cause problems. */ protected void onConnected() { // Tell the service that we are now visible. mService.setActivityVisible(true); // Update user control updateUserControlMenuItems(); // Restore push to talk state, if toggled. Otherwise make sure it's turned off. if (settings.isPushToTalk() && mService.isRecording()) { if (settings.isPushToTalkToggle() && settings.isPushToTalkButtonShown()) setPushToTalk(true); else mService.setPushToTalk(false); } if (settings.isPushToTalk() && mService.isRecording()) if (chatTarget != null) { listFragment.setChatTarget(chatTarget); chatFragment.setChatTarget(chatTarget); } // Showcase hints List<ShowcaseView> showcaseViews = new ArrayList<ShowcaseView>(); if (settings.isPushToTalk() && settings.isPushToTalkButtonShown()) { ConfigOptions pttConfig = new ConfigOptions(); pttConfig.shotType = ShowcaseView.TYPE_ONE_SHOT; pttConfig.showcaseId = Globals.SHOWCASE_PUSH_TO_TALK; showcaseViews.add( ShowcaseView.insertShowcaseView( pttView, this, R.string.hint_ptt, R.string.hint_ptt_summary, pttConfig)); } if (mViewPager != null) { ConfigOptions switcherConfig = new ConfigOptions(); switcherConfig.shotType = ShowcaseView.TYPE_ONE_SHOT; switcherConfig.showcaseId = Globals.SHOWCASE_SWITCHER; showcaseViews.add( ShowcaseView.insertShowcaseView( ShowcaseView.ITEM_ACTION_HOME, 0, this, R.string.hint_switching, R.string.hint_switching_summary, switcherConfig)); } ShowcaseViewQueue queue = new ShowcaseViewQueue(showcaseViews); queue.queueNext(); }
/** * Handles activity initialization when the Service has connected. * * <p>Should be called when there is a reason to believe that the connection might have became * valid. The connection MUST be established but other validity criteria may still be unfilled * such as server synchronization being complete. * * <p>The method implements the logic required for making sure that the Connected service is in * such a state that it fills all the connection criteria for ChannelList. * * <p>The method also takes care of making sure that its initialization code is executed only once * so calling it several times doesn't cause problems. */ protected void onConnected() { // Tell the service that we are now visible. mService.setActivityVisible(true); // Update user control updateUserControlMenuItems(); // Restore push to talk state, if toggled. Otherwise make sure it's turned off. if (settings.isPushToTalk() && mService.isRecording()) { if (settings.isPushToTalkToggle() && settings.isPushToTalkButtonShown()) setPushToTalk(true); else mService.setPushToTalk(false); } if (settings.isPushToTalk() && mService.isRecording()) if (chatTarget != null) { listFragment.setChatTarget(chatTarget); chatFragment.setChatTarget(chatTarget); } }
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { // Push to talk hardware key if (settings.isPushToTalk() && keyCode == settings.getPushToTalkKey() && event.getAction() == KeyEvent.ACTION_UP) { setPushToTalk(false); return true; } return super.onKeyUp(keyCode, event); }
@Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { final AlertDialog.Builder b = new AlertDialog.Builder(this); b.setTitle(R.string.disconnect); b.setMessage(R.string.disconnectSure); b.setPositiveButton(android.R.string.yes, onDisconnectConfirm); b.setNegativeButton(android.R.string.no, null); b.show(); return true; } // Push to talk hardware key if (settings.isPushToTalk() && keyCode == settings.getPushToTalkKey() && event.getAction() == KeyEvent.ACTION_DOWN) { setPushToTalk(true); return true; } return super.onKeyDown(keyCode, event); }
// Settings observer @Override public void update(Observable observable, Object data) { Settings settings = (Settings) observable; if (data.equals(Settings.OBSERVER_KEY_ALL)) { // Create PTT overlay dismissPTTOverlay(); if (settings.isPushToTalk() && !settings.getHotCorner().equals(Settings.ARRAY_HOT_CORNER_NONE)) { createPTTOverlay(); } // Handle voice activity try { mAudioInput .stopRecordingAndBlock(); // We block because we want to wait before restarting // recording to avoid a concurrent modificatione exception. } catch (InterruptedException e) { e.printStackTrace(); } finally { if (settings.isVoiceActivity()) mAudioInput.startRecording(); } } }
private void updatePTTConfiguration() { pttView.setVisibility( settings.isPushToTalk() && settings.isPushToTalkButtonShown() ? View.VISIBLE : View.GONE); }