Permalink
Browse files

Add Camera sound toggle [3/3]

AOSiP edits:
clean up some options

Change-Id: Ib203a35cccc1823f435b5e1b428d6e0c32d0b24b
  • Loading branch information...
mnm9994u authored and akhilnarang committed Jan 16, 2016
1 parent 0ec8a0c commit 50d78f82aaf940b5b5f0146bb3e556e3a63e2d7d
@@ -245,4 +245,9 @@
<string name="less_notification_sounds_2m">2 minutes</string>
<string name="less_notification_sounds_5m">5 minutes</string>
<!-- Camera sound -->
<string name="camera_sounds_title">Camera shutter sound</string>
<string name="camera_sounds_summary">Enable camera shutter sound</string>
<string name="camera_sound_warning_dialog_text">Disabling the camera shutter sound is illegal in some areas! Please check the applicable law in your country</string>
</resources>
@@ -19,6 +19,19 @@
android:title="@string/sound_title"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
<!-- Heads up -->
<com.aosip.owlsnest.preference.GlobalSettingSwitchPreference
android:key="heads_up_notifications_enabled"
android:title="@string/heads_up_notifications"
android:summaryOn="@string/summary_heads_up_enabled"
android:summaryOff="@string/summary_heads_up_disabled" />
<SwitchPreference
android:key="camera_sounds"
android:title="@string/camera_sounds_title"
android:summary="@string/camera_sounds_summary"
android:defaultValue="true" />
<SwitchPreference
android:key="safe_headset_volume"
android:title="@string/safe_headset_volume_title"
@@ -122,5 +122,4 @@
android:key="wifi_display"
android:title="@string/wifi_display_settings_title"
android:fragment="com.android.settings.wfd.WifiDisplaySettings" />
</PreferenceScreen>
@@ -28,6 +28,7 @@
import android.support.v7.preference.PreferenceScreen;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.Log;
@@ -40,18 +41,22 @@
private static final String TAG = "SoundSettings";
private static final int DLG_SAFE_HEADSET_VOLUME = 0;
private static final int DLG_CAMERA_SOUND = 1;
private static final String KEY_SAFE_HEADSET_VOLUME = "safe_headset_volume";
private static final String PREF_LESS_NOTIFICATION_SOUNDS = "less_notification_sounds";
private static final String KEY_CAMERA_SOUNDS = "camera_sounds";
private static final String PROP_CAMERA_SOUND = "persist.sys.camera-sound";
private SwitchPreference mSafeHeadsetVolume;
private ListPreference mAnnoyingNotifications;
private SwitchPreference mCameraSounds;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.slim_sound_settings);
addPreferencesFromResource(R.xml.aosip_sound_settings);
mSafeHeadsetVolume = (SwitchPreference) findPreference(KEY_SAFE_HEADSET_VOLUME);
mSafeHeadsetVolume.setChecked(Settings.System.getInt(getContentResolver(),
@@ -65,6 +70,9 @@ public void onCreate(Bundle savedInstanceState) {
mAnnoyingNotifications.setValue(Integer.toString(notificationThreshold));
mAnnoyingNotifications.setOnPreferenceChangeListener(this);
mCameraSounds = (SwitchPreference) findPreference(KEY_CAMERA_SOUNDS);
mCameraSounds.setChecked(SystemProperties.getBoolean(PROP_CAMERA_SOUND, true));
mCameraSounds.setOnPreferenceChangeListener(this);
}
@Override
@@ -87,6 +95,13 @@ public boolean onPreferenceChange(Preference preference, Object objValue) {
Settings.System.putInt(getContentResolver(),
Settings.System.MUTE_ANNOYING_NOTIFICATIONS_THRESHOLD, val);
}
if (KEY_CAMERA_SOUNDS.equals(key)) {
if ((Boolean) objValue) {
SystemProperties.set(PROP_CAMERA_SOUND, "1");
} else {
showDialogInner(DLG_CAMERA_SOUND);
}
}
return true;
}
@@ -133,6 +148,23 @@ public void onClick(DialogInterface dialog, int which) {
}
})
.create();
case DLG_CAMERA_SOUND:
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.attention)
.setMessage(R.string.camera_sound_warning_dialog_text)
.setPositiveButton(R.string.dlg_ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
SystemProperties.set(PROP_CAMERA_SOUND, "0");
}
})
.setNegativeButton(R.string.dlg_cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
})
.create();
}
throw new IllegalArgumentException("unknown id " + id);
}
@@ -144,6 +176,9 @@ public void onCancel(DialogInterface dialog) {
case DLG_SAFE_HEADSET_VOLUME:
getOwner().mSafeHeadsetVolume.setChecked(true);
break;
case DLG_CAMERA_SOUND:
getOwner().mCameraSounds.setChecked(true);
break;
}
}
}

0 comments on commit 50d78f8

Please sign in to comment.