Skip to content

Commit

Permalink
shark: parts: Import from SharkParts
Browse files Browse the repository at this point in the history
Commits here: https://github.com/rtx4d/android_device_xiaomi_shark/commits/lineage-21-mi845/parts

shark: parts: Add built-in speaker tweaks config

shark: parts: Declare exported flags in manifest

shark: parts: Target current sdk

shark: parts: Migrate to CompoundButton.OnCheckedChangeListener

shark: parts: Enable use_resource_processor for all sysui deps

shark: parts: allow media and alarms in DND

shark: parts: clean up rear LED code

shark: parts: toggle DND with slider

shark: parts: Init SharkParts

Co-authored-by: Roman Rihter <[email protected]>
  • Loading branch information
rtx4d and tdrkDev committed Jun 24, 2024
1 parent 36b9e9c commit 25da148
Show file tree
Hide file tree
Showing 23 changed files with 1,404 additions and 1 deletion.
61 changes: 60 additions & 1 deletion parts/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015-2016 The CyanogenMod Project
2017-2021 The LineageOS Project
2017-2021, 2024 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.
Expand Down Expand Up @@ -42,6 +42,65 @@
</intent-filter>
</receiver>

<activity
android:name=".SharkParts"
android:label="@string/sharkparts_title"
android:exported="false">
<intent-filter>
<action android:name="com.android.settings.action.IA_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="com.android.settings.category"
android:value="com.android.settings.category.ia.system" />
<meta-data
android:name="com.android.settings.icon_tintable"
android:value="true" />
<meta-data
android:name="com.android.settings.icon"
android:resource="@drawable/sharkparts"/>
<meta-data
android:name="com.android.settings.summary"
android:resource="@string/sharkparts_summary" />
</activity>

<activity
android:name=".logo.LogoActivity"
android:label="@string/logo_control_title"
android:exported="true">

<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
</intent-filter>

<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />

</activity>

<activity
android:name=".speaker.SpeakerActivity"
android:label="@string/speaker_control_title">
</activity>

<service
android:exported="true"
android:name=".logo.QsService"
android:icon="@drawable/logo"
android:label="@string/logo_control_title"
android:foregroundServiceType="specialUse"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="tile" />
</service>

<activity android:name=".KeyHandler" />

<activity
android:name=".dirac.DiracActivity"
android:exported="false"
Expand Down
13 changes: 13 additions & 0 deletions parts/proguard.flags
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,16 @@
-keep class org.lineageos.settings.doze.* {
*;
}

-keep class org.lineageos.settings.logo.* {
*;
}

-keep class org.lineageos.settings.speaker.* {
*;
}

# Keep keyhandler constructor
-keep public class * implements com.android.internal.os.DeviceKeyHandler {
public <init>(android.content.Context);
}
10 changes: 10 additions & 0 deletions parts/res/drawable/logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="#000000"
android:pathData="M22.56 11.39C22.36 10.59 21.82 9.85 21.05 9.44L20.63 7.74C21.11 7.58 21.57 7.41 22 7.23V5C20 6.07 16.53 7.03 12 7.03S4 6.07 2 5V7.23C2.43 7.41 2.89 7.58 3.37 7.74L2.95 9.44C2.18 9.85 1.64 10.59 1.44 11.39C.905 13.57 .385 17.31 2.92 17.93C4 18.2 6 17.89 7.27 12.82C7.46 12 7.33 11.12 6.84 10.39L7.26 8.67C8.14 8.81 9.05 8.9 10 8.96V10.74C9.35 11.33 9 12.17 9 13C9 15.24 9.39 19 12 19C13.12 19 15 18.22 15 13C15 12.17 14.65 11.33 14 10.74V8.96C14.95 8.9 15.86 8.81 16.74 8.67L17.16 10.39C16.67 11.12 16.54 12 16.73 12.82C18 17.89 20 18.2 21.08 17.93C23.61 17.31 23.09 13.57 22.56 11.39M5.81 12.47C5.81 12.47 4.74 16.84 3.28 16.5C1.82 16.12 2.9 11.75 2.9 11.75S3.26 10.29 4.71 10.65 5.81 12.47 5.81 12.47M12 17.5C10.5 17.5 10.5 13 10.5 13S10.5 11.5 12 11.5 13.5 13 13.5 13 13.5 17.5 12 17.5M20.72 16.5C19.27 16.84 18.19 12.47 18.19 12.47S17.83 11 19.29 10.65 21.1 11.75 21.1 11.75 22.18 16.12 20.72 16.5Z"/>
</vector>
10 changes: 10 additions & 0 deletions parts/res/drawable/sharkparts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="#000"
android:pathData="M280,920Q247,920 223.5,896.5Q200,873 200,840L200,120Q200,87 223.5,63.5Q247,40 280,40L680,40Q713,40 736.5,63.5Q760,87 760,120L760,280L680,280L680,240L280,240L280,720L680,720L680,680L760,680L760,840Q760,873 736.5,896.5Q713,920 680,920L280,920ZM280,800L280,840Q280,840 280,840Q280,840 280,840L680,840Q680,840 680,840Q680,840 680,840L680,800L280,800ZM680,640L674,590Q666,587 660,583.5Q654,580 648,574L602,594L562,524L602,494Q600,486 600,479Q600,472 602,464L562,434L604,366L648,384Q654,379 660,376Q666,373 674,370L680,320L760,320L766,370Q774,373 780,376Q786,379 792,384L836,366L878,434L838,464Q840,472 840,479Q840,486 838,494L878,524L838,594L792,574Q786,580 780,583.5Q774,587 766,590L760,640L680,640ZM720,540Q746,540 763,523Q780,506 780,480Q780,454 763,437Q746,420 720,420Q694,420 677,437Q660,454 660,480Q660,506 677,523Q694,540 720,540ZM280,160L680,160L680,120Q680,120 680,120Q680,120 680,120L280,120Q280,120 280,120Q280,120 280,120L280,160ZM280,160L280,120Q280,120 280,120Q280,120 280,120L280,120Q280,120 280,120Q280,120 280,120L280,160L280,160ZM280,800L280,800L280,840Q280,840 280,840Q280,840 280,840L280,840Q280,840 280,840Q280,840 280,840L280,800Z"/>
</vector>
11 changes: 11 additions & 0 deletions parts/res/drawable/speaker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal"
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
android:pathData="M560,829L560,747Q650,721 705,647Q760,573 760,479Q760,385 705,311Q650,237 560,211L560,129Q684,157 762,254.5Q840,352 840,479Q840,606 762,703.5Q684,801 560,829ZM120,600L120,360L280,360L480,160L480,800L280,600L120,600ZM560,640L560,318Q607,340 633.5,384Q660,428 660,480Q660,531 633.5,574.5Q607,618 560,640ZM400,354L314,440L200,440L200,520L314,520L400,606L400,354ZM300,480L300,480L300,480L300,480L300,480L300,480L300,480Z"/>
</vector>
22 changes: 22 additions & 0 deletions parts/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,26 @@
<item>"0,4,2,0,-2,-2,4"</item>
<item>"2,0,0,-2,-4,0,0"</item>
</string-array>

<string-array name="logo_control_mode_entries" translatable="false">
<item>@string/logo_control_breath_title</item>
<item>@string/logo_control_manual_title</item>
</string-array>

<string-array name="logo_control_mode_values" translatable="false">
<item>1</item>
<item>2</item>
</string-array>

<string-array name="speaker_control_gamemode_entries" translatable="false">
<item>@string/speaker_control_gamemode_0</item>
<item>@string/speaker_control_gamemode_1</item>
<item>@string/speaker_control_gamemode_2</item>
</string-array>

<string-array name="speaker_control_gamemode_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
</resources>
31 changes: 31 additions & 0 deletions parts/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,37 @@
<string name="dirac_preset_dance">Dance</string>
<string name="dirac_preset_metal">Metal</string>

<!-- Settings name -->
<string name="sharkparts_title">Black Shark settings</string>
<string name="sharkparts_summary">Additional device specific tweaks</string>

<!-- S Logo -->
<string name="logo_control_title">Rear LED</string>
<string name="logo_control_mode_title">Mode</string>
<string name="logo_control_enable_title">Enabled</string>
<string name="logo_control_summary">Change the behaviour of rear LED logo</string>
<string name="logo_control_breath_title">Breathing RGB</string>
<string name="logo_control_manual_title">Manual</string>
<string name="logo_control_intensity_title_red">Red</string>
<string name="logo_control_intensity_title_green">Green</string>
<string name="logo_control_intensity_title_blue">Blue</string>

<!-- Speaker -->
<string name="speaker_control_title">Speaker tweaks</string>
<string name="speaker_control_summary">Enable built-in EQ or game mode</string>
<string name="speaker_control_enable_title">Enabled</string>
<string name="speaker_control_eq_title">Equalizer</string>
<string name="speaker_control_eq_band_0">256 Hz</string>
<string name="speaker_control_eq_band_1">512 Hz</string>
<string name="speaker_control_eq_band_2">1024 Hz</string>
<string name="speaker_control_eq_band_3">2048 Hz</string>
<string name="speaker_control_eq_band_4">4096 Hz</string>
<string name="speaker_control_gamemode_title">Game mode</string>
<string name="speaker_control_gamemode_0">Disabled</string>
<string name="speaker_control_gamemode_1">Default</string>
<string name="speaker_control_gamemode_2">Shooter</string>
<string name="speaker_control_footer">If game mode is enabled, EQ will not be working. To apply changes immediately, you can restart playback, if something was playing.</string>

<!-- Thermal profiles -->
<string name="thermal_title">Thermal profiles</string>
<string name="thermal_summary">Adjust per-app thermal profiles for optimum performance</string>
Expand Down
52 changes: 52 additions & 0 deletions parts/res/xml/logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2020 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:title="@string/logo_control_title">

<com.android.settingslib.widget.MainSwitchPreference
android:defaultValue="false"
android:key="logo_control_enable"
android:title="@string/logo_control_enable_title" />

<ListPreference
android:key="logo_control_mode"
android:title="@string/logo_control_mode_title"
android:entries="@array/logo_control_mode_entries"
android:entryValues="@array/logo_control_mode_values"
android:dependency="logo_control_enable" />

<SeekBarPreference
android:key="logo_control_manual_red"
android:title="@string/logo_control_intensity_title_red"
android:min="0"
android:max="255"
android:persistent="false"
android:dependency="logo_control_enable" />
<SeekBarPreference
android:key="logo_control_manual_green"
android:title="@string/logo_control_intensity_title_green"
android:min="0"
android:max="255"
android:persistent="false"
android:dependency="logo_control_enable" />
<SeekBarPreference
android:key="logo_control_manual_blue"
android:title="@string/logo_control_intensity_title_blue"
android:min="0"
android:max="255"
android:persistent="false"
android:dependency="logo_control_enable" />

</PreferenceScreen>
34 changes: 34 additions & 0 deletions parts/res/xml/sharkparts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">

<PreferenceScreen
android:key="logo"
android:fragment="org.lineageos.settings.device.logo.LogoActivity"
android:icon="@drawable/logo"
android:summary="@string/logo_control_summary"
android:title="@string/logo_control_title" />

<PreferenceScreen
android:key="speaker"
android:fragment="org.lineageos.settings.device.speaker.SpeakerActivity"
android:icon="@drawable/speaker"
android:summary="@string/speaker_control_summary"
android:title="@string/speaker_control_title" />
</PreferenceScreen>
17 changes: 17 additions & 0 deletions parts/res/xml/shortcuts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:enabled="true"
android:icon="@drawable/logo"
android:shortcutId="shortcuts_switch"
android:shortcutDisabledMessage="@string/logo_control_title"
android:shortcutLongLabel="@string/logo_control_title"
android:shortcutShortLabel="@string/logo_control_title">

<intent
android:action="android.intent.action.VIEW"
android:targetClass="org.lineageos.settings.device.logo.QsActivity"
android:targetPackage="org.lineageos.settings.device" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
</shortcuts>
94 changes: 94 additions & 0 deletions parts/res/xml/speaker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2020 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:title="@string/speaker_control_title">

<com.android.settingslib.widget.MainSwitchPreference
android:defaultValue="false"
android:key="speaker_tweaks_enable"
android:title="@string/speaker_control_enable_title" />

<PreferenceCategory
android:title="@string/speaker_control_gamemode_title">

<ListPreference
android:key="speaker_gamemode_val"
android:title="@string/speaker_control_gamemode_title"
android:entries="@array/speaker_control_gamemode_entries"
android:entryValues="@array/speaker_control_gamemode_values"
android:dependency="speaker_tweaks_enable" />

</PreferenceCategory>

<PreferenceCategory
android:title="@string/speaker_control_eq_title">

<SeekBarPreference
android:key="speaker_control_eq_band_0"
android:title="@string/speaker_control_eq_band_0"
android:defaultValue="3"
android:min="0"
android:max="6"
android:persistent="false"
android:dependency="speaker_tweaks_enable" />

<SeekBarPreference
android:key="speaker_control_eq_band_1"
android:title="@string/speaker_control_eq_band_1"
android:defaultValue="3"
android:min="0"
android:max="6"
android:persistent="false"
android:dependency="speaker_tweaks_enable" />

<SeekBarPreference
android:key="speaker_control_eq_band_2"
android:title="@string/speaker_control_eq_band_2"
android:defaultValue="3"
android:min="0"
android:max="6"
android:persistent="false"
android:dependency="speaker_tweaks_enable" />

<SeekBarPreference
android:key="speaker_control_eq_band_3"
android:title="@string/speaker_control_eq_band_3"
android:defaultValue="3"
android:min="0"
android:max="6"
android:persistent="false"
android:dependency="speaker_tweaks_enable" />

<SeekBarPreference
android:key="speaker_control_eq_band_4"
android:title="@string/speaker_control_eq_band_4"
android:defaultValue="3"
android:min="0"
android:max="6"
android:persistent="false"
android:dependency="speaker_tweaks_enable" />

<com.android.settingslib.widget.FooterPreference
android:key="speaker_control_footer"
android:title="@string/speaker_control_footer"
android:dependency="speaker_tweaks_enable"/>

</PreferenceCategory>

</PreferenceScreen>
Loading

0 comments on commit 25da148

Please sign in to comment.