powersave flex

This commit is contained in:
gdlbo
2022-09-15 18:05:31 +03:00
parent 1e0e432d57
commit e576fa0be5
4 changed files with 30 additions and 7 deletions
@@ -2,6 +2,7 @@ package ru.vtosters.lite.hooks;
import static java.lang.Long.MAX_VALUE;
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
import static ru.vtosters.lite.utils.Preferences.ads;
import static ru.vtosters.lite.utils.Preferences.adsslider;
@@ -10,6 +11,9 @@ import static ru.vtosters.lite.utils.Preferences.friendsrecomm;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.vkme;
import android.content.Context;
import android.os.PowerManager;
import com.vk.core.preference.Preference;
import com.vtosters.lite.api.ExtendedCommunityProfile;
@@ -122,4 +126,10 @@ public class NewsfeedHook {
hashSet.add("ads_post_pretty_cards");
hashSet.add("ads_post_snippet_video");
}
public static boolean isPowerSaveMode() {
var pw = (PowerManager) getGlobalContext().getSystemService(Context.POWER_SERVICE);
return !getBoolValue("force_disable_psm", false) && pw.isPowerSaveMode();
}
}