summaryrefslogtreecommitdiffstats
path: root/GNexusParts/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'GNexusParts/src/com')
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/ColorHackPresets.java61
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java36
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/DevicePreferenceActivity.java23
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java16
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java23
5 files changed, 70 insertions, 89 deletions
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);