remove the "Long tap to activate shutter" feature

This commit is contained in:
tibbi 2016-08-26 22:56:49 +02:00
parent e27b2bfd38
commit 2a11b98a17
11 changed files with 16 additions and 81 deletions

View File

@ -30,14 +30,6 @@ public class Config {
mPrefs.edit().putBoolean(Constants.IS_DARK_THEME, isDarkTheme).apply(); mPrefs.edit().putBoolean(Constants.IS_DARK_THEME, isDarkTheme).apply();
} }
public boolean getLongTapEnabled() {
return mPrefs.getBoolean(Constants.LONG_TAP, true);
}
public void setLongTapEnabled(boolean enabled) {
mPrefs.edit().putBoolean(Constants.LONG_TAP, enabled).apply();
}
public boolean getFocusBeforeCaptureEnabled() { public boolean getFocusBeforeCaptureEnabled() {
return mPrefs.getBoolean(Constants.FOCUS_BEFORE_CAPTURE, false); return mPrefs.getBoolean(Constants.FOCUS_BEFORE_CAPTURE, false);
} }

View File

@ -9,7 +9,6 @@ public class Constants {
public static final String PREFS_KEY = "Camera"; public static final String PREFS_KEY = "Camera";
public static final String IS_FIRST_RUN = "is_first_run"; public static final String IS_FIRST_RUN = "is_first_run";
public static final String IS_DARK_THEME = "is_dark_theme"; public static final String IS_DARK_THEME = "is_dark_theme";
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 SOUND = "sound";
public static final String FORCE_RATIO = "force_ratio"; public static final String FORCE_RATIO = "force_ratio";

View File

@ -16,7 +16,6 @@ import android.view.Surface;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import android.view.SurfaceView; import android.view.SurfaceView;
import android.view.View; import android.view.View;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.simplemobiletools.camera.activities.MainActivity; import com.simplemobiletools.camera.activities.MainActivity;
@ -29,8 +28,8 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.OnTouchListener, OnLongClickListener, View.OnClickListener, public class Preview extends ViewGroup
MediaScannerConnection.OnScanCompletedListener { implements SurfaceHolder.Callback, View.OnTouchListener, View.OnClickListener, MediaScannerConnection.OnScanCompletedListener {
private static final String TAG = Preview.class.getSimpleName(); private static final String TAG = Preview.class.getSimpleName();
private static final int FOCUS_AREA_SIZE = 100; private static final int FOCUS_AREA_SIZE = 100;
private static final int PHOTO_PREVIEW_LENGTH = 1000; private static final int PHOTO_PREVIEW_LENGTH = 1000;
@ -48,6 +47,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
private static String mCurVideoPath; private static String mCurVideoPath;
private static Point mScreenSize; private static Point mScreenSize;
private static Uri mTargetUri; private static Uri mTargetUri;
private static Context mContext;
private static boolean mCanTakePicture; private static boolean mCanTakePicture;
private static boolean mIsFlashEnabled; private static boolean mIsFlashEnabled;
@ -85,6 +85,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
mSetupPreviewAfterMeasure = false; mSetupPreviewAfterMeasure = false;
mCurVideoPath = ""; mCurVideoPath = "";
mScreenSize = Utils.getScreenSize(mActivity); mScreenSize = Utils.getScreenSize(mActivity);
mContext = getContext();
} }
public void trySwitchToVideo() { public void trySwitchToVideo() {
@ -102,7 +103,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
newCamera = Camera.open(cameraId); newCamera = Camera.open(cameraId);
mCallback.setIsCameraAvailable(true); mCallback.setIsCameraAvailable(true);
} catch (Exception e) { } catch (Exception e) {
Utils.showToast(getContext(), R.string.camera_open_error); Utils.showToast(mContext, R.string.camera_open_error);
Log.e(TAG, "setCamera open " + e.getMessage()); Log.e(TAG, "setCamera open " + e.getMessage());
mCallback.setIsCameraAvailable(false); mCallback.setIsCameraAvailable(false);
return false; return false;
@ -146,10 +147,9 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
initRecorder(); initRecorder();
} }
final Config config = Config.newInstance(getContext()); final Config config = Config.newInstance(mContext);
mFocusBeforeCapture = config.getFocusBeforeCaptureEnabled(); mFocusBeforeCapture = config.getFocusBeforeCaptureEnabled();
mForceAspectRatio = config.getForceRatioEnabled(); mForceAspectRatio = config.getForceRatioEnabled();
mSurfaceView.setOnLongClickListener(config.getLongTapEnabled() ? this : null);
return true; return true;
} }
@ -222,7 +222,7 @@ 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);
if (Config.newInstance(getContext()).getIsSoundEnabled()) { if (Config.newInstance(mContext).getIsSoundEnabled()) {
new MediaActionSound().play(MediaActionSound.SHUTTER_CLICK); new MediaActionSound().play(MediaActionSound.SHUTTER_CLICK);
} }
@ -276,7 +276,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
} }
private int getMaxPhotoResolution() { private int getMaxPhotoResolution() {
final int maxRes = Config.newInstance(getContext()).getMaxPhotoResolution(); final int maxRes = Config.newInstance(mContext).getMaxPhotoResolution();
switch (maxRes) { switch (maxRes) {
case 0: case 0:
return 6000000; return 6000000;
@ -292,7 +292,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
} }
private int getMaxVideoResolution() { private int getMaxVideoResolution() {
final int maxRes = Config.newInstance(getContext()).getMaxVideoResolution(); final int maxRes = Config.newInstance(mContext).getMaxVideoResolution();
switch (maxRes) { switch (maxRes) {
case 0: case 0:
return 400000; return 400000;
@ -330,7 +330,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
} }
if (i == cnt - 1) { if (i == cnt - 1) {
Utils.showToast(getContext(), R.string.no_valid_resolution_found); Utils.showToast(mContext, R.string.no_valid_resolution_found);
} }
} }
return maxSize; return maxSize;
@ -601,9 +601,9 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
mRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT); mRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
mRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT); mRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mCurVideoPath = Utils.getOutputMediaFile(getContext(), false); mCurVideoPath = Utils.getOutputMediaFile(mContext, false);
if (mCurVideoPath.isEmpty()) { if (mCurVideoPath.isEmpty()) {
Utils.showToast(getContext(), R.string.video_creating_error); Utils.showToast(mContext, R.string.video_creating_error);
return false; return false;
} }
@ -622,7 +622,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
try { try {
mRecorder.prepare(); mRecorder.prepare();
} catch (Exception e) { } catch (Exception e) {
Utils.showToast(getContext(), R.string.video_setup_error); Utils.showToast(mContext, R.string.video_setup_error);
Log.e(TAG, "initRecorder " + e.getMessage()); Log.e(TAG, "initRecorder " + e.getMessage());
releaseCamera(); releaseCamera();
return false; return false;
@ -651,7 +651,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
mRecorder.start(); mRecorder.start();
mIsRecording = true; mIsRecording = true;
} catch (Exception e) { } catch (Exception e) {
Utils.showToast(getContext(), R.string.video_setup_error); Utils.showToast(mContext, R.string.video_setup_error);
Log.e(TAG, "toggleRecording " + e.getMessage()); Log.e(TAG, "toggleRecording " + e.getMessage());
releaseCamera(); releaseCamera();
} }
@ -662,10 +662,10 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
try { try {
mRecorder.stop(); mRecorder.stop();
final String[] paths = {mCurVideoPath}; final String[] paths = {mCurVideoPath};
MediaScannerConnection.scanFile(getContext(), paths, null, this); MediaScannerConnection.scanFile(mContext, paths, null, this);
} catch (RuntimeException e) { } catch (RuntimeException e) {
new File(mCurVideoPath).delete(); new File(mCurVideoPath).delete();
Utils.showToast(getContext(), R.string.video_saving_error); Utils.showToast(mContext, R.string.video_saving_error);
Log.e(TAG, "stopRecording " + e.getMessage()); Log.e(TAG, "stopRecording " + e.getMessage());
mRecorder = null; mRecorder = null;
mIsRecording = false; mIsRecording = false;
@ -682,12 +682,6 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
} }
} }
@Override
public boolean onLongClick(View v) {
mCallback.activateShutter();
return true;
}
@Override @Override
public void onClick(View v) { public void onClick(View v) {
focusArea(false); focusArea(false);
@ -712,8 +706,6 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
void setIsCameraAvailable(boolean available); void setIsCameraAvailable(boolean available);
void activateShutter();
int getCurrentOrientation(); int getCurrentOrientation();
void videoSaved(Uri uri); void videoSaved(Uri uri);

View File

@ -590,11 +590,6 @@ public class MainActivity extends SimpleActivity
mIsCameraAvailable = available; mIsCameraAvailable = available;
} }
@Override
public void activateShutter() {
handleShutter();
}
@Override @Override
public int getCurrentOrientation() { public int getCurrentOrientation() {
return mOrientation; return mOrientation;

View File

@ -18,7 +18,6 @@ import butterknife.OnItemSelected;
public class SettingsActivity extends SimpleActivity { public class SettingsActivity extends SimpleActivity {
@BindView(R.id.settings_dark_theme) SwitchCompat mDarkThemeSwitch; @BindView(R.id.settings_dark_theme) SwitchCompat mDarkThemeSwitch;
@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_sound) SwitchCompat mSoundSwitch;
@BindView(R.id.settings_force_ratio) SwitchCompat mForceRatioSwitch; @BindView(R.id.settings_force_ratio) SwitchCompat mForceRatioSwitch;
@ -35,7 +34,6 @@ public class SettingsActivity extends SimpleActivity {
ButterKnife.bind(this); ButterKnife.bind(this);
setupDarkTheme(); setupDarkTheme();
setupLongTap();
setupFocusBeforeCapture(); setupFocusBeforeCapture();
setupSound(); setupSound();
setupForceRatio(); setupForceRatio();
@ -65,10 +63,6 @@ public class SettingsActivity extends SimpleActivity {
mDarkThemeSwitch.setChecked(mConfig.getIsDarkTheme()); mDarkThemeSwitch.setChecked(mConfig.getIsDarkTheme());
} }
private void setupLongTap() {
mLongTapSwitch.setChecked(mConfig.getLongTapEnabled());
}
private void setupFocusBeforeCapture() { private void setupFocusBeforeCapture() {
mFocusBeforeCaptureSwitch.setChecked(mConfig.getFocusBeforeCaptureEnabled()); mFocusBeforeCaptureSwitch.setChecked(mConfig.getFocusBeforeCaptureEnabled());
} }
@ -96,12 +90,6 @@ public class SettingsActivity extends SimpleActivity {
restartActivity(); restartActivity();
} }
@OnClick(R.id.settings_long_tap_holder)
public void handleLongTapToTrigger() {
mLongTapSwitch.setChecked(!mLongTapSwitch.isChecked());
mConfig.setLongTapEnabled(mLongTapSwitch.isChecked());
}
@OnClick(R.id.settings_focus_before_capture_holder) @OnClick(R.id.settings_focus_before_capture_holder)
public void handleFocusBeforeCapture() { public void handleFocusBeforeCapture() {
mFocusBeforeCaptureSwitch.setChecked(!mFocusBeforeCaptureSwitch.isChecked()); mFocusBeforeCaptureSwitch.setChecked(!mFocusBeforeCaptureSwitch.isChecked());

View File

@ -38,32 +38,6 @@
</RelativeLayout> </RelativeLayout>
<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 <RelativeLayout
android:id="@+id/settings_focus_before_capture_holder" android:id="@+id/settings_focus_before_capture_holder"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -18,7 +18,6 @@
<!-- Settings --> <!-- Settings -->
<string name="settings">Impostazioni</string> <string name="settings">Impostazioni</string>
<string name="dark_theme">Tema scuro</string> <string name="dark_theme">Tema scuro</string>
<string name="long_tap_capture">Tocco prolungato per la cattura</string>
<string name="focus_before_capture">Messa a fuoco prima della cattura</string> <string name="focus_before_capture">Messa a fuoco prima della cattura</string>
<string name="force_ratio">Forza proporzione 16:9</string> <string name="force_ratio">Forza proporzione 16:9</string>
<string name="max_photo_size">Limite risoluzione foto</string> <string name="max_photo_size">Limite risoluzione foto</string>

View File

@ -18,7 +18,6 @@
<!-- Settings --> <!-- Settings -->
<string name="settings">設定</string> <string name="settings">設定</string>
<string name="dark_theme">ダークテーマ</string> <string name="dark_theme">ダークテーマ</string>
<string name="long_tap_capture">長押ししてキャプチャする</string>
<string name="focus_before_capture">キャプチャ前に再度焦点を合わせる</string> <string name="focus_before_capture">キャプチャ前に再度焦点を合わせる</string>
<string name="force_ratio">強制的に 16:9 レシオにする</string> <string name="force_ratio">強制的に 16:9 レシオにする</string>
<string name="max_photo_size">写真解像度の限度</string> <string name="max_photo_size">写真解像度の限度</string>

View File

@ -18,7 +18,6 @@
<!-- Settings --> <!-- Settings -->
<string name="settings">Настройки</string> <string name="settings">Настройки</string>
<string name="dark_theme">темная тема</string> <string name="dark_theme">темная тема</string>
<string name="long_tap_capture">Длинное нажатие для захвата</string>
<string name="focus_before_capture">Перефокусировка перед захватом</string> <string name="focus_before_capture">Перефокусировка перед захватом</string>
<string name="force_ratio">Принудительное соотношение сторон 16:9</string> <string name="force_ratio">Принудительное соотношение сторон 16:9</string>
<string name="max_photo_size">Лимит разрешения фото</string> <string name="max_photo_size">Лимит разрешения фото</string>

View File

@ -18,7 +18,6 @@
<!-- Settings --> <!-- Settings -->
<string name="settings">Inställningar</string> <string name="settings">Inställningar</string>
<string name="dark_theme">Mörkt tema</string> <string name="dark_theme">Mörkt tema</string>
<string name="long_tap_capture">Långtryck för bildtagning</string>
<string name="focus_before_capture">Fokusera om innan bildtagning</string> <string name="focus_before_capture">Fokusera om innan bildtagning</string>
<string name="force_ratio">Tvinga 16:9-förhållande</string> <string name="force_ratio">Tvinga 16:9-förhållande</string>
<string name="max_photo_size">Bildupplösningsgräns</string> <string name="max_photo_size">Bildupplösningsgräns</string>

View File

@ -18,7 +18,6 @@
<!-- Settings --> <!-- Settings -->
<string name="settings">Settings</string> <string name="settings">Settings</string>
<string name="dark_theme">Dark theme</string> <string name="dark_theme">Dark theme</string>
<string name="long_tap_capture">Long tap to capture</string>
<string name="focus_before_capture">Refocus before capture</string> <string name="focus_before_capture">Refocus before capture</string>
<string name="force_ratio">Force 16:9 ratio</string> <string name="force_ratio">Force 16:9 ratio</string>
<string name="max_photo_size">Photo resolution limit</string> <string name="max_photo_size">Photo resolution limit</string>