Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Settings: Add charging control preferences
Change-Id: I936add4df464eb9818258de4955b651266c67ec3 Signed-off-by: Mohammad Hasan Keramat J <ikeramat@protonmail.com> ChargingControl: Don't index settings if it is not supported Change-Id: I8e7e26d39ffdd31fd35d0d25a2f6bd8b7dcbe3f4 Signed-off-by: Mohammad Hasan Keramat J <ikeramat@protonmail.com>
- Loading branch information
1 parent
98d2143
commit b01f75a
Showing
12 changed files
with
819 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (C) 2023 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. | ||
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:paddingLeft="16dp" | ||
android:paddingRight="16dp" | ||
android:orientation="vertical"> | ||
|
||
<TimePicker | ||
android:id="@+id/time_picker" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_vertical" | ||
android:paddingTop="8dp" /> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (C) 2023 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. | ||
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="wrap_content" | ||
android:gravity="center_vertical" | ||
android:paddingVertical="6dip" | ||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" | ||
android:paddingStart="?android:attr/listPreferredItemPaddingStart" | ||
android:background="?android:attr/selectableItemBackground" | ||
android:orientation="vertical"> | ||
|
||
<RelativeLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="0dp" | ||
android:layout_weight="1"> | ||
|
||
<TextView | ||
android:id="@android:id/title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:singleLine="true" | ||
android:textAppearance="?android:attr/textAppearanceLarge" | ||
android:textColor="?android:attr/textColorPrimary" | ||
android:ellipsize="marquee" | ||
android:fadingEdge="horizontal" /> | ||
|
||
<TextView | ||
android:id="@+id/value" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentEnd="true" | ||
android:layout_centerVertical="true" | ||
android:textAppearance="?android:attr/textAppearanceSmall" | ||
android:textColor="?android:attr/textColorSecondary" | ||
android:singleLine="true" /> | ||
|
||
</RelativeLayout> | ||
|
||
<SeekBar | ||
android:id="@+id/seekbar_widget" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingVertical="15dip" | ||
android:min="70" | ||
android:max="100" /> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (C) 2023 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. | ||
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. | ||
--> | ||
|
||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:key="charging_control" | ||
android:title="@string/charging_control_title"> | ||
|
||
<com.android.settings.custom.preference.SystemSettingMainSwitchPreference | ||
android:key="charging_control_enabled" | ||
android:title="@string/charging_control_enable_title" /> | ||
|
||
<com.android.settings.custom.preference.SystemSettingDropDownPreference | ||
android:key="charging_control_mode" | ||
android:title="@string/charging_control_mode_title" | ||
android:entries="@array/charging_control_mode_entries" | ||
android:entryValues="@array/charging_control_mode_values" | ||
android:dependency="charging_control_enabled" /> | ||
|
||
<com.android.settings.lineage.health.StartTimePreference | ||
android:key="charging_control_start_time" | ||
android:title="@string/charging_control_start_time_title" | ||
android:dependency="charging_control_enabled" /> | ||
|
||
<com.android.settings.lineage.health.TargetTimePreference | ||
android:key="charging_control_target_time" | ||
android:title="@string/charging_control_target_time_title" | ||
android:dependency="charging_control_enabled" /> | ||
|
||
<com.android.settings.lineage.health.ChargingLimitPreference | ||
android:key="charging_control_charging_limit" | ||
android:title="@string/charging_control_limit_title" | ||
android:dependency="charging_control_enabled" /> | ||
|
||
</PreferenceScreen> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/com/android/settings/lineage/health/ChargingControlPreferenceController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (C) 2022 The PixelExperience Project | ||
* Copyright (C) 2023 The lineage Foundation | ||
* | ||
* 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.android.settings.lineage.health; | ||
|
||
import android.content.Context; | ||
import android.os.IBinder; | ||
import android.os.ServiceManager; | ||
|
||
import com.android.settings.core.BasePreferenceController; | ||
import com.android.settings.R; | ||
|
||
public class ChargingControlPreferenceController extends BasePreferenceController { | ||
|
||
public static final String KEY = "charging_control"; | ||
|
||
private Context mContext; | ||
|
||
public ChargingControlPreferenceController(Context context, String key) { | ||
super(context, key); | ||
|
||
mContext = context; | ||
} | ||
|
||
public ChargingControlPreferenceController(Context context) { | ||
this(context, KEY); | ||
|
||
mContext = context; | ||
} | ||
|
||
private boolean isNegated(String key) { | ||
return key != null && key.startsWith("!"); | ||
} | ||
|
||
@Override | ||
public int getAvailabilityStatus() { | ||
String rService = "lineagehealth"; | ||
boolean negated = isNegated(rService); | ||
if (negated) { | ||
rService = rService.substring(1); | ||
} | ||
IBinder value = ServiceManager.getService(rService); | ||
boolean available = value != null; | ||
if (available == negated) { | ||
return UNSUPPORTED_ON_DEVICE; | ||
} | ||
return AVAILABLE; | ||
} | ||
|
||
} |
Oops, something went wrong.