Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Chipppppppppp committed Nov 18, 2024
1 parent 723ead2 commit 40ad6a7
Show file tree
Hide file tree
Showing 16 changed files with 311 additions and 282 deletions.
48 changes: 24 additions & 24 deletions app/src/main/java/io/github/chipppppppppp/lime/LimeOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,30 @@ public Option(String name, int id, boolean checked) {
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 callTone = new Option("call_tone", R.string.call_tone, false);

public Option[] options = {
removeVoom,
removeWallet,
removeNewsOrCall,
distributeEvenly,
extendClickableArea,
removeIconLabels,
removeAds,
removeRecommendation,
removePremiumRecommendation,
removeServiceLabels,
removeAllServices,
removeReplyMute,
redirectWebView,
openInBrowser,
preventMarkAsRead,
preventUnsendMessage,
archived,
sendMuteMessage,
removeKeepUnread,
blockTracking,
stopVersionCheck,
outputCommunication,
callTone
removeVoom,
removeWallet,
removeNewsOrCall,
distributeEvenly,
extendClickableArea,
removeIconLabels,
removeAds,
removeRecommendation,
removePremiumRecommendation,
removeServiceLabels,
removeAllServices,
removeReplyMute,
redirectWebView,
openInBrowser,
preventMarkAsRead,
preventUnsendMessage,
archived,
sendMuteMessage,
removeKeepUnread,
blockTracking,
stopVersionCheck,
outputCommunication,
callTone
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
SQLiteDatabase db = SQLiteDatabase.openDatabase(dbFile, dbParams);

hookSAMethod(loadPackageParam, db, appContext);
hookMessageDeletion(loadPackageParam, appContext, db, appContext);
hookMessageDeletion(loadPackageParam, appContext, db, appContext);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Context context = (Context) param.thisObject;
PackageManager pm = context.getPackageManager();
long versionCode = pm.getPackageInfo(loadPackageParam.packageName, 0).getLongVersionCode();
String versionCodeStr = String.valueOf(versionCode);
String versionCodeStr = String.valueOf(versionCode);

if (!BuildConfig.HOOK_TARGET_VERSION.equals(versionCodeStr)) {
Utils.addModuleAssetPath(context);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
package io.github.chipppppppppp.lime.hooks;

import android.content.Context;

import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Switch;
import android.widget.TextView;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
Expand Down Expand Up @@ -44,7 +35,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
layout.setLayoutParams(layoutParams);

Switch switchView = new Switch(context);
switchView.setText(textKeepUnread);
switchView.setText(textKeepUnread);
RelativeLayout.LayoutParams switchParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
switchParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
Expand All @@ -58,14 +49,14 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
((ListView) viewGroup.getChildAt(0)).addFooterView(layout);
}
});

XposedHelpers.findAndHookMethod(
loadPackageParam.classLoader.loadClass(Constants.MARK_AS_READ_HOOK.className),
Constants.MARK_AS_READ_HOOK.methodName,
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(null);
param.setResult(null);
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.webkit.WebView;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import io.github.chipppppppppp.lime.LimeOptions;
Expand All @@ -34,17 +33,17 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

if (currentUrl != null && (
currentUrl.startsWith("https://account-center.lylink.yahoo.co.jp") ||
currentUrl.startsWith("https://access.line.me") ||
currentUrl.startsWith("https://id.lylink.yahoo.co.jp/federation/ly/normal/callback/first") ||
currentUrl.startsWith("https://liff.line.me") ||
currentUrl.startsWith("https://lin.ee") ||
currentUrl.startsWith("https://line.me/R/") ||
currentUrl.startsWith("line://")
)
) {
currentUrl.startsWith("https://access.line.me") ||
currentUrl.startsWith("https://id.lylink.yahoo.co.jp/federation/ly/normal/callback/first") ||
currentUrl.startsWith("https://liff.line.me") ||
currentUrl.startsWith("https://lin.ee") ||
currentUrl.startsWith("https://line.me/R/") ||
currentUrl.startsWith("line://")
)
) {
return;
}

webView.setVisibility(View.GONE);
webView.stopLoading();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
}
);

XposedHelpers.findAndHookMethod(
ViewGroup.class,
"addView",
Expand All @@ -73,8 +73,8 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
View view = (View) param.args[0];
String className = view.getClass().getName();
if (className.contains("Ad") ) {
String className = view.getClass().getName();
if (className.contains("Ad")) {
if (!adClassNames.contains(className)) {
adClassNames.add(className);
}
Expand All @@ -83,7 +83,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
}
);

for (String adClassName : adClassNames) {
XposedBridge.hookAllConstructors(
loadPackageParam.classLoader.loadClass(adClassName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
|| viewId == serviceTitleBackgroundResId
|| viewId == serviceTitleResId
|| viewId == serviceSeeMoreResId
|| viewId == serviceSeeMoreBadgeResId))
{
|| viewId == serviceSeeMoreBadgeResId)) {
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.height = 0;
view.setLayoutParams(layoutParams);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

public class Ringtone implements IHook {
private android.media.Ringtone ringtone = null;
private boolean isPlaying = false;
private boolean isPlaying = false;

@Override
public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {

Expand All @@ -39,7 +40,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (paramValue.contains("RESULT=REJECTED,") ||
paramValue.contains("RESULT=REJECTED,")) {
if (ringtone != null && ringtone.isPlaying()) {
ringtone.stop();
ringtone.stop();
isPlaying = false;
}
}
Expand Down
69 changes: 45 additions & 24 deletions app/src/main/java/io/github/chipppppppppp/lime/hooks/UnsentCap.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
import android.widget.TextView;
import android.widget.Toast;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

import io.github.chipppppppppp.lime.LimeOptions;
import io.github.chipppppppppp.lime.R;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
Expand All @@ -40,6 +32,13 @@
import java.util.Date;
import java.util.Locale;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import io.github.chipppppppppp.lime.LimeOptions;
import io.github.chipppppppppp.lime.R;

public class UnsentCap implements IHook {

public static final String Main_file = "unsent_capture.txt";
Expand Down Expand Up @@ -348,7 +347,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (db != null) db.close();
}
});
} catch (ClassNotFoundException ignored ) {
} catch (ClassNotFoundException ignored) {
}
}

Expand All @@ -363,14 +362,19 @@ private void processMessage(String paramValue, Context moduleContext, SQLiteData
for (String part : parts) {
part = part.trim();
if (part.startsWith("param1:")) talkId = part.substring("param1:".length()).trim();
else if (part.startsWith("param2:")) serverId = part.substring("param2:".length()).trim();
else if (part.startsWith("revision:")) revision = part.substring("revision:".length()).trim();
else if (part.startsWith("createdTime:")) createdTime = part.substring("createdTime:".length()).trim();
else if (part.startsWith("param2:"))
serverId = part.substring("param2:".length()).trim();
else if (part.startsWith("revision:"))
revision = part.substring("revision:".length()).trim();
else if (part.startsWith("createdTime:"))
createdTime = part.substring("createdTime:".length()).trim();
else if (part.startsWith("type:")) type = part.substring("type:".length()).trim();
else if (part.startsWith("from:")) from = part.substring("from:".length()).trim();
else if (part.startsWith("to:")) to = part.substring("to:".length()).trim();
else if (part.startsWith("contentMetadata:")) param12 = part.substring("contentMetadata:".length()).trim();
else if (part.startsWith("operationContent:")) operationContent = part.substring("operationContent:".length()).trim();
else if (part.startsWith("contentMetadata:"))
param12 = part.substring("contentMetadata:".length()).trim();
else if (part.startsWith("operationContent:"))
operationContent = part.substring("operationContent:".length()).trim();
}

if (serverId == null || talkId == null) continue;
Expand All @@ -388,17 +392,24 @@ private void processMessage(String paramValue, Context moduleContext, SQLiteData
String from_mid = null, sender_name = null;
if (groupName != null) {
from_mid = queryDatabase(db1, "SELECT from_mid FROM chat_history WHERE server_id=?", serverId);
if (from_mid != null) sender_name = queryDatabase(db2, "SELECT profile_name FROM contacts WHERE mid=?", from_mid);
if (from_mid != null)
sender_name = queryDatabase(db2, "SELECT profile_name FROM contacts WHERE mid=?", from_mid);
}

if (sender_name != null) name = groupName + ": " + sender_name;

String mediaDescription = "";
if (media != null) {
switch (media) {
case "7": mediaDescription = moduleContext.getResources().getString(R.string.sticker); break;
case "1": mediaDescription = moduleContext.getResources().getString(R.string.picture); break;
case "2": mediaDescription = moduleContext.getResources().getString(R.string.video); break;
case "7":
mediaDescription = moduleContext.getResources().getString(R.string.sticker);
break;
case "1":
mediaDescription = moduleContext.getResources().getString(R.string.picture);
break;
case "2":
mediaDescription = moduleContext.getResources().getString(R.string.video);
break;
}
}

Expand All @@ -424,12 +435,14 @@ private void saveUnresolvedIds(String serverId, String talkId, String filePath)
while ((line = reader.readLine()) != null) {
if (line.equals(newEntry)) return;
}
} catch (IOException ignored) {}
} catch (IOException ignored) {
}

try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath, true))) {
writer.write(newEntry);
writer.newLine();
} catch (IOException ignored) {}
} catch (IOException ignored) {
}
}

private void resolveUnresolvedIds(XC_LoadPackage.LoadPackageParam loadPackageParam, Context context, SQLiteDatabase db1, SQLiteDatabase db2, Context moduleContext) {
Expand Down Expand Up @@ -460,16 +473,23 @@ private void resolveUnresolvedIds(XC_LoadPackage.LoadPackageParam loadPackagePar
String mediaDescription = "";
if (media != null) {
switch (media) {
case "7": mediaDescription = moduleContext.getResources().getString(R.string.sticker); break;
case "1": mediaDescription = moduleContext.getResources().getString(R.string.picture); break;
case "2": mediaDescription = moduleContext.getResources().getString(R.string.video); break;
case "7":
mediaDescription = moduleContext.getResources().getString(R.string.sticker);
break;
case "1":
mediaDescription = moduleContext.getResources().getString(R.string.picture);
break;
case "2":
mediaDescription = moduleContext.getResources().getString(R.string.video);
break;
}
}

String from_mid = null, sender_name = null;
if (groupName != null) {
from_mid = queryDatabase(db1, "SELECT from_mid FROM chat_history WHERE server_id=?", serverId);
if (from_mid != null) sender_name = queryDatabase(db2, "SELECT profile_name FROM contacts WHERE mid=?", from_mid);
if (from_mid != null)
sender_name = queryDatabase(db2, "SELECT profile_name FROM contacts WHERE mid=?", from_mid);
}

if (sender_name != null) name = groupName + ": " + sender_name;
Expand All @@ -484,6 +504,7 @@ private void resolveUnresolvedIds(XC_LoadPackage.LoadPackageParam loadPackagePar

unresolvedFile.delete();
}

private String formatMessageTime(String timeEpochStr) {
if (timeEpochStr == null) return null;
long timeEpoch = Long.parseLong(timeEpochStr);
Expand Down
Loading

1 comment on commit 40ad6a7

@s1204IT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Chipppppppppp
Branch protection rule を戻してほしいです。

Please sign in to comment.