diff options
author | Andrew Dodd <atd7@cornell.edu> | 2012-07-07 11:15:24 -0400 |
---|---|---|
committer | Andrew Dodd <atd7@cornell.edu> | 2012-07-07 11:15:24 -0400 |
commit | 44f182eecda0fc1e2f9bd387efe86f116664e860 (patch) | |
tree | ae4f07d33bd9fef8cbbf32a37ca8d2bea9f96042 /DeviceSettings/src/com/cyanogenmod/settings | |
parent | 1df319d7679de75e14dfa35900d04f8c31efd0ba (diff) | |
download | device_samsung_n7000-44f182eecda0fc1e2f9bd387efe86f116664e860.zip device_samsung_n7000-44f182eecda0fc1e2f9bd387efe86f116664e860.tar.gz device_samsung_n7000-44f182eecda0fc1e2f9bd387efe86f116664e860.tar.bz2 |
n7000: Sync DeviceSettings with merged galaxys2
I was a bit too lazy about translation patches...
Copy the whole thing over from GS2 and rename
to GalaxyNoteSettings.
Change-Id: Ia6ca5cbf474edecb4a77e5bb77b847829910a4a1
Diffstat (limited to 'DeviceSettings/src/com/cyanogenmod/settings')
3 files changed, 79 insertions, 13 deletions
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java index 015dd7b..bc42a95 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java @@ -80,14 +80,15 @@ public class SensorsFragmentActivity extends PreferenceFragment { public static void restore(Context context) { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); - String gyroCalib = sharedPrefs.getString(DeviceSettings.KEY_USE_GYRO_CALIBRATION, "1"); + boolean gyroCalib = sharedPrefs.getBoolean(DeviceSettings.KEY_USE_GYRO_CALIBRATION, true); // When use gyro calibration value is set to 1, calibration is done at the same time, which // means it is reset at each boot, providing wrong calibration most of the time at each reboot. // So we only set it to "0" if user wants it, as it defaults to 1 at boot - if (gyroCalib.compareTo("1") != 0) - Utils.writeValue(FILE_USE_GYRO_CALIB, gyroCalib); + if (!gyroCalib) + Utils.writeValue(FILE_USE_GYRO_CALIB, "0"); - Utils.writeValue(FILE_TOUCHKEY_LIGHT, sharedPrefs.getString(DeviceSettings.KEY_TOUCHKEY_LIGHT, "1")); + boolean light = sharedPrefs.getBoolean(DeviceSettings.KEY_TOUCHKEY_LIGHT, true); + Utils.writeValue(FILE_TOUCHKEY_LIGHT, light); } } diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java index 7566273..a3b5135 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java @@ -31,6 +31,7 @@ public class Startup extends BroadcastReceiver { RadioFragmentActivity.restore(context); HapticFragmentActivity.restore(context); VibratorIntensity.restore(context); + SensorsFragmentActivity.restore(context); } } diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java index 9d4176c..237ea0f 100644 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java @@ -16,32 +16,96 @@ package com.cyanogenmod.settings.device; +import android.util.Log; + import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.SyncFailedException; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Context; public class Utils { + private static final String TAG = "GalaxyNoteSettings_Utils"; + private static final String TAG_READ = "GalaxyNoteSettings_Utils_Read"; + private static final String TAG_WRITE = "GalaxyNoteSettings_Utils_Write"; + /** * Write a string value to the specified file. - * @param filename The filename - * @param value The value + * + * @param filename The filename + * @param value The value */ public static void writeValue(String filename, String value) { + FileOutputStream fos = null; try { - FileOutputStream fos = new FileOutputStream(new File(filename)); + fos = new FileOutputStream(new File(filename), false); fos.write(value.getBytes()); fos.flush(); - fos.getFD().sync(); - fos.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); + // fos.getFD().sync(); + } catch (FileNotFoundException ex) { + Log.w(TAG, "file " + filename + " not found: " + ex); + } catch (SyncFailedException ex) { + Log.w(TAG, "file " + filename + " sync failed: " + ex); + } catch (IOException ex) { + Log.w(TAG, "IOException trying to sync " + filename + ": " + ex); + } catch (RuntimeException ex) { + Log.w(TAG, "exception while syncing file: ", ex); + } finally { + if (fos != null) { + try { + Log.w(TAG_WRITE, "file " + filename + ": " + value); + fos.close(); + } catch (IOException ex) { + Log.w(TAG, "IOException while closing synced file: ", ex); + } catch (RuntimeException ex) { + Log.w(TAG, "exception while closing file: ", ex); + } + } + } + + } + + /** + * Write a string value to the specified file. + * + * @param filename The filename + * @param value The value + */ + public static void writeValue(String filename, Boolean value) { + FileOutputStream fos = null; + String sEnvia; + try { + fos = new FileOutputStream(new File(filename), false); + if (value) + sEnvia = "1"; + else + sEnvia = "0"; + fos.write(sEnvia.getBytes()); + fos.flush(); + // fos.getFD().sync(); + } catch (FileNotFoundException ex) { + Log.w(TAG, "file " + filename + " not found: " + ex); + } catch (SyncFailedException ex) { + Log.w(TAG, "file " + filename + " sync failed: " + ex); + } catch (IOException ex) { + Log.w(TAG, "IOException trying to sync " + filename + ": " + ex); + } catch (RuntimeException ex) { + Log.w(TAG, "exception while syncing file: ", ex); + } finally { + if (fos != null) { + try { + Log.w(TAG_WRITE, "file " + filename + ": " + value); + fos.close(); + } catch (IOException ex) { + Log.w(TAG, "IOException while closing synced file: ", ex); + } catch (RuntimeException ex) { + Log.w(TAG, "exception while closing file: ", ex); + } + } } } |