Fix settings pref switch for multi-user

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
This commit is contained in:
Pranav Vashi
2022-11-26 22:25:49 +05:30
committed by Joey
parent 981cdd2b8e
commit bb57322336
8 changed files with 32 additions and 24 deletions

View File

@@ -7,6 +7,7 @@
package lineageos.preference;
import android.content.Context;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.AttributeSet;
@@ -31,12 +32,12 @@ public class SecureSettingSwitchPreference extends SelfRemovingSwitchPreference
@Override
protected void putBoolean(String key, boolean value) {
Settings.Secure.putInt(getContext().getContentResolver(), key, value ? 1 : 0);
Settings.Secure.putIntForUser(getContext().getContentResolver(), key, value ? 1 : 0, UserHandle.USER_CURRENT);
}
@Override
protected boolean getBoolean(String key, boolean defaultValue) {
return Settings.Secure.getInt(getContext().getContentResolver(),
key, defaultValue ? 1 : 0) != 0;
return Settings.Secure.getIntForUser(getContext().getContentResolver(),
key, defaultValue ? 1 : 0, UserHandle.USER_CURRENT) != 0;
}
}