android:name=".DozePreferenceActivity"
android:exported="false"
android:label="@string/ambient_display_gestures_title"
- android:theme="@style/Theme.Main">
+ android:theme="@style/Theme.SubSettingsBase">
<intent-filter>
<action android:name="org.lineageos.settings.device.DOZE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
android:name=".ActionsPreferenceActivity"
android:exported="false"
android:label="@string/moto_gestures_panel_title"
- android:theme="@style/Theme.Main">
+ android:theme="@style/Theme.SubSettingsBase">
<intent-filter>
<action android:name="com.android.settings.action.IA_SETTINGS" />
</intent-filter>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 2014, The Android Open Source 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.
-*/
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <include layout="@layout/switch_bar" />
-
-</LinearLayout>
-
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015-2016 The CyanogenMod Project
- Copyright (C) 2017 The LineageOS Project
+ Copyright (C) 2017,2022 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License"
you may not use this file except in compliance with the License.
See the License for the specific language governing permissions and
limitations under the License.
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/actions_title">
<PreferenceCategory
- android:key="actions_key"
- android:title="@string/actions_title">
+ android:key="actions_key">
<SwitchPreference
android:key="gesture_camera_action"
See the License for the specific language governing permissions and
limitations under the License.
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/ambient_display_title">
+
+ <com.android.settingslib.widget.TopIntroPreference
+ android:key="doze_top_intro"
+ android:title="@string/ambient_display_enable_summary"/>
+
+ <com.android.settingslib.widget.MainSwitchPreference
+ android:defaultValue="false"
+ android:key="doze_enable"
+ android:title="@string/ambient_display_enable_title" />
<SwitchPreference
android:key="always_on_display"
package org.lineageos.settings.device;
import android.os.Bundle;
-import android.preference.PreferenceActivity;
-public class ActionsPreferenceActivity extends PreferenceActivity {
+import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
+import com.android.settingslib.collapsingtoolbar.R;
+
+public class ActionsPreferenceActivity extends CollapsingToolbarBaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getFragmentManager()
.beginTransaction()
- .replace(android.R.id.content, new ActionsPreferenceFragment())
+ .replace(R.id.content_frame, new ActionsPreferenceFragment())
.commit();
}
}
package org.lineageos.settings.device;
-import android.app.ActionBar;
import android.os.Bundle;
import android.view.MenuItem;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.actions_panel);
- final ActionBar actionBar = getActivity().getActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
if (!CameraActivationSensor.hasSensor(getContext())) {
PreferenceCategory category = findPreference(KEY_ACTIONS_CATEGORY);
/*
* Copyright (C) 2015-2016 The CyanogenMod Project
- * 2017 The LineageOS Project
+ * 2017,2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.lineageos.settings.device;
import android.os.Bundle;
-import android.preference.PreferenceActivity;
-public class DozePreferenceActivity extends PreferenceActivity {
+import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
+import com.android.settingslib.collapsingtoolbar.R;
+
+public class DozePreferenceActivity extends CollapsingToolbarBaseActivity {
private static final String TAG_DOZE = "doze";
super.onCreate(savedInstanceState);
getFragmentManager()
.beginTransaction()
- .replace(android.R.id.content, new DozePreferenceFragment(), TAG_DOZE)
+ .replace(R.id.content_frame, new DozePreferenceFragment(), TAG_DOZE)
.commit();
}
}
package org.lineageos.settings.device;
-import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.CompoundButton;
import android.widget.Switch;
-import android.widget.TextView;
import androidx.preference.Preference;
-import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragment;
import androidx.preference.SwitchPreference;
+import com.android.settingslib.widget.MainSwitchPreference;
+import com.android.settingslib.widget.OnMainSwitchChangeListener;
+
public class DozePreferenceFragment extends PreferenceFragment
- implements OnPreferenceChangeListener, CompoundButton.OnCheckedChangeListener {
+ implements Preference.OnPreferenceChangeListener, OnMainSwitchChangeListener {
- private TextView mTextView;
- private View mSwitchBar;
+ private MainSwitchPreference mSwitchBar;
private SwitchPreference mAlwaysOnDisplayPreference;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.doze_panel);
- final ActionBar actionBar = getActivity().getActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
SharedPreferences prefs =
getActivity().getSharedPreferences("doze_panel", Activity.MODE_PRIVATE);
boolean dozeEnabled = MotoActionsSettings.isDozeEnabled(getActivity());
+ mSwitchBar = (MainSwitchPreference) findPreference(MotoActionsSettings.DOZE_ENABLE);
+ mSwitchBar.addOnSwitchChangeListener(this);
+ mSwitchBar.setChecked(dozeEnabled);
+
mAlwaysOnDisplayPreference = findPreference(MotoActionsSettings.ALWAYS_ON_DISPLAY);
mAlwaysOnDisplayPreference.setEnabled(dozeEnabled);
mAlwaysOnDisplayPreference.setChecked(MotoActionsSettings.isAlwaysOnEnabled(getActivity()));
}
}
- @Override
- public View onCreateView(
- LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final View view =
- LayoutInflater.from(getContext()).inflate(R.layout.doze, container, false);
- ((ViewGroup) view).addView(super.onCreateView(inflater, container, savedInstanceState));
- return view;
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- boolean dozeEnabled = MotoActionsSettings.isDozeEnabled(getActivity());
-
- mTextView = view.findViewById(R.id.switch_text);
- mTextView.setText(
- getString(dozeEnabled ? R.string.switch_bar_on : R.string.switch_bar_off));
-
- mSwitchBar = view.findViewById(R.id.switch_bar);
- Switch switchWidget = mSwitchBar.findViewById(android.R.id.switch_widget);
- switchWidget.setChecked(dozeEnabled);
- switchWidget.setOnCheckedChangeListener(this);
- mSwitchBar.setActivated(dozeEnabled);
- mSwitchBar.setOnClickListener(
- v -> {
- switchWidget.setChecked(!switchWidget.isChecked());
- mSwitchBar.setActivated(switchWidget.isChecked());
- });
- }
-
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (MotoActionsSettings.ALWAYS_ON_DISPLAY.equals(preference.getKey())) {
}
@Override
- public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
+ public void onSwitchChanged(Switch switchView, boolean isChecked) {
MotoActionsSettings.enableDoze(getActivity(), isChecked);
- mTextView.setText(getString(isChecked ? R.string.switch_bar_on : R.string.switch_bar_off));
- mSwitchBar.setActivated(isChecked);
+ mSwitchBar.setChecked(isChecked);
if (!isChecked) {
MotoActionsSettings.enableAlwaysOn(getActivity(), false);
mPocketPreference.setEnabled(isChecked);
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- getActivity().onBackPressed();
- return true;
- }
- return false;
- }
-
public static class HelpDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
static final String GESTURE_PICK_UP_KEY = "gesture_pick_up";
static final String GESTURE_POCKET_KEY = "gesture_pocket";
+ static final String DOZE_ENABLE = "doze_enable";
static final String ALWAYS_ON_DISPLAY = "always_on_display";
private final Context mContext;