mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-06-27 09:02:59 +02:00
make Focus Before Capture optional, disabled by default
This commit is contained in:
@ -21,4 +21,12 @@ public class Config {
|
|||||||
public void setLongTapEnabled(boolean enabled) {
|
public void setLongTapEnabled(boolean enabled) {
|
||||||
prefs.edit().putBoolean(Constants.LONG_TAP, enabled).apply();
|
prefs.edit().putBoolean(Constants.LONG_TAP, enabled).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getFocusBeforeCaptureEnabled() {
|
||||||
|
return prefs.getBoolean(Constants.FOCUS_BEFORE_CAPTURE, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFocusBeforeCaptureEnabled(boolean enabled) {
|
||||||
|
prefs.edit().putBoolean(Constants.FOCUS_BEFORE_CAPTURE, enabled).apply();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,4 +8,5 @@ public class Constants {
|
|||||||
// Shared preferences
|
// Shared preferences
|
||||||
public static final String PREFS_KEY = "Camera";
|
public static final String PREFS_KEY = "Camera";
|
||||||
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";
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
|||||||
private static boolean isSurfaceCreated;
|
private static boolean isSurfaceCreated;
|
||||||
private static boolean switchToVideoAsap;
|
private static boolean switchToVideoAsap;
|
||||||
private static boolean isVideoCaptureIntent;
|
private static boolean isVideoCaptureIntent;
|
||||||
|
private static boolean focusBeforeCapture;
|
||||||
private boolean setupPreviewAfterMeasure;
|
private boolean setupPreviewAfterMeasure;
|
||||||
private static String curVideoPath;
|
private static String curVideoPath;
|
||||||
private static int lastClickX;
|
private static int lastClickX;
|
||||||
@ -145,6 +146,8 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
|||||||
final boolean isLongTapEnabled = Config.newInstance(getContext()).getLongTapEnabled();
|
final boolean isLongTapEnabled = Config.newInstance(getContext()).getLongTapEnabled();
|
||||||
surfaceView.setOnLongClickListener(isLongTapEnabled ? this : null);
|
surfaceView.setOnLongClickListener(isLongTapEnabled ? this : null);
|
||||||
|
|
||||||
|
focusBeforeCapture = Config.newInstance(getContext()).getFocusBeforeCaptureEnabled();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +197,11 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void tryTakePicture() {
|
public void tryTakePicture() {
|
||||||
|
if (focusBeforeCapture) {
|
||||||
focusArea(true);
|
focusArea(true);
|
||||||
|
} else {
|
||||||
|
takePicture();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void takePicture() {
|
private void takePicture() {
|
||||||
|
@ -10,6 +10,7 @@ import butterknife.OnClick;
|
|||||||
|
|
||||||
public class SettingsActivity extends AppCompatActivity {
|
public class SettingsActivity extends AppCompatActivity {
|
||||||
@BindView(R.id.settings_long_tap) SwitchCompat longTapSwitch;
|
@BindView(R.id.settings_long_tap) SwitchCompat longTapSwitch;
|
||||||
|
@BindView(R.id.settings_focus_before_capture) SwitchCompat focusBeforeCaptureSwitch;
|
||||||
|
|
||||||
private static Config mConfig;
|
private static Config mConfig;
|
||||||
|
|
||||||
@ -19,16 +20,28 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
setContentView(R.layout.activity_settings);
|
setContentView(R.layout.activity_settings);
|
||||||
mConfig = Config.newInstance(getApplicationContext());
|
mConfig = Config.newInstance(getApplicationContext());
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
setupLongTap();
|
setupLongTap();
|
||||||
|
setupFocusBeforeCapture();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupLongTap() {
|
private void setupLongTap() {
|
||||||
longTapSwitch.setChecked(mConfig.getLongTapEnabled());
|
longTapSwitch.setChecked(mConfig.getLongTapEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupFocusBeforeCapture() {
|
||||||
|
focusBeforeCaptureSwitch.setChecked(mConfig.getFocusBeforeCaptureEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
@OnClick(R.id.settings_long_tap_holder)
|
@OnClick(R.id.settings_long_tap_holder)
|
||||||
public void handleLongTapToTrigger() {
|
public void handleLongTapToTrigger() {
|
||||||
longTapSwitch.setChecked(!longTapSwitch.isChecked());
|
longTapSwitch.setChecked(!longTapSwitch.isChecked());
|
||||||
mConfig.setLongTapEnabled(longTapSwitch.isChecked());
|
mConfig.setLongTapEnabled(longTapSwitch.isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.settings_focus_before_capture_holder)
|
||||||
|
public void handleFocusBeforeCapture() {
|
||||||
|
focusBeforeCaptureSwitch.setChecked(!focusBeforeCaptureSwitch.isChecked());
|
||||||
|
mConfig.setFocusBeforeCaptureEnabled(focusBeforeCaptureSwitch.isChecked());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
android:id="@+id/settings_holder"
|
android:id="@+id/settings_holder"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/settings_long_tap_holder"
|
android:id="@+id/settings_long_tap_holder"
|
||||||
@ -30,4 +31,30 @@
|
|||||||
android:clickable="false"/>
|
android:clickable="false"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/settings_focus_before_capture_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_focus_before_capture_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:paddingLeft="@dimen/settings_padding"
|
||||||
|
android:text="@string/focus_before_capture"/>
|
||||||
|
|
||||||
|
<android.support.v7.widget.SwitchCompat
|
||||||
|
android:id="@+id/settings_focus_before_capture"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:background="@null"
|
||||||
|
android:clickable="false"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="settings">Settings</string>
|
<string name="settings">Settings</string>
|
||||||
<string name="long_tap_capture">Long tap to capture</string>
|
<string name="long_tap_capture">Long tap to capture</string>
|
||||||
|
<string name="focus_before_capture">Focus before capture</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
|
Reference in New Issue
Block a user