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

@@ -486,4 +486,12 @@
<string name="powermenu_users">Users</string> <string name="powermenu_users">Users</string>
<string name="powermenu_logout">Logout</string> <string name="powermenu_logout">Logout</string>
<string name="powermenu_emergency">Emergency</string> <string name="powermenu_emergency">Emergency</string>
<!-- Unlock FPS for specific games -->
<string name="use_games_spoof_title">Unlock higher FPS in games</string>
<string name="use_games_spoof_summary">Spoof your device as a different model for specific games to unlock higher FPS</string>
<!-- Unlimited google photos storage -->
<string name="use_photos_spoof_title">Unlimited Photos storage</string>
<string name="use_photos_spoof_summary">Spoof your device as Pixel XL for Google Photos app only to provide unlimited storage for backup</string>
</resources> </resources>

View File

@@ -37,4 +37,17 @@
android:summary="@string/click_partial_screenshot_summary" android:summary="@string/click_partial_screenshot_summary"
android:defaultValue="false" /> android:defaultValue="false" />
<!-- Unlock FPS for specific games -->
<SwitchPreference
android:key="use_games_spoof"
android:title="@string/use_games_spoof_title"
android:summary="@string/use_games_spoof_summary" />
<!-- Unlimited Photos storage -->
<SwitchPreference
android:key="use_photos_spoof"
android:title="@string/use_photos_spoof_title"
android:summary="@string/use_photos_spoof_summary"
android:defaultValue="true" />
</PreferenceScreen> </PreferenceScreen>

View File

@@ -7,6 +7,7 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.SystemProperties;
import android.content.Context; import android.content.Context;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.res.Resources; import android.content.res.Resources;
@@ -44,6 +45,14 @@ import java.util.List;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC) @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class MiscSettings extends SettingsPreferenceFragment implements public class MiscSettings extends SettingsPreferenceFragment implements
OnPreferenceChangeListener { 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 @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
@@ -61,11 +70,28 @@ public class MiscSettings extends SettingsPreferenceFragment implements
} catch (NameNotFoundException e) { } catch (NameNotFoundException e) {
e.printStackTrace(); 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 @Override
public boolean onPreferenceChange(Preference preference, Object objValue) { 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; return false;
} }