Move setGlobalDurationScale to AegisActivity

Also, rename the method and make the error string translatable
pull/66/head
Alexander Bakker 6 years ago
parent 5d835b05ee
commit 92458d0d3b

@ -1,6 +1,5 @@
package com.beemdevelopment.aegis;
import android.animation.ValueAnimator;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -10,8 +9,6 @@ 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;
@ -34,8 +31,6 @@ 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();
}
@ -74,17 +69,6 @@ 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) {

@ -1,8 +1,12 @@
package com.beemdevelopment.aegis.ui;
import android.animation.ValueAnimator;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.view.WindowManager;
import android.widget.Toast;
import com.beemdevelopment.aegis.AegisApplication;
import com.beemdevelopment.aegis.Preferences;
@ -35,6 +39,9 @@ public abstract class AegisActivity extends AppCompatActivity {
// set the theme
setPreferredTheme(Theme.fromInteger(getPreferences().getCurrentTheme()));
// apply a dirty hack to make progress bars work even if animations are disabled
setGlobalAnimationDurationScale();
}
protected AegisApplication getApp() {
@ -58,4 +65,15 @@ public abstract class AegisActivity extends AppCompatActivity {
break;
}
}
private void setGlobalAnimationDurationScale() {
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, R.string.progressbar_error, Toast.LENGTH_SHORT).show();
}
}
}
}

@ -130,6 +130,7 @@
<string name="remove_group">Remove group</string>
<string name="remove_group_description">Are you sure you want to remove this group? Entries in this group will automatically switch to \'No group\'.</string>
<string name="adding_new_slot_error">An error occurred while trying to add a new slot:</string>
<string name="progressbar_error">Unable to reset animator duration scale. Progress bars will be invisible</string>
<string name="details">Details</string>
<string name="filter">Filter</string>
<string name="lock">Lock</string>

Loading…
Cancel
Save