Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions app/src/main/java/com/totsp/crossword/ClueListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<Clue>(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<Clue>(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) {
Expand Down
32 changes: 31 additions & 1 deletion puzlib/src/main/java/com/totsp/crossword/puz/Box.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down
11 changes: 11 additions & 0 deletions puzlib/src/main/java/com/totsp/crossword/puz/Playboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -704,6 +711,10 @@ public boolean equals(Object obj) {
return false;
}

if (this.answerLength != other.answerLength) {
return false;
}

return true;
}

Expand Down
10 changes: 10 additions & 0 deletions puzlib/src/main/java/com/totsp/crossword/puz/Puzzle.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,23 @@ 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;
}

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;
}
Expand Down