summaryrefslogtreecommitdiffstats
path: root/DeviceSettings/src/com/cyanogenmod/settings
diff options
context:
space:
mode:
authorAndrew Dodd <atd7@cornell.edu>2012-06-17 12:16:05 -0400
committerAndrew Dodd <atd7@cornell.edu>2012-06-17 12:16:05 -0400
commitf5a640bbed057a3b4af7f2720a8a99cc4d8f158d (patch)
tree551418934fce87a5d1e73336bdf8fd8c8102256b /DeviceSettings/src/com/cyanogenmod/settings
parent02d3dd24907604e7f61f1baa15d3662c42b437fa (diff)
downloaddevice_samsung_n7000-f5a640bbed057a3b4af7f2720a8a99cc4d8f158d.zip
device_samsung_n7000-f5a640bbed057a3b4af7f2720a8a99cc4d8f158d.tar.gz
device_samsung_n7000-f5a640bbed057a3b4af7f2720a8a99cc4d8f158d.tar.bz2
DeviceSettings: Control vibrator strength
Change-Id: I504f483cf8ef30274ceb2742d87be380aadacf6b
Diffstat (limited to 'DeviceSettings/src/com/cyanogenmod/settings')
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java3
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java66
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java2
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java59
4 files changed, 130 insertions, 0 deletions
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
index 4bd1810..58003a2 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
@@ -45,6 +45,7 @@ public class DeviceSettings extends FragmentActivity {
public static final String KEY_CALIBRATE_GYRO = "calibrate_gyro";
public static final String KEY_TOUCHSCREEN_SENSITIVITY = "touchscreen_sensitivity";
public static final String KEY_TOUCHKEY_LIGHT = "touchkey_light";
+ public static final String KEY_VIBRATOR_INTENSITY = "vibrator_intensity";
ViewPager mViewPager;
TabsAdapter mTabsAdapter;
@@ -69,6 +70,8 @@ public class DeviceSettings extends FragmentActivity {
mDNIeFragmentActivity.class, null);
mTabsAdapter.addTab(bar.newTab().setText(R.string.category_sensors_title),
SensorsFragmentActivity.class, null);
+ mTabsAdapter.addTab(bar.newTab().setText(R.string.category_haptic_title),
+ HapticFragmentActivity.class, null);
if (savedInstanceState != null) {
bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
new file mode 100644
index 0000000..d67c234
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
+import android.util.Log;
+
+import com.cyanogenmod.settings.device.R;
+
+public class HapticFragmentActivity extends PreferenceFragment {
+
+ private static final String PREF_ENABLED = "1";
+ private static final String TAG = "GalaxyNoteParts_General";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.haptic_preferences);
+
+ PreferenceScreen prefSet = getPreferenceScreen();
+
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+
+ String boxValue;
+ String key = preference.getKey();
+
+ Log.w(TAG, "key: " + key);
+
+ return true;
+ }
+
+ public static boolean isSupported(String FILE) {
+ return Utils.fileExists(FILE);
+ }
+
+ public static void restore(Context context) {
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ }
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
index 6951f26..7566273 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
@@ -29,6 +29,8 @@ public class Startup extends BroadcastReceiver {
mDNIeNegative.restore(context);
mDNIeOutdoor.restore(context);
RadioFragmentActivity.restore(context);
+ HapticFragmentActivity.restore(context);
+ VibratorIntensity.restore(context);
}
}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java
new file mode 100644
index 0000000..7a809a5
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import java.io.IOException;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.content.SharedPreferences;
+import android.preference.Preference;
+import android.preference.ListPreference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class VibratorIntensity extends ListPreference implements OnPreferenceChangeListener {
+
+ public VibratorIntensity(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setOnPreferenceChangeListener(this);
+ }
+
+ private static final String FILE = "/sys/vibrator/pwm_val";
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE);
+ }
+
+ /**
+ * Restore vibrator intensity setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_VIBRATOR_INTENSITY, "50"));
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE, (String) newValue);
+ return true;
+ }
+
+}