add a Setting for forcing 16:9 ratio

This commit is contained in:
tibbi 2016-06-29 13:53:18 +02:00
parent 0fec754659
commit ac77afd80c
5 changed files with 48 additions and 0 deletions

View File

@ -29,4 +29,12 @@ public class Config {
public void setFocusBeforeCaptureEnabled(boolean enabled) {
mPrefs.edit().putBoolean(Constants.FOCUS_BEFORE_CAPTURE, enabled).apply();
}
public boolean getForceRatioEnabled() {
return mPrefs.getBoolean(Constants.FORCE_RATIO, true);
}
public void setForceRatioEnabled(boolean enabled) {
mPrefs.edit().putBoolean(Constants.FORCE_RATIO, enabled).apply();
}
}

View File

@ -9,4 +9,5 @@ public class Constants {
public static final String PREFS_KEY = "Camera";
public static final String LONG_TAP = "long_tap";
public static final String FOCUS_BEFORE_CAPTURE = "focus_before_capture";
public static final String FORCE_RATIO = "force_ratio";
}

View File

@ -14,6 +14,7 @@ import butterknife.OnClick;
public class SettingsActivity extends AppCompatActivity {
@BindView(R.id.settings_long_tap) SwitchCompat mLongTapSwitch;
@BindView(R.id.settings_focus_before_capture) SwitchCompat mFocusBeforeCaptureSwitch;
@BindView(R.id.settings_force_ratio) SwitchCompat mForceRatioSwitch;
private static Config mConfig;
@ -26,6 +27,7 @@ public class SettingsActivity extends AppCompatActivity {
setupLongTap();
setupFocusBeforeCapture();
setupForceRatio();
}
private void setupLongTap() {
@ -36,6 +38,10 @@ public class SettingsActivity extends AppCompatActivity {
mFocusBeforeCaptureSwitch.setChecked(mConfig.getFocusBeforeCaptureEnabled());
}
private void setupForceRatio() {
mForceRatioSwitch.setChecked(mConfig.getForceRatioEnabled());
}
@OnClick(R.id.settings_long_tap_holder)
public void handleLongTapToTrigger() {
mLongTapSwitch.setChecked(!mLongTapSwitch.isChecked());
@ -47,4 +53,10 @@ public class SettingsActivity extends AppCompatActivity {
mFocusBeforeCaptureSwitch.setChecked(!mFocusBeforeCaptureSwitch.isChecked());
mConfig.setFocusBeforeCaptureEnabled(mFocusBeforeCaptureSwitch.isChecked());
}
@OnClick(R.id.settings_force_ratio_holder)
public void handleForceRatio() {
mForceRatioSwitch.setChecked(!mForceRatioSwitch.isChecked());
mConfig.setForceRatioEnabled(mForceRatioSwitch.isChecked());
}
}

View File

@ -57,4 +57,30 @@
android:clickable="false"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_force_ratio_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_force_ratio_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="@dimen/settings_padding"
android:text="@string/force_ratio"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/settings_force_ratio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@null"
android:clickable="false"/>
</RelativeLayout>
</LinearLayout>

View File

@ -16,6 +16,7 @@
<string name="settings">Settings</string>
<string name="long_tap_capture">Long tap to capture</string>
<string name="focus_before_capture">Refocus before capture</string>
<string name="force_ratio">Force 16:9 ratio</string>
<!-- About -->
<string name="about">About</string>