summaryrefslogtreecommitdiffstats
path: root/DeviceSettings
diff options
context:
space:
mode:
authorDaniel Hillenbrand <daniel.hillenbrand@codeworkx.de>2012-06-17 12:24:13 +0200
committerDaniel Hillenbrand <daniel.hillenbrand@codeworkx.de>2012-06-17 12:24:13 +0200
commita24f04fafd95854c75097bff12c2030e973662c9 (patch)
tree1310c89ab04c52a3c96d099afc987f4647de255a /DeviceSettings
parent764ca1f6bd7ee2afd3ce3cd2446e44902c6eb0b7 (diff)
downloaddevice_samsung_i9300-a24f04fafd95854c75097bff12c2030e973662c9.zip
device_samsung_i9300-a24f04fafd95854c75097bff12c2030e973662c9.tar.gz
device_samsung_i9300-a24f04fafd95854c75097bff12c2030e973662c9.tar.bz2
settings: some fixes on touchkey restore, cosmetic changes
Diffstat (limited to 'DeviceSettings')
-rw-r--r--DeviceSettings/AndroidManifest.xml5
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java2
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java19
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java82
4 files changed, 93 insertions, 15 deletions
diff --git a/DeviceSettings/AndroidManifest.xml b/DeviceSettings/AndroidManifest.xml
index d658983..d373ded 100644
--- a/DeviceSettings/AndroidManifest.xml
+++ b/DeviceSettings/AndroidManifest.xml
@@ -22,9 +22,10 @@
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
-
- <activity android:name=".mDNIeFragmentActivity" />
+
+ <activity android:name=".HapticFragmentActivity" />
<activity android:name=".RadioFragmentActivity" />
+ <activity android:name=".ScreenFragmentActivity" />
</application>
</manifest>
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
index 527e931..59047fa 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
@@ -33,7 +33,7 @@ import com.cyanogenmod.settings.device.R;
public class HapticFragmentActivity extends PreferenceFragment {
private static final String PREF_ENABLED = "1";
- private static final String TAG = "GalaxyS3Parts_General";
+ private static final String TAG = "GalaxyS3Settings_General";
@Override
public void onCreate(Bundle savedInstanceState) {
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
index e0d225f..37f25b8 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
@@ -33,7 +33,7 @@ import com.cyanogenmod.settings.device.R;
public class ScreenFragmentActivity extends PreferenceFragment {
private static final String PREF_ENABLED = "1";
- private static final String TAG = "GalaxyS3Parts_General";
+ private static final String TAG = "GalaxyS3Settings_General";
private mDNIeScenario mmDNIeScenario;
private mDNIeMode mmDNIeMode;
private mDNIeNegative mmDNIeNegative;
@@ -82,7 +82,20 @@ public class ScreenFragmentActivity extends PreferenceFragment {
public static void restore(Context context) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- Utils.writeValue(FILE_TOUCHKEY_DISABLE, sharedPrefs.getString(DeviceSettings.KEY_TOUCHKEY_LIGHT, "0"));
- Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, sharedPrefs.getString(DeviceSettings.KEY_TOUCHKEY_LIGHT, "1"));
+
+ Boolean light = sharedPrefs.getBoolean(DeviceSettings.KEY_TOUCHKEY_LIGHT, true);
+ String disabled;
+ String brightness;
+
+ if (light == true) {
+ disabled = "0";
+ brightness = "1";
+ } else {
+ disabled = "1";
+ brightness = "2";
+ }
+
+ Utils.writeValue(FILE_TOUCHKEY_DISABLE, disabled);
+ Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, brightness);
}
}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
index 9d4176c..d4df92f 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 = "GalaxyS3Settings_Utils";
+ private static final String TAG_READ = "GalaxyS3Settings_Utils_Read";
+ private static final String TAG_WRITE = "GalaxyS3Settings_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);
+ }
+ }
}
}