Cherish: Pulse navbar audio gfx visualizer for Android 10 [3/4]
This commit is contained in:
@@ -588,4 +588,27 @@
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Pulse -->
|
||||
<string-array name="pulse_render_mode_entries">
|
||||
<item>@string/pulse_render_mode_fading_bars</item>
|
||||
<item>@string/pulse_render_mode_solid_lines</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pulse_render_mode_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pulse_color_mode_entries">
|
||||
<item>@string/pulse_color_accent</item>
|
||||
<item>@string/pulse_color_custom</item>
|
||||
<item>@string/pulse_color_lava_lamp</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pulse_color_mode_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -686,4 +686,34 @@
|
||||
<string name="lockscreen_tuner_title">Lockscreen bottom shortcuts</string>
|
||||
<string name="lockscreen_tuner_summary">Customize bottom left and right shortcuts</string>
|
||||
|
||||
<!-- Pulse -->
|
||||
<string name="pulse_help_policy_notice_summary">Pulse does not work with some audio sources when listening on device speaker</string>
|
||||
<string name="pulse_settings">Pulse</string>
|
||||
<string name="pulse_settings_summary">Navigation bar audio graphic equalizer</string>
|
||||
<string name="show_pulse_title">Show Pulse</string>
|
||||
<string name="show_pulse_summary">Audio graphic equalizer on the navigation bar</string>
|
||||
<string name="pulse_render_mode_title">Render mode</string>
|
||||
<string name="pulse_render_mode_fading_bars">Fading blocks</string>
|
||||
<string name="pulse_render_mode_solid_lines">Solid lines</string>
|
||||
<string name="pulse_color">Color</string>
|
||||
<string name="pulse_color_mode">Color mode</string>
|
||||
<string name="pulse_color_accent">Accent</string>
|
||||
<string name="pulse_color_custom">Custom</string>
|
||||
<string name="pulse_color_lava_lamp">Lava lamp</string>
|
||||
<string name="pulse_color_chooser">Choose color</string>
|
||||
<string name="smoothing_enabled_title">Turn on smoothing</string>
|
||||
<string name="smoothing_enabled_summary">Each bar is animated more smoothly</string>
|
||||
<string name="pulse_advanced_category">Advanced</string>
|
||||
<string name="pulse_legacy_mode_advanced_category">Fading blocks mode settings</string>
|
||||
<string name="pulse_custom_fudge_factor">Sanity level</string>
|
||||
<string name="lavamp_speed_title">Lava lamp speed</string>
|
||||
<string name="pulse_solid_units_count">Solid lines count</string>
|
||||
<string name="pulse_solid_lines_count">Solid lines count</string>
|
||||
<string name="pulse_solid_units_opacity">Solid lines opacity</string>
|
||||
<string name="pulse_solid_dimen_category">Solid lines mode settings</string>
|
||||
<string name="pulse_custom_dimen">Bar width</string>
|
||||
<string name="pulse_custom_div">Bar spacing</string>
|
||||
<string name="pulse_filled_block_size">Block size</string>
|
||||
<string name="pulse_empty_block_size">Block spacing</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -95,6 +95,13 @@
|
||||
android:icon="@drawable/ic_media"
|
||||
android:defaultValue="true" />
|
||||
|
||||
<Preference
|
||||
android:key="pulse"
|
||||
android:title="@string/pulse_settings"
|
||||
android:icon="@drawable/ic_visualizer"
|
||||
android:summary="@string/pulse_settings_summary"
|
||||
android:fragment="com.cherish.settings.fragments.PulseSettings" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
|
||||
android:key="lockscreen_media_blur"
|
||||
android:title="@string/lockscreen_media_blur_title"
|
||||
|
||||
144
res/xml/cherish_settings_pulse.xml
Normal file
144
res/xml/cherish_settings_pulse.xml
Normal file
@@ -0,0 +1,144 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2012-2014 The TeamEos 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"
|
||||
android:title="@string/pulse_settings" >
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="navbar_pulse_enabled"
|
||||
android:title="@string/show_pulse_title"
|
||||
android:summary="@string/show_pulse_summary"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingListPreference
|
||||
android:key="navbar_pulse_render_style"
|
||||
android:title="@string/pulse_render_mode_title"
|
||||
android:entries="@array/pulse_render_mode_entries"
|
||||
android:entryValues="@array/pulse_render_mode_values"
|
||||
android:defaultValue="0"
|
||||
android:dependency="navbar_pulse_enabled" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="pulse_smoothing_enabled"
|
||||
android:title="@string/smoothing_enabled_title"
|
||||
android:summary="@string/smoothing_enabled_summary"
|
||||
android:defaultValue="false"
|
||||
android:dependency="navbar_pulse_enabled" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="pulse_color_category"
|
||||
android:title="@string/pulse_color"
|
||||
android:dependency="navbar_pulse_enabled">
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingListPreference
|
||||
android:key="navbar_pulse_color_type"
|
||||
android:title="@string/pulse_color_mode"
|
||||
android:entries="@array/pulse_color_mode_entries"
|
||||
android:entryValues="@array/pulse_color_mode_values"
|
||||
android:defaultValue="1"/>
|
||||
|
||||
<com.cherish.settings.colorpicker.ColorPickerPreference
|
||||
android:key="navbar_pulse_color_user"
|
||||
android:title="@string/pulse_color_chooser"
|
||||
android:persistent="false" />
|
||||
|
||||
<com.cherish.settings.preferences.CustomSystemSeekBarPreference
|
||||
android:key="navbar_pulse_lavalamp_speed"
|
||||
android:title="@string/lavamp_speed_title"
|
||||
android:max="30000"
|
||||
android:defaultValue="10000"
|
||||
settings:min="200"
|
||||
settings:interval="200"
|
||||
settings:units="ms"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="pulse_fading_bars_category"
|
||||
android:title="@string/pulse_legacy_mode_advanced_category"
|
||||
android:dependency="navbar_pulse_enabled">
|
||||
|
||||
<com.cherish.settings.preferences.CustomSystemSeekBarPreference
|
||||
android:key="pulse_custom_dimen"
|
||||
android:title="@string/pulse_custom_dimen"
|
||||
android:max="30"
|
||||
android:defaultValue="14"
|
||||
settings:min="1"
|
||||
settings:units="dp"/>
|
||||
|
||||
<com.cherish.settings.preferences.CustomSystemSeekBarPreference
|
||||
android:key="pulse_custom_div"
|
||||
android:title="@string/pulse_custom_div"
|
||||
android:max="44"
|
||||
android:defaultValue="16"
|
||||
settings:min="2"
|
||||
settings:interval="2"
|
||||
settings:units="dp"/>
|
||||
|
||||
<com.cherish.settings.preferences.CustomSystemSeekBarPreference
|
||||
android:key="pulse_filled_block_size"
|
||||
android:title="@string/pulse_filled_block_size"
|
||||
android:max="8"
|
||||
android:defaultValue="4"
|
||||
settings:min="4"
|
||||
settings:units="dp"/>
|
||||
|
||||
<com.cherish.settings.preferences.CustomSystemSeekBarPreference
|
||||
android:key="pulse_empty_block_size"
|
||||
android:title="@string/pulse_empty_block_size"
|
||||
android:max="4"
|
||||
android:defaultValue="1"
|
||||
settings:min="0"
|
||||
settings:units="dp"/>
|
||||
|
||||
<com.cherish.settings.preferences.CustomSystemSeekBarPreference
|
||||
android:key="pulse_custom_fudge_factor"
|
||||
android:title="@string/pulse_custom_fudge_factor"
|
||||
android:max="6"
|
||||
android:defaultValue="4"
|
||||
settings:min="2"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="pulse_2"
|
||||
android:title="@string/pulse_solid_dimen_category"
|
||||
android:dependency="navbar_pulse_enabled">
|
||||
|
||||
<com.cherish.settings.preferences.CustomSystemSeekBarPreference
|
||||
android:key="pulse_solid_units_opacity"
|
||||
android:title="@string/pulse_solid_units_opacity"
|
||||
android:max="255"
|
||||
android:defaultValue="200"
|
||||
settings:min="0"/>
|
||||
|
||||
<com.cherish.settings.preferences.CustomSystemSeekBarPreference
|
||||
android:key="pulse_solid_units_count"
|
||||
android:title="@string/pulse_solid_units_count"
|
||||
android:max="128"
|
||||
android:defaultValue="64"
|
||||
settings:interval="16"
|
||||
settings:min="32"/>
|
||||
|
||||
<com.cherish.settings.preferences.CustomSystemSeekBarPreference
|
||||
android:key="pulse_solid_fudge_factor"
|
||||
android:title="@string/pulse_custom_fudge_factor"
|
||||
android:max="7"
|
||||
android:defaultValue="5"
|
||||
settings:min="2"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
154
src/com/cherish/settings/fragments/PulseSettings.java
Normal file
154
src/com/cherish/settings/fragments/PulseSettings.java
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Dirty Unicorns 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.cherish.settings.fragments;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
||||
import com.android.internal.util.cherish.CherishUtils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
|
||||
@SearchIndexable
|
||||
public class PulseSettings extends SettingsPreferenceFragment implements
|
||||
Preference.OnPreferenceChangeListener, Indexable {
|
||||
private static final String TAG = PulseSettings.class.getSimpleName();
|
||||
private static final String PULSE_COLOR_MODE_KEY = "navbar_pulse_color_type";
|
||||
private static final String PULSE_COLOR_MODE_CHOOSER_KEY = "navbar_pulse_color_user";
|
||||
private static final String PULSE_COLOR_MODE_LAVA_SPEED_KEY = "navbar_pulse_lavalamp_speed";
|
||||
private static final String PULSE_RENDER_CATEGORY_SOLID = "pulse_2";
|
||||
private static final String PULSE_RENDER_CATEGORY_FADING = "pulse_fading_bars_category";
|
||||
private static final String PULSE_RENDER_MODE_KEY = "navbar_pulse_render_style";
|
||||
private static final int RENDER_STYLE_FADING_BARS = 0;
|
||||
private static final int RENDER_STYLE_SOLID_LINES = 1;
|
||||
private static final int COLOR_TYPE_ACCENT = 0;
|
||||
private static final int COLOR_TYPE_USER = 1;
|
||||
private static final int COLOR_TYPE_LAVALAMP = 2;
|
||||
|
||||
private Preference mRenderMode;
|
||||
private ListPreference mColorModePref;
|
||||
private ColorPickerPreference mColorPickerPref;
|
||||
private Preference mLavaSpeedPref;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.cherish_settings_pulse);
|
||||
|
||||
mFooterPreferenceMixin.createFooterPreference()
|
||||
.setTitle(R.string.pulse_help_policy_notice_summary);
|
||||
|
||||
mColorModePref = (ListPreference) findPreference(PULSE_COLOR_MODE_KEY);
|
||||
mColorPickerPref = (ColorPickerPreference) findPreference(PULSE_COLOR_MODE_CHOOSER_KEY);
|
||||
mLavaSpeedPref = findPreference(PULSE_COLOR_MODE_LAVA_SPEED_KEY);
|
||||
mColorModePref.setOnPreferenceChangeListener(this);
|
||||
int colorMode = Settings.System.getIntForUser(getContentResolver(),
|
||||
Settings.System.PULSE_COLOR_TYPE, COLOR_TYPE_ACCENT, UserHandle.USER_CURRENT);
|
||||
mColorPickerPref.setDefaultValue(CherishUtils.getThemeAccentColor(getContext()));
|
||||
if (colorMode == COLOR_TYPE_ACCENT) {
|
||||
mColorPickerPref.setNewPreviewColor(CherishUtils.getThemeAccentColor(getContext()));
|
||||
}
|
||||
updateColorPrefs(colorMode);
|
||||
|
||||
mRenderMode = findPreference(PULSE_RENDER_MODE_KEY);
|
||||
mRenderMode.setOnPreferenceChangeListener(this);
|
||||
int renderMode = Settings.System.getIntForUser(getContentResolver(),
|
||||
Settings.System.PULSE_RENDER_STYLE_URI, 0, UserHandle.USER_CURRENT);
|
||||
updateRenderCategories(renderMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (preference.equals(mColorModePref)) {
|
||||
updateColorPrefs(Integer.valueOf(String.valueOf(newValue)));
|
||||
return true;
|
||||
} else if (preference.equals(mRenderMode)) {
|
||||
updateRenderCategories(Integer.valueOf(String.valueOf(newValue)));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateColorPrefs(int val) {
|
||||
switch (val) {
|
||||
case COLOR_TYPE_ACCENT:
|
||||
mColorPickerPref.setEnabled(false);
|
||||
mLavaSpeedPref.setEnabled(false);
|
||||
break;
|
||||
case COLOR_TYPE_USER:
|
||||
mColorPickerPref.setEnabled(true);
|
||||
mLavaSpeedPref.setEnabled(false);
|
||||
break;
|
||||
case COLOR_TYPE_LAVALAMP:
|
||||
mColorPickerPref.setEnabled(false);
|
||||
mLavaSpeedPref.setEnabled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRenderCategories(int mode) {
|
||||
PreferenceCategory fadingBarsCat = (PreferenceCategory) findPreference(
|
||||
PULSE_RENDER_CATEGORY_FADING);
|
||||
fadingBarsCat.setEnabled(mode == RENDER_STYLE_FADING_BARS);
|
||||
PreferenceCategory solidBarsCat = (PreferenceCategory) findPreference(
|
||||
PULSE_RENDER_CATEGORY_SOLID);
|
||||
solidBarsCat.setEnabled(mode == RENDER_STYLE_SOLID_LINES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||
}
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.cherish_settings_pulse;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
final List<String> keys = super.getNonIndexableKeys(context);
|
||||
return keys;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user