List of usage examples for android.view.accessibility AccessibilityEvent setClassName
public void setClassName(CharSequence className)
From source file:com.android.internal.widget.ViewPager.java
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setClassName(ViewPager.class.getName()); event.setScrollable(canScroll());//from w w w. j a v a2s . c o m if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED && mAdapter != null) { event.setItemCount(mAdapter.getCount()); event.setFromIndex(mCurItem); event.setToIndex(mCurItem); } }
From source file:com.albedinsky.android.ui.widget.SeekBarWidget.java
/** *//*from w w w. j a v a 2 s .c om*/ @Override @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void onInitializeAccessibilityEvent(@NonNull AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setClassName(SeekBarWidget.class.getName()); }
From source file:com.android.tv.MainActivity.java
/** * Says {@code text} when accessibility is turned on. */// w w w. j a v a 2s . c o m public void sendAccessibilityText(String text) { if (mAccessibilityManager.isEnabled()) { AccessibilityEvent event = AccessibilityEvent.obtain(); event.setClassName(getClass().getName()); event.setPackageName(getPackageName()); event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT); event.getText().add(text); mAccessibilityManager.sendAccessibilityEvent(event); } }
From source file:de.vanita5.twittnuker.util.Utils.java
public static void announceForAccessibilityCompat(final Context context, final View view, final CharSequence text, final Class<?> cls) { final AccessibilityManager accessibilityManager = (AccessibilityManager) context .getSystemService(Context.ACCESSIBILITY_SERVICE); if (!accessibilityManager.isEnabled()) return;//from w w w.j a v a 2 s.c o m // Prior to SDK 16, announcements could only be made through FOCUSED // events. Jelly Bean (SDK 16) added support for speaking text verbatim // using the ANNOUNCEMENT event type. final int eventType; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { eventType = AccessibilityEvent.TYPE_VIEW_FOCUSED; } else { eventType = AccessibilityEventCompat.TYPE_ANNOUNCEMENT; } // Construct an accessibility event with the minimum recommended // attributes. An event without a class name or package may be dropped. final AccessibilityEvent event = AccessibilityEvent.obtain(eventType); event.getText().add(text); event.setClassName(cls.getName()); event.setPackageName(context.getPackageName()); event.setSource(view); // Sends the event directly through the accessibility manager. If your // application only targets SDK 14+, you should just call // getParent().requestSendAccessibilityEvent(this, event); accessibilityManager.sendAccessibilityEvent(event); }
From source file:com.android.tv.MainActivity.java
private void tune() { if (DEBUG)/*from w w w .j a v a2 s . c om*/ Log.d(TAG, "tune()"); mTuneDurationTimer.start(); lazyInitializeIfNeeded(LAZY_INITIALIZATION_DELAY); // Prerequisites to be able to tune. if (mInputIdUnderSetup != null) { mTunePending = true; return; } mTunePending = false; final Channel channel = mChannelTuner.getCurrentChannel(); if (!mChannelTuner.isCurrentChannelPassthrough()) { if (mTvInputManagerHelper.getTunerTvInputSize() == 0) { Toast.makeText(this, R.string.msg_no_input, Toast.LENGTH_SHORT).show(); // TODO: Direct the user to a Play Store landing page for TvInputService apps. finish(); return; } SetupUtils setupUtils = SetupUtils.getInstance(this); if (setupUtils.isFirstTune()) { if (!mChannelTuner.areAllChannelsLoaded()) { // tune() will be called, once all channels are loaded. stopTv("tune()", false); return; } if (mChannelDataManager.getChannelCount() > 0) { mOverlayManager.showIntroDialog(); } else if (!Features.ONBOARDING_EXPERIENCE.isEnabled(this)) { mOverlayManager.showSetupFragment(); return; } } if (!TvCommonUtils.isRunningInTest() && mShowNewSourcesFragment && setupUtils.hasUnrecognizedInput(mTvInputManagerHelper)) { // Show new channel sources fragment. runAfterAttachedToWindow(new Runnable() { @Override public void run() { mOverlayManager.runAfterOverlaysAreClosed(new Runnable() { @Override public void run() { mOverlayManager.showNewSourcesFragment(); } }); } }); } mShowNewSourcesFragment = false; if (mChannelTuner.getBrowsableChannelCount() == 0 && mChannelDataManager.getChannelCount() > 0 && !mOverlayManager.getSideFragmentManager().isActive()) { if (!mChannelTuner.areAllChannelsLoaded()) { return; } if (mTvInputManagerHelper.getTunerTvInputSize() == 1) { mOverlayManager.getSideFragmentManager().show(new CustomizeChannelListFragment()); } else { showSettingsFragment(); } return; } // TODO: need to refactor the following code to put in startTv. if (channel == null) { // There is no channel to tune to. stopTv("tune()", false); if (!mChannelDataManager.isDbLoadFinished()) { // Wait until channel data is loaded in order to know the number of channels. // tune() will be retried, once the channel data is loaded. return; } if (mOverlayManager.getSideFragmentManager().isActive()) { return; } mOverlayManager.showSetupFragment(); return; } setupUtils.onTuned(); if (mTuneParams != null) { Long initChannelId = mTuneParams.getLong(KEY_INIT_CHANNEL_ID); if (initChannelId == channel.getId()) { mTuneParams.remove(KEY_INIT_CHANNEL_ID); } else { mTuneParams = null; } } } mIsCurrentChannelUnblockedByUser = false; if (!isUnderShrunkenTvView()) { mLastAllowedRatingForCurrentChannel = null; } mHandler.removeMessages(MSG_UPDATE_CHANNEL_BANNER_BY_INFO_UPDATE); if (mAccessibilityManager.isEnabled()) { // For every tune, we need to inform the tuned channel or input to a user, // if Talkback is turned on. AccessibilityEvent event = AccessibilityEvent.obtain(); event.setClassName(getClass().getName()); event.setPackageName(getPackageName()); event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT); if (TvContract.isChannelUriForPassthroughInput(channel.getUri())) { TvInputInfo input = mTvInputManagerHelper.getTvInputInfo(channel.getInputId()); event.getText().add(Utils.loadLabel(this, input)); } else if (TextUtils.isEmpty(channel.getDisplayName())) { event.getText().add(channel.getDisplayNumber()); } else { event.getText().add(channel.getDisplayNumber() + " " + channel.getDisplayName()); } mAccessibilityManager.sendAccessibilityEvent(event); } boolean success = mTvView.tuneTo(channel, mTuneParams, mOnTuneListener); mOnTuneListener.onTune(channel, isUnderShrunkenTvView()); mTuneParams = null; if (!success) { Toast.makeText(this, R.string.msg_tune_failed, Toast.LENGTH_SHORT).show(); return; } // Explicitly make the TV view main to make the selected input an HDMI-CEC active source. mTvView.setMain(); scheduleRestoreMainTvView(); if (!isUnderShrunkenTvView()) { if (!channel.isPassthrough()) { addToRecentChannels(channel.getId()); } Utils.setLastWatchedChannel(this, channel); TvApplication.getSingletons(this).getMainActivityWrapper().notifyCurrentChannelChange(this, channel); } checkChannelLockNeeded(mTvView); updateChannelBannerAndShowIfNeeded(UPDATE_CHANNEL_BANNER_REASON_TUNE); if (mActivityResumed) { // requestVisibleBehind should be called after onResume() is called. But, when // launcher is over the TV app and the screen is turned off and on, tune() can // be called during the pause state by mBroadcastReceiver (Intent.ACTION_SCREEN_ON). requestVisibleBehind(true); } updateMediaSession(); }
From source file:com.appunite.list.HorizontalListView.java
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setClassName(HorizontalListView.class.getName()); }
From source file:com.awrtechnologies.carbudgetsales.hlistview.widget.HListView.java
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setClassName(HListView.class.getName()); }
From source file:com.appunite.list.ListView.java
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setClassName(ListView.class.getName()); }
From source file:android.app.Activity.java
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { event.setClassName(getClass().getName()); event.setPackageName(getPackageName()); LayoutParams params = getWindow().getAttributes(); boolean isFullScreen = (params.width == LayoutParams.MATCH_PARENT) && (params.height == LayoutParams.MATCH_PARENT); event.setFullScreen(isFullScreen);//from w w w . j av a 2s.c o m CharSequence title = getTitle(); if (!TextUtils.isEmpty(title)) { event.getText().add(title); } return true; }
From source file:com.appunite.list.AbsHorizontalListView.java
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setClassName(AbsHorizontalListView.class.getName()); }