Cherish: User toggle for unlimited ph0t0s st0rage [2/2].

Signed-off-by: spezi77 <spezi7713@gmx.net>
Change-Id: I5fca5843a2178f5a39a753ff77c6194220a3026d
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
spezi77
2022-01-31 01:01:52 +01:00
committed by Hưng Phan
parent 25f5a19112
commit cd5963d562
3 changed files with 36 additions and 1 deletions

View File

@@ -691,5 +691,10 @@
<!-- Black theme -->
<string name="system_black_theme_title">Use black theme</string>
<string name="system_black_theme_summary">Force black background colors</string>
<!-- Unlimited g00gle ph0t0s st0rage -->
<string name="use_photos_spoof_title">Unlimited Photos storage</string>
<string name="use_photos_spoof_summary">Your device will be identified as a Pixel XL by the Photos app to get unlimited photo storage at original quality</string>
<string name="photos_spoof_toast">Restart the Photos app for it to take effect</string>
</resources>

View File

@@ -30,6 +30,13 @@
android:summary="@string/charging_animation_summary"
android:defaultValue="false" />
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="use_photos_spoof"
android:title="@string/use_photos_spoof_title"
android:summary="@string/use_photos_spoof_summary"
android:defaultValue="true"
android:persistent="false" />
<PreferenceCategory
android:key="burnin_category"
android:title="@string/burnin_category">

View File

@@ -6,6 +6,7 @@ import android.os.Bundle;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.content.Context;
import android.content.ContentResolver;
@@ -28,7 +29,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import android.widget.Toast;
import android.content.pm.PackageManager.NameNotFoundException;
import com.android.settings.SettingsPreferenceFragment;
import com.cherish.settings.preferences.SystemSettingMasterSwitchPreference;
@@ -44,6 +45,11 @@ import java.util.List;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class MiscSettings extends SettingsPreferenceFragment implements
OnPreferenceChangeListener {
private static final String KEY_SPOOF = "use_photos_spoof";
private static final String SYS_SPOOF = "persist.sys.photo";
private SwitchPreference mSpoof;
@Override
public void onCreate(Bundle icicle) {
@@ -52,6 +58,13 @@ public class MiscSettings extends SettingsPreferenceFragment implements
addPreferencesFromResource(R.xml.cherish_settings_misc);
final PreferenceScreen prefSet = getPreferenceScreen();
final String useSpoof = SystemProperties.get(SYS_SPOOF, "1");
mSpoof = (SwitchPreference) findPreference(KEY_SPOOF);
mSpoof.setChecked("1".equals(useSpoof));
mSpoof.setOnPreferenceChangeListener(this);
Resources res = null;
Context ctx = getContext();
float density = Resources.getSystem().getDisplayMetrics().density;
@@ -66,6 +79,16 @@ public class MiscSettings extends SettingsPreferenceFragment implements
@Override
public boolean onPreferenceChange(Preference preference, Object objValue) {
if (preference == mSpoof) {
boolean value = (Boolean) objValue;
Settings.System.putInt(getActivity().getContentResolver(),
Settings.System.USE_PHOTOS_SPOOF, value ? 1 : 0);
SystemProperties.set(SYS_SPOOF, value ? "1" : "0");
Toast.makeText(getActivity(),
(R.string.photos_spoof_toast),
Toast.LENGTH_LONG).show();
return true;
}
return false;
}