add the option to disable Shutter sound
This commit is contained in:
parent
17b771a649
commit
b33ecdcc20
|
@ -53,4 +53,12 @@ public class Config {
|
||||||
public void setMaxResolution(int maxRes) {
|
public void setMaxResolution(int maxRes) {
|
||||||
mPrefs.edit().putInt(Constants.MAX_RESOLUTION, maxRes).apply();
|
mPrefs.edit().putInt(Constants.MAX_RESOLUTION, maxRes).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getIsSoundEnabled() {
|
||||||
|
return mPrefs.getBoolean(Constants.SOUND, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsSoundEnabled(boolean enabled) {
|
||||||
|
mPrefs.edit().putBoolean(Constants.SOUND, enabled).apply();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ public class Constants {
|
||||||
public static final String IS_FIRST_RUN = "is_first_run";
|
public static final String IS_FIRST_RUN = "is_first_run";
|
||||||
public static final String LONG_TAP = "long_tap";
|
public static final String LONG_TAP = "long_tap";
|
||||||
public static final String FOCUS_BEFORE_CAPTURE = "focus_before_capture";
|
public static final String FOCUS_BEFORE_CAPTURE = "focus_before_capture";
|
||||||
|
public static final String SOUND = "sound";
|
||||||
public static final String FORCE_RATIO = "force_ratio";
|
public static final String FORCE_RATIO = "force_ratio";
|
||||||
public static final String MAX_RESOLUTION = "max_resolution";
|
public static final String MAX_RESOLUTION = "max_resolution";
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,9 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
||||||
mParameters.setPictureSize(maxSize.width, maxSize.height);
|
mParameters.setPictureSize(maxSize.width, maxSize.height);
|
||||||
mParameters.setRotation(rotation % 360);
|
mParameters.setRotation(rotation % 360);
|
||||||
|
|
||||||
MediaPlayer.create(getContext(), R.raw.camera_shutter).start();
|
if (Config.newInstance(getContext()).getIsSoundEnabled())
|
||||||
|
MediaPlayer.create(getContext(), R.raw.camera_shutter).start();
|
||||||
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||||
mCamera.enableShutterSound(false);
|
mCamera.enableShutterSound(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import butterknife.OnItemSelected;
|
||||||
public class SettingsActivity extends AppCompatActivity {
|
public class SettingsActivity extends AppCompatActivity {
|
||||||
@BindView(R.id.settings_long_tap) SwitchCompat mLongTapSwitch;
|
@BindView(R.id.settings_long_tap) SwitchCompat mLongTapSwitch;
|
||||||
@BindView(R.id.settings_focus_before_capture) SwitchCompat mFocusBeforeCaptureSwitch;
|
@BindView(R.id.settings_focus_before_capture) SwitchCompat mFocusBeforeCaptureSwitch;
|
||||||
|
@BindView(R.id.settings_sound) SwitchCompat mSoundSwitch;
|
||||||
@BindView(R.id.settings_force_ratio) SwitchCompat mForceRatioSwitch;
|
@BindView(R.id.settings_force_ratio) SwitchCompat mForceRatioSwitch;
|
||||||
@BindView(R.id.settings_max_resolution) AppCompatSpinner mMaxResolutionSpinner;
|
@BindView(R.id.settings_max_resolution) AppCompatSpinner mMaxResolutionSpinner;
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
setupLongTap();
|
setupLongTap();
|
||||||
setupFocusBeforeCapture();
|
setupFocusBeforeCapture();
|
||||||
|
setupSound();
|
||||||
setupForceRatio();
|
setupForceRatio();
|
||||||
setupMaxResolution();
|
setupMaxResolution();
|
||||||
}
|
}
|
||||||
|
@ -42,6 +44,10 @@ public class SettingsActivity extends AppCompatActivity {
|
||||||
mFocusBeforeCaptureSwitch.setChecked(mConfig.getFocusBeforeCaptureEnabled());
|
mFocusBeforeCaptureSwitch.setChecked(mConfig.getFocusBeforeCaptureEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupSound() {
|
||||||
|
mSoundSwitch.setChecked(mConfig.getIsSoundEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
private void setupForceRatio() {
|
private void setupForceRatio() {
|
||||||
mForceRatioSwitch.setChecked(mConfig.getForceRatioEnabled());
|
mForceRatioSwitch.setChecked(mConfig.getForceRatioEnabled());
|
||||||
}
|
}
|
||||||
|
@ -62,6 +68,12 @@ public class SettingsActivity extends AppCompatActivity {
|
||||||
mConfig.setFocusBeforeCaptureEnabled(mFocusBeforeCaptureSwitch.isChecked());
|
mConfig.setFocusBeforeCaptureEnabled(mFocusBeforeCaptureSwitch.isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.settings_sound_holder)
|
||||||
|
public void handleSound() {
|
||||||
|
mSoundSwitch.setChecked(!mSoundSwitch.isChecked());
|
||||||
|
mConfig.setIsSoundEnabled(mSoundSwitch.isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
@OnClick(R.id.settings_force_ratio_holder)
|
@OnClick(R.id.settings_force_ratio_holder)
|
||||||
public void handleForceRatio() {
|
public void handleForceRatio() {
|
||||||
mForceRatioSwitch.setChecked(!mForceRatioSwitch.isChecked());
|
mForceRatioSwitch.setChecked(!mForceRatioSwitch.isChecked());
|
||||||
|
|
|
@ -58,6 +58,32 @@
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/settings_sound_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/settings_padding"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:padding="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/settings_sound_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:paddingLeft="@dimen/settings_padding"
|
||||||
|
android:text="@string/shutter_sound"/>
|
||||||
|
|
||||||
|
<android.support.v7.widget.SwitchCompat
|
||||||
|
android:id="@+id/settings_sound"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:background="@null"
|
||||||
|
android:clickable="false"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/settings_force_ratio_holder"
|
android:id="@+id/settings_force_ratio_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
<string name="force_ratio">Force 16:9 ratio</string>
|
<string name="force_ratio">Force 16:9 ratio</string>
|
||||||
<string name="max_size">Photo resolution limit</string>
|
<string name="max_size">Photo resolution limit</string>
|
||||||
<string name="no_limit">none</string>
|
<string name="no_limit">none</string>
|
||||||
|
<string name="shutter_sound">Shutter sound</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
|
|
Loading…
Reference in New Issue