Revert "settings: Add Ambient Customizations [2/2]"

This reverts commit b3d28a851f.
This commit is contained in:
elpaablo 2024-07-10 17:59:30 +02:00
parent 6549b3e360
commit 74ff3f63a1
5 changed files with 0 additions and 380 deletions

View file

@ -29,37 +29,6 @@
<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>
<!-- Status bar - Battery -->
<string-array name="status_bar_battery_style_entries" translatable="false">
<item>@string/status_bar_battery_style_icon_portrait</item>

View file

@ -40,36 +40,6 @@
<string name="statusbar_left_padding">Left padding</string>
<string name="statusbar_right_padding">Right padding</string>
<!-- Ambient Customization -->
<string name="default_string">Default</string>
<string name="ambient_text_category">Text customization</string>
<string name="ambient_image_category">Image customization</string>
<string name="ambient_text_category_title">Ambient customization</string>
<string name="ambient_text_category_summary">Customizing the looks of ambient display</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>
<!-- Quicksettings media category -->
<string name="media_category">Media player</string>

View file

@ -20,14 +20,6 @@
xmlns:lineage="http://schemas.android.com/apk/res-auto"
android:title="@string/lockscreen_title">
<!-- Ambient Display -->
<Preference
android:key="doze_fragment"
android:icon="@drawable/ic_ambient"
android:title="@string/doze_display_title"
android:summary="@string/doze_display_summary"
android:fragment="com.alpha.settings.fragments.lockscreen.doze.DozeSettings" />
<PreferenceCategory
android:key="lockscreen_clock_category"
android:title="@string/qs_clock_title">

View file

@ -1,94 +0,0 @@
<?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.alpha.settings.preferences.SystemSettingSwitchPreference
android:key="ambient_text"
android:title="@string/ambient_text_title"
android:summary="@string/ambient_text_summary"
android:defaultValue="false" />
<com.alpha.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.alpha.settings.preferences.SystemSettingEditTextPreference
android:key="ambient_text_string"
android:title="@string/ambient_text_string_title"
android:dependency="ambient_text"
android:defaultValue="#gtrcd" />
<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" />
<com.alpha.settings.preferences.colorpicker.ColorPickerPreference
android:key="ambient_text_color"
android:title="@string/ambient_text_color_title"
android:persistent="false"
android:defaultValue="0xFFFFFFFF" />
<com.alpha.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.alpha.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>

View file

@ -1,217 +0,0 @@
/**
* 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.alpha.settings.fragments.lockscreen.doze;
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.internal.util.crdroid.Utils;
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.alpha.settings.preferences.CustomSeekBarPreference;
import com.alpha.settings.preferences.SystemSettingListPreference;
import com.alpha.settings.preferences.SystemSettingEditTextPreference;
import com.alpha.settings.preferences.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_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 static final String IMAGE_PICKER = "com.android.gallery3d";
private SystemSettingEditTextPreference mAmbientText;
private ListPreference mAmbientTextAlign;
private ListPreference mAmbientTextTypeColor;
private ColorPickerPreference mAmbientTextColor;
private Preference mAmbientImage;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.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 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);
// disable file picker if gallery3d is not enabled
if (!Utils.isPackageEnabled(getContext(), IMAGE_PICKER)) {
mAmbientImage.setEnabled(false);
}
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference == mAmbientImage) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setPackage("com.android.gallery3d");
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 == 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.ALPHA;
}
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.ambient_customization;
result.add(sir);
return result;
}
@Override
public List<String> getNonIndexableKeys(Context context) {
List<String> keys = super.getNonIndexableKeys(context);
return keys;
}
};
}