diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 67161ee5..dded7f15 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -21,6 +21,23 @@
android:largeScreens="true"
android:xlargeScreens="true"
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -90,22 +107,7 @@
-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
@@ -277,58 +251,6 @@
-
-
-
-
diff --git a/camera2libs/core_dex2jar.jar b/camera2libs/core_dex2jar.jar
deleted file mode 100644
index 3ab45a60..00000000
Binary files a/camera2libs/core_dex2jar.jar and /dev/null differ
diff --git a/camera2libs/framework2_dex2jar.jar b/camera2libs/framework2_dex2jar.jar
new file mode 100755
index 00000000..0fcd6f3b
Binary files /dev/null and b/camera2libs/framework2_dex2jar.jar differ
diff --git a/camera2libs/framework_dex2jar.jar b/camera2libs/framework_dex2jar.jar
old mode 100644
new mode 100755
index a1fe2c43..be23a9f2
Binary files a/camera2libs/framework_dex2jar.jar and b/camera2libs/framework_dex2jar.jar differ
diff --git a/jni/almashot/armeabi-v7a/libalmalib_eval.a b/jni/almashot/armeabi-v7a/libalmalib_eval.a
index 3e715d9a..23b799bf 100644
Binary files a/jni/almashot/armeabi-v7a/libalmalib_eval.a and b/jni/almashot/armeabi-v7a/libalmalib_eval.a differ
diff --git a/jni/almashot/x86/libalmalib_eval.a b/jni/almashot/x86/libalmalib_eval.a
index dfb9947c..e9b030cb 100644
Binary files a/jni/almashot/x86/libalmalib_eval.a and b/jni/almashot/x86/libalmalib_eval.a differ
diff --git a/jni/dro/almashot-dro.cpp b/jni/dro/almashot-dro.cpp
index 6f06331c..563207c6 100755
--- a/jni/dro/almashot-dro.cpp
+++ b/jni/dro/almashot-dro.cpp
@@ -147,8 +147,9 @@ extern "C" JNIEXPORT jint JNICALL Java_com_almalence_plugins_processing_simple_A
jfloat max_amplify,
jboolean local_mapping,
jint filterStrength,
- jint strongFilter,
- jint pullUV
+ jint pullUV,
+ jfloat dark_noise_pass,
+ jfloat gamma
)
{
int i, x, y;
@@ -188,9 +189,9 @@ extern "C" JNIEXPORT jint JNICALL Java_com_almalence_plugins_processing_simple_A
float max_limit[3] = {3.0f,2.0f,2.0f};
if (local_mapping)
- Dro_ComputeToneTable(hist_loc[x][y], lookup_table[x][y], 0.5, 64, 0.5f, min_limit, max_limit, max_amplify);
+ Dro_ComputeToneTable(hist_loc[x][y], lookup_table[x][y], gamma, 64, 0.5f, min_limit, max_limit, max_amplify);
else
- Dro_ComputeToneTable(hist, lookup_table[x][y], 0.5, 64, 0.5f, min_limit, max_limit, max_amplify);
+ Dro_ComputeToneTable(hist, lookup_table[x][y], gamma, 64, 0.5f, min_limit, max_limit, max_amplify);
}
@@ -200,8 +201,8 @@ extern "C" JNIEXPORT jint JNICALL Java_com_almalence_plugins_processing_simple_A
local_mapping ? NULL:lookup_table[0][0],
local_mapping ? lookup_table:NULL,
filterStrength,
- strongFilter,
pullUV, 5,
+ dark_noise_pass,
sx, sy);
}
@@ -253,6 +254,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_almalence_plugins_capture_video_Realt
jboolean force_update,
jint uv_desat,
jint dark_uv_desat,
+ jfloat dark_noise_pass,
jfloat mix_factor,
jfloat gamma, // default = 0.5
jfloat max_black_level, // default = 16
@@ -278,6 +280,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_almalence_plugins_capture_video_Realt
force_update,
uv_desat,
dark_uv_desat,
+ dark_noise_pass,
mix_factor,
gamma,
max_black_level,
diff --git a/jni/include/almashot/dro.h b/jni/include/almashot/dro.h
index 92bcc86e..75df10c4 100644
--- a/jni/include/almashot/dro.h
+++ b/jni/include/almashot/dro.h
@@ -31,7 +31,7 @@
SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE, MISUSE OR
INABILITY TO USE THE SOFTWARE OR RELATED DOCUMENTATION.
- COPYRIGHT 2012, ALMALENCE, INC.
+ COPYRIGHT 2012-2014, ALMALENCE, INC.
---------------------------------------------------------------------------
@@ -78,26 +78,23 @@ void Dro_GetHistogramNV21
// Input:
// hist - pointer to histogram with 256 elements
// Output:
-// lookup_table[256] - filled with tone-table multipliers (in q5.10 fixed-point format)
+// lookup_table - filled with tone-table multipliers (in q5.10 fixed-point format)
//
// Parameters:
// gamma - Defines how 'bright' the output image will be. Lower values cause brighter output.
// Default: 0.5
// max_black_level - threshold for black level correction. Default: 16
// black_level_atten - how much to attenuate black level. Default: 0.5
-// min_limit[3] - Minimum limit on contrast reduction. Range: [0..0.9]. Default: 0.5
+// min_limit[3] - Minimum limit on contrast reduction. Range: [0..0.9]. Default: {0.5, 0.5, 0.5}
+// max_limit[3] - Maximum limit on contrast enhancement. Range: [1..10]. Default:
// [0] - for shadows, [1] - for midtones, [2] - for highlights.
-// max_limit[3] - Maximum limit on contrast enhancement. Range: [1..10].
-// [0] - for shadows, default: 4 - for hdr-like effects, 3 for more balanced results
-// [1] - for midtones, default: 2
-// [2] - for highlights, default: 2
+// {4.0, 2.0, 2.0} - for hdr-like effects;
+// {3.0, 2.0, 2.0} - for more balanced results.
// global_limit - Maximum limit on total brightness amplification. Recommended: 4
-// Return:
-// pointer to lookup_table.
-Int32 *Dro_ComputeToneTable
+void Dro_ComputeToneTable
(
- Uint32 *hist,
- Int32 *lookup_table,
+ Uint32 hist[256],
+ Int32 lookup_table[256],
float gamma,
float max_black_level,
float black_level_atten,
@@ -107,6 +104,39 @@ Int32 *Dro_ComputeToneTable
);
+// ComputeToneTableLocal - same as ComputeToneTable, but compute 3x3 tone tables.
+// Input:
+// hist_loc - 3x3 histograms each with 256 elements
+// Output:
+// lookup_table_loc - filled with multipliers for each of 3x3 image areas
+//
+// Parameters:
+// gamma - Defines how 'bright' the output image will be. Lower values cause brighter output.
+// Default: 0.5
+// max_black_level - threshold for black level correction. Default: 16
+// black_level_atten - how much to attenuate black level. Default: 0.5
+// min_limit[3] - Minimum limit on contrast reduction. Range: [0..0.9]. Default: {0.5, 0.5, 0.5}
+// max_limit[3] - Maximum limit on contrast enhancement. Range: [1..10]. Default:
+// [0] - for shadows, [1] - for midtones, [2] - for highlights.
+// {4.0, 2.0, 2.0} - for hdr-like effects;
+// {3.0, 2.0, 2.0} - for more balanced results.
+// global_limit - Maximum limit on total brightness amplification. Recommended: 4
+// mix_factor - Defines the level of inter-dependence of image areas. Range: [0..1].
+// Recommended: 0.2
+void Dro_ComputeToneTableLocal
+(
+ Uint32 hist_loc[3][3][256],
+ Int32 lookup_table_loc[3][3][256],
+ float gamma,
+ float max_black_level,
+ float black_level_atten,
+ float min_limit[3],
+ float max_limit[3],
+ float global_limit,
+ float mix_factor
+);
+
+
// ApplyToneTableNV21 - apply lookup_table[256] to YUV.
//
// Input:
@@ -156,35 +186,13 @@ int Dro_ApplyToneTableFilteredNV21
Int32 lookup_table[256],
Int32 lookup_local[3][3][256],
int filter,
- int strong_filter,
int uv_desat,
int dark_uv_desat,
+ float dark_noise_pass,
int sx,
int sy
);
-// Description:
-// Detects if a new histogram is sufficiently different from the base one.
-// If so - new histogram is copied into base.
-// It is further detected if scene is changed.
-//
-// Return:
-//
-// 0 = no tone table update is needed
-// hist_base remain untouched
-//
-// 1 = tone update is needed, but no scene change (slowly advance to the new table)
-// hist_base updated with the new hist
-//
-// 2 = tone update is needed, scene change (switch to the new table immediately)
-// hist_base updated with the new hist
-//
-int Dro_CheckToneUpdateNeeded
-(
- Uint32 *hist,
- Uint32 *hist_base
-);
-
//
// Example:
@@ -237,12 +245,13 @@ void Dro_StreamingRender
int force_update,
int uv_desat,
int dark_uv_desat,
+ float dark_noise_pass,
float mix_factor,
float gamma, // default = 0.5
float max_black_level, // default = 16
float black_level_atten, // default = 0.5
- float min_limit[3], // default = 0.5 0.5 0.5
- float max_limit[3], // default = 3 2 2
+ float min_limit[3], // default = {0.5, 0.5, 0.5}
+ float max_limit[3], // default = {3.0, 2.0, 2.0}
unsigned int texture_out
);
diff --git a/jni/include/almashot/filters.h b/jni/include/almashot/filters.h
index f6425a66..cf3be46c 100644
--- a/jni/include/almashot/filters.h
+++ b/jni/include/almashot/filters.h
@@ -31,7 +31,7 @@
SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE, MISUSE OR
INABILITY TO USE THE SOFTWARE OR RELATED DOCUMENTATION.
- COPYRIGHT 2010-2012, ALMALENCE, INC.
+ COPYRIGHT 2010-2014, ALMALENCE, INC.
---------------------------------------------------------------------------
@@ -195,6 +195,28 @@ void Filters_PostFilter
int sharpen
);
+void Filters_OuterMirrorFill
+(
+ Uint8 *in,
+ int sx,
+ int sy,
+ int x0,
+ int y0,
+ int w,
+ int h
+);
+
+void Filters_FillFilterPressure
+(
+ Int32 Scale,
+ int sx,
+ int sy,
+ Uint8 *nMov,
+ Uint8 *mcurTbl,
+ int subsampMov,
+ int sxMov
+);
+
void Filters_PostFilterQuick
(
void *instance,
@@ -203,8 +225,24 @@ void Filters_PostFilterQuick
Int32 Scale,
int sx,
int sy,
+ int sharpen,
+ Uint8 *nMov,
+ Uint8 *mcurTbl,
+ int subsampMov,
+ int sxMov
+);
+
+void Filters_PostFilterQuick_CPU
+(
+ void *instance,
+ Uint8 *Y,
+ int sx,
+ int sy,
int stride,
- int sharpen
+ int sharpen,
+ Uint8 *mcurTbl,
+ int subsampMov,
+ int sxMov
);
void Filters_PostFilterUV
@@ -247,7 +285,8 @@ void Filters_ResidualQuarterCompute
int sx,
int sy,
int sxs,
- int sys
+ int sys,
+ int pressure
);
void Filters_ResidualQuarterComputeUV
@@ -258,7 +297,8 @@ void Filters_ResidualQuarterComputeUV
int sx,
int sy,
int sxs,
- int sys
+ int sys,
+ int stride
);
// Filter lower spatial components of the frame
@@ -279,7 +319,25 @@ void Filters_FilterLowSpatialUV
Uint8 *inUV,
int sx,
int sy,
- int Filter
+ int Filter,
+ int stride
+);
+
+void Filters_FilterMoving
+(
+ void *instance,
+ Uint8 *Y,
+ Uint8 *nMov,
+ Int32 Scale,
+// int mtx,
+// int mty,
+ int x_st,
+ int y_st,
+ int x_en,
+ int y_en,
+ int sx,
+ int sy,
+ int stride
);
diff --git a/jni/include/almashot/superzoom.h b/jni/include/almashot/superzoom.h
index 9bcbedfa..3a67928c 100644
--- a/jni/include/almashot/superzoom.h
+++ b/jni/include/almashot/superzoom.h
@@ -31,7 +31,7 @@
SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE, MISUSE OR
INABILITY TO USE THE SOFTWARE OR RELATED DOCUMENTATION.
- COPYRIGHT 2010-2012, ALMALENCE, INC.
+ COPYRIGHT 2010-2014, ALMALENCE, INC.
---------------------------------------------------------------------------
@@ -122,11 +122,7 @@ int SuperZoom_StartStreaming
int sy,
int sxo,
int syo,
- int SensorGain,
- int DeGhostGain,
int DeGhostFrames,
- int kelvin1,
- int kelvin2,
int noSres,
int cameraIndex
);
@@ -147,6 +143,10 @@ int SuperZoom_ResolveFrame
int *h_out,
int nImages,
int nRefImage,
+ int SensorGain,
+ int MovObjGain,
+ int kelvin1,
+ int kelvin2,
int enh_edges
);
diff --git a/jni/prebuilt/armeabi-v7a/libandroid_runtime.so b/jni/prebuilt/armeabi-v7a/libandroid_runtime.so
index 379a4f4c..7594cf4c 100755
Binary files a/jni/prebuilt/armeabi-v7a/libandroid_runtime.so and b/jni/prebuilt/armeabi-v7a/libandroid_runtime.so differ
diff --git a/jni/sequence/almashot-sequence.cpp b/jni/sequence/almashot-sequence.cpp
index 290a5107..b7ae4eba 100755
--- a/jni/sequence/almashot-sequence.cpp
+++ b/jni/sequence/almashot-sequence.cpp
@@ -114,54 +114,6 @@ void NV21toARGB(
}
}
-// Decode from JPEG to NV21 using skia lib
-/*int decodeFromJpeg(unsigned char *data, int len, int idx, int sx, int sy)
-{
- int x, y;
- Uint32 * pix;
- Uint32 p1, p2;
-
- SkBitmap bm;
- SkBitmap::Config pref = SkBitmap::kARGB_8888_Config;
-
- if (SkImageDecoder::DecodeMemory(data, len, &bm, pref, SkImageDecoder::kDecodePixels_Mode))
- {
- pix = (Uint32 *)bm.getPixels();
-
- for (y=0; y
-
-
diff --git a/res/layout/gui_almalence_layout.xml b/res/layout/gui_almalence_layout.xml
index 7f1c5e62..f51dff7c 100755
--- a/res/layout/gui_almalence_layout.xml
+++ b/res/layout/gui_almalence_layout.xml
@@ -363,10 +363,28 @@
+
+
+
+
-
-
+
-
-
diff --git a/res/layout/gui_almalence_whatsnew.xml b/res/layout/gui_almalence_whatsnew.xml
index 0eb884bc..c09e2070 100755
--- a/res/layout/gui_almalence_whatsnew.xml
+++ b/res/layout/gui_almalence_whatsnew.xml
@@ -6,21 +6,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
>
-
-
diff --git a/res/layout/plugin_capture_video_layout.xml b/res/layout/plugin_capture_video_layout.xml
index ff860b09..2fe48e91 100755
--- a/res/layout/plugin_capture_video_layout.xml
+++ b/res/layout/plugin_capture_video_layout.xml
@@ -1,6 +1,6 @@
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+ android:layout_height="wrap_content" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/plugin_processing_multishot_options_layout.xml b/res/layout/plugin_processing_multishot_options_layout.xml
index 474400da..e135ec59 100755
--- a/res/layout/plugin_processing_multishot_options_layout.xml
+++ b/res/layout/plugin_processing_multishot_options_layout.xml
@@ -4,7 +4,8 @@
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
- android:orientation="vertical" >
+ android:orientation="vertical"
+ android:visibility="gone">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginTop="10dp" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/selftimer_dialog.xml b/res/layout/selftimer_dialog.xml
index 3421faf6..1191b3ab 100755
--- a/res/layout/selftimer_dialog.xml
+++ b/res/layout/selftimer_dialog.xml
@@ -1,78 +1,99 @@
-
+
-
+
+
-
-
-
-
-
-
-
-
+ android:layout_height="wrap_content" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/res/values-ru/strings_almalence_gui.xml b/res/values-ru/strings_almalence_gui.xml
index 43e54089..920f154e 100755
--- a/res/values-ru/strings_almalence_gui.xml
+++ b/res/values-ru/strings_almalence_gui.xml
@@ -38,7 +38,7 @@
Съемка по таймеру
Показать контрол съемки по таймеру на главном экране
Показывать помощь
- Показывать помощь при запуске режима (режимы панорамы, удаление движущихся объектов, групповой снимок)
+ Показывать помощь при запуске режима (режимы панорамы, Smart multishot)
выбран
diff --git a/res/values-ru/strings_plugin_capture_multishot.xml b/res/values-ru/strings_plugin_capture_multishot.xml
new file mode 100755
index 00000000..b8e655a1
--- /dev/null
+++ b/res/values-ru/strings_plugin_capture_multishot.xml
@@ -0,0 +1,6 @@
+
+
+ Размер снимка (Smart Multishot)
+ Smart multishot помощь
+ 1. Держите телефон ровно, не сдвигайте\n2. Нажмите кнопку спуска для начала съемки\n3. Дождитесь конца съемки серии снимков и завершения обработки\n
+
diff --git a/res/values-ru/strings_plugin_capture_night.xml b/res/values-ru/strings_plugin_capture_night.xml
index 0358291a..3727c1f6 100755
--- a/res/values-ru/strings_plugin_capture_night.xml
+++ b/res/values-ru/strings_plugin_capture_night.xml
@@ -10,7 +10,7 @@
Ночная съемка
Съемка при слабом освещении
- Размер снимка(hi-speed)
+ Размер снимка (Ночь hi-speed)
Режим фокусировки
Выберите подходящий режим фокусировки
diff --git a/res/values/array_plugin_capture_multishot.xml b/res/values/array_plugin_capture_multishot.xml
deleted file mode 100755
index 422d4094..00000000
--- a/res/values/array_plugin_capture_multishot.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
- - @string/Res_MultiShot_Capture_5
- - @string/Res_MultiShot_Capture_6
- - @string/Res_MultiShot_Capture_7
- - @string/Res_MultiShot_Capture_8
-
-
-
- - 5
- - 6
- - 7
- - 8
-
-
-
- - 0,25 sec
- - 0,5 sec
- - 0,75 sec
- - 1 sec
-
-
-
- - 250
- - 500
- - 750
- - 1000
-
-
-
diff --git a/res/values/strings_almalence_gui.xml b/res/values/strings_almalence_gui.xml
index 76f31573..7cb150dc 100755
--- a/res/values/strings_almalence_gui.xml
+++ b/res/values/strings_almalence_gui.xml
@@ -34,7 +34,7 @@
Self-timer capture
Show self-timer control
Show help
- Show help when mode started (Panorama, Object removal, Sequence, Groupshot)
+ Show help when mode started (Panorama, Smart multishot)
Headset shutter
Use headset buttons as shutter
diff --git a/res/values/strings_modes.xml b/res/values/strings_modes.xml
index d64115bd..87e9a47f 100755
--- a/res/values/strings_modes.xml
+++ b/res/values/strings_modes.xml
@@ -27,7 +27,7 @@
Object removal
- Multi shot
+ Smart multishot
Group shot
diff --git a/res/values/strings_plugin_capture_multishot.xml b/res/values/strings_plugin_capture_multishot.xml
index 05269598..afa30b4d 100755
--- a/res/values/strings_plugin_capture_multishot.xml
+++ b/res/values/strings_plugin_capture_multishot.xml
@@ -1,20 +1,6 @@
- Multi shot capture
- Multi shoot mode
- Set number of images in capture
-
- Number of images
-
- multiShotImagesAmount
- multiShotPauseBetweenShots
-
- Multi shot help
+ Image size (Smart Multishot)
+ Smart multishot help
1. Hold device still and do not move\n2. Press shutter to start\n3. Wait until series of images taken and processed\n
-
- Pause between shots
- 5 images
- 6 images
- 7 images
- 8 images
diff --git a/res/values/strings_plugin_capture_night.xml b/res/values/strings_plugin_capture_night.xml
index 9ac06bd0..ce3cfece 100755
--- a/res/values/strings_plugin_capture_night.xml
+++ b/res/values/strings_plugin_capture_night.xml
@@ -25,7 +25,7 @@
Night capture
Low light capturing
- Image size (hi-speed mode)
+ Image size (Night hi-speed mode)
Focus mode
Select suitable focus mode
diff --git a/res/values/strings_plugin_capture_selftimer.xml b/res/values/strings_plugin_capture_selftimer.xml
index 7744f845..6c5e1aca 100755
--- a/res/values/strings_plugin_capture_selftimer.xml
+++ b/res/values/strings_plugin_capture_selftimer.xml
@@ -17,4 +17,6 @@
1 image
2 images
3 images
+
+ Self timer
diff --git a/res/values/strings_plugin_capture_video.xml b/res/values/strings_plugin_capture_video.xml
index 56325571..82176933 100755
--- a/res/values/strings_plugin_capture_video.xml
+++ b/res/values/strings_plugin_capture_video.xml
@@ -11,6 +11,7 @@
None
Set
+ Time lapse
Standard video camera
Use standard camera for video recording
diff --git a/res/values/strings_plugin_processing_multishot.xml b/res/values/strings_plugin_processing_multishot.xml
index 08f86092..16bbdabc 100755
--- a/res/values/strings_plugin_processing_multishot.xml
+++ b/res/values/strings_plugin_processing_multishot.xml
@@ -1,7 +1,7 @@
- Multi shot processing
+ Smart multishot processing
Process multishot
Save original frames
diff --git a/res/values/strings_plugin_vf_common.xml b/res/values/strings_plugin_vf_common.xml
index 7da857a6..d09c755e 100755
--- a/res/values/strings_plugin_vf_common.xml
+++ b/res/values/strings_plugin_vf_common.xml
@@ -9,4 +9,6 @@
Max screen brightness
Force the screen to maximum brightness
+ Dismiss keyguard
+ Skip non sequre lock keyguard when device is turned on
diff --git a/res/values/strings_preferences_modes.xml b/res/values/strings_preferences_modes.xml
index ef8228f1..518c3754 100755
--- a/res/values/strings_preferences_modes.xml
+++ b/res/values/strings_preferences_modes.xml
@@ -9,7 +9,7 @@
HDR
Night
Video
- Multishot
+ Smart multishot
Pre-shot
+
+
+
+
+
+
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/xml/preferences_capture_night.xml b/res/xml/preferences_capture_night.xml
index 98043356..fbf05fb3 100755
--- a/res/xml/preferences_capture_night.xml
+++ b/res/xml/preferences_capture_night.xml
@@ -1,36 +1,26 @@
-
+
-
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
-
+ +++
+ -->
+
+
\ No newline at end of file
diff --git a/res/xml/preferences_capture_video.xml b/res/xml/preferences_capture_video.xml
index e78db606..b1f0e682 100755
--- a/res/xml/preferences_capture_video.xml
+++ b/res/xml/preferences_capture_video.xml
@@ -2,18 +2,6 @@
-
-
+ android:key="@string/Preference_SortByDataValue" />
diff --git a/res/xml/preferences_general_image_size.xml b/res/xml/preferences_general_image_size.xml
new file mode 100755
index 00000000..f7b60050
--- /dev/null
+++ b/res/xml/preferences_general_image_size.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/xml/preferences_vf_more.xml b/res/xml/preferences_vf_more.xml
new file mode 100755
index 00000000..013a601e
--- /dev/null
+++ b/res/xml/preferences_vf_more.xml
@@ -0,0 +1,8 @@
+
+
+
\ No newline at end of file
diff --git a/src/com/almalence/YuvImage.java b/src/com/almalence/YuvImage.java
index 1055ed65..638489d8 100755
--- a/src/com/almalence/YuvImage.java
+++ b/src/com/almalence/YuvImage.java
@@ -260,11 +260,11 @@ public static native boolean SaveJpegFreeOut(int oriYuv, int format, int width,
int[] strides, int quality, OutputStream stream, byte[] tempStorage);
// Return: pointer to the frame data in heap converted to int
- public static synchronized native int GetFrame(int frame);
+ public static synchronized native int GetFrame(int frameNum);
- public static synchronized native byte[] GetByteFrame(int frame);
+ public static synchronized native byte[] GetByteFrame(int frameNum);
- public static synchronized native void RemoveFrame(int frame);
+ public static synchronized native void RemoveFrame(int frameNum);
// Return: error status (0 = all ok)
public static synchronized native int CreateYUVImage(ByteBuffer Y, ByteBuffer U, ByteBuffer V, int pixelStrideY,
diff --git a/src/com/almalence/googsharing/Thumbnail.java b/src/com/almalence/googsharing/Thumbnail.java
index 105ad806..e35bc304 100755
--- a/src/com/almalence/googsharing/Thumbnail.java
+++ b/src/com/almalence/googsharing/Thumbnail.java
@@ -44,11 +44,12 @@
import android.os.Environment;
import android.provider.MediaStore.Images;
import android.provider.MediaStore.Images.ImageColumns;
-import android.provider.MediaStore.MediaColumns;
import android.provider.MediaStore.Video;
import android.provider.MediaStore.Video.VideoColumns;
import android.util.Log;
+import com.almalence.opencam.MainScreen;
+import com.almalence.opencam.PluginManager;
import com.almalence.util.Util;
public class Thumbnail
@@ -321,7 +322,7 @@ public static Media getLastImageThumbnail(ContentResolver resolver)
Uri query = baseUri.buildUpon().appendQueryParameter("limit", "1").build();
String[] projection = new String[] { ImageColumns._ID, ImageColumns.ORIENTATION, ImageColumns.DATE_TAKEN };
- String selection = ImageColumns.MIME_TYPE + "='image/jpeg'";
+ String selection = ImageColumns.DATA + " like '" + PluginManager.getSaveDir(false).getAbsolutePath() + "%' AND " + ImageColumns.MIME_TYPE + "='image/jpeg'";
String order = ImageColumns.DATE_TAKEN + " DESC," + ImageColumns._ID + " DESC";
Cursor cursor = null;
@@ -350,10 +351,9 @@ public static Media getLastImageThumbnail(ContentResolver resolver)
try
{
Uri baseUri = Images.Media.EXTERNAL_CONTENT_URI;
-
Uri query = baseUri.buildUpon().appendQueryParameter("limit", "1").build();
String[] projection = new String[] { ImageColumns._ID, ImageColumns.ORIENTATION, ImageColumns.DATE_TAKEN };
- String selection = ImageColumns.MIME_TYPE + "='image/jpeg'";
+ String selection = ImageColumns.DATA + " like '" + PluginManager.getSaveDir(false).getAbsolutePath() + "%' AND " + ImageColumns.MIME_TYPE + "='image/jpeg'";
String order = ImageColumns.DATE_TAKEN + " DESC," + ImageColumns._ID + " DESC";
Cursor cursor = null;
@@ -419,31 +419,81 @@ private static Thumbnail createThumbnail(Uri uri, Bitmap bitmap, Bitmap fullBitm
private static Media getLastVideoThumbnail(ContentResolver resolver)
{
- Uri baseUri = Video.Media.EXTERNAL_CONTENT_URI;
-
- Uri query = baseUri.buildUpon().appendQueryParameter("limit", "1").build();
- String[] projection = new String[] { VideoColumns._ID, MediaColumns.DATA, VideoColumns.DATE_TAKEN };
- String selection = ImageColumns.MIME_TYPE + "='video/mp4'";
- String order = VideoColumns.DATE_TAKEN + " DESC," + VideoColumns._ID + " DESC";
+
+ Media internalMedia = null;
+ Media externalMedia = null;
- Cursor cursor = null;
try
{
- cursor = resolver.query(query, projection, selection, null, order);
- if (cursor != null && cursor.moveToFirst())
+ Uri baseUri = Video.Media.INTERNAL_CONTENT_URI;
+
+ Uri query = baseUri.buildUpon().appendQueryParameter("limit", "1").build();
+ String[] projection = new String[] { VideoColumns._ID, VideoColumns.DATA, VideoColumns.DATE_TAKEN };
+ String selection = VideoColumns.DATA + " like '" + PluginManager.getSaveDir(false).getAbsolutePath() + "%' AND " + VideoColumns.MIME_TYPE + "='video/mp4'";
+ String order = VideoColumns.DATE_TAKEN + " DESC," + VideoColumns._ID + " DESC";
+
+ Cursor cursor = null;
+
+ try
{
- Log.d(TAG, "getLastVideoThumbnail: " + cursor.getString(1));
- long id = cursor.getLong(0);
- return new Media(id, 0, cursor.getLong(2), ContentUris.withAppendedId(baseUri, id));
+ cursor = resolver.query(query, projection, selection, null, order);
+ if (cursor != null && cursor.moveToFirst())
+ {
+ final long id = cursor.getLong(0);
+ internalMedia = new Media(id, 0, cursor.getLong(2), ContentUris.withAppendedId(baseUri, id));
+ }
+ } finally
+ {
+ if (cursor != null)
+ {
+ cursor.close();
+ }
}
- } finally
+ } catch (Exception e)
{
- if (cursor != null)
+
+ }
+
+ try
+ {
+ Uri baseUri = Video.Media.EXTERNAL_CONTENT_URI;
+ Uri query = baseUri.buildUpon().appendQueryParameter("limit", "1").build();
+ String[] projection = new String[] { VideoColumns._ID, VideoColumns.DATA, VideoColumns.DATE_TAKEN };
+ String selection = VideoColumns.DATA + " like '" + PluginManager.getSaveDir(false).getAbsolutePath() + "%' AND " + VideoColumns.MIME_TYPE + "='video/mp4'";
+ String order = VideoColumns.DATE_TAKEN + " DESC," + VideoColumns._ID + " DESC";
+
+ Cursor cursor = null;
+
+ try
{
- cursor.close();
+ cursor = resolver.query(query, projection, selection, null, order);
+ if (cursor != null && cursor.moveToFirst())
+ {
+ final long id = cursor.getLong(0);
+ externalMedia = new Media(id, 0, cursor.getLong(2), ContentUris.withAppendedId(baseUri, id));
+ }
+ } finally
+ {
+ if (cursor != null)
+ {
+ cursor.close();
+ }
}
+ } catch (Exception e)
+ {
+
+ }
+
+ if (internalMedia == null)
+ {
+ return externalMedia;
+ } else if (externalMedia == null)
+ {
+ return internalMedia;
+ } else
+ {
+ return internalMedia.dateTaken > externalMedia.dateTaken ? internalMedia : externalMedia;
}
- return null;
}
public static Bitmap createVideoThumbnail(FileDescriptor fd, int targetWidth)
diff --git a/src/com/almalence/opencam/FolderPicker.java b/src/com/almalence/opencam/FolderPicker.java
index 66e9747b..bbd3571e 100755
--- a/src/com/almalence/opencam/FolderPicker.java
+++ b/src/com/almalence/opencam/FolderPicker.java
@@ -342,7 +342,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event)
if (keyCode == KeyEvent.KEYCODE_BACK)
{
- PreferenceManager.getDefaultSharedPreferences(this).edit().putString("saveToPref", "" + this.old_value)
+ PreferenceManager.getDefaultSharedPreferences(this).edit().putString(getResources().getString(R.string.Preference_SaveToValue), "" + this.old_value)
.commit();
}
diff --git a/src/com/almalence/opencam/Fragment.java b/src/com/almalence/opencam/Fragment.java
index 084e0c84..01043da9 100755
--- a/src/com/almalence/opencam/Fragment.java
+++ b/src/com/almalence/opencam/Fragment.java
@@ -109,7 +109,7 @@ public boolean onPreferenceClick(Preference preference)
}
});
- ListPreference saveToPreference = (ListPreference) this.findPreference("saveToPref");
+ ListPreference saveToPreference = (ListPreference) this.findPreference(getResources().getString(R.string.Preference_SaveToValue));
if (saveToPreference != null)
saveToPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener()
{
diff --git a/src/com/almalence/opencam/MainScreen.java b/src/com/almalence/opencam/MainScreen.java
index 409cb514..eab9374a 100755
--- a/src/com/almalence/opencam/MainScreen.java
+++ b/src/com/almalence/opencam/MainScreen.java
@@ -14,15 +14,15 @@
The Initial Developer of the Original Code is Almalence Inc.
Portions created by Initial Developer are Copyright (C) 2013
by Almalence Inc. All Rights Reserved.
-*/
+ */
/* */
+ package com.almalence.opencam_plus;
+ +++ --> */
//
+//-+- -->
import java.io.File;
import java.io.FileInputStream;
@@ -34,6 +34,12 @@ Portions created by Initial Developer are Copyright (C) 2013
import java.util.List;
import java.util.Map;
+import org.onepf.oms.OpenIabHelper;
+import org.onepf.oms.appstore.googleUtils.IabHelper;
+import org.onepf.oms.appstore.googleUtils.IabResult;
+import org.onepf.oms.appstore.googleUtils.Inventory;
+import org.onepf.oms.appstore.googleUtils.Purchase;
+
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
@@ -52,6 +58,7 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.hardware.Camera;
import android.hardware.Camera.Area;
import android.media.AudioManager;
+import android.media.CamcorderProfile;
import android.media.ImageReader;
import android.media.MediaPlayer;
import android.net.Uri;
@@ -90,28 +97,25 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.widget.RelativeLayout;
import android.widget.Toast;
-import com.almalence.util.AppWidgetNotifier;
-import com.almalence.util.Util;
-
import com.almalence.opencam.cameracontroller.CameraController;
import com.almalence.opencam.cameracontroller.HALv3;
//
/* */
+ import com.almalence.opencam_plus.ui.AlmalenceGUI;
+ import com.almalence.opencam_plus.ui.GLLayer;
+ import com.almalence.opencam_plus.ui.GUI;
+ +++ --> */
/***
* MainScreen - main activity screen with camera functionality
@@ -119,8 +123,8 @@ Portions created by Initial Developer are Copyright (C) 2013
* Passes all main events to PluginManager
***/
-public class MainScreen extends Activity implements ApplicationInterface, View.OnClickListener,
- View.OnTouchListener, SurfaceHolder.Callback, Handler.Callback, Camera.ShutterCallback
+public class MainScreen extends Activity implements ApplicationInterface, View.OnClickListener, View.OnTouchListener,
+ SurfaceHolder.Callback, Handler.Callback, Camera.ShutterCallback
{
// >>Description
// section with different global parameters available for everyone
@@ -130,72 +134,76 @@ public class MainScreen extends Activity implements ApplicationInterface, View.O
// Global defines and others
//
// Description<<
-
- private static final int MSG_RETURN_CAPTURED = -1;
-
- private static MainScreen thiz;
- private Context mainContext;
- private Handler messageHandler;
- //Interface to HALv3 camera and Old style camera
- private CameraController cameraController = null;
-
- //HALv3 camera's objects
- private ImageReader mImageReaderPreviewYUV;
- private ImageReader mImageReaderYUV;
- private ImageReader mImageReaderJPEG;
-
- private boolean captureYUVFrames = false; //Used for HALv3 to init YUV or JPEG surfaces for capturing.
- //Both type of surfaces are not supported in current version of HALv3
+ private static final int MSG_RETURN_CAPTURED = -1;
+
+ private static final int MODE_GENERAL = 0;
+ private static final int MODE_NIGHT = 1;
+ private static final int MODE_SMART_MULTISHOT = 2;
+ private static final int MODE_VIDEO = 3;
+
+ public static MainScreen thiz;
+ public Context mainContext;
+ private Handler messageHandler;
- private GUI guiManager = null;
+ // Interface to HALv3 camera and Old style camera
+ private CameraController cameraController = null;
+
+ // HALv3 camera's objects
+ private ImageReader mImageReaderPreviewYUV;
+ private ImageReader mImageReaderYUV;
+ private ImageReader mImageReaderJPEG;
+
+ private boolean captureYUVFrames = false;
+
+ public GUI guiManager = null;
// OpenGL layer. May be used to allow capture plugins to draw overlaying
// preview, such as night vision or panorama frames.
- private GLLayer glView;
+ private GLLayer glView;
- private boolean mPausing = false;
-
- private File forceFilename = null;
- private Uri forceFilenameUri;
+ private boolean mPausing = false;
- private SurfaceHolder surfaceHolder;
- private SurfaceView preview;
- private Surface mCameraSurface = null;
- private OrientationEventListener orientListener;
- private boolean landscapeIsNormal = false;
- private boolean surfaceCreated = false;
+ private File forceFilename = null;
+ private Uri forceFilenameUri;
+
+ private SurfaceHolder surfaceHolder;
+ private SurfaceView preview;
+ private Surface mCameraSurface = null;
+ private OrientationEventListener orientListener;
+ private boolean landscapeIsNormal = false;
+ private boolean surfaceCreated = false;
// shared between activities
- private int imageWidth, imageHeight;
- private int previewWidth, previewHeight;
- private int saveImageWidth, saveImageHeight;
+ private int imageWidth, imageHeight;
+ private int previewWidth, previewHeight;
+ private int saveImageWidth, saveImageHeight;
- private CountDownTimer screenTimer = null;
- private boolean isScreenTimerRunning = false;
+ private CountDownTimer screenTimer = null;
+ private boolean isScreenTimerRunning = false;
- private static boolean wantLandscapePhoto = false;
- private int orientationMain = 0;
- private int orientationMainPrevious = 0;
+ private static boolean wantLandscapePhoto = false;
+ private int orientationMain = 0;
+ private int orientationMainPrevious = 0;
- private SoundPlayer shutterPlayer = null;
+ private SoundPlayer shutterPlayer = null;
// Common preferences
- private String imageSizeIdxPreference;
- private boolean shutterPreference = true;
- private boolean shotOnTapPreference = false;
-
- private boolean showHelp = false;
-
- private boolean keepScreenOn = false;
-
- private String saveToPath;
- private String saveToPreference;
- private boolean sortByDataPreference;
-
- private static boolean maxScreenBrightnessPreference;
-
- private static boolean mAFLocked = false;
+ private String imageSizeIdxPreference;
+ private boolean shutterPreference = true;
+ private boolean shotOnTapPreference = false;
+
+ private boolean showHelp = false;
+
+ private boolean keepScreenOn = false;
+
+ private String saveToPath;
+ private String saveToPreference;
+ private boolean sortByDataPreference;
+
+ private static boolean maxScreenBrightnessPreference;
+
+ private static boolean mAFLocked = false;
// >>Description
// section with initialize, resume, start, stop procedures, preferences
@@ -207,89 +215,78 @@ public class MainScreen extends Activity implements ApplicationInterface, View.O
//
// Description<<
- private static boolean isCreating = false;
- private static boolean mApplicationStarted = false;
-
- public static final String EXTRA_ITEM = "WidgetModeID"; //Clicked mode id from widget.
- public static final String EXTRA_TORCH = "WidgetTorchMode";
- public static final String EXTRA_BARCODE = "WidgetBarcodeMode";
- public static final String EXTRA_SHOP = "WidgetGoShopping";
-
- private static boolean launchTorch = false;
- private static boolean launchBarcode = false;
- private static boolean goShopping = false;
-
- private static int prefFlash = -1;
- private static boolean prefBarcode = false;
-
- private static final int VOLUME_FUNC_SHUTTER = 0;
- private static final int VOLUME_FUNC_EXPO = 2;
- private static final int VOLUME_FUNC_NONE = 3;
-
- private static String deviceSS3_01;
- private static String deviceSS3_02;
- private static String deviceSS3_03;
- private static String deviceSS3_04;
- private static String deviceSS3_05;
- private static String deviceSS3_06;
- private static String deviceSS3_07;
- private static String deviceSS3_08;
- private static String deviceSS3_09;
- private static String deviceSS3_10;
- private static String deviceSS3_11;
- private static String deviceSS3_12;
- private static String deviceSS3_13;
-
- private static List mMeteringAreaMatrix5 = new ArrayList();
- private static List mMeteringAreaMatrix4 = new ArrayList();
- private static List mMeteringAreaMatrix1 = new ArrayList();
- private static List mMeteringAreaCenter = new ArrayList();
- private static List mMeteringAreaSpot = new ArrayList();
-
- private int currentMeteringMode = -1;
-
- public static String sEvPref;
- public static String sSceneModePref;
- public static String sWBModePref;
- public static String sFrontFocusModePref;
- public static String sRearFocusModePref;
- public static String sFlashModePref;
- public static String sISOPref;
- public static String sMeteringModePref;
-
- public static String sDelayedCapturePref;
- public static String sShowDelayedCapturePref;
- public static String sDelayedSoundPref;
- public static String sDelayedFlashPref;
- public static String sDelayedCaptureIntervalPref;
-
- private static String sUseFrontCameraPref;
- private static String sShutterPref;
- private static String sShotOnTapPref;
- private static String sVolumeButtonPref;
-
- private static String sImageSizeRearPref;
- private static String sImageSizeFrontPref;
-
- public static String sJPEGQualityPref;
-
- public static String sDefaultInfoSetPref;
- public static String sSWCheckedPref;
- public static String sSavePathPref;
- public static String sSaveToPref;
- public static String sSortByDataPref;
-
- public static String sDefaultModeName;
-
- public static int sDefaultValue = CameraParameters.SCENE_MODE_AUTO;
- public static int sDefaultFocusValue = CameraParameters.AF_MODE_CONTINUOUS_PICTURE;
- public static int sDefaultFlashValue = CameraParameters.FLASH_MODE_OFF;
+ private static boolean isCreating = false;
+ private static boolean mApplicationStarted = false;
+ private static boolean mCameraStarted = false;
+
+ // Clicked mode id from widget.
+ public static final String EXTRA_ITEM = "WidgetModeID";
+
+ public static final String EXTRA_TORCH = "WidgetTorchMode";
+ public static final String EXTRA_BARCODE = "WidgetBarcodeMode";
+ public static final String EXTRA_SHOP = "WidgetGoShopping";
+
+ private static boolean launchTorch = false;
+ private static boolean launchBarcode = false;
+ private static boolean goShopping = false;
+
+ private static int prefFlash = -1;
+ private static boolean prefBarcode = false;
+
+ private static final int VOLUME_FUNC_SHUTTER = 0;
+ private static final int VOLUME_FUNC_EXPO = 2;
+ private static final int VOLUME_FUNC_NONE = 3;
+
+ private static List mMeteringAreaMatrix5 = new ArrayList();
+ private static List mMeteringAreaMatrix4 = new ArrayList();
+ private static List mMeteringAreaMatrix1 = new ArrayList();
+ private static List mMeteringAreaCenter = new ArrayList();
+ private static List mMeteringAreaSpot = new ArrayList();
+
+ private int currentMeteringMode = -1;
+
+ public static String sEvPref;
+ public static String sSceneModePref;
+ public static String sWBModePref;
+ public static String sFrontFocusModePref;
+ public static String sRearFocusModePref;
+ public static String sFlashModePref;
+ public static String sISOPref;
+ public static String sMeteringModePref;
+
+ public static String sDelayedCapturePref;
+ public static String sShowDelayedCapturePref;
+ public static String sDelayedSoundPref;
+ public static String sDelayedFlashPref;
+ public static String sDelayedCaptureIntervalPref;
+
+ private static String sUseFrontCameraPref;
+ private static String sShutterPref;
+ private static String sShotOnTapPref;
+ private static String sVolumeButtonPref;
+
+ private static String sImageSizeRearPref;
+ private static String sImageSizeFrontPref;
+
+ public static String sJPEGQualityPref;
+
+ public static String sDefaultInfoSetPref;
+ public static String sSWCheckedPref;
+ public static String sSavePathPref;
+ public static String sSaveToPref;
+ public static String sSortByDataPref;
+
+ public static String sDefaultModeName;
+
+ public static int sDefaultValue = CameraParameters.SCENE_MODE_AUTO;
+ public static int sDefaultFocusValue = CameraParameters.AF_MODE_CONTINUOUS_PICTURE;
+ public static int sDefaultFlashValue = CameraParameters.FLASH_MODE_OFF;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
-
+
sEvPref = getResources().getString(R.string.Preference_EvCompensationValue);
sSceneModePref = getResources().getString(R.string.Preference_SceneModeValue);
sWBModePref = getResources().getString(R.string.Preference_WBModeValue);
@@ -298,51 +295,37 @@ public void onCreate(Bundle savedInstanceState)
sFlashModePref = getResources().getString(R.string.Preference_FlashModeValue);
sISOPref = getResources().getString(R.string.Preference_ISOValue);
sMeteringModePref = getResources().getString(R.string.Preference_MeteringModeValue);
-
+
sDelayedCapturePref = getResources().getString(R.string.Preference_DelayedCaptureValue);
sShowDelayedCapturePref = getResources().getString(R.string.Preference_ShowDelayedCaptureValue);
sDelayedSoundPref = getResources().getString(R.string.Preference_DelayedSoundValue);
sDelayedFlashPref = getResources().getString(R.string.Preference_DelayedFlashValue);
sDelayedCaptureIntervalPref = getResources().getString(R.string.Preference_DelayedCaptureIntervalValue);
-
+
sUseFrontCameraPref = getResources().getString(R.string.Preference_UseFrontCameraValue);
sShutterPref = getResources().getString(R.string.Preference_ShutterCommonValue);
sShotOnTapPref = getResources().getString(R.string.Preference_ShotOnTapValue);
sVolumeButtonPref = getResources().getString(R.string.Preference_VolumeButtonValue);
-
+
sImageSizeRearPref = getResources().getString(R.string.Preference_ImageSizeRearValue);
sImageSizeFrontPref = getResources().getString(R.string.Preference_ImageSizeFrontValue);
-
+
sJPEGQualityPref = getResources().getString(R.string.Preference_JPEGQualityCommonValue);
-
- sDefaultInfoSetPref = getResources().getString(R.string.Preference_DefaultInfoSetValue);
+
+ sDefaultInfoSetPref = getResources().getString(R.string.Preference_DefaultInfoSetValue);
sSWCheckedPref = getResources().getString(R.string.Preference_SWCheckedValue);
sSavePathPref = getResources().getString(R.string.Preference_SavePathValue);
sSaveToPref = getResources().getString(R.string.Preference_SaveToValue);
sSortByDataPref = getResources().getString(R.string.Preference_SortByDataValue);
-
+
sDefaultModeName = getResources().getString(R.string.Preference_DefaultModeName);
-
- deviceSS3_01 = getResources().getString(R.string.device_name_ss3_01);
- deviceSS3_02 = getResources().getString(R.string.device_name_ss3_02);
- deviceSS3_03 = getResources().getString(R.string.device_name_ss3_03);
- deviceSS3_04 = getResources().getString(R.string.device_name_ss3_04);
- deviceSS3_05 = getResources().getString(R.string.device_name_ss3_05);
- deviceSS3_06 = getResources().getString(R.string.device_name_ss3_06);
- deviceSS3_07 = getResources().getString(R.string.device_name_ss3_07);
- deviceSS3_08 = getResources().getString(R.string.device_name_ss3_08);
- deviceSS3_09 = getResources().getString(R.string.device_name_ss3_09);
- deviceSS3_10 = getResources().getString(R.string.device_name_ss3_10);
- deviceSS3_11 = getResources().getString(R.string.device_name_ss3_11);
- deviceSS3_12 = getResources().getString(R.string.device_name_ss3_12);
- deviceSS3_13 = getResources().getString(R.string.device_name_ss3_13);
Intent intent = this.getIntent();
String mode = intent.getStringExtra(EXTRA_ITEM);
launchTorch = intent.getBooleanExtra(EXTRA_TORCH, false);
launchBarcode = intent.getBooleanExtra(EXTRA_BARCODE, false);
goShopping = intent.getBooleanExtra(EXTRA_SHOP, false);
-
+
mainContext = this.getBaseContext();
messageHandler = new Handler(this);
thiz = this;
@@ -353,102 +336,120 @@ public void onCreate(Bundle savedInstanceState)
// ensure landscape orientation
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// set to fullscreen
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN|WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
+ getWindow().addFlags(
+ WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
+ | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
// set some common view here
setContentView(R.layout.opencamera_main_layout);
-
- //reset or save settings
+
+ // reset or save settings
resetOrSaveSettings();
-
+
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
-
- if(null != mode)
+
+ if (null != mode)
prefs.edit().putString("defaultModeName", mode).commit();
-
- if(launchTorch)
+
+ if (launchTorch)
{
prefFlash = prefs.getInt(sFlashModePref, CameraParameters.FLASH_MODE_AUTO);
prefs.edit().putInt(sFlashModePref, CameraParameters.FLASH_MODE_TORCH).commit();
}
-
- if(launchBarcode)
+
+ if (launchBarcode)
{
prefBarcode = prefs.getBoolean("PrefBarcodescannerVF", false);
prefs.edit().putBoolean("PrefBarcodescannerVF", true).commit();
}
-
+
//
-
+ // -+- -->
+
AppWidgetNotifier.app_launched(this);
try
{
cameraController = CameraController.getInstance();
- }
- catch(VerifyError exp)
+ } catch (VerifyError exp)
{
Log.e("MainScreen", exp.getMessage());
}
- cameraController.onCreate(MainScreen.thiz, MainScreen.thiz, PluginManager.getInstance());
-
-
+ cameraController.onCreate(MainScreen.thiz, MainScreen.thiz, PluginManager.getInstance());
+
// set preview, on click listener and surface buffers
preview = (SurfaceView) this.findViewById(R.id.SurfaceView01);
- preview.setZOrderMediaOverlay(true);
preview.setOnClickListener(this);
preview.setOnTouchListener(this);
preview.setKeepScreenOn(true);
surfaceHolder = preview.getHolder();
surfaceHolder.addCallback(this);
-// surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
-// if(!CameraController.isUseHALv3())
-// {
-// surfaceHolder.addCallback(this);
-// surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
-// }
-
- orientListener = new OrientationEventListener(this) {
+ // surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
+ // if(!CameraController.isUseHALv3())
+ // {
+ // surfaceHolder.addCallback(this);
+ // surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
+ // }
+
+ orientListener = new OrientationEventListener(this)
+ {
@Override
- public void onOrientationChanged(int orientation) {
+ public void onOrientationChanged(int orientation)
+ {
// figure landscape or portrait
- if (MainScreen.thiz.landscapeIsNormal) {
+ if (MainScreen.thiz.landscapeIsNormal)
+ {
orientation += 90;
}
- if ((orientation < 45)
- || (orientation > 315 && orientation < 405)
- || ((orientation > 135) && (orientation < 225))) {
- if (MainScreen.wantLandscapePhoto) {
+ if ((orientation < 45) || (orientation > 315 && orientation < 405)
+ || ((orientation > 135) && (orientation < 225)))
+ {
+ if (MainScreen.wantLandscapePhoto)
+ {
MainScreen.wantLandscapePhoto = false;
}
- } else {
- if (!MainScreen.wantLandscapePhoto) {
+ } else
+ {
+ if (!MainScreen.wantLandscapePhoto)
+ {
MainScreen.wantLandscapePhoto = true;
}
}
@@ -462,8 +463,8 @@ else if ((orientation < 325) && (orientation > 225))
orientationMain = 0;
else if ((orientation < 135) && (orientation > 45))
orientationMain = 180;
-
- if(orientationMain != orientationMainPrevious)
+
+ if (orientationMain != orientationMainPrevious)
{
orientationMainPrevious = orientationMain;
}
@@ -472,16 +473,20 @@ else if ((orientation < 135) && (orientation > 45))
keepScreenOn = prefs.getBoolean("keepScreenOn", false);
// prevent power drain
- screenTimer = new CountDownTimer(180000, 180000) {
- public void onTick(long millisUntilFinished) {
- //Not used
+ screenTimer = new CountDownTimer(180000, 180000)
+ {
+ public void onTick(long millisUntilFinished)
+ {
+ // Not used
}
- public void onFinish() {
- boolean isVideoRecording = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext()).getBoolean("videorecording", false);
+ public void onFinish()
+ {
+ boolean isVideoRecording = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext())
+ .getBoolean("videorecording", false);
if (isVideoRecording || keepScreenOn)
{
- //restart timer
+ // restart timer
screenTimer.start();
isScreenTimerRunning = true;
preview.setKeepScreenOn(true);
@@ -505,311 +510,382 @@ public void onFinish() {
// init plugin manager
PluginManager.getInstance().onCreate();
- if (this.getIntent().getAction() != null)
+ if (this.getIntent().getAction() != null)
{
- if (this.getIntent().getAction().equals(MediaStore.ACTION_IMAGE_CAPTURE))
+ if (this.getIntent().getAction().equals(MediaStore.ACTION_IMAGE_CAPTURE))
{
- try
+ try
{
- forceFilenameUri = this.getIntent().getExtras()
- .getParcelable(MediaStore.EXTRA_OUTPUT);
+ forceFilenameUri = this.getIntent().getExtras().getParcelable(MediaStore.EXTRA_OUTPUT);
MainScreen.setForceFilename(new File(((Uri) forceFilenameUri).getPath()));
- if (MainScreen.getForceFilename().getAbsolutePath().equals("/scrapSpace"))
+ if (MainScreen.getForceFilename().getAbsolutePath().equals("/scrapSpace"))
{
- MainScreen.setForceFilename(new File(Environment
- .getExternalStorageDirectory()
- .getAbsolutePath()
- + "/mms/scrapSpace/.temp.jpg"));
+ MainScreen.setForceFilename(new File(Environment.getExternalStorageDirectory()
+ .getAbsolutePath() + "/mms/scrapSpace/.temp.jpg"));
new File(MainScreen.getForceFilename().getParent()).mkdirs();
}
- }
- catch (Exception e)
+ } catch (Exception e)
{
MainScreen.setForceFilename(null);
}
- }
- else
+ } else
{
MainScreen.setForceFilename(null);
}
- } else {
+ } else
+ {
MainScreen.setForceFilename(null);
}
-
+
//
+ // -+- -->
}
-
-
-
-
+
/*
- * Get/Set method for private variables
+ * Get/Set method for private variables
*/
public static MainScreen getInstance()
{
return thiz;
}
-
+
public static Context getMainContext()
{
return thiz.mainContext;
}
-
+
public static Handler getMessageHandler()
{
return thiz.messageHandler;
}
-
+
public static CameraController getCameraController()
{
return thiz.cameraController;
}
-
+
public static GUI getGUIManager()
{
return thiz.guiManager;
}
-
- @TargetApi(19)
+
+ @TargetApi(21)
public static void createImageReaders()
{
- //ImageReader for preview frames in YUV format
- thiz.mImageReaderPreviewYUV = ImageReader.newInstance(thiz.previewWidth, thiz.previewHeight, ImageFormat.YUV_420_888, 1);
-
- //ImageReader for YUV still images
+ // ImageReader for preview frames in YUV format
+ thiz.mImageReaderPreviewYUV = ImageReader.newInstance(thiz.previewWidth, thiz.previewHeight,
+ ImageFormat.YUV_420_888, 1);
+
+ // ImageReader for YUV still images
thiz.mImageReaderYUV = ImageReader.newInstance(thiz.imageWidth, thiz.imageHeight, ImageFormat.YUV_420_888, 1);
-
- //ImageReader for JPEG still images
+
+ // ImageReader for JPEG still images
thiz.mImageReaderJPEG = ImageReader.newInstance(thiz.imageWidth, thiz.imageHeight, ImageFormat.JPEG, 1);
}
-
+
public static ImageReader getPreviewYUVImageReader()
{
return thiz.mImageReaderPreviewYUV;
}
-
+
public static ImageReader getYUVImageReader()
{
return thiz.mImageReaderYUV;
}
-
+
public static ImageReader getJPEGImageReader()
{
return thiz.mImageReaderJPEG;
}
-
+
public static boolean isCaptureYUVFrames()
{
return thiz.captureYUVFrames;
}
-
+
public static void setCaptureYUVFrames(boolean captureYUV)
{
thiz.captureYUVFrames = captureYUV;
}
-
+
public static File getForceFilename()
{
return thiz.forceFilename;
}
-
+
public static void setForceFilename(File fileName)
{
thiz.forceFilename = fileName;
}
-
+
public static Uri getForceFilenameURI()
{
return thiz.forceFilenameUri;
}
-
+
public static SurfaceHolder getPreviewSurfaceHolder()
{
return thiz.surfaceHolder;
}
-
+
public static SurfaceView getPreviewSurfaceView()
{
return thiz.preview;
}
-
+
public static int getOrientation()
{
return thiz.orientationMain;
}
-
+
public static String getImageSizeIndex()
{
return thiz.imageSizeIdxPreference;
}
-
+
public static boolean isShutterSoundEnabled()
{
return thiz.shutterPreference;
}
-
+
public static boolean isShotOnTap()
{
return thiz.shotOnTapPreference;
}
-
+
public static boolean isShowHelp()
{
return thiz.showHelp;
}
-
+
public static void setShowHelp(boolean show)
{
thiz.showHelp = show;
}
-
+
public static String getSaveToPath()
{
return thiz.saveToPath;
}
-
+
public static String getSaveTo()
{
return thiz.saveToPreference;
}
-
+
public static boolean isSortByData()
{
return thiz.sortByDataPreference;
}
-
- public static boolean isDeviceModelProhibited()
- {
- return (Build.MODEL.contains(MainScreen.deviceSS3_01) || Build.MODEL.contains(MainScreen.deviceSS3_02) ||
- Build.MODEL.contains(MainScreen.deviceSS3_03) || Build.MODEL.contains(MainScreen.deviceSS3_04) ||
- Build.MODEL.contains(MainScreen.deviceSS3_05) || Build.MODEL.contains(MainScreen.deviceSS3_06) ||
- Build.MODEL.contains(MainScreen.deviceSS3_07) || Build.MODEL.contains(MainScreen.deviceSS3_08) ||
- Build.MODEL.contains(MainScreen.deviceSS3_09) || Build.MODEL.contains(MainScreen.deviceSS3_10) ||
- Build.MODEL.contains(MainScreen.deviceSS3_11) || Build.MODEL.contains(MainScreen.deviceSS3_12) || Build.MODEL.contains(MainScreen.deviceSS3_13));
- }
-
+
public static int getMeteringMode()
{
return thiz.currentMeteringMode;
}
- /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Get/Set method for private variables
+
+ /*
+ * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Get/Set method for private variables
*/
-
-
public void onPreferenceCreate(PreferenceFragment prefActivity)
{
- CharSequence[] entries;
- CharSequence[] entryValues;
+ setImageSizeOptions(prefActivity, MODE_GENERAL);
+ setImageSizeOptions(prefActivity, MODE_NIGHT);
+ setImageSizeOptions(prefActivity, MODE_SMART_MULTISHOT);
+ setImageSizeOptions(prefActivity, MODE_VIDEO);
+ }
- if (CameraController.getResolutionsIdxesList() != null) {
- entries = CameraController.getResolutionsNamesList()
- .toArray(new CharSequence[CameraController.getResolutionsNamesList().size()]);
- entryValues = CameraController.getResolutionsIdxesList()
- .toArray(new CharSequence[CameraController.getResolutionsIdxesList().size()]);
+ private void setImageSizeOptions(PreferenceFragment prefActivity, int mode)
+ {
+ CharSequence[] entries = null;
+ CharSequence[] entryValues = null;
-
- ListPreference lp = (ListPreference) prefActivity
- .findPreference("imageSizePrefCommonBack");
- ListPreference lp2 = (ListPreference) prefActivity
- .findPreference("imageSizePrefCommonFront");
-
- if(CameraController.getCameraIndex() == 0 && lp2 != null && lp != null)
+ int idx = 0;
+ int currentIdx = -1;
+ String opt1 = "";
+ String opt2 = "";
+
+ if (mode == MODE_GENERAL)
+ {
+ opt1 = "imageSizePrefCommonBack";
+ opt2 = "imageSizePrefCommonFront";
+ currentIdx = CameraController.getCameraImageSizeIndex();
+ entries = CameraController.getResolutionsNamesList().toArray(
+ new CharSequence[CameraController.getResolutionsNamesList().size()]);
+ entryValues = CameraController.getResolutionsIdxesList().toArray(
+ new CharSequence[CameraController.getResolutionsIdxesList().size()]);
+ } else if (mode == MODE_NIGHT)
+ {
+ opt1 = "imageSizePrefNightBack";
+ opt2 = "imageSizePrefNightFront";
+ NightCapturePlugin.selectImageDimensionNight();
+ currentIdx = NightCapturePlugin.CapIdx;
+ entries = NightCapturePlugin.getResolutionsNamesList().toArray(
+ new CharSequence[NightCapturePlugin.getResolutionsNamesList().size()]);
+ entryValues = NightCapturePlugin.getResolutionsIdxesList().toArray(
+ new CharSequence[NightCapturePlugin.getResolutionsIdxesList().size()]);
+ } else if (mode == MODE_SMART_MULTISHOT)
+ {
+ opt1 = "imageSizePrefSmartMultishotBack";
+ opt2 = "imageSizePrefSmartMultishotFront";
+ MultiShotCapturePlugin.selectImageDimensionMultishot();
+ currentIdx = MultiShotCapturePlugin.getCaptureIndex();
+ entries = MultiShotCapturePlugin.getResolutionsNamesList().toArray(
+ new CharSequence[MultiShotCapturePlugin.getResolutionsNamesList().size()]);
+ entryValues = MultiShotCapturePlugin.getResolutionsIdxesList().toArray(
+ new CharSequence[MultiShotCapturePlugin.getResolutionsIdxesList().size()]);
+ } else if (mode == MODE_VIDEO)
+ {
+ opt1 = "imageSizePrefVideoBack";
+ opt2 = "imageSizePrefVideoFront";
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
+ currentIdx = Integer.parseInt(prefs.getString(CameraController.getCameraIndex() == 0 ? opt1 : opt2, "2"));
+
+ CharSequence[] entriesTmp = new CharSequence[6];
+ CharSequence[] entryValuesTmp = new CharSequence[6];
+ if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), VideoCapturePlugin.QUALITY_4K))
{
- prefActivity.getPreferenceScreen().removePreference(lp2);
- lp.setEntries(entries);
- lp.setEntryValues(entryValues);
+ entriesTmp[idx] = "4K";
+ entryValuesTmp[idx] = "5";
+ idx++;
}
- else if(lp2 != null && lp != null)
+ if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_1080P))
{
- prefActivity.getPreferenceScreen().removePreference(lp);
- lp2.setEntries(entries);
- lp2.setEntryValues(entryValues);
+ entriesTmp[idx] = "1080p";
+ entryValuesTmp[idx] = "2";
+ idx++;
+ }
+ if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_720P))
+ {
+ entriesTmp[idx] = "720p";
+ entryValuesTmp[idx] = "3";
+ idx++;
+ }
+ if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_480P))
+ {
+ entriesTmp[idx] = "480p";
+ entryValuesTmp[idx] = "4";
+ idx++;
+ }
+ if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_CIF))
+ {
+ entriesTmp[idx] = "352 x 288";
+ entryValuesTmp[idx] = "1";
+ idx++;
+ }
+ if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_QCIF))
+ {
+ entriesTmp[idx] = "176 x 144";
+ entryValuesTmp[idx] = "0";
+ idx++;
}
- else
- return;
- // set currently selected image size
- int idx;
- for (idx = 0; idx < CameraController.getResolutionsIdxesList().size(); ++idx) {
- if (idx == CameraController.getCameraImageSizeIndex()) {
- break;
- }
+ entries = new CharSequence[idx];
+ entryValues = new CharSequence[idx];
+
+ for (int i = 0; i < idx; i++)
+ {
+ entries[i] = entriesTmp[i];
+ entryValues[i] = entryValuesTmp[i];
}
- if (idx < CameraController.getResolutionsIdxesList().size()) {
- if(CameraController.getCameraIndex() == 0)
- lp.setValueIndex(idx);
- else
- lp2.setValueIndex(idx);
+ }
+
+ if (CameraController.getResolutionsIdxesList() != null)
+ {
+ ListPreference lp = (ListPreference) prefActivity.findPreference(opt1);
+ ListPreference lp2 = (ListPreference) prefActivity.findPreference(opt2);
+
+ if (CameraController.getCameraIndex() == 0 && lp2 != null)
+ prefActivity.getPreferenceScreen().removePreference(lp2);
+ else if (lp != null && lp2 != null)
+ {
+ prefActivity.getPreferenceScreen().removePreference(lp);
+ lp = lp2;
}
- if(CameraController.getCameraIndex() == 0)
- lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
- public boolean onPreferenceChange(Preference preference,
- Object newValue) {
- int value = Integer.parseInt(newValue.toString());
- CameraController.setCameraImageSizeIndex(value);
- return true;
- }
- });
- else
- lp2.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
- public boolean onPreferenceChange(Preference preference,
- Object newValue) {
- int value = Integer.parseInt(newValue.toString());
- CameraController.setCameraImageSizeIndex(value);
- return true;
+ if (lp != null)
+ {
+ lp.setEntries(entries);
+ lp.setEntryValues(entryValues);
+
+ // set currently selected image size
+ for (idx = 0; idx < entryValues.length; ++idx)
+ {
+ if (Integer.valueOf(entryValues[idx].toString()) == currentIdx)
+ {
+ break;
}
- });
-
+ }
+ if (idx < CameraController.getResolutionsIdxesList().size())
+ {
+ if (CameraController.getCameraIndex() == 0)
+ lp.setValueIndex(idx);
+ else
+ lp2.setValueIndex(idx);
+ }
+ if (mode == MODE_GENERAL)
+ {
+ lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener()
+ {
+ public boolean onPreferenceChange(Preference preference, Object newValue)
+ {
+ int value = Integer.parseInt(newValue.toString());
+ CameraController.setCameraImageSizeIndex(value);
+ return true;
+ }
+ });
+ }
+ }
}
+
}
-
+
public void onAdvancePreferenceCreate(PreferenceFragment prefActivity)
{
- CheckBoxPreference cp = (CheckBoxPreference)prefActivity.findPreference(getResources().getString(R.string.Preference_UseHALv3Key));
- if(cp != null)
+ CheckBoxPreference cp = (CheckBoxPreference) prefActivity.findPreference(getResources().getString(
+ R.string.Preference_UseHALv3Key));
+ if (cp != null)
{
- if(!CameraController.isHALv3Supported())
+ if (!CameraController.isHALv3Supported())
cp.setEnabled(false);
else
cp.setEnabled(true);
- }
+ }
}
-
+
public void glSetRenderingMode(final int renderMode)
- {
- if (renderMode != GLSurfaceView.RENDERMODE_WHEN_DIRTY
- && renderMode != GLSurfaceView.RENDERMODE_CONTINUOUSLY)
- {
- throw new IllegalArgumentException();
- }
-
- final GLSurfaceView surfaceView = glView;
- if (surfaceView != null)
- {
- surfaceView.setRenderMode(renderMode);
- }
- }
-
- public void glRequestRender()
- {
- final GLSurfaceView surfaceView = glView;
- if (surfaceView != null)
- {
- surfaceView.requestRender();
- }
- }
+ {
+ if (renderMode != GLSurfaceView.RENDERMODE_WHEN_DIRTY && renderMode != GLSurfaceView.RENDERMODE_CONTINUOUSLY)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ final GLSurfaceView surfaceView = glView;
+ if (surfaceView != null)
+ {
+ surfaceView.setRenderMode(renderMode);
+ }
+ }
+
+ public void glRequestRender()
+ {
+ final GLSurfaceView surfaceView = glView;
+ if (surfaceView != null)
+ {
+ surfaceView.requestRender();
+ }
+ }
+
public void queueGLEvent(final Runnable runnable)
{
final GLSurfaceView surfaceView = glView;
@@ -824,12 +900,12 @@ public int glGetPreviewTexture()
{
return glView.getPreviewTexture();
}
-
+
public SurfaceTexture glGetSurfaceTexture()
{
return glView.getSurfaceTexture();
}
-
+
@Override
protected void onStart()
{
@@ -839,7 +915,6 @@ protected void onStart()
PluginManager.getInstance().onStart();
}
-
@Override
protected void onStop()
{
@@ -850,12 +925,12 @@ protected void onStop()
MainScreen.getGUIManager().onStop();
PluginManager.getInstance().onStop();
MainScreen.getCameraController().onStop();
-
- if(CameraController.isUseHALv3())
+
+ if (CameraController.isUseHALv3())
stopImageReaders();
}
-
- @TargetApi(19)
+
+ @TargetApi(21)
private void stopImageReaders()
{
// IamgeReader should be closed
@@ -876,17 +951,16 @@ private void stopImageReaders()
}
}
-
@Override
protected void onDestroy()
- {
+ {
super.onDestroy();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
- if(launchTorch && prefs.getInt(sFlashModePref, -1) == CameraParameters.FLASH_MODE_TORCH)
+ if (launchTorch && prefs.getInt(sFlashModePref, -1) == CameraParameters.FLASH_MODE_TORCH)
{
prefs.edit().putInt(sFlashModePref, prefFlash).commit();
}
- if(launchBarcode && prefs.getBoolean("PrefBarcodescannerVF", false))
+ if (launchBarcode && prefs.getBoolean("PrefBarcodescannerVF", false))
{
prefs.edit().putBoolean("PrefBarcodescannerVF", prefBarcode).commit();
}
@@ -898,96 +972,85 @@ protected void onDestroy()
/**** Billing *****/
destroyBillingHandler();
/**** Billing *****/
- //-+- -->
-
+ // -+- -->
+
this.hideOpenGLLayer();
}
-
@Override
protected void onResume()
{
super.onResume();
-
+
if (!isCreating)
- new CountDownTimer(50, 50) {
- public void onTick(long millisUntilFinished) {
- //Not used
+ new CountDownTimer(50, 50)
+ {
+ public void onTick(long millisUntilFinished)
+ {
+ // Not used
}
- public void onFinish() {
+ public void onFinish()
+ {
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(MainScreen.getMainContext());
-
+
updatePreferences();
-
+
captureYUVFrames = false;
-
- saveToPath = prefs.getString(sSavePathPref, Environment
- .getExternalStorageDirectory().getAbsolutePath());
+
+ saveToPath = prefs.getString(sSavePathPref, Environment.getExternalStorageDirectory()
+ .getAbsolutePath());
saveToPreference = prefs.getString(MainScreen.sSaveToPref, "0");
- sortByDataPreference = prefs.getBoolean(MainScreen.sSortByDataPref,
- false);
-
+ sortByDataPreference = prefs.getBoolean(MainScreen.sSortByDataPref, false);
+
maxScreenBrightnessPreference = prefs.getBoolean("maxScreenBrightnessPref", false);
setScreenBrightness(maxScreenBrightnessPreference);
-
- CameraController.useHALv3(prefs.getBoolean(getResources().getString(R.string.Preference_UseHALv3Key), false));
-
+
+ CameraController.useHALv3(prefs.getBoolean(getResources()
+ .getString(R.string.Preference_UseHALv3Key), false));
+
MainScreen.getGUIManager().onResume();
PluginManager.getInstance().onResume();
MainScreen.thiz.mPausing = false;
-
- if(CameraController.isUseHALv3())
+
+ if (CameraController.isUseHALv3())
{
MainScreen.thiz.findViewById(R.id.mainLayout2).setVisibility(View.VISIBLE);
Log.e("MainScreen", "onResume: cameraController.setupCamera(null)");
cameraController.setupCamera(null);
-
+
if (glView != null)
{
glView.onResume();
Log.e("GL", "glView onResume");
}
-
+
PluginManager.getInstance().onGUICreate();
MainScreen.getGUIManager().onGUICreate();
-
- if (showStore)
- {
- guiManager.showStore();
- showStore = false;
- }
- }
- else if (surfaceCreated && (!CameraController.isCameraCreated()))
+ } else if (surfaceCreated && (!CameraController.isCameraCreated()))
{
MainScreen.thiz.findViewById(R.id.mainLayout2).setVisibility(View.VISIBLE);
cameraController.setupCamera(surfaceHolder);
-
+
if (glView != null)
{
glView.onResume();
Log.e("GL", "glView onResume");
}
-
+
PluginManager.getInstance().onGUICreate();
MainScreen.getGUIManager().onGUICreate();
-
- if (showStore)
- {
- guiManager.showStore();
- showStore = false;
- }
- }
+ }
orientListener.enable();
}
- }.start();
-
+ }.start();
- shutterPlayer = new SoundPlayer(this.getBaseContext(), getResources()
- .openRawResourceFd(R.raw.plugin_capture_tick));
+ shutterPlayer = new SoundPlayer(this.getBaseContext(), getResources().openRawResourceFd(
+ R.raw.plugin_capture_tick));
- if (screenTimer != null) {
+ if (screenTimer != null)
+ {
if (isScreenTimerRunning)
screenTimer.cancel();
screenTimer.start();
@@ -995,23 +1058,39 @@ else if (surfaceCreated && (!CameraController.isCameraCreated()))
}
Log.e("Density", "" + getResources().getDisplayMetrics().toString());
-
+
long memoryFree = getAvailableInternalMemory();
- if (memoryFree<30)
- Toast.makeText(MainScreen.getMainContext(), "Almost no free space left on internal storage.", Toast.LENGTH_LONG).show();
+ if (memoryFree < 30)
+ Toast.makeText(MainScreen.getMainContext(), "Almost no free space left on internal storage.",
+ Toast.LENGTH_LONG).show();
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
+ boolean dismissKeyguard = prefs.getBoolean("dismissKeyguard", true);
+ if (dismissKeyguard)
+ getWindow()
+ .addFlags(
+ WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
+ | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
+ else
+ getWindow()
+ .clearFlags(
+ WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
+ | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
}
-
-
+
public void relaunchCamera()
{
- if(CameraController.isUseHALv3())
+ if (CameraController.isUseHALv3())
{
- new CountDownTimer(100, 100) {
- public void onTick(long millisUntilFinished) {
- //Not used
+ new CountDownTimer(100, 100)
+ {
+ public void onTick(long millisUntilFinished)
+ {
+ // Not used
}
- public void onFinish() {
+ public void onFinish()
+ {
PluginManager.getInstance().switchMode(
ConfigParser.getInstance().getMode(PluginManager.getInstance().getActiveModeID()));
}
@@ -1027,22 +1106,20 @@ private long getAvailableInternalMemory()
long availableBlocks = stat.getAvailableBlocks();
return availableBlocks * blockSize / 1048576;
}
-
+
private void updatePreferences()
{
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
- CameraController.setCameraIndex(!prefs.getBoolean(MainScreen.sUseFrontCameraPref, false)? 0 : 1);
- shutterPreference = prefs.getBoolean(MainScreen.sShutterPref,
- false);
- shotOnTapPreference = prefs.getBoolean(MainScreen.sShotOnTapPref,
- false);
- imageSizeIdxPreference = prefs.getString(CameraController.getCameraIndex() == 0 ?
- MainScreen.sImageSizeRearPref : MainScreen.sImageSizeFrontPref, "-1");
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
+ CameraController.setCameraIndex(!prefs.getBoolean(MainScreen.sUseFrontCameraPref, false) ? 0 : 1);
+ shutterPreference = prefs.getBoolean(MainScreen.sShutterPref, false);
+ shotOnTapPreference = prefs.getBoolean(MainScreen.sShotOnTapPref, false);
+ imageSizeIdxPreference = prefs.getString(CameraController.getCameraIndex() == 0 ? MainScreen.sImageSizeRearPref
+ : MainScreen.sImageSizeFrontPref, "-1");
}
-
+
@Override
- protected void onPause() {
+ protected void onPause()
+ {
super.onPause();
mApplicationStarted = false;
@@ -1051,7 +1128,8 @@ protected void onPause() {
orientListener.disable();
- if (shutterPreference) {
+ if (shutterPreference)
+ {
AudioManager mgr = (AudioManager) MainScreen.thiz
.getSystemService(MainScreen.getMainContext().AUDIO_SERVICE);
mgr.setStreamMute(AudioManager.STREAM_SYSTEM, false);
@@ -1061,141 +1139,155 @@ protected void onPause() {
this.hideOpenGLLayer();
- if (screenTimer != null) {
+ if (screenTimer != null)
+ {
if (isScreenTimerRunning)
screenTimer.cancel();
isScreenTimerRunning = false;
}
cameraController.onPause();
-
+
this.findViewById(R.id.mainLayout2).setVisibility(View.INVISIBLE);
- if (shutterPlayer != null) {
+ if (shutterPlayer != null)
+ {
shutterPlayer.release();
shutterPlayer = null;
}
}
- public void pauseMain() {
+ public void pauseMain()
+ {
onPause();
}
- public void stopMain() {
+ public void stopMain()
+ {
onStop();
}
- public void startMain() {
+ public void startMain()
+ {
onStart();
}
- public void resumeMain() {
+ public void resumeMain()
+ {
onResume();
}
@Override
- public void surfaceChanged(final SurfaceHolder holder, final int format,
- final int width, final int height) {
+ public void surfaceChanged(final SurfaceHolder holder, final int format, final int width, final int height)
+ {
if (!isCreating)
- new CountDownTimer(50, 50) {
- public void onTick(long millisUntilFinished) {
- //Not used
+ new CountDownTimer(50, 50)
+ {
+ public void onTick(long millisUntilFinished)
+ {
+ // Not used
}
- public void onFinish() {
+ public void onFinish()
+ {
updatePreferences();
- if (!MainScreen.thiz.mPausing && surfaceCreated
- && (!CameraController.isCameraCreated())) {
- MainScreen.thiz.findViewById(R.id.mainLayout2)
- .setVisibility(View.VISIBLE);
+ if (!MainScreen.thiz.mPausing && surfaceCreated && (!CameraController.isCameraCreated()))
+ {
+ MainScreen.thiz.findViewById(R.id.mainLayout2).setVisibility(View.VISIBLE);
Log.e("MainScreen", "surfaceChanged: cameraController.setupCamera(null)");
- if(!CameraController.isUseHALv3())
+ if (!CameraController.isUseHALv3())
{
cameraController.setupCamera(holder);
PluginManager.getInstance().onGUICreate();
MainScreen.getGUIManager().onGUICreate();
- }
- else
+ } else
{
messageHandler.sendEmptyMessage(PluginManager.MSG_SURFACE_READY);
- }
+ }
}
}
}.start();
- else {
+ else
+ {
updatePreferences();
}
}
-
+
public void onSurfaceChangedMain(final SurfaceHolder holder, final int width, final int height)
{
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
CameraController.setCameraImageSizeIndex(!prefs.getBoolean("useFrontCamera", false) ? 0 : 1);
- shutterPreference = prefs.getBoolean("shutterPrefCommon",
- false);
- shotOnTapPreference = prefs.getBoolean("shotontapPrefCommon",
- false);
- imageSizeIdxPreference = prefs.getString(CameraController.getCameraIndex() == 0 ?
- "imageSizePrefCommonBack" : "imageSizePrefCommonFront", "-1");
-
- if (!MainScreen.thiz.mPausing && surfaceCreated
- && (!CameraController.isCameraCreated())) {
- MainScreen.thiz.findViewById(R.id.mainLayout2)
- .setVisibility(View.VISIBLE);
-
- if(CameraController.isUseHALv3())
+ shutterPreference = prefs.getBoolean("shutterPrefCommon", false);
+ shotOnTapPreference = prefs.getBoolean("shotontapPrefCommon", false);
+ imageSizeIdxPreference = prefs.getString(CameraController.getCameraIndex() == 0 ? "imageSizePrefCommonBack"
+ : "imageSizePrefCommonFront", "-1");
+
+ if (!MainScreen.thiz.mPausing && surfaceCreated && (!CameraController.isCameraCreated()))
+ {
+ MainScreen.thiz.findViewById(R.id.mainLayout2).setVisibility(View.VISIBLE);
+
+ if (CameraController.isUseHALv3())
messageHandler.sendEmptyMessage(PluginManager.MSG_SURFACE_READY);
else
{
Log.e("MainScreen", "surfaceChangedMain: cameraController.setupCamera(null)");
cameraController.setupCamera(holder);
-// PluginManager.getInstance().onGUICreate();
-// MainScreen.getGUIManager().onGUICreate();
+ // PluginManager.getInstance().onGUICreate();
+ // MainScreen.getGUIManager().onGUICreate();
}
}
- }
-
-
+ }
+
@Override
public void addSurfaceCallback()
{
thiz.surfaceHolder.addCallback(thiz);
}
-
+
@Override
public void configureCamera()
{
Log.e("MainScreen", "configureCamera()");
-
+
CameraController.getInstance().updateCameraFeatures();
// prepare list of surfaces to be used in capture requests
- if(CameraController.isUseHALv3())
+ if (CameraController.isUseHALv3())
configureHALv3Camera(captureYUVFrames);
else
{
- // ----- Select preview dimensions with ratio correspondent to full-size image
+ // ----- Select preview dimensions with ratio correspondent to
+ // full-size image
PluginManager.getInstance().setCameraPreviewSize(CameraController.getInstance().getCameraParameters());
-
+
Camera.Size sz = CameraController.getInstance().getCameraParameters().getPreviewSize();
-
+
guiManager.setupViewfinderPreviewSize(cameraController.new Size(sz.width, sz.height));
- CameraController.getInstance().allocatePreviewBuffer(sz.width * sz.height
- * ImageFormat.getBitsPerPixel(CameraController.getInstance().getCameraParameters().getPreviewFormat()) / 8);
+ CameraController.getInstance().allocatePreviewBuffer(
+ sz.width
+ * sz.height
+ * ImageFormat.getBitsPerPixel(CameraController.getInstance().getCameraParameters()
+ .getPreviewFormat()) / 8);
+
+ CameraController.getCamera().setErrorCallback(CameraController.getInstance());
+
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_CAMERA_CONFIGURED, 0);
}
- if(!CameraController.isUseHALv3())
- CameraController.getCamera().setErrorCallback(CameraController.getInstance());
-
+ }
+
+
+ private void onCameraConfigured()
+ {
PluginManager.getInstance().setCameraPictureSize();
PluginManager.getInstance().setupCameraParameters();
- if(!CameraController.isUseHALv3())
+ if (!CameraController.isUseHALv3())
{
- try {
+ try
+ {
// Nexus 5 is giving preview which is too dark without this
if (Build.MODEL.contains("Nexus 5"))
{
@@ -1203,9 +1295,9 @@ public void configureCamera()
params.setPreviewFpsRange(7000, 30000);
cameraController.setCameraParameters(params);
}
- } catch (RuntimeException e) {
- Log.e("CameraTest", "MainScreen.setupCamera unable setParameters "
- + e.getMessage());
+ } catch (RuntimeException e)
+ {
+ Log.e("CameraTest", "MainScreen.setupCamera unable setParameters " + e.getMessage());
}
previewWidth = CameraController.getInstance().getCameraParameters().getPreviewSize().width;
@@ -1216,15 +1308,14 @@ public void configureCamera()
{
Util.initialize(mainContext);
Util.initializeMeteringMatrix();
- }
- catch(Exception e)
+ } catch (Exception e)
{
Log.e("Main setup camera", "Util.initialize failed!");
}
-
+
prepareMeteringAreas();
- if(!CameraController.isUseHALv3())
+ if (!CameraController.isUseHALv3())
{
guiManager.onCameraCreate();
PluginManager.getInstance().onCameraParametersSetup();
@@ -1237,23 +1328,24 @@ public void configureCamera()
new CountDownTimer(10, 10)
{
@Override
- public void onFinish()
+ public void onFinish()
{
- if(!CameraController.isUseHALv3())
+ if (!CameraController.isUseHALv3())
{
- // exceptions sometimes happen here when resuming after processing
+ // exceptions sometimes happen here when resuming after
+ // processing
try
{
CameraController.startCameraPreview();
- } catch (RuntimeException e) {
+ } catch (RuntimeException e)
+ {
Toast.makeText(MainScreen.thiz, "Unable to start camera", Toast.LENGTH_LONG).show();
return;
}
CameraController.getCamera().setPreviewCallbackWithBuffer(CameraController.getInstance());
CameraController.getCamera().addCallbackBuffer(CameraController.getInstance().getPreviewBuffer());
- }
- else
+ } else
{
guiManager.onCameraCreate();
PluginManager.getInstance().onCameraParametersSetup();
@@ -1266,140 +1358,138 @@ public void onFinish()
}
@Override
- public void onTick(long millisUntilFinished) {
- //Not used
+ public void onTick(long millisUntilFinished)
+ {
+ // Not used
}
}.start();
}
-
-
-
+
@SuppressLint("NewApi")
- @TargetApi(19)
+ @TargetApi(21)
private void configureHALv3Camera(boolean captureYUVFrames)
{
List sfl = new ArrayList();
-
- sfl.add(mCameraSurface); // surface for viewfinder preview
- sfl.add(mImageReaderPreviewYUV.getSurface()); // surface for preview yuv images
- if(captureYUVFrames)
+
+ sfl.add(mCameraSurface); // surface for viewfinder preview
+ sfl.add(mImageReaderPreviewYUV.getSurface()); // surface for preview yuv
+ // images
+ if (captureYUVFrames)
{
Log.e("MainScreen", "add mImageReaderYUV");
- sfl.add(mImageReaderYUV.getSurface()); // surface for yuv image capture
- }
- else
+ sfl.add(mImageReaderYUV.getSurface()); // surface for yuv image
+ // capture
+ } else
{
Log.e("MainScreen", "add mImageReaderJPEG");
- sfl.add(mImageReaderJPEG.getSurface()); // surface for jpeg image capture
+ sfl.add(mImageReaderJPEG.getSurface()); // surface for jpeg image
+ // capture
}
-
+
cameraController.setPreviewSurface(mImageReaderPreviewYUV.getSurface());
guiManager.setupViewfinderPreviewSize(cameraController.new Size(1280, 720));
-
+
// configure camera with all the surfaces to be ever used
- try {
- Log.e("MainScreen", "HALv3.getCamera2().configureOutputs(sfl);");
- HALv3.getCamera2().configureOutputs(sfl);
- } catch (Exception e) {
- Log.e("MainScreen", "configureOutputs failed. " + e.getMessage());
- e.printStackTrace();
- }
-
try
{
- HALv3.getInstance().configurePreviewRequest();
-
- }
- catch (Exception e)
+ Log.e("MainScreen", "HALv3.getCamera2().configureOutputs(sfl);");
+ HALv3.getCamera2().createCaptureSession(sfl,
+ HALv3.captureSessionStateListener,
+ null);
+ } catch (Exception e)
{
- Log.d("MainScreen", "setting up preview failed");
+ Log.e("MainScreen", "configureOutputs failed. " + e.getMessage());
e.printStackTrace();
}
- // ^^ HALv3 code -------------------------------------------------------------------
+
+ // ^^ HALv3 code
+ // -------------------------------------------------------------------
}
-
-
+
private void prepareMeteringAreas()
{
- Rect centerRect = Util.convertToDriverCoordinates(new Rect(previewWidth/4, previewHeight/4, previewWidth - previewWidth/4, previewHeight - previewHeight/4));
- Rect topLeftRect = Util.convertToDriverCoordinates(new Rect(0, 0, previewWidth/2, previewHeight/2));
- Rect topRightRect = Util.convertToDriverCoordinates(new Rect(previewWidth/2, 0, previewWidth, previewHeight/2));
- Rect bottomRightRect = Util.convertToDriverCoordinates(new Rect(previewWidth/2, previewHeight/2, previewWidth, previewHeight));
- Rect bottomLeftRect = Util.convertToDriverCoordinates(new Rect(0, previewHeight/2, previewWidth/2, previewHeight));
- Rect spotRect = Util.convertToDriverCoordinates(new Rect(previewWidth/2 - 10, previewHeight/2 - 10, previewWidth/2 + 10, previewHeight/2 + 10));
-
+ Rect centerRect = Util.convertToDriverCoordinates(new Rect(previewWidth / 4, previewHeight / 4, previewWidth
+ - previewWidth / 4, previewHeight - previewHeight / 4));
+ Rect topLeftRect = Util.convertToDriverCoordinates(new Rect(0, 0, previewWidth / 2, previewHeight / 2));
+ Rect topRightRect = Util.convertToDriverCoordinates(new Rect(previewWidth / 2, 0, previewWidth,
+ previewHeight / 2));
+ Rect bottomRightRect = Util.convertToDriverCoordinates(new Rect(previewWidth / 2, previewHeight / 2,
+ previewWidth, previewHeight));
+ Rect bottomLeftRect = Util.convertToDriverCoordinates(new Rect(0, previewHeight / 2, previewWidth / 2,
+ previewHeight));
+ Rect spotRect = Util.convertToDriverCoordinates(new Rect(previewWidth / 2 - 10, previewHeight / 2 - 10,
+ previewWidth / 2 + 10, previewHeight / 2 + 10));
+
mMeteringAreaMatrix5.clear();
mMeteringAreaMatrix5.add(new Area(centerRect, 600));
mMeteringAreaMatrix5.add(new Area(topLeftRect, 200));
mMeteringAreaMatrix5.add(new Area(topRightRect, 200));
mMeteringAreaMatrix5.add(new Area(bottomRightRect, 200));
mMeteringAreaMatrix5.add(new Area(bottomLeftRect, 200));
-
+
mMeteringAreaMatrix4.clear();
mMeteringAreaMatrix4.add(new Area(topLeftRect, 250));
mMeteringAreaMatrix4.add(new Area(topRightRect, 250));
mMeteringAreaMatrix4.add(new Area(bottomRightRect, 250));
mMeteringAreaMatrix4.add(new Area(bottomLeftRect, 250));
-
+
mMeteringAreaMatrix1.clear();
mMeteringAreaMatrix1.add(new Area(centerRect, 1000));
-
+
mMeteringAreaCenter.clear();
mMeteringAreaCenter.add(new Area(centerRect, 1000));
-
+
mMeteringAreaSpot.clear();
mMeteringAreaSpot.add(new Area(spotRect, 1000));
}
-
@Override
- public void surfaceCreated(SurfaceHolder holder) {
+ public void surfaceCreated(SurfaceHolder holder)
+ {
// ----- Find 'normal' orientation of the device
- Display display = ((WindowManager) this
- .getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
+ Display display = ((WindowManager) this.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int rotation = display.getRotation();
- if ((rotation == Surface.ROTATION_90)
- || (rotation == Surface.ROTATION_270))
+ if ((rotation == Surface.ROTATION_90) || (rotation == Surface.ROTATION_270))
landscapeIsNormal = true; // false; - if landscape view orientation
// set for MainScreen
else
landscapeIsNormal = false;
surfaceCreated = true;
-
+
mCameraSurface = surfaceHolder.getSurface();
-
+
Log.e("MainScreen", "SURFACE CREATED");
}
@Override
- public void surfaceDestroyed(SurfaceHolder holder) {
+ public void surfaceDestroyed(SurfaceHolder holder)
+ {
surfaceCreated = false;
}
-
-
- //SURFACES (preview, image readers)
+
+ // SURFACES (preview, image readers)
public Surface getCameraSurface()
{
return mCameraSurface;
}
-
- @TargetApi(19)
+
+ @TargetApi(21)
public Surface getPreviewYUVSurface()
{
return mImageReaderPreviewYUV.getSurface();
}
-
-
@TargetApi(14)
- public boolean isFaceDetectionAvailable(Camera.Parameters params) {
+ public boolean isFaceDetectionAvailable(Camera.Parameters params)
+ {
return params.getMaxNumDetectedFaces() > 0;
}
- public CameraController.Size getPreviewSize() {
+ public CameraController.Size getPreviewSize()
+ {
LayoutParams lp = preview.getLayoutParams();
if (lp == null)
return null;
@@ -1412,54 +1502,54 @@ public CameraController.Size getPreviewSize() {
* need an icons of supported camera parameters (scene, iso, wb, flash,
* focus) Methods return id of drawable icon
*/
- public int getSceneIcon(int sceneMode) {
+ public int getSceneIcon(int sceneMode)
+ {
return guiManager.getSceneIcon(sceneMode);
}
- public int getWBIcon(int wb) {
+ public int getWBIcon(int wb)
+ {
return guiManager.getWBIcon(wb);
}
- public int getFocusIcon(int focusMode) {
+ public int getFocusIcon(int focusMode)
+ {
return guiManager.getFocusIcon(focusMode);
}
- public int getFlashIcon(int flashMode) {
+ public int getFlashIcon(int flashMode)
+ {
return guiManager.getFlashIcon(flashMode);
}
- public int getISOIcon(int isoMode) {
+ public int getISOIcon(int isoMode)
+ {
return guiManager.getISOIcon(isoMode);
- }
+ }
-
-
public void setCameraMeteringMode(int mode)
{
- if(CameraParameters.meteringModeAuto == mode)
+ if (CameraParameters.meteringModeAuto == mode)
cameraController.setCameraMeteringAreas(null);
- else if(CameraParameters.meteringModeMatrix == mode)
- {
+ else if (CameraParameters.meteringModeMatrix == mode)
+ {
int maxAreasCount = CameraController.getInstance().getMaxNumMeteringAreas();
- if(maxAreasCount > 4)
+ if (maxAreasCount > 4)
cameraController.setCameraMeteringAreas(mMeteringAreaMatrix5);
- else if(maxAreasCount > 3)
+ else if (maxAreasCount > 3)
cameraController.setCameraMeteringAreas(mMeteringAreaMatrix4);
- else if(maxAreasCount > 0)
+ else if (maxAreasCount > 0)
cameraController.setCameraMeteringAreas(mMeteringAreaMatrix1);
else
- cameraController.setCameraMeteringAreas(null);
- }
- else if(CameraParameters.meteringModeCenter == mode)
+ cameraController.setCameraMeteringAreas(null);
+ } else if (CameraParameters.meteringModeCenter == mode)
cameraController.setCameraMeteringAreas(mMeteringAreaCenter);
- else if(CameraParameters.meteringModeSpot == mode)
+ else if (CameraParameters.meteringModeSpot == mode)
cameraController.setCameraMeteringAreas(mMeteringAreaSpot);
-
+
currentMeteringMode = mode;
}
-
-
/*
*
* CAMERA parameters access function ended
@@ -1471,45 +1561,45 @@ else if(CameraParameters.meteringModeSpot == mode)
// all events translated to PluginManager
// Description<<
-
-
public static void setAutoFocusLock(boolean locked)
{
mAFLocked = locked;
}
-
+
public static boolean getAutoFocusLock()
{
return mAFLocked;
}
@Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
+ public boolean onKeyDown(int keyCode, KeyEvent event)
+ {
if (!mApplicationStarted)
return true;
- //menu button processing
- if (keyCode == KeyEvent.KEYCODE_MENU) {
+ // menu button processing
+ if (keyCode == KeyEvent.KEYCODE_MENU)
+ {
menuButtonPressed();
return true;
}
- //shutter/camera button processing
- if (keyCode == KeyEvent.KEYCODE_CAMERA
- || keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
+ // shutter/camera button processing
+ if (keyCode == KeyEvent.KEYCODE_CAMERA || keyCode == KeyEvent.KEYCODE_DPAD_CENTER)
+ {
MainScreen.getGUIManager().onHardwareShutterButtonPressed();
return true;
}
- //focus/half-press button processing
- if (keyCode == KeyEvent.KEYCODE_FOCUS) {
+ // focus/half-press button processing
+ if (keyCode == KeyEvent.KEYCODE_FOCUS)
+ {
MainScreen.getGUIManager().onHardwareFocusButtonPressed();
return true;
}
-
- //check if Headset Hook button has some functions except standard
- if ( keyCode == KeyEvent.KEYCODE_HEADSETHOOK )
+
+ // check if Headset Hook button has some functions except standard
+ if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK)
{
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
boolean headsetFunc = prefs.getBoolean("headsetPrefCommon", false);
if (headsetFunc)
{
@@ -1518,29 +1608,25 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
return true;
}
}
-
- //check if volume button has some functions except Zoom-ing
- if ( keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP )
+
+ // check if volume button has some functions except Zoom-ing
+ if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP)
{
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
int buttonFunc = Integer.parseInt(prefs.getString(MainScreen.sVolumeButtonPref, "0"));
if (buttonFunc == VOLUME_FUNC_SHUTTER)
{
MainScreen.getGUIManager().onHardwareFocusButtonPressed();
MainScreen.getGUIManager().onHardwareShutterButtonPressed();
return true;
- }
- else if (buttonFunc == VOLUME_FUNC_EXPO)
+ } else if (buttonFunc == VOLUME_FUNC_EXPO)
{
MainScreen.getGUIManager().onVolumeBtnExpo(keyCode);
return true;
- }
- else if (buttonFunc == VOLUME_FUNC_NONE)
+ } else if (buttonFunc == VOLUME_FUNC_NONE)
return true;
}
-
-
+
if (PluginManager.getInstance().onKeyDown(true, keyCode, event))
return true;
if (guiManager.onKeyDown(true, keyCode, event))
@@ -1548,52 +1634,54 @@ else if (buttonFunc == VOLUME_FUNC_NONE)
//
-
+ {
+ if (AppRater.showRateDialogIfNeeded(this))
+ {
+ return true;
+ }
+ if (AppWidgetNotifier.showNotifierDialogIfNeeded(this))
+ {
+ return true;
+ }
+ }
+ // -+- -->
+
if (super.onKeyDown(keyCode, event))
return true;
return false;
}
@Override
- public void onClick(View v) {
+ public void onClick(View v)
+ {
if (mApplicationStarted)
MainScreen.getGUIManager().onClick(v);
}
@Override
- public boolean onTouch(View view, MotionEvent event) {
+ public boolean onTouch(View view, MotionEvent event)
+ {
if (mApplicationStarted)
return MainScreen.getGUIManager().onTouch(view, event);
return true;
}
- public boolean onTouchSuper(View view, MotionEvent event) {
+ public boolean onTouchSuper(View view, MotionEvent event)
+ {
return super.onTouchEvent(event);
}
- public void onButtonClick(View v) {
+ public void onButtonClick(View v)
+ {
MainScreen.getGUIManager().onButtonClick(v);
}
-
+
@Override
public void onShutter()
{
PluginManager.getInstance().onShutter();
}
-
-
// >>Description
// message processor
//
@@ -1603,14 +1691,19 @@ public void onShutter()
//
// Description<<
@Override
- public boolean handleMessage(Message msg) {
+ public boolean handleMessage(Message msg)
+ {
- switch(msg.what)
+ switch (msg.what)
{
case MSG_RETURN_CAPTURED:
this.setResult(RESULT_OK);
this.finish();
break;
+ case PluginManager.MSG_CAMERA_CONFIGURED:
+ Log.e("MainScreen", "case PluginManager.MSG_CAMERA_CONFIGURED");
+ onCameraConfigured();
+ break;
case PluginManager.MSG_CAMERA_READY:
{
configureCamera();
@@ -1618,18 +1711,26 @@ public boolean handleMessage(Message msg) {
MainScreen.getGUIManager().onGUICreate();
} break;
case PluginManager.MSG_CAMERA_OPENED:
+ Log.e("MainScreen", "case PluginManager.MSG_CAMERA_OPENED");
+ if(mCameraStarted)
+ break;
case PluginManager.MSG_SURFACE_READY:
{
// if both surface is created and camera device is opened
// - ready to set up preview and other things
if (surfaceCreated && (HALv3.getCamera2() != null))
{
- Log.e("MainScreen", "case PluginManager.MSG_CAMERA_OPENED and case PluginManager.MSG_SURFACE_READY:");
+ Log.e("MainScreen", "case PluginManager.MSG_SURFACE_READY");
configureCamera();
PluginManager.getInstance().onGUICreate();
MainScreen.getGUIManager().onGUICreate();
+ mCameraStarted = true;
}
- } break;
+ } break;
+ case PluginManager.MSG_CAMERA_STOPED:
+ Log.e("MainScreen", "case PluginManager.MSG_CAMERA_STOPED");
+ mCameraStarted = false;
+ break;
default:
PluginManager.getInstance().handleMessage(msg);
break;
@@ -1638,12 +1739,13 @@ public boolean handleMessage(Message msg) {
return true;
}
- public void menuButtonPressed() {
+ public void menuButtonPressed()
+ {
PluginManager.getInstance().menuButtonPressed();
}
- public void disableCameraParameter(GUI.CameraParameter iParam,
- boolean bDisable, boolean bInitMenu) {
+ public void disableCameraParameter(GUI.CameraParameter iParam, boolean bDisable, boolean bInitMenu)
+ {
guiManager.disableCameraParameter(iParam, bDisable, bInitMenu);
}
@@ -1652,9 +1754,9 @@ public void showOpenGLLayer(final int version)
if (glView == null)
{
glView = new GLLayer(MainScreen.getMainContext(), version);
- glView.setLayoutParams(new LayoutParams(
- LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
- ((RelativeLayout)this.findViewById(R.id.mainLayout2)).addView(glView, 1);
+ glView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
+ ((RelativeLayout) this.findViewById(R.id.mainLayout2)).addView(glView, 0);
+ preview.bringToFront();
glView.setZOrderMediaOverlay(true);
}
}
@@ -1663,188 +1765,236 @@ public void hideOpenGLLayer()
{
if (glView != null)
{
+ //preview.getHolder().getSurface().lockCanvas(null).drawColor(Color.BLACK);
glView.onPause();
- ((RelativeLayout)this.findViewById(R.id.mainLayout2)).removeView(glView);
+ ((RelativeLayout) this.findViewById(R.id.mainLayout2)).removeView(glView);
glView = null;
}
}
- public void playShutter(int sound) {
- if (!MainScreen.isShutterSoundEnabled()) {
- MediaPlayer mediaPlayer = MediaPlayer
- .create(MainScreen.thiz, sound);
+ public void playShutter(int sound)
+ {
+ if (!MainScreen.isShutterSoundEnabled())
+ {
+ MediaPlayer mediaPlayer = MediaPlayer.create(MainScreen.thiz, sound);
mediaPlayer.start();
}
}
- public void playShutter() {
- if (!MainScreen.isShutterSoundEnabled()) {
+ public void playShutter()
+ {
+ if (!MainScreen.isShutterSoundEnabled())
+ {
if (shutterPlayer != null)
shutterPlayer.play();
}
}
// set TRUE to mute and FALSE to unmute
- public void muteShutter(boolean mute) {
- if (MainScreen.isShutterSoundEnabled()) {
+ public void muteShutter(boolean mute)
+ {
+ if (MainScreen.isShutterSoundEnabled())
+ {
AudioManager mgr = (AudioManager) MainScreen.thiz
.getSystemService(MainScreen.getMainContext().AUDIO_SERVICE);
mgr.setStreamMute(AudioManager.STREAM_SYSTEM, mute);
}
}
- public static int getImageWidth() {
+ public static int getImageWidth()
+ {
return thiz.imageWidth;
}
- public static void setImageWidth(int setImageWidth) {
+ public static void setImageWidth(int setImageWidth)
+ {
thiz.imageWidth = setImageWidth;
}
- public static int getImageHeight() {
+ public static int getImageHeight()
+ {
return thiz.imageHeight;
}
- public static void setImageHeight(int setImageHeight) {
+ public static void setImageHeight(int setImageHeight)
+ {
thiz.imageHeight = setImageHeight;
}
- public static int getSaveImageWidth() {
+ public static int getSaveImageWidth()
+ {
return thiz.saveImageWidth;
}
- public static void setSaveImageWidth(int setSaveImageWidth) {
+ public static void setSaveImageWidth(int setSaveImageWidth)
+ {
thiz.saveImageWidth = setSaveImageWidth;
}
- public static int getSaveImageHeight() {
+ public static int getSaveImageHeight()
+ {
return thiz.saveImageHeight;
}
- public static void setSaveImageHeight(int setSaveImageHeight) {
+ public static void setSaveImageHeight(int setSaveImageHeight)
+ {
thiz.saveImageHeight = setSaveImageHeight;
}
-
- public static int getPreviewWidth(){
+
+ public static int getPreviewWidth()
+ {
return thiz.previewWidth;
}
-
- public static void setPreviewWidth(int iWidth){
+
+ public static void setPreviewWidth(int iWidth)
+ {
thiz.previewWidth = iWidth;
}
-
- public static int getPreviewHeight(){
- return thiz.previewWidth;
+
+ public static int getPreviewHeight()
+ {
+ return thiz.previewHeight;
}
-
- public static void setPreviewHeight(int iHeight){
+
+ public static void setPreviewHeight(int iHeight)
+ {
thiz.previewHeight = iHeight;
}
- public static boolean getWantLandscapePhoto() {
+ public static boolean getWantLandscapePhoto()
+ {
return wantLandscapePhoto;
}
- public static void setWantLandscapePhoto(boolean setWantLandscapePhoto) {
+ public static void setWantLandscapePhoto(boolean setWantLandscapePhoto)
+ {
wantLandscapePhoto = setWantLandscapePhoto;
}
-
+
public void setScreenBrightness(boolean setMax)
{
Window window = getWindow();
WindowManager.LayoutParams layoutpars = window.getAttributes();
-
- //Set the brightness of this window
- if(setMax)
+
+ // Set the brightness of this window
+ if (setMax)
layoutpars.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL;
else
layoutpars.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
- //Apply attribute changes to this window
- window.setAttributes(layoutpars);
+ // Apply attribute changes to this window
+ window.setAttributes(layoutpars);
}
/*******************************************************/
/************************ Billing ************************/
- private boolean showStore = false;
-//
-
+
+ // -+- -->
+
/************************ Billing ************************/
/*******************************************************/
-
-//
-
- //widget ad code
+ {
+ try
+ {
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setData(Uri.parse("market://details?id=com.almalence.opencam"));
+ act.startActivity(intent);
+ } catch (ActivityNotFoundException e)
+ {
+ return;
+ }
+ }
+
+ // -+- -->
+
+ // widget ad code
public static void callStoreWidgetInstall(Activity act)
- {
- try
- {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse("market://details?id=com.almalence.opencamwidget"));
- act.startActivity(intent);
- }
- catch(ActivityNotFoundException e)
- {
- return;
- }
- }
-
+ {
+ try
+ {
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setData(Uri.parse("market://details?id=com.almalence.opencamwidget"));
+ act.startActivity(intent);
+ } catch (ActivityNotFoundException e)
+ {
+ return;
+ }
+ }
+
private void resetOrSaveSettings()
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
@@ -2510,62 +2874,62 @@ private void resetOrSaveSettings()
prefsEditor.putString("defaultModeName", "single");
prefsEditor.commit();
}
-
+
isSaving = prefs.getBoolean("SaveConfiguration_ImageSize", true);
if (!isSaving)
- {
- //general settings - image size
+ {
+ // general settings - image size
prefsEditor.putString("imageSizePrefCommonBack", "-1");
prefsEditor.putString("imageSizePrefCommonFront", "-1");
- //night hi sped image size
+ // night hi sped image size
prefsEditor.putString("imageSizePrefNightBack", "-1");
prefsEditor.putString("pref_plugin_capture_panoramaaugmented_imageheight", "0");
prefsEditor.commit();
}
-
+
isSaving = prefs.getBoolean("SaveConfiguration_SceneMode", false);
if (!isSaving)
- {
+ {
prefsEditor.putInt(sSceneModePref, sDefaultValue);
prefsEditor.commit();
}
-
+
isSaving = prefs.getBoolean("SaveConfiguration_FocusMode", true);
if (!isSaving)
- {
+ {
prefsEditor.putInt("sRearFocusModePref", sDefaultFocusValue);
prefsEditor.putInt(sFrontFocusModePref, sDefaultFocusValue);
prefsEditor.commit();
}
-
+
isSaving = prefs.getBoolean("SaveConfiguration_WBMode", false);
if (!isSaving)
- {
+ {
prefsEditor.putInt(sWBModePref, sDefaultValue);
prefsEditor.commit();
}
-
+
isSaving = prefs.getBoolean("SaveConfiguration_ISOMode", false);
if (!isSaving)
- {
+ {
prefsEditor.putInt(sISOPref, sDefaultValue);
prefsEditor.commit();
}
-
+
isSaving = prefs.getBoolean("SaveConfiguration_FlashMode", true);
if (!isSaving)
- {
+ {
prefsEditor.putInt(sFlashModePref, sDefaultValue);
prefsEditor.commit();
}
-
+
isSaving = prefs.getBoolean("SaveConfiguration_FrontRearCamera", true);
if (!isSaving)
- {
+ {
prefsEditor.putBoolean("useFrontCamera", false);
prefsEditor.commit();
}
-
+
isSaving = prefs.getBoolean("SaveConfiguration_ExpoCompensation", false);
if (!isSaving)
{
diff --git a/src/com/almalence/opencam/Plugin.java b/src/com/almalence/opencam/Plugin.java
index cd42f71c..85529d14 100755
--- a/src/com/almalence/opencam/Plugin.java
+++ b/src/com/almalence/opencam/Plugin.java
@@ -236,12 +236,14 @@ public void onShutter()
{
}
- public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
+ public void onImageTaken(int frame, byte[] frameData, int frame_len, boolean isYUV)
{
+
}
-
- public void onImageAvailable(Image im)
+
+ public void onPreviewFrame(byte[] data)
{
+
}
@TargetApi(19)
@@ -249,15 +251,11 @@ public void onCaptureCompleted(CaptureResult result)
{
}
- public void onPreviewAvailable(Image im)
- {
- }
-
- public void onPreviewFrame(byte[] data, Camera paramCamera)
- {
- }
+ private int MIN_MPIX_SUPPORTED = 1280 * 960;
- private int MIN_MPIX_SUPPORTED = 1280 * 960;
+ private long MPIX_8 = 3504 * 2336; // Actually 8.2 mpix,
+ // some reserve for
+ // unusual cameras;
public void selectImageDimension()
{
@@ -290,10 +288,10 @@ public void selectImageDimension()
cs.add(additional);
}
}
- int Capture5mIdx = -1;
- long Capture5mMpix = 0;
- int Capture5mWidth = 0;
- int Capture5mHeight = 0;
+ int defaultCaptureIdx = -1;
+ long defaultCaptureMpix = 0;
+ int defaultCaptureWidth = 0;
+ int defaultCaptureHeight = 0;
long CaptureMpix = 0;
int CaptureWidth = 0;
int CaptureHeight = 0;
@@ -308,12 +306,12 @@ public void selectImageDimension()
if ((mpix >= MIN_MPIX_SUPPORTED) && (mpix < maxMpix))
{
- if (mpix > Capture5mMpix)
+ if (mpix > defaultCaptureMpix && mpix <= MPIX_8)
{
- Capture5mIdx = ii;
- Capture5mMpix = mpix;
- Capture5mWidth = s.getWidth();
- Capture5mHeight = s.getHeight();
+ defaultCaptureIdx = ii;
+ defaultCaptureMpix = mpix;
+ defaultCaptureWidth = s.getWidth();
+ defaultCaptureHeight = s.getHeight();
}
}
@@ -347,16 +345,16 @@ public void selectImageDimension()
ii++;
}
- // default to about 5Mpix if nothing is set in preferences or maximum
+ // default to about 8Mpix if nothing is set in preferences or maximum
// resolution is above memory limits
- if (Capture5mMpix > 0)
+ if (defaultCaptureMpix > 0)
{
if (!prefFound)
{
- CaptureIdx = Capture5mIdx;
- CaptureMpix = Capture5mMpix;
- CaptureWidth = Capture5mWidth;
- CaptureHeight = Capture5mHeight;
+ CaptureIdx = defaultCaptureIdx;
+ CaptureMpix = defaultCaptureMpix;
+ CaptureWidth = defaultCaptureWidth;
+ CaptureHeight = defaultCaptureHeight;
}
}
diff --git a/src/com/almalence/opencam/PluginCapture.java b/src/com/almalence/opencam/PluginCapture.java
index b8cf42e3..1d04b472 100755
--- a/src/com/almalence/opencam/PluginCapture.java
+++ b/src/com/almalence/opencam/PluginCapture.java
@@ -30,6 +30,7 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.hardware.Camera;
import android.media.Image;
+import android.preference.PreferenceFragment;
public abstract class PluginCapture extends Plugin
{
@@ -83,13 +84,10 @@ public void takePicture()
public abstract void onAutoFocus(boolean paramBoolean);
@Override
- public abstract void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera);
-
- @Override
- public abstract void onImageAvailable(Image im);
-
+ public abstract void onImageTaken(int frame, byte[] frameData, int frame_len, boolean isYUV);
+
@Override
- public abstract void onPreviewFrame(byte[] data, Camera paramCamera);
+ public abstract void onPreviewFrame(byte[] data);
public boolean shouldPreviewToGPU()
{
diff --git a/src/com/almalence/opencam/PluginManager.java b/src/com/almalence/opencam/PluginManager.java
index 4a2e3961..4421abe5 100644
--- a/src/com/almalence/opencam/PluginManager.java
+++ b/src/com/almalence/opencam/PluginManager.java
@@ -23,6 +23,7 @@ Portions created by Initial Developer are Copyright (C) 2013
//
@@ -46,6 +47,7 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.SwapHeap;
import com.almalence.opencam.CameraParameters;
+
import android.content.ContentValues;
import android.graphics.ImageFormat;
import android.graphics.Rect;
@@ -75,6 +77,7 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.content.res.AssetFileDescriptor;
import android.hardware.Camera;
import android.hardware.camera2.CaptureResult;
+import android.hardware.camera2.TotalCaptureResult;
import android.media.Image;
import android.opengl.GLSurfaceView;
import android.os.AsyncTask;
@@ -198,7 +201,9 @@ public class PluginManager implements PluginManagerInterface
public static final int MSG_NOTIFY_LIMIT_REACHED = 14;
public static final int MSG_CAPTURE_FINISHED_NORESULT = 15;
+ public static final int MSG_CAMERA_CONFIGURED = 160;
public static final int MSG_CAMERA_READY = 161;
+ public static final int MSG_CAMERA_STOPED = 162;
// For HALv3 code version
public static final int MSG_CAMERA_OPENED = 16;
@@ -235,6 +240,7 @@ public class PluginManager implements PluginManagerInterface
public static final int MSG_FOCUS_CHANGED = 63;
public static final int MSG_FLASH_CHANGED = 64;
public static final int MSG_ISO_CHANGED = 65;
+ public static final int MSG_AEWB_CHANGED = 66;
// OpenGL layer messages
public static final int MSG_OPENGL_LAYER_SHOW = 70;
@@ -395,7 +401,7 @@ private PluginManager()
listExport.add(testExportPlugin);
// parsing configuration file to setup modes
- ParseConfig();
+ parseConfig();
}
public void setupDefaultMode()
@@ -507,7 +513,7 @@ private void restartMainScreen()
}
// parse config to get camera and modes configurations
- void ParseConfig()
+ void parseConfig()
{
try
{
@@ -653,8 +659,8 @@ public void onPause(boolean isFromMain)
if (delayedCaptureFlashPrefCommon || delayedCaptureSoundPrefCommon)
{
releaseSoundPlayers();
- countdownHandler.removeCallbacks(FlashOff);
- finalcountdownHandler.removeCallbacks(FlashBlink);
+ countdownHandler.removeCallbacks(flashOff);
+ finalcountdownHandler.removeCallbacks(flashBlink);
}
// stops timer before exit to be sure it's canceled
if (timer != null)
@@ -751,7 +757,8 @@ public void onShutterClick()
for (int i = 0; i < activeVF.size(); i++)
pluginList.get(activeVF.get(i)).onShutterClick();
if (null != pluginList.get(activeCapture)
- && MainScreen.getInstance().findViewById(R.id.postprocessingLayout).getVisibility() == View.GONE)
+ && MainScreen.getInstance().findViewById(R.id.postprocessingLayout).getVisibility() == View.GONE
+ && MainScreen.getInstance().findViewById(R.id.blockingLayout).getVisibility() == View.GONE)
pluginList.get(activeCapture).onShutterClick();
} else
{
@@ -824,6 +831,10 @@ public void loadHeaderContent(String settings, PreferenceFragment pf)
{
pf.addPreferencesFromResource(R.xml.preferences_general_more);
MainScreen.getInstance().onAdvancePreferenceCreate(pf);
+ } else if ("general_image_size".equals(settings))
+ {
+ pf.addPreferencesFromResource(R.xml.preferences_general_image_size);
+ MainScreen.getInstance().onPreferenceCreate(pf);
} else if ("vf_settings".equals(settings))
{
pf.addPreferencesFromResource(R.xml.preferences_vf_common);
@@ -839,6 +850,8 @@ public void loadHeaderContent(String settings, PreferenceFragment pf)
}
addHeadersContent(pf, activePlugins, false);
+ pf.addPreferencesFromResource(R.xml.preferences_vf_more);
+
if (activePlugins.size() != listVF.size() && isPreferenecesAvailable(inactivePlugins, false))
pf.addPreferencesFromResource(R.xml.preferences_vf_inactive);
} else if ("vf_inactive_settings".equals(settings))
@@ -1076,18 +1089,18 @@ public void loadHeaderContent(String settings, PreferenceFragment pf)
//
}
}
@@ -1129,7 +1142,6 @@ private void loadStandardSettingsBefore(PreferenceFragment pf, String settings)
if ("general_settings".equals(settings))
{
pf.addPreferencesFromResource(R.xml.preferences);
- MainScreen.getInstance().onPreferenceCreate(pf);
}
}
@@ -1271,44 +1283,24 @@ void onShutter()
pluginList.get(activeCapture).onShutter();
}
- @Override
- public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
- {
- if (null != pluginList.get(activeCapture))
- pluginList.get(activeCapture).onPictureTaken(paramArrayOfByte, paramCamera);
- }
- public void onImageAvailable(Image im)
+ @Override
+ public void onImageTaken(int frame, byte[] frameData, int frame_len, boolean isYUV)
{
if (null != pluginList.get(activeCapture))
- pluginList.get(activeCapture).onImageAvailable(im);
+ pluginList.get(activeCapture).onImageTaken(frame, frameData, frame_len, isYUV);
}
- @TargetApi(19)
- public void onCaptureCompleted(CaptureResult result)
+ @TargetApi(21)
+ public void onCaptureCompleted(TotalCaptureResult result)
{
if (null != pluginList.get(activeCapture))
pluginList.get(activeCapture).onCaptureCompleted(result);
}
- public void onPreviewAvailable(Image im)
- {
- if (isRestarting)
- {
- RelativeLayout pluginsLayout = (RelativeLayout) MainScreen.getInstance().findViewById(R.id.mainLayout1);
- pluginsLayout.requestLayout();
- isRestarting = false;
- }
-
- for (int i = 0; i < activeVF.size(); i++)
- pluginList.get(activeVF.get(i)).onPreviewAvailable(im);
-
- if (null != pluginList.get(activeCapture))
- pluginList.get(activeCapture).onPreviewAvailable(im);
- }
@Override
- public void onPreviewFrame(byte[] data, Camera paramCamera)
+ public void onPreviewFrame(byte[] data)
{
// prevents plugin's views to disappear
if (isRestarting)
@@ -1319,10 +1311,10 @@ public void onPreviewFrame(byte[] data, Camera paramCamera)
}
for (int i = 0; i < activeVF.size(); i++)
- pluginList.get(activeVF.get(i)).onPreviewFrame(data, paramCamera);
+ pluginList.get(activeVF.get(i)).onPreviewFrame(data);
if (null != pluginList.get(activeCapture))
- pluginList.get(activeCapture).onPreviewFrame(data, paramCamera);
+ pluginList.get(activeCapture).onPreviewFrame(data);
}
public void onFrameAvailable()
@@ -1465,8 +1457,7 @@ public boolean handleMessage(Message msg)
// -+- -->
MainScreen.getGUIManager().lockControls = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_UNLOCKED);
break;
case MSG_CAPTURE_FINISHED_NORESULT:
@@ -1482,9 +1473,8 @@ public boolean handleMessage(Message msg)
MainScreen.getGUIManager().lockControls = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
-
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_UNLOCKED);
+
MainScreen.getGUIManager().onExportFinished();
for (int i = 0; i < activeVF.size(); i++)
@@ -1496,8 +1486,7 @@ public boolean handleMessage(Message msg)
if (null != pluginList.get(activeProcessing))
{
MainScreen.getGUIManager().lockControls = true;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_LOCKED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_LOCKED);
pluginList.get(activeProcessing).onStartPostProcessing();
MainScreen.getGUIManager().onPostProcessingStarted();
@@ -1512,8 +1501,7 @@ public boolean handleMessage(Message msg)
// notify GUI about saved images
MainScreen.getGUIManager().lockControls = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_UNLOCKED);
MainScreen.getGUIManager().onPostProcessingFinished();
if (null != pluginList.get(activeExport) && 0 != sessionID)
@@ -1632,7 +1620,7 @@ public boolean addToSharedMem(String key, String value)
return true;
}
- public boolean addToSharedMem_ExifTagsFromJPEG(final byte[] paramArrayOfByte, final long SessionID, final int num)
+ public boolean addToSharedMemExifTagsFromJPEG(final byte[] paramArrayOfByte, final long SessionID, final int num)
{
try
{
@@ -1690,8 +1678,8 @@ else if (s1 != null)
}
@SuppressLint("NewApi")
- @TargetApi(19)
- public boolean addToSharedMem_ExifTagsFromCaptureResult(final CaptureResult result, final long SessionID)
+ @TargetApi(21)
+ public boolean addToSharedMemExifTagsFromCaptureResult(final CaptureResult result, final long SessionID)
{
String exposure_time = String.valueOf(result.get(CaptureResult.SENSOR_EXPOSURE_TIME));
String sensitivity = String.valueOf(result.get(CaptureResult.SENSOR_SENSITIVITY));
@@ -1716,7 +1704,7 @@ public boolean addToSharedMem_ExifTagsFromCaptureResult(final CaptureResult resu
return true;
}
- public boolean addToSharedMem_ExifTagsFromCamera(final long SessionID)
+ public boolean addToSharedMemExifTagsFromCamera(final long SessionID)
{
Camera.Parameters params = CameraController.getInstance().getCameraParameters();
if (params == null)
@@ -1914,7 +1902,7 @@ public int getProcessingCounter()
// get file saving directory
// toInternalMemory - should be true only if force save to internal
- public File GetSaveDir(boolean forceSaveToInternalMemory)
+ public static File getSaveDir(boolean forceSaveToInternalMemory)
{
File dcimDir, saveDir = null, memcardDir;
boolean usePhoneMem = true;
@@ -1926,7 +1914,7 @@ public File GetSaveDir(boolean forceSaveToInternalMemory)
abcDir = String.format("%tF", rightNow);
}
- if ((Integer.parseInt(MainScreen.getSaveTo()) == 1))
+ if (Integer.parseInt(MainScreen.getSaveTo()) == 1)
{
dcimDir = Environment.getExternalStorageDirectory();
@@ -2006,8 +1994,8 @@ private void delayedCapture(int delayInterval)
MainScreen.getInstance().getResources().openRawResourceFd(R.raw.plugin_capture_selftimer_countdown),
MainScreen.getInstance().getResources()
.openRawResourceFd(R.raw.plugin_capture_selftimer_finalcountdown));
- countdownHandler.removeCallbacks(FlashOff);
- finalcountdownHandler.removeCallbacks(FlashBlink);
+ countdownHandler.removeCallbacks(flashOff);
+ finalcountdownHandler.removeCallbacks(flashBlink);
timer = new CountDownTimer(delayInterval * 1000 + 500, 1000)
{
@@ -2037,7 +2025,7 @@ public void onTick(long millisUntilFinished)
e.printStackTrace();
Log.e("Self-timer", "Torch exception: " + e.getMessage());
}
- countdownHandler.postDelayed(FlashOff, 50);
+ countdownHandler.postDelayed(flashOff, 50);
}
}
}
@@ -2047,8 +2035,8 @@ public void onFinish()
countdownView.clearAnimation();
countdownLayout.setVisibility(View.GONE);
- countdownHandler.removeCallbacks(FlashOff);
- finalcountdownHandler.removeCallbacks(FlashBlink);
+ countdownHandler.removeCallbacks(flashOff);
+ finalcountdownHandler.removeCallbacks(flashBlink);
if (CameraController.getInstance().getSupportedFlashModes() != null)
CameraController.getInstance().setCameraFlashMode(flashModeBackUp);
@@ -2101,7 +2089,7 @@ public void releaseSoundPlayers()
}
}
- private Runnable FlashOff = new Runnable()
+ private Runnable flashOff = new Runnable()
{
public void run()
{
@@ -2110,7 +2098,7 @@ public void run()
}
};
- private Runnable FlashBlink = new Runnable()
+ private Runnable flashBlink = new Runnable()
{
boolean isFlashON = false;
@@ -2190,7 +2178,7 @@ public void saveResultPicture(long sessionID)
// save fused result
try
{
- File saveDir = GetSaveDir(false);
+ File saveDir = getSaveDir(false);
Calendar d = Calendar.getInstance();
@@ -2265,7 +2253,7 @@ public void saveResultPicture(long sessionID)
{
// save always if not working saving to sdcard
e.printStackTrace();
- saveDir = GetSaveDir(true);
+ saveDir = getSaveDir(true);
if (MainScreen.getForceFilename() == null)
{
file = new File(saveDir, fileFormat);
@@ -2398,7 +2386,11 @@ public void saveResultPicture(long sessionID)
break;
}
- values = new ContentValues(9);
+ File parent = file.getParentFile();
+ String path = parent.toString().toLowerCase();
+ String name = parent.getName().toLowerCase();
+
+ values = new ContentValues();
values.put(
ImageColumns.TITLE,
file.getName().substring(
@@ -2409,6 +2401,8 @@ public void saveResultPicture(long sessionID)
values.put(ImageColumns.DATE_TAKEN, System.currentTimeMillis());
values.put(ImageColumns.MIME_TYPE, "image/jpeg");
values.put(ImageColumns.ORIENTATION, writeOrientationTag ? orientation_tag : String.valueOf(0));
+ values.put(ImageColumns.BUCKET_ID, path.hashCode());
+ values.put(ImageColumns.BUCKET_DISPLAY_NAME, name);
values.put(ImageColumns.DATA, file.getAbsolutePath());
File tmpFile;
@@ -2551,6 +2545,7 @@ public void saveResultPicture(long sessionID)
}
} catch (Exception e)
{
+ e.printStackTrace();
}
if (tag_scene != null)
{
@@ -2766,7 +2761,7 @@ public void saveResultPicture(long sessionID)
public String getFileFormat()
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
- int saveOption = Integer.parseInt(prefs.getString("exportName", "3"));
+ saveOption = Integer.parseInt(prefs.getString("exportName", "2"));
Calendar d = Calendar.getInstance();
String fileFormat = String.format("%04d%02d%02d_%02d%02d%02d", d.get(Calendar.YEAR), d.get(Calendar.MONTH) + 1,
d.get(Calendar.DAY_OF_MONTH), d.get(Calendar.HOUR_OF_DAY), d.get(Calendar.MINUTE),
@@ -2811,6 +2806,7 @@ public void writeData(FileOutputStream os, boolean isYUV, Long SessionID, int i,
if (resultMirrored != null)
cameraMirrored = Boolean.parseBoolean(resultMirrored);
+ int mDisplayOrientation = Integer.parseInt(resultOrientation);
if (os != null)
{
if (!isYUV)
@@ -2826,7 +2822,6 @@ public void writeData(FileOutputStream os, boolean isYUV, Long SessionID, int i,
}
os.close();
- int mDisplayOrientation = MainScreen.getGUIManager().getDisplayOrientation();
ExifInterface ei = new ExifInterface(file.getAbsolutePath());
int exif_orientation = ExifInterface.ORIENTATION_NORMAL;
switch (mDisplayOrientation)
@@ -2836,28 +2831,39 @@ public void writeData(FileOutputStream os, boolean isYUV, Long SessionID, int i,
exif_orientation = ExifInterface.ORIENTATION_NORMAL;
break;
case 90:
- exif_orientation = cameraMirrored ? ExifInterface.ORIENTATION_ROTATE_270
- : ExifInterface.ORIENTATION_ROTATE_90;
+ if (cameraMirrored)
+ {
+ mDisplayOrientation = 270;
+ exif_orientation = ExifInterface.ORIENTATION_ROTATE_270;
+ } else
+ {
+ exif_orientation = ExifInterface.ORIENTATION_ROTATE_90;
+ }
break;
case 180:
exif_orientation = ExifInterface.ORIENTATION_ROTATE_180;
break;
case 270:
- exif_orientation = cameraMirrored ? ExifInterface.ORIENTATION_ROTATE_90
- : ExifInterface.ORIENTATION_ROTATE_270;
+ if (cameraMirrored)
+ {
+ mDisplayOrientation = 90;
+ exif_orientation = ExifInterface.ORIENTATION_ROTATE_90;
+ } else
+ {
+ exif_orientation = ExifInterface.ORIENTATION_ROTATE_270;
+ }
break;
}
ei.setAttribute(ExifInterface.TAG_ORIENTATION, "" + exif_orientation);
ei.saveAttributes();
}
- values = new ContentValues(9);
+ values = new ContentValues();
values.put(ImageColumns.TITLE, file.getName().substring(0, file.getName().lastIndexOf(".")));
values.put(ImageColumns.DISPLAY_NAME, file.getName());
values.put(ImageColumns.DATE_TAKEN, System.currentTimeMillis());
values.put(ImageColumns.MIME_TYPE, "image/jpeg");
- values.put(ImageColumns.ORIENTATION, (!orientationLandscape && !cameraMirrored) ? 90
- : (!orientationLandscape && cameraMirrored) ? -90 : 0);
+ values.put(ImageColumns.ORIENTATION, mDisplayOrientation);
values.put(ImageColumns.DATA, file.getAbsolutePath());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
@@ -2882,7 +2888,7 @@ public void writeData(FileOutputStream os, boolean isYUV, Long SessionID, int i,
MainScreen.getInstance().getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);
}
-
+
public void sendMessage(int what, String obj, int arg1, int arg2)
{
Message message = new Message();
@@ -2891,9 +2897,8 @@ public void sendMessage(int what, String obj, int arg1, int arg2)
message.arg2 = arg2;
message.what = what;
MainScreen.getMessageHandler().sendMessage(message);
-
}
-
+
public void sendMessage(int what, int arg1)
{
Message message = new Message();
@@ -2901,7 +2906,7 @@ public void sendMessage(int what, int arg1)
message.what = what;
MainScreen.getMessageHandler().sendMessage(message);
}
-
+
public void sendMessage(int what, String obj)
{
Message message = new Message();
diff --git a/src/com/almalence/opencam/PluginManagerInterface.java b/src/com/almalence/opencam/PluginManagerInterface.java
index e47fa4c0..45b0d043 100644
--- a/src/com/almalence/opencam/PluginManagerInterface.java
+++ b/src/com/almalence/opencam/PluginManagerInterface.java
@@ -36,8 +36,9 @@ public interface PluginManagerInterface
public void onAutoFocus(boolean focused);
- public void onPreviewFrame(byte[] data, Camera paramCamera);
+ public void onPreviewFrame(byte[] data);
- public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera);
+// public void onPictureTaken(byte[] paramArrayOfByte, boolean isYUV);
+ public void onImageTaken(int frame, byte[] frameData, int frame_len, boolean isYUV);
}
diff --git a/src/com/almalence/opencam/cameracontroller/CameraController.java b/src/com/almalence/opencam/cameracontroller/CameraController.java
index 73351965..89c4cc7f 100644
--- a/src/com/almalence/opencam/cameracontroller/CameraController.java
+++ b/src/com/almalence/opencam/cameracontroller/CameraController.java
@@ -25,25 +25,33 @@
//-+- -->
import java.io.IOException;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import com.almalence.SwapHeap;
+import com.almalence.YuvImage;
import com.almalence.opencam.ApplicationInterface;
import com.almalence.opencam.CameraParameters;
import com.almalence.opencam.MainScreen;
import com.almalence.opencam.PluginManager;
import com.almalence.opencam.PluginManagerInterface;
import com.almalence.opencam.R;
+import com.almalence.util.ImageConversion;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
+import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.hardware.Camera.Area;
+import android.media.Image;
import android.os.Build;
+import android.os.CountDownTimer;
+import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.util.Log;
@@ -52,7 +60,7 @@
import android.widget.Toast;
public class CameraController implements Camera.PictureCallback, Camera.AutoFocusCallback, Camera.ErrorCallback,
- Camera.PreviewCallback, Camera.ShutterCallback
+ Camera.PreviewCallback, Camera.ShutterCallback, Handler.Callback
{
private static final String TAG = "CameraController";
@@ -158,7 +166,11 @@ public class CameraController implements Camera.PictureCallback, Camera.AutoFocu
private static Camera camera = null;
private static Camera.Parameters cameraParameters = null;
private byte[] pviewBuffer;
-
+
+ //Message handler for multishot capturing with pause between shots
+ //and different exposure compensations
+ private Handler messageHandler;
+
private static boolean isHALv3 = false;
private static boolean isHALv3Supported = false;
@@ -178,11 +190,11 @@ public class CameraController implements Camera.PictureCallback, Camera.AutoFocu
protected boolean mVideoStabilizationSupported = false;
- private static byte[] supportedSceneModes;
- private static byte[] supportedWBModes;
- private static byte[] supportedFocusModes;
- private static byte[] supportedFlashModes;
- private static byte[] supportedISOModes;
+ private static int[] supportedSceneModes;
+ private static int[] supportedWBModes;
+ private static int[] supportedFocusModes;
+ private static int[] supportedFlashModes;
+ private static int[] supportedISOModes;
private static int maxRegionsSupported;
@@ -248,6 +260,8 @@ public void onCreate(Context context, ApplicationInterface app, PluginManagerInt
pluginManager = pluginManagerBase;
appInterface = app;
mainContext = context;
+
+ messageHandler = new Handler(this);
sceneAuto = mainContext.getResources().getString(R.string.sceneAutoSystem);
sceneAction = mainContext.getResources().getString(R.string.sceneActionSystem);
@@ -807,7 +821,7 @@ public static boolean isCameraCreated()
}
- @TargetApi(19)
+ @TargetApi(21)
public static boolean isCameraCreatedHALv3()
{
return HALv3.getInstance().camDevice != null;
@@ -1277,7 +1291,7 @@ public void resetExposureCompensation()
private boolean getSceneModeSupported()
{
- byte[] supported_scene = getSupportedSceneModesInternal();
+ int[] supported_scene = getSupportedSceneModesInternal();
return supported_scene != null && supported_scene.length > 0
&& supported_scene[0] != CameraParameters.SCENE_MODE_UNSUPPORTED;
}
@@ -1287,7 +1301,7 @@ public boolean isSceneModeSupported()
return mSceneModeSupported;
}
- private byte[] getSupportedSceneModesInternal()
+ private int[] getSupportedSceneModesInternal()
{
if (!CameraController.isHALv3)
{
@@ -1296,7 +1310,7 @@ private byte[] getSupportedSceneModesInternal()
{
Set known_scenes = CameraController.key_scene.keySet();
sceneModes.retainAll(known_scenes);
- byte[] scenes = new byte[sceneModes.size()];
+ int[] scenes = new int[sceneModes.size()];
for (int i = 0; i < sceneModes.size(); i++)
{
String mode = sceneModes.get(i);
@@ -1307,19 +1321,19 @@ private byte[] getSupportedSceneModesInternal()
return scenes;
}
- return new byte[0];
+ return new int[0];
} else
return HALv3.getSupportedSceneModesHALv3();
}
- public byte[] getSupportedSceneModes()
+ public int[] getSupportedSceneModes()
{
return supportedSceneModes;
}
private boolean getWhiteBalanceSupported()
{
- byte[] supported_wb = getSupportedWhiteBalanceInternal();
+ int[] supported_wb = getSupportedWhiteBalanceInternal();
return supported_wb != null && supported_wb.length > 0;
}
@@ -1328,7 +1342,7 @@ public boolean isWhiteBalanceSupported()
return mWBSupported;
}
- private byte[] getSupportedWhiteBalanceInternal()
+ private int[] getSupportedWhiteBalanceInternal()
{
if (!CameraController.isHALv3)
{
@@ -1337,7 +1351,7 @@ private byte[] getSupportedWhiteBalanceInternal()
{
Set known_wb = CameraController.key_wb.keySet();
wbModes.retainAll(known_wb);
- byte[] wb = new byte[wbModes.size()];
+ int[] wb = new int[wbModes.size()];
for (int i = 0; i < wbModes.size(); i++)
{
String mode = wbModes.get(i);
@@ -1347,19 +1361,19 @@ private byte[] getSupportedWhiteBalanceInternal()
return wb;
}
- return new byte[0];
+ return new int[0];
} else
return HALv3.getSupportedWhiteBalanceHALv3();
}
- public byte[] getSupportedWhiteBalance()
+ public int[] getSupportedWhiteBalance()
{
return supportedWBModes;
}
private boolean getFocusModeSupported()
{
- byte[] supported_focus = getSupportedFocusModesInternal();
+ int[] supported_focus = getSupportedFocusModesInternal();
return supported_focus != null && supported_focus.length > 0;
}
@@ -1368,7 +1382,7 @@ public boolean isFocusModeSupported()
return mFocusModeSupported;
}
- private byte[] getSupportedFocusModesInternal()
+ private int[] getSupportedFocusModesInternal()
{
if (!CameraController.isHALv3)
{
@@ -1377,7 +1391,7 @@ private byte[] getSupportedFocusModesInternal()
{
Set known_focus = CameraController.key_focus.keySet();
focusModes.retainAll(known_focus);
- byte[] focus = new byte[focusModes.size()];
+ int[] focus = new int[focusModes.size()];
for (int i = 0; i < focusModes.size(); i++)
{
String mode = focusModes.get(i);
@@ -1388,12 +1402,12 @@ private byte[] getSupportedFocusModesInternal()
return focus;
}
- return new byte[0];
+ return new int[0];
} else
return HALv3.getSupportedFocusModesHALv3();
}
- public byte[] getSupportedFocusModes()
+ public int[] getSupportedFocusModes()
{
return supportedFocusModes;
}
@@ -1404,7 +1418,7 @@ private boolean getFlashModeSupported()
return HALv3.isFlashModeSupportedHALv3();
else
{
- byte[] supported_flash = getSupportedFlashModesInternal();
+ int[] supported_flash = getSupportedFlashModesInternal();
return supported_flash != null && supported_flash.length > 0;
}
}
@@ -1414,13 +1428,13 @@ public boolean isFlashModeSupported()
return mFlashModeSupported;
}
- private byte[] getSupportedFlashModesInternal()
+ private int[] getSupportedFlashModesInternal()
{
if (CameraController.isHALv3)
{
if (isFlashModeSupported())
{
- byte[] flash = new byte[3];
+ int[] flash = new int[3];
flash[0] = CameraParameters.FLASH_MODE_OFF;
flash[1] = CameraParameters.FLASH_MODE_SINGLE;
flash[2] = CameraParameters.FLASH_MODE_TORCH;
@@ -1433,7 +1447,7 @@ private byte[] getSupportedFlashModesInternal()
{
Set known_flash = CameraController.key_flash.keySet();
flashModes.retainAll(known_flash);
- byte[] flash = new byte[flashModes.size()];
+ int[] flash = new int[flashModes.size()];
for (int i = 0; i < flashModes.size(); i++)
{
String mode = flashModes.get(i);
@@ -1445,10 +1459,10 @@ private byte[] getSupportedFlashModesInternal()
}
}
- return new byte[0];
+ return new int[0];
}
- public byte[] getSupportedFlashModes()
+ public int[] getSupportedFlashModes()
{
return supportedFlashModes;
}
@@ -1457,7 +1471,7 @@ private boolean getISOSupported()
{
if (!CameraController.isHALv3)
{
- byte[] supported_iso = getSupportedISO();
+ int[] supported_iso = getSupportedISO();
String isoSystem = CameraController.getInstance().getCameraParameters().get("iso");
String isoSystem2 = CameraController.getInstance().getCameraParameters().get("iso-speed");
return supported_iso != null || isoSystem != null || isoSystem2 != null;
@@ -1470,7 +1484,7 @@ public boolean isISOSupported()
return mISOSupported;
}
- private byte[] getSupportedISOInternal()
+ private int[] getSupportedISOInternal()
{
if (!CameraController.isHALv3)
{
@@ -1498,9 +1512,9 @@ else if (supportedIsoValues3 != null && !supportedIsoValues3.equals(""))
for (int i = 0; i < isoList.length; i++)
isoModes.add(isoList[i]);
} else
- return new byte[0];
+ return new int[0];
- byte[] iso = new byte[isoModes.size()];
+ int[] iso = new int[isoModes.size()];
for (int i = 0; i < isoModes.size(); i++)
{
String mode = isoModes.get(i);
@@ -1516,12 +1530,12 @@ else if (CameraController.key_iso2.containsKey(mode))
return iso;
}
- return new byte[0];
+ return new int[0];
} else
return HALv3.getSupportedISOModesHALv3();
}
- public byte[] getSupportedISO()
+ public int[] getSupportedISO()
{
return supportedISOModes;
}
@@ -1577,7 +1591,7 @@ public static void setCameraImageSizeIndex(int captureIndex)
CapIdx = captureIndex;
}
- public static boolean isModeAvailable(byte[] modeList, int mode)
+ public static boolean isModeAvailable(int[] modeList, int mode)
{
boolean isAvailable = false;
for (int currMode : modeList)
@@ -1970,56 +1984,54 @@ public static int captureImage(int nFrames, int format)
{
synchronized (SYNC_OBJECT)
{
- if (camera != null && CameraController.getFocusState() != CameraController.FOCUS_STATE_FOCUSING)
- {
- mCaptureState = CameraController.CAPTURE_STATE_CAPTURING;
- camera.setPreviewCallback(null);
- camera.takePicture(CameraController.getInstance(), null, null, CameraController.getInstance());
- return 0;
- }
-
- return -1;
+ CameraController.getInstance().sendMessage(MSG_TAKE_IMAGE);
+// if (camera != null && CameraController.getFocusState() != CameraController.FOCUS_STATE_FOCUSING)
+// {
+// mCaptureState = CameraController.CAPTURE_STATE_CAPTURING;
+// camera.setPreviewCallback(null);
+// camera.takePicture(CameraController.getInstance(), null, null, CameraController.getInstance());
+// return 0;
+// }
+
+// return -1;
+ return 0;
}
} else
return HALv3.captureImageHALv3(nFrames, format);
}
// Experimental code to take multiple images. Works only with HALv3
- // interface in API 19
- protected static int pauseBetweenShots = 0;
+ // interface in API 19(currently minimum API version for Android L increased to 21)
+ protected static int[] pauseBetweenShots = new int[0];
protected static final int MAX_HDR_FRAMES = 4;
protected static int[] evValues = new int[MAX_HDR_FRAMES];
protected static int total_frames;
protected static int frame_num;
+
+ protected static boolean takePreviewFrame = false;
+
+ protected static boolean takeYUVFrame = false;
- public static int captureImagesWithParams(int nFrames, int format, int pause, int[] evRequested)
+ public static int captureImagesWithParams(int nFrames, int format, int[] pause, int[] evRequested)
{
+ pauseBetweenShots = pause;
+ evValues = evRequested;
+
+ total_frames = nFrames;
+ frame_num = 0;
+
if (!CameraController.isHALv3)
{
- synchronized (SYNC_OBJECT)
- {
- if (camera != null && CameraController.getFocusState() != CameraController.FOCUS_STATE_FOCUSING)
- {
- mCaptureState = CameraController.CAPTURE_STATE_CAPTURING;
- camera.setPreviewCallback(null);
- camera.takePicture(CameraController.getInstance(), null, null, CameraController.getInstance());
- return 0;
- }
-
- return -1;
- }
+ takeYUVFrame = (format == CameraController.YUV);
+ if (evRequested != null && evRequested.length >= total_frames)
+ CameraController.getInstance().sendMessage(MSG_SET_EXPOSURE);
+ else
+ CameraController.getInstance().sendMessage(MSG_TAKE_IMAGE);
+ return 0;
} else
- {
- pauseBetweenShots = pause;
- evValues = evRequested;
-
- total_frames = nFrames;
- frame_num = 0;
-
return HALv3.captureImageWithParamsHALv3(nFrames, format, pause, evRequested);
- }
}
public static boolean autoFocus(Camera.AutoFocusCallback listener)
@@ -2099,14 +2111,32 @@ public static void cancelAutoFocus()
HALv3.cancelAutoFocusHALv3();
}
+
+ //Callback always contains JPEG frame.
+ //So, we have to convert JPEG to YUV if capture plugin has requested YUV frame.
@Override
public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
{
+ Log.e(TAG, "onPictureTaken");
CameraController.getCamera().setPreviewCallbackWithBuffer(CameraController.getInstance());
CameraController.getCamera().addCallbackBuffer(pviewBuffer);
- pluginManager.onPictureTaken(paramArrayOfByte, paramCamera);
+ if(!CameraController.takeYUVFrame) //if JPEG frame requested
+ {
+ int frame = SwapHeap.SwapToHeap(paramArrayOfByte);
+ pluginManager.onImageTaken(frame, paramArrayOfByte, paramArrayOfByte.length, false);
+ }
+ else //is YUV frame requested
+ {
+ int yuvFrame = ImageConversion.JpegConvert(paramArrayOfByte, MainScreen.getImageWidth(), MainScreen.getImageHeight(), false, false, 0);
+ int frameLen = MainScreen.getImageWidth()*MainScreen.getImageHeight()+2*((MainScreen.getImageWidth()+1)/2)*((MainScreen.getImageHeight()+1)/2);
+ byte[] frameData = SwapHeap.CopyFromHeap(yuvFrame, frameLen);
+ pluginManager.onImageTaken(yuvFrame, frameData, frameLen, true);
+ }
+
CameraController.mCaptureState = CameraController.CAPTURE_STATE_IDLE;
+
+ CameraController.getInstance().sendMessage(MSG_NEXT_FRAME);
}
@Override
@@ -2129,10 +2159,45 @@ public void onAutoFocus(boolean focused)
}
@Override
- public void onPreviewFrame(byte[] data, Camera paramCamera)
- {
- pluginManager.onPreviewFrame(data, paramCamera);
+ public void onPreviewFrame(byte[] data, Camera camera)
+ {
+ pluginManager.onPreviewFrame(data);
CameraController.getCamera().addCallbackBuffer(pviewBuffer);
+
+ if(takePreviewFrame)
+ {
+ takePreviewFrame = false;
+ if(CameraController.takeYUVFrame)
+ {
+ int frame = SwapHeap.SwapToHeap(data);
+ pluginManager.onImageTaken(frame, data, data.length, true);
+ }
+ else
+ {
+ int jpegData = 0;
+// int yuvFrame = ImageConversion.JpegConvert(paramArrayOfByte, MainScreen.getImageWidth(), MainScreen.getImageHeight(), false, false, 0);
+// pluginManager.onImageTaken(yuvFrame, null, 0, true);
+ }
+
+// pluginManager.onPictureTaken(data, true);
+ CameraController.getInstance().sendMessage(MSG_NEXT_FRAME);
+ return;
+ }
+
+ if (evLatency > 0)
+ {
+ previewWorking = true;
+ if (--evLatency == 0)
+ {
+ if (cdt != null)
+ {
+ cdt.cancel();
+ cdt = null;
+ }
+ CameraController.getInstance().sendMessage(MSG_TAKE_IMAGE);
+ }
+ return;
+ }
}
public static void setPreviewCallbackWithBuffer()
@@ -2146,6 +2211,126 @@ public static void setPreviewCallbackWithBuffer()
// ^^^^^^^^^^^^^ CAPTURE AND FOCUS FUNCTION ----------------------------
+
+
+ // =============== Captured Image data manipulation ======================
+ @TargetApi(19)
+ public static int getImageFrame(Image im)
+ {
+ int frame = 0;
+
+ if (im.getFormat() == ImageFormat.YUV_420_888)
+ {
+ ByteBuffer Y = im.getPlanes()[0].getBuffer();
+ ByteBuffer U = im.getPlanes()[1].getBuffer();
+ ByteBuffer V = im.getPlanes()[2].getBuffer();
+
+ if ((!Y.isDirect()) || (!U.isDirect()) || (!V.isDirect()))
+ {
+ Log.e(TAG, "Oops, YUV ByteBuffers isDirect failed");
+ return -1;
+ }
+
+ // Note: android documentation guarantee that:
+ // - Y pixel stride is always 1
+ // - U and V strides are the same
+ // So, passing all these parameters is a bit overkill
+ int status = YuvImage.CreateYUVImage(Y, U, V, im.getPlanes()[0].getPixelStride(),
+ im.getPlanes()[0].getRowStride(), im.getPlanes()[1].getPixelStride(),
+ im.getPlanes()[1].getRowStride(), im.getPlanes()[2].getPixelStride(),
+ im.getPlanes()[2].getRowStride(), MainScreen.getImageWidth(), MainScreen.getImageHeight(), 0);
+
+ if (status != 0)
+ Log.e(TAG, "Error while cropping: " + status);
+
+ frame = YuvImage.GetFrame(0);
+ } else if (im.getFormat() == ImageFormat.JPEG)
+ {
+ ByteBuffer jpeg = im.getPlanes()[0].getBuffer();
+
+ int frame_len = jpeg.limit();
+ byte[] jpegByteArray = new byte[frame_len];
+ jpeg.get(jpegByteArray, 0, frame_len);
+
+ frame = SwapHeap.SwapToHeap(jpegByteArray);
+ }
+
+ return frame;
+ }
+
+ // =============== Captured Image data manipulation ======================
+ @TargetApi(19)
+ public static byte[] getImageFrameData(Image im)
+ {
+ byte[] frameData = new byte[0];
+
+ if (im.getFormat() == ImageFormat.YUV_420_888)
+ {
+ ByteBuffer Y = im.getPlanes()[0].getBuffer();
+ ByteBuffer U = im.getPlanes()[1].getBuffer();
+ ByteBuffer V = im.getPlanes()[2].getBuffer();
+
+ if ((!Y.isDirect()) || (!U.isDirect()) || (!V.isDirect()))
+ {
+ Log.e(TAG, "Oops, YUV ByteBuffers isDirect failed");
+ return frameData;
+ }
+
+ // Note: android documentation guarantee that:
+ // - Y pixel stride is always 1
+ // - U and V strides are the same
+ // So, passing all these parameters is a bit overkill
+ int status = YuvImage.CreateYUVImage(Y, U, V, im.getPlanes()[0].getPixelStride(),
+ im.getPlanes()[0].getRowStride(), im.getPlanes()[1].getPixelStride(),
+ im.getPlanes()[1].getRowStride(), im.getPlanes()[2].getPixelStride(),
+ im.getPlanes()[2].getRowStride(), MainScreen.getImageWidth(), MainScreen.getImageHeight(), 0);
+
+ if (status != 0)
+ Log.e(TAG, "Error while cropping: " + status);
+
+ frameData = YuvImage.GetByteFrame(0);
+
+ } else if (im.getFormat() == ImageFormat.JPEG)
+ {
+ ByteBuffer jpeg = im.getPlanes()[0].getBuffer();
+
+ int frame_len = jpeg.limit();
+ frameData = new byte[frame_len];
+ jpeg.get(frameData, 0, frame_len);
+ }
+
+ return frameData;
+ }
+
+ @TargetApi(19)
+ public static boolean isYUVImage(Image im)
+ {
+ return im.getFormat() == ImageFormat.YUV_420_888;
+ }
+
+ @TargetApi(19)
+ public static int getImageLenght(Image im)
+ {
+ if (im.getFormat() == ImageFormat.YUV_420_888)
+ {
+ return MainScreen.getImageWidth() * MainScreen.getImageHeight() + MainScreen.getImageWidth()
+ * ((MainScreen.getImageHeight() + 1) / 2);
+ }
+ else if (im.getFormat() == ImageFormat.JPEG)
+ {
+ ByteBuffer jpeg = im.getPlanes()[0].getBuffer();
+
+ return jpeg.limit();
+ }
+
+ return 0;
+ }
+
+ // ^^^^^^^^^^^^^^^^^^^^^ Image data manipulation ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+
+
+
public class Size
{
private int mWidth;
@@ -2183,4 +2368,124 @@ public void onShutter()
{
// Not used
}
+
+
+ // set exposure based on onpreviewframe
+ private int evLatency;
+ private boolean previewMode = false;
+ private boolean previewWorking = false;
+ private CountDownTimer cdt = null;
+
+ public static final int MSG_SET_EXPOSURE = 01;
+ public static final int MSG_NEXT_FRAME = 02;
+ public static final int MSG_TAKE_IMAGE = 03;
+
+ public void sendMessage(int what)
+ {
+ Message message = new Message();
+ message.what = what;
+ messageHandler.sendMessage(message);
+ }
+
+ //Handle messages only for old camera interface logic
+ @Override
+ public boolean handleMessage(Message msg) {
+
+ switch(msg.what)
+ {
+ case MSG_SET_EXPOSURE:
+ Log.e(TAG, "MSG_SET_EXPOSURE");
+ try
+ {
+// if (UseLumaAdaptation && LumaAdaptationAvailable)
+// CameraController.getInstance().setLumaAdaptation(evValues[frame_num]);
+// else
+ CameraController.getInstance().setCameraExposureCompensation(evValues[frame_num]);
+ } catch (RuntimeException e)
+ {
+ Log.e(TAG, "setExpo fail in MSG_SET_EXPOSURE");
+ }
+
+ if (previewMode)
+ {
+ // message to capture image will be emitted 2 or 3 frames after
+ // setExposure
+ evLatency = 10; // the minimum value at which Galaxy Nexus is
+ // changing exposure in a stable way
+
+ // Note 3 need more time to change exposure.
+ if (Build.MODEL.contains("SM-N900"))
+ evLatency = 20;
+ } else
+ {
+ new CountDownTimer(500, 500)
+ {
+ public void onTick(long millisUntilFinished)
+ {
+ }
+
+ public void onFinish()
+ {
+ CameraController.getInstance().sendMessage(MSG_TAKE_IMAGE);
+ }
+ }.start();
+ }
+
+ return true;
+
+ case MSG_NEXT_FRAME:
+ Log.e(TAG, "MSG_NEXT_FRAME");
+ if (++frame_num < total_frames)
+ {
+ if(pauseBetweenShots[frame_num] == 0)
+ {
+ if (evValues != null && evValues.length >= total_frames)
+ CameraController.getInstance().sendMessage(MSG_SET_EXPOSURE);
+ else
+ CameraController.getInstance().sendMessage(MSG_TAKE_IMAGE);
+ }
+ else
+ {
+ new CountDownTimer(pauseBetweenShots[frame_num], pauseBetweenShots[frame_num])
+ {
+ public void onTick(long millisUntilFinished)
+ {
+ }
+
+ public void onFinish()
+ {
+ if (evValues != null && evValues.length >= total_frames)
+ CameraController.getInstance().sendMessage(MSG_SET_EXPOSURE);
+ else
+ CameraController.getInstance().sendMessage(MSG_TAKE_IMAGE);
+ }
+ }.start();
+ }
+ }
+ break;
+ case MSG_TAKE_IMAGE:
+ Log.e(TAG, "MSG_TAKE_IMAGE");
+ synchronized (SYNC_OBJECT)
+ {
+ int imageWidth = MainScreen.getImageWidth();
+ int imageHeight = MainScreen.getImageHeight();
+ int previewWidth = MainScreen.getPreviewWidth();
+ int previewHeight = MainScreen.getPreviewHeight();
+
+ if(imageWidth == previewWidth && imageHeight == previewHeight)
+ takePreviewFrame = true;
+ else if (camera != null && CameraController.getFocusState() != CameraController.FOCUS_STATE_FOCUSING)
+ {
+ mCaptureState = CameraController.CAPTURE_STATE_CAPTURING;
+ camera.setPreviewCallback(null);
+ camera.takePicture(CameraController.getInstance(), null, null, CameraController.getInstance());
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ return true;
+ }
}
diff --git a/src/com/almalence/opencam/cameracontroller/HALv3.java b/src/com/almalence/opencam/cameracontroller/HALv3.java
index 780b9f9f..94fdc485 100644
--- a/src/com/almalence/opencam/cameracontroller/HALv3.java
+++ b/src/com/almalence/opencam/cameracontroller/HALv3.java
@@ -24,9 +24,12 @@
//-+- -->
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
+import com.almalence.SwapHeap;
+import com.almalence.YuvImage;
import com.almalence.opencam.CameraParameters;
import com.almalence.opencam.MainScreen;
import com.almalence.opencam.PluginManager;
@@ -35,10 +38,12 @@
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
+import android.graphics.ImageFormat;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.hardware.Camera.Area;
+import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
@@ -46,28 +51,41 @@
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.TotalCaptureResult;
+import android.hardware.camera2.params.MeteringRectangle;
+import android.hardware.camera2.params.StreamConfigurationMap;
import android.media.Image;
import android.media.ImageReader;
import android.os.CountDownTimer;
+import android.os.Handler;
+import android.os.HandlerThread;
import android.preference.PreferenceManager;
import android.util.Log;
+import android.util.Range;
+import android.util.Size;
+import android.widget.Toast;
//HALv3 camera's objects
@SuppressLint("NewApi")
-@TargetApi(19)
+@TargetApi(21)
public class HALv3
{
- private static final String TAG = "HALv3Controller";
-
- private static HALv3 instance = null;
-
- private static Rect activeRect = null;
- private static Rect zoomCropPreview = null;
- private static Rect zoomCropCapture = null;
- private static float zoomLevel = 1f;
- private static int[] af_regions;
- private static int[] ae_regions;
+ private static final String TAG = "HALv3Controller";
+
+ private static HALv3 instance = null;
+
+ private static Rect activeRect = null;
+ private static Rect zoomCropPreview = null;
+ private static Rect zoomCropCapture = null;
+ private static float zoomLevel = 1f;
+ private static MeteringRectangle[] af_regions;
+ private static MeteringRectangle[] ae_regions;
+
+ private static int totalFrames = 0;
+ private static int currentFrameIndex = 0;
+ private static int[] pauseBetweenShots = new int[0];
+ private static int[] expRequested = null;
public static HALv3 getInstance()
{
@@ -80,11 +98,19 @@ public static HALv3 getInstance()
private CameraManager manager = null;
private CameraCharacteristics camCharacter = null;
- // private cameraAvailableListener availListener = null;
- protected CameraDevice camDevice = null;
+
private CaptureRequest.Builder previewRequestBuilder = null;
+ private CameraCaptureSession mCaptureSession = null;
+
+ protected CameraDevice camDevice = null;
+
private static boolean autoFocusTriggered = false;
+
+ /**
+ * True if the app is currently trying to open camera
+ */
+ private boolean mOpeningCamera;
public static void onCreateHALv3()
{
@@ -111,11 +137,24 @@ public static void onPauseHALv3()
// (HALv3.getInstance().manager != null))
// HALv3.getInstance().manager.removeAvailabilityListener(HALv3.getInstance().availListener);
- if (null != HALv3.getInstance().camDevice)
+ if (null != HALv3.getInstance().camDevice && null != HALv3.getInstance().mCaptureSession)
+ try
+ {
+ HALv3.getInstance().mCaptureSession.stopRepeating();
+ HALv3.getInstance().mCaptureSession.close();
+ HALv3.getInstance().mCaptureSession = null;
+ }
+ catch (final CameraAccessException e)
+ {
+ // Doesn't matter, cloising device anyway
+ e.printStackTrace();
+ }
+ finally
{
HALv3.getInstance().camDevice.close();
HALv3.getInstance().camDevice = null;
- }
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_CAMERA_STOPED, 0);
+ }
}
public static void openCameraHALv3()
@@ -127,32 +166,44 @@ public static void openCameraHALv3()
{
try
{
- onCreateHALv3();
+// onCreateHALv3();
Log.e(TAG, "try to manager.openCamera");
- HALv3.getInstance().manager.openCamera(
- CameraController.getInstance().cameraIdList[CameraController.CameraIndex],
- HALv3.getInstance().new openListener(), null);
+ String cameraId = CameraController.getInstance().cameraIdList[CameraController.CameraIndex];
+ HALv3.getInstance().camCharacter = HALv3.getInstance().manager.getCameraCharacteristics(CameraController
+ .getInstance().cameraIdList[CameraController.CameraIndex]);
+ HALv3.getInstance().manager.openCamera(cameraId, openListener, null);
} catch (CameraAccessException e)
{
- Log.e(TAG, "manager.openCamera failed: " + e.getMessage());
+ Log.e(TAG, "CameraAccessException manager.openCamera failed: " + e.getMessage());
+ e.printStackTrace();
+ MainScreen.getInstance().finish();
+ }
+ catch(IllegalArgumentException e)
+ {
+ Log.e(TAG, "IllegalArgumentException manager.openCamera failed: " + e.getMessage());
+ e.printStackTrace();
+ MainScreen.getInstance().finish();
+ }
+ catch(SecurityException e)
+ {
+ Log.e(TAG, "SecurityException manager.openCamera failed: " + e.getMessage());
e.printStackTrace();
+ MainScreen.getInstance().finish();
}
}
- try
- {
- HALv3.getInstance().camCharacter = HALv3.getInstance().manager.getCameraCharacteristics(CameraController
- .getInstance().cameraIdList[CameraController.CameraIndex]);
- } catch (CameraAccessException e)
- {
- Log.e(TAG, "getCameraCharacteristics failed: " + e.getMessage());
- e.printStackTrace();
- }
+// try
+// {
+// HALv3.getInstance().camCharacter = HALv3.getInstance().manager.getCameraCharacteristics(CameraController
+// .getInstance().cameraIdList[CameraController.CameraIndex]);
+// } catch (CameraAccessException e)
+// {
+// Log.e(TAG, "getCameraCharacteristics failed: " + e.getMessage());
+// e.printStackTrace();
+// MainScreen.getInstance().finish();
+// }
- if (HALv3.getInstance().camCharacter.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT)
- CameraController.CameraMirrored = true;
- else
- CameraController.CameraMirrored = false;
+ CameraController.CameraMirrored = (HALv3.getInstance().camCharacter.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT);
// Add an Availability Listener as Cameras become available or
// unavailable
@@ -185,14 +236,18 @@ public static void setupImageReadersHALv3()
// HALv3 code
// -------------------------------------------------------------------
MainScreen.createImageReaders();
+
+ final HandlerThread backgroundThread = new HandlerThread("imageReaders");
+ backgroundThread.start();
+
MainScreen.getPreviewYUVImageReader().setOnImageAvailableListener(
- HALv3.getInstance().new imageAvailableListener(), null);
+ imageAvailableListener, null);
- MainScreen.getYUVImageReader().setOnImageAvailableListener(HALv3.getInstance().new imageAvailableListener(),
- null);
+ MainScreen.getYUVImageReader().setOnImageAvailableListener(imageAvailableListener,
+ null);
- MainScreen.getJPEGImageReader().setOnImageAvailableListener(HALv3.getInstance().new imageAvailableListener(),
- null);
+ MainScreen.getJPEGImageReader().setOnImageAvailableListener(imageAvailableListener,
+ null);
}
public static void populateCameraDimensionsHALv3()
@@ -204,13 +259,14 @@ public static void populateCameraDimensionsHALv3()
int minMPIX = CameraController.MIN_MPIX_SUPPORTED;
CameraCharacteristics params = getCameraParameters2();
- android.hardware.camera2.Size[] cs = params.get(CameraCharacteristics.SCALER_AVAILABLE_PROCESSED_SIZES);
+ StreamConfigurationMap configMap = params.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+ final Size[] cs = configMap.getOutputSizes(ImageFormat.YUV_420_888);
int iHighestIndex = 0;
- android.hardware.camera2.Size sHighest = cs[iHighestIndex];
+ Size sHighest = cs[iHighestIndex];
int ii = 0;
- for (android.hardware.camera2.Size s : cs)
+ for (Size s : cs)
{
int currSizeWidth = s.getWidth();
int currSizeHeight = s.getHeight();
@@ -233,7 +289,7 @@ public static void populateCameraDimensionsHALv3()
if (CameraController.ResolutionsNamesList.isEmpty())
{
- android.hardware.camera2.Size s = cs[iHighestIndex];
+ Size s = cs[iHighestIndex];
int currSizeWidth = s.getWidth();
int currSizeHeight = s.getHeight();
@@ -246,17 +302,16 @@ public static void populateCameraDimensionsHALv3()
public static void fillPreviewSizeList(List previewSizes)
{
- android.hardware.camera2.Size[] cs = HALv3.getInstance().camCharacter
- .get(CameraCharacteristics.SCALER_AVAILABLE_PROCESSED_SIZES);
- for (android.hardware.camera2.Size sz : cs)
+ Size[] cs = HALv3.getInstance().camCharacter.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP).getOutputSizes(ImageFormat.YUV_420_888);
+ for (Size sz : cs)
previewSizes.add(CameraController.getInstance().new Size(sz.getWidth(), sz.getHeight()));
}
public static void fillPictureSizeList(List pictureSizes)
{
- android.hardware.camera2.Size[] cs = HALv3.getInstance().camCharacter
- .get(CameraCharacteristics.SCALER_AVAILABLE_PROCESSED_SIZES);
- for (android.hardware.camera2.Size sz : cs)
+ StreamConfigurationMap configMap = HALv3.getInstance().camCharacter.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+ Size[] cs = configMap.getOutputSizes(ImageFormat.YUV_420_888);
+ for (Size sz : cs)
pictureSizes.add(CameraController.getInstance().new Size(sz.getWidth(), sz.getHeight()));
}
@@ -306,8 +361,8 @@ public static void setZoom(float newZoom)
HALv3.getInstance().previewRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, zoomCropPreview);
try
{
- CameraController.iCaptureID = HALv3.getInstance().camDevice.setRepeatingRequest(
- HALv3.getInstance().previewRequestBuilder.build(), HALv3.getInstance().new captureListener(), null);
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.setRepeatingRequest(
+ HALv3.getInstance().previewRequestBuilder.build(), captureListener, null);
} catch (CameraAccessException e)
{
e.printStackTrace();
@@ -333,8 +388,8 @@ public static boolean isExposureCompensationSupportedHALv3()
{
if (HALv3.getInstance().camCharacter != null)
{
- int[] expRange = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE);
- return expRange[1] == expRange[0] ? false : true;
+ Range expRange = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE);
+ return expRange.getLower() == expRange.getUpper() ? false : true;
}
return false;
@@ -344,8 +399,8 @@ public static int getMinExposureCompensationHALv3()
{
if (HALv3.getInstance().camCharacter != null)
{
- int[] expRange = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE);
- return expRange[0];
+ Range expRange = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE);
+ return expRange.getLower();
}
return 0;
@@ -355,8 +410,8 @@ public static int getMaxExposureCompensationHALv3()
{
if (HALv3.getInstance().camCharacter != null)
{
- int[] expRange = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE);
- return expRange[1];
+ Range expRange = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE);
+ return expRange.getUpper();
}
return 0;
@@ -365,7 +420,7 @@ public static int getMaxExposureCompensationHALv3()
public static float getExposureCompensationStepHALv3()
{
if (HALv3.getInstance().camCharacter != null)
- return HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP).toFloat();
+ return HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP).floatValue();
return 0;
}
@@ -376,8 +431,8 @@ public static void resetExposureCompensationHALv3()
HALv3.getInstance().previewRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, 0);
try
{
- CameraController.iCaptureID = HALv3.getInstance().camDevice.setRepeatingRequest(
- HALv3.getInstance().previewRequestBuilder.build(), HALv3.getInstance().new captureListener(),
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.setRepeatingRequest(
+ HALv3.getInstance().previewRequestBuilder.build(), captureListener,
null);
} catch (CameraAccessException e)
{
@@ -386,58 +441,58 @@ public static void resetExposureCompensationHALv3()
}
}
- public static byte[] getSupportedSceneModesHALv3()
+ public static int[] getSupportedSceneModesHALv3()
{
if (HALv3.getInstance().camCharacter != null)
{
- byte[] scenes = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AVAILABLE_SCENE_MODES);
- if (scenes.length > 0 && scenes[0] != CameraCharacteristics.CONTROL_SCENE_MODE_UNSUPPORTED)
+ int[] scenes = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AVAILABLE_SCENE_MODES);
+ if (scenes.length > 0 && scenes[0] != CameraCharacteristics.CONTROL_SCENE_MODE_DISABLED)
return scenes;
}
- return new byte[0];
+ return new int[0];
}
- public static byte[] getSupportedWhiteBalanceHALv3()
+ public static int[] getSupportedWhiteBalanceHALv3()
{
if (HALv3.getInstance().camCharacter != null)
{
- byte[] wb = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AWB_AVAILABLE_MODES);
+ int[] wb = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AWB_AVAILABLE_MODES);
if (wb.length > 0)
return wb;
}
- return null;
+ return new int[0];
}
- public static byte[] getSupportedFocusModesHALv3()
+ public static int[] getSupportedFocusModesHALv3()
{
if (HALv3.getInstance().camCharacter != null)
{
- byte[] focus = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES);
+ int[] focus = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES);
if (focus.length > 0)
return focus;
}
- return new byte[0];
+ return new int[0];
}
public static boolean isFlashModeSupportedHALv3()
{
if (HALv3.getInstance().camCharacter != null)
{
- return HALv3.getInstance().camCharacter.get(CameraCharacteristics.FLASH_INFO_AVAILABLE) == 1 ? true : false;
+ return HALv3.getInstance().camCharacter.get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
}
return false;
}
- public static byte[] getSupportedISOModesHALv3()
+ public static int[] getSupportedISOModesHALv3()
{
if (HALv3.getInstance().camCharacter != null)
{
- int[] iso = HALv3.getInstance().camCharacter.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
- int max_iso = iso[1];
+ Range iso = HALv3.getInstance().camCharacter.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
+ int max_iso = iso.getUpper();
int index = 0;
for (index = 0; index < CameraController.getIsoValuesList().size(); index++)
@@ -448,7 +503,7 @@ public static byte[] getSupportedISOModesHALv3()
break;
}
}
- byte[] iso_values = new byte[index];
+ int[] iso_values = new int[index];
for (int i = 0; i < index; i++)
iso_values[i] = CameraController.getIsoValuesList().get(i).byteValue();
@@ -456,15 +511,15 @@ public static byte[] getSupportedISOModesHALv3()
return iso_values;
}
- return new byte[0];
+ return new int[0];
}
public static boolean isISOModeSupportedHALv3()
{
if (HALv3.getInstance().camCharacter != null)
{
- int[] iso = HALv3.getInstance().camCharacter.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
- if (iso[0] == iso[1])
+ Range iso = HALv3.getInstance().camCharacter.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
+ if (iso.getLower() == iso.getUpper())
return false;
return true;
}
@@ -476,7 +531,7 @@ public static int getMaxNumMeteringAreasHALv3()
{
if (HALv3.getInstance().camCharacter != null)
{
- return HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_MAX_REGIONS);
+ return HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_MAX_REGIONS_AE);
}
return 0;
@@ -486,7 +541,7 @@ public static int getMaxNumFocusAreasHALv3()
{
if (HALv3.getInstance().camCharacter != null)
{
- return HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_MAX_REGIONS);
+ return HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_MAX_REGIONS_AF);
}
return 0;
@@ -499,8 +554,8 @@ public static void setCameraSceneModeHALv3(int mode)
HALv3.getInstance().previewRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, mode);
try
{
- CameraController.iCaptureID = HALv3.getInstance().camDevice.setRepeatingRequest(
- HALv3.getInstance().previewRequestBuilder.build(), HALv3.getInstance().new captureListener(),
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.setRepeatingRequest(
+ HALv3.getInstance().previewRequestBuilder.build(), captureListener,
null);
} catch (CameraAccessException e)
{
@@ -519,8 +574,8 @@ public static void setCameraWhiteBalanceHALv3(int mode)
HALv3.getInstance().previewRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, mode);
try
{
- CameraController.iCaptureID = HALv3.getInstance().camDevice.setRepeatingRequest(
- HALv3.getInstance().previewRequestBuilder.build(), HALv3.getInstance().new captureListener(),
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.setRepeatingRequest(
+ HALv3.getInstance().previewRequestBuilder.build(), captureListener,
null);
} catch (CameraAccessException e)
{
@@ -541,8 +596,8 @@ public static void setCameraFocusModeHALv3(int mode)
HALv3.getInstance().previewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, mode);
try
{
- CameraController.iCaptureID = HALv3.getInstance().camDevice.setRepeatingRequest(
- HALv3.getInstance().previewRequestBuilder.build(), HALv3.getInstance().new captureListener(),
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.setRepeatingRequest(
+ HALv3.getInstance().previewRequestBuilder.build(), captureListener,
null);
} catch (CameraAccessException e)
{
@@ -564,8 +619,8 @@ public static void setCameraFlashModeHALv3(int mode)
HALv3.getInstance().previewRequestBuilder.set(CaptureRequest.FLASH_MODE, mode);
try
{
- CameraController.iCaptureID = HALv3.getInstance().camDevice.setRepeatingRequest(
- HALv3.getInstance().previewRequestBuilder.build(), HALv3.getInstance().new captureListener(),
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.setRepeatingRequest(
+ HALv3.getInstance().previewRequestBuilder.build(), captureListener,
null);
} catch (CameraAccessException e)
{
@@ -586,8 +641,8 @@ public static void setCameraISOModeHALv3(int mode)
.getIsoModeHALv3().get(mode));
try
{
- CameraController.iCaptureID = HALv3.getInstance().camDevice.setRepeatingRequest(
- HALv3.getInstance().previewRequestBuilder.build(), HALv3.getInstance().new captureListener(),
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.setRepeatingRequest(
+ HALv3.getInstance().previewRequestBuilder.build(), captureListener,
null);
} catch (CameraAccessException e)
{
@@ -601,13 +656,13 @@ public static void setCameraISOModeHALv3(int mode)
public static void setCameraExposureCompensationHALv3(int iEV)
{
- if (HALv3.getInstance().previewRequestBuilder != null && HALv3.getInstance().camDevice != null)
+ if (HALv3.getInstance().previewRequestBuilder != null && HALv3.getInstance().camDevice != null && HALv3.getInstance().mCaptureSession != null)
{
HALv3.getInstance().previewRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, iEV);
try
{
- CameraController.iCaptureID = HALv3.getInstance().camDevice.setRepeatingRequest(
- HALv3.getInstance().previewRequestBuilder.build(), HALv3.getInstance().new captureListener(),
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.setRepeatingRequest(
+ HALv3.getInstance().previewRequestBuilder.build(), captureListener,
null);
} catch (CameraAccessException e)
{
@@ -624,7 +679,7 @@ public static void setCameraFocusAreasHALv3(List focusAreas)
Rect zoomRect = getZoomRect(zoomLevel, activeRect.width(), activeRect.height());
if (focusAreas != null)
{
- af_regions = new int[5 * focusAreas.size()];
+ af_regions = new MeteringRectangle[focusAreas.size()];
for (int i = 0; i < focusAreas.size(); i++)
{
Rect r = focusAreas.get(i).rect;
@@ -640,21 +695,24 @@ public static void setCameraFocusAreasHALv3(List focusAreas)
Util.rectFToRect(rectF, r);
Log.e(TAG, "focusArea after matrix: " + r.left + " " + r.top + " " + r.right + " " + r.bottom);
- int currRegion = i * 5;
- af_regions[currRegion] = r.left;
- af_regions[currRegion + 1] = r.top;
- af_regions[currRegion + 2] = r.right;
- af_regions[currRegion + 3] = r.bottom;
- af_regions[currRegion + 4] = 10;
+ int currRegion = i;
+ af_regions[currRegion] = new MeteringRectangle(r.left, r.top, r.right, r.bottom, 10);
+// af_regions[currRegion] = r.left;
+// af_regions[currRegion + 1] = r.top;
+// af_regions[currRegion + 2] = r.right;
+// af_regions[currRegion + 3] = r.bottom;
+// af_regions[currRegion + 4] = 10;
}
} else
{
- af_regions = new int[5];
- af_regions[0] = 0;
- af_regions[1] = 0;
- af_regions[2] = activeRect.width() - 1;
- af_regions[3] = activeRect.height() - 1;
- af_regions[4] = 0;
+ af_regions = new MeteringRectangle[1];
+ af_regions[0] = new MeteringRectangle(0, 0, activeRect.width() - 1, activeRect.height() - 1, 10);
+// af_regions = new int[5];
+// af_regions[0] = 0;
+// af_regions[1] = 0;
+// af_regions[2] = activeRect.width() - 1;
+// af_regions[3] = activeRect.height() - 1;
+// af_regions[4] = 0;
}
Log.e(TAG, "activeRect: " + activeRect.left + " " + activeRect.top + " " + activeRect.right + " "
+ activeRect.bottom);
@@ -665,8 +723,8 @@ public static void setCameraFocusAreasHALv3(List focusAreas)
HALv3.getInstance().previewRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, af_regions);
try
{
- CameraController.iCaptureID = HALv3.getInstance().camDevice.setRepeatingRequest(
- HALv3.getInstance().previewRequestBuilder.build(), HALv3.getInstance().new captureListener(),
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.setRepeatingRequest(
+ HALv3.getInstance().previewRequestBuilder.build(), captureListener,
null);
} catch (CameraAccessException e)
{
@@ -681,7 +739,7 @@ public static void setCameraMeteringAreasHALv3(List meteringAreas)
Rect zoomRect = getZoomRect(zoomLevel, activeRect.width(), activeRect.height());
if (meteringAreas != null)
{
- ae_regions = new int[5 * meteringAreas.size()];
+ ae_regions = new MeteringRectangle[meteringAreas.size()];
for (int i = 0; i < meteringAreas.size(); i++)
{
Rect r = meteringAreas.get(i).rect;
@@ -695,21 +753,24 @@ public static void setCameraMeteringAreasHALv3(List meteringAreas)
matrix.mapRect(rectF);
Util.rectFToRect(rectF, r);
- int currRegion = i * 5;
- ae_regions[currRegion] = r.left;
- ae_regions[currRegion + 1] = r.top;
- ae_regions[currRegion + 2] = r.right;
- ae_regions[currRegion + 3] = r.bottom;
- ae_regions[currRegion + 4] = 10;
+ int currRegion = i;
+ ae_regions[currRegion] = new MeteringRectangle(r.left, r.top, r.right, r.bottom, 10);
+// ae_regions[currRegion] = r.left;
+// ae_regions[currRegion + 1] = r.top;
+// ae_regions[currRegion + 2] = r.right;
+// ae_regions[currRegion + 3] = r.bottom;
+// ae_regions[currRegion + 4] = 10;
}
} else
{
- ae_regions = new int[5];
- ae_regions[0] = 0;
- ae_regions[1] = 0;
- ae_regions[2] = activeRect.width() - 1;
- ae_regions[3] = activeRect.height() - 1;
- ae_regions[4] = 0;
+ ae_regions = new MeteringRectangle[1];
+ ae_regions[0] = new MeteringRectangle(0, 0, activeRect.width() - 1, activeRect.height() - 1, 10);
+// ae_regions = new int[5];
+// ae_regions[0] = 0;
+// ae_regions[1] = 0;
+// ae_regions[2] = activeRect.width() - 1;
+// ae_regions[3] = activeRect.height() - 1;
+// ae_regions[4] = 0;
}
if (HALv3.getInstance().previewRequestBuilder != null && HALv3.getInstance().camDevice != null)
@@ -717,8 +778,8 @@ public static void setCameraMeteringAreasHALv3(List meteringAreas)
HALv3.getInstance().previewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, ae_regions);
try
{
- CameraController.iCaptureID = HALv3.getInstance().camDevice.setRepeatingRequest(
- HALv3.getInstance().previewRequestBuilder.build(), HALv3.getInstance().new captureListener(),
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.setRepeatingRequest(
+ HALv3.getInstance().previewRequestBuilder.build(), captureListener,
null);
} catch (CameraAccessException e)
{
@@ -729,9 +790,9 @@ public static void setCameraMeteringAreasHALv3(List meteringAreas)
public static int getPreviewFrameRateHALv3()
{
- int[] range = { 0, 0 };
+ Range[] range;
range = HALv3.getInstance().camCharacter.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
- return range[range.length - 1];
+ return range[range.length - 1].getUpper();
}
public static int captureImageHALv3(int nFrames, int format)
@@ -786,8 +847,8 @@ public static int captureImageHALv3(int nFrames, int format)
// requests for SZ input frames
for (int n = 0; n < nFrames; ++n)
{
- requestID = HALv3.getInstance().camDevice.capture(stillRequestBuilder.build(),
- HALv3.getInstance().new captureListener(), null);
+ requestID = HALv3.getInstance().mCaptureSession.capture(stillRequestBuilder.build(),
+ captureListener, null);
}
// Log.e("CameraController", "captureImage 4");
// One more capture for comparison with a standard frame
@@ -811,7 +872,8 @@ public static int captureImageHALv3(int nFrames, int format)
return requestID;
}
- public static int captureImageWithParamsHALv3(final int nFrames, final int format, final int pause,
+
+ public static int captureImageWithParamsHALv3(final int nFrames, final int format, final int[] pause,
final int[] evRequested)
{
int requestID = -1;
@@ -858,156 +920,159 @@ public static int captureImageWithParamsHALv3(final int nFrames, final int forma
* camDevice.captureBurst(requests, new captureListener() , null);
*/
- HALv3.getInstance().camDevice.stopRepeating();
+// HALv3.getInstance().mCaptureSession.stopRepeating();
// requests for SZ input frames
- if (pause > 0)
+ if (pause[0] > 0)
{
- new CountDownTimer(pause, nFrames * pause)
- {
- int index = 0;
-
- public void onTick(long millisUntilFinished)
- {
- Log.e(TAG, "onTick " + index + " millisUntilFinished = " + millisUntilFinished);
- if (evRequested != null && evRequested.length > index)
- {
- stillRequestBuilder
- .set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, evRequested[index]);
- // setCameraExposureCompensationHALv3(evRequested[index]);
- }
-
- try
- {
- HALv3.getInstance().camDevice.capture(stillRequestBuilder.build(),
- HALv3.getInstance().new captureListener(), null);
- } catch (CameraAccessException e)
- {
- e.printStackTrace();
- }
-
- index++;
- }
-
- public void onFinish()
- {
- Log.e(TAG, "onFinish index = " + index);
- if (evRequested != null && evRequested.length > index)
- {
- stillRequestBuilder
- .set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, evRequested[index]);
- // setCameraExposureCompensationHALv3(evRequested[index]);
- }
-
- try
- {
- HALv3.getInstance().camDevice.capture(stillRequestBuilder.build(),
- HALv3.getInstance().new captureListener(), null);
- } catch (CameraAccessException e)
- {
- e.printStackTrace();
- }
- }
- }.start();
+ totalFrames = nFrames;
+ currentFrameIndex = 0;
+ pauseBetweenShots = pause;
+ expRequested = evRequested;
+ captureNextImageWithParams(format, pause[currentFrameIndex], evRequested, currentFrameIndex);
+// new CountDownTimer(nFrames * pause, pause)
+// {
+// int index = 0;
+//
+// public void onTick(long millisUntilFinished)
+// {
+// Log.e(TAG, "onTick " + index + " millisUntilFinished = " + millisUntilFinished);
+// if (evRequested != null && evRequested.length > index)
+// {
+// stillRequestBuilder
+// .set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, evRequested[index]);
+// // setCameraExposureCompensationHALv3(evRequested[index]);
+// }
+//
+// try
+// {
+// HALv3.getInstance().mCaptureSession.capture(stillRequestBuilder.build(),
+// captureListener, null);
+// } catch (CameraAccessException e)
+// {
+// e.printStackTrace();
+// }
+//
+// index++;
+// }
+//
+// public void onFinish()
+// {
+// Log.e(TAG, "onFinish index = " + index);
+// if (evRequested != null && evRequested.length > index)
+// {
+// stillRequestBuilder
+// .set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, evRequested[index]);
+// // setCameraExposureCompensationHALv3(evRequested[index]);
+// }
+//
+// try
+// {
+// HALv3.getInstance().mCaptureSession.capture(stillRequestBuilder.build(),
+// captureListener, null);
+// } catch (CameraAccessException e)
+// {
+// e.printStackTrace();
+// }
+// }
+// }.start();
} else
{
if (evRequested != null && evRequested.length >= nFrames)
{
- // for (int n=0; n= nFrames)
- return;
-
- Log.e(TAG, "onTick " + index + " millisUntilFinished = " + millisUntilFinished);
- if (evRequested != null && evRequested.length > index)
- {
- // long expTime = index == 2 ? expt/2 : index ==
- // 3 ? expt*2 : expt;
- // Log.e(TAG, "Exp Time = " + expTime);
- // stillRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
- // CameraMetadata.CONTROL_AE_MODE_OFF);
- // stillRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME,
- // expTime);
-
- stillRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION,
- evRequested[index]);
- // setCameraExposureCompensationHALv3(evRequested[index]);
- }
-
- try
- {
- HALv3.getInstance().camDevice.capture(stillRequestBuilder.build(),
- HALv3.getInstance().new captureListener(), null);
- } catch (CameraAccessException e)
- {
- e.printStackTrace();
- }
-
- index++;
- }
-
- public void onFinish()
+ HALv3.getInstance().mCaptureSession.capture(stillRequestBuilder.build(),
+ captureListener, null);
+ } catch (CameraAccessException e)
{
- if (index > nFrames)
- return;
-
- Log.e(TAG, "onFinish index = " + index);
- if (evRequested != null && evRequested.length > index)
- {
- // long expTime = index == 2 ? expt/2 : index ==
- // 3 ? expt*2 : expt;
- //
- // Log.e(TAG, "Exp Time = " + expTime);
- //
- // stillRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
- // CameraMetadata.CONTROL_AE_MODE_OFF);
- // stillRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME,
- // expTime);
-
- stillRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION,
- evRequested[index]);
- // setCameraExposureCompensationHALv3(evRequested[index]);
- }
-
- try
- {
- HALv3.getInstance().camDevice.capture(stillRequestBuilder.build(),
- HALv3.getInstance().new captureListener(), null);
- } catch (CameraAccessException e)
- {
- e.printStackTrace();
- }
+ e.printStackTrace();
}
- }.start();
- Log.e(TAG, "CountDownTimer started");
+ }
+
+// stillRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, evRequested[0]);
+// // setCameraExposureCompensationHALv3(evRequested[0]);
+// // final long expt = exposureTime;
+// // stillRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
+// // CameraMetadata.CONTROL_AE_MODE_OFF);
+// // stillRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME,
+// // expt);
+// Log.e(TAG, "evRequested != null");
+// new CountDownTimer(500 * nFrames, 500)
+// {
+// int index = 1;
+//
+// public void onTick(long millisUntilFinished)
+// {
+// if (index >= nFrames)
+// return;
+//
+// Log.e(TAG, "onTick " + index + " millisUntilFinished = " + millisUntilFinished);
+// if (evRequested != null && evRequested.length > index)
+// {
+// // long expTime = index == 2 ? expt/2 : index ==
+// // 3 ? expt*2 : expt;
+// // Log.e(TAG, "Exp Time = " + expTime);
+// // stillRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
+// // CameraMetadata.CONTROL_AE_MODE_OFF);
+// // stillRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME,
+// // expTime);
+//
+// stillRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION,
+// evRequested[index]);
+// // setCameraExposureCompensationHALv3(evRequested[index]);
+// }
+//
+// try
+// {
+// HALv3.getInstance().mCaptureSession.capture(stillRequestBuilder.build(),
+// captureListener, null);
+// } catch (CameraAccessException e)
+// {
+// e.printStackTrace();
+// }
+//
+// index++;
+// }
+//
+// public void onFinish()
+// {
+// if (index > nFrames)
+// return;
+//
+// Log.e(TAG, "onFinish index = " + index);
+// if (evRequested != null && evRequested.length > index)
+// {
+// // long expTime = index == 2 ? expt/2 : index ==
+// // 3 ? expt*2 : expt;
+// //
+// // Log.e(TAG, "Exp Time = " + expTime);
+// //
+// // stillRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
+// // CameraMetadata.CONTROL_AE_MODE_OFF);
+// // stillRequestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME,
+// // expTime);
+//
+// stillRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION,
+// evRequested[index]);
+// // setCameraExposureCompensationHALv3(evRequested[index]);
+// }
+//
+// try
+// {
+// HALv3.getInstance().mCaptureSession.capture(stillRequestBuilder.build(),
+// captureListener, null);
+// } catch (CameraAccessException e)
+// {
+// e.printStackTrace();
+// }
+// }
+// }.start();
+// Log.e(TAG, "CountDownTimer started");
} else
{
for (int n = 0; n < nFrames; ++n)
@@ -1018,18 +1083,18 @@ public void onFinish()
// evRequested[n]);
// setCameraExposureCompensationHALv3(evRequested[n]);
// }
- requestID = HALv3.getInstance().camDevice.capture(stillRequestBuilder.build(),
- HALv3.getInstance().new captureListener(), null);
+ requestID = HALv3.getInstance().mCaptureSession.capture(stillRequestBuilder.build(),
+ captureListener, null);
}
}
}
// requestID =
// HALv3.getInstance().camDevice.captureBurst(requestList,
- // HALv3.getInstance().new captureListener() , null);
+ // captureListener , null);
// requestID =
// HALv3.getInstance().camDevice.capture(stillRequestBuilder.build(),
- // HALv3.getInstance().new captureListener() , null);
+ // captureListener , null);
// Log.e("CameraController", "captureImage 4");
// One more capture for comparison with a standard frame
// stillRequestBuilder.set(CaptureRequest.EDGE_MODE,
@@ -1051,6 +1116,69 @@ public void onFinish()
return requestID;
}
+
+ private static int captureNextImageWithParams(final int format, final int pause, final int[] evRequested, final int index)
+ {
+ int requestID = -1;
+ final CaptureRequest.Builder stillRequestBuilder;
+ try
+ {
+ stillRequestBuilder = HALv3.getInstance().camDevice
+ .createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
+ stillRequestBuilder.set(CaptureRequest.EDGE_MODE, CaptureRequest.EDGE_MODE_HIGH_QUALITY);
+ stillRequestBuilder.set(CaptureRequest.NOISE_REDUCTION_MODE,
+ CaptureRequest.NOISE_REDUCTION_MODE_HIGH_QUALITY);
+ stillRequestBuilder.set(CaptureRequest.TONEMAP_MODE, CaptureRequest.TONEMAP_MODE_HIGH_QUALITY);
+ if (zoomLevel >= 1.0f)
+ {
+ zoomCropCapture = getZoomRect(zoomLevel, activeRect.width(), activeRect.height());
+ stillRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, zoomCropCapture);
+ }
+
+ if (format == CameraController.JPEG)
+ {
+ stillRequestBuilder.addTarget(MainScreen.getJPEGImageReader().getSurface());
+ } else
+ {
+ stillRequestBuilder.addTarget(MainScreen.getYUVImageReader().getSurface());
+ }
+
+ if (pause > 0)
+ {
+ new CountDownTimer(pause, pause)
+ {
+ public void onTick(long millisUntilFinished)
+ {
+
+ }
+
+ public void onFinish()
+ {
+ if (evRequested != null && evRequested.length > index)
+ stillRequestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, evRequested[index]);
+
+ try
+ {
+ HALv3.getInstance().mCaptureSession.capture(stillRequestBuilder.build(),
+ captureListener, null);
+ } catch (CameraAccessException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }.start();
+
+ }
+ }
+ catch (CameraAccessException e)
+ {
+ Log.e(TAG, "setting up still image capture request failed");
+ e.printStackTrace();
+ throw new RuntimeException();
+ }
+
+ return requestID;
+ }
public static boolean autoFocusHALv3()
{
@@ -1065,8 +1193,8 @@ public static boolean autoFocusHALv3()
{
Log.e(TAG,
"autoFocusHALv3. CaptureRequest.CONTROL_AF_TRIGGER, CameraCharacteristics.CONTROL_AF_TRIGGER_START");
- CameraController.iCaptureID = HALv3.getInstance().camDevice.capture(
- HALv3.getInstance().previewRequestBuilder.build(), HALv3.getInstance().new focusListener(),
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.capture(
+ HALv3.getInstance().previewRequestBuilder.build(), focusListener,
null);
} catch (CameraAccessException e)
{
@@ -1090,8 +1218,8 @@ public static void cancelAutoFocusHALv3()
CameraCharacteristics.CONTROL_AF_TRIGGER_CANCEL);
try
{
- CameraController.iCaptureID = HALv3.getInstance().camDevice.capture(
- HALv3.getInstance().previewRequestBuilder.build(), HALv3.getInstance().new captureListener(),
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.capture(
+ HALv3.getInstance().previewRequestBuilder.build(), captureListener,
null);
} catch (CameraAccessException e)
{
@@ -1109,44 +1237,16 @@ public void configurePreviewRequest() throws CameraAccessException
.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
HALv3.getInstance().previewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
- HALv3.getInstance().previewRequestBuilder.set(CaptureRequest.REQUEST_ID, 555);
HALv3.getInstance().previewRequestBuilder.addTarget(MainScreen.getInstance().getCameraSurface());
HALv3.getInstance().previewRequestBuilder.addTarget(MainScreen.getInstance().getPreviewYUVSurface());
- HALv3.getInstance().camDevice.setRepeatingRequest(HALv3.getInstance().previewRequestBuilder.build(),
- HALv3.getInstance().new captureListener(), null);
+ HALv3.getInstance().mCaptureSession.setRepeatingRequest(HALv3.getInstance().previewRequestBuilder.build(),
+ captureListener, null);
}
// HALv3 ------------------------------------------------ camera-related
// listeners
-
- // Note: never received onCameraAvailable notifications, only
- // onCameraUnavailable
@SuppressLint("Override")
- @TargetApi(19)
- public class cameraAvailableListener extends CameraManager.AvailabilityListener
- {
- @Override
- public void onCameraAvailable(java.lang.String cameraId)
- {
- // should we call this?
- super.onCameraAvailable(cameraId);
-
- Log.d(TAG, "CameraManager.AvailabilityListener.onCameraAvailable");
- }
-
- @Override
- public void onCameraUnavailable(java.lang.String cameraId)
- {
- // should we call this?
- super.onCameraUnavailable(cameraId);
-
- Log.d(TAG, "CameraManager.AvailabilityListener.onCameraUnavailable");
- }
- }
-
- @SuppressLint("Override")
- @TargetApi(19)
- public class openListener extends CameraDevice.StateListener
+ public final static CameraDevice.StateListener openListener = new CameraDevice.StateListener()
{
@Override
public void onDisconnected(CameraDevice arg0)
@@ -1156,12 +1256,10 @@ public void onDisconnected(CameraDevice arg0)
{
try
{
- HALv3.getInstance().camDevice.stopRepeating();
- HALv3.getInstance().camDevice.waitUntilIdle();
- HALv3.getInstance().camDevice.flush();
HALv3.getInstance().camDevice.close();
HALv3.getInstance().camDevice = null;
- } catch (CameraAccessException e)
+ HALv3.getInstance().mOpeningCamera = false;
+ } catch (Exception e)
{
HALv3.getInstance().camDevice = null;
Log.e(TAG, "close camera device failed: " + e.getMessage());
@@ -1173,6 +1271,7 @@ public void onDisconnected(CameraDevice arg0)
@Override
public void onError(CameraDevice arg0, int arg1)
{
+ HALv3.getInstance().mOpeningCamera = false;
Log.e(TAG, "CameraDevice.StateListener.onError: " + arg1);
}
@@ -1182,26 +1281,61 @@ public void onOpened(CameraDevice arg0)
Log.e(TAG, "CameraDevice.StateListener.onOpened");
HALv3.getInstance().camDevice = arg0;
+
+ HALv3.getInstance().mOpeningCamera = false;
MainScreen.getMessageHandler().sendEmptyMessage(PluginManager.MSG_CAMERA_OPENED);
// dumpCameraCharacteristics();
}
- }
-
- // Note: there other onCaptureXxxx methods in this listener which we do not
- // implement
- @TargetApi(19)
- public class focusListener extends CameraDevice.CaptureListener
+ };
+
+
+ public final static CameraCaptureSession.StateListener captureSessionStateListener = new CameraCaptureSession.StateListener()
{
@Override
- public void onCapturePartial(CameraDevice camera, CaptureRequest request, CaptureResult result)
+ public void onConfigureFailed(final CameraCaptureSession session)
{
- Log.e(TAG, "onFocusPartial. AF State = " + result.get(CaptureResult.CONTROL_AF_STATE));
+ Log.e(TAG, "CaptureSessionConfigure failed");
+ MainScreen.getInstance().finish();
}
@Override
- public void onCaptureCompleted(CameraDevice camera, CaptureRequest request, CaptureResult result)
+ public void onConfigured(final CameraCaptureSession session)
+ {
+ Log.e(TAG, "CaptureSession configured SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ HALv3.getInstance().mCaptureSession = session;
+
+ try
+ {
+ Log.e(TAG, "configurePreviewRequest()");
+ HALv3.getInstance().previewRequestBuilder = HALv3.getInstance().camDevice
+ .createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
+ HALv3.getInstance().previewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
+ CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
+ HALv3.getInstance().previewRequestBuilder.addTarget(MainScreen.getInstance().getCameraSurface());
+ HALv3.getInstance().previewRequestBuilder.addTarget(MainScreen.getInstance().getPreviewYUVSurface());
+ session.setRepeatingRequest(HALv3.getInstance().previewRequestBuilder.build(),
+ captureListener, null);
+
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_CAMERA_CONFIGURED, 0);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+ Toast.makeText(MainScreen.getInstance(), "Unable to start preview: " + e.getMessage(), Toast.LENGTH_SHORT).show();
+ MainScreen.getInstance().finish();
+ }
+ }
+
+ };
+
+ // Note: there other onCaptureXxxx methods in this listener which we do not
+ // implement
+ public final static CameraCaptureSession.CaptureListener focusListener = new CameraCaptureSession.CaptureListener()
+ {
+ @Override
+ public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
{
PluginManager.getInstance().onCaptureCompleted(result);
try
@@ -1241,7 +1375,7 @@ public void onCaptureCompleted(CameraDevice camera, CaptureRequest request, Capt
Log.e(TAG, "Exception: " + e.getMessage());
}
- // if(result.get(CaptureResult.REQUEST_ID) == iCaptureID)
+ // if(result.getSequenceId() == iCaptureID)
// {
// //Log.e(TAG, "Image metadata received. Capture timestamp = " +
// result.get(CaptureResult.SENSOR_TIMESTAMP));
@@ -1273,7 +1407,7 @@ private void resetCaptureListener()
try
{
// HALv3.getInstance().camDevice.stopRepeating();
- CameraController.iCaptureID = HALv3.getInstance().camDevice.capture(
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.capture(
HALv3.getInstance().previewRequestBuilder.build(), null, null);
} catch (CameraAccessException e)
{
@@ -1281,13 +1415,12 @@ private void resetCaptureListener()
}
}
}
- }
+ };
- @TargetApi(19)
- public class captureListener extends CameraDevice.CaptureListener
+ public final static CameraCaptureSession.CaptureListener captureListener = new CameraCaptureSession.CaptureListener()
{
@Override
- public void onCaptureCompleted(CameraDevice camera, CaptureRequest request, CaptureResult result)
+ public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
{
PluginManager.getInstance().onCaptureCompleted(result);
try
@@ -1326,7 +1459,7 @@ public void onCaptureCompleted(CameraDevice camera, CaptureRequest request, Capt
Log.e(TAG, "Exception: " + e.getMessage());
}
- // if(result.get(CaptureResult.REQUEST_ID) == iCaptureID)
+ // if(result.getSequenceId() == iCaptureID)
// {
// //Log.e(TAG, "Image metadata received. Capture timestamp = " +
// result.get(CaptureResult.SENSOR_TIMESTAMP));
@@ -1358,7 +1491,7 @@ private void resetCaptureListener()
try
{
// HALv3.getInstance().camDevice.stopRepeating();
- CameraController.iCaptureID = HALv3.getInstance().camDevice.capture(
+ CameraController.iCaptureID = HALv3.getInstance().mCaptureSession.capture(
HALv3.getInstance().previewRequestBuilder.build(), null, null);
} catch (CameraAccessException e)
{
@@ -1366,10 +1499,9 @@ private void resetCaptureListener()
}
}
}
- }
+ };
- @TargetApi(19)
- public class imageAvailableListener implements ImageReader.OnImageAvailableListener
+ public final static ImageReader.OnImageAvailableListener imageAvailableListener = new ImageReader.OnImageAvailableListener()
{
@Override
public void onImageAvailable(ImageReader ir)
@@ -1383,17 +1515,100 @@ public void onImageAvailable(ImageReader ir)
Image im = ir.acquireNextImage();
// if(iPreviewFrameID == im.getTimestamp())
if (ir.getSurface() == CameraController.mPreviewSurface)
- PluginManager.getInstance().onPreviewAvailable(im);
+ {
+ ByteBuffer Y = im.getPlanes()[0].getBuffer();
+ ByteBuffer U = im.getPlanes()[1].getBuffer();
+ ByteBuffer V = im.getPlanes()[2].getBuffer();
+
+ if ((!Y.isDirect()) || (!U.isDirect()) || (!V.isDirect()))
+ {
+ Log.e(TAG, "Oops, YUV ByteBuffers isDirect failed");
+ return;
+ }
+
+ int imageWidth = im.getWidth();
+ int imageHeight = im.getHeight();
+ // Note: android documentation guarantee that:
+ // - Y pixel stride is always 1
+ // - U and V strides are the same
+ // So, passing all these parameters is a bit overkill
+
+ byte[] data = YuvImage.CreateSingleYUVImage(Y, U, V, im.getPlanes()[0].getPixelStride(),
+ im.getPlanes()[0].getRowStride(), im.getPlanes()[1].getPixelStride(),
+ im.getPlanes()[1].getRowStride(), im.getPlanes()[2].getPixelStride(),
+ im.getPlanes()[2].getRowStride(), imageWidth, imageHeight);
+
+ PluginManager.getInstance().onPreviewFrame(data);
+ }
else
{
Log.e("HALv3", "onImageAvailable");
- PluginManager.getInstance().onImageAvailable(im);
+ //PluginManager.getInstance().onImageAvailable(im);
+// int frame = CameraController.getImageFrame(im);
+// byte[] frameData = CameraController.getImageFrameData(im);
+// int frame_len = CameraController.getImageLenght(im);
+// boolean isYUV = CameraController.isYUVImage(im);
+
+
+ int frame = 0;
+ byte[] frameData = new byte[0];
+ int frame_len = 0;
+ boolean isYUV = false;
+
+ if (im.getFormat() == ImageFormat.YUV_420_888)
+ {
+ ByteBuffer Y = im.getPlanes()[0].getBuffer();
+ ByteBuffer U = im.getPlanes()[1].getBuffer();
+ ByteBuffer V = im.getPlanes()[2].getBuffer();
+
+ if ((!Y.isDirect()) || (!U.isDirect()) || (!V.isDirect()))
+ {
+ Log.e(TAG, "Oops, YUV ByteBuffers isDirect failed");
+ return;
+ }
+
+ // Note: android documentation guarantee that:
+ // - Y pixel stride is always 1
+ // - U and V strides are the same
+ // So, passing all these parameters is a bit overkill
+ int status = YuvImage.CreateYUVImage(Y, U, V, im.getPlanes()[0].getPixelStride(),
+ im.getPlanes()[0].getRowStride(), im.getPlanes()[1].getPixelStride(),
+ im.getPlanes()[1].getRowStride(), im.getPlanes()[2].getPixelStride(),
+ im.getPlanes()[2].getRowStride(), MainScreen.getImageWidth(), MainScreen.getImageHeight(), 0);
+
+ if (status != 0)
+ Log.e(TAG, "Error while cropping: " + status);
+
+ frameData = YuvImage.GetByteFrame(0);
+ frame = YuvImage.GetFrame(0);
+
+
+ frame_len = MainScreen.getImageWidth() * MainScreen.getImageHeight() + MainScreen.getImageWidth()
+ * ((MainScreen.getImageHeight() + 1) / 2);
+
+ isYUV = true;
+
+ } else if (im.getFormat() == ImageFormat.JPEG)
+ {
+ ByteBuffer jpeg = im.getPlanes()[0].getBuffer();
+
+ frame_len = jpeg.limit();
+ frameData = new byte[frame_len];
+ jpeg.get(frameData, 0, frame_len);
+
+ frame = SwapHeap.SwapToHeap(frameData);
+ }
+
+ PluginManager.getInstance().onImageTaken(frame, frameData, frame_len, isYUV);
+
+ if(++currentFrameIndex < totalFrames)
+ captureNextImageWithParams(im.getFormat(), pauseBetweenShots[currentFrameIndex], expRequested, currentFrameIndex);
}
// Image should be closed after we are done with it
im.close();
}
- }
+ };
// ^^ HALv3 code
// --------------------------------------------------------------
// camera-related listeners
diff --git a/src/com/almalence/opencam/ui/AlmalenceGUI.java b/src/com/almalence/opencam/ui/AlmalenceGUI.java
index 0387f5aa..030b638a 100644
--- a/src/com/almalence/opencam/ui/AlmalenceGUI.java
+++ b/src/com/almalence/opencam/ui/AlmalenceGUI.java
@@ -14,16 +14,15 @@
The Initial Developer of the Original Code is Almalence Inc.
Portions created by Initial Developer are Copyright (C) 2013
by Almalence Inc. All Rights Reserved.
-*/
-
+ */
/* */
+ package com.almalence.opencam_plus.ui;
+ +++ --> */
//
+//-+- -->
import java.io.IOException;
import java.util.ArrayList;
@@ -56,7 +55,6 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.os.AsyncTask;
import android.os.Build;
import android.os.CountDownTimer;
-import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.preference.PreferenceManager;
import android.util.DisplayMetrics;
@@ -67,7 +65,6 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.OrientationEventListener;
-import android.view.Surface;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
@@ -113,17 +110,17 @@ Portions created by Initial Developer are Copyright (C) 2013
//-+- -->
/* */
+ import com.almalence.opencam_plus.CameraController;
+ import com.almalence.opencam_plus.CameraParameters;
+ import com.almalence.opencam_plus.ConfigParser;
+ import com.almalence.opencam_plus.MainScreen;
+ import com.almalence.opencam_plus.Mode;
+ import com.almalence.opencam_plus.Plugin;
+ import com.almalence.opencam_plus.PluginManager;
+ import com.almalence.opencam_plus.PluginType;
+ import com.almalence.opencam_plus.Preferences;
+ import com.almalence.opencam_plus.R;
+ +++ --> */
import com.almalence.util.Util;
@@ -131,235 +128,249 @@ Portions created by Initial Developer are Copyright (C) 2013
* AlmalenceGUI is an instance of GUI class, implements current GUI
***/
-public class AlmalenceGUI extends GUI implements
- SeekBar.OnSeekBarChangeListener, View.OnLongClickListener,
- View.OnClickListener {
- private SharedPreferences preferences;
+public class AlmalenceGUI extends GUI implements SeekBar.OnSeekBarChangeListener, View.OnLongClickListener,
+ View.OnClickListener
+{
+ private SharedPreferences preferences;
- private static final int INFO_ALL = 0;
- private static final int INFO_NO = 1;
- private static final int INFO_GRID = 2;
- private static final int INFO_PARAMS = 3;
- private int infoSet = INFO_PARAMS;
+ private static final int INFO_ALL = 0;
+ private static final int INFO_NO = 1;
+ private static final int INFO_GRID = 2;
+ private static final int INFO_PARAMS = 3;
+ private int infoSet = INFO_PARAMS;
- public enum ShutterButton {
- DEFAULT, RECORDER_START, RECORDER_STOP, RECORDER_RECORDING, RECORDER_PAUSED
+ public enum ShutterButton
+ {
+ DEFAULT, RECORDER_START_WITH_PAUSE, RECORDER_START, RECORDER_STOP_WITH_PAUSE, RECORDER_STOP, RECORDER_RECORDING_WITH_PAUSE, RECORDER_RECORDING, RECORDER_PAUSED
}
- public enum SettingsType {
+ public enum SettingsType
+ {
SCENE, WB, FOCUS, FLASH, ISO, METERING, CAMERA, EV, MORE
}
- private OrientationEventListener orientListener;
+ private OrientationEventListener orientListener;
// certain quick control visible
- private boolean quickControlsVisible = false;
+ private boolean quickControlsVisible = false;
// Quick control customization variables
- private ElementAdapter quickControlAdapter;
- private List quickControlChangeres;
- private View currentQuickView = null; // Current quick control to replace
- private boolean quickControlsChangeVisible = false; // If qc customization
- // layout is showing now
+ private ElementAdapter quickControlAdapter;
+ private List quickControlChangeres;
+ private View currentQuickView = null;
+ // Current quick control to replace If qc customization layout is showing now
+ private boolean quickControlsChangeVisible = false;
// Settings layout
- private ElementAdapter settingsAdapter;
- private List settingsViews;
- private boolean settingsControlsVisible = false; // If quick settings layout
- // is showing now
+ private ElementAdapter settingsAdapter;
+ private List settingsViews;
+ private boolean settingsControlsVisible = false;
+ // If quick settings layout is showing now
// Mode selector layout
- private ElementAdapter modeAdapter;
- private List modeViews;
- private boolean modeSelectorVisible = false; // If quick settings layout is
- // showing now
+ private ElementAdapter modeAdapter;
+ private List modeViews;
+ private boolean modeSelectorVisible = false;
+ // If quick settings layout is showing now
+
+ private AlmalenceStore store;
+
+ private SelfTimer selfTimer;
- private AlmalenceStore store;
-
- private SelfTimer selfTimer;
-
// Assoc list for storing association between mode button and mode ID
- private Map buttonModeViewAssoc;
+ private Map buttonModeViewAssoc;
- private Thumbnail mThumbnail;
- private RotateImageView thumbnailView;
-
- private RotateImageView shutterButton;
+ private Thumbnail mThumbnail;
+ private RotateImageView thumbnailView;
- private static final Integer ICON_EV = R.drawable.gui_almalence_settings_exposure;
- private static final Integer ICON_CAM = R.drawable.gui_almalence_settings_changecamera;
- private static final Integer ICON_SETTINGS = R.drawable.gui_almalence_settings_more_settings;
+ private RotateImageView shutterButton;
- private static final int FOCUS_AF_LOCK = 10;
+ private static final Integer ICON_EV = R.drawable.gui_almalence_settings_exposure;
+ private static final Integer ICON_CAM = R.drawable.gui_almalence_settings_changecamera;
+ private static final Integer ICON_SETTINGS = R.drawable.gui_almalence_settings_more_settings;
+
+ private static final int FOCUS_AF_LOCK = 10;
// Lists of icons for camera parameters (scene mode, flash mode, focus mode,
// white balance, iso)
- private static final Map ICONS_SCENE = new HashMap() {
- {
- put(CameraParameters.SCENE_MODE_AUTO, R.drawable.gui_almalence_settings_scene_auto);
- put(CameraParameters.SCENE_MODE_ACTION, R.drawable.gui_almalence_settings_scene_action);
- put(CameraParameters.SCENE_MODE_PORTRAIT, R.drawable.gui_almalence_settings_scene_portrait);
- put(CameraParameters.SCENE_MODE_LANDSCAPE, R.drawable.gui_almalence_settings_scene_landscape);
- put(CameraParameters.SCENE_MODE_NIGHT, R.drawable.gui_almalence_settings_scene_night);
- put(CameraParameters.SCENE_MODE_NIGHT_PORTRAIT, R.drawable.gui_almalence_settings_scene_nightportrait);
- put(CameraParameters.SCENE_MODE_THEATRE, R.drawable.gui_almalence_settings_scene_theater);
- put(CameraParameters.SCENE_MODE_BEACH, R.drawable.gui_almalence_settings_scene_beach);
- put(CameraParameters.SCENE_MODE_SNOW, R.drawable.gui_almalence_settings_scene_snow);
- put(CameraParameters.SCENE_MODE_SUNSET, R.drawable.gui_almalence_settings_scene_sunset);
- put(CameraParameters.SCENE_MODE_STEADYPHOTO, R.drawable.gui_almalence_settings_scene_steadyphoto);
- put(CameraParameters.SCENE_MODE_FIREWORKS, R.drawable.gui_almalence_settings_scene_fireworks);
- put(CameraParameters.SCENE_MODE_SPORTS, R.drawable.gui_almalence_settings_scene_sports);
- put(CameraParameters.SCENE_MODE_PARTY, R.drawable.gui_almalence_settings_scene_party);
- put(CameraParameters.SCENE_MODE_CANDLELIGHT, R.drawable.gui_almalence_settings_scene_candlelight);
- put(CameraParameters.SCENE_MODE_BARCODE, R.drawable.gui_almalence_settings_scene_barcode);
+ private static final Map ICONS_SCENE = new HashMap()
+ {
+ {
+ put(CameraParameters.SCENE_MODE_AUTO, R.drawable.gui_almalence_settings_scene_auto);
+ put(CameraParameters.SCENE_MODE_ACTION, R.drawable.gui_almalence_settings_scene_action);
+ put(CameraParameters.SCENE_MODE_PORTRAIT, R.drawable.gui_almalence_settings_scene_portrait);
+ put(CameraParameters.SCENE_MODE_LANDSCAPE, R.drawable.gui_almalence_settings_scene_landscape);
+ put(CameraParameters.SCENE_MODE_NIGHT, R.drawable.gui_almalence_settings_scene_night);
+ put(CameraParameters.SCENE_MODE_NIGHT_PORTRAIT, R.drawable.gui_almalence_settings_scene_nightportrait);
+ put(CameraParameters.SCENE_MODE_THEATRE, R.drawable.gui_almalence_settings_scene_theater);
+ put(CameraParameters.SCENE_MODE_BEACH, R.drawable.gui_almalence_settings_scene_beach);
+ put(CameraParameters.SCENE_MODE_SNOW, R.drawable.gui_almalence_settings_scene_snow);
+ put(CameraParameters.SCENE_MODE_SUNSET, R.drawable.gui_almalence_settings_scene_sunset);
+ put(CameraParameters.SCENE_MODE_STEADYPHOTO, R.drawable.gui_almalence_settings_scene_steadyphoto);
+ put(CameraParameters.SCENE_MODE_FIREWORKS, R.drawable.gui_almalence_settings_scene_fireworks);
+ put(CameraParameters.SCENE_MODE_SPORTS, R.drawable.gui_almalence_settings_scene_sports);
+ put(CameraParameters.SCENE_MODE_PARTY, R.drawable.gui_almalence_settings_scene_party);
+ put(CameraParameters.SCENE_MODE_CANDLELIGHT, R.drawable.gui_almalence_settings_scene_candlelight);
+ put(CameraParameters.SCENE_MODE_BARCODE, R.drawable.gui_almalence_settings_scene_barcode);
}
};
- private static final Map ICONS_WB = new HashMap() {
+ private static final Map ICONS_WB = new HashMap()
+ {
{
- put(CameraParameters.WB_MODE_AUTO, R.drawable.gui_almalence_settings_wb_auto);
- put(CameraParameters.WB_MODE_INCANDESCENT, R.drawable.gui_almalence_settings_wb_incandescent);
- put(CameraParameters.WB_MODE_FLUORESCENT, R.drawable.gui_almalence_settings_wb_fluorescent);
+ put(CameraParameters.WB_MODE_AUTO, R.drawable.gui_almalence_settings_wb_auto);
+ put(CameraParameters.WB_MODE_INCANDESCENT, R.drawable.gui_almalence_settings_wb_incandescent);
+ put(CameraParameters.WB_MODE_FLUORESCENT, R.drawable.gui_almalence_settings_wb_fluorescent);
put(CameraParameters.WB_MODE_WARM_FLUORESCENT, R.drawable.gui_almalence_settings_wb_warmfluorescent);
- put(CameraParameters.WB_MODE_DAYLIGHT, R.drawable.gui_almalence_settings_wb_daylight);
- put(CameraParameters.WB_MODE_CLOUDY_DAYLIGHT, R.drawable.gui_almalence_settings_wb_cloudydaylight);
- put(CameraParameters.WB_MODE_TWILIGHT, R.drawable.gui_almalence_settings_wb_twilight);
- put(CameraParameters.WB_MODE_SHADE, R.drawable.gui_almalence_settings_wb_shade);
+ put(CameraParameters.WB_MODE_DAYLIGHT, R.drawable.gui_almalence_settings_wb_daylight);
+ put(CameraParameters.WB_MODE_CLOUDY_DAYLIGHT, R.drawable.gui_almalence_settings_wb_cloudydaylight);
+ put(CameraParameters.WB_MODE_TWILIGHT, R.drawable.gui_almalence_settings_wb_twilight);
+ put(CameraParameters.WB_MODE_SHADE, R.drawable.gui_almalence_settings_wb_shade);
}
};
- private static final Map ICONS_FOCUS = new HashMap() {
+ private static final Map ICONS_FOCUS = new HashMap()
+ {
{
- put(CameraParameters.AF_MODE_AUTO, R.drawable.gui_almalence_settings_focus_auto);
- put(CameraParameters.AF_MODE_INFINITY, R.drawable.gui_almalence_settings_focus_infinity);
- put(CameraParameters.AF_MODE_NORMAL, R.drawable.gui_almalence_settings_focus_normal);
- put(CameraParameters.AF_MODE_MACRO, R.drawable.gui_almalence_settings_focus_macro);
- put(CameraParameters.AF_MODE_FIXED, R.drawable.gui_almalence_settings_focus_fixed);
- put(CameraParameters.AF_MODE_EDOF, R.drawable.gui_almalence_settings_focus_edof);
- put(CameraParameters.AF_MODE_CONTINUOUS_VIDEO, R.drawable.gui_almalence_settings_focus_continiuousvideo);
+ put(CameraParameters.AF_MODE_AUTO, R.drawable.gui_almalence_settings_focus_auto);
+ put(CameraParameters.AF_MODE_INFINITY, R.drawable.gui_almalence_settings_focus_infinity);
+ put(CameraParameters.AF_MODE_NORMAL, R.drawable.gui_almalence_settings_focus_normal);
+ put(CameraParameters.AF_MODE_MACRO, R.drawable.gui_almalence_settings_focus_macro);
+ put(CameraParameters.AF_MODE_FIXED, R.drawable.gui_almalence_settings_focus_fixed);
+ put(CameraParameters.AF_MODE_EDOF, R.drawable.gui_almalence_settings_focus_edof);
+ put(CameraParameters.AF_MODE_CONTINUOUS_VIDEO, R.drawable.gui_almalence_settings_focus_continiuousvideo);
put(CameraParameters.AF_MODE_CONTINUOUS_PICTURE, R.drawable.gui_almalence_settings_focus_continiuouspicture);
- put(FOCUS_AF_LOCK, R.drawable.gui_almalence_settings_focus_aflock);
+ put(FOCUS_AF_LOCK, R.drawable.gui_almalence_settings_focus_aflock);
}
};
- private static final Map ICONS_FLASH = new HashMap() {
+ private static final Map ICONS_FLASH = new HashMap()
+ {
{
- put(CameraParameters.FLASH_MODE_OFF, R.drawable.gui_almalence_settings_flash_off);
- put(CameraParameters.FLASH_MODE_AUTO, R.drawable.gui_almalence_settings_flash_auto);
+ put(CameraParameters.FLASH_MODE_OFF, R.drawable.gui_almalence_settings_flash_off);
+ put(CameraParameters.FLASH_MODE_AUTO, R.drawable.gui_almalence_settings_flash_auto);
put(CameraParameters.FLASH_MODE_SINGLE, R.drawable.gui_almalence_settings_flash_on);
put(CameraParameters.FLASH_MODE_REDEYE, R.drawable.gui_almalence_settings_flash_redeye);
- put(CameraParameters.FLASH_MODE_TORCH, R.drawable.gui_almalence_settings_flash_torch);
+ put(CameraParameters.FLASH_MODE_TORCH, R.drawable.gui_almalence_settings_flash_torch);
}
};
- private static final Map ICONS_ISO = new HashMap() {
+ private static final Map ICONS_ISO = new HashMap()
+ {
{
put(CameraParameters.ISO_AUTO, R.drawable.gui_almalence_settings_iso_auto);
- put(CameraParameters.ISO_50, R.drawable.gui_almalence_settings_iso_50);
- put(CameraParameters.ISO_100, R.drawable.gui_almalence_settings_iso_100);
- put(CameraParameters.ISO_200, R.drawable.gui_almalence_settings_iso_200);
- put(CameraParameters.ISO_400, R.drawable.gui_almalence_settings_iso_400);
- put(CameraParameters.ISO_800, R.drawable.gui_almalence_settings_iso_800);
+ put(CameraParameters.ISO_50, R.drawable.gui_almalence_settings_iso_50);
+ put(CameraParameters.ISO_100, R.drawable.gui_almalence_settings_iso_100);
+ put(CameraParameters.ISO_200, R.drawable.gui_almalence_settings_iso_200);
+ put(CameraParameters.ISO_400, R.drawable.gui_almalence_settings_iso_400);
+ put(CameraParameters.ISO_800, R.drawable.gui_almalence_settings_iso_800);
put(CameraParameters.ISO_1600, R.drawable.gui_almalence_settings_iso_1600);
- put(CameraParameters.ISO_3200, R.drawable.gui_almalence_settings_iso_3200);
+ put(CameraParameters.ISO_3200, R.drawable.gui_almalence_settings_iso_3200);
}
};
-
- private static final Map ICONS_DEFAULT_ISO = new HashMap() {
+
+ private static final Map ICONS_DEFAULT_ISO = new HashMap()
+ {
{
put(MainScreen.getInstance().getResources().getString(R.string.isoAutoDefaultSystem), R.drawable.gui_almalence_settings_iso_auto);
- put(MainScreen.getInstance().getResources().getString(R.string.iso50DefaultSystem), R.drawable.gui_almalence_settings_iso_50);
- put(MainScreen.getInstance().getResources().getString(R.string.iso100DefaultSystem), R.drawable.gui_almalence_settings_iso_100);
- put(MainScreen.getInstance().getResources().getString(R.string.iso200DefaultSystem), R.drawable.gui_almalence_settings_iso_200);
- put(MainScreen.getInstance().getResources().getString(R.string.iso400DefaultSystem), R.drawable.gui_almalence_settings_iso_400);
- put(MainScreen.getInstance().getResources().getString(R.string.iso800DefaultSystem), R.drawable.gui_almalence_settings_iso_800);
+ put(MainScreen.getInstance().getResources().getString(R.string.iso50DefaultSystem), R.drawable.gui_almalence_settings_iso_50);
+ put(MainScreen.getInstance().getResources().getString(R.string.iso100DefaultSystem), R.drawable.gui_almalence_settings_iso_100);
+ put(MainScreen.getInstance().getResources().getString(R.string.iso200DefaultSystem), R.drawable.gui_almalence_settings_iso_200);
+ put(MainScreen.getInstance().getResources().getString(R.string.iso400DefaultSystem), R.drawable.gui_almalence_settings_iso_400);
+ put(MainScreen.getInstance().getResources().getString(R.string.iso800DefaultSystem), R.drawable.gui_almalence_settings_iso_800);
put(MainScreen.getInstance().getResources().getString(R.string.iso1600DefaultSystem), R.drawable.gui_almalence_settings_iso_1600);
- put(MainScreen.getInstance().getResources().getString(R.string.iso3200DefaultSystem), R.drawable.gui_almalence_settings_iso_3200);
+ put(MainScreen.getInstance().getResources().getString(R.string.iso3200DefaultSystem), R.drawable.gui_almalence_settings_iso_3200);
}
};
-
- private static final Map ICONS_METERING = new HashMap() {
+
+ private static final Map ICONS_METERING = new HashMap()
+ {
{
put(0, R.drawable.gui_almalence_settings_metering_auto);
put(1, R.drawable.gui_almalence_settings_metering_matrix);
- put(2, R.drawable.gui_almalence_settings_metering_center);
+ put(2, R.drawable.gui_almalence_settings_metering_center);
put(3, R.drawable.gui_almalence_settings_metering_spot);
}
};
- // List of localized names for camera parameters values
- private static final Map NAMES_SCENE = new HashMap() {
+ // List of localized names for camera parameters values
+ private static final Map NAMES_SCENE = new HashMap()
+ {
{
- put(CameraParameters.SCENE_MODE_AUTO, MainScreen.getInstance().getResources().getString(R.string.sceneAuto));
- put(CameraParameters.SCENE_MODE_ACTION, MainScreen.getInstance().getResources().getString(R.string.sceneAction));
- put(CameraParameters.SCENE_MODE_PORTRAIT, MainScreen.getInstance().getResources().getString(R.string.scenePortrait));
- put(CameraParameters.SCENE_MODE_LANDSCAPE, MainScreen.getInstance().getResources().getString(R.string.sceneLandscape));
- put(CameraParameters.SCENE_MODE_NIGHT, MainScreen.getInstance().getResources().getString(R.string.sceneNight));
+ put(CameraParameters.SCENE_MODE_AUTO, MainScreen.getInstance().getResources().getString(R.string.sceneAuto));
+ put(CameraParameters.SCENE_MODE_ACTION, MainScreen.getInstance().getResources().getString(R.string.sceneAction));
+ put(CameraParameters.SCENE_MODE_PORTRAIT, MainScreen.getInstance().getResources().getString(R.string.scenePortrait));
+ put(CameraParameters.SCENE_MODE_LANDSCAPE, MainScreen.getInstance().getResources().getString(R.string.sceneLandscape));
+ put(CameraParameters.SCENE_MODE_NIGHT, MainScreen.getInstance().getResources().getString(R.string.sceneNight));
put(CameraParameters.SCENE_MODE_NIGHT_PORTRAIT, MainScreen.getInstance().getResources().getString(R.string.sceneNightPortrait));
- put(CameraParameters.SCENE_MODE_THEATRE, MainScreen.getInstance().getResources().getString(R.string.sceneTheatre));
- put(CameraParameters.SCENE_MODE_BEACH, MainScreen.getInstance().getResources().getString(R.string.sceneBeach));
- put(CameraParameters.SCENE_MODE_SNOW, MainScreen.getInstance().getResources().getString(R.string.sceneSnow));
- put(CameraParameters.SCENE_MODE_SUNSET, MainScreen.getInstance().getResources().getString(R.string.sceneSunset));
- put(CameraParameters.SCENE_MODE_STEADYPHOTO, MainScreen.getInstance().getResources().getString(R.string.sceneSteadyPhoto));
- put(CameraParameters.SCENE_MODE_FIREWORKS, MainScreen.getInstance().getResources().getString(R.string.sceneFireworks));
- put(CameraParameters.SCENE_MODE_SPORTS, MainScreen.getInstance().getResources().getString(R.string.sceneSports));
- put(CameraParameters.SCENE_MODE_PARTY, MainScreen.getInstance().getResources().getString(R.string.sceneParty));
- put(CameraParameters.SCENE_MODE_CANDLELIGHT, MainScreen.getInstance().getResources().getString(R.string.sceneCandlelight));
- put(CameraParameters.SCENE_MODE_BARCODE, MainScreen.getInstance().getResources().getString(R.string.sceneBarcode));
+ put(CameraParameters.SCENE_MODE_THEATRE, MainScreen.getInstance().getResources().getString(R.string.sceneTheatre));
+ put(CameraParameters.SCENE_MODE_BEACH, MainScreen.getInstance().getResources().getString(R.string.sceneBeach));
+ put(CameraParameters.SCENE_MODE_SNOW, MainScreen.getInstance().getResources().getString(R.string.sceneSnow));
+ put(CameraParameters.SCENE_MODE_SUNSET, MainScreen.getInstance().getResources().getString(R.string.sceneSunset));
+ put(CameraParameters.SCENE_MODE_STEADYPHOTO, MainScreen.getInstance().getResources().getString(R.string.sceneSteadyPhoto));
+ put(CameraParameters.SCENE_MODE_FIREWORKS, MainScreen.getInstance().getResources().getString(R.string.sceneFireworks));
+ put(CameraParameters.SCENE_MODE_SPORTS, MainScreen.getInstance().getResources().getString(R.string.sceneSports));
+ put(CameraParameters.SCENE_MODE_PARTY, MainScreen.getInstance().getResources().getString(R.string.sceneParty));
+ put(CameraParameters.SCENE_MODE_CANDLELIGHT, MainScreen.getInstance().getResources().getString(R.string.sceneCandlelight));
+ put(CameraParameters.SCENE_MODE_BARCODE, MainScreen.getInstance().getResources().getString(R.string.sceneBarcode));
}
};
- private static final Map NAMES_WB = new HashMap() {
+ private static final Map NAMES_WB = new HashMap()
+ {
{
- put(CameraParameters.WB_MODE_AUTO, MainScreen.getInstance().getResources().getString(R.string.wbAuto));
- put(CameraParameters.WB_MODE_INCANDESCENT, MainScreen.getInstance().getResources().getString(R.string.wbIncandescent));
- put(CameraParameters.WB_MODE_FLUORESCENT, MainScreen.getInstance().getResources().getString(R.string.wbFluorescent));
+ put(CameraParameters.WB_MODE_AUTO, MainScreen.getInstance().getResources().getString(R.string.wbAuto));
+ put(CameraParameters.WB_MODE_INCANDESCENT, MainScreen.getInstance().getResources().getString(R.string.wbIncandescent));
+ put(CameraParameters.WB_MODE_FLUORESCENT, MainScreen.getInstance().getResources().getString(R.string.wbFluorescent));
put(CameraParameters.WB_MODE_WARM_FLUORESCENT, MainScreen.getInstance().getResources().getString(R.string.wbWarmFluorescent));
- put(CameraParameters.WB_MODE_DAYLIGHT, MainScreen.getInstance().getResources().getString(R.string.wbDaylight));
- put(CameraParameters.WB_MODE_CLOUDY_DAYLIGHT, MainScreen.getInstance().getResources().getString(R.string.wbCloudyDaylight));
- put(CameraParameters.WB_MODE_TWILIGHT, MainScreen.getInstance().getResources().getString(R.string.wbTwilight));
- put(CameraParameters.WB_MODE_SHADE, MainScreen.getInstance().getResources().getString(R.string.wbShade));
+ put(CameraParameters.WB_MODE_DAYLIGHT, MainScreen.getInstance().getResources().getString(R.string.wbDaylight));
+ put(CameraParameters.WB_MODE_CLOUDY_DAYLIGHT, MainScreen.getInstance().getResources().getString(R.string.wbCloudyDaylight));
+ put(CameraParameters.WB_MODE_TWILIGHT, MainScreen.getInstance().getResources().getString(R.string.wbTwilight));
+ put(CameraParameters.WB_MODE_SHADE, MainScreen.getInstance().getResources().getString(R.string.wbShade));
}
};
-
- private static final Map NAMES_FOCUS = new HashMap() {
+ private static final Map NAMES_FOCUS = new HashMap()
+ {
{
- put(CameraParameters.AF_MODE_AUTO, MainScreen.getInstance().getResources().getString(R.string.focusAuto));
- put(CameraParameters.AF_MODE_INFINITY, MainScreen.getInstance().getResources().getString(R.string.focusInfinity));
- put(CameraParameters.AF_MODE_NORMAL, MainScreen.getInstance().getResources().getString(R.string.focusNormal));
- put(CameraParameters.AF_MODE_MACRO, MainScreen.getInstance().getResources().getString(R.string.focusMacro));
- put(CameraParameters.AF_MODE_FIXED, MainScreen.getInstance().getResources().getString(R.string.focusFixed));
- put(CameraParameters.AF_MODE_EDOF, MainScreen.getInstance().getResources().getString(R.string.focusEdof));
- put(CameraParameters.AF_MODE_CONTINUOUS_VIDEO, MainScreen.getInstance().getResources().getString(R.string.focusContinuousVideo));
+ put(CameraParameters.AF_MODE_AUTO, MainScreen.getInstance().getResources().getString(R.string.focusAuto));
+ put(CameraParameters.AF_MODE_INFINITY, MainScreen.getInstance().getResources().getString(R.string.focusInfinity));
+ put(CameraParameters.AF_MODE_NORMAL, MainScreen.getInstance().getResources().getString(R.string.focusNormal));
+ put(CameraParameters.AF_MODE_MACRO, MainScreen.getInstance().getResources().getString(R.string.focusMacro));
+ put(CameraParameters.AF_MODE_FIXED, MainScreen.getInstance().getResources().getString(R.string.focusFixed));
+ put(CameraParameters.AF_MODE_EDOF, MainScreen.getInstance().getResources().getString(R.string.focusEdof));
+ put(CameraParameters.AF_MODE_CONTINUOUS_VIDEO, MainScreen.getInstance().getResources().getString(R.string.focusContinuousVideo));
put(CameraParameters.AF_MODE_CONTINUOUS_PICTURE, MainScreen.getInstance().getResources().getString(R.string.focusContinuousPicture));
}
};
- private static final Map NAMES_FLASH = new HashMap() {
+ private static final Map NAMES_FLASH = new HashMap()
+ {
{
- put(CameraParameters.FLASH_MODE_OFF, MainScreen.getInstance().getResources().getString(R.string.flashOff));
- put(CameraParameters.FLASH_MODE_AUTO, MainScreen.getInstance().getResources().getString(R.string.flashAuto));
- put(CameraParameters.FLASH_MODE_SINGLE, MainScreen.getInstance().getResources().getString(R.string.flashOn));
- put(CameraParameters.FLASH_MODE_REDEYE, MainScreen.getInstance().getResources().getString(R.string.flashRedEye));
- put(CameraParameters.FLASH_MODE_TORCH, MainScreen.getInstance().getResources().getString(R.string.flashTorch));
+ put(CameraParameters.FLASH_MODE_OFF, MainScreen.getInstance().getResources().getString(R.string.flashOff));
+ put(CameraParameters.FLASH_MODE_AUTO, MainScreen.getInstance().getResources().getString(R.string.flashAuto));
+ put(CameraParameters.FLASH_MODE_SINGLE, MainScreen.getInstance().getResources().getString(R.string.flashOn));
+ put(CameraParameters.FLASH_MODE_REDEYE, MainScreen.getInstance().getResources().getString(R.string.flashRedEye));
+ put(CameraParameters.FLASH_MODE_TORCH, MainScreen.getInstance().getResources().getString(R.string.flashTorch));
}
};
- private static final Map NAMES_ISO = new HashMap() {
+ private static final Map NAMES_ISO = new HashMap()
+ {
{
put(CameraParameters.ISO_AUTO, MainScreen.getInstance().getResources().getString(R.string.isoAuto));
- put(CameraParameters.ISO_50, MainScreen.getInstance().getResources().getString(R.string.iso50));
- put(CameraParameters.ISO_100, MainScreen.getInstance().getResources().getString(R.string.iso100));
- put(CameraParameters.ISO_200, MainScreen.getInstance().getResources().getString(R.string.iso200));
- put(CameraParameters.ISO_400, MainScreen.getInstance().getResources().getString(R.string.iso400));
- put(CameraParameters.ISO_800, MainScreen.getInstance().getResources().getString(R.string.iso800));
+ put(CameraParameters.ISO_50, MainScreen.getInstance().getResources().getString(R.string.iso50));
+ put(CameraParameters.ISO_100, MainScreen.getInstance().getResources().getString(R.string.iso100));
+ put(CameraParameters.ISO_200, MainScreen.getInstance().getResources().getString(R.string.iso200));
+ put(CameraParameters.ISO_400, MainScreen.getInstance().getResources().getString(R.string.iso400));
+ put(CameraParameters.ISO_800, MainScreen.getInstance().getResources().getString(R.string.iso800));
put(CameraParameters.ISO_1600, MainScreen.getInstance().getResources().getString(R.string.iso1600));
put(CameraParameters.ISO_3200, MainScreen.getInstance().getResources().getString(R.string.iso3200));
}
};
-
- private static final Map NAMES_METERING = new HashMap() {
+
+ private static final Map NAMES_METERING = new HashMap()
+ {
{
put(0, MainScreen.getInstance().getResources().getString(R.string.meteringAutoSystem));
put(1, MainScreen.getInstance().getResources().getString(R.string.meteringMatrixSystem));
@@ -367,9 +378,9 @@ public enum SettingsType {
put(3, MainScreen.getInstance().getResources().getString(R.string.meteringSpotSystem));
}
};
-
-
- private static final Map UNLOCK_MODE_PREFERENCES = new HashMap() {
+
+ private static final Map UNLOCK_MODE_PREFERENCES = new HashMap()
+ {
{
put("hdrmode", "plugin_almalence_hdr");
put("movingobjects", "plugin_almalence_moving_burst");
@@ -378,136 +389,138 @@ public enum SettingsType {
put("panorama_augmented", "plugin_almalence_panorama");
}
};
-
+
// Defining for top menu buttons (camera parameters settings)
- private static final int MODE_EV = R.id.evButton;
- private static final int MODE_SCENE = R.id.sceneButton;
- private static final int MODE_WB = R.id.wbButton;
- private static final int MODE_FOCUS = R.id.focusButton;
- private static final int MODE_FLASH = R.id.flashButton;
- private static final int MODE_ISO = R.id.isoButton;
- private static final int MODE_CAM = R.id.camerachangeButton;
- private static final int MODE_MET = R.id.meteringButton;
+ private static final int MODE_EV = R.id.evButton;
+ private static final int MODE_SCENE = R.id.sceneButton;
+ private static final int MODE_WB = R.id.wbButton;
+ private static final int MODE_FOCUS = R.id.focusButton;
+ private static final int MODE_FLASH = R.id.flashButton;
+ private static final int MODE_ISO = R.id.isoButton;
+ private static final int MODE_CAM = R.id.camerachangeButton;
+ private static final int MODE_MET = R.id.meteringButton;
private Map topMenuButtons;
- private Map topMenuPluginButtons; // Each plugin may have one
- // top menu (and appropriate
- // quick control) button
+
+ // Each plugin may have one top menu (and appropriate quick control) button
+ private Map topMenuPluginButtons;
+
// Current quick controls
- private View quickControl1 = null;
- private View quickControl2 = null;
- private View quickControl3 = null;
- private View quickControl4 = null;
-
- private ElementAdapter scenemodeAdapter;
- private ElementAdapter wbmodeAdapter;
- private ElementAdapter focusmodeAdapter;
- private ElementAdapter flashmodeAdapter;
- private ElementAdapter isoAdapter;
- private ElementAdapter meteringmodeAdapter;
-
- private Map sceneModeButtons;
- private Map wbModeButtons;
- private Map focusModeButtons;
- private Map flashModeButtons;
- private Map isoButtons;
- private Map meteringModeButtons;
+ private View quickControl1 = null;
+ private View quickControl2 = null;
+ private View quickControl3 = null;
+ private View quickControl4 = null;
+
+ private ElementAdapter scenemodeAdapter;
+ private ElementAdapter wbmodeAdapter;
+ private ElementAdapter focusmodeAdapter;
+ private ElementAdapter flashmodeAdapter;
+ private ElementAdapter isoAdapter;
+ private ElementAdapter meteringmodeAdapter;
+
+ private Map sceneModeButtons;
+ private Map wbModeButtons;
+ private Map focusModeButtons;
+ private Map flashModeButtons;
+ private Map isoButtons;
+ private Map meteringModeButtons;
// Camera settings values which is exist at current device
- private List activeScene;
- private List activeWB;
- private List activeFocus;
- private List activeFlash;
- private List activeISO;
- private List activeMetering;
-
- private List activeSceneNames;
- private List activeWBNames;
- private List activeFocusNames;
- private List activeFlashNames;
- private List activeISONames;
- private List activeMeteringNames;
-
- private boolean isEVEnabled = true;
- private boolean isSceneEnabled = true;
- private boolean isWBEnabled = true;
- private boolean isFocusEnabled = true;
- private boolean isFlashEnabled = true;
- private boolean isIsoEnabled = true;
- private boolean isCameraChangeEnabled = true;
- private boolean isMeteringEnabled = true;
+ private List activeScene;
+ private List activeWB;
+ private List activeFocus;
+ private List activeFlash;
+ private List activeISO;
+ private List activeMetering;
+
+ private List activeSceneNames;
+ private List activeWBNames;
+ private List activeFocusNames;
+ private List activeFlashNames;
+ private List activeISONames;
+ private List activeMeteringNames;
+
+ private boolean isEVEnabled = true;
+ private boolean isSceneEnabled = true;
+ private boolean isWBEnabled = true;
+ private boolean isFocusEnabled = true;
+ private boolean isFlashEnabled = true;
+ private boolean isIsoEnabled = true;
+ private boolean isCameraChangeEnabled = true;
+ private boolean isMeteringEnabled = true;
// GUI Layout
- private View guiView;
+ private View guiView;
// Current camera parameters
- private int mEV = 0;
- private int mSceneMode = -1;
- private int mFlashMode = -1;
- private int mFocusMode = -1;
- private int mWB = -1;
- private int mISO = -1;
- private int mMeteringMode = -1;
+ private int mEV = 0;
+ private int mSceneMode = -1;
+ private int mFlashMode = -1;
+ private int mFocusMode = -1;
+ private int mWB = -1;
+ private int mISO = -1;
+ private int mMeteringMode = -1;
- private float fScreenDensity;
+ private float fScreenDensity;
- private int iInfoViewMaxHeight;
- private int iInfoViewMaxWidth;
- private int iInfoViewHeight;
+ private int iInfoViewMaxHeight;
+ private int iInfoViewMaxWidth;
+ private int iInfoViewHeight;
- private int iCenterViewMaxHeight;
- private int iCenterViewMaxWidth;
+ private int iCenterViewMaxHeight;
+ private int iCenterViewMaxWidth;
// indicates if it's first launch - to show hint layer.
- private boolean isFirstLaunch = true;
-
- private static int iScreenType = MainScreen.getInstance().getResources().getInteger(R.integer.screen_type);
+ private boolean isFirstLaunch = true;
- public AlmalenceGUI() {
-
- mThumbnail = null;
- topMenuButtons = new HashMap();
- topMenuPluginButtons = new HashMap();
-
- scenemodeAdapter = new ElementAdapter();
- wbmodeAdapter = new ElementAdapter();
- focusmodeAdapter = new ElementAdapter();
- flashmodeAdapter = new ElementAdapter();
- isoAdapter = new ElementAdapter();
- meteringmodeAdapter = new ElementAdapter();
-
- sceneModeButtons = new HashMap();
- wbModeButtons = new HashMap();
- focusModeButtons = new HashMap();
- flashModeButtons = new HashMap();
- isoButtons = new HashMap();
- meteringModeButtons = new HashMap();
-
- activeScene = new ArrayList();
- activeWB = new ArrayList();
- activeFocus = new ArrayList();
- activeFlash = new ArrayList();
- activeISO = new ArrayList();
- activeMetering = new ArrayList();
-
- activeSceneNames = new ArrayList();
- activeWBNames = new ArrayList();
- activeFocusNames = new ArrayList();
- activeFlashNames = new ArrayList();
- activeISONames = new ArrayList();
- activeMeteringNames = new ArrayList();
-
- settingsAdapter = new ElementAdapter();
- settingsViews = new ArrayList();
-
- quickControlAdapter = new ElementAdapter();
+ private static int iScreenType = MainScreen.getInstance().getResources().getInteger(R.integer.screen_type);
+
+ public AlmalenceGUI()
+ {
+
+ mThumbnail = null;
+ topMenuButtons = new HashMap();
+ topMenuPluginButtons = new HashMap();
+
+ scenemodeAdapter = new ElementAdapter();
+ wbmodeAdapter = new ElementAdapter();
+ focusmodeAdapter = new ElementAdapter();
+ flashmodeAdapter = new ElementAdapter();
+ isoAdapter = new ElementAdapter();
+ meteringmodeAdapter = new ElementAdapter();
+
+ sceneModeButtons = new HashMap();
+ wbModeButtons = new HashMap();
+ focusModeButtons = new HashMap();
+ flashModeButtons = new HashMap();
+ isoButtons = new HashMap();
+ meteringModeButtons = new HashMap();
+
+ activeScene = new ArrayList();
+ activeWB = new ArrayList();
+ activeFocus = new ArrayList();
+ activeFlash = new ArrayList();
+ activeISO = new ArrayList();
+ activeMetering = new ArrayList();
+
+ activeSceneNames = new ArrayList();
+ activeWBNames = new ArrayList();
+ activeFocusNames = new ArrayList();
+ activeFlashNames = new ArrayList();
+ activeISONames = new ArrayList();
+ activeMeteringNames = new ArrayList();
+
+ settingsAdapter = new ElementAdapter();
+ settingsViews = new ArrayList();
+
+ quickControlAdapter = new ElementAdapter();
quickControlChangeres = new ArrayList();
- modeAdapter = new ElementAdapter();
- modeViews = new ArrayList();
- buttonModeViewAssoc = new HashMap();
-
+ modeAdapter = new ElementAdapter();
+ modeViews = new ArrayList();
+ buttonModeViewAssoc = new HashMap();
+
}
/*
@@ -517,7 +530,7 @@ public AlmalenceGUI() {
*/
public int getSceneIcon(int sceneMode)
{
- if(ICONS_SCENE.containsKey(sceneMode))
+ if (ICONS_SCENE.containsKey(sceneMode))
return ICONS_SCENE.get(sceneMode);
else
return -1;
@@ -525,7 +538,7 @@ public int getSceneIcon(int sceneMode)
public int getWBIcon(int wb)
{
- if(ICONS_WB.containsKey(wb))
+ if (ICONS_WB.containsKey(wb))
return ICONS_WB.get(wb);
else
return -1;
@@ -533,23 +546,24 @@ public int getWBIcon(int wb)
public int getFocusIcon(int focusMode)
{
- if(ICONS_FOCUS.containsKey(focusMode))
+ if (ICONS_FOCUS.containsKey(focusMode))
{
- try {
+ try
+ {
return ICONS_FOCUS.get(focusMode);
- } catch (Exception e) {
+ } catch (Exception e)
+ {
e.printStackTrace();
Log.e("getFocusIcon", "icons_focus.get exception: " + e.getMessage());
return -1;
}
- }
- else
+ } else
return -1;
}
public int getFlashIcon(int flashMode)
{
- if(ICONS_FLASH.containsKey(flashMode))
+ if (ICONS_FLASH.containsKey(flashMode))
return ICONS_FLASH.get(flashMode);
else
return -1;
@@ -557,87 +571,89 @@ public int getFlashIcon(int flashMode)
public int getISOIcon(int isoMode)
{
- if(ICONS_ISO.containsKey(isoMode))
+ if (ICONS_ISO.containsKey(isoMode))
return ICONS_ISO.get(isoMode);
- else if(ICONS_DEFAULT_ISO.containsKey(isoMode))
+ else if (ICONS_DEFAULT_ISO.containsKey(isoMode))
return ICONS_DEFAULT_ISO.get(isoMode);
else
return -1;
}
-
+
public int getMeteringIcon(String meteringMode)
{
- if(ICONS_METERING.containsKey(meteringMode))
+ if (ICONS_METERING.containsKey(meteringMode))
return ICONS_METERING.get(meteringMode);
else
return -1;
}
@Override
- public float getScreenDensity() {
+ public float getScreenDensity()
+ {
return fScreenDensity;
}
@Override
- public void onStart() {
+ public void onStart()
+ {
// Calculate right sizes for plugin's controls
DisplayMetrics metrics = new DisplayMetrics();
- MainScreen.getInstance().getWindowManager().getDefaultDisplay()
- .getMetrics(metrics);
+ MainScreen.getInstance().getWindowManager().getDefaultDisplay().getMetrics(metrics);
fScreenDensity = metrics.density;
- iInfoViewMaxHeight = (int) (MainScreen.getMainContext().getResources()
- .getInteger(R.integer.infoControlHeight) * fScreenDensity);
- iInfoViewMaxWidth = (int) (MainScreen.getMainContext().getResources()
- .getInteger(R.integer.infoControlWidth) * fScreenDensity);
+ iInfoViewMaxHeight = (int) (MainScreen.getMainContext().getResources().getInteger(R.integer.infoControlHeight) * fScreenDensity);
+ iInfoViewMaxWidth = (int) (MainScreen.getMainContext().getResources().getInteger(R.integer.infoControlWidth) * fScreenDensity);
- iCenterViewMaxHeight = (int) (MainScreen.getMainContext().getResources()
- .getInteger(R.integer.centerViewHeight) * fScreenDensity);
- iCenterViewMaxWidth = (int) (MainScreen.getMainContext().getResources()
- .getInteger(R.integer.centerViewWidth) * fScreenDensity);
+ iCenterViewMaxHeight = (int) (MainScreen.getMainContext().getResources().getInteger(R.integer.centerViewHeight) * fScreenDensity);
+ iCenterViewMaxWidth = (int) (MainScreen.getMainContext().getResources().getInteger(R.integer.centerViewWidth) * fScreenDensity);
- //Create orientation listener
+ // Create orientation listener
initOrientationListener();
- //Create select mode button with appropriate icon
- createMergedSelectModeButton();
-
+ // Create select mode button with appropriate icon
+ createMergedSelectModeButton();
+
//
+ // -+- -->
+
+ //added immersive full-screen mode support
+ //guiView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY|View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
-
+
private void initOrientationListener()
{
// set orientation listener to rotate controls
- this.orientListener = new OrientationEventListener(
- MainScreen.getMainContext()) {
+ this.orientListener = new OrientationEventListener(MainScreen.getMainContext())
+ {
@Override
- public void onOrientationChanged(int orientation) {
+ public void onOrientationChanged(int orientation)
+ {
if (orientation == ORIENTATION_UNKNOWN)
return;
- final Display display = ((WindowManager) MainScreen.getInstance()
- .getSystemService(Context.WINDOW_SERVICE))
- .getDefaultDisplay();
- final int orientationProc = (display.getWidth() <= display
- .getHeight()) ? Configuration.ORIENTATION_PORTRAIT
+ final Display display = ((WindowManager) MainScreen.getInstance().getSystemService(
+ Context.WINDOW_SERVICE)).getDefaultDisplay();
+ final int orientationProc = (display.getWidth() <= display.getHeight()) ? Configuration.ORIENTATION_PORTRAIT
: Configuration.ORIENTATION_LANDSCAPE;
final int rotation = display.getRotation();
@@ -646,32 +662,23 @@ public void onOrientationChanged(int orientation) {
if (remapOrientation)
orientation = (orientation - 90 + 360) % 360;
- AlmalenceGUI.mDeviceOrientation = Util.roundOrientation(
- orientation, AlmalenceGUI.mDeviceOrientation);
+ AlmalenceGUI.mDeviceOrientation = Util.roundOrientation(orientation, AlmalenceGUI.mDeviceOrientation);
- ((RotateImageView) topMenuButtons.get(MODE_EV))
- .setOrientation(AlmalenceGUI.mDeviceOrientation);
- ((RotateImageView) topMenuButtons.get(MODE_SCENE))
- .setOrientation(AlmalenceGUI.mDeviceOrientation);
- ((RotateImageView) topMenuButtons.get(MODE_WB))
- .setOrientation(AlmalenceGUI.mDeviceOrientation);
- ((RotateImageView) topMenuButtons.get(MODE_FOCUS))
- .setOrientation(AlmalenceGUI.mDeviceOrientation);
- ((RotateImageView) topMenuButtons.get(MODE_FLASH))
- .setOrientation(AlmalenceGUI.mDeviceOrientation);
- ((RotateImageView) topMenuButtons.get(MODE_ISO))
- .setOrientation(AlmalenceGUI.mDeviceOrientation);
- ((RotateImageView) topMenuButtons.get(MODE_CAM))
- .setOrientation(AlmalenceGUI.mDeviceOrientation);
- ((RotateImageView) topMenuButtons.get(MODE_MET))
- .setOrientation(AlmalenceGUI.mDeviceOrientation);
+ ((RotateImageView) topMenuButtons.get(MODE_EV)).setOrientation(AlmalenceGUI.mDeviceOrientation);
+ ((RotateImageView) topMenuButtons.get(MODE_SCENE)).setOrientation(AlmalenceGUI.mDeviceOrientation);
+ ((RotateImageView) topMenuButtons.get(MODE_WB)).setOrientation(AlmalenceGUI.mDeviceOrientation);
+ ((RotateImageView) topMenuButtons.get(MODE_FOCUS)).setOrientation(AlmalenceGUI.mDeviceOrientation);
+ ((RotateImageView) topMenuButtons.get(MODE_FLASH)).setOrientation(AlmalenceGUI.mDeviceOrientation);
+ ((RotateImageView) topMenuButtons.get(MODE_ISO)).setOrientation(AlmalenceGUI.mDeviceOrientation);
+ ((RotateImageView) topMenuButtons.get(MODE_CAM)).setOrientation(AlmalenceGUI.mDeviceOrientation);
+ ((RotateImageView) topMenuButtons.get(MODE_MET)).setOrientation(AlmalenceGUI.mDeviceOrientation);
Set keys = topMenuPluginButtons.keySet();
Iterator it = keys.iterator();
- while (it.hasNext()) {
+ while (it.hasNext())
+ {
String key = it.next();
- ((RotateImageView) topMenuPluginButtons.get(key))
- .setOrientation(AlmalenceGUI.mDeviceOrientation);
+ ((RotateImageView) topMenuPluginButtons.get(key)).setOrientation(AlmalenceGUI.mDeviceOrientation);
}
((RotateImageView) guiView.findViewById(R.id.buttonGallery))
@@ -686,72 +693,68 @@ public void onOrientationChanged(int orientation) {
if (AlmalenceGUI.mPreviousDeviceOrientation != AlmalenceGUI.mDeviceOrientation)
rotateSquareViews(degree, 250);
- ((TextView) guiView.findViewById(R.id.blockingText))
- .setRotation(-AlmalenceGUI.mDeviceOrientation);
-
+ ((TextView) guiView.findViewById(R.id.blockingText)).setRotation(-AlmalenceGUI.mDeviceOrientation);
+
store.setOrientation();
-
+
AlmalenceGUI.mPreviousDeviceOrientation = AlmalenceGUI.mDeviceOrientation;
-
+
PluginManager.getInstance().onOrientationChanged(getDisplayOrientation());
-
- selfTimer.setOrientation();
+
+ if (selfTimer!=null)
+ selfTimer.setOrientation();
}
- };
+ };
}
-
+
private void createMergedSelectModeButton()
{
// create merged image for select mode button
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
String defaultModeName = prefs.getString(MainScreen.sDefaultModeName, "");
Mode mode = ConfigParser.getInstance().getMode(defaultModeName);
try
{
Bitmap bm = null;
- Bitmap iconBase = BitmapFactory.decodeResource(
- MainScreen.getMainContext().getResources(),
+ Bitmap iconBase = BitmapFactory.decodeResource(MainScreen.getMainContext().getResources(),
R.drawable.gui_almalence_select_mode);
Bitmap iconOverlay = BitmapFactory.decodeResource(
MainScreen.getMainContext().getResources(),
- MainScreen.getInstance().getResources().getIdentifier(mode.icon,
- "drawable", MainScreen.getInstance().getPackageName()));
- iconOverlay = Bitmap.createScaledBitmap(iconOverlay,
- (int) (iconBase.getWidth() / 1.8),
+ MainScreen.getInstance().getResources()
+ .getIdentifier(mode.icon, "drawable", MainScreen.getInstance().getPackageName()));
+ iconOverlay = Bitmap.createScaledBitmap(iconOverlay, (int) (iconBase.getWidth() / 1.8),
(int) (iconBase.getWidth() / 1.8), false);
-
+
bm = mergeImage(iconBase, iconOverlay);
- bm = Bitmap.createScaledBitmap(bm, (int) (MainScreen.getMainContext()
- .getResources().getDimension(R.dimen.paramsLayoutHeight)),
- (int) (MainScreen.getMainContext().getResources()
- .getDimension(R.dimen.paramsLayoutHeight)), false);
- ((RotateImageView) guiView.findViewById(R.id.buttonSelectMode))
- .setImageBitmap(bm);
- }
- catch(Exception e)
+ bm = Bitmap.createScaledBitmap(bm,
+ (int) (MainScreen.getMainContext().getResources().getDimension(R.dimen.paramsLayoutHeight)),
+ (int) (MainScreen.getMainContext().getResources().getDimension(R.dimen.paramsLayoutHeight)), false);
+ ((RotateImageView) guiView.findViewById(R.id.buttonSelectMode)).setImageBitmap(bm);
+ } catch (Exception e)
{
e.printStackTrace();
}
}
@Override
- public void onStop() {
+ public void onStop()
+ {
removePluginViews();
mDeviceOrientation = 0;
mPreviousDeviceOrientation = 0;
}
@Override
- public void onPause() {
+ public void onPause()
+ {
if (quickControlsChangeVisible)
closeQuickControlsSettings();
orientListener.disable();
if (modeSelectorVisible)
hideModeList();
if (settingsControlsVisible)
- ((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false,true);
- if (((RelativeLayout) guiView.findViewById(R.id.viewPagerLayout)).getVisibility() == View.VISIBLE)
+ ((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false, true);
+ if (((RelativeLayout) guiView.findViewById(R.id.viewPagerLayoutMain)).getVisibility() == View.VISIBLE)
hideStore();
}
@@ -760,18 +763,21 @@ public void showStore()
{
store.showStore();
}
-
+
@Override
public void hideStore()
{
store.hideStore();
- }
-
+ }
+
@Override
- public void onResume() {
- MainScreen.getInstance().runOnUiThread(new Runnable() {
+ public void onResume()
+ {
+ MainScreen.getInstance().runOnUiThread(new Runnable()
+ {
@Override
- public void run() {
+ public void run()
+ {
AlmalenceGUI.this.updateThumbnailButton();
}
});
@@ -791,11 +797,12 @@ public void run() {
disableCameraParameter(CameraParameter.CAMERA_PARAMETER_CAMERACHANGE, false, true);
// if first launch - show layout with hints
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
- if (prefs.contains("isFirstLaunch")) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
+ if (prefs.contains("isFirstLaunch"))
+ {
isFirstLaunch = prefs.getBoolean("isFirstLaunch", true);
- } else {
+ } else
+ {
Editor prefsEditor = prefs.edit();
prefsEditor.putBoolean("isFirstLaunch", false);
prefsEditor.commit();
@@ -807,47 +814,39 @@ public void run() {
guiView.findViewById(R.id.hintLayout).setVisibility(View.GONE);
else
guiView.findViewById(R.id.hintLayout).setVisibility(View.VISIBLE);
-
+
manageUnlockControl();
}
-
-
+
@Override
public void onDestroy()
{
- //Not used
+ // Not used
}
@Override
- public void createInitialGUI() {
- guiView = LayoutInflater.from(MainScreen.getMainContext()).inflate(
- R.layout.gui_almalence_layout, null);
+ public void createInitialGUI()
+ {
+ guiView = LayoutInflater.from(MainScreen.getMainContext()).inflate(R.layout.gui_almalence_layout, null);
// Add GUI Layout to main layout of OpenCamera
- ((RelativeLayout) MainScreen.getInstance().findViewById(R.id.mainLayout1))
- .addView(guiView);
+ ((RelativeLayout) MainScreen.getInstance().findViewById(R.id.mainLayout1)).addView(guiView);
}
// Create standard OpenCamera's buttons and theirs OnClickListener
@Override
- public void onCreate() {
+ public void onCreate()
+ {
// Get application preferences object
- preferences = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
+ preferences = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
guiView.findViewById(R.id.evButton).setOnTouchListener(MainScreen.getInstance());
- guiView.findViewById(R.id.sceneButton).setOnTouchListener(
- MainScreen.getInstance());
+ guiView.findViewById(R.id.sceneButton).setOnTouchListener(MainScreen.getInstance());
guiView.findViewById(R.id.wbButton).setOnTouchListener(MainScreen.getInstance());
- guiView.findViewById(R.id.focusButton).setOnTouchListener(
- MainScreen.getInstance());
- guiView.findViewById(R.id.flashButton).setOnTouchListener(
- MainScreen.getInstance());
- guiView.findViewById(R.id.isoButton)
- .setOnTouchListener(MainScreen.getInstance());
- guiView.findViewById(R.id.meteringButton)
- .setOnTouchListener(MainScreen.getInstance());
- guiView.findViewById(R.id.camerachangeButton).setOnTouchListener(
- MainScreen.getInstance());
+ guiView.findViewById(R.id.focusButton).setOnTouchListener(MainScreen.getInstance());
+ guiView.findViewById(R.id.flashButton).setOnTouchListener(MainScreen.getInstance());
+ guiView.findViewById(R.id.isoButton).setOnTouchListener(MainScreen.getInstance());
+ guiView.findViewById(R.id.meteringButton).setOnTouchListener(MainScreen.getInstance());
+ guiView.findViewById(R.id.camerachangeButton).setOnTouchListener(MainScreen.getInstance());
// Long clicks are needed to open quick controls customization layout
guiView.findViewById(R.id.evButton).setOnLongClickListener(this);
@@ -857,8 +856,7 @@ public void onCreate() {
guiView.findViewById(R.id.flashButton).setOnLongClickListener(this);
guiView.findViewById(R.id.isoButton).setOnLongClickListener(this);
guiView.findViewById(R.id.meteringButton).setOnLongClickListener(this);
- guiView.findViewById(R.id.camerachangeButton).setOnLongClickListener(
- this);
+ guiView.findViewById(R.id.camerachangeButton).setOnLongClickListener(this);
// Get all top menu buttons
topMenuButtons.put(MODE_EV, guiView.findViewById(R.id.evButton));
@@ -870,102 +868,94 @@ public void onCreate() {
topMenuButtons.put(MODE_MET, guiView.findViewById(R.id.meteringButton));
topMenuButtons.put(MODE_CAM, guiView.findViewById(R.id.camerachangeButton));
- sceneModeButtons = initCameraParameterModeButtons(ICONS_SCENE,
- NAMES_SCENE, sceneModeButtons, MODE_SCENE);
- wbModeButtons = initCameraParameterModeButtons(ICONS_WB, NAMES_WB,
- wbModeButtons, MODE_WB);
- focusModeButtons = initCameraParameterModeButtons(ICONS_FOCUS,
- NAMES_FOCUS, focusModeButtons, MODE_FOCUS);
- flashModeButtons = initCameraParameterModeButtons(ICONS_FLASH,
- NAMES_FLASH, flashModeButtons, MODE_FLASH);
- isoButtons = initCameraParameterModeButtons(ICONS_ISO, NAMES_ISO,
- isoButtons, MODE_ISO);
- meteringModeButtons = initCameraParameterModeButtons(ICONS_METERING, NAMES_METERING,
- meteringModeButtons, MODE_MET);
+ sceneModeButtons = initCameraParameterModeButtons(ICONS_SCENE, NAMES_SCENE, sceneModeButtons, MODE_SCENE);
+ wbModeButtons = initCameraParameterModeButtons(ICONS_WB, NAMES_WB, wbModeButtons, MODE_WB);
+ focusModeButtons = initCameraParameterModeButtons(ICONS_FOCUS, NAMES_FOCUS, focusModeButtons, MODE_FOCUS);
+ flashModeButtons = initCameraParameterModeButtons(ICONS_FLASH, NAMES_FLASH, flashModeButtons, MODE_FLASH);
+ isoButtons = initCameraParameterModeButtons(ICONS_ISO, NAMES_ISO, isoButtons, MODE_ISO);
+ meteringModeButtons = initCameraParameterModeButtons(ICONS_METERING, NAMES_METERING, meteringModeButtons,
+ MODE_MET);
// Create top menu buttons for plugins (each plugin may have only one
// top menu button)
createPluginTopMenuButtons();
- thumbnailView = (RotateImageView) guiView
- .findViewById(R.id.buttonGallery);
+ thumbnailView = (RotateImageView) guiView.findViewById(R.id.buttonGallery);
+
+ ((RelativeLayout) MainScreen.getInstance().findViewById(R.id.mainLayout1)).setOnTouchListener(MainScreen
+ .getInstance());
+ ((LinearLayout) MainScreen.getInstance().findViewById(R.id.evLayout)).setOnTouchListener(MainScreen
+ .getInstance());
- ((RelativeLayout) MainScreen.getInstance().findViewById(R.id.mainLayout1))
- .setOnTouchListener(MainScreen.getInstance());
- ((LinearLayout) MainScreen.getInstance().findViewById(R.id.evLayout))
- .setOnTouchListener(MainScreen.getInstance());
-
shutterButton = ((RotateImageView) guiView.findViewById(R.id.buttonShutter));
shutterButton.setOnLongClickListener(this);
-
+
store = new AlmalenceStore(guiView);
-
+
manageUnlockControl();
}
-
private void manageUnlockControl()
{
- //manage unlock control
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
+ // manage unlock control
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
if (prefs.getBoolean("unlock_all_forever", false))
store.HideUnlockControl();
- else
+ else
{
String modeID = PluginManager.getInstance().getActiveMode().modeID;
visibilityUnlockControl(UNLOCK_MODE_PREFERENCES.get(modeID));
}
}
-
+
private void visibilityUnlockControl(String prefName)
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
-
+
if (prefs.getBoolean(prefName, false))
store.HideUnlockControl();
else
store.ShowUnlockControl();
}
-
- private Map initCameraParameterModeButtons(
- Map icons_map, Map names_map,
- Map paramMap, final int mode) {
+
+ private Map initCameraParameterModeButtons(Map icons_map,
+ Map names_map, Map paramMap, final int mode)
+ {
paramMap.clear();
- Set keys = icons_map.keySet();
+ Set keys = icons_map.keySet();
Iterator it = keys.iterator();
- while (it.hasNext()) {
+ while (it.hasNext())
+ {
final int system_name = it.next();
final String value_name = names_map.get(system_name);
LayoutInflater inflator = MainScreen.getInstance().getLayoutInflater();
- View paramMode = inflator.inflate(
- R.layout.gui_almalence_quick_control_grid_element, null,
- false);
+ View paramMode = inflator.inflate(R.layout.gui_almalence_quick_control_grid_element, null, false);
// set some mode icon
- ((ImageView) paramMode.findViewById(R.id.imageView))
- .setImageResource(icons_map.get(system_name));
- ((TextView) paramMode.findViewById(R.id.textView))
- .setText(value_name);
-
+ ((ImageView) paramMode.findViewById(R.id.imageView)).setImageResource(icons_map.get(system_name));
+ ((TextView) paramMode.findViewById(R.id.textView)).setText(value_name);
+
if (system_name == CameraParameters.AF_MODE_AUTO)
- paramMode.setOnTouchListener(new OnTouchListener(){
+ paramMode.setOnTouchListener(new OnTouchListener()
+ {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- if(event.getAction() == MotionEvent.ACTION_CANCEL)
+ @Override
+ public boolean onTouch(View v, MotionEvent event)
{
- settingsModeClicked(mode, system_name);
+ if (event.getAction() == MotionEvent.ACTION_CANCEL)
+ {
+ settingsModeClicked(mode, system_name);
+ return false;
+ }
return false;
}
- return false;
- }
- });
+ });
- paramMode.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
+ paramMode.setOnClickListener(new OnClickListener()
+ {
+ public void onClick(View v)
+ {
settingsModeClicked(mode, system_name);
- guiView.findViewById(R.id.topPanel).setVisibility(
- View.VISIBLE);
+ guiView.findViewById(R.id.topPanel).setVisibility(View.VISIBLE);
quickControlsVisible = false;
}
});
@@ -978,7 +968,8 @@ public void onClick(View v) {
private void settingsModeClicked(int mode, int system_name)
{
- switch (mode) {
+ switch (mode)
+ {
case MODE_SCENE:
setSceneMode(system_name);
break;
@@ -1001,28 +992,26 @@ private void settingsModeClicked(int mode, int system_name)
break;
}
}
-
+
@Override
- public void onGUICreate() {
+ public void onGUICreate()
+ {
if (MainScreen.getInstance().findViewById(R.id.infoLayout).getVisibility() == View.VISIBLE)
- iInfoViewHeight = MainScreen.getInstance().findViewById(R.id.infoLayout)
- .getHeight();
+ iInfoViewHeight = MainScreen.getInstance().findViewById(R.id.infoLayout).getHeight();
// Recreate plugin views
removePluginViews();
createPluginViews();
-
- //add self-timer control
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
+
+ // add self-timer control
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
boolean showDelayedCapturePrefCommon = prefs.getBoolean(MainScreen.sShowDelayedCapturePref, false);
selfTimer = new SelfTimer();
selfTimer.addSelfTimerControl(showDelayedCapturePrefCommon);
- LinearLayout infoLayout = (LinearLayout) guiView
- .findViewById(R.id.infoLayout);
- RelativeLayout.LayoutParams infoParams = (RelativeLayout.LayoutParams) infoLayout
- .getLayoutParams();
- if (infoParams != null) {
+ LinearLayout infoLayout = (LinearLayout) guiView.findViewById(R.id.infoLayout);
+ RelativeLayout.LayoutParams infoParams = (RelativeLayout.LayoutParams) infoLayout.getLayoutParams();
+ if (infoParams != null)
+ {
int width = infoParams.width;
if (infoLayout.getChildCount() == 0)
infoParams.rightMargin = -width;
@@ -1031,23 +1020,25 @@ public void onGUICreate() {
infoLayout.setLayoutParams(infoParams);
infoLayout.requestLayout();
}
-
+
infoSet = prefs.getInt(MainScreen.sDefaultInfoSetPref, INFO_PARAMS);
- if (infoSet == INFO_PARAMS && !isAnyViewOnViewfinder()) {
+ if (infoSet == INFO_PARAMS && !isAnyViewOnViewfinder())
+ {
infoSet = INFO_ALL;
prefs.edit().putInt(MainScreen.sDefaultInfoSetPref, infoSet).commit();
}
setInfo(false, 0, 0, false);
- MainScreen.getInstance().runOnUiThread(new Runnable() {
+ MainScreen.getInstance().runOnUiThread(new Runnable()
+ {
@Override
- public void run() {
+ public void run()
+ {
AlmalenceGUI.this.updateThumbnailButton();
}
});
- final View postProcessingLayout = guiView
- .findViewById(R.id.postprocessingLayout);
+ final View postProcessingLayout = guiView.findViewById(R.id.postprocessingLayout);
final View topPanel = guiView.findViewById(R.id.topPanel);
final View mainButtons = guiView.findViewById(R.id.mainButtons);
final View qcLayout = guiView.findViewById(R.id.qcLayout);
@@ -1063,35 +1054,38 @@ public void run() {
View help = guiView.findViewById(R.id.mode_help);
help.bringToFront();
+
+ if (MainScreen.getInstance().isShowStore())
+ {
+ showStore();
+ MainScreen.getInstance().setShowStore(false);
+ }
}
-
+
@Override
public void setupViewfinderPreviewSize(CameraController.Size previewSize)
{
float cameraAspect = (float) previewSize.getWidth() / previewSize.getHeight();
- RelativeLayout ll = (RelativeLayout) MainScreen.getInstance()
- .findViewById(R.id.mainLayout1);
+ RelativeLayout ll = (RelativeLayout) MainScreen.getInstance().findViewById(R.id.mainLayout1);
int previewSurfaceWidth = ll.getWidth();
int previewSurfaceHeight = ll.getHeight();
- float surfaceAspect = (float) previewSurfaceHeight
- / previewSurfaceWidth;
+ float surfaceAspect = (float) previewSurfaceHeight / previewSurfaceWidth;
- RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.WRAP_CONTENT,
+ RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
DisplayMetrics metrics = new DisplayMetrics();
- MainScreen.getInstance().getWindowManager().getDefaultDisplay()
- .getMetrics(metrics);
+ MainScreen.getInstance().getWindowManager().getDefaultDisplay().getMetrics(metrics);
int screen_height = metrics.heightPixels;
lp.width = previewSurfaceWidth;
lp.height = previewSurfaceHeight;
- if (Math.abs(surfaceAspect - cameraAspect) > 0.05d) {
- if (surfaceAspect > cameraAspect
- && (Math.abs(1 - cameraAspect) > 0.05d)) {
+ if (Math.abs(surfaceAspect - cameraAspect) > 0.05d)
+ {
+ if (surfaceAspect > cameraAspect && (Math.abs(1 - cameraAspect) > 0.05d))
+ {
int paramsLayoutHeight = (int) MainScreen.getInstance().getResources()
.getDimension(R.dimen.paramsLayoutHeight);
// if wide-screen - decrease width of surface
@@ -1099,7 +1093,8 @@ public void setupViewfinderPreviewSize(CameraController.Size previewSize)
lp.height = (int) (screen_height - 2 * paramsLayoutHeight);
lp.topMargin = (int) (paramsLayoutHeight);
- } else if (surfaceAspect > cameraAspect) {
+ } else if (surfaceAspect > cameraAspect)
+ {
int paramsLayoutHeight = (int) MainScreen.getInstance().getResources()
.getDimension(R.dimen.paramsLayoutHeight);
// if wide-screen - decrease width of surface
@@ -1120,34 +1115,31 @@ public void setupViewfinderPreviewSize(CameraController.Size previewSize)
* Each plugin may have only one top menu button Icon id and Title (plugin's
* members) is use to make design of button
*/
- public void createPluginTopMenuButtons() {
+ public void createPluginTopMenuButtons()
+ {
topMenuPluginButtons.clear();
- createPluginTopMenuButtons(PluginManager.getInstance()
- .getActivePlugins(PluginType.ViewFinder));
- createPluginTopMenuButtons(PluginManager.getInstance()
- .getActivePlugins(PluginType.Capture));
- createPluginTopMenuButtons(PluginManager.getInstance()
- .getActivePlugins(PluginType.Processing));
- createPluginTopMenuButtons(PluginManager.getInstance()
- .getActivePlugins(PluginType.Filter));
- createPluginTopMenuButtons(PluginManager.getInstance()
- .getActivePlugins(PluginType.Export));
- }
-
- public void createPluginTopMenuButtons(List plugins) {
- if (!plugins.isEmpty()) {
- for (int i = 0; i < plugins.size(); i++) {
+ createPluginTopMenuButtons(PluginManager.getInstance().getActivePlugins(PluginType.ViewFinder));
+ createPluginTopMenuButtons(PluginManager.getInstance().getActivePlugins(PluginType.Capture));
+ createPluginTopMenuButtons(PluginManager.getInstance().getActivePlugins(PluginType.Processing));
+ createPluginTopMenuButtons(PluginManager.getInstance().getActivePlugins(PluginType.Filter));
+ createPluginTopMenuButtons(PluginManager.getInstance().getActivePlugins(PluginType.Export));
+ }
+
+ public void createPluginTopMenuButtons(List plugins)
+ {
+ if (!plugins.isEmpty())
+ {
+ for (int i = 0; i < plugins.size(); i++)
+ {
Plugin plugin = plugins.get(i);
if (plugin == null || plugin.getQuickControlIconID() <= 0)
continue;
LayoutInflater inflator = MainScreen.getInstance().getLayoutInflater();
- ImageView qcView = (ImageView) inflator.inflate(
- R.layout.gui_almalence_quick_control_button,
- (ViewGroup) guiView.findViewById(R.id.paramsLayout),
- false);
+ ImageView qcView = (ImageView) inflator.inflate(R.layout.gui_almalence_quick_control_button,
+ (ViewGroup) guiView.findViewById(R.id.paramsLayout), false);
qcView.setOnTouchListener(MainScreen.getInstance());
qcView.setOnClickListener(this);
@@ -1158,10 +1150,7 @@ public void createPluginTopMenuButtons(List plugins) {
}
}
- // onGUICreate called when main layout is rendered and size's variables is
- // available
- // @Override
- public void createPluginViews()
+ public void createPluginViews()
{
createPluginViews(PluginType.ViewFinder);
createPluginViews(PluginType.Capture);
@@ -1176,29 +1165,32 @@ private void createPluginViews(PluginType type)
List info_views = null;
Map plugin_views = null;
-
- List plugins = PluginManager.getInstance().getActivePlugins(
- type);
- if (!plugins.isEmpty()) {
- for (int i = 0; i < plugins.size(); i++) {
+
+ List plugins = PluginManager.getInstance().getActivePlugins(type);
+ if (!plugins.isEmpty())
+ {
+ for (int i = 0; i < plugins.size(); i++)
+ {
Plugin plugin = plugins.get(i);
- if (plugin != null) {
+ if (plugin != null)
+ {
plugin_views = plugin.getPluginViews();
addPluginViews(plugin_views);
// Add info controls
info_views = plugin.getInfoViews();
- for (int j = 0; j < info_views.size(); j++) {
+ for (int j = 0; j < info_views.size(); j++)
+ {
View infoView = info_views.get(j);
// Calculate appropriate size of added plugin's view
android.widget.LinearLayout.LayoutParams viewLayoutParams = (android.widget.LinearLayout.LayoutParams) infoView
.getLayoutParams();
- viewLayoutParams = this.getTunedLinearLayoutParams(
- infoView, viewLayoutParams, iInfoViewMaxWidth,
- iInfoViewMaxHeight);
+ viewLayoutParams = this.getTunedLinearLayoutParams(infoView, viewLayoutParams,
+ iInfoViewMaxWidth, iInfoViewMaxHeight);
- if (iInfoControlsRemainingHeight >= viewLayoutParams.height) {
+ if (iInfoControlsRemainingHeight >= viewLayoutParams.height)
+ {
iInfoControlsRemainingHeight -= viewLayoutParams.height;
this.addInfoView(infoView, viewLayoutParams);
}
@@ -1207,31 +1199,32 @@ private void createPluginViews(PluginType type)
}
}
}
-
+
//
- private void initDefaultQuickControls() {
+ private void initDefaultQuickControls()
+ {
initDefaultQuickControls(quickControl1);
initDefaultQuickControls(quickControl2);
initDefaultQuickControls(quickControl3);
initDefaultQuickControls(quickControl4);
}
- private void initDefaultQuickControls(View quickControl)
+ private void initDefaultQuickControls(View quickControl)
{
LayoutInflater inflator = MainScreen.getInstance().getLayoutInflater();
- quickControl = inflator.inflate(
- R.layout.gui_almalence_invisible_button,
+ quickControl = inflator.inflate(R.layout.gui_almalence_invisible_button,
(ViewGroup) guiView.findViewById(R.id.paramsLayout), false);
quickControl.setOnLongClickListener(this);
quickControl.setOnClickListener(this);
}
-
+
// Called when camera object created in MainScreen.
// After camera creation it is possibly to obtain
// all camera possibilities such as supported scene mode, flash mode and
// etc.
@Override
- public void onCameraCreate() {
+ public void onCameraCreate()
+ {
String defaultQuickControl1 = "";
String defaultQuickControl2 = "";
@@ -1250,7 +1243,7 @@ public void onCameraCreate() {
mISOSupported = false;
mMeteringAreasSupported = false;
mCameraChangeSupported = false;
-
+
mEVLockSupported = false;
mWBLockSupported = false;
@@ -1270,16 +1263,17 @@ public void onCameraCreate() {
removeAllQuickViews();
initDefaultQuickControls();
-
+
createPluginTopMenuButtons();
-
- if(CameraController.getInstance().isExposureLockSupported())
+
+ if (CameraController.getInstance().isExposureLockSupported())
mEVLockSupported = true;
- if(CameraController.getInstance().isWhiteBalanceLockSupported())
+ if (CameraController.getInstance().isWhiteBalanceLockSupported())
mWBLockSupported = true;
-
+
// Create Exposure compensation button and slider with supported values
- if (CameraController.getInstance().isExposureCompensationSupported()) {
+ if (CameraController.getInstance().isExposureCompensationSupported())
+ {
mEVSupported = true;
defaultQuickControl1 = String.valueOf(MODE_EV);
@@ -1289,15 +1283,14 @@ public void onCameraCreate() {
int maxValue = CameraController.getInstance().getMaxExposureCompensation();
SeekBar evBar = (SeekBar) guiView.findViewById(R.id.evSeekBar);
- if (evBar != null) {
+ if (evBar != null)
+ {
int initValue = preferences.getInt(MainScreen.sEvPref, 0);
evBar.setMax(maxValue - minValue);
evBar.setProgress(initValue + maxValue);
- TextView leftText = (TextView) guiView
- .findViewById(R.id.seekBarLeftText);
- TextView rightText = (TextView) guiView
- .findViewById(R.id.seekBarRightText);
+ TextView leftText = (TextView) guiView.findViewById(R.id.seekBarLeftText);
+ TextView rightText = (TextView) guiView.findViewById(R.id.seekBarRightText);
int minValueReal = Math.round(minValue * ev_step);
int maxValueReal = Math.round(maxValue * ev_step);
@@ -1320,81 +1313,82 @@ public void onCameraCreate() {
RotateImageView but = (RotateImageView) topMenuButtons.get(MODE_EV);
but.setImageResource(ICON_EV);
- }
- else
+ } else
mEVSupported = false;
// Create Scene mode button and adding supported scene modes
- byte[] supported_scene = CameraController.getInstance().getSupportedSceneModes();
+ int[] supported_scene = CameraController.getInstance().getSupportedSceneModes();
if (supported_scene != null && supported_scene.length > 0 && activeScene != null)
{
- for(byte scene_name : supported_scene)
+ for (int scene_name : supported_scene)
{
- if(scene_name != CameraParameters.SCENE_MODE_NIGHT)
- activeScene.add(sceneModeButtons.get(Integer.valueOf(scene_name)));
- activeSceneNames.add(Integer.valueOf(scene_name));
+ if(sceneModeButtons.containsKey(scene_name))
+ {
+ if (scene_name != CameraParameters.SCENE_MODE_NIGHT)
+ activeScene.add(sceneModeButtons.get(Integer.valueOf(scene_name)));
+ activeSceneNames.add(Integer.valueOf(scene_name));
+ }
}
-
- if(!activeSceneNames.isEmpty())
+
+ if (!activeSceneNames.isEmpty())
{
mSceneModeSupported = true;
scenemodeAdapter.Elements = activeScene;
- GridView gridview = (GridView) guiView
- .findViewById(R.id.scenemodeGrid);
+ GridView gridview = (GridView) guiView.findViewById(R.id.scenemodeGrid);
gridview.setAdapter(scenemodeAdapter);
-
- int initValue = preferences.getInt(MainScreen.sSceneModePref,
- MainScreen.sDefaultValue);
- if (!activeSceneNames.contains(initValue)) {
+
+ int initValue = preferences.getInt(MainScreen.sSceneModePref, MainScreen.sDefaultValue);
+ if (!activeSceneNames.contains(initValue))
+ {
if (CameraController.isFrontCamera())
initValue = activeSceneNames.get(0);
else
initValue = CameraParameters.SCENE_MODE_AUTO;
}
-
+
setButtonSelected(sceneModeButtons, initValue);
setCameraParameterValue(MODE_SCENE, initValue);
-
- if (ICONS_SCENE!=null && ICONS_SCENE.containsKey(initValue))
+
+ if (ICONS_SCENE != null && ICONS_SCENE.containsKey(initValue))
{
- RotateImageView but = (RotateImageView) topMenuButtons
- .get(MODE_SCENE);
+ RotateImageView but = (RotateImageView) topMenuButtons.get(MODE_SCENE);
int icon_id = ICONS_SCENE.get(initValue);
but.setImageResource(icon_id);
}
-
+
CameraController.getInstance().setCameraSceneMode(mSceneMode);
- }
- else
+ } else
{
mSceneModeSupported = false;
mSceneMode = -1;
}
- }
- else
+ } else
{
mSceneModeSupported = false;
mSceneMode = -1;
}
// Create White Balance mode button and adding supported white balances
- byte[] supported_wb = CameraController.getInstance().getSupportedWhiteBalance();
+ int[] supported_wb = CameraController.getInstance().getSupportedWhiteBalance();
if (supported_wb != null && supported_wb.length > 0 && activeWB != null)
{
- for(byte wb_name : supported_wb)
- {
- activeWB.add(wbModeButtons.get(Integer.valueOf(wb_name)));
- activeWBNames.add(Integer.valueOf(wb_name));
+ for (int wb_name : supported_wb)
+ {
+ if(wbModeButtons.containsKey(wb_name))
+ {
+ activeWB.add(wbModeButtons.get(Integer.valueOf(wb_name)));
+ activeWBNames.add(Integer.valueOf(wb_name));
+ }
}
-
- if(!activeWBNames.isEmpty())
+
+ if (!activeWBNames.isEmpty())
{
mWBSupported = true;
-
+
wbmodeAdapter.Elements = activeWB;
GridView gridview = (GridView) guiView.findViewById(R.id.wbGrid);
gridview.setAdapter(wbmodeAdapter);
-
+
int initValue = preferences.getInt(MainScreen.sWBModePref, MainScreen.sDefaultValue);
if (!activeWBNames.contains(initValue))
{
@@ -1405,184 +1399,191 @@ public void onCameraCreate() {
}
setButtonSelected(wbModeButtons, initValue);
setCameraParameterValue(MODE_WB, initValue);
-
- if (ICONS_WB!=null && ICONS_WB.containsKey(initValue))
+
+ if (ICONS_WB != null && ICONS_WB.containsKey(initValue))
{
RotateImageView but = (RotateImageView) topMenuButtons.get(MODE_WB);
int icon_id = ICONS_WB.get(initValue);
but.setImageResource(icon_id);
}
-
+
CameraController.getInstance().setCameraWhiteBalance(mWB);
- }
- else
+ } else
{
mWBSupported = false;
mWB = -1;
}
- }
- else
+ } else
{
mWBSupported = false;
mWB = -1;
}
// Create Focus mode button and adding supported focus modes
- final byte[] supported_focus = CameraController.getInstance().getSupportedFocusModes();
+ final int[] supported_focus = CameraController.getInstance().getSupportedFocusModes();
if (supported_focus != null && supported_focus.length > 0 && activeFocus != null)
{
- for(byte focus_name : supported_focus)
- {
- activeFocus.add(focusModeButtons.get(Integer.valueOf(focus_name)));
- activeFocusNames.add(Integer.valueOf(focus_name));
+ for (int focus_name : supported_focus)
+ {
+ if(focusModeButtons.containsKey(focus_name))
+ {
+ activeFocus.add(focusModeButtons.get(Integer.valueOf(focus_name)));
+ activeFocusNames.add(Integer.valueOf(focus_name));
+ }
}
-
- if(!activeFocusNames.isEmpty())
+
+ if (!activeFocusNames.isEmpty())
{
mFocusModeSupported = true;
defaultQuickControl3 = String.valueOf(MODE_FOCUS);
-
- if(CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_AUTO) ||
- CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_MACRO))
+
+ if (CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_AUTO)
+ || CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_MACRO))
{
LayoutInflater inflator = MainScreen.getInstance().getLayoutInflater();
- View paramMode = inflator.inflate(
- R.layout.gui_almalence_quick_control_grid_element, null,
- false);
+ View paramMode = inflator.inflate(R.layout.gui_almalence_quick_control_grid_element, null, false);
String aflock_name = MainScreen.getInstance().getResources().getString(R.string.focusAFLock);
((ImageView) paramMode.findViewById(R.id.imageView))
.setImageResource(R.drawable.gui_almalence_settings_focus_aflock);
- ((TextView) paramMode.findViewById(R.id.textView))
- .setText(aflock_name);
-
- paramMode.setOnClickListener(new OnClickListener(){
+ ((TextView) paramMode.findViewById(R.id.textView)).setText(aflock_name);
+
+ paramMode.setOnClickListener(new OnClickListener()
+ {
@Override
public void onClick(View v)
{
MainScreen.setAutoFocusLock(true);
- try {
- RotateImageView but = (RotateImageView) topMenuButtons.get(MODE_FOCUS);
+ try
+ {
+ RotateImageView but = (RotateImageView) topMenuButtons.get(MODE_FOCUS);
but.setImageResource(R.drawable.gui_almalence_settings_focus_aflock);
- } catch (Exception e) {
+ } catch (Exception e)
+ {
e.printStackTrace();
Log.e("set AF-L failed", "icons_focus.get exception: " + e.getMessage());
}
-
+
mFocusMode = FOCUS_AF_LOCK;
-
+
int afMode = -1;
- if(CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_AUTO))
+ if (CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_AUTO))
afMode = CameraParameters.AF_MODE_AUTO;
- else if(CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_MACRO))
+ else if (CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_MACRO))
afMode = CameraParameters.AF_MODE_MACRO;
else
afMode = supported_focus[0];
-
+
CameraController.getInstance().setCameraFocusMode(afMode);
-
- preferences.edit().putInt(CameraController.isFrontCamera() ? MainScreen.sRearFocusModePref : MainScreen.sFrontFocusModePref, afMode).commit();
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
+ preferences
+ .edit()
+ .putInt(CameraController.isFrontCamera() ? MainScreen.sRearFocusModePref
+ : MainScreen.sFrontFocusModePref, afMode).commit();
+
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
PluginManager.MSG_FOCUS_CHANGED);
-
+
initSettingsMenu();
hideSecondaryMenus();
unselectPrimaryTopMenuButtons(-1);
-
- guiView.findViewById(R.id.topPanel).setVisibility(
- View.VISIBLE);
+
+ guiView.findViewById(R.id.topPanel).setVisibility(View.VISIBLE);
quickControlsVisible = false;
- }
+ }
});
-
+
focusModeButtons.put(FOCUS_AF_LOCK, paramMode);
activeFocus.add(focusModeButtons.get(FOCUS_AF_LOCK));
activeFocusNames.add(FOCUS_AF_LOCK);
}
focusmodeAdapter.Elements = activeFocus;
- GridView gridview = (GridView) guiView
- .findViewById(R.id.focusmodeGrid);
+ GridView gridview = (GridView) guiView.findViewById(R.id.focusmodeGrid);
gridview.setAdapter(focusmodeAdapter);
-
+
int initValue = preferences.getInt(CameraController.isFrontCamera() ? MainScreen.sRearFocusModePref
: MainScreen.sFrontFocusModePref, MainScreen.sDefaultFocusValue);
- if (!activeFocusNames.contains(initValue)) {
+ if (!activeFocusNames.contains(initValue))
+ {
if (activeFocusNames.contains(MainScreen.sDefaultValue))
initValue = MainScreen.sDefaultValue;
else
initValue = activeFocusNames.get(0);
}
-
+
setButtonSelected(focusModeButtons, initValue);
setCameraParameterValue(MODE_FOCUS, initValue);
-
- if (ICONS_FOCUS!=null && ICONS_FOCUS.containsKey(initValue))
+
+ if (ICONS_FOCUS != null && ICONS_FOCUS.containsKey(initValue))
{
- RotateImageView but = (RotateImageView) topMenuButtons
- .get(MODE_FOCUS);
- try {
+ RotateImageView but = (RotateImageView) topMenuButtons.get(MODE_FOCUS);
+ try
+ {
int icon_id = ICONS_FOCUS.get(initValue);
but.setImageResource(icon_id);
- } catch (Exception e) {
+ } catch (Exception e)
+ {
e.printStackTrace();
Log.e("onCameraCreate", "icons_focus.get exception: " + e.getMessage());
}
}
-
- if(mFocusMode == FOCUS_AF_LOCK)
+
+ if (mFocusMode == FOCUS_AF_LOCK)
{
int afMode = -1;
- if(CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_AUTO))
+ if (CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_AUTO))
afMode = CameraParameters.AF_MODE_AUTO;
- else if(CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_MACRO))
+ else if (CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_MACRO))
afMode = CameraParameters.AF_MODE_MACRO;
else
afMode = supported_focus[0];
-
+
CameraController.getInstance().setCameraFocusMode(afMode);
}
- else
+ else
CameraController.getInstance().setCameraFocusMode(mFocusMode);
- }
- else
+ } else
{
mFocusModeSupported = false;
mFocusMode = -1;
}
- }
- else
+ } else
{
mFocusMode = -1;
mFocusModeSupported = false;
}
// Create Flash mode button and adding supported flash modes
- byte[] supported_flash = CameraController.getInstance().getSupportedFlashModes();
- if (supported_flash != null && supported_flash.length > 0 && activeFlash != null &&
- !(supported_flash.length == 1 && CameraController.isModeAvailable(supported_flash, CameraParameters.FLASH_MODE_OFF)))
- {
- for(byte flash_name : supported_flash)
- {
- activeFlash.add(flashModeButtons.get(Integer.valueOf(flash_name)));
- activeFlashNames.add(Integer.valueOf(flash_name));
+ int[] supported_flash = CameraController.getInstance().getSupportedFlashModes();
+ if (supported_flash != null
+ && supported_flash.length > 0
+ && activeFlash != null
+ && !(supported_flash.length == 1 && CameraController.isModeAvailable(supported_flash,
+ CameraParameters.FLASH_MODE_OFF)))
+ {
+ for (int flash_name : supported_flash)
+ {
+ if(flashModeButtons.containsKey(flash_name))
+ {
+ activeFlash.add(flashModeButtons.get(Integer.valueOf(flash_name)));
+ activeFlashNames.add(Integer.valueOf(flash_name));
+ }
}
-
- if(!activeFlashNames.isEmpty())
+
+ if (!activeFlashNames.isEmpty())
{
mFlashModeSupported = true;
defaultQuickControl2 = String.valueOf(MODE_FLASH);
flashmodeAdapter.Elements = activeFlash;
- GridView gridview = (GridView) guiView
- .findViewById(R.id.flashmodeGrid);
+ GridView gridview = (GridView) guiView.findViewById(R.id.flashmodeGrid);
gridview.setAdapter(flashmodeAdapter);
-
- int initValue = preferences.getInt(MainScreen.sFlashModePref,
- MainScreen.sDefaultFlashValue);
- if (!activeFlashNames.contains(initValue)) {
+
+ int initValue = preferences.getInt(MainScreen.sFlashModePref, MainScreen.sDefaultFlashValue);
+ if (!activeFlashNames.contains(initValue))
+ {
if (CameraController.isFrontCamera())
initValue = activeFlashNames.get(0);
else
@@ -1590,93 +1591,90 @@ else if(CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MO
}
setButtonSelected(flashModeButtons, initValue);
setCameraParameterValue(MODE_FLASH, initValue);
-
- if (ICONS_FLASH!=null && ICONS_FLASH.containsKey(initValue))
+
+ if (ICONS_FLASH != null && ICONS_FLASH.containsKey(initValue))
{
- RotateImageView but = (RotateImageView) topMenuButtons
- .get(MODE_FLASH);
+ RotateImageView but = (RotateImageView) topMenuButtons.get(MODE_FLASH);
int icon_id = ICONS_FLASH.get(initValue);
but.setImageResource(icon_id);
}
-
-
+
CameraController.getInstance().setCameraFlashMode(mFlashMode);
- }
- else
+ } else
{
mFlashModeSupported = false;
- mFlashMode = -1;
+ mFlashMode = -1;
}
- }
- else
+ } else
{
mFlashModeSupported = false;
mFlashMode = -1;
}
// Create ISO button and adding supported ISOs
- byte[] supported_iso = CameraController.getInstance().getSupportedISO();
- if ((supported_iso != null && supported_iso.length > 0 && activeISO != null) ||
- (CameraController.getInstance().isISOSupported() && activeISO != null))
- {
- if(supported_iso != null)
- for(byte iso_name : supported_iso)
- {
- activeISO.add(isoButtons.get(Integer.valueOf(iso_name)));
- activeISONames.add(Integer.valueOf(iso_name));
+ int[] supported_iso = CameraController.getInstance().getSupportedISO();
+ if ((supported_iso != null && supported_iso.length > 0 && activeISO != null)
+ || (CameraController.getInstance().isISOSupported() && activeISO != null))
+ {
+ if (supported_iso != null)
+ for (int iso_name : supported_iso)
+ {
+ if(isoButtons.containsKey(iso_name))
+ {
+ activeISO.add(isoButtons.get(Integer.valueOf(iso_name)));
+ activeISONames.add(Integer.valueOf(iso_name));
+ }
}
else
{
- for(String iso_name : CameraController.getIsoDefaultList())
+ for (String iso_name : CameraController.getIsoDefaultList())
{
activeISO.add(isoButtons.get(CameraController.getIsoKey().get(iso_name)));
activeISONames.add(CameraController.getIsoKey().get(iso_name));
}
}
-
- if(!activeISONames.isEmpty())
+
+ if (!activeISONames.isEmpty())
{
mISOSupported = true;
isoAdapter.Elements = activeISO;
GridView gridview = (GridView) guiView.findViewById(R.id.isoGrid);
gridview.setAdapter(isoAdapter);
-
+
int initValue = preferences.getInt(MainScreen.sISOPref, MainScreen.sDefaultValue);
- if (!activeISONames.contains(initValue)) {
+ if (!activeISONames.contains(initValue))
+ {
if (CameraController.isFrontCamera())
initValue = activeISONames.get(0);
else
initValue = MainScreen.sDefaultValue;
-
+
preferences.edit().putInt(MainScreen.sISOPref, initValue).commit();
}
setButtonSelected(isoButtons, initValue);
setCameraParameterValue(MODE_ISO, initValue);
-
- if (ICONS_ISO!=null && ICONS_ISO.containsKey(initValue))
+
+ if (ICONS_ISO != null && ICONS_ISO.containsKey(initValue))
{
- RotateImageView but = (RotateImageView) topMenuButtons
- .get(MODE_ISO);
+ RotateImageView but = (RotateImageView) topMenuButtons.get(MODE_ISO);
int icon_id = ICONS_ISO.get(initValue);
but.setImageResource(icon_id);
}
CameraController.getInstance().setCameraISO(mISO);
- }
- else
+ } else
{
mISOSupported = false;
- mISO = -1;
+ mISO = -1;
}
- }
- else
+ } else
{
mISOSupported = false;
mISO = -1;
}
-
+
int iMeteringAreasSupported = CameraController.getInstance().getMaxNumMeteringAreas();
- if(iMeteringAreasSupported > 0)
+ if (iMeteringAreasSupported > 0)
{
Collection unsorted_keys = NAMES_METERING.keySet();
List keys = Util.asSortedList(unsorted_keys);
@@ -1684,130 +1682,123 @@ else if(CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MO
while (it.hasNext())
{
int metering_name = it.next();
- activeMetering.add(meteringModeButtons.get(metering_name));
- activeMeteringNames.add(metering_name);
+ if(meteringModeButtons.containsKey(metering_name))
+ {
+ activeMetering.add(meteringModeButtons.get(metering_name));
+ activeMeteringNames.add(metering_name);
+ }
}
-
- if(!activeMeteringNames.isEmpty())
+
+ if (!activeMeteringNames.isEmpty())
{
this.mMeteringAreasSupported = true;
meteringmodeAdapter.Elements = activeMetering;
- GridView gridview = (GridView) guiView
- .findViewById(R.id.meteringmodeGrid);
+ GridView gridview = (GridView) guiView.findViewById(R.id.meteringmodeGrid);
gridview.setAdapter(meteringmodeAdapter);
-
- int initValue = preferences.getInt(MainScreen.sMeteringModePref,
- MainScreen.sDefaultValue);
+
+ int initValue = preferences.getInt(MainScreen.sMeteringModePref, MainScreen.sDefaultValue);
if (!activeMeteringNames.contains(initValue))
- initValue = activeMeteringNames.get(0);
-
+ initValue = activeMeteringNames.get(0);
+
setButtonSelected(meteringModeButtons, initValue);
setCameraParameterValue(MODE_MET, initValue);
-
- if (ICONS_METERING!=null && ICONS_METERING.containsKey(initValue))
+
+ if (ICONS_METERING != null && ICONS_METERING.containsKey(initValue))
{
- RotateImageView but = (RotateImageView) topMenuButtons
- .get(MODE_MET);
+ RotateImageView but = (RotateImageView) topMenuButtons.get(MODE_MET);
int icon_id = ICONS_METERING.get(initValue);
but.setImageResource(icon_id);
}
-
+
MainScreen.getInstance().setCameraMeteringMode(mMeteringMode);
- }
- else
+ } else
{
mMeteringAreasSupported = false;
- mMeteringMode = -1;
+ mMeteringMode = -1;
}
- }
- else
+ } else
{
this.mMeteringAreasSupported = false;
this.mMeteringMode = -1;
}
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD)
+ {
addCameraChangeButton();
defaultQuickControl4 = String.valueOf(MODE_CAM);
} else
mCameraChangeSupported = false;
-
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
- String qc1 = prefs.getString(MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton1),
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
+ String qc1 = prefs.getString(
+ MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton1),
defaultQuickControl1);
- String qc2 = prefs.getString(MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton2),
+ String qc2 = prefs.getString(
+ MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton2),
defaultQuickControl2);
- String qc3 = prefs.getString(MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton3),
+ String qc3 = prefs.getString(
+ MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton3),
defaultQuickControl3);
- String qc4 = prefs.getString(MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton4),
+ String qc4 = prefs.getString(
+ MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton4),
defaultQuickControl4);
- quickControl1 = isCameraParameterSupported(qc1) ? getQuickControlButton(
- qc1, quickControl1) : getFreeQuickControlButton(qc1, qc2, qc3,
- qc4, quickControl1);
- quickControl2 = isCameraParameterSupported(qc2) ? getQuickControlButton(
- qc2, quickControl2) : getFreeQuickControlButton(qc1, qc2, qc3,
- qc4, quickControl2);
- quickControl3 = isCameraParameterSupported(qc3) ? getQuickControlButton(
- qc3, quickControl3) : getFreeQuickControlButton(qc1, qc2, qc3,
- qc4, quickControl3);
- quickControl4 = isCameraParameterSupported(qc4) ? getQuickControlButton(
- qc4, quickControl4) : getFreeQuickControlButton(qc1, qc2, qc3,
- qc4, quickControl4);
+ quickControl1 = isCameraParameterSupported(qc1) ? getQuickControlButton(qc1, quickControl1)
+ : getFreeQuickControlButton(qc1, qc2, qc3, qc4, quickControl1);
+ quickControl2 = isCameraParameterSupported(qc2) ? getQuickControlButton(qc2, quickControl2)
+ : getFreeQuickControlButton(qc1, qc2, qc3, qc4, quickControl2);
+ quickControl3 = isCameraParameterSupported(qc3) ? getQuickControlButton(qc3, quickControl3)
+ : getFreeQuickControlButton(qc1, qc2, qc3, qc4, quickControl3);
+ quickControl4 = isCameraParameterSupported(qc4) ? getQuickControlButton(qc4, quickControl4)
+ : getFreeQuickControlButton(qc1, qc2, qc3, qc4, quickControl4);
try
- {
- ((LinearLayout) guiView.findViewById(R.id.paramsLayout))
- .addView(quickControl1);
+ {
+ ((LinearLayout) guiView.findViewById(R.id.paramsLayout)).addView(quickControl1);
} catch (Exception e)
{
e.printStackTrace();
Log.e("AlmalenceGUI", "addView exception: " + e.getMessage());
}
-
+
try
{
- ((LinearLayout) guiView.findViewById(R.id.paramsLayout))
- .addView(quickControl2);
+ ((LinearLayout) guiView.findViewById(R.id.paramsLayout)).addView(quickControl2);
} catch (Exception e)
{
e.printStackTrace();
Log.e("AlmalenceGUI", "addView exception: " + e.getMessage());
}
-
+
try
{
- ((LinearLayout) guiView.findViewById(R.id.paramsLayout))
- .addView(quickControl3);
+ ((LinearLayout) guiView.findViewById(R.id.paramsLayout)).addView(quickControl3);
} catch (Exception e)
{
e.printStackTrace();
Log.e("AlmalenceGUI", "addView exception: " + e.getMessage());
}
-
+
try
{
- ((LinearLayout) guiView.findViewById(R.id.paramsLayout))
- .addView(quickControl4);
+ ((LinearLayout) guiView.findViewById(R.id.paramsLayout)).addView(quickControl4);
} catch (Exception e)
{
e.printStackTrace();
Log.e("AlmalenceGUI", "addView exception: " + e.getMessage());
}
- if (mEVSupported) {
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_EV_CHANGED);
+ if (mEVSupported)
+ {
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_EV_CHANGED);
}
-
}
-
+
@Override
public void onPluginsInitialized()
- {
+ {
// Hide all opened menu
hideSecondaryMenus();
unselectPrimaryTopMenuButtons(-1);
@@ -1815,8 +1806,10 @@ public void onPluginsInitialized()
// create and fill drawing slider
initSettingsMenu();
- Panel.OnPanelListener pListener = new OnPanelListener() {
- public void onPanelOpened(Panel panel) {
+ Panel.OnPanelListener pListener = new OnPanelListener()
+ {
+ public void onPanelOpened(Panel panel)
+ {
settingsControlsVisible = true;
if (modeSelectorVisible)
@@ -1826,33 +1819,32 @@ public void onPanelOpened(Panel panel) {
if (isSecondaryMenusVisible())
hideSecondaryMenus();
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_LOCKED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_LOCKED);
}
- public void onPanelClosed(Panel panel) {
+ public void onPanelClosed(Panel panel)
+ {
settingsControlsVisible = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
- ((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false,
- false);
+ PluginManager.getInstance()
+ .sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_UNLOCKED);
+ ((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false, false);
}
};
guiView.findViewById(R.id.topPanel).bringToFront();
- ((Panel) guiView.findViewById(R.id.topPanel))
- .setOnPanelListener(pListener);
+ ((Panel) guiView.findViewById(R.id.topPanel)).setOnPanelListener(pListener);
}
-
- private boolean isCameraParameterSupported(String param) {
+ private boolean isCameraParameterSupported(String param)
+ {
if (!param.equals("") && topMenuPluginButtons.containsKey(param))
return true;
else if (!param.equals("") && com.almalence.util.Util.isNumeric(param))
{
int cameraParameter = Integer.valueOf(param);
- switch (cameraParameter) {
+ switch (cameraParameter)
+ {
case MODE_EV:
return mEVSupported;
case MODE_SCENE:
@@ -1877,10 +1869,13 @@ else if (!param.equals("") && com.almalence.util.Util.isNumeric(param))
return false;
}
- //bInitMenu - by default should be true. if called several simultaneously - all should be false and last - true
- public void disableCameraParameter(CameraParameter iParam, boolean bDisable, boolean bInitMenu) {
+ // bInitMenu - by default should be true. if called several simultaneously -
+ // all should be false and last - true
+ public void disableCameraParameter(CameraParameter iParam, boolean bDisable, boolean bInitMenu)
+ {
View topMenuView = null;
- switch (iParam) {
+ switch (iParam)
+ {
case CAMERA_PARAMETER_EV:
topMenuView = topMenuButtons.get(MODE_EV);
isEVEnabled = !bDisable;
@@ -1917,7 +1912,8 @@ public void disableCameraParameter(CameraParameter iParam, boolean bDisable, boo
break;
}
- if (topMenuView != null) {
+ if (topMenuView != null)
+ {
correctTopMenuButtonBackground(topMenuView, !bDisable);
if (bInitMenu)
@@ -1926,27 +1922,29 @@ public void disableCameraParameter(CameraParameter iParam, boolean bDisable, boo
}
- private void correctTopMenuButtonBackground(View topMenuView,
- boolean isEnabled) {
- if (topMenuView != null) {
- if (!isEnabled) {
- ((RotateImageView) topMenuView).setColorFilter(0x50FAFAFA,
- PorterDuff.Mode.DST_IN);
- } else {
+ private void correctTopMenuButtonBackground(View topMenuView, boolean isEnabled)
+ {
+ if (topMenuView != null)
+ {
+ if (!isEnabled)
+ {
+ ((RotateImageView) topMenuView).setColorFilter(0x50FAFAFA, PorterDuff.Mode.DST_IN);
+ } else
+ {
((RotateImageView) topMenuView).clearColorFilter();
}
}
}
- private View getQuickControlButton(String qcID, View defaultView) {
- if (!qcID.equals("") && topMenuPluginButtons.containsKey(qcID)) {
+ private View getQuickControlButton(String qcID, View defaultView)
+ {
+ if (!qcID.equals("") && topMenuPluginButtons.containsKey(qcID))
+ {
Plugin plugin = PluginManager.getInstance().getPlugin(qcID);
- RotateImageView view = (RotateImageView) topMenuPluginButtons
- .get(qcID);
+ RotateImageView view = (RotateImageView) topMenuPluginButtons.get(qcID);
view.setImageResource(plugin.getQuickControlIconID());
return view;
- } else if (!qcID.equals("")
- && topMenuButtons.containsKey(Integer.valueOf(qcID)))
+ } else if (!qcID.equals("") && topMenuButtons.containsKey(Integer.valueOf(qcID)))
return topMenuButtons.get(Integer.valueOf(qcID));
return defaultView;
@@ -1954,38 +1952,45 @@ private View getQuickControlButton(String qcID, View defaultView) {
// Method for finding a button for a top menu which not yet represented in
// that top menu
- private View getFreeQuickControlButton(String qc1, String qc2, String qc3,
- String qc4, View emptyView) {
+ private View getFreeQuickControlButton(String qc1, String qc2, String qc3, String qc4, View emptyView)
+ {
Set topMenuButtonsKeys = topMenuButtons.keySet();
- Iterator topMenuButtonsIterator = topMenuButtonsKeys
- .iterator();
+ Iterator topMenuButtonsIterator = topMenuButtonsKeys.iterator();
Set topMenuPluginButtonsKeys = topMenuPluginButtons.keySet();
- Iterator topMenuPluginButtonsIterator = topMenuPluginButtonsKeys
- .iterator();
+ Iterator topMenuPluginButtonsIterator = topMenuPluginButtonsKeys.iterator();
// Searching for free button in the top menu buttons list (scene mode,
// wb, focus, flash, camera switch)
- while (topMenuButtonsIterator.hasNext()) {
+ while (topMenuButtonsIterator.hasNext())
+ {
int id1, id2, id3, id4;
- try {
+ try
+ {
id1 = Integer.valueOf(qc1);
- } catch (NumberFormatException exp) {
+ } catch (NumberFormatException exp)
+ {
id1 = -1;
}
- try {
+ try
+ {
id2 = Integer.valueOf(qc2);
- } catch (NumberFormatException exp) {
+ } catch (NumberFormatException exp)
+ {
id2 = -1;
}
- try {
+ try
+ {
id3 = Integer.valueOf(qc3);
- } catch (NumberFormatException exp) {
+ } catch (NumberFormatException exp)
+ {
id3 = -1;
}
- try {
+ try
+ {
id4 = Integer.valueOf(qc4);
- } catch (NumberFormatException exp) {
+ } catch (NumberFormatException exp)
+ {
id4 = -1;
}
@@ -1999,7 +2004,8 @@ && isCameraParameterSupported(String.valueOf(buttonID)))
// If top menu buttons dosn't have a free button, search in plugin's
// buttons list
- while (topMenuPluginButtonsIterator.hasNext()) {
+ while (topMenuPluginButtonsIterator.hasNext())
+ {
String buttonID = topMenuPluginButtonsIterator.next();
View topMenuButton = topMenuPluginButtons.get(buttonID);
@@ -2010,29 +2016,24 @@ && isCameraParameterSupported(String.valueOf(buttonID)))
// If no button is found create a empty button
return emptyView;
}
-
- //Util function used to check if topMenuButton already added to top menu
- private boolean checkTopMenuButtonStringID(final View topMenuButton, final String buttonID,
- final String qc1, final String qc2, final String qc3, final String qc4)
+
+ // Util function used to check if topMenuButton already added to top menu
+ private boolean checkTopMenuButtonStringID(final View topMenuButton, final String buttonID, final String qc1,
+ final String qc2, final String qc3, final String qc4)
{
- return topMenuButton != quickControl1
- && topMenuButton != quickControl2
- && topMenuButton != quickControl3
- && topMenuButton != quickControl4 && buttonID != qc1
- && buttonID != qc2 && buttonID != qc3 && buttonID != qc4;
+ return topMenuButton != quickControl1 && topMenuButton != quickControl2 && topMenuButton != quickControl3
+ && topMenuButton != quickControl4 && buttonID != qc1 && buttonID != qc2 && buttonID != qc3
+ && buttonID != qc4;
}
-
- //Util function used to check if topMenuButton already added to top menu
- private boolean checkTopMenuButtonIntegerID(final View topMenuButton, final int buttonID,
- final int qc1, final int qc2, final int qc3, final int qc4)
+
+ // Util function used to check if topMenuButton already added to top menu
+ private boolean checkTopMenuButtonIntegerID(final View topMenuButton, final int buttonID, final int qc1,
+ final int qc2, final int qc3, final int qc4)
{
- return topMenuButton != quickControl1
- && topMenuButton != quickControl2
- && topMenuButton != quickControl3
- && topMenuButton != quickControl4 && buttonID != qc1
- && buttonID != qc2 && buttonID != qc3 && buttonID != qc4;
+ return topMenuButton != quickControl1 && topMenuButton != quickControl2 && topMenuButton != quickControl3
+ && topMenuButton != quickControl4 && buttonID != qc1 && buttonID != qc2 && buttonID != qc3
+ && buttonID != qc4;
}
-
private void addCameraChangeButton()
{
@@ -2040,20 +2041,19 @@ private void addCameraChangeButton()
{
mCameraChangeSupported = true;
- RotateImageView but = (RotateImageView) topMenuButtons
- .get(MODE_CAM);
+ RotateImageView but = (RotateImageView) topMenuButtons.get(MODE_CAM);
but.setImageResource(ICON_CAM);
} else
mCameraChangeSupported = false;
}
- public void rotateSquareViews(final int degree, int duration) {
- if (AlmalenceGUI.mPreviousDeviceOrientation != AlmalenceGUI.mDeviceOrientation
- || duration == 0) {
+ public void rotateSquareViews(final int degree, int duration)
+ {
+ if (AlmalenceGUI.mPreviousDeviceOrientation != AlmalenceGUI.mDeviceOrientation || duration == 0)
+ {
int startDegree = AlmalenceGUI.mPreviousDeviceOrientation == 0 ? 0
: 360 - AlmalenceGUI.mPreviousDeviceOrientation;
- int endDegree = AlmalenceGUI.mDeviceOrientation == 0 ? 0
- : 360 - AlmalenceGUI.mDeviceOrientation;
+ int endDegree = AlmalenceGUI.mDeviceOrientation == 0 ? 0 : 360 - AlmalenceGUI.mDeviceOrientation;
int diff = endDegree - startDegree;
// diff = diff >= 0 ? diff : 360 + diff; // make it in range [0,
@@ -2062,52 +2062,51 @@ public void rotateSquareViews(final int degree, int duration) {
// // Make it in range [-179, 180]. That's the shorted distance
// between the
// // two angles
- endDegree = diff > 180 ? endDegree - 360 : diff < -180
- && endDegree == 0 ? 360 : endDegree;
-
+ endDegree = diff > 180 ? endDegree - 360 : diff < -180 && endDegree == 0 ? 360 : endDegree;
+
if (modeSelectorVisible)
rotateViews(modeViews, startDegree, endDegree, duration);
if (!settingsViews.isEmpty())
{
- int delay = ((Panel)guiView.findViewById(R.id.topPanel)).isOpen()?duration:0;
+ int delay = ((Panel) guiView.findViewById(R.id.topPanel)).isOpen() ? duration : 0;
rotateViews(settingsViews, startDegree, endDegree, delay);
}
- if (!quickControlChangeres.isEmpty()
- && this.quickControlsChangeVisible)
- rotateViews(quickControlChangeres, startDegree, endDegree,
- duration);
+ if (!quickControlChangeres.isEmpty() && this.quickControlsChangeVisible)
+ rotateViews(quickControlChangeres, startDegree, endDegree, duration);
- rotateViews(activeScene, startDegree, endDegree, duration);
- rotateViews(activeWB, startDegree, endDegree, duration);
- rotateViews(activeFocus, startDegree, endDegree, duration);
- rotateViews(activeFlash, startDegree, endDegree, duration);
- rotateViews(activeISO, startDegree, endDegree, duration);
- rotateViews(activeMetering, startDegree, endDegree, duration);
+ rotateViews(activeScene, startDegree, endDegree, duration);
+ rotateViews(activeWB, startDegree, endDegree, duration);
+ rotateViews(activeFocus, startDegree, endDegree, duration);
+ rotateViews(activeFlash, startDegree, endDegree, duration);
+ rotateViews(activeISO, startDegree, endDegree, duration);
+ rotateViews(activeMetering, startDegree, endDegree, duration);
}
}
- private void rotateViews(List views, final float startDegree,
- final float endDegree, long duration) {
- for (int i = 0; i < views.size(); i++) {
+ private void rotateViews(List views, final float startDegree, final float endDegree, long duration)
+ {
+ for (int i = 0; i < views.size(); i++)
+ {
float start = startDegree;
float end = endDegree;
final View view = views.get(i);
-
- if(view == null)
+
+ if (view == null)
continue;
- duration=0;
- if (duration == 0) {
+ duration = 0;
+ if (duration == 0)
+ {
view.clearAnimation();
view.setRotation(endDegree);
- } else {
+ } else
+ {
start = startDegree - view.getRotation();
end = endDegree - view.getRotation();
- RotateAnimation animation = new RotateAnimation(start, end,
- view.getWidth() / 2, view.getHeight() / 2);
+ RotateAnimation animation = new RotateAnimation(start, end, view.getWidth() / 2, view.getHeight() / 2);
animation.setDuration(duration);
animation.setFillAfter(true);
@@ -2137,7 +2136,8 @@ private void addQuickSetting(SettingsType type, boolean isQuickControl)
CharSequence icon_text = "";
boolean isEnabled = true;
- switch (type) {
+ switch (type)
+ {
case SCENE:
icon_id = ICONS_SCENE.get(mSceneMode);
icon_text = MainScreen.getInstance().getResources().getString(R.string.settings_mode_scene);
@@ -2151,14 +2151,13 @@ private void addQuickSetting(SettingsType type, boolean isQuickControl)
case FOCUS:
try
{
- if(mFocusMode == FOCUS_AF_LOCK)
+ if (mFocusMode == FOCUS_AF_LOCK)
icon_id = R.drawable.gui_almalence_settings_focus_aflock;
else
icon_id = ICONS_FOCUS.get(mFocusMode);
icon_text = MainScreen.getInstance().getResources().getString(R.string.settings_mode_focus);
isEnabled = isFocusEnabled;
- }
- catch (Exception e)
+ } catch (Exception e)
{
e.printStackTrace();
Log.e("addQuickSetting", "icons_focus.get exception: " + e.getMessage());
@@ -2178,7 +2177,7 @@ private void addQuickSetting(SettingsType type, boolean isQuickControl)
icon_id = ICONS_METERING.get(mMeteringMode);
icon_text = MainScreen.getInstance().getResources().getString(R.string.settings_mode_metering);
isEnabled = isMeteringEnabled;
- break;
+ break;
case CAMERA:
icon_id = ICON_CAM;
if (!preferences.getBoolean("useFrontCamera", false))
@@ -2211,7 +2210,8 @@ private void addQuickSetting(SettingsType type, boolean isQuickControl)
if (!isEnabled && !isQuickControl)
{
- iconView.setColorFilter(MainScreen.getMainContext().getResources().getColor(R.color.buttonDisabled), PorterDuff.Mode.DST_IN);
+ iconView.setColorFilter(MainScreen.getMainContext().getResources().getColor(R.color.buttonDisabled),
+ PorterDuff.Mode.DST_IN);
textView.setTextColor(MainScreen.getMainContext().getResources().getColor(R.color.textDisabled));
}
@@ -2253,7 +2253,7 @@ private void addQuickSetting(SettingsType type, boolean isQuickControl)
createQuickControlMeteringOnClick(settingView);
else
createSettingMeteringOnClick(settingView);
- break;
+ break;
case CAMERA:
if (isQuickControl)
createQuickControlCameraChangeOnClick(settingView);
@@ -2291,10 +2291,8 @@ private void addPluginQuickSetting(Plugin plugin, boolean isQuickControl)
return;
LayoutInflater inflator = MainScreen.getInstance().getLayoutInflater();
- View qcView = inflator.inflate(
- R.layout.gui_almalence_quick_control_grid_element, null, false);
- ((ImageView) qcView.findViewById(R.id.imageView))
- .setImageResource(iconID);
+ View qcView = inflator.inflate(R.layout.gui_almalence_quick_control_grid_element, null, false);
+ ((ImageView) qcView.findViewById(R.id.imageView)).setImageResource(iconID);
((TextView) qcView.findViewById(R.id.textView)).setText(title);
createPluginQuickControlOnClick(plugin, qcView, isQuickControl);
@@ -2356,7 +2354,7 @@ private void initQuickControlsMenu(View currentView)
case R.id.meteringButton:
if (mMeteringAreasSupported)
addQuickSetting(SettingsType.METERING, true);
- break;
+ break;
case R.id.camerachangeButton:
if (mCameraChangeSupported)
addQuickSetting(SettingsType.CAMERA, true);
@@ -2367,17 +2365,11 @@ private void initQuickControlsMenu(View currentView)
}
// Add quick conrols from plugins
- initPluginQuickControls(PluginManager.getInstance().getActivePlugins(
- PluginType.ViewFinder));
- initPluginQuickControls(PluginManager.getInstance().getActivePlugins(
- PluginType.Capture));
- initPluginQuickControls(PluginManager.getInstance().getActivePlugins(
- PluginType.Processing));
- initPluginQuickControls(PluginManager.getInstance().getActivePlugins(
- PluginType.Filter));
- initPluginQuickControls(PluginManager.getInstance().getActivePlugins(
- PluginType.Export));
-
+ initPluginQuickControls(PluginManager.getInstance().getActivePlugins(PluginType.ViewFinder));
+ initPluginQuickControls(PluginManager.getInstance().getActivePlugins(PluginType.Capture));
+ initPluginQuickControls(PluginManager.getInstance().getActivePlugins(PluginType.Processing));
+ initPluginQuickControls(PluginManager.getInstance().getActivePlugins(PluginType.Filter));
+ initPluginQuickControls(PluginManager.getInstance().getActivePlugins(PluginType.Export));
quickControlAdapter.Elements = quickControlChangeres;
quickControlAdapter.notifyDataSetChanged();
@@ -2400,7 +2392,7 @@ private void initPluginQuickControls(List plugins)
private void initPluginSettingsControls(List plugins)
{
- if (!plugins.isEmpty())
+ if (!plugins.isEmpty())
{
for (int i = 0; i < plugins.size(); i++)
{
@@ -2435,25 +2427,21 @@ public void onClick(View v)
{
public void onClick(View v)
{
- try
+ try
{
plugin.onQuickControlClick();
-
+
int icon_id = plugin.getQuickControlIconID();
String title = plugin.getQuickControlTitle();
- Drawable icon = MainScreen.getMainContext().getResources()
- .getDrawable(icon_id);
- ((ImageView) v.findViewById(R.id.imageView))
- .setImageResource(icon_id);
+ Drawable icon = MainScreen.getMainContext().getResources().getDrawable(icon_id);
+ ((ImageView) v.findViewById(R.id.imageView)).setImageResource(icon_id);
((TextView) v.findViewById(R.id.textView)).setText(title);
-
- RotateImageView pluginButton = (RotateImageView) topMenuPluginButtons
- .get(plugin.getID());
+
+ RotateImageView pluginButton = (RotateImageView) topMenuPluginButtons.get(plugin.getID());
pluginButton.setImageDrawable(icon);
-
+
initSettingsMenu();
- }
- catch (Exception e)
+ } catch (Exception e)
{
e.printStackTrace();
Log.e("Almalence GUI", "createPluginQuickControlOnClick exception" + e.getMessage());
@@ -2468,10 +2456,8 @@ private void createQuickControlEVOnClick(View ev)
{
public void onClick(View v)
{
- RotateImageView ev = (RotateImageView) topMenuButtons
- .get(MODE_EV);
- Drawable icon = MainScreen.getMainContext().getResources()
- .getDrawable(ICON_EV);
+ RotateImageView ev = (RotateImageView) topMenuButtons.get(MODE_EV);
+ Drawable icon = MainScreen.getMainContext().getResources().getDrawable(ICON_EV);
ev.setImageDrawable(icon);
switchViews(currentQuickView, ev, String.valueOf(MODE_EV));
@@ -2490,10 +2476,8 @@ private void createQuickControlSceneOnClick(View scene)
{
public void onClick(View v)
{
- RotateImageView scene = (RotateImageView) topMenuButtons
- .get(MODE_SCENE);
- Drawable icon = MainScreen.getMainContext().getResources()
- .getDrawable(ICONS_SCENE.get(mSceneMode));
+ RotateImageView scene = (RotateImageView) topMenuButtons.get(MODE_SCENE);
+ Drawable icon = MainScreen.getMainContext().getResources().getDrawable(ICONS_SCENE.get(mSceneMode));
scene.setImageDrawable(icon);
switchViews(currentQuickView, scene, String.valueOf(MODE_SCENE));
@@ -2511,10 +2495,8 @@ private void createQuickControlWBOnClick(View wb)
{
public void onClick(View v)
{
- RotateImageView wb = (RotateImageView) topMenuButtons
- .get(MODE_WB);
- Drawable icon = MainScreen.getMainContext().getResources()
- .getDrawable(ICONS_WB.get(mWB));
+ RotateImageView wb = (RotateImageView) topMenuButtons.get(MODE_WB);
+ Drawable icon = MainScreen.getMainContext().getResources().getDrawable(ICONS_WB.get(mWB));
wb.setImageDrawable(icon);
switchViews(currentQuickView, wb, String.valueOf(MODE_WB));
@@ -2537,8 +2519,7 @@ public void onClick(View v)
{
Drawable icon = MainScreen.getMainContext().getResources().getDrawable(ICONS_FOCUS.get(mFocusMode));
focus.setImageDrawable(icon);
- }
- catch (Exception e)
+ } catch (Exception e)
{
e.printStackTrace();
Log.e("createQuickControlFocusOnClick", "icons_focus.get exception: " + e.getMessage());
@@ -2552,13 +2533,14 @@ public void onClick(View v)
});
}
- private void createQuickControlFlashOnClick(View flash) {
- flash.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- RotateImageView flash = (RotateImageView) topMenuButtons
- .get(MODE_FLASH);
- Drawable icon = MainScreen.getMainContext().getResources()
- .getDrawable(ICONS_FLASH.get(mFlashMode));
+ private void createQuickControlFlashOnClick(View flash)
+ {
+ flash.setOnClickListener(new OnClickListener()
+ {
+ public void onClick(View v)
+ {
+ RotateImageView flash = (RotateImageView) topMenuButtons.get(MODE_FLASH);
+ Drawable icon = MainScreen.getMainContext().getResources().getDrawable(ICONS_FLASH.get(mFlashMode));
flash.setImageDrawable(icon);
switchViews(currentQuickView, flash, String.valueOf(MODE_FLASH));
@@ -2571,13 +2553,14 @@ public void onClick(View v) {
});
}
- private void createQuickControlIsoOnClick(View iso) {
- iso.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- RotateImageView iso = (RotateImageView) topMenuButtons
- .get(MODE_ISO);
- Drawable icon = MainScreen.getMainContext().getResources()
- .getDrawable(ICONS_ISO.get(mISO));
+ private void createQuickControlIsoOnClick(View iso)
+ {
+ iso.setOnClickListener(new OnClickListener()
+ {
+ public void onClick(View v)
+ {
+ RotateImageView iso = (RotateImageView) topMenuButtons.get(MODE_ISO);
+ Drawable icon = MainScreen.getMainContext().getResources().getDrawable(ICONS_ISO.get(mISO));
iso.setImageDrawable(icon);
switchViews(currentQuickView, iso, String.valueOf(MODE_ISO));
@@ -2589,12 +2572,14 @@ public void onClick(View v) {
});
}
-
- private void createQuickControlMeteringOnClick(View metering) {
- metering.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- RotateImageView metering = (RotateImageView) topMenuButtons
- .get(MODE_MET);
+
+ private void createQuickControlMeteringOnClick(View metering)
+ {
+ metering.setOnClickListener(new OnClickListener()
+ {
+ public void onClick(View v)
+ {
+ RotateImageView metering = (RotateImageView) topMenuButtons.get(MODE_MET);
Drawable icon = MainScreen.getMainContext().getResources()
.getDrawable(ICONS_METERING.get(mMeteringMode));
metering.setImageDrawable(icon);
@@ -2609,13 +2594,14 @@ public void onClick(View v) {
});
}
- private void createQuickControlCameraChangeOnClick(View cameraChange) {
- cameraChange.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- RotateImageView cam = (RotateImageView) topMenuButtons
- .get(MODE_CAM);
- Drawable icon = MainScreen.getMainContext().getResources()
- .getDrawable(ICON_CAM);
+ private void createQuickControlCameraChangeOnClick(View cameraChange)
+ {
+ cameraChange.setOnClickListener(new OnClickListener()
+ {
+ public void onClick(View v)
+ {
+ RotateImageView cam = (RotateImageView) topMenuButtons.get(MODE_CAM);
+ Drawable icon = MainScreen.getMainContext().getResources().getDrawable(ICON_CAM);
cam.setImageDrawable(icon);
switchViews(currentQuickView, cam, String.valueOf(MODE_CAM));
@@ -2627,44 +2613,38 @@ public void onClick(View v) {
});
}
-
- public void changeCurrentQuickControl(View newCurrent) {
+ public void changeCurrentQuickControl(View newCurrent)
+ {
if (currentQuickView != null)
- currentQuickView.setBackgroundDrawable(MainScreen.getMainContext()
- .getResources().getDrawable(
- R.drawable.transparent_background));
+ currentQuickView.setBackgroundResource(R.drawable.transparent_background);
currentQuickView = newCurrent;
- newCurrent.setBackgroundDrawable(MainScreen.getMainContext().getResources()
- .getDrawable(R.drawable.layout_border_qc_button));
+ newCurrent.setBackgroundResource(R.drawable.layout_border_qc_button);
((RotateImageView) newCurrent).setBackgroundEnabled(true);
}
- private void showQuickControlsSettings() {
+ private void showQuickControlsSettings()
+ {
unselectPrimaryTopMenuButtons(-1);
hideSecondaryMenus();
GridView gridview = (GridView) guiView.findViewById(R.id.qcGrid);
gridview.setAdapter(quickControlAdapter);
- ((RelativeLayout) guiView.findViewById(R.id.qcLayout))
- .setVisibility(View.VISIBLE);
+ ((RelativeLayout) guiView.findViewById(R.id.qcLayout)).setVisibility(View.VISIBLE);
- ((LinearLayout) guiView.findViewById(R.id.paramsLayout))
- .setBackgroundDrawable(MainScreen.getMainContext().getResources()
- .getDrawable(R.drawable.blacktransparentlayertop));
+ ((LinearLayout) guiView.findViewById(R.id.paramsLayout)).setBackgroundResource(R.drawable.blacktransparentlayertop);
Set topmenu_keys = topMenuButtons.keySet();
Iterator it = topmenu_keys.iterator();
- while (it.hasNext()) {
+ while (it.hasNext())
+ {
int key = it.next();
- if (currentQuickView != topMenuButtons.get(key)) {
- ((RotateImageView) topMenuButtons.get(key))
- .setBackgroundEnabled(true);
- topMenuButtons.get(key).setBackgroundDrawable(
- MainScreen.getMainContext().getResources().getDrawable(
- R.drawable.transparent_background));
+ if (currentQuickView != topMenuButtons.get(key))
+ {
+ ((RotateImageView) topMenuButtons.get(key)).setBackgroundEnabled(true);
+ topMenuButtons.get(key).setBackgroundResource(R.drawable.transparent_background);
}
}
@@ -2674,43 +2654,30 @@ private void showQuickControlsSettings() {
: AlmalenceGUI.mDeviceOrientation % 360 + 360;
rotateSquareViews(degree, 0);
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_LOCKED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_LOCKED);
}
- private void closeQuickControlsSettings() {
- RelativeLayout gridview = (RelativeLayout) guiView
- .findViewById(R.id.qcLayout);
+ private void closeQuickControlsSettings()
+ {
+ RelativeLayout gridview = (RelativeLayout) guiView.findViewById(R.id.qcLayout);
gridview.setVisibility(View.INVISIBLE);
quickControlsChangeVisible = false;
- currentQuickView.setBackgroundDrawable(MainScreen.getMainContext()
- .getResources().getDrawable(R.drawable.transparent_background));
+ currentQuickView.setBackgroundResource(R.drawable.transparent_background);
currentQuickView = null;
- ((LinearLayout) guiView.findViewById(R.id.paramsLayout))
- .setBackgroundDrawable(MainScreen.getMainContext().getResources()
- .getDrawable(R.drawable.blacktransparentlayertop));
-
- correctTopMenuButtonBackground(
- MainScreen.getInstance().findViewById(MODE_EV), isEVEnabled);
- correctTopMenuButtonBackground(
- MainScreen.getInstance().findViewById(MODE_SCENE), isSceneEnabled);
- correctTopMenuButtonBackground(
- MainScreen.getInstance().findViewById(MODE_WB), isWBEnabled);
- correctTopMenuButtonBackground(
- MainScreen.getInstance().findViewById(MODE_FOCUS), isFocusEnabled);
- correctTopMenuButtonBackground(
- MainScreen.getInstance().findViewById(MODE_FLASH), isFlashEnabled);
- correctTopMenuButtonBackground(
- MainScreen.getInstance().findViewById(MODE_ISO), isIsoEnabled);
- correctTopMenuButtonBackground(
- MainScreen.getInstance().findViewById(MODE_MET), isMeteringEnabled);
- correctTopMenuButtonBackground(
- MainScreen.getInstance().findViewById(MODE_CAM), isCameraChangeEnabled);
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
+ ((LinearLayout) guiView.findViewById(R.id.paramsLayout)).setBackgroundResource(R.drawable.blacktransparentlayertop);
+
+ correctTopMenuButtonBackground(MainScreen.getInstance().findViewById(MODE_EV), isEVEnabled);
+ correctTopMenuButtonBackground(MainScreen.getInstance().findViewById(MODE_SCENE), isSceneEnabled);
+ correctTopMenuButtonBackground(MainScreen.getInstance().findViewById(MODE_WB), isWBEnabled);
+ correctTopMenuButtonBackground(MainScreen.getInstance().findViewById(MODE_FOCUS), isFocusEnabled);
+ correctTopMenuButtonBackground(MainScreen.getInstance().findViewById(MODE_FLASH), isFlashEnabled);
+ correctTopMenuButtonBackground(MainScreen.getInstance().findViewById(MODE_ISO), isIsoEnabled);
+ correctTopMenuButtonBackground(MainScreen.getInstance().findViewById(MODE_MET), isMeteringEnabled);
+ correctTopMenuButtonBackground(MainScreen.getInstance().findViewById(MODE_CAM), isCameraChangeEnabled);
+
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_UNLOCKED);
guiView.findViewById(R.id.topPanel).setVisibility(View.VISIBLE);
}
@@ -2728,10 +2695,12 @@ private void closeQuickControlsSettings() {
*
* begin >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
****************************************************************************************/
- private void initSettingsMenu() {
+ private void initSettingsMenu()
+ {
// Clear view list to recreate all settings buttons
settingsViews.clear();
- if (settingsAdapter.Elements != null) {
+ if (settingsAdapter.Elements != null)
+ {
settingsAdapter.Elements.clear();
settingsAdapter.notifyDataSetChanged();
}
@@ -2739,11 +2708,13 @@ private void initSettingsMenu() {
// Obtain all theoretical buttons we know
Set keys = topMenuButtons.keySet();
Iterator it = keys.iterator();
- while (it.hasNext()) {
+ while (it.hasNext())
+ {
// If such camera feature is supported then add a button to settings
// menu
Integer id = it.next();
- switch (id) {
+ switch (id)
+ {
case R.id.evButton:
if (mEVSupported)
addQuickSetting(SettingsType.EV, false);
@@ -2771,7 +2742,7 @@ private void initSettingsMenu() {
case R.id.meteringButton:
if (mMeteringAreasSupported)
addQuickSetting(SettingsType.METERING, false);
- break;
+ break;
case R.id.camerachangeButton:
if (mCameraChangeSupported)
addQuickSetting(SettingsType.CAMERA, false);
@@ -2782,16 +2753,11 @@ private void initSettingsMenu() {
}
// Add quick conrols from plugins
- initPluginSettingsControls(PluginManager.getInstance()
- .getActivePlugins(PluginType.ViewFinder));
- initPluginSettingsControls(PluginManager.getInstance()
- .getActivePlugins(PluginType.Capture));
- initPluginSettingsControls(PluginManager.getInstance()
- .getActivePlugins(PluginType.Processing));
- initPluginSettingsControls(PluginManager.getInstance()
- .getActivePlugins(PluginType.Filter));
- initPluginSettingsControls(PluginManager.getInstance()
- .getActivePlugins(PluginType.Export));
+ initPluginSettingsControls(PluginManager.getInstance().getActivePlugins(PluginType.ViewFinder));
+ initPluginSettingsControls(PluginManager.getInstance().getActivePlugins(PluginType.Capture));
+ initPluginSettingsControls(PluginManager.getInstance().getActivePlugins(PluginType.Processing));
+ initPluginSettingsControls(PluginManager.getInstance().getActivePlugins(PluginType.Filter));
+ initPluginSettingsControls(PluginManager.getInstance().getActivePlugins(PluginType.Export));
// The very last control is always MORE SETTINGS
addQuickSetting(SettingsType.MORE, false);
@@ -2815,26 +2781,23 @@ public void onClick(final View v)
{
if (!isSceneEnabled)
{
- showToast(null, Toast.LENGTH_SHORT, Gravity.BOTTOM,
- MainScreen.getInstance().getResources().getString(R.string.settings_not_available),
- true,
- false);
+ showToast(null, Toast.LENGTH_SHORT, Gravity.BOTTOM, MainScreen.getInstance().getResources()
+ .getString(R.string.settings_not_available), true, false);
return;
}
- byte[] supported_scene = CameraController.getInstance().getSupportedSceneModes();
+ int[] supported_scene = CameraController.getInstance().getSupportedSceneModes();
if (supported_scene == null)
return;
if (supported_scene.length > 0)
{
- if(iScreenType == 0)
+ if (iScreenType == 0)
((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false, false);
-
- if(guiView.findViewById(R.id.scenemodeLayout).getVisibility() != View.VISIBLE)
+
+ if (guiView.findViewById(R.id.scenemodeLayout).getVisibility() != View.VISIBLE)
{
- hideSecondaryMenus();
+ hideSecondaryMenus();
showParams(MODE_SCENE);
- }
- else
+ } else
hideSecondaryMenus();
}
}
@@ -2849,23 +2812,21 @@ public void onClick(View v)
{
if (!isWBEnabled)
{
- showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER,
- MainScreen.getInstance().getResources().getString(R.string.settings_not_available),
- true,
- false);
+ showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER, MainScreen.getInstance().getResources()
+ .getString(R.string.settings_not_available), true, false);
return;
}
- byte[] supported_wb = CameraController.getInstance().getSupportedWhiteBalance();
+ int[] supported_wb = CameraController.getInstance().getSupportedWhiteBalance();
if (supported_wb == null)
return;
if (supported_wb.length > 0)
{
- if(iScreenType == 0)
+ if (iScreenType == 0)
((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false, false);
-
- if(guiView.findViewById(R.id.wbLayout).getVisibility() != View.VISIBLE)
+
+ if (guiView.findViewById(R.id.wbLayout).getVisibility() != View.VISIBLE)
{
- hideSecondaryMenus();
+ hideSecondaryMenus();
showParams(MODE_WB);
}
@@ -2884,26 +2845,23 @@ public void onClick(View v)
{
if (!isFocusEnabled)
{
- showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER,
- MainScreen.getInstance().getResources().getString(R.string.settings_not_available),
- true,
- false);
+ showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER, MainScreen.getInstance().getResources()
+ .getString(R.string.settings_not_available), true, false);
return;
}
- byte[] supported_focus = CameraController.getInstance().getSupportedFocusModes();
+ int[] supported_focus = CameraController.getInstance().getSupportedFocusModes();
if (supported_focus == null)
return;
if (supported_focus.length > 0)
{
- if(iScreenType == 0)
+ if (iScreenType == 0)
((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false, false);
-
- if(guiView.findViewById(R.id.focusmodeLayout).getVisibility() != View.VISIBLE)
+
+ if (guiView.findViewById(R.id.focusmodeLayout).getVisibility() != View.VISIBLE)
{
- hideSecondaryMenus();
+ hideSecondaryMenus();
showParams(MODE_FOCUS);
- }
- else
+ } else
hideSecondaryMenus();
}
}
@@ -2918,26 +2876,23 @@ public void onClick(View v)
{
if (!isFlashEnabled)
{
- showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER,
- MainScreen.getInstance().getResources().getString(R.string.settings_not_available),
- true,
- false);
+ showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER, MainScreen.getInstance().getResources()
+ .getString(R.string.settings_not_available), true, false);
return;
}
- byte[] supported_flash = CameraController.getInstance().getSupportedFlashModes();
+ int[] supported_flash = CameraController.getInstance().getSupportedFlashModes();
if (supported_flash == null)
return;
if (supported_flash.length > 0)
{
- if(iScreenType == 0)
+ if (iScreenType == 0)
((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false, false);
-
- if(guiView.findViewById(R.id.flashmodeLayout).getVisibility() != View.VISIBLE)
+
+ if (guiView.findViewById(R.id.flashmodeLayout).getVisibility() != View.VISIBLE)
{
- hideSecondaryMenus();
+ hideSecondaryMenus();
showParams(MODE_FLASH);
- }
- else
+ } else
hideSecondaryMenus();
}
}
@@ -2952,31 +2907,28 @@ public void onClick(View v)
{
if (!isIsoEnabled)
{
- showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER,
- MainScreen.getInstance().getResources().getString(R.string.settings_not_available),
- true,
- false);
+ showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER, MainScreen.getInstance().getResources()
+ .getString(R.string.settings_not_available), true, false);
return;
}
- byte[] supported_iso = CameraController.getInstance().getSupportedISO();
- if ((supported_iso != null && supported_iso.length > 0) ||
- CameraController.getInstance().isISOSupported())
- {
- if(iScreenType == 0)
+ int[] supported_iso = CameraController.getInstance().getSupportedISO();
+ if ((supported_iso != null && supported_iso.length > 0)
+ || CameraController.getInstance().isISOSupported())
+ {
+ if (iScreenType == 0)
((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false, false);
-
- if(guiView.findViewById(R.id.isoLayout).getVisibility() != View.VISIBLE)
+
+ if (guiView.findViewById(R.id.isoLayout).getVisibility() != View.VISIBLE)
{
- hideSecondaryMenus();
+ hideSecondaryMenus();
showParams(MODE_ISO);
- }
- else
+ } else
hideSecondaryMenus();
}
}
});
}
-
+
private void createSettingMeteringOnClick(View settingView)
{
settingView.setOnClickListener(new OnClickListener()
@@ -2985,30 +2937,26 @@ public void onClick(View v)
{
if (!isMeteringEnabled)
{
- showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER,
- MainScreen.getInstance().getResources().getString(R.string.settings_not_available),
- true,
- false);
+ showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER, MainScreen.getInstance().getResources()
+ .getString(R.string.settings_not_available), true, false);
return;
}
int iMeteringAreasSupported = CameraController.getInstance().getMaxNumMeteringAreas();
if (iMeteringAreasSupported > 0)
- {
- if(iScreenType == 0)
+ {
+ if (iScreenType == 0)
((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false, false);
-
- if(guiView.findViewById(R.id.meteringLayout).getVisibility() != View.VISIBLE)
+
+ if (guiView.findViewById(R.id.meteringLayout).getVisibility() != View.VISIBLE)
{
- hideSecondaryMenus();
+ hideSecondaryMenus();
showParams(MODE_MET);
- }
- else
+ } else
hideSecondaryMenus();
}
}
});
}
-
private void createSettingCameraOnClick(View settingView)
{
@@ -3018,10 +2966,8 @@ public void onClick(View v)
{
if (!isCameraChangeEnabled)
{
- showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER,
- MainScreen.getInstance().getResources().getString(R.string.settings_not_available),
- true,
- false);
+ showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER, MainScreen.getInstance().getResources()
+ .getString(R.string.settings_not_available), true, false);
return;
}
cameraSwitched(true);
@@ -3037,21 +2983,18 @@ public void onClick(View v)
{
if (!isEVEnabled)
{
- showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER,
- MainScreen.getInstance().getResources().getString(R.string.settings_not_available),
- true,
- false);
+ showToast(null, Toast.LENGTH_SHORT, Gravity.CENTER, MainScreen.getInstance().getResources()
+ .getString(R.string.settings_not_available), true, false);
return;
}
- if(iScreenType == 0)
+ if (iScreenType == 0)
((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false, false);
-
- if(guiView.findViewById(R.id.evLayout).getVisibility() != View.VISIBLE)
+
+ if (guiView.findViewById(R.id.evLayout).getVisibility() != View.VISIBLE)
{
- hideSecondaryMenus();
+ hideSecondaryMenus();
showParams(MODE_EV);
- }
- else
+ } else
hideSecondaryMenus();
}
});
@@ -3083,8 +3026,12 @@ private void cameraSwitched(boolean restart)
if (PluginManager.getInstance().getProcessingCounter() != 0)
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
- boolean isFrontCamera = prefs.getBoolean(MainScreen.getMainContext().getResources().getString(R.string.Preference_UseFrontCameraValue), false);
- prefs.edit().putBoolean(MainScreen.getMainContext().getResources().getString(R.string.Preference_UseFrontCameraValue), !isFrontCamera).commit();
+ boolean isFrontCamera = prefs.getBoolean(
+ MainScreen.getMainContext().getResources().getString(R.string.Preference_UseFrontCameraValue), false);
+ prefs.edit()
+ .putBoolean(
+ MainScreen.getMainContext().getResources().getString(R.string.Preference_UseFrontCameraValue),
+ !isFrontCamera).commit();
if (restart)
{
@@ -3103,8 +3050,9 @@ private void showModeList()
MainScreen.getInstance().getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels;
int modeHeightByWidth = (int) (width / 3 - 5 * metrics.density);
- int modeHeightByDimen = Math.round(MainScreen.getInstance().getResources().getDimension(R.dimen.gridModeImageSize)
- + MainScreen.getInstance().getResources().getDimension(R.dimen.gridModeTextLayoutSize));
+ int modeHeightByDimen = Math.round(MainScreen.getInstance().getResources()
+ .getDimension(R.dimen.gridModeImageSize)
+ + MainScreen.getInstance().getResources().getDimension(R.dimen.gridModeTextLayoutSize));
int modeHeight = modeHeightByDimen > modeHeightByWidth ? modeHeightByWidth : modeHeightByDimen;
@@ -3118,7 +3066,7 @@ private void showModeList()
GridView gridview = (GridView) guiView.findViewById(R.id.modeGrid);
gridview.setAdapter(modeAdapter);
-
+
gridview.setOnTouchListener(new OnTouchListener()
{
@Override
@@ -3134,15 +3082,15 @@ public boolean onTouch(View v, MotionEvent event)
modeSelectorVisible = true;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_LOCKED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_LOCKED);
}
private void hideModeList()
{
RelativeLayout gridview = (RelativeLayout) guiView.findViewById(R.id.modeLayout);
- Animation gone = AnimationUtils.loadAnimation(MainScreen.getInstance(), R.anim.gui_almalence_modelist_invisible);
+ Animation gone = AnimationUtils
+ .loadAnimation(MainScreen.getInstance(), R.anim.gui_almalence_modelist_invisible);
gone.setFillAfter(true);
gridview.setAnimation(gone);
@@ -3163,20 +3111,19 @@ public void onAnimationEnd(Animation animation)
@Override
public void onAnimationRepeat(Animation animation)
{
- //Not used
+ // Not used
}
@Override
public void onAnimationStart(Animation animation)
{
- //Not used
+ // Not used
}
});
modeSelectorVisible = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_UNLOCKED);
}
@Override
@@ -3216,8 +3163,7 @@ else if (isAnyViewOnViewfinder())
infoSet = INFO_ALL;
setInfo(toLeft, xToVisible, xToInvisible, true);
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
prefs.edit().putInt(MainScreen.sDefaultInfoSetPref, infoSet).commit();
}
@@ -3240,13 +3186,14 @@ private void setInfo(boolean toLeft, float xToVisible, float xToInvisible, boole
lrvisible.setInterpolator(new DecelerateInterpolator());
int duration_invisible = 0;
- duration_invisible = isAnimate ? com.almalence.util.Util.clamp(
- Math.abs(Math.round(((toLeft ? xToVisible : (screenWidth - xToVisible)) * 500) / screenWidth)), 10, 500) : 0;
-
- int duration_visible = 0;
+ duration_invisible = isAnimate ? com.almalence.util.Util
+ .clamp(Math.abs(Math.round(((toLeft ? xToVisible : (screenWidth - xToVisible)) * 500) / screenWidth)),
+ 10, 500) : 0;
+
+ int duration_visible = 0;
duration_visible = isAnimate ? com.almalence.util.Util.clamp(
- Math.abs(Math.round(((toLeft ? xToInvisible : (screenWidth - xToInvisible)) * 500) / screenWidth)), 10, 500) : 0;
-
+ Math.abs(Math.round(((toLeft ? xToInvisible : (screenWidth - xToInvisible)) * 500) / screenWidth)), 10,
+ 500) : 0;
Animation invisible_alpha = new AlphaAnimation(1, 0);
invisible_alpha.setDuration(duration_invisible);
@@ -3283,26 +3230,26 @@ private void setInfo(boolean toLeft, float xToVisible, float xToInvisible, boole
lrvisible.addAnimation(lrvisible_translate);
- int[] zonesVisibility = new int[]{View.GONE, View.GONE, View.GONE};
+ int[] zonesVisibility = new int[] { View.GONE, View.GONE, View.GONE };
switch (infoSet)
{
- case INFO_ALL:
- zonesVisibility = initZonesVisibility(View.VISIBLE, View.VISIBLE, View.VISIBLE);
- break;
-
- case INFO_NO:
- zonesVisibility = initZonesVisibility(View.GONE, View.GONE, View.GONE);
- break;
-
- case INFO_GRID:
- zonesVisibility = initZonesVisibility(View.GONE, View.GONE, View.VISIBLE);
- break;
-
- case INFO_PARAMS:
- zonesVisibility = initZonesVisibility(View.VISIBLE, View.GONE, View.GONE);
- break;
- default:
- break;
+ case INFO_ALL:
+ zonesVisibility = initZonesVisibility(View.VISIBLE, View.VISIBLE, View.VISIBLE);
+ break;
+
+ case INFO_NO:
+ zonesVisibility = initZonesVisibility(View.GONE, View.GONE, View.GONE);
+ break;
+
+ case INFO_GRID:
+ zonesVisibility = initZonesVisibility(View.GONE, View.GONE, View.VISIBLE);
+ break;
+
+ case INFO_PARAMS:
+ zonesVisibility = initZonesVisibility(View.VISIBLE, View.GONE, View.GONE);
+ break;
+ default:
+ break;
}
applyZonesVisibility(zonesVisibility, isAnimate, toLeft, rlvisible, lrvisible, rlinvisible, lrinvisible);
@@ -3317,13 +3264,13 @@ public void onAnimationEnd(Animation animation)
@Override
public void onAnimationRepeat(Animation animation)
{
- //Not used
+ // Not used
}
@Override
public void onAnimationStart(Animation animation)
{
- //Not used
+ // Not used
}
});
@@ -3338,66 +3285,75 @@ public void onAnimationEnd(Animation animation)
@Override
public void onAnimationRepeat(Animation animation)
{
- //Not used
+ // Not used
}
@Override
public void onAnimationStart(Animation animation)
{
- //Not used
+ // Not used
}
});
// checks preferences
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
Editor prefsEditor = prefs.edit();
prefsEditor.putInt(MainScreen.sDefaultInfoSetPref, infoSet);
prefsEditor.commit();
}
-
- private int[] initZonesVisibility(final int zoneVisibiltyFirst, final int zoneVisibiltySecond, final int zoneVisibilityThird)
+
+ private int[] initZonesVisibility(final int zoneVisibiltyFirst, final int zoneVisibiltySecond,
+ final int zoneVisibilityThird)
{
int[] zonesVisibility = new int[3];
zonesVisibility[0] = zoneVisibiltyFirst;
zonesVisibility[1] = zoneVisibiltySecond;
zonesVisibility[2] = zoneVisibilityThird;
-
+
return zonesVisibility;
}
-
- private void applyZonesVisibility(int[] zonesVisibility, boolean isAnimate, boolean toLeft, AnimationSet rlvisible, AnimationSet lrvisible, AnimationSet rlinvisible, AnimationSet lrinvisible)
+
+ private void applyZonesVisibility(int[] zonesVisibility, boolean isAnimate, boolean toLeft, AnimationSet rlvisible,
+ AnimationSet lrvisible, AnimationSet rlinvisible, AnimationSet lrinvisible)
{
hideSecondaryMenus();
unselectPrimaryTopMenuButtons(-1);
- if(guiView.findViewById(R.id.paramsLayout).getVisibility() != zonesVisibility[0])
+ if (guiView.findViewById(R.id.paramsLayout).getVisibility() != zonesVisibility[0])
{
if (isAnimate)
- guiView.findViewById(R.id.paramsLayout).startAnimation(toLeft ? zonesVisibility[0] == View.VISIBLE? rlvisible : rlinvisible : zonesVisibility[0] == View.VISIBLE? lrvisible : lrinvisible);
+ guiView.findViewById(R.id.paramsLayout).startAnimation(
+ toLeft ? zonesVisibility[0] == View.VISIBLE ? rlvisible : rlinvisible
+ : zonesVisibility[0] == View.VISIBLE ? lrvisible : lrinvisible);
guiView.findViewById(R.id.paramsLayout).setVisibility(zonesVisibility[0]);
((Panel) guiView.findViewById(R.id.topPanel)).reorder(zonesVisibility[0] == View.GONE, true);
}
-
- if(guiView.findViewById(R.id.pluginsLayout).getVisibility() != zonesVisibility[1])
+
+ if (guiView.findViewById(R.id.pluginsLayout).getVisibility() != zonesVisibility[1])
{
if (isAnimate)
- guiView.findViewById(R.id.pluginsLayout).startAnimation(toLeft ? zonesVisibility[1] == View.VISIBLE? rlvisible : rlinvisible : zonesVisibility[1] == View.VISIBLE? lrvisible : lrinvisible);
+ guiView.findViewById(R.id.pluginsLayout).startAnimation(
+ toLeft ? zonesVisibility[1] == View.VISIBLE ? rlvisible : rlinvisible
+ : zonesVisibility[1] == View.VISIBLE ? lrvisible : lrinvisible);
guiView.findViewById(R.id.pluginsLayout).setVisibility(zonesVisibility[1]);
-
+
if (isAnimate)
- guiView.findViewById(R.id.infoLayout).startAnimation(toLeft ? zonesVisibility[1] == View.VISIBLE? rlvisible : rlinvisible : zonesVisibility[1] == View.VISIBLE? lrvisible : lrinvisible);
+ guiView.findViewById(R.id.infoLayout).startAnimation(
+ toLeft ? zonesVisibility[1] == View.VISIBLE ? rlvisible : rlinvisible
+ : zonesVisibility[1] == View.VISIBLE ? lrvisible : lrinvisible);
guiView.findViewById(R.id.infoLayout).setVisibility(zonesVisibility[1]);
}
-
- if(guiView.findViewById(R.id.fullscreenLayout).getVisibility() != zonesVisibility[2])
+
+ if (guiView.findViewById(R.id.fullscreenLayout).getVisibility() != zonesVisibility[2])
{
if (isAnimate)
- guiView.findViewById(R.id.fullscreenLayout).startAnimation(toLeft ? zonesVisibility[2] == View.VISIBLE? rlvisible : rlinvisible : zonesVisibility[2] == View.VISIBLE? lrvisible : lrinvisible);
+ guiView.findViewById(R.id.fullscreenLayout).startAnimation(
+ toLeft ? zonesVisibility[2] == View.VISIBLE ? rlvisible : rlinvisible
+ : zonesVisibility[2] == View.VISIBLE ? lrvisible : lrinvisible);
guiView.findViewById(R.id.fullscreenLayout).setVisibility(zonesVisibility[2]);
}
}
-
+
private void clearLayoutsAnimation()
{
guiView.findViewById(R.id.paramsLayout).clearAnimation();
@@ -3413,53 +3369,61 @@ private void switchViews(View currentView, View newView, String qcID)
if (currentView == newView)
return;
- SharedPreferences pref = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
+ SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
int currentQCNumber = -1;
String currentViewID = "";
if (currentView == quickControl1)
{
- currentViewID = pref.getString(MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton1), "");
+ currentViewID = pref.getString(
+ MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton1), "");
currentQCNumber = 1;
- }
- else if (currentView == quickControl2)
+ } else if (currentView == quickControl2)
{
- currentViewID = pref.getString(MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton2), "");
+ currentViewID = pref.getString(
+ MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton2), "");
currentQCNumber = 2;
- }
- else if (currentView == quickControl3)
+ } else if (currentView == quickControl3)
{
- currentViewID = pref.getString(MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton3), "");
+ currentViewID = pref.getString(
+ MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton3), "");
currentQCNumber = 3;
- }
- else if (currentView == quickControl4)
+ } else if (currentView == quickControl4)
{
- currentViewID = pref.getString(MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton4), "");
+ currentViewID = pref.getString(
+ MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton4), "");
currentQCNumber = 4;
}
if (newView == quickControl1)
{
quickControl1 = currentView;
- pref.edit().putString(MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton1), currentViewID).commit();
- }
- else if (newView == quickControl2)
+ pref.edit()
+ .putString(
+ MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton1),
+ currentViewID).commit();
+ } else if (newView == quickControl2)
{
quickControl2 = currentView;
- pref.edit().putString(MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton2), currentViewID).commit();
- }
- else if (newView == quickControl3)
+ pref.edit()
+ .putString(
+ MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton2),
+ currentViewID).commit();
+ } else if (newView == quickControl3)
{
quickControl3 = currentView;
- pref.edit().putString(MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton3), currentViewID).commit();
- }
- else if (newView == quickControl4)
+ pref.edit()
+ .putString(
+ MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton3),
+ currentViewID).commit();
+ } else if (newView == quickControl4)
{
quickControl4 = currentView;
- pref.edit().putString(MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton4), currentViewID).commit();
- }
- else
+ pref.edit()
+ .putString(
+ MainScreen.getInstance().getResources().getString(R.string.Preference_QuickControlButton4),
+ currentViewID).commit();
+ } else
{
if (currentView.getParent() != null)
((ViewGroup) currentView.getParent()).removeView(currentView);
@@ -3576,11 +3540,11 @@ public boolean onLongClick(View v)
if (modeSelectorVisible)
return true;
-
- if(shutterButton != v)
+
+ if (shutterButton != v)
{
changeCurrentQuickControl(v);
-
+
initQuickControlsMenu(v);
showQuickControlsSettings();
guiView.findViewById(R.id.topPanel).setVisibility(View.GONE);
@@ -3603,13 +3567,11 @@ public void onClick(View v)
String pluginID = it.next();
if (v == topMenuPluginButtons.get(pluginID))
{
- Plugin plugin = PluginManager.getInstance().getPlugin(
- pluginID);
+ Plugin plugin = PluginManager.getInstance().getPlugin(pluginID);
plugin.onQuickControlClick();
int icon_id = plugin.getQuickControlIconID();
- Drawable icon = MainScreen.getMainContext().getResources()
- .getDrawable(icon_id);
+ Drawable icon = MainScreen.getMainContext().getResources().getDrawable(icon_id);
((RotateImageView) v).setImageDrawable(icon);
initSettingsMenu();
@@ -3633,9 +3595,9 @@ public void onButtonClick(View button)
if (guiView.findViewById(R.id.hintLayout).getVisibility() == View.VISIBLE)
guiView.findViewById(R.id.hintLayout).setVisibility(View.INVISIBLE);
- if (guiView.findViewById(R.id.mode_help).getVisibility() == View.VISIBLE)
+ if (guiView.findViewById(R.id.mode_help).getVisibility() == View.VISIBLE)
guiView.findViewById(R.id.mode_help).setVisibility(View.INVISIBLE);
-
+
int id = button.getId();
if (lockControls && R.id.buttonShutter != id)
return;
@@ -3643,16 +3605,16 @@ public void onButtonClick(View button)
// 1. if quick settings slider visible - lock everything
// 2. if modes visible - allow only selectmode button
// 3. if change quick controls visible - allow only OK button
-
+
if (settingsControlsVisible || quickControlsChangeVisible
- || (modeSelectorVisible && (R.id.buttonSelectMode != id)))
+ || (modeSelectorVisible && (R.id.buttonSelectMode != id)))
{
// if change control visible and
if (quickControlsChangeVisible)
{
// quick control button pressed
- if ((button != quickControl1) && (button != quickControl2)
- && (button != quickControl3) && (button != quickControl4))
+ if ((button != quickControl1) && (button != quickControl2) && (button != quickControl3)
+ && (button != quickControl4))
closeQuickControlsSettings();
}
if (settingsControlsVisible)
@@ -3916,7 +3878,7 @@ public void onButtonClick(View button)
}
this.initSettingsMenu();
}
-
+
private boolean changeQuickControlIfVisible(View button)
{
if (quickControlsChangeVisible)
@@ -3926,70 +3888,69 @@ private boolean changeQuickControlIfVisible(View button)
showQuickControlsSettings();
return true;
}
-
+
return false;
}
private void setSceneMode(int newMode)
{
- if(newMode != -1 && sceneModeButtons.containsKey(newMode))
+ if (newMode != -1 && sceneModeButtons.containsKey(newMode))
{
CameraController.getInstance().setCameraSceneMode(newMode);
mSceneMode = newMode;
- }
- else if(sceneModeButtons.containsKey(CameraParameters.SCENE_MODE_AUTO))
+ } else if (sceneModeButtons.containsKey(CameraParameters.SCENE_MODE_AUTO))
{
CameraController.getInstance().setCameraSceneMode(CameraParameters.SCENE_MODE_AUTO);
- mSceneMode = CameraParameters.SCENE_MODE_AUTO;
- }
- else if(CameraController.getInstance().getSupportedSceneModes() != null)
+ mSceneMode = CameraParameters.SCENE_MODE_AUTO;
+ } else if (CameraController.getInstance().getSupportedSceneModes() != null)
{
- CameraController.getInstance().setCameraSceneMode(CameraController.getInstance().getSupportedSceneModes()[0]);
+ CameraController.getInstance().setCameraSceneMode(
+ CameraController.getInstance().getSupportedSceneModes()[0]);
mSceneMode = CameraController.getInstance().getSupportedSceneModes()[0];
}
// After change scene mode it may be changed other stuff such as
// flash, wb, focus mode.
// Need to get this information and update state of current
- // parameters.
+ // parameters.
int wbNew = CameraController.getInstance().getWBMode();
int flashNew = CameraController.getInstance().getFlashMode();
int focusNew = CameraController.getInstance().getFocusMode();
int isoNew = CameraController.getInstance().getISOMode();
-
+
// Save new params value
- if(wbNew != -1 && wbModeButtons.containsKey(wbNew))
+ if (wbNew != -1 && wbModeButtons.containsKey(wbNew))
mWB = wbNew;
- else if(wbModeButtons.containsKey(CameraParameters.WB_MODE_AUTO))
+ else if (wbModeButtons.containsKey(CameraParameters.WB_MODE_AUTO))
mWB = CameraParameters.WB_MODE_AUTO;
- else if(CameraController.getInstance().isWhiteBalanceSupported())
+ else if (CameraController.getInstance().isWhiteBalanceSupported())
mWB = CameraController.getInstance().getSupportedWhiteBalance()[0];
else
mWB = -1;
-
- if(focusNew != -1 && focusModeButtons.containsKey(focusNew))
+
+ if (focusNew != -1 && focusModeButtons.containsKey(focusNew))
mFocusMode = focusNew;
- else if(focusModeButtons.containsKey(CameraParameters.AF_MODE_AUTO))
+ else if (focusModeButtons.containsKey(CameraParameters.AF_MODE_AUTO))
mFocusMode = CameraParameters.AF_MODE_AUTO;
- else if(CameraController.getInstance().isFocusModeSupported())
+ else if (CameraController.getInstance().isFocusModeSupported())
mFocusMode = CameraController.getInstance().getSupportedFocusModes()[0];
else
mFocusMode = -1;
-
- if(flashNew != -1 && flashModeButtons.containsKey(flashNew))
+
+ if (flashNew != -1 && flashModeButtons.containsKey(flashNew))
mFlashMode = flashNew;
- else if(focusModeButtons.containsKey(CameraParameters.FLASH_MODE_AUTO))
+ else if (focusModeButtons.containsKey(CameraParameters.FLASH_MODE_AUTO))
mFlashMode = CameraParameters.FLASH_MODE_AUTO;
- else if(CameraController.getInstance().isFlashModeSupported())
+ else if (CameraController.getInstance().isFlashModeSupported())
mFlashMode = CameraController.getInstance().getSupportedFlashModes()[0];
else
mFlashMode = -1;
-
- if(isoNew != -1 && isoButtons.containsKey(isoNew))
+
+ if (isoNew != -1 && isoButtons.containsKey(isoNew))
mISO = isoNew;
- else if(isoButtons.containsKey(CameraParameters.ISO_AUTO))
+ else if (isoButtons.containsKey(CameraParameters.ISO_AUTO))
mISO = CameraParameters.ISO_AUTO;
- else if(CameraController.getInstance().getSupportedISO() != null)
+ else if (CameraController.getInstance().getSupportedISO() != null)
mISO = CameraController.getInstance().getSupportedISO()[0];
else
mISO = -1;
@@ -4011,8 +3972,7 @@ else if(CameraController.getInstance().getSupportedISO() != null)
but.setImageResource(icon_id);
preferences.edit().putInt(MainScreen.sWBModePref, mWB).commit();
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_WB_CHANGED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_WB_CHANGED);
}
if (mFocusMode != -1)
{
@@ -4027,22 +3987,21 @@ else if(CameraController.getInstance().getSupportedISO() != null)
Log.e("setSceneMode", "icons_focus.get exception: " + e.getMessage());
}
- preferences.edit().putInt(CameraController.isFrontCamera() ? MainScreen.sRearFocusModePref
+ preferences
+ .edit()
+ .putInt(CameraController.isFrontCamera() ? MainScreen.sRearFocusModePref
: MainScreen.sFrontFocusModePref, mFocusMode).commit();
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_FOCUS_CHANGED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_FOCUS_CHANGED);
}
if (mFlashMode != -1)
{
but = (RotateImageView) topMenuButtons.get(MODE_FLASH);
icon_id = ICONS_FLASH.get(mFlashMode);
but.setImageResource(icon_id);
- preferences.edit().putInt(MainScreen.sFlashModePref, mFlashMode)
- .commit();
+ preferences.edit().putInt(MainScreen.sFlashModePref, mFlashMode).commit();
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_FLASH_CHANGED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_FLASH_CHANGED);
}
if (mISO != -1)
{
@@ -4051,12 +4010,10 @@ else if(CameraController.getInstance().getSupportedISO() != null)
but.setImageResource(icon_id);
preferences.edit().putInt(MainScreen.sISOPref, mISO).commit();
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_ISO_CHANGED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_ISO_CHANGED);
}
preferences.edit().putInt(MainScreen.sSceneModePref, newMode).commit();
-
but = (RotateImageView) topMenuButtons.get(MODE_SCENE);
icon_id = ICONS_SCENE.get(mSceneMode);
but.setImageResource(icon_id);
@@ -4065,8 +4022,7 @@ else if(CameraController.getInstance().getSupportedISO() != null)
hideSecondaryMenus();
unselectPrimaryTopMenuButtons(-1);
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_SCENE_CHANGED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_SCENE_CHANGED);
}
private void setWhiteBalance(int newMode)
@@ -4076,9 +4032,9 @@ private void setWhiteBalance(int newMode)
if ((mSceneMode != CameraParameters.SCENE_MODE_AUTO || mWB != newMode)
&& CameraController.getInstance().isSceneModeSupported())
setSceneMode(CameraParameters.SCENE_MODE_AUTO);
-
+
CameraController.getInstance().setCameraWhiteBalance(newMode);
-
+
mWB = newMode;
setButtonSelected(wbModeButtons, mWB);
@@ -4093,24 +4049,26 @@ private void setWhiteBalance(int newMode)
hideSecondaryMenus();
unselectPrimaryTopMenuButtons(-1);
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_WB_CHANGED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_WB_CHANGED);
}
private void setFocusMode(int newMode)
{
- if (newMode != -1 )
+ if (newMode != -1)
{
if (mSceneMode != CameraParameters.SCENE_MODE_AUTO && mFocusMode != CameraParameters.AF_MODE_AUTO)
if (CameraController.getInstance().isSceneModeSupported())
setSceneMode(CameraParameters.SCENE_MODE_AUTO);
CameraController.getInstance().setCameraFocusMode(newMode);
-
+
mFocusMode = newMode;
setButtonSelected(focusModeButtons, mFocusMode);
- preferences.edit().putInt(CameraController.isFrontCamera() ? MainScreen.sRearFocusModePref : MainScreen.sFrontFocusModePref, newMode).commit();
+ preferences
+ .edit()
+ .putInt(CameraController.isFrontCamera() ? MainScreen.sRearFocusModePref
+ : MainScreen.sFrontFocusModePref, newMode).commit();
}
try
@@ -4123,14 +4081,13 @@ private void setFocusMode(int newMode)
e.printStackTrace();
Log.e("setFocusMode", "icons_focus.get exception: " + e.getMessage());
}
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_FOCUS_CHANGED);
+
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_FOCUS_CHANGED);
initSettingsMenu();
hideSecondaryMenus();
unselectPrimaryTopMenuButtons(-1);
-
+
MainScreen.setAutoFocusLock(false);
}
@@ -4157,8 +4114,7 @@ private void setFlashMode(int newMode)
hideSecondaryMenus();
unselectPrimaryTopMenuButtons(-1);
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_FLASH_CHANGED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_FLASH_CHANGED);
}
private void setISO(int newMode)
@@ -4184,10 +4140,9 @@ private void setISO(int newMode)
hideSecondaryMenus();
unselectPrimaryTopMenuButtons(-1);
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_ISO_CHANGED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_ISO_CHANGED);
}
-
+
private void setMeteringMode(int newMode)
{
if (newMode != -1 && mMeteringMode != newMode)
@@ -4227,21 +4182,23 @@ private void unselectPrimaryTopMenuButtons(int iTopMenuButtonSelected)
pressed_button.setSelected(true);
}
}
-
+
private int findTopMenuButtonIndex(View view)
{
Set keys = topMenuButtons.keySet();
Iterator it = keys.iterator();
Integer pressed_button = -1;
- while (it.hasNext()) {
+ while (it.hasNext())
+ {
Integer it_button = it.next();
View v = topMenuButtons.get(it_button);
- if (v == view) {
+ if (v == view)
+ {
pressed_button = it_button;
break;
}
}
-
+
return pressed_button;
}
@@ -4249,31 +4206,29 @@ private void topMenuButtonPressed(int iTopMenuButtonPressed)
{
Set keys = topMenuButtons.keySet();
Iterator it = keys.iterator();
- while (it.hasNext()) {
+ while (it.hasNext())
+ {
Integer it_button = it.next();
if (isTopMenuButtonEnabled(it_button))
- (topMenuButtons.get(it_button))
- .setBackgroundDrawable(MainScreen.getMainContext()
- .getResources().getDrawable(
- R.drawable.transparent_background));
+ (topMenuButtons.get(it_button)).setBackgroundDrawable(MainScreen.getMainContext().getResources()
+ .getDrawable(R.drawable.transparent_background));
}
if ((iTopMenuButtonPressed > -1 && isTopMenuButtonEnabled(iTopMenuButtonPressed))
- && topMenuButtons.containsKey(iTopMenuButtonPressed)) {
- RotateImageView pressed_button = (RotateImageView) topMenuButtons
- .get(iTopMenuButtonPressed);
- pressed_button
- .setBackgroundDrawable(MainScreen.getMainContext()
- .getResources()
- .getDrawable(
- R.drawable.almalence_gui_button_background_pressed));
+ && topMenuButtons.containsKey(iTopMenuButtonPressed))
+ {
+ RotateImageView pressed_button = (RotateImageView) topMenuButtons.get(iTopMenuButtonPressed);
+ pressed_button.setBackgroundDrawable(MainScreen.getMainContext().getResources()
+ .getDrawable(R.drawable.almalence_gui_button_background_pressed));
}
}
- public boolean isTopMenuButtonEnabled(int iTopMenuButtonKey) {
+ public boolean isTopMenuButtonEnabled(int iTopMenuButtonKey)
+ {
boolean isEnabled = false;
- switch (iTopMenuButtonKey) {
+ switch (iTopMenuButtonKey)
+ {
case MODE_SCENE:
if (isSceneEnabled)
isEnabled = true;
@@ -4301,7 +4256,7 @@ public boolean isTopMenuButtonEnabled(int iTopMenuButtonKey) {
case MODE_MET:
if (isMeteringEnabled)
isEnabled = true;
- break;
+ break;
case MODE_CAM:
if (isCameraChangeEnabled)
isEnabled = true;
@@ -4315,7 +4270,8 @@ public boolean isTopMenuButtonEnabled(int iTopMenuButtonKey) {
// Hide all pop-up layouts
@Override
- public void hideSecondaryMenus() {
+ public void hideSecondaryMenus()
+ {
if (!isSecondaryMenusVisible())
return;
@@ -4330,11 +4286,11 @@ public void hideSecondaryMenus() {
guiView.findViewById(R.id.modeLayout).setVisibility(View.GONE);
guiView.findViewById(R.id.vfLayout).setVisibility(View.GONE);
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_UNLOCKED);
}
- public boolean isSecondaryMenusVisible() {
+ public boolean isSecondaryMenusVisible()
+ {
if (guiView.findViewById(R.id.evLayout).getVisibility() == View.VISIBLE
|| guiView.findViewById(R.id.scenemodeLayout).getVisibility() == View.VISIBLE
|| guiView.findViewById(R.id.wbLayout).getVisibility() == View.VISIBLE
@@ -4347,25 +4303,22 @@ public boolean isSecondaryMenusVisible() {
}
// Decide what layout to show when some main's parameters button is clicked
- private void showParams(int iButton) {
+ private void showParams(int iButton)
+ {
DisplayMetrics metrics = new DisplayMetrics();
- MainScreen.getInstance().getWindowManager().getDefaultDisplay()
- .getMetrics(metrics);
+ MainScreen.getInstance().getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels;
int modeHeightByWidth = (int) (width / 3 - 5 * metrics.density);
- int modeHeightByDimen = Math.round(MainScreen.getInstance().getResources()
- .getDimension(R.dimen.gridImageSize)
- + MainScreen.getInstance().getResources().getDimension(
- R.dimen.gridTextLayoutHeight));
+ int modeHeightByDimen = Math.round(MainScreen.getInstance().getResources().getDimension(R.dimen.gridImageSize)
+ + MainScreen.getInstance().getResources().getDimension(R.dimen.gridTextLayoutHeight));
- int modeHeight = modeHeightByDimen > modeHeightByWidth ? modeHeightByWidth
- : modeHeightByDimen;
-
- AbsListView.LayoutParams params = new AbsListView.LayoutParams(
- LayoutParams.WRAP_CONTENT, modeHeight);
+ int modeHeight = modeHeightByDimen > modeHeightByWidth ? modeHeightByWidth : modeHeightByDimen;
+
+ AbsListView.LayoutParams params = new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT, modeHeight);
List views = null;
- switch (iButton) {
+ switch (iButton)
+ {
case MODE_SCENE:
views = activeScene;
break;
@@ -4388,32 +4341,32 @@ private void showParams(int iButton) {
break;
}
- if (views != null) {
- for (int i = 0; i < views.size(); i++) {
+ if (views != null)
+ {
+ for (int i = 0; i < views.size(); i++)
+ {
View param = views.get(i);
- if(param != null)
+ if (param != null)
param.setLayoutParams(params);
}
}
- switch (iButton) {
+ switch (iButton)
+ {
case MODE_EV:
guiView.findViewById(R.id.evLayout).setVisibility(View.VISIBLE);
break;
case MODE_SCENE:
- guiView.findViewById(R.id.scenemodeLayout).setVisibility(
- View.VISIBLE);
+ guiView.findViewById(R.id.scenemodeLayout).setVisibility(View.VISIBLE);
break;
case MODE_WB:
guiView.findViewById(R.id.wbLayout).setVisibility(View.VISIBLE);
break;
case MODE_FOCUS:
- guiView.findViewById(R.id.focusmodeLayout).setVisibility(
- View.VISIBLE);
+ guiView.findViewById(R.id.focusmodeLayout).setVisibility(View.VISIBLE);
break;
case MODE_FLASH:
- guiView.findViewById(R.id.flashmodeLayout).setVisibility(
- View.VISIBLE);
+ guiView.findViewById(R.id.flashmodeLayout).setVisibility(View.VISIBLE);
break;
case MODE_ISO:
guiView.findViewById(R.id.isoLayout).setVisibility(View.VISIBLE);
@@ -4427,28 +4380,30 @@ private void showParams(int iButton) {
quickControlsVisible = true;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_LOCKED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_LOCKED);
}
- private void setButtonSelected(Map buttonsList,
- int mode_id) {
+ private void setButtonSelected(Map buttonsList, int mode_id)
+ {
Set keys = buttonsList.keySet();
Iterator it = keys.iterator();
- while (it.hasNext()) {
+ while (it.hasNext())
+ {
int it_button = it.next();
((RelativeLayout) buttonsList.get(it_button)).setPressed(false);
}
- if (buttonsList.containsKey(mode_id)) {
- RelativeLayout pressed_button = (RelativeLayout) buttonsList
- .get(mode_id);
+ if (buttonsList.containsKey(mode_id))
+ {
+ RelativeLayout pressed_button = (RelativeLayout) buttonsList.get(mode_id);
pressed_button.setPressed(false);
}
}
- private void setCameraParameterValue(int iParameter, int sValue) {
- switch (iParameter) {
+ private void setCameraParameterValue(int iParameter, int sValue)
+ {
+ switch (iParameter)
+ {
case MODE_SCENE:
mSceneMode = sValue;
break;
@@ -4478,49 +4433,50 @@ private void setCameraParameterValue(int iParameter, int sValue) {
* controls from other plugins
*
***********************************************************************************/
- private void addInfoControl(View info_control) {
+ private void addInfoControl(View info_control)
+ {
// Calculate appropriate size of added plugin's view
android.widget.LinearLayout.LayoutParams viewLayoutParams = (android.widget.LinearLayout.LayoutParams) info_control
.getLayoutParams();
- viewLayoutParams = this.getTunedLinearLayoutParams(info_control,
- viewLayoutParams, iInfoViewMaxWidth, iInfoViewMaxHeight);
+ viewLayoutParams = this.getTunedLinearLayoutParams(info_control, viewLayoutParams, iInfoViewMaxWidth,
+ iInfoViewMaxHeight);
- ((LinearLayout) guiView.findViewById(R.id.infoLayout)).addView(
- info_control, viewLayoutParams);
+ ((LinearLayout) guiView.findViewById(R.id.infoLayout)).addView(info_control, viewLayoutParams);
}
// Public interface for all plugins
// Automatically decide where to put view and correct view's size if
// necessary
@Override
- protected void addPluginViews(Map views_map) {
+ protected void addPluginViews(Map views_map)
+ {
Set view_set = views_map.keySet();
Iterator it = view_set.iterator();
- while (it.hasNext()) {
-
- try {
+ while (it.hasNext())
+ {
+
+ try
+ {
View view = it.next();
Plugin.ViewfinderZone desire_zone = views_map.get(view);
-
+
android.widget.RelativeLayout.LayoutParams viewLayoutParams = (android.widget.RelativeLayout.LayoutParams) view
.getLayoutParams();
- viewLayoutParams = this.getTunedPluginLayoutParams(view,
- desire_zone, viewLayoutParams);
-
- if (viewLayoutParams == null) // No free space on plugin's layout
+ viewLayoutParams = this.getTunedPluginLayoutParams(view, desire_zone, viewLayoutParams);
+
+ if (viewLayoutParams == null) // No free space on plugin's
+ // layout
return;
-
+
view.setLayoutParams(viewLayoutParams);
if (desire_zone == Plugin.ViewfinderZone.VIEWFINDER_ZONE_FULLSCREEN
|| desire_zone == Plugin.ViewfinderZone.VIEWFINDER_ZONE_CENTER)
- ((RelativeLayout) guiView.findViewById(R.id.fullscreenLayout))
- .addView(view, 0,
- (ViewGroup.LayoutParams) viewLayoutParams);
+ ((RelativeLayout) guiView.findViewById(R.id.fullscreenLayout)).addView(view, 0,
+ (ViewGroup.LayoutParams) viewLayoutParams);
else
- ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout))
- .addView(view, viewLayoutParams);
- }
- catch (Exception e) {
+ ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout)).addView(view, viewLayoutParams);
+ } catch (Exception e)
+ {
e.printStackTrace();
Log.e("Almalence GUI", "addPluginViews exception: " + e.getMessage());
}
@@ -4528,11 +4484,11 @@ protected void addPluginViews(Map views_map) {
}
@Override
- public void addViewQuick(View view, Plugin.ViewfinderZone desire_zone) {
+ public void addViewQuick(View view, Plugin.ViewfinderZone desire_zone)
+ {
android.widget.RelativeLayout.LayoutParams viewLayoutParams = (android.widget.RelativeLayout.LayoutParams) view
.getLayoutParams();
- viewLayoutParams = this.getTunedPluginLayoutParams(view, desire_zone,
- viewLayoutParams);
+ viewLayoutParams = this.getTunedPluginLayoutParams(view, desire_zone, viewLayoutParams);
if (viewLayoutParams == null) // No free space on plugin's layout
return;
@@ -4540,74 +4496,71 @@ public void addViewQuick(View view, Plugin.ViewfinderZone desire_zone) {
view.setLayoutParams(viewLayoutParams);
if (desire_zone == Plugin.ViewfinderZone.VIEWFINDER_ZONE_FULLSCREEN
|| desire_zone == Plugin.ViewfinderZone.VIEWFINDER_ZONE_CENTER)
- ((RelativeLayout) guiView.findViewById(R.id.fullscreenLayout))
- .addView(view, 0, (ViewGroup.LayoutParams) viewLayoutParams);
+ ((RelativeLayout) guiView.findViewById(R.id.fullscreenLayout)).addView(view, 0,
+ (ViewGroup.LayoutParams) viewLayoutParams);
else
- ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout))
- .addView(view, viewLayoutParams);
+ ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout)).addView(view, viewLayoutParams);
}
@Override
- protected void removePluginViews(Map views_map) {
+ protected void removePluginViews(Map views_map)
+ {
Set view_set = views_map.keySet();
Iterator it = view_set.iterator();
- while (it.hasNext()) {
+ while (it.hasNext())
+ {
View view = it.next();
if (view.getParent() != null)
((ViewGroup) view.getParent()).removeView(view);
- ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout))
- .removeView(view);
+ ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout)).removeView(view);
}
}
@Override
- public void removeViewQuick(View view) {
+ public void removeViewQuick(View view)
+ {
if (view == null)
return;
if (view.getParent() != null)
((ViewGroup) view.getParent()).removeView(view);
- ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout))
- .removeView(view);
+ ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout)).removeView(view);
}
/* Private section for adding plugin's views */
// INFO VIEW SECTION
@Override
- protected void addInfoView(View view,
- android.widget.LinearLayout.LayoutParams viewLayoutParams) {
- if (((LinearLayout) guiView.findViewById(R.id.infoLayout))
- .getChildCount() != 0)
+ protected void addInfoView(View view, android.widget.LinearLayout.LayoutParams viewLayoutParams)
+ {
+ if (((LinearLayout) guiView.findViewById(R.id.infoLayout)).getChildCount() != 0)
viewLayoutParams.topMargin = 4;
- ((LinearLayout) guiView.findViewById(R.id.infoLayout)).addView(view,
- viewLayoutParams);
+ ((LinearLayout) guiView.findViewById(R.id.infoLayout)).addView(view, viewLayoutParams);
}
@Override
- protected void removeInfoView(View view) {
+ protected void removeInfoView(View view)
+ {
if (view.getParent() != null)
((ViewGroup) view.getParent()).removeView(view);
((LinearLayout) guiView.findViewById(R.id.infoLayout)).removeView(view);
}
- protected boolean isAnyViewOnViewfinder() {
- RelativeLayout pluginsLayout = (RelativeLayout) MainScreen.getInstance()
- .findViewById(R.id.pluginsLayout);
- LinearLayout infoLayout = (LinearLayout) MainScreen.getInstance()
- .findViewById(R.id.infoLayout);
- RelativeLayout fullScreenLayout = (RelativeLayout) MainScreen.getInstance()
- .findViewById(R.id.fullscreenLayout);
-
- return pluginsLayout.getChildCount() > 0
- || infoLayout.getChildCount() > 0
+ protected boolean isAnyViewOnViewfinder()
+ {
+ RelativeLayout pluginsLayout = (RelativeLayout) MainScreen.getInstance().findViewById(R.id.pluginsLayout);
+ LinearLayout infoLayout = (LinearLayout) MainScreen.getInstance().findViewById(R.id.infoLayout);
+ RelativeLayout fullScreenLayout = (RelativeLayout) MainScreen.getInstance().findViewById(R.id.fullscreenLayout);
+
+ return pluginsLayout.getChildCount() > 0 || infoLayout.getChildCount() > 0
|| fullScreenLayout.getChildCount() > 0;
}
// controls if info about new mode shown or not. to prevent from double info
- private void initModeList() {
+ private void initModeList()
+ {
modeViews.clear();
buttonModeViewAssoc.clear();
@@ -4615,38 +4568,36 @@ private void initModeList() {
Iterator it = hash.iterator();
int mode_number = 0;
- while (it.hasNext()) {
+ while (it.hasNext())
+ {
Mode tmp = it.next();
LayoutInflater inflator = MainScreen.getInstance().getLayoutInflater();
- View mode = inflator.inflate(
- R.layout.gui_almalence_select_mode_grid_element, null,
- false);
+ View mode = inflator.inflate(R.layout.gui_almalence_select_mode_grid_element, null, false);
// set some mode icon
- ((ImageView) mode.findViewById(R.id.modeImage))
- .setImageResource(MainScreen.getInstance().getResources()
- .getIdentifier(tmp.icon, "drawable",
- MainScreen.getInstance().getPackageName()));
+ ((ImageView) mode.findViewById(R.id.modeImage)).setImageResource(MainScreen.getInstance().getResources()
+ .getIdentifier(tmp.icon, "drawable", MainScreen.getInstance().getPackageName()));
- int id = MainScreen.getInstance().getResources().getIdentifier(tmp.modeName,
- "string", MainScreen.getInstance().getPackageName());
+ int id = MainScreen.getInstance().getResources()
+ .getIdentifier(tmp.modeName, "string", MainScreen.getInstance().getPackageName());
String modename = MainScreen.getInstance().getResources().getString(id);
((TextView) mode.findViewById(R.id.modeText)).setText(modename);
- if (mode_number==0)
- mode.setOnTouchListener(new OnTouchListener()
- {
- @Override
- public boolean onTouch(View v, MotionEvent event)
+ if (mode_number == 0)
+ mode.setOnTouchListener(new OnTouchListener()
{
- if(event.getAction() == MotionEvent.ACTION_CANCEL)// && isFirstMode)
+ @Override
+ public boolean onTouch(View v, MotionEvent event)
{
- return changeMode(v);
- }
+ if (event.getAction() == MotionEvent.ACTION_CANCEL)// &&
+ // isFirstMode)
+ {
+ return changeMode(v);
+ }
return false;
- }
-
- });
+ }
+
+ });
mode.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
@@ -4657,18 +4608,19 @@ public void onClick(View v)
buttonModeViewAssoc.put(mode, tmp.modeID);
modeViews.add(mode);
- //select active mode in grid with frame
- if (PluginManager.getInstance().getActiveModeID() == tmp.modeID) {
+ // select active mode in grid with frame
+ if (PluginManager.getInstance().getActiveModeID() == tmp.modeID)
+ {
mode.findViewById(R.id.modeSelectLayout2).setBackgroundResource(
R.drawable.thumbnail_background_selected_inner);
}
-
+
mode_number++;
}
modeAdapter.Elements = modeViews;
}
-
+
private boolean changeMode(View v)
{
hideModeList();
@@ -4691,137 +4643,107 @@ private boolean changeMode(View v)
PluginManager.getInstance().onPause(true);
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
MainScreen.getInstance().startActivity(intent);
- return true;
+ return true;
}
}
-
+
//
-
- new CountDownTimer(100, 100) {
- public void onTick(long millisUntilFinished) {
- //Not used
+ // -+- -->
+
+ new CountDownTimer(100, 100)
+ {
+ public void onTick(long millisUntilFinished)
+ {
+ // Not used
}
- public void onFinish() {
- PluginManager.getInstance().switchMode(
- tmpActiveMode);
+ public void onFinish()
+ {
+ PluginManager.getInstance().switchMode(tmpActiveMode);
}
}.start();
// set modes icon inside mode selection icon
Bitmap bm = null;
- Bitmap iconBase = BitmapFactory.decodeResource(
- MainScreen.getMainContext().getResources(),
+ Bitmap iconBase = BitmapFactory.decodeResource(MainScreen.getMainContext().getResources(),
R.drawable.gui_almalence_select_mode);
Bitmap iconOverlay = BitmapFactory.decodeResource(
MainScreen.getMainContext().getResources(),
- MainScreen.getInstance().getResources().getIdentifier(
- mode.icon, "drawable",
- MainScreen.getInstance().getPackageName()));
- iconOverlay = Bitmap.createScaledBitmap(iconOverlay,
- (int) (iconBase.getWidth() / 1.8),
+ MainScreen.getInstance().getResources()
+ .getIdentifier(mode.icon, "drawable", MainScreen.getInstance().getPackageName()));
+ iconOverlay = Bitmap.createScaledBitmap(iconOverlay, (int) (iconBase.getWidth() / 1.8),
(int) (iconBase.getWidth() / 1.8), false);
bm = mergeImage(iconBase, iconOverlay);
- bm = Bitmap
- .createScaledBitmap(
- bm,
- (int) (MainScreen.getMainContext()
- .getResources()
- .getDimension(R.dimen.mainButtonHeightSelect)),
- (int) (MainScreen.getMainContext()
- .getResources()
- .getDimension(R.dimen.mainButtonHeightSelect)),
- false);
- ((RotateImageView) guiView
- .findViewById(R.id.buttonSelectMode))
- .setImageBitmap(bm);
-
- int rid = MainScreen.getInstance().getResources().getIdentifier(
- tmpActiveMode.howtoText, "string",
- MainScreen.getInstance().getPackageName());
+ bm = Bitmap.createScaledBitmap(bm,
+ (int) (MainScreen.getMainContext().getResources().getDimension(R.dimen.mainButtonHeightSelect)),
+ (int) (MainScreen.getMainContext().getResources().getDimension(R.dimen.mainButtonHeightSelect)), false);
+ ((RotateImageView) guiView.findViewById(R.id.buttonSelectMode)).setImageBitmap(bm);
+
+ int rid = MainScreen.getInstance().getResources()
+ .getIdentifier(tmpActiveMode.howtoText, "string", MainScreen.getInstance().getPackageName());
String howto = "";
if (rid != 0)
howto = MainScreen.getInstance().getResources().getString(rid);
// show toast on mode changed
- showToast(
- v,
- Toast.LENGTH_SHORT,
- Gravity.CENTER,
- ((TextView) v.findViewById(R.id.modeText))
- .getText()
- + " "
- + MainScreen.getInstance().getResources().getString(
- R.string.almalence_gui_selected)
- + (tmpActiveMode.howtoText.isEmpty() ? ""
- : "\n") + howto, false, true);
+ showToast(v, Toast.LENGTH_SHORT, Gravity.CENTER, ((TextView) v.findViewById(R.id.modeText)).getText() + " "
+ + MainScreen.getInstance().getResources().getString(R.string.almalence_gui_selected)
+ + (tmpActiveMode.howtoText.isEmpty() ? "" : "\n") + howto, false, true);
return false;
}
-
- public void showToast(final View v, final int showLength,
- final int gravity, final String toastText,
- final boolean withBackground, final boolean startOffset) {
- MainScreen.getInstance().runOnUiThread(new Runnable() {
+ public void showToast(final View v, final int showLength, final int gravity, final String toastText,
+ final boolean withBackground, final boolean startOffset)
+ {
+ MainScreen.getInstance().runOnUiThread(new Runnable()
+ {
@Override
- public void run() {
- final RelativeLayout modeLayout = (RelativeLayout) guiView
- .findViewById(R.id.changeModeToast);
+ public void run()
+ {
+ final RelativeLayout modeLayout = (RelativeLayout) guiView.findViewById(R.id.changeModeToast);
DisplayMetrics metrics = new DisplayMetrics();
- MainScreen.getInstance().getWindowManager().getDefaultDisplay()
- .getMetrics(metrics);
+ MainScreen.getInstance().getWindowManager().getDefaultDisplay().getMetrics(metrics);
int screen_height = metrics.heightPixels;
int screen_width = metrics.widthPixels;
- RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) modeLayout
- .getLayoutParams();
+ RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) modeLayout.getLayoutParams();
int[] rules = lp.getRules();
- if (gravity == Gravity.CENTER
- || (mDeviceOrientation != 0 && mDeviceOrientation != 360))
+ if (gravity == Gravity.CENTER || (mDeviceOrientation != 0 && mDeviceOrientation != 360))
lp.addRule(RelativeLayout.CENTER_IN_PARENT, 1);
- else {
+ else
+ {
rules[RelativeLayout.CENTER_IN_PARENT] = 0;
lp.addRule(RelativeLayout.CENTER_HORIZONTAL, 1);
View shutter = guiView.findViewById(R.id.buttonShutter);
- int shutter_height = shutter.getHeight()
- + shutter.getPaddingBottom();
+ int shutter_height = shutter.getHeight() + shutter.getPaddingBottom();
lp.setMargins(
0,
(int) (screen_height
- - MainScreen.getInstance().getResources()
- .getDimension(
- R.dimen.paramsLayoutHeight) - shutter_height),
+ - MainScreen.getInstance().getResources().getDimension(R.dimen.paramsLayoutHeight) - shutter_height),
0, shutter_height);
}
if (withBackground)
- modeLayout.setBackgroundDrawable(MainScreen.getInstance()
- .getResources().getDrawable(
- R.drawable.almalence_gui_toast_background));
+ modeLayout.setBackgroundDrawable(MainScreen.getInstance().getResources()
+ .getDrawable(R.drawable.almalence_gui_toast_background));
else
modeLayout.setBackgroundDrawable(null);
- RotateImageView imgView = (RotateImageView) modeLayout
- .findViewById(R.id.selectModeIcon);
- TextView text = (TextView) modeLayout
- .findViewById(R.id.selectModeText);
-
- if (v != null) {
- RelativeLayout.LayoutParams pm = (RelativeLayout.LayoutParams) imgView
- .getLayoutParams();
- pm.width = (int) MainScreen.getInstance().getResources()
- .getDimension(R.dimen.mainButtonHeight);
- pm.height = (int) MainScreen.getInstance().getResources()
- .getDimension(R.dimen.mainButtonHeight);
- imgView.setImageDrawable(((ImageView) v
- .findViewById(R.id.modeImage)).getDrawable());
- } else {
- RelativeLayout.LayoutParams pm = (RelativeLayout.LayoutParams) imgView
- .getLayoutParams();
+ RotateImageView imgView = (RotateImageView) modeLayout.findViewById(R.id.selectModeIcon);
+ TextView text = (TextView) modeLayout.findViewById(R.id.selectModeText);
+
+ if (v != null)
+ {
+ RelativeLayout.LayoutParams pm = (RelativeLayout.LayoutParams) imgView.getLayoutParams();
+ pm.width = (int) MainScreen.getInstance().getResources().getDimension(R.dimen.mainButtonHeight);
+ pm.height = (int) MainScreen.getInstance().getResources().getDimension(R.dimen.mainButtonHeight);
+ imgView.setImageDrawable(((ImageView) v.findViewById(R.id.modeImage)).getDrawable());
+ } else
+ {
+ RelativeLayout.LayoutParams pm = (RelativeLayout.LayoutParams) imgView.getLayoutParams();
pm.width = 0;
pm.height = 0;
}
@@ -4837,43 +4759,49 @@ public void run() {
visible_alpha.setRepeatCount(0);
final Animation invisible_alpha = new AlphaAnimation(1, 0);
- invisible_alpha
- .setStartOffset(showLength == Toast.LENGTH_SHORT ? 1000
- : 3000);
+ invisible_alpha.setStartOffset(showLength == Toast.LENGTH_SHORT ? 1000 : 3000);
invisible_alpha.setDuration(1000);
invisible_alpha.setRepeatCount(0);
- visible_alpha.setAnimationListener(new AnimationListener() {
+ visible_alpha.setAnimationListener(new AnimationListener()
+ {
@Override
- public void onAnimationEnd(Animation animation) {
+ public void onAnimationEnd(Animation animation)
+ {
modeLayout.startAnimation(invisible_alpha);
}
@Override
- public void onAnimationRepeat(Animation animation) {
- //Not used
+ public void onAnimationRepeat(Animation animation)
+ {
+ // Not used
}
@Override
- public void onAnimationStart(Animation animation) {
- //Not used
+ public void onAnimationStart(Animation animation)
+ {
+ // Not used
}
});
- invisible_alpha.setAnimationListener(new AnimationListener() {
+ invisible_alpha.setAnimationListener(new AnimationListener()
+ {
@Override
- public void onAnimationEnd(Animation animation) {
+ public void onAnimationEnd(Animation animation)
+ {
modeLayout.setVisibility(View.GONE);
}
@Override
- public void onAnimationRepeat(Animation animation) {
- //Not used
+ public void onAnimationRepeat(Animation animation)
+ {
+ // Not used
}
@Override
- public void onAnimationStart(Animation animation) {
- //Not used
+ public void onAnimationStart(Animation animation)
+ {
+ // Not used
}
});
@@ -4886,12 +4814,12 @@ public void onAnimationStart(Animation animation) {
}
// helper function to draw one bitmap on another
- private Bitmap mergeImage(Bitmap base, Bitmap overlay) {
+ private Bitmap mergeImage(Bitmap base, Bitmap overlay)
+ {
int adWDelta = (int) (base.getWidth() - overlay.getWidth()) / 2;
int adHDelta = (int) (base.getHeight() - overlay.getHeight()) / 2;
- Bitmap mBitmap = Bitmap.createBitmap(base.getWidth(), base.getHeight(),
- Config.ARGB_8888);
+ Bitmap mBitmap = Bitmap.createBitmap(base.getWidth(), base.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(mBitmap);
canvas.drawBitmap(base, 0, 0, null);
canvas.drawBitmap(overlay, adWDelta, adHDelta, null);
@@ -4901,12 +4829,13 @@ private Bitmap mergeImage(Bitmap base, Bitmap overlay) {
// Supplementary methods to find suitable size for plugin's view
// For LINEARLAYOUT
- private android.widget.RelativeLayout.LayoutParams getTunedRelativeLayoutParams(
- View view, android.widget.RelativeLayout.LayoutParams currParams,
- int goodWidth, int goodHeight) {
+ private android.widget.RelativeLayout.LayoutParams getTunedRelativeLayoutParams(View view,
+ android.widget.RelativeLayout.LayoutParams currParams, int goodWidth, int goodHeight)
+ {
int viewHeight, viewWidth;
- if (currParams != null) {
+ if (currParams != null)
+ {
viewHeight = currParams.height;
viewWidth = currParams.width;
@@ -4920,9 +4849,9 @@ private android.widget.RelativeLayout.LayoutParams getTunedRelativeLayoutParams(
currParams.height = viewHeight;
view.setLayoutParams(currParams);
- } else {
- currParams = new android.widget.RelativeLayout.LayoutParams(
- goodWidth, goodHeight);
+ } else
+ {
+ currParams = new android.widget.RelativeLayout.LayoutParams(goodWidth, goodHeight);
view.setLayoutParams(currParams);
}
@@ -4930,10 +4859,11 @@ private android.widget.RelativeLayout.LayoutParams getTunedRelativeLayoutParams(
}
// For RELATIVELAYOUT
- private android.widget.LinearLayout.LayoutParams getTunedLinearLayoutParams(
- View view, android.widget.LinearLayout.LayoutParams currParams,
- int goodWidth, int goodHeight) {
- if (currParams != null) {
+ private android.widget.LinearLayout.LayoutParams getTunedLinearLayoutParams(View view,
+ android.widget.LinearLayout.LayoutParams currParams, int goodWidth, int goodHeight)
+ {
+ if (currParams != null)
+ {
int viewHeight = currParams.height;
int viewWidth = currParams.width;
@@ -4947,9 +4877,9 @@ private android.widget.LinearLayout.LayoutParams getTunedLinearLayoutParams(
currParams.height = viewHeight;
view.setLayoutParams(currParams);
- } else {
- currParams = new android.widget.LinearLayout.LayoutParams(
- goodWidth, goodHeight);
+ } else
+ {
+ currParams = new android.widget.LinearLayout.LayoutParams(goodWidth, goodHeight);
view.setLayoutParams(currParams);
}
@@ -4964,134 +4894,140 @@ private android.widget.LinearLayout.LayoutParams getTunedLinearLayoutParams(
* >>>>>>>>> BEGIN
***********************************************************************************************/
- protected Plugin.ViewfinderZone[] zones = {
- Plugin.ViewfinderZone.VIEWFINDER_ZONE_TOP_LEFT,
- Plugin.ViewfinderZone.VIEWFINDER_ZONE_TOP_RIGHT,
- Plugin.ViewfinderZone.VIEWFINDER_ZONE_CENTER_RIGHT,
- Plugin.ViewfinderZone.VIEWFINDER_ZONE_BOTTOM_RIGHT,
- Plugin.ViewfinderZone.VIEWFINDER_ZONE_BOTTOM_LEFT,
+ protected Plugin.ViewfinderZone[] zones = { Plugin.ViewfinderZone.VIEWFINDER_ZONE_TOP_LEFT,
+ Plugin.ViewfinderZone.VIEWFINDER_ZONE_TOP_RIGHT, Plugin.ViewfinderZone.VIEWFINDER_ZONE_CENTER_RIGHT,
+ Plugin.ViewfinderZone.VIEWFINDER_ZONE_BOTTOM_RIGHT, Plugin.ViewfinderZone.VIEWFINDER_ZONE_BOTTOM_LEFT,
Plugin.ViewfinderZone.VIEWFINDER_ZONE_CENTER_LEFT };
- protected android.widget.RelativeLayout.LayoutParams getTunedPluginLayoutParams(
- View view, Plugin.ViewfinderZone desire_zone,
- android.widget.RelativeLayout.LayoutParams currParams) {
+ protected android.widget.RelativeLayout.LayoutParams getTunedPluginLayoutParams(View view,
+ Plugin.ViewfinderZone desire_zone, android.widget.RelativeLayout.LayoutParams currParams)
+ {
int left = 0, right = 0, top = 0, bottom = 0;
- RelativeLayout pluginLayout = (RelativeLayout) MainScreen.getInstance()
- .findViewById(R.id.pluginsLayout);
+ RelativeLayout pluginLayout = (RelativeLayout) MainScreen.getInstance().findViewById(R.id.pluginsLayout);
if (currParams == null)
- currParams = new android.widget.RelativeLayout.LayoutParams(
- getMinPluginViewWidth(), getMinPluginViewHeight());
+ currParams = new android.widget.RelativeLayout.LayoutParams(getMinPluginViewWidth(),
+ getMinPluginViewHeight());
- switch (desire_zone) {
- case VIEWFINDER_ZONE_TOP_LEFT: {
- left = 0;
- right = currParams.width;
- top = 0;
- bottom = currParams.height;
+ switch (desire_zone)
+ {
+ case VIEWFINDER_ZONE_TOP_LEFT:
+ {
+ left = 0;
+ right = currParams.width;
+ top = 0;
+ bottom = currParams.height;
- currParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
- currParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
- }
+ }
break;
- case VIEWFINDER_ZONE_TOP_RIGHT: {
- left = pluginLayout.getWidth() - currParams.width;
- right = pluginLayout.getWidth();
- top = 0;
- bottom = currParams.height;
+ case VIEWFINDER_ZONE_TOP_RIGHT:
+ {
+ left = pluginLayout.getWidth() - currParams.width;
+ right = pluginLayout.getWidth();
+ top = 0;
+ bottom = currParams.height;
- currParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
- currParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- }
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ }
break;
- case VIEWFINDER_ZONE_CENTER_LEFT: {
- left = 0;
- right = currParams.width;
- top = pluginLayout.getHeight() / 2 - currParams.height / 2;
- bottom = pluginLayout.getHeight() / 2 + currParams.height / 2;
+ case VIEWFINDER_ZONE_CENTER_LEFT:
+ {
+ left = 0;
+ right = currParams.width;
+ top = pluginLayout.getHeight() / 2 - currParams.height / 2;
+ bottom = pluginLayout.getHeight() / 2 + currParams.height / 2;
- currParams.addRule(RelativeLayout.CENTER_VERTICAL);
- currParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
- }
+ currParams.addRule(RelativeLayout.CENTER_VERTICAL);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
+ }
break;
- case VIEWFINDER_ZONE_CENTER_RIGHT: {
- left = pluginLayout.getWidth() - currParams.width;
- right = pluginLayout.getWidth();
- top = pluginLayout.getHeight() / 2 - currParams.height / 2;
- bottom = pluginLayout.getHeight() / 2 + currParams.height / 2;
+ case VIEWFINDER_ZONE_CENTER_RIGHT:
+ {
+ left = pluginLayout.getWidth() - currParams.width;
+ right = pluginLayout.getWidth();
+ top = pluginLayout.getHeight() / 2 - currParams.height / 2;
+ bottom = pluginLayout.getHeight() / 2 + currParams.height / 2;
- currParams.addRule(RelativeLayout.CENTER_VERTICAL);
- currParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- }
+ currParams.addRule(RelativeLayout.CENTER_VERTICAL);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ }
break;
- case VIEWFINDER_ZONE_BOTTOM_LEFT: {
- left = 0;
- right = currParams.width;
- top = pluginLayout.getHeight() - currParams.height;
- bottom = pluginLayout.getHeight();
+ case VIEWFINDER_ZONE_BOTTOM_LEFT:
+ {
+ left = 0;
+ right = currParams.width;
+ top = pluginLayout.getHeight() - currParams.height;
+ bottom = pluginLayout.getHeight();
- currParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
- currParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
- }
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
+ }
break;
- case VIEWFINDER_ZONE_BOTTOM_RIGHT: {
- left = pluginLayout.getWidth() - currParams.width;
- right = pluginLayout.getWidth();
- top = pluginLayout.getHeight() - currParams.height;
- bottom = pluginLayout.getHeight();
+ case VIEWFINDER_ZONE_BOTTOM_RIGHT:
+ {
+ left = pluginLayout.getWidth() - currParams.width;
+ right = pluginLayout.getWidth();
+ top = pluginLayout.getHeight() - currParams.height;
+ bottom = pluginLayout.getHeight();
- currParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
- currParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- }
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ }
break;
- case VIEWFINDER_ZONE_FULLSCREEN: {
- currParams.width = MainScreen.getInstance().getPreviewSize() != null ? MainScreen.getInstance()
- .getPreviewSize().getWidth() : 0;
- currParams.height = MainScreen.getInstance().getPreviewSize() != null ? MainScreen.getInstance()
- .getPreviewSize().getHeight() : 0;
- currParams.addRule(RelativeLayout.CENTER_IN_PARENT);
- return currParams;
- }
- case VIEWFINDER_ZONE_CENTER: {
- if (currParams.width > iCenterViewMaxWidth)
- currParams.width = iCenterViewMaxWidth;
+ case VIEWFINDER_ZONE_FULLSCREEN:
+ {
+ currParams.width = MainScreen.getInstance().getPreviewSize() != null ? MainScreen.getInstance()
+ .getPreviewSize().getWidth() : 0;
+ currParams.height = MainScreen.getInstance().getPreviewSize() != null ? MainScreen.getInstance()
+ .getPreviewSize().getHeight() : 0;
+ currParams.addRule(RelativeLayout.CENTER_IN_PARENT);
+ return currParams;
+ }
+ case VIEWFINDER_ZONE_CENTER:
+ {
+ if (currParams.width > iCenterViewMaxWidth)
+ currParams.width = iCenterViewMaxWidth;
- if (currParams.height > iCenterViewMaxHeight)
- currParams.height = iCenterViewMaxHeight;
+ if (currParams.height > iCenterViewMaxHeight)
+ currParams.height = iCenterViewMaxHeight;
- currParams.addRule(RelativeLayout.CENTER_IN_PARENT);
- return currParams;
- }
+ currParams.addRule(RelativeLayout.CENTER_IN_PARENT);
+ return currParams;
+ }
default:
break;
}
- return findFreeSpaceOnLayout(new Rect(left, top, right, bottom),
- currParams, desire_zone);
+ return findFreeSpaceOnLayout(new Rect(left, top, right, bottom), currParams, desire_zone);
}
- protected android.widget.RelativeLayout.LayoutParams findFreeSpaceOnLayout(
- Rect currRect,
- android.widget.RelativeLayout.LayoutParams currParams,
- Plugin.ViewfinderZone currZone) {
+ protected android.widget.RelativeLayout.LayoutParams findFreeSpaceOnLayout(Rect currRect,
+ android.widget.RelativeLayout.LayoutParams currParams, Plugin.ViewfinderZone currZone)
+ {
boolean isFree = true;
Rect childRect;
View pluginLayout = MainScreen.getInstance().findViewById(R.id.pluginsLayout);
// Looking in all zones at clockwise direction for free place
- for (int j = Plugin.ViewfinderZone.getInt(currZone), counter = 0; j < zones.length; j++, counter++) {
+ for (int j = Plugin.ViewfinderZone.getInt(currZone), counter = 0; j < zones.length; j++, counter++)
+ {
isFree = true;
// Check intersections with already added views
- for (int i = 0; i < ((ViewGroup) pluginLayout).getChildCount(); ++i) {
+ for (int i = 0; i < ((ViewGroup) pluginLayout).getChildCount(); ++i)
+ {
View nextChild = ((ViewGroup) pluginLayout).getChildAt(i);
currRect = getPluginViewRectInZone(currParams, zones[j]);
childRect = getPluginViewRect(nextChild);
- if (currRect.intersect(childRect)) {
+ if (currRect.intersect(childRect))
+ {
isFree = false;
break;
}
@@ -5101,41 +5037,49 @@ protected android.widget.RelativeLayout.LayoutParams findFreeSpaceOnLayout(
{
if (currZone == zones[j]) // Current zone is free
return currParams;
- else {
+ else
+ {
int[] rules = currParams.getRules();
for (int i = 0; i < rules.length; i++)
currParams.addRule(i, 0);
- switch (zones[j]) {
- case VIEWFINDER_ZONE_TOP_LEFT: {
- currParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
- currParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
- }
+ switch (zones[j])
+ {
+ case VIEWFINDER_ZONE_TOP_LEFT:
+ {
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
+ }
break;
- case VIEWFINDER_ZONE_TOP_RIGHT: {
- currParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
- currParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- }
+ case VIEWFINDER_ZONE_TOP_RIGHT:
+ {
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ }
break;
- case VIEWFINDER_ZONE_CENTER_LEFT: {
- currParams.addRule(RelativeLayout.CENTER_VERTICAL);
- currParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
- }
+ case VIEWFINDER_ZONE_CENTER_LEFT:
+ {
+ currParams.addRule(RelativeLayout.CENTER_VERTICAL);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
+ }
break;
- case VIEWFINDER_ZONE_CENTER_RIGHT: {
- currParams.addRule(RelativeLayout.CENTER_VERTICAL);
- currParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- }
+ case VIEWFINDER_ZONE_CENTER_RIGHT:
+ {
+ currParams.addRule(RelativeLayout.CENTER_VERTICAL);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ }
break;
- case VIEWFINDER_ZONE_BOTTOM_LEFT: {
- currParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
- currParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
- }
+ case VIEWFINDER_ZONE_BOTTOM_LEFT:
+ {
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
+ }
break;
- case VIEWFINDER_ZONE_BOTTOM_RIGHT: {
- currParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
- currParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- }
+ case VIEWFINDER_ZONE_BOTTOM_RIGHT:
+ {
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
+ currParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
+ }
break;
default:
break;
@@ -5143,7 +5087,8 @@ protected android.widget.RelativeLayout.LayoutParams findFreeSpaceOnLayout(
return currParams;
}
- } else {
+ } else
+ {
if (counter == zones.length - 1) // Already looked in all zones
// and they are all full
return null;
@@ -5157,12 +5102,11 @@ protected android.widget.RelativeLayout.LayoutParams findFreeSpaceOnLayout(
return null;
}
- protected Rect getPluginViewRectInZone(
- RelativeLayout.LayoutParams currParams, Plugin.ViewfinderZone zone) {
+ protected Rect getPluginViewRectInZone(RelativeLayout.LayoutParams currParams, Plugin.ViewfinderZone zone)
+ {
int left = -1, right = -1, top = -1, bottom = -1;
- RelativeLayout pluginLayout = (RelativeLayout) MainScreen.getInstance()
- .findViewById(R.id.pluginsLayout);
+ RelativeLayout pluginLayout = (RelativeLayout) MainScreen.getInstance().findViewById(R.id.pluginsLayout);
int viewWidth = currParams.width;
int viewHeight = currParams.height;
@@ -5170,48 +5114,55 @@ protected Rect getPluginViewRectInZone(
int layoutWidth = pluginLayout.getWidth();
int layoutHeight = pluginLayout.getHeight();
- switch (zone) {
- case VIEWFINDER_ZONE_TOP_LEFT: {
- left = 0;
- right = viewWidth;
- top = 0;
- bottom = viewHeight;
- }
+ switch (zone)
+ {
+ case VIEWFINDER_ZONE_TOP_LEFT:
+ {
+ left = 0;
+ right = viewWidth;
+ top = 0;
+ bottom = viewHeight;
+ }
break;
- case VIEWFINDER_ZONE_TOP_RIGHT: {
- left = layoutWidth - viewWidth;
- right = layoutWidth;
- top = 0;
- bottom = viewHeight;
- }
+ case VIEWFINDER_ZONE_TOP_RIGHT:
+ {
+ left = layoutWidth - viewWidth;
+ right = layoutWidth;
+ top = 0;
+ bottom = viewHeight;
+ }
break;
- case VIEWFINDER_ZONE_CENTER_LEFT: {
- left = 0;
- right = viewWidth;
- top = layoutHeight / 2 - viewHeight / 2;
- bottom = layoutHeight / 2 + viewHeight / 2;
- }
+ case VIEWFINDER_ZONE_CENTER_LEFT:
+ {
+ left = 0;
+ right = viewWidth;
+ top = layoutHeight / 2 - viewHeight / 2;
+ bottom = layoutHeight / 2 + viewHeight / 2;
+ }
break;
- case VIEWFINDER_ZONE_CENTER_RIGHT: {
- left = layoutWidth - viewWidth;
- right = layoutWidth;
- top = layoutHeight / 2 - viewHeight / 2;
- bottom = layoutHeight / 2 + viewHeight / 2;
- }
+ case VIEWFINDER_ZONE_CENTER_RIGHT:
+ {
+ left = layoutWidth - viewWidth;
+ right = layoutWidth;
+ top = layoutHeight / 2 - viewHeight / 2;
+ bottom = layoutHeight / 2 + viewHeight / 2;
+ }
break;
- case VIEWFINDER_ZONE_BOTTOM_LEFT: {
- left = 0;
- right = viewWidth;
- top = layoutHeight - viewHeight;
- bottom = layoutHeight;
- }
+ case VIEWFINDER_ZONE_BOTTOM_LEFT:
+ {
+ left = 0;
+ right = viewWidth;
+ top = layoutHeight - viewHeight;
+ bottom = layoutHeight;
+ }
break;
- case VIEWFINDER_ZONE_BOTTOM_RIGHT: {
- left = layoutWidth - viewWidth;
- right = layoutWidth;
- top = layoutHeight - viewHeight;
- bottom = layoutHeight;
- }
+ case VIEWFINDER_ZONE_BOTTOM_RIGHT:
+ {
+ left = layoutWidth - viewWidth;
+ right = layoutWidth;
+ top = layoutHeight - viewHeight;
+ bottom = layoutHeight;
+ }
break;
default:
break;
@@ -5220,13 +5171,12 @@ protected Rect getPluginViewRectInZone(
return new Rect(left, top, right, bottom);
}
- protected Rect getPluginViewRect(View view) {
+ protected Rect getPluginViewRect(View view)
+ {
int left = -1, right = -1, top = -1, bottom = -1;
- RelativeLayout pluginLayout = (RelativeLayout) MainScreen.getInstance()
- .findViewById(R.id.pluginsLayout);
- RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) view
- .getLayoutParams();
+ RelativeLayout pluginLayout = (RelativeLayout) MainScreen.getInstance().findViewById(R.id.pluginsLayout);
+ RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) view.getLayoutParams();
int[] rules = lp.getRules();
int viewWidth = lp.width;
@@ -5236,22 +5186,27 @@ protected Rect getPluginViewRect(View view) {
int layoutHeight = pluginLayout.getHeight();
// Get X coordinates
- if (rules[RelativeLayout.ALIGN_PARENT_LEFT] != 0) {
+ if (rules[RelativeLayout.ALIGN_PARENT_LEFT] != 0)
+ {
left = 0;
right = viewWidth;
- } else if (rules[RelativeLayout.ALIGN_PARENT_RIGHT] != 0) {
+ } else if (rules[RelativeLayout.ALIGN_PARENT_RIGHT] != 0)
+ {
left = layoutWidth - viewWidth;
right = layoutWidth;
}
// Get Y coordinates
- if (rules[RelativeLayout.ALIGN_PARENT_TOP] != 0) {
+ if (rules[RelativeLayout.ALIGN_PARENT_TOP] != 0)
+ {
top = 0;
bottom = viewHeight;
- } else if (rules[RelativeLayout.ALIGN_PARENT_BOTTOM] != 0) {
+ } else if (rules[RelativeLayout.ALIGN_PARENT_BOTTOM] != 0)
+ {
top = layoutHeight - viewHeight;
bottom = layoutHeight;
- } else if (rules[RelativeLayout.CENTER_VERTICAL] != 0) {
+ } else if (rules[RelativeLayout.CENTER_VERTICAL] != 0)
+ {
top = layoutHeight / 2 - viewHeight / 2;
bottom = layoutHeight / 2 + viewHeight / 2;
}
@@ -5261,27 +5216,27 @@ protected Rect getPluginViewRect(View view) {
// Supplementary methods for getting appropriate sizes for plugin's views
@Override
- public int getMaxPluginViewHeight() {
- return ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout))
- .getHeight() / 3;
+ public int getMaxPluginViewHeight()
+ {
+ return ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout)).getHeight() / 3;
}
@Override
- public int getMaxPluginViewWidth() {
- return ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout))
- .getWidth() / 2;
+ public int getMaxPluginViewWidth()
+ {
+ return ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout)).getWidth() / 2;
}
@Override
- public int getMinPluginViewHeight() {
- return ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout))
- .getHeight() / 12;
+ public int getMinPluginViewHeight()
+ {
+ return ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout)).getHeight() / 12;
}
@Override
- public int getMinPluginViewWidth() {
- return ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout))
- .getWidth() / 4;
+ public int getMinPluginViewWidth()
+ {
+ return ((RelativeLayout) guiView.findViewById(R.id.pluginsLayout)).getWidth() / 4;
}
/************************************************************************************************
@@ -5292,47 +5247,47 @@ public int getMinPluginViewWidth() {
* <<<<<<<<<< END
***********************************************************************************************/
- private static float X = 0;
+ private static float X = 0;
- private static float Xprev = 0;
+ private static float Xprev = 0;
- private static float Xoffset = 0;
+ private static float Xoffset = 0;
- private static float XtoLeftInvisible = 0;
- private static float XtoLeftVisible = 0;
+ private static float XtoLeftInvisible = 0;
+ private static float XtoLeftVisible = 0;
- private static float XtoRightInvisible = 0;
- private static float XtoRightVisible = 0;
+ private static float XtoRightInvisible = 0;
+ private static float XtoRightVisible = 0;
- private MotionEvent prevEvent;
- private MotionEvent downEvent;
- private boolean scrolling = false;
+ private MotionEvent prevEvent;
+ private MotionEvent downEvent;
+ private boolean scrolling = false;
@Override
- public boolean onTouch(View view, MotionEvent event) {
+ public boolean onTouch(View view, MotionEvent event)
+ {
// hide hint screen
- if (guiView.findViewById(R.id.hintLayout).getVisibility() == View.VISIBLE) {
+ if (guiView.findViewById(R.id.hintLayout).getVisibility() == View.VISIBLE)
+ {
if (event.getAction() == MotionEvent.ACTION_UP)
- guiView.findViewById(R.id.hintLayout).setVisibility(
- View.INVISIBLE);
+ guiView.findViewById(R.id.hintLayout).setVisibility(View.INVISIBLE);
return true;
}
- if (view == (LinearLayout) guiView.findViewById(R.id.evLayout)
- || lockControls)
+ if (view == (LinearLayout) guiView.findViewById(R.id.evLayout) || lockControls)
return true;
// to possibly slide-out top panel
if (view == MainScreen.getPreviewSurfaceView()
- || view == (View) MainScreen.getInstance()
- .findViewById(R.id.mainLayout1))
- ((Panel) guiView.findViewById(R.id.topPanel)).touchListener
- .onTouch(view, event);
+ || view == (View) MainScreen.getInstance().findViewById(R.id.mainLayout1))
+ ((Panel) guiView.findViewById(R.id.topPanel)).touchListener.onTouch(view, event);
- else if (view.getParent() == (View) MainScreen.getInstance()
- .findViewById(R.id.paramsLayout) && !quickControlsChangeVisible) {
+ else if (view.getParent() == (View) MainScreen.getInstance().findViewById(R.id.paramsLayout)
+ && !quickControlsChangeVisible)
+ {
- if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ if (event.getAction() == MotionEvent.ACTION_DOWN)
+ {
downEvent = MotionEvent.obtain(event);
prevEvent = MotionEvent.obtain(event);
scrolling = false;
@@ -5340,50 +5295,48 @@ else if (view.getParent() == (View) MainScreen.getInstance()
topMenuButtonPressed(findTopMenuButtonIndex(view));
return false;
- } else if (event.getAction() == MotionEvent.ACTION_UP) {
+ } else if (event.getAction() == MotionEvent.ACTION_UP)
+ {
topMenuButtonPressed(-1);
if (scrolling)
- ((Panel) guiView.findViewById(R.id.topPanel)).touchListener
- .onTouch(view, event);
+ ((Panel) guiView.findViewById(R.id.topPanel)).touchListener.onTouch(view, event);
scrolling = false;
if (prevEvent == null || downEvent == null)
return false;
if (prevEvent.getAction() == MotionEvent.ACTION_DOWN)
return false;
- if (prevEvent.getAction() == MotionEvent.ACTION_MOVE) {
+ if (prevEvent.getAction() == MotionEvent.ACTION_MOVE)
+ {
if ((event.getY() - downEvent.getY()) < 50)
return false;
}
- } else if (event.getAction() == MotionEvent.ACTION_MOVE
- && !scrolling) {
+ } else if (event.getAction() == MotionEvent.ACTION_MOVE && !scrolling)
+ {
if (downEvent == null)
return false;
if ((event.getY() - downEvent.getY()) < 50)
return false;
- else {
+ else
+ {
scrolling = true;
- ((Panel) guiView.findViewById(R.id.topPanel)).touchListener
- .onTouch(view, downEvent);
+ ((Panel) guiView.findViewById(R.id.topPanel)).touchListener.onTouch(view, downEvent);
}
}
- ((Panel) guiView.findViewById(R.id.topPanel)).touchListener
- .onTouch(view, event);
+ ((Panel) guiView.findViewById(R.id.topPanel)).touchListener.onTouch(view, event);
}
// to allow quickControl's to process onClick, onLongClick
- if (view.getParent() == (View) MainScreen.getInstance()
- .findViewById(R.id.paramsLayout)) {
+ if (view.getParent() == (View) MainScreen.getInstance().findViewById(R.id.paramsLayout))
+ {
return false;
}
boolean isMenuOpened = false;
- if (quickControlsChangeVisible || modeSelectorVisible
- || settingsControlsVisible || isSecondaryMenusVisible())
+ if (quickControlsChangeVisible || modeSelectorVisible || settingsControlsVisible || isSecondaryMenusVisible())
isMenuOpened = true;
if (quickControlsChangeVisible
- && view.getParent() != (View) MainScreen.getInstance()
- .findViewById(R.id.paramsLayout))
+ && view.getParent() != (View) MainScreen.getInstance().findViewById(R.id.paramsLayout))
closeQuickControlsSettings();
if (modeSelectorVisible)
@@ -5398,167 +5351,175 @@ else if (!isMenuOpened)
// call onTouch of active vf and capture plugins
PluginManager.getInstance().onTouch(view, event);
- RelativeLayout pluginLayout = (RelativeLayout) guiView
- .findViewById(R.id.pluginsLayout);
- RelativeLayout fullscreenLayout = (RelativeLayout) guiView
- .findViewById(R.id.fullscreenLayout);
- LinearLayout paramsLayout = (LinearLayout) guiView
- .findViewById(R.id.paramsLayout);
- LinearLayout infoLayout = (LinearLayout) guiView
- .findViewById(R.id.infoLayout);
+ RelativeLayout pluginLayout = (RelativeLayout) guiView.findViewById(R.id.pluginsLayout);
+ RelativeLayout fullscreenLayout = (RelativeLayout) guiView.findViewById(R.id.fullscreenLayout);
+ LinearLayout paramsLayout = (LinearLayout) guiView.findViewById(R.id.paramsLayout);
+ LinearLayout infoLayout = (LinearLayout) guiView.findViewById(R.id.infoLayout);
// OnTouch listener to show info and sliding grids
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN: {
- X = event.getX();
- Xoffset = X;
- Xprev = X;
+ switch (event.getAction())
+ {
+ case MotionEvent.ACTION_DOWN:
+ {
+ X = event.getX();
+ Xoffset = X;
+ Xprev = X;
- pluginLayout.clearAnimation();
- fullscreenLayout.clearAnimation();
- paramsLayout.clearAnimation();
- infoLayout.clearAnimation();
+ pluginLayout.clearAnimation();
+ fullscreenLayout.clearAnimation();
+ paramsLayout.clearAnimation();
+ infoLayout.clearAnimation();
- topMenuButtonPressed(findTopMenuButtonIndex(view));
+ topMenuButtonPressed(findTopMenuButtonIndex(view));
- return true;
- }
- case MotionEvent.ACTION_UP: {
- float difX = event.getX();
- if ((X > difX) && (X - difX > 100)) {
- sliderLeftEvent();
- return true;
- } else if (X < difX && (difX - X > 100)) {
- sliderRightEvent();
return true;
}
+ case MotionEvent.ACTION_UP:
+ {
+ float difX = event.getX();
+ if ((X > difX) && (X - difX > 100))
+ {
+ sliderLeftEvent();
+ return true;
+ } else if (X < difX && (difX - X > 100))
+ {
+ sliderRightEvent();
+ return true;
+ }
- pluginLayout.clearAnimation();
- fullscreenLayout.clearAnimation();
- paramsLayout.clearAnimation();
- infoLayout.clearAnimation();
+ pluginLayout.clearAnimation();
+ fullscreenLayout.clearAnimation();
+ paramsLayout.clearAnimation();
+ infoLayout.clearAnimation();
- topMenuButtonPressed(-1);
+ topMenuButtonPressed(-1);
- break;
- }
- case MotionEvent.ACTION_MOVE: {
- int pluginzoneWidth = guiView.findViewById(R.id.pluginsLayout)
- .getWidth();
- int infozoneWidth = guiView.findViewById(R.id.infoLayout)
- .getWidth();
- int screenWidth = pluginzoneWidth + infozoneWidth;
-
- float difX = event.getX();
-
- Animation in_animation;
- Animation out_animation;
- Animation reverseout_animation;
- boolean toLeft;
- if (difX > Xprev) {
- out_animation = new TranslateAnimation(Xprev - Xoffset, difX
- - Xoffset, 0, 0);
- out_animation.setDuration(10);
- out_animation.setInterpolator(new LinearInterpolator());
- out_animation.setFillAfter(true);
-
- in_animation = new TranslateAnimation(Xprev - Xoffset
- - screenWidth, difX - Xoffset - screenWidth, 0, 0);
- in_animation.setDuration(10);
- in_animation.setInterpolator(new LinearInterpolator());
- in_animation.setFillAfter(true);
-
- reverseout_animation = new TranslateAnimation(difX
- + (screenWidth - Xoffset), Xprev
- + (screenWidth - Xoffset), 0, 0);
- reverseout_animation.setDuration(10);
- reverseout_animation.setInterpolator(new LinearInterpolator());
- reverseout_animation.setFillAfter(true);
-
- toLeft = false;
-
- XtoRightInvisible = difX - Xoffset;
- XtoRightVisible = difX - Xoffset - screenWidth;
- } else {
- out_animation = new TranslateAnimation(difX - Xoffset, Xprev
- - Xoffset, 0, 0);
- out_animation.setDuration(10);
- out_animation.setInterpolator(new LinearInterpolator());
- out_animation.setFillAfter(true);
-
- in_animation = new TranslateAnimation(screenWidth
- + (Xprev - Xoffset), screenWidth + (difX - Xoffset), 0,
- 0);
- in_animation.setDuration(10);
- in_animation.setInterpolator(new LinearInterpolator());
- in_animation.setFillAfter(true);
-
- reverseout_animation = new TranslateAnimation(Xprev - Xoffset
- - screenWidth, difX - Xoffset - screenWidth, 0, 0);
- reverseout_animation.setDuration(10);
- reverseout_animation.setInterpolator(new LinearInterpolator());
- reverseout_animation.setFillAfter(true);
-
- toLeft = true;
-
- XtoLeftInvisible = Xprev - Xoffset;
- XtoLeftVisible = screenWidth + (difX - Xoffset);
+ break;
}
+ case MotionEvent.ACTION_MOVE:
+ {
+ int pluginzoneWidth = guiView.findViewById(R.id.pluginsLayout).getWidth();
+ int infozoneWidth = guiView.findViewById(R.id.infoLayout).getWidth();
+ int screenWidth = pluginzoneWidth + infozoneWidth;
- switch (infoSet) {
- case INFO_ALL: {
- pluginLayout.startAnimation(out_animation);
- fullscreenLayout.startAnimation(out_animation);
- infoLayout.startAnimation(out_animation);
- if ((difX < X) || !isAnyViewOnViewfinder())
- paramsLayout.startAnimation(out_animation);
+ float difX = event.getX();
+
+ Animation in_animation;
+ Animation out_animation;
+ Animation reverseout_animation;
+ boolean toLeft;
+ if (difX > Xprev)
+ {
+ out_animation = new TranslateAnimation(Xprev - Xoffset, difX - Xoffset, 0, 0);
+ out_animation.setDuration(10);
+ out_animation.setInterpolator(new LinearInterpolator());
+ out_animation.setFillAfter(true);
+
+ in_animation = new TranslateAnimation(Xprev - Xoffset - screenWidth, difX - Xoffset - screenWidth,
+ 0, 0);
+ in_animation.setDuration(10);
+ in_animation.setInterpolator(new LinearInterpolator());
+ in_animation.setFillAfter(true);
+
+ reverseout_animation = new TranslateAnimation(difX + (screenWidth - Xoffset), Xprev
+ + (screenWidth - Xoffset), 0, 0);
+ reverseout_animation.setDuration(10);
+ reverseout_animation.setInterpolator(new LinearInterpolator());
+ reverseout_animation.setFillAfter(true);
+
+ toLeft = false;
+
+ XtoRightInvisible = difX - Xoffset;
+ XtoRightVisible = difX - Xoffset - screenWidth;
+ } else
+ {
+ out_animation = new TranslateAnimation(difX - Xoffset, Xprev - Xoffset, 0, 0);
+ out_animation.setDuration(10);
+ out_animation.setInterpolator(new LinearInterpolator());
+ out_animation.setFillAfter(true);
+
+ in_animation = new TranslateAnimation(screenWidth + (Xprev - Xoffset), screenWidth
+ + (difX - Xoffset), 0, 0);
+ in_animation.setDuration(10);
+ in_animation.setInterpolator(new LinearInterpolator());
+ in_animation.setFillAfter(true);
+
+ reverseout_animation = new TranslateAnimation(Xprev - Xoffset - screenWidth, difX - Xoffset
+ - screenWidth, 0, 0);
+ reverseout_animation.setDuration(10);
+ reverseout_animation.setInterpolator(new LinearInterpolator());
+ reverseout_animation.setFillAfter(true);
+
+ toLeft = true;
+
+ XtoLeftInvisible = Xprev - Xoffset;
+ XtoLeftVisible = screenWidth + (difX - Xoffset);
}
+
+ switch (infoSet)
+ {
+ case INFO_ALL:
+ {
+ pluginLayout.startAnimation(out_animation);
+ fullscreenLayout.startAnimation(out_animation);
+ infoLayout.startAnimation(out_animation);
+ if ((difX < X) || !isAnyViewOnViewfinder())
+ paramsLayout.startAnimation(out_animation);
+ }
break;
- case INFO_NO: {
- if ((toLeft && difX < X) || (!toLeft && difX > X))
- fullscreenLayout.startAnimation(in_animation);
- else
- paramsLayout.startAnimation(reverseout_animation);
- if (!toLeft && isAnyViewOnViewfinder()) {
- pluginLayout.startAnimation(in_animation);
- fullscreenLayout.startAnimation(in_animation);
- infoLayout.startAnimation(in_animation);
- } else if (toLeft && difX > X && isAnyViewOnViewfinder()) {
- pluginLayout.startAnimation(reverseout_animation);
- paramsLayout.startAnimation(reverseout_animation);
- infoLayout.startAnimation(reverseout_animation);
+ case INFO_NO:
+ {
+ if ((toLeft && difX < X) || (!toLeft && difX > X))
+ fullscreenLayout.startAnimation(in_animation);
+ else
+ paramsLayout.startAnimation(reverseout_animation);
+ if (!toLeft && isAnyViewOnViewfinder())
+ {
+ pluginLayout.startAnimation(in_animation);
+ fullscreenLayout.startAnimation(in_animation);
+ infoLayout.startAnimation(in_animation);
+ } else if (toLeft && difX > X && isAnyViewOnViewfinder())
+ {
+ pluginLayout.startAnimation(reverseout_animation);
+ paramsLayout.startAnimation(reverseout_animation);
+ infoLayout.startAnimation(reverseout_animation);
+ }
}
- }
break;
- case INFO_GRID: {
- if (difX > X)//to INFO_NO
- fullscreenLayout.startAnimation(out_animation);
- else//to INFO_PARAMS
+ case INFO_GRID:
{
- fullscreenLayout.startAnimation(out_animation);
- paramsLayout.startAnimation(in_animation);
+ if (difX > X)// to INFO_NO
+ fullscreenLayout.startAnimation(out_animation);
+ else
+ // to INFO_PARAMS
+ {
+ fullscreenLayout.startAnimation(out_animation);
+ paramsLayout.startAnimation(in_animation);
+ }
}
- }
break;
- case INFO_PARAMS: {
- fullscreenLayout.startAnimation(in_animation);
- if (difX > X)
- paramsLayout.startAnimation(out_animation);
- if (toLeft) {
- pluginLayout.startAnimation(in_animation);
- infoLayout.startAnimation(in_animation);
- } else if (difX < X) {
- pluginLayout.startAnimation(reverseout_animation);
- infoLayout.startAnimation(reverseout_animation);
+ case INFO_PARAMS:
+ {
+ fullscreenLayout.startAnimation(in_animation);
+ if (difX > X)
+ paramsLayout.startAnimation(out_animation);
+ if (toLeft)
+ {
+ pluginLayout.startAnimation(in_animation);
+ infoLayout.startAnimation(in_animation);
+ } else if (difX < X)
+ {
+ pluginLayout.startAnimation(reverseout_animation);
+ infoLayout.startAnimation(reverseout_animation);
+ }
}
- }
break;
default:
break;
- }
+ }
- Xprev = Math.round(difX);
+ Xprev = Math.round(difX);
- }
+ }
break;
default:
break;
@@ -5566,15 +5527,16 @@ else if (!isMenuOpened)
return false;
}
- private int getRelativeLeft(View myView) {
+ private int getRelativeLeft(View myView)
+ {
if (myView.getParent() == myView.getRootView())
return myView.getLeft();
else
- return myView.getLeft()
- + getRelativeLeft((View) myView.getParent());
+ return myView.getLeft() + getRelativeLeft((View) myView.getParent());
}
- private int getRelativeTop(View myView) {
+ private int getRelativeTop(View myView)
+ {
if (myView.getParent() == myView.getRootView())
return myView.getTop();
else
@@ -5582,9 +5544,9 @@ private int getRelativeTop(View myView) {
}
@Override
- public void onProgressChanged(SeekBar seekBar, int progress,
- boolean fromUser) {
-
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
+ {
+
int iEv = progress - CameraController.getInstance().getMaxExposureCompensation();
CameraController.getInstance().setCameraExposureCompensation(iEv);
@@ -5592,23 +5554,22 @@ public void onProgressChanged(SeekBar seekBar, int progress,
mEV = iEv;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_EV_CHANGED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_EV_CHANGED);
}
@Override
public void onVolumeBtnExpo(int keyCode)
{
- if ( keyCode == KeyEvent.KEYCODE_VOLUME_DOWN )
+ if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
expoMinus();
- else if ( keyCode == KeyEvent.KEYCODE_VOLUME_UP )
- expoPlus();
+ else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP)
+ expoPlus();
}
-
+
private void expoMinus()
{
SeekBar evBar = (SeekBar) guiView.findViewById(R.id.evSeekBar);
- if (evBar != null)
+ if (evBar != null)
{
int minValue = CameraController.getInstance().getMinExposureCompensation();
int step = 1;
@@ -5622,19 +5583,18 @@ private void expoMinus()
preferences
.edit()
.putInt(MainScreen.sEvPref,
- Math.round((iEv + minValue)
- * CameraController.getInstance()
- .getExposureCompensationStep()))
+ Math.round((iEv + minValue) * CameraController.getInstance().getExposureCompensationStep()))
.commit();
evBar.setProgress(iEv);
}
}
-
+
private void expoPlus()
{
SeekBar evBar = (SeekBar) guiView.findViewById(R.id.evSeekBar);
- if (evBar != null) {
+ if (evBar != null)
+ {
int minValue = CameraController.getInstance().getMinExposureCompensation();
int maxValue = CameraController.getInstance().getMaxExposureCompensation();
@@ -5644,117 +5604,143 @@ private void expoPlus()
int iEv = currProgress + step;
if (iEv > maxValue - minValue)
iEv = maxValue - minValue;
-
+
CameraController.getInstance().setCameraExposureCompensation(iEv + minValue);
preferences
.edit()
.putInt(MainScreen.sEvPref,
- Math.round((iEv + minValue)
- * CameraController.getInstance()
- .getExposureCompensationStep()))
+ Math.round((iEv + minValue) * CameraController.getInstance().getExposureCompensationStep()))
.commit();
evBar.setProgress(iEv);
}
}
-
+
@Override
- public void onStartTrackingTouch(SeekBar seekBar) {
+ public void onStartTrackingTouch(SeekBar seekBar)
+ {
}
@Override
- public void onStopTrackingTouch(SeekBar seekBar) {
+ public void onStopTrackingTouch(SeekBar seekBar)
+ {
}
// Slider events handler
- private void sliderLeftEvent() {
+ private void sliderLeftEvent()
+ {
infoSlide(true, XtoLeftVisible, XtoLeftInvisible);
}
- private void sliderRightEvent() {
+ private void sliderRightEvent()
+ {
infoSlide(false, XtoRightVisible, XtoRightInvisible);
}
// shutter icons setter
- public void setShutterIcon(ShutterButton id) {
+ public void setShutterIcon(ShutterButton id)
+ {
RotateImageView mainButton = (RotateImageView) guiView.findViewById(R.id.buttonShutter);
RotateImageView additionalButton = (RotateImageView) guiView.findViewById(R.id.buttonShutterAdditional);
LinearLayout buttonShutterContainer = (LinearLayout) guiView.findViewById(R.id.buttonShutterContainer);
-
- // photo
- if (id == ShutterButton.DEFAULT) {
+
+ // 1 button
+ if (id == ShutterButton.DEFAULT || id == ShutterButton.RECORDER_START || id == ShutterButton.RECORDER_STOP
+ || id == ShutterButton.RECORDER_RECORDING)
+ {
buttonShutterContainer.setOrientation(LinearLayout.VERTICAL);
buttonShutterContainer.setPadding(0, 0, 0, 0);
-
+
additionalButton.setVisibility(View.GONE);
-
- mainButton.setImageResource(R.drawable.button_shutter);
+
+ if (id == ShutterButton.DEFAULT)
+ {
+ mainButton.setImageResource(R.drawable.button_shutter);
+ } else if (id == ShutterButton.RECORDER_START)
+ {
+ mainButton.setImageResource(R.drawable.gui_almalence_shutter_video_off);
+ } else if (id == ShutterButton.RECORDER_STOP)
+ {
+ mainButton.setImageResource(R.drawable.gui_almalence_shutter_video_stop);
+ } else if (id == ShutterButton.RECORDER_RECORDING)
+ {
+ mainButton.setImageResource(R.drawable.gui_almalence_shutter_video_stop_red);
+ }
+
int dp = (int) MainScreen.getInstance().getResources().getDimension(R.dimen.shutterHeight);
mainButton.getLayoutParams().width = dp;
mainButton.getLayoutParams().height = dp;
- }
- // video
- else {
+ }
+ // video with pause (2 butons)
+ else
+ {
buttonShutterContainer.setOrientation(LinearLayout.HORIZONTAL);
buttonShutterContainer.setPadding(0, Util.dpToPixel(15), 0, 0);
-
+
additionalButton.setVisibility(View.VISIBLE);
int dp = (int) MainScreen.getInstance().getResources().getDimension(R.dimen.videoShutterHeight);
mainButton.getLayoutParams().width = dp;
mainButton.getLayoutParams().height = dp;
-
- if (id == ShutterButton.RECORDER_START) {
+
+ if (id == ShutterButton.RECORDER_START_WITH_PAUSE)
+ {
mainButton.setImageResource(R.drawable.gui_almalence_shutter_video_off);
additionalButton.setImageResource(R.drawable.gui_almalence_shutter_video_pause);
- }
- else if (id == ShutterButton.RECORDER_STOP) {
+ } else if (id == ShutterButton.RECORDER_STOP_WITH_PAUSE)
+ {
mainButton.setImageResource(R.drawable.gui_almalence_shutter_video_stop);
additionalButton.setImageResource(R.drawable.gui_almalence_shutter_video_pause);
- } else if (id == ShutterButton.RECORDER_PAUSED) {
+ } else if (id == ShutterButton.RECORDER_PAUSED)
+ {
additionalButton.setImageResource(R.drawable.gui_almalence_shutter_video_pause_red);
mainButton.setImageResource(R.drawable.gui_almalence_shutter_video_stop_red);
- }
- else if (id == ShutterButton.RECORDER_RECORDING) {
+ } else if (id == ShutterButton.RECORDER_RECORDING_WITH_PAUSE)
+ {
mainButton.setImageResource(R.drawable.gui_almalence_shutter_video_stop_red);
}
}
- }
+ }
- public boolean onKeyDown(boolean isFromMain, int keyCode, KeyEvent event) {
+ public boolean onKeyDown(boolean isFromMain, int keyCode, KeyEvent event)
+ {
// hide hint screen
if (guiView.findViewById(R.id.hintLayout).getVisibility() == View.VISIBLE)
guiView.findViewById(R.id.hintLayout).setVisibility(View.INVISIBLE);
-
- if (guiView.findViewById(R.id.mode_help).getVisibility() == View.VISIBLE)
+
+ if (guiView.findViewById(R.id.mode_help).getVisibility() == View.VISIBLE)
{
guiView.findViewById(R.id.mode_help).setVisibility(View.INVISIBLE);
return true;
}
int res = 0;
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- if (quickControlsChangeVisible) {
+ if (keyCode == KeyEvent.KEYCODE_BACK)
+ {
+ if (quickControlsChangeVisible)
+ {
closeQuickControlsSettings();
res++;
guiView.findViewById(R.id.topPanel).setVisibility(View.VISIBLE);
- } else if (settingsControlsVisible) {
- ((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false,
- true);
+ } else if (settingsControlsVisible)
+ {
+ ((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false, true);
res++;
- } else if (modeSelectorVisible) {
+ } else if (modeSelectorVisible)
+ {
hideModeList();
res++;
- } else if (quickControlsVisible) {
+ } else if (quickControlsVisible)
+ {
unselectPrimaryTopMenuButtons(-1);
hideSecondaryMenus();
res++;
guiView.findViewById(R.id.topPanel).setVisibility(View.VISIBLE);
quickControlsVisible = false;
}
- if (((RelativeLayout) guiView.findViewById(R.id.viewPagerLayout)).getVisibility() == View.VISIBLE)
+ if (((RelativeLayout) guiView.findViewById(R.id.viewPagerLayoutMain)).getVisibility() == View.VISIBLE)
{
hideStore();
res++;
@@ -5764,17 +5750,19 @@ public boolean onKeyDown(boolean isFromMain, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_CAMERA /*
* || keyCode ==
* KeyEvent.KEYCODE_DPAD_CENTER
- */) {
- if (settingsControlsVisible || quickControlsChangeVisible
- || modeSelectorVisible) {
+ */)
+ {
+ if (settingsControlsVisible || quickControlsChangeVisible || modeSelectorVisible)
+ {
if (quickControlsChangeVisible)
closeQuickControlsSettings();
- if (settingsControlsVisible) {
- ((Panel) guiView.findViewById(R.id.topPanel)).setOpen(
- false, true);
+ if (settingsControlsVisible)
+ {
+ ((Panel) guiView.findViewById(R.id.topPanel)).setOpen(false, true);
return false;
}
- if (modeSelectorVisible) {
+ if (modeSelectorVisible)
+ {
hideModeList();
return false;
}
@@ -5785,24 +5773,23 @@ public boolean onKeyDown(boolean isFromMain, int keyCode, KeyEvent event) {
// check if back button pressed and processing is in progress
if (res == 0)
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- if (PluginManager.getInstance().getProcessingCounter() != 0) {
+ if (keyCode == KeyEvent.KEYCODE_BACK)
+ {
+ if (PluginManager.getInstance().getProcessingCounter() != 0)
+ {
// splash screen about processing
- AlertDialog.Builder builder = new AlertDialog.Builder(
- MainScreen.getInstance())
+ AlertDialog.Builder builder = new AlertDialog.Builder(MainScreen.getInstance())
.setTitle("Processing...")
.setMessage(
- MainScreen.getInstance().getResources().getString(
- R.string.processing_not_finished))
- .setPositiveButton("Ok",
- new DialogInterface.OnClickListener() {
- public void onClick(
- DialogInterface dialog,
- int which) {
- // continue with delete
- dialog.cancel();
- }
- });
+ MainScreen.getInstance().getResources().getString(R.string.processing_not_finished))
+ .setPositiveButton("Ok", new DialogInterface.OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int which)
+ {
+ // continue with delete
+ dialog.cancel();
+ }
+ });
AlertDialog alert = builder.create();
alert.show();
}
@@ -5811,76 +5798,88 @@ public void onClick(
return res > 0 ? true : false;
}
- private void openGallery() {
+ private void openGallery()
+ {
if (mThumbnail == null)
return;
Uri uri = this.mThumbnail.getUri();
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_STOP_CAPTURE);
-
- try {
- MainScreen.getInstance().startActivity(new Intent(Intent.ACTION_VIEW,
- uri));
- } catch (ActivityNotFoundException ex) {
- try {
- MainScreen.getInstance().startActivity(new Intent(Intent.ACTION_VIEW,
- uri));
- } catch (ActivityNotFoundException e) {
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_STOP_CAPTURE);
+
+ try
+ {
+ MainScreen.getInstance().startActivity(new Intent(Intent.ACTION_VIEW, uri));
+ } catch (ActivityNotFoundException ex)
+ {
+ try
+ {
+ MainScreen.getInstance().startActivity(new Intent(Intent.ACTION_VIEW, uri));
+ } catch (ActivityNotFoundException e)
+ {
Log.e("AlmalenceGUI", "review image fail. uri=" + uri, e);
}
}
}
- public static boolean isUriValid(Uri uri, ContentResolver resolver) {
+ public static boolean isUriValid(Uri uri, ContentResolver resolver)
+ {
if (uri == null)
return false;
- try {
+ try
+ {
ParcelFileDescriptor pfd = resolver.openFileDescriptor(uri, "r");
- if (pfd == null) {
+ if (pfd == null)
+ {
Log.e("AlmalenceGUI", "Fail to open URI. URI=" + uri);
return false;
}
pfd.close();
- } catch (IOException ex) {
+ } catch (IOException ex)
+ {
return false;
}
return true;
}
-
+
@Override
public void onCaptureFinished()
{
- //Not used
+ // Not used
}
// called to set any indication when export plugin work finished.
@Override
- public void onExportFinished() {
+ public void onExportFinished()
+ {
// stop animation
- if (processingAnim != null) {
+ if (processingAnim != null)
+ {
processingAnim.clearAnimation();
processingAnim.setVisibility(View.GONE);
}
- RelativeLayout rl = (RelativeLayout) guiView
- .findViewById(R.id.blockingLayout);
- if (rl.getVisibility() == View.VISIBLE) {
+ RelativeLayout rl = (RelativeLayout) guiView.findViewById(R.id.blockingLayout);
+ if (rl.getVisibility() == View.VISIBLE)
+ {
rl.setVisibility(View.GONE);
}
updateThumbnailButton();
thumbnailView.invalidate();
- if (0 != PluginManager.getInstance().getProcessingCounter()) {
- new CountDownTimer(10, 10) {
- public void onTick(long millisUntilFinished) {
- //Not used
+ if (0 != PluginManager.getInstance().getProcessingCounter())
+ {
+ new CountDownTimer(10, 10)
+ {
+ public void onTick(long millisUntilFinished)
+ {
+ // Not used
}
- public void onFinish() {
+ public void onFinish()
+ {
startProcessingAnimation();
}
}.start();
@@ -5888,34 +5887,33 @@ public void onFinish() {
}
@Override
- public void onPostProcessingStarted() {
+ public void onPostProcessingStarted()
+ {
guiView.findViewById(R.id.buttonGallery).setEnabled(false);
guiView.findViewById(R.id.buttonShutter).setEnabled(false);
guiView.findViewById(R.id.buttonSelectMode).setEnabled(false);
- guiView.findViewById(R.id.postprocessingLayout).setVisibility(
- View.VISIBLE);
+ guiView.findViewById(R.id.postprocessingLayout).setVisibility(View.VISIBLE);
guiView.findViewById(R.id.postprocessingLayout).bringToFront();
- List processingPlugins = PluginManager.getInstance()
- .getActivePlugins(PluginType.Processing);
- if (!processingPlugins.isEmpty()) {
- View postProcessingView = processingPlugins.get(0)
- .getPostProcessingView();
+ List processingPlugins = PluginManager.getInstance().getActivePlugins(PluginType.Processing);
+ if (!processingPlugins.isEmpty())
+ {
+ View postProcessingView = processingPlugins.get(0).getPostProcessingView();
if (postProcessingView != null)
- ((RelativeLayout) guiView
- .findViewById(R.id.postprocessingLayout))
- .addView(postProcessingView);
+ ((RelativeLayout) guiView.findViewById(R.id.postprocessingLayout)).addView(postProcessingView);
}
}
@Override
- public void onPostProcessingFinished() {
+ public void onPostProcessingFinished()
+ {
List postprocessingView = new ArrayList();
RelativeLayout pluginsLayout = (RelativeLayout) MainScreen.getInstance()
.findViewById(R.id.postprocessingLayout);
for (int i = 0; i < pluginsLayout.getChildCount(); i++)
postprocessingView.add(pluginsLayout.getChildAt(i));
- for (int j = 0; j < postprocessingView.size(); j++) {
+ for (int j = 0; j < postprocessingView.size(); j++)
+ {
View view = postprocessingView.get(j);
if (view.getParent() != null)
((ViewGroup) view.getParent()).removeView(view);
@@ -5923,8 +5921,7 @@ public void onPostProcessingFinished() {
pluginsLayout.removeView(view);
}
- guiView.findViewById(R.id.postprocessingLayout)
- .setVisibility(View.GONE);
+ guiView.findViewById(R.id.postprocessingLayout).setVisibility(View.GONE);
guiView.findViewById(R.id.buttonGallery).setEnabled(true);
guiView.findViewById(R.id.buttonShutter).setEnabled(true);
guiView.findViewById(R.id.buttonSelectMode).setEnabled(true);
@@ -5933,109 +5930,114 @@ public void onPostProcessingFinished() {
thumbnailView.invalidate();
}
- private UpdateThumbnailButtonTask t = null;
- public void updateThumbnailButton() {
-
+ private UpdateThumbnailButtonTask t = null;
+
+ public void updateThumbnailButton()
+ {
+
t = new UpdateThumbnailButtonTask(MainScreen.getInstance());
- t.execute();
-
- new CountDownTimer(3000, 3000) {
- public void onTick(long millisUntilFinished){
- //Not used
+ t.execute();
+
+ new CountDownTimer(1000, 1000)
+ {
+ public void onTick(long millisUntilFinished)
+ {
+ // Not used
}
- public void onFinish() {
+ public void onFinish()
+ {
try
{
if (t != null && t.getStatus() != AsyncTask.Status.FINISHED)
{
t.cancel(true);
}
- }catch(Exception e)
+ } catch (Exception e)
{
Log.e("AlmalenceGUI", "Can't stop thumbnail processing");
}
}
}.start();
}
-
- private class UpdateThumbnailButtonTask extends AsyncTask
+
+ private class UpdateThumbnailButtonTask extends AsyncTask
{
- public UpdateThumbnailButtonTask(Context context)
+ public UpdateThumbnailButtonTask(Context context)
{
}
-
+
@Override
- protected void onPreExecute() {
- // do nothing.
+ protected void onPreExecute()
+ {
+ // do nothing.
}
-
+
@Override
- protected Void doInBackground(Void... params)
+ protected Void doInBackground(Void... params)
{
mThumbnail = Thumbnail.getLastThumbnail(MainScreen.getInstance().getContentResolver());
return null;
}
@Override
- protected void onPostExecute(Void v)
+ protected void onPostExecute(Void v)
{
- if (mThumbnail != null) {
+ if (mThumbnail != null)
+ {
final Bitmap bitmap = mThumbnail.getBitmap();
- if (bitmap != null) {
- if (bitmap.getHeight() > 0 && bitmap.getWidth() > 0) {
+ if (bitmap != null)
+ {
+ if (bitmap.getHeight() > 0 && bitmap.getWidth() > 0)
+ {
System.gc();
- try {
- Bitmap bm = Thumbnail
- .getRoundedCornerBitmap(
- bitmap,
- (int) (MainScreen.getMainContext()
- .getResources()
- .getDimension(R.dimen.mainButtonHeight)*1.2),
- (int) (MainScreen.getMainContext()
- .getResources()
- .getDimension(R.dimen.mainButtonHeight)/1.1));
+ try
+ {
+ Bitmap bm = Thumbnail.getRoundedCornerBitmap(bitmap, (int) (MainScreen.getMainContext()
+ .getResources().getDimension(R.dimen.mainButtonHeight) * 1.2), (int) (MainScreen
+ .getMainContext().getResources().getDimension(R.dimen.mainButtonHeight) / 1.1));
thumbnailView.setImageBitmap(bm);
- } catch (Exception e) {
+ } catch (Exception e)
+ {
Log.v("AlmalenceGUI", "Can't set thumbnail");
}
}
}
- } else {
- try {
+ } else
+ {
+ try
+ {
Bitmap bitmap = Bitmap.createBitmap(96, 96, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawColor(Color.BLACK);
- Bitmap bm = Thumbnail.getRoundedCornerBitmap(bitmap,
- (int) (MainScreen.getMainContext().getResources()
- .getDimension(R.dimen.mainButtonHeight)*1.2),
- (int) (MainScreen.getMainContext()
- .getResources()
- .getDimension(R.dimen.mainButtonHeight)/1.1));
+ Bitmap bm = Thumbnail.getRoundedCornerBitmap(bitmap, (int) (MainScreen.getMainContext()
+ .getResources().getDimension(R.dimen.mainButtonHeight) * 1.2), (int) (MainScreen
+ .getMainContext().getResources().getDimension(R.dimen.mainButtonHeight) / 1.1));
thumbnailView.setImageBitmap(bm);
- } catch (Exception e) {
+ } catch (Exception e)
+ {
Log.v("AlmalenceGUI", "Can't set thumbnail");
}
}
}
}
-
- private ImageView processingAnim;
- public void startProcessingAnimation() {
- if(processingAnim != null && processingAnim.getVisibility() == View.VISIBLE)
+ private ImageView processingAnim;
+
+ public void startProcessingAnimation()
+ {
+ if (processingAnim != null && processingAnim.getVisibility() == View.VISIBLE)
return;
- processingAnim = ((ImageView) guiView
- .findViewById(R.id.buttonGallery2));
+ processingAnim = ((ImageView) guiView.findViewById(R.id.buttonGallery2));
processingAnim.setVisibility(View.VISIBLE);
- int height = (int)MainScreen.getInstance().getResources().getDimension(R.dimen.paramsLayoutHeightScanner);
- int width = (int)MainScreen.getInstance().getResources().getDimension(R.dimen.paramsLayoutHeightScanner);
- Animation rotation = new RotateAnimation(0, 360, width/2, height/2);
+ int height = (int) MainScreen.getInstance().getResources().getDimension(R.dimen.paramsLayoutHeightScanner);
+ int width = (int) MainScreen.getInstance().getResources().getDimension(R.dimen.paramsLayoutHeightScanner);
+ Animation rotation = new RotateAnimation(0, 360, width / 2, height / 2);
rotation.setDuration(800);
rotation.setInterpolator(new LinearInterpolator());
rotation.setRepeatCount(100);
@@ -6043,10 +6045,11 @@ public void startProcessingAnimation() {
processingAnim.startAnimation(rotation);
}
- public void processingBlockUI() {
- RelativeLayout rl = (RelativeLayout) guiView
- .findViewById(R.id.blockingLayout);
- if (rl.getVisibility() == View.GONE) {
+ public void processingBlockUI()
+ {
+ RelativeLayout rl = (RelativeLayout) guiView.findViewById(R.id.blockingLayout);
+ if (rl.getVisibility() == View.GONE)
+ {
rl.setVisibility(View.VISIBLE);
rl.bringToFront();
@@ -6057,26 +6060,31 @@ public void processingBlockUI() {
}
// capture indication - will play shutter icon opened/closed
- private boolean captureIndication = true;
- private boolean isIndicationOn = false;
+ private boolean captureIndication = true;
+ private boolean isIndicationOn = false;
- public void startContinuousCaptureIndication() {
+ public void startContinuousCaptureIndication()
+ {
captureIndication = true;
- new CountDownTimer(200, 200) {
- public void onTick(long millisUntilFinished) {
- //Not used
+ new CountDownTimer(200, 200)
+ {
+ public void onTick(long millisUntilFinished)
+ {
+ // Not used
}
- public void onFinish() {
- if (captureIndication) {
- if (isIndicationOn) {
- ((RotateImageView) guiView
- .findViewById(R.id.buttonShutter))
+ public void onFinish()
+ {
+ if (captureIndication)
+ {
+ if (isIndicationOn)
+ {
+ ((RotateImageView) guiView.findViewById(R.id.buttonShutter))
.setImageResource(R.drawable.gui_almalence_shutter);
isIndicationOn = false;
- } else {
- ((RotateImageView) guiView
- .findViewById(R.id.buttonShutter))
+ } else
+ {
+ ((RotateImageView) guiView.findViewById(R.id.buttonShutter))
.setImageResource(R.drawable.gui_almalence_shutter_pressed);
isIndicationOn = true;
}
@@ -6086,123 +6094,132 @@ public void onFinish() {
}.start();
}
- public void stopCaptureIndication() {
+ public void stopCaptureIndication()
+ {
captureIndication = false;
- ((RotateImageView) guiView.findViewById(R.id.buttonShutter))
- .setImageResource(R.drawable.button_shutter);
+ ((RotateImageView) guiView.findViewById(R.id.buttonShutter)).setImageResource(R.drawable.button_shutter);
}
- public void showCaptureIndication() {
- new CountDownTimer(400, 200) {
- public void onTick(long millisUntilFinished) {
+ public void showCaptureIndication()
+ {
+ new CountDownTimer(400, 200)
+ {
+ public void onTick(long millisUntilFinished)
+ {
((RotateImageView) guiView.findViewById(R.id.buttonShutter))
.setImageResource(R.drawable.gui_almalence_shutter_pressed);
}
- public void onFinish() {
+ public void onFinish()
+ {
((RotateImageView) guiView.findViewById(R.id.buttonShutter))
.setImageResource(R.drawable.button_shutter);
}
}.start();
}
-
-
@Override
- public void onCameraSetup() {
- //Not used
+ public void onCameraSetup()
+ {
+ // Not used
}
@Override
- public void menuButtonPressed() {
- //Not used
+ public void menuButtonPressed()
+ {
+ // Not used
}
@Override
- public void addMode(View mode) {
- //Not used
+ public void addMode(View mode)
+ {
+ // Not used
}
@Override
- public void SetModeSelected(View v) {
- //Not used
+ public void SetModeSelected(View v)
+ {
+ // Not used
}
@Override
- public void hideModes() {
- //Not used
+ public void hideModes()
+ {
+ // Not used
}
@Override
- public int getMaxModeViewWidth() {
+ public int getMaxModeViewWidth()
+ {
return -1;
}
@Override
- public int getMaxModeViewHeight() {
+ public int getMaxModeViewHeight()
+ {
return -1;
}
@Override
@TargetApi(14)
- public void setFocusParameters() {
- //Not used
+ public void setFocusParameters()
+ {
+ // Not used
}
-
- //mode help procedure
+
+ // mode help procedure
@Override
public void showHelp(String modeName, String text, int imageID, String preferences)
{
- final SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
boolean needToShow = prefs.getBoolean(preferences, true);
-
- //check show help settings
+
+ // check show help settings
MainScreen.setShowHelp(prefs.getBoolean("showHelpPrefCommon", true));
if (!needToShow || !MainScreen.isShowHelp())
return;
-
+
if (guiView.findViewById(R.id.postprocessingLayout).getVisibility() == View.VISIBLE)
return;
-
+
final String preference = preferences;
-
+
final View help = guiView.findViewById(R.id.mode_help);
- ImageView helpImage = (ImageView)guiView.findViewById(R.id.helpImage);
+ ImageView helpImage = (ImageView) guiView.findViewById(R.id.helpImage);
helpImage.setImageResource(imageID);
- TextView helpText = (TextView)guiView.findViewById(R.id.helpText);
+ TextView helpText = (TextView) guiView.findViewById(R.id.helpText);
helpText.setText(text);
-
- TextView helpTextModeName = (TextView)guiView.findViewById(R.id.helpTextModeName);
+
+ TextView helpTextModeName = (TextView) guiView.findViewById(R.id.helpTextModeName);
helpTextModeName.setText(modeName);
-
- Button button = (Button)guiView.findViewById(R.id.buttonOk);
- button.setOnClickListener(new OnClickListener()
+
+ Button button = (Button) guiView.findViewById(R.id.buttonOk);
+ button.setOnClickListener(new OnClickListener()
{
- public void onClick(View v)
+ public void onClick(View v)
{
help.setVisibility(View.GONE);
}
});
-
- Button buttonDontShow = (Button)guiView.findViewById(R.id.buttonDontShow);
- buttonDontShow.setOnClickListener(new OnClickListener()
+
+ Button buttonDontShow = (Button) guiView.findViewById(R.id.buttonDontShow);
+ buttonDontShow.setOnClickListener(new OnClickListener()
{
- public void onClick(View v)
+ public void onClick(View v)
{
help.setVisibility(View.GONE);
-
+
{
Editor prefsEditor = prefs.edit();
-
+
prefsEditor.putBoolean(preference, false);
prefsEditor.commit();
- }
+ }
}
});
-
+
help.setVisibility(View.VISIBLE);
help.bringToFront();
}
-
+
}
diff --git a/src/com/almalence/opencam/ui/AlmalenceStore.java b/src/com/almalence/opencam/ui/AlmalenceStore.java
index f53282ed..260ff42b 100755
--- a/src/com/almalence/opencam/ui/AlmalenceStore.java
+++ b/src/com/almalence/opencam/ui/AlmalenceStore.java
@@ -41,14 +41,11 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.ui.RotateImageView;
import android.content.SharedPreferences;
-import android.os.Message;
import android.preference.PreferenceManager;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
-import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
-import android.view.View.OnTouchListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
@@ -87,15 +84,6 @@ public void showStore()
GridView gridview = (GridView) store.findViewById(R.id.storeGrid);
gridview.setAdapter(storeAdapter);
- gridview.setOnTouchListener(new OnTouchListener()
- {
- @Override
- public boolean onTouch(View v, MotionEvent event)
- {
- return false;
- }
-
- });
page.addView(store);
pages.add(page);
@@ -140,7 +128,7 @@ public boolean onTouch(View v, MotionEvent event)
pages.add(page);
SamplePagerAdapter pagerAdapter = new SamplePagerAdapter(pages);
- ViewPager viewPager = new ViewPager(MainScreen.getInstance());
+ final ViewPager viewPager = new ViewPager(MainScreen.getInstance());
viewPager.setAdapter(pagerAdapter);
viewPager.setCurrentItem(0);
viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener()
@@ -209,13 +197,15 @@ public void onPageSelected(int position)
final RelativeLayout pagerLayout = ((RelativeLayout) guiView.findViewById(R.id.viewPagerLayout));
pagerLayout.addView(viewPager);
- pagerLayout.setVisibility(View.VISIBLE);
- pagerLayout.bringToFront();
+
+ final RelativeLayout pagerLayoutMain = ((RelativeLayout) guiView.findViewById(R.id.viewPagerLayoutMain));
+ pagerLayoutMain.setVisibility(View.VISIBLE);
+ pagerLayoutMain.bringToFront();
}
public void hideStore()
{
- ((RelativeLayout) guiView.findViewById(R.id.viewPagerLayout)).setVisibility(View.INVISIBLE);
+ ((RelativeLayout) guiView.findViewById(R.id.viewPagerLayoutMain)).setVisibility(View.INVISIBLE);
guiView.findViewById(R.id.buttonGallery).setEnabled(true);
guiView.findViewById(R.id.buttonShutter).setEnabled(true);
@@ -235,7 +225,7 @@ private void initStoreList()
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
boolean bOnSale = prefs.getBoolean("bOnSale", false);
- for (int i = 0; i < 6; i++)
+ for (int i = 0; i < 8; i++)
{
LayoutInflater inflator = MainScreen.getInstance().getLayoutInflater();
@@ -317,20 +307,40 @@ private void initStoreList()
else
price.setText("");
break;
+ case 6:
+ // subscription year
+ icon.setImageResource(R.drawable.store_promo);
+ description.setText(MainScreen.getInstance().getResources()
+ .getString(R.string.Pref_Upgrde_SubscriptionYear_Preference_Title));
+ if (MainScreen.getInstance().isPurchasedUnlockAllSubscriptionYear() || MainScreen.getInstance().isPurchasedAll())
+ price.setText(R.string.already_unlocked);
+ else
+ price.setText(MainScreen.getInstance().titleSubscriptionYear);
+ break;
+ case 7:
+ // subscription month
+ icon.setImageResource(R.drawable.store_promo);
+ description.setText(MainScreen.getInstance().getResources()
+ .getString(R.string.Pref_Upgrde_SubscriptionMonth_Preference_Title));
+ if (MainScreen.getInstance().isPurchasedUnlockAllSubscriptionMonth() || MainScreen.getInstance().isPurchasedAll())
+ price.setText(R.string.already_unlocked);
+ else
+ price.setText(MainScreen.getInstance().titleSubscriptionMonth);
+ break;
default:
break;
}
- item.setOnTouchListener(new OnTouchListener()
- {
- @Override
- public boolean onTouch(View v, MotionEvent event)
- {
- if (event.getAction() == MotionEvent.ACTION_CANCEL)
- purchasePressed(v);
- return false;
- }
- });
+// item.setOnTouchListener(new OnTouchListener()
+// {
+// @Override
+// public boolean onTouch(View v, MotionEvent event)
+// {
+// if (event.getAction() == MotionEvent.ACTION_CANCEL)
+// purchasePressed(v);
+// return false;
+// }
+// });
item.setOnClickListener(new OnClickListener()
{
@@ -372,6 +382,12 @@ private void purchasePressed(View v)
case 5:// Promo
MainScreen.getInstance().enterPromo();
break;
+ case 6:// Year subscription
+ MainScreen.getInstance().purchasedUnlockAllSubscriptionYear();
+ break;
+ case 7:// Month subscription
+ MainScreen.getInstance().purchasedUnlockAllSubscriptionMonth();
+ break;
default:
break;
}
diff --git a/src/com/almalence/opencam/ui/SelfTimer.java b/src/com/almalence/opencam/ui/SelfTimer.java
index ad004ebf..9ffe5901 100644
--- a/src/com/almalence/opencam/ui/SelfTimer.java
+++ b/src/com/almalence/opencam/ui/SelfTimer.java
@@ -27,22 +27,9 @@ Portions created by Initial Developer are Copyright (C) 2013
import java.util.ArrayList;
import java.util.List;
-/* */
-//
-
-import com.almalence.ui.RotateImageView;
-
-import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnDismissListener;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;
@@ -51,16 +38,41 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
-import android.widget.Button;
+import android.view.Window;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.NumberPicker;
import android.widget.RelativeLayout;
import android.widget.Switch;
+/* */
+//
+import com.almalence.ui.RotateDialog;
+import com.almalence.ui.RotateImageView;
+import com.almalence.ui.RotateLayout;
+/* */
+//
+
public class SelfTimer
{
private RotateImageView timeLapseButton = null;
+ private SelfTimerDialog dialog = null;
boolean swChecked = false;
String[] stringInterval = { "3", "5", "10", "15", "30", "60" };
@@ -70,11 +82,9 @@ public void selfTimerDialog()
int interval = prefs.getInt(MainScreen.sDelayedCaptureIntervalPref, 0);
swChecked = prefs.getBoolean(MainScreen.sSWCheckedPref, false);
- final Dialog d = new Dialog(MainScreen.getInstance());
- d.setTitle("Self timer settings");
- d.setContentView(R.layout.selftimer_dialog);
- final Button bSet = (Button) d.findViewById(R.id.button1);
- final NumberPicker np = (NumberPicker) d.findViewById(R.id.numberPicker1);
+ dialog = new SelfTimerDialog(MainScreen.getInstance());
+ dialog.setContentView(R.layout.selftimer_dialog);
+ final NumberPicker np = (NumberPicker) dialog.findViewById(R.id.numberPicker1);
np.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
np.setMaxValue(5);
np.setMinValue(0);
@@ -82,15 +92,15 @@ public void selfTimerDialog()
np.setDisplayedValues(stringInterval);
np.setWrapSelectorWheel(false);
- final CheckBox flashCheckbox = (CheckBox) d.findViewById(R.id.flashCheckbox);
+ final CheckBox flashCheckbox = (CheckBox) dialog.findViewById(R.id.flashCheckbox);
boolean flash = prefs.getBoolean(MainScreen.sDelayedFlashPref, false);
flashCheckbox.setChecked(flash);
- final CheckBox soundCheckbox = (CheckBox) d.findViewById(R.id.soundCheckbox);
+ final CheckBox soundCheckbox = (CheckBox) dialog.findViewById(R.id.soundCheckbox);
boolean sound = prefs.getBoolean(MainScreen.sDelayedSoundPref, false);
soundCheckbox.setChecked(sound);
- final Switch sw = (Switch) d.findViewById(R.id.selftimer_switcher);
+ final Switch sw = (Switch) dialog.findViewById(R.id.selftimer_switcher);
// disable/enable controls in dialog
sw.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
@@ -100,45 +110,49 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if (!sw.isChecked())
{
- np.setEnabled(false);
+// np.setEnabled(false);
flashCheckbox.setEnabled(false);
soundCheckbox.setEnabled(false);
swChecked = false;
} else
{
- np.setEnabled(true);
+// np.setEnabled(true);
flashCheckbox.setEnabled(true);
soundCheckbox.setEnabled(true);
swChecked = true;
- bSet.setEnabled(true);
}
}
});
+ np.setOnScrollListener(new NumberPicker.OnScrollListener()
+ {
+ @Override
+ public void onScrollStateChange(NumberPicker numberPicker, int scrollState)
+ {
+ sw.setChecked(true);
+ }
+ });
+
// disable control in dialog by default
if (!swChecked)
{
sw.setChecked(false);
flashCheckbox.setEnabled(false);
soundCheckbox.setEnabled(false);
- np.setEnabled(false);
- bSet.setEnabled(false);
+ //np.setEnabled(false);
} else
{
- np.setEnabled(true);
+ //np.setEnabled(true);
flashCheckbox.setEnabled(true);
soundCheckbox.setEnabled(true);
- bSet.setEnabled(true);
sw.setChecked(true);
}
- // set button in dialog pressed
- bSet.setOnClickListener(new OnClickListener()
+ dialog.setOnDismissListener(new OnDismissListener()
{
@Override
- public void onClick(View v)
+ public void onDismiss(DialogInterface dialog)
{
- d.dismiss();
int interval = 0;
Editor prefsEditor = prefs.edit();
@@ -163,7 +177,7 @@ public void onClick(View v)
updateTimelapseButton(real_int);
}
});
- d.show();
+ dialog.show();
}
public void addSelfTimerControl(boolean needToShow)
@@ -293,5 +307,37 @@ public void setOrientation()
timeLapseButton.invalidate();
timeLapseButton.requestLayout();
}
+
+ if (dialog != null)
+ {
+ dialog.setRotate(AlmalenceGUI.mDeviceOrientation);
+ }
+ }
+
+ protected class SelfTimerDialog extends RotateDialog
+ {
+ public SelfTimerDialog(Context context)
+ {
+ super(context);
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ }
+
+ @Override
+ public void setRotate(int degree)
+ {
+ degree = degree >= 0 ? degree % 360 : degree % 360 + 360;
+
+ if (degree == currentOrientation)
+ {
+ return;
+ }
+ currentOrientation = degree;
+
+ RotateLayout r = (RotateLayout) findViewById(R.id.rotateLayout);
+ r.setAngle(degree);
+ r.requestLayout();
+ r.invalidate();
+
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/com/almalence/plugins/capture/bestshot/BestShotCapturePlugin.java b/src/com/almalence/plugins/capture/bestshot/BestShotCapturePlugin.java
index 9a7ddd21..d79d4063 100755
--- a/src/com/almalence/plugins/capture/bestshot/BestShotCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/bestshot/BestShotCapturePlugin.java
@@ -19,6 +19,8 @@ Portions created by Initial Developer are Copyright (C) 2013
package com.almalence.plugins.capture.bestshot;
import java.nio.ByteBuffer;
+import java.util.Arrays;
+
import android.annotation.TargetApi;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
@@ -27,7 +29,6 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.hardware.camera2.CaptureResult;
import android.media.Image;
import android.os.CountDownTimer;
-import android.os.Message;
import android.preference.PreferenceManager;
import android.util.Log;
@@ -175,39 +176,38 @@ public void takePicture()
inCapture = true;
refreshPreferences();
takingAlready = true;
- if (imagesTaken == 0)
+
+ // play tick sound
+ MainScreen.getGUIManager().showCaptureIndication();
+ MainScreen.getInstance().playShutter();
+
+ try
{
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_NEXT_FRAME);
- } else
+ int[] pause = new int[imageAmount];
+ Arrays.fill(pause, 50);
+ requestID = CameraController.captureImagesWithParams(imageAmount, CameraController.YUV, pause, null);
+ } catch (Exception e)
{
- new CountDownTimer(50, 50)
- {
- public void onTick(long millisUntilFinished)
- {
- }
-
- public void onFinish()
- {
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_NEXT_FRAME);
- }
- }.start();
+ e.printStackTrace();
+ Log.e("Bestshot takePicture() failed", "takePicture: " + e.getMessage());
+ inCapture = false;
+ takingAlready = false;
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
+ PluginManager.MSG_CONTROL_UNLOCKED);
+ MainScreen.getGUIManager().lockControls = false;
}
}
}
+
@Override
- public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
+ public void onImageTaken(int frame, byte[] frameData, int frame_len, boolean isYUV)
{
- Log.i("Bestshot", "1");
imagesTaken++;
- int frame_len = paramArrayOfByte.length;
- int frame = SwapHeap.SwapToHeap(paramArrayOfByte);
if (frame == 0)
{
- Log.i("Bestshot", "Load to heap failed");
+ Log.e("Bestshot", "Load to heap failed");
PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
String.valueOf(SessionID));
@@ -225,16 +225,17 @@ public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
String.valueOf(MainScreen.getGUIManager().getDisplayOrientation()));
PluginManager.getInstance().addToSharedMem("framemirrored" + imagesTaken + SessionID,
String.valueOf(CameraController.isFrontCamera()));
+ PluginManager.getInstance().addToSharedMem("isyuv" + SessionID, String.valueOf(isYUV));
- if (imagesTaken == 1)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromJPEG(paramArrayOfByte, SessionID, -1);
+ if (imagesTaken == 1 && !isYUV)
+ PluginManager.getInstance().addToSharedMemExifTagsFromJPEG(frameData, SessionID, -1);
try
{
- paramCamera.startPreview();
+ CameraController.startCameraPreview();
} catch (RuntimeException e)
{
- Log.i("Bestshot", "StartPreview fail");
+ Log.e("Bestshot", "StartPreview fail");
PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
String.valueOf(SessionID));
@@ -243,111 +244,32 @@ public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
inCapture = false;
return;
}
- if (imagesTaken < imageAmount)
- MainScreen.getMessageHandler().sendEmptyMessage(PluginManager.MSG_TAKE_PICTURE);
- else
+
+ if (imagesTaken >= imageAmount)
{
PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
String.valueOf(imagesTaken));
PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
String.valueOf(SessionID));
-
+
+ Log.e("Bestshot", "CAPTURE FINISHED");
+
imagesTaken = 0;
inCapture = false;
}
inCapture = false;
- takingAlready = false;
+ takingAlready = false;
}
- @TargetApi(19)
- @Override
- public void onImageAvailable(Image im)
- {
- imagesTaken++;
- int frame = 0;
- int frame_len = 0;
- boolean isYUV = false;
-
- if (im.getFormat() == ImageFormat.YUV_420_888)
- {
- ByteBuffer Y = im.getPlanes()[0].getBuffer();
- ByteBuffer U = im.getPlanes()[1].getBuffer();
- ByteBuffer V = im.getPlanes()[2].getBuffer();
-
- if ((!Y.isDirect()) || (!U.isDirect()) || (!V.isDirect()))
- {
- Log.e("BestShotCapturePlugin", "Oops, YUV ByteBuffers isDirect failed");
- return;
- }
-
- // Note: android documentation guarantee that:
- // - Y pixel stride is always 1
- // - U and V strides are the same
- // So, passing all these parameters is a bit overkill
- int status = YuvImage.CreateYUVImage(Y, U, V, im.getPlanes()[0].getPixelStride(),
- im.getPlanes()[0].getRowStride(), im.getPlanes()[1].getPixelStride(),
- im.getPlanes()[1].getRowStride(), im.getPlanes()[2].getPixelStride(),
- im.getPlanes()[2].getRowStride(), MainScreen.getImageWidth(), MainScreen.getImageHeight(), 0);
-
- if (status != 0)
- Log.e("BestShotCapturePlugin", "Error while cropping: " + status);
-
- frame = YuvImage.GetFrame(0);
- frame_len = MainScreen.getImageWidth() * MainScreen.getImageHeight() + MainScreen.getImageWidth()
- * ((MainScreen.getImageHeight() + 1) / 2);
-
- isYUV = true;
- } else if (im.getFormat() == ImageFormat.JPEG)
- {
- Log.e("BestShotCapturePlugin", "JPEG Image received");
- ByteBuffer jpeg = im.getPlanes()[0].getBuffer();
-
- frame_len = jpeg.limit();
- byte[] jpegByteArray = new byte[frame_len];
- jpeg.get(jpegByteArray, 0, frame_len);
-
- frame = SwapHeap.SwapToHeap(jpegByteArray);
-
- if (imagesTaken == 1)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromJPEG(jpegByteArray, SessionID, -1);
- }
-
- String frameName = "frame" + imagesTaken;
- String frameLengthName = "framelen" + imagesTaken;
-
- PluginManager.getInstance().addToSharedMem(frameName + SessionID, String.valueOf(frame));
- PluginManager.getInstance().addToSharedMem(frameLengthName + SessionID, String.valueOf(frame_len));
- PluginManager.getInstance().addToSharedMem("frameorientation" + imagesTaken + SessionID,
- String.valueOf(MainScreen.getGUIManager().getDisplayOrientation()));
- PluginManager.getInstance().addToSharedMem("framemirrored" + imagesTaken + SessionID,
- String.valueOf(CameraController.isFrontCamera()));
-
- PluginManager.getInstance().addToSharedMem("isyuv" + SessionID, String.valueOf(isYUV));
-
- if (imagesTaken == imageAmount)
- {
- PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
- String.valueOf(imagesTaken));
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- imagesTaken = 0;
- inCapture = false;
- }
- inCapture = false;
- takingAlready = false;
- }
-
- @TargetApi(19)
+ @TargetApi(21)
@Override
public void onCaptureCompleted(CaptureResult result)
{
- if (result.get(CaptureResult.REQUEST_ID) == requestID)
+ if (result.getSequenceId() == requestID)
{
if (imagesTaken == 1)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromCaptureResult(result, SessionID);
+ PluginManager.getInstance().addToSharedMemExifTagsFromCaptureResult(result, SessionID);
}
}
@@ -358,35 +280,9 @@ public void onAutoFocus(boolean paramBoolean)
takePicture();
}
+
@Override
- public boolean onBroadcast(int arg1, int arg2)
- {
- if (arg1 == PluginManager.MSG_NEXT_FRAME)
- {
- // play tick sound
- MainScreen.getGUIManager().showCaptureIndication();
- MainScreen.getInstance().playShutter();
-
- try
- {
- requestID = CameraController.captureImagesWithParams(imageAmount, CameraController.YUV, 50, new int[0]);
- } catch (Exception e)
- {
- e.printStackTrace();
- Log.e("Bestshot takePicture() failed", "takePicture: " + e.getMessage());
- inCapture = false;
- takingAlready = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
- MainScreen.getGUIManager().lockControls = false;
- }
- return true;
- }
- return false;
- }
-
- @Override
- public void onPreviewFrame(byte[] data, Camera paramCamera)
+ public void onPreviewFrame(byte[] data)
{
}
}
diff --git a/src/com/almalence/plugins/capture/burst/BurstCapturePlugin.java b/src/com/almalence/plugins/capture/burst/BurstCapturePlugin.java
index d7cf6d57..886714be 100755
--- a/src/com/almalence/plugins/capture/burst/BurstCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/burst/BurstCapturePlugin.java
@@ -19,6 +19,8 @@ Portions created by Initial Developer are Copyright (C) 2013
package com.almalence.plugins.capture.burst;
import java.nio.ByteBuffer;
+import java.util.Arrays;
+
import android.annotation.TargetApi;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
@@ -188,37 +190,37 @@ public void takePicture()
refreshPreferences();
inCapture = true;
takingAlready = true;
- if (imagesTaken == 0 || pauseBetweenShots == 0)
+
+ // play tick sound
+ MainScreen.getGUIManager().showCaptureIndication();
+ MainScreen.getInstance().playShutter();
+
+ try
{
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_NEXT_FRAME);
- } else
+ int[] pause = new int[imageAmount];
+ Arrays.fill(pause, pauseBetweenShots);
+ requestID = CameraController.captureImagesWithParams(imageAmount, CameraController.JPEG, pause, null);
+ } catch (Exception e)
{
- new CountDownTimer(pauseBetweenShots, pauseBetweenShots)
- {
- public void onTick(long millisUntilFinished)
- {
- }
-
- public void onFinish()
- {
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_NEXT_FRAME);
- }
- }.start();
+ e.printStackTrace();
+ Log.e("CameraController.captureImagesWithParams failed", "takePicture: " + e.getMessage());
+ inCapture = false;
+ takingAlready = false;
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
+ PluginManager.MSG_CONTROL_UNLOCKED);
+ MainScreen.getGUIManager().lockControls = false;
}
}
+
@Override
- public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
+ public void onImageTaken(int frame, byte[] frameData, int frame_len, boolean isYUV)
{
imagesTaken++;
- int frame_len = paramArrayOfByte.length;
- int frame = SwapHeap.SwapToHeap(paramArrayOfByte);
if (frame == 0)
{
- Log.i("Burst", "Load to heap failed");
+ Log.e("Burst", "Load to heap failed");
PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
String.valueOf(SessionID));
@@ -237,111 +239,15 @@ public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
PluginManager.getInstance().addToSharedMem("framemirrored" + imagesTaken + SessionID,
String.valueOf(CameraController.isFrontCamera()));
- if (imagesTaken == 1)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromJPEG(paramArrayOfByte, SessionID, -1);
-
- try
- {
- paramCamera.startPreview();
- } catch (RuntimeException e)
- {
- Log.i("Burst", "StartPreview fail");
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- imagesTaken = 0;
- MainScreen.getInstance().muteShutter(false);
- inCapture = false;
- return;
- }
- if (imagesTaken < imageAmount)
- MainScreen.getMessageHandler().sendEmptyMessage(PluginManager.MSG_TAKE_PICTURE);
- else
- {
- PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
- String.valueOf(imagesTaken));
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- imagesTaken = 0;
- inCapture = false;
- }
- takingAlready = false;
- }
-
- @TargetApi(19)
- @Override
- public void onImageAvailable(Image im)
- {
- imagesTaken++;
-
- String frameName = "frame" + imagesTaken;
- String frameLengthName = "framelen" + imagesTaken;
-
- int frame = 0;
- int frame_len = 0;
- boolean isYUV = false;
-
- if (im.getFormat() == ImageFormat.YUV_420_888)
- {
- Log.e("BurstCapturePlugin", "YUV Image received");
- ByteBuffer Y = im.getPlanes()[0].getBuffer();
- ByteBuffer U = im.getPlanes()[1].getBuffer();
- ByteBuffer V = im.getPlanes()[2].getBuffer();
-
- if ((!Y.isDirect()) || (!U.isDirect()) || (!V.isDirect()))
- {
- Log.e("BurstCapturePlugin", "Oops, YUV ByteBuffers isDirect failed");
- return;
- }
-
- // Note: android documentation guarantee that:
- // - Y pixel stride is always 1
- // - U and V strides are the same
- // So, passing all these parameters is a bit overkill
- int status = YuvImage.CreateYUVImage(Y, U, V, im.getPlanes()[0].getPixelStride(),
- im.getPlanes()[0].getRowStride(), im.getPlanes()[1].getPixelStride(),
- im.getPlanes()[1].getRowStride(), im.getPlanes()[2].getPixelStride(),
- im.getPlanes()[2].getRowStride(), MainScreen.getImageWidth(), MainScreen.getImageHeight(), 0);
-
- if (status != 0)
- Log.e("BurstCapturePlugin", "Error while cropping: " + status);
-
- frame = YuvImage.GetFrame(0);
- frame_len = MainScreen.getImageWidth() * MainScreen.getImageHeight() + MainScreen.getImageWidth()
- * ((MainScreen.getImageHeight() + 1) / 2);
- isYUV = true;
- } else if (im.getFormat() == ImageFormat.JPEG)
- {
- Log.e("BurstCapturePlugin", "JPEG Image received");
- ByteBuffer jpeg = im.getPlanes()[0].getBuffer();
-
- frame_len = jpeg.limit();
- byte[] jpegByteArray = new byte[frame_len];
- jpeg.get(jpegByteArray, 0, frame_len);
-
- frame = SwapHeap.SwapToHeap(jpegByteArray);
-
- if (imagesTaken == 1)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromJPEG(jpegByteArray, SessionID, -1);
- }
-
- PluginManager.getInstance().addToSharedMem(frameName + SessionID, String.valueOf(frame));
- PluginManager.getInstance().addToSharedMem(frameLengthName + SessionID, String.valueOf(frame_len));
- PluginManager.getInstance().addToSharedMem("frameorientation" + imagesTaken + SessionID,
- String.valueOf(MainScreen.getGUIManager().getDisplayOrientation()));
- PluginManager.getInstance().addToSharedMem("framemirrored" + imagesTaken + SessionID,
- String.valueOf(CameraController.isFrontCamera()));
-
- PluginManager.getInstance().addToSharedMem("isyuv" + SessionID, String.valueOf(isYUV));
+ if (imagesTaken == 1 && !isYUV)
+ PluginManager.getInstance().addToSharedMemExifTagsFromJPEG(frameData, SessionID, -1);
try
{
CameraController.startCameraPreview();
} catch (RuntimeException e)
{
- Log.i("Burst", "StartPreview fail");
+ Log.e("Burst", "StartPreview fail");
PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
String.valueOf(SessionID));
@@ -350,9 +256,9 @@ public void onImageAvailable(Image im)
inCapture = false;
return;
}
- if (imagesTaken == imageAmount)
+
+ if (imagesTaken >= imageAmount)
{
- Log.e("Burst", "CAPTURE FINISHED");
PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
String.valueOf(imagesTaken));
@@ -362,17 +268,17 @@ public void onImageAvailable(Image im)
imagesTaken = 0;
inCapture = false;
}
- takingAlready = false;
+ takingAlready = false;
}
- @TargetApi(19)
+ @TargetApi(21)
@Override
public void onCaptureCompleted(CaptureResult result)
{
- if (result.get(CaptureResult.REQUEST_ID) == requestID)
+ if (result.getSequenceId() == requestID)
{
if (imagesTaken == 1)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromCaptureResult(result, SessionID);
+ PluginManager.getInstance().addToSharedMemExifTagsFromCaptureResult(result, SessionID);
}
}
@@ -383,36 +289,9 @@ public void onAutoFocus(boolean paramBoolean)
takePicture();
}
- @Override
- public boolean onBroadcast(int arg1, int arg2)
- {
- if (arg1 == PluginManager.MSG_NEXT_FRAME)
- {
- // play tick sound
- MainScreen.getGUIManager().showCaptureIndication();
- MainScreen.getInstance().playShutter();
-
- try
- {
- requestID = CameraController.captureImage(imageAmount, CameraController.JPEG);
- } catch (Exception e)
- {
- e.printStackTrace();
- Log.e("CameraController.captureImagesWithParams failed", "takePicture: " + e.getMessage());
- inCapture = false;
- takingAlready = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
- MainScreen.getGUIManager().lockControls = false;
- }
-
- return true;
- }
- return false;
- }
@Override
- public void onPreviewFrame(byte[] data, Camera paramCamera)
+ public void onPreviewFrame(byte[] data)
{
}
}
diff --git a/src/com/almalence/plugins/capture/expobracketing/ExpoBracketingCapturePlugin.java b/src/com/almalence/plugins/capture/expobracketing/ExpoBracketingCapturePlugin.java
index b3ae3cd8..b0d7226e 100755
--- a/src/com/almalence/plugins/capture/expobracketing/ExpoBracketingCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/expobracketing/ExpoBracketingCapturePlugin.java
@@ -152,7 +152,7 @@ public void onResume()
}
@Override
- public void onPause()
+ public void onPause()
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
prefs.edit().putInt("EvCompensationValue", preferenceEVCompensationValue).commit();
@@ -188,11 +188,11 @@ public void setCameraPictureSize()
CameraController.getInstance().setPictureSize(MainScreen.getImageWidth(), MainScreen.getImageHeight());
CameraController.getInstance().setJpegQuality(jpegQuality);
- CameraController.getInstance().applyCameraParameters();
+// CameraController.getInstance().applyCameraParameters();
try
{
- byte[] sceneModes = CameraController.getInstance().getSupportedSceneModes();
+ int[] sceneModes = CameraController.getInstance().getSupportedSceneModes();
if (sceneModes != null && CameraController.isModeAvailable(sceneModes, CameraParameters.SCENE_MODE_AUTO))
{
CameraController.getInstance().setCameraSceneMode(CameraParameters.SCENE_MODE_AUTO);
@@ -263,148 +263,8 @@ else if (!takingAlready
}
}
- public boolean onBroadcast(int arg1, int arg2)
- {
- if (arg1 == PluginManager.MSG_SET_EXPOSURE)
- {
- try
- {
- if (UseLumaAdaptation && LumaAdaptationAvailable)
- CameraController.getInstance().setLumaAdaptation(evRequested);
- else
- CameraController.getInstance().setCameraExposureCompensation(evRequested);
- } catch (RuntimeException e)
- {
- Log.i("ExpoBracketing", "setExpo fail in MSG_SET_EXPOSURE");
- }
-
- if (previewMode)
- {
- // message to capture image will be emitted 2 or 3 frames after
- // setExposure
- evLatency = 10; // the minimum value at which Galaxy Nexus is
- // changing exposure in a stable way
-
- // Note 3 need more time to change exposure.
- if (Build.MODEL.contains("SM-N900"))
- evLatency = 20;
- } else
- {
- new CountDownTimer(500, 500)
- {
- public void onTick(long millisUntilFinished)
- {
- }
-
- public void onFinish()
- {
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_TAKE_PICTURE);
- }
- }.start();
- }
-
- return true;
- } else if (arg1 == PluginManager.MSG_NEXT_FRAME)
- {
- if (++frame_num < total_frames)
- {
- // re-open preview (closed once frame is captured)
- try
- {
- // remaining frames
- if (RefocusPreference)
- {
- takingAlready = false;
- aboutToTakePicture = true;
- CameraController.autoFocus();
- } else
- CaptureFrame();
- } catch (RuntimeException e)
- {
- Log.i("ExpoBracketing", "RuntimeException in MSG_NEXT_FRAME");
- // motorola's sometimes fail to restart preview after
- // onPictureTaken (fixed),
- // especially on night scene
- // just repost our request and try once more (takePicture
- // latency issues?)
- --frame_num;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_NEXT_FRAME);
- }
- } else
- {
- takingAlready = false;
- inCapture = false;
- previewWorking = true;
- if (cdt != null)
- {
- cdt.cancel();
- cdt = null;
- }
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- CameraController.getInstance().resetExposureCompensation();
- }
- return true;
- } else if (arg1 == PluginManager.MSG_TAKE_PICTURE)
- {
- // some models (acer liquid, HTC aria) seem to either ignore
- // exposure setting
- // that we called couple frames before or simply auto change expo
- // back to 0Ev after we've
- // others (motorola's) will not react to exposure change that quick,
- // and takePicture
- // will happen with previously set exposure
- // let's try to set the exposure two times, catching possible throws
- // on differing models
- try
- {
- if (UseLumaAdaptation && LumaAdaptationAvailable)
- CameraController.getInstance().setLumaAdaptation(evRequested);
- else
- CameraController.getInstance().setCameraExposureCompensation(evRequested);
- } catch (RuntimeException e)
- {
- Log.i("ExpoBracketing", "setExpo fail before takePicture");
- }
-
- MainScreen.getGUIManager().showCaptureIndication();
- MainScreen.getInstance().playShutter();
-
- try
- {
- if (PluginManager.getInstance().getActiveModeID().equals("hdrmode"))
- requestID = CameraController.captureImagesWithParams(3, CameraController.YUV, 0, evValues);
- else
- requestID = CameraController.captureImage(1, CameraController.JPEG);
- } catch (Exception e)
- {
- e.printStackTrace();
- Log.e("MainScreen takePicture() failed", "takePicture: " + e.getMessage());
- takingAlready = false;
- inCapture = false;
- previewWorking = true;
- if (cdt != null)
- {
- cdt.cancel();
- cdt = null;
- }
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- CameraController.getInstance().resetExposureCompensation();
- }
- return true;
- }
- return false;
- }
-
@Override
- public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
+ public void onImageTaken(int frame, byte[] frameData, int frame_len, boolean isYUV)
{
int n = evIdx[frame_num];
if (cm7_crap && (total_frames == 3))
@@ -416,145 +276,9 @@ else if (frame_num == 1)
else
n = evIdx[1];
}
-
- compressed_frame[n] = SwapHeap.SwapToHeap(paramArrayOfByte);
- compressed_frame_len[n] = paramArrayOfByte.length;
- PluginManager.getInstance().addToSharedMem("frame" + (n + 1) + SessionID, String.valueOf(compressed_frame[n]));
- PluginManager.getInstance().addToSharedMem("framelen" + (n + 1) + SessionID,
- String.valueOf(compressed_frame_len[n]));
-
- PluginManager.getInstance().addToSharedMem("frameorientation" + (n + 1) + SessionID,
- String.valueOf(MainScreen.getGUIManager().getDisplayOrientation()));
- PluginManager.getInstance().addToSharedMem("framemirrored" + (n + 1) + SessionID,
- String.valueOf(CameraController.isFrontCamera()));
- PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID, String.valueOf(n + 1));
-
- PluginManager.getInstance().addToSharedMem_ExifTagsFromJPEG(paramArrayOfByte, SessionID, n + 1);
-
- if (compressed_frame[n] == 0)
- {
- NotEnoughMemory();
- }
-
- try
- {
- paramCamera.startPreview();
- } catch (RuntimeException e)
- {
- takingAlready = false;
- inCapture = false;
- previewWorking = true;
- if (cdt != null)
- {
- cdt.cancel();
- cdt = null;
- }
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- CameraController.getInstance().resetExposureCompensation();
- return;
- }
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_NEXT_FRAME);
-
- // if preview not working
- if (previewMode)
- return;
- previewWorking = false;
- // start timer to check if onpreviewframe working
- cdt = new CountDownTimer(5000, 5000)
- {
- public void onTick(long millisUntilFinished)
- {
- }
-
- public void onFinish()
- {
- if (!previewWorking)
- {
- Log.e("ExpoBracketing", "previewMode DISABLED!");
- previewMode = false;
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(MainScreen.getMainContext());
- Editor prefsEditor = prefs.edit();
- prefsEditor.putBoolean(sExpoPreviewModePref, false);
- prefsEditor.commit();
- evLatency = 0;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_TAKE_PICTURE);
- }
- }
- };
- cdt.start();
-
- }
-
- @TargetApi(19)
- @Override
- public void onImageAvailable(Image im)
- {
- int frame = 0;
- int frame_len = 0;
- boolean isYUV = false;
-
- int n = evIdx[frame_num];
- if (cm7_crap && (total_frames == 3))
- {
- if (frame_num == 0)
- n = evIdx[0];
- else if (frame_num == 1)
- n = evIdx[2];
- else
- n = evIdx[1];
- }
-
- if (im.getFormat() == ImageFormat.YUV_420_888)
- {
- Log.e("CapturePlugin", "YUV Image received");
- ByteBuffer Y = im.getPlanes()[0].getBuffer();
- ByteBuffer U = im.getPlanes()[1].getBuffer();
- ByteBuffer V = im.getPlanes()[2].getBuffer();
-
- if ((!Y.isDirect()) || (!U.isDirect()) || (!V.isDirect()))
- {
- Log.e("CapturePlugin", "Oops, YUV ByteBuffers isDirect failed");
- return;
- }
-
- // Note: android documentation guarantee that:
- // - Y pixel stride is always 1
- // - U and V strides are the same
- // So, passing all these parameters is a bit overkill
- int status = YuvImage.CreateYUVImage(Y, U, V, im.getPlanes()[0].getPixelStride(),
- im.getPlanes()[0].getRowStride(), im.getPlanes()[1].getPixelStride(),
- im.getPlanes()[1].getRowStride(), im.getPlanes()[2].getPixelStride(),
- im.getPlanes()[2].getRowStride(), MainScreen.getImageWidth(), MainScreen.getImageHeight(), 0);
-
- if (status != 0)
- Log.e("CapturePlugin", "Error while cropping: " + status);
-
- compressed_frame[n] = YuvImage.GetFrame(0);
- compressed_frame_len[n] = MainScreen.getImageWidth() * MainScreen.getImageHeight()
- + MainScreen.getImageWidth() * ((MainScreen.getImageHeight() + 1) / 2);
- isYUV = true;
- } else if (im.getFormat() == ImageFormat.JPEG)
- {
- Log.e("CapturePlugin", "JPEG Image received");
- ByteBuffer jpeg = im.getPlanes()[0].getBuffer();
-
- frame_len = jpeg.limit();
- byte[] jpegByteArray = new byte[frame_len];
- jpeg.get(jpegByteArray, 0, frame_len);
-
- compressed_frame[n] = SwapHeap.SwapToHeap(jpegByteArray);
- compressed_frame_len[n] = frame_len;
-
- if (n == 0)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromJPEG(jpegByteArray, SessionID, -1);
- }
+
+ compressed_frame[n] = frame;
+ compressed_frame_len[n] = frame_len;
PluginManager.getInstance().addToSharedMem("frame" + (n + 1) + SessionID, String.valueOf(compressed_frame[n]));
PluginManager.getInstance().addToSharedMem("framelen" + (n + 1) + SessionID,
@@ -608,14 +332,14 @@ else if (frame_num == 1)
}
}
- @TargetApi(19)
+ @TargetApi(21)
@Override
public void onCaptureCompleted(CaptureResult result)
{
- if (result.get(CaptureResult.REQUEST_ID) == requestID)
+ if (result.getSequenceId() == requestID)
{
if (evIdx[frame_num] == 0)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromCaptureResult(result, SessionID);
+ PluginManager.getInstance().addToSharedMemExifTagsFromCaptureResult(result, SessionID);
}
}
@@ -817,11 +541,11 @@ public void NotEnoughMemory()
public void CaptureFrame()
{
- // only requesting exposure change here
- evRequested = evValues[cur_ev];
- cur_ev += 1;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_SET_EXPOSURE);
+ MainScreen.getGUIManager().showCaptureIndication();
+ MainScreen.getInstance().playShutter();
+
+ boolean isHDRMode = PluginManager.getInstance().getActiveModeID().equals("hdrmode");
+ requestID = CameraController.captureImagesWithParams(3, isHDRMode? CameraController.YUV : CameraController.JPEG, new int[0], evValues);
}
public void onAutoFocus(boolean paramBoolean)
@@ -844,43 +568,22 @@ public void onAutoFocus(boolean paramBoolean)
// onPreviewFrame is used only to provide an exact delay between setExposure
// and takePicture
@Override
- public void onPreviewFrame(byte[] data, Camera paramCamera)
+ public void onPreviewFrame(byte[] data)
{
- if (evLatency > 0)
- {
- previewWorking = true;
- if (--evLatency == 0)
- {
- if (cdt != null)
- {
- cdt.cancel();
- cdt = null;
- }
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_TAKE_PICTURE);
- }
- return;
- }
- }
-
- @TargetApi(19)
- @Override
- public void onPreviewAvailable(Image im)
- {
- if (evLatency > 0)
- {
- previewWorking = true;
- if (--evLatency == 0)
- {
- if (cdt != null)
- {
- cdt.cancel();
- cdt = null;
- }
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_TAKE_PICTURE);
- }
- return;
- }
+// if (evLatency > 0)
+// {
+// previewWorking = true;
+// if (--evLatency == 0)
+// {
+// if (cdt != null)
+// {
+// cdt.cancel();
+// cdt = null;
+// }
+// PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
+// PluginManager.MSG_TAKE_PICTURE);
+// }
+// return;
+// }
}
}
diff --git a/src/com/almalence/plugins/capture/groupshot/GroupShotCapturePlugin.java b/src/com/almalence/plugins/capture/groupshot/GroupShotCapturePlugin.java
deleted file mode 100755
index 7bce8cf3..00000000
--- a/src/com/almalence/plugins/capture/groupshot/GroupShotCapturePlugin.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (the "License"); you may not use this file except in
-compliance with the License. You may obtain a copy of the License at
-http://www.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is collection of files collectively known as Open Camera.
-
-The Initial Developer of the Original Code is Almalence Inc.
-Portions created by Initial Developer are Copyright (C) 2013
-by Almalence Inc. All Rights Reserved.
- */
-
-package com.almalence.plugins.capture.groupshot;
-
-import java.nio.ByteBuffer;
-import android.annotation.TargetApi;
-import android.content.SharedPreferences;
-import android.hardware.Camera;
-import android.hardware.camera2.CaptureResult;
-import android.media.Image;
-import android.os.CountDownTimer;
-import android.os.Message;
-import android.preference.PreferenceManager;
-import android.util.Log;
-
-/* */
-//
-import com.almalence.SwapHeap;
-import com.almalence.YuvImage;
-
-/***
- * Implements group shot capture plugin - captures predefined number of images
- ***/
-
-public class GroupShotCapturePlugin extends PluginCapture
-{
- // defaul val. value should come from config
- private int imageAmount = 5;
- private int pauseBetweenShots = 0;
-
- private int imagesTaken = 0;
-
- private String sImagesAmountPref;
- private String sPauseBetweenShotsPref;
-
- public GroupShotCapturePlugin()
- {
- super("com.almalence.plugins.groupshotcapture", R.xml.preferences_capture_groupshot, 0, 0, null);
- }
-
- @Override
- public void onCreate()
- {
- sImagesAmountPref = MainScreen.getInstance().getResources()
- .getString(R.string.Preference_GroupShotImagesAmountPref);
- sPauseBetweenShotsPref = MainScreen.getInstance().getResources()
- .getString(R.string.Preference_GroupShotPauseBetweenShotsPref);
- }
-
- @Override
- public void onResume()
- {
- takingAlready = false;
- imagesTaken = 0;
- inCapture = false;
- refreshPreferences();
-
- MainScreen.setCaptureYUVFrames(true);
- }
-
- @Override
- public void onGUICreate()
- {
- MainScreen.getGUIManager().showHelp(MainScreen.getInstance().getString(R.string.GroupShot_Help_Header),
- MainScreen.getInstance().getResources().getString(R.string.GroupShot_Help),
- R.drawable.plugin_help_groupshot, "groupshotRemovalShowHelp");
- }
-
- private void refreshPreferences()
- {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
- imageAmount = Integer.parseInt(prefs.getString(sImagesAmountPref, "7"));
- pauseBetweenShots = Integer.parseInt(prefs.getString(sPauseBetweenShotsPref, "750"));
- }
-
- public boolean delayedCaptureSupported()
- {
- return true;
- }
-
- public void takePicture()
- {
- if (!inCapture)
- {
- refreshPreferences();
- inCapture = true;
- takingAlready = true;
-
- if (imagesTaken == 0 || pauseBetweenShots == 0)
- {
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_NEXT_FRAME);
- } else
- {
- new CountDownTimer(pauseBetweenShots, pauseBetweenShots)
- {
- public void onTick(long millisUntilFinished)
- {
- }
-
- public void onFinish()
- {
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_NEXT_FRAME);
- }
- }.start();
- }
- }
- }
-
- @Override
- public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
- {
- imagesTaken++;
- int frame_len = paramArrayOfByte.length;
- int frame = SwapHeap.SwapToHeap(paramArrayOfByte);
-
- if (frame == 0)
- {
- Log.i("Group Shot", "Load to heap failed");
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- imagesTaken = 0;
- MainScreen.getInstance().muteShutter(false);
- inCapture = false;
- return;
- }
- String frameName = "frame" + imagesTaken;
- String frameLengthName = "framelen" + imagesTaken;
-
- PluginManager.getInstance().addToSharedMem(frameName + SessionID, String.valueOf(frame));
- PluginManager.getInstance().addToSharedMem(frameLengthName + SessionID, String.valueOf(frame_len));
-
- if (imagesTaken == 1)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromJPEG(paramArrayOfByte, SessionID, -1);
-
- try
- {
- paramCamera.startPreview();
- } catch (RuntimeException e)
- {
- Log.i("Group Shot", "StartPreview fail");
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- imagesTaken = 0;
- MainScreen.getInstance().muteShutter(false);
- inCapture = false;
- return;
- }
- if (imagesTaken < imageAmount)
- {
- inCapture = false;
- MainScreen.getMessageHandler().sendEmptyMessage(PluginManager.MSG_TAKE_PICTURE);
- } else
- {
- PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
- String.valueOf(imagesTaken));
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- imagesTaken = 0;
-
- // call timer to reset inCapture
- new CountDownTimer(5000, 5000)
- {
- public void onTick(long millisUntilFinished)
- {
- }
-
- public void onFinish()
- {
- inCapture = false;
- }
- }.start();
- }
- takingAlready = false;
- }
-
- @TargetApi(19)
- @Override
- public void onImageAvailable(Image im)
- {
- imagesTaken++;
-
- ByteBuffer Y = im.getPlanes()[0].getBuffer();
- ByteBuffer U = im.getPlanes()[1].getBuffer();
- ByteBuffer V = im.getPlanes()[2].getBuffer();
-
- if ((!Y.isDirect()) || (!U.isDirect()) || (!V.isDirect()))
- {
- Log.e("CapturePlugin", "Oops, YUV ByteBuffers isDirect failed");
- return;
- }
-
- // Note: android documentation guarantee that:
- // - Y pixel stride is always 1
- // - U and V strides are the same
- // So, passing all these parameters is a bit overkill
- int status = YuvImage.CreateYUVImage(Y, U, V, im.getPlanes()[0].getPixelStride(),
- im.getPlanes()[0].getRowStride(), im.getPlanes()[1].getPixelStride(), im.getPlanes()[1].getRowStride(),
- im.getPlanes()[2].getPixelStride(), im.getPlanes()[2].getRowStride(), MainScreen.getImageWidth(),
- MainScreen.getImageHeight(), 0);
-
- if (status != 0)
- Log.e("CapturePlugin", "Error while cropping: " + status);
-
- byte[] byte_frame = YuvImage.GetByteFrame(0);
- int frame_len = byte_frame.length;
- int frame = SwapHeap.SwapToHeap(byte_frame);
-
- if (frame == 0)
- {
- Log.i("Group Shot", "Load to heap failed");
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- imagesTaken = 0;
- MainScreen.getInstance().muteShutter(false);
- inCapture = false;
- return;
- }
- String frameName = "frame" + imagesTaken;
- String frameLengthName = "framelen" + imagesTaken;
-
- PluginManager.getInstance().addToSharedMem(frameName + SessionID, String.valueOf(frame));
- PluginManager.getInstance().addToSharedMem(frameLengthName + SessionID, String.valueOf(frame_len));
-
- PluginManager.getInstance().addToSharedMem("isyuv" + SessionID, String.valueOf(true));
-
- try
- {
- CameraController.startCameraPreview();
- } catch (RuntimeException e)
- {
- Log.i("Group Shot", "StartPreview fail");
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- imagesTaken = 0;
- MainScreen.getInstance().muteShutter(false);
- inCapture = false;
- return;
- }
- if (imagesTaken < imageAmount)
- {
- inCapture = false;
- MainScreen.getMessageHandler().sendEmptyMessage(PluginManager.MSG_TAKE_PICTURE);
- } else
- {
- PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
- String.valueOf(imagesTaken));
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- imagesTaken = 0;
-
- inCapture = false;
- }
- takingAlready = false;
- }
-
- @TargetApi(19)
- @Override
- public void onCaptureCompleted(CaptureResult result)
- {
- if (result.get(CaptureResult.REQUEST_ID) == requestID)
- {
- if (imagesTaken == 1)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromCaptureResult(result, SessionID);
- }
- }
-
- @Override
- public void onAutoFocus(boolean paramBoolean)
- {
- if (takingAlready)
- takePicture();
- }
-
- @Override
- public boolean onBroadcast(int arg1, int arg2)
- {
- if (arg1 == PluginManager.MSG_NEXT_FRAME)
- {
- // play tick sound
- MainScreen.getGUIManager().showCaptureIndication();
- MainScreen.getInstance().playShutter();
- try
- {
- requestID = CameraController.captureImage(1, CameraController.YUV);
- } catch (RuntimeException exp)
- {
- inCapture = false;
- takingAlready = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
-
- MainScreen.getGUIManager().lockControls = false;
- }
-
- return true;
- }
- return false;
- }
-
- @Override
- public void onPreviewFrame(byte[] data, Camera paramCamera)
- {
- }
-}
diff --git a/src/com/almalence/plugins/capture/multishot/MultiShotCapturePlugin.java b/src/com/almalence/plugins/capture/multishot/MultiShotCapturePlugin.java
index 3d71e842..af3e295d 100755
--- a/src/com/almalence/plugins/capture/multishot/MultiShotCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/multishot/MultiShotCapturePlugin.java
@@ -19,6 +19,8 @@ Portions created by Initial Developer are Copyright (C) 2013
package com.almalence.plugins.capture.multishot;
import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
import android.annotation.TargetApi;
import android.content.SharedPreferences;
@@ -26,10 +28,17 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.hardware.camera2.CaptureResult;
import android.media.Image;
import android.os.CountDownTimer;
-import android.os.Message;
+import android.os.Debug;
import android.preference.PreferenceManager;
import android.util.Log;
+//-+- -->
+import com.almalence.SwapHeap;
+import com.almalence.YuvImage;
+import com.almalence.opencam.MainScreen;
+import com.almalence.opencam.PluginCapture;
+import com.almalence.opencam.PluginManager;
+import com.almalence.opencam.R;
/* */
//
-import com.almalence.SwapHeap;
-import com.almalence.YuvImage;
/***
* Implements group shot capture plugin - captures predefined number of images
@@ -54,16 +56,51 @@ Portions created by Initial Developer are Copyright (C) 2013
public class MultiShotCapturePlugin extends PluginCapture
{
- private static final String TAG = "MultiShotCapturePlugin";
+ private static final String TAG = "MultiShotCapturePlugin";
+
+ private static final int MIN_MPIX_SUPPORTED = 1280 * 960;
+ private static final int MIN_MPIX_PREVIEW = 600 * 400;
+ private static final long MPIX_8 = 3504 * 2336;
+ private static final long MPIX_1080 = 1920 * 1088;
+
+ private static List ResolutionsSizesList; ;
+ private static List ResolutionsMPixList;
+ private static List ResolutionsIdxesList;
+ private static List ResolutionsNamesList;
+
+ private static int captureIndex = -1;
+
+ public static int getCaptureIndex()
+ {
+ return captureIndex;
+ }
+
+ private static int imgCaptureWidth = 0;
+ private static int imgCaptureHeight = 0;
+
+ public static List getResolutionsMPixList()
+ {
+ return ResolutionsMPixList;
+ }
+
+ public static List getResolutionsIdxesList()
+ {
+ return ResolutionsIdxesList;
+ }
+
+ public static List getResolutionsNamesList()
+ {
+ return ResolutionsNamesList;
+ }
// defaul val. value should come from config
- private int imageAmount = 1;
- private int pauseBetweenShots = 0;
- private int imagesTaken = 0;
+ private int imageAmount = 8;
+ private int[] pauseBetweenShots = { 0, 0, 250, 250, 500, 750, 1000, 1250 };
+ private int imagesTaken = 0;
public MultiShotCapturePlugin()
{
- super("com.almalence.plugins.multishotcapture", R.xml.preferences_capture_multishot, 0, 0, null);
+ super("com.almalence.plugins.multishotcapture", 0, 0, 0, null);
}
@Override
@@ -73,8 +110,6 @@ public void onResume()
imagesTaken = 0;
inCapture = false;
- refreshPreferences();
-
MainScreen.setCaptureYUVFrames(true);
}
@@ -86,13 +121,6 @@ public void onGUICreate()
R.drawable.plugin_help_object, "multiShotShowHelp");
}
- private void refreshPreferences()
- {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
- imageAmount = Integer.parseInt(prefs.getString("multiShotImagesAmount", "7"));
- pauseBetweenShots = Integer.parseInt(prefs.getString("multiShotPauseBetweenShots", "750"));
- }
-
public boolean delayedCaptureSupported()
{
return true;
@@ -104,43 +132,34 @@ public void takePicture()
{
inCapture = true;
takingAlready = true;
- refreshPreferences();
-
- if (imagesTaken == 0 || pauseBetweenShots == 0)
+
+ try
{
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_NEXT_FRAME);
- } else
+ requestID = CameraController.captureImagesWithParams(imageAmount, CameraController.YUV, pauseBetweenShots, null);
+ } catch (Exception e)
{
- new CountDownTimer(pauseBetweenShots, pauseBetweenShots)
- {
- public void onTick(long millisUntilFinished)
- {
- }
-
- public void onFinish()
- {
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_NEXT_FRAME);
- }
- }.start();
+ e.printStackTrace();
+ Log.e(TAG, "CameraController.captureImage failed: " + e.getMessage());
+ inCapture = false;
+ takingAlready = false;
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
+ PluginManager.MSG_CONTROL_UNLOCKED);
+ MainScreen.getGUIManager().lockControls = false;
}
}
}
+
@Override
- public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
+ public void onImageTaken(int frame, byte[] frameData, int frame_len, boolean isYUV)
{
imagesTaken++;
- int frame_len = paramArrayOfByte.length;
- int frame = SwapHeap.SwapToHeap(paramArrayOfByte);
if (frame == 0)
{
Log.i(TAG, "Load to heap failed");
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED, String.valueOf(SessionID));
imagesTaken = 0;
MainScreen.getInstance().muteShutter(false);
@@ -157,36 +176,30 @@ public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
PluginManager.getInstance().addToSharedMem("framemirrored" + imagesTaken + SessionID,
String.valueOf(CameraController.isFrontCamera()));
- PluginManager.getInstance().addToSharedMem("isyuv" + SessionID, String.valueOf(false));
+ PluginManager.getInstance().addToSharedMem("isyuv" + SessionID, String.valueOf(isYUV));
- if (imagesTaken == 1)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromJPEG(paramArrayOfByte, SessionID, -1);
+ if (imagesTaken == 1 && !isYUV)
+ PluginManager.getInstance().addToSharedMemExifTagsFromJPEG(frameData, SessionID, -1);
try
{
- paramCamera.startPreview();
+ CameraController.startCameraPreview();
} catch (RuntimeException e)
{
Log.i(TAG, "StartPreview fail");
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED, String.valueOf(SessionID));
imagesTaken = 0;
MainScreen.getInstance().muteShutter(false);
inCapture = false;
return;
}
- if (imagesTaken < imageAmount)
- {
- inCapture = false;
- MainScreen.getMessageHandler().sendEmptyMessage(PluginManager.MSG_TAKE_PICTURE);
- } else
+ if (imagesTaken >= imageAmount)
{
PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
String.valueOf(imagesTaken));
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED, String.valueOf(SessionID));
imagesTaken = 0;
new CountDownTimer(5000, 5000)
@@ -204,144 +217,237 @@ public void onFinish()
takingAlready = false;
}
- @TargetApi(19)
+ @TargetApi(21)
@Override
- public void onImageAvailable(Image im)
+ public void onCaptureCompleted(CaptureResult result)
{
- imagesTaken++;
-
- ByteBuffer Y = im.getPlanes()[0].getBuffer();
- ByteBuffer U = im.getPlanes()[1].getBuffer();
- ByteBuffer V = im.getPlanes()[2].getBuffer();
-
- if ((!Y.isDirect()) || (!U.isDirect()) || (!V.isDirect()))
+ if (result.getSequenceId() == requestID)
{
- Log.e("CapturePlugin", "Oops, YUV ByteBuffers isDirect failed");
- return;
+ if (imagesTaken == 1)
+ PluginManager.getInstance().addToSharedMemExifTagsFromCaptureResult(result, SessionID);
}
+ }
- // Note: android documentation guarantee that:
- // - Y pixel stride is always 1
- // - U and V strides are the same
- // So, passing all these parameters is a bit overkill
- int status = YuvImage.CreateYUVImage(Y, U, V, im.getPlanes()[0].getPixelStride(),
- im.getPlanes()[0].getRowStride(), im.getPlanes()[1].getPixelStride(), im.getPlanes()[1].getRowStride(),
- im.getPlanes()[2].getPixelStride(), im.getPlanes()[2].getRowStride(), MainScreen.getImageWidth(),
- MainScreen.getImageHeight(), 0);
+ @Override
+ public void onAutoFocus(boolean paramBoolean)
+ {
+ if (takingAlready)
+ takePicture();
+ }
- if (status != 0)
- Log.e("CapturePlugin", "Error while cropping: " + status);
+ @Override
+ public void onPreviewFrame(byte[] data)
+ {
+ }
- int frame = YuvImage.GetFrame(0);
- int frame_len = MainScreen.getImageWidth() * MainScreen.getImageHeight() + MainScreen.getImageWidth()
- * ((MainScreen.getImageHeight() + 1) / 2);
+ @Override
+ public void selectImageDimension()
+ {
+ selectImageDimensionMultishot();
+ setCameraImageSize();
+ }
- if (frame == 0)
+ private void setCameraImageSize()
+ {
+ if (imgCaptureWidth > 0 && imgCaptureHeight > 0)
{
- Log.e(TAG, "Load to heap failed");
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
+ MainScreen.setSaveImageWidth(imgCaptureWidth);
+ MainScreen.setSaveImageHeight(imgCaptureHeight);
- imagesTaken = 0;
- MainScreen.getInstance().muteShutter(false);
- inCapture = false;
- return;
+ MainScreen.setImageWidth(imgCaptureWidth);
+ MainScreen.setImageHeight(imgCaptureHeight);
}
- String frameName = "frame" + imagesTaken;
- String frameLengthName = "framelen" + imagesTaken;
+ }
- PluginManager.getInstance().addToSharedMem(frameName + SessionID, String.valueOf(frame));
- PluginManager.getInstance().addToSharedMem(frameLengthName + SessionID, String.valueOf(frame_len));
- PluginManager.getInstance().addToSharedMem("frameorientation" + imagesTaken + SessionID,
- String.valueOf(MainScreen.getGUIManager().getDisplayOrientation()));
- PluginManager.getInstance().addToSharedMem("framemirrored" + imagesTaken + SessionID,
- String.valueOf(CameraController.isFrontCamera()));
+ public static void selectImageDimensionMultishot()
+ {
+ populateCameraDimensions();
- PluginManager.getInstance().addToSharedMem("isyuv" + SessionID, String.valueOf(true));
+ long maxMem = Runtime.getRuntime().maxMemory() - Debug.getNativeHeapAllocatedSize();
+ long maxMpix = (maxMem - 1000000) / 3; // 2 x Mpix - result, 1/4 x Mpix
+ // x 4 - compressed input jpegs,
+ // 1Mb - safe reserve
- try
+ if (maxMpix < MIN_MPIX_SUPPORTED)
{
- CameraController.startCameraPreview();
- } catch (RuntimeException e)
- {
- Log.e(TAG, "StartPreview fail");
+ String msg;
+ msg = "MainScreen.selectImageDimension maxMem = " + maxMem;
+ Log.e("MultishotCapturePlugin", "MainScreen.selectImageDimension maxMpix < MIN_MPIX_SUPPORTED");
+ Log.e("MultishotCapturePlugin", msg);
+ }
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
+ // find index selected in preferences
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
+ int prefIdx = Integer.parseInt(prefs.getString(
+ CameraController.getCameraIndex() == 0 ? "imageSizePrefSmartMultishotBack"
+ : "imageSizePrefSmartMultishotFront", "-1"));
+
+ // ----- Find max-resolution capture dimensions
+ int minMPIX = MIN_MPIX_PREVIEW;
+
+ int defaultCaptureIdx = -1;
+ long defaultCaptureMpix = 0;
+ int defaultCaptureWidth = 0;
+ int defaultCaptureHeight = 0;
+ long captureMpix = 0;
+ int captureWidth = 0;
+ int captureHeight = 0;
+ int captureIdx = -1;
+ boolean prefFound = false;
+
+ // figure default resolution
+ for (int ii = 0; ii < ResolutionsSizesList.size(); ++ii)
+ {
+ CameraController.Size s = ResolutionsSizesList.get(ii);
+ long mpix = (long) s.getWidth() * s.getHeight();
- imagesTaken = 0;
- MainScreen.getInstance().muteShutter(false);
- inCapture = false;
- return;
+ if ((mpix >= minMPIX) && (mpix < maxMpix) && (mpix > defaultCaptureMpix) && (mpix <= MPIX_8))
+ {
+ defaultCaptureIdx = ii;
+ defaultCaptureMpix = mpix;
+ defaultCaptureWidth = s.getWidth();
+ defaultCaptureHeight = s.getHeight();
+ }
}
- if (imagesTaken < imageAmount)
- {
- inCapture = false;
- MainScreen.getMessageHandler().sendEmptyMessage(PluginManager.MSG_TAKE_PICTURE);
- } else
+
+ for (int ii = 0; ii < ResolutionsSizesList.size(); ++ii)
{
- PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
- String.valueOf(imagesTaken));
+ CameraController.Size s = ResolutionsSizesList.get(ii);
+ long mpix = (long) s.getWidth() * s.getHeight();
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
+ if ((ii == prefIdx) && (mpix >= minMPIX))
+ {
+ prefFound = true;
+ captureIdx = ii;
+ captureMpix = mpix;
+ captureWidth = s.getWidth();
+ captureHeight = s.getHeight();
+ break;
+ }
- imagesTaken = 0;
- inCapture = false;
+ if (mpix > captureMpix)
+ {
+ captureIdx = ii;
+ captureMpix = mpix;
+ captureWidth = s.getWidth();
+ captureHeight = s.getHeight();
+ }
}
- takingAlready = false;
- }
-
- @TargetApi(19)
- @Override
- public void onCaptureCompleted(CaptureResult result)
- {
- if (result.get(CaptureResult.REQUEST_ID) == requestID)
+ // default to about 8Mpix if nothing is set in preferences or maximum
+ // resolution is above memory limits
+ if (defaultCaptureMpix > 0 && !prefFound)
{
- if (imagesTaken == 1)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromCaptureResult(result, SessionID);
+ captureIdx = defaultCaptureIdx;
+ captureMpix = defaultCaptureMpix;
+ captureWidth = defaultCaptureWidth;
+ captureHeight = defaultCaptureHeight;
}
- }
- @Override
- public void onAutoFocus(boolean paramBoolean)
- {
- if (takingAlready)
- takePicture();
+ captureIndex = captureIdx;
+ imgCaptureWidth = captureWidth;
+ imgCaptureHeight = captureHeight;
}
- @Override
- public boolean onBroadcast(int arg1, int arg2)
+ public static void populateCameraDimensions()
{
- if (arg1 == PluginManager.MSG_NEXT_FRAME)
+ ResolutionsMPixList = new ArrayList();
+ ResolutionsIdxesList = new ArrayList();
+ ResolutionsNamesList = new ArrayList();
+
+ List cs;
+ int minMPIX = MIN_MPIX_PREVIEW;
+ cs = CameraController.getInstance().getResolutionsSizeList();
+ ResolutionsSizesList = new ArrayList(cs);
+
+ List csPreview = CameraController.getInstance().getSupportedPreviewSizes();
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
+ int prefIdx = Integer.parseInt(prefs.getString("imageSizePrefSmartMultishotBack", "-1"));
+ for (int i = 0; i < ResolutionsSizesList.size(); i++)
{
- // play tick sound
- MainScreen.getGUIManager().showCaptureIndication();
- MainScreen.getInstance().playShutter();
+ CameraController.Size s = ResolutionsSizesList.get(i);
+ CameraController.Size sPreview = csPreview.get(0);
- try
+ if (s.getHeight() * s.getWidth() < sPreview.getHeight() * sPreview.getWidth())
{
- requestID = CameraController.captureImage(1, CameraController.YUV);
- } catch (Exception e)
+ ResolutionsSizesList.add(i, sPreview);
+ if (sPreview.getHeight() * sPreview.getWidth() > MPIX_1080) {
+ if (prefIdx == -1) {
+ SharedPreferences.Editor prefEditor = prefs.edit();
+ prefEditor.putString("imageSizePrefSmartMultishotBack", String.valueOf(i));
+ prefEditor.commit();
+ }
+ }
+ break;
+ }
+
+ if ((ResolutionsSizesList.size() - 1 == i)
+ && (s.getHeight() * s.getWidth() != sPreview.getHeight() * sPreview.getWidth()))
{
- e.printStackTrace();
- Log.e(TAG, "CameraController.captureImage failed: " + e.getMessage());
- inCapture = false;
- takingAlready = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
- MainScreen.getGUIManager().lockControls = false;
+ ResolutionsSizesList.add(sPreview);
+ if (sPreview.getHeight() * sPreview.getWidth() > MPIX_1080) {
+ if (prefIdx == -1) {
+ SharedPreferences.Editor prefEditor = prefs.edit();
+ prefEditor.putString("imageSizePrefSmartMultishotBack", String.valueOf(i + 1));
+ prefEditor.commit();
+ }
+ }
+ break;
+ }
+ }
+
+ for (int i = 0; i < ResolutionsSizesList.size(); i++)
+ {
+ CameraController.Size s = ResolutionsSizesList.get(i);
+ CameraController.Size sPreview = csPreview.get(1);
+
+ if (s.getHeight() * s.getWidth() < sPreview.getHeight() * sPreview.getWidth())
+ {
+ ResolutionsSizesList.add(i, sPreview);
+ break;
}
- return true;
+ if ((ResolutionsSizesList.size() - 1 == i)
+ && (s.getHeight() * s.getWidth() != sPreview.getHeight() * sPreview.getWidth()))
+ {
+ ResolutionsSizesList.add(sPreview);
+ break;
+ }
}
- return false;
- }
- @Override
- public void onPreviewFrame(byte[] data, Camera paramCamera)
- {
+ CharSequence[] ratioStrings = { " ", "4:3", "3:2", "16:9", "1:1" };
+
+ for (int ii = 0; ii < ResolutionsSizesList.size(); ++ii)
+ {
+ CameraController.Size s = ResolutionsSizesList.get(ii);
+
+ if ((long) s.getWidth() * s.getHeight() < minMPIX)
+ continue;
+
+ Long lmpix = (long) s.getWidth() * s.getHeight();
+ float mpix = (float) lmpix / 1000000.f;
+ float ratio = (float) s.getWidth() / s.getHeight();
+
+ // find good location in a list
+ int loc;
+ for (loc = 0; loc < ResolutionsMPixList.size(); ++loc)
+ if (ResolutionsMPixList.get(loc) < lmpix)
+ break;
+
+ int ri = 0;
+ if (Math.abs(ratio - 4 / 3.f) < 0.1f)
+ ri = 1;
+ if (Math.abs(ratio - 3 / 2.f) < 0.12f)
+ ri = 2;
+ if (Math.abs(ratio - 16 / 9.f) < 0.15f)
+ ri = 3;
+ if (Math.abs(ratio - 1) == 0)
+ ri = 4;
+
+ ResolutionsNamesList.add(loc, String.format("%3.1f Mpix " + ratioStrings[ri], mpix));
+ ResolutionsIdxesList.add(loc, String.format("%d", ii));
+ ResolutionsMPixList.add(loc, lmpix);
+ }
}
}
\ No newline at end of file
diff --git a/src/com/almalence/plugins/capture/night/NightCapturePlugin.java b/src/com/almalence/plugins/capture/night/NightCapturePlugin.java
index 17378aaa..83a92e11 100755
--- a/src/com/almalence/plugins/capture/night/NightCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/night/NightCapturePlugin.java
@@ -92,6 +92,14 @@ public class NightCapturePlugin extends PluginCapture
private static final int HI_RES_FRAMES = 8;
private static final int MIN_MPIX_SUPPORTED = 1280 * 960;
private static final int MIN_MPIX_PREVIEW = 600 * 400;
+ private static final long MPIX_8 = 3504 * 2336; // Actually
+ // 8.2
+ // mpix,
+ // some
+ // reserve
+ // for
+ // unusual
+ // cameras;
private static Toast capturingDialog;
@@ -101,7 +109,7 @@ public class NightCapturePlugin extends PluginCapture
private int nVFframesToBuffer;
// shared between activities
- private static int CapIdx;
+ public static int CapIdx;
private static int total_frames;
private static int[] compressed_frame = new int[HI_SPEED_FRAMES];
private static int[] compressed_frame_len = new int[HI_SPEED_FRAMES];
@@ -134,9 +142,9 @@ public class NightCapturePlugin extends PluginCapture
float currHalfWidth;
float currHalfHeight;
- int captureIndex = -1;
- int imgCaptureWidth = 0;
- int imgCaptureHeight = 0;
+ static int captureIndex = -1;
+ static int imgCaptureWidth = 0;
+ static int imgCaptureHeight = 0;
float cameraDist;
@@ -148,6 +156,21 @@ public class NightCapturePlugin extends PluginCapture
private static String ImageSizeIdxPreference;
private static List ResolutionsMPixList;
+ public static List getResolutionsMPixList()
+ {
+ return ResolutionsMPixList;
+ }
+
+ public static List getResolutionsIdxesList()
+ {
+ return ResolutionsIdxesList;
+ }
+
+ public static List getResolutionsNamesList()
+ {
+ return ResolutionsNamesList;
+ }
+
private static List ResolutionsIdxesList;
private static List ResolutionsNamesList;
@@ -385,7 +408,7 @@ public void onShowPreferences()
selectImageDimension();
}
- private void selectImageDimensionNight()
+ public static void selectImageDimensionNight()
{
int mode = Integer.parseInt(ModePreference);
@@ -437,14 +460,14 @@ private void selectImageDimensionNight()
}
}
- int capture5mIdx = -1;
- long capture5mMpix = 0;
- int capture5mWidth = 0;
- int capture5mHeight = 0;
- int captureIdx = -1;
+ int defaultCaptureIdx = -1;
+ long defaultCaptureMpix = 0;
+ int defaultCaptureWidth = 0;
+ int defaultCaptureHeight = 0;
long captureMpix = 0;
int captureWidth = 0;
int captureHeight = 0;
+ int captureIdx = -1;
boolean prefFound = false;
// figure default resolution
@@ -453,12 +476,12 @@ private void selectImageDimensionNight()
CameraController.Size s = cs.get(ii);
long mpix = (long) s.getWidth() * s.getHeight();
- if ((mpix >= minMPIX) && (mpix < maxMpix) && (mpix > capture5mMpix))
+ if ((mpix >= minMPIX) && (mpix < maxMpix) && (mpix > defaultCaptureMpix) && (mpix <= MPIX_8))
{
- capture5mIdx = ii;
- capture5mMpix = mpix;
- capture5mWidth = s.getWidth();
- capture5mHeight = s.getHeight();
+ defaultCaptureIdx = ii;
+ defaultCaptureMpix = mpix;
+ defaultCaptureWidth = s.getWidth();
+ defaultCaptureHeight = s.getHeight();
}
}
@@ -486,17 +509,18 @@ private void selectImageDimensionNight()
}
}
- // default to about 5Mpix if nothing is set in preferences or maximum
+ // default to about 8Mpix if nothing is set in preferences or maximum
// resolution is above memory limits
- if (capture5mMpix > 0 && !prefFound)
+ if (defaultCaptureMpix > 0 && !prefFound)
{
- captureIdx = capture5mIdx;
- captureMpix = capture5mMpix;
- captureWidth = capture5mWidth;
- captureHeight = capture5mHeight;
+ captureIdx = defaultCaptureIdx;
+ captureMpix = defaultCaptureMpix;
+ captureWidth = defaultCaptureWidth;
+ captureHeight = defaultCaptureHeight;
}
captureIndex = captureIdx;
+ CapIdx = captureIdx;
imgCaptureWidth = captureWidth;
imgCaptureHeight = captureHeight;
}
@@ -587,11 +611,9 @@ public void setCameraPictureSize()
{
CameraController.getInstance().setPictureSize(MainScreen.getImageWidth(), MainScreen.getImageHeight());
CameraController.getInstance().setJpegQuality(100);
-
- CameraController.getInstance().applyCameraParameters();
}
- byte[] sceneModes = CameraController.getInstance().getSupportedSceneModes();
+ int[] sceneModes = CameraController.getInstance().getSupportedSceneModes();
if (sceneModes != null && CameraController.isModeAvailable(sceneModes, CameraParameters.SCENE_MODE_NIGHT)
&& (!Build.MODEL.contains("Nexus")))
{
@@ -605,7 +627,7 @@ public void setCameraPictureSize()
try
{
- byte[] focusModes = CameraController.getInstance().getSupportedFocusModes();
+ int[] focusModes = CameraController.getInstance().getSupportedFocusModes();
if (focusModes != null)
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
@@ -651,7 +673,7 @@ public void setCameraPictureSize()
try
{
- byte[] flashModes = CameraController.getInstance().getSupportedFlashModes();
+ int[] flashModes = CameraController.getInstance().getSupportedFlashModes();
if (flashModes != null)
{
CameraController.getInstance().setCameraSceneMode(CameraParameters.SCENE_MODE_AUTO);
@@ -813,57 +835,6 @@ public void onPreferenceCreate(PreferenceActivity prefActivity)
{
final PreferenceActivity mPref = prefActivity;
- CharSequence[] entries;
- CharSequence[] entryValues;
-
- if (ResolutionsIdxesList != null)
- {
- entries = ResolutionsNamesList.toArray(new CharSequence[ResolutionsNamesList.size()]);
- entryValues = ResolutionsIdxesList.toArray(new CharSequence[ResolutionsIdxesList.size()]);
-
- PreferenceCategory cat = (PreferenceCategory) prefActivity.findPreference("Pref_NightCapture_Category");
- ListPreference lp = (ListPreference) prefActivity.findPreference("imageSizePrefNightBack");
- ListPreference lp2 = (ListPreference) prefActivity.findPreference("imageSizePrefNightFront");
-
- if (CameraController.getCameraIndex() == 0 && lp2 != null)
- cat.removePreference(lp2);
- else if (lp != null && lp2 != null)
- {
- cat.removePreference(lp);
- lp = lp2;
- }
- if (lp != null)
- {
- lp.setEntries(entries);
- lp.setEntryValues(entryValues);
-
- // set currently selected image size
- int idx;
- for (idx = 0; idx < ResolutionsIdxesList.size(); ++idx)
- {
- if (Integer.parseInt(ResolutionsIdxesList.get(idx)) == CapIdx)
- {
- break;
- }
- }
- if (idx < ResolutionsIdxesList.size())
- {
- lp.setValueIndex(idx);
- lp.setSummary(entries[idx]);
- lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener()
- {
- // @Override
- public boolean onPreferenceChange(Preference preference, Object newValue)
- {
- int value = Integer.parseInt(newValue.toString());
- CapIdx = value;
- return true;
- }
- });
- }
- }
- }
-
Preference fp = prefActivity.findPreference(nightCaptureFocusPref);
if (fp != null)
{
@@ -896,56 +867,6 @@ public void onPreferenceCreate(PreferenceFragment prefActivity)
{
final PreferenceFragment mPref = prefActivity;
- CharSequence[] entries;
- CharSequence[] entryValues;
-
- if (ResolutionsIdxesList != null)
- {
- entries = ResolutionsNamesList.toArray(new CharSequence[ResolutionsNamesList.size()]);
- entryValues = ResolutionsIdxesList.toArray(new CharSequence[ResolutionsIdxesList.size()]);
-
- PreferenceCategory cat = (PreferenceCategory) prefActivity.findPreference("Pref_NightCapture_Category");
- ListPreference lp = (ListPreference) prefActivity.findPreference("imageSizePrefNightBack");
- ListPreference lp2 = (ListPreference) prefActivity.findPreference("imageSizePrefNightFront");
-
- if (CameraController.getCameraIndex() == 0 && lp2 != null)
- cat.removePreference(lp2);
- else if (lp != null && lp2 != null)
- {
- cat.removePreference(lp);
- lp = lp2;
- }
- if (lp != null)
- {
- lp.setEntries(entries);
- lp.setEntryValues(entryValues);
-
- // set currently selected image size
- int idx;
- for (idx = 0; idx < ResolutionsIdxesList.size(); ++idx)
- {
- if (Integer.parseInt(ResolutionsIdxesList.get(idx)) == CapIdx)
- {
- break;
- }
- }
- if (idx < ResolutionsIdxesList.size())
- {
- lp.setValueIndex(idx);
- lp.setSummary(entries[idx]);
- lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener()
- {
- public boolean onPreferenceChange(Preference preference, Object newValue)
- {
- int value = Integer.parseInt(newValue.toString());
- CapIdx = value;
- return true;
- }
- });
- }
- }
- }
-
Preference fp = prefActivity.findPreference(nightCaptureFocusPref);
if (fp != null)
{
@@ -1051,7 +972,7 @@ else if (!takingAlready
{
inCapture = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
PluginManager.MSG_CONTROL_UNLOCKED);
MainScreen.getGUIManager().lockControls = false;
@@ -1060,11 +981,13 @@ else if (!takingAlready
}
}
+
@Override
- public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
+ public void onImageTaken(int frame, byte[] frameData, int frame_len, boolean isYUV)
{
- compressed_frame[frameNumber] = SwapHeap.SwapToHeap(paramArrayOfByte);
- compressed_frame_len[frameNumber] = paramArrayOfByte.length;
+ Log.e("Night", "onImageTaken");
+ compressed_frame[frameNumber] = frame;
+ compressed_frame_len[frameNumber] = frame_len;
PluginManager.getInstance().addToSharedMem("frame" + (frameNumber + 1) + SessionID,
String.valueOf(compressed_frame[frameNumber]));
@@ -1077,110 +1000,45 @@ public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
String.valueOf(CameraController.isFrontCamera()));
PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
String.valueOf(frameNumber + 1));
+
+ PluginManager.getInstance().addToSharedMem("isyuv" + SessionID, String.valueOf(isYUV));
- if (frameNumber == 0)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromJPEG(paramArrayOfByte, SessionID, -1);
-
- String message = MainScreen.getInstance().getResources().getString(R.string.capturing);
- message += " ";
- message += frameNumber + 1 + "/";
- message += total_frames;
- capturingDialog.setText(message);
- capturingDialog.show();
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_NEXT_FRAME);
- }
-
- @TargetApi(19)
- @Override
- public void onImageAvailable(Image im)
- {
- int frame_len = 0;
- boolean isYUV = false;
-
- if (im.getFormat() == ImageFormat.YUV_420_888)
+ if (frameNumber == 0 && !isYUV)
+ PluginManager.getInstance().addToSharedMemExifTagsFromJPEG(frameData, SessionID, -1);
+
+
+ try
{
- Log.e("CapturePlugin", "YUV Image received");
- ByteBuffer Y = im.getPlanes()[0].getBuffer();
- ByteBuffer U = im.getPlanes()[1].getBuffer();
- ByteBuffer V = im.getPlanes()[2].getBuffer();
-
- if ((!Y.isDirect()) || (!U.isDirect()) || (!V.isDirect()))
- {
- Log.e("CapturePlugin", "Oops, YUV ByteBuffers isDirect failed");
- return;
- }
-
- // Note: android documentation guarantee that:
- // - Y pixel stride is always 1
- // - U and V strides are the same
- // So, passing all these parameters is a bit overkill
- int status = YuvImage.CreateYUVImage(Y, U, V, im.getPlanes()[0].getPixelStride(),
- im.getPlanes()[0].getRowStride(), im.getPlanes()[1].getPixelStride(),
- im.getPlanes()[1].getRowStride(), im.getPlanes()[2].getPixelStride(),
- im.getPlanes()[2].getRowStride(), MainScreen.getImageWidth(), MainScreen.getImageHeight(), 0);
-
- if (status != 0)
- Log.e("CapturePlugin", "Error while cropping: " + status);
-
- compressed_frame[frameNumber] = YuvImage.GetFrame(0);
- compressed_frame_len[frameNumber] = MainScreen.getImageWidth() * MainScreen.getImageHeight()
- + MainScreen.getImageWidth() * ((MainScreen.getImageHeight() + 1) / 2);
- isYUV = true;
- } else if (im.getFormat() == ImageFormat.JPEG)
+ CameraController.startCameraPreview();
+ } catch (RuntimeException e)
{
- Log.e("NightCapturePlugin", "JPEG Image received");
- ByteBuffer jpeg = im.getPlanes()[0].getBuffer();
-
- frame_len = jpeg.limit();
- byte[] jpegByteArray = new byte[frame_len];
- jpeg.get(jpegByteArray, 0, frame_len);
-
- compressed_frame[frameNumber] = SwapHeap.SwapToHeap(jpegByteArray);
- compressed_frame_len[frameNumber] = frame_len;
+ Log.e("Night", "StartPreview fail");
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
+ String.valueOf(SessionID));
- if (frameNumber == 0)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromJPEG(jpegByteArray, SessionID, -1);
+ frameNumber = 0;
+ MainScreen.getInstance().muteShutter(false);
+ takingAlready = false;
+ inCapture = false;
+ return;
}
-
- PluginManager.getInstance().addToSharedMem("frame" + (frameNumber + 1) + SessionID,
- String.valueOf(compressed_frame[frameNumber]));
- PluginManager.getInstance().addToSharedMem("framelen" + (frameNumber + 1) + SessionID,
- String.valueOf(compressed_frame[frameNumber]));
- PluginManager.getInstance().addToSharedMem("frameorientation" + (frameNumber + 1) + SessionID,
- String.valueOf(MainScreen.getGUIManager().getDisplayOrientation()));
- PluginManager.getInstance().addToSharedMem("framemirrored" + (frameNumber + 1) + SessionID,
- String.valueOf(CameraController.isFrontCamera()));
-
- PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
- String.valueOf(frameNumber + 1));
-
- PluginManager.getInstance().addToSharedMem("isyuv" + SessionID, String.valueOf(isYUV));
-
- String message = MainScreen.getInstance().getResources().getString(R.string.capturing);
- message += " ";
- message += frameNumber + 1 + "/";
- message += total_frames;
- capturingDialog.setText(message);
- capturingDialog.show();
-
+
if (++frameNumber == total_frames)
- {
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
+ {
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED, String.valueOf(SessionID));
takingAlready = false;
inCapture = false;
}
+
}
- @TargetApi(19)
+ @TargetApi(21)
@Override
public void onCaptureCompleted(CaptureResult result)
{
- if (result.get(CaptureResult.REQUEST_ID) == requestID && frameNumber == 0)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromCaptureResult(result, SessionID);
+ if (result.getSequenceId() == requestID && frameNumber == 0)
+ PluginManager.getInstance().addToSharedMemExifTagsFromCaptureResult(result, SessionID);
}
public void captureFrame()
@@ -1201,7 +1059,8 @@ public void captureFrame()
// play tick sound
MainScreen.getGUIManager().showCaptureIndication();
MainScreen.getInstance().playShutter();
- requestID = CameraController.captureImagesWithParams(total_frames, CameraController.YUV, 0, new int[0]);
+
+ requestID = CameraController.captureImagesWithParams(total_frames, CameraController.YUV, new int[0], null);
} catch (RuntimeException e)
{
Log.e("CameraTest", "takePicture fail in CaptureFrame (called after release?)");
@@ -1214,9 +1073,9 @@ public void captureFrame()
// and takePicture
// or to collect frames in super mode
@Override
- public void onPreviewFrame(byte[] data, Camera paramCamera)
+ public void onPreviewFrame(byte[] data)
{
- if (OpenGLPreference)
+ if (OpenGLPreference && !inCapture)
{
if (data1 == null)
data1 = data;
@@ -1229,9 +1088,12 @@ else if (data2 == null)
else if (dataS.length < data2.length)
dataS = new byte[data2.length];
- Camera.Parameters params = CameraController.getInstance().getCameraParameters();
- int imageWidth = params.getPreviewSize().width;
- int imageHeight = params.getPreviewSize().height;
+// Camera.Parameters params = CameraController.getInstance().getCameraParameters();
+// int imageWidth = params.getPreviewSize().width;
+// int imageHeight = params.getPreviewSize().height;
+
+ int imageWidth = MainScreen.getPreviewWidth();
+ int imageHeight = MainScreen.getPreviewHeight();
ImageConversion.sumByteArraysNV21(data1, data2, dataS, imageWidth, imageHeight);
if (CameraController.isFrontCamera())
@@ -1247,6 +1109,12 @@ else if (dataS.length < data2.length)
data2 = null;
}
}
+ else if(inCapture && data1 != null)
+ {
+ data1 = null;
+ data2 = null;
+ dataS = null;
+ }
if (Integer.parseInt(ModePreference) == 1 && nVFframesToBuffer != 0)
{
@@ -1278,7 +1146,7 @@ else if (dataS.length < data2.length)
String.valueOf(frameNumber + 1));
if (frameNumber == 0)
- PluginManager.getInstance().addToSharedMem_ExifTagsFromCamera(SessionID);
+ PluginManager.getInstance().addToSharedMemExifTagsFromCamera(SessionID);
++frameNumber;
--nVFframesToBuffer;
@@ -1289,8 +1157,7 @@ else if (dataS.length < data2.length)
// play tick sound
MainScreen.getInstance().playShutter();
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED, String.valueOf(SessionID));
MainScreen.getGUIManager().stopCaptureIndication();
@@ -1300,142 +1167,6 @@ else if (dataS.length < data2.length)
}
}
- @TargetApi(19)
- @Override
- public void onPreviewAvailable(Image im)
- {
- if (OpenGLPreference)
- {
- ByteBuffer Y = im.getPlanes()[0].getBuffer();
- ByteBuffer U = im.getPlanes()[1].getBuffer();
- ByteBuffer V = im.getPlanes()[2].getBuffer();
-
- if ((!Y.isDirect()) || (!U.isDirect()) || (!V.isDirect()))
- {
- Log.e("NightCapturePlugin", "Oops, YUV ByteBuffers isDirect failed");
- return;
- }
-
- int imageWidth = im.getWidth();
- int imageHeight = im.getHeight();
- // Note: android documentation guarantee that:
- // - Y pixel stride is always 1
- // - U and V strides are the same
- // So, passing all these parameters is a bit overkill
-
- byte[] data = YuvImage.CreateSingleYUVImage(Y, U, V, im.getPlanes()[0].getPixelStride(),
- im.getPlanes()[0].getRowStride(), im.getPlanes()[1].getPixelStride(),
- im.getPlanes()[1].getRowStride(), im.getPlanes()[2].getPixelStride(),
- im.getPlanes()[2].getRowStride(), imageWidth, imageHeight);
-
- if (data1 == null)
- data1 = data;
- else if (data2 == null)
- {
- data2 = data;
-
- if (dataS == null)
- dataS = new byte[data2.length];
- else if (dataS.length < data2.length)
- dataS = new byte[data2.length];
-
- ImageConversion.sumByteArraysNV21(data1, data2, dataS, imageWidth, imageHeight);
- if (CameraController.isFrontCamera())
- {
- dataRotated = new byte[dataS.length];
- ImageConversion.TransformNV21(dataS, dataRotated, imageWidth, imageHeight, 1, 0, 0);
-
- yuvData = dataRotated;
- } else
- yuvData = dataS;
-
- data1 = data2;
- data2 = null;
- }
- }
-
- if (Integer.parseInt(ModePreference) == 1 && nVFframesToBuffer != 0)
- {
- Log.e("CapturePlugin", "YUV Image received");
- ByteBuffer Y = im.getPlanes()[0].getBuffer();
- ByteBuffer U = im.getPlanes()[1].getBuffer();
- ByteBuffer V = im.getPlanes()[2].getBuffer();
-
- if ((!Y.isDirect()) || (!U.isDirect()) || (!V.isDirect()))
- {
- Log.e("CapturePlugin", "Oops, YUV ByteBuffers isDirect failed");
- return;
- }
-
- int imageWidth = im.getWidth();
- int imageHeight = im.getHeight();
- // Note: android documentation guarantee that:
- // - Y pixel stride is always 1
- // - U and V strides are the same
- // So, passing all these parameters is a bit overkill
- int status = YuvImage.CreateYUVImage(Y, U, V, im.getPlanes()[0].getPixelStride(),
- im.getPlanes()[0].getRowStride(), im.getPlanes()[1].getPixelStride(),
- im.getPlanes()[1].getRowStride(), im.getPlanes()[2].getPixelStride(),
- im.getPlanes()[2].getRowStride(), imageWidth, imageHeight, 0);
-
- if (status != 0)
- Log.e("CapturePlugin", "Error while cropping: " + status);
-
- byte[] data = YuvImage.GetByteFrame(0);
-
- if (CameraController.isFrontCamera())
- {
- byte[] rotatedFrame = new byte[data.length];
- ImageConversion.TransformNV21(data, rotatedFrame, imageWidth, imageHeight, 1, 0, 0);
-
- data = rotatedFrame;
- }
- System.gc();
-
- // swap-out frame data to the heap
- compressed_frame[HI_SPEED_FRAMES - nVFframesToBuffer] = SwapHeap.SwapToHeap(data);
- compressed_frame_len[HI_SPEED_FRAMES - nVFframesToBuffer] = imageWidth * 2 * imageHeight * 2 + 2
- * ((imageWidth * 2 + 1) / 2) * ((imageHeight * 2 + 1) / 2);
-
- PluginManager.getInstance().addToSharedMem("frame" + (frameNumber + 1) + SessionID,
- String.valueOf(compressed_frame[frameNumber]));
- PluginManager.getInstance().addToSharedMem("framelen" + (frameNumber + 1) + SessionID,
- String.valueOf(compressed_frame_len[frameNumber]));
-
- PluginManager.getInstance().addToSharedMem("frameorientation" + (frameNumber + 1) + SessionID,
- String.valueOf(MainScreen.getGUIManager().getDisplayOrientation()));
- PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
- String.valueOf(frameNumber + 1));
-
- if (frameNumber == 0)
- {
- PluginManager.getInstance().addToSharedMem_ExifTagsFromCamera(SessionID);
- MainScreen.setImageWidth(imageWidth);
- MainScreen.setImageHeight(imageHeight);
- MainScreen.setSaveImageWidth(imageWidth * 2);
- MainScreen.setSaveImageHeight(imageHeight * 2);
- }
-
- ++frameNumber;
- --nVFframesToBuffer;
-
- // all frames captured - initiate processing
- if (nVFframesToBuffer == 0)
- {
- PluginManager.getInstance().addToSharedMem("isyuv" + SessionID, String.valueOf(true));
- // play tick sound
- MainScreen.getInstance().playShutter();
-
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
-
- MainScreen.getGUIManager().stopCaptureIndication();
-
- takingAlready = false;
- inCapture = false;
- }
- }
- }
/******************************************************************************************************
* OpenGL layer functions
@@ -1560,13 +1291,11 @@ public boolean onBroadcast(int arg1, int arg2)
// just repost our request and try once more (takePicture
// latency issues?)
--frameNumber;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_NEXT_FRAME);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_NEXT_FRAME);
}
} else
{
- PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED,
- String.valueOf(SessionID));
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_CAPTURE_FINISHED, String.valueOf(SessionID));
takingAlready = false;
inCapture = false;
diff --git a/src/com/almalence/plugins/capture/objectremoval/ObjectRemovalCapturePlugin.java b/src/com/almalence/plugins/capture/objectremoval/ObjectRemovalCapturePlugin.java
deleted file mode 100755
index 73ae2339..00000000
--- a/src/com/almalence/plugins/capture/objectremoval/ObjectRemovalCapturePlugin.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (the "License"); you may not use this file except in
-compliance with the License. You may obtain a copy of the License at
-http://www.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is collection of files collectively known as Open Camera.
-
-The Initial Developer of the Original Code is Almalence Inc.
-Portions created by Initial Developer are Copyright (C) 2013
-by Almalence Inc. All Rights Reserved.
- */
-
-package com.almalence.plugins.capture.objectremoval;
-
-import java.nio.ByteBuffer;
-import android.annotation.TargetApi;
-import android.content.SharedPreferences;
-import android.hardware.Camera;
-import android.hardware.camera2.CaptureResult;
-import android.media.Image;
-import android.os.CountDownTimer;
-import android.os.Message;
-import android.preference.PreferenceManager;
-import android.util.Log;
-import com.almalence.SwapHeap;
-import com.almalence.YuvImage;
-
-/* */
-// */
-// */
+//
+import com.almalence.ui.RotateDialog;
+import com.almalence.ui.RotateLayout;
+
+public class TimeLapseDialog extends RotateDialog
+{
+
+ public TimeLapseDialog(Context context)
+ {
+ super(context);
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ }
+
+ @Override
+ public void setRotate(int degree)
+ {
+ degree = degree >= 0 ? degree % 360 : degree % 360 + 360;
+
+ if (degree == currentOrientation)
+ {
+ return;
+ }
+ currentOrientation = degree;
+
+ RotateLayout r = (RotateLayout) findViewById(R.id.rotateLayout);
+ r.setAngle(degree);
+ r.requestLayout();
+ r.invalidate();
+
+ }
+}
diff --git a/src/com/almalence/plugins/capture/video/VideoCapturePlugin.java b/src/com/almalence/plugins/capture/video/VideoCapturePlugin.java
index 1a112c2d..f93e686f 100644
--- a/src/com/almalence/plugins/capture/video/VideoCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/video/VideoCapturePlugin.java
@@ -24,6 +24,7 @@ Portions created by Initial Developer are Copyright (C) 2013
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
+import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@@ -35,9 +36,9 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.annotation.TargetApi;
import android.app.AlertDialog;
-import android.app.Dialog;
import android.content.ContentValues;
import android.content.DialogInterface;
+import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
@@ -45,23 +46,20 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.media.CamcorderProfile;
import android.media.Image;
import android.media.MediaRecorder;
-import android.media.MediaScannerConnection;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.CountDownTimer;
import android.os.Handler;
-import android.os.Message;
import android.os.SystemClock;
import android.preference.CheckBoxPreference;
-import android.preference.ListPreference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
-import android.provider.MediaStore.Images;
-import android.provider.MediaStore.Images.ImageColumns;
+import android.provider.MediaStore.Video;
+import android.provider.MediaStore.Video.VideoColumns;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
@@ -73,11 +71,11 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.RotateAnimation;
-import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.NumberPicker;
import android.widget.RelativeLayout;
+import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
@@ -101,9 +99,9 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.opencam.ui.AlmalenceGUI.ShutterButton;
//-+- -->
import com.almalence.ui.RotateImageView;
-import com.almalence.ui.Switch.Switch;
import com.almalence.util.Util;
import com.coremedia.iso.IsoFile;
+import com.coremedia.iso.boxes.Container;
import com.googlecode.mp4parser.authoring.Movie;
import com.googlecode.mp4parser.authoring.Track;
import com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder;
@@ -120,6 +118,7 @@ public class VideoCapturePlugin extends PluginCapture
private volatile boolean isRecording;
private boolean onPause;
+ private boolean lockPauseButton = false;
private static int CameraIDPreference;
@@ -155,11 +154,12 @@ public class VideoCapturePlugin extends PluginCapture
private boolean videoStabilization = false;
- private static final int QUALITY_4K = 4096;
+ public static final int QUALITY_4K = 4096;
ImageView rotateToLandscapeNotifier;
boolean showRotateToLandscapeNotifier = false;
private View rotatorLayout;
+ private TimeLapseDialog timeLapseDialog;
private boolean displayTakePicture;
private ContentValues values;
@@ -197,7 +197,7 @@ public class VideoCapturePlugin extends PluginCapture
// On
// 1=DRO
// Off
- private Switch modeSwitcher;
+ private com.almalence.ui.Switch.Switch modeSwitcher;
private DROVideoEngine droEngine = new DROVideoEngine();
@@ -224,32 +224,10 @@ public void onCreate()
}
}
- private void setExposureParameters()
- {
- final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
-
- final int currEv = prefs.getInt(MainScreen.sEvPref, 0);
- int newEv = currEv;
- final int minValue = CameraController.getInstance().getMinExposureCompensation();
- float expStep = CameraController.getInstance().getExposureCompensationStep();
-
- if (this.modeDRO())
- {
- if (expStep < 0.3f)
- expStep = 0.33f; // there is a bug in Nexus 5 (android 4.4.2)
- int cmpns = -(int) (0.8f / expStep);
- if (cmpns == 0)
- cmpns = -1; // on Ascend P6 Ev compensation step is 1.0
- newEv -= cmpns;
- }
-
- CameraController.getInstance().setCameraExposureCompensation(Math.max(minValue, newEv));
- }
-
private void createModeSwitcher()
{
LayoutInflater inflator = MainScreen.getInstance().getLayoutInflater();
- modeSwitcher = (Switch) inflator.inflate(R.layout.plugin_capture_standard_modeswitcher, null, false);
+ modeSwitcher = (com.almalence.ui.Switch.Switch) inflator.inflate(R.layout.plugin_capture_standard_modeswitcher, null, false);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
ModePreference = prefs.getString("modeVideoDROPref", "1");
@@ -271,8 +249,6 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
ModePreference = "1";
}
- VideoCapturePlugin.this.setExposureParameters();
-
SharedPreferences.Editor editor = prefs.edit();
editor.putString("modeVideoDROPref", ModePreference);
editor.commit();
@@ -308,14 +284,14 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
timeLapseButton.setVisibility(View.GONE);
MainScreen.getInstance().showOpenGLLayer(2);
MainScreen.getInstance().glSetRenderingMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
- } else
+ }
+ else
{
if (displayTakePicture)
takePictureButton.setVisibility(View.VISIBLE);
timeLapseButton.setVisibility(View.VISIBLE);
droEngine.onPause();
- MainScreen.getInstance().hideOpenGLLayer();
Camera camera = CameraController.getCamera();
if (camera != null)
@@ -336,8 +312,10 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
e.printStackTrace();
}
CameraController.startCameraPreview();
+ MainScreen.getInstance().hideOpenGLLayer();
}
- } catch (final Exception e)
+ }
+ catch (final Exception e)
{
Log.e(TAG, Util.toString(e.getStackTrace(), '\n'));
e.printStackTrace();
@@ -366,7 +344,13 @@ public void onGUICreate()
isRecording = false;
prefs.edit().putBoolean("videorecording", false).commit();
- MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START);
+ if (swChecked)
+ {
+ MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START);
+ } else
+ {
+ MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START_WITH_PAUSE);
+ }
onPreferenceCreate((PreferenceFragment) null);
@@ -535,12 +519,19 @@ public void onClick(View v)
});
}
- List specialView2 = new ArrayList();
- RelativeLayout specialLayout2 = (RelativeLayout) MainScreen.getInstance().findViewById(
- R.id.specialPluginsLayout2);
- for (int i = 0; i < specialLayout2.getChildCount(); i++)
- specialView2.add(specialLayout2.getChildAt(i));
+ for (int j = 0; j < specialView.size(); j++)
+ {
+ View view = specialView.get(j);
+ int view_id = view.getId();
+ if (view_id == this.buttonsLayout.getId())
+ {
+ if (view.getParent() != null)
+ ((ViewGroup) view.getParent()).removeView(view);
+ specialLayout.removeView(view);
+ }
+ }
+
params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
params.height = (int) MainScreen.getInstance().getResources().getDimension(R.dimen.videobuttons_size);
@@ -570,12 +561,6 @@ public void onClick(View v)
timeLapseButton.invalidate();
timeLapseButton.requestLayout();
- if (MainScreen.isDeviceModelProhibited())
- {
- takePictureButton.setVisibility(View.GONE);
- displayTakePicture = false;
- }
-
if (this.modeDRO())
{
takePictureButton.setVisibility(View.GONE);
@@ -737,8 +722,7 @@ public void onQuickControlClick()
}
CameraController.startCameraPreview();
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_PREVIEW_CHANGED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_PREVIEW_CHANGED);
}
@Override
@@ -784,6 +768,11 @@ public void onOrientationChanged(int orientation)
}
}
}
+
+ if (timeLapseDialog != null)
+ {
+ timeLapseDialog.setRotate(MainScreen.getGUIManager().getLayoutOrientation());
+ }
}
@Override
@@ -813,7 +802,7 @@ public void startrotateAnimation()
private static File getOutputMediaFile()
{
- File saveDir = PluginManager.getInstance().GetSaveDir(false);
+ File saveDir = PluginManager.getInstance().getSaveDir(false);
Calendar d = Calendar.getInstance();
String fileFormat = String.format("%04d%02d%02d_%02d%02d%02d", d.get(Calendar.YEAR), d.get(Calendar.MONTH) + 1,
@@ -1012,8 +1001,6 @@ public void onCameraParametersSetup()
cp.setPreviewFrameRate(30);
cp.setRecordingHint(true);
- this.setExposureParameters();
-
CameraController.getInstance().setCameraParameters(cp);
}
}
@@ -1032,32 +1019,9 @@ public void setCameraPreviewSize(Camera.Parameters cp)
int ImageSizeIdxPreference = Integer.parseInt(prefs.getString(
CameraController.getCameraIndex() == 0 ? "imageSizePrefVideoBack" : "imageSizePrefVideoFront", "2"));
- final Camera.Size sz;
- if (!this.modeDRO())
- {
- boolean aspect169 = true;
- switch (ImageSizeIdxPreference)
- {
- case 0:
- case 1:
- case 4:
- aspect169 = false;
- break;
- case 2:
- case 3:
- case 5:
- aspect169 = true;
- break;
- default:
- break;
- }
-
- sz = getBestPreviewSizeNormal(aspect169);
- } else
- {
- sz = getBestPreviewSizeDRO(ImageSizeIdxPreference);
- }
+ final Camera.Size sz = getBestPreviewSizeDRO(ImageSizeIdxPreference);
+ Log.i(TAG, String.format("Preview size: %dx%d", sz.width, sz.height));
cp.setPreviewSize(sz.width, sz.height);
CameraController.getInstance().setCameraParameters(cp);
@@ -1071,7 +1035,8 @@ private static Camera.Size getBestPreviewSizeNormal(final boolean aspect169)
if (aspect169)
{
return selectMaxPreviewSize(16.0f / 9.0f);
- } else
+ }
+ else
{
return selectMaxPreviewSize(4.0f / 3.0f);
}
@@ -1239,7 +1204,7 @@ public void run()
{
stopRecording();
}
- }, 2500 - delta);
+ }, 1500 - delta);
} else
{
this.startRecording();
@@ -1268,7 +1233,13 @@ private void stopRecording()
.putBoolean("videorecording", false).commit();
// change shutter icon
- MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START);
+ if (swChecked)
+ {
+ MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START);
+ } else
+ {
+ MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START_WITH_PAUSE);
+ }
onPreExportVideo();
Runnable runnable = new Runnable()
@@ -1290,12 +1261,18 @@ protected void onPreExportVideo()
{
MainScreen.getGUIManager().startProcessingAnimation();
- values = new ContentValues(7);
- values.put(ImageColumns.TITLE, fileSaved.getName().substring(0, fileSaved.getName().lastIndexOf(".")));
- values.put(ImageColumns.DISPLAY_NAME, fileSaved.getName());
- values.put(ImageColumns.DATE_TAKEN, System.currentTimeMillis());
- values.put(ImageColumns.MIME_TYPE, "video/mp4");
- values.put(ImageColumns.DATA, fileSaved.getAbsolutePath());
+ File parent = fileSaved.getParentFile();
+ String path = parent.toString().toLowerCase();
+ String name = parent.getName().toLowerCase();
+
+ values = new ContentValues();
+ values.put(VideoColumns.TITLE, fileSaved.getName().substring(0, fileSaved.getName().lastIndexOf(".")));
+ values.put(VideoColumns.DISPLAY_NAME, fileSaved.getName());
+ values.put(VideoColumns.DATE_TAKEN, System.currentTimeMillis());
+ values.put(VideoColumns.MIME_TYPE, "video/mp4");
+ values.put(VideoColumns.BUCKET_ID, path.hashCode());
+ values.put(VideoColumns.BUCKET_DISPLAY_NAME, name);
+ values.put(VideoColumns.DATA, fileSaved.getAbsolutePath());
}
protected void doExportVideo()
@@ -1329,8 +1306,7 @@ protected void doExportVideo()
mRecordingTimeView.setText("00:00");
mRecorded = 0;
- MainScreen.getInstance().getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);
- MediaScannerConnection.scanFile(MainScreen.getInstance(), filesSavedNames, null, null);
+ MainScreen.getInstance().getContentResolver().insert(Video.Media.EXTERNAL_CONTENT_URI, values);
try
{
@@ -1377,8 +1353,7 @@ public void onTick(long millisUntilFinished)
public void onFinish()
{
shutterOff = false;
- if (!MainScreen.isDeviceModelProhibited())
- MainScreen.getGUIManager().lockControls = false;
+ MainScreen.getGUIManager().lockControls = false;
}
}.start();
} else
@@ -1428,7 +1403,13 @@ private void stopVideoRecording()
.putBoolean("videorecording", false).commit();
// change shutter icon
- MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START);
+ if (swChecked)
+ {
+ MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START);
+ } else
+ {
+ MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START_WITH_PAUSE);
+ }
onPreExportVideo();
Runnable runnable = new Runnable()
@@ -1581,8 +1562,8 @@ private void startVideoRecording()
MainScreen.getGUIManager().lockControls = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
+ PluginManager.getInstance()
+ .sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_UNLOCKED);
}
lastUseProfile = useProfile;
@@ -1688,8 +1669,7 @@ private void startVideoRecording()
Log.e("Video", "On shutter pressed " + e.getMessage());
MainScreen.getGUIManager().lockControls = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_UNLOCKED);
releaseMediaRecorder(); // release the MediaRecorder object
camera.lock(); // take camera access back from MediaRecorder
camera.stopPreview();
@@ -1726,8 +1706,7 @@ private void startVideoRecording()
Toast.makeText(MainScreen.getInstance(), "Failed to start video recording", Toast.LENGTH_LONG).show();
MainScreen.getGUIManager().lockControls = false;
- PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST,
- PluginManager.MSG_CONTROL_UNLOCKED);
+ PluginManager.getInstance().sendMessage(PluginManager.MSG_BROADCAST, PluginManager.MSG_CONTROL_UNLOCKED);
camera.lock(); // take camera access back from MediaRecorder
camera.stopPreview();
camera.startPreview();
@@ -1736,7 +1715,13 @@ private void startVideoRecording()
}
// change shutter icon
- MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_STOP);
+ if (swChecked)
+ {
+ MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_STOP);
+ } else
+ {
+ MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_STOP_WITH_PAUSE);
+ }
// inform the user that recording has started
isRecording = true;
@@ -1758,8 +1743,7 @@ public void onTick(long millisUntilFinished)
public void onFinish()
{
shutterOff = false;
- if (!MainScreen.isDeviceModelProhibited())
- MainScreen.getGUIManager().lockControls = false;
+ MainScreen.getGUIManager().lockControls = false;
}
}.start();
}
@@ -1767,100 +1751,6 @@ public void onFinish()
@Override
public void onPreferenceCreate(PreferenceFragment pf)
{
- CharSequence[] entries = new CharSequence[6];
- CharSequence[] entryValues = new CharSequence[6];
-
- int idx = 0;
- if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_QCIF)
- || this.qualityQCIFSupported)
- {
- entries[idx] = "176 x 144";
- entryValues[idx] = "0";
- idx++;
- }
- if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_CIF)
- || this.qualityCIFSupported)
- {
- entries[idx] = "352 x 288";
- entryValues[idx] = "1";
- idx++;
- }
- if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_1080P)
- || this.quality1080Supported)
- {
- entries[idx] = "1080p";
- entryValues[idx] = "2";
- idx++;
- }
- if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_720P)
- || this.quality720Supported)
- {
- entries[idx] = "720p";
- entryValues[idx] = "3";
- idx++;
- }
- if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_480P)
- || this.quality480Supported)
- {
- entries[idx] = "480p";
- entryValues[idx] = "4";
- idx++;
- }
- if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), QUALITY_4K) || this.quality4KSupported)
- {
- entries[idx] = "4K";
- entryValues[idx] = "5";
- idx++;
- }
-
- CharSequence[] entriesFin = new CharSequence[idx];
- CharSequence[] entryValuesFin = new CharSequence[idx];
-
- for (int i = 0; i < idx; i++)
- {
- entriesFin[i] = entries[i];
- entryValuesFin[i] = entryValues[i];
- }
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
- int imageSizePrefVideo = Integer.parseInt(prefs.getString(
- CameraController.getCameraIndex() == 0 ? "imageSizePrefVideoBack" : "imageSizePrefVideoFront", "2"));
- if (pf != null)
- {
- ListPreference lp = (ListPreference) pf.findPreference("imageSizePrefVideoBack");
- ListPreference lp2 = (ListPreference) pf.findPreference("imageSizePrefVideoFront");
-
- PreferenceCategory cat = (PreferenceCategory) pf.findPreference("Pref_VideoCapture_Category");
- if (CameraController.getCameraIndex() == 0 && lp2 != null && cat != null)
- {
- cat.removePreference(lp2);
- } else if (lp != null && lp2 != null && cat != null)
- {
- cat.removePreference(lp);
- lp = lp2;
- } else if (lp == null)
- lp = lp2;
-
- lp.setEntries(entriesFin);
- lp.setEntryValues(entryValuesFin);
-
- for (idx = 0; idx < entryValuesFin.length; ++idx)
- {
- if (Integer.valueOf(entryValuesFin[idx].toString()) == imageSizePrefVideo)
- {
- lp.setValueIndex(idx);
- break;
- }
- }
- } else
- {
- for (idx = 0; idx < entryValuesFin.length; ++idx)
- {
- if (Integer.valueOf(entryValuesFin[idx].toString()) == imageSizePrefVideo)
- break;
- }
- }
-
if (pf != null && !MainScreen.getCameraController().isVideoStabilizationSupported())
{
PreferenceCategory cat = (PreferenceCategory) pf.findPreference("Pref_VideoCapture_Category");
@@ -1979,11 +1869,23 @@ public void onFinish()
// show recording shutter
if (showRecording)
{
- MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_STOP);
+ if (swChecked)
+ {
+ MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_STOP);
+ } else
+ {
+ MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_STOP_WITH_PAUSE);
+ }
showRecording = false;
} else
{
- MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_RECORDING);
+ if (swChecked)
+ {
+ MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_RECORDING);
+ } else
+ {
+ MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_RECORDING_WITH_PAUSE);
+ }
showRecording = true;
}
}
@@ -2097,9 +1999,14 @@ public void run()
{
pauseDRORecording();
}
- }, 2500 - delta);
+ }, 1500 - delta);
} else
{
+ if (lockPauseButton)
+ {
+ return;
+ }
+
if (onPause)
{
startVideoRecording();
@@ -2108,6 +2015,7 @@ public void run()
// Pause video recording, merge files and remove last.
else
{
+ lockPauseButton = true;
long now = SystemClock.uptimeMillis();
long delta = now - mRecordingStartTime;
Handler handler = new Handler();
@@ -2117,19 +2025,25 @@ public void run()
{
pauseRecording();
}
- }, 2500 - delta);
+ }, 1500 - delta);
}
}
}
private void pauseDRORecording()
{
- this.onPause = !this.onPause;
- this.droEngine.setPaused(this.onPause);
if (onPause)
{
+ mRecordingStartTime = SystemClock.uptimeMillis();
+ showRecordingUI(isRecording);
+ onPause = false;
+ showRecordingUI(isRecording);
+ } else
+ {
+ onPause = true;
MainScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_PAUSED);
}
+ this.droEngine.setPaused(this.onPause);
}
private void pauseRecording()
@@ -2142,14 +2056,23 @@ private void pauseRecording()
mMediaRecorder.stop(); // stop the recording
ContentValues values = null;
- values = new ContentValues(7);
- values.put(ImageColumns.TITLE, fileSaved.getName().substring(0, fileSaved.getName().lastIndexOf(".")));
- values.put(ImageColumns.DISPLAY_NAME, fileSaved.getName());
- values.put(ImageColumns.DATE_TAKEN, System.currentTimeMillis());
- values.put(ImageColumns.MIME_TYPE, "video/mp4");
- values.put(ImageColumns.DATA, fileSaved.getAbsolutePath());
+ values = new ContentValues();
+ File parent = fileSaved.getParentFile();
+ String path = parent.toString().toLowerCase();
+ String name = parent.getName().toLowerCase();
+
+ values = new ContentValues();
+ values.put(VideoColumns.TITLE, fileSaved.getName().substring(0, fileSaved.getName().lastIndexOf(".")));
+ values.put(VideoColumns.DISPLAY_NAME, fileSaved.getName());
+ values.put(VideoColumns.DATE_TAKEN, System.currentTimeMillis());
+ values.put(VideoColumns.MIME_TYPE, "video/mp4");
+ values.put(VideoColumns.BUCKET_ID, path.hashCode());
+ values.put(VideoColumns.BUCKET_DISPLAY_NAME, name);
+ values.put(VideoColumns.DATA, fileSaved.getAbsolutePath());
filesList.add(fileSaved);
+
+ lockPauseButton = false;
} catch (RuntimeException e)
{
// Note that a RuntimeException is intentionally thrown to the
@@ -2220,23 +2143,11 @@ public static void copy(FileInputStream in, FileOutputStream out) throws IOExcep
public static void append(final String firstFile, final String secondFile, final String newFile) throws IOException
{
- final FileInputStream fisOne = new FileInputStream(new File(secondFile));
- final FileInputStream fisTwo = new FileInputStream(new File(firstFile));
final FileOutputStream fos = new FileOutputStream(new File(String.format(newFile)));
-
- append(fisOne, fisTwo, fos);
-
- fisOne.close();
- fisTwo.close();
- fos.close();
- }
-
- public static void append(final FileInputStream fisOne, final FileInputStream fisTwo, final FileOutputStream out)
- throws IOException
- {
-
- final Movie movieOne = MovieCreator.build(Channels.newChannel(fisOne));
- final Movie movieTwo = MovieCreator.build(Channels.newChannel(fisTwo));
+ final FileChannel fc = fos.getChannel();
+
+ final Movie movieOne = MovieCreator.build(firstFile);
+ final Movie movieTwo = MovieCreator.build(secondFile);
final Movie finalMovie = new Movie();
final List