Skip to content

Commit

Permalink
Add a switch to custom the icon layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Chipppppppppp committed Jan 20, 2024
1 parent 03f04ac commit a12ce3d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
5 changes: 3 additions & 2 deletions app/src/main/java/io/github/chipppppppppp/lime/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lparam) throws Thr
prefs.reload();
boolean deleteVoom = prefs.getBoolean("delete_voom", true);
boolean deleteWallet = prefs.getBoolean("delete_wallet", true);
boolean distributeEvenly = prefs.getBoolean("distribute_evenly", true);
boolean deleteAds = prefs.getBoolean("delete_ads", true);
boolean redirectWebView = prefs.getBoolean("redirect_webview", true);
boolean openInBrowser = prefs.getBoolean("open_in_browser", false);
Expand Down Expand Up @@ -55,13 +56,13 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (deleteVoom) {
int timelineSpacerResId = activity.getResources().getIdentifier("bnb_timeline_spacer", "id", activity.getPackageName());
int timelineResId = activity.getResources().getIdentifier("bnb_timeline", "id", activity.getPackageName());
activity.findViewById(timelineSpacerResId).setVisibility(View.GONE);
if (distributeEvenly) activity.findViewById(timelineSpacerResId).setVisibility(View.GONE);
activity.findViewById(timelineResId).setVisibility(View.GONE);
}
if (deleteWallet) {
int walletSpacerResId = activity.getResources().getIdentifier("bnb_wallet_spacer", "id", activity.getPackageName());
int walletResId = activity.getResources().getIdentifier("bnb_wallet", "id", activity.getPackageName());
activity.findViewById(walletSpacerResId).setVisibility(View.GONE);
if (distributeEvenly) activity.findViewById(walletSpacerResId).setVisibility(View.GONE);
activity.findViewById(walletResId).setVisibility(View.GONE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,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 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 @@ -26,6 +27,7 @@ protected void onCreate(Bundle savedInstanceState) {
prefs = getSharedPreferences("settings", MODE_WORLD_READABLE);
switchDeleteVoom.setChecked(prefs.getBoolean("delete_voom", true));
switchDeleteWallet.setChecked(prefs.getBoolean("delete_wallet", true));
switchDistributeEvenly.setChecked(prefs.getBoolean("distribute_evenly", true));
switchDeleteAds.setChecked(prefs.getBoolean("delete_ads", true));
switchRedirectWebView.setChecked(prefs.getBoolean("redirect_webview", true));
switchOpenInBrowser.setChecked(prefs.getBoolean("open_in_browser", false));
Expand All @@ -38,6 +40,10 @@ protected void onCreate(Bundle savedInstanceState) {
prefs.edit().putBoolean("delete_wallet", isChecked).apply();
});

switchDistributeEvenly.setOnCheckedChangeListener((buttonView, isChecked) -> {
prefs.edit().putBoolean("distribute_evenly", 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 @@ -18,6 +18,13 @@
android:layout_marginTop="20dp"
android:text="@string/switch_delete_wallet" />

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

<Switch
android:id="@+id/switch_delete_ads"
android:layout_width="wrap_content"
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

<!-- SettingsActivity -->
<string name="switch_delete_voom">VOOM アイコンを削除</string>
<string name="switch_delete_wallet">Wallet アイコンを削除</string>
<string name="switch_delete_wallet">ウォレットアイコンを削除</string>
<string name="switch_distribute_evenly">アイコンを均等に配置</string>
<string name="switch_delete_ads">広告を削除</string>
<string name="switch_redirect_webview">WebView をデフォルトブラウザにリダイレクト</string>
<string name="switch_open_in_browser">ブラウザで開く</string>
<string name="switch_open_in_browser">ブラウザアプリで開く</string>
<string name="module_not_enabled_title">エラー</string>
<string name="module_not_enabled_text">モジュールが有効化されていません!</string>
</resources>
5 changes: 3 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
<!-- SettingsActivity -->
<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_ads">Delete ads</string>
<string name="switch_redirect_webview">Redirect WebView to your browser</string>
<string name="switch_open_in_browser">Open in your browser</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>
<string name="module_not_enabled_title">Error</string>
<string name="module_not_enabled_text">Module not enabled!</string>
</resources>

0 comments on commit a12ce3d

Please sign in to comment.