|
|
@ -8,6 +8,7 @@ import android.graphics.Bitmap;
|
|
|
|
import android.graphics.BitmapFactory;
|
|
|
|
import android.graphics.BitmapFactory;
|
|
|
|
import android.graphics.ImageDecoder;
|
|
|
|
import android.graphics.ImageDecoder;
|
|
|
|
import android.media.midi.MidiDevice;
|
|
|
|
import android.media.midi.MidiDevice;
|
|
|
|
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Looper;
|
|
|
|
import android.os.Looper;
|
|
|
|
import android.os.Message;
|
|
|
|
import android.os.Message;
|
|
|
|
import android.os.SystemClock;
|
|
|
|
import android.os.SystemClock;
|
|
|
@ -52,6 +53,8 @@ import android.util.Size;
|
|
|
|
import android.util.SparseIntArray;
|
|
|
|
import android.util.SparseIntArray;
|
|
|
|
import android.view.Surface;
|
|
|
|
import android.view.Surface;
|
|
|
|
import android.view.TextureView;
|
|
|
|
import android.view.TextureView;
|
|
|
|
|
|
|
|
import android.view.Window;
|
|
|
|
|
|
|
|
import android.view.WindowManager;
|
|
|
|
import android.widget.Toast;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
import com.xypower.mpapp.MicroPhotoService;
|
|
|
|
import com.xypower.mpapp.MicroPhotoService;
|
|
|
@ -167,14 +170,38 @@ public class RawActivity extends AppCompatActivity {
|
|
|
|
private final TextureView.SurfaceTextureListener mSurfaceTextureListener
|
|
|
|
private final TextureView.SurfaceTextureListener mSurfaceTextureListener
|
|
|
|
= new TextureView.SurfaceTextureListener() {
|
|
|
|
= new TextureView.SurfaceTextureListener() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean mTaken = false;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onSurfaceTextureAvailable(SurfaceTexture texture, int width, int height) {
|
|
|
|
public void onSurfaceTextureAvailable(SurfaceTexture texture, int width, int height) {
|
|
|
|
configureTransform(width, height);
|
|
|
|
configureTransform(width, height);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!mTaken) {
|
|
|
|
|
|
|
|
mTaken = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mMessageHandler.postDelayed(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
takePicture();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, 400);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onSurfaceTextureSizeChanged(SurfaceTexture texture, int width, int height) {
|
|
|
|
public void onSurfaceTextureSizeChanged(SurfaceTexture texture, int width, int height) {
|
|
|
|
configureTransform(width, height);
|
|
|
|
configureTransform(width, height);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!mTaken) {
|
|
|
|
|
|
|
|
mTaken = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mMessageHandler.postDelayed(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
takePicture();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, 400);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -558,6 +585,23 @@ public class RawActivity extends AppCompatActivity {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Window win = getWindow();
|
|
|
|
|
|
|
|
int flags = /*WindowManager.LayoutParams.FLAG_FULLSCREEN
|
|
|
|
|
|
|
|
| */WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
|
|
|
|
|
|
|
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
|
|
|
|
|
|
|
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
|
|
|
|
|
|
|
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
|
|
|
|
|
|
|
|
int mask = /*WindowManager.LayoutParams.FLAG_FULLSCREEN |
|
|
|
|
|
|
|
|
| */WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
|
|
|
|
|
|
|
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
|
|
|
|
|
|
|
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
|
|
|
|
|
|
|
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
|
|
|
|
|
|
|
|
win.setFlags(flags, mask);
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
|
|
|
|
|
|
|
setShowWhenLocked(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setContentView(R.layout.activity_raw);
|
|
|
|
setContentView(R.layout.activity_raw);
|
|
|
|
|
|
|
|
|
|
|
|
mTextureView = (AutoFitTextureView) findViewById(R.id.texture);
|
|
|
|
mTextureView = (AutoFitTextureView) findViewById(R.id.texture);
|
|
|
@ -590,12 +634,7 @@ public class RawActivity extends AppCompatActivity {
|
|
|
|
MicroPhotoService.infoLog("RawActivity created PHOTOID=" + Long.toString(mPhotoId));
|
|
|
|
MicroPhotoService.infoLog("RawActivity created PHOTOID=" + Long.toString(mPhotoId));
|
|
|
|
|
|
|
|
|
|
|
|
mTextureView.setAspectRatio(width, height);
|
|
|
|
mTextureView.setAspectRatio(width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onResume() {
|
|
|
|
|
|
|
|
super.onResume();
|
|
|
|
|
|
|
|
startBackgroundThread();
|
|
|
|
startBackgroundThread();
|
|
|
|
openCamera();
|
|
|
|
openCamera();
|
|
|
|
|
|
|
|
|
|
|
@ -605,28 +644,35 @@ public class RawActivity extends AppCompatActivity {
|
|
|
|
// the SurfaceTextureListener).
|
|
|
|
// the SurfaceTextureListener).
|
|
|
|
if (mTextureView.isAvailable()) {
|
|
|
|
if (mTextureView.isAvailable()) {
|
|
|
|
configureTransform(mTextureView.getWidth(), mTextureView.getHeight());
|
|
|
|
configureTransform(mTextureView.getWidth(), mTextureView.getHeight());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mMessageHandler.postDelayed(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
takePicture();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, 400);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);
|
|
|
|
mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mOrientationListener != null && mOrientationListener.canDetectOrientation()) {
|
|
|
|
if (mOrientationListener != null && mOrientationListener.canDetectOrientation()) {
|
|
|
|
mOrientationListener.enable();
|
|
|
|
mOrientationListener.enable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mMessageHandler.postDelayed(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void onResume() {
|
|
|
|
takePicture();
|
|
|
|
super.onResume();
|
|
|
|
}
|
|
|
|
|
|
|
|
}, 400);
|
|
|
|
MicroPhotoService.infoLog("RawActivity onResume PHOTOID=" + Long.toString(mPhotoId));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onPause() {
|
|
|
|
public void onPause() {
|
|
|
|
if (mOrientationListener != null) {
|
|
|
|
|
|
|
|
mOrientationListener.disable();
|
|
|
|
MicroPhotoService.infoLog("RawActivity onPause PHOTOID=" + Long.toString(mPhotoId));
|
|
|
|
}
|
|
|
|
|
|
|
|
closeCamera();
|
|
|
|
|
|
|
|
stopBackgroundThread();
|
|
|
|
|
|
|
|
super.onPause();
|
|
|
|
super.onPause();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -634,6 +680,12 @@ public class RawActivity extends AppCompatActivity {
|
|
|
|
protected void onDestroy() {
|
|
|
|
protected void onDestroy() {
|
|
|
|
super.onDestroy();
|
|
|
|
super.onDestroy();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mOrientationListener != null) {
|
|
|
|
|
|
|
|
mOrientationListener.disable();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
closeCamera();
|
|
|
|
|
|
|
|
stopBackgroundThread();
|
|
|
|
|
|
|
|
|
|
|
|
MicroPhotoService.infoLog("RawActivity destroyed PHOTOID=" + Long.toString(mPhotoId));
|
|
|
|
MicroPhotoService.infoLog("RawActivity destroyed PHOTOID=" + Long.toString(mPhotoId));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|