From 2a47fa4de58cda38c014a13af7905c4fac7f197b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Sch=C3=A4ttgen?= Date: Tue, 16 Apr 2019 22:12:49 +0200 Subject: [PATCH] Add method to set global duration scale Fixes #35 --- .../beemdevelopment/aegis/AegisApplication.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/com/beemdevelopment/aegis/AegisApplication.java b/app/src/main/java/com/beemdevelopment/aegis/AegisApplication.java index 4213f836..47d34b60 100644 --- a/app/src/main/java/com/beemdevelopment/aegis/AegisApplication.java +++ b/app/src/main/java/com/beemdevelopment/aegis/AegisApplication.java @@ -1,5 +1,6 @@ package com.beemdevelopment.aegis; +import android.animation.ValueAnimator; import android.app.Application; import android.content.BroadcastReceiver; import android.content.Context; @@ -9,6 +10,8 @@ import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutManager; import android.graphics.drawable.Icon; import android.os.Build; +import android.provider.Settings; +import android.widget.Toast; import com.beemdevelopment.aegis.db.DatabaseManager; import com.beemdevelopment.aegis.ui.MainActivity; @@ -31,6 +34,8 @@ public class AegisApplication extends Application { ScreenOffReceiver receiver = new ScreenOffReceiver(); registerReceiver(receiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); + setGlobalDurationScale(); + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { initAppShortcuts(); } @@ -69,6 +74,17 @@ public class AegisApplication extends Application { return _prefs.isAutoLockEnabled() && _manager.isEncryptionEnabled() && !_manager.isLocked(); } + private void setGlobalDurationScale() { + float durationScale = Settings.Global.getFloat(getContentResolver(), Settings.Global.ANIMATOR_DURATION_SCALE, 0); + if (durationScale != 1) { + try { + ValueAnimator.class.getMethod("setDurationScale", float.class).invoke(null, 1f); + } catch (Throwable t) { + Toast.makeText(this, "Unable to reset animator duration scale. Progressbars will be invisible", Toast.LENGTH_SHORT).show(); + } + } + } + private class ScreenOffReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) {