mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-23 11:31:33 +01:00
Move activity utility classes to separate package
This commit is contained in:
parent
cab87d7ab4
commit
05a8322ce7
|
@ -24,8 +24,8 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import org.petero.droidfish.DroidFishApp;
|
||||
import org.petero.droidfish.activities.PGNFile;
|
||||
import org.petero.droidfish.activities.PGNFile.GameInfo;
|
||||
import org.petero.droidfish.activities.util.PGNFile;
|
||||
import org.petero.droidfish.activities.util.PGNFile.GameInfo;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.petero.droidfish.tb;
|
||||
|
||||
import org.petero.droidfish.tb.ProbeResult;
|
||||
import org.petero.droidfish.tb.ProbeResult.Type;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
|
|
@ -20,8 +20,6 @@ package org.petero.droidfish.tb;
|
|||
|
||||
import org.petero.droidfish.gamelogic.Position;
|
||||
import org.petero.droidfish.gamelogic.TextIO;
|
||||
import org.petero.droidfish.tb.Probe;
|
||||
import org.petero.droidfish.tb.ProbeResult;
|
||||
|
||||
import android.os.Environment;
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ import org.petero.droidfish.activities.EditPGNLoad;
|
|||
import org.petero.droidfish.activities.EditPGNSave;
|
||||
import org.petero.droidfish.activities.LoadFEN;
|
||||
import org.petero.droidfish.activities.LoadScid;
|
||||
import org.petero.droidfish.activities.PGNFile;
|
||||
import org.petero.droidfish.activities.PGNFile.GameInfo;
|
||||
import org.petero.droidfish.activities.util.PGNFile;
|
||||
import org.petero.droidfish.activities.util.PGNFile.GameInfo;
|
||||
import org.petero.droidfish.activities.Preferences;
|
||||
import org.petero.droidfish.book.BookOptions;
|
||||
import org.petero.droidfish.engine.EngineUtil;
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.petero.droidfish.FileUtil;
|
|||
import org.petero.droidfish.R;
|
||||
import org.petero.droidfish.Util;
|
||||
import org.petero.droidfish.Util.MaterialDiff;
|
||||
import org.petero.droidfish.activities.util.ChessBoardEdit;
|
||||
import org.petero.droidfish.gamelogic.ChessParseError;
|
||||
import org.petero.droidfish.gamelogic.Move;
|
||||
import org.petero.droidfish.gamelogic.Piece;
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.petero.droidfish.DroidFishApp;
|
|||
import org.petero.droidfish.FileUtil;
|
||||
import org.petero.droidfish.R;
|
||||
import org.petero.droidfish.Util;
|
||||
import org.petero.droidfish.activities.util.FileBrowseUtil;
|
||||
import org.petero.droidfish.databinding.EditoptionsBinding;
|
||||
import org.petero.droidfish.databinding.UciOptionButtonBinding;
|
||||
import org.petero.droidfish.databinding.UciOptionCheckBinding;
|
||||
|
|
|
@ -49,7 +49,9 @@ import org.petero.droidfish.DroidFishApp;
|
|||
import org.petero.droidfish.ObjectCache;
|
||||
import org.petero.droidfish.R;
|
||||
import org.petero.droidfish.Util;
|
||||
import org.petero.droidfish.activities.PGNFile.GameInfo;
|
||||
import org.petero.droidfish.activities.util.PGNFile.GameInfo;
|
||||
import org.petero.droidfish.activities.util.GameAdapter;
|
||||
import org.petero.droidfish.activities.util.PGNFile;
|
||||
import org.petero.droidfish.databinding.SelectGameBinding;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
@ -40,8 +40,9 @@ import org.petero.droidfish.ColorTheme;
|
|||
import org.petero.droidfish.DroidFishApp;
|
||||
import org.petero.droidfish.R;
|
||||
import org.petero.droidfish.Util;
|
||||
import org.petero.droidfish.activities.FENFile.FenInfo;
|
||||
import org.petero.droidfish.activities.FENFile.FenInfoResult;
|
||||
import org.petero.droidfish.activities.util.FENFile;
|
||||
import org.petero.droidfish.activities.util.FENFile.FenInfo;
|
||||
import org.petero.droidfish.activities.util.FENFile.FenInfoResult;
|
||||
import org.petero.droidfish.databinding.LoadFenBinding;
|
||||
import org.petero.droidfish.gamelogic.ChessParseError;
|
||||
import org.petero.droidfish.gamelogic.Position;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.petero.droidfish.activities;
|
||||
package org.petero.droidfish.activities.util;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.FileNotFoundException;
|
|
@ -16,7 +16,7 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.petero.droidfish.activities;
|
||||
package org.petero.droidfish.activities.util;
|
||||
|
||||
import org.petero.droidfish.gamelogic.Move;
|
||||
import org.petero.droidfish.gamelogic.Piece;
|
|
@ -16,7 +16,7 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.petero.droidfish.activities;
|
||||
package org.petero.droidfish.activities.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
|
@ -32,6 +32,7 @@ import android.widget.LinearLayout;
|
|||
|
||||
import org.petero.droidfish.FileUtil;
|
||||
import org.petero.droidfish.R;
|
||||
import org.petero.droidfish.activities.Preferences;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
|
@ -16,7 +16,7 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.petero.droidfish.activities;
|
||||
package org.petero.droidfish.activities.util;
|
||||
|
||||
import android.util.Pair;
|
||||
|
||||
|
@ -35,9 +35,9 @@ public class FENFile {
|
|||
return fileName.getAbsolutePath();
|
||||
}
|
||||
|
||||
static final class FenInfo {
|
||||
int gameNo;
|
||||
String fen;
|
||||
public static final class FenInfo {
|
||||
public int gameNo;
|
||||
public String fen;
|
||||
|
||||
FenInfo(int gameNo, String fen) {
|
||||
this.gameNo = gameNo;
|
|
@ -16,7 +16,7 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.petero.droidfish.activities;
|
||||
package org.petero.droidfish.activities.util;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
|
@ -16,7 +16,7 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.petero.droidfish.activities;
|
||||
package org.petero.droidfish.activities.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -117,7 +117,7 @@ public class GameAdapter<T> extends BaseAdapter implements Filterable {
|
|||
}
|
||||
}
|
||||
|
||||
interface ItemMatcher<U> {
|
||||
public interface ItemMatcher<U> {
|
||||
/** Return true if item matches the search criteria. */
|
||||
boolean matches(U item);
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class GameAdapter<T> extends BaseAdapter implements Filterable {
|
|||
/** Return an object that determines if an item matches given search criteria.
|
||||
* @param matchStr The match string.
|
||||
* @param useRegExp If true matchStr is interpreted as a regular expression. */
|
||||
static <U> ItemMatcher<U> getItemMatcher(String matchStr, boolean useRegExp) {
|
||||
public static <U> ItemMatcher<U> getItemMatcher(String matchStr, boolean useRegExp) {
|
||||
if (useRegExp) {
|
||||
Pattern tmp;
|
||||
try {
|
|
@ -16,7 +16,7 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.petero.droidfish.activities;
|
||||
package org.petero.droidfish.activities.util;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.Closeable;
|
||||
|
@ -51,14 +51,14 @@ public class PGNFile {
|
|||
public long startPos;
|
||||
public long endPos;
|
||||
|
||||
GameInfo setNull(long currPos) {
|
||||
public GameInfo setNull(long currPos) {
|
||||
info = null;
|
||||
startPos = currPos;
|
||||
endPos = currPos;
|
||||
return this;
|
||||
}
|
||||
|
||||
boolean isNull() { return info == null; }
|
||||
public boolean isNull() { return info == null; }
|
||||
|
||||
public String toString() {
|
||||
if (info == null)
|
||||
|
@ -410,7 +410,7 @@ public class PGNFile {
|
|||
}
|
||||
|
||||
/** Read one game defined by gi. Return null on failure. */
|
||||
String readOneGame(GameInfo gi) {
|
||||
public String readOneGame(GameInfo gi) {
|
||||
try (RandomAccessFile f = new RandomAccessFile(fileName, "r")) {
|
||||
byte[] pgnData = new byte[(int) (gi.endPos - gi.startPos)];
|
||||
f.seek(gi.startPos);
|
||||
|
@ -458,7 +458,7 @@ public class PGNFile {
|
|||
}
|
||||
}
|
||||
|
||||
boolean deleteGame(GameInfo gi, ArrayList<GameInfo> gamesInFile) {
|
||||
public boolean deleteGame(GameInfo gi, ArrayList<GameInfo> gamesInFile) {
|
||||
try {
|
||||
File tmpFile = new File(fileName + ".tmp_delete");
|
||||
try (RandomAccessFile fileReader = new RandomAccessFile(fileName, "r");
|
||||
|
@ -490,7 +490,7 @@ public class PGNFile {
|
|||
return false;
|
||||
}
|
||||
|
||||
void replacePGN(String pgnToSave, GameInfo gi, boolean silent) {
|
||||
public void replacePGN(String pgnToSave, GameInfo gi, boolean silent) {
|
||||
try {
|
||||
File tmpFile = new File(fileName + ".tmp_delete");
|
||||
try (RandomAccessFile fileReader = new RandomAccessFile(fileName, "r");
|
||||
|
@ -523,7 +523,7 @@ public class PGNFile {
|
|||
}
|
||||
|
||||
/** Delete the file. */
|
||||
boolean delete() {
|
||||
public boolean delete() {
|
||||
return fileName.delete();
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.petero.droidfish.activities;
|
||||
package org.petero.droidfish.activities.util;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
|
@ -14,7 +14,7 @@
|
|||
android:id="@+id/eb_chessboard"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
class="org.petero.droidfish.activities.ChessBoardEdit" />
|
||||
class="org.petero.droidfish.activities.util.ChessBoardEdit" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
layout="@layout/title" />
|
||||
|
||||
<view
|
||||
class="org.petero.droidfish.activities.ChessBoardEdit"
|
||||
class="org.petero.droidfish.activities.util.ChessBoardEdit"
|
||||
android:id="@+id/eb_chessboard"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" />
|
||||
|
|
|
@ -30,12 +30,12 @@
|
|||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:title="@string/prefs_engine_settings">
|
||||
<org.petero.droidfish.activities.SeekBarPreference
|
||||
<org.petero.droidfish.activities.util.SeekBarPreference
|
||||
android:key="strength"
|
||||
android:title="@string/prefs_strength_title"
|
||||
android:summary="@string/prefs_strength_summary"
|
||||
android:defaultValue="1000">
|
||||
</org.petero.droidfish.activities.SeekBarPreference>
|
||||
</org.petero.droidfish.activities.util.SeekBarPreference>
|
||||
<CheckBoxPreference
|
||||
android:key="ponderMode"
|
||||
android:title="@string/prefs_ponderMode_title"
|
||||
|
@ -585,19 +585,19 @@
|
|||
android:summary="@string/prefs_bookTournamentMode_summary"
|
||||
android:defaultValue="false">
|
||||
</CheckBoxPreference>
|
||||
<org.petero.droidfish.activities.SeekBarPreference
|
||||
<org.petero.droidfish.activities.util.SeekBarPreference
|
||||
android:key="bookRandom"
|
||||
android:defaultValue="500"
|
||||
android:title="@string/prefs_bookRandom_title">
|
||||
</org.petero.droidfish.activities.SeekBarPreference>
|
||||
<org.petero.droidfish.activities.EditFilePreference
|
||||
</org.petero.droidfish.activities.util.SeekBarPreference>
|
||||
<org.petero.droidfish.activities.util.EditFilePreference
|
||||
android:key="bookFile"
|
||||
android:title="@string/prefs_bookFile_title"
|
||||
android:summary="@string/prefs_bookFile_summary"
|
||||
defaultPath="DroidFish/book/"
|
||||
ignorePattern=".*:$"
|
||||
android:defaultValue="">
|
||||
</org.petero.droidfish.activities.EditFilePreference>
|
||||
</org.petero.droidfish.activities.util.EditFilePreference>
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen
|
||||
android:key="pgnSettings"
|
||||
|
@ -718,28 +718,28 @@
|
|||
android:summary="@string/prefs_tbEngineProbe_summary"
|
||||
android:defaultValue="true">
|
||||
</CheckBoxPreference>
|
||||
<org.petero.droidfish.activities.EditFilePreference
|
||||
<org.petero.droidfish.activities.util.EditFilePreference
|
||||
android:key="gtbPath"
|
||||
android:title="@string/prefs_gtbPath_title"
|
||||
android:summary="@string/prefs_gtbPath_summary"
|
||||
pickDirectory="true"
|
||||
defaultPath="DroidFish/gtb"
|
||||
android:defaultValue="">
|
||||
</org.petero.droidfish.activities.EditFilePreference>
|
||||
</org.petero.droidfish.activities.util.EditFilePreference>
|
||||
<EditTextPreference
|
||||
android:key="gtbPathNet"
|
||||
android:title="@string/prefs_gtbPathNet_title"
|
||||
android:summary="@string/prefs_gtbPathNet_summary"
|
||||
android:defaultValue="">
|
||||
</EditTextPreference>
|
||||
<org.petero.droidfish.activities.EditFilePreference
|
||||
<org.petero.droidfish.activities.util.EditFilePreference
|
||||
android:key="rtbPath"
|
||||
android:title="@string/prefs_rtbPath_title"
|
||||
android:summary="@string/prefs_rtbPath_summary"
|
||||
pickDirectory="true"
|
||||
defaultPath="DroidFish/rtb"
|
||||
android:defaultValue="">
|
||||
</org.petero.droidfish.activities.EditFilePreference>
|
||||
</org.petero.droidfish.activities.util.EditFilePreference>
|
||||
<EditTextPreference
|
||||
android:key="rtbPathNet"
|
||||
android:title="@string/prefs_rtbPathNet_title"
|
||||
|
|
Loading…
Reference in New Issue
Block a user