Cherish: [SQUASH] User toggle for unlimited photos storage and GamesProp [2/2][2/2]

Co-authored-by: spezi77 <spezi7713@gmx.net>
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Pranav Vashi
2022-09-06 18:00:26 +07:00
committed by Hưng Phan
parent 9354fecbab
commit 0590d07893
3 changed files with 49 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.UserHandle;
import android.os.SystemProperties;
import android.content.Context;
import android.content.ContentResolver;
import android.content.res.Resources;
@@ -44,6 +45,14 @@ import java.util.List;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class MiscSettings extends SettingsPreferenceFragment implements
OnPreferenceChangeListener {
private static final String KEY_GAMES_SPOOF = "use_games_spoof";
private static final String KEY_PHOTOS_SPOOF = "use_photos_spoof";
private static final String SYS_GAMES_SPOOF = "persist.sys.pixelprops.games";
private static final String SYS_PHOTOS_SPOOF = "persist.sys.pixelprops.gphotos";
private SwitchPreference mGamesSpoof;
private SwitchPreference mPhotosSpoof;
@Override
public void onCreate(Bundle icicle) {
@@ -61,11 +70,28 @@ public class MiscSettings extends SettingsPreferenceFragment implements
} catch (NameNotFoundException e) {
e.printStackTrace();
}
mGamesSpoof = (SwitchPreference) findPreference(KEY_GAMES_SPOOF);
mGamesSpoof.setChecked(SystemProperties.getBoolean(SYS_GAMES_SPOOF, false));
mGamesSpoof.setOnPreferenceChangeListener(this);
mPhotosSpoof = (SwitchPreference) findPreference(KEY_PHOTOS_SPOOF);
mPhotosSpoof.setChecked(SystemProperties.getBoolean(SYS_PHOTOS_SPOOF, true));
mPhotosSpoof.setOnPreferenceChangeListener(this);
}
@Override
public boolean onPreferenceChange(Preference preference, Object objValue) {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference == mGamesSpoof) {
boolean value = (Boolean) newValue;
SystemProperties.set(SYS_GAMES_SPOOF, value ? "true" : "false");
return true;
} else if (preference == mPhotosSpoof) {
boolean value = (Boolean) newValue;
SystemProperties.set(SYS_PHOTOS_SPOOF, value ? "true" : "false");
return true;
}
return false;
}