aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriele M <moto.falcon.git@gmail.com>2016-04-03 18:02:36 +0200
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-05-13 13:12:22 -0700
commit19e9f74d7f574478b83ed8bffae568b025a53514 (patch)
tree40e936ecd1d4c73ad0a5bd31a84d757293f54db6
parentac47ef9272e1f5b5eeaa964d41eb924e14197091 (diff)
msm8226-common: CMActions: Use Preference Fragments
PreferenceActivity.addPreferencesFromResource() is deprecated. Change-Id: Iff77d74341c7f9b5425172ce520055f1434b82c1
-rw-r--r--CMActions/AndroidManifest.xml2
-rw-r--r--CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceActivity.java42
-rw-r--r--CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceFragment.java (renamed from CMActions/src/com/cyanogenmod/cmactions/GestureSettings.java)36
3 files changed, 47 insertions, 33 deletions
diff --git a/CMActions/AndroidManifest.xml b/CMActions/AndroidManifest.xml
index 2cd7f5d..b07768e 100644
--- a/CMActions/AndroidManifest.xml
+++ b/CMActions/AndroidManifest.xml
@@ -23,7 +23,7 @@
</service>
<activity
- android:name=".GestureSettings"
+ android:name=".GesturePreferenceActivity"
android:label="@string/screen_gestures_panel_title"
android:theme="@android:style/Theme.Material.Settings">
<intent-filter>
diff --git a/CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceActivity.java b/CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceActivity.java
new file mode 100644
index 0000000..9f76e6e
--- /dev/null
+++ b/CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceActivity.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016 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.cmactions;
+
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+import android.view.MenuItem;
+
+public class GesturePreferenceActivity extends PreferenceActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+ getFragmentManager().beginTransaction()
+ .replace(android.R.id.content, new GesturePreferenceFragment()).commit();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/CMActions/src/com/cyanogenmod/cmactions/GestureSettings.java b/CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceFragment.java
index 573011b..ffbcf03 100644
--- a/CMActions/src/com/cyanogenmod/cmactions/GestureSettings.java
+++ b/CMActions/src/com/cyanogenmod/cmactions/GesturePreferenceFragment.java
@@ -16,18 +16,13 @@
package com.cyanogenmod.cmactions;
-import android.app.ActionBar;
import android.os.Bundle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
import android.preference.SwitchPreference;
import android.provider.Settings;
-import android.view.Menu;
-import android.view.MenuItem;
-import org.cyanogenmod.internal.util.ScreenType;
-
-public class GestureSettings extends PreferenceActivity {
+public class GesturePreferenceFragment extends PreferenceFragment {
private static final String KEY_AMBIENT_DISPLAY_ENABLE = "ambient_display_enable";
private static final String KEY_GESTURE_POCKET = "gesture_pocket";
@@ -53,38 +48,15 @@ public class GestureSettings extends PreferenceActivity {
mHandwavePreference =
(SwitchPreference) findPreference(KEY_GESTURE_HAND_WAVE);
mHandwavePreference.setEnabled(dozeEnabled);
-
- final ActionBar bar = getActionBar();
- bar.setDisplayHomeAsUpEnabled(true);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- }
- return false;
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- // If running on a phone, remove padding around the listview
- if (!ScreenType.isTablet(this)) {
- getListView().setPadding(0, 0, 0, 0);
- }
}
private boolean enableDoze(boolean enable) {
- return Settings.Secure.putInt(getContentResolver(),
+ return Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.DOZE_ENABLED, enable ? 1 : 0);
}
private boolean isDozeEnabled() {
- return Settings.Secure.getInt(getContentResolver(),
+ return Settings.Secure.getInt(getActivity().getContentResolver(),
Settings.Secure.DOZE_ENABLED, 1) != 0;
}