-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use system animator duration scale for animations
So animations follow the system settings (and can be shut off completely when "Remove animations" is on). This commit also decreases the duration of the ripple effect to just 200ms (if `animatorDurationScale` is 1, the default value). So all animations share the same duration time now.
- Loading branch information
1 parent
dc99264
commit 77f5f34
Showing
6 changed files
with
113 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
app/src/main/java/de/markusfisch/android/pielauncher/preference/SystemSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package de.markusfisch.android.pielauncher.preference; | ||
|
||
import android.content.ContentResolver; | ||
import android.database.ContentObserver; | ||
import android.os.Build; | ||
import android.provider.Settings; | ||
|
||
class SystemSettings { | ||
private static final boolean HAS_GLOBAL = | ||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1; | ||
|
||
private final ContentResolver contentResolver; | ||
|
||
private float animatorDurationScale = 1f; | ||
|
||
public SystemSettings(ContentResolver contentResolver) { | ||
this.contentResolver = contentResolver; | ||
contentResolver.registerContentObserver( | ||
HAS_GLOBAL | ||
? Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE) | ||
: Settings.System.getUriFor(Settings.System.TRANSITION_ANIMATION_SCALE), | ||
false, | ||
new ContentObserver(null) { | ||
@Override | ||
public void onChange(boolean selfChange) { | ||
onAnimatorScaleChanged(); | ||
} | ||
}); | ||
onAnimatorScaleChanged(); | ||
} | ||
|
||
public float getAnimatorDurationScale() { | ||
return animatorDurationScale; | ||
} | ||
|
||
private void onAnimatorScaleChanged() { | ||
if (HAS_GLOBAL) { | ||
animatorDurationScale = Settings.Global.getFloat(contentResolver, | ||
Settings.Global.ANIMATOR_DURATION_SCALE, | ||
animatorDurationScale); | ||
} else { | ||
animatorDurationScale = Settings.System.getFloat(contentResolver, | ||
Settings.System.TRANSITION_ANIMATION_SCALE, | ||
animatorDurationScale); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters