File tree Expand file tree Collapse file tree 4 files changed +39
-0
lines changed
java/com/programminghoch10/DisableSounds Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1
1
com.programminghoch10.DisableSounds.DisableForcedCameraSoundHook
2
2
com.programminghoch10.DisableSounds.DisableScreenshotSoundHook
3
+ com.programminghoch10.DisableSounds.DisableShutterSoundsHook
Original file line number Diff line number Diff line change
1
+ package com.programminghoch10.DisableSounds
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.media.MediaActionSound
5
+ import android.os.Build
6
+ import de.robv.android.xposed.IXposedHookLoadPackage
7
+ import de.robv.android.xposed.XC_MethodReplacement
8
+ import de.robv.android.xposed.XSharedPreferences
9
+ import de.robv.android.xposed.XposedHelpers
10
+ import de.robv.android.xposed.callbacks.XC_LoadPackage
11
+
12
+ class DisableShutterSoundsHook : IXposedHookLoadPackage {
13
+ @SuppressLint(" ObsoleteSdkInt" )
14
+ override fun handleLoadPackage (lpparam : XC_LoadPackage .LoadPackageParam ? ) {
15
+ val sharedPreferences = XSharedPreferences (BuildConfig .APPLICATION_ID , SHARED_PREFERENCES_NAME )
16
+ if (! sharedPreferences.getBoolean(" shutter" , false )) return
17
+
18
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN ) for (methodName in listOf (" load" , " play" )) XposedHelpers .findAndHookMethod(
19
+ MediaActionSound ::class .java,
20
+ methodName,
21
+ Int ::class .java,
22
+ XC_MethodReplacement .DO_NOTHING ,
23
+ )
24
+
25
+ // TODO: need a native hook for old Camera API methods
26
+ // https://cs.android.com/android/platform/superproject/main/+/main:frameworks/av/services/camera/libcameraservice/CameraService.cpp;l=4097?q=camera_click.ogg
27
+ // then the "might not work" warning can be removed from @string/disable_shutter_sounds_description_on
28
+ }
29
+ }
Original file line number Diff line number Diff line change 3
3
<string name =" title_activity_settings" >DisableSounds Configuration</string >
4
4
<string name =" app_name" >DisableSounds</string >
5
5
<string name =" description" >Disable various system sounds</string >
6
+ <string name =" disable_shutter_sounds_title" >Disable shutter sounds</string >
7
+ <string name =" disable_shutter_sounds_description" >Disable shutter, focus and video recording sounds.</string >
8
+ <string name =" disable_shutter_sounds_description_on" >Some apps using the old Camera API might not be muted. On Android 13 and older the screenshot sound might be muted too.</string >
6
9
<string name =" disable_screenshot_sound_title" >Disable screenshot sound</string >
7
10
<string name =" disable_screenshot_sound_description" >@null</string >
8
11
</resources >
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
2
<PreferenceScreen
3
3
xmlns : app =" http://schemas.android.com/apk/res-auto" >
4
+ <SwitchPreference
5
+ app : key =" shutter"
6
+ app : title =" @string/disable_shutter_sounds_title"
7
+ app : summary =" @string/disable_shutter_sounds_description"
8
+ app : summaryOn =" @string/disable_shutter_sounds_description_on"
9
+ />
4
10
<SwitchPreference
5
11
app : key =" screenshot"
6
12
app : title =" @string/disable_screenshot_sound_title"
You can’t perform that action at this time.
0 commit comments