diff options
Diffstat (limited to 'src/com/android/camera')
-rwxr-xr-x | src/com/android/camera/CaptureModule.java | 196 | ||||
-rwxr-xr-x | src/com/android/camera/CaptureUI.java | 32 | ||||
-rwxr-xr-x[-rw-r--r--] | src/com/android/camera/ListPreference.java | 10 | ||||
-rwxr-xr-x | src/com/android/camera/SettingsActivity.java | 34 | ||||
-rwxr-xr-x | src/com/android/camera/SettingsManager.java | 44 |
5 files changed, 197 insertions, 119 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 3480c762a..1df541fb2 100755 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -90,6 +90,7 @@ import android.view.SurfaceHolder; import android.view.View; import android.view.ViewTreeObserver; import android.view.WindowManager; +import android.widget.TextView; import android.widget.Toast; import android.widget.LinearLayout; import android.widget.FrameLayout; @@ -392,6 +393,8 @@ public class CaptureModule implements CameraModule, PhotoController, private Camera2GraphView mGraphViewR,mGraphViewGB,mGraphViewB; private Camera2BGBitMap bgstats_view; private Camera2BEBitMap bestats_view; + private TextView mBgStatsLabel; + private TextView mBeStatsLabel; private DrawAutoHDR2 mDrawAutoHDR2; public boolean mAutoHdrEnable; /*HDR Test*/ @@ -545,6 +548,9 @@ public class CaptureModule implements CameraModule, PhotoController, public static int be_g_statsdata[] = new int[BESTATS_DATA]; public static int be_b_statsdata[] = new int[BESTATS_DATA]; + // AWB Info + public static String[] awbinfo_data = new String[4]; + private static final int SELFIE_FLASH_DURATION = 680; private static final int SESSION_CONFIGURE_TIMEOUT_MS = 3000; @@ -759,7 +765,7 @@ public class CaptureModule implements CameraModule, PhotoController, CaptureRequest request, TotalCaptureResult result) { int id = (int) result.getRequest().getTag(); - int r, g, b, index; + if (id == getMainCameraId()) { updateFocusStateChange(result); @@ -771,100 +777,133 @@ public class CaptureModule implements CameraModule, PhotoController, updateFaceView(faces, null); } } - if (SettingsManager.getInstance().isStatsVisualizerSupport() == 3) { - int[] histogramStats = result.get(CaptureModule.histogramStats); - if (histogramStats != null && mHiston) { + + detectHDRMode(result, id); + processCaptureResult(result); + mPostProcessor.onMetaAvailable(result); + String stats_visualizer = mSettingsManager.getValue( + SettingsManager.KEY_STATS_VISUALIZER_VALUE); + if (stats_visualizer != null) { + updateStatsView(stats_visualizer,result); + } + } + }; + + private void updateStatsView(String stats_visualizer,CaptureResult result) { + int r, g, b, index; + if (stats_visualizer.contains("2")) { + int[] histogramStats = result.get(CaptureModule.histogramStats); + if (histogramStats != null && mHiston) { /*The first element in the array stores max hist value . Stats data begin from second value*/ - synchronized (statsdata) { - System.arraycopy(histogramStats, 0, statsdata, 0, STATS_DATA); - } - updateGraghView(); + synchronized (statsdata) { + System.arraycopy(histogramStats, 0, statsdata, 0, STATS_DATA); } + updateGraghView(); } + } - // BG stats display - if (SettingsManager.getInstance().isStatsVisualizerSupport() == 1) { - int[] bgRStats = null; - int[] bgGStats = null; - int[] bgBStats = null; - try{ - bgRStats = result.get(CaptureModule.bgRStats); - bgGStats = result.get(CaptureModule.bgGStats); - bgBStats = result.get(CaptureModule.bgBStats); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } - if (bgRStats != null && bgGStats != null && bgBStats != null && mBGStatson) { - synchronized (bg_r_statsdata) { - System.arraycopy(bgRStats, 0, bg_r_statsdata, 0, BGSTATS_DATA); - System.arraycopy(bgGStats, 0, bg_g_statsdata, 0, BGSTATS_DATA); - System.arraycopy(bgBStats, 0, bg_b_statsdata, 0, BGSTATS_DATA); + // BG stats display + if (stats_visualizer.contains("0")) { + int[] bgRStats = null; + int[] bgGStats = null; + int[] bgBStats = null; + try{ + bgRStats = result.get(CaptureModule.bgRStats); + bgGStats = result.get(CaptureModule.bgGStats); + bgBStats = result.get(CaptureModule.bgBStats); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + if (bgRStats != null && bgGStats != null && bgBStats != null && mBGStatson) { + synchronized (bg_r_statsdata) { + System.arraycopy(bgRStats, 0, bg_r_statsdata, 0, BGSTATS_DATA); + System.arraycopy(bgGStats, 0, bg_g_statsdata, 0, BGSTATS_DATA); + System.arraycopy(bgBStats, 0, bg_b_statsdata, 0, BGSTATS_DATA); - for (int el = 0; el < 3072; el++) - { - r = bg_r_statsdata[el] >> 6; - g = bg_g_statsdata[el] >> 6; - b = bg_b_statsdata[el] >> 6; + for (int el = 0; el < 3072; el++) + { + r = bg_r_statsdata[el] >> 6; + g = bg_g_statsdata[el] >> 6; + b = bg_b_statsdata[el] >> 6; - for (int hi = 0; hi < 10; hi++) + for (int hi = 0; hi < 10; hi++) + { + for (int wi = 0; wi < 10; wi++) { - for (int wi = 0; wi < 10; wi++) - { - index = 10*(int)(el/64) + 48*10*hi + 48*10*10*(el%64) + wi; - bg_statsdata[480*(639-(int)(index/480))+(index%480)] = Color.argb(255, r, g, b); - } + index = 10*(int)(el/64) + 48*10*hi + 48*10*10*(el%64) + wi; + bg_statsdata[480*(639-(int)(index/480))+(index%480)] = Color.argb(255, r, g, b); } } } - updateBGStatsView(); } + updateBGStatsView(); } + } - // BE stats display - if (SettingsManager.getInstance().isStatsVisualizerSupport() == 2) { - int[] beRStats = null; - int[] beGStats = null; - int[] beBStats = null; - try{ - beRStats = result.get(CaptureModule.beRStats); - beGStats = result.get(CaptureModule.beGStats); - beBStats = result.get(CaptureModule.beBStats); - }catch (IllegalArgumentException e) { - e.printStackTrace(); - } + // BE stats display + if (stats_visualizer.contains("1")) { + int[] beRStats = null; + int[] beGStats = null; + int[] beBStats = null; + try{ + beRStats = result.get(CaptureModule.beRStats); + beGStats = result.get(CaptureModule.beGStats); + beBStats = result.get(CaptureModule.beBStats); + }catch (IllegalArgumentException e) { + e.printStackTrace(); + } - if (beRStats != null && beGStats != null && beBStats != null && mBEStatson) { - synchronized (be_r_statsdata) { - System.arraycopy(beRStats, 0, be_r_statsdata, 0, BESTATS_DATA); - System.arraycopy(beGStats, 0, be_g_statsdata, 0, BESTATS_DATA); - System.arraycopy(beBStats, 0, be_b_statsdata, 0, BESTATS_DATA); + if (beRStats != null && beGStats != null && beBStats != null && mBEStatson) { + synchronized (be_r_statsdata) { + System.arraycopy(beRStats, 0, be_r_statsdata, 0, BESTATS_DATA); + System.arraycopy(beGStats, 0, be_g_statsdata, 0, BESTATS_DATA); + System.arraycopy(beBStats, 0, be_b_statsdata, 0, BESTATS_DATA); - for (int el = 0; el < 3072; el++) - { - r = be_r_statsdata[el] >> 6; - g = be_g_statsdata[el] >> 6; - b = be_b_statsdata[el] >> 6; + for (int el = 0; el < 3072; el++) + { + r = be_r_statsdata[el] >> 6; + g = be_g_statsdata[el] >> 6; + b = be_b_statsdata[el] >> 6; - for (int hi = 0; hi < 10; hi++) + for (int hi = 0; hi < 10; hi++) + { + for (int wi = 0; wi < 10; wi++) { - for (int wi = 0; wi < 10; wi++) - { - index = 10*(int)(el/64) + 48*10*hi + 48*10*10*(el%64) + wi; - be_statsdata[480*(639-(int)(index/480))+(index%480)] = Color.argb(255, r, g, b); - } + index = 10*(int)(el/64) + 48*10*hi + 48*10*10*(el%64) + wi; + be_statsdata[480*(639-(int)(index/480))+(index%480)] = Color.argb(255, r, g, b); } } } - updateBEStatsView(); } + updateBEStatsView(); } + } - detectHDRMode(result, id); - processCaptureResult(result); - mPostProcessor.onMetaAvailable(result); + // AWB Info display + if (stats_visualizer.contains("3")) { + try{ + awbinfo_data[0] = Float.toString(mRGain); + awbinfo_data[1] = Float.toString(mGGain); + awbinfo_data[2] = Float.toString(mBGain); + awbinfo_data[3] = Float.toString(mCctAWB); + synchronized (awbinfo_data) { + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mUI.updateAWBInfoVisibility(View.VISIBLE); + mUI.updateAwbInfoText(awbinfo_data); + } + }); + } + } catch (IllegalArgumentException | NullPointerException e) { + e.printStackTrace(); + } + } else { + mUI.updateAWBInfoVisibility(View.GONE); } - }; + } + private final CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() { @@ -1230,6 +1269,8 @@ public class CaptureModule implements CameraModule, PhotoController, mGraphViewB = (Camera2GraphView) mRootView.findViewById(R.id.graph_view_b); bgstats_view = (Camera2BGBitMap) mRootView.findViewById(R.id.bg_stats_graph); bestats_view = (Camera2BEBitMap) mRootView.findViewById(R.id.be_stats_graph); + mBgStatsLabel = (TextView) mRootView.findViewById(R.id.bg_stats_graph_label); + mBeStatsLabel = (TextView) mRootView.findViewById(R.id.be_stats_graph_label); mDrawAutoHDR2 = (DrawAutoHDR2 )mRootView.findViewById(R.id.autohdr_view); mGraphViewR.setDataSection(0,256); mGraphViewGB.setDataSection(256,512); @@ -5374,7 +5415,7 @@ public class CaptureModule implements CameraModule, PhotoController, private void applyHistogram(CaptureRequest.Builder request) { String value = mSettingsManager.getValue(SettingsManager.KEY_STATS_VISUALIZER_VALUE); if (value != null ) { - if (value.equals("3")) { + if (value.contains("2")) { final byte enable = 1; request.set(CaptureModule.histMode, enable); mHiston = true; @@ -5390,7 +5431,7 @@ public class CaptureModule implements CameraModule, PhotoController, private void applyBGStats(CaptureRequest.Builder request) { String value = mSettingsManager.getValue(SettingsManager.KEY_STATS_VISUALIZER_VALUE); if (value != null ) { - if (value.equals("1")){ + if (value.contains("0")){ final byte enable = 1; try{ request.set(CaptureModule.bgStatsMode, enable); @@ -5412,7 +5453,7 @@ public class CaptureModule implements CameraModule, PhotoController, private void applyBEStats(CaptureRequest.Builder request) { String value = mSettingsManager.getValue(SettingsManager.KEY_STATS_VISUALIZER_VALUE); if (value != null ) { - if (value.equals("2")){ + if (value.contains("1")){ final byte enable = 1; try{ request.set(CaptureModule.beStatsMode, enable); @@ -5501,6 +5542,7 @@ public class CaptureModule implements CameraModule, PhotoController, public void run() { if(bgstats_view != null) { bgstats_view.setVisibility(visibility); + mBgStatsLabel.setVisibility(visibility); } } }); @@ -5522,6 +5564,7 @@ public class CaptureModule implements CameraModule, PhotoController, public void run() { if(bestats_view != null) { bestats_view.setVisibility(visibility); + mBeStatsLabel.setVisibility(visibility); } } }); @@ -6925,11 +6968,11 @@ class Camera2BGBitMap extends View { private Paint mPaint = new Paint(); private Paint mPaintRect = new Paint(); private Canvas mCanvas = new Canvas(); - private float mScale = (float)3; + private Paint mTextPaint = new Paint(); private int mWidth; private int mHeight; private CaptureModule mCaptureModule; - private static final String TAG = "BGGraphView"; + private static final String TAG = "BG GraphView"; public Camera2BGBitMap(Context context, AttributeSet attrs) { @@ -6986,7 +7029,7 @@ class Camera2BEBitMap extends View { private int mWidth; private int mHeight; private CaptureModule mCaptureModule; - private static final String TAG = "BGGraphView"; + private static final String TAG = "BE GraphView"; public Camera2BEBitMap(Context context, AttributeSet attrs) { @@ -7019,7 +7062,6 @@ class Camera2BEBitMap extends View { if (mBitmap != null) { final Canvas cavas = mCanvas; cavas.drawColor(0xFFAAAAAA); - synchronized(CaptureModule.be_statsdata){ mBitmap.setPixels(CaptureModule.be_statsdata, 0, 48*10, 0, 0, 48*10, 64*10); } diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java index 39b2d3441..57ef697b2 100755 --- a/src/com/android/camera/CaptureUI.java +++ b/src/com/android/camera/CaptureUI.java @@ -108,6 +108,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, private static final int ANIMATION_DURATION = 300; private static final int CLICK_THRESHOLD = 200; private static final int AUTOMATIC_MODE = 0; + private static final String[] AWB_INFO_TITLE = {" R gain "," G gain "," B gain "," CCT "}; private CameraActivity mActivity; private View mRootView; private View mPreviewCover; @@ -232,6 +233,12 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, private int mDownSampleFactor = 4; private DecodeImageForReview mDecodeTaskForReview = null; + private View mStatsAwbInfo; + private TextView mStatsAwbRText; + private TextView mStatsAwbGText; + private TextView mStatsAwbBText; + private TextView mStatsAwbCcText; + int mPreviewWidth; int mPreviewHeight; private boolean mIsVideoUI = false; @@ -416,6 +423,12 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mPauseButton = (PauseButton) mRootView.findViewById(R.id.video_pause); mPauseButton.setOnPauseButtonListener(this); + mStatsAwbInfo = mRootView.findViewById(R.id.stats_awb_info); + mStatsAwbRText = mRootView.findViewById(R.id.stats_awb_r_text); + mStatsAwbGText = mRootView.findViewById(R.id.stats_awb_g_text); + mStatsAwbBText = mRootView.findViewById(R.id.stats_awb_b_text); + mStatsAwbCcText = mRootView.findViewById(R.id.stats_awb_cc_text); + mMuteButton = (RotateImageView)mRootView.findViewById(R.id.mute_button); mMuteButton.setVisibility(View.VISIBLE); setMuteButtonResource(!mModule.isAudioMute()); @@ -583,6 +596,25 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, } } + public void updateAwbInfoText(String[] info) { + if (info == null || info.length <4) + return; + mStatsAwbRText.setText(AWB_INFO_TITLE[0]+info[0]); + mStatsAwbGText.setText(AWB_INFO_TITLE[1]+info[1]); + mStatsAwbBText.setText(AWB_INFO_TITLE[2]+info[2]); + mStatsAwbCcText.setText(AWB_INFO_TITLE[3]+info[3]); + } + + public void updateAWBInfoVisibility(int visibility) { + mActivity.runOnUiThread(new Runnable() { + public void run() { + if(mStatsAwbInfo != null) { + mStatsAwbInfo.setVisibility(visibility); + } + } + }); + } + private int getCurrentIntentMode() { return mModule.getCurrentIntentMode(); } diff --git a/src/com/android/camera/ListPreference.java b/src/com/android/camera/ListPreference.java index ae37356e1..033ae4b6e 100644..100755 --- a/src/com/android/camera/ListPreference.java +++ b/src/com/android/camera/ListPreference.java @@ -18,6 +18,7 @@ package com.android.camera; import java.util.ArrayList; import java.util.List; +import java.util.Set; import android.content.Context; import android.content.SharedPreferences; @@ -160,6 +161,15 @@ public class ListPreference extends CameraPreference { persistStringValue(value); } + public void setFromMultiValues(Set<String> set) { + String value = ""; + for (String str : set) { + value = value + str +";"; + } + mValue = value; + persistStringValue(value); + } + public void setValueIndex(int index) { setValue(mEntryValues[index].toString()); } diff --git a/src/com/android/camera/SettingsActivity.java b/src/com/android/camera/SettingsActivity.java index 330733d29..22649892e 100755 --- a/src/com/android/camera/SettingsActivity.java +++ b/src/com/android/camera/SettingsActivity.java @@ -38,6 +38,7 @@ import android.content.pm.PackageManager; import android.graphics.ImageFormat; import android.os.Bundle; import android.preference.ListPreference; +import android.preference.MultiSelectListPreference; import android.preference.Preference; import android.preference.PreferenceCategory; import android.preference.PreferenceGroup; @@ -59,6 +60,7 @@ import org.codeaurora.snapcam.R; import com.android.camera.util.CameraUtil; import com.android.camera.ui.RotateTextToast; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -88,6 +90,9 @@ public class SettingsActivity extends PreferenceActivity { } else if (p instanceof ListPreference){ value = ((ListPreference) p).getValue(); mSettingsManager.setValue(key, value); + } else if (p instanceof MultiSelectListPreference) { + Set<String> valueSet = ((MultiSelectListPreference)p).getValues(); + mSettingsManager.setValue(key,valueSet); } if (key.equals(SettingsManager.KEY_VIDEO_QUALITY)) { updatePreference(SettingsManager.KEY_VIDEO_HIGH_FRAME_RATE); @@ -648,9 +653,9 @@ public class SettingsActivity extends PreferenceActivity { updatePreference(SettingsManager.KEY_VIDEO_ENCODER); updatePreference(SettingsManager.KEY_ZOOM); updatePreference(SettingsManager.KEY_SWITCH_CAMERA); + updateMultiPreference(SettingsManager.KEY_STATS_VISUALIZER_VALUE); updatePictureSizePreferenceButton(); updateVideoHDRPreference(); - updateStatsVisualizerPreference(); Map<String, SettingsManager.Values> map = mSettingsManager.getValuesMap(); Set<Map.Entry<String, SettingsManager.Values>> set = map.entrySet(); @@ -704,14 +709,6 @@ public class SettingsActivity extends PreferenceActivity { } } - private void updateStatsVisualizerPreference() { - ListPreference pref = (ListPreference)findPreference(SettingsManager.KEY_STATS_VISUALIZER_VALUE); - if (pref == null) { - return; - } - pref.setEnabled(true); - } - private void updateVideoHDRPreference() { ListPreference pref = (ListPreference)findPreference(SettingsManager.KEY_VIDEO_HDR_VALUE); if (pref == null) { @@ -760,6 +757,25 @@ public class SettingsActivity extends PreferenceActivity { } } + private void updateMultiPreference(String key) { + MultiSelectListPreference pref = (MultiSelectListPreference) findPreference(key); + if (pref != null) { + if (mSettingsManager.getEntries(key) != null) { + pref.setEntries(mSettingsManager.getEntries(key)); + pref.setEntryValues(mSettingsManager.getEntryValues(key)); + String values = mSettingsManager.getValue(key); + if (values != null) { + Set<String> valueSet = new HashSet<String>(); + String[] splitValues = values.split(";"); + for (String str : splitValues) { + valueSet.add(str); + } + pref.setValues(valueSet); + } + } + } + } + private boolean isOn(String value) { return value.equals("on") || value.equals("enable"); } diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java index f71c79cdc..0c0dac746 100755 --- a/src/com/android/camera/SettingsManager.java +++ b/src/com/android/camera/SettingsManager.java @@ -643,6 +643,17 @@ public class SettingsManager implements ListMenu.SettingsListener { } } + public boolean setValue(String key, Set<String> set) { + ListPreference pref = mPreferenceGroup.findPreference(key); + if (pref != null) { + pref.setFromMultiValues(set); + updateMapAndNotify(pref); + return true; + } else { + return false; + } + } + public void setValueIndex(String key, int index) { ListPreference pref = mPreferenceGroup.findPreference(key); if (pref != null) { @@ -813,13 +824,6 @@ public class SettingsManager implements ListMenu.SettingsListener { } } - if (stats_visualizer != null) { - if (filterUnsupportedOptions(stats_visualizer, - getSupportedStatsVisualizerAvailableModes(cameraId))) { - mFilteredKeys.add(stats_visualizer.getKey()); - } - } - if (hdr != null){ if (filterUnsupportedOptions(hdr, getSupportedHdrAvailableModes(cameraId))) { @@ -1726,21 +1730,6 @@ public class SettingsManager implements ListMenu.SettingsListener { return modes; } - public List<String> getSupportedStatsVisualizerAvailableModes(int cameraId) { - int[] statsVisualizerAvailableModes = {0, 1, 2, 3}; - /* - 0 - disable stats - 1 - enable BG stats - 2 - enable BE stats - 3 - enable Hist stats - */ - List<String> modes = new ArrayList<>(); - for (int i : statsVisualizerAvailableModes) { - modes.add(""+i); - } - return modes; - } - public List<String> getSupportedHdrAvailableModes(int cameraId) { String[] data = {"enable","disable"}; List<String> modes = new ArrayList<>(); @@ -1759,17 +1748,6 @@ public class SettingsManager implements ListMenu.SettingsListener { return profile; } - public int isStatsVisualizerSupport(){ - String value = getValue(KEY_STATS_VISUALIZER_VALUE); - int num_val; - if (value == null) { - num_val = -1; - return num_val; - } - num_val = Integer.parseInt(value); - return num_val; - } - public boolean isCamera2HDRSupport(){ |