Skip to content

Commit

Permalink
Add a switch to custom the icon labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Chipppppppppp committed Jan 21, 2024
1 parent 667b034 commit 33508f6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
27 changes: 9 additions & 18 deletions app/src/main/java/io/github/chipppppppppp/lime/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.TextView;

import androidx.browser.customtabs.CustomTabsIntent;
import java.lang.reflect.*;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
Expand All @@ -27,27 +24,14 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lparam) throws Thr
boolean deleteVoom = prefs.getBoolean("delete_voom", true);
boolean deleteWallet = prefs.getBoolean("delete_wallet", true);
boolean distributeEvenly = prefs.getBoolean("distribute_evenly", true);
boolean deleteIconLabels = prefs.getBoolean("delete_icon_labels", false);
boolean deleteAds = prefs.getBoolean("delete_ads", true);
boolean redirectWebView = prefs.getBoolean("redirect_webview", true);
boolean openInBrowser = prefs.getBoolean("open_in_browser", false);

Class hookTarget;

hookTarget = lparam.classLoader.loadClass("android.widget.TextView");
XposedBridge.hookAllMethods(hookTarget, "setText", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
TextView textView = (TextView) param.thisObject;
XposedBridge.log(textView.getText().toString());
View parent = (View) textView.getParent();
while (parent != null) {
XposedBridge.log(parent.getClass().getName());
parent = (View) parent.getParent();
}
}
});

if (deleteVoom || deleteWallet) {
if (deleteVoom || deleteWallet || deleteIconLabels) {
hookTarget = lparam.classLoader.loadClass("jp.naver.line.android.activity.main.MainActivity");
XposedHelpers.findAndHookMethod(hookTarget, "onResume", new XC_MethodHook() {
@Override
Expand All @@ -65,6 +49,13 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (distributeEvenly) activity.findViewById(walletSpacerResId).setVisibility(View.GONE);
activity.findViewById(walletResId).setVisibility(View.GONE);
}
if (deleteIconLabels) {
String[] resNames = {"bnb_home_v2", "bnb_chat", "bnb_timeline", "bnb_news", "bnb_call", "bnb_wallet"};
for (String resName : resNames) {
int resId = activity.getResources().getIdentifier(resName, "id", activity.getPackageName());
((ViewGroup) activity.findViewById(resId)).getChildAt(5).setVisibility(View.GONE);
}
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protected void onCreate(Bundle savedInstanceState) {
Switch switchDeleteVoom = findViewById(R.id.switch_delete_voom);
Switch switchDeleteWallet = findViewById(R.id.switch_delete_wallet);
Switch switchDistributeEvenly = findViewById(R.id.switch_distribute_evenly);
Switch switchDeleteIconLabels = findViewById(R.id.switch_delete_icon_labels);
Switch switchDeleteAds = findViewById(R.id.switch_delete_ads);
Switch switchRedirectWebView = findViewById(R.id.switch_redirect_webview);
Switch switchOpenInBrowser = findViewById(R.id.switch_open_in_browser);
Expand All @@ -28,6 +29,7 @@ protected void onCreate(Bundle savedInstanceState) {
switchDeleteVoom.setChecked(prefs.getBoolean("delete_voom", true));
switchDeleteWallet.setChecked(prefs.getBoolean("delete_wallet", true));
switchDistributeEvenly.setChecked(prefs.getBoolean("distribute_evenly", true));
switchDeleteIconLabels.setChecked(prefs.getBoolean("delete_icon_labels", false));
switchDeleteAds.setChecked(prefs.getBoolean("delete_ads", true));
switchRedirectWebView.setChecked(prefs.getBoolean("redirect_webview", true));
switchOpenInBrowser.setChecked(prefs.getBoolean("open_in_browser", false));
Expand All @@ -44,6 +46,10 @@ protected void onCreate(Bundle savedInstanceState) {
prefs.edit().putBoolean("distribute_evenly", isChecked).apply();
});

switchDeleteIconLabels.setOnCheckedChangeListener((buttonView, isChecked) -> {
prefs.edit().putBoolean("delete_icon_labels", isChecked).apply();
});

switchDeleteAds.setOnCheckedChangeListener((buttonView, isChecked) -> {
prefs.edit().putBoolean("delete_ads", isChecked).apply();
});
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/settings_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
android:layout_marginTop="20dp"
android:text="@string/switch_distribute_evenly" />

<Switch
android:id="@+id/switch_delete_icon_labels"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/switch_delete_icon_labels" />

<Switch
android:id="@+id/switch_delete_ads"
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<string name="switch_delete_voom">VOOM アイコンを削除</string>
<string name="switch_delete_wallet">ウォレットアイコンを削除</string>
<string name="switch_distribute_evenly">アイコンを均等に配置</string>
<string name="switch_delete_icon_labels">アイコンのラベルを削除</string>
<string name="switch_delete_ads">広告を削除</string>
<string name="switch_redirect_webview">WebView をデフォルトブラウザにリダイレクト</string>
<string name="switch_open_in_browser">ブラウザアプリで開く</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string name="switch_delete_voom">Delete the VOOM icon</string>
<string name="switch_delete_wallet">Delete the Wallet icon</string>
<string name="switch_distribute_evenly">Distribute the icons evenly</string>
<string name="switch_delete_icon_labels">Delete the icon labels</string>
<string name="switch_delete_ads">Delete ads</string>
<string name="switch_redirect_webview">Redirect WebView to the default browser</string>
<string name="switch_open_in_browser">Open in the browser app</string>
Expand Down

0 comments on commit 33508f6

Please sign in to comment.