Skip to content

Commit b33ecdc

Browse files
committed
add the option to disable Shutter sound
1 parent 17b771a commit b33ecdc

6 files changed

Lines changed: 51 additions & 1 deletion

File tree

app/src/main/java/com/simplemobiletools/camera/Config.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,12 @@ public int getMaxResolution() {
5353
public void setMaxResolution(int maxRes) {
5454
mPrefs.edit().putInt(Constants.MAX_RESOLUTION, maxRes).apply();
5555
}
56+
57+
public boolean getIsSoundEnabled() {
58+
return mPrefs.getBoolean(Constants.SOUND, true);
59+
}
60+
61+
public void setIsSoundEnabled(boolean enabled) {
62+
mPrefs.edit().putBoolean(Constants.SOUND, enabled).apply();
63+
}
5664
}

app/src/main/java/com/simplemobiletools/camera/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class Constants {
1010
public static final String IS_FIRST_RUN = "is_first_run";
1111
public static final String LONG_TAP = "long_tap";
1212
public static final String FOCUS_BEFORE_CAPTURE = "focus_before_capture";
13+
public static final String SOUND = "sound";
1314
public static final String FORCE_RATIO = "force_ratio";
1415
public static final String MAX_RESOLUTION = "max_resolution";
1516
}

app/src/main/java/com/simplemobiletools/camera/Preview.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ private void takePicture() {
223223
mParameters.setPictureSize(maxSize.width, maxSize.height);
224224
mParameters.setRotation(rotation % 360);
225225

226-
MediaPlayer.create(getContext(), R.raw.camera_shutter).start();
226+
if (Config.newInstance(getContext()).getIsSoundEnabled())
227+
MediaPlayer.create(getContext(), R.raw.camera_shutter).start();
228+
227229
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
228230
mCamera.enableShutterSound(false);
229231
}

app/src/main/java/com/simplemobiletools/camera/activities/SettingsActivity.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
public class SettingsActivity extends AppCompatActivity {
1717
@BindView(R.id.settings_long_tap) SwitchCompat mLongTapSwitch;
1818
@BindView(R.id.settings_focus_before_capture) SwitchCompat mFocusBeforeCaptureSwitch;
19+
@BindView(R.id.settings_sound) SwitchCompat mSoundSwitch;
1920
@BindView(R.id.settings_force_ratio) SwitchCompat mForceRatioSwitch;
2021
@BindView(R.id.settings_max_resolution) AppCompatSpinner mMaxResolutionSpinner;
2122

@@ -30,6 +31,7 @@ protected void onCreate(Bundle savedInstanceState) {
3031

3132
setupLongTap();
3233
setupFocusBeforeCapture();
34+
setupSound();
3335
setupForceRatio();
3436
setupMaxResolution();
3537
}
@@ -42,6 +44,10 @@ private void setupFocusBeforeCapture() {
4244
mFocusBeforeCaptureSwitch.setChecked(mConfig.getFocusBeforeCaptureEnabled());
4345
}
4446

47+
private void setupSound() {
48+
mSoundSwitch.setChecked(mConfig.getIsSoundEnabled());
49+
}
50+
4551
private void setupForceRatio() {
4652
mForceRatioSwitch.setChecked(mConfig.getForceRatioEnabled());
4753
}
@@ -62,6 +68,12 @@ public void handleFocusBeforeCapture() {
6268
mConfig.setFocusBeforeCaptureEnabled(mFocusBeforeCaptureSwitch.isChecked());
6369
}
6470

71+
@OnClick(R.id.settings_sound_holder)
72+
public void handleSound() {
73+
mSoundSwitch.setChecked(!mSoundSwitch.isChecked());
74+
mConfig.setIsSoundEnabled(mSoundSwitch.isChecked());
75+
}
76+
6577
@OnClick(R.id.settings_force_ratio_holder)
6678
public void handleForceRatio() {
6779
mForceRatioSwitch.setChecked(!mForceRatioSwitch.isChecked());

app/src/main/res/layout/activity_settings.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,32 @@
5858

5959
</RelativeLayout>
6060

61+
<RelativeLayout
62+
android:id="@+id/settings_sound_holder"
63+
android:layout_width="match_parent"
64+
android:layout_height="wrap_content"
65+
android:layout_marginTop="@dimen/settings_padding"
66+
android:background="?android:attr/selectableItemBackground"
67+
android:padding="@dimen/activity_margin">
68+
69+
<TextView
70+
android:id="@+id/settings_sound_label"
71+
android:layout_width="wrap_content"
72+
android:layout_height="wrap_content"
73+
android:layout_centerVertical="true"
74+
android:paddingLeft="@dimen/settings_padding"
75+
android:text="@string/shutter_sound"/>
76+
77+
<android.support.v7.widget.SwitchCompat
78+
android:id="@+id/settings_sound"
79+
android:layout_width="wrap_content"
80+
android:layout_height="wrap_content"
81+
android:layout_alignParentRight="true"
82+
android:background="@null"
83+
android:clickable="false"/>
84+
85+
</RelativeLayout>
86+
6187
<RelativeLayout
6288
android:id="@+id/settings_force_ratio_holder"
6389
android:layout_width="match_parent"

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<string name="force_ratio">Force 16:9 ratio</string>
2020
<string name="max_size">Photo resolution limit</string>
2121
<string name="no_limit">none</string>
22+
<string name="shutter_sound">Shutter sound</string>
2223

2324
<!-- About -->
2425
<string name="about">About</string>

0 commit comments

Comments
 (0)