diff --git a/app/src/main/java/com/totsp/crossword/ClueListActivity.java b/app/src/main/java/com/totsp/crossword/ClueListActivity.java index 794ccad8..0944ed13 100755 --- a/app/src/main/java/com/totsp/crossword/ClueListActivity.java +++ b/app/src/main/java/com/totsp/crossword/ClueListActivity.java @@ -13,6 +13,7 @@ import android.view.KeyEvent; import android.view.MenuItem; import android.view.View; +import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; @@ -21,9 +22,11 @@ import android.widget.ListView; import android.widget.TabHost; import android.widget.TabHost.TabSpec; +import android.widget.TextView; import android.widget.Toast; import com.totsp.crossword.io.IO; +import com.totsp.crossword.puz.Playboard.Clue; import com.totsp.crossword.puz.Playboard.Position; import com.totsp.crossword.puz.Playboard.Word; import com.totsp.crossword.puz.Puzzle; @@ -242,13 +245,33 @@ public void onTap(Point e) { this.across = (ListView) this.findViewById(R.id.acrossList); this.down = (ListView) this.findViewById(R.id.downList); - across.setAdapter(new ArrayAdapter<>(this, + across.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, ShortyzApplication.BOARD - .getAcrossClues())); + .getAcrossClues()) { + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + TextView base = (TextView) super.getView(position, convertView, parent); + if (prefs.getBoolean("showCount", false)) { + base.append(" [" + getItem(position).answerLength + "]"); + } + return base; + } + }); across.setFocusableInTouchMode(true); - down.setAdapter(new ArrayAdapter<>(this, + down.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, ShortyzApplication.BOARD - .getDownClues())); + .getDownClues()) { + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + TextView base = (TextView) super.getView(position, convertView, parent); + if (prefs.getBoolean("showCount", false)) { + base.append(" [" + getItem(position).answerLength + "]"); + } + return base; + } + }); across.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { diff --git a/puzlib/src/main/java/com/totsp/crossword/puz/Box.java b/puzlib/src/main/java/com/totsp/crossword/puz/Box.java index 30bbd38e..ffdf822a 100755 --- a/puzlib/src/main/java/com/totsp/crossword/puz/Box.java +++ b/puzlib/src/main/java/com/totsp/crossword/puz/Box.java @@ -7,8 +7,10 @@ public class Box implements Serializable { private String responder; private boolean across; + private int acrossAnswerLength; private boolean cheated; private boolean down; + private int downAnswerLength; private boolean circled; private char response = BLANK; private char solution; @@ -112,6 +114,20 @@ public void setAcross(boolean across) { this.across = across; } + /** + * @return the length of the across answer that starts in this box; 0 otherwise + */ + public int getAcrossAnswerLength() { + return acrossAnswerLength; + } + + /** + * @param acrossAnswerLength the length of the across answer that starts in this box + */ + public void setAcrossAnswerLength(int acrossAnswerLength) { + this.acrossAnswerLength = acrossAnswerLength; + } + /** * @return the cheated */ @@ -139,7 +155,21 @@ public boolean isDown() { public void setDown(boolean down) { this.down = down; } - + + /** + * @return the length of the down answer that starts in this box; 0 otherwise + */ + public int getDownAnswerLength() { + return downAnswerLength; + } + + /** + * @param downAnswerLength the length of the down answer that starts in this box + */ + public void setDownAnswerLength(int downAnswerLength) { + this.downAnswerLength = downAnswerLength; + } + /** * @return if the box is circled */ diff --git a/puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java b/puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java index cd29bdc7..30a2c7f1 100755 --- a/puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java +++ b/puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java @@ -75,6 +75,8 @@ public Clue[] getAcrossClues() { clues[i] = new Clue(); clues[i].hint = puzzle.getAcrossClues()[i]; clues[i].number = puzzle.getAcrossCluesLookup()[i]; + Position p = acrossWordStarts.get(clues[i].number); + clues[i].answerLength = this.getBoxes()[p.across][p.down].getAcrossAnswerLength(); } return clues; @@ -91,6 +93,8 @@ public Clue getClue() { Position start = this.getCurrentWordStart(); c.number = this.getBoxes()[start.across][start.down].getClueNumber(); c.hint = this.across ? this.puzzle.findAcrossClue(c.number) : this.puzzle.findDownClue(c.number); + c.answerLength = this.across ? this.getBoxes()[start.across][start.down].getAcrossAnswerLength() : + this.getBoxes()[start.across][start.down].getDownAnswerLength(); } catch (Exception e) { } @@ -216,6 +220,8 @@ public Clue[] getDownClues() { clues[i] = new Clue(); clues[i].hint = puzzle.getDownClues()[i]; clues[i].number = puzzle.getDownCluesLookup()[i]; + Position p = downWordStarts.get(clues[i].number); + clues[i].answerLength = this.getBoxes()[p.across][p.down].getDownAnswerLength(); } return clues; @@ -683,6 +689,7 @@ public void toggleShowErrors() { public static class Clue implements Serializable { public String hint; public int number; + public int answerLength; @Override public boolean equals(Object obj) { @@ -704,6 +711,10 @@ public boolean equals(Object obj) { return false; } + if (this.answerLength != other.answerLength) { + return false; + } + return true; } diff --git a/puzlib/src/main/java/com/totsp/crossword/puz/Puzzle.java b/puzlib/src/main/java/com/totsp/crossword/puz/Puzzle.java index 94558fb9..9898304f 100755 --- a/puzlib/src/main/java/com/totsp/crossword/puz/Puzzle.java +++ b/puzlib/src/main/java/com/totsp/crossword/puz/Puzzle.java @@ -102,6 +102,11 @@ public void setBoxes(Box[][] boxes) { if (!somethingAbove(boxes, row, col)) { if (somethingBelow(boxes, row, col)) { boxes[row][col].setDown(true); + int numBoxesBelow = 1; + while (somethingBelow(boxes, row + numBoxesBelow, col)) { + ++numBoxesBelow; + } + boxes[row][col].setDownAnswerLength(numBoxesBelow + 1); } tickedClue = true; } @@ -109,6 +114,11 @@ public void setBoxes(Box[][] boxes) { if (!somethingLeftOf(boxes, row, col)) { if (somethingRightOf(boxes, row, col)) { boxes[row][col].setAcross(true); + int numBoxesRightOf = 1; + while (somethingRightOf(boxes, row, col + numBoxesRightOf)) { + ++numBoxesRightOf; + } + boxes[row][col].setAcrossAnswerLength(numBoxesRightOf + 1); } tickedClue = true; }