Skip to content

Commit

Permalink
added timer feature
Browse files Browse the repository at this point in the history
  • Loading branch information
cleemansen committed Jun 24, 2011
1 parent 574f223 commit c1cfd5c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 13 deletions.
4 changes: 4 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<string name="key_burstMode">burstMode</string>
<string name="key_burstNumberValue">burstNumberValue</string>
<string name="key_burstIntervalValue">burstIntervalValue</string>

<string name="key_timerMode">timerMode</string>
<string name="key_timerNumberValue">timerNumberValue</string>

<string name="key_picQuali">pictureQuality</string>
<string name="key_colorEffect">colorEffect</string>
<string name="key_sceneMode">sceneMode</string>
Expand Down
11 changes: 11 additions & 0 deletions res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@
android:positiveButtonText="Ok"
android:negativeButtonText="Cancel" />
</PreferenceScreen>
<CheckBoxPreference
android:key="@string/key_timerMode"
android:title="Timer Mode" />
<EditTextPreference
android:key="@string/key_timerNumberValue"
android:dependency="@string/key_timerMode"
android:title="Timer"
android:dialogTitle="Timer"
android:dialogMessage="Seconds until the first picture will be captured?"
android:positiveButtonText="Ok"
android:negativeButtonText="Cancel" />
</PreferenceCategory>
<PreferenceCategory
android:key="prefCat_camera"
Expand Down
4 changes: 2 additions & 2 deletions src/de/starquay/android/camera5000/HelperMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void onPictureTaken(byte[] imageData, Camera c) {
};

/**
* From original Camera App
* From original Android Camera App
* See: http://android.git.kernel.org/?p=platform/packages/apps/Camera.git;a=blob;f=src/com/android/camera/ImageManager.java;h=76a6d1dffdcfb91f2c55032ce14f7cd9ecf7962c;hb=HEAD
* @param imageData
* @param quality
Expand All @@ -76,7 +76,7 @@ public static boolean StoreByteImage(byte[] imageData, int quality, String filen
File file = new File(directory, filename);
outputStream = new FileOutputStream(file);
if (source != null) {
source.compress(CompressFormat.JPEG, 100, outputStream);
source.compress(CompressFormat.JPEG, 95, outputStream);
} else {
outputStream.write(imageData);
// degree[0] = getExifOrientation(filePath);
Expand Down
10 changes: 9 additions & 1 deletion src/de/starquay/android/camera5000/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void fillPreferencesWithValues() {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

/**
* BURST Settings
* BURST / TIMER Settings
*/

/** Burst Mode */
Expand All @@ -66,6 +66,14 @@ private void fillPreferencesWithValues() {
myEditText = (EditText)etp.getEditText();
myEditText.setInputType(InputType.TYPE_CLASS_NUMBER);

/** Timer Mode */
/** Seconds until picture */
key = this.getString(R.string.key_timerNumberValue);
etp = (EditTextPreference) findPreference(key);
etp.setSummary(settings.getString(key, "not set"));
// only numbers!
myEditText = (EditText)etp.getEditText();
myEditText.setInputType(InputType.TYPE_CLASS_NUMBER);

/**
* All Camera Settings
Expand Down
35 changes: 25 additions & 10 deletions src/de/starquay/android/camera5000/Screen.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,21 @@ public void surfaceDestroyed(SurfaceHolder holder) {
@Override
public void onClick(View v) {
SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
int timer = 0;
int shots = 1;
int secBetween2Pics = 0;
if (shared.getBoolean(this.getString(R.string.key_timerMode), false)) {
//TIMER
timer = Integer.valueOf(shared.getString(this.getString(R.string.key_timerNumberValue), "1"));
}
if (shared.getBoolean(this.getString(R.string.key_burstMode), false)) {
int shots = Integer.valueOf(shared.getString(this.getString(R.string.key_burstNumberValue), "1"));
int frequency = Integer.valueOf(shared.getString(this.getString(R.string.key_burstIntervalValue), "5"));
startBurstSession(shots, frequency);
//BURST (plus maybe TIMER)
shots = Integer.valueOf(shared.getString(this.getString(R.string.key_burstNumberValue), "1"));
secBetween2Pics = Integer.valueOf(shared.getString(this.getString(R.string.key_burstIntervalValue), "5"));
} else {
HelperMethods.takePicture(mCamera);
// HelperMethods.takePicture(mCamera);
}
startBurstSession(shots, secBetween2Pics, timer);
}

/**
Expand All @@ -344,12 +352,13 @@ public void onClick(View v) {
*
* @param shots
* : number of pictures
* @param frequency
* @param secBetween2Pics
* : pause between two shoots in seconds!
* @param timer: seconds until first picture
*/
private void startBurstSession(int shots, int frequency) {
private void startBurstSession(int shots, int secBetween2Pics, int timer) {
/** init a countdown for the user */
countDown = new CountDownAction(frequency * 1000, 1000, shots);
countDown = new CountDownAction(timer * 1000, 1000, shots, secBetween2Pics * 1000);
/** this will take the pictures in the given interval */
// mBurstHandler = new BurstHandler(this, shots, frequency);

Expand All @@ -364,12 +373,17 @@ private void startBurstSession(int shots, int frequency) {
public class CountDownAction extends CountDownTimer {

private int burstCnt;
private long countDownInterval;
private long secondsBetween2Pics;

public CountDownAction(long millisInFuture, long countDownInterval, int burstCnt) {
public CountDownAction(long millisInFuture, long countDownInterval, int burstCnt, long secondsBetween2Pics) {
super(millisInFuture, countDownInterval);
this.burstCnt = burstCnt;
this.countDownInterval = countDownInterval;
this.secondsBetween2Pics = secondsBetween2Pics;
// start immediately with the first picture
HelperMethods.takePicture(mCamera);
// NO! see feature timer
// HelperMethods.takePicture(mCamera);
burstCntView.setText("Img Cnt: " + burstCnt);
this.start();
}
Expand All @@ -381,7 +395,8 @@ public void onFinish() {
burstCnt--;
burstCntView.setText("Img Cnt: " + burstCnt);
if (burstCnt > 0) {
this.start();
//BURST MODE
countDown = new CountDownAction(secondsBetween2Pics, countDownInterval, burstCnt, secondsBetween2Pics);
}
}

Expand Down

0 comments on commit c1cfd5c

Please sign in to comment.