Skip to content

Commit

Permalink
add AE lock
Browse files Browse the repository at this point in the history
  • Loading branch information
default committed Jul 10, 2019
1 parent 29573c1 commit 0cf2960
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
12 changes: 10 additions & 2 deletions app/src/main/java/com/jonasjuffinger/timelapse/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ class Settings {
private static final String EXTRA_SHOTCOUNT = "com.jonasjuffinger.timelapse.SHOTCOUNT";
private static final String EXTRA_DISPLAYOFF = "com.jonasjuffinger.timelapse.DISPLAYOFF";
private static final String EXTRA_SILENTSHUTTER = "com.jonasjuffinger.timelapse.SILENTSHUTTER";
private static final String EXTRA_AEL = "com.jonasjuffinger.timelapse.AEL";

int interval, rawInterval;
int shotCount, rawShotCount;
boolean displayOff;
boolean silentShutter;
boolean ael;
int fps; // index

Settings() {
Expand All @@ -29,29 +31,33 @@ class Settings {
rawShotCount = 1;
displayOff = false;
silentShutter = true;
ael = true;
fps = 0;
}

public Settings(int interval, int shotCount, boolean displayOff, boolean silentShutter) {
public Settings(int interval, int shotCount, boolean displayOff, boolean silentShutter, boolean ael) {
this.interval = interval;
this.shotCount = shotCount;
this.displayOff = displayOff;
this.silentShutter = silentShutter;
this.ael = ael;
}

void putInIntent(Intent intent) {
intent.putExtra(EXTRA_INTERVAL, interval);
intent.putExtra(EXTRA_SHOTCOUNT, shotCount);
intent.putExtra(EXTRA_DISPLAYOFF, displayOff);
intent.putExtra(EXTRA_SILENTSHUTTER, silentShutter);
intent.putExtra(EXTRA_AEL, ael);
}

static Settings getFromIntent(Intent intent) {
return new Settings(
intent.getIntExtra(EXTRA_INTERVAL, 1),
intent.getIntExtra(EXTRA_SHOTCOUNT, 1),
intent.getBooleanExtra(EXTRA_DISPLAYOFF, false),
intent.getBooleanExtra(EXTRA_SILENTSHUTTER, false)
intent.getBooleanExtra(EXTRA_SILENTSHUTTER, false),
intent.getBooleanExtra(EXTRA_AEL, false)
);
}

Expand All @@ -62,6 +68,7 @@ void save(Context context)
editor.putInt("interval", rawInterval);
editor.putInt("shotCount", rawShotCount);
editor.putBoolean("silentShutter", silentShutter);
editor.putBoolean("ael", ael);
editor.putInt("fps", fps);
editor.apply();
}
Expand All @@ -72,6 +79,7 @@ void load(Context context)
rawInterval = sharedPref.getInt("interval", rawInterval);
rawShotCount = sharedPref.getInt("shotCount", rawShotCount);
silentShutter = sharedPref.getBoolean("silentShutter", silentShutter);
ael = sharedPref.getBoolean("ael", ael);
fps = sharedPref.getInt("fps", fps);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class SettingsActivity extends BaseActivity
private Spinner spnFps;

private CheckBox cbSilentShutter;
private CheckBox cbAEL;

@Override
protected void onCreate(Bundle savedInstanceState)
Expand Down Expand Up @@ -72,6 +73,7 @@ protected void onCreate(Bundle savedInstanceState)
sbShots = (AdvancedSeekBar) findViewById(R.id.sbShots);
spnFps = (Spinner) findViewById(R.id.spnFps);
cbSilentShutter = (CheckBox) findViewById(R.id.cbSilentShutter);
cbAEL = (CheckBox) findViewById(R.id.cbAEL);

sbInterval.setMax(83);
sbInterval.setOnSeekBarChangeListener(sbIntervalOnSeekBarChangeListener);
Expand All @@ -88,6 +90,9 @@ protected void onCreate(Bundle savedInstanceState)
cbSilentShutter.setOnCheckedChangeListener(cbSilentShutterOnCheckListener);
//cbSilentShutter.setVisibility(View.INVISIBLE);

cbAEL.setChecked(settings.ael);
cbAEL.setOnCheckedChangeListener(cbAELOnCheckListener);

//try {
//CameraEx cameraEx = CameraEx.open(0, null);
//final CameraEx.ParametersModifier modifier = cameraEx.createParametersModifier(cameraEx.getNormalCamera().getParameters());
Expand Down Expand Up @@ -214,6 +219,13 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
}
};

CheckBox.OnCheckedChangeListener cbAELOnCheckListener = new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
settings.ael = b;
}
};

void updateTimes() {
if(settings.shotCount == Integer.MAX_VALUE)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected void onResume() {
//autoReviewControl.setPictureReviewInfoHist(true);
cameraEx.setAutoPictureReviewControl(autoReviewControl);

final Camera.Parameters params = cameraEx.createEmptyParameters();
final Camera.Parameters params = cameraEx.getNormalCamera().getParameters();
final CameraEx.ParametersModifier modifier = cameraEx.createParametersModifier(params);
modifier.setDriveMode(CameraEx.ParametersModifier.DRIVE_MODE_SINGLE);
// setSilentShutterMode doesn't exist on all cameras
Expand All @@ -131,6 +131,17 @@ protected void onResume() {
}
catch(NoSuchMethodError ignored)
{}

try{
//add also AEL if set
if(settings.ael) {
modifier.setAutoExposureLock(CameraEx.ParametersModifier.AE_LOCK_ON);
}
}
catch (Exception e){
//do nothing
}

cameraEx.getNormalCamera().setParameters(params);

pictureReviewTime = autoReviewControl.getPictureReviewTime();
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@
android:layout_marginLeft="10dp"
android:checked="true"
android:text="Silent Shutter" />

<CheckBox
android:id="@+id/cbAEL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:checked="true"
android:layout_toRightOf="@id/cbSilentShutter"
android:text="AEL" />
</RelativeLayout>
</LinearLayout>

Expand Down

0 comments on commit 0cf2960

Please sign in to comment.