Browse Source

[android, tools] remove unused XML strings; add script to find unused XML strings

Signed-off-by: lizzie <lizzie@eden-emu.dev>
pull/2777/head
lizzie 5 months ago
parent
commit
5e60622019
No known key found for this signature in database GPG Key ID: 287378CADCAB13
  1. 25
      src/android/app/src/main/res/values/strings.xml
  2. 1
      tools/README.md
  3. 53
      tools/find-unused-strings.pl

25
src/android/app/src/main/res/values/strings.xml

@ -17,7 +17,6 @@
<!-- Spinbox strings -->
<string name="increment">Increment</string>
<string name="decrement">Decrement</string>
<string name="value">Value</string>
<string name="value_too_low">Value must be at least %1$d</string>
<string name="value_too_high">Value must be at most %1$d</string>
<string name="invalid_value">Invalid value</string>
@ -50,8 +49,6 @@
<string name="show_fps_description">Display current frames per second</string>
<string name="show_frametime">Show Frametime</string>
<string name="show_frametime_description">Display current frametime</string>
<string name="show_speed">Show Speed</string>
<string name="show_speed_description">Display current emulation speed percentage</string>
<string name="show_app_ram_usage">Show App Memory Usage</string>
<string name="show_app_ram_usage_description">Display the amount of RAM the emulator is using</string>
<string name="show_system_ram_usage">Show System Memory Usage</string>
@ -344,8 +341,6 @@
<string name="settings_description">Configure emulator settings</string>
<string name="search_recently_played">Recently played</string>
<string name="search_recently_added">Recently added</string>
<string name="search_retail">Retail</string>
<string name="search_homebrew">Homebrew</string>
<string name="open_user_folder">Open Eden folder</string>
<string name="open_user_folder_description">Manage Eden\'s internal files</string>
<string name="theme_and_color_description">Modify the look of the app</string>
@ -603,7 +598,6 @@
<string name="qualified_button">%1$s%2$s%3$sButton %4$s</string>
<string name="qualified_axis">Axis %1$s%2$s</string>
<string name="unused">Unused</string>
<string name="input_prompt">Move or press an input</string>
<string name="unsupported_input">Unsupported input type</string>
<string name="input_mapping_filter">Input mapping filter</string>
<string name="input_mapping_filter_description">Select a device to filter mapping inputs</string>
@ -650,8 +644,6 @@
<string name="slider_default">Default</string>
<string name="ini_saved">Saved settings</string>
<string name="gameid_saved">Saved settings for %1$s</string>
<string name="error_saving">Error saving %1$s.ini: %2$s</string>
<string name="unimplemented_menu">Unimplemented Menu</string>
<string name="loading">Loading…</string>
<string name="shutting_down">Shutting down…</string>
<string name="reset_setting_confirmation">Do you want to reset this setting back to its default value?</string>
@ -677,15 +669,11 @@
<string name="import_success">Imported successfully</string>
<string name="export_success">Exported successfully</string>
<string name="start">Start</string>
<string name="clear">Clear</string>
<string name="global">Global</string>
<string name="custom">Custom</string>
<string name="notice">Notice</string>
<string name="import_complete">Import complete</string>
<string name="more_options">More options</string>
<string name="use_global_setting">Use global setting</string>
<string name="operation_completed_successfully">The operation completed successfully</string>
<string name="retry">Retry</string>
<string name="confirm">Confirm</string>
<string name="load">Load</string>
<string name="save">Save</string>
@ -703,12 +691,9 @@
<!-- GPU driver fetcher -->
<string name="fetch_error">Error while Fetching</string>
<string name="check_connection">Check your connection and try again.</string>
<string name="show_releases">Show Releases</string>
<string name="view_full_release_notes">Release Notes</string>
<string name="failed_to_fetch">Failed to fetch</string>
<string name="error_during_fetch">Error during Fetch</string>
<string name="toggle_release_notes">Toggle release notes</string>
<string name="downloads">Downloads</string>
<string name="show_downloads">Show Downloads</string>
<string name="hide_downloads">Hide Downloads</string>
@ -728,7 +713,6 @@
<!-- Preferences Screen -->
<string name="preferences_settings">Settings</string>
<string name="preferences_general">General</string>
<string name="preferences_system">System</string>
<string name="preferences_system_description">Docked mode, region, language</string>
<string name="preferences_graphics">Graphics</string>
@ -841,8 +825,6 @@
<string name="config_already_exists_message">Custom settings already exist for %1$s.\n\nWould you like to overwrite the existing configuration?\n\nThis action cannot be undone.</string>
<string name="config_exists_prompt">Checking for existing configuration...</string>
<string name="overwrite_cancelled">Overwrite cancelled</string>
<string name="checking_driver">Checking for custom driver: %1$s</string>
<string name="driver_unavailable">Custom driver not available for this device</string>
<string name="overwrite">Overwrite</string>
<!-- Driver strings -->
@ -852,8 +834,6 @@
<string name="driver_installed">Driver installed successfully</string>
<string name="driver_installation_failed_title">Driver Installation Failed</string>
<string name="driver_installation_failed_message">Failed to install the GPU driver: %s</string>
<string name="driver_not_available_title">Driver Not Available</string>
<string name="driver_not_available_message">The selected driver is not available for download.</string>
<string name="driver_not_found">Required driver not installed: %s</string>
<string name="invalid_driver_file">Invalid driver file: %s</string>
<string name="network_unavailable">No network connection available. Please check your internet connection and try again.</string>
@ -865,8 +845,6 @@
<!-- Emulation Menu -->
<string name="emulation_exit">Exit emulation</string>
<string name="emulation_done">Done</string>
<string name="emulation_fps_counter">FPS counter</string>
<string name="emulation_thermal_indicator">Thermal indicator</string>
<string name="emulation_toggle_controls">Toggle controls</string>
<string name="emulation_rel_stick_center">Relative stick center</string>
<string name="emulation_dpad_slide">D-pad slide</string>
@ -921,7 +899,6 @@
<string name="memory_8gb">8GB (Unsafe)</string>
<!--CPU clock speeds-->
<string name="clock_base">Base (1000MHz)</string>
<string name="clock_boost">Boost (1700MHz)</string>
<string name="clock_fast">Fast (2000MHz)</string>
@ -956,7 +933,6 @@
<string name="language_serbian" translatable="false">српски</string>
<!-- Memory Sizes -->
<string name="memory_byte">Byte</string>
<string name="memory_byte_shorthand">B</string>
<string name="memory_kilobyte">KB</string>
<string name="memory_megabyte">MB</string>
@ -1074,7 +1050,6 @@
<string name="gamepad_screenshot">Screenshot</string>
<!-- Disk shader cache -->
<string name="preparing_shaders">Preparing shaders</string>
<string name="building_shaders">Building shaders</string>
<!-- Theme options -->

1
tools/README.md

@ -8,6 +8,7 @@ Tools for Eden and other subprojects.
## Eden
- `find-unused-strings.pl`: Find unused strings (for Android XML files).
- `shellcheck.sh`: Ensure POSIX compliance (and syntax sanity) for all tools in this directory and subdirectories.
- `llvmpipe-run.sh`: Sets environment variables needed to run any command (or Eden) with llvmpipe.
- `optimize-assets.sh`: Optimize PNG assets with OptiPng.

53
tools/find-unused-strings.pl

@ -0,0 +1,53 @@
#!/usr/bin/perl
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
use strict;
use warnings;
use List::Util qw(uniq);
open STRINGS, '<', 'src/android/app/src/main/res/values/strings.xml';
my @raw_strings = <STRINGS>;
my @line_strings = grep {/\bstring name="\b/} @raw_strings;
my @strings = map { my @x = split('"', $_); $x[1] } @line_strings;
close STRINGS;
my $pattern = join('|', @strings);
my $regex = qr/($pattern)/;
my @unused_strings = @strings;
sub process_file {
my $b = $_[1];
open FILE, "<".$_[0] or die "cant open ".$_[0];
#print "<!-- FILE: ".$_[0]." -->"."\n";
while (my $line = <FILE>) {
$line =~ s/^\s+|\s+$//g; #trim
if ($line =~ $regex) {
foreach my $e (@strings) {
my $re = $b != 0 ? ('\b'.quotemeta("R.string.".$e).'\b') : quotemeta("\@string/".$e);
#print "<!-- match: ".$e." -> ".$line."-->\n" if $line =~ /$re/;
@unused_strings = grep {!/$e/} @unused_strings if $line =~ /$re/;
}
}
}
close FILE;
}
# xml files
open XML_LIST, "find src/android/app/src/main -type f -iname '*.xml' |" || die;
foreach (<XML_LIST>) { process_file($_, 0) if $_ !~ /\/strings.xml/; }
close XML_LIST;
# kotlin
open KOT_LIST, "find src/android/app/src/main -type f -iname '*.kt' |" || die;
foreach (<KOT_LIST>) { process_file $_, 1; }
close KOT_LIST;
#print "unused strings: ".scalar(@unused_strings)."\n";
#foreach (@unused_strings) { print $_."\n"; }
open STRINGS, '<', 'src/android/app/src/main/res/values/strings.xml';
while (my $line = <STRINGS>) {
my $b = 1;
if ($line =~ $regex) {
foreach my $e (@unused_strings) {
my $re = quotemeta('"'.$e.'"');
print "<!-- UNUSED ".$line." : ".$e."-->\n" if $line =~ /$re/;
$b = $line =~ /$re/ ? 0 : $b;
}
}
print $line if $b > 0;
}
close STRINGS;
Loading…
Cancel
Save