samsung: doze: Integrate with Settings

Bring this up to speed on the Settings changes in N:
 * Use support libs for preferences
 * Hook up to Settings drawer through SettingsDrawerActivity

Change-Id: I9365b3ebd1bbfed2936302e30da50e3f9af06665
tirimbino
Zhao Wei Liew 8 years ago committed by Jan Altensen
parent 257f8c1d0c
commit 6d0ea5b8c8
No known key found for this signature in database
GPG Key ID: 3E45BB95F7AD33DA
  1. 21
      doze/Android.mk
  2. 4
      doze/AndroidManifest.xml
  3. 6
      doze/proguard.flags
  4. 21
      doze/res/values/styles.xml
  5. 34
      doze/src/com/cyanogenmod/settings/device/SamsungDozeActivity.java
  6. 19
      doze/src/com/cyanogenmod/settings/device/TouchscreenGestureSettings.java

@ -10,10 +10,31 @@ LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true LOCAL_PRIVILEGED_MODULE := true
LOCAL_STATIC_JAVA_LIBRARIES := \ LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-v14-preference \
android-support-v7-appcompat \
android-support-v7-preference \
android-support-v7-recyclerview \
org.cyanogenmod.platform.internal org.cyanogenmod.platform.internal
LOCAL_PROGUARD_FLAG_FILES := proguard.flags LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_RESOURCE_DIR := \
$(LOCAL_PATH)/res \
frameworks/support/v14/preference/res \
frameworks/support/v7/appcompat/res \
frameworks/support/v7/preference/res \
frameworks/support/v7/recyclerview/res
LOCAL_AAPT_FLAGS := --auto-add-overlay \
--extra-packages android.support.v14.preference:android.support.v7.appcompat:android.support.v7.preference:android.support.v7.recyclerview
ifneq ($(INCREMENTAL_BUILDS),)
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_JACK_ENABLED := incremental
endif
include frameworks/base/packages/SettingsLib/common.mk
include $(BUILD_PACKAGE) include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH)) include $(call all-makefiles-under,$(LOCAL_PATH))

@ -30,9 +30,9 @@
</service> </service>
<activity <activity
android:name=".TouchscreenGestureSettings" android:name=".SamsungDozeActivity"
android:label="@string/screen_gestures_panel_title" android:label="@string/screen_gestures_panel_title"
android:theme="@android:style/Theme.Material.Settings"> android:theme="@style/SamsungDozeSettings">
<intent-filter> <intent-filter>
<action android:name="com.android.settings.action.EXTRA_SETTINGS" /> <action android:name="com.android.settings.action.EXTRA_SETTINGS" />
</intent-filter> </intent-filter>

@ -1,3 +1,9 @@
-keep class com.cyanogenmod.settings.device.* { -keep class com.cyanogenmod.settings.device.* {
*; *;
} }
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keep class ** extends android.support.v14.preference.PreferenceFragment

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<style name="SamsungDozeSettings" parent="@android:style/Theme.Material.Settings">
<item name="preferenceTheme">@android:style/Theme.Material.Settings</item>
</style>
</resources>

@ -0,0 +1,34 @@
/*
* 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.settings.device;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import com.android.settingslib.drawer.SettingsDrawerActivity;
public class SamsungDozeActivity extends SettingsDrawerActivity {
private static final String TAG = "samsung_doze";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getFragmentManager().beginTransaction().replace(R.id.content_frame,
new TouchscreenGestureSettings(), TAG).commit();
}
}

@ -17,14 +17,14 @@
package com.cyanogenmod.settings.device; package com.cyanogenmod.settings.device;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.support.v14.preference.PreferenceFragment;
import android.preference.PreferenceActivity; import android.support.v14.preference.SwitchPreference;
import android.preference.SwitchPreference; import android.support.v7.preference.Preference;
import android.provider.Settings; import android.provider.Settings;
import org.cyanogenmod.internal.util.ScreenType; import org.cyanogenmod.internal.util.ScreenType;
public class TouchscreenGestureSettings extends PreferenceActivity { public class TouchscreenGestureSettings extends PreferenceFragment {
private static final String KEY_AMBIENT_DISPLAY_ENABLE = "ambient_display_enable"; private static final String KEY_AMBIENT_DISPLAY_ENABLE = "ambient_display_enable";
private static final String KEY_HAND_WAVE = "gesture_hand_wave"; private static final String KEY_HAND_WAVE = "gesture_hand_wave";
@ -37,8 +37,7 @@ public class TouchscreenGestureSettings extends PreferenceActivity {
private SwitchPreference mProximityWakePreference; private SwitchPreference mProximityWakePreference;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.gesture_panel); addPreferencesFromResource(R.xml.gesture_panel);
boolean dozeEnabled = isDozeEnabled(); boolean dozeEnabled = isDozeEnabled();
mAmbientDisplayPreference = mAmbientDisplayPreference =
@ -59,22 +58,22 @@ public class TouchscreenGestureSettings extends PreferenceActivity {
} }
@Override @Override
protected void onResume() { public void onResume() {
super.onResume(); super.onResume();
// If running on a phone, remove padding around the listview // If running on a phone, remove padding around the listview
if (!ScreenType.isTablet(this)) { if (!ScreenType.isTablet(getContext())) {
getListView().setPadding(0, 0, 0, 0); getListView().setPadding(0, 0, 0, 0);
} }
} }
private boolean enableDoze(boolean enable) { private boolean enableDoze(boolean enable) {
return Settings.Secure.putInt(getContentResolver(), return Settings.Secure.putInt(getContext().getContentResolver(),
Settings.Secure.DOZE_ENABLED, enable ? 1 : 0); Settings.Secure.DOZE_ENABLED, enable ? 1 : 0);
} }
private boolean isDozeEnabled() { private boolean isDozeEnabled() {
return Settings.Secure.getInt(getContentResolver(), return Settings.Secure.getInt(getContext().getContentResolver(),
Settings.Secure.DOZE_ENABLED, 1) != 0; Settings.Secure.DOZE_ENABLED, 1) != 0;
} }

Loading…
Cancel
Save