From 96000dbbfb24df181b87e284ae27a8eea8d40fb8 Mon Sep 17 00:00:00 2001 From: Daniel Hillenbrand Date: Sun, 9 Jun 2013 11:51:32 +0200 Subject: i9300: move advanced settings to common Change-Id: Icce502a25b33a13448de371c09eb80b7ce2c447c --- .../src/com/cyanogenmod/settings/device/CABC.java | 58 ------ .../settings/device/DeviceSettings.java | 169 ---------------- .../settings/device/DockFragmentActivity.java | 72 ------- .../settings/device/HapticFragmentActivity.java | 72 ------- .../src/com/cyanogenmod/settings/device/Hspa.java | 67 ------- .../com/cyanogenmod/settings/device/LedFade.java | 59 ------ .../settings/device/RadioFragmentActivity.java | 66 ------- .../settings/device/ScreenFragmentActivity.java | 106 ---------- .../com/cyanogenmod/settings/device/Startup.java | 40 ---- .../settings/device/TouchkeyTimeout.java | 59 ------ .../src/com/cyanogenmod/settings/device/Utils.java | 163 --------------- .../settings/device/VibratorTuningPreference.java | 219 --------------------- .../com/cyanogenmod/settings/device/mDNIeMode.java | 59 ------ .../cyanogenmod/settings/device/mDNIeNegative.java | 59 ------ .../cyanogenmod/settings/device/mDNIeScenario.java | 59 ------ 15 files changed, 1327 deletions(-) delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/DockFragmentActivity.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/VibratorTuningPreference.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java delete mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java (limited to 'DeviceSettings/src/com/cyanogenmod') 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 af247d8..0000000 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/CABC.java +++ /dev/null @@ -1,58 +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 { - - public CABC(Context context, AttributeSet attrs) { - super(context, attrs); - this.setOnPreferenceChangeListener(this); - } - - private static final String FILE = "/sys/class/lcd/panel/power_reduce"; - - public static boolean isSupported() { - return Utils.fileExists(FILE); - } - - /** - * Restore cabc 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.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 486fe79..0000000 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java +++ /dev/null @@ -1,169 +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_VIBRATOR_INTENSITY = "vibrator_intensity"; - public static final String KEY_USE_DOCK_AUDIO = "dock_audio"; - - 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_dock_title), - DockFragmentActivity.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 mTabs = new ArrayList(); - - 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= 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 7969637..0000000 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.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 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 { - - public mDNIeMode(Context context, AttributeSet attrs) { - super(context, attrs); - this.setOnPreferenceChangeListener(this); - } - - private static final String FILE = "/sys/class/mdnie/mdnie/mode"; - - public static boolean isSupported() { - return Utils.fileExists(FILE); - } - - /** - * 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) { - if (!isSupported()) { - 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 c2ccc7b..0000000 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.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 mDNIeNegative extends ListPreference implements OnPreferenceChangeListener { - - public mDNIeNegative(Context context, AttributeSet attrs) { - super(context, attrs); - this.setOnPreferenceChangeListener(this); - } - - private static final String FILE = "/sys/class/mdnie/mdnie/negative"; - - public static boolean isSupported() { - return Utils.fileExists(FILE); - } - - /** - * 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) { - if (!isSupported()) { - 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 a9c935a..0000000 --- a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.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 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 { - - public mDNIeScenario(Context context, AttributeSet attrs) { - super(context,attrs); - this.setOnPreferenceChangeListener(this); - } - - private static final String FILE = "/sys/class/mdnie/mdnie/scenario"; - - public static boolean isSupported() { - return Utils.fileExists(FILE); - } - - /** - * Restore mdnie "camera" 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_MDNIE_SCENARIO, "0")); - } - - public boolean onPreferenceChange(Preference preference, Object newValue) { - Utils.writeValue(FILE, (String) newValue); - return true; - } - -} -- cgit v1.1