summaryrefslogtreecommitdiffstats
path: root/DeviceSettings/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'DeviceSettings/src/com')
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/AudioFragmentActivity.java103
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/AudioOut.java269
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java60
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java170
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java78
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java67
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/IncallAudio.java347
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java59
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java74
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/SPenPowerSavingMode.java61
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java133
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java43
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java59
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java163
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java223
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java61
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java61
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java61
18 files changed, 0 insertions, 2092 deletions
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/AudioFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/AudioFragmentActivity.java
deleted file mode 100644
index f02f53a..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/AudioFragmentActivity.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-* 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.app.ActivityManagerNative;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.os.UserHandle;
-import android.preference.CheckBoxPreference;
-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 AudioFragmentActivity extends PreferenceFragment {
-
- private static final String PREF_ENABLED = "1";
- private static final String TAG = "DeviceSettings_Audio";
- public static final String KEY_INCALL_TUNING = "incall_tuning";
- public static final String KEY_AUDIOOUT_TUNING = "audioout_tuning";
-
- private static boolean sIncallTuning;
- private static boolean sAudioOutTuning;
- private static boolean mEnableIncall = false;
- private static boolean mEnableAudioOut = false;
- private IncallAudio mIncallTuning;
- private AudioOut mAudioOutTuning;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- addPreferencesFromResource(R.xml.audio_preferences);
- PreferenceScreen prefSet = getPreferenceScreen();
-
- Resources res = getResources();
- sIncallTuning = res.getBoolean(R.bool.has_incall_audio_tuning);
- sAudioOutTuning = res.getBoolean(R.bool.has_output_audio_tuning);
-
- mIncallTuning = (IncallAudio) findPreference(KEY_INCALL_TUNING);
- mAudioOutTuning = (AudioOut) findPreference(KEY_AUDIOOUT_TUNING);
-
- if(sIncallTuning){
- if(mIncallTuning.isSupported("earpiece") || mIncallTuning.isSupported("headphone") ||
- mIncallTuning.isSupported("speaker") || mIncallTuning.isSupported("bt"))
- mEnableIncall = true;
- }
-
- if(sAudioOutTuning){
- if(mAudioOutTuning.isSupported("headphone") || mAudioOutTuning.isSupported("speaker"))
- mEnableAudioOut = true;
- }
-
- mIncallTuning.setEnabled(mEnableIncall);
- mAudioOutTuning.setEnabled(mEnableAudioOut);
- }
-
- @Override
- public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
-
- String boxValue;
- String key = preference.getKey();
-
- Log.w(TAG, "key: " + key);
-
- if (key.compareTo(DeviceSettings.KEY_USE_DOCK_AUDIO) == 0) {
- boxValue = (((CheckBoxPreference)preference).isChecked() ? "1" : "0");
- Intent i = new Intent("com.cyanogenmod.settings.SamsungDock");
- i.putExtra("data", boxValue);
- ActivityManagerNative.broadcastStickyIntent(i, null, UserHandle.USER_ALL);
- }
- return true;
- }
-
- public static void restore(Context context) {
- SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- boolean dockAudio = sharedPrefs.getBoolean(DeviceSettings.KEY_USE_DOCK_AUDIO, false);
- Intent i = new Intent("com.cyanogenmod.settings.SamsungDock");
- i.putExtra("data", (dockAudio? "1" : "0"));
- ActivityManagerNative.broadcastStickyIntent(i, null, UserHandle.USER_ALL);
- }
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/AudioOut.java b/DeviceSettings/src/com/cyanogenmod/settings/device/AudioOut.java
deleted file mode 100644
index 179a7dd..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/AudioOut.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright (C) 2013 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.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
-import android.graphics.Color;
-import android.graphics.LightingColorFilter;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
-import android.os.Bundle;
-import android.os.Vibrator;
-import android.preference.DialogPreference;
-import android.preference.PreferenceManager;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.View;
-import android.widget.SeekBar;
-import android.widget.TextView;
-import android.widget.Button;
-
-import java.lang.Math;
-import java.text.DecimalFormat;
-
-/**
- * Special preference type that allows configuration of audio out volume on some smdk4412
- * Devices
- */
-public class AudioOut extends DialogPreference implements SeekBar.OnSeekBarChangeListener {
- private static final String TAG = "DeviceSettings_AudioOut";
-
- private static String AUDIOOUT_HEADPHONE_FILE = "/data/local/audio/out_headphone";
- private static String AUDIOOUT_SPEAKER_FILE = "/data/local/audio/out_speaker";
- private static int MAX_VALUE;
- private static int WARNING_THRESHOLD;
- private static int DEFAULT_VALUE;
- private static int MIN_VALUE;
-
- private SeekBar mHeadphoneSeekBar;
- private SeekBar mSpeakerSeekBar;
- private TextView mHeadphoneValue;
- private TextView mSpeakerValue;
- private TextView mWarning;
-
- private String mHeadphoneOgValue;
- private String mSpeakerOgValue;
- private int mHeadphoneOgPercent;
- private int mSpeakerOgPercent;
-
- private Drawable mHeadphoneProgressDrawable;
- private Drawable mSpeakerProgressDrawable;
- private Drawable mHeadphoneProgressThumb;
- private Drawable mSpeakerProgressThumb;
- private LightingColorFilter mRedFilter;
-
- private enum Device {
- headphone,
- speaker
- }
-
- public AudioOut(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- MAX_VALUE = Integer.valueOf(context.getResources().getString(R.string.audioout_max_value));
- WARNING_THRESHOLD = Integer.valueOf(context.getResources().getString(R.string.audioout_warning_threshold));
- DEFAULT_VALUE = Integer.valueOf(context.getResources().getString(R.string.audioout_default_value));
- MIN_VALUE = Integer.valueOf(context.getResources().getString(R.string.audioout_min_value));
-
- setDialogLayoutResource(R.layout.preference_dialog_output_audio_tuning);
- }
-
- @Override
- protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
- builder.setNeutralButton(R.string.defaults_button, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- }
-
- @Override
- protected void onBindDialogView(View view) {
- super.onBindDialogView(view);
-
- mHeadphoneSeekBar = (SeekBar) view.findViewById(R.id.audioout_headphone_seekbar);
- mHeadphoneValue = (TextView) view.findViewById(R.id.audioout_headphone_value);
- mSpeakerSeekBar = (SeekBar) view.findViewById(R.id.audioout_speaker_seekbar);
- mSpeakerValue = (TextView) view.findViewById(R.id.audioout_speaker_value);
- mWarning = (TextView) view.findViewById(R.id.audioout_textWarn);
-
- String strWarnMsg = getContext().getResources().getString(R.string.audioout_warning, volumeToPercent(WARNING_THRESHOLD));
- mWarning.setText(strWarnMsg);
-
- Drawable progressDrawableHeadphone = mHeadphoneSeekBar.getProgressDrawable();
- if (progressDrawableHeadphone instanceof LayerDrawable) {
- LayerDrawable ldHeadphone = (LayerDrawable) progressDrawableHeadphone;
- mHeadphoneProgressDrawable = ldHeadphone.findDrawableByLayerId(android.R.id.progress);
- }
- Drawable progressDrawableSpeaker = mSpeakerSeekBar.getProgressDrawable();
- if (progressDrawableSpeaker instanceof LayerDrawable) {
- LayerDrawable ldSpeaker = (LayerDrawable) progressDrawableSpeaker;
- mSpeakerProgressDrawable = ldSpeaker.findDrawableByLayerId(android.R.id.progress);
- }
-
- mHeadphoneProgressThumb = mHeadphoneSeekBar.getThumb();
- mSpeakerProgressThumb = mSpeakerSeekBar.getThumb();
-
- mRedFilter = new LightingColorFilter(Color.BLACK,
- getContext().getResources().getColor(android.R.color.holo_red_light));
-
- mHeadphoneOgValue = Utils.readOneLine(AUDIOOUT_HEADPHONE_FILE);
- mHeadphoneOgPercent = volumeToPercent(Integer.parseInt(mHeadphoneOgValue));
-
- mHeadphoneSeekBar.setOnSeekBarChangeListener(this);
- mHeadphoneSeekBar.setProgress(Integer.valueOf(mHeadphoneOgPercent));
-
- mSpeakerOgValue = Utils.readOneLine(AUDIOOUT_SPEAKER_FILE);
- mSpeakerOgPercent = volumeToPercent(Integer.parseInt(mSpeakerOgValue));
-
- mSpeakerSeekBar.setOnSeekBarChangeListener(this);
- mSpeakerSeekBar.setProgress(Integer.valueOf(mSpeakerOgPercent));
- }
-
- @Override
- protected void showDialog(Bundle state) {
- super.showDialog(state);
-
- // can't use onPrepareDialogBuilder for this as we want the dialog
- // to be kept open on click
- AlertDialog d = (AlertDialog) getDialog();
- Button defaultsButton = d.getButton(DialogInterface.BUTTON_NEUTRAL);
- defaultsButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mHeadphoneSeekBar.setProgress(volumeToPercent(DEFAULT_VALUE));
- mSpeakerSeekBar.setProgress(volumeToPercent(DEFAULT_VALUE));
- }
- });
- }
-
- @Override
- protected void onDialogClosed(boolean positiveResult) {
- super.onDialogClosed(positiveResult);
- int volumeHeadphone, volumeSpeaker;
-
- if (positiveResult) {
- Editor editor = getEditor();
-
- volumeHeadphone = percentToVolume(mHeadphoneSeekBar.getProgress());
- editor.putString(AUDIOOUT_HEADPHONE_FILE, String.valueOf(volumeHeadphone));
- volumeSpeaker = percentToVolume(mSpeakerSeekBar.getProgress());
- editor.putString(AUDIOOUT_SPEAKER_FILE, String.valueOf(volumeSpeaker));
- editor.commit();
- } else {
- Utils.writeValue(AUDIOOUT_HEADPHONE_FILE, String.valueOf(mHeadphoneOgValue));
- Utils.writeValue(AUDIOOUT_SPEAKER_FILE, String.valueOf(mSpeakerOgValue));
- }
- }
-
- public static void restore(Context context) {
- SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
-
- if (isSupported("headphone"))
- Utils.writeValue(AUDIOOUT_HEADPHONE_FILE, sharedPrefs.getString(AUDIOOUT_HEADPHONE_FILE, "50"));
- if (isSupported("speaker"))
- Utils.writeValue(AUDIOOUT_SPEAKER_FILE, sharedPrefs.getString(AUDIOOUT_SPEAKER_FILE, "50"));
- }
-
- public static boolean isSupported(String output) {
- String FILE = null;
- Device outputDevice = Device.valueOf(output);
-
- switch(outputDevice) {
- case headphone:
- FILE = AUDIOOUT_HEADPHONE_FILE;
- case speaker:
- FILE = AUDIOOUT_SPEAKER_FILE;
- }
- return Utils.fileExists(FILE);
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- boolean shouldWarn = progress >= volumeToPercent(WARNING_THRESHOLD);
- int stepSize = 1;
- progress = Math.round(progress/stepSize)*stepSize;
-
- if(seekBar == mHeadphoneSeekBar){
- if (mHeadphoneProgressDrawable != null) {
- mHeadphoneProgressDrawable.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- if (mHeadphoneProgressThumb != null) {
- mHeadphoneProgressThumb.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- mHeadphoneSeekBar.setProgress(progress);
- Utils.writeValue(AUDIOOUT_HEADPHONE_FILE, String.valueOf(percentToVolume(progress)));
- mHeadphoneValue.setText(String.format("%d%%", progress));
- }else if(seekBar == mSpeakerSeekBar){
- if (mSpeakerProgressDrawable != null) {
- mSpeakerProgressDrawable.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- if (mSpeakerProgressThumb != null) {
- mSpeakerProgressThumb.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- mSpeakerSeekBar.setProgress(progress);
- Utils.writeValue(AUDIOOUT_SPEAKER_FILE, String.valueOf(percentToVolume(progress)));
- mSpeakerValue.setText(String.format("%d%%", progress));
- }
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // Do nothing
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- //Vibrator vib = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
- //vib.vibrate(200);
- }
-
- /**
- * Convert volume to percent
- */
- public static int volumeToPercent(int volume) {
- double maxValue = MAX_VALUE;
- double minValue = MIN_VALUE;
-
- double percent = Math.round((volume - minValue) * (100 / (maxValue - minValue)));
-
- if (percent > 100)
- percent = 100;
- else if (percent < 0)
- percent = 0;
-
- return (int) percent;
- }
-
- /**
- * Convert percent to volume
- */
- public static int percentToVolume(int percent) {
- int volume = Math.round((((MAX_VALUE - MIN_VALUE) * percent) / 100) + MIN_VALUE);
-
- if (volume > MAX_VALUE)
- volume = MAX_VALUE;
- else if (volume < MIN_VALUE)
- volume = MIN_VALUE;
-
- return volume;
- }
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java b/DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java
deleted file mode 100644
index 9e0ab7c..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2013 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.preference.CheckBoxPreference;
-import android.preference.Preference;
-import android.preference.Preference.OnPreferenceChangeListener;
-import android.preference.PreferenceManager;
-import android.util.AttributeSet;
-
-public class CABC extends CheckBoxPreference implements OnPreferenceChangeListener {
-
- private static String FILE = null;
-
- public CABC(Context context, AttributeSet attrs) {
- super(context, attrs);
- this.setOnPreferenceChangeListener(this);
- FILE = context.getResources().getString(R.string.mdnie_cabc_sysfs_file);
- }
-
- public static boolean isSupported(String filePath) {
- return Utils.fileExists(filePath);
- }
-
- /**
- * Restore cabc setting from SharedPreferences. (Write to kernel.)
- * @param context The context to read the SharedPreferences from
- */
- public static void restore(Context context) {
- FILE = context.getResources().getString(R.string.mdnie_cabc_sysfs_file);
- if (!isSupported(FILE)) {
- return;
- }
-
- SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- Utils.writeValue(FILE, sharedPrefs.getBoolean(DeviceSettings.KEY_CABC, true) ? "1" : "0");
- }
-
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- Utils.writeValue(FILE, (Boolean)newValue ? "1" : "0");
- return true;
- }
-
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
deleted file mode 100644
index 7c1072f..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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.app.ActionBar;
-import android.app.ActionBar.Tab;
-import android.app.Activity;
-import android.app.Fragment;
-import android.app.FragmentTransaction;
-import android.content.Context;
-import android.os.Bundle;
-import android.support.v4.app.FragmentActivity;
-import android.support.v13.app.FragmentPagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.view.MenuItem;
-
-import com.cyanogenmod.settings.device.R;
-
-import java.util.ArrayList;
-
-public class DeviceSettings extends FragmentActivity {
-
- public static final String SHARED_PREFERENCES_BASENAME = "com.cyanogenmod.settings.device";
- public static final String ACTION_UPDATE_PREFERENCES = "com.cyanogenmod.settings.device.UPDATE";
- public static final String KEY_CABC = "cabc";
- public static final String KEY_MDNIE_SCENARIO = "mdnie_scenario";
- public static final String KEY_MDNIE_MODE = "mdnie_mode";
- public static final String KEY_MDNIE_NEGATIVE = "mdnie_negative";
- public static final String KEY_LED_FADE = "led_fade";
- public static final String KEY_TOUCHKEY_LIGHT = "touchkey_light";
- public static final String KEY_TOUCHKEY_TIMEOUT = "touchkey_timeout";
- public static final String KEY_HSPA = "hspa";
- public static final String KEY_USE_DOCK_AUDIO = "dock_audio";
- public static final String KEY_CATEGORY_SPEN = "category_spen";
- public static final String KEY_SPEN_POWER_SAVING_MODE = "spen_power_saving";
-
- ViewPager mViewPager;
- TabsAdapter mTabsAdapter;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- mViewPager = new ViewPager(this);
- mViewPager.setId(R.id.viewPager);
- setContentView(mViewPager);
-
- final ActionBar bar = getActionBar();
- bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
- bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
- bar.setTitle(R.string.app_name);
- bar.setDisplayHomeAsUpEnabled(true);
-
- mTabsAdapter = new TabsAdapter(this, mViewPager);
- mTabsAdapter.addTab(bar.newTab().setText(R.string.category_radio_title),
- RadioFragmentActivity.class, null);
- mTabsAdapter.addTab(bar.newTab().setText(R.string.category_screen_title),
- ScreenFragmentActivity.class, null);
- mTabsAdapter.addTab(bar.newTab().setText(R.string.category_haptic_title),
- HapticFragmentActivity.class, null);
- mTabsAdapter.addTab(bar.newTab().setText(R.string.category_audio_title),
- AudioFragmentActivity.class, null);
-
- if (savedInstanceState != null) {
- bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
- }
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putInt("tab", getActionBar().getSelectedNavigationIndex());
- }
-
- public static class TabsAdapter extends FragmentPagerAdapter
- implements ActionBar.TabListener, ViewPager.OnPageChangeListener {
- private final Context mContext;
- private final ActionBar mActionBar;
- private final ViewPager mViewPager;
- private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
-
- static final class TabInfo {
- private final Class<?> clss;
- private final Bundle args;
-
- TabInfo(Class<?> _class, Bundle _args) {
- clss = _class;
- args = _args;
- }
- }
-
- public TabsAdapter(Activity activity, ViewPager pager) {
- super(activity.getFragmentManager());
- mContext = activity;
- mActionBar = activity.getActionBar();
- mViewPager = pager;
- mViewPager.setAdapter(this);
- mViewPager.setOnPageChangeListener(this);
- }
-
- public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
- TabInfo info = new TabInfo(clss, args);
- tab.setTag(info);
- tab.setTabListener(this);
- mTabs.add(info);
- mActionBar.addTab(tab);
- notifyDataSetChanged();
- }
-
- @Override
- public int getCount() {
- return mTabs.size();
- }
-
- @Override
- public Fragment getItem(int position) {
- TabInfo info = mTabs.get(position);
- return Fragment.instantiate(mContext, info.clss.getName(), info.args);
- }
-
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- }
-
- public void onPageSelected(int position) {
- mActionBar.setSelectedNavigationItem(position);
- }
-
- public void onPageScrollStateChanged(int state) {
- }
-
- public void onTabSelected(Tab tab, FragmentTransaction ft) {
- Object tag = tab.getTag();
- for (int i=0; i<mTabs.size(); i++) {
- if (mTabs.get(i) == tag) {
- mViewPager.setCurrentItem(i);
- }
- }
- }
-
- public void onTabUnselected(Tab tab, FragmentTransaction ft) {
- }
-
- public void onTabReselected(Tab tab, FragmentTransaction ft) {
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- DeviceSettings.this.onBackPressed();
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
deleted file mode 100644
index 039817e..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.res.Resources;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-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 TAG = "DeviceSettings_Haptic";
- public static final String KEY_VIBRATOR_TUNING = "vibrator_tuning";
-
- private static boolean sVibratorTuning;
- private static boolean mEnableVibratorTuning = false;
- private VibratorTuningPreference mVibratorTuning;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Resources res = getResources();
- sVibratorTuning = res.getBoolean(R.bool.has_vibrator_tuning);
-
- addPreferencesFromResource(R.xml.haptic_preferences);
-
- mVibratorTuning = (VibratorTuningPreference) findPreference(KEY_VIBRATOR_TUNING);
-
- if (sVibratorTuning) {
- String vibratorFilePath = res.getString(R.string.vibrator_sysfs_file);
- if(VibratorTuningPreference.isSupported(vibratorFilePath)){
- mEnableVibratorTuning = true;
- }
- }
-
- mVibratorTuning.setEnabled(mEnableVibratorTuning);
- }
-
- @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/Hspa.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java
deleted file mode 100644
index f19eff7..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.Intent;
-import android.content.SharedPreferences;
-import android.util.AttributeSet;
-import android.preference.ListPreference;
-import android.preference.Preference;
-import android.preference.Preference.OnPreferenceChangeListener;
-import android.preference.PreferenceManager;
-
-public class Hspa extends ListPreference implements OnPreferenceChangeListener {
-
- private static final String FILE = "/system/app/SamsungServiceMode.apk";
- private Context mCtx;
-
- public Hspa(Context context, AttributeSet attrs) {
- super(context, attrs);
- this.setOnPreferenceChangeListener(this);
- mCtx = context;
- }
-
- public static boolean isSupported() {
- return Utils.fileExists(FILE);
- }
-
- /**
- * Restore hspa 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);
- sendIntent(context, sharedPrefs.getString(DeviceSettings.KEY_HSPA, "23"));
- }
-
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- sendIntent(mCtx, (String) newValue);
- return true;
- }
-
- private static void sendIntent(Context context, String value) {
- Intent i = new Intent("com.cyanogenmod.SamsungServiceMode.EXECUTE");
- i.putExtra("sub_type", 20); // HSPA Setting
- i.putExtra("data", value);
- context.sendBroadcast(i);
- }
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/IncallAudio.java b/DeviceSettings/src/com/cyanogenmod/settings/device/IncallAudio.java
deleted file mode 100644
index 8f973cb..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/IncallAudio.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Copyright (C) 2013 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.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
-import android.graphics.Color;
-import android.graphics.LightingColorFilter;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
-import android.os.Bundle;
-import android.os.Vibrator;
-import android.preference.DialogPreference;
-import android.preference.PreferenceManager;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.View;
-import android.widget.SeekBar;
-import android.widget.TextView;
-import android.widget.Button;
-
-import java.lang.Math;
-import java.text.DecimalFormat;
-
-/**
- * Special preference type that allows configuration of incall volume on some smdk4412
- * Devices
- */
-public class IncallAudio extends DialogPreference implements SeekBar.OnSeekBarChangeListener {
- private static final String TAG = "DeviceSettings_IncallAudio";
-
- private static String INCALL_EARPIECE_FILE = "/data/local/audio/incall_earpiece";
- private static String INCALL_HEADPHONE_FILE = "/data/local/audio/incall_headphone";
- private static String INCALL_SPEAKER_FILE = "/data/local/audio/incall_speaker";
- private static String INCALL_BT_FILE = "/data/local/audio/incall_bt";
- private static int MAX_VALUE;
- private static int WARNING_THRESHOLD;
- private static int DEFAULT_VALUE;
- private static int MIN_VALUE;
-
- private SeekBar mEarpieceSeekBar;
- private SeekBar mHeadphoneSeekBar;
- private SeekBar mSpeakerSeekBar;
- private SeekBar mBtSeekBar;
- private TextView mEarpieceValue;
- private TextView mHeadphoneValue;
- private TextView mSpeakerValue;
- private TextView mBtValue;
- private TextView mWarning;
-
- private String mEarpieceOgValue;
- private String mHeadphoneOgValue;
- private String mSpeakerOgValue;
- private String mBtOgValue;
- private int mEarpieceOgPercent;
- private int mHeadphoneOgPercent;
- private int mSpeakerOgPercent;
- private int mBtOgPercent;
-
- private Drawable mEarpieceProgressDrawable;
- private Drawable mHeadphoneProgressDrawable;
- private Drawable mSpeakerProgressDrawable;
- private Drawable mBtProgressDrawable;
- private Drawable mEarpieceProgressThumb;
- private Drawable mHeadphoneProgressThumb;
- private Drawable mSpeakerProgressThumb;
- private Drawable mBtProgressThumb;
- private LightingColorFilter mRedFilter;
-
- private enum Device {
- earpiece,
- headphone,
- speaker,
- bt
- }
-
- public IncallAudio(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- MAX_VALUE = Integer.valueOf(context.getResources().getString(R.string.incall_max_value));
- WARNING_THRESHOLD = Integer.valueOf(context.getResources().getString(R.string.incall_warning_threshold));
- DEFAULT_VALUE = Integer.valueOf(context.getResources().getString(R.string.incall_default_value));
- MIN_VALUE = Integer.valueOf(context.getResources().getString(R.string.incall_min_value));
-
- setDialogLayoutResource(R.layout.preference_dialog_incall_audio_tuning);
- }
-
- @Override
- protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
- builder.setNeutralButton(R.string.defaults_button, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- }
-
- @Override
- protected void onBindDialogView(View view) {
- super.onBindDialogView(view);
-
- mEarpieceSeekBar = (SeekBar) view.findViewById(R.id.earpiece_seekbar);
- mEarpieceValue = (TextView) view.findViewById(R.id.earpiece_value);
- mHeadphoneSeekBar = (SeekBar) view.findViewById(R.id.headphone_seekbar);
- mHeadphoneValue = (TextView) view.findViewById(R.id.headphone_value);
- mSpeakerSeekBar = (SeekBar) view.findViewById(R.id.speaker_seekbar);
- mSpeakerValue = (TextView) view.findViewById(R.id.speaker_value);
- mBtSeekBar = (SeekBar) view.findViewById(R.id.bt_seekbar);
- mBtValue = (TextView) view.findViewById(R.id.bt_value);
- mWarning = (TextView) view.findViewById(R.id.incall_textWarn);
-
- String strWarnMsg = getContext().getResources().getString(R.string.incall_warning, volumeToPercent(WARNING_THRESHOLD));
- mWarning.setText(strWarnMsg);
-
- Drawable progressDrawableEarpiece = mEarpieceSeekBar.getProgressDrawable();
- if (progressDrawableEarpiece instanceof LayerDrawable) {
- LayerDrawable ldEarpiece = (LayerDrawable) progressDrawableEarpiece;
- mEarpieceProgressDrawable = ldEarpiece.findDrawableByLayerId(android.R.id.progress);
- }
- Drawable progressDrawableHeadphone = mHeadphoneSeekBar.getProgressDrawable();
- if (progressDrawableHeadphone instanceof LayerDrawable) {
- LayerDrawable ldHeadphone = (LayerDrawable) progressDrawableHeadphone;
- mHeadphoneProgressDrawable = ldHeadphone.findDrawableByLayerId(android.R.id.progress);
- }
- Drawable progressDrawableSpeaker = mSpeakerSeekBar.getProgressDrawable();
- if (progressDrawableSpeaker instanceof LayerDrawable) {
- LayerDrawable ldSpeaker = (LayerDrawable) progressDrawableSpeaker;
- mSpeakerProgressDrawable = ldSpeaker.findDrawableByLayerId(android.R.id.progress);
- }
- Drawable progressDrawableBt = mBtSeekBar.getProgressDrawable();
- if (progressDrawableBt instanceof LayerDrawable) {
- LayerDrawable ldBt = (LayerDrawable) progressDrawableBt;
- mBtProgressDrawable = ldBt.findDrawableByLayerId(android.R.id.progress);
- }
- mEarpieceProgressThumb = mEarpieceSeekBar.getThumb();
- mHeadphoneProgressThumb = mHeadphoneSeekBar.getThumb();
- mSpeakerProgressThumb = mSpeakerSeekBar.getThumb();
- mBtProgressThumb = mBtSeekBar.getThumb();
- mRedFilter = new LightingColorFilter(Color.BLACK,
- getContext().getResources().getColor(android.R.color.holo_red_light));
-
- mEarpieceOgValue = Utils.readOneLine(INCALL_EARPIECE_FILE);
- mEarpieceOgPercent = volumeToPercent(Integer.parseInt(mEarpieceOgValue));
-
- mEarpieceSeekBar.setOnSeekBarChangeListener(this);
- mEarpieceSeekBar.setProgress(Integer.valueOf(mEarpieceOgPercent));
-
- mHeadphoneOgValue = Utils.readOneLine(INCALL_HEADPHONE_FILE);
- mHeadphoneOgPercent = volumeToPercent(Integer.parseInt(mHeadphoneOgValue));
-
- mHeadphoneSeekBar.setOnSeekBarChangeListener(this);
- mHeadphoneSeekBar.setProgress(Integer.valueOf(mHeadphoneOgPercent));
-
- mSpeakerOgValue = Utils.readOneLine(INCALL_SPEAKER_FILE);
- mSpeakerOgPercent = volumeToPercent(Integer.parseInt(mSpeakerOgValue));
-
- mSpeakerSeekBar.setOnSeekBarChangeListener(this);
- mSpeakerSeekBar.setProgress(Integer.valueOf(mSpeakerOgPercent));
-
- mBtOgValue = Utils.readOneLine(INCALL_BT_FILE);
- mBtOgPercent = volumeToPercent(Integer.parseInt(mBtOgValue));
-
- mBtSeekBar.setOnSeekBarChangeListener(this);
- mBtSeekBar.setProgress(Integer.valueOf(mBtOgPercent));
- }
-
- @Override
- protected void showDialog(Bundle state) {
- super.showDialog(state);
-
- // can't use onPrepareDialogBuilder for this as we want the dialog
- // to be kept open on click
- AlertDialog d = (AlertDialog) getDialog();
- Button defaultsButton = d.getButton(DialogInterface.BUTTON_NEUTRAL);
- defaultsButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mEarpieceSeekBar.setProgress(volumeToPercent(DEFAULT_VALUE));
- mHeadphoneSeekBar.setProgress(volumeToPercent(DEFAULT_VALUE));
- mSpeakerSeekBar.setProgress(volumeToPercent(DEFAULT_VALUE));
- mBtSeekBar.setProgress(volumeToPercent(DEFAULT_VALUE));
- }
- });
- }
-
- @Override
- protected void onDialogClosed(boolean positiveResult) {
- super.onDialogClosed(positiveResult);
- int volumeEarpiece, volumeHeadphone, volumeSpeaker, volumeBt;
-
- if (positiveResult) {
- Editor editor = getEditor();
-
- volumeEarpiece = percentToVolume(mEarpieceSeekBar.getProgress());
- editor.putString(INCALL_EARPIECE_FILE, String.valueOf(volumeEarpiece));
- volumeHeadphone = percentToVolume(mHeadphoneSeekBar.getProgress());
- editor.putString(INCALL_HEADPHONE_FILE, String.valueOf(volumeHeadphone));
- volumeSpeaker = percentToVolume(mSpeakerSeekBar.getProgress());
- editor.putString(INCALL_SPEAKER_FILE, String.valueOf(volumeSpeaker));
- volumeBt = percentToVolume(mBtSeekBar.getProgress());
- editor.putString(INCALL_BT_FILE, String.valueOf(volumeBt));
- editor.commit();
- } else {
- Utils.writeValue(INCALL_EARPIECE_FILE, String.valueOf(mEarpieceOgValue));
- Utils.writeValue(INCALL_HEADPHONE_FILE, String.valueOf(mHeadphoneOgValue));
- Utils.writeValue(INCALL_SPEAKER_FILE, String.valueOf(mSpeakerOgValue));
- Utils.writeValue(INCALL_BT_FILE, String.valueOf(mBtOgValue));
- }
- }
-
- public static void restore(Context context) {
- SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
-
- if (isSupported("earpiece"))
- Utils.writeValue(INCALL_EARPIECE_FILE, sharedPrefs.getString(INCALL_EARPIECE_FILE, "5"));
- if (isSupported("headphone"))
- Utils.writeValue(INCALL_HEADPHONE_FILE, sharedPrefs.getString(INCALL_HEADPHONE_FILE, "5"));
- if (isSupported("speaker"))
- Utils.writeValue(INCALL_SPEAKER_FILE, sharedPrefs.getString(INCALL_SPEAKER_FILE, "5"));
- if (isSupported("bt"))
- Utils.writeValue(INCALL_BT_FILE, sharedPrefs.getString(INCALL_BT_FILE, "5"));
- }
-
- public static boolean isSupported(String output) {
- String FILE = null;
- Device outputDevice = Device.valueOf(output);
-
- switch(outputDevice) {
- case earpiece:
- FILE = INCALL_EARPIECE_FILE;
- case headphone:
- FILE = INCALL_HEADPHONE_FILE;
- case speaker:
- FILE = INCALL_SPEAKER_FILE;
- case bt:
- FILE = INCALL_BT_FILE;
- }
- return Utils.fileExists(FILE);
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- boolean shouldWarn = progress >= volumeToPercent(WARNING_THRESHOLD);
- int stepSize = 10;
- progress = Math.round(progress/stepSize)*stepSize;
-
- if(seekBar == mEarpieceSeekBar){
- if (mEarpieceProgressDrawable != null) {
- mEarpieceProgressDrawable.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- if (mEarpieceProgressThumb != null) {
- mEarpieceProgressThumb.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- mEarpieceSeekBar.setProgress(progress);
- Utils.writeValue(INCALL_EARPIECE_FILE, String.valueOf(percentToVolume(progress)));
- mEarpieceValue.setText(String.format("%d%%", progress));
- }else if(seekBar == mHeadphoneSeekBar){
- if (mHeadphoneProgressDrawable != null) {
- mHeadphoneProgressDrawable.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- if (mHeadphoneProgressThumb != null) {
- mHeadphoneProgressThumb.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- mHeadphoneSeekBar.setProgress(progress);
- Utils.writeValue(INCALL_HEADPHONE_FILE, String.valueOf(percentToVolume(progress)));
- mHeadphoneValue.setText(String.format("%d%%", progress));
- }else if(seekBar == mSpeakerSeekBar){
- if (mSpeakerProgressDrawable != null) {
- mSpeakerProgressDrawable.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- if (mSpeakerProgressThumb != null) {
- mSpeakerProgressThumb.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- mSpeakerSeekBar.setProgress(progress);
- Utils.writeValue(INCALL_SPEAKER_FILE, String.valueOf(percentToVolume(progress)));
- mSpeakerValue.setText(String.format("%d%%", progress));
- }else if(seekBar == mBtSeekBar){
- if (mBtProgressThumb != null) {
- mBtProgressThumb.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- if (mBtProgressDrawable != null) {
- mBtProgressDrawable.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- mBtSeekBar.setProgress(progress);
- Utils.writeValue(INCALL_BT_FILE, String.valueOf(percentToVolume(progress)));
- mBtValue.setText(String.format("%d%%", progress));
- }
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // Do nothing
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- //Vibrator vib = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
- //vib.vibrate(200);
- }
-
- /**
- * Convert volume to percent
- */
- public static int volumeToPercent(int volume) {
- double maxValue = MAX_VALUE;
- double minValue = MIN_VALUE;
-
- double percent = volume * 10;
-
- if (percent > 100)
- percent = 100;
- else if (percent < 0)
- percent = 0;
-
- return (int) percent;
- }
-
- /**
- * Convert percent to volume
- */
- public static int percentToVolume(int percent) {
- int volume = Math.round(percent / 10);
-
- if (volume > MAX_VALUE)
- volume = MAX_VALUE;
- else if (volume < MIN_VALUE)
- volume = MIN_VALUE;
-
- return volume;
- }
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java b/DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java
deleted file mode 100644
index 6d11947..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 LedFade extends ListPreference implements OnPreferenceChangeListener {
-
- public LedFade(Context context, AttributeSet attrs) {
- super(context, attrs);
- this.setOnPreferenceChangeListener(this);
- }
-
- private static final String FILE = "/sys/class/sec/led/led_fade";
-
- public static boolean isSupported() {
- return Utils.fileExists(FILE);
- }
-
- /**
- * Restore led fading mode 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_LED_FADE, "1"));
- }
-
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- Utils.writeValue(FILE, (String) newValue);
- return true;
- }
-
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java
deleted file mode 100644
index e4b1eda..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.res.Resources;
-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 RadioFragmentActivity extends PreferenceFragment {
-
- private static final String PREF_ENABLED = "1";
- private static final String TAG = "DeviceSettings_Radio";
-
- private static boolean sHspa;
- private Hspa mHspa;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- addPreferencesFromResource(R.xml.radio_preferences);
-
- PreferenceScreen prefSet = getPreferenceScreen();
- Resources res = getResources();
- sHspa = res.getBoolean(R.bool.has_hspa);
-
- mHspa = (Hspa) findPreference(DeviceSettings.KEY_HSPA);
- mHspa.setEnabled(sHspa);
- }
-
- @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/SPenPowerSavingMode.java b/DeviceSettings/src/com/cyanogenmod/settings/device/SPenPowerSavingMode.java
deleted file mode 100644
index e80edd8..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/SPenPowerSavingMode.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.Intent;
-import android.content.SharedPreferences;
-import android.util.AttributeSet;
-import android.preference.CheckBoxPreference;
-import android.preference.Preference;
-import android.preference.Preference.OnPreferenceChangeListener;
-import android.preference.PreferenceManager;
-
-public class SPenPowerSavingMode extends CheckBoxPreference implements OnPreferenceChangeListener {
-
- private static String FILE_PATH = null;
-
- public SPenPowerSavingMode(Context context, AttributeSet attrs) {
- super(context, attrs);
- this.setOnPreferenceChangeListener(this);
- FILE_PATH = context.getResources().getString(R.string.spen_powersaving_sysfs_file);
- }
-
- public static boolean isSupported(String filePath) {
- return Utils.fileExists(filePath);
- }
-
- /**
- * Restore s-pen setting from SharedPreferences. (Write to kernel.)
- * @param context The context to read the SharedPreferences from
- */
- public static void restore(Context context) {
- FILE_PATH = context.getResources().getString(R.string.spen_powersaving_sysfs_file);
-
- if (!isSupported(FILE_PATH)) {
- return;
- }
-
- SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- Utils.writeValue(FILE_PATH, sharedPrefs.getBoolean(DeviceSettings.KEY_SPEN_POWER_SAVING_MODE, false) ? "1" : "0");
- }
-
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- Utils.writeValue(FILE_PATH, ((Boolean) newValue) ? "1" : "0");
- return true;
- }
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
deleted file mode 100644
index 669cc44..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.res.Resources;
-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.PreferenceCategory;
-import android.preference.PreferenceFragment;
-import android.preference.PreferenceManager;
-import android.preference.PreferenceScreen;
-import android.util.Log;
-
-import com.cyanogenmod.settings.device.R;
-
-public class ScreenFragmentActivity extends PreferenceFragment {
-
- private static final String PREF_ENABLED = "1";
- private static final String TAG = "DeviceSettings_Screen";
- private CABC mCABC;
- private mDNIeScenario mmDNIeScenario;
- private mDNIeMode mmDNIeMode;
- private mDNIeNegative mmDNIeNegative;
- private LedFade mLedFade;
- private CheckBoxPreference mTouchKey;
- private TouchkeyTimeout mTouchKeyTimeout;
-
- private static boolean sSPenSupported;
- private static boolean sTouchkeySupport;
-
- private static final String FILE_TOUCHKEY_BRIGHTNESS = "/sys/class/sec/sec_touchkey/brightness";
- private static final String FILE_TOUCHKEY_DISABLE = "/sys/class/sec/sec_touchkey/force_disable";
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- addPreferencesFromResource(R.xml.screen_preferences);
- PreferenceScreen preferenceScreen = getPreferenceScreen();
- Resources res = getResources();
-
- /* CABC */
- mCABC = (CABC) findPreference(DeviceSettings.KEY_CABC);
- mCABC.setEnabled(CABC.isSupported(res.getString(R.string.mdnie_cabc_sysfs_file)));
-
- /* mDNIe */
- mmDNIeScenario = (mDNIeScenario) findPreference(DeviceSettings.KEY_MDNIE_SCENARIO);
- mmDNIeScenario.setEnabled(mDNIeScenario.isSupported(res.getString(R.string.mdnie_scenario_sysfs_file)));
-
- mmDNIeMode = (mDNIeMode) findPreference(DeviceSettings.KEY_MDNIE_MODE);
- mmDNIeMode.setEnabled(mDNIeMode.isSupported(res.getString(R.string.mdnie_mode_sysfs_file)));
-
- mmDNIeNegative = (mDNIeNegative) findPreference(DeviceSettings.KEY_MDNIE_NEGATIVE);
- mmDNIeNegative.setEnabled(mDNIeNegative.isSupported(res.getString(R.string.mdnie_negative_sysfs_file)));
-
- /* LED */
- mLedFade = (LedFade) findPreference(DeviceSettings.KEY_LED_FADE);
- mLedFade.setEnabled(LedFade.isSupported());
-
- /* Touchkey */
- sTouchkeySupport = res.getBoolean(R.bool.has_touchkey);
- mTouchKey = (CheckBoxPreference)preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_LIGHT);
- mTouchKey.setEnabled(sTouchkeySupport);
-
- mTouchKeyTimeout = (TouchkeyTimeout)preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT);
-
- if (mTouchKey.isChecked() && mTouchKey.isEnabled()) {
- mTouchKeyTimeout.setEnabled(mTouchKeyTimeout.isSupported());
- } else {
- mTouchKeyTimeout.setEnabled(false);
- }
-
- /* S-Pen */
- String spenFilePath = res.getString(R.string.spen_sysfs_file);
- sSPenSupported = SPenPowerSavingMode.isSupported(spenFilePath);
-
- PreferenceCategory spenCategory = (PreferenceCategory) findPreference(DeviceSettings.KEY_CATEGORY_SPEN);
- if (!sSPenSupported) {
- preferenceScreen.removePreference(spenCategory);
- }
- }
-
- @Override
- public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
-
- String key = preference.getKey();
- Log.w(TAG, "key: " + key);
-
- if (key.compareTo(DeviceSettings.KEY_TOUCHKEY_LIGHT) == 0) {
- if (((CheckBoxPreference)preference).isChecked()) {
- Utils.writeValue(FILE_TOUCHKEY_DISABLE, "0");
- Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, "1");
- mTouchKeyTimeout.setEnabled(mTouchKeyTimeout.isSupported());
- } else {
- Utils.writeValue(FILE_TOUCHKEY_DISABLE, "1");
- Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, "2");
- mTouchKeyTimeout.setEnabled(false);
- }
- }
- return true;
- }
-
- public static boolean isSupported(String FILE) {
- return Utils.fileExists(FILE);
- }
-
- public static void restore(Context context) {
- SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- boolean light = sharedPrefs.getBoolean(DeviceSettings.KEY_TOUCHKEY_LIGHT, true);
-
- Utils.writeValue(FILE_TOUCHKEY_DISABLE, light ? "0" : "1");
- Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, light ? "1" : "2");
- }
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
deleted file mode 100644
index b91a197..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-public class Startup extends BroadcastReceiver {
-
- @Override
- public void onReceive(final Context context, final Intent bootintent) {
- AudioFragmentActivity.restore(context);
- AudioOut.restore(context);
- CABC.restore(context);
- HapticFragmentActivity.restore(context);
- Hspa.restore(context);
- IncallAudio.restore(context);
- LedFade.restore(context);
- mDNIeScenario.restore(context);
- mDNIeMode.restore(context);
- mDNIeNegative.restore(context);
- RadioFragmentActivity.restore(context);
- ScreenFragmentActivity.restore(context);
- SPenPowerSavingMode.restore(context);
- TouchkeyTimeout.restore(context);
- VibratorTuningPreference.restore(context);
- }
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java b/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java
deleted file mode 100644
index 6ea9bfb..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 TouchkeyTimeout extends ListPreference implements OnPreferenceChangeListener {
-
- public TouchkeyTimeout(Context context, AttributeSet attrs) {
- super(context, attrs);
- this.setOnPreferenceChangeListener(this);
- }
-
- private static final String FILE_TOUCHKEY_TIMEOUT = "/sys/class/sec/sec_touchkey/timeout";
-
- public static boolean isSupported() {
- return Utils.fileExists(FILE_TOUCHKEY_TIMEOUT);
- }
-
- /**
- * Restore touchscreen sensitivity 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_TOUCHKEY_TIMEOUT, sharedPrefs.getString(DeviceSettings.KEY_TOUCHKEY_TIMEOUT, "3"));
- }
-
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- Utils.writeValue(FILE_TOUCHKEY_TIMEOUT, (String) newValue);
- return true;
- }
-
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
deleted file mode 100644
index 4ca2e9e..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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.util.Log;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-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 = "DeviceSettings_Utils";
- private static final String TAG_READ = "DeviceSettings_Utils_Read";
- private static final String TAG_WRITE = "DeviceSettings_Utils_Write";
-
- // Read value from sysfs interface
- public static String readOneLine(String sFile) {
- BufferedReader brBuffer;
- String sLine = null;
-
- try {
- brBuffer = new BufferedReader(new FileReader(sFile), 512);
- try {
- sLine = brBuffer.readLine();
- } finally {
- Log.w(TAG_READ, "file " + sFile + ": " + sLine);
- brBuffer.close();
- }
- } catch (Exception e) {
- Log.e(TAG_READ, "IO Exception when reading /sys/ file", e);
- }
- return sLine;
- }
-
- /**
- * Write a string value to the specified file.
- *
- * @param filename The filename
- * @param value The value
- */
- public static void writeValue(String filename, String value) {
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(new File(filename), false);
- fos.write(value.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);
- }
- }
- }
-
- }
-
- /**
- * 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);
- }
- }
- }
- }
-
- /**
- * Write the "color value" to the specified file. The value is scaled from
- * an integer to an unsigned integer by multiplying by 2.
- * @param filename The filename
- * @param value The value of max value Integer.MAX
- */
- public static void writeColor(String filename, int value) {
- writeValue(filename, String.valueOf((long) value * 2));
- }
-
- /**
- * Check if the specified file exists.
- * @param filename The filename
- * @return Whether the file exists or not
- */
- public static boolean fileExists(String filename) {
- return new File(filename).exists();
- }
-
- public static void showDialog(Context ctx, String title, String message) {
- final AlertDialog alertDialog = new AlertDialog.Builder(ctx).create();
- alertDialog.setTitle(title);
- alertDialog.setMessage(message);
- alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- alertDialog.dismiss();
- }
- });
- alertDialog.show();
- }
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java b/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java
deleted file mode 100644
index f2880e9..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2013 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.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
-import android.graphics.Color;
-import android.graphics.LightingColorFilter;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
-import android.os.Bundle;
-import android.os.Vibrator;
-import android.preference.DialogPreference;
-import android.preference.PreferenceManager;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.View;
-import android.widget.SeekBar;
-import android.widget.TextView;
-import android.widget.Button;
-
-import java.lang.Math;
-import java.text.DecimalFormat;
-
-/**
- * Special preference type that allows configuration of vibrator intensity settings on Samsung devices
- */
-public class VibratorTuningPreference extends DialogPreference implements SeekBar.OnSeekBarChangeListener {
- private static final String TAG = "DeviceSettings_Vibrator";
-
- private static String FILE_PATH = null;
- private static int MAX_VALUE;
- private static int WARNING_THRESHOLD;
- private static int DEFAULT_VALUE;
- private static int MIN_VALUE;
-
- private Context mContext;
- private SeekBar mSeekBar;
- private TextView mValue;
- private TextView mWarning;
- private String mOriginalValue;
- private Drawable mProgressDrawable;
- private Drawable mProgressThumb;
- private LightingColorFilter mRedFilter;
-
- public VibratorTuningPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- mContext = context;
-
- FILE_PATH = context.getResources().getString(R.string.vibrator_sysfs_file);
- MAX_VALUE = Integer.valueOf(context.getResources().getString(R.string.intensity_max_value));
- WARNING_THRESHOLD = Integer.valueOf(context.getResources().getString(R.string.intensity_warning_threshold));
- DEFAULT_VALUE = Integer.valueOf(context.getResources().getString(R.string.intensity_default_value));
- MIN_VALUE = Integer.valueOf(context.getResources().getString(R.string.intensity_min_value));
-
- setDialogLayoutResource(R.layout.preference_dialog_vibrator_tuning);
- }
-
- @Override
- protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
- builder.setNeutralButton(R.string.defaults_button, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- }
-
- @Override
- protected void onBindDialogView(View view) {
- super.onBindDialogView(view);
-
- mSeekBar = (SeekBar) view.findViewById(R.id.vibrator_seekbar);
- mValue = (TextView) view.findViewById(R.id.vibrator_value);
- mWarning = (TextView) view.findViewById(R.id.textWarn);
-
- String strWarnMsg = getContext().getResources().getString(R.string.vibrator_warning, strengthToPercent(WARNING_THRESHOLD));
- mWarning.setText(strWarnMsg);
-
- Drawable progressDrawable = mSeekBar.getProgressDrawable();
- if (progressDrawable instanceof LayerDrawable) {
- LayerDrawable ld = (LayerDrawable) progressDrawable;
- mProgressDrawable = ld.findDrawableByLayerId(android.R.id.progress);
- }
- mProgressThumb = mSeekBar.getThumb();
- mRedFilter = new LightingColorFilter(Color.BLACK,
- getContext().getResources().getColor(android.R.color.holo_red_light));
-
- // Read the current value from sysfs in case user wants to dismiss his changes
- mOriginalValue = Utils.readOneLine(FILE_PATH);
-
- // Restore percent value from SharedPreferences object
- SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mContext);
- int percent = settings.getInt("percent", strengthToPercent(DEFAULT_VALUE));
-
- mSeekBar.setOnSeekBarChangeListener(this);
- mSeekBar.setProgress(Integer.valueOf(percent));
- }
-
- @Override
- protected void showDialog(Bundle state) {
- super.showDialog(state);
-
- // can't use onPrepareDialogBuilder for this as we want the dialog
- // to be kept open on click
- AlertDialog d = (AlertDialog) getDialog();
- Button defaultsButton = d.getButton(DialogInterface.BUTTON_NEUTRAL);
- defaultsButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mSeekBar.setProgress(strengthToPercent(DEFAULT_VALUE));
- }
- });
- }
-
- @Override
- protected void onDialogClosed(boolean positiveResult) {
- super.onDialogClosed(positiveResult);
-
- if (positiveResult) {
- // Store percent value in SharedPreferences object
- SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mContext);
- SharedPreferences.Editor editor = settings.edit();
- editor.putInt("percent", mSeekBar.getProgress());
- editor.commit();
- } else {
- Utils.writeValue(FILE_PATH, String.valueOf(mOriginalValue));
- }
- }
-
- public static void restore(Context context) {
- FILE_PATH = context.getResources().getString(R.string.vibrator_sysfs_file);
-
- if (!isSupported(FILE_PATH)) {
- return;
- }
-
- MAX_VALUE = Integer.valueOf(context.getResources().getString(R.string.intensity_max_value));
- DEFAULT_VALUE = Integer.valueOf(context.getResources().getString(R.string.intensity_default_value));
- MIN_VALUE = Integer.valueOf(context.getResources().getString(R.string.intensity_min_value));
-
- SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
- int strength = percentToStrength(settings.getInt("percent", strengthToPercent(DEFAULT_VALUE)));
-
- Log.d(TAG, "Restoring vibration setting: " + strength);
- Utils.writeValue(FILE_PATH, String.valueOf(strength));
- }
-
- public static boolean isSupported(String filePath) {
- return Utils.fileExists(filePath);
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- boolean shouldWarn = progress >= strengthToPercent(WARNING_THRESHOLD);
- if (mProgressDrawable != null) {
- mProgressDrawable.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- if (mProgressThumb != null) {
- mProgressThumb.setColorFilter(shouldWarn ? mRedFilter : null);
- }
- Utils.writeValue(FILE_PATH, String.valueOf(percentToStrength(progress)));
- mValue.setText(String.format("%d%%", progress));
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // Do nothing
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- Vibrator vib = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
- vib.vibrate(200);
- }
-
- /**
- * Convert vibrator strength to percent
- */
- public static int strengthToPercent(int strength) {
- double maxValue = MAX_VALUE;
- double minValue = MIN_VALUE;
-
- double percent = (strength - minValue) * (100 / (maxValue - minValue));
-
- if (percent > 100)
- percent = 100;
- else if (percent < 0)
- percent = 0;
-
- return (int) percent;
- }
-
- /**
- * Convert percent to vibrator strength
- */
- public static int percentToStrength(int percent) {
- int strength = Math.round((((MAX_VALUE - MIN_VALUE) * percent) / 100) + MIN_VALUE);
-
- if (strength > MAX_VALUE)
- strength = MAX_VALUE;
- else if (strength < MIN_VALUE)
- strength = MIN_VALUE;
-
- return strength;
- }
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java
deleted file mode 100644
index 2e473e6..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.util.AttributeSet;
-import android.preference.Preference;
-import android.preference.ListPreference;
-import android.preference.Preference.OnPreferenceChangeListener;
-import android.preference.PreferenceManager;
-
-public class mDNIeMode extends ListPreference implements OnPreferenceChangeListener {
-
- private static String FILE = null;
-
- public mDNIeMode(Context context, AttributeSet attrs) {
- super(context, attrs);
- this.setOnPreferenceChangeListener(this);
- FILE = context.getResources().getString(R.string.mdnie_mode_sysfs_file);
- }
-
- public static boolean isSupported(String filePath) {
- return Utils.fileExists(filePath);
- }
-
- /**
- * Restore mdnie user mode setting from SharedPreferences. (Write to kernel.)
- * @param context The context to read the SharedPreferences from
- */
- public static void restore(Context context) {
- FILE = context.getResources().getString(R.string.mdnie_mode_sysfs_file);
- if (!isSupported(FILE)) {
- return;
- }
-
- SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_MDNIE_MODE, "0"));
- }
-
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- Utils.writeValue(FILE, (String) newValue);
- return true;
- }
-
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java
deleted file mode 100644
index 3851c85..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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 mDNIeNegative extends ListPreference implements OnPreferenceChangeListener {
-
- private static String FILE = null;
-
- public mDNIeNegative(Context context, AttributeSet attrs) {
- super(context, attrs);
- this.setOnPreferenceChangeListener(this);
- FILE = context.getResources().getString(R.string.mdnie_negative_sysfs_file);
- }
-
- public static boolean isSupported(String filePath) {
- return Utils.fileExists(filePath);
- }
-
- /**
- * Restore mdnie user mode setting from SharedPreferences. (Write to kernel.)
- * @param context The context to read the SharedPreferences from
- */
- public static void restore(Context context) {
- FILE = context.getResources().getString(R.string.mdnie_negative_sysfs_file);
- if (!isSupported(FILE)) {
- return;
- }
-
- SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_MDNIE_NEGATIVE, "0"));
- }
-
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- Utils.writeValue(FILE, (String) newValue);
- return true;
- }
-
-}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java
deleted file mode 100644
index 2a852a3..0000000
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.util.AttributeSet;
-import android.preference.Preference;
-import android.preference.ListPreference;
-import android.preference.Preference.OnPreferenceChangeListener;
-import android.preference.PreferenceManager;
-
-public class mDNIeScenario extends ListPreference implements OnPreferenceChangeListener {
-
- private static String FILE = null;
-
- public mDNIeScenario(Context context, AttributeSet attrs) {
- super(context,attrs);
- this.setOnPreferenceChangeListener(this);
- FILE = context.getResources().getString(R.string.mdnie_scenario_sysfs_file);
- }
-
- public static boolean isSupported(String filePath) {
- return Utils.fileExists(filePath);
- }
-
- /**
- * Restore mdnie "camera" setting from SharedPreferences. (Write to kernel.)
- * @param context The context to read the SharedPreferences from
- */
- public static void restore(Context context) {
- FILE = context.getResources().getString(R.string.mdnie_scenario_sysfs_file);
- if (!isSupported(FILE)) {
- return;
- }
-
- SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_MDNIE_SCENARIO, "0"));
- }
-
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- Utils.writeValue(FILE, (String) newValue);
- return true;
- }
-
-}