Skip to content

Commit

Permalink
Trying to fix #3 again
Browse files Browse the repository at this point in the history
- Disable animation on xiaomi device if accessibility manager turned off
  • Loading branch information
danimahardhika authored Sep 16, 2017
1 parent 9a22bdc commit e24c385
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion library/src/main/java/com/danimahardhika/cafebar/CafeBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ public boolean onPreDraw() {
}

private boolean isAccessibilityManagerEnabled() {
String manufacturer = android.os.Build.MANUFACTURER;
LogUtil.d("Manufacturer: " +manufacturer);
if (manufacturer.equalsIgnoreCase("xiaomi")) {
//Seriously accessibility manager on xiaomi device is a mess
//Better to returns false
return false;
}

int accessibilityEnabled = 0;
try {
accessibilityEnabled = Settings.Secure.getInt(mBuilder.mContext.getContentResolver(),
Expand All @@ -379,7 +387,7 @@ private boolean isAccessibilityManagerEnabled() {
} catch (Exception e) {
LogUtil.d("Accessibility manager is disabled");
}
return accessibilityEnabled > 0;
return accessibilityEnabled == 1;
}

private void setAccessibilityManagerDisabled() {
Expand All @@ -395,6 +403,7 @@ private void setAccessibilityManagerDisabled() {
mAccessibilityManagerField.setAccessible(true);
AccessibilityManager accessibilityManager = (AccessibilityManager) mAccessibilityManagerField.get(mSnackBar);
Field mIsEnabledField = AccessibilityManager.class.getDeclaredField("mIsEnabled");

mIsEnabledField.setAccessible(true);
mIsEnabledField.setBoolean(accessibilityManager, false);
mAccessibilityManagerField.set(mSnackBar, accessibilityManager);
Expand Down

0 comments on commit e24c385

Please sign in to comment.