Skip to content

Commit

Permalink
Merge pull request #23 from bojanv55/ael_lock
Browse files Browse the repository at this point in the history
Ael lock
  • Loading branch information
jonasjuffinger committed Jul 11, 2019
2 parents ab316cc + 0cf2960 commit 8176a49
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 7 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 10
buildToolsVersion '26.0.2'

defaultConfig {
applicationId "com.jonasjuffinger.timelapse"
Expand Down
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
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.3.2'
}
}

Expand All @@ -13,5 +14,6 @@ allprojects {
maven {
url "https://jitpack.io"
}
google()
}
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Nov 01 21:14:52 CET 2017
#Mon Jul 01 14:13:06 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

0 comments on commit 8176a49

Please sign in to comment.