Evolver: Add various Lock/Unlock sounds [2/2]

Signed-off-by: AnierinB <anierin@evolution-x.org>
This commit is contained in:
AnierinB
2024-09-05 02:37:23 +00:00
committed by Joey Huab
parent b27961e568
commit 4e4f6ea45e
5 changed files with 166 additions and 0 deletions

View File

@@ -52,6 +52,79 @@
<item>preset</item>
</string-array>
<!-- Themes - Lock/Unlock Sounds -->
<string-array name="themes_lock_unlock_sounds_entries" translatable="false">
<item>Default</item>
<item>Amazon Fire</item>
<item>Asus Zenfone Max</item>
<item>Essential PH-1</item>
<item>HTC M8</item>
<item>Huawei</item>
<item>Hyper OS</item>
<item>Iqoo</item>
<item>LG G3</item>
<item>Minecraft door</item>
<item>MIUI 10</item>
<item>MIUI 11</item>
<item>Nextbit</item>
<item>Nokia X</item>
<item>Old School IOS</item>
<item>One UI</item>
<item>OOS 14</item>
<item>Razer Phone</item>
<item>Soong</item>
<item>Windows Device</item>
<item>Windows Error</item>
</string-array>
<string-array name="themes_lock_sounds_values" translatable="false">
<item>/product/media/audio/ui/Lock.ogg</item>
<item>/product/media/audio/ui/Amazon_Fire_Lock.ogg</item>
<item>/product/media/audio/ui/Asus_Zenfone_Max_Lock.ogg</item>
<item>/product/media/audio/ui/Essential_PH-1_Lock.ogg</item>
<item>/product/media/audio/ui/HTC_M8_Lock.ogg</item>
<item>/product/media/audio/ui/Huawei_Lock.ogg</item>
<item>/product/media/audio/ui/Hyper_OS_Lock.ogg</item>
<item>/product/media/audio/ui/Iqoo_Lock.ogg</item>
<item>/product/media/audio/ui/LG_G3_Lock.ogg</item>
<item>/product/media/audio/ui/Minecraft_Door_Lock.ogg</item>
<item>/product/media/audio/ui/MIUI_10_Lock.ogg</item>
<item>/product/media/audio/ui/MIUI_11_Lock.ogg</item>
<item>/product/media/audio/ui/Nextbit_Lock.ogg</item>
<item>/product/media/audio/ui/Nokia_X_Lock.ogg</item>
<item>/product/media/audio/ui/Old_School_IOS_Lock.ogg</item>
<item>/product/media/audio/ui/One_UI_Lock.ogg</item>
<item>/product/media/audio/ui/OOS_14_Lock.ogg</item>
<item>/product/media/audio/ui/Razer_Phone_Lock.ogg</item>
<item>/product/media/audio/ui/Soong_Lock.ogg</item>
<item>/product/media/audio/ui/Windows_Device_Lock.ogg</item>
<item>/product/media/audio/ui/Windows_Error_Lock.ogg</item>
</string-array>
<string-array name="themes_unlock_sounds_values" translatable="false">
<item>/product/media/audio/ui/Unlock.ogg</item>
<item>/product/media/audio/ui/Amazon_Fire_Unlock.ogg</item>
<item>/product/media/audio/ui/Asus_Zenfone_Max_Unlock.ogg</item>
<item>/product/media/audio/ui/Essential_PH-1_Unlock.ogg</item>
<item>/product/media/audio/ui/HTC_M8_Unlock.ogg</item>
<item>/product/media/audio/ui/Huawei_Unlock.ogg</item>
<item>/product/media/audio/ui/Hyper_OS_Unlock.ogg</item>
<item>/product/media/audio/ui/Iqoo_Unlock.ogg</item>
<item>/product/media/audio/ui/LG_G3_Unlock.ogg</item>
<item>/product/media/audio/ui/Minecraft_Door_Unlock.ogg</item>
<item>/product/media/audio/ui/MIUI_10_Unlock.ogg</item>
<item>/product/media/audio/ui/MIUI_11_Unlock.ogg</item>
<item>/product/media/audio/ui/Nextbit_Unlock.ogg</item>
<item>/product/media/audio/ui/Nokia_X_Unlock.ogg</item>
<item>/product/media/audio/ui/Old_School_IOS_Unlock.ogg</item>
<item>/product/media/audio/ui/One_UI_Unlock.ogg</item>
<item>/product/media/audio/ui/OOS_14_Unlock.ogg</item>
<item>/product/media/audio/ui/Razer_Phone_Unlock.ogg</item>
<item>/product/media/audio/ui/Soong_Unlock.ogg</item>
<item>/product/media/audio/ui/Windows_Device_Unlock.ogg</item>
<item>/product/media/audio/ui/Windows_Error_Unlock.ogg</item>
</string-array>
<!-- Themes - Screen off animation -->
<string-array name="themes_screen_off_animation_entries">
<item>@string/themes_screen_off_animation_default</item>

View File

@@ -33,6 +33,9 @@
<string name="themes_monet_category">Monet</string>
<string name="themes_monet_title">Monet settings</string>
<string name="themes_monet_summary">Customize Android\'s built-in theme engine</string>
<string name="themes_audio_category">Audio</string>
<string name="themes_lock_sound_title">Lock sound</string>
<string name="themes_unlock_sound_title">Unlock sound</string>
<string name="themes_fonts_category">Fonts</string>
<string name="themes_system_font_title">System font</string>
<string name="themes_system_font_summary">Set system font style</string>
@@ -472,4 +475,10 @@
<string name="unit_milliseconds">milliseconds</string>
<string name="unit_pixels" translatable="false">dp</string>
<string name="unit_seconds">seconds</string>
<!-- SystemUI restart dialog -->
<string name="systemui_restart_title">SystemUI restart required</string>
<string name="systemui_restart_message">For changes to take effect, a SystemUI restart is required. Restart SystemUI now?</string>
<string name="systemui_restart_yes">Yes</string>
<string name="systemui_restart_not_now">Not now</string>
</resources>

View File

@@ -21,6 +21,27 @@
android:fragment="org.evolution.settings.fragments.themes.MonetSettings" />
</PreferenceCategory>
<PreferenceCategory
android:key="themes_audio_category"
android:title="@string/themes_audio_category">
<!-- Lock sound -->
<org.evolution.settings.preferences.GlobalSettingListPreference
android:key="lock_sound"
android:title="@string/themes_lock_sound_title"
android:entries="@array/themes_lock_unlock_sounds_entries"
android:entryValues="@array/themes_lock_sounds_values"
android:defaultValue="/product/media/audio/ui/Lock.ogg" />
<!-- Unlock sound -->
<org.evolution.settings.preferences.GlobalSettingListPreference
android:key="unlock_sound"
android:title="@string/themes_unlock_sound_title"
android:entries="@array/themes_lock_unlock_sounds_entries"
android:entryValues="@array/themes_unlock_sounds_values"
android:defaultValue="/product/media/audio/ui/Unlock.ogg" />
</PreferenceCategory>
<PreferenceCategory
android:key="themes_fonts_category"
android:title="@string/themes_fonts_category">

View File

@@ -25,7 +25,9 @@ import com.android.settingslib.search.SearchIndexable;
import java.util.List;
import org.evolution.settings.preferences.GlobalSettingListPreference;
import org.evolution.settings.utils.DeviceUtils;
import org.evolution.settings.utils.SystemUtils;
@SearchIndexable
public class Themes extends SettingsPreferenceFragment implements
@@ -33,6 +35,8 @@ public class Themes extends SettingsPreferenceFragment implements
private static final String TAG = "Themes";
private static final String KEY_LOCK_SOUND = "lock_sound";
private static final String KEY_UNLOCK_SOUND = "unlock_sound";
private static final String KEY_ICONS_CATEGORY = "themes_icons_category";
private static final String KEY_NAVBAR_ICON = "android.theme.customization.navbar";
private static final String KEY_SIGNAL_ICON = "android.theme.customization.signal_icon";
@@ -40,6 +44,8 @@ public class Themes extends SettingsPreferenceFragment implements
private static final String KEY_ANIMATIONS_CATEGORY = "themes_animations_category";
private static final String KEY_UDFPS_ANIMATION = "udfps_animation";
private GlobalSettingListPreference mLockSound;
private GlobalSettingListPreference mUnlockSound;
private PreferenceCategory mIconsCategory;
private Preference mNavbarIcon;
private Preference mSignalIcon;
@@ -57,6 +63,10 @@ public class Themes extends SettingsPreferenceFragment implements
final PreferenceScreen prefScreen = getPreferenceScreen();
final Resources resources = context.getResources();
mLockSound = (GlobalSettingListPreference) findPreference(KEY_LOCK_SOUND);
mLockSound.setOnPreferenceChangeListener(this);
mUnlockSound = (GlobalSettingListPreference) findPreference(KEY_UNLOCK_SOUND);
mUnlockSound.setOnPreferenceChangeListener(this);
mIconsCategory = (PreferenceCategory) findPreference(KEY_ICONS_CATEGORY);
mNavbarIcon = (Preference) findPreference(KEY_NAVBAR_ICON);
mSignalIcon = (Preference) findPreference(KEY_SIGNAL_ICON);
@@ -92,6 +102,10 @@ public class Themes extends SettingsPreferenceFragment implements
public boolean onPreferenceChange(Preference preference, Object newValue) {
final Context context = getContext();
final ContentResolver resolver = context.getContentResolver();
if (preference == mLockSound || preference == mUnlockSound) {
SystemUtils.showSystemUiRestartDialog(context);
return true;
}
return false;
}

View File

@@ -0,0 +1,49 @@
/*
* SPDX-FileCopyrightText: 2024 The Evolution X Project
* SPDX-License-Identifier: Apache-2.0
*/
package org.evolution.settings.utils;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.IActivityManager;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import com.android.settings.R;
public class SystemUtils {
public static void showSystemUiRestartDialog(final Context context) {
new AlertDialog.Builder(context)
.setTitle(R.string.systemui_restart_title)
.setMessage(R.string.systemui_restart_message)
.setPositiveButton(R.string.systemui_restart_yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
ActivityManager am =
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
IActivityManager ams = ActivityManager.getService();
for (ActivityManager.RunningAppProcessInfo app : am.getRunningAppProcesses()) {
if ("com.android.systemui".equals(app.processName)) {
ams.killApplicationProcess(app.processName, app.uid);
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}.execute();
}
})
.setNegativeButton(R.string.systemui_restart_not_now, null)
.show();
}
}