diff --git a/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java b/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java index a6747fbf..da1238fa 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java +++ b/app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java @@ -33,7 +33,8 @@ public Option(String name, int id, boolean checked) { public Option blockTracking = new Option("block_tracking", R.string.switch_block_tracking, false); public Option stopVersionCheck = new Option("stop_version_check", R.string.switch_stop_version_check, false); public Option outputCommunication = new Option("output_communication", R.string.switch_output_communication, false); - public Option Archived = new Option("Archived_message", R.string.switch_archived, false); + public Option archived = new Option("archived_message", R.string.switch_archived, false); + public Option callTone = new Option("call_tone", R.string.call_tone, false); public Option[] options = { removeVoom, @@ -51,11 +52,12 @@ public Option(String name, int id, boolean checked) { openInBrowser, preventMarkAsRead, preventUnsendMessage, - Archived, + archived, sendMuteMessage, removeKeepUnread, blockTracking, stopVersionCheck, - outputCommunication + outputCommunication, + callTone }; } diff --git a/app/src/main/java/io/github/chipppppppppp/lime/Main.java b/app/src/main/java/io/github/chipppppppppp/lime/Main.java index 8a92a78d..86113d5a 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/Main.java +++ b/app/src/main/java/io/github/chipppppppppp/lime/Main.java @@ -30,6 +30,7 @@ import io.github.chipppppppppp.lime.hooks.RemoveIconLabels; import io.github.chipppppppppp.lime.hooks.RemoveIcons; import io.github.chipppppppppp.lime.hooks.RemoveReplyMute; +import io.github.chipppppppppp.lime.hooks.Ringtone; import io.github.chipppppppppp.lime.hooks.SendMuteMessage; import io.github.chipppppppppp.lime.hooks.SpoofAndroidId; import io.github.chipppppppppp.lime.hooks.SpoofUserAgent; @@ -64,8 +65,9 @@ public class Main implements IXposedHookLoadPackage, IXposedHookInitPackageResou new BlockTracking(), new ModifyResponse(), new OutputRequest(), - new UnsentCap(), - new Archived() + new Archived(), + new Ringtone(), + new UnsentCap() }; public void handleLoadPackage(@NonNull XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { diff --git a/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived.java b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived.java index 7e99b824..45a804eb 100644 --- a/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived.java +++ b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Archived.java @@ -27,7 +27,7 @@ public class Archived implements IHook { @Override public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { - if (!limeOptions.Archived.checked) return; + if (!limeOptions.archived.checked) return; XposedBridge.hookAllMethods(Application.class, "onCreate", new XC_MethodHook() { @Override @@ -50,7 +50,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } private void hookMessageDeletion(XC_LoadPackage.LoadPackageParam loadPackageParam, Context context, SQLiteDatabase db, Context moduleContext) { - if (!limeOptions.Archived.checked) return; + if (!limeOptions.archived.checked) return; try { XposedBridge.hookAllMethods( diff --git a/app/src/main/java/io/github/chipppppppppp/lime/hooks/Ringtone.java b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Ringtone.java new file mode 100644 index 00000000..2cd38678 --- /dev/null +++ b/app/src/main/java/io/github/chipppppppppp/lime/hooks/Ringtone.java @@ -0,0 +1,61 @@ +package io.github.chipppppppppp.lime.hooks; + +import android.app.AndroidAppHelper; +import android.content.Context; +import android.media.RingtoneManager; +import android.net.Uri; + +import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.XposedBridge; +import de.robv.android.xposed.callbacks.XC_LoadPackage; +import io.github.chipppppppppp.lime.LimeOptions; + +public class Ringtone implements IHook { + private android.media.Ringtone ringtone = null; + private boolean isPlaying = false; + @Override + public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { + + if (!limeOptions.callTone.checked) return; + + XposedBridge.hookAllMethods( + loadPackageParam.classLoader.loadClass(Constants.RESPONSE_HOOK.className), + Constants.RESPONSE_HOOK.methodName, + new XC_MethodHook() { + + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + String paramValue = param.args[1].toString(); + + if (paramValue.contains("type:NOTIFIED_RECEIVED_CALL,") && !isPlaying) { + Context context = AndroidAppHelper.currentApplication().getApplicationContext(); + if (context != null) { + Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); + ringtone = RingtoneManager.getRingtone(context, ringtoneUri); + ringtone.play(); + isPlaying = true; + } + + if (paramValue.contains("RESULT=REJECTED,") || + paramValue.contains("RESULT=REJECTED,")) { + if (ringtone != null && ringtone.isPlaying()) { + ringtone.stop(); + isPlaying = false; + } + } + } + } + }); + + Class voIPBaseFragmentClass = loadPackageParam.classLoader.loadClass("com.linecorp.voip2.common.base.VoIPBaseFragment"); + XposedBridge.hookAllMethods(voIPBaseFragmentClass, "onCreate", new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + if (ringtone != null && ringtone.isPlaying()) { + ringtone.stop(); + isPlaying = false; + } + } + }); + } +} diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 10a72e48..1e5b57e9 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -51,7 +51,7 @@ レスポンスを改変 コピー ペースト - + 着信音を鳴らす(LSPatch用) 未読のまま閲覧 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 488561c9..f9986397 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -52,7 +52,7 @@ Modify responses Copy Paste - + Notify ringtone of LSPatch Keep unread