use of java.lang.NumberFormatException in project android_packages_apps_Snap by LineageOS.
the class DrawAutoHDR method UpdateManualWBSettings.
private void UpdateManualWBSettings() {
// dismiss all popups first, because we need to show edit dialog
mUI.collapseCameraControls();
final AlertDialog.Builder alert = new AlertDialog.Builder(mActivity);
LinearLayout linear = new LinearLayout(mActivity);
linear.setOrientation(1);
alert.setTitle("Manual White Balance Settings");
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
String cctMode = mActivity.getString(R.string.pref_camera_manual_wb_value_color_temperature);
String rgbGainMode = mActivity.getString(R.string.pref_camera_manual_wb_value_rbgb_gains);
String manualWBMode = mPreferences.getString(CameraSettings.KEY_MANUAL_WB, mActivity.getString(R.string.pref_camera_manual_wb_default));
final String wbPref = mPreferences.getString(CameraSettings.KEY_WHITE_BALANCE, mActivity.getString(R.string.pref_camera_whitebalance_default));
Log.v(TAG, "manualWBMode selected = " + manualWBMode);
if (manualWBMode.equals(cctMode)) {
final TextView CCTtext = new TextView(mActivity);
final EditText CCTinput = new EditText(mActivity);
CCTinput.setInputType(InputType.TYPE_CLASS_NUMBER);
final int minCCT = mParameters.getInt(CameraSettings.KEY_MIN_WB_CCT);
final int maxCCT = mParameters.getInt(CameraSettings.KEY_MAX_WB_CCT);
// refresh camera parameters to get latest CCT value
mParameters = mCameraDevice.getParameters();
String currentCCT = mParameters.get(CameraSettings.KEY_MANUAL_WB_CCT);
if (currentCCT != null) {
CCTtext.setText("Current CCT is " + currentCCT);
}
alert.setMessage("Enter CCT value in the range of " + minCCT + " to " + maxCCT);
linear.addView(CCTinput);
linear.addView(CCTtext);
alert.setView(linear);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
int newCCT = -1;
String cct = CCTinput.getText().toString();
if (cct.length() > 0) {
newCCT = Integer.parseInt(cct);
}
if (newCCT <= maxCCT && newCCT >= minCCT) {
mManual3AEnabled |= MANUAL_WB;
Log.v(TAG, "Setting CCT value : " + newCCT);
mParameters.setWhiteBalance(CameraSettings.KEY_MANUAL_WHITE_BALANCE);
// 0 corresponds to manual CCT mode
mParameters.set(CameraSettings.KEY_MANUAL_WB_TYPE, 0);
mParameters.set(CameraSettings.KEY_MANUAL_WB_VALUE, newCCT);
updateCommonManual3ASettings();
onSharedPreferenceChanged();
} else {
RotateTextToast.makeText(mActivity, "Invalid CCT", Toast.LENGTH_SHORT).show();
}
}
});
alert.show();
} else if (manualWBMode.equals(rgbGainMode)) {
final TextView RGBtext = new TextView(mActivity);
final EditText Rinput = new EditText(mActivity);
Rinput.setHint("Enter R gain here");
final EditText Ginput = new EditText(mActivity);
Ginput.setHint("Enter G gain here");
final EditText Binput = new EditText(mActivity);
Binput.setHint("Enter B gain here");
int floatType = InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER;
Rinput.setInputType(floatType);
Ginput.setInputType(floatType);
Binput.setInputType(floatType);
String minGainStr = mParameters.get(CameraSettings.KEY_MIN_WB_GAIN);
final double minGain = Double.parseDouble(minGainStr);
String maxGainStr = mParameters.get(CameraSettings.KEY_MAX_WB_GAIN);
final double maxGain = Double.parseDouble(maxGainStr);
// refresh camera parameters to get latest WB gains
mParameters = mCameraDevice.getParameters();
String currentGains = mParameters.get(CameraSettings.KEY_MANUAL_WB_GAINS);
if (currentGains != null) {
RGBtext.setText("Current RGB gains are " + currentGains);
}
alert.setMessage("Enter RGB gains in the range of " + minGain + " to " + maxGain);
linear.addView(Rinput);
linear.addView(Ginput);
linear.addView(Binput);
linear.addView(RGBtext);
alert.setView(linear);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
String Rgain = Rinput.getText().toString();
String Ggain = Ginput.getText().toString();
String Bgain = Binput.getText().toString();
double Rgainf = -1;
double Ggainf = -1;
double Bgainf = -1;
if (Rgain.length() > 0 && Ggain.length() > 0 && Bgain.length() > 0) {
try {
Rgainf = Double.parseDouble(Rgain);
Ggainf = Double.parseDouble(Ggain);
Bgainf = Double.parseDouble(Bgain);
} catch (NumberFormatException e) {
Log.w(TAG, "Input RGB gain is invalid");
Rgainf = maxGain + 1f;
Ggainf = maxGain + 1f;
Bgainf = maxGain + 1f;
}
String RGBGain = Rgain + "," + Ggain + "," + Bgain;
if (Rgainf <= maxGain && Rgainf >= minGain && Ggainf <= maxGain && Ggainf >= minGain && Bgainf <= maxGain && Bgainf >= minGain) {
Log.v(TAG, "Setting RGB gains : " + RGBGain);
mManual3AEnabled |= MANUAL_WB;
mParameters.setWhiteBalance(CameraSettings.KEY_MANUAL_WHITE_BALANCE);
// 1 corresponds to manual WB gain mode
mParameters.set(CameraSettings.KEY_MANUAL_WB_TYPE, 1);
mParameters.set(CameraSettings.KEY_MANUAL_WB_VALUE, RGBGain);
updateCommonManual3ASettings();
onSharedPreferenceChanged();
} else {
RotateTextToast.makeText(mActivity, "Invalid RGB gains", Toast.LENGTH_SHORT).show();
}
} else {
RotateTextToast.makeText(mActivity, "Invalid RGB gains", Toast.LENGTH_SHORT).show();
}
}
});
alert.show();
} else {
// reset white balance
mManual3AEnabled &= ~MANUAL_WB;
mUI.overrideSettings(CameraSettings.KEY_WHITE_BALANCE, null);
updateCommonManual3ASettings();
onSharedPreferenceChanged();
}
}
use of java.lang.NumberFormatException in project android_packages_apps_Snap by LineageOS.
the class DrawAutoHDR method UpdateManualFocusSettings.
private void UpdateManualFocusSettings() {
// dismiss all popups first, because we need to show edit dialog
mUI.collapseCameraControls();
final AlertDialog.Builder alert = new AlertDialog.Builder(mActivity);
LinearLayout linear = new LinearLayout(mActivity);
linear.setOrientation(1);
alert.setTitle("Manual Focus Settings");
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
final TextView focusPositionText = new TextView(mActivity);
String scaleMode = mActivity.getString(R.string.pref_camera_manual_focus_value_scale_mode);
String diopterMode = mActivity.getString(R.string.pref_camera_manual_focus_value_diopter_mode);
String manualFocusMode = mPreferences.getString(CameraSettings.KEY_MANUAL_FOCUS, mActivity.getString(R.string.pref_camera_manual_focus_default));
Log.v(TAG, "manualFocusMode selected = " + manualFocusMode);
if (manualFocusMode.equals(scaleMode)) {
final SeekBar focusbar = new SeekBar(mActivity);
final int minFocusPos = mParameters.getInt(CameraSettings.KEY_MIN_FOCUS_SCALE);
final int maxFocusPos = mParameters.getInt(CameraSettings.KEY_MAX_FOCUS_SCALE);
// update mparameters to fetch latest focus position
mParameters = mCameraDevice.getParameters();
int CurFocusPos = minFocusPos;
try {
CurFocusPos = mParameters.getInt(CameraSettings.KEY_MANUAL_FOCUS_SCALE);
} catch (NumberFormatException e) {
// Do nothing
}
focusbar.setProgress(CurFocusPos);
focusPositionText.setText("Current focus position is " + CurFocusPos);
alert.setMessage("Enter focus position in the range of " + minFocusPos + " to " + maxFocusPos);
focusbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
focusPositionText.setText("Current focus position is " + progress);
}
});
linear.addView(focusbar);
linear.addView(focusPositionText);
alert.setView(linear);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
int focusPos = focusbar.getProgress();
Log.v(TAG, "Setting focus position : " + focusPos);
mManual3AEnabled |= MANUAL_FOCUS;
mParameters.setFocusMode(ParametersWrapper.FOCUS_MODE_MANUAL_POSITION);
// 2 for scale mode
mParameters.set(CameraSettings.KEY_MANUAL_FOCUS_TYPE, 2);
mParameters.set(CameraSettings.KEY_MANUAL_FOCUS_POSITION, focusPos);
updateCommonManual3ASettings();
onSharedPreferenceChanged();
}
});
alert.show();
} else if (manualFocusMode.equals(diopterMode)) {
String minFocusStr = mParameters.get(CameraSettings.KEY_MIN_FOCUS_DIOPTER);
String maxFocusStr = mParameters.get(CameraSettings.KEY_MAX_FOCUS_DIOPTER);
final double minFocusPos = Double.parseDouble(minFocusStr);
final double maxFocusPos = Double.parseDouble(maxFocusStr);
final EditText input = new EditText(mActivity);
int floatType = InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER;
input.setInputType(floatType);
alert.setMessage("Enter focus position in the range of " + minFocusPos + " to " + maxFocusPos);
// update mparameters to fetch latest focus position
mParameters = mCameraDevice.getParameters();
final String CurFocusPos = mParameters.get(CameraSettings.KEY_MANUAL_FOCUS_DIOPTER);
focusPositionText.setText("Current focus position is " + (CurFocusPos != null ? CurFocusPos : minFocusStr));
linear.addView(input);
linear.addView(focusPositionText);
alert.setView(linear);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
double focuspos = 0;
String focusStr = input.getText().toString();
if (focusStr.length() > 0) {
try {
focuspos = Double.parseDouble(focusStr);
} catch (NumberFormatException e) {
Log.w(TAG, "Input foucspos " + focuspos + " is invalid");
focuspos = maxFocusPos + 1f;
}
} else {
RotateTextToast.makeText(mActivity, "Invalid focus position", Toast.LENGTH_SHORT).show();
return;
}
if (focuspos >= minFocusPos && focuspos <= maxFocusPos) {
Log.v(TAG, "Setting focus position : " + focusStr);
mManual3AEnabled |= MANUAL_FOCUS;
mParameters.setFocusMode(ParametersWrapper.FOCUS_MODE_MANUAL_POSITION);
// focus type 3 is diopter mode
mParameters.set(CameraSettings.KEY_MANUAL_FOCUS_TYPE, 3);
mParameters.set(CameraSettings.KEY_MANUAL_FOCUS_POSITION, focusStr);
updateCommonManual3ASettings();
onSharedPreferenceChanged();
} else {
RotateTextToast.makeText(mActivity, "Invalid focus position", Toast.LENGTH_SHORT).show();
}
}
});
alert.show();
} else {
mManual3AEnabled &= ~MANUAL_FOCUS;
mParameters.setFocusMode(mFocusManager.getFocusMode(false));
mUI.overrideSettings(CameraSettings.KEY_FOCUS_MODE, null);
updateCommonManual3ASettings();
onSharedPreferenceChanged();
}
}
use of java.lang.NumberFormatException in project android_packages_apps_Snap by LineageOS.
the class DrawAutoHDR method UpdateManualExposureSettings.
private void UpdateManualExposureSettings() {
// dismiss all popups first, because we need to show edit dialog
mUI.collapseCameraControls();
final AlertDialog.Builder alert = new AlertDialog.Builder(mActivity);
LinearLayout linear = new LinearLayout(mActivity);
linear.setOrientation(1);
final TextView ISOtext = new TextView(mActivity);
final EditText ISOinput = new EditText(mActivity);
final TextView ExpTimeText = new TextView(mActivity);
final EditText ExpTimeInput = new EditText(mActivity);
ISOinput.setInputType(InputType.TYPE_CLASS_NUMBER);
int floatType = InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER;
ExpTimeInput.setInputType(floatType);
alert.setTitle("Manual Exposure Settings");
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
mParameters = mCameraDevice.getParameters();
final int minISO = mParameters.getInt(CameraSettings.KEY_MIN_ISO);
final int maxISO = mParameters.getInt(CameraSettings.KEY_MAX_ISO);
String isoMode = CameraSettings.getISOValue(mParameters);
final String isoManual = CameraSettings.KEY_MANUAL_ISO;
String currentISO = mParameters.get(CameraSettings.KEY_CURRENT_ISO);
if (currentISO != null) {
ISOtext.setText("Current ISO is " + currentISO);
}
final String minExpTime = mParameters.get(CameraSettings.KEY_MIN_EXPOSURE_TIME);
final String maxExpTime = mParameters.get(CameraSettings.KEY_MAX_EXPOSURE_TIME);
String currentExpTime = mParameters.get(CameraSettings.KEY_CURRENT_EXPOSURE_TIME);
if (currentExpTime != null) {
ExpTimeText.setText("Current exposure time is " + currentExpTime);
}
String isoPriority = mActivity.getString(R.string.pref_camera_manual_exp_value_ISO_priority);
String expTimePriority = mActivity.getString(R.string.pref_camera_manual_exp_value_exptime_priority);
String userSetting = mActivity.getString(R.string.pref_camera_manual_exp_value_user_setting);
String manualExposureMode = mPreferences.getString(CameraSettings.KEY_MANUAL_EXPOSURE, mActivity.getString(R.string.pref_camera_manual_exp_default));
Log.v(TAG, "manual Exposure Mode selected = " + manualExposureMode);
if (manualExposureMode.equals(isoPriority)) {
alert.setMessage("Enter ISO in the range of " + minISO + " to " + maxISO);
linear.addView(ISOinput);
linear.addView(ISOtext);
alert.setView(linear);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
int newISO = -1;
String iso = ISOinput.getText().toString();
Log.v(TAG, "string iso length " + iso.length());
if (iso.length() > 0) {
newISO = Integer.parseInt(iso);
}
if (newISO <= maxISO && newISO >= minISO) {
Log.v(TAG, "Setting ISO : " + newISO);
mManual3AEnabled |= MANUAL_EXPOSURE;
CameraSettings.setISOValue(mParameters, isoManual);
mParameters.set(CameraSettings.KEY_CONTINUOUS_ISO, newISO);
mParameters.set(CameraSettings.KEY_EXPOSURE_TIME, "0");
updateCommonManual3ASettings();
onSharedPreferenceChanged();
} else {
RotateTextToast.makeText(mActivity, "Invalid ISO", Toast.LENGTH_SHORT).show();
}
}
});
alert.show();
} else if (manualExposureMode.equals(expTimePriority)) {
alert.setMessage("Enter exposure time in the range of " + minExpTime + "ms to " + maxExpTime + "ms");
linear.addView(ExpTimeInput);
linear.addView(ExpTimeText);
alert.setView(linear);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
double newExpTime = -1;
String expTime = ExpTimeInput.getText().toString();
if (expTime.length() > 0) {
try {
newExpTime = Double.parseDouble(expTime);
} catch (NumberFormatException e) {
Log.w(TAG, "Input expTime " + expTime + " is invalid");
newExpTime = Double.parseDouble(maxExpTime) + 1f;
}
}
if (newExpTime <= Double.parseDouble(maxExpTime) && newExpTime >= Double.parseDouble(minExpTime)) {
Log.v(TAG, "Setting Exposure time : " + newExpTime);
mManual3AEnabled |= MANUAL_EXPOSURE;
mParameters.set(CameraSettings.KEY_EXPOSURE_TIME, expTime);
CameraSettings.setISOValue(mParameters, Parameters.ISO_AUTO);
mUI.setPreference(CameraSettings.KEY_ISO, ParametersWrapper.ISO_AUTO);
mUI.overrideSettings(CameraSettings.KEY_ISO, null);
updateCommonManual3ASettings();
onSharedPreferenceChanged();
} else {
RotateTextToast.makeText(mActivity, "Invalid exposure time", Toast.LENGTH_SHORT).show();
}
}
});
alert.show();
} else if (manualExposureMode.equals(userSetting)) {
alert.setMessage("Full manual mode - Enter both ISO and Exposure Time");
final TextView ISORangeText = new TextView(mActivity);
final TextView ExpTimeRangeText = new TextView(mActivity);
ISORangeText.setText("Enter ISO in the range of " + minISO + " to " + maxISO);
ExpTimeRangeText.setText("Enter exposure time in the range of " + minExpTime + "ms to " + maxExpTime + "ms");
linear.addView(ISORangeText);
linear.addView(ISOinput);
linear.addView(ISOtext);
linear.addView(ExpTimeRangeText);
linear.addView(ExpTimeInput);
linear.addView(ExpTimeText);
alert.setView(linear);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
int newISO = -1;
String iso = ISOinput.getText().toString();
Log.v(TAG, "string iso length " + iso.length());
if (iso.length() > 0) {
newISO = Integer.parseInt(iso);
}
double newExpTime = -1;
String expTime = ExpTimeInput.getText().toString();
if (expTime.length() > 0) {
try {
newExpTime = Double.parseDouble(expTime);
} catch (NumberFormatException e) {
Log.w(TAG, "input newExpTime " + newExpTime + " is invalid");
newExpTime = Double.parseDouble(maxExpTime) + 1f;
}
}
if (newISO <= maxISO && newISO >= minISO && newExpTime <= Double.parseDouble(maxExpTime) && newExpTime >= Double.parseDouble(minExpTime)) {
mManual3AEnabled |= MANUAL_EXPOSURE;
Log.v(TAG, "Setting ISO : " + newISO);
CameraSettings.setISOValue(mParameters, isoManual);
mParameters.set(CameraSettings.KEY_CONTINUOUS_ISO, newISO);
Log.v(TAG, "Setting Exposure time : " + newExpTime);
mParameters.set(CameraSettings.KEY_EXPOSURE_TIME, expTime);
updateCommonManual3ASettings();
onSharedPreferenceChanged();
} else {
RotateTextToast.makeText(mActivity, "Invalid input", Toast.LENGTH_SHORT).show();
}
}
});
alert.show();
} else {
mManual3AEnabled &= ~MANUAL_EXPOSURE;
// auto exposure mode - reset both exposure time and ISO
mParameters.set(CameraSettings.KEY_EXPOSURE_TIME, "0");
mUI.overrideSettings(CameraSettings.KEY_ISO, null);
updateCommonManual3ASettings();
onSharedPreferenceChanged();
}
}
use of java.lang.NumberFormatException in project openj9 by eclipse.
the class BDEncodingTest method testEncoding2.
@Test
public void testEncoding2() {
char[] doubleWidthChars = new char[] { '\uff0b', '\uff11', '\uff12', '\uff0e', '\uff13', '\uff14', '\uff15', '\uff25', '\uff0d', '\uff16', '\uff17', '\uff18', '\uff19', '\uff10', '\uff10' };
char[] singleWidthChars = new char[] { '+', '1', '2', '.', '3', '4', '5', 'e', '-', '6', '7', '8', '9', '0', '0' };
boolean caught = false;
try {
BigDecimal doubleWidthBD = new BigDecimal(doubleWidthChars);
BigDecimal singleWidthBD = new BigDecimal(singleWidthChars);
} catch (NumberFormatException e) {
caught = true;
}
AssertJUnit.assertTrue("testEncoding2", caught);
}
use of java.lang.NumberFormatException in project barcodescanner-sdk-cordova by Scandit.
the class UIParamParser method updatePickerUI.
public static void updatePickerUI(BarcodePicker picker, Bundle bundle) {
if (picker == null || bundle == null) {
return;
}
if (bundle.containsKey(paramBeep)) {
picker.getOverlayView().setBeepEnabled(bundle.getBoolean(paramBeep));
}
if (bundle.containsKey(paramVibrate)) {
picker.getOverlayView().setVibrateEnabled(bundle.getBoolean(paramVibrate));
}
if (bundle.containsKey(paramTorch)) {
picker.getOverlayView().setTorchEnabled(bundle.getBoolean(paramTorch));
}
if (bundleContainsStringKey(bundle, paramTorchButtonOffAccessibilityLabel)) {
String label = bundle.getString(paramTorchButtonOffAccessibilityLabel);
picker.getOverlayView().setTorchOffContentDescription(label);
}
if (bundleContainsStringKey(bundle, paramTorchButtonOnAccessibilityLabel)) {
String label = bundle.getString(paramTorchButtonOnAccessibilityLabel);
picker.getOverlayView().setTorchOnContentDescription(label);
}
if (bundleContainsListKey(bundle, paramTorchButtonMarginsAndSize)) {
List<Object> marginsAndSize = (List<Object>) bundle.getSerializable(paramTorchButtonMarginsAndSize);
if ((checkClassOfListObjects(marginsAndSize, Integer.class) || checkClassOfListObjects(marginsAndSize, String.class)) && marginsAndSize.size() == 4) {
picker.getOverlayView().setTorchButtonMarginsAndSize(getSize(marginsAndSize.get(0), 0), getSize(marginsAndSize.get(1), 0), getSize(marginsAndSize.get(2), 0), getSize(marginsAndSize.get(3), 0));
} else {
Log.e("ScanditSDK", "Failed to parse torch button margins and size - wrong type");
}
}
if (bundle.containsKey(paramCameraSwitchVisibility)) {
switch(bundle.getInt(paramCameraSwitchVisibility, -1)) {
case 0:
picker.getOverlayView().setCameraSwitchVisibility(ScanOverlay.CAMERA_SWITCH_NEVER);
break;
case 1:
picker.getOverlayView().setCameraSwitchVisibility(ScanOverlay.CAMERA_SWITCH_ON_TABLET);
break;
case 2:
picker.getOverlayView().setCameraSwitchVisibility(ScanOverlay.CAMERA_SWITCH_ALWAYS);
break;
default:
Log.e("ScanditSDK", "Failed to parse camera switch visibility - wrong type");
break;
}
}
if (bundleContainsListKey(bundle, paramCameraSwitchButtonMarginsAndSize)) {
List<Object> marginsAndSize = (List<Object>) bundle.getSerializable(paramCameraSwitchButtonMarginsAndSize);
if ((checkClassOfListObjects(marginsAndSize, Integer.class) || checkClassOfListObjects(marginsAndSize, String.class)) && marginsAndSize.size() == 4) {
picker.getOverlayView().setCameraSwitchButtonMarginsAndSize(getSize(marginsAndSize.get(0), 0), getSize(marginsAndSize.get(1), 0), getSize(marginsAndSize.get(2), 0), getSize(marginsAndSize.get(3), 0));
} else {
Log.e("ScanditSDK", "Failed to parse camera switch button margins and size - wrong type");
}
}
if (bundleContainsStringKey(bundle, paramCameraSwitchButtonBackAccessibilityLabel)) {
String label = bundle.getString(paramCameraSwitchButtonBackAccessibilityLabel);
picker.getOverlayView().setTorchOffContentDescription(label);
}
if (bundleContainsStringKey(bundle, paramCameraSwitchButtonFrontAccessibilityLabel)) {
String label = bundle.getString(paramCameraSwitchButtonFrontAccessibilityLabel);
picker.getOverlayView().setTorchOnContentDescription(label);
}
if (bundleContainsListKey(bundle, paramViewfinderDimension)) {
List<Object> viewfinderDimension = (List<Object>) bundle.getSerializable(paramViewfinderDimension);
if (checkClassOfListObjects(viewfinderDimension, Float.class) && viewfinderDimension.size() == 4) {
picker.getOverlayView().setViewfinderDimension((Float) viewfinderDimension.get(0), (Float) viewfinderDimension.get(1), (Float) viewfinderDimension.get(2), (Float) viewfinderDimension.get(3));
} else {
Log.e("ScanditSDK", "Failed to parse viewfinder dimension - wrong type");
}
}
if (bundleContainsStringKey(bundle, paramViewfinderColor)) {
String color = bundle.getString(paramViewfinderColor);
if (color.length() == 6) {
try {
String red = color.substring(0, 2);
String green = color.substring(2, 4);
String blue = color.substring(4, 6);
float r = ((float) Integer.parseInt(red, 16)) / 256.0f;
float g = ((float) Integer.parseInt(green, 16)) / 256.0f;
float b = ((float) Integer.parseInt(blue, 16)) / 256.0f;
picker.getOverlayView().setViewfinderColor(r, g, b);
} catch (NumberFormatException e) {
}
}
}
if (bundleContainsStringKey(bundle, paramViewfinderDecodedColor)) {
String color = bundle.getString(paramViewfinderDecodedColor);
if (color.length() == 6) {
try {
String red = color.substring(0, 2);
String green = color.substring(2, 4);
String blue = color.substring(4, 6);
float r = ((float) Integer.parseInt(red, 16)) / 256.0f;
float g = ((float) Integer.parseInt(green, 16)) / 256.0f;
float b = ((float) Integer.parseInt(blue, 16)) / 256.0f;
picker.getOverlayView().setViewfinderDecodedColor(r, g, b);
} catch (NumberFormatException e) {
}
}
}
if (bundle.containsKey(paramGuiStyle)) {
switch(bundle.getInt(paramGuiStyle, -1)) {
case 0:
picker.getOverlayView().setGuiStyle(ScanOverlay.GUI_STYLE_DEFAULT);
break;
case 1:
picker.getOverlayView().setGuiStyle(ScanOverlay.GUI_STYLE_LASER);
break;
case 2:
picker.getOverlayView().setGuiStyle(ScanOverlay.GUI_STYLE_NONE);
break;
case 3:
picker.getOverlayView().setGuiStyle(ScanOverlay.GUI_STYLE_MATRIX_SCAN);
break;
case 4:
picker.getOverlayView().setGuiStyle(ScanOverlay.GUI_STYLE_LOCATIONS_ONLY);
break;
default:
Log.e("ScanditSDK", "Failed to parse gui style - wrong type");
break;
}
}
if (bundleContainsBundleKey(bundle, paramProperties)) {
Bundle properties = bundle.getBundle(paramProperties);
for (String key : properties.keySet()) {
picker.getOverlayView().setProperty(key, properties.get(key));
}
}
if (bundleContainsStringKey(bundle, paramMissingCameraPermissionInfoText)) {
String missingCameraPermissionInfoText = bundle.getString(paramMissingCameraPermissionInfoText);
picker.getOverlayView().setMissingCameraPermissionInfoText(missingCameraPermissionInfoText);
}
if (bundle.containsKey(paramTextRecognitionSwitchVisible)) {
picker.getOverlayView().setTextRecognitionSwitchVisible(bundle.getBoolean(paramTextRecognitionSwitchVisible));
}
if (bundleContainsBundleKey(bundle, paramMatrixScanHighlightingColor)) {
Bundle colors = bundle.getBundle(paramMatrixScanHighlightingColor);
for (String key : colors.keySet()) {
try {
int color = Integer.parseInt(colors.getString(key), 16);
picker.getOverlayView().setMatrixScanHighlightingColor(Integer.parseInt(key), color);
} catch (NumberFormatException e) {
}
}
}
}
Aggregations