Skip to content

Commit

Permalink
Merge branch 'master' into patch-30
Browse files Browse the repository at this point in the history
  • Loading branch information
s1204IT authored Oct 26, 2024
2 parents b807a8a + 789b412 commit 5f42870
Show file tree
Hide file tree
Showing 8 changed files with 657 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -51,11 +52,12 @@ public Option(String name, int id, boolean checked) {
openInBrowser,
preventMarkAsRead,
preventUnsendMessage,
Archived,
archived,
sendMuteMessage,
removeKeepUnread,
blockTracking,
stopVersionCheck,
outputCommunication
outputCommunication,
callTone
};
}
6 changes: 5 additions & 1 deletion app/src/main/java/io/github/chipppppppppp/lime/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
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;
import io.github.chipppppppppp.lime.hooks.UnsentCap;

public class Main implements IXposedHookLoadPackage, IXposedHookInitPackageResources, IXposedHookZygoteInit {
public static String modulePath;
Expand Down Expand Up @@ -63,7 +65,9 @@ public class Main implements IXposedHookLoadPackage, IXposedHookInitPackageResou
new BlockTracking(),
new ModifyResponse(),
new OutputRequest(),
new Archived()
new Archived(),
new Ringtone(),
new UnsentCap()
};

public void handleLoadPackage(@NonNull XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

public class RemoveFlexibleContents implements IHook {
int recommendationResId, serviceNameResId, notificationResId;
int serviceRowContainerResId, serviceIconResId, serviceCarouselResId;
int serviceTitleBackgroundResId, serviceTitleResId, serviceSeeMoreResId, serviceSeeMoreBadgeResId;

@Override
public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
Expand All @@ -25,6 +27,13 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
recommendationResId = context.getResources().getIdentifier("home_tab_contents_recommendation_placement", "id", context.getPackageName());
serviceNameResId = context.getResources().getIdentifier("home_tab_service_name", "id", context.getPackageName());
notificationResId = context.getResources().getIdentifier("notification_hub_row_rolling_view_group", "id", context.getPackageName());
serviceRowContainerResId = context.getResources().getIdentifier("service_row_container", "id", context.getPackageName());
serviceIconResId = context.getResources().getIdentifier("home_tab_service_icon", "id", context.getPackageName());
serviceCarouselResId = context.getResources().getIdentifier("home_tab_service_carousel", "id", context.getPackageName());
serviceTitleBackgroundResId = context.getResources().getIdentifier("home_tab_service_title_background", "id", context.getPackageName());
serviceTitleResId = context.getResources().getIdentifier("home_tab_service_title", "id", context.getPackageName());
serviceSeeMoreResId = context.getResources().getIdentifier("home_tab_service_see_more", "id", context.getPackageName());
serviceSeeMoreBadgeResId = context.getResources().getIdentifier("home_tab_service_see_more_badge", "id", context.getPackageName());
}
}
);
Expand All @@ -33,22 +42,37 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
View.class,
"onAttachedToWindow",
new XC_MethodHook() {
View view;

@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
view = (View) param.thisObject;
if (limeOptions.removeRecommendation.checked && view.getId() == recommendationResId
|| limeOptions.removeServiceLabels.checked && view.getId() == serviceNameResId) {
View view = (View) param.thisObject;
int viewId = view.getId();
//String resourceName = getResourceName(view.getContext(), viewId);
//XposedBridge.log("View ID: " + viewId + ", Resource Name: " + resourceName);

if (limeOptions.removeRecommendation.checked && viewId == recommendationResId
|| limeOptions.removeServiceLabels.checked && viewId == serviceNameResId
|| viewId == serviceRowContainerResId
|| viewId == serviceIconResId
|| viewId == serviceCarouselResId
|| viewId == serviceTitleBackgroundResId
|| viewId == serviceTitleResId
|| viewId == serviceSeeMoreResId
|| viewId == serviceSeeMoreBadgeResId) {
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.height = 0;
view.setLayoutParams(layoutParams);
view.setVisibility(View.GONE);
} else if (view.getId() == notificationResId) {
} else if (viewId == notificationResId) {
((View) view.getParent()).setVisibility(View.GONE);
}
}
}
);
}

/*
private String getResourceName(Context context, int resourceId) {
return context.getResources().getResourceEntryName(resourceId);
}
*/
}
61 changes: 61 additions & 0 deletions app/src/main/java/io/github/chipppppppppp/lime/hooks/Ringtone.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
});
}
}
Loading

0 comments on commit 5f42870

Please sign in to comment.