Cherish: Add Ambient Customizations [2/2]
Co-authored-by: TikkiTikki <radstylemusic@gmail.com> Co-authored-by: SuperDroidBond <superdroidbond@yahoo.com> Signed-off-by: SuperDroidBond <superdroidbond@yahoo.com> Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -606,4 +606,114 @@
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Ambient Text Alignment -->
|
||||
<string-array name="ambient_text_alignment_entries" translatable="false">
|
||||
<item>@string/ambient_text_align_start_top</item>
|
||||
<item>@string/ambient_text_align_start_center</item>
|
||||
<!--item>@string/ambient_text_align_start_bottom</item-->
|
||||
<item>@string/ambient_text_align_center</item>
|
||||
<item>@string/ambient_text_align_end_top</item>
|
||||
<item>@string/ambient_text_align_end_center</item>
|
||||
<!--item>@string/ambient_text_align_end_bottom</item-->
|
||||
</string-array>
|
||||
<string-array name="ambient_text_alignment_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<!--item>2</item-->
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<!--item>6</item-->
|
||||
</string-array>
|
||||
|
||||
<string-array name="ambient_text_type_color_entries" translatable="false">
|
||||
<item>@string/ambient_notification_light_color_mode_accent</item>
|
||||
<item>@string/ambient_notification_light_color_mode_wall</item>
|
||||
<item>@string/ambient_notification_light_color_mode_custom</item>
|
||||
</string-array>
|
||||
<string-array name="ambient_text_type_color_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Lock Clock Fonts -->
|
||||
<string-array name="lock_clock_fonts_entries">
|
||||
<item>@string/lock_clock_font_stock</item>
|
||||
<item>@string/lock_clock_font_italic</item>
|
||||
<item>@string/lock_clock_font_bold</item>
|
||||
<item>@string/lock_clock_font_bold_italic</item>
|
||||
<item>@string/lock_clock_font_light_italic</item>
|
||||
<item>@string/lock_clock_font_light</item>
|
||||
<item>@string/lock_clock_font_thin_italic</item>
|
||||
<item>@string/lock_clock_font_thin</item>
|
||||
<item>@string/lock_clock_font_condensed_normal</item>
|
||||
<item>@string/lock_clock_font_condensed_italic</item>
|
||||
<item>@string/lock_clock_font_condensed_bold</item>
|
||||
<item>@string/lock_clock_font_condensed_bold_italic</item>
|
||||
<item>@string/lock_clock_font_condensed_light</item>
|
||||
<item>@string/lock_clock_font_condensed_light_italic</item>
|
||||
<item>@string/lock_clock_font_medium_normal</item>
|
||||
<item>@string/lock_clock_font_medium_italic</item>
|
||||
<item>@string/lock_clock_font_black</item>
|
||||
<item>@string/lock_clock_font_black_italic</item>
|
||||
<item>@string/lock_clock_font_dancingscript</item>
|
||||
<item>@string/lock_clock_font_dancingscript_bold</item>
|
||||
<item>@string/lock_clock_font_comingsoon</item>
|
||||
<item>@string/lock_clock_font_notoserif</item>
|
||||
<item>@string/lock_clock_font_notoserif_italic</item>
|
||||
<item>@string/lock_clock_font_notoserif_bold</item>
|
||||
<item>@string/lock_clock_font_notoserif_bold_italic</item>
|
||||
<item>@string/lock_clock_font_gobold</item>
|
||||
<item>@string/lock_clock_font_roadrage</item>
|
||||
<item>@string/lock_clock_font_snowstorm</item>
|
||||
<item>@string/lock_clock_font_googlesans</item>
|
||||
<item>@string/lock_clock_font_neoneon</item>
|
||||
<item>@string/lock_clock_font_themeable</item>
|
||||
<item>@string/lock_clock_font_samsung</item>
|
||||
<item>@string/lock_clock_font_mexcellent</item>
|
||||
<item>@string/lock_clock_font_burnstown</item>
|
||||
<item>@string/lock_clock_font_dumbledor</item>
|
||||
<item>@string/lock_clock_font_phantombold</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="lock_clock_fonts_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<item>6</item>
|
||||
<item>7</item>
|
||||
<item>8</item>
|
||||
<item>9</item>
|
||||
<item>10</item>
|
||||
<item>11</item>
|
||||
<item>12</item>
|
||||
<item>13</item>
|
||||
<item>14</item>
|
||||
<item>15</item>
|
||||
<item>16</item>
|
||||
<item>17</item>
|
||||
<item>18</item>
|
||||
<item>19</item>
|
||||
<item>20</item>
|
||||
<item>21</item>
|
||||
<item>22</item>
|
||||
<item>23</item>
|
||||
<item>24</item>
|
||||
<item>25</item>
|
||||
<item>26</item>
|
||||
<item>27</item>
|
||||
<item>28</item>
|
||||
<item>29</item>
|
||||
<item>30</item>
|
||||
<item>31</item>
|
||||
<item>32</item>
|
||||
<item>33</item>
|
||||
<item>34</item>
|
||||
<item>35</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -806,4 +806,73 @@
|
||||
<string name="pulse_light_both">All Four Sides</string>
|
||||
<string name="pulse_light_top_bottom">Only Top-Bottom</string>
|
||||
<string name="pulse_light_left_right">Only Left-Right</string>
|
||||
|
||||
<!-- Ambient Customization -->
|
||||
<string name="ambient_text_category">Text Customization</string>
|
||||
<string name="ambient_image_category">Image Customization</string>
|
||||
<string name="ambient_text_category_title">Ambient-AOD Customization</string>
|
||||
<string name="ambient_text_category_summary">Customizing the looks of ambient-aod</string>
|
||||
<string name="ambient_text_title">Ambient Text</string>
|
||||
<string name="ambient_text_summary">Show Ambient Text in AoD</string>
|
||||
<string name="ambient_text_animation_title">Ambient Text Animation</string>
|
||||
<string name="ambient_text_animation_summary">Show a Animation when show AoD</string>
|
||||
<string name="ambient_text_size_title">Ambient Text Size</string>
|
||||
<string name="ambient_text_font_title">Ambient Text Font</string>
|
||||
<string name="ambient_text_string_title">Set Ambient Text</string>
|
||||
<string name="ambient_text_align_title">Ambient Text Align</string>
|
||||
<string name="ambient_text_align_start_top">Right n Top</string>
|
||||
<string name="ambient_text_align_start_center">Right n Center</string>
|
||||
<string name="ambient_text_align_start_bottom">Right n Bottom</string>
|
||||
<string name="ambient_text_align_center">Center</string>
|
||||
<string name="ambient_text_align_end_top">Left n Top</string>
|
||||
<string name="ambient_text_align_end_center">Left n Center</string>
|
||||
<string name="ambient_text_align_end_bottom">Left n Bottom</string>
|
||||
<string name="ambient_text_type_color_title">Ambient Text Type Color</string>
|
||||
<string name="ambient_text_color_title">Ambient Text Color</string>
|
||||
<string name="ambient_notification_light_color_mode_accent">System accent color</string>
|
||||
<string name="ambient_notification_light_color_mode_custom">Custom color</string>
|
||||
<string name="ambient_notification_light_color_mode_wall">Wallpaper color</string>
|
||||
<string name="ambient_image_title">Ambient Image</string>
|
||||
<string name="file_header_select_title">Select local image</string>
|
||||
<string name="file_header_select_summary">Select image from storage</string>
|
||||
|
||||
<!-- Lock Clock Fonts -->
|
||||
<string name="lock_clock_font_title">LS Clock font style</string>
|
||||
<string name="lock_clock_font_dialog_title">Select lockscreen clock font</string>
|
||||
<string name="lock_clock_font_stock">Normal (default)</string>
|
||||
<string name="lock_clock_font_bold">Bold</string>
|
||||
<string name="lock_clock_font_italic">Italic</string>
|
||||
<string name="lock_clock_font_bold_italic">Bold Italic</string>
|
||||
<string name="lock_clock_font_light_italic">Light Italic</string>
|
||||
<string name="lock_clock_font_thin_italic">Thin Italic</string>
|
||||
<string name="lock_clock_font_light">Light</string>
|
||||
<string name="lock_clock_font_thin">Thin</string>
|
||||
<string name="lock_clock_font_condensed_normal">Condensed</string>
|
||||
<string name="lock_clock_font_condensed_italic">Condensed Italic</string>
|
||||
<string name="lock_clock_font_condensed_bold">Condensed Bold</string>
|
||||
<string name="lock_clock_font_condensed_bold_italic">Condensed Bold Italic</string>
|
||||
<string name="lock_clock_font_condensed_light">Condensed Light</string>
|
||||
<string name="lock_clock_font_condensed_light_italic">Condensed Light Italic</string>
|
||||
<string name="lock_clock_font_medium_normal">Medium</string>
|
||||
<string name="lock_clock_font_medium_italic">Medium Italic</string>
|
||||
<string name="lock_clock_font_black">Black</string>
|
||||
<string name="lock_clock_font_black_italic">Black Italic</string>
|
||||
<string name="lock_clock_font_dancingscript">DancingScript</string>
|
||||
<string name="lock_clock_font_dancingscript_bold">DancingScript Bold</string>
|
||||
<string name="lock_clock_font_comingsoon">ComingSoon</string>
|
||||
<string name="lock_clock_font_notoserif">NotoSerif Normal</string>
|
||||
<string name="lock_clock_font_notoserif_italic">NotoSerif Italic</string>
|
||||
<string name="lock_clock_font_notoserif_bold">NotoSerif Bold</string>
|
||||
<string name="lock_clock_font_notoserif_bold_italic">NotoSerif Bold Italic</string>
|
||||
<string name="lock_clock_font_gobold">GoBold Light</string>
|
||||
<string name="lock_clock_font_roadrage">Road Rage</string>
|
||||
<string name="lock_clock_font_snowstorm">Snowstorm</string>
|
||||
<string name="lock_clock_font_googlesans">Google Sans</string>
|
||||
<string name="lock_clock_font_neoneon">Neoneon</string>
|
||||
<string name="lock_clock_font_themeable">Themeable (or VCR OSD Mono)</string>
|
||||
<string name="lock_clock_font_samsung">Shamshung</string>
|
||||
<string name="lock_clock_font_mexcellent">Mexcellent</string>
|
||||
<string name="lock_clock_font_burnstown">Burnstown</string>
|
||||
<string name="lock_clock_font_dumbledor">Dumbledor</string>
|
||||
<string name="lock_clock_font_phantombold">PhantomBold</string>
|
||||
</resources>
|
||||
|
||||
105
res/xml/cherish_ambient_customization.xml
Normal file
105
res/xml/cherish_ambient_customization.xml
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2017 - 2021 The Project-Xtended
|
||||
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/ambient_text_category_title">
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/ambient_text_category" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="ambient_text"
|
||||
android:title="@string/ambient_text_title"
|
||||
android:summary="@string/ambient_text_summary"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="ambient_text_animation"
|
||||
android:title="@string/ambient_text_animation_title"
|
||||
android:summary="@string/ambient_text_animation_summary"
|
||||
android:dependency="ambient_text"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingEditTextPreference
|
||||
android:key="ambient_text_string"
|
||||
android:title="@string/ambient_text_string_title"
|
||||
android:dependency="ambient_text"
|
||||
android:defaultValue="#Welcome To Cherish" />
|
||||
|
||||
<ListPreference
|
||||
android:key="ambient_text_font"
|
||||
android:title="@string/ambient_text_font_title"
|
||||
android:dialogTitle="@string/ambient_text_font_title"
|
||||
android:entries="@array/lock_clock_fonts_entries"
|
||||
android:entryValues="@array/lock_clock_fonts_values"
|
||||
android:summary="%s"
|
||||
android:defaultValue="8"
|
||||
android:dependency="ambient_text"
|
||||
android:persistent="false" />
|
||||
|
||||
<ListPreference
|
||||
android:key="ambient_text_type_color"
|
||||
android:title="@string/ambient_text_type_color_title"
|
||||
android:dialogTitle="@string/ambient_text_type_color_title"
|
||||
android:entries="@array/ambient_text_type_color_entries"
|
||||
android:entryValues="@array/ambient_text_type_color_values"
|
||||
android:summary="%s"
|
||||
android:defaultValue="0"
|
||||
android:dependency="ambient_text"
|
||||
android:persistent="false" />
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="ambient_text_color"
|
||||
android:title="@string/ambient_text_color_title"
|
||||
android:persistent="false"
|
||||
settings:defaultColorValue="0xFF880000" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
|
||||
android:key="ambient_text_size"
|
||||
android:title="@string/ambient_text_size_title"
|
||||
android:max="100"
|
||||
android:min="1"
|
||||
android:dependency="ambient_text"
|
||||
settings:units="dp"
|
||||
android:defaultValue="30" />
|
||||
|
||||
<ListPreference
|
||||
android:key="ambient_text_alignment"
|
||||
android:title="@string/ambient_text_align_title"
|
||||
android:summary="%s"
|
||||
android:dialogTitle="@string/ambient_text_align_title"
|
||||
android:entries="@array/ambient_text_alignment_entries"
|
||||
android:entryValues="@array/ambient_text_alignment_values"
|
||||
android:defaultValue="3"
|
||||
android:dependency="ambient_text"
|
||||
android:persistent="false" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/ambient_image_category" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="ambient_image"
|
||||
android:title="@string/ambient_image_title"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<Preference
|
||||
android:key="file_ambient_select"
|
||||
android:title="@string/file_header_select_title"
|
||||
android:summary="@string/file_header_select_summary"
|
||||
android:persistent="false"
|
||||
android:dependency="ambient_image" >
|
||||
</Preference>
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -116,6 +116,12 @@
|
||||
android:summary="%s"
|
||||
android:defaultValue="0" />
|
||||
|
||||
<Preference
|
||||
android:key="ambient_customization"
|
||||
android:title="@string/ambient_text_category_title"
|
||||
android:summary="@string/ambient_text_category_summary"
|
||||
android:fragment="com.cherish.settings.fragments.AmbientCustomizations" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
|
||||
225
src/com/cherish/settings/fragments/AmbientCustomizations.java
Normal file
225
src/com/cherish/settings/fragments/AmbientCustomizations.java
Normal file
@@ -0,0 +1,225 @@
|
||||
/**
|
||||
* Copyright (C) 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.
|
||||
*/
|
||||
package com.cherish.settings.fragments;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.ContentResolver;
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.preference.SwitchPreference;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.cherish.settings.preferences.CustomSeekBarPreference;
|
||||
import com.cherish.settings.preferences.SystemSettingListPreference;
|
||||
import com.cherish.settings.preferences.SystemSettingEditTextPreference;
|
||||
import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class AmbientCustomizations extends SettingsPreferenceFragment implements
|
||||
Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String AMBIENT_TEXT_STRING = "ambient_text_string";
|
||||
private static final String AMBIENT_TEXT_ALIGNMENT = "ambient_text_alignment";
|
||||
private static final String AMBIENT_TEXT_FONT = "ambient_text_font";
|
||||
private static final String AMBIENT_TEXT_TYPE_COLOR = "ambient_text_type_color";
|
||||
private static final String AMBIENT_TEXT_COLOR = "ambient_text_color";
|
||||
private static final String FILE_AMBIENT_SELECT = "file_ambient_select";
|
||||
|
||||
private static final int REQUEST_PICK_IMAGE = 0;
|
||||
|
||||
private SystemSettingEditTextPreference mAmbientText;
|
||||
private ListPreference mAmbientTextAlign;
|
||||
private ListPreference mAmbientTextFonts;
|
||||
private ListPreference mAmbientTextTypeColor;
|
||||
private ColorPickerPreference mAmbientTextColor;
|
||||
|
||||
private Preference mAmbientImage;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
addPreferencesFromResource(R.xml.cherish_ambient_customization);
|
||||
final PreferenceScreen prefScreen = getPreferenceScreen();
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
Resources resources = getResources();
|
||||
|
||||
// set ambient text alignment
|
||||
mAmbientTextAlign = (ListPreference) findPreference(AMBIENT_TEXT_ALIGNMENT);
|
||||
int align = Settings.System.getInt(resolver,
|
||||
Settings.System.AMBIENT_TEXT_ALIGNMENT, 3);
|
||||
mAmbientTextAlign.setValue(String.valueOf(align));
|
||||
mAmbientTextAlign.setSummary(mAmbientTextAlign.getEntry());
|
||||
mAmbientTextAlign.setOnPreferenceChangeListener(this);
|
||||
|
||||
// ambient text Fonts
|
||||
mAmbientTextFonts = (ListPreference) findPreference(AMBIENT_TEXT_FONT);
|
||||
mAmbientTextFonts.setValue(String.valueOf(Settings.System.getInt(
|
||||
getContentResolver(), Settings.System.AMBIENT_TEXT_FONT, 8)));
|
||||
mAmbientTextFonts.setSummary(mAmbientTextFonts.getEntry());
|
||||
mAmbientTextFonts.setOnPreferenceChangeListener(this);
|
||||
|
||||
// ambient text color type
|
||||
mAmbientTextTypeColor = (ListPreference) findPreference(AMBIENT_TEXT_TYPE_COLOR);
|
||||
mAmbientTextTypeColor.setValue(String.valueOf(Settings.System.getInt(
|
||||
getContentResolver(), Settings.System.AMBIENT_TEXT_TYPE_COLOR, 0)));
|
||||
mAmbientTextTypeColor.setSummary(mAmbientTextTypeColor.getEntry());
|
||||
mAmbientTextTypeColor.setOnPreferenceChangeListener(this);
|
||||
|
||||
mAmbientTextColor = (ColorPickerPreference) findPreference(AMBIENT_TEXT_COLOR);
|
||||
mAmbientTextColor.setOnPreferenceChangeListener(this);
|
||||
int ambientTextColor = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.AMBIENT_TEXT_COLOR, 0xFF3980FF);
|
||||
String ambientTextColorHex = String.format("#%08x", (0xFF3980FF & ambientTextColor));
|
||||
if (ambientTextColorHex.equals("#ff3980ff")) {
|
||||
mAmbientTextColor.setSummary(R.string.default_string);
|
||||
} else {
|
||||
mAmbientTextColor.setSummary(ambientTextColorHex);
|
||||
}
|
||||
mAmbientTextColor.setNewPreviewColor(ambientTextColor);
|
||||
|
||||
mAmbientImage = findPreference(FILE_AMBIENT_SELECT);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
if (preference == mAmbientImage) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK);
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(intent, REQUEST_PICK_IMAGE);
|
||||
return true;
|
||||
}
|
||||
return super.onPreferenceTreeClick(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
if (preference == mAmbientText) {
|
||||
String value = (String) newValue;
|
||||
Settings.System.putString(resolver,
|
||||
Settings.System.AMBIENT_TEXT_STRING, value);
|
||||
return true;
|
||||
} else if (preference == mAmbientTextAlign) {
|
||||
int align = Integer.valueOf((String) newValue);
|
||||
int index = mAmbientTextAlign.findIndexOfValue((String) newValue);
|
||||
Settings.System.putInt(getActivity().getContentResolver(),
|
||||
Settings.System.AMBIENT_TEXT_ALIGNMENT, align);
|
||||
mAmbientTextAlign.setSummary(mAmbientTextAlign.getEntries()[index]);
|
||||
return true;
|
||||
} else if (preference == mAmbientTextFonts) {
|
||||
Settings.System.putInt(getContentResolver(), Settings.System.AMBIENT_TEXT_FONT,
|
||||
Integer.valueOf((String) newValue));
|
||||
mAmbientTextFonts.setValue(String.valueOf(newValue));
|
||||
mAmbientTextFonts.setSummary(mAmbientTextFonts.getEntry());
|
||||
return true;
|
||||
} else if (preference == mAmbientTextTypeColor) {
|
||||
int value = Integer.valueOf((String) newValue);
|
||||
int vIndex = mAmbientTextTypeColor.findIndexOfValue((String) newValue);
|
||||
mAmbientTextTypeColor.setSummary(mAmbientTextTypeColor.getEntries()[vIndex]);
|
||||
Settings.System.putInt(getActivity().getContentResolver(),
|
||||
Settings.System.AMBIENT_TEXT_TYPE_COLOR, value);
|
||||
if (value == 2) {
|
||||
mAmbientTextColor.setEnabled(true);
|
||||
} else {
|
||||
mAmbientTextColor.setEnabled(false);
|
||||
}
|
||||
return true;
|
||||
} else if (preference == mAmbientTextColor) {
|
||||
String hex = ColorPickerPreference.convertToARGB(
|
||||
Integer.valueOf(String.valueOf(newValue)));
|
||||
if (hex.equals("#ff3980ff")) {
|
||||
preference.setSummary(R.string.default_string);
|
||||
} else {
|
||||
preference.setSummary(hex);
|
||||
}
|
||||
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.AMBIENT_TEXT_COLOR, intHex);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent result) {
|
||||
if (requestCode == REQUEST_PICK_IMAGE) {
|
||||
if (resultCode != Activity.RESULT_OK) {
|
||||
return;
|
||||
}
|
||||
final Uri imageUri = result.getData();
|
||||
Settings.System.putString(getContentResolver(), Settings.System.AMBIENT_CUSTOM_IMAGE, imageUri.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
ArrayList<SearchIndexableResource> result =
|
||||
new ArrayList<SearchIndexableResource>();
|
||||
SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.cherish_ambient_customization;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
List<String> keys = super.getNonIndexableKeys(context);
|
||||
return keys;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user