com.google.zxing.client.android.PreferencesActivity Java Examples

The following examples show how to use com.google.zxing.client.android.PreferencesActivity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CameraManager.java    From android-apps with MIT License 6 votes vote down vote up
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder The surface object which the camera will draw preview frames into.
 * @throws IOException Indicates the camera driver failed to open.
 */
public void openDriver(SurfaceHolder holder) throws IOException {
  Camera theCamera = camera;
  if (theCamera == null) {
    theCamera = Camera.open();
    if (theCamera == null) {
      throw new IOException();
    }
    camera = theCamera;
  }
  theCamera.setPreviewDisplay(holder);

  if (!initialized) {
    initialized = true;
    configManager.initFromCameraParameters(theCamera);
    if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
      setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
      requestedFramingRectWidth = 0;
      requestedFramingRectHeight = 0;
    }
  }
  configManager.setDesiredCameraParameters(theCamera);

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
  reverseImage = prefs.getBoolean(PreferencesActivity.KEY_REVERSE_IMAGE, false);
}
 
Example #2
Source File: ResultHandler.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
private String parseCustomSearchURL() {
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  String customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH,
      null);
  if (customProductSearch != null && customProductSearch.trim().isEmpty()) {
    return null;
  }
  return customProductSearch;
}
 
Example #3
Source File: AutoFocusManager.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
AutoFocusManager(Context context, Camera camera) {
  this.camera = camera;
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  String currentFocusMode = camera.getParameters().getFocusMode();
  useAutoFocus =
      sharedPrefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true) &&
      FOCUS_MODES_CALLING_AF.contains(currentFocusMode);
  Log.i(TAG, "Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus);
  start();
}
 
Example #4
Source File: HistoryManager.java    From android-apps with MIT License 5 votes vote down vote up
public void addHistoryItem(Result result, ResultHandler handler) {
  // Do not save this item to the history if the preference is turned off, or the contents are
  // considered secure.
  if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
      handler.areContentsSecure()) {
    return;
  }

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
    deletePrevious(result.getText());
  }

  ContentValues values = new ContentValues();
  values.put(DBHelper.TEXT_COL, result.getText());
  values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
  values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
  values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    // Insert the new entry into the DB.
    db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
  } finally {
    close(null, db);
  }
}
 
Example #5
Source File: CameraConfigurationManager.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
private void doSetTorch(Camera.Parameters parameters, boolean newSetting, boolean safeMode) {
  CameraConfigurationUtils.setTorch(parameters, newSetting);
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (!safeMode && !prefs.getBoolean(PreferencesActivity.KEY_DISABLE_EXPOSURE, true)) {
    CameraConfigurationUtils.setBestExposure(parameters, newSetting);
  }
}
 
Example #6
Source File: ResultHandler.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
private String parseCustomSearchURL() {
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  String customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH,
      null);
  if (customProductSearch != null && customProductSearch.trim().isEmpty()) {
    return null;
  }
  return customProductSearch;
}
 
Example #7
Source File: ResultHandler.java    From android-apps with MIT License 5 votes vote down vote up
private String parseCustomSearchURL() {
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  String customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH,
      null);
  if (customProductSearch != null && customProductSearch.trim().length() == 0) {
    return null;
  }
  return customProductSearch;
}
 
Example #8
Source File: HistoryManager.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
public void addHistoryItem(Result result, ResultHandler handler) {
  // Do not save this item to the history if the preference is turned off, or the contents are
  // considered secure.
  if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
      handler.areContentsSecure() || !enableHistory) {
    return;
  }

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
    deletePrevious(result.getText());
  }

  ContentValues values = new ContentValues();
  values.put(DBHelper.TEXT_COL, result.getText());
  values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
  values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
  values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    // Insert the new entry into the DB.
    db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
  } finally {
    close(null, db);
  }
}
 
Example #9
Source File: AutoFocusManager.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
AutoFocusManager(Context context, Camera camera) {
  this.camera = camera;
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  String currentFocusMode = camera.getParameters().getFocusMode();
  useAutoFocus =
      sharedPrefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true) &&
      FOCUS_MODES_CALLING_AF.contains(currentFocusMode);
  Log.i(TAG, "Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus);
  start();
}
 
Example #10
Source File: CameraConfigurationManager.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
private void doSetTorch(Camera.Parameters parameters, boolean newSetting, boolean safeMode) {
  CameraConfigurationUtils.setTorch(parameters, newSetting);
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (!safeMode && !prefs.getBoolean(PreferencesActivity.KEY_DISABLE_EXPOSURE, true)) {
    CameraConfigurationUtils.setBestExposure(parameters, newSetting);
  }
}
 
Example #11
Source File: HistoryManager.java    From weex with Apache License 2.0 5 votes vote down vote up
public void addHistoryItem(Result result, ResultHandler handler) {
  // Do not save this item to the history if the preference is turned off, or the contents are
  // considered secure.
  if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
      handler.areContentsSecure() || !enableHistory) {
    return;
  }

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
    deletePrevious(result.getText());
  }

  ContentValues values = new ContentValues();
  values.put(DBHelper.TEXT_COL, result.getText());
  values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
  values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
  values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    // Insert the new entry into the DB.
    db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
  } finally {
    close(null, db);
  }
}
 
Example #12
Source File: CameraConfigurationManager.java    From android-apps with MIT License 5 votes vote down vote up
void setTorch(Camera camera, boolean newSetting) {
  Camera.Parameters parameters = camera.getParameters();
  doSetTorch(parameters, newSetting);
  camera.setParameters(parameters);
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
  boolean currentSetting = prefs.getBoolean(PreferencesActivity.KEY_FRONT_LIGHT, false);
  if (currentSetting != newSetting) {
    SharedPreferences.Editor editor = prefs.edit();
    editor.putBoolean(PreferencesActivity.KEY_FRONT_LIGHT, newSetting);
    editor.commit();
  }
}
 
Example #13
Source File: HistoryManager.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
public void addHistoryItem(Result result, ResultHandler handler) {
  // Do not save this item to the history if the preference is turned off, or the contents are
  // considered secure.
  if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
      handler.areContentsSecure() || !enableHistory) {
    return;
  }

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
    deletePrevious(result.getText());
  }

  ContentValues values = new ContentValues();
  values.put(DBHelper.TEXT_COL, result.getText());
  values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
  values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
  values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    // Insert the new entry into the DB.
    db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
  } finally {
    close(null, db);
  }
}
 
Example #14
Source File: AutoFocusManager.java    From reacteu-app with MIT License 5 votes vote down vote up
AutoFocusManager(Context context, Camera camera) {
  this.camera = camera;
  taskExec = new AsyncTaskExecManager().build();
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  String currentFocusMode = camera.getParameters().getFocusMode();
  useAutoFocus =
      sharedPrefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true) &&
      FOCUS_MODES_CALLING_AF.contains(currentFocusMode);
  Log.i(TAG, "Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus);
  start();
}
 
Example #15
Source File: CameraConfigurationManager.java    From reacteu-app with MIT License 5 votes vote down vote up
void setTorch(Camera camera, boolean newSetting) {
  Camera.Parameters parameters = camera.getParameters();
  doSetTorch(parameters, newSetting, false);
  camera.setParameters(parameters);
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
  boolean currentSetting = prefs.getBoolean(PreferencesActivity.KEY_FRONT_LIGHT, false);
  if (currentSetting != newSetting) {
    SharedPreferences.Editor editor = prefs.edit();
    editor.putBoolean(PreferencesActivity.KEY_FRONT_LIGHT, newSetting);
    editor.commit();
  }
}
 
Example #16
Source File: HistoryManager.java    From reacteu-app with MIT License 5 votes vote down vote up
public void addHistoryItem(Result result, ResultHandler handler) {
  // Do not save this item to the history if the preference is turned off, or the contents are
  // considered secure.
  if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
      handler.areContentsSecure()) {
    return;
  }

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
    deletePrevious(result.getText());
  }

  ContentValues values = new ContentValues();
  values.put(DBHelper.TEXT_COL, result.getText());
  values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
  values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
  values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    // Insert the new entry into the DB.
    db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
  } finally {
    close(null, db);
  }
}
 
Example #17
Source File: ResultHandler.java    From reacteu-app with MIT License 5 votes vote down vote up
private String parseCustomSearchURL() {
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  String customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH,
      null);
  if (customProductSearch != null && customProductSearch.trim().length() == 0) {
    return null;
  }
  return customProductSearch;
}
 
Example #18
Source File: ResultHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
private String parseCustomSearchURL() {
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  String customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH,
      null);
  if (customProductSearch != null && customProductSearch.trim().isEmpty()) {
    return null;
  }
  return customProductSearch;
}
 
Example #19
Source File: AutoFocusManager.java    From ZXing-Standalone-library with Apache License 2.0 5 votes vote down vote up
AutoFocusManager(Context context, Camera camera) {
  this.camera = camera;
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  String currentFocusMode = camera.getParameters().getFocusMode();
  useAutoFocus =
      sharedPrefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true) &&
      FOCUS_MODES_CALLING_AF.contains(currentFocusMode);
  Log.i(TAG, "Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus);
  start();
}
 
Example #20
Source File: CameraConfigurationManager.java    From ZXing-Standalone-library with Apache License 2.0 5 votes vote down vote up
private void doSetTorch(Camera.Parameters parameters, boolean newSetting, boolean safeMode) {
  CameraConfigurationUtils.setTorch(parameters, newSetting);
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (!safeMode && !prefs.getBoolean(PreferencesActivity.KEY_DISABLE_EXPOSURE, true)) {
    CameraConfigurationUtils.setBestExposure(parameters, newSetting);
  }
}
 
Example #21
Source File: ResultHandler.java    From ZXing-Standalone-library with Apache License 2.0 5 votes vote down vote up
private String parseCustomSearchURL() {
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  String customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH,
      null);
  if (customProductSearch != null && customProductSearch.trim().isEmpty()) {
    return null;
  }
  return customProductSearch;
}
 
Example #22
Source File: HistoryManager.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
public void addHistoryItem(Result result, ResultHandler handler) {
  // Do not save this item to the history if the preference is turned off, or the contents are
  // considered secure.
  if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
      handler.areContentsSecure()) {
    return;
  }

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
    deletePrevious(result.getText());
  }

  ContentValues values = new ContentValues();
  values.put(DBHelper.TEXT_COL, result.getText());
  values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
  values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
  values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    // Insert the new entry into the DB.
    db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
  } finally {
    close(null, db);
  }
}
 
Example #23
Source File: HistoryManager.java    From ZXing-Standalone-library with Apache License 2.0 5 votes vote down vote up
public void addHistoryItem(Result result, ResultHandler handler) {
  // Do not save this item to the history if the preference is turned off, or the contents are
  // considered secure.
  if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
      handler.areContentsSecure() || !enableHistory) {
    return;
  }

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
    deletePrevious(result.getText());
  }

  ContentValues values = new ContentValues();
  values.put(DBHelper.TEXT_COL, result.getText());
  values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
  values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
  values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    // Insert the new entry into the DB.
    db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
  } finally {
    close(null, db);
  }
}
 
Example #24
Source File: AutoFocusManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
AutoFocusManager(Context context, Camera camera) {
  this.camera = camera;
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  String currentFocusMode = camera.getParameters().getFocusMode();
  useAutoFocus =
      sharedPrefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true) &&
      FOCUS_MODES_CALLING_AF.contains(currentFocusMode);
  Log.i(TAG, "Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus);
  start();
}
 
Example #25
Source File: ResultHandler.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
private String parseCustomSearchURL() {
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  String customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH,
      null);
  if (customProductSearch != null && customProductSearch.trim().isEmpty()) {
    return null;
  }
  return customProductSearch;
}
 
Example #26
Source File: CameraConfigurationManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
private void doSetTorch(Camera.Parameters parameters, boolean newSetting, boolean safeMode) {
  CameraConfigurationUtils.setTorch(parameters, newSetting);
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (!safeMode && !prefs.getBoolean(PreferencesActivity.KEY_DISABLE_EXPOSURE, true)) {
    CameraConfigurationUtils.setBestExposure(parameters, newSetting);
  }
}
 
Example #27
Source File: CameraConfigurationManager.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
private void doSetTorch(Camera.Parameters parameters, boolean newSetting, boolean safeMode) {
  CameraConfigurationUtils.setTorch(parameters, newSetting);
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (!safeMode && !prefs.getBoolean(PreferencesActivity.KEY_DISABLE_EXPOSURE, true)) {
    CameraConfigurationUtils.setBestExposure(parameters, newSetting);
  }
}
 
Example #28
Source File: HistoryManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
public void addHistoryItem(Result result, ResultHandler handler) {
  // Do not save this item to the history if the preference is turned off, or the contents are
  // considered secure.
  if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) ||
      handler.areContentsSecure() || !enableHistory) {
    return;
  }

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
  if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) {
    deletePrevious(result.getText());
  }

  ContentValues values = new ContentValues();
  values.put(DBHelper.TEXT_COL, result.getText());
  values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString());
  values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString());
  values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis());

  SQLiteOpenHelper helper = new DBHelper(activity);
  SQLiteDatabase db = null;
  try {
    db = helper.getWritableDatabase();      
    // Insert the new entry into the DB.
    db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values);
  } finally {
    close(null, db);
  }
}
 
Example #29
Source File: AutoFocusManager.java    From weex with Apache License 2.0 5 votes vote down vote up
AutoFocusManager(Context context, Camera camera) {
  this.camera = camera;
  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
  String currentFocusMode = camera.getParameters().getFocusMode();
  useAutoFocus =
      sharedPrefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true) &&
      FOCUS_MODES_CALLING_AF.contains(currentFocusMode);
  Log.i(TAG, "Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus);
  start();
}
 
Example #30
Source File: CameraConfigurationManager.java    From weex with Apache License 2.0 5 votes vote down vote up
private void doSetTorch(Camera.Parameters parameters, boolean newSetting, boolean safeMode) {
  CameraConfigurationUtils.setTorch(parameters, newSetting);
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
  if (!safeMode && !prefs.getBoolean(PreferencesActivity.KEY_DISABLE_EXPOSURE, true)) {
    CameraConfigurationUtils.setBestExposure(parameters, newSetting);
  }
}