From d51f72662390f3dbe1bb373202ef5bea0312da64 Mon Sep 17 00:00:00 2001 From: Chris Boyle Date: Sat, 30 Apr 2022 11:53:59 +0100 Subject: [PATCH] Tag descriptions directly while I'm at it --- app/build.gradle | 8 +- .../boyle/chris/sgtpuzzles/GameChooser.java | 3 +- app/src/main/res/values/strings.xml | 81 +++++++++---------- 3 files changed, 47 insertions(+), 45 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a2db366db..014b542e9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -115,21 +115,25 @@ project.extensions.findByName("android").applicationVariants.all { variant -> out.text = """package name.boyle.chris.sgtpuzzles; |import java.util.Collections; |import java.util.LinkedHashMap; + |import java.util.Locale; |import java.util.Map; |import androidx.annotation.DrawableRes; + |import androidx.annotation.StringRes; |import androidx.annotation.NonNull; |import androidx.annotation.Nullable; | |/** Names of all the backends. Automatically generated file, do not modify. */ |public enum BackendName { - | ${backends.collect {"${it[0].toUpperCase(Locale.ROOT)}(\"${it[1]}\", R.drawable.day_${it[0]}, R.drawable.night_${it[0]}, ${it[2]})"}.join(",\n ")}; + | ${backends.collect {"${it[0].toUpperCase(Locale.ROOT)}(\"${it[1]}\", R.drawable.day_${it[0]}, R.drawable.night_${it[0]}, ${it[2]}, R.string.desc_${it[0]})"}.join(",\n ")}; | private final String _displayName; | private final String[] _colours; | @DrawableRes private final int _dayIcon, _nightIcon; - | private BackendName(@NonNull final String displayName, @DrawableRes final int dayIcon, @DrawableRes final int nightIcon, @NonNull final String[] colours) { _displayName = displayName; _dayIcon = dayIcon; _nightIcon = nightIcon; _colours = colours; } + | @StringRes private final int _description; + | private BackendName(@NonNull final String displayName, @DrawableRes final int dayIcon, @DrawableRes final int nightIcon, @NonNull final String[] colours, @StringRes final int description) { _displayName = displayName; _dayIcon = dayIcon; _nightIcon = nightIcon; _colours = colours; _description = description; } | @NonNull public String getDisplayName() { return _displayName; } | @DrawableRes public int getDayIcon() { return _dayIcon; } | @DrawableRes public int getNightIcon() { return _nightIcon; } + | @StringRes public int getDescription() { return _description; } | @NonNull public String[] getColours() { return _colours; } | @NonNull public String toString() { return name().toLowerCase(Locale.ROOT); } | private static final Map BY_DISPLAY_NAME, BY_LOWERCASE; diff --git a/app/src/main/java/name/boyle/chris/sgtpuzzles/GameChooser.java b/app/src/main/java/name/boyle/chris/sgtpuzzles/GameChooser.java index 8454b45da..e3d00b7dc 100644 --- a/app/src/main/java/name/boyle/chris/sgtpuzzles/GameChooser.java +++ b/app/src/main/java/name/boyle/chris/sgtpuzzles/GameChooser.java @@ -158,11 +158,10 @@ private void buildViews() R.layout.list_item, table, false); final LayerDrawable starredIcon = mkStarryIcon(backend); ((ImageView)views[i].findViewById(R.id.icon)).setImageDrawable(starredIcon); - final int descId = getResources().getIdentifier("desc_"+backend, "string", getPackageName()); SpannableStringBuilder desc = new SpannableStringBuilder(backend.getDisplayName()); desc.setSpan(new TextAppearanceSpan(this, R.style.ChooserItemName), 0, desc.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - desc.append(": ").append(getString(descId > 0 ? descId : R.string.no_desc)); + desc.append(": ").append(getString(backend.getDescription())); final TextView textView = views[i].findViewById(R.id.text); textView.setText(desc); textView.setVisibility(useGrid ? View.GONE : View.VISIBLE); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 349a78a30..a2bc01bdc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -153,47 +153,46 @@ Version %s" Tracks - (no summary available) - Locate the balls inside the box by firing lasers and observing how they are deflected or absorbed. - Connect the islands with the given bridge counts so no bridges are crossing. - Roll the cube to collect all the paint. - Pair the numbers to form a complete and distinct set of dominoes. - Slide tiles around to form a grid in numerical order. - Number the squares to form regions with the same number, which is also the size of the region. - Turn over squares until all are light side up, but flipping one flips its neighbours. - Try to get the whole grid to be the same colour within the given number of moves, by repeatedly flood-filling the top left corner in different colours. - Divide the grid into 180-degree rotationally symmetric regions each centred on a dot. - Guess the hidden colour sequence: black is correct, white is the correct colour in the wrong place. - Move the ball around to collect all the gems without hitting a mine. - Enter digits so every row and column contains exactly one of each digit and the arithmetic clues are satisfied. - Place lamps so all squares are lit, no lamp lights another and numbered squares have the given number of adjacent lamps. - Draw a single unbroken and uncrossing line such that numbered squares have the given number of edges filled. - Place magnets and blanks to satisfy the +/- counts and avoid magnets repelling. - Copy the 4 colours to colour the map with no regions of the same colour touching. - Uncover all squares except the mines using the given counts of adjacent mines. *N.B.* Game is generated after first move; you may see “not responding” warnings. - Colour squares black or white. Clues give the number of black squares in the 3x3 region around (and including) the clue square itself. - Rotate tiles to connect all tiles (not just endpoints) to the centre tile. - Slide rows and columns to connect all tiles (not just endpoints) to the centre tile. - Draw lines along the grid edges, in such a way that the grid is divided into connected regions, all of the size shown in the status line. Also, each square containing a number should have that many of its edges drawn in. - Fill the grid so that the numbers are the length of each stretch of black tiles in order. - Draw a single loop with corners on black, before/after white, and not vice versa. - Remove pegs by jumping others over them, until only one is left. - Place black squares to limit the visible distance from each numbered cell. - Divide the grid into rectangles containing only one number, which is also the area of the rectangle. - Remove groups (2 or more) of the same colour to clear the grid, scoring more for larger groups. - Connect the squares into a path following the arrows. - Remove numbers so no number appears twice in any row/column, no two black squares are adjacent and the white squares are all connected. - Slide rows and columns around to form a grid in numerical order. - Draw diagonal lines in every square such that circles have the given numbers of lines meeting at them and there are no loops. - Fill the grid so each block, row and column contains exactly one of each digit. - Place tents so each tree has a separate adjacent tent (not diagonally), no tents are next to each other (even diagonally) and the row and column counts are correct. - Place towers so each row/column contains one of each height and each clue matches the number of towers visible looking into the grid from that point. - Complete the track from A to B so that the rows and columns contain the numbers of track segments indicated. The track may not cross itself. - Rotate groups of 4 to form a grid in numerical order. - Fill the grid with monsters so the correct numbers of them can be seen from each point, taking mirrors into account. - Enter digits so every row and column contains exactly one of each digit and the greater-than signs are satisfied. - Colour every square either black or white such that no three consecutive squares, horizontally or vertically, are the same colour, and each row and column contains the same number of black and white squares. - Move points around until no lines cross. + Locate the balls inside the box by firing lasers and observing how they are deflected or absorbed. + Connect the islands with the given bridge counts so no bridges are crossing. + Roll the cube to collect all the paint. + Pair the numbers to form a complete and distinct set of dominoes. + Slide tiles around to form a grid in numerical order. + Number the squares to form regions with the same number, which is also the size of the region. + Turn over squares until all are light side up, but flipping one flips its neighbours. + Try to get the whole grid to be the same colour within the given number of moves, by repeatedly flood-filling the top left corner in different colours. + Divide the grid into 180-degree rotationally symmetric regions each centred on a dot. + Guess the hidden colour sequence: black is correct, white is the correct colour in the wrong place. + Move the ball around to collect all the gems without hitting a mine. + Enter digits so every row and column contains exactly one of each digit and the arithmetic clues are satisfied. + Place lamps so all squares are lit, no lamp lights another and numbered squares have the given number of adjacent lamps. + Draw a single unbroken and uncrossing line such that numbered squares have the given number of edges filled. + Place magnets and blanks to satisfy the +/- counts and avoid magnets repelling. + Copy the 4 colours to colour the map with no regions of the same colour touching. + Uncover all squares except the mines using the given counts of adjacent mines. *N.B.* Game is generated after first move; you may see “not responding” warnings. + Colour squares black or white. Clues give the number of black squares in the 3x3 region around (and including) the clue square itself. + Rotate tiles to connect all tiles (not just endpoints) to the centre tile. + Slide rows and columns to connect all tiles (not just endpoints) to the centre tile. + Draw lines along the grid edges, in such a way that the grid is divided into connected regions, all of the size shown in the status line. Also, each square containing a number should have that many of its edges drawn in. + Fill the grid so that the numbers are the length of each stretch of black tiles in order. + Draw a single loop with corners on black, before/after white, and not vice versa. + Remove pegs by jumping others over them, until only one is left. + Place black squares to limit the visible distance from each numbered cell. + Divide the grid into rectangles containing only one number, which is also the area of the rectangle. + Remove groups (2 or more) of the same colour to clear the grid, scoring more for larger groups. + Connect the squares into a path following the arrows. + Remove numbers so no number appears twice in any row/column, no two black squares are adjacent and the white squares are all connected. + Slide rows and columns around to form a grid in numerical order. + Draw diagonal lines in every square such that circles have the given numbers of lines meeting at them and there are no loops. + Fill the grid so each block, row and column contains exactly one of each digit. + Place tents so each tree has a separate adjacent tent (not diagonally), no tents are next to each other (even diagonally) and the row and column counts are correct. + Place towers so each row/column contains one of each height and each clue matches the number of towers visible looking into the grid from that point. + Complete the track from A to B so that the rows and columns contain the numbers of track segments indicated. The track may not cross itself. + Rotate groups of 4 to form a grid in numerical order. + Fill the grid with monsters so the correct numbers of them can be seen from each point, taking mirrors into account. + Enter digits so every row and column contains exactly one of each digit and the greater-than signs are satisfied. + Colour every square either black or white such that no three consecutive squares, horizontally or vertically, are the same colour, and each row and column contains the same number of black and white squares. + Move points around until no lines cross. Tap a colour to flood fill from the top left Drag colours into place, then tap smaller pegs when done