use of android.view.accessibility.AccessibilityManager in project android_packages_apps_Launcher2 by CyanogenMod.
the class DragLayer method onInterceptHoverEvent.
@Override
public boolean onInterceptHoverEvent(MotionEvent ev) {
if (mLauncher == null || mLauncher.getWorkspace() == null) {
return false;
}
Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
if (currentFolder == null) {
return false;
} else {
AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityManager.isTouchExplorationEnabled()) {
final int action = ev.getAction();
boolean isOverFolder;
switch(action) {
case MotionEvent.ACTION_HOVER_ENTER:
isOverFolder = isEventOverFolder(currentFolder, ev);
if (!isOverFolder) {
sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
mHoverPointClosesFolder = true;
return true;
} else if (isOverFolder) {
mHoverPointClosesFolder = false;
} else {
return true;
}
case MotionEvent.ACTION_HOVER_MOVE:
isOverFolder = isEventOverFolder(currentFolder, ev);
if (!isOverFolder && !mHoverPointClosesFolder) {
sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
mHoverPointClosesFolder = true;
return true;
} else if (isOverFolder) {
mHoverPointClosesFolder = false;
} else {
return true;
}
}
}
}
return false;
}
use of android.view.accessibility.AccessibilityManager in project Etar-Calendar by Etar-Group.
the class EventInfoFragment method sendAccessibilityEvent.
private void sendAccessibilityEvent() {
AccessibilityManager am = (AccessibilityManager) getActivity().getSystemService(Service.ACCESSIBILITY_SERVICE);
if (!am.isEnabled()) {
return;
}
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_FOCUSED);
event.setClassName(getClass().getName());
event.setPackageName(getActivity().getPackageName());
List<CharSequence> text = event.getText();
addFieldToAccessibilityEvent(text, mTitle, null);
addFieldToAccessibilityEvent(text, mWhenDateTime, null);
addFieldToAccessibilityEvent(text, mWhere, null);
addFieldToAccessibilityEvent(text, null, mDesc);
if (mResponseRadioGroup.getVisibility() == View.VISIBLE) {
int id = mResponseRadioGroup.getCheckedRadioButtonId();
if (id != View.NO_ID) {
text.add(((TextView) getView().findViewById(R.id.response_label)).getText());
text.add((((RadioButton) (mResponseRadioGroup.findViewById(id))).getText() + PERIOD_SPACE));
}
}
am.sendAccessibilityEvent(event);
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.
the class DevicePolicyManagerService method getAccessibilityManagerForUser.
private AccessibilityManager getAccessibilityManagerForUser(int userId) {
// Not using AccessibilityManager.getInstance because that guesses
// at the user you require based on callingUid and caches for a given
// process.
IBinder iBinder = ServiceManager.getService(Context.ACCESSIBILITY_SERVICE);
IAccessibilityManager service = iBinder == null ? null : IAccessibilityManager.Stub.asInterface(iBinder);
return new AccessibilityManager(mContext, service, userId);
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.
the class DevicePolicyManagerService method getPermittedAccessibilityServicesForUser.
@Override
public List getPermittedAccessibilityServicesForUser(int userId) {
if (!mHasFeature) {
return null;
}
synchronized (this) {
List<String> result = null;
// If we have multiple profiles we return the intersection of the
// permitted lists. This can happen in cases where we have a device
// and profile owner.
int[] profileIds = mUserManager.getProfileIdsWithDisabled(userId);
for (int profileId : profileIds) {
// Just loop though all admins, only device or profiles
// owners can have permitted lists set.
DevicePolicyData policy = getUserDataUnchecked(profileId);
final int N = policy.mAdminList.size();
for (int j = 0; j < N; j++) {
ActiveAdmin admin = policy.mAdminList.get(j);
List<String> fromAdmin = admin.permittedAccessiblityServices;
if (fromAdmin != null) {
if (result == null) {
result = new ArrayList<>(fromAdmin);
} else {
result.retainAll(fromAdmin);
}
}
}
}
// If we have a permitted list add all system accessibility services.
if (result != null) {
long id = mInjector.binderClearCallingIdentity();
try {
UserInfo user = getUserInfo(userId);
if (user.isManagedProfile()) {
userId = user.profileGroupId;
}
AccessibilityManager accessibilityManager = getAccessibilityManagerForUser(userId);
List<AccessibilityServiceInfo> installedServices = accessibilityManager.getInstalledAccessibilityServiceList();
if (installedServices != null) {
for (AccessibilityServiceInfo service : installedServices) {
ServiceInfo serviceInfo = service.getResolveInfo().serviceInfo;
ApplicationInfo applicationInfo = serviceInfo.applicationInfo;
if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
result.add(serviceInfo.packageName);
}
}
}
} finally {
mInjector.binderRestoreCallingIdentity(id);
}
}
return result;
}
}
use of android.view.accessibility.AccessibilityManager in project Etar-Calendar by Etar-Group.
the class MonthWeekEventsView method onHoverEvent.
@Override
public boolean onHoverEvent(MotionEvent event) {
Context context = getContext();
// only send accessibility events if accessibility and exploration are
// on.
AccessibilityManager am = (AccessibilityManager) context.getSystemService(Service.ACCESSIBILITY_SERVICE);
if (!am.isEnabled() || !am.isTouchExplorationEnabled()) {
return super.onHoverEvent(event);
}
if (event.getAction() != MotionEvent.ACTION_HOVER_EXIT) {
Time hover = getDayFromLocation(event.getX());
if (hover != null && (mLastHoverTime == null || Time.compare(hover, mLastHoverTime) != 0)) {
Long millis = hover.toMillis(true);
String date = Utils.formatDateRange(context, millis, millis, DateUtils.FORMAT_SHOW_DATE);
AccessibilityEvent accessEvent = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
accessEvent.getText().add(date);
if (mShowDetailsInMonth && mEvents != null) {
int dayStart = SPACING_WEEK_NUMBER + mPadding;
int dayPosition = (int) ((event.getX() - dayStart) * mNumDays / (mWidth - dayStart - mPadding));
ArrayList<Event> events = mEvents.get(dayPosition);
List<CharSequence> text = accessEvent.getText();
for (Event e : events) {
text.add(e.getTitleAndLocation() + ". ");
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
if (!e.allDay) {
flags |= DateUtils.FORMAT_SHOW_TIME;
if (DateFormat.is24HourFormat(context)) {
flags |= DateUtils.FORMAT_24HOUR;
}
} else {
flags |= DateUtils.FORMAT_UTC;
}
text.add(Utils.formatDateRange(context, e.startMillis, e.endMillis, flags) + ". ");
}
}
sendAccessibilityEventUnchecked(accessEvent);
mLastHoverTime = hover;
}
}
return true;
}
Aggregations