Skip to content

Commit

Permalink
Settings: Chamber of Secrets (2/2) [WIP]
Browse files Browse the repository at this point in the history
PS2: Rebase

Change-Id: I4bee793580fe32b022cf7cbfc7ca5195d2c9a434
  • Loading branch information
Jubakuba authored and Gerrit Code Review committed Dec 24, 2013
1 parent 06fa106 commit 7810549
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
4 changes: 4 additions & 0 deletions res/values/slim_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -882,4 +882,8 @@ two in order to insert additional control points. \'Remove\' deletes the selecte
<!-- Hostname setting -->
<string name="device_hostname">Device hostname</string>

<!-- Chamber of Secrets -->
<string name="chamber_title">Chamber of secrets</string>
<string name="chamber_toast">The chamber of secrets has opened</string>

</resources>
9 changes: 9 additions & 0 deletions res/xml/development_prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,13 @@

</PreferenceCategory>

<!-- Must remain at bottom -->
<Preference
android:key="chamber_of_secrets"
android:title="\n \n" />

<CheckBoxPreference
android:key="chamber_of_unlocked_secrets"
android:title="@string/chamber_title" />

</PreferenceScreen>
47 changes: 47 additions & 0 deletions src/com/android/settings/DevelopmentSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;

import dalvik.system.VMRuntime;

Expand Down Expand Up @@ -150,6 +151,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment

private static final String TERMINAL_APP_PACKAGE = "com.android.terminal";

private static final String KEY_CHAMBER_OF_SECRETS = "chamber_of_secrets";
private static final String KEY_CHAMBER_OF_UNLOCKED_SECRETS =
"chamber_of_unlocked_secrets";

private static final int RESULT_DEBUG_APP = 1000;

private IWindowManager mWindowManager;
Expand Down Expand Up @@ -207,6 +212,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment

private CheckBoxPreference mShowAllANRs;

private Preference mChamber;
private CheckBoxPreference mChamberUnlocked;

private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>();
private final ArrayList<CheckBoxPreference> mResetCbPrefs
= new ArrayList<CheckBoxPreference>();
Expand Down Expand Up @@ -337,6 +345,22 @@ public void onCreate(Bundle icicle) {
mAllPrefs.add(mRootAccess);
}

mChamber = (Preference) findPreference(KEY_CHAMBER_OF_SECRETS);
mAllPrefs.add(mChamber);
mChamberUnlocked =
findAndInitCheckboxPref(KEY_CHAMBER_OF_UNLOCKED_SECRETS);
mChamberUnlocked.setOnPreferenceChangeListener(this);

boolean chamberOpened = Settings.Secure.getInt(
getActivity().getContentResolver(),
Settings.Secure.CHAMBER_OF_SECRETS, 0) == 1;
mChamberUnlocked.setChecked(chamberOpened);

if (chamberOpened) {
removePreference(mChamber);
} else {
removePreference(mChamberUnlocked);
}
}

private ListPreference addListPreference(String prefKey) {
Expand Down Expand Up @@ -425,6 +449,12 @@ private void removePreference(Preference preference) {
mAllPrefs.remove(preference);
}

private void addPreference(Preference preference) {
getPreferenceScreen().addPreference(preference);
preference.setOnPreferenceChangeListener(this);
mAllPrefs.add(preference);
}

private void setPrefsEnabledState(boolean enabled) {
for (int i = 0; i < mAllPrefs.size(); i++) {
Preference pref = mAllPrefs.get(i);
Expand Down Expand Up @@ -1314,6 +1344,18 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preferen
writeForceRtlOptions();
} else if (preference == mWifiDisplayCertification) {
writeWifiDisplayCertificationOptions();
} else if (preference == mChamber) {
if (Settings.Secure.getInt(getActivity().getContentResolver(),
Settings.Secure.CHAMBER_OF_SECRETS, 0) == 0) {
Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.CHAMBER_OF_SECRETS, 1);
Toast.makeText(getActivity(),
R.string.chamber_toast,
Toast.LENGTH_LONG).show();
getPreferenceScreen().removePreference(mChamber);
addPreference(mChamberUnlocked);
mChamberUnlocked.setChecked(true);
}
} else {
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
Expand Down Expand Up @@ -1401,6 +1443,11 @@ public void onClick(DialogInterface dialog, int which) {
writeRootAccessOptions(newValue);
}
return true;
} else if (preference == mChamberUnlocked) {
Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.CHAMBER_OF_SECRETS,
(Boolean) newValue ? 1 : 0);
return true;
}
return false;
}
Expand Down

1 comment on commit 7810549

@trevd
Copy link

@trevd trevd commented on 7810549 Dec 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SlimRoms What the fuck is this all about?

Please sign in to comment.