mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-01-22 11:29:59 +01:00
allow disabling the Long tap tp capture feature
This commit is contained in:
parent
68e7a8de1e
commit
4fdfa9b157
24
app/src/main/java/com/simplemobiletools/camera/Config.java
Normal file
24
app/src/main/java/com/simplemobiletools/camera/Config.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.simplemobiletools.camera;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
public class Config {
|
||||
private SharedPreferences prefs;
|
||||
|
||||
public static Config newInstance(Context context) {
|
||||
return new Config(context);
|
||||
}
|
||||
|
||||
public Config(Context context) {
|
||||
prefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public boolean getLongTapEnabled() {
|
||||
return prefs.getBoolean(Constants.LONG_TAP, true);
|
||||
}
|
||||
|
||||
public void setLongTapEnabled(boolean enabled) {
|
||||
prefs.edit().putBoolean(Constants.LONG_TAP, enabled).apply();
|
||||
}
|
||||
}
|
@ -4,4 +4,8 @@ public class Constants {
|
||||
public static final int ORIENT_PORTRAIT = 0;
|
||||
public static final int ORIENT_LANDSCAPE_LEFT = 1;
|
||||
public static final int ORIENT_LANDSCAPE_RIGHT = 2;
|
||||
|
||||
// Shared preferences
|
||||
public static final String PREFS_KEY = "Camera";
|
||||
public static final String LONG_TAP = "long_tap";
|
||||
}
|
||||
|
@ -72,7 +72,6 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
||||
canTakePicture = false;
|
||||
surfaceView.setOnTouchListener(this);
|
||||
surfaceView.setOnClickListener(this);
|
||||
surfaceView.setOnLongClickListener(this);
|
||||
isFlashEnabled = false;
|
||||
isVideoMode = false;
|
||||
isSurfaceCreated = false;
|
||||
@ -143,6 +142,9 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
||||
initRecorder();
|
||||
}
|
||||
|
||||
final boolean isLongTapEnabled = Config.newInstance(getContext()).getLongTapEnabled();
|
||||
surfaceView.setOnLongClickListener(isLongTapEnabled ? this : null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,33 @@ package com.simplemobiletools.camera;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
@BindView(R.id.settings_long_tap) SwitchCompat longTapSwitch;
|
||||
|
||||
private static Config mConfig;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_settings);
|
||||
mConfig = Config.newInstance(getApplicationContext());
|
||||
ButterKnife.bind(this);
|
||||
setupLongTap();
|
||||
}
|
||||
|
||||
private void setupLongTap() {
|
||||
longTapSwitch.setChecked(mConfig.getLongTapEnabled());
|
||||
}
|
||||
|
||||
@OnClick(R.id.settings_long_tap_holder)
|
||||
public void handleLongTapToTrigger() {
|
||||
longTapSwitch.setChecked(!longTapSwitch.isChecked());
|
||||
mConfig.setLongTapEnabled(longTapSwitch.isChecked());
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,31 @@
|
||||
android:id="@+id/settings_holder"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/activity_margin">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_long_tap_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_long_tap_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="@dimen/settings_padding"
|
||||
android:text="@string/long_tap_capture"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/settings_long_tap"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@null"
|
||||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
@ -3,4 +3,5 @@
|
||||
<dimen name="preview_btn_margin">32dp</dimen>
|
||||
<dimen name="side_icon_padding">12dp</dimen>
|
||||
<dimen name="icon_size">56dp</dimen>
|
||||
<dimen name="settings_padding">8dp</dimen>
|
||||
</resources>
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Settings</string>
|
||||
<string name="long_tap_capture">Long tap to capture</string>
|
||||
|
||||
<!-- About -->
|
||||
<string name="about">About</string>
|
||||
|
Loading…
Reference in New Issue
Block a user