From 8d0aaa3342810ea2fce3fb432b60ce745a6e4d9e Mon Sep 17 00:00:00 2001 From: Markus Reumueller Date: Sat, 8 Dec 2012 18:07:30 +0100 Subject: Bugfix --> presets are not restored after reboot Some cleanups German Translation PatchSet2: derp... Change-Id: Ic85b340ea67b1c5e1b80bc62e40238bc6fde5eff --- .../res/layout/preference_colorgamma_presets.xml | 7 +-- .../res/layout/preference_dialog_color_tuning.xml | 5 +- GNexusParts/res/values-de/arrays.xml | 7 +++ GNexusParts/res/values-de/strings.xml | 16 +++++- .../settings/device/ColorHackPresets.java | 61 +++++++++++----------- .../settings/device/ColorTuningPreference.java | 36 +++++++------ .../settings/device/DevicePreferenceActivity.java | 23 -------- .../settings/device/GammaTuningPreference.java | 16 +++--- .../settings/device/VibratorTuningPreference.java | 23 ++++---- 9 files changed, 99 insertions(+), 95 deletions(-) create mode 100644 GNexusParts/res/values-de/arrays.xml (limited to 'GNexusParts') diff --git a/GNexusParts/res/layout/preference_colorgamma_presets.xml b/GNexusParts/res/layout/preference_colorgamma_presets.xml index af85740..e99dfba 100755 --- a/GNexusParts/res/layout/preference_colorgamma_presets.xml +++ b/GNexusParts/res/layout/preference_colorgamma_presets.xml @@ -117,15 +117,16 @@ android:layout_width="320dp" android:layout_height="wrap_content" android:layout_weight="1" + android:gravity="center" android:layout_below="@+id/linearLayout2" > + android:gravity="center" + android:text="@string/credits_presets" + android:textSize="15dp"/> diff --git a/GNexusParts/res/layout/preference_dialog_color_tuning.xml b/GNexusParts/res/layout/preference_dialog_color_tuning.xml index 51883d1..b49b505 100644 --- a/GNexusParts/res/layout/preference_dialog_color_tuning.xml +++ b/GNexusParts/res/layout/preference_dialog_color_tuning.xml @@ -126,15 +126,16 @@ android:layout_width="320dp" android:layout_height="wrap_content" android:layout_weight="1" + android:gravity="center" android:layout_below="@+id/linearLayout1"> + android:textSize="15dp"/> diff --git a/GNexusParts/res/values-de/arrays.xml b/GNexusParts/res/values-de/arrays.xml new file mode 100644 index 0000000..69b405e --- /dev/null +++ b/GNexusParts/res/values-de/arrays.xml @@ -0,0 +1,7 @@ + + + 307,2 MHz (Standard) + 384,0 MHz + 512,0 MHz + + diff --git a/GNexusParts/res/values-de/strings.xml b/GNexusParts/res/values-de/strings.xml index 89d6fc3..e42198c 100644 --- a/GNexusParts/res/values-de/strings.xml +++ b/GNexusParts/res/values-de/strings.xml @@ -2,6 +2,7 @@ Galaxy Nexus Einstellungen + Anzeige Farbmultiplikator Farbmultiplikator einstellen Gammakorrektur @@ -18,6 +19,16 @@ CM Natural DSS Gammawert + Werte höher als 200 sind nicht ratsam + + + Hardware + Vibration + Ändert die Grundeinstellung der Vibrationsintensität + + Vibration % + Standard + Test Standard Maximal @@ -25,10 +36,13 @@ Warm Kalt Natürlich - Dank an: ale.landra91 cpaixao provolinoo + Dank an: ale.landra91, cpaixao, provolinoo Mobilfunk HSPA HSDPA/HSUPA aktivieren + GRAFIK + GPU Taktfrequenz + diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/ColorHackPresets.java b/GNexusParts/src/com/cyanogenmod/settings/device/ColorHackPresets.java index 94a638d..8a260c5 100644 --- a/GNexusParts/src/com/cyanogenmod/settings/device/ColorHackPresets.java +++ b/GNexusParts/src/com/cyanogenmod/settings/device/ColorHackPresets.java @@ -24,13 +24,14 @@ import android.preference.PreferenceManager; import android.util.AttributeSet; import android.view.View; import android.view.View.OnClickListener; -import android.widget.TextView; import android.widget.Button; import android.util.Log; + + /** - * Special preference type that allows configuration of both the ring volume and - * notification volume. + * Special preference type that allows to set a pre-configuration of Color and Gamma + * Value on Nexus Devices. */ public class ColorHackPresets extends DialogPreference implements OnClickListener { @@ -49,13 +50,9 @@ public class ColorHackPresets extends DialogPreference implements OnClickListene "/sys/class/misc/samoled_color/blue_multiplier" }; - // Track instances to know when to restore original color - // (when the orientation changes, a new dialog is created before the old one - // is destroyed) - private static int sInstances = 0; - // Align MAX_VALUE with Voodoo Control settings private static final int MAX_VALUE = 2000000000; + public ColorHackPresets(Context context, AttributeSet attrs) { super(context, attrs); @@ -66,9 +63,6 @@ public class ColorHackPresets extends DialogPreference implements OnClickListene @Override protected void onBindDialogView(View view) { super.onBindDialogView(view); - - sInstances++; - SetupButtonClickListeners(view); } @@ -90,26 +84,13 @@ public class ColorHackPresets extends DialogPreference implements OnClickListene protected void onDialogClosed(boolean positiveResult) { super.onDialogClosed(positiveResult); - sInstances--; - - } - - /** - * Restore screen color tuning from SharedPreferences. (Write to kernel.) - * - * @param context The context to read the SharedPreferences from - */ - public static void restore(Context context) { - if (!isSupported()) { - return; - } - } + /** - * Check whether the running kernel supports color tuning or not. + * Check whether the running kernel supports color/gamma tuning or not. * - * @return Whether color tuning is supported or not + * @return Whether color/gamma tuning is supported or not */ public static boolean isSupported() { boolean supported = true; @@ -123,7 +104,6 @@ public class ColorHackPresets extends DialogPreference implements OnClickListene supported = false; } } - return supported; } @@ -146,20 +126,39 @@ public class ColorHackPresets extends DialogPreference implements OnClickListene break; case R.id.btnPreset6: Preset6(); - break; + break; } } + private void WriteMultiplier(Double fValue , int iPos) { int iValue = (int) ((double) MAX_VALUE * fValue); + int iValue2; Utils.writeColor(FILE_PATH_MULTI[iPos], iValue); - Log.i(TAG,"KalimAz: Multiplier: " + iPos+ " Value " + iValue ); + + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + iValue2 = sharedPrefs.getInt(FILE_PATH_MULTI[iPos], iValue); + //storing to SharedPreferences because of reloaded @ startup + Editor editor = getEditor(); + editor.putInt(FILE_PATH_MULTI[iPos], iValue); + editor.commit(); + Log.d(TAG, "Changing ColorMultiplier " +iPos+ " from:" +iValue2+ " to: " +iValue); } + private void WriteGamma(int iValue , int iPos) { + int iValue2; Utils.writeValue(FILE_PATH_GAMMA[iPos], String.valueOf((long) iValue)); - Log.i(TAG,"KalimAz: Gamma: " + iPos+ " Value " + iValue ); + + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + iValue2 = sharedPrefs.getInt(FILE_PATH_GAMMA[iPos], iValue); + //storing to SharedPreferences because of reloaded @ startup + Editor editor = getEditor(); + editor.putInt(FILE_PATH_GAMMA[iPos], iValue); + editor.commit(); + Log.d(TAG, "Changing GammaValue " +iPos+ " from:" +iValue2+ " to: " +iValue); } + private void Preset1() { WriteMultiplier(0.5, 0); diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java b/GNexusParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java index 25cbeb7..a24ea00 100644 --- a/GNexusParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java +++ b/GNexusParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java @@ -30,8 +30,8 @@ import android.util.Log; import android.widget.Button; /** - * Special preference type that allows configuration of both the ring volume and - * notification volume. + * Special preference type that allows configuration of Color settings on Nexus + * Devices */ public class ColorTuningPreference extends DialogPreference implements OnClickListener { @@ -67,7 +67,7 @@ public class ColorTuningPreference extends DialogPreference implements OnClickLi public ColorTuningPreference(Context context, AttributeSet attrs) { super(context, attrs); - + setDialogLayoutResource(R.layout.preference_dialog_color_tuning); } @@ -112,7 +112,7 @@ public class ColorTuningPreference extends DialogPreference implements OnClickLi } /** - * Restore screen color tuning from SharedPreferences. (Write to kernel.) + * Restore color tuning from SharedPreferences. (Write to kernel.) * * @param context The context to read the SharedPreferences from */ @@ -120,26 +120,28 @@ public class ColorTuningPreference extends DialogPreference implements OnClickLi if (!isSupported()) { return; } - - int iValue, iValue2; + + int iValue; SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); + Boolean bFirstTime = sharedPrefs.getBoolean("FirstTimeColor", true); for (String filePath : FILE_PATH) { String sDefaultValue = Utils.readOneLine(filePath); - Log.d(TAG,"INIT: " + sDefaultValue); - try { - iValue2 = Integer.parseInt(sDefaultValue); - } catch (NumberFormatException e) { - iValue2 = MAX_VALUE; + iValue = sharedPrefs.getInt(filePath, Integer.valueOf(sDefaultValue)); + if (bFirstTime){ + Utils.writeColor(filePath, MAX_VALUE); + Log.d(TAG, "restore default value: " +MAX_VALUE+ " File: " + filePath); } - try { - iValue = sharedPrefs.getInt(filePath, iValue2); + else{ + Utils.writeColor(filePath, iValue); Log.d(TAG, "restore: iValue: " + iValue + " File: " + filePath); - } catch (NumberFormatException e) { - iValue = iValue2; - Log.e(TAG, "restore ERROR: iValue: " + iValue + " File: " + filePath); } - Utils.writeColor(filePath, (int) iValue); + } + if (bFirstTime) + { + SharedPreferences.Editor editor = sharedPrefs.edit(); + editor.putBoolean("FirstTimeColor", false); + editor.commit(); } } diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/DevicePreferenceActivity.java b/GNexusParts/src/com/cyanogenmod/settings/device/DevicePreferenceActivity.java index 957883b..ca09344 100644 --- a/GNexusParts/src/com/cyanogenmod/settings/device/DevicePreferenceActivity.java +++ b/GNexusParts/src/com/cyanogenmod/settings/device/DevicePreferenceActivity.java @@ -16,32 +16,11 @@ package com.cyanogenmod.settings.device; -import android.app.ActionBar; -import android.app.ActionBar.Tab; -import android.app.ActionBar.TabListener; -import android.app.Activity; -import android.app.Fragment; -import android.app.FragmentManager; -import android.app.FragmentTransaction; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; import android.os.Bundle; -import android.os.IBinder; import android.preference.ListPreference; -import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; -import android.preference.PreferenceScreen; -import android.support.v13.app.FragmentPagerAdapter; -import android.support.v4.app.FragmentActivity; -import android.support.v4.view.ViewPager; -import android.view.MenuItem; - import com.cyanogenmod.settings.device.R; -import java.util.ArrayList; - public class DevicePreferenceActivity extends PreferenceFragment { public static final String SHARED_PREFERENCES_BASENAME = "com.cyanogenmod.settings.device"; @@ -78,8 +57,6 @@ public class DevicePreferenceActivity extends PreferenceFragment { mVibratorTuning = (VibratorTuningPreference) findPreference(KEY_VIBRATOR_TUNING); mVibratorTuning.setEnabled(VibratorTuningPreference.isSupported()); - PreferenceScreen prefSet = getPreferenceScreen(); - mGpuOverclock = (ListPreference) findPreference(KEY_GPU_OVERCLOCK); mGpuOverclock.setEnabled(GpuOverclock.isSupported()); mGpuOverclock.setOnPreferenceChangeListener(new GpuOverclock()); diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java b/GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java index 3c5aef0..b54bc58 100644 --- a/GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java +++ b/GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java @@ -30,8 +30,8 @@ import android.widget.Button; import android.util.Log; /** - * Special preference type that allows configuration of both the ring volume and - * notification volume. + * Special preference type that allows configuration of Gamma settings on Nexus + * Devices */ public class GammaTuningPreference extends DialogPreference implements OnClickListener { @@ -117,7 +117,7 @@ public class GammaTuningPreference extends DialogPreference implements OnClickLi } /** - * Restore screen color tuning from SharedPreferences. (Write to kernel.) + * Restore screen gamma tuning from SharedPreferences. (Write to kernel.) * * @param context The context to read the SharedPreferences from */ @@ -133,10 +133,14 @@ public class GammaTuningPreference extends DialogPreference implements OnClickLi for (String filePath : FILE_PATH) { String sDefaultValue = Utils.readOneLine(filePath); iValue = sharedPrefs.getInt(filePath, Integer.valueOf(sDefaultValue)); - if (bFirstTime) + if (bFirstTime){ Utils.writeValue(filePath, "0"); - else + Log.d(TAG, "restore default value: 0 File: " + filePath); + } + else{ Utils.writeValue(filePath, String.valueOf((long) iValue)); + Log.d(TAG, "restore: iValue: " + iValue + " File: " + filePath); + } } if (bFirstTime) { @@ -185,8 +189,6 @@ public class GammaTuningPreference extends DialogPreference implements OnClickLi iOffset = offsetValue; iMax = maxValue; - SharedPreferences sharedPreferences = getSharedPreferences(); - // Read original value if (Utils.fileExists(mFilePath)) { String sDefaultValue = Utils.readOneLine(mFilePath); diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java b/GNexusParts/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java index f8aec17..fce408f 100644 --- a/GNexusParts/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java +++ b/GNexusParts/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java @@ -31,12 +31,12 @@ import android.util.Log; import android.os.Vibrator; /** - * Special preference type that allows configuration of both the ring volume and - * notification volume. + * Special preference type that allows configuration of vibrator intensity settings on Nexus + * Devices */ public class VibratorTuningPreference extends DialogPreference implements OnClickListener { - private static final String TAG = "vibrator..."; + private static final String TAG = "VIBRATOR..."; private static final int[] SEEKBAR_ID = new int[] { R.id.vibrator_seekbar @@ -110,7 +110,7 @@ public class VibratorTuningPreference extends DialogPreference implements OnClic } /** - * Restore screen color tuning from SharedPreferences. (Write to kernel.) + * Restore vibrator tuning from SharedPreferences. (Write to kernel.) * * @param context The context to read the SharedPreferences from */ @@ -125,13 +125,16 @@ public class VibratorTuningPreference extends DialogPreference implements OnClic for (String filePath : FILE_PATH) { String sDefaultValue = Utils.readOneLine(filePath); int iValue = sharedPrefs.getInt(filePath, Integer.valueOf(sDefaultValue)); - if (bFirstTime) + if (bFirstTime){ Utils.writeValue(filePath, "100"); - else + Log.d(TAG, "restore default value: 100 File: " + filePath); + } + else{ Utils.writeValue(filePath, String.valueOf((long) iValue)); + Log.d(TAG, "restore: iValue: " + iValue + " File: " + filePath); + } } - if (bFirstTime) - { + if (bFirstTime) { SharedPreferences.Editor editor = sharedPrefs.edit(); editor.putBoolean("FirstTimevibrator", false); editor.commit(); @@ -139,7 +142,7 @@ public class VibratorTuningPreference extends DialogPreference implements OnClic } /** - * Check whether the running kernel supports color tuning or not. + * Check whether the running kernel supports vibrator tuning or not. * * @return Whether color tuning is supported or not */ @@ -177,8 +180,6 @@ public class VibratorTuningPreference extends DialogPreference implements OnClic iOffset = offsetValue; iMax = maxValue; - SharedPreferences sharedPreferences = getSharedPreferences(); - // Read original value if (Utils.fileExists(mFilePath)) { String sDefaultValue = Utils.readOneLine(mFilePath); -- cgit v1.1