Skip to content

Commit

Permalink
RC 2 - bugfixes and removed display off
Browse files Browse the repository at this point in the history
It showed that turning off the display doesn't save energy, but was buggy
  • Loading branch information
jonasjuffinger committed Oct 24, 2017
1 parent 8c4db80 commit 657b2d4
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 140 deletions.
Binary file added app/TimeLapse-release-0.3.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.jonasjuffinger.timelapse"
minSdkVersion 10
targetSdkVersion 10
versionCode 2
versionName "0.2"
versionCode 3
versionName "0.3"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Settings {
interval = 1;
shotCount = 1;
displayOff = false;
silentShutter = false;
silentShutter = true;
}

public Settings(int interval, int shotCount, boolean displayOff, boolean silentShutter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class SettingsActivity extends BaseActivity
private int fps;
private Spinner spnFps;

private CheckBox cbDisplayOff, cbSilentShutter;
private CheckBox cbSilentShutter;


@Override
Expand Down Expand Up @@ -78,7 +78,7 @@ protected void onCreate(Bundle savedInstanceState)
tvIntervalUnit = (TextView) findViewById(R.id.tvIntervalUnit);

sbInterval = (AdvancedSeekBar) findViewById(R.id.sbInterval);
sbInterval.setMax(46);
sbInterval.setMax(83);
sbInterval.setOnSeekBarChangeListener(sbIntervalOnSeekBarChangeListener);

tvShotsValue = (TextView) findViewById(R.id.tvShotsValue);
Expand All @@ -96,9 +96,6 @@ protected void onCreate(Bundle savedInstanceState)
spnFps.setSelection(0);
spnFps.setOnItemSelectedListener(spnFpsOnItemSelectedListener);

cbDisplayOff = (CheckBox) findViewById(R.id.cbDisplayOff);
cbDisplayOff.setOnCheckedChangeListener(cbDisplayOffOnCheckListener);

cbSilentShutter = (CheckBox) findViewById(R.id.cbSilentShutter);
cbSilentShutter.setOnCheckedChangeListener(cbSilentShutterOnCheckListener);
}
Expand Down Expand Up @@ -127,24 +124,19 @@ public void onProgressChanged(SeekBar seekBar, int i, boolean b) {

i++;

if(i <= 20) {
if(i <= 40) {
settings.interval = i;
intervalTextValue = settings.interval;
intervalUnit = "s";
}
else if(i <= 28) {
settings.interval = (i-20) * 5 + 20;
else if(i <= 56) {
settings.interval = (i-40) * 5 + 40;
intervalTextValue = settings.interval;
intervalUnit = "s";
}
else if(i <= 37) {
settings.interval = (i-27) * 60;
intervalTextValue = (i-27);
intervalUnit = "min";
}
else if(i <= 47) {
settings.interval = ((i-37) * 5 + 10) * 60;
intervalTextValue = (i-37) * 5 + 10;
else if(i <= 84) {
settings.interval = (i-54) * 60;
intervalTextValue = (i-54);
intervalUnit = "min";
}

Expand All @@ -171,18 +163,18 @@ public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
else if(i <= 36)
settings.shotCount = (i-20) * 5 + 20;

else if(i <= 80)
settings.shotCount = (i-36) * 20 + 120;
else if(i <= 81)
settings.shotCount = (i-36) * 20 + 100;

else if(i <= 100)
settings.shotCount = (i-80) * 50 + 1000;
settings.shotCount = (i-81) * 50 + 1000;

else if(i <= 130)
settings.shotCount = (i-100) * 100 + 2000;

shotsText = Integer.toString(settings.shotCount);

if(i == 301) {
if(i == 131) {
settings.shotCount = Integer.MAX_VALUE;
shotsText = "inf";
}
Expand Down Expand Up @@ -210,20 +202,23 @@ public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l)
public void onNothingSelected(AdapterView<?> adapterView) {}
};

CheckBox.OnCheckedChangeListener cbDisplayOffOnCheckListener = new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
settings.displayOff = b;
}
},
cbSilentShutterOnCheckListener = new CheckBox.OnCheckedChangeListener() {
CheckBox.OnCheckedChangeListener cbSilentShutterOnCheckListener = new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
settings.silentShutter = b;
}
};

void updateTimes() {
if(settings.shotCount == Integer.MAX_VALUE)
{
tvDurationValue.setText("inf");
tvDurationUnit.setText("");
tvVideoTimeValue.setText("inf");
tvVideoTimeUnit.setText("");
return;
}

int duration = settings.interval * settings.shotCount;
int videoTime = settings.shotCount / fps;

Expand Down
23 changes: 14 additions & 9 deletions app/src/main/java/com/jonasjuffinger/timelapse/ShootActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.os.Handler;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.TextView;

import com.github.ma1co.pmcademo.app.BaseActivity;
Expand All @@ -22,8 +23,9 @@ public class ShootActivity extends BaseActivity implements SurfaceHolder.Callba

private int shotCount;

private TextView tvCount, tvInfo;
private TextView tvCount; //, tvInfo;

private SurfaceView reviewSurfaceView;
private SurfaceHolder cameraSurfaceHolder;
private CameraEx cameraEx;
private Camera camera;
Expand All @@ -46,22 +48,23 @@ public void run()
if(stopPicturePreview) {
stopPicturePreview = false;
camera.stopPreview();
display.off();
reviewSurfaceView.setVisibility(View.GONE);
//display.off();
}

if(shotCount < settings.shotCount) {
long remainingTime = shootTime + settings.interval * 1000 - System.currentTimeMillis();

log(" Remaining Time: " + Long.toString(remainingTime));

if (remainingTime <= 0) {
if (remainingTime <= 150) { // 300ms is vaguely the time this postDelayed is to slow
shoot();
if(!settings.displayOff) {
log(Boolean.toString(settings.displayOff));
display.on();
}
} else {
shootRunnableHandler.postDelayed(this, remainingTime);
shootRunnableHandler.postDelayed(this, remainingTime-150);
}
}
else {
Expand Down Expand Up @@ -90,10 +93,11 @@ protected void onCreate(Bundle savedInstanceState) {
takingPicture = false;

tvCount = (TextView) findViewById(R.id.tvCount);
tvInfo = (TextView) findViewById(R.id.tvInfo);
//tvInfo = (TextView) findViewById(R.id.tvInfo);

SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
cameraSurfaceHolder = surfaceView.getHolder();
reviewSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
reviewSurfaceView.setZOrderOnTop(false);
cameraSurfaceHolder = reviewSurfaceView.getHolder();
cameraSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}

Expand All @@ -107,15 +111,14 @@ protected void onResume() {
cameraEx.setShutterListener(this);
cameraSurfaceHolder.addCallback(this);
autoReviewControl = new CameraEx.AutoPictureReviewControl();
//autoReviewControl.setPictureReviewInfoHist(true);
cameraEx.setAutoPictureReviewControl(autoReviewControl);


final Camera.Parameters params = cameraEx.createEmptyParameters();
final CameraEx.ParametersModifier modifier = cameraEx.createParametersModifier(params);
modifier.setSilentShutterMode(settings.silentShutter);
cameraEx.getNormalCamera().setParameters(params);


pictureReviewTime = autoReviewControl.getPictureReviewTime();
log(Integer.toString(pictureReviewTime));

Expand Down Expand Up @@ -224,6 +227,8 @@ public void onShutter(int i, CameraEx cameraEx) {
// show the preview picture for some time
else {
long previewPictureShowTime = Math.min(remainingTime, pictureReviewTime * 1000);
log(" Stop preview in: " + Long.toString(previewPictureShowTime));
reviewSurfaceView.setVisibility(View.VISIBLE);
stopPicturePreview = true;
shootRunnableHandler.postDelayed(shootRunnable, previewPictureShowTime);
}
Expand Down
Loading

0 comments on commit 657b2d4

Please sign in to comment.