mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-04-25 12:38:46 +02:00
recognize the hardware shutter button
This commit is contained in:
parent
8f4ec64521
commit
7bf72858be
@ -15,6 +15,7 @@ import android.os.Handler;
|
|||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -52,6 +53,7 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
|
|||||||
private boolean isCameraAvailable;
|
private boolean isCameraAvailable;
|
||||||
private boolean isImageCaptureIntent;
|
private boolean isImageCaptureIntent;
|
||||||
private boolean isVideoCaptureIntent;
|
private boolean isVideoCaptureIntent;
|
||||||
|
private boolean isHardwareShutterHandled;
|
||||||
private int currVideoRecTimer;
|
private int currVideoRecTimer;
|
||||||
private int orientation;
|
private int orientation;
|
||||||
private int currCamera;
|
private int currCamera;
|
||||||
@ -65,6 +67,25 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
|
|||||||
tryInitCamera();
|
tryInitCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_CAMERA && !isHardwareShutterHandled) {
|
||||||
|
isHardwareShutterHandled = true;
|
||||||
|
shutterPressed();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return super.onKeyDown(keyCode, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_CAMERA) {
|
||||||
|
isHardwareShutterHandled = false;
|
||||||
|
}
|
||||||
|
return super.onKeyUp(keyCode, event);
|
||||||
|
}
|
||||||
|
|
||||||
private void hideToggleModeAbout() {
|
private void hideToggleModeAbout() {
|
||||||
if (togglePhotoVideoBtn != null)
|
if (togglePhotoVideoBtn != null)
|
||||||
togglePhotoVideoBtn.setVisibility(View.GONE);
|
togglePhotoVideoBtn.setVisibility(View.GONE);
|
||||||
@ -201,7 +222,11 @@ public class MainActivity extends AppCompatActivity implements SensorEventListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.shutter)
|
@OnClick(R.id.shutter)
|
||||||
public void shutterPressed() {
|
public void handleShutterPressed() {
|
||||||
|
shutterPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shutterPressed() {
|
||||||
if (!checkCameraAvailable()) {
|
if (!checkCameraAvailable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user